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 flattenArray(array) { | |
var arrayPool = []; | |
if(array.length > 0) { | |
for(var i=0; i < array.length; i++){ | |
if(array[i].constructor === Array){ | |
arrayPool = arrayPool.concat(flattenArray(array[i])); | |
} else { | |
arrayPool.push(array[i]); | |
} | |
} |
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 resize($img, $w, $h, $newfilename) { | |
//Check if GD extension is loaded | |
if (!extension_loaded('gd') && !extension_loaded('gd2')) { | |
trigger_error("GD is not loaded", E_USER_WARNING); | |
return false; | |
} | |
//Get Image size info |
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 list_files($dir) | |
{ | |
if(is_dir($dir)) | |
{ | |
if($handle = opendir($dir)) | |
{ | |
while(($file = readdir($handle)) !== 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 | |
function getRealIPAddr() | |
{ | |
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet | |
{ | |
$ip=$_SERVER['HTTP_CLIENT_IP']; | |
} | |
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy | |
{ | |
$ip=$_SERVER['HTTP_X_FORWARDED_FOR']; |
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 base64url_encode($plainText) { | |
$base64 = base64_encode($plainText); | |
$base64url = strtr($base64, '+/=', '-_,'); | |
return $base64url; | |
} | |
function base64url_decode($plainText) { | |
$base64url = strtr($plainText, '-_,', '+/='); | |
$base64 = base64_decode($base64url); |
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 | |
$to = "viralpatel.net@gmail.com"; | |
$subject = "VIRALPATEL.net"; | |
$body = "Body of your message here you can use HTML too. e.g. <br> <b> Bold </b>"; | |
$headers = "From: Peter\r\n"; | |
$headers .= "Reply-To: info@yoursite.com\r\n"; | |
$headers .= "Return-Path: info@yoursite.com\r\n"; | |
$headers .= "X-Mailer: PHP5\n"; | |
$headers .= 'MIME-Version: 1.0' . "\n"; | |
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; |
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 get_client_language($availableLanguages, $default='en'){ | |
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { | |
$langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); | |
foreach ($langs as $value){ | |
$choice=substr($value,0,2); | |
if(in_array($choice, $availableLanguages)){ | |
return $choice; | |
} |
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 data_uri($file, $mime) { | |
$contents=file_get_contents($file); | |
$base64=base64_encode($contents); | |
echo "data:$mime;base64,$base64"; | |
} |
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
<?ph | |
function _make_url_clickable_cb($matches) { | |
$ret = ''; | |
$url = $matches[2]; | |
if ( empty($url) ) | |
return $matches[0]; | |
// removed trailing [.,;:] from URL | |
if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) { | |
$ret = substr($url, -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 | |
error_reporting(0); | |
Header("Content-Type: image/jpeg"); | |
//Get IP | |
if (!empty($_SERVER['HTTP_CLIENT_IP'])) | |
{ | |
$ip=$_SERVER['HTTP_CLIENT_IP']; | |
} | |
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) |
NewerOlder