Pages

Sunday, September 29, 2013

CodeIgniter-Seo Urls

1. I am using ubuntu 13.04. To setup mod_rewrite on debian based machines ubuntu is in concern here go through my this post

http://itfeast.blogspot.in/2013/09/cakephpubuntu-setting-up-cakephp-on.html

If you are assured that mod_rewrite is working perfectly on your Apache Server Proceed Further.

Now We will proceed with configuring CodeIgniter for seo urls

2. Remove Index.php

Your root .htaccess should look like this

 <IfModule mod_rewrite.c>  
 # Turn on URL rewriting  
 RewriteEngine On  
 # If your website begins from a folder e.g localhost/my_project then   
 # you have to change it to: RewriteBase /my_project/  
 # If your site begins from the root e.g. example.local/ then  
 # let it as it is  
 RewriteBase /ci/  
 # Protect application and system files from being viewed when the index.php is missing  
 RewriteCond $1 ^(application|system|private|logs)  
 # Rewrite to index.php/access_denied/URL  
 RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]  
 # Allow these directories and files to be displayed directly:  
 RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images)  
 # No rewriting  
 RewriteRule ^(.*)$ - [PT,L]  
 # Rewrite to index.php/URL  
 RewriteRule ^(.*)$ index.php/$1 [PT,L]  
 </IfModule>  

3. Now in application/config/config.php

change
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';

In some cases you may also need to configure

$config['uri_protocol'] = 'AUTO';

To

$config['uri_protocol'] = 'PATH_INFO';

Or To

$config['uri_protocol'] = 'REQUEST_URI';

4. Now your folder structure should look like this

website_folder/ 
–––– application/ 
–––– system/ 
–––– user_guide/ 
====>.htaccess
–––– index.php 
–––– license.txt
 
You might also go for custom routing further as
 
$route['default_controller'] = 'webpages'; //Our default Controller

//Get rid of the first segment (in our case we get rid of webpages)
$route["about"] = 'webpages/about'; 
$route["blog/(.*)"] = 'webpages/blog/$1';
$route["view/(.*)"] = 'webpages/view/$1';
 
Source: http://www.web-and-development.com/codeigniter-remove-index-php-minimize-url/ 

Sunday, September 22, 2013

PHP-Find current quarter for genarating quarterly payments etc.

    $firstday1=date("Y-1-1 00:00:00");
        $lastday1=date("Y-3-31 23:59:59");
        $firstday2=date("Y-4-1 00:00:00");
        $lastday2=date("Y-6-30 23:59:59");
        $firstday3=date("Y-7-1 00:00:00");
        $lastday3=date("Y-9-30 23:59:59");
        $firstday4=date("Y-10-1 00:00:00");
        $lastday4=date("Y-12-31 23:59:59");
        $today = time();
        if( (strtotime($firstday1) <= $today) && ($today<= strtotime($lastday1)))
        {
            $qtr=1;
        }
        elseif( (strtotime($firstday2) <= $today) && ($today <= strtotime($lastday2)))
        {
            $qtr=2;
        }
        elseif( (strtotime($firstday3) <= $today) && ($today <= strtotime($lastday3)))
        {
            $qtr=3;
        }
        elseif( (strtotime($firstday4) <= $today) && ($today <= strtotime($lastday4)))
        {
            $qtr=4;
        }
        echo $qtr;

Wednesday, September 18, 2013

Design-Issue for site in IE8 and IE9

Recently I face a design issue error in IE8 and IE9 the design was a bit misaligned it was coming perfectly on all other browser's

My team fixed the same by adding following tag above HTML

 <!DocType html>  



Thanks to Manendra Verma for his efforts

FFMPEG-[libmp3lame @ 0x1c0d8d0]flv does not support that sample rate, choose from (44100, 22050, 11025)

Recently while converting video's for my site I came across this error

The solution was simple simple place all the parameters after -i parameter i.e input parameter

for ex I was using -ar 44100 -y -qscale 4 before -i anf ter i shifted all of them after -i my issue was resolved

Sunday, September 15, 2013

Cakephp-Data Validation Not Working-Resolution workflow

Recently while working on a Linux Machine I faced an issue where cake's default validation was not working.Here is the walkthrough of steps which you must ensure to make it work if it still doesn't let me know

1. First things first-If you are working on linux server File Name Casing is an issue.Make sure your model File name,Class name matches the name of your first parameter in form.


 //File name  
 Task.php  
 //Model Class  
 class Task extends AppModel  
 {  
 }  
 //Form Start  
 <?php echo $this->Form->create('Task');?>  

2. Check Validation rule's format they should match cake convention's

     public $validate = array(
        'title'=>array(
            'alphaNumeric' => array(
                'rule'     => 'alphaNumeric',
                'required' => true,
                'message'  => 'Alphanumeric only'
            ))); 

I was doing everything right but my file name was incorrect I was using a lowercase filename which caused the error

Cakephp,Ubuntu-Setting Up Cakephp on Ubuntu Server/Enabling Mode_Rewrite

Recently while installing Cakephp on Ubuntu Server I face some initial setup errors.

1. Firstly rewrite_module was not enabled I enabled it using the following commands

sudo a2enmod rewrite

2.  Needed to Enable AllowOverride All For this I modified following file

/etc/apache2/sites-available/default



 <VirtualHost *:80>  
      ServerAdmin webmaster@localhost  
      DocumentRoot /var/www  
      <Directory />  
           Options FollowSymLinks  
           AllowOverride All  
      </Directory>  
      <Directory /var/www/>  
           Options Indexes FollowSymLinks MultiViews  
           AllowOverride All  
           Order allow,deny  
           allow from all  
      </Directory>  
      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/  
      <Directory "/usr/lib/cgi-bin">  
           AllowOverride All  
           Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch  
           Order allow,deny  
           Allow from all  
      </Directory>  
      ErrorLog ${APACHE_LOG_DIR}/error.log  
      # Possible values include: debug, info, notice, warn, error, crit,  
      # alert, emerg.  
      LogLevel warn  
      CustomLog ${APACHE_LOG_DIR}/access.log combined  
   Alias /doc/ "/usr/share/doc/"  
   <Directory "/usr/share/doc/">  
     Options Indexes MultiViews FollowSymLinks  
     AllowOverride All  
     Order deny,allow  
     Deny from all  
     Allow from 127.0.0.0/255.0.0.0 ::1/128  
   </Directory>  
 </VirtualHost>  


3. Finally restart Apache

 sudo /etc/init.d/apache2 restart