Users Online Footer

Well, Here is my new footer:hugegrin: What it does is loads the html of the index page of the forum and gets the users online. Then, it picks a random user and displays it with GD.

Just to let you know… I did not use any reference from nokrev’s code :stuck_out_tongue:

@a mod: Is it fine to do this, or do you not want the script loading a page from the forum? It could potentially take up some bandwidth, couldn’t it? I won’t apply it until I hear from one of you…

:sc:

<?php
 
$kirupa = file_get_contents("http://www.kirupa.com/forum/");
$blockpos = strpos($kirupa,"<!-- logged-in users -->");
$blocklen = strpos($kirupa,"<!-- end logged-in users -->") - $blockpos;
$kirupa = strip_tags(substr($kirupa, $blockpos, $blocklen));

$lines = explode("
",$kirupa);
$linetoevaluate = "";
$nextline = false;
for($i=0; $i<count($lines); $i++){
    $line = $lines[$i];
    if ($nextline){
        $linetoevaluate = trim($line);    
        break;
    }
    if (strpos($line,"Most users ever online") !== false){
        $nextline = true;
    }
}
$matches = explode(", ",$linetoevaluate);
if (count($matches) == 0){
    $string = "Error Acquiring Users";    
}else{
    $string = "Hi " . $matches[array_rand($matches)] . "!";
}

$params = array();
$params['string'] = $string;
$params['bgcolor'] = array(0x28a9d9,0x0b75e1,0x0e5e7b);
$params['fgcolor'] = 0xffffff;
$params['size'] = 25;
$params['font'] = "Stylograph.ttf";
$params['width'] = 300;
$params['height'] = 50;
$params['align'] = "center";

$bounding = imagettfbbox($params['size'], 0, $params['font'], $params['string']);
$width = max($bounding[4] - $bounding[6], $bounding[0] - $bounding[2]);
$ybounding = imagettfbbox($params['size'], 0, $params['font'], "ygpq");
$height = max($ybounding[3] - $ybounding[5], $ybounding[1] - $ybounding[7]);
$buffer = $params['size'] / 10 + 3;
$offset_x = 0;
$offset_y = 0;
if (!isset($params['width']) || !isset($params['height'])){
    $width_final = $width + $buffer;
    $height_final = $height + $height / 2;
}else{
    $align = ($params['align'] == "center" || $params['align'] == "right") ? $params['align'] : "left";
    $width_final = $params['width'];
    $height_final = $params['height'];
    if ($align == "center"){
        $offset_x = $width_final / 2 - ($width + $buffer) / 2 - $buffer;
    }else if($align == "right"){
        $offset_x = $width_final - $width - $buffer;
    }else{
        $offset_x = 0;
    }
    $offset_y = $height_final / 2 - $height / 2;
}

$canvas = imagecreatetruecolor($width_final, $height_final);
imageantialias($canvas, true);
imagefill($canvas, 0, 0, $params['bgcolor'][array_rand($params['bgcolor'])]);
imagettftext($canvas, $params['size'], 0, $offset_x, $height + $offset_y, $params['fgcolor'], $params['font'], $params['string']);

header("Content-type: image/jpeg");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

imagejpeg($canvas,"",100);

imagedestroy($canvas);
?>

-bigmtnskier :smiley: