mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 01:34:55 +02:00
* moved characters.php html code to Twig template
* moved news.php to Twig news.html template * fixed some duplicated code in signature generators * always check if name parameter is set when generating signatures
This commit is contained in:
@@ -1,52 +1,32 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$player = $ots->createObject( 'Player' );
|
||||
$player->find($_GET['name']);
|
||||
if(function_exists('imagecreatefrompng'))
|
||||
$font = SIGNATURES_FONTS . 'font.ttf';
|
||||
$fontsize = 12;
|
||||
|
||||
$image = imagecreatefrompng(SIGNATURES_BACKGROUNDS . 'signature.png');
|
||||
$color= imagecolorallocate($image , 255, 255, 255);
|
||||
imagettftext($image , 12, 0, 20, 32, $color, $font, 'Name:');
|
||||
imagettftext($image , 12, 0, 70, 32, $color, $font, $player->getName());
|
||||
|
||||
$vocation = 'Unknown vocation';
|
||||
if(isset($config['vocations'][$player->getVocation()]))
|
||||
$vocation = $config['vocations'][$player->getVocation()];
|
||||
|
||||
imagettftext($image , $fontsize, 0, 20, 52, $color, $font, 'Level:');
|
||||
imagettftext($image , $fontsize, 0, 70, 52, $color, $font, $player->getLevel() . ' ' . $vocation);
|
||||
|
||||
$rank = $player->getRank();
|
||||
if($rank->isLoaded())
|
||||
{
|
||||
if($player->isLoaded())
|
||||
{
|
||||
$file = SIGNATURES_CACHE.$player->getId().'.png';
|
||||
if ( file_exists( $file ) and ( time( ) < ( filemtime($file) + ( 60 * $config['signature_cache_time'] ) ) ) )
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_CACHE.$player->getId().'.png' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$image = imagecreatefrompng(SIGNATURES_BACKGROUNDS . 'signature.png');
|
||||
$color= imagecolorallocate($image , 255, 255, 255);
|
||||
imagettftext($image , 12, 0, 20, 32, $color, SIGNATURES_FONTS . 'font.ttf' , 'Name:');
|
||||
imagettftext($image , 12, 0, 70, 32, $color, SIGNATURES_FONTS . 'font.ttf' , $player->getName());
|
||||
|
||||
imagettftext($image , 12, 0, 20, 52, $color, SIGNATURES_FONTS . 'font.ttf' , 'Level:');
|
||||
imagettftext($image , 12, 0, 70, 52, $color, SIGNATURES_FONTS . 'font.ttf' , $player->getLevel() . ' ' . $config['vocations'][$player->getVocation()]);
|
||||
|
||||
$rank = $player->getRank();
|
||||
if($rank->isLoaded())
|
||||
{
|
||||
imagettftext($image , 12, 0, 20, 75, $color, SIGNATURES_FONTS . 'font.ttf' , 'Guild:');
|
||||
imagettftext($image , 12, 0, 70, 75, $color, SIGNATURES_FONTS . 'font.ttf' , $player->getRank()->getName() . ' of the ' . $$rank->getGuild()->getName());
|
||||
}
|
||||
imagettftext($image , 12, 0, 20, 95, $color, SIGNATURES_FONTS . 'font.ttf' , 'Last Login:');
|
||||
imagettftext($image , 12, 0, 100, 95, $color, SIGNATURES_FONTS . 'font.ttf' , (($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');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Content-type: image/png');
|
||||
readfile(SIGNATURES_IMAGES . 'nocharacter.png');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Content-type: image/png');
|
||||
readfile(SIGNATURES_IMAGES . 'nogd.png');
|
||||
imagettftext($image , $fontsize, 0, 20, 75, $color, $font, 'Guild:');
|
||||
imagettftext($image , $fontsize, 0, 70, 75, $color, $font, $player->getRank()->getName() . ' of the ' . $$rank->getGuild()->getName());
|
||||
}
|
||||
imagettftext($image , $fontsize, 0, 20, 95, $color, $font, 'Last Login:');
|
||||
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');
|
||||
?>
|
@@ -4,20 +4,51 @@
|
||||
require(SYSTEM . 'init.php');
|
||||
|
||||
// Definitions
|
||||
define('SIGNATURES', BASE . 'tools/signature/');
|
||||
define('SIGNATURES', TOOLS . 'signature/');
|
||||
define('SIGNATURES_BACKGROUNDS', 'images/backgrounds/');
|
||||
define('SIGNATURES_CACHE', SYSTEM . 'cache/signatures/');
|
||||
define('SIGNATURES_CACHE', CACHE . 'signatures/');
|
||||
define('SIGNATURES_DATA', SYSTEM . 'data/');
|
||||
define('SIGNATURES_FONTS', SIGNATURES . 'fonts/');
|
||||
define('SIGNATURES_IMAGES', SIGNATURES . 'images/');
|
||||
define('SIGNATURES_ITEMS', BASE . 'images/items/');
|
||||
|
||||
if(!$config['signature_enabled'])
|
||||
die('Signatures disabled.');
|
||||
die('Signatures are disabled on this server.');
|
||||
|
||||
$file = strtolower($config['signature_type']) . '.php';
|
||||
$file = trim(strtolower($config['signature_type'])) . '.php';
|
||||
if(!file_exists($file))
|
||||
die('ERROR: Wrong signature type in config.');
|
||||
|
||||
putenv('GDFONTPATH=' . SIGNATURES_FONTS);
|
||||
|
||||
if(!isset($_REQUEST['name']))
|
||||
die('Please enter name as get or post parameter.');
|
||||
|
||||
$name = stripslashes(ucwords(strtolower(trim($_REQUEST['name']))));
|
||||
$player = new OTS_Player();
|
||||
$player->find($name);
|
||||
|
||||
if(!$player->isLoaded())
|
||||
{
|
||||
header('Content-type: image/png');
|
||||
readfile(SIGNATURES_IMAGES.'nocharacter.png');
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!function_exists( 'imagecreatefrompng'))
|
||||
{
|
||||
header('Content-type: image/png');
|
||||
readfile(SIGNATURES_IMAGES.'nogd.png');
|
||||
exit;
|
||||
}
|
||||
|
||||
$cached = SIGNATURES_CACHE.$player->getId() . '.png';
|
||||
if (file_exists($cached) and (time() < (filemtime($cached) + (60 * $config['signature_cache_time']))))
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_CACHE.$player->getId().'.png' );
|
||||
exit;
|
||||
}
|
||||
|
||||
require($file);
|
||||
?>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
**/
|
||||
|
||||
/** Load the MadGD class **/
|
||||
require( 'gd.class.php' );
|
||||
require('gd.class.php');
|
||||
/** Default values **/
|
||||
list( $i, $eachRow, $percent ) = array( .5, 14, array( 'size' => 7 ) );
|
||||
/** Get experience points for a certain level **/
|
||||
@@ -20,185 +20,153 @@
|
||||
$dat_path = SIGNATURES_DATA.'Tibia.dat';
|
||||
$otb_path = SIGNATURES_DATA.'items.otb';
|
||||
|
||||
$name = stripslashes( isset( $_GET['name'] ) ? $_GET['name'] : '-' );
|
||||
$player = $ots->createObject( 'Player' );
|
||||
$player->find( $name );
|
||||
|
||||
if ( function_exists( 'imagecreatefrompng' ) )
|
||||
$background = 'default.png';
|
||||
if ( file_exists( SIGNATURES_BACKGROUNDS.$background ) )
|
||||
{
|
||||
if ( $player->isLoaded( ) )
|
||||
$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 )
|
||||
{
|
||||
$file = SIGNATURES_CACHE.$player->getId().'.png';
|
||||
if ( file_exists( $file ) and ( time( ) < ( filemtime($file) + ( 60 * $config['signature_cache_time'] ) ) ) )
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_CACHE.$player->getId().'.png' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$background = 'default.png';
|
||||
if ( file_exists( SIGNATURES_BACKGROUNDS.$background ) )
|
||||
{
|
||||
$MadGD = new MadGD( SIGNATURES_BACKGROUNDS.$background );
|
||||
$MadGD->testMode = false;
|
||||
$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->setDefaultStyle( SIGNATURES_FONTS.'arial.ttf', SIGNATURES_FONTS.'arialbd.ttf', 8 );
|
||||
$MadGD->setEquipmentBackground( SIGNATURES_IMAGES.'equipments.png' );
|
||||
$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 );
|
||||
|
||||
/** 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 **/
|
||||
$MadGD->addText( 'Profession:', $MadGD->textBold )->setPosition( 10, $i * $eachRow );
|
||||
$MadGD->addText( $config['vocations'][$player->getVocation()] )->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 ) )
|
||||
//{
|
||||
// require(SYSTEM . 'item.php');
|
||||
// generateItem($item['itemtype'], $count);
|
||||
//}
|
||||
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
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_IMAGES.'nobackground.png' );
|
||||
}
|
||||
}
|
||||
/** 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
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_IMAGES.'nocharacter.png' );
|
||||
$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
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_IMAGES.'nogd.png' );
|
||||
readfile( SIGNATURES_IMAGES . 'nobackground.png' );
|
||||
}
|
||||
?>
|
||||
|
@@ -1,160 +1,133 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
define('FONTS', TOOLS . 'signature/fonts/');
|
||||
putenv('GDFONTPATH=' . FONTS);
|
||||
$img = imagecreatefrompng(SIGNATURES_IMAGES . 'stats.png');
|
||||
if(!$img) {
|
||||
die('Error while using function imagecreatefrompng. Maybe you got php extension xdebug loaded?');
|
||||
}
|
||||
|
||||
$font = FONTS . "arialbd.ttf";
|
||||
$font = SIGNATURES_FONTS . "arialbd.ttf";
|
||||
$fontsize = 8;
|
||||
|
||||
$name = stripslashes(ucwords(strtolower(trim($_REQUEST['name']))));
|
||||
if(!check_name($name))
|
||||
return;
|
||||
$title = imagecolorallocate($img, 160, 160, 160);
|
||||
$text = imagecolorallocate($img, 180, 180, 180);
|
||||
$bar = imagecolorallocate($img, 0, 0, 0);
|
||||
$barfill = imagecolorallocate($img, 200, 0, 0);
|
||||
$hpfill = imagecolorallocate($img, 200, 0, 0);
|
||||
$manafill = imagecolorallocate($img, 0, 0, 200);
|
||||
|
||||
$player = $ots->createObject('Player');
|
||||
$player->find($name);
|
||||
imagettftext($img, $fontsize, 0, 20, 11, $title, $font, $player->getName() . ' - ' . BASE_URL);
|
||||
|
||||
if(!$player->isLoaded())
|
||||
{
|
||||
header('Content-type: image/png');
|
||||
readfile(SIGNATURES_IMAGES.'nocharacter.png');
|
||||
}
|
||||
// experience
|
||||
$needexp = OTS_Toolbox::experienceForLevel($player->getLevel() + 1);
|
||||
$experience = $player->getExperience();
|
||||
if($experience > $needexp) $experience = $needexp;
|
||||
imagettftext($img, $fontsize, 0, 15, 30, $text, $font, 'Experience');
|
||||
imagettftext($img, $fontsize, 0, 100, 30, $text, $font, number_format($experience)." (".number_format($needexp).")");
|
||||
|
||||
// level
|
||||
imagettftext($img, $fontsize, 0, 15, 43, $text, $font, 'Level');
|
||||
imagettftext($img, $fontsize, 0, 100, 43, $text, $font, number_format($player->getLevel()));
|
||||
|
||||
// experience bar
|
||||
$exppercent = round($experience / $needexp * 100);
|
||||
imagerectangle($img, 14, 46, 166, 50, $bar);
|
||||
if($exppercent > 0)
|
||||
imagefilledrectangle($img, 15, 47, $exppercent * 1.5 + 15, 49, $barfill);
|
||||
|
||||
imagettftext($img, $fontsize, 0, 170, 51, $text, $font, $exppercent . '%');
|
||||
|
||||
// vocation
|
||||
$vocation = 'Unknown';
|
||||
if(isset($config['vocations'][$player->getVocation()]))
|
||||
$vocation = $config['vocations'][$player->getVocation()];
|
||||
|
||||
if(!function_exists( 'imagecreatefrompng'))
|
||||
{
|
||||
header('Content-type: image/png');
|
||||
readfile(SIGNATURES_IMAGES.'nogd.png');
|
||||
}
|
||||
$file = SIGNATURES_CACHE.$player->getId().'.png';
|
||||
if ( file_exists( $file ) and ( time( ) < ( filemtime($file) + ( 60 * $config['signature_cache_time'] ) ) ) )
|
||||
{
|
||||
header( 'Content-type: image/png' );
|
||||
readfile( SIGNATURES_CACHE.$player->getId().'.png' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$img = imagecreatefrompng(SIGNATURES_IMAGES . 'stats.png');
|
||||
if(!$img)
|
||||
{
|
||||
echo 'Error while using function imagecreatefrompng. Maybe you got php extension xdebug loaded?';
|
||||
die();
|
||||
}
|
||||
$title = imagecolorallocate($img, 160, 160, 160);
|
||||
$text = imagecolorallocate($img, 180, 180, 180);
|
||||
$bar = imagecolorallocate($img, 0, 0, 0);
|
||||
$barfill = imagecolorallocate($img, 200, 0, 0);
|
||||
$hpfill = imagecolorallocate($img, 200, 0, 0);
|
||||
$manafill = imagecolorallocate($img, 0, 0, 200);
|
||||
imagettftext($img, $fontsize, 0, 15, 62, $text, $font, 'Vocation');
|
||||
imagettftext($img, $fontsize, 0, 100, 62, $text, $font, $vocation);
|
||||
|
||||
imagettftext($img, $fontsize, 0, 20, 11, $title, $font, $player->getName() . ' - ' . BASE_URL);
|
||||
// hit points, Mana, Soul Points, Capacity
|
||||
$health = $player->getHealth();
|
||||
if($health > $player->getHealthMax())
|
||||
$health = $player->getHealthMax();
|
||||
|
||||
// experience
|
||||
$needexp = OTS_Toolbox::experienceForLevel($player->getLevel() + 1);
|
||||
$experience = $player->getExperience();
|
||||
if($experience > $needexp) $experience = $needexp;
|
||||
imagettftext($img, $fontsize, 0, 15, 30, $text, $font, 'Experience');
|
||||
imagettftext($img, $fontsize, 0, 100, 30, $text, $font, number_format($experience)." (".number_format($needexp).")");
|
||||
$empty = imagecreatefrompng('images/empty.png');
|
||||
//imagerectangle($img, 39, 67, 141, 75, $bar);
|
||||
$fillhp = round($player->getHealth()/$player->getHealthMax() * 100);
|
||||
//imagefilledrectangle($img, 40, 68, 40+$fillhp, 74, $hpfill);
|
||||
$healthicon = imagecreatefrompng('images/hpicon.png');
|
||||
imagecopy($img, $healthicon, 15, 65, 0, 0, 12, 12);
|
||||
$healthfg = imagecreatefrompng('images/healthfull.png');
|
||||
imagecopy($img, $empty, 32, 65, 0, 0, 100, 12);
|
||||
imagecopy($img, $healthfg, 32, 65, 0, 0, $fillhp, 12);
|
||||
//imagettftext($img, $fontsize, 0, 15, 75, $text, $font, "Hit Points");
|
||||
imagettftext($img, $fontsize, 0, 140, 75, $text, $font, $player->getHealth());
|
||||
|
||||
// level
|
||||
imagettftext($img, $fontsize, 0, 15, 43, $text, $font, 'Level');
|
||||
imagettftext($img, $fontsize, 0, 100, 43, $text, $font, number_format($player->getLevel()));
|
||||
//imagerectangle($img, 39, 80, 141, 88, $bar);
|
||||
$mana = $player->getMana();
|
||||
if($mana > $player->getManaMax())
|
||||
$mana = $player->getManaMax();
|
||||
|
||||
// experience bar
|
||||
$exppercent = round($experience / $needexp * 100);
|
||||
imagerectangle($img, 14, 46, 166, 50, $bar);
|
||||
if($exppercent > 0)
|
||||
imagefilledrectangle($img, 15, 47, $exppercent * 1.5 + 15, 49, $barfill);
|
||||
$fillmana = 0;
|
||||
if($player->getMana() > 0 && $player->getManaMax() > 0)
|
||||
$fillmana = round($player->getMana()/$player->getManaMax() * 100);
|
||||
|
||||
imagettftext($img, $fontsize, 0, 170, 51, $text, $font, $exppercent . '%');
|
||||
//imagefilledrectangle($img, 40, 81, 40+$fillmana, 87, $manafill);
|
||||
$manaicon = imagecreatefrompng('images/manaicon.png');
|
||||
imagecopy($img, $manaicon, 15, 79, 0, 0, 12, 10);
|
||||
$manafg = imagecreatefrompng('images/manafull.png');
|
||||
imagecopy($img, $empty, 32, 78, 0, 0, 100, 12);
|
||||
imagecopy($img, $manafg, 32, 78, 0, 0, $fillmana, 12);
|
||||
//imagettftext($img, $fontsize, 0, 15, 88, $text, $font, "Mana");
|
||||
imagettftext($img, $fontsize, 0, 140, 88, $text, $font, $player->getMana());
|
||||
|
||||
// vocation
|
||||
imagettftext($img, $fontsize, 0, 15, 62, $text, $font, 'Vocation');
|
||||
imagettftext($img, $fontsize, 0, 100, 62, $text, $font, $config['vocations'][$player->getVocation()]);
|
||||
imagettftext($img, $fontsize, 0, 15, 101, $text, $font, 'Soul Points');
|
||||
imagettftext($img, $fontsize, 0, 100, 101, $text, $font, number_format($player->getSoul()));
|
||||
imagettftext($img, $fontsize, 0, 15, 114, $text, $font, 'Capacity');
|
||||
imagettftext($img, $fontsize, 0, 100, 114, $text, $font, number_format($player->getCap()));
|
||||
|
||||
// hit points, Mana, Soul Points, Capacity
|
||||
$health = $player->getHealth();
|
||||
if($health > $player->getHealthMax())
|
||||
$health = $player->getHealthMax();
|
||||
// magic Level
|
||||
imagettftext($img, $fontsize, 0, 15, 127, $text, $font, 'Magic Level');
|
||||
imagettftext($img, $fontsize, 0, 100, 127, $text, $font, number_format($player->getMagLevel()));
|
||||
|
||||
$empty = imagecreatefrompng('images/empty.png');
|
||||
//imagerectangle($img, 39, 67, 141, 75, $bar);
|
||||
$fillhp = round($player->getHealth()/$player->getHealthMax() * 100);
|
||||
//imagefilledrectangle($img, 40, 68, 40+$fillhp, 74, $hpfill);
|
||||
$healthicon = imagecreatefrompng('images/hpicon.png');
|
||||
imagecopy($img, $healthicon, 15, 65, 0, 0, 12, 12);
|
||||
$healthfg = imagecreatefrompng('images/healthfull.png');
|
||||
imagecopy($img, $empty, 32, 65, 0, 0, 100, 12);
|
||||
imagecopy($img, $healthfg, 32, 65, 0, 0, $fillhp, 12);
|
||||
//imagettftext($img, $fontsize, 0, 15, 75, $text, $font, "Hit Points");
|
||||
imagettftext($img, $fontsize, 0, 140, 75, $text, $font, $player->getHealth());
|
||||
// premium status
|
||||
$account = $player->getAccount();
|
||||
imagettftext($img, $fontsize, 0, 15, 140, $text, $font, $account->getPremDays() > 0 ? 'Premium Account': 'Free Account');
|
||||
|
||||
//imagerectangle($img, 39, 80, 141, 88, $bar);
|
||||
$mana = $player->getMana();
|
||||
if($mana > $player->getManaMax())
|
||||
$mana = $player->getManaMax();
|
||||
|
||||
$fillmana = 0;
|
||||
if($player->getMana() > 0 && $player->getManaMax() > 0)
|
||||
$fillmana = round($player->getMana()/$player->getManaMax() * 100);
|
||||
|
||||
//imagefilledrectangle($img, 40, 81, 40+$fillmana, 87, $manafill);
|
||||
$manaicon = imagecreatefrompng('images/manaicon.png');
|
||||
imagecopy($img, $manaicon, 15, 79, 0, 0, 12, 10);
|
||||
$manafg = imagecreatefrompng('images/manafull.png');
|
||||
imagecopy($img, $empty, 32, 78, 0, 0, 100, 12);
|
||||
imagecopy($img, $manafg, 32, 78, 0, 0, $fillmana, 12);
|
||||
//imagettftext($img, $fontsize, 0, 15, 88, $text, $font, "Mana");
|
||||
imagettftext($img, $fontsize, 0, 140, 88, $text, $font, $player->getMana());
|
||||
|
||||
imagettftext($img, $fontsize, 0, 15, 101, $text, $font, 'Soul Points');
|
||||
imagettftext($img, $fontsize, 0, 100, 101, $text, $font, number_format($player->getSoul()));
|
||||
imagettftext($img, $fontsize, 0, 15, 114, $text, $font, 'Capacity');
|
||||
imagettftext($img, $fontsize, 0, 100, 114, $text, $font, number_format($player->getCap()));
|
||||
|
||||
// magic Level
|
||||
imagettftext($img, $fontsize, 0, 15, 127, $text, $font, 'Magic Level');
|
||||
imagettftext($img, $fontsize, 0, 100, 127, $text, $font, number_format($player->getMagLevel()));
|
||||
|
||||
// premium status
|
||||
$account = $player->getAccount();
|
||||
imagettftext($img, $fontsize, 0, 15, 140, $text, $font, $account->getPremDays() > 0 ? 'Premium Account': 'Free Account');
|
||||
|
||||
imagefilledrectangle($img, 225, 40, 225, 130, $title); //seperator
|
||||
$posy = 50;
|
||||
imagefilledrectangle($img, 225, 40, 225, 130, $title); //seperator
|
||||
$posy = 50;
|
||||
|
||||
if(fieldExist('skill_fist', 'players')) {// tfs 1.0+
|
||||
$skills_db = $db->query('SELECT `skill_fist`, `skill_club`, `skill_sword`, `skill_axe`, `skill_dist`, `skill_shielding`, `skill_fishing` FROM `players` WHERE `id` = ' . $player->getId())->fetch();
|
||||
|
||||
if(fieldExist('skill_fist', 'players')) {// tfs 1.0+
|
||||
$skills_db = $db->query('SELECT `skill_fist`, `skill_club`, `skill_sword`, `skill_axe`, `skill_dist`, `skill_shielding`, `skill_fishing` FROM `players` WHERE `id` = ' . $player->getId())->fetch();
|
||||
|
||||
$skill_ids = array(
|
||||
POT::SKILL_FIST => 'skill_fist',
|
||||
POT::SKILL_CLUB => 'skill_club',
|
||||
POT::SKILL_SWORD => 'skill_sword',
|
||||
POT::SKILL_AXE => 'skill_axe',
|
||||
POT::SKILL_DIST => 'skill_dist',
|
||||
POT::SKILL_SHIELD => 'skill_shielding',
|
||||
POT::SKILL_FISH => 'skill_fishing',
|
||||
);
|
||||
|
||||
$skills = array();
|
||||
foreach($skill_ids as $skillid => $field_name) {
|
||||
$skills[] = array('skillid' => $skillid, 'value' => $skills_db[$field_name]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$skills = $db->query('SELECT ' . $db->fieldName('skillid') . ', ' . $db->fieldName('value') . ' FROM ' . $db->tableName('player_skills') . ' WHERE ' . $db->fieldName('player_id') . ' = ' . $player->getId() . ' LIMIT 7');
|
||||
}
|
||||
|
||||
foreach($skills as $skill)
|
||||
{
|
||||
imagettftext($img, $fontsize, 0, 235, $posy, $text, $font, getSkillName($skill['skillid']));
|
||||
imagettftext($img, $fontsize, 0, 360, $posy, $text, $font, $skill['value']);
|
||||
$posy = $posy + 13;
|
||||
}
|
||||
|
||||
imagepng($img, SIGNATURES_CACHE . $player->getID() . '.png');
|
||||
imagedestroy($img);
|
||||
$skill_ids = array(
|
||||
POT::SKILL_FIST => 'skill_fist',
|
||||
POT::SKILL_CLUB => 'skill_club',
|
||||
POT::SKILL_SWORD => 'skill_sword',
|
||||
POT::SKILL_AXE => 'skill_axe',
|
||||
POT::SKILL_DIST => 'skill_dist',
|
||||
POT::SKILL_SHIELD => 'skill_shielding',
|
||||
POT::SKILL_FISH => 'skill_fishing',
|
||||
);
|
||||
|
||||
header('Content-type: image/png');
|
||||
readfile(SIGNATURES_CACHE.$player->getId() . '.png' );
|
||||
$skills = array();
|
||||
foreach($skill_ids as $skillid => $field_name) {
|
||||
$skills[] = array('skillid' => $skillid, 'value' => $skills_db[$field_name]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$skills = $db->query('SELECT ' . $db->fieldName('skillid') . ', ' . $db->fieldName('value') . ' FROM ' . $db->tableName('player_skills') . ' WHERE ' . $db->fieldName('player_id') . ' = ' . $player->getId() . ' LIMIT 7');
|
||||
}
|
||||
|
||||
foreach($skills as $skill)
|
||||
{
|
||||
imagettftext($img, $fontsize, 0, 235, $posy, $text, $font, getSkillName($skill['skillid']));
|
||||
imagettftext($img, $fontsize, 0, 360, $posy, $text, $font, $skill['value']);
|
||||
$posy = $posy + 13;
|
||||
}
|
||||
|
||||
imagepng($img, SIGNATURES_CACHE . $player->getID() . '.png');
|
||||
imagedestroy($img);
|
||||
|
||||
header('Content-type: image/png');
|
||||
readfile(SIGNATURES_CACHE.$player->getId() . '.png' );
|
||||
?>
|
||||
|
Reference in New Issue
Block a user