diff --git a/config.php b/config.php index abd4dc2d..bea8514f 100644 --- a/config.php +++ b/config.php @@ -158,7 +158,8 @@ $config = array( 'signature_enabled' => true, 'signature_type' => 'tibian', // signature engine to use: tibian, mango, gesior - 'signature_cache_time' => 5, // how long to store cached file (in minutes) + 'signature_cache_time' => 5, // how long to store cached file (in minutes), default 5 minutes + 'signature_browser_cache' => 60, // how long to cache by browser (in minutes), default 1 hour // online page 'online_record' => true, // display players record? diff --git a/system/templates/news.add.html.twig b/system/templates/news.add.html.twig index 1edf3bec..da4fe640 100644 --- a/system/templates/news.add.html.twig +++ b/system/templates/news.add.html.twig @@ -3,7 +3,7 @@ tinymce.init({ selector : "textarea", theme : "modern", - plugins: 'print preview fullpage searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount spellchecker imagetools contextmenu colorpicker textpattern help', + plugins: 'print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount spellchecker imagetools contextmenu colorpicker textpattern help', toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat', image_advtab: true }); diff --git a/tools/signature/gesior.php b/tools/signature/gesior.php index c029f591..11ec9d52 100644 --- a/tools/signature/gesior.php +++ b/tools/signature/gesior.php @@ -26,7 +26,4 @@ imagettftext($image , $fontsize, 0, 100, 95, $color, $font, (($player->getLastLogin() > 0) ? date("j F Y, g:i a", $player->getLastLogin()) : 'Never logged in.')); imagepng($image, SIGNATURES_CACHE . $player->getID() . '.png'); imagedestroy($image); - - header('Content-type: image/png'); - readfile(SIGNATURES_CACHE . $player->getId() . '.png'); ?> \ No newline at end of file diff --git a/tools/signature/index.php b/tools/signature/index.php index 7a3c6db2..4903803f 100644 --- a/tools/signature/index.php +++ b/tools/signature/index.php @@ -43,7 +43,7 @@ } $cached = SIGNATURES_CACHE.$player->getId() . '.png'; - if (file_exists($cached) and (time() < (filemtime($cached) + (60 * $config['signature_cache_time'])))) + if(file_exists($cached) and (time() < (filemtime($cached) + (60 * $config['signature_cache_time'])))) { header( 'Content-type: image/png' ); readfile( SIGNATURES_CACHE.$player->getId().'.png' ); @@ -51,4 +51,11 @@ } require($file); + header('Content-type: image/png'); + $seconds_to_cache = $config['signature_browser_cache'] * 60; + $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT"; + header('Expires: ' . $ts); + header('Pragma: cache'); + header('Cache-Control: max-age=' . $seconds_to_cache); + readfile(SIGNATURES_CACHE . $player->getId() . '.png'); ?> diff --git a/tools/signature/mango.php b/tools/signature/mango.php index f84511e7..e7852ec7 100644 --- a/tools/signature/mango.php +++ b/tools/signature/mango.php @@ -21,152 +21,149 @@ $otb_path = SIGNATURES_DATA.'items.otb'; $background = 'default.png'; - if ( file_exists( SIGNATURES_BACKGROUNDS.$background ) ) - { - $MadGD = new MadGD( SIGNATURES_BACKGROUNDS.$background ); - $MadGD->testMode = false; - - $MadGD->setDefaultStyle( SIGNATURES_FONTS.'arial.ttf', SIGNATURES_FONTS.'arialbd.ttf', 8 ); - $MadGD->setEquipmentBackground( SIGNATURES_IMAGES.'equipments.png' ); - - /** NAME **/ - $MadGD->addText( 'Name:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $MadGD->addText( $player->getName(), ( $player->isOnline() ? array( 'color' => '5df82d' ) : array( ) ) )->setPosition( ); $i++; - /** SEX **/ - $MadGD->addText( 'Sex:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $player_sex = 'unknown'; - if(isset($config['genders'][$player->getSex()])) - $player_sex = strtolower($config['genders'][$player->getSex()]); - $MadGD->addText($player_sex)->setPosition( ); $i++; - /** PROFESSION **/ - $vocation = 'Unknown'; - if(isset($config['vocations'][$player->getVocation()])) - $vocation = $config['vocations'][$player->getVocation()]; - - $MadGD->addText( 'Profession:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $MadGD->addText( $vocation )->setPosition( ); $i++; - /** LEVEL **/ - $MadGD->addText( 'Level:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $MadGD->addText( $player->getLevel() )->setPosition( ); $i++; - /** WORLD **/ - if($config['multiworld']) { - $MadGD->addText( 'World:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $MadGD->addText( $config['worlds'][$player->getWorldId()] )->setPosition( ); $i++; - } - - /** RESIDENCE **/ - $MadGD->addText( 'Residence:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $MadGD->addText( $config['towns'][$player->getTownId()] )->setPosition( ); $i++; - - /** HOUSE **/ - $town = 'town'; - if(fieldExist('town_id', 'houses')) - $town = 'town_id'; - - $house = $db->query( 'SELECT `houses`.`name`, `houses`.`' . $town . '` as town FROM `houses` WHERE `houses`.`owner` = '.$player->getId().';' )->fetchAll(); - if ( count( $house ) != 0 ) - { - $MadGD->addText( 'House:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $MadGD->addText( $house[0]['name'].' ('.$towns_list[$player->getWorldId()][$house[0]['town']].')' )->setPosition( ); $i++; - } - /** GUILD **/ - $rank = $player->getRank(); - if ($rank->isLoaded()) - { - $MadGD->addText( 'Guild membership:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $MadGD->addText( $rank->getName().' of the '.$player->getRank()->getGuild()->getName() )->setPosition( ); $i++; - } - /** LAST LOGIN **/ - $MadGD->addText( 'Last login:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $MadGD->addText( ( $player->getLastLogin() == 0 ? 'Never logged in' : date( 'M d Y, H:i:s T', $player->getLastLogin() ) ) )->setPosition( ); $i++; - /** ACCOUNT STATUS **/ - $MadGD->addText( 'Account Status:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); - $MadGD->addText( ( $player->getAccount()->getPremDays() > 0 ? 'Premium Account' : 'Free Account' ) )->setPosition( ); $i++; - - $MadGD->addIcon( SIGNATURES_IMAGES.'bg.png' )->setPosition( 200, 45 ); - $MadGD->addIcon( SIGNATURES_IMAGES.'bg.png' )->setPosition( 200, 54 ); - $MadGD->addIcon( SIGNATURES_IMAGES.'bg.png' )->setPosition( 200, 63 ); - - /** HEALTH BAR **/ - $MadGD->addText( 'HP:', $percent )->setPosition( 182, 40 ); - if ( ( $player->getHealth() > $player->getHealthMax() ) or ( $player->getHealth() > 0 and $player->getHealthMax() > 0 ) ) - { - $MadGD->addIcon( SIGNATURES_IMAGES.'health.png', $player->getHealth() / $player->getHealthMax() * 100 )->setPosition( 201, 46 ); - $MadGD->addText( floor( $player->getHealth() / $player->getHealthMax() * 100 ).'%', $percent )->setPosition( 305, 40 ); - } - else - { - $MadGD->addIcon( SIGNATURES_IMAGES.'health.png', 100 )->setPosition( 201, 46 ); - $MadGD->addText( '100%', $percent )->setPosition( 305, 40 ); - } - /** MANA BAR **/ - $MadGD->addText( 'MP:', $percent )->setPosition( 180, 50 ); - if ( ( $player->getMana() > $player->getManaMax() ) or ( $player->getMana() > 0 and $player->getManaMax() > 0 ) ) - { - $MadGD->addIcon( SIGNATURES_IMAGES.'mana.png', $player->getMana() / $player->getManaMax() * 100 )->setPosition( 201, 55 ); - $MadGD->addText( floor( $player->getMana() / $player->getManaMax() * 100 ).'%', $percent )->setPosition( 305, 50 ); - } - else - { - $MadGD->addIcon( SIGNATURES_IMAGES.'mana.png', 100 )->setPosition( 201, 55 ); - $MadGD->addText( '100%', $percent )->setPosition( 305, 50 ); - } - /** EXPERIENCE BAR **/ - $MadGD->addText( 'EXP:', $percent )->setPosition( 176, 60 ); - if ( $player->getExperience() > 0 and ( $player->getExperience() / getExpToLevel( $player->getLevel() + 1 ) * 100 ) <= 100 ) - { - $MadGD->addIcon( SIGNATURES_IMAGES.'exp.png', $player->getExperience() / getExpToLevel( $player->getLevel() + 1 ) * 100 )->setPosition( 201, 64 ); - $MadGD->addText( floor( $player->getExperience() / getExpToLevel( $player->getLevel() + 1 ) * 100 ).'%', $percent )->setPosition( 305, 60 ); - } - else - { - $MadGD->addIcon( SIGNATURES_IMAGES.'exp.png', 100 )->setPosition( 201, 64 ); - $MadGD->addText( '100%', $percent )->setPosition( 305, 60 ); - } - - $slots = array( - 2 => array( $MadGD->equipment['x']['amulet'], $MadGD->equipment['y']['amulet'] ), - 1 => array( $MadGD->equipment['x']['helmet'], $MadGD->equipment['y']['helmet'] ), - 3 => array( $MadGD->equipment['x']['backpack'], $MadGD->equipment['y']['backpack'] ), - 6 => array( $MadGD->equipment['x']['lefthand'], $MadGD->equipment['y']['lefthand'] ), - 4 => array( $MadGD->equipment['x']['armor'], $MadGD->equipment['y']['armor'] ), - 5 => array( $MadGD->equipment['x']['righthand'], $MadGD->equipment['y']['righthand'] ), - 9 => array( $MadGD->equipment['x']['ring'], $MadGD->equipment['y']['ring'] ), - 7 => array( $MadGD->equipment['x']['legs'], $MadGD->equipment['y']['legs'] ), - 10 => array( $MadGD->equipment['x']['ammunition'], $MadGD->equipment['y']['ammunition'] ), - 8 => array( $MadGD->equipment['x']['boots'], $MadGD->equipment['y']['boots'] ) - ); - foreach ( $slots as $pid => $position ) - { - $item = $db->query( 'SELECT `itemtype`, `attributes` FROM `player_items` WHERE `player_items`.`player_id` = '.$player->getId().' AND `player_items`.`pid` = '.$pid.';' )->fetch(); - if ( $item['itemtype'] != null ) - { - $count = unpack( 'C*', $item['attributes'] ); - if ( isset( $count[2] ) ) { - $count = $count[2]; - } - else { - $count = 1; - } - - $imagePath = SIGNATURES_ITEMS . ( $count > 1 ? $item['itemtype'].'/'.$count : $item['itemtype'] ).'.gif'; - //} - if ( file_exists( $imagePath ) ) { - $MadGD->addIcon( $imagePath )->setPosition( $position[0], $position[1] ); - } - else { - $MadGD->addIcon( SIGNATURES_IMAGES.'noitem.png' )->setPosition( $position[0], $position[1] ); - } - } - } - - $MadGD->save($player->getID()); - header( 'Content-type: image/png' ); - readfile( SIGNATURES_CACHE . $player->getId().'.png' ); - } - else + if ( !file_exists( SIGNATURES_BACKGROUNDS.$background ) ) { header( 'Content-type: image/png' ); readfile( SIGNATURES_IMAGES . 'nobackground.png' ); + exit; } + + $MadGD = new MadGD( SIGNATURES_BACKGROUNDS.$background ); + $MadGD->testMode = false; + + $MadGD->setDefaultStyle( SIGNATURES_FONTS.'arial.ttf', SIGNATURES_FONTS.'arialbd.ttf', 8 ); + $MadGD->setEquipmentBackground( SIGNATURES_IMAGES.'equipments.png' ); + + /** NAME **/ + $MadGD->addText( 'Name:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $MadGD->addText( $player->getName(), ( $player->isOnline() ? array( 'color' => '5df82d' ) : array( ) ) )->setPosition( ); $i++; + /** SEX **/ + $MadGD->addText( 'Sex:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $player_sex = 'unknown'; + if(isset($config['genders'][$player->getSex()])) + $player_sex = strtolower($config['genders'][$player->getSex()]); + $MadGD->addText($player_sex)->setPosition( ); $i++; + /** PROFESSION **/ + $vocation = 'Unknown'; + if(isset($config['vocations'][$player->getVocation()])) + $vocation = $config['vocations'][$player->getVocation()]; + + $MadGD->addText( 'Profession:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $MadGD->addText( $vocation )->setPosition( ); $i++; + /** LEVEL **/ + $MadGD->addText( 'Level:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $MadGD->addText( $player->getLevel() )->setPosition( ); $i++; + /** WORLD **/ + if($config['multiworld']) { + $MadGD->addText( 'World:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $MadGD->addText( $config['worlds'][$player->getWorldId()] )->setPosition( ); $i++; + } + + /** RESIDENCE **/ + $MadGD->addText( 'Residence:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $MadGD->addText( $config['towns'][$player->getTownId()] )->setPosition( ); $i++; + + /** HOUSE **/ + $town = 'town'; + if(fieldExist('town_id', 'houses')) + $town = 'town_id'; + + $house = $db->query( 'SELECT `houses`.`name`, `houses`.`' . $town . '` as town FROM `houses` WHERE `houses`.`owner` = '.$player->getId().';' )->fetchAll(); + if ( count( $house ) != 0 ) + { + $MadGD->addText( 'House:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $MadGD->addText( $house[0]['name'].' ('.$towns_list[$player->getWorldId()][$house[0]['town']].')' )->setPosition( ); $i++; + } + /** GUILD **/ + $rank = $player->getRank(); + if ($rank->isLoaded()) + { + $MadGD->addText( 'Guild membership:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $MadGD->addText( $rank->getName().' of the '.$player->getRank()->getGuild()->getName() )->setPosition( ); $i++; + } + /** LAST LOGIN **/ + $MadGD->addText( 'Last login:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $MadGD->addText( ( $player->getLastLogin() == 0 ? 'Never logged in' : date( 'M d Y, H:i:s T', $player->getLastLogin() ) ) )->setPosition( ); $i++; + /** ACCOUNT STATUS **/ + $MadGD->addText( 'Account Status:', $MadGD->textBold )->setPosition( 10, $i * $eachRow ); + $MadGD->addText( ( $player->getAccount()->getPremDays() > 0 ? 'Premium Account' : 'Free Account' ) )->setPosition( ); $i++; + + $MadGD->addIcon( SIGNATURES_IMAGES.'bg.png' )->setPosition( 200, 45 ); + $MadGD->addIcon( SIGNATURES_IMAGES.'bg.png' )->setPosition( 200, 54 ); + $MadGD->addIcon( SIGNATURES_IMAGES.'bg.png' )->setPosition( 200, 63 ); + + /** HEALTH BAR **/ + $MadGD->addText( 'HP:', $percent )->setPosition( 182, 40 ); + if ( ( $player->getHealth() > $player->getHealthMax() ) or ( $player->getHealth() > 0 and $player->getHealthMax() > 0 ) ) + { + $MadGD->addIcon( SIGNATURES_IMAGES.'health.png', $player->getHealth() / $player->getHealthMax() * 100 )->setPosition( 201, 46 ); + $MadGD->addText( floor( $player->getHealth() / $player->getHealthMax() * 100 ).'%', $percent )->setPosition( 305, 40 ); + } + else + { + $MadGD->addIcon( SIGNATURES_IMAGES.'health.png', 100 )->setPosition( 201, 46 ); + $MadGD->addText( '100%', $percent )->setPosition( 305, 40 ); + } + /** MANA BAR **/ + $MadGD->addText( 'MP:', $percent )->setPosition( 180, 50 ); + if ( ( $player->getMana() > $player->getManaMax() ) or ( $player->getMana() > 0 and $player->getManaMax() > 0 ) ) + { + $MadGD->addIcon( SIGNATURES_IMAGES.'mana.png', $player->getMana() / $player->getManaMax() * 100 )->setPosition( 201, 55 ); + $MadGD->addText( floor( $player->getMana() / $player->getManaMax() * 100 ).'%', $percent )->setPosition( 305, 50 ); + } + else + { + $MadGD->addIcon( SIGNATURES_IMAGES.'mana.png', 100 )->setPosition( 201, 55 ); + $MadGD->addText( '100%', $percent )->setPosition( 305, 50 ); + } + /** EXPERIENCE BAR **/ + $MadGD->addText( 'EXP:', $percent )->setPosition( 176, 60 ); + if ( $player->getExperience() > 0 and ( $player->getExperience() / getExpToLevel( $player->getLevel() + 1 ) * 100 ) <= 100 ) + { + $MadGD->addIcon( SIGNATURES_IMAGES.'exp.png', $player->getExperience() / getExpToLevel( $player->getLevel() + 1 ) * 100 )->setPosition( 201, 64 ); + $MadGD->addText( floor( $player->getExperience() / getExpToLevel( $player->getLevel() + 1 ) * 100 ).'%', $percent )->setPosition( 305, 60 ); + } + else + { + $MadGD->addIcon( SIGNATURES_IMAGES.'exp.png', 100 )->setPosition( 201, 64 ); + $MadGD->addText( '100%', $percent )->setPosition( 305, 60 ); + } + + $slots = array( + 2 => array( $MadGD->equipment['x']['amulet'], $MadGD->equipment['y']['amulet'] ), + 1 => array( $MadGD->equipment['x']['helmet'], $MadGD->equipment['y']['helmet'] ), + 3 => array( $MadGD->equipment['x']['backpack'], $MadGD->equipment['y']['backpack'] ), + 6 => array( $MadGD->equipment['x']['lefthand'], $MadGD->equipment['y']['lefthand'] ), + 4 => array( $MadGD->equipment['x']['armor'], $MadGD->equipment['y']['armor'] ), + 5 => array( $MadGD->equipment['x']['righthand'], $MadGD->equipment['y']['righthand'] ), + 9 => array( $MadGD->equipment['x']['ring'], $MadGD->equipment['y']['ring'] ), + 7 => array( $MadGD->equipment['x']['legs'], $MadGD->equipment['y']['legs'] ), + 10 => array( $MadGD->equipment['x']['ammunition'], $MadGD->equipment['y']['ammunition'] ), + 8 => array( $MadGD->equipment['x']['boots'], $MadGD->equipment['y']['boots'] ) + ); + foreach ( $slots as $pid => $position ) + { + $item = $db->query( 'SELECT `itemtype`, `attributes` FROM `player_items` WHERE `player_items`.`player_id` = '.$player->getId().' AND `player_items`.`pid` = '.$pid.';' )->fetch(); + if ( $item['itemtype'] != null ) + { + $count = unpack( 'C*', $item['attributes'] ); + if ( isset( $count[2] ) ) { + $count = $count[2]; + } + else { + $count = 1; + } + + $imagePath = SIGNATURES_ITEMS . ( $count > 1 ? $item['itemtype'].'/'.$count : $item['itemtype'] ).'.gif'; + //} + if ( file_exists( $imagePath ) ) { + $MadGD->addIcon( $imagePath )->setPosition( $position[0], $position[1] ); + } + else { + $MadGD->addIcon( SIGNATURES_IMAGES.'noitem.png' )->setPosition( $position[0], $position[1] ); + } + } + } + + $MadGD->save($player->getID()); ?> diff --git a/tools/signature/tibian.php b/tools/signature/tibian.php index 4356f7ca..ff6ced04 100644 --- a/tools/signature/tibian.php +++ b/tools/signature/tibian.php @@ -127,7 +127,4 @@ imagepng($img, SIGNATURES_CACHE . $player->getID() . '.png'); imagedestroy($img); - - header('Content-type: image/png'); - readfile(SIGNATURES_CACHE.$player->getId() . '.png' ); ?>