Skip to content

Commit

Permalink
Merge pull request #11 from paintballrefjosh/4.0.6
Browse files Browse the repository at this point in the history
4.0.6
  • Loading branch information
Josh authored Feb 10, 2017
2 parents 1e1aefe + 94e3cc7 commit 36650ce
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 93 deletions.
2 changes: 1 addition & 1 deletion core/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= " ";
Expand Down
141 changes: 81 additions & 60 deletions core/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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-05, 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 . ' &copy; 2017, <a href="http://www.mistvale.com">Mistvale Dev Team</a>. 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;
Expand All @@ -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']))
Expand All @@ -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));
}

Expand All @@ -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"))
Expand All @@ -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'))
Expand All @@ -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'))
Expand All @@ -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/');
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion inc/admin/script_files/admin.fplinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'1-News',
'2-Account',
'3-GameGuide',
'4-Interactive',
'4-Workshop',
'5-Media',
'6-Forums',
'7-Community',
Expand Down
17 changes: 14 additions & 3 deletions inc/admin/template_files/admin.chartools.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,22 @@
<center><h2><?php echo $lang['char_list']; ?></h2></center>
<table>
<tr>
<td align='center'> <b><?php echo $lang['realm']; ?>:</b><br />|
<td align='center'> <b><?php echo $lang['realm']; ?>:</b><br />
<?php
$x = 0;
foreach($Realms as $Rlm)
{
echo "<a href=\"javascript:setcookie('cur_selected_realm', '". $Rlm['id'] ."'); window.location.reload();\">";
if($x == 1)
{
$separator = " | ";
}
else
{
$separator = "";
$x = 1;
}

echo $separator . "<a href=\"javascript:setcookie('cur_selected_realm', '". $Rlm['id'] ."'); window.location.reload();\">";
if($user['cur_selected_realm'] == $Rlm['id'])
{
echo "<b><font color=green>".$Rlm['name']."</font></b>";
Expand All @@ -213,7 +224,7 @@
{
echo $Rlm['name'];
}
echo "</a> | ";
echo "</a>";
}
?>
</td>
Expand Down
17 changes: 14 additions & 3 deletions inc/admin/template_files/admin.sendgamemail.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,23 @@
<h2><center>Send In Game Mail</center></h2>
<table>
<tr>
<td align='center'> <b><?php echo $lang['realm']; ?>:</b><br />|
<td align='center'><b><?php echo $lang['realm']; ?>:</b><br />
<?php
$Realms = getRealmlist('0');
$x = 0;
foreach($Realms as $Rlm)
{
echo "<a href=\"javascript:setcookie('cur_selected_realm', '". $Rlm['id'] ."'); window.location.reload();\">";
if($x == 1)
{
$separator = " | ";
}
else
{
$separator = "";
$x = 1;
}

echo $separator . "<a href=\"javascript:setcookie('cur_selected_realm', '". $Rlm['id'] ."'); window.location.reload();\">";
if($user['cur_selected_realm'] == $Rlm['id'])
{
echo "<b><font color=green>".$Rlm['name']."</font></b>";
Expand All @@ -43,7 +54,7 @@
{
echo $Rlm['name'];
}
echo "</a> | ";
echo "</a>";
}
?>
</td>
Expand Down
11 changes: 7 additions & 4 deletions inc/server/server.chars.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -43,7 +46,7 @@

$cc = 0;

// array´s
// arrays
$query1 = array();

//===== Filter ==========//
Expand Down
16 changes: 13 additions & 3 deletions inc/server/server.playersonline.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@
/* Original MangosWeb (C) 2007, Sasha, Nafe, TGM, Peec */
/****************************************************************************/

//========================//
if(INCLUDED !== TRUE) {
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);
}

// 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);
Expand Down
Loading

0 comments on commit 36650ce

Please sign in to comment.