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
<? | |
//restituisce il valore dell'array piu vicino al valore richiesto!!!! | |
$value = intval($argv[1]); | |
$tnsizes = array(10,50,100,150,300); | |
echo nearValue($value, $tnsizes); | |
function nearValue($tnsize, $tnsizes) |
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
<? | |
//send http post request and return http headers in array form | |
function http_post_request($url,$pdata,$getHeaders=false) | |
{ | |
$pdata = is_array($pdata) ? http_build_query($pdata) : $pdata; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url ); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $pdata); |
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 imagerotateEquivalent($srcImg, $angle, $bgcolor, $ignore_transparent = 0) { | |
function rotateX($x, $y, $theta){ | |
return $x * cos($theta) - $y * sin($theta); | |
} | |
function rotateY($x, $y, $theta){ | |
return $x * sin($theta) + $y * cos($theta); | |
} |
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
<? | |
header('Content-Type: image/png'); | |
$size= 80; | |
$extImg = imagecreatetruecolor($size,$size); | |
$targetFileImg = 'mime.png'; | |
$ext = trim($_GET['t']); | |
$ctext = imagecolorallocate($extImg, 100, 100, 100); //testo |
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
<? | |
//generate random phrase | |
function randDesc($maxDescLen = 100) | |
{ | |
$desc =''; | |
while(true) | |
{ | |
$lwr = rand(2,8);//lunghezza parola |
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
#!/usr/bin/env php | |
<? | |
$alphNums = '<>/:-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | |
$l = strlen($alphNums); | |
#$maxl = 100; | |
while(true) | |
{ | |
echo $alphNums{rand(0,$l)}; | |
usleep(1000); |
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 charCodeAt($str, $i) | |
{ | |
return ord(substr($str, $i, 1)); | |
} | |
function textToBase64($t) | |
{ | |
$tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
$r=''; $m=0; $a=0; $tl=strlen($t)-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
<? | |
function encRC4($key, $text) | |
{ | |
$kl=strlen($key); | |
$s=array(); | |
for($i=0; $i<256; $i++) | |
$s[$i]=$i; | |
$y=0; |
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
<? | |
/* Simple Websocket Client | |
copyleft Stefano Cudini 2011-01-19 | |
[email protected] | |
inspired by: | |
http://caucho.com/resin-4.0/examples/websocket-php/ | |
*/ | |
$host = 'localhost'; //where is the websocket server | |
$port = 9000; |
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
<? | |
//convert time from utc to locale timezone | |
$tz = getenv('TZ'); // Get current server time zone setting | |
echo "Current timezone setting: $tz <br>"; | |
putenv("TZ=EST5EDT"); // Change to US Eastern time zone or whatever you want | |
$lt = localtime(time(), TRUE); | |
echo "EST local time: ".$lt['tm_hour'].':'.$lt['tm_min'].':'.$lt['tm_sec']." <br>"; | |
putenv("TZ=$tz"); // Change it back to the original server time zone | |
?> |
OlderNewer