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
<?php | |
function download_file($file){ | |
$file = $file; //Set File Location | |
if (file_exists($file)) { // Check if file exists | |
if(!is_dir($file)){ // Check if it is a directory or a file | |
// The following files will set the headers to the file download | |
header('Content-Description: File Transfer'); | |
header('Content-Type: application/octet-stream'); | |
header('Content-Disposition: attachment; filename='.basename($file)); | |
header('Content-Transfer-Encoding: binary'); |
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 validateUsername(str) { | |
var error = ""; | |
var illegalChars = /\W/; // allow letters, numbers, and underscores | |
if (str == "") { | |
error = "• Please enter Username<br>"; | |
} else if ((str.length < 5) || (str.length > 15)) { | |
error = "• Username must have 5-15 characters<br>"; | |
} else if (illegalChars.test(str)) { | |
error = "• Please enter valid Username. Use only numbers and alphabets<br>"; |
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
/*================================================== | |
= Bootstrap 3 Media Queries = | |
==================================================*/ | |
/*========== Mobile First Method ==========*/ | |
/* Custom, iPhone Retina */ | |
@media only screen and (min-width : 320px) { | |
/*-- example usage : custom grid spacing --*/ | |
.row{ |
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 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
<?php if (!defined('BASEPATH')) { | |
exit('No direct script access allowed'); | |
} | |
class Perfectcontroller extends MX_Controller | |
{ | |
function __construct() | |
{ | |
parent::__construct(); |