Exemplo n.º 1
0
<?php

/**
 * @package Realm Status Module for joomla 1.5
 * @author Brad Cimbura
 * @copyright (C) 2010- Brad Cimbura
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 * @link http://soylentcode.com/
**/
//don't allow other scripts to grab and execute our file
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
require_once dirname(__FILE__) . DS . 'helper.php';
$data = modRealmStatus::wow_ss($params->get('realm'), $params->get('display'), $params->get('region'), $params->get('updatetimer'), 'modules/mod_realm_status/images/', $params->get('imagetype'));
require JModuleHelper::getLayoutPath('mod_realm_status');
Exemplo n.º 2
0
 function wow_ss_image($realm_status, $wowss)
 {
     ## Error control
     if ($realm_status['status'] == 'down') {
         $realm_status['population'] = 'offline';
     }
     if ($realm_status['status'] == 'error' or count($realm_status['script_errors'])) {
         $realm_status['status'] = 'unknown';
         $realm_status['population'] = 'error';
     }
     if ($realm_status['type'] == 'error') {
         unset($realm_status['type']);
     }
     ## Set Default Fonts
     if (!isset($wowss['server_font'])) {
         $wowss['server_font'] = 'silkscreen.ttf';
     }
     if (!isset($wowss['type_font'])) {
         $wowss['type_font'] = 'silkscreenb.ttf';
     }
     $server_font = $wowss['data_path'] . $wowss['server_font'];
     $type_font = $wowss['data_path'] . $wowss['type_font'];
     ## Get and combine base images, set colors
     if ($wowss['image_type'] == 'png') {
         $back = imagecreatefrompng($wowss['data_path'] . $realm_status['status'] . '.png');
     }
     if ($wowss['image_type'] == 'gif') {
         $back = imagecreatefromgif($wowss['data_path'] . $realm_status['status'] . '.gif');
     }
     $backwidth = imagesx($back);
     if ($wowss['image_type'] == 'png') {
         $bottom = imagecreatefrompng($wowss['data_path'] . strtolower($realm_status['status']) . '2.png');
     }
     if ($wowss['image_type'] == 'gif') {
         $bottom = imagecreatefromgif($wowss['data_path'] . strtolower($realm_status['status']) . '2.gif');
     }
     if ($wowss['image_type'] == 'png') {
         $realm_status['population'] = imagecreatefrompng($wowss['data_path'] . strtolower($realm_status['population']) . '.png');
     }
     if ($wowss['image_type'] == 'gif') {
         $realm_status['population'] = imagecreatefromgif($wowss['data_path'] . strtolower($realm_status['population']) . '.gif');
     }
     $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, $realm_status['population'], round(($backwidth - imagesx($realm_status['population'])) / 2), 62, 0, 0, imagesx($realm_status['population']), imagesy($realm_status['population']));
     ## Ouput centered $server name
     $vadj = 0;
     $maxw = 62;
     $box = imagettfbbox(6, 0, $server_font, $realm_status['realm']);
     $w = abs($box[0]) + abs($box[2]);
     if ($w > $maxw) {
         $i = $w;
         $t = strlen($realm_status['realm']);
         while ($i > $maxw) {
             $t--;
             $box = imagettfbbox(6, 0, $server_font, substr($realm_status['realm'], 0, $t));
             $i = abs($box[0]) + abs($box[2]);
         }
         $t = strrpos(substr($realm_status['realm'], 0, $t), " ");
         $output[0] = substr($realm_status['realm'], 0, $t);
         $output[1] = ltrim(substr($realm_status['realm'], $t));
         $vadj = -6;
     } else {
         $output[0] = $realm_status['realm'];
     }
     $i = 0;
     foreach ($output as $value) {
         $box = imagettfbbox(6, 0, $server_font, $value);
         $w = abs($box[0]) + abs($box[2]);
         imagettftext($back, 6, 0, round(($backwidth - $w) / 2) + 1, 58 + $i * 8 + $vadj, $shadow, $server_font, $value);
         imagettftext($back, 6, 0, round(($backwidth - $w) / 2), 57 + $i * 8 + $vadj, -$textcolor, $server_font, $value);
         $i++;
     }
     ## Ouput centered $realm_status['type']
     if ($realm_status['type'] and !isset($err)) {
         $realm_status['type'] = $wowss[$realm_status['type']];
         $box = imagettfbbox(6, 0, $type_font, $realm_status['type']);
         $w = abs($box[0]) + abs($box[2]);
         imagettftext($back, 6, 0, round(($backwidth - $w) / 2) + 1, 85, $shadow, $type_font, $realm_status['type']);
         imagettftext($back, 6, 0, round(($backwidth - $w) / 2), 84, -$textcolor, $type_font, $realm_status['type']);
     }
     if ($wowss['image_type'] == 'png') {
         imagepng($back, $wowss['data_path'] . strtolower(modRealmStatus::wow_ss_sfn($realm_status['realm'] . ' ' . $wowss['region'])) . '.png');
     }
     if ($wowss['image_type'] == 'gif') {
         imagegif($back, $wowss['data_path'] . strtolower(modRealmStatus::wow_ss_sfn($realm_status['realm'] . ' ' . $wowss['region'])) . '.gif');
     }
     imagedestroy($back);
 }