September 17, 2012

Cross-site request forgery (CSRF) Updated

Cross-site request forgery (CSRF) Updated public function csrf_verify() { // If no POST data exists we will set the CSRF cookie if (count($_POST) == 0) { return $this->csrf_set_cookie(); } if((isset($_SERVER[‘HTTP_X_REQUESTED_WITH’]) && $_SERVER[‘HTTP_X_REQUESTED_WITH’] == “XMLHttpRequest”) || isset($_SERVER[‘HTTP_REFERER’])) { if(isset($_SERVER[‘HTTP_REFERER’])) { $parse_url = parse_url($_SERVER[‘HTTP_REFERER’]); if($parse_url[‘host’]!=$_SERVER[‘HTTP_HOST’] && !in_array($parse_url[‘host’], array(‘apps.facebook.com’))) { $this->csrf_show_error(); } else { //echo ‘Safe’; //echo ‘Host […]

September 14, 2012

Cross-site request forgery (CSRF) – Ajax Fix

Cross-site request forgery (CSRF) – Ajax Fix CSRF Security Class is great practice which is not really in practice commonly. The reason is workload of the scope of the project. Developers mostly don’t care about the form class of the CI and 20% or less people use form helper to generate 100% forms in their […]

August 8, 2012

Current Week No. PHP Function

Current Week No. PHP Function if(!function_exists(‘current_week_no’)) { function current_week_no() { $current_date = date(‘Y-m-d’); $date_part = explode(‘-‘, $current_date); $date_part[2] = ’01’; $start_of_month = implode(‘-‘, $date_part); $day_for_first = date(‘N’, strtotime($start_of_month)); $day_for_month = date(‘j’, strtotime($current_date)); $current_month_current_week = floor(($day_for_first + $day_for_month – 1) / 7) + 1; $last_month = (date(‘m’)-1); $week_limit_of_last_month = $last_month*4; $return = $week_limit_of_last_month+$current_month_current_week; return $return; } […]

June 15, 2012

Codeigniter Error Reporting – Intelligent Fix

Codeigniter Error Reporting – Intelligent Fix Description: This little fix will help you to manage the error reporting automatically that if you ever will go online so error reporting will be disabled and when you will import you database in localhost and development phase will be continued so no headache of changing this ENVIRONMENT constant […]

February 22, 2012

Codeigniter Session not working with IE

Solution in online is: user “native session” class instead of CI_Session class Download (Courtesy of http://codeigniter.com/wiki/Native_session) Details: There are many articles on this issue and many solutions suggest but the problem is the same that codeigniter is using mixture of session and cookies. Sometimes it is suggested that go to internet options and reduce privacy […]

December 8, 2011

PHP Explode, PHP End, File Name, File Extension

PHP Explode, PHP End, File Name, File Extension if ( ! function_exists(‘file_parts’)) { function file_parts($url,$params=’ext’) { if($params==’ext’) { $parts = explode(‘.’,$url); return end($parts); } elseif($params==’name’) { $parts = explode(‘/’,$url); return end($parts); } else { $parts = explode(‘/’,$url); $file_name_ext = explode(‘.’,end($parts)); $file_name = array_pop($file_name_ext); return implode(‘.’,$file_name); } } }

Cufon MouseOver Effect Works!!! With CodeIgniter Helper & JS Function

Cufon MouseOver Effect With CodeIgniter Helper Function This helper function can help in mouseover and mouseout effect when you are using cufon for fonts on web pages. if ( ! function_exists(‘link_hover’)) { function link_hover($title, $class=’anchor’, $tag = ‘span’, $url) { $CI =& get_instance(); $time = time(); $active_url = ‘link_’.$time; $inactive_url = ‘link_’.$time.’_over’; if($tag != ”) […]

Mysql Max Import Size Phpmyadmin

Mysql Max Import Size Phpmyadmin Sometimes this simple solution gets a different turn when we go to modify the mysql related phpmyadmin max import size from 2M to more. And it is mostly because that wampserver has different menus for PHP, MySql and Apache configuration. But a rule of thumb can resolve this issue here […]