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 | |
function duration($len){ | |
$hr = floor($len / 60 / 60); | |
$min = floor($len / 60); | |
$sec = floor($len % 60); | |
return array('hr' => $hr, 'min' => $min,'sec' => $sec); | |
} | |
$dur = 28853.45; | |
$totals = duration($dur); |
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 | |
function blacklist($ip){ | |
$listed = true; | |
$dnsbl_lookup = array( | |
"dnsbl-1.uceprotect.net", | |
"dnsbl-2.uceprotect.net", | |
"dnsbl-3.uceprotect.net", | |
"dnsbl.dronebl.org", | |
"dnsbl.sorbs.net", | |
"zen.spamhaus.org" |
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 | |
function key_implode($glue, $array){ | |
$keys = array_keys($array); | |
return implode($glue, $keys); | |
} | |
$arr = array("cats" => 4, "dogs" => 8, "fish" =>10); | |
echo key_implode(",", $arr); | |
?> |
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 | |
// set the variable to 0, it'll matter only if the cookie for the variable is not set | |
$visitCounter = 0; | |
// if cookie is set for the variable, it'll go to $visitCounter and get added by 1; otherwise it'll show 0 for tha variable | |
if(isset($_COOKIE['visitCounter'])){ | |
$visitCounter = $_COOKIE['visitCounter']; | |
$visitCounter ++; | |
} | |
// if the last visist cookie is set, it'll pass the value to $lastVisit, and it'll be displayed below; | |
if(isset($_COOKIE['lastVisit'])){ |
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 | |
// +----------------------------------------------------------------------+ | |
// | Akelos PHP Application Framework | | |
// +----------------------------------------------------------------------+ | |
// | Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.com/ | | |
// | Released under the GNU Lesser General Public License | | |
// +----------------------------------------------------------------------+ | |
// | You should have received the following files along with this library | | |
// | - COPYRIGHT (Additional copyright notice) | |
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 | |
header("Cache-Control: private, max-age=10800, pre-check=10800"); | |
header("Pragma: private"); | |
// Set to expire in 2 days | |
header("Expires: " . date(DATE_RFC822,strtotime(" 2 day"))); | |
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])){ | |
// if the browser has a cached version of this image, send 304 | |
header('Last-Modified: '.$_SERVER['HTTP_IF_MODIFIED_SINCE'],true,304); | |
exit; | |
} |
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 | |
$input = str_replace(array('^', '.', '|', '(', ')', '[', ']', '*', '+', '?', '{', '}', '$' ), | |
array('\^', '\.', '\|', '\(', '\)', '\[', '\]', '\*', '\+', '\?', '\{', '\}', '\$' ), $input); |
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 | |
$regex = "/([a-z0-9_]+|[a-z0-9_]+\.[a-z0-9_]+)@(([a-z0-9]|[a-z0-9]+\.[a-z0-9]+)+\.([a-z]{2,4}))/i"; | |
// usage | |
if(!preg_match($regex, $email)) { | |
echo "Invalid email address"; | |
} | |
else { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Registration</title> | |
<script src="http://www.java.com/js/deployJava.js"></script> | |
</head> | |
<script> | |
function onLoad() { | |
if (deployJava.getJREs().length > 0) { | |
document.getElementById('install').style.display = 'block'; |
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
// Function to get the client IP address | |
function get_client_ip() { | |
$ipaddress = ''; | |
if (getenv('HTTP_CLIENT_IP')) | |
$ipaddress = getenv('HTTP_CLIENT_IP'); | |
else if(getenv('HTTP_X_FORWARDED_FOR')) | |
$ipaddress = getenv('HTTP_X_FORWARDED_FOR'); | |
else if(getenv('HTTP_X_FORWARDED')) | |
$ipaddress = getenv('HTTP_X_FORWARDED'); | |
else if(getenv('HTTP_FORWARDED_FOR')) |