From be2a2d5121d144a174f32e40299fa82a34d0d278 Mon Sep 17 00:00:00 2001 From: paintballrefjosh Date: Sun, 5 Feb 2017 21:35:28 -0600 Subject: [PATCH 1/4] Fixed missing function on playersonline page From the frontpage you can click on the number of users online for any given realm. This should take you to the usersonline page and show the respectful realm. The function to check, or set the current realm based on the link was missing so this was added. --- core/common.php | 2 +- inc/server/server.playersonline.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/common.php b/core/common.php index 32a07f4..61c09c7 100644 --- a/core/common.php +++ b/core/common.php @@ -346,7 +346,7 @@ function check_for_symbols($string, $space_check = 0) { //$space_check=1 means space is not allowed $len=strlen($string); - $allowed_chars="abcdefghijklmnopqrstuvwxyz���ABCDEFGHIJKLMNOPQRSTUVWXYZ���0123456789"; + $allowed_chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; if(!$space_check) { $allowed_chars .= " "; diff --git a/inc/server/server.playersonline.php b/inc/server/server.playersonline.php index 30af769..0057dfb 100644 --- a/inc/server/server.playersonline.php +++ b/inc/server/server.playersonline.php @@ -13,7 +13,18 @@ echo "Not Included!"; exit; } -$pathway_info[] = array('title'=>$lang['online_players'],'link'=>''); + +// Check to see if the changerealm_to variable is set in the URI. If so we need to set the selected +// realm cookie and reload the page in order to pull the players online from the correct realm +if(isset($_GET['changerealm_to'])) +{ + setcookie("cur_selected_realm", $_GET['changerealm_to'], time() + (3600 * 24 * 365)); + redirect("?p=server&sub=playersonline",1); +} + +// ==================== // +$pathway_info[] = array('title' => $lang['online_players'], 'link' => '?p=server&sub=playersonline'); +$pathway_info[] = array('title' => $realm['name'], 'link' => ''); // ==================== // // Tell the cache not to cache the file because we want live feeds From a920ef74f7e0e87577bf0e06e4e8d66b4490029e Mon Sep 17 00:00:00 2001 From: paintballrefjosh Date: Sun, 5 Feb 2017 22:19:40 -0600 Subject: [PATCH 2/4] Updated Core file to adhere to OOP standards Travis CI identified several broken class references between Config & Core. This update fixes that and cleans up the variables and functions. --- core/core.php | 141 +++++++++++++++++++++++++++++--------------------- index.php | 2 +- 2 files changed, 82 insertions(+), 61 deletions(-) diff --git a/core/core.php b/core/core.php index 478b316..883bc9d 100644 --- a/core/core.php +++ b/core/core.php @@ -10,48 +10,59 @@ class Core { - var $version = '4.0.3'; - var $version_date = '2017-01-28, 00:15'; - var $exp_dbversion = '1.0a'; + public $version = '4.0.6'; + public $version_date = '2017-02-0528, 22:16'; + public $exp_dbversion = '2.0'; + private $conf; - function __construct() + public function __construct(Config $conf) { + $this->conf = $conf; $this->Initialize(); } -// ************************************************************ -// Main initialize function. Sets the path in the config for the site - - function Initialize() +//************************************************************** +// +// Main initialize function. Sets the path in the config for +// the site. +// +//************************************************************** + private function Initialize() { - global $Config; - $this->Cache_Refresh_Time = (int)$Config->get('cache_expire_time'); + $this->Cache_Refresh_Time = (int)$this->conf->get('cache_expire_time'); $this->copyright = 'Powered by MangosWeb version ' . $this->version . ' © 2017, Mistvale Dev Team. All Rights Reserved.'; // Fill in the config with the proper directory info if the directory info is wrong define('SITE_DIR', dirname( $_SERVER['PHP_SELF'] ).'/'); define('PRE_SITE_HREF', str_replace('//', '/', SITE_DIR)); define('SITE_HREF', stripslashes(PRE_SITE_HREF)); - define('SITE_BASE_HREF', 'http://'.$_SERVER["HTTP_HOST"]. SITE_HREF); - + if(isset($_SERVER['HTTP_HOST'])) + { + define('SITE_BASE_HREF', 'http://'.$_SERVER['HTTP_HOST'] . SITE_HREF); + } + else + { + define('SITE_BASE_HREF', $this->conf->get('site_base_href') . SITE_HREF); + } + // If the site href doesnt match whats in the config, we need to set it - if($Config->get('site_base_href') != SITE_BASE_HREF) + if($this->conf->get('site_base_href') != SITE_BASE_HREF) { - $Config->set('site_base_href', SITE_BASE_HREF); - $Config->set('site_href', SITE_HREF); - $Config->Save(); + $this->conf->set('site_base_href', SITE_BASE_HREF); + $this->conf->set('site_href', SITE_HREF); + $this->conf->Save(); } return TRUE; } -// ************************************************************ -// Set the site globals and determine what language and realm -// the user has selected. If no cookie set, then set one - - function setGlobals() +//************************************************************** +// +// Set the site globals and determine what language and realm +// the user has selected. If no cookie set, then set one +// +//************************************************************** + public function setGlobals() { - global $Config; - // Setup the site globals $GLOBALS['users_online'] = array(); $GLOBALS['guests_online'] = 0; @@ -62,7 +73,7 @@ function setGlobals() $GLOBALS['cur_selected_realm'] = ''; // === Load the languages and set users language === // - $languages = explode(",", $Config->get('available_lang')); + $languages = explode(",", $this->conf->get('available_lang')); // Check if a language cookie is set if(isset($_COOKIE['Language'])) @@ -74,13 +85,13 @@ function setGlobals() } else { - $GLOBALS['user_cur_lang'] = (string)$Config->get('default_lang'); + $GLOBALS['user_cur_lang'] = (string)$this->conf->get('default_lang'); setcookie("Language", $GLOBALS['user_cur_lang'], time() + (3600 * 24 * 365)); } } else { - $GLOBALS['user_cur_lang'] = (string)$Config->get('default_lang'); + $GLOBALS['user_cur_lang'] = (string)$this->conf->get('default_lang'); setcookie("Language", $GLOBALS['user_cur_lang'], time() + (3600 * 24 * 365)); } @@ -91,19 +102,19 @@ function setGlobals() } else { - $GLOBALS['cur_selected_realm'] = (int)$Config->get('default_realm_id'); - setcookie("cur_selected_realm", (int)$Config->get('default_realm_id'), time() + (3600 * 24 * 365)); + $GLOBALS['cur_selected_realm'] = (int)$this->conf->get('default_realm_id'); + setcookie("cur_selected_realm", (int)$this->conf->get('default_realm_id'), time() + (3600 * 24 * 365)); } } -// ************************************************************ -/* - Loads the server permissions such as allowing fopen - to open a url. Als checks to see of the function exists - fsockopen. -*/ - - function load_permissions() +//************************************************************** +// +// Loads the server permissions such as allowing fopen +// to open a url. Als checks to see of the function exists +// fsockopen. +// +//************************************************************** + public function load_permissions() { $allow_url_fopen = ini_get('allow_url_fopen'); if(function_exists("fsockopen")) @@ -119,12 +130,12 @@ function load_permissions() } -// === CACHING FUNCTIONS === // - -// ************************************************************ +//************************************************************** +// // Checks is the file ID is cached, and is current on time. - - function isCached($id) +// +//************************************************************** + public function isCached($id) { // Check if the cache file exists. If not, return false if(file_exists('core/cache/'.$id.'.cache')) @@ -147,11 +158,13 @@ function isCached($id) } } -// ************************************************************ -// Loads the html code from the cached file, and returns it in -// a string - - function getCache($id) +//************************************************************** +// +// Loads the html code from the cached file, and returns it in +// a string +// +//************************************************************** + public function getCache($id) { // Check if file exists incase isCache wasnt checked first. Else return false if(file_exists('core/cache/'.$id.'.cache')) @@ -164,19 +177,23 @@ function getCache($id) } } -// ************************************************************ -// Writes to a cache file ($id) - - function writeCache($id, $content) +//************************************************************** +// +// Writes to a cache file ($id) +// +//************************************************************** + public function writeCache($id, $content) { // Write the cache file file_put_contents('core/cache/'.$id.'.cache', $content); } -// ************************************************************ +//************************************************************** +// // Clean out all cache files. For individual delete, use deleteCache - - function clearCache() +// +//************************************************************** + public function clearCache() { // get a list of all files and directories $files = scandir('core/cache/'); @@ -191,18 +208,22 @@ function clearCache() return TRUE; } -// ************************************************************ +//************************************************************** +// // Deletes a cache file with the name of $id - - function deleteCache($id) +// +//************************************************************** + public function deleteCache($id) { unlink('core/cache/'.$id); #Remove file } -// ************************************************************ -// Return the next cache update time on a file. - - function getNextUpdate($filename) +//************************************************************** +// +// Return the next cache update time on a file. +// +//************************************************************** + public function getNextUpdate($filename) { return (fileatime($filename) + $this->Cache_Refresh_Time) - time(); } diff --git a/index.php b/index.php index 12827ef..7f4a38f 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,7 @@ include('core/class.config.php'); $Config = new Config; include('core/core.php'); -$Core = new Core; +$Core = new Core($Config); /*************************************************************** * Show Site Notice if enabled in config, and user cookie not set From d5d7149f95236a6ad1bf62f99152cf6d3d4410d2 Mon Sep 17 00:00:00 2001 From: paintballrefjosh Date: Mon, 6 Feb 2017 00:58:23 -0600 Subject: [PATCH 3/4] Fixed date typo --- core/core.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.php b/core/core.php index 883bc9d..d7d12fd 100644 --- a/core/core.php +++ b/core/core.php @@ -11,7 +11,7 @@ class Core { public $version = '4.0.6'; - public $version_date = '2017-02-0528, 22:16'; + public $version_date = '2017-02-05, 22:16'; public $exp_dbversion = '2.0'; private $conf; From 94e3cc7c989b68dae057b63983b52c3352e1ad58 Mon Sep 17 00:00:00 2001 From: paintballrefjosh Date: Thu, 9 Feb 2017 22:46:08 -0600 Subject: [PATCH 4/4] General cleanup SQL installation file - Added Server Statistics page - Reordered entries - Removed hard set item ID from insert statements, used NULL instead so DB will auto_increment Server Statistics - Removed unused lines of code - Cleaned up top menu breadcrumb links Players Online - Cleaned up top menu breadcrumb links Admin In Game Email & Character Tools - Cleaned up the way the realm names were listed --- inc/admin/script_files/admin.fplinks.php | 2 +- inc/admin/template_files/admin.chartools.php | 17 +++++++++-- .../template_files/admin.sendgamemail.php | 17 +++++++++-- inc/server/server.chars.php | 11 ++++--- inc/server/server.playersonline.php | 5 ++-- inc/server/server.statistic.php | 4 +-- install/sql/full_install.sql | 29 ++++++++++--------- 7 files changed, 54 insertions(+), 31 deletions(-) diff --git a/inc/admin/script_files/admin.fplinks.php b/inc/admin/script_files/admin.fplinks.php index 39531ea..33c208c 100644 --- a/inc/admin/script_files/admin.fplinks.php +++ b/inc/admin/script_files/admin.fplinks.php @@ -18,7 +18,7 @@ '1-News', '2-Account', '3-GameGuide', - '4-Interactive', + '4-Workshop', '5-Media', '6-Forums', '7-Community', diff --git a/inc/admin/template_files/admin.chartools.php b/inc/admin/template_files/admin.chartools.php index e197ec3..f18dd81 100644 --- a/inc/admin/template_files/admin.chartools.php +++ b/inc/admin/template_files/admin.chartools.php @@ -200,11 +200,22 @@

- diff --git a/inc/admin/template_files/admin.sendgamemail.php b/inc/admin/template_files/admin.sendgamemail.php index 6d100fb..10d630a 100644 --- a/inc/admin/template_files/admin.sendgamemail.php +++ b/inc/admin/template_files/admin.sendgamemail.php @@ -29,12 +29,23 @@

Send In Game Mail

:
| +
:
"; + if($x == 1) + { + $separator = " | "; + } + else + { + $separator = ""; + $x = 1; + } + + echo $separator . ""; if($user['cur_selected_realm'] == $Rlm['id']) { echo "".$Rlm['name'].""; @@ -213,7 +224,7 @@ { echo $Rlm['name']; } - echo " | "; + echo ""; } ?>
- diff --git a/inc/server/server.chars.php b/inc/server/server.chars.php index 9b42e6c..291641d 100644 --- a/inc/server/server.chars.php +++ b/inc/server/server.chars.php @@ -8,13 +8,16 @@ /* Original MangosWeb (C) 2007, Sasha, Nafe, TGM, Peec */ /****************************************************************************/ -//========================// if(INCLUDED !== TRUE) { echo "Not Included!"; exit; } -$pathway_info[] = array('title'=>$lang['Characters'],'link'=>''); -//========================// + +// build top of page navigation breadcrumbs +$realm = $DB->selectRow("SELECT * FROM realmlist WHERE `id`='".$user['cur_selected_realm']."' LIMIT 1"); +$pathway_info[] = array('title' => $lang['Characters'], 'link' => '?p=server&sub=chars'); +$pathway_info[] = array('title' => $realm['name'], 'link' => ''); + // Tell the cache not to cache the file because theres more then 1 page define("CACHE_FILE", FALSE); @@ -43,7 +46,7 @@ $cc = 0; -// array´s +// arrays $query1 = array(); //===== Filter ==========// diff --git a/inc/server/server.playersonline.php b/inc/server/server.playersonline.php index 0057dfb..2666719 100644 --- a/inc/server/server.playersonline.php +++ b/inc/server/server.playersonline.php @@ -8,7 +8,6 @@ /* Original MangosWeb (C) 2007, Sasha, Nafe, TGM, Peec */ /****************************************************************************/ -//========================// if(INCLUDED !== TRUE) { echo "Not Included!"; exit; @@ -22,10 +21,10 @@ redirect("?p=server&sub=playersonline",1); } -// ==================== // +// build top of page navigation breadcrumbs +$realm = $DB->selectRow("SELECT * FROM realmlist WHERE `id`='".$user['cur_selected_realm']."' LIMIT 1"); $pathway_info[] = array('title' => $lang['online_players'], 'link' => '?p=server&sub=playersonline'); $pathway_info[] = array('title' => $realm['name'], 'link' => ''); -// ==================== // // Tell the cache not to cache the file because we want live feeds define("CACHE_FILE", FALSE); diff --git a/inc/server/server.statistic.php b/inc/server/server.statistic.php index f370105..278436e 100644 --- a/inc/server/server.statistic.php +++ b/inc/server/server.statistic.php @@ -12,13 +12,13 @@ echo "Not Included!"; exit; } +// build top of page navigation breadcrumbs $realm = $DB->selectRow("SELECT * FROM realmlist WHERE `id`='".$user['cur_selected_realm']."' LIMIT 1"); $pathway_info[] = array('title' => 'Server Statistics', 'link' => '?p=server&sub=statistic'); $pathway_info[] = array('title' => $realm['name'], 'link' => ''); //initialize $num_chars variable $num_chars = 0; -//$realm_param = get_realm_byid($_COOKIE['cur_selected_realm']);; $rc = $CDB->select("SELECT race, count(race) AS `num` FROM `characters` GROUP BY race"); foreach($rc as $row) @@ -35,8 +35,6 @@ } $num_chars += $data[$i]; - - // echo "data[$i] = ".$data[$i]." - num_chars = $num_chars
"; } //Check if 0 entries to avoid PHP warnings if 0 chars in database. diff --git a/install/sql/full_install.sql b/install/sql/full_install.sql index 5c16bed..3c060c9 100644 --- a/install/sql/full_install.sql +++ b/install/sql/full_install.sql @@ -181,20 +181,21 @@ CREATE TABLE `mw_menu_items` ( -- ---------------------------- -- Records of mw_menu_items -- ---------------------------- -INSERT INTO `mw_menu_items` VALUES ('1', 'News', './', '1', '1', '0', '1'); -INSERT INTO `mw_menu_items` VALUES ('1', 'RSS', 'rss.php', '2', '1', '0', '2'); -INSERT INTO `mw_menu_items` VALUES ('2', 'Register', '?p=account&sub=register', '1', '1', '1', '3'); -INSERT INTO `mw_menu_items` VALUES ('2', 'Admin Panel', '?p=admin', '1', '3', '0', '4'); -INSERT INTO `mw_menu_items` VALUES ('7', 'Vote', '?p=vote', '1', '2', '0', '5'); -INSERT INTO `mw_menu_items` VALUES ('7', 'Shop', '?p=shop', '3', '2', '0', '6'); -INSERT INTO `mw_menu_items` VALUES ('2', 'Manage Account', '?p=account', '2', '2', '0', '7'); -INSERT INTO `mw_menu_items` VALUES ('4', 'Server Characters', '?p=server&sub=chars', '2', '1', '0', '8'); -INSERT INTO `mw_menu_items` VALUES ('4', 'Players Online', '?p=server&sub=playersonline', '3', '1', '0', '9'); -INSERT INTO `mw_menu_items` VALUES ('8', 'FAQ', '?p=support&sub=faq', '1', '1', '0', '10'); -INSERT INTO `mw_menu_items` VALUES ('7', 'Donate', '?p=donate', '2', '2', '0', '11'); -INSERT INTO `mw_menu_items` VALUES ('4', 'Realm Status', '?p=server&sub=realmstatus', '1', '1', '0', '12'); -INSERT INTO `mw_menu_items` VALUES ('2', 'Account Restore', '?p=account&sub=restore', '2', '1', '1', '13'); -INSERT INTO `mw_menu_items` VALUES ('4', 'Top Kills', '?p=server&sub=topkills', '1', '1', '0', '14'); +INSERT INTO `mw_menu_items` VALUES ('1', 'News', './', '1', '1', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('1', 'RSS', 'rss.php', '2', '1', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('2', 'Admin Panel', '?p=admin', '1', '3', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('2', 'Manage Account', '?p=account', '2', '2', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('2', 'Register', '?p=account&sub=register', '3', '1', '1', NULL); +INSERT INTO `mw_menu_items` VALUES ('2', 'Account Restore', '?p=account&sub=restore', '4', '1', '1', NULL); +INSERT INTO `mw_menu_items` VALUES ('4', 'Top Kills', '?p=server&sub=topkills', '1', '1', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('4', 'Characters', '?p=server&sub=chars', '2', '1', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('4', 'Players Online', '?p=server&sub=playersonline', '3', '1', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('4', 'Realm Status', '?p=server&sub=realmstatus', '4', '1', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('4', 'Server Statistics', '?p=server&sub=statistic', '5', '1', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('7', 'Donate', '?p=donate', '1', '2', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('7', 'Vote', '?p=vote', '2', '2', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('7', 'Shop', '?p=shop', '3', '2', '0', NULL); +INSERT INTO `mw_menu_items` VALUES ('8', 'FAQ', '?p=support&sub=faq', '1', '1', '0', NULL); -- ---------------------------- -- Table structure for `mw_news`
:
| +
:
"; + if($x == 1) + { + $separator = " | "; + } + else + { + $separator = ""; + $x = 1; + } + + echo $separator . ""; if($user['cur_selected_realm'] == $Rlm['id']) { echo "".$Rlm['name'].""; @@ -43,7 +54,7 @@ { echo $Rlm['name']; } - echo " | "; + echo ""; } ?>