From d50fb7a2912b6ca4847b39f9f19af4eabc2082b7 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 1 Sep 2017 17:00:29 +0200 Subject: [PATCH] * 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 --- system/functions.php | 2 +- system/pages/characters.php | 932 ++++++++-------------- system/pages/news.php | 67 +- system/templates/account.change_info.html | 49 +- system/templates/characters.html | 351 ++++++++ system/templates/news.html | 23 + system/templates/news.php | 34 - templates/kathrine/news.php | 42 - templates/kathrine/templates/news.html | 25 + templates/tibiacom/news.php | 39 - tools/signature/gesior.php | 72 +- tools/signature/index.php | 39 +- tools/signature/mango.php | 308 ++++--- tools/signature/tibian.php | 249 +++--- 14 files changed, 1139 insertions(+), 1093 deletions(-) create mode 100644 system/templates/characters.html create mode 100644 system/templates/news.html delete mode 100644 system/templates/news.php delete mode 100644 templates/kathrine/news.php create mode 100644 templates/kathrine/templates/news.html delete mode 100644 templates/tibiacom/news.php diff --git a/system/functions.php b/system/functions.php index 98e18313..6f77edb7 100644 --- a/system/functions.php +++ b/system/functions.php @@ -441,7 +441,7 @@ function check_name($name, &$error = '') return false; } - return preg_match("/[A-z ']{1,25}/", $name); + return preg_match("/[A-z ']/", $name); } /** diff --git a/system/pages/characters.php b/system/pages/characters.php index 928721a4..90cb7adc 100644 --- a/system/pages/characters.php +++ b/system/pages/characters.php @@ -14,79 +14,17 @@ $title = 'Characters'; require(SYSTEM . 'item.php'); $groups = new OTS_Groups_List(); -function generate_search_table($autofocus = false) +function generate_search_form($autofocus = false) { - global $config, $template_path, $twig; + global $config, $twig; return $twig->render('characters.form.html', array( 'link' => getPageLink('characters'), 'vdarkborder' => $config['vdarkborder'], 'darkborder' => $config['darkborder'], - 'autofocus' => $autofocus, - 'template_path' => $template_path + 'autofocus' => $autofocus )); } -function generate_player_lookup($player) -{ - global $db; - $eq_sql = $db->query('SELECT `pid`, `itemtype` FROM player_items WHERE player_id = '.$player->getId().' AND (`pid` >= 1 and `pid` <= 10)'); - $player_eq = array(); - foreach($eq_sql as $eq) - $player_eq[$eq['pid']] = $eq['itemtype']; - - $empty_slots = array("", "no_helmet", "no_necklace", "no_backpack", "no_armor", "no_handleft", "no_handright", "no_legs", "no_boots", "no_ring", "no_ammo"); - for($i = 0; $i <= 10; $i++) - { - if(!isset($player_eq[$i]) || $player_eq[$i] == 0) - $player_eq[$i] = $empty_slots[$i]; - } -/* - if(PHP_VERSION_ID == NULL || PHP_VERSION_ID < 70000) { - for($i = 1; $i < 11; $i++) - { - if(!itemImageExists($player_eq[$i])) - Items::generate($player_eq[$i]); - } - } - */ - for($i = 1; $i < 11; $i++) - { - if(check_number($player_eq[$i])) - $player_eq[$i] = getItemImage($player_eq[$i]); - else - $player_eq[$i] = ' ' . $player_eq[$i] . ''; - } - - $skulls = array( - 1 => 'yellow_skull', - 2 => 'green_skull', - 3 => 'white_skull', - 4 => 'red_skull', - 5 => 'black_skull' - ); - - return ' - - - - - -
- - - -
'.$player_eq[2].'
'.$player_eq[6].'
'.$player_eq[9].'
'.($player->getSkullTime() > 0 && ($player->getSkull() == 4 || $player->getSkull() == 5) ? '' : '').'
-
- - -
'.$player_eq[1].'
'.$player_eq[4].'
'.$player_eq[7].'
'.$player_eq[8].'
-
- - -
'.$player_eq[3].'
'.$player_eq[5].'
'.$player_eq[10].'
-
'; -} - function retrieve_former_name($name) { global $oldName, $db; @@ -112,7 +50,7 @@ if(empty($name)) { $tmp_link = getPlayerLink($name); echo 'Here you can get detailed information about a certain player on ' . $config['lua']['serverName'] . '.
'; - echo generate_search_table(true); + echo generate_search_form(true); return; } @@ -141,538 +79,362 @@ if($player->isLoaded() && !$player->isDeleted()) $title = $player->getName() . ' - ' . $title; $account = $player->getAccount(); $rows = 0; -?> - - - '; - } - echo '
- - -
- - - - - getCustomField('country')); - - echo - ''. - ' - '; - - $player_sex = 'Unknown'; - if(isset($config['genders'][$player->getSex()])) - $player_sex = strtolower($config['genders'][$player->getSex()]); - - echo - ''; - - if($config['characters']['marriage_info'] && fieldExist('marriage', 'players')) - { - echo - ''; - } - - echo - ''. - ''. - ''; - - if($config['characters']['level']) - echo ''; - - if($config['characters']['experience']) - echo ''; - - if($config['characters']['magic_level']) - echo''; - - //frags - if(tableExist('player_killers') && $config['characters']['frags']) { - $frags_count = 0; - $frags_query = $db->query( - 'SELECT COUNT(`player_id`) as `frags`' . - 'FROM `player_killers`' . - 'WHERE `player_id` = ' .$player->getId() . ' ' . - 'GROUP BY `player_id`' . - 'ORDER BY COUNT(`player_id`) DESC'); - - if($frags_query->rowCount() > 0) - { - $frags_query = $frags_query->fetch(); - $frags_count = $frags_query['frags']; - } - - echo - ''; - } - - if(!empty($config['towns'][$player->getTownId()])) - echo ''; - - if($config['characters']['balance']) - echo ''; - - $town_field = 'town'; - if(fieldExist('town_id', 'houses')) - $town_field = 'town_id'; - else if(fieldExist('townid', 'houses')) - $town_field = 'townid'; - else if(!fieldExist('town', 'houses')) - $town_field = false; - - if(fieldExist('name', 'houses')) { - $house = $db->query('SELECT `id`, `paid`, `name`' . ($town_field != false ? ', `' . $town_field . '` as `town`' : '') . ' FROM `houses` WHERE `owner` = '.$player->getId())->fetch(); - if(isset($house['id'])) - { - $add = ''; - if($house['paid'] > 0) - $add = ' is paid until '.date("M d Y", $house['paid']); - - echo - ' - - - '; - } - } - - $rank_of_player = $player->getRank(); - if($rank_of_player->isLoaded()) { - $guild = $rank_of_player->getGuild(); - if($guild->isLoaded()) { - $guild_name = $guild->getName(); - echo - ''. - ''. - ''; - } - } - - echo - ''; - if($config['characters']['creation_date']) - echo - ''; - - $comment = $player->getComment();/* - $newlines = array("\r\n", "\n", "\r"); - $comment_with_lines = str_replace($newlines, '
', $comment, $count); - if($count < 50) - $comment = $comment_with_lines;*/ - if(!empty($comment)) - echo ''; - - echo - ''. - '
Character Information
Name:' . $flag . ' '.$player->getName().''.$oldName. - '
Sex:' . $player_sex . '
Marital status:'; - $marriage = new OTS_Player(); - $marriage->load($player->getMarriage()); - if($marriage->isLoaded()) - echo 'married to ' . getPlayerLink($marriage->getName()); - else - echo 'single'; - echo - '
Profession:' . $config['vocations'][$player->getVocation()] . '
Level:'.$player->getLevel().'
Experience:'.$player->getExperience().'
Magic Level:'.$player->getMagLevel().'
Frags:' . $frags_count . '
Residence:' . $config['towns'][$player->getTownId()] . '
Balance:'.$player->getBalance().' Gold Coins.
House: - - - -
' . (isset($house['name']) ? $house['name'] : $house['id']) . (isset($house['town']) ? ' (' . $config['towns'][$house['town']] . ')' : '') . $add . ' -
- - -
-
-
Guild membership:'.$rank_of_player->getName().' of the ' . getGuildLink($guild_name) . '
Last login:'; - $lastlogin = $player->getLastLogin(); - if(empty($lastlogin)) - echo 'Never logged in.'; - else - echo date("M d Y, H:i:s", $lastlogin).' CEST'; - - echo '
Created:'.date("M d Y, H:i:s", $player->getCreated()).' CEST
Comment:' . wordwrap(nl2br($comment), 60, "
", true) . '
Account Status:' . (($account->isPremium()) ? 'Premium Account' : 'Free Account') . '
'; - - echo '
'. - ''; - - if($config['characters']['skills']) - { - 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 `skillid`, `value` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' LIMIT 7'); - echo ' - '; - } - - if($config['characters']['quests'] && !empty($config['quests'])) - { - $quests = $config['quests']; - $sql_query_in = ''; - $i = 0; - foreach($quests as $quest_name => $quest_storage) - { - if($i != 0) - $sql_query_in .= ', '; - - $sql_query_in .= $quest_storage; - $i++; - } - - $storage_sql = $db->query('SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = '.$player->getId().' AND `key` IN (' . $sql_query_in . ')'); - $player_storage = array(); - foreach($storage_sql as $storage) - $player_storage[$storage['key']] = $storage['value']; - - echo ' - '; - } - - if($config['characters']['equipment']) - { - echo ' - '; - } - - echo '
'. - ' - - - '; - - $i = 0; - foreach($skills as $skill) - { - echo - ' - - - '; - } - - echo - '
Skills
' . getSkillName($skill['skillid']) . '' . $skill['value'] . '
-
'. - ' - - - '; - - //for($i=0; $i < count($quests); $i++) - $i = 0; - foreach($quests as $name => $storage) - { - $i++; - echo - ' - - - '; - } - - echo - '
Quests
'.$name.'
-
'. - ''. - ''. - ' -
Equipment
'.generate_player_lookup($player).'
-
'; - - - if(tableExist('killers')) { - $player_deaths = $db->query('SELECT `id`, `date`, `level` FROM `player_deaths` WHERE `player_id` = '.$player->getId().' ORDER BY `date` DESC LIMIT 0,10;'); - if(count($player_deaths)) - { - $dead_add_content = '
'; - - $number_of_rows = 0; - foreach($player_deaths as $death) - { - $dead_add_content .= " - - "; - } - - if($number_of_rows > 0) - echo $dead_add_content . '
Character Deaths
".date("j M Y, H:i", $death['date'])." "; - $killers = $db->query("SELECT environment_killers.name AS monster_name, players.name AS player_name, players.deleted AS player_exists FROM killers LEFT JOIN environment_killers ON killers.id = environment_killers.kill_id -LEFT JOIN player_killers ON killers.id = player_killers.kill_id LEFT JOIN players ON players.id = player_killers.player_id -WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, killers.id ASC")->fetchAll(); - - $i = 0; - $count = count($killers); - foreach($killers as $killer) - { - $i++; - if($killer['player_name'] != "") - { - if($i == 1) - $dead_add_content .= "Killed at level ".$death['level'].""; - else if($i == $count) - $dead_add_content .= " and"; - else - $dead_add_content .= ","; - - $dead_add_content .= " by "; - if($killer['monster_name'] != "") - $dead_add_content .= $killer['monster_name']." summoned by "; - - if($killer['player_exists'] == 0) - $dead_add_content .= getPlayerLink($killer['player_name']); - else - $dead_add_content .= $killer['player_name']; - } - else - { - if($i == 1) - $dead_add_content .= "Died at level ".$death['level'].""; - else if($i == $count) - $dead_add_content .= " and"; - else - $dead_add_content .= ","; - - $dead_add_content .= " by ".$killer['monster_name']; - } - } - - $dead_add_content .= ".
'; - } - } - else { - $mostdamage = ''; - if(fieldExist('mostdamage_by', 'player_deaths')) - $mostdamage = ', `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`'; - $deaths = $db->query('SELECT - `player_id`, `time`, `level`, `killed_by`, `is_player`' . $mostdamage . ' - FROM `player_deaths` - WHERE `player_id` = ' . $player->getId() . ' ORDER BY `time` DESC LIMIT 10;'); - - if(count($deaths)) - { - $dead_add_content = '
'; - - $number_of_rows = 0; - foreach($deaths as $death) - { - $dead_add_content .= " - - "; - } - - if($number_of_rows > 0) - echo $dead_add_content . '
Character Deaths
".date("j M Y, H:i", $death['time'])." "; - - $lasthit = ($death['is_player']) ? getPlayerLink($death['killed_by']) : $death['killed_by']; - $dead_add_content .= 'Killed at level ' . $death['level'] . ' by ' . $lasthit; - if($death['unjustified']) { - $dead_add_content .= " (unjustified)"; - } - - $mostdmg = ($death['mostdamage_by'] !== $death['killed_by']) ? true : false; - if($mostdmg) - { - $mostdmg = ($death['mostdamage_is_player']) ? getPlayerLink($death['mostdamage_by']) : $death['mostdamage_by']; - $dead_add_content .= ' and by ' . $mostdmg; - - if ($death['mostdamage_unjustified']) { - $dead_add_content .= " (unjustified)"; - } - } - else { - $dead_add_content .= " (soloed)"; - } - - $dead_add_content .= ".
'; - } - } - - if($config['characters']['frags']) + $outfit = $config['outfit_images_url'] . '?id=' . $player->getLookType() . (fieldExist('lookaddons', 'players') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet(); + + $flag = ''; + if($config['account_country']) + $flag = getFlagImage($account->getCustomField('country')); + + $player_sex = 'Unknown'; + if(isset($config['genders'][$player->getSex()])) + $player_sex = strtolower($config['genders'][$player->getSex()]); + + $marriage = new OTS_Player(); + $marriage->load($player->getMarriage()); + + $marital_status = 'single'; + if($marriage->isLoaded()) + $marital_status = 'married to ' . getPlayerLink($marriage->getName()); + + $frags_enabled = tableExist('player_killers') && $config['characters']['frags']; + $frags_count = 0; + if($frags_enabled) { + $query = $db->query( + 'SELECT COUNT(`player_id`) as `frags`' . + 'FROM `player_killers`' . + 'WHERE `player_id` = ' .$player->getId() . ' ' . + 'GROUP BY `player_id`' . + 'ORDER BY COUNT(`player_id`) DESC'); + + if($query->rowCount() > 0) { - //frags list by Xampy - $i = 0; - $frags_limit = 10; // frags limit to show? // default: 10 - $player_frags = $db->query('SELECT `player_deaths`.*, `players`.`name`, `killers`.`unjustified` FROM `player_deaths` LEFT JOIN `killers` ON `killers`.`death_id` = `player_deaths`.`id` LEFT JOIN `player_killers` ON `player_killers`.`kill_id` = `killers`.`id` LEFT JOIN `players` ON `players`.`id` = `player_deaths`.`player_id` WHERE `player_killers`.`player_id` = '.$player->getId().' ORDER BY `date` DESC LIMIT 0,'.$frags_limit.';'); - if(count($player_frags)) - { - $frags = 0; - $frag_add_content .= '
'; - foreach($player_frags as $frag) - { - $frags++; - $frag_add_content .= ' - - "; - } - if($frags > 0) - echo $frag_add_content . '
Victims
' . date("j M Y, H:i", $frag['date']) . 'Fragged ' . $frag[name] . ' at level ' . $frag[level]; - - $frag_add_content .= ". (".(($frag['unjustified'] == 0) ? "Justified" : "Unjustified").")
'; - } + $query = $query->fetch(); + $frags_count = $query['frags']; } - - //Signature - //Js - if($config['signature_enabled']) + } + + $town_field = 'town'; + if(fieldExist('town_id', 'houses')) + $town_field = 'town_id'; + else if(fieldExist('townid', 'houses')) + $town_field = 'townid'; + else if(!fieldExist('town', 'houses')) + $town_field = false; + + if(fieldExist('name', 'houses')) { + $house = $db->query('SELECT `id`, `paid`, `name`' . ($town_field != false ? ', `' . $town_field . '` as `town`' : '') . ' FROM `houses` WHERE `owner` = '.$player->getId())->fetch(); + if(isset($house['id'])) + { + $add = ''; + if($house['paid'] > 0) + $add = ' is paid until '.date("M d Y", $house['paid']); + } + } + + $rank_of_player = $player->getRank(); + if($rank_of_player->isLoaded()) { + $guild = $rank_of_player->getGuild(); + if($guild->isLoaded()) { + $guild_name = $guild->getName(); + } + } + + $comment = $player->getComment(); + + if($config['characters']['skills']) { - echo ''; - echo '
- - -
Signature
'; - $signature_url = BASE_URL . 'tools/signature/?name=' . urlencode($player->getName()); - if($config['friendly_urls']) - $signature_url = BASE_URL . urlencode($player->getName()) . '.png'; - - echo ' - Signature for player '.$player->getName().' -
- Show links -
- - - - - - - - - - - - - - -
'; + else + $skills = $db->query('SELECT `skillid`, `value` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' LIMIT 7'); + + foreach($skills as &$skill) { + $skill['name'] = getSkillName($skill['skillid']); + } + } + + $quests_enabled = $config['characters']['quests'] && !empty($config['quests']); + if($quests_enabled) + { + $quests = $config['quests']; + $sql_query_in = ''; + $i = 0; + foreach($quests as $quest_name => $quest_storage) + { + if($i != 0) + $sql_query_in .= ', '; + + $sql_query_in .= $quest_storage; + $i++; + } + + $storage_sql = $db->query('SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = '.$player->getId().' AND `key` IN (' . $sql_query_in . ')'); + $player_storage = array(); + foreach($storage_sql as $storage) + $player_storage[$storage['key']] = $storage['value']; + + foreach($quests as &$storage) { + $storage = isset($player_storage[$storage]) && $player_storage[$storage] > 0; + } + } + + if($config['characters']['equipment']) + { + global $db; + $eq_sql = $db->query('SELECT `pid`, `itemtype` FROM player_items WHERE player_id = '.$player->getId().' AND (`pid` >= 1 and `pid` <= 10)'); + $equipment = array(); + foreach($eq_sql as $eq) + $equipment[$eq['pid']] = $eq['itemtype']; + + $empty_slots = array("", "no_helmet", "no_necklace", "no_backpack", "no_armor", "no_handleft", "no_handright", "no_legs", "no_boots", "no_ring", "no_ammo"); + for($i = 0; $i <= 10; $i++) + { + if(!isset($equipment[$i]) || $equipment[$i] == 0) + $equipment[$i] = $empty_slots[$i]; + } + + for($i = 1; $i < 11; $i++) + { + if(check_number($equipment[$i])) + $equipment[$i] = getItemImage($equipment[$i]); + else + $equipment[$i] = ' ' . $equipment[$i] . ''; + } + + $skulls = array( + 1 => 'yellow_skull', + 2 => 'green_skull', + 3 => 'white_skull', + 4 => 'red_skull', + 5 => 'black_skull' + ); } - if($player->getCustomField('hidden') != 1) + $dead_add_content = ''; + if(tableExist('killers')) { + $player_deaths = $db->query('SELECT `id`, `date`, `level` FROM `player_deaths` WHERE `player_id` = '.$player->getId().' ORDER BY `date` DESC LIMIT 0,10;'); + if(count($player_deaths)) { - $rows = 0; - echo '

- - - - '; - - $realName = $account->getCustomField('rlname'); - if(!empty($realName)) + $dead_add_content = '
Account Information
'; + + $number_of_rows = 0; + foreach($player_deaths as $death) { - echo ' - - - - '; - } - - $group = $player->getGroup(); - if($group->isLoaded() && $group->getId() != 1) - { - echo - ' - - - '; - } - - $realLocation = $account->getCustomField('location'); - if(isset($realLocation[0])) - { - echo - ' - - - '; - } - - echo - ' - '; - $bannedUntil = ''; - $banned = array(); - if(tableExist('account_bans')) - $banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = '.$account->getId().' and `expires_at` > ' . time()); - else if(tableExist('bans')) { - if(fieldExist('expires', 'bans')) - $banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = '.$account->getId().' or `value` = '.$player->getId().') and `active` = 1 and `type` != 2 and `type` != 4 and `expires` > ' . time()); - else - $banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = '.$account->getId().' or `player` = '.$player->getId().') and `type` != 2 and `type` != 4 and `time` > ' . time()); - } - foreach($banned as $ban) + $dead_add_content .= ' + + - -
Character Deaths
Real name:'.$realName.'
Position:' . ucfirst($group->getName()) . '
Location:'.$realLocation.'
Created:
'.date("j M Y, H:i", $death['date']).' '; + $killers = $db->query("SELECT environment_killers.name AS monster_name, players.name AS player_name, players.deleted AS player_exists FROM killers LEFT JOIN environment_killers ON killers.id = environment_killers.kill_id +LEFT JOIN player_killers ON killers.id = player_killers.kill_id LEFT JOIN players ON players.id = player_killers.player_id +WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, killers.id ASC")->fetchAll(); + + $i = 0; + $count = count($killers); + foreach($killers as $killer) + { + $i++; + if($killer['player_name'] != "") { - $bannedUntil = ' [Banished '.($ban['expires'] == "-1" ? 'forever' : 'until '.date("d F Y, h:s", $ban['expires'])).']'; + if($i == 1) + $dead_add_content .= "Killed at level ".$death['level'].""; + else if($i == $count) + $dead_add_content .= " and"; + else + $dead_add_content .= ","; + + $dead_add_content .= " by "; + if($killer['monster_name'] != "") + $dead_add_content .= $killer['monster_name']." summoned by "; + + if($killer['player_exists'] == 0) + $dead_add_content .= getPlayerLink($killer['player_name']); + else + $dead_add_content .= $killer['player_name']; } - echo ''.date("j F Y, g:i a", $account->getCustomField("created")).$bannedUntil.'
'; - - echo '

- - - - - - - - - - '; - + else + { + if($i == 1) + $dead_add_content .= "Died at level ".$death['level'].""; + else if($i == $count) + $dead_add_content .= " and"; + else + $dead_add_content .= ","; + + $dead_add_content .= " by ".$killer['monster_name']; + } + } + + $dead_add_content .= "."; + } + + if($number_of_rows > 0) + $dead_add_content += '
Characters
NameLevelStatus 
'; + else + $dead_add_content = ''; + } + } + else { + $mostdamage = ''; + if(fieldExist('mostdamage_by', 'player_deaths')) + $mostdamage = ', `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`'; + $deaths_db = $db->query('SELECT + `player_id`, `time`, `level`, `killed_by`, `is_player`' . $mostdamage . ' + FROM `player_deaths` + WHERE `player_id` = ' . $player->getId() . ' ORDER BY `time` DESC LIMIT 10;'); + + if(count($deaths_db)) + { + $dead_add_content = '
'; + + $number_of_rows = 0; + foreach($deaths_db as $death) + { + $dead_add_content .= ' + + "; + } + + if($number_of_rows > 0) + $dead_add_content += '
Character Deaths
'.date("j M Y, H:i", $death['time']).' '; + + $lasthit = ($death['is_player']) ? getPlayerLink($death['killed_by']) : $death['killed_by']; + $dead_add_content .= 'Killed at level ' . $death['level'] . ' by ' . $lasthit; + if($death['unjustified']) { + $dead_add_content .= " (unjustified)"; + } + + $mostdmg = ($death['mostdamage_by'] !== $death['killed_by']) ? true : false; + if($mostdmg) + { + $mostdmg = ($death['mostdamage_is_player']) ? getPlayerLink($death['mostdamage_by']) : $death['mostdamage_by']; + $dead_add_content .= ' and by ' . $mostdmg; + + if ($death['mostdamage_unjustified']) { + $dead_add_content .= " (unjustified)"; + } + } + else { + $dead_add_content .= " (soloed)"; + } + + $dead_add_content .= ".
'; + else + $dead_add_content = ''; + } + } + + $frag_add_content = ''; + if($config['characters']['frags']) + { + //frags list by Xampy + $i = 0; + $frags_limit = 10; // frags limit to show? // default: 10 + $player_frags = $db->query('SELECT `player_deaths`.*, `players`.`name`, `killers`.`unjustified` FROM `player_deaths` LEFT JOIN `killers` ON `killers`.`death_id` = `player_deaths`.`id` LEFT JOIN `player_killers` ON `player_killers`.`kill_id` = `killers`.`id` LEFT JOIN `players` ON `players`.`id` = `player_deaths`.`player_id` WHERE `player_killers`.`player_id` = '.$player->getId().' ORDER BY `date` DESC LIMIT 0,'.$frags_limit.';'); + if(count($player_frags)) + { + $frags = 0; + $frag_add_content .= '
'; + foreach($player_frags as $frag) + { + $frags++; + $frag_add_content .= ' + + "; + } + + if($frags > 0) + $frag_add_content += '
Victims
' . date("j M Y, H:i", $frag['date']) . 'Fragged ' . $frag[name] . ' at level ' . $frag[level]; + + $frag_add_content .= ". (".(($frag['unjustified'] == 0) ? "Justified" : "Unjustified").")
'; + else + $frag_add_content = ''; + } + } + + // signature + if($config['signature_enabled']) { + $signature_url = BASE_URL . 'tools/signature/?name=' . urlencode($player->getName()); + if($config['friendly_urls']) + $signature_url = BASE_URL . urlencode($player->getName()) . '.png'; + } + + $hidden = $player->getCustomField('hidden'); + if($hidden != 1) { + // check if account has been banned + $bannedUntil = ''; + $banned = array(); + if (tableExist('account_bans')) + $banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = ' . $account->getId() . ' and `expires_at` > ' . time()); + else if (tableExist('bans')) { + if (fieldExist('expires', 'bans')) + $banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = ' . $account->getId() . ' or `value` = ' . $player->getId() . ') and `active` = 1 and `type` != 2 and `type` != 4 and `expires` > ' . time()); + else + $banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = ' . $account->getId() . ' or `player` = ' . $player->getId() . ') and `type` != 2 and `type` != 4 and `time` > ' . time()); + } + foreach ($banned as $ban) { + $bannedUntil = ' [Banished ' . ($ban['expires'] == "-1" ? 'forever' : 'until ' . date("d F Y, h:s", $ban['expires'])) . ']'; + } + $account_players = $account->getPlayersList(); $account_players->orderBy('name'); - $player_number = 0; - foreach($account_players as $player_list) - { - $player_list_status = ''; - if($player_list->isHidden()) - continue; - - $player_number++; - if($player_list->isOnline()) - $player_list_status = 'Online'; - - echo '
'.$player_number.'. '.$player_list->getName(); - echo ($player_list->isDeleted()) ? ' [DELETED]' : ''; - echo ''.$player_list->getLevel().' '.$config['vocations'][$player_list->getVocation()].'' . $player_list_status . '
'; - } - echo '

' . generate_search_table(); - echo ''; + } + + echo $twig->render('characters.html', array( + 'outfit' => $outfit, + 'player' => $player, + 'account' => $account, + 'config' => $config, + 'flag' => $flag, + 'oldName' => $oldName, + 'sex' => $player_sex, + 'marriage_enabled' => $config['characters']['marriage_info'] && fieldExist('marriage', 'players'), + 'marital_status' => $marital_status, + 'vocation' => $config['vocations'][$player->getVocation()], + 'frags_enabled' => $frags_enabled, + 'frags_count' => $frags_count, + 'town' => isset($config['towns'][$player->getTownId()]) ? $config['towns'][$player->getTownId()] : null, + 'house' => array( + 'found' => isset($house['id']), + 'add' => isset($house['id']) ? $add : null, + 'name' => isset($house['id']) ? (isset($house['name']) ? $house['name'] : $house['id']) : null, + 'town' => isset($house['town']) ? ' (' . $config['towns'][$house['town']] . ')' : '' + ), + 'guild' => array( + 'rank' => isset($guild_name) ? $rank_of_player->getName() : null, + 'link' => isset($guild_name) ? getGuildLink($guild_name) : null + ), + 'comment' => !empty($comment) ? wordwrap(nl2br($comment), 60, "
", true) : null, + 'skills' => isset($skills) ? $skills : null, + 'quests_enabled' => $quests_enabled, + 'quests' => isset($quests) ? $quests : null, + 'equipment' => isset($equipment) ? $equipment : null, + 'skull' => $player->getSkullTime() > 0 && ($player->getSkull() == 4 || $player->getSkull() == 5) ? $skulls[$player->getSkull()] : null, + 'deaths' => $dead_add_content, + 'frags' => $frag_add_content, + 'signature_url' => isset($signature_url) ? $signature_url : null, + 'player_link' => getPlayerLink($player->getName(), false), + 'hidden' => $hidden, + 'bannedUntil' => isset($bannedUntil) ? $bannedUntil : null, + 'characters_link' => internalLayoutLink('characters'), + 'account_players' => isset($account_players) ? $account_players : null, + 'search_form' => generate_search_form() + )); } else { @@ -702,7 +464,7 @@ else echo ''; } - echo generate_search_table(true); + echo generate_search_form(true); } if(!empty($search_errors)) diff --git a/system/pages/news.php b/system/pages/news.php index 97133b51..6fa7cd95 100644 --- a/system/pages/news.php +++ b/system/pages/news.php @@ -32,26 +32,40 @@ if(isset($_GET['archive'])) if($_REQUEST['id'] < 100000) $field_name = 'id'; - $news = $db->query('SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'news').' WHERE type = 1 AND hidden != 1 and `' . $field_name . '` = ' . (int)$_REQUEST['id'] . ''); + $news = $db->query('SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'news').' WHERE `type` = 1 AND `hidden` != 1 AND `' . $field_name . '` = ' . (int)$_REQUEST['id'] . ''); if($news->rowCount() == 1) { - if(@file_exists($template_path . '/news.php')) - require($template_path . '/news.php'); - else - require(SYSTEM . 'templates/news.php'); - $news = $news->fetch(); $author = ''; - $query = $db->query('SELECT name FROM players WHERE id = ' . $db->quote($news['player_id'] . ' LIMIT 1')); + $query = $db->query('SELECT `name` FROM `players` WHERE id = ' . $db->quote($news['player_id'] . ' LIMIT 1;')); if($query->rowCount() > 0) { $query = $query->fetch(); $author = $query['name']; } - - echo news_parse($news['title'], $news['body'], $news['date'], $categories[$news['category']]['icon_id'], $config['news_author'] ? $author : '', $news['comments'] != 0 ? getForumThreadLink($news['comments']) : NULL); + + $content = $news['body']; + $firstLetter = ''; + if($content[0] != '<') + { + $tmp = $template_path.'/images/letters/' . $content[0] . '.gif'; + if(file_exists($tmp)) { + $firstLetter = '' . $content[0] . ''; + $content = $firstLetter . substr($content, 1); + } + } + + echo $twig->render('news.html', array( + 'title' => stripslashes($news['title']), + 'content' => $content, + 'date' => $news['date'], + 'icon' => $categories[$news['category']]['icon_id'], + 'author' => $config['news_author'] ? $author : '', + 'comments' => $news['comments'] != 0 ? getForumThreadLink($news['comments']) : null, + 'news_date_format' => $config['news_date_format'] + )); } else - echo 'This news doesn\'t exist or is hidden.
'; + echo "This news doesn't exist or is hidden.
"; //echo '
Back to Archive'; ?> @@ -257,12 +271,6 @@ if(isset($tickers_to_add[0])) if(!$news_cached) { ob_start(); - // newses - if(@file_exists($template_path . '/news.php')) - require($template_path . '/news.php'); - else - require(SYSTEM . 'templates/news.php'); - if($canEdit) { ?> @@ -427,7 +435,7 @@ if(!$news_cached) foreach($newses as $news) { $author = ''; - $query = $db->query('SELECT name FROM players WHERE id = ' . $db->quote($news['player_id'] . ' LIMIT 1')); + $query = $db->query('SELECT `name` FROM `players` WHERE id = ' . $db->quote($news['player_id'] . ' LIMIT 1')); if($query->rowCount() > 0) { $query = $query->fetch(); $author = $query['name']; @@ -447,8 +455,27 @@ if(!$news_cached) ' . ($news['hidden'] != 1 ? 'Hide' : 'Show') . ' '; } - - echo news_parse($news['title'], $news['body'] . $admin_options, $news['date'], $categories[$news['category']]['icon_id'], $config['news_author'] ? $author : '', $news['comments'] != 0 ? getForumThreadLink($news['comments']) : NULL); + + $content = $news['body']; + $firstLetter = ''; + if($content[0] != '<') + { + $tmp = $template_path.'/images/letters/' . $content[0] . '.gif'; + if(file_exists($tmp)) { + $firstLetter = '' . $content[0] . ''; + $content = $firstLetter . substr($content, 1); + } + } + + echo $twig->render('news.html', array( + 'title' => stripslashes($news['title']), + 'content' => $content . $admin_options, + 'date' => $news['date'], + 'icon' => $categories[$news['category']]['icon_id'], + 'author' => $config['news_author'] ? $author : '', + 'comments' => $news['comments'] != 0 ? getForumThreadLink($news['comments']) : null, + 'news_date_format' => $config['news_date_format'] + )); } } @@ -564,7 +591,7 @@ class Forum { global $db; $thread_id = 0; - if($db->insert(TABLE_PREFIX . 'forum', array('id' => 'null', 'first_post' => 0, 'last_post' => time(), 'section' => $section_id, 'replies' => 0, 'views' => 0, 'author_aid' => isset($account_id) ? $account_id : 0, 'author_guid' => isset($player_id) ? $player_id : 0, 'post_text' => $body, 'post_topic' => $title, 'post_smile' => 0, 'post_date' => time(), 'last_edit_aid' => 0, 'edit_date' => 0, 'post_ip' => $_SERVER['REMOTE_ADDR']))) { + if($db->insert(TABLE_PREFIX . 'forum', array('first_post' => 0, 'last_post' => time(), 'section' => $section_id, 'replies' => 0, 'views' => 0, 'author_aid' => isset($account_id) ? $account_id : 0, 'author_guid' => isset($player_id) ? $player_id : 0, 'post_text' => $body, 'post_topic' => $title, 'post_smile' => 0, 'post_date' => time(), 'last_edit_aid' => 0, 'edit_date' => 0, 'post_ip' => $_SERVER['REMOTE_ADDR']))) { $thread_id = $db->lastInsertId(); $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id); } diff --git a/system/templates/account.change_info.html b/system/templates/account.change_info.html index b8470f6f..af9511f4 100644 --- a/system/templates/account.change_info.html +++ b/system/templates/account.change_info.html @@ -66,18 +66,39 @@ Here you can tell other players about yourself. This information will be display {% endif %} -
+ + + + + +
-
-
- -
-
-
-
-
- -
-
-
-
\ No newline at end of file + + + + + + +
+ +
+
+
+
+ + + + + + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/system/templates/characters.html b/system/templates/characters.html new file mode 100644 index 00000000..328338e2 --- /dev/null +++ b/system/templates/characters.html @@ -0,0 +1,351 @@ +{% set rows = 0 %} + + + + + +
+ + {% if config.characters.outfit %} +
+ {% endif %} + + + + + + {% set rows = rows + 1 %} + + + + + + {% set rows = rows + 1 %} + + + + + + {% if marriage_enabled %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% set rows = rows + 1 %} + + + + + + {% if config.characters.level %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% if config.characters.experience %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% if config.characters.magic_level %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% if frags_enabled %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% set rows = rows + 1 %} + + + + + + {% if config.characters.balance %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% if house.found %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% if guild.rank is not null %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% set rows = rows + 1 %} + + + + + + {% if config.characters.creation_date %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% if comment is not null %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% set rows = rows + 1 %} + + + + +
Character Information
Name:{{ flag|raw }} {{ player.getName() }}{{ oldName }}
Sex:{{ sex }}
Marital status:{{ marital_status }}
Profession:{{ vocation }}
Level:{{ player.getLevel() }}
Experience:{{ player.getExperience() }}
Magic Level:{{ player.getMagLevel() }}
Frags:{{ frags_count }}
Residence:{{ town }}
Balance:{{ player.getBalance() }} Gold Coins.
House: + + + + + +
{{ house.name ~ house.town ~ house.add }} +
+ + +
+
+
Guild membership:{{ guild.rank }} of the {{ guild.link|raw }}
Last login:{% if player.getLastLogin() == 0 %}Never logged in.{% else %}{{ player.getLastLogin()|date("M d Y, H:i:s") }} CEST{% endif %}
Created:{{ player.getCreated()|date("M d Y, H:i:s") }} CEST
Comment:{{ comment|raw }}
Account Status:{% if account.isPremium() %}Premium Account{% else %}Free Account{% endif %}
+
+ + + {% if config.characters.skills %} + + {% endif %} + + {% if quests_enabled %} + + {% endif %} + + {% if config.characters.equipment %} + + {% endif %} + +
+ + + + + {% set i = 0 %} + {% for skill in skills %} + {% set i = i + 1 %} + + + + + {% endfor %} +
Skills
{{ skill.name }}{{ skill.value }}
+
+ + + + + {% set i = 0 %} + {% for name, done in quests %} + {% set i = i + 1 %} + + + + + {% endfor %} +
Quests
{{ name }}
+
+ + + + + + + +
Equipment
+ + + + + + +
+ + + +
{{ equipment[2]|raw }}
{{ equipment[6]|raw }}
{{ equipment[9]|raw }}
{% if skull is not null %}{% endif %}
+
+ + +
{{ equipment[1]|raw }}
{{ equipment[4]|raw }}
{{ equipment[7]|raw }}
{{ equipment[8]|raw }}
+
+ + +
{{ equipment[3]|raw }}
{{ equipment[5]|raw }}
{{ equipment[10]|raw }}
+
+
+
+ + {{ deaths|raw }} + {{ frags|raw }} + + {% if config.signature_enabled %} + +
+ + +
Signature
+ Signature for player {{ player.getName() }} +
+ Show links +
+ + + + + + + + + + + + + + +
+ {% endif %} + + {% if hidden != 1 %} + {% set rows = 0 %} +

+ + + + + + {% set realName = account.getCustomField('rlname') %} + {% if realName is not empty %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% set group = player.getGroup() %} + {% if group.isLoaded() and group.getId() != 1 %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% set realLocation = account.getCustomField('location') %} + {% if realLocation is not empty %} + {% set rows = rows + 1 %} + + + + + {% endif %} + + {% set rows = rows + 1 %} + + + + +
Account Information
Real name:{{ realName }}
Position:{{ group.getName()|capitalize }}
Location:{{ realLocation }}
Created:{{ account.getCustomField("created")|date("j F Y, g:i a") ~bannedUntil }}
+

+ + + + + + + + + + + {% set i = 0 %} + {% for player in account_players %} + {% if not player.isHidden() %} + {% set i = i + 1 %} + + + {% set vocation = 'Unknown' %} + {% if config.vocations[player.getVocation()] is defined %} + {% set vocation = config.vocations[player.getVocation()] %} + {% endif %} + + + + + + {% endif %} + {% endfor %} +
Characters
NameLevelStatus 
+ {{ i }}. {{ player.getName() }}{% if player.isDeleted() %} [DELETED]{% endif %} + {{ player.getLevel() }} {{ vocation }}{% if player.isOnline() %}Online{% endif %} + + + + + + +
+ + +
+
+ {% endif %} +
+ +
+

{{ search_form|raw }} \ No newline at end of file diff --git a/system/templates/news.html b/system/templates/news.html new file mode 100644 index 00000000..6b085717 --- /dev/null +++ b/system/templates/news.html @@ -0,0 +1,23 @@ +
+
+ +
{{ date|date(news_date_format) }} -
+
{{ title }}
+ {% if author is not empty %} +
Author: {{ author }}
+ {% endif %} +
+
+ + + + + {% if comments is not null %} + + + + {% endif %} +
{{ content|raw }}
+ +
+
\ No newline at end of file diff --git a/system/templates/news.php b/system/templates/news.php deleted file mode 100644 index 8dfff9eb..00000000 --- a/system/templates/news.php +++ /dev/null @@ -1,34 +0,0 @@ -'; - //$content[0] = ''; - //} - - return ' -
-
- -
' . date($config['news_date_format'], $date) . ' -
-
' . stripslashes($title) . '
- ' . (isset($author[0]) ? ' -
Author: ' . $author . '
' : '') . ' -
-
- - - - ' - . (isset($comments[0]) ? ' - - - ' : '') . - '
' . $content . '
- -

'; -} -?> \ No newline at end of file diff --git a/templates/kathrine/news.php b/templates/kathrine/news.php deleted file mode 100644 index 995f8655..00000000 --- a/templates/kathrine/news.php +++ /dev/null @@ -1,42 +0,0 @@ -'; - $content = substr($content, 1); - } - } - - return ' -
-
-
- -
' . date("j.n.Y", $date) . ' -
-
' . stripslashes($title) . '
- ' . (isset($author[0]) ? ' -
Author: ' . $author . '
' : '') . ' -
-
-
- - - - ' - . (isset($comments[0]) ? ' - - - ' : '') . - '
' . $firstLetter.$content . '
- -

'; -} -?> diff --git a/templates/kathrine/templates/news.html b/templates/kathrine/templates/news.html new file mode 100644 index 00000000..6672e322 --- /dev/null +++ b/templates/kathrine/templates/news.html @@ -0,0 +1,25 @@ +
+
+
+ +
{{ date|date(news_date_format) }} -
+
{{ title }}
+ {% if author is not empty %} +
Author: {{ author }}
+ {% endif %} +
+
+
+ + + + + {% if comments is not null %} + + + + {% endif %} +
{{ content|raw }}
+ +
+
\ No newline at end of file diff --git a/templates/tibiacom/news.php b/templates/tibiacom/news.php deleted file mode 100644 index 9870a5c8..00000000 --- a/templates/tibiacom/news.php +++ /dev/null @@ -1,39 +0,0 @@ -'; - $content = substr($content, 1); - } - } - - return ' -
-
- -
' . date("j.n.Y", $date) . ' -
-
' . stripslashes($title) . '
- ' . (isset($author[0]) ? ' -
Author: ' . $author . '
' : '') . ' -
-
- - - - ' - . (isset($comments[0]) ? ' - - - ' : '') . - '
' . (isset($firstLetter) ? $firstLetter : '').$content . '
- -

'; -} -?> diff --git a/tools/signature/gesior.php b/tools/signature/gesior.php index 095c9c9d..c029f591 100644 --- a/tools/signature/gesior.php +++ b/tools/signature/gesior.php @@ -1,52 +1,32 @@ 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'); ?> \ No newline at end of file diff --git a/tools/signature/index.php b/tools/signature/index.php index 68f50aa9..4facd40b 100644 --- a/tools/signature/index.php +++ b/tools/signature/index.php @@ -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); ?> diff --git a/tools/signature/mango.php b/tools/signature/mango.php index b69b818f..f84511e7 100644 --- a/tools/signature/mango.php +++ b/tools/signature/mango.php @@ -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' ); } +?> diff --git a/tools/signature/tibian.php b/tools/signature/tibian.php index fbb80273..4356f7ca 100644 --- a/tools/signature/tibian.php +++ b/tools/signature/tibian.php @@ -1,160 +1,133 @@ 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' ); ?>