From 876b1b988a03c46aeff0110dab3b284317ff6752 Mon Sep 17 00:00:00 2001 From: Lee <42119604+Leesneaks@users.noreply.github.com> Date: Sun, 2 Dec 2018 05:30:36 +0000 Subject: [PATCH] Code clean up + datatables (#64) * Reformat Code Reformat Code - spaces + tabs * Code cleanup removed duplicated datatables code * Datatables replace spells, monsters tables with JavaScript Sortable Tables (DataTables?) --- admin/template/style.css | 47 +- admin/template/template.php | 395 ++--- system/pages/admin/accounts.php | 652 +++---- system/pages/admin/changelog.php | 2 +- system/pages/admin/dashboard.php | 132 +- system/pages/admin/items.php | 6 +- system/pages/admin/login.php | 18 +- system/pages/admin/logs.php | 174 +- system/pages/admin/mailer.php | 30 +- system/pages/admin/menus.php | 174 +- system/pages/admin/notepad.php | 13 +- system/pages/admin/pages.php | 74 +- system/pages/admin/phpinfo.php | 10 +- system/pages/admin/players.php | 1491 +++++++++-------- system/pages/admin/plugins.php | 52 +- system/pages/admin/tools.php | 8 +- system/pages/admin/version.php | 10 +- system/pages/admin/visitors.php | 15 +- system/pages/creatures.php | 296 ++-- system/pages/spells.php | 23 +- system/templates/admin.dashboard.html.twig | 198 +-- system/templates/admin.items.html.twig | 4 +- system/templates/admin.login.html.twig | 70 +- system/templates/admin.mailer.html.twig | 80 +- system/templates/admin.menus.form.html.twig | 48 +- system/templates/admin.menus.js.html.twig | 55 +- system/templates/admin.notepad.html.twig | 84 +- system/templates/admin.pages.form.html.twig | 208 +-- system/templates/admin.pages.html.twig | 127 +- system/templates/admin.pages.links.html.twig | 6 +- system/templates/admin.plugins.form.html.twig | 50 +- system/templates/admin.plugins.html.twig | 126 +- system/templates/admin.statistics.html.twig | 74 +- system/templates/admin.visitors.html.twig | 104 +- system/templates/spells.html.twig | 40 +- tools/css/dataTables.bootstrap.min.css | 1 - tools/css/jquery.dataTables.min.css | 1 + tools/js/dataTables.bootstrap.min.js | 8 - 38 files changed, 2396 insertions(+), 2510 deletions(-) delete mode 100644 tools/css/dataTables.bootstrap.min.css create mode 100644 tools/css/jquery.dataTables.min.css delete mode 100644 tools/js/dataTables.bootstrap.min.js diff --git a/admin/template/style.css b/admin/template/style.css index df283139..c94f27c9 100644 --- a/admin/template/style.css +++ b/admin/template/style.css @@ -1,43 +1,44 @@ .slidecontainer { - width: 100%; + width: 100%; } .slider { - -webkit-appearance: none; - width: 100%; + -webkit-appearance: none; + width: 100%; - outline: none; - opacity: 0.7; - -webkit-transition: .2s; - transition: opacity .2s; + outline: none; + opacity: 0.7; + -webkit-transition: .2s; + transition: opacity .2s; } .slider:hover { - opacity: 1; + opacity: 1; } .slider::-webkit-slider-thumb { - -webkit-appearance: none; - appearance: none; - width: 15px; - height: 25px; - background: #3c8dbc; - cursor: pointer; + -webkit-appearance: none; + appearance: none; + width: 15px; + height: 25px; + background: #3c8dbc; + cursor: pointer; } .slider::-moz-range-thumb { - width: 25px; - height: 25px; - background: #3c8dbc; - cursor: pointer; + width: 25px; + height: 25px; + background: #3c8dbc; + cursor: pointer; } td.details-control { - text-align:center; - color:forestgreen; - cursor: pointer; + text-align: center; + color: forestgreen; + cursor: pointer; } + tr.shown td.details-control { - text-align:center; - color:red; + text-align: center; + color: red; } \ No newline at end of file diff --git a/admin/template/template.php b/admin/template/template.php index 850a7d97..b728b231 100644 --- a/admin/template/template.php +++ b/admin/template/template.php @@ -2,220 +2,221 @@ - - - - - + + + + + - - - - - + + + + + - + -
- - -
- +
+ + +
+ - -
-
+ + if ($has_child) { + $used_menu = ""; + $nav_construct = ''; + foreach ($_page as $__name => $__page) { + $nav_construct = $nav_construct . ' -
-

- Admin Panel -
- -
-

-
-
- -
+ if ($page == $__page) { + $nav_construct = $nav_construct . ' class="active"'; + $used_menu = true; + } + $nav_construct = $nav_construct . '> ' . $__name . ''; + } -
+ echo ''; + } + $i++; + } - +
+
+

+ - Admin Panel +
+ +
+

+
+
+ +
-
- -
- + - - - - - - + +
+ + + + + + + + + \ No newline at end of file diff --git a/system/pages/admin/accounts.php b/system/pages/admin/accounts.php index b0e39f71..754d1986 100644 --- a/system/pages/admin/accounts.php +++ b/system/pages/admin/accounts.php @@ -14,24 +14,24 @@ $base = BASE_URL . 'admin/?p=accounts'; function echo_success($message) { - echo '

' . $message . '

'; + echo '

' . $message . '

'; } function echo_error($message) { - global $error; - echo '

' . $message . '

'; - $error = true; + global $error; + echo '

' . $message . '

'; + $error = true; } function verify_number($number, $name, $max_length) { - if (!Validator::number($number)) - echo_error($name . ' can contain only numbers.'); + if (!Validator::number($number)) + echo_error($name . ' can contain only numbers.'); - $number_length = strlen($number); - if ($number_length <= 0 || $number_length > $max_length) - echo_error($name . ' cannot be longer than ' . $max_length . ' digits.'); + $number_length = strlen($number); + if ($number_length <= 0 || $number_length > $max_length) + echo_error($name . ' cannot be longer than ' . $max_length . ' digits.'); } $hasCoinsColumn = $db->hasColumn('accounts', 'coins'); @@ -43,383 +43,385 @@ $hasCoinsColumn = $db->hasColumn('accounts', 'coins'); query('SELECT `id` FROM `accounts` WHERE `name` = ' . $db->quote($_REQUEST['search_name'])); - if ($query->rowCount() == 1) { - $query = $query->fetch(); - $id = $query['id']; - } else { - $query = $db->query('SELECT `id`, `name` FROM `accounts` WHERE `name` LIKE ' . $db->quote('%' . $_REQUEST['search_name'] . '%')); - if ($query->rowCount() > 0 && $query->rowCount() <= 10) { - echo 'Do you mean?'; - } else if ($query->rowCount() > 10) - echo 'Specified name resulted with too many accounts.'; - } - } - } + if (strlen($_REQUEST['search_name']) < 3 && !Validator::number($_REQUEST['search_name'])) { + echo 'Player name is too short.'; + } else { + if (Validator::number($_REQUEST['search_name'])) + $id = $_REQUEST['search_name']; + else { + $query = $db->query('SELECT `id` FROM `accounts` WHERE `name` = ' . $db->quote($_REQUEST['search_name'])); + if ($query->rowCount() == 1) { + $query = $query->fetch(); + $id = $query['id']; + } else { + $query = $db->query('SELECT `id`, `name` FROM `accounts` WHERE `name` LIKE ' . $db->quote('%' . $_REQUEST['search_name'] . '%')); + if ($query->rowCount() > 0 && $query->rowCount() <= 10) { + echo 'Do you mean?'; + } else if ($query->rowCount() > 10) + echo 'Specified name resulted with too many accounts.'; + } + } + } } if ($id > 0) { - $account = new OTS_Account(); - $account->load($id); + $account = new OTS_Account(); + $account->load($id); - if (isset($account) && $account->isLoaded() && isset($_POST['save'])) {// we want to save - $error = false; + if (isset($account) && $account->isLoaded() && isset($_POST['save'])) {// we want to save + $error = false; - $name = $_POST['name']; - $_error = ''; + $name = $_POST['name']; + $_error = ''; - //if (!Validator::check_account_name($name)) - // echo_error(Validator::getLastError()); + //if (!Validator::check_account_name($name)) + // echo_error(Validator::getLastError()); - $account_db = new OTS_Account(); - $account_db->find($name); - if ($account_db->isLoaded() && $account->getName() != $name) - echo_error('This name is already used. Please choose another name!'); + $account_db = new OTS_Account(); + $account_db->find($name); + if ($account_db->isLoaded() && $account->getName() != $name) + echo_error('This name is already used. Please choose another name!'); - $account_db->load($id); - if (!$account_db->isLoaded()) - echo_error('Account with this id doesn\'t exist.'); + $account_db->load($id); + if (!$account_db->isLoaded()) + echo_error('Account with this id doesn\'t exist.'); - //type - $group = $_POST['group']; + //type + $group = $_POST['group']; - $password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null)); - if(!Validator::password($password)) { - $errors['password'] = Validator::getLastError(); - } + $password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null)); + if (!Validator::password($password)) { + $errors['password'] = Validator::getLastError(); + } - //secret - $secret = $_POST['secret']; - //key - $key = $_POST['key']; + //secret + $secret = $_POST['secret']; + //key + $key = $_POST['key']; - $email = $_POST['email']; - if(!Validator::email($email)) - $errors['email'] = Validator::getLastError(); + $email = $_POST['email']; + if (!Validator::email($email)) + $errors['email'] = Validator::getLastError(); - // prem days - $p_days = $_POST['p_days']; - verify_number($p_days, 'Prem days', 11); + // prem days + $p_days = $_POST['p_days']; + verify_number($p_days, 'Prem days', 11); - //tibia coins - if($hasCoinsColumn) { - $t_coins = $_POST['t_coins']; - verify_number($t_coins, 'Tibia coins', 12); - } + //tibia coins + if ($hasCoinsColumn) { + $t_coins = $_POST['t_coins']; + verify_number($t_coins, 'Tibia coins', 12); + } - //prem points - $p_points = $_POST['p_points']; - verify_number($p_points, 'Prem Points', 11); + //prem points + $p_points = $_POST['p_points']; + verify_number($p_points, 'Prem Points', 11); - //rl name - $rl_name = $_POST['rl_name']; + //rl name + $rl_name = $_POST['rl_name']; - //location - $rl_loca = $_POST['rl_loca']; + //location + $rl_loca = $_POST['rl_loca']; - //country - $rl_country = $_POST['rl_country']; + //country + $rl_country = $_POST['rl_country']; - //created - $created = $_POST['created']; - verify_number($created, 'Created', 20); + //created + $created = $_POST['created']; + verify_number($created, 'Created', 20); - //last login - $lastlogin = $_POST['lastlogin']; - verify_number($lastlogin, 'Last login', 20); + //last login + $lastlogin = $_POST['lastlogin']; + verify_number($lastlogin, 'Last login', 20); - //web last login - $web_lastlogin = $_POST['web_lastlogin']; - verify_number($web_lastlogin, 'Web Last logout', 20); + //web last login + $web_lastlogin = $_POST['web_lastlogin']; + verify_number($web_lastlogin, 'Web Last logout', 20); - if (!$error) { - $account->setName($name); - $account->setCustomField('type', $group); - $account->setCustomField('secret', $secret); - $account->setCustomField('key', $key); - $account->setEMail($email); - $account->setPremDays($p_days); - if($hasCoinsColumn) { - $account->setCustomField('coins', $t_coins); - } + if (!$error) { + $account->setName($name); + $account->setCustomField('type', $group); + $account->setCustomField('secret', $secret); + $account->setCustomField('key', $key); + $account->setEMail($email); + $account->setPremDays($p_days); + if ($hasCoinsColumn) { + $account->setCustomField('coins', $t_coins); + } - $account->setRLName($rl_name); - $account->setLocation($rl_loca); - $account->setCountry($rl_country); + $account->setRLName($rl_name); + $account->setLocation($rl_loca); + $account->setCountry($rl_country); - if ($db->hasColumn('accounts', 'premium_points')){ - $account->setCustomField('premium_points', $p_points);} + if ($db->hasColumn('accounts', 'premium_points')) { + $account->setCustomField('premium_points', $p_points); + } - if (isset($password)) { - $config_salt_enabled = $db->hasColumn('accounts', 'salt'); - if($config_salt_enabled) - { - $salt = generateRandomString(10, false, true, true); - $password = $salt . $password; - $account_logged->setCustomField('salt', $salt); - } + if (isset($password)) { + $config_salt_enabled = $db->hasColumn('accounts', 'salt'); + if ($config_salt_enabled) { + $salt = generateRandomString(10, false, true, true); + $password = $salt . $password; + $account_logged->setCustomField('salt', $salt); + } - $password = encrypt($password); - $account->setPassword($password); + $password = encrypt($password); + $account->setPassword($password); - if ($config_salt_enabled) - $account->setCustomField('salt', $salt); - } + if ($config_salt_enabled) + $account->setCustomField('salt', $salt); + } - $account->setEMail($email); + $account->setEMail($email); - //$account->setCustomField('created', time()); + //$account->setCustomField('created', time()); - $account->save(); - echo_success('Account saved at: ' . date('G:i')); - } - } + $account->save(); + echo_success('Account saved at: ' . date('G:i')); + } + } } $search_name = ''; $search_account = ''; if (isset($_REQUEST['search_name'])) - $search_name = $_REQUEST['search_name']; + $search_name = $_REQUEST['search_name']; else if (isset($_REQUEST['search_account'])) - $search_account = $_REQUEST['search_account']; + $search_account = $_REQUEST['search_account']; else if ($id > 0 && isset($account) && $account->isLoaded()) - $search_name = $account->getName(); + $search_name = $account->getName(); ?>
- isLoaded()) { - ?> + isLoaded()) { + ?> - -
-
-
-
-
-
- - -
-
- - -
-
-
-
- - -
-
- -
+ + +
+
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ +
+ name="c_pass" + id="c_pass" + value="false" + class="input_control"/> - -
-
-
-
-
- - -
-
- - -
-
-
-
- - -
-
- - -
- -
- - -
- - hasColumn('players', 'blessings')): ?> -
- - -
- -
-
-
- - -
-
- - -
-
- - -
-
+ +
+
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+ +
+ + +
+ + hasColumn('players', 'blessings')): ?> +
+ + +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
-
-
- - -
-
- - -
-
- - -
-
+
+
+ + +
+
+ + +
+
+ + +
+
- - + + -
-
- +
+
+
-
-
-

Search Account:

-
- -
-
+
+
+

Search Account:

+
+ +
+
-
-
-
- - +
+ +
+ + -
- -
-
- isLoaded()) { - $account_players = array(); - $query = $db->query('SELECT `name`,`level`,`vocation` FROM `players` WHERE `account_id` = ' . $account->getId() . ' ORDER BY `name`')->fetchAll(); - if (isset($query)) { - ?> -
-
-

Character List:

-
-
- - - - - - - - - - - + + + + + isLoaded()) { + $account_players = array(); + $query = $db->query('SELECT `name`,`level`,`vocation` FROM `players` WHERE `account_id` = ' . $account->getId() . ' ORDER BY `name`')->fetchAll(); + if (isset($query)) { + ?> +
+
+

Character List:

+
+
+
#NameLevelEdit
'.$i.'.'.$p['name'] . ''.$p['level'].'
+ + + + + + + + + + + '; - $i++; - } ?> - -
#NameLevelEdit
' . $i . '.' . $p['name'] . '' . $p['level'] . '
-
-
+ $i++; + } ?> + + +
+
- +
\ No newline at end of file diff --git a/system/pages/admin/changelog.php b/system/pages/admin/changelog.php index 53c07d65..e0120cad 100644 --- a/system/pages/admin/changelog.php +++ b/system/pages/admin/changelog.php @@ -10,7 +10,7 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'MyAAC Changelog'; -if(!file_exists(BASE . 'CHANGELOG')) { +if (!file_exists(BASE . 'CHANGELOG')) { echo 'File CHANGELOG doesn\'t exist.'; return; } diff --git a/system/pages/admin/dashboard.php b/system/pages/admin/dashboard.php index 49fe4efb..10e8dbe8 100644 --- a/system/pages/admin/dashboard.php +++ b/system/pages/admin/dashboard.php @@ -12,39 +12,39 @@ $title = 'Dashboard'; $cache = Cache::getInstance(); if ($cache->enabled()) { - if (isset($_GET['clear_cache'])) { - if (clearCache()) - success('Cache cleared.'); - else - error('Error while clearing cache.'); - } + if (isset($_GET['clear_cache'])) { + if (clearCache()) + success('Cache cleared.'); + else + error('Error while clearing cache.'); + } } if (isset($_GET['maintenance'])) { - $_status = (int)$_POST['status']; - $message = $_POST['message']; - if (empty($message)) { - error('Message cannot be empty.'); - } else if (strlen($message) > 255) { - error('Message is too long. Maximum length allowed is 255 chars.'); - } else { - $tmp = ''; - if (fetchDatabaseConfig('site_closed', $tmp)) - updateDatabaseConfig('site_closed', $_status); - else - registerDatabaseConfig('site_closed', $_status); + $_status = (int)$_POST['status']; + $message = $_POST['message']; + if (empty($message)) { + error('Message cannot be empty.'); + } else if (strlen($message) > 255) { + error('Message is too long. Maximum length allowed is 255 chars.'); + } else { + $tmp = ''; + if (fetchDatabaseConfig('site_closed', $tmp)) + updateDatabaseConfig('site_closed', $_status); + else + registerDatabaseConfig('site_closed', $_status); - if (fetchDatabaseConfig('site_closed_message', $tmp)) - updateDatabaseConfig('site_closed_message', $message); - else - registerDatabaseConfig('site_closed_message', $message); - } + if (fetchDatabaseConfig('site_closed_message', $tmp)) + updateDatabaseConfig('site_closed_message', $message); + else + registerDatabaseConfig('site_closed_message', $message); + } } $is_closed = getDatabaseConfig('site_closed') == '1'; $closed_message = 'Server is under maintenance, please visit later.'; $tmp = ''; if (fetchDatabaseConfig('site_closed_message', $tmp)) - $closed_message = $tmp; + $closed_message = $tmp; $query = $db->query('SELECT count(*) as `how_much` FROM `accounts`;'); $query = $query->fetch(); @@ -63,73 +63,73 @@ $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;'); + $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; + $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;'); + $coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;'); } else { - $coins = 0; + $coins = 0; } $twig->display('admin.statistics.html.twig', array( - 'total_accounts' => $total_accounts, - 'total_players' => $total_players, - 'total_guilds' => $total_guilds, - 'total_houses' => $total_houses + 'total_accounts' => $total_accounts, + 'total_players' => $total_players, + 'total_guilds' => $total_guilds, + 'total_houses' => $total_houses )); $twig->display('admin.dashboard.html.twig', array( - 'is_closed' => $is_closed, - 'closed_message' => $closed_message, - 'status' => $status, - 'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'), - 'points' => $points, - 'coins' => $coins, + 'is_closed' => $is_closed, + 'closed_message' => $closed_message, + 'status' => $status, + 'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'), + 'points' => $points, + 'coins' => $coins, )); function clearCache() { - global $template_name; - $cache = Cache::getInstance(); + global $template_name; + $cache = Cache::getInstance(); - $tmp = ''; - if ($cache->fetch('status', $tmp)) - $cache->delete('status'); + $tmp = ''; + if ($cache->fetch('status', $tmp)) + $cache->delete('status'); - if ($cache->fetch('templates', $tmp)) - $cache->delete('templates'); + if ($cache->fetch('templates', $tmp)) + $cache->delete('templates'); - if ($cache->fetch('config_lua', $tmp)) - $cache->delete('config_lua'); + if ($cache->fetch('config_lua', $tmp)) + $cache->delete('config_lua'); - if ($cache->fetch('vocations', $tmp)) - $cache->delete('vocations'); + if ($cache->fetch('vocations', $tmp)) + $cache->delete('vocations'); - if ($cache->fetch('towns', $tmp)) - $cache->delete('towns'); + if ($cache->fetch('towns', $tmp)) + $cache->delete('towns'); - if ($cache->fetch('groups', $tmp)) - $cache->delete('groups'); + if ($cache->fetch('groups', $tmp)) + $cache->delete('groups'); - if ($cache->fetch('visitors', $tmp)) - $cache->delete('visitors'); + if ($cache->fetch('visitors', $tmp)) + $cache->delete('visitors'); - if ($cache->fetch('views_counter', $tmp)) - $cache->delete('views_counter'); + if ($cache->fetch('views_counter', $tmp)) + $cache->delete('views_counter'); - if ($cache->fetch('failed_logins', $tmp)) - $cache->delete('failed_logins'); + if ($cache->fetch('failed_logins', $tmp)) + $cache->delete('failed_logins'); - if ($cache->fetch('news' . $template_name . '_' . NEWS, $tmp)) - $cache->delete('news' . $template_name . '_' . NEWS); + if ($cache->fetch('news' . $template_name . '_' . NEWS, $tmp)) + $cache->delete('news' . $template_name . '_' . NEWS); - if ($cache->fetch('news' . $template_name . '_' . TICKER, $tmp)) - $cache->delete('news' . $template_name . '_' . TICKER); + if ($cache->fetch('news' . $template_name . '_' . TICKER, $tmp)) + $cache->delete('news' . $template_name . '_' . TICKER); - if ($cache->fetch('template_ini' . $template_name, $tmp)) - $cache->delete('template_ini' . $template_name); + if ($cache->fetch('template_ini' . $template_name, $tmp)) + $cache->delete('template_ini' . $template_name); - return true; + return true; } \ No newline at end of file diff --git a/system/pages/admin/items.php b/system/pages/admin/items.php index 906ee60e..1accd7cf 100644 --- a/system/pages/admin/items.php +++ b/system/pages/admin/items.php @@ -16,13 +16,13 @@ require LIBS . 'weapons.php'; $twig->display('admin.items.html.twig'); $reload = isset($_REQUEST['reload']) && (int)$_REQUEST['reload'] == 1; -if($reload) { - if(Items::loadFromXML(true)) +if ($reload) { + if (Items::loadFromXML(true)) success('Successfully loaded items.'); else error(Items::getError()); - if(Weapons::loadFromXML(true)) + if (Weapons::loadFromXML(true)) success('Successfully loaded weapons.'); else error(Weapons::getError()); diff --git a/system/pages/admin/login.php b/system/pages/admin/login.php index 3bc8a8e5..e0c95e02 100644 --- a/system/pages/admin/login.php +++ b/system/pages/admin/login.php @@ -10,23 +10,23 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Login'; $logout = ''; -if($action == 'logout') { - $logout = "You have been logged out!"; +if ($action == 'logout') { + $logout = "You have been logged out!"; } $search_errors[] = 'Character does not exist or has been deleted.'; -if(isset($errors)) { - foreach($errors as $error) { +if (isset($errors)) { + foreach ($errors as $error) { error($error); - $twig->display('admin.error.html.twig', array('errors' => $error)); + $twig->display('admin.error.html.twig', array('errors' => $error)); } } $twig->display('admin.login.html.twig', array( - 'errors' => $search_errors, - 'logout' => $logout, - 'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number', - )); \ No newline at end of file + 'errors' => $search_errors, + 'logout' => $logout, + 'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number', +)); \ No newline at end of file diff --git a/system/pages/admin/logs.php b/system/pages/admin/logs.php index d90997fa..0fea9301 100644 --- a/system/pages/admin/logs.php +++ b/system/pages/admin/logs.php @@ -12,113 +12,113 @@ $title = 'Logs viewer'; ?>
-
-

Logs:

-
-
-
-
-
- - - - - - - - - +

Logs:

+ +
+
+
+
+
Log name - Last - updated -
+ + + + + + + + - - - - - - - - - - -
Log name + Last + updated +
- -
Log nameLast updated
-
-
-
-
+ $i = 0; + foreach ($files as $f) { + ?> + + + + + + + + + + Log name + Last updated + + +
+
+
+

' . $file . '

'; - echo nl2br(file_get_contents($aac_path_logs . $file)); - echo '
+ echo nl2br(file_get_contents($aac_path_logs . $file)); + echo ' '; - } else if (file_exists($server_path_logs . $file)) { - echo '

' . $file . '

'; - echo nl2br(file_get_contents($server_path_logs . $file)); - echo '
'; - } else - echo 'Specified file does not exist.'; - } else - echo 'Invalid file name specified.'; + } else if (file_exists($server_path_logs . $file)) { + echo '

' . $file . '

'; + echo nl2br(file_get_contents($server_path_logs . $file)); + echo '
'; + } else + echo 'Specified file does not exist.'; + } else + echo 'Invalid file name specified.'; } ?> \ No newline at end of file diff --git a/system/pages/admin/mailer.php b/system/pages/admin/mailer.php index 31cd6587..d380e05c 100644 --- a/system/pages/admin/mailer.php +++ b/system/pages/admin/mailer.php @@ -10,14 +10,12 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Mailer'; -if(!hasFlag(FLAG_CONTENT_MAILER) && !superAdmin()) -{ +if (!hasFlag(FLAG_CONTENT_MAILER) && !superAdmin()) { echo 'Access denied.'; return; } -if(!$config['mail_enabled']) -{ +if (!$config['mail_enabled']) { echo 'Mail support disabled.'; return; } @@ -27,11 +25,11 @@ $mail_subject = isset($_POST['mail_subject']) ? stripslashes($_POST['mail_subjec $preview = isset($_REQUEST['preview']); $preview_done = false; -if($preview) { - if(!empty($mail_content) && !empty($mail_subject)) { +if ($preview) { + if (!empty($mail_content) && !empty($mail_subject)) { $preview_done = _mail($account_logged->getCustomField('email'), $mail_subject, $mail_content); - if(!$preview_done) + if (!$preview_done) error('Error while sending preview mail: ' . $mailer->ErrorInfo); } } @@ -43,31 +41,29 @@ $twig->display('admin.mailer.html.twig', array( 'preview_done' => $preview_done )); -if(empty($mail_content) || empty($mail_subject) || $preview) +if (empty($mail_content) || empty($mail_subject) || $preview) return; $success = 0; $failed = 0; $add = ''; -if($config['account_mail_verify']) { +if ($config['account_mail_verify']) { note('Note: Sending only to users with verified E-Mail.'); $add = ' AND ' . $db->fieldName('email_verified') . ' = 1'; } $query = $db->query('SELECT ' . $db->fieldName('email') . ' FROM ' . $db->tableName('accounts') . ' WHERE ' . $db->fieldName('email') . ' != ""' . $add); -foreach($query as $email) -{ - if(_mail($email['email'], $mail_subject, $mail_content)) +foreach ($query as $email) { + if (_mail($email['email'], $mail_subject, $mail_content)) $success++; - else - { + else { $failed++; echo '
'; error('An error occorred while sending email to ' . $email['email'] . '. Error: ' . $mailer->ErrorInfo); } } - success('Mailing finished.'); - success("$success emails delivered."); - warning("$failed emails failed."); +success('Mailing finished.'); +success("$success emails delivered."); +warning("$failed emails failed."); diff --git a/system/pages/admin/menus.php b/system/pages/admin/menus.php index d50ee760..910e3ab6 100644 --- a/system/pages/admin/menus.php +++ b/system/pages/admin/menus.php @@ -10,84 +10,81 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Menus'; -if(!hasFlag(FLAG_CONTENT_MENUS) && !superAdmin()) -{ - echo 'Access denied.'; - return; +if (!hasFlag(FLAG_CONTENT_MENUS) && !superAdmin()) { + echo 'Access denied.'; + return; } -if(isset($_REQUEST['template'])) { - $template = $_REQUEST['template']; +if (isset($_REQUEST['template'])) { + $template = $_REQUEST['template']; - if(isset($_REQUEST['menu'])) { - $post_menu = $_REQUEST['menu']; - $post_menu_link = $_REQUEST['menu_link']; - $post_menu_blank = $_REQUEST['menu_blank']; - $post_menu_color = $_REQUEST['menu_color']; - if(count($post_menu) != count($post_menu_link)) { - echo 'Menu count is not equal menu links. Something went wrong when sending form.'; - return; - } + if (isset($_REQUEST['menu'])) { + $post_menu = $_REQUEST['menu']; + $post_menu_link = $_REQUEST['menu_link']; + $post_menu_blank = $_REQUEST['menu_blank']; + $post_menu_color = $_REQUEST['menu_color']; + if (count($post_menu) != count($post_menu_link)) { + echo 'Menu count is not equal menu links. Something went wrong when sending form.'; + return; + } - $db->query('DELETE FROM `' . TABLE_PREFIX . 'menu` WHERE `template` = ' . $db->quote($template)); - foreach($post_menu as $category => $menus) { - foreach($menus as $i => $menu) { - if(empty($menu)) // don't save empty menu item - continue; + $db->query('DELETE FROM `' . TABLE_PREFIX . 'menu` WHERE `template` = ' . $db->quote($template)); + foreach ($post_menu as $category => $menus) { + foreach ($menus as $i => $menu) { + if (empty($menu)) // don't save empty menu item + continue; - try { - $db->insert(TABLE_PREFIX . 'menu', array('template' => $template, 'name' => $menu, 'link' => $post_menu_link[$category][$i], 'blank' => $post_menu_blank[$category][$i] == 'on' ? 1 : 0, 'color' => str_replace('#', '', $post_menu_color[$category][$i]), 'category' => $category, 'ordering' => $i)); - } - catch(PDOException $error) { - warning('Error while adding menu item (' . $menu . '): ' . $error->getMessage()); - } - } - } + try { + $db->insert(TABLE_PREFIX . 'menu', array('template' => $template, 'name' => $menu, 'link' => $post_menu_link[$category][$i], 'blank' => $post_menu_blank[$category][$i] == 'on' ? 1 : 0, 'color' => str_replace('#', '', $post_menu_color[$category][$i]), 'category' => $category, 'ordering' => $i)); + } catch (PDOException $error) { + warning('Error while adding menu item (' . $menu . '): ' . $error->getMessage()); + } + } + } - success('Saved at ' . date('H:i')); - } + success('Saved at ' . date('H:i')); + } - $file = TEMPLATES . $template . '/config.php'; - if(file_exists($file)) { - require_once $file; - } - else { - echo 'Cannot find template config.php file.'; - return; - } + $file = TEMPLATES . $template . '/config.php'; + if (file_exists($file)) { + require_once $file; + } else { + echo 'Cannot find template config.php file.'; + return; + } - if(!isset($config['menu_categories'])) { - echo "No menu categories set in template config.php.
This template doesn't support dynamic menus."; - return; - } + if (!isset($config['menu_categories'])) { + echo "No menu categories set in template config.php.
This template doesn't support dynamic menus."; + return; + } - echo 'Hint: You can drag menu items.
+ echo 'Hint: You can drag menu items.
Hint: Add links to external sites using: http:// prefix.
Not all templates support blank and colorful links.
'; - $menus = array(); - $menus_db = $db->query('SELECT `name`, `link`, `blank`, `color`, `category`, `ordering` FROM `' . TABLE_PREFIX . 'menu` WHERE `enabled` = 1 AND `template` = ' . $db->quote($template) . ' ORDER BY `ordering` ASC;')->fetchAll(); - foreach($menus_db as $menu) { - $menus[$menu['category']][] = array('name' => $menu['name'], 'link' => $menu['link'], 'blank' => $menu['blank'], 'color' => $menu['color'], 'ordering' => $menu['ordering']); - } + $menus = array(); + $menus_db = $db->query('SELECT `name`, `link`, `blank`, `color`, `category`, `ordering` FROM `' . TABLE_PREFIX . 'menu` WHERE `enabled` = 1 AND `template` = ' . $db->quote($template) . ' ORDER BY `ordering` ASC;')->fetchAll(); + foreach ($menus_db as $menu) { + $menus[$menu['category']][] = array('name' => $menu['name'], 'link' => $menu['link'], 'blank' => $menu['blank'], 'color' => $menu['color'], 'ordering' => $menu['ordering']); + } - $last_id = array(); - echo '
'; - echo ''; - echo ''; - echo '
'; - echo ''; + } + echo '
'; + echo ''; + echo ''; + echo '
'; + echo ''; - $twig->display('admin.menus.js.html.twig', array( - 'menus' => $menus, - 'last_id' => $last_id - )); - ?> + $twig->display('admin.menus.js.html.twig', array( + 'menus' => $menus, + 'last_id' => $last_id + )); + ?> - query('SELECT `template` FROM `' . TABLE_PREFIX . 'menu` GROUP BY `template`;')->fetchAll(); - foreach($templates as $key => $value) { - $file = TEMPLATES . $value['template'] . '/config.php'; - if(!file_exists($file)) { - unset($templates[$key]); - } - } + query('SELECT `template` FROM `' . TABLE_PREFIX . 'menu` GROUP BY `template`;')->fetchAll(); + foreach ($templates as $key => $value) { + $file = TEMPLATES . $value['template'] . '/config.php'; + if (!file_exists($file)) { + unset($templates[$key]); + } + } - $twig->display('admin.menus.form.html.twig', array( - 'templates' => $templates - )); + $twig->display('admin.menus.form.html.twig', array( + 'templates' => $templates + )); } \ No newline at end of file diff --git a/system/pages/admin/notepad.php b/system/pages/admin/notepad.php index e99d617e..99f3224e 100644 --- a/system/pages/admin/notepad.php +++ b/system/pages/admin/notepad.php @@ -11,19 +11,16 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Notepad'; $notepad_content = Notepad::get($account_logged->getId()); -if(isset($_POST['content'])) -{ +if (isset($_POST['content'])) { $_content = html_entity_decode(stripslashes($_POST['content'])); - if(!$notepad_content) + if (!$notepad_content) Notepad::create($account_logged->getId(), $_content); else Notepad::update($account_logged->getId(), $_content); echo '
Saved at ' . date('H:i') . '
'; -} -else -{ - if($notepad_content !== false) +} else { + if ($notepad_content !== false) $_content = $notepad_content; } @@ -35,7 +32,7 @@ class Notepad { global $db; $query = $db->select(TABLE_PREFIX . 'notepad', array('account_id' => $account_id)); - if($query !== false) + if ($query !== false) return $query['content']; return false; diff --git a/system/pages/admin/pages.php b/system/pages/admin/pages.php index 514beaef..954faa68 100644 --- a/system/pages/admin/pages.php +++ b/system/pages/admin/pages.php @@ -10,8 +10,7 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Pages'; -if(!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) -{ +if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) { echo 'Access denied.'; return; } @@ -24,66 +23,59 @@ $groups = new OTS_Groups_List(); $php = false; $access = 0; -if(!empty($action)) -{ - if($action == 'delete' || $action == 'edit' || $action == 'hide') +if (!empty($action)) { + if ($action == 'delete' || $action == 'edit' || $action == 'hide') $id = $_REQUEST['id']; - if(isset($_REQUEST['name'])) + if (isset($_REQUEST['name'])) $name = $_REQUEST['name']; - if(isset($_REQUEST['title'])) + if (isset($_REQUEST['title'])) $p_title = $_REQUEST['title']; $php = isset($_REQUEST['php']) && $_REQUEST['php'] == 1; - if($php) + if ($php) $body = $_REQUEST['body']; - else if(isset($_REQUEST['body'])) { + else if (isset($_REQUEST['body'])) { //$body = $_REQUEST['body']; $body = html_entity_decode(stripslashes($_REQUEST['body'])); } - if(isset($_REQUEST['access'])) + if (isset($_REQUEST['access'])) $access = $_REQUEST['access']; $errors = array(); $player_id = 1; - if($action == 'add') { - if(Pages::add($name, $p_title, $body, $player_id, $php, $access, $errors)) - { + if ($action == 'add') { + if (Pages::add($name, $p_title, $body, $player_id, $php, $access, $errors)) { $name = $p_title = $body = ''; $player_id = $access = 0; $php = false; } - } - else if($action == 'delete') { - if(Pages::delete($id, $errors)) + } else if ($action == 'delete') { + if (Pages::delete($id, $errors)) success('Page with id ' . $id . ' has been deleted'); - } - else if($action == 'edit') - { - if(isset($id) && !isset($_REQUEST['name'])) { + } else if ($action == 'edit') { + if (isset($id) && !isset($_REQUEST['name'])) { $_page = Pages::get($id); $name = $_page['name']; $p_title = $_page['title']; $body = $_page['body']; $php = $_page['php'] == '1'; $access = $_page['access']; - } - else { + } else { Pages::update($id, $name, $p_title, $body, $player_id, $php, $access); $action = $name = $p_title = $body = ''; $player_id = 1; $access = 0; $php = false; } - } - else if($action == 'hide') { + } else if ($action == 'hide') { Pages::toggleHidden($id, $errors); } - if(!empty($errors)) + if (!empty($errors)) $twig->display('admin.error.html.twig', array('errors' => $errors)); } @@ -91,7 +83,7 @@ $query = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'pages')); $pages = array(); -foreach($query as $_page) { +foreach ($query as $_page) { $pages[] = array( 'link' => getFullLink($_page['name'], $_page['name'], true), 'title' => substr($_page['title'], 0, 20), @@ -121,7 +113,7 @@ class Pages { global $db; $query = $db->select(TABLE_PREFIX . 'pages', array('id' => $id)); - if($query !== false) + if ($query !== false) return $query; return false; @@ -130,21 +122,20 @@ class Pages static public function add($name, $title, $body, $player_id, $php, $access, &$errors) { global $db; - if(isset($name[0]) && isset($title[0]) && isset($body[0]) && $player_id != 0) - { + if (isset($name[0]) && isset($title[0]) && isset($body[0]) && $player_id != 0) { $query = $db->select(TABLE_PREFIX . 'pages', array('name' => $name)); - if($query === false) + if ($query === false) $db->insert(TABLE_PREFIX . 'pages', array('name' => $name, 'title' => $title, 'body' => $body, 'player_id' => $player_id, 'php' => $php ? '1' : '0', 'access' => $access)); else $errors[] = 'Page with this link already exists.'; - } - else + } else $errors[] = 'Please fill all inputs.'; return !count($errors); } - static public function update($id, $name, $title, $body, $player_id, $php, $access) { + static public function update($id, $name, $title, $body, $player_id, $php, $access) + { global $db; $db->update(TABLE_PREFIX . 'pages', array('name' => $name, 'title' => $title, 'body' => $body, 'player_id' => $player_id, 'php' => $php ? '1' : '0', 'access' => $access), array('id' => $id)); } @@ -152,14 +143,12 @@ class Pages static public function delete($id, &$errors) { global $db; - if(isset($id)) - { - if($db->select(TABLE_PREFIX . 'pages', array('id' => $id)) !== false) + if (isset($id)) { + if ($db->select(TABLE_PREFIX . 'pages', array('id' => $id)) !== false) $db->delete(TABLE_PREFIX . 'pages', array('id' => $id)); else $errors[] = 'Page with id ' . $id . ' does not exists.'; - } - else + } else $errors[] = 'id not set'; return !count($errors); @@ -168,18 +157,17 @@ class Pages static public function toggleHidden($id, &$errors) { global $db; - if(isset($id)) - { + if (isset($id)) { $query = $db->select(TABLE_PREFIX . 'pages', array('id' => $id)); - if($query !== false) + if ($query !== false) $db->update(TABLE_PREFIX . 'pages', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id)); else $errors[] = 'Page with id ' . $id . ' does not exists.'; - } - else + } else $errors[] = 'id not set'; return !count($errors); } } + ?> \ No newline at end of file diff --git a/system/pages/admin/phpinfo.php b/system/pages/admin/phpinfo.php index 5f322597..3c557aa8 100644 --- a/system/pages/admin/phpinfo.php +++ b/system/pages/admin/phpinfo.php @@ -10,10 +10,10 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'PHP Info'; -if(!function_exists('phpinfo')) { ?> -phpinfo() function is disabled in your webserver config.
-You can enable it by editing php.ini file. - + phpinfo() function is disabled in your webserver config.
+ You can enable it by editing php.ini file. + -