This file contains hidden or 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
$lightgray : #819090; | |
$gray : #708284; | |
$mediumgray : #536870; | |
$darkgray : #475B62; | |
$darkblue : #0A2933; | |
$darkerblue : #042029; | |
$paleryellow : #FCF4DC; | |
$paleyellow : #EAE3CB; | |
$yellow : #A57706; | |
$orange : #BD3613; |
This file contains hidden or 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 echo $_SERVER['PHP_SELF']; ?> |
This file contains hidden or 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 | |
/*Validates if $phone is a valid U.S. phone number in the 202-555-1234 format. | |
Note that the first didgit cannot be a 1 as no area code in the U.S. starts with a 1. | |
*/ | |
function validatePhoneNo($phone) { | |
if(preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $phone)) | |
return true; | |
else | |
return false; | |
} |
This file contains hidden or 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 | |
/* Validates if $zipCode is a 5 digit number in the 12345 format. Note that this simply checks to see if $zipCode is a 5 digit number, not necessarily a valid U.S. Zip Code. | |
*/ | |
function validateZipCode($zipCode) { | |
if (preg_match('#[0-9]{5}#', $zipCode)) | |
return true; | |
else | |
return false; | |
} | |
?> |
This file contains hidden or 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 | |
/* Generates a random string from the charachters listed in $characters and returns the random string. | |
*/ | |
function genRandomString($length) { | |
$characters = '0123456789abcdefghijklmnopqrstuvwxyz!@#$%&*()'; | |
$randstring = ""; | |
for ($p = 0; $p < $length; $p++) { | |
$randstring .= $characters[mt_rand(0, strlen($characters))]; | |
} | |
return $randstring; |
This file contains hidden or 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 | |
/* formats a 10 or 7 digit phone number (number only) by adding dashes at the appropriate locations */ | |
function phoneFormat($number) { | |
if(ctype_digit($number) && strlen($number) == 10) { | |
$number = substr($number, 0, 3) .'-'. substr($number, 3, 3) .'-'. substr($number, 6); | |
} else { | |
if(ctype_digit($number) && strlen($number) == 7) { | |
$number = substr($number, 0, 3) .'-'. substr($number, 3, 4); | |
} |
This file contains hidden or 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 | |
// used to find the extenstion of a filename | |
function findExtension ($filename) { | |
$filename = strtolower($filename) ; | |
$exts = split("[/\\.]", $filename) ; | |
$n = count($exts)-1; | |
$exts = $exts[$n]; | |
return $exts; | |
} | |
?> |
This file contains hidden or 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 | |
/* | |
Use To validate an email address according to RFCs 5321, 5322 and others. | |
-------------------------------------------------------------------------------- | |
How to use is_email() | |
-------------------------------------------------------------------------------- | |
1. Add the downloaded file is_email.php to your project | |
2. In your scripts use it like this: |
This file contains hidden or 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 | |
// Used to determine the IP address of the client. | |
function GetIpAddr() | |
{ | |
if (!empty($_SERVER['HTTP_CLIENT_IP'])) | |
{ | |
$ip=$_SERVER['HTTP_CLIENT_IP']; | |
} | |
else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) | |
{ |
This file contains hidden or 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 | |
// returns "City, State" if found otherwise defaults to "Unkown Location" | |
function detect_city($ip) { | |
$default = 'Unkown Location'; | |
if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost') | |
$ip = '8.8.8.8'; | |
$curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'; |
NewerOlder