Skip to main content

Posts

Showing posts from November, 2011

CakePHP url rewriting problem?

If you are facing url rewriting problem in cakephp even though you have enabled rewrite module .....Here is the solution.... - Just go to the httpd.conf file. - Find the following text groups   <Directory />        Options FollowSymLinks        AllowOverride None        Order deny,allow        Deny from all   </Directory> and   # AllowOverride controls what directives may be placed in .htaccess files.   # It can be "All", "None", or any combination of the keywords:  # Options FileInfo AuthConfig Limit  AllowOverride None. - Replace 'AllowOverride None' with 'AllowOverride All' on both places. - Save file and Restart Apache Refresh Page and the problem is resolved. :)

SMS Gateway Integration in PHP

To Integrate SMS Gateway in PHP you have to signup for an account with SMS service providers. To find any one out of them just google for it and you will get a list of providers. All of them are paid service providers and some of them provide you just few free credits so that you can test their service. Following is the example of such a provider http://www.clickatell.com/ After logged in it provides us an API that we would have to use for sending sms. You can connect to the gateway using HTTP/s, SMPP, SMTP, FTP, XML, SOAP etc... I have opted for HTTP/s Following are the step to connect via HTTP:     1) When you sign up for an HTTP/S account, you will be given a username, password and api_id: keep these at hand!     2) Once your registration has been activated you will receive 10 free credits with which to test our service.     3) Have the number you wish to send to ready in international format e.g. 448311234567.     4)Open your browser (e.g. Internet Explorer), a

How to access remote server using PHP SSH?

To remotely access a server in PHP provides a full library of functions called SSH2 functions. You can get the manual from the link . You'll get most of the information from the manual itself but it also leaves the user with some questions which are unanswered. Here i am just trying to explain the same in some better way.. Simple Example :  <?php     if (!function_exists("ssh2_connect"))         die("function ssh2_connect doesn't exist");     if(!($con = ssh2_connect("www.example.com", 22(port number)))){         echo "fail: unable to establish connection\n";     } else {         if(!ssh2_auth_password($con, "username", "password")) {             echo "fail: unable to authenticate\n";         } else {             echo "okay: root logged in...\n";             $stream = shell_exec("mkdir /var/www/shiv");         }     } ?> Important Notes : 1) If you are logged i

CakePHP-MultivalidatableBehavior: Using many validation rulesets per model.

If you are looking for action specific validation on a model then here it goes like that : Following code examples are based on the following scenario: 1) We have a model Member. 2) We wanna two type of validation sets on that.      a) First in case of Login (default)      b) Second in case editing Profile.  3) How to use these validation sets in action. Step 1 : <?php      class MultivalidatableBehavior extends ModelBehavior {     /**      * Stores previous validation ruleset      *      * @var Array      */     var $__oldRules = array();     /**      * Stores Model default validation ruleset      *      * @var unknown_type      */     var $__defaultRules = array();     function setUp(&$model, $config = array()) {         $this->__defaultRules[$model->name] = $model->validate;     }     /**      * Installs a new validation ruleset      *      * If $rules is an array, it will be set as current validation ruleset,      * otherwise it will look into Mode

Automatic Startup of Apache on Linux Server?

To start Apache automatically, follow these steps: Copy Apache startup file to the startup directory: cp /usr/local/apache/bin/apachectl /etc/init.d/             In my case ‘apachectl’  was at location /usr/sbin/apachectl so I have used             cp /usr/sbin/apachectl /etc/init.d/  Edit /etc/init.d/apachectl by inserting these 2 lines in bold :            #!/bin/sh # # chkconfig: - 345 85 15 # description: Apache is a Web server used to serve HTML files and CGI. # # Copyright 2000-2005 The Apache Software Foundation or its licensors, as # applicable. . . . # Apache control script designed to allow an easy command line interface # to controlling Apache.  Written by Marc Slemko, 1997/08/23 . . . Enable httpd to startup automatically:            # chkconfig –-add httpd To start mysql on startup too, use:          # chkconfig –-add mysqld Reboot

Installing GUI under CentOS 6

If you installed using a text login and wish to switch to a graphical login, follow this procedure. 1) If you are not already root, switch users to the root account: su - Provide the administrator password when prompted. 2) If you have not already done so, install the X Window System and a graphical desktop environment. For example, to install the GNOME desktop environment, use this command: yum groupinstall "X Window System" Desktop To install the KDE desktop environment, use: yum groupinstall "X Window System" "KDE Desktop" This step may take some time as your Linux system downloads and installs additional software. You may be asked to provide the installation media depending on your original installation source. 3) Run the following command to edit the /etc/inittab file: vi /etc/inittab 4) Press the 'i' key to enter insert mode. 5) Find the line that includes the text initdefault . To change from a console to a grap

How to install Linux – CentOS 6 for Servers & Desktops

1) Set your computers BIOS to boot form CD / DVD 2) Insert the CentOS 6 CD or DVD 3) When presented with the following screen press enter on Install or upgrade an existing system. 4) You will now be presented with a CD Check, I always skip this step… I live life on the edge when it comes to media checking on Linux installs. However you might want to check the media. 5) You will now see some black and white text on your screen as your computer loads the X11 environment for the CentOS install, after 30 seconds or so you will be presented with the CentOS GUI installer, click next. 6) Select your Language, I am British (please no jokes about drinking tea on Twitter…) so I would select English (English). 7) Select your keyboard type 8) Storage type, as I am installing on my local hard drive I selected “Basic storage type” if you are using iSCSI or similar technology now would be the time to set it up. 9) As this is a clean install and the drive has never