Support ⇒ Gamers Modules & Blocks ⇒ would like to make a block with this code.... ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum Index Modules & Blocks Gamers Modules & Blocks

would like to make a block with this code.... Reply to topic


<?php foreach ($_GET as $key => $value) $$key = $value; if (!$realm) $server = "Dark Iron"; // Your full Server name, case sensitive $up = 'Server Up'; // Set your "Server Up" message $down = 'Server Down'; // Set your "Server Down" message $max = 'Max (Queued)'; // Set Maxed (Queued) $high = 'High'; // Set High Population $medium = 'Medium'; // Set Medium Population $low = 'Low'; // Set Low Population $error = 'Server Error'; // Set Error Message $timer = 10; // Minutes between status update refresh 0-60 if (!$image) $generate_image = true; // Set to TRUE if you would like the script // to automatically generate an image if (!$display) $display = 'half'; // Set to 'half' to only display server status $folder_path = './images/blocks/wowss/'; // Path to wowss folder $url = 'http://www.worldofwarcraft.com/realmstatus/status.xml'; // World of Wacraft XML status page URL //////// Configure what the script outputs as text //////// Edit if you have a knowledge of PHP and HTML function output($server,$servertype,$serverstatus,$serverpop) { return "<u>$server</u> $servertype: <b>$serverstatus | $serverpop</b>";} //////// PHP Magic Below, Don't Edit $magic_array = array(min,server,servertype,serverstatus,serverpop,err); if ($realm) $server = $realm; if ($image == 'true') $generate_image = true; if ($image == 'false') $generate_image = false; // Check timestamp, update when ready if (substr($folder_path, -1, 1) != '/') $folder_path = '$folder_path/'; $timestamp = $folder_path . 'wowss_data.txt'; $min = date(i)*1; $info = explode(",", file_get_contents($timestamp)); if (filesize($timestamp) == 0) { $pass = true; } if ($min >= ($info[0]+$timer) or $min < $info[0] or $realm or $pass) { // Fetch and format XML data error_reporting(0); $xml = file_get_contents($url); if ($xml) { $server = str_replace('\\','',str_replace("'","&#039;",$server)); if (!strpos($xml,$server)) { $error = "$error, check Realm name"; $err = true; } // Determine Server Type $servertype = substr($xml,strpos($xml,$server) + (strlen($server)+5),1); if (is_numeric($servertype) and $servertype <= 3) { if ($servertype == 0) $servertype = 'RP PVP'; elseif ($servertype == 1) $servertype = 'PVE'; elseif ($servertype == 2) $servertype = 'PVP'; elseif ($servertype == 3) $servertype = 'Roleplay'; } else $err = true; // Determine Serverstatus $serverstatus = substr($xml,strpos($xml,$server) + (strlen($server)+11),1); if (is_numeric($serverstatus) and $serverstatus <= 1) { $serverstatus = 'up'; } else $serverstatus = 'down'; // Determine Server Pop. $serverpop = substr($xml,strpos($xml,$server) + (strlen($server)+17),1); if (is_numeric($serverpop) and $serverpop != 0 and $serverpop >= 1 and $serverpop <= 4) { if ($serverpop == 1) $serverpop = 'low'; elseif ($serverpop == 2) $serverpop = 'medium'; elseif ($serverpop == 3) $serverpop = 'high'; else $serverpop = 'max'; } // Write info to data file for storage if (!$realm) { foreach($magic_array as $value) $data = $data . $$value . ','; $handle = fopen($timestamp,"w"); flock($handle, LOCK_EX); fwrite($handle, $data); flock($handle, LOCK_UN); fclose($handle); } } else { $error = 'Realmstatus Not Available'; $err = true; } }// If timer isn't up yet, fetch old data and output else { $i=0; foreach ($info as $value) { $$magic_array[$i] = $value; $i++; } } // Where to go and what to do function calls if ($generate_image) { imgoutput ($server,$servertype,$serverstatus,$serverpop,$err,$folder_path,$display); } else { $serverstatus = $$serverstatus; $serverpop = $$serverpop; if (!$err) echo trim(output($server,$servertype,$serverstatus,$serverpop)); else echo $error; } // Begin dynamic image generation function function imgoutput ($server,$servertype,$serverstatus,$serverpop,$err,$folder_path,$display) { $serverfont = $folder_path . 'silkscreen.ttf'; $typefont = $folder_path . 'silkscreenb.ttf'; header("Content-type: image/png"); // Error control if ($serverstatus == 'down') $serverpop = 'offline'; if ($err){$serverstatus = 'unknown'; $serverpop = 'error';} // Get and combine base images, set colors $back = imagecreatefrompng($folder_path . strtolower($serverstatus) . '.png'); if ($display == 'full') { $backwidth = imagesx($back); $bottom = imagecreatefrompng($folder_path . strtolower($serverstatus) . '2.png'); $serverpop = imagecreatefrompng($folder_path . strtolower($serverpop) . '.png'); $full = imagecreate($backwidth,(imagesy($back)+imagesy($bottom))); $bg = imagecolorallocate($full, 0, 255, 255); $red = imagecolorallocate($full,204,0,0); // HIGH Red color imagecolortransparent($full, $bg); imagecopy($full,$back,0,0,0,0,$backwidth,imagesy($back)); imagecopy($full,$bottom,0,imagesy($back),0,0,imagesx($bottom),imagesy($bottom)); $back = $full; $textcolor = imagecolorallocate($back, 51, 51, 51); $shadow = imagecolorclosest($back, 255, 204, 0); imagecopy($back,$serverpop,round(($backwidth-imagesx($serverpop))/2),62,0,0,imagesx($serverpop),imagesy($serverpop)); // Ouput centered $server name $maxw = 62; $box = imagettfbbox(6,0,$serverfont,$server); $w = abs($box[0]) + abs($box[2]); if ($w > $maxw) { $i = $w; $t = strlen($server); while ($i > $maxw) { $t--; $box = imagettfbbox (6, 0,$serverfont,substr($server,0,$t)); $i = abs($box[0]) + abs($box[2]); } $t = strrpos(substr($server, 0, $t), " "); $output[0] = substr($server, 0, $t); $output[1] = ltrim(substr($server, $t)); $vadj = -6; } else $output[0] = $server; $i = 0; foreach($output as $value) { $box = imagettfbbox(6,0,$serverfont,$value); $w = abs($box[0]) + abs($box[2]); imagettftext($back, 6, 0, round(($backwidth-$w)/2)+1, 58+($i*8)+$vadj, $shadow, $serverfont, $value); imagettftext($back, 6, 0, round(($backwidth-$w)/2), 57+($i*8)+$vadj, -$textcolor, $serverfont, $value); $i++; } // Ouput centered $servertype if ($servertype and !$err) { $box = imagettfbbox(6,0,$typefont,$servertype); $w = abs($box[0]) + abs($box[2]); imagettftext($back, 6, 0, round(($backwidth-$w)/2)+1, 85, $shadow, $typefont, $servertype); imagettftext($back, 6, 0, round(($backwidth-$w)/2), 84, -$textcolor, $typefont, $servertype); } } imagepng($back); imagedestroy($back); } ?>
any idea?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CentOS 5, Apache 1.3.39, MySQL 4.1.21, PHP 5.2.5, Dragonfly CMS 9.2.2.1


It seems to be an image script?
Try to make separate php file with that content and upload it anywhere you want, then you just link to it with for example:
<img src="images/thatfile.php" />

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
-


hrmm let me see if i can figgure that out one moment.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CentOS 5, Apache 1.3.39, MySQL 4.1.21, PHP 5.2.5, Dragonfly CMS 9.2.2.1

All times are UTC


Jump to: