Pages

Saturday, September 13, 2014

Ubuntu LAMP-Enable Curl and mcrypt

To EnaBLE CURL FIRST WE NEED TO DOWNLOAD AND INSTALL 
Curl Libraries for this enable the following command
 
 sudo apt-get install curl libcurl3 libcurl3-dev php5-curl  
 
To Enable Mcrypt we need to download and Install 
Mcrypt libraries
 
 sudo php5enmod mcrypt  
 
Mcrypt is already there and is just not enabled.
 
If its still not accessible locate "mcrypt.so" if you find the same 
 at a location like 
 
/usr/lib/php5/20121212/mcrypt.so
 
edit its path in mcrypt.ini and then run the command
 
"sudo php5enmod mcrypt"
 
That's it this enables both of these php extensions. 

Sunday, August 24, 2014

Zend-Using ZendX library in Zend

Recently I had to use Jquery UI components in one of my applications.I used ZendX Library to counter the same and I worked upon the same as the same as follows

 In bootstrap.php

       protected function _initJquery() {  
     $view = Zend_Layout::startMvc()->getView();  
     $view->addHelperPath("ZendX/JQuery/View/Helper",  
                 "ZendX_JQuery_View_Helper"  
                );  
     Zend_Controller_Action_HelperBroker::addHelper(  
               new ZendX_JQuery_Controller_Action_Helper_AutoComplete()  
                );  
     $view->jQuery()  
        ->enable()  
        ->setVersion('1.11.0')  
        ->setUiVersion('1.10.4')  
        ->addStylesheet('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css')  
        ->uiEnable();  
   }  

In View

 <?php  
 $this->jQuery()->addJavascriptFile($this->baseUrl().'/assets/js/validation/jquery.validate.min.js');  
 $this->headScript()->prependFile($this->baseUrl().'/assets/js/validation/myvalidation.js');  
 ?>  

Layout

 <?php   
 echo $this->jQuery();  
 echo $this->jQuery()->uiEnable();  
 echo $this->headScript();  
 echo $this->headLink();  
 echo $this->headTitle('My Website');  
 ?>  

ZendX-Use events and properties of jquery-ui widgets in Zend forms

Recently I added a ZendX Date Picker to one of my Zend Applications now I was able to add properties but I was unable to add events so I had to use another Zend magic function
Zend_Json_Expr

As shown in code below

    /*************Order Date From****************************************/     
         $order_date_from = new ZendX_JQuery_Form_Element_DatePicker('order_date_from',  
               array('jQueryParams' => array('dateFormat' => 'yy-mm-dd',  
                 'onClose'=>new Zend_Json_Expr('function( selectedDate ) {$( "#order_date_to" ).datepicker( "option", "minDate", selectedDate );}')  
                 ))  
           );  
         $order_date_from->setAttribs(array('class'=>"",  
             //'id'=>'datepickerfrom'  
         )  
           );  
         $order_date_from->removeDecorator('DtDdWrapper')  
           ->removeDecorator('HtmlTag')  
           ->removeDecorator('Errors')  
           ->removeDecorator('Label');  
         $this->addElement($order_date_from);  
         /*************Order Date From****************************************/  
         /*************Order Date To****************************************/  
         $order_date_to = new ZendX_JQuery_Form_Element_DatePicker('order_date_to',  
               array('jQueryParams' => array(  
                 'onClose'=>new Zend_Json_Expr('function( selectedDate) {$( "#order_date_from" ).datepicker( "option", "maxDate", selectedDate );}'),  
                 'dateFormat' => 'yy-mm-dd'              
                 ))  
           );  
         $order_date_to->setAttribs(array('class'=>"",  
             //'id'=>'datepickerto'  
         )  
           );  
         $order_date_to->removeDecorator('DtDdWrapper')  
           ->removeDecorator('HtmlTag')  
           ->removeDecorator('Errors')  
           ->removeDecorator('Label');  
         $this->addElement($order_date_to);  
         /*************Order Date To****************************************/  

Thursday, June 26, 2014

Fix wordpress image urls in post on migration

Whenever we migrate wordpress from old domain to new domain we seldom encounter url errors where image urls in post do not get updated etc..

To Tackle this out here is a simple sql script

 UPDATE wp_posts SET post_content = REPLACE (  
 post_content,  
 'olddomain.com/wp-content/',  
 'newdomain.com/wp-content/');  

Tuesday, April 29, 2014

Linux-Scrap Website from terminal

Fool the server that we are using mozilla if unable to do via simple way
 $ wget --user-agent="Mozilla 2.0" -m http://www.itfeast.blogspot.com  
The Simple way
 $ wget -m --tries=7 "http://www.itfeast.blogspot.com"  

Sunday, April 27, 2014

Zend 1.12-Render individual form opening and closing tags

Though I am still looking for a workout of the same from zend function's.But still to get best of results I use following manually added code.
 <form action="<?php echo $this->form->getAction() ?>"  
    enctype="<?php echo $this->form->getEnctype() ?>"  
    method="<?php echo $this->form->getMethod() ?>"  
    id="<?php echo $this->form->getId() ?>"  
    class="<?php echo $this->form->getAttrib('class') ?>" >  
 </form>  


Saturday, April 26, 2014

Zend-Option Group in Zend_Form_Element_Multiselect

 $techDoc = new Zend_Form_Element_Multiselect(‘technical_doc’);  
 $techDoc->setLabel(‘Technical Documents’)  
 ->setMultiOptions(array(“Option Group 1″ => array(“option1″,”option2″,”option3″),  
 “Option Group 2″=>array(“option1″,”option2″,”option3″)));  

Tuesday, April 22, 2014

Change default wordpress login URL

Change default Login URL-Wordpress

Add the following line to the end of .htaccess

RewriteRule ^login$ http://YOUR_SITE.com/wp-login.php[NC,L]

Sunday, March 30, 2014

Wordpress-allow login with email address

Wordpress allow login with email address

    function login_with_email_address($username)  
    {  
      $user = get_user_by_email($username);  
      if(!empty($user->user_login))  
          $username = $user->user_login;  
      return $username;  
    }  
    add_action('wp_authenticate','login_with_email_address');  



Tuesday, March 18, 2014

Zend-Setup on Ubuntu 13.10

To setup zend on ubuntu 13.10(my version)

We need to download its latest framework from
http://www.zend.com/en/company/community/downloads

Zend 1.12.5 is latest as of writing this post

Next unzip and place the same in your home directory and delete all folders except bin and library

Next we need to tell our php to include Zend library so in our php.ini

(found in /etc/php5/apache2/php.ini)

perform following actions

Add
include_path=".:/home/gaurav/ZendFramework-1.12.5/library"
if you find include_path  not used or

Append "/home/gaurav/ZendFramework-1.12.5/library" to current path if include_path is defined (check it's commented by default)

Save and Close

Next move to root and using root privileges(sudo)
 
create a file 
cd /
nano .bashrc
 
and add code 
 
"alias zf=/home/gaurav/ZendFramework-1.12.5/bin/zf.sh"

Save and exit

Next Source .bashrc by following command
 
"source .bashrc"
 
now run zf command
 
If you get an output as follows
 
 An Error Has Occurred                         
 An action and provider is required.                                    

Zend Framework Command Line Console Tool v1.12.4
Usage:
    zf [--global-opts] action-name [--action-opts] provider-name [--provider-opts] [provider parameters ...]
    Note: You may use "?" in any place of the above usage string to ask for more specific help information.
    Example: "zf ? version" will list all available actions for the version provider.

Providers and their actions:
  Version
    zf show version mode[=mini] name-included[=1]
    Note: There are specialties, use zf show version.? to get specific help on them.

  Config
    zf create config
    zf show config
    zf enable config
    Note: There are specialties, use zf enable config.? to get specific help on them.
    zf disable config
    Note: There are specialties, use zf disable config.? to get specific help on them.

  Phpinfo
    zf show phpinfo

  Manifest
    zf show manifest

  Profile
    zf show profile

  Project
    zf create project path name-of-profile file-of-profile
    zf show project
    Note: There are specialties, use zf show project.? to get specific help on them.

  Application
    zf change application.class-name-prefix class-name-prefix

  Model
    zf create model name module

  View
    zf create view controller-name action-name-or-simple-name module

  Controller
    zf create controller name index-action-included[=1] module

  Action
    zf create action name controller-name[=Index] view-included[=1] module

  Module
    zf create module name

  Form
    zf enable form module
    zf create form name module

  Layout
    zf enable layout
    zf disable layout

  DbAdapter
    zf configure db-adapter dsn section-name[=production]

  DbTable
    zf create db-table name actual-table-name module force-overwrite
    Note: There are specialties, use zf create db-table.? to get specific help on them.

  ProjectProvider
    zf create project-provider name actions