Skip to content

Commit

Permalink
some fixed and new features
Browse files Browse the repository at this point in the history
* added outfit shower, in characters, online, and highscores
* updated database to version 2
* fixed item images (now using item-images.ots.me host by default)
* fixed news ticket and posting long newses
(https://otland.net/threads/myaac-v0-0-1.251454/page-5#post-2442026)
* news body limit increased to 65535 (mysql text field)
* removed some unused code from my old server
* added spells & monsters to kathrine template
  • Loading branch information
slawkens committed May 13, 2017
1 parent 1a7dbec commit 449ce31
Show file tree
Hide file tree
Showing 17 changed files with 156 additions and 186 deletions.
2 changes: 1 addition & 1 deletion common.php
Expand Up @@ -28,7 +28,7 @@

define('MYAAC', true);
define('MYAAC_VERSION', '0.1.3');
define('DATABASE_VERSION', 1);
define('DATABASE_VERSION', 2);
define('TABLE_PREFIX', 'myaac_');
define('START_TIME', microtime(true));
define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : 'LINUX');
Expand Down
10 changes: 8 additions & 2 deletions config.php
Expand Up @@ -75,6 +75,10 @@
//'2' => 'Your Second World Name'
),

// items
'outfit_images_url' => 'http://outfit-images.ots.me/outfit.php', // set to animoutfit.php for animated outfit
'item_images_url' => 'http://item-images.ots.me/960/', // set to images/items if you host your own items in images folder

// account
'account_management' => true, // disable if you're using other method to manage users (fe. tfs account manager)
'account_mail_verify' => false, // force users to confirm their email addresses when registering account
Expand All @@ -86,6 +90,7 @@
'account_country' => true, // user will be able to set country of origin when registering account, this information will be viewable in others places aswell
'account_change_character_name' => false, // can user change their character name for premium points?
'account_change_character_name_points' => 30, // cost of name change
'characters_per_account' => 10, // max. number of characters per account

// mail
'mail_enabled' => false, // is aac maker configured to send e-mails?
Expand Down Expand Up @@ -133,8 +138,6 @@
1 => 'Sample town'
),

'characters_per_account' => 10, // max. number of characters per account

// guilds
'guild_management' => true, // enable guild management system on the site?
'guild_need_level' => 1, // min. level to form a guild
Expand All @@ -155,6 +158,7 @@
'online_vocations' => false, // display vocation statistics?
'online_vocations_images' => false, // display vocation images?
'online_skulls' => false, // display skull images
'online_outfit' => true,
'online_afk' => false,

// support list page
Expand All @@ -171,6 +175,7 @@
'highscores_vocation_box' => true, // show 'Choose a vocation' box on the highscores (allowing peoples to sort highscores by vocation)?
'highscores_vocation' => true, // show player vocation under his nickname?
'highscores_frags' => false, // show 'Frags' tab (best fraggers on the server)? Only 0.3
'highscores_outfit' => true, // show player outfit?
'highscores_country_box' => false, // doesnt work yet! (not implemented)
'highscores_groups_hidden' => 4, // this group id and higher won't be shown on the highscores

Expand All @@ -181,6 +186,7 @@
'magic_level' => false,
'balance' => false,
'marriage_info' => true, // only 0.3
'outfit' => true,
'creation_date' => true,
'quests' => true,
'skills' => true,
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
8 changes: 4 additions & 4 deletions index.php
Expand Up @@ -217,10 +217,10 @@ function error_handler($errno, $errstr) {
}

ob_start();
$hooks->trigger(HOOK_BEFORE_PAGE);

if(!$ignore)
require($file);
if($hooks->trigger(HOOK_BEFORE_PAGE)) {
if(!$ignore)
require($file);
}

if($config['backward_support'] && isset($main_content[0]))
$content .= $main_content;
Expand Down
4 changes: 2 additions & 2 deletions install/includes/schema.sql
Expand Up @@ -146,8 +146,8 @@ CREATE TABLE `myaac_movies`
CREATE TABLE `myaac_news`
(
`id` INT(11) NOT NULL AUTO_INCREMENT,
`title` VARCHAR(50) NOT NULL,
`body` VARCHAR(10000) NOT NULL,
`title` VARCHAR(100) NOT NULL,
`body` TEXT NOT NULL,
`type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - news, 2 - ticket, 3 - article',
`date` INT(11) NOT NULL DEFAULT 0,
`category` TINYINT(1) NOT NULL DEFAULT 0,
Expand Down
2 changes: 1 addition & 1 deletion system/functions.php
Expand Up @@ -148,7 +148,7 @@ function getItemImage($id, $count = 1)
$file_name .= '-' . $count;

global $config;
return '<img src="images/items/' . $file_name . '.gif" width="32" height="32" border="0" alt=" ' .$id . '" />';
return '<img src="' . $config['item_images_url'] . $file_name . '.gif" width="32" height="32" border="0" alt=" ' .$id . '" />';
}

function getFlagImage($country)
Expand Down
2 changes: 1 addition & 1 deletion system/hooks.php
Expand Up @@ -51,7 +51,7 @@ public function execute($params)
require(BASE . $this->_file);
}

return false;
return true;
}

public function name() {return $this->_name;}
Expand Down
3 changes: 3 additions & 0 deletions system/libs/pot/OTS_Account.php
Expand Up @@ -916,6 +916,9 @@ public function logAction($action)
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']))
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];

if($ip == NULL)
$ip = '0';

return $this->db->query('INSERT INTO ' . $this->db->tableName(TABLE_PREFIX . 'account_actions') . ' (' . $this->db->fieldName('account_id') . ', ' . $this->db->fieldName('ip') . ', ' . $this->db->fieldName('date') . ', ' . $this->db->fieldName('action') . ') VALUES (' . $this->db->quote($this->getId()).', INET_ATON(' . $this->db->quote($ip) . '), UNIX_TIMESTAMP(NOW()), ' . $this->db->quote($action).')');
}

Expand Down
6 changes: 6 additions & 0 deletions system/migrations/2.php
@@ -0,0 +1,6 @@
<?php
$db->query("ALTER TABLE `" . TABLE_PREFIX . "faq` MODIFY `answer` VARCHAR(1020) NOT NULL DEFAULT '';");
$db->query("ALTER TABLE `" . TABLE_PREFIX . "movies` MODIFY `title` VARCHAR(100) NOT NULL DEFAULT '';");
$db->query("ALTER TABLE `" . TABLE_PREFIX . "news` MODIFY `title` VARCHAR(100) NOT NULL DEFAULT '';");
$db->query("ALTER TABLE `" . TABLE_PREFIX . "news` MODIFY `body` TEXT NOT NULL DEFAULT '';");
?>
40 changes: 30 additions & 10 deletions system/pages/characters.php
Expand Up @@ -60,29 +60,46 @@ function generate_player_lookup($player)
$player_eq[$i] = $empty_slots[$i];
}

//for($i = 1; $i < 11; $i++)
//{
//if(!itemImageExists($player_eq[$i]))
// Items::generate($player_eq[$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] = '<img src="images/items/' . $player_eq[$i] . '.gif" width="32" height="32" border="0" alt=" ' . $player_eq[$i] . '" />';
}

$skulls = array(
1 => 'skull_yellow',
2 => 'skull_green',
3 => 'skull_white',
4 => 'skull_red',
5 => 'skull_black'
);

return '<table width="100" align="center" cellspacing="0" cellpadding="0" style="background: #808080; border:1px solid #808080;">
<tr>
<td>
<table cellspacing="0" style="background: #292929;">
<tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[2]).'</td></tr><tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[6]).'</td></tr><tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[9]).'</td></tr>
<tr height="11px"><td>'.($player->getSkull() > 0 ? '<img src="images/red_skull.gif">' : '').'</td></tr>
<tr><td style="border:1px solid #808080;">'.$player_eq[2].'</td></tr><tr><td style="border:1px solid #808080;">'.$player_eq[6].'</td></tr><tr><td style="border:1px solid #808080;">'.$player_eq[9].'</td></tr>
<tr height="11px"><td>'.($player->getSkullTime() > 0 && ($player->getSkull() == 4 || $player->getSkull() == 5) ? '<img src="images/' . $skulls[$player->getSkull()] . '.gif">' : '').'</td></tr>
</table>
</td>
<td>
<table cellspacing="0" style="background: #292929;">
<tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[1]).'</td></tr><tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[4]).'</td></tr><tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[7]).'</td></tr><tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[8]).'</td></tr>
<tr><td style="border:1px solid #808080;">'.$player_eq[1].'</td></tr><tr><td style="border:1px solid #808080;">'.$player_eq[4].'</td></tr><tr><td style="border:1px solid #808080;">'.$player_eq[7].'</td></tr><tr><td style="border:1px solid #808080;">'.$player_eq[8].'</td></tr>
</table>
</td>
<td>
<table cellspacing="0" style="background: #292929;">
<tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[3]).'</td></tr><tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[5]).'</td></tr><tr><td style="border:1px solid #808080;">'.getItemImage($player_eq[10]).'</td></tr>
<tr><td style="border:1px solid #808080;">'.$player_eq[3].'</td></tr><tr><td style="border:1px solid #808080;">'.$player_eq[5].'</td></tr><tr><td style="border:1px solid #808080;">'.$player_eq[10].'</td></tr>
</table>
</td>
</tr>
Expand Down Expand Up @@ -148,6 +165,9 @@ function retrieve_former_name($name)
<td><img src="<?php echo $template_path; ?>/images/general/blank.gif" width="10" height="1" border="0"></td>
<td>
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<?php if($config['characters']['outfit']): ?>
<div style="width:64px;height:64px;border:2px solid #F1E0C6; border-radius:50px; padding:13px; margin-top:38px;margin-left:376px;position:absolute;"><img style="margin-left:<?php echo (in_array($player->getLookType(), array(75, 266, 302)) ? '-0px;margin-top:-0px;width:64px;height:64px;' : '-60px;margin-top:-60px;width:128px;height:128px;'); ?>" src="<?php echo $config['outfit_images_url'] . '?id=' . $player->getLookType() . '&addons=' . $player->getLookAddons() . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet() . '"';?>></div>
<?php endif; ?>
<tr bgcolor="<?php echo $config['vdarkborder']; ?>">
<td colspan="2" class="white"><b>Character Information</b></td>
</tr>
Expand Down
26 changes: 18 additions & 8 deletions system/pages/highscores.php
Expand Up @@ -99,6 +99,10 @@
if(fieldExist('deletion', 'players'))
$deleted = 'deletion';

$outfit = '';
if($config['highscores_outfit'])
$outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons';

$offset = $_page * 100;
if($skill <= POT::SKILL_LAST) { // skills
if(fieldExist('skill_fist', 'players')) {// tfs 1.0
Expand All @@ -112,14 +116,14 @@
POT::SKILL_FISH => 'skill_fishing',
);

$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . ', ' . $skill_ids[$skill] . ' as value FROM accounts,players WHERE players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id > 6 AND accounts.id = players.account_id ORDER BY ' . $skill_ids[$skill] . ' DESC LIMIT 101 OFFSET '.$offset);
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . $outfit . ', ' . $skill_ids[$skill] . ' as value FROM accounts,players WHERE players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id > 6 AND accounts.id = players.account_id ORDER BY ' . $skill_ids[$skill] . ' DESC LIMIT 101 OFFSET '.$offset);
}
else
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',value,level,vocation' . $promotion . ' FROM accounts,players,player_skills WHERE players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id > 6 AND players.id = player_skills.player_id AND player_skills.skillid = '.$skill.' AND accounts.id = players.account_id ORDER BY value DESC, count DESC LIMIT 101 OFFSET '.$offset);
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',value,level,vocation' . $promotion . $outfit . ' FROM accounts,players,player_skills WHERE players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id > 6 AND players.id = player_skills.player_id AND player_skills.skillid = '.$skill.' AND accounts.id = players.account_id ORDER BY value DESC, count DESC LIMIT 101 OFFSET '.$offset);
}
else if($skill == 666 && $config['otserv_version'] == TFS_03) // frags
{
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . ',COUNT(`player_killers`.`player_id`) as value' .
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . $outfit . ',COUNT(`player_killers`.`player_id`) as value' .
' FROM `accounts`, `players`, `player_killers` ' .
' WHERE players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id = player_killers.player_id AND accounts.id = players.account_id' .
' GROUP BY `player_id`' .
Expand All @@ -129,10 +133,10 @@
else
{
if($skill == POT::SKILL__MAGLEVEL) {
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',maglevel,level,vocation' . $promotion . ' FROM accounts, players WHERE players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND players.id > 6 AND accounts.id = players.account_id ORDER BY maglevel DESC, manaspent DESC LIMIT 101 OFFSET '.$offset);
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',maglevel,level,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND players.id > 6 AND accounts.id = players.account_id ORDER BY maglevel DESC, manaspent DESC LIMIT 101 OFFSET '.$offset);
}
else { // level
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,experience,vocation' . $promotion . ' FROM accounts, players WHERE players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND players.id > 6 AND accounts.id = players.account_id ORDER BY level DESC, experience DESC LIMIT 101 OFFSET '.$offset);
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,experience,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND players.id > 6 AND accounts.id = players.account_id ORDER BY level DESC, experience DESC LIMIT 101 OFFSET '.$offset);
$list = 'experience';
}
}
Expand All @@ -150,6 +154,9 @@
<td width="11px" class="white">#</td>
<?php endif; ?>
<td width="10%" class="white"><b>Rank</b></td>
<?php if($config['highscores_outfit']): ?>
<td class="white"><b>Outfit</b></td>
<?php endif; ?>
<td width="75%" class="white"><b>Name</b></td>
<td width="15%" class="white"><b><?php echo ($skill != 666 ? 'Level' : 'Frags'); ?></b></td>
<?php if($skill == POT::SKILL__LEVEL): ?>
Expand Down Expand Up @@ -177,15 +184,18 @@
{
if($skill == POT::SKILL__MAGIC)
$player['value'] = $player['maglevel'];

if($skill == POT::SKILL__LEVEL)
else if($skill == POT::SKILL__LEVEL)
$player['value'] = $player['level'];
echo '
<tr bgcolor="' . getStyle($i) . '">';
if($config['account_country'])
echo '<td>' . getFlagImage($player['country']) . '</td>';
echo '
<td>' . ($offset + $i) . '.</td>
<td>' . ($offset + $i) . '.</td>';
if($config['highscores_outfit'])
echo '<td><img style="position:absolute;margin-top:-45px;margin-left:-25px;" src="' . $config['outfit_images_url'] . '?id=' . $player['looktype'] . '&addons=' . $player['lookaddons'] . '&head=' . $player['lookhead'] . '&body=' . $player['lookbody'] . '&legs=' . $player['looklegs'] . '&feet=' . $player['lookfeet'] . '" alt="" /></td>';

echo '
<td>
<a href="' . getPlayerLink($player['name'], false) . '">
<font color="' . ($player['online'] > 0 ? 'green' : 'red') . '">' . $player['name'] . '</font>
Expand Down
58 changes: 39 additions & 19 deletions system/pages/news.php
Expand Up @@ -98,7 +98,8 @@
define('TICKET', 2);
define('ARTICLE', 3);

define('BODY_LIMIT', 10000); // maximum news body length
define('TITLE_LIMIT', 100);
define('BODY_LIMIT', 65535); // maximum news body length

$canEdit = hasFlag(FLAG_CONTENT_NEWS) || superAdmin();
if($canEdit)
Expand Down Expand Up @@ -143,9 +144,10 @@
$player_id = $news['player_id'];
}
else {
News::update($id, $p_title, $body, $type, $category, $player_id, $comments);
$action = $p_title = $body = $comments = '';
$type = $category = $player_id = 0;
if(News::update($id, $p_title, $body, $type, $category, $player_id, $comments, $errors)) {
$action = $p_title = $body = $comments = '';
$type = $category = $player_id = 0;
}
}
}
else if($action == 'hide') {
Expand Down Expand Up @@ -214,7 +216,7 @@
<span class="NewsTickerDate">'.date("j M Y", $news['date']).' -</span>
<div id="TickerEntry-'.$rows.'-ShortText" class="NewsTickerShortText">';
//if admin show button to delete (hide) ticker
$tickers_to_add .= short_text($news['body'], 60).'</div>
$tickers_to_add .= short_text(strip_tags($news['body']), 100).'</div>
<div id="TickerEntry-'.$rows.'-FullText" class="NewsTickerFullText">';
//if admin show button to delete (hide) ticker
$tickers_to_add .= $news['body'] . $admin_options . '</div>
Expand Down Expand Up @@ -300,7 +302,7 @@

<tr bgcolor="<?php echo getStyle($rows++); ?>">
<td><b>Title:</b></td>
<td><input name="title" value="<?php echo (isset($p_title) ? $p_title : ''); ?>" size="50" maxlength="50"/></td>
<td><input name="title" value="<?php echo (isset($p_title) ? $p_title : ''); ?>" size="50" maxlength="100"/></td>
</tr>

<tr bgcolor="<?php echo getStyle($rows++); ?>">
Expand Down Expand Up @@ -456,38 +458,56 @@
if($cache->enabled() && !$canEdit)
$cache->set('news_' . $template_name . '_' . NEWS, $tmp_content, 120);

echo $tmp_content;
echo $tmp_content;
}
else
echo $news_cached;

class News
{
static public function add($title, $body, $type, $category, $player_id, $comments, &$errors)
static public function verify($title, $body, &$errors)
{
global $db;
if(strlen($body) <= BODY_LIMIT)
{
if(isset($title[0]) && isset($body[0])) {
$db->insert(TABLE_PREFIX . 'news', array('title' => $title, 'body' => $body, 'type' => $type, 'date' => time(), 'category' => $category, 'player_id' => isset($player_id) ? $player_id : 0, 'comments' => $comments));
}
else
$errors[] = 'Please fill all inputs.';
if(!isset($title[0]) || !isset($body[0])) {
$errors[] = 'Please fill all inputs.';
return false;
}
else

if(strlen($title) > TITLE_LIMIT) {
$errors[] = 'News title cannot be longer than ' . TITLE_LIMIT . ' characters.';
return false;
}

if(strlen($body) > BODY_LIMIT) {
$errors[] = 'News content cannot be longer than ' . BODY_LIMIT . ' characters.';
return false;
}

return true;
}

return !count($errors);
static public function add($title, $body, $type, $category, $player_id, $comments, &$errors)
{
global $db;
if(!News::verify($title, $body, $errors))
return false;

$db->insert(TABLE_PREFIX . 'news', array('title' => $title, 'body' => $body, 'type' => $type, 'date' => time(), 'category' => $category, 'player_id' => isset($player_id) ? $player_id : 0, 'comments' => $comments));
return true;
}

static public function get($id) {
global $db;
return $db->select(TABLE_PREFIX . 'news', array('id' => $id));
}

static public function update($id, $title, $body, $type, $category, $player_id, $comments) {
static public function update($id, $title, $body, $type, $category, $player_id, $comments, &$errors)
{
global $db;
if(!News::verify($title, $body, $errors))
return false;

$db->update(TABLE_PREFIX . 'news', array('title' => $title, 'body' => $body, 'type' => $type, 'category' => $category, 'last_modified_by' => isset($player_id) ? $player_id : 0, 'last_modified_date' => time(), 'comments' => $comments), array('id' => $id));
return true;
}

static public function delete($id, &$errors)
Expand Down

0 comments on commit 449ce31

Please sign in to comment.