Saturday, 7 December 2013

Linux-vsftpd : restrict user to root directory

To avoid security issues or restrict user to root directory you have to limit users of vsftp to only their home directory. So how to do it ? 

Open vsftpd configuration file - /etc/vsftpd/vsftpd.conf :

Make sure following line exists and uncommented (add if not exists):


Save and close the file. Restart vsftpd service.

/etc/init.d/vsftpd restart 

 Done. Using a ftp client to check with some acccount.

Friday, 6 December 2013

Yii: Widget example and common errors

Widget is a flexible structure in yii. So how and where it can be used ?

Intended use : 

Create static blocks such as : header, footer, menu, sidebar blocks (other post, contact, ...)

Simple header widget example: 

Directory structure :

class header extends CWidget { //class must be same with file name and extended CWidget class
    public function init() {
            // do something
    public function run() {
        //do something ...
        $model = Model::model()->findAll();
        $this->render('headerView',array('model'=>$model ));

<div id="topHeader">
          <!-- header content -->
          <?php var_dump($model); ?>

Using in layout :
<!DOCTYPE html>
<html dir="ltr" lang="en"> 
                   <?php $this->widget('application.widgets.header.header'); ?>
                   <?php echo $content; ?>

Common errors:

 "include(header.php): failed to open stream: No such file or directory"

How to solve :
1. Check alias path : "'application.widgets.header.header'" make it correct
2. Check class name in file header.php : make sure that it is same with file name.
3. Check other logic