diff --git a/admin/template/template.php b/admin/template/template.php index 5a1d26ba..3bbb62f4 100644 --- a/admin/template/template.php +++ b/admin/template/template.php @@ -56,15 +56,16 @@ 'dashboard', + 'News' => 'news', 'Mailer' => 'mailer', 'Pages' => 'pages', 'Menus' => 'menus', diff --git a/system/pages/admin/dashboard.php b/system/pages/admin/dashboard.php index 10e8dbe8..ec86249e 100644 --- a/system/pages/admin/dashboard.php +++ b/system/pages/admin/dashboard.php @@ -62,18 +62,6 @@ $query = $db->query('SELECT count(*) as `how_much` FROM `houses`;'); $query = $query->fetch(); $total_houses = $query['how_much']; -if ($db->hasColumn('accounts', 'premium_points')) { - $points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;'); -} else { - $points = 0; -} - -if ($db->hasColumn('accounts', 'coins')) { - $coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;'); -} else { - $coins = 0; -} - $twig->display('admin.statistics.html.twig', array( 'total_accounts' => $total_accounts, 'total_players' => $total_players, @@ -86,9 +74,23 @@ $twig->display('admin.dashboard.html.twig', array( 'closed_message' => $closed_message, 'status' => $status, 'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'), - 'points' => $points, - 'coins' => $coins, + )); + +echo '
'; +$config['modules'] = "lastlogin,points,coins"; +if(isset($config['modules'])) + $config['modules'] = explode(",", $config['modules']); + +$twig_loader->prependPath(__DIR__ . '/modules/templates'); +foreach($config['modules'] as $box) { + $file = __DIR__ . '/modules/' . $box . '.php'; + if(file_exists($file)) { + include($file); + } +} +echo '
'; + function clearCache() { global $template_name; diff --git a/system/pages/admin/modules/coins.php b/system/pages/admin/modules/coins.php new file mode 100644 index 00000000..3dbc19c8 --- /dev/null +++ b/system/pages/admin/modules/coins.php @@ -0,0 +1,11 @@ +hasColumn('accounts', 'coins')) { + $coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;'); +} else { + $coins = 0; +} + +$twig->display('coins.html.twig', array( + 'coins' => $coins +)); \ No newline at end of file diff --git a/system/pages/admin/modules/lastlogin.php b/system/pages/admin/modules/lastlogin.php new file mode 100644 index 00000000..85a16ec7 --- /dev/null +++ b/system/pages/admin/modules/lastlogin.php @@ -0,0 +1,11 @@ +hasColumn('players', 'lastlogin')) { + $players = $db->query('SELECT ' . (USE_ACCOUNT_NAME ? 'name' : 'id') . ' as name, level,lastlogin FROM players ORDER BY lastlogin DESC LIMIT 10;'); +} else { + $players = 0; +} + +$twig->display('lastlogin.html.twig', array( + 'players' => $players, +)); \ No newline at end of file diff --git a/system/pages/admin/modules/points.php b/system/pages/admin/modules/points.php new file mode 100644 index 00000000..e5040f53 --- /dev/null +++ b/system/pages/admin/modules/points.php @@ -0,0 +1,10 @@ +hasColumn('accounts', 'premium_points')) { + $points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;'); +} else { + $points = 0; +} + +$twig->display('points.html.twig', array( + 'points' => $points, +)); \ No newline at end of file diff --git a/system/pages/admin/modules/templates/coins.html.twig b/system/pages/admin/modules/templates/coins.html.twig new file mode 100644 index 00000000..e5183443 --- /dev/null +++ b/system/pages/admin/modules/templates/coins.html.twig @@ -0,0 +1,29 @@ +{% if coins is iterable %} +
+
+
+

Top 10 - Most coins

+
+
+ + + + + + + + {% set i = 0 %} + {% for result in coins %} + {% set i = i + 1 %} + + + + + + {% endfor %} + +
#Account {{ account_type }}Tibia coins
{{ i }}{{ result.name }}{{ result.coins }}
+
+
+
+{% endif %} \ No newline at end of file diff --git a/system/pages/admin/modules/templates/lastlogin.html.twig b/system/pages/admin/modules/templates/lastlogin.html.twig new file mode 100644 index 00000000..62d6fbc5 --- /dev/null +++ b/system/pages/admin/modules/templates/lastlogin.html.twig @@ -0,0 +1,29 @@ +{% if players is iterable %} +
+
+
+

Last 10 Logins

+
+
+ + + + + + + + {% set i = 0 %} + {% for result in players %} + {% set i = i + 1 %} + + + + + + {% endfor %} + +
#PlayerLogin Date
{{ i }}{{ result.name }}{{ result.lastlogin|date("M d Y, H:i:s") }}
+
+
+
+{% endif %} \ No newline at end of file diff --git a/system/pages/admin/modules/templates/points.html.twig b/system/pages/admin/modules/templates/points.html.twig new file mode 100644 index 00000000..acdcd390 --- /dev/null +++ b/system/pages/admin/modules/templates/points.html.twig @@ -0,0 +1,29 @@ +{% if points is iterable %} +
+
+
+

Top 10 - Most premium points

+
+
+ + + + + + + + {% set i = 0 %} + {% for result in points %} + {% set i = i + 1 %} + + + + + + {% endfor %} + +
#Account {{ account_type }}Premium points
{{ i }}{{ result.name }}{{ result.premium_points }}
+
+
+
+{% endif %} \ No newline at end of file diff --git a/system/pages/admin/news.php b/system/pages/admin/news.php new file mode 100644 index 00000000..1a871ed5 --- /dev/null +++ b/system/pages/admin/news.php @@ -0,0 +1,242 @@ + + * @copyright 2017 MyAAC + * @link http://my-aac.org + */ +defined('MYAAC') or die('Direct access not allowed!'); +require_once LIBS . 'forum.php'; + +$title = 'News Panel'; + +if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) { + echo 'Access denied.'; + return; +} + +header('X-XSS-Protection:0'); + +// some constants, used mainly by database (cannot by modified without schema changes) +define('TITLE_LIMIT', 100); +define('BODY_LIMIT', 65535); // maximum news body length +define('ARTICLE_TEXT_LIMIT', 300); +define('ARTICLE_IMAGE_LIMIT', 100); + +$name = $p_title = ''; +if(!empty($action)) +{ + $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; + $p_title = isset($_REQUEST['title']) ? $_REQUEST['title'] : null; + $body = isset($_REQUEST['body']) ? stripslashes($_REQUEST['body']) : null; + $comments = isset($_REQUEST['comments']) ? $_REQUEST['comments'] : null; + $type = isset($_REQUEST['type']) ? (int)$_REQUEST['type'] : null; + $category = isset($_REQUEST['category']) ? (int)$_REQUEST['category'] : null; + $player_id = isset($_REQUEST['player_id']) ? (int)$_REQUEST['player_id'] : null; + $article_text = isset($_REQUEST['article_text']) ? $_REQUEST['article_text'] : null; + $article_image = isset($_REQUEST['article_image']) ? $_REQUEST['article_image'] : null; + $forum_section = isset($_REQUEST['forum_section']) ? $_REQUEST['forum_section'] : null; + $errors = array(); + + if($action == 'add') { + if(isset($forum_section) && $forum_section != '-1') { + $forum_add = Forum::add_thread($p_title, $body, $forum_section, $player_id, $account_logged->getId(), $errors); + } + + if(News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $article_text, $article_image, $errors)) { + $p_title = $body = $comments = $article_text = $article_image = ''; + $type = $category = $player_id = 0; + + success("Added successful."); + } + } + else if($action == 'delete') { + News::delete($id, $errors); + success("Deleted successful."); + } + else if($action == 'edit') + { + if(isset($id) && !isset($p_title)) { + $news = News::get($id); + $p_title = $news['title']; + $body = $news['body']; + $comments = $news['comments']; + $type = $news['type']; + $category = $news['category']; + $player_id = $news['player_id']; + $article_text = $news['article_text']; + $article_image = $news['article_image']; + } + else { + if(News::update($id, $p_title, $body, $type, $category, $player_id, $forum_section, $article_text, $article_image, $errors)) { + // update forum thread if exists + if(isset($forum_section) && Validator::number($forum_section)) { + $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $player_id.", `post_text` = ".$db->quote($body).", `post_topic` = ".$db->quote($p_title).", `edit_date` = " . time() . " WHERE `id` = " . $db->quote($forum_section)); + } + + $action = $p_title = $body = $comments = $article_text = $article_image = ''; + $type = $category = $player_id = 0; + + success("Updated successful."); + } + } + } + else if($action == 'hide') { + News::toggleHidden($id, $errors, $status); + success(($status == 1 ? 'Show' : 'Hide') . " successful."); + } + + if(!empty($errors)) + error(implode(", ", $errors)); +} + +$categories = array(); +foreach($db->query('SELECT `id`, `name`, `icon_id` FROM `' . TABLE_PREFIX . 'news_categories` WHERE `hidden` != 1') as $cat) +{ + $categories[$cat['id']] = array( + 'name' => $cat['name'], + 'icon_id' => $cat['icon_id'] + ); +} + +if($action == 'edit' || $action == 'new') { + if($action == 'edit') { + $player = new OTS_Player(); + $player->load($player_id); + } + + $account_players = $account_logged->getPlayersList(); + $account_players->orderBy('group_id', POT::ORDER_DESC); + $twig->display('admin.news.form.html.twig', array( + 'action' => $action, + 'news_link' => getLink(PAGE), + 'news_link_form' => '?p=news&action=' . ($action == 'edit' ? 'edit' : 'add'), + 'news_id' => isset($id) ? $id : null, + 'title' => isset($p_title) ? $p_title : '', + 'body' => isset($body) ? htmlentities($body, ENT_COMPAT, 'UTF-8') : '', + 'type' => isset($type) ? $type : null, + 'player' => isset($player) && $player->isLoaded() ? $player : null, + 'player_id' => isset($player_id) ? $player_id : null, + 'account_players' => $account_players, + 'category' => isset($category) ? $category : 0, + 'categories' => $categories, + 'forum_boards' => getForumBoards(), + 'forum_section' => isset($forum_section) ? $forum_section : null, + 'comments' => isset($comments) ? $comments : null, + 'article_text' => isset($article_text) ? $article_text : null, + 'article_image' => isset($article_image) ? $article_image : null + )); +} + +$query = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news')); +$newses = array(); +foreach ($query as $_news) { + $_player = new OTS_Player(); + $_player->load($_news['player_id']); + + $newses[$_news['type']][] = array( + 'id' => $_news['id'], + 'hidden' => $_news['hidden'], + 'archive_link' => getLink('news') . '/archive/' . $_news['id'], + 'title' => $_news['title'], + 'date' => $_news['date'], + 'player_name' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '', + 'player_link' => isset($_player) && $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '', + ); +} + +$twig->display('admin.news.html.twig', array( + 'newses' => $newses +)); + +class News +{ + static public function verify($title, $body, $article_text, $article_image, &$errors) + { + if(!isset($title[0]) || !isset($body[0])) { + $errors[] = 'Please fill all inputs.'; + return false; + } + 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; + } + if(strlen($article_text) > ARTICLE_TEXT_LIMIT) { + $errors[] = 'Article text cannot be longer than ' . ARTICLE_TEXT_LIMIT . ' characters.'; + return false; + } + if(strlen($article_image) > ARTICLE_IMAGE_LIMIT) { + $errors[] = 'Article image cannot be longer than ' . ARTICLE_IMAGE_LIMIT . ' characters.'; + return false; + } + return true; + } + + static public function add($title, $body, $type, $category, $player_id, $comments, $article_text, $article_image, &$errors) + { + global $db; + if(!self::verify($title, $body, $article_text, $article_image, $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, 'article_text' => ($type == 3 ? $article_text : ''), 'article_image' => ($type == 3 ? $article_image : ''))); + 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, $article_text, $article_image, &$errors) + { + global $db; + if(!self::verify($title, $body, $article_text, $article_image, $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, 'article_text' => $article_text, 'article_image' => $article_image), array('id' => $id)); + return true; + } + + static public function delete($id, &$errors) + { + global $db; + if(isset($id)) + { + if($db->select(TABLE_PREFIX . 'news', array('id' => $id)) !== false) + $db->delete(TABLE_PREFIX . 'news', array('id' => $id)); + else + $errors[] = 'News with id ' . $id . ' does not exists.'; + } + else + $errors[] = 'News id not set.'; + + return !count($errors); + } + + static public function toggleHidden($id, &$errors, &$status) + { + global $db; + if(isset($id)) + { + $query = $db->select(TABLE_PREFIX . 'news', array('id' => $id)); + if($query !== false) + { + $db->update(TABLE_PREFIX . 'news', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id)); + $status = $query['hidden']; + } + else + $errors[] = 'News with id ' . $id . ' does not exists.'; + } + else + $errors[] = 'News id not set.'; + + return !count($errors); + } +} +?> \ No newline at end of file diff --git a/system/pages/admin/pages.php b/system/pages/admin/pages.php index 954faa68..cc200aa5 100644 --- a/system/pages/admin/pages.php +++ b/system/pages/admin/pages.php @@ -76,7 +76,7 @@ if (!empty($action)) { } if (!empty($errors)) - $twig->display('admin.error.html.twig', array('errors' => $errors)); + error(implode(", ", $errors)); } $query = diff --git a/system/pages/news.php b/system/pages/news.php index b461336c..dba75dfc 100644 --- a/system/pages/news.php +++ b/system/pages/news.php @@ -17,8 +17,7 @@ if(isset($_GET['archive'])) $title = 'News Archive'; $categories = array(); - foreach($db->query( - 'SELECT id, name, icon_id FROM ' . TABLE_PREFIX . 'news_categories WHERE hidden != 1') as $cat) + foreach($db->query('SELECT id, name, icon_id FROM ' . TABLE_PREFIX . 'news_categories WHERE hidden != 1') as $cat) { $categories[$cat['id']] = array( 'name' => $cat['name'], @@ -98,91 +97,16 @@ header('X-XSS-Protection: 0'); $title = 'Latest News'; $cache = Cache::getInstance(); +$canEdit = hasFlag(FLAG_CONTENT_NEWS) || superAdmin(); $news_cached = false; -// some constants, used mainly by database (cannot by modified without schema changes) -define('TITLE_LIMIT', 100); -define('BODY_LIMIT', 65535); // maximum news body length -define('ARTICLE_TEXT_LIMIT', 300); -define('ARTICLE_IMAGE_LIMIT', 100); - -$canEdit = hasFlag(FLAG_CONTENT_NEWS) || superAdmin(); -if($canEdit) -{ - if(!empty($action)) - { - $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; - $p_title = isset($_REQUEST['title']) ? $_REQUEST['title'] : null; - $body = isset($_REQUEST['body']) ? stripslashes($_REQUEST['body']) : null; - $comments = isset($_REQUEST['comments']) ? $_REQUEST['comments'] : null; - $type = isset($_REQUEST['type']) ? (int)$_REQUEST['type'] : null; - $category = isset($_REQUEST['category']) ? (int)$_REQUEST['category'] : null; - $player_id = isset($_REQUEST['player_id']) ? (int)$_REQUEST['player_id'] : null; - $article_text = isset($_REQUEST['article_text']) ? $_REQUEST['article_text'] : null; - $article_image = isset($_REQUEST['article_image']) ? $_REQUEST['article_image'] : null; - $forum_section = isset($_REQUEST['forum_section']) ? $_REQUEST['forum_section'] : null; - $errors = array(); - - if($action == 'add') { - if(isset($forum_section) && $forum_section != '-1') { - $forum_add = Forum::add_thread($p_title, $body, $forum_section, $player_id, $account_logged->getId(), $errors); - } - - if(News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $article_text, $article_image, $errors)) { - $p_title = $body = $comments = $article_text = $article_image = ''; - $type = $category = $player_id = 0; - } - } - else if($action == 'delete') { - News::delete($id, $errors); - } - else if($action == 'edit') - { - if(isset($id) && !isset($p_title)) { - $news = News::get($id); - $p_title = $news['title']; - $body = $news['body']; - $comments = $news['comments']; - $type = $news['type']; - $category = $news['category']; - $player_id = $news['player_id']; - $article_text = $news['article_text']; - $article_image = $news['article_image']; - } - else { - if(News::update($id, $p_title, $body, $type, $category, $player_id, $forum_section, $article_text, $article_image, $errors)) { - // update forum thread if exists - if(isset($forum_section) && Validator::number($forum_section)) { - $db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $player_id.", `post_text` = ".$db->quote($body).", `post_topic` = ".$db->quote($p_title).", `edit_date` = " . time() . " WHERE `id` = " . $db->quote($forum_section)); - } - - $action = $p_title = $body = $comments = $article_text = $article_image = ''; - $type = $category = $player_id = 0; - } - } - } - else if($action == 'hide') { - News::toggleHidden($id, $errors); - } - - if(!empty($errors)) - $twig->display('error_box.html.twig', array('errors' => $errors)); - - if($cache->enabled()) - { - $cache->set('news_' . $template_name . '_' . NEWS, '', 120); - $cache->set('news_' . $template_name . '_' . TICKER, '', 120); - } - } -} -else if($cache->enabled()) +if($cache->enabled()) $news_cached = News::getCached(NEWS); if(!$news_cached) { $categories = array(); - foreach($db->query( - 'SELECT `id`, `name`, `icon_id` FROM `' . TABLE_PREFIX . 'news_categories` WHERE `hidden` != 1') as $cat) + foreach($db->query('SELECT `id`, `name`, `icon_id` FROM `' . TABLE_PREFIX . 'news_categories` WHERE `hidden` != 1') as $cat) { $categories[$cat['id']] = array( 'name' => $cat['name'], @@ -190,12 +114,7 @@ if(!$news_cached) ); } - $tickers_db = - $db->query( - 'SELECT * FROM `' . TABLE_PREFIX . 'news` WHERE `type` = ' . TICKER . - ($canEdit ? '' : ' AND `hidden` != 1') . - ' ORDER BY `date` DESC LIMIT ' . $config['news_ticker_limit']); - + $tickers_db = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'news` WHERE `type` = ' . TICKER .($canEdit ? '' : ' AND `hidden` != 1') .' ORDER BY `date` DESC LIMIT ' . $config['news_ticker_limit']); $tickers_content = ''; if($tickers_db->rowCount() > 0) { @@ -214,12 +133,7 @@ if(!$news_cached) if($cache->enabled() && !$canEdit) $cache->set('news_' . $template_name . '_' . TICKER, $tickers_content, 120); - $featured_article_db = - $db->query( - 'SELECT `id`, `title`, `article_text`, `article_image`, `hidden` FROM `' . TABLE_PREFIX . 'news` WHERE `type` = ' . ARTICLE . - ($canEdit ? '' : ' AND `hidden` != 1') . - ' ORDER BY `date` DESC LIMIT 1'); - + $featured_article_db =$db->query('SELECT `id`, `title`, `article_text`, `article_image`, `hidden` FROM `' . TABLE_PREFIX . 'news` WHERE `type` = ' . ARTICLE . ($canEdit ? '' : ' AND `hidden` != 1') .' ORDER BY `date` DESC LIMIT 1'); $article = ''; if($featured_article_db->rowCount() > 0) { $article = $featured_article_db->fetch(); @@ -251,44 +165,7 @@ else { if(!$news_cached) { ob_start(); - if($canEdit) - { - if($action == 'edit') { - $player = new OTS_Player(); - $player->load($player_id); - } - - $account_players = $account_logged->getPlayersList(); - $account_players->orderBy('group_id', POT::ORDER_DESC); - - $twig->display('news.add.html.twig', array( - 'action' => $action, - 'news_link' => getLink(PAGE), - 'news_link_form' => getLink('news/' . ($action == 'edit' ? 'edit' : 'add')), - 'news_id' => isset($id) ? $id : null, - 'title' => isset($p_title) ? $p_title : '', - 'body' => isset($body) ? $body : '', - 'type' => isset($type) ? $type : null, - 'player' => isset($player) && $player->isLoaded() ? $player : null, - 'player_id' => isset($player_id) ? $player_id : null, - 'account_players' => $account_players, - 'category' => isset($category) ? $category : 0, - 'categories' => $categories, - 'forum_boards' => getForumBoards(), - 'forum_section' => isset($forum_section) ? $forum_section : null, - 'comments' => isset($comments) ? $comments : null, - 'article_text' => isset($article_text) ? $article_text : null, - 'article_image' => isset($article_image) ? $article_image : null - )); - } - - $newses = - $db->query( - 'SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'news'). - ' WHERE type = ' . NEWS . - ($canEdit ? '' : ' AND hidden != 1') . - ' ORDER BY date' . - ' DESC LIMIT ' . $config['news_limit']); + $newses = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news') . ' WHERE type = ' . NEWS . ($canEdit ? '' : ' AND hidden != 1') . ' ORDER BY date' . ' DESC LIMIT ' . $config['news_limit']); if($newses->rowCount() > 0) { foreach($newses as $news) @@ -303,13 +180,13 @@ if(!$news_cached) $admin_options = ''; if($canEdit) { - $admin_options = '

+ $admin_options = '

Edit - + Delete - + ' . ($news['hidden'] != 1 ? 'Hide' : 'Show') . ' '; @@ -353,94 +230,6 @@ else class News { - static public function verify($title, $body, $article_text, $article_image, &$errors) - { - if(!isset($title[0]) || !isset($body[0])) { - $errors[] = 'Please fill all inputs.'; - return false; - } - - 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; - } - - if(strlen($article_text) > ARTICLE_TEXT_LIMIT) { - $errors[] = 'Article text cannot be longer than ' . ARTICLE_TEXT_LIMIT . ' characters.'; - return false; - } - - if(strlen($article_image) > ARTICLE_IMAGE_LIMIT) { - $errors[] = 'Article image cannot be longer than ' . ARTICLE_IMAGE_LIMIT . ' characters.'; - return false; - } - - return true; - } - - static public function add($title, $body, $type, $category, $player_id, $comments, $article_text, $article_image, &$errors) - { - global $db; - if(!self::verify($title, $body, $article_text, $article_image, $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, 'article_text' => ($type == 3 ? $article_text : ''), 'article_image' => ($type == 3 ? $article_image : ''))); - 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, $article_text, $article_image, &$errors) - { - global $db; - if(!self::verify($title, $body, $article_text, $article_image, $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, 'article_text' => $article_text, 'article_image' => $article_image), array('id' => $id)); - return true; - } - - static public function delete($id, &$errors) - { - global $db; - if(isset($id)) - { - if($db->select(TABLE_PREFIX . 'news', array('id' => $id)) !== false) - $db->delete(TABLE_PREFIX . 'news', array('id' => $id)); - else - $errors[] = 'News with id ' . $id . ' does not exists.'; - } - else - $errors[] = 'News id not set.'; - - return !count($errors); - } - - static public function toggleHidden($id, &$errors) - { - global $db; - if(isset($id)) - { - $query = $db->select(TABLE_PREFIX . 'news', array('id' => $id)); - if($query !== false) - $db->update(TABLE_PREFIX . 'news', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id)); - else - $errors[] = 'News with id ' . $id . ' does not exists.'; - } - else - $errors[] = 'News id not set.'; - - return !count($errors); - } - static public function getCached($type) { global $template_name; diff --git a/system/pages/team.php b/system/pages/team.php index 202ee1bb..16b9beb4 100644 --- a/system/pages/team.php +++ b/system/pages/team.php @@ -56,11 +56,11 @@ foreach($groupList as $id => $group) 'group_name' => $group->getName(), 'player' => $member, 'outfit' => $config['team_display_outfit'] ? $config['outfit_images_url'] . '?id=' . $member->getLookType() . ($outfit_addons ? '&addons=' . $member->getLookAddons() : '') . '&head=' . $member->getLookHead() . '&body=' . $member->getLookBody() . '&legs=' . $member->getLookLegs() . '&feet=' . $member->getLookFeet() : null, - 'status' => $member->isOnline(), + 'status' => $config['team_display_status'] ? $member->isOnline() : null, 'link' => getPlayerLink($member->getName()), - 'flag_image' => getFlagImage($member->getAccount()->getCountry()), - 'world_name' => getWorldName($member->getWorldId()), - 'last_login' => $lastLogin + 'flag_image' => $config['account_country'] ? getFlagImage($member->getAccount()->getCountry()) : null, + 'world_name' => ($config['multiworld'] || $config['team_display_world']) ? getWorldName($member->getWorldId()) : null, + 'last_login' => $config['team_display_lastlogin'] ? $lastLogin : null ); } diff --git a/system/templates/admin.news.form.html.twig b/system/templates/admin.news.form.html.twig new file mode 100644 index 00000000..3222c85a --- /dev/null +++ b/system/templates/admin.news.form.html.twig @@ -0,0 +1,189 @@ +{% if action %} +
+
+ {% if action == 'edit' %} + + {% endif %} +
+
+
+

{% if action == 'edit' %}Edit{% else %}Add{% endif %} news

+
+ +
+
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ + + + + + {% if action == 'edit' %} + {% if player is defined %} +
+ + +
+ +
+
+ {% endif %} + {% endif %} + +
+ + +
+ +
+
+ + {% if action != 'edit' %} +
+ + +
+ +
+
+ {% elseif comments is not null %} + + {% endif %} + +
+ + +
+ {% for id, cat in categories %} + + + {% endfor %} +
+
+
+ + +
+
+
+
+ + {% if action != 'edit' %} + + {% endif %} + + + +{% endif %} \ No newline at end of file diff --git a/system/templates/admin.news.html.twig b/system/templates/admin.news.html.twig new file mode 100644 index 00000000..4320f120 --- /dev/null +++ b/system/templates/admin.news.html.twig @@ -0,0 +1,188 @@ +
+
+

News:

+
+ New +
+
+
+
+
+ + + + + + + + + + + + {% for news in newses[constant('NEWS')] %} + + + + + + + + {% endfor %} + +
IDTitleDatePlayerOptions
{{ news.id|raw }}{{ news.title }}{{ news.date|date(config.news_date_format) }}{{ news.player_name }} + + + + + + + + + + + + + + {% if news.hidden != 1 %} + + + + {% else %} + + + + {% endif %} + +
+
+
+
+
+ +
+
+

Tickers:

+
+ New +
+
+
+
+
+ + + + + + + + + + + + {% for ticker in newses[constant('TICKER')] %} + + + + + + + + {% endfor %} + +
IDTitleDatePlayerOptions
{{ ticker.id|raw }}{{ ticker.title }}{{ ticker.date|date(config.news_date_format) }}{{ ticker.player_name }} + + + + + + + + + + + + + + {% if ticker.hidden != 1 %} + + + + {% else %} + + + + {% endif %} + +
+
+
+
+
+ +
+
+

Articles:

+
+ New +
+
+
+
+
+ + + + + + + + + + + + {% for article in newses[constant('ARTICLE')] %} + + + + + + + + {% endfor %} + +
IDTitleDatePlayerOptions
{{ article.id|raw }}{{ article.title }}{{ article.date|date(config.news_date_format) }}{{ article.player_name }} + + + + + + + + + + + + {% if article.hidden != 1 %} + + + + {% else %} + + + + {% endif %} + +
+
+
+
+
+ + \ No newline at end of file diff --git a/system/templates/news.add.html.twig b/system/templates/news.add.html.twig deleted file mode 100644 index b95161cf..00000000 --- a/system/templates/news.add.html.twig +++ /dev/null @@ -1,238 +0,0 @@ -
-{% if action != 'edit' %} -Add news -{% endif %} -
- {% if action == 'edit' %} - - {% endif %} - - - - - - {% set rows = 1 %} - - {% set rows = rows + 1 %} - - - - - - {% set rows = rows + 1 %} - - - - - - {% set rows = rows + 1 %} - - - - - - {% set rows = rows + 1 %} - - - - - - {% set rows = rows + 1 %} - - - - - - {% if action == 'edit' %} - {% set rows = rows + 1 %} - {% if player is defined %} - - - - - {% endif %} - {% endif %} - - {% set rows = rows + 1 %} - - - - - - {% set rows = rows + 1 %} - - - - - - {% if action == '' %} - {% set rows = rows + 1 %} - - - - - {% elseif comments is not null%} - - {% endif %} - - {% set rows = rows + 1 %} - - - - -
{% if action == 'edit'%}Edit{% else %}Add{% endif %} news
Title:
Type: - -
Author: - -
{% if action == 'edit' %}Modified by{% else %}Author{% endif %}: - -
Category: - {% for id, cat in categories %} - - {% endfor %} -
Create forum thread in section: - -
- Preview - - - -
-
- -{% if action != 'edit' %} - -{% endif %} - - \ No newline at end of file diff --git a/system/templates/team.html.twig b/system/templates/team.html.twig index b3353644..93fdbf19 100644 --- a/system/templates/team.html.twig +++ b/system/templates/team.html.twig @@ -52,89 +52,17 @@ {% for group in groupmember|reverse %} - {% for member in group.members|reverse %} - - {{ group.group_name }} - - {% if config.team_display_outfit %} - - player outfit - - {% endif %} - - - {% if config.account_country %} - {{ member.flag_image|raw }} - {% endif %} - {{ member.link|raw }} - - - {% if config.team_display_status %} - - {% if member.status %} - Online - {% else %} - Offline - {% endif %} - - {% endif %} - - {% if (config.multiworld or config.team_display_world) %} - - {{ member.world_name }} - - {% endif %} - - {% if config.team_display_lastlogin %} - - {{ member.last_login }} - - {% endif %} - - {% endfor %} - {% endfor %} - - {% elseif config.team_style == 2 %} - {% for group in groupmember|reverse %} -

{{ group.group_name }}

- - + {% if group.members is not empty %} + {% for member in group.members|reverse %} - {% if config.team_display_outfit %} - - {% endif %} + - - - {% if config.team_display_status %} - - {% endif %} - - {% if (config.multiworld or config.team_display_world) %} - - {% endif %} - - {% if config.team_display_lastlogin %} - - {% endif %} - - - {% for member in group.members %} - {% if config.team_display_outfit %} {% endif %} - + - {% endif %} + {% endif %} {% endfor %} -
Outfit{{ group.group_name }} - Name - - Status - - World - - Last login -
player outfit {% if config.account_country %} {{ member.flag_image|raw }} @@ -162,10 +90,86 @@ {{ member.last_login }}
+ {% endif %} + {% endfor %} + + {% elseif config.team_style == 2 %} + {% for group in groupmember|reverse %} + {% if group.members is not empty %} +

{{ group.group_name }}

+ + + + {% if config.team_display_outfit %} + + {% endif %} + + + + {% if config.team_display_status %} + + {% endif %} + + {% if (config.multiworld or config.team_display_world) %} + + {% endif %} + + {% if config.team_display_lastlogin %} + + {% endif %} + + + {% for member in group.members %} + + {% if config.team_display_outfit %} + + {% endif %} + + + + {% if config.team_display_status %} + + {% endif %} + + {% if (config.multiworld or config.team_display_world) %} + + {% endif %} + + {% if config.team_display_lastlogin %} + + {% endif %} + + {% endfor %} +
Outfit + Name + + Status + + World + + Last login +
+ player outfit + + {% if config.account_country %} + {{ member.flag_image|raw }} + {% endif %} + {{ member.link|raw }} + + {% if member.status %} + Online + {% else %} + Offline + {% endif %} + + {{ member.world_name }} + + {{ member.last_login }} +
+ {% endif %} {% endfor %} {% endif %}