PHP Code: Verzeichnis listing
Einfache Funktion um einen Ordner auszulesen.
<?php
function get_dirlist ($path = '') {
if (empty($path)) $path = "./";
$dirlist = array();
$d = dir($path);
while($entry=$d->read()) {
if ($entry=='.' OR $entry=='..') continue;
if ($entry == 'images') continue;
if (is_dir($entry)) $dirlist[] = $entry;
}
$d->close();
sort($dirlist);
@reset($dirlist);
return $dirlist;
}
?>
PHP Code: Bild-Größen Limit
Dieses Script begrenzt die Größe eines Bildes auf den, in der Funktion definierten Wert.
<?php
function piclimiter ($bild, $size) {
$imginfo = @getimagesize($bild);
if(($imginfo[0] != 0 && $imginfo[0] > $size) || ($imginfo[1] != 0 && $imginfo[1] > $size)) {
if($size != 0) {
$div1 = $size / $imginfo[0];
$div2 = $size / $imginfo[1];
} else {
$div1 = 1;
$div2 = 1;
}
if($div1 < $div2) {
$imgwidth = $size;
$imgheight = round($imginfo[1]*$div1);
} else {
$imgheight = $size;
$imgwidth = round($imginfo[0]*$div2);
}
$picture = '<img src="'.$bild.'"width="'.$imgwidth.'"height="'.$imgheight.'" border="0">';
} else {
$picture = '<img src="'.$bild.'" border="0">';
}
return $picture;
}
?>
PHP Code: ICQ Online Check
Hiermit kannst du überprüfen ob eine ICQ Nummer online ist. Die Ausgabe erfolgt in Text.
<?php
function GetICQ($uin) {
if (!is_numaeric($uin)) return FALSE;
$fp = fsockopen('web.icq.com',80,&$errno,&$errstr,8);
if (!$fp) return FALSE;
$request = "HEAD /whitepages/online?icq=$uin&img=5 HTTP/1.0\r\n"."Host: web.icq.com\r\n"."Connection: close\r\n\r\n";
fputs($fp, $request);
do {
$response = fgets($fp, 1024);
} while (!feof($fp) && !stristr($response,'Location'));
fclose($fp);
if (strstr($response, '4367'))
return 'online';
if (strstr($response, '4349'))
return 'offline';
if (strstr($response, '4386'))
return 'disabled';
return FALSE;
}
?>
