This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function generateCsv($data, $delimiter = ',', $enclosure = '"') { | |
$handle = fopen('php://temp', 'r+'); | |
foreach ($data as $line) { | |
fputcsv($handle, $line, $delimiter, $enclosure); | |
} | |
rewind($handle); | |
while (!feof($handle)) { | |
$contents .= fread($handle, 8192); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$filename= "my_picture.jpg"; | |
list($w, $h, $type, $attr) = getimagesize($filename); | |
$src_im = imagecreatefromjpeg($filename); | |
$src_x = '0'; // begin x | |
$src_y = '0'; // begin y | |
$src_w = '100'; // width | |
$src_h = '100'; // height | |
$dst_x = '0'; // destination x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isValidCreditCard(type, ccnum) { | |
if (type == "Visa") { | |
// Visa: length 16, prefix 4, dashes optional. | |
var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/; | |
} else if (type == "MC") { | |
// Mastercard: length 16, prefix 51-55, dashes optional. | |
var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/; | |
} else if (type == "Disc") { | |
// Discover: length 16, prefix 6011, dashes optional. | |
var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
301 Redirects | |
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html | |
Redirect 301 /oldpage2.html http://www.yoursite.com/folder/ | |
------------------------------------------------------------- | |
Custom Error Pages | |
ErrorDocument 400 /400.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function hide_update_notice_to_all_but_admin_users() | |
{ | |
if (!current_user_can('update_core')) { | |
remove_action( 'admin_notices', 'update_nag', 3 ); | |
} | |
} | |
add_action( 'admin_notices', 'hide_update_notice_to_all_but_admin_users', 1 ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php (defined('BASEPATH')) OR exit('No direct script access allowed'); | |
/* load the MX_Loader class */ | |
require APPPATH."third_party/MX/Loader.php"; | |
class MY_Loader extends MX_Loader | |
{ | |
/** Load a module view **/ | |
public function view($view, $vars = array(), $return = FALSE) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (!defined('BASEPATH')) { | |
exit('No direct script access allowed'); | |
} | |
class My_Model extends CI_Model | |
{ | |
public $tablename; | |
function __construct() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (!defined('BASEPATH')) { | |
exit('No direct script access allowed'); | |
} | |
class Mdl_perfectmodel extends MY_Model | |
{ | |
function __construct() | |
{ | |
parent::__construct(); | |
$this->tablename = 'mytablename'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Options +FollowSymLinks | |
Options -Indexes | |
DirectoryIndex index.php | |
RewriteEngine On | |
RewriteCond $1 !^(index\.php|images|rebots\.txt) | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ index.php/$1 [L,QSA] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Download CI | |
2. Download HMVC extension from | |
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc | |
3. Download MY_Loader.php and place it under 'core' folder as it is a fix for a small bug in HMVC extension. | |
https://gist.github.com/aslamdoctor/387fa9ef6ba0f74f20e7fad793dafb1f | |
4. Download MY_Model.php and place it under 'core' folder | |
https://gist.github.com/aslamdoctor/cf592175987d042de9a667ac49f40f5c |