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 setZeroPaddedNumber($value, $padding) { | |
return str_pad($value, $padding, "0", STR_PAD_LEFT); | |
} | |
/** | |
* Usage: | |
* | |
* echo setZeroPaddedNumber(123, 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
<?php | |
// This can be used for comments and other from of communication to tell the time ago | |
// instead of the exact time which might not be correct to some one in another time zone. | |
// The function only uses unix time stamp like the result of time(); | |
function _ago($tm, $rcs = 0) { | |
$cur_tm = time(); $dif = $cur_tm-$tm; |
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 | |
/** | |
* @param String $string | |
* @return float | |
* | |
* Returns a float between 0 and 100. The closer the number is to 100 the | |
* the stronger password is; further from 100 the weaker the password is. | |
*/ |
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 (!empty($_SERVER['HTTP_CLIENT_IP'])) { | |
$ip = $_SERVER['HTTP_CLIENT_IP']; | |
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { | |
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
} else { | |
$ip = $_SERVER['REMOTE_ADDR']; | |
} |
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 hex2rgb($colour) | |
{ | |
if ($colour[0] == '#') { | |
$colour = substr($colour, 1); | |
} | |
if (strlen($colour) == 6) { | |
list($r, $g, $b) = array( |
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 text2bbc($text) | |
{ | |
$find = array( | |
'~\[b\](.*?)\[/b\]~s', | |
'~\[i\](.*?)\[/i\]~s', | |
'~\[u\](.*?)\[/u\]~s', | |
'~\[size=(.*?)\](.*?)\[/size\]~s', | |
'~\[color=(.*?)\](.*?)\[/color\]~s' |
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 br2nl( $input ) { | |
return preg_replace('/<br(\s+)?\/?>/i', "\n", $input); | |
} |
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 | |
// These can be useful for embedding images into HTML/CSS/JS | |
// to save on HTTP requests, at the cost of maintainability. | |
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
<?php | |
ini_set("default_socket_timeout", "05"); | |
set_time_limit(5); | |
$f = fopen("http://github.com", "r"); | |
$r = fread($f, 1000); | |
fclose($f); | |
if (strlen($r) > 1) { |
OlderNewer