Posts

Showing posts from September, 2012

CakePHP : Filter dropwdown list

Image
Controller: $contactGroups=$this->Contact->ContactGroup->find('list',                             array('fields'=> array('group_name'), //field to be displayed in dropdown                             'conditions'=>array('user_id'=>$this->Auth->User('id') //filtered by user_id                                                                           ))); $this->set(compact('contactGroups'));

Using multiple database in CakePHP 2.2.2

Image
Edit your app/Config/database.php class DATABASE_CONFIG {     public $default = array(         'datasource' => 'Database/Mysql',         'persistent' => false,         'host' => 'localhost',         'login' => 'username1',         'password' => 'password1',         'database' => 'databasename1',         'prefix' => '',         //'encoding' => 'utf8',     );     public $sms_gateway = array(         'datasource' => 'Database/Mysql',         'persistent' => false,         'host' => '192.168.1.1',         'login' => 'username2',     ...

PHP : Write a file on a remote server via ssh

<?php //remote server address $remote_ip = '192.168.1.1'; $port = '80'; //login account $username = 'yourusername'; $password = 'yourpassword'; //ssh connection $connection = ssh2_connect($remote_ip, $port); ssh2_auth_password($connection, $username, $password'); $sftp = ssh2_sftp($connection); $remote_dir = '/var/www/'; $the_msg = 'I am creating and writing in a file on a remote server via ssh"; $stream = @fopen("ssh2.sftp://".$sftp.$remote_dir, 'w+'); if (fwrite($stream, $the_msg) == false){           echo "Could not write data"; } //close connection fclose($stream); ?>

PHP - Call to undefined function ssh2_connect

Error: Call to undefined function ssh2_connect() Steps for installing the extension package on (Ubuntu) Debian systems: > sudo apt-get install libssh2-php Restart APACHE to take effect > sudo /etc/init.d/apache2 restart