Skip to content

Commit

Permalink
ADM: Make server offline feature work
Browse files Browse the repository at this point in the history
  • Loading branch information
Gorlum committed Jul 21, 2010
1 parent 2fba88c commit 41f0b85
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 34 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ config.php
/cache/

# Ignore backup folder
/admin/backup/
/admin/sxd/backup/
/admin/sxd/cfg.php
/admin/sxd/error.log
/admin/sxd/ses.php
Expand All @@ -23,4 +21,7 @@ config.php
!.gitattributes

# Ignore backups
admin/backup/*.gz
/admin/backup/*.gz
/admin/backup/*.bz2
/admin/sxd/backup/*.gz
/admin/sxd/backup/*.bz2
19 changes: 10 additions & 9 deletions admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@
include($ugamela_root_path . 'common.' . $phpEx);

function DisplayGameSettingsPage ( $CurrentUser ) {
global $lang, $game_config, $_POST;
global $lang, $game_config, $_POST, $config;

includeLang('admin/settings');

if ( $CurrentUser['authlevel'] >= 3 ) {
if ($_POST['opt_save'] == "1") {
// Jeu Ouvert ou Ferm� !
if (isset($_POST['closed']) && $_POST['closed'] == 'on') {
$game_config['game_disable'] = "1";
$game_config['close_reason'] = addslashes( $_POST['close_reason'] );
$config->game_disable = "1";
} else {
$game_config['game_disable'] = "0";
$game_config['close_reason'] = "";
$config->game_disable = "0";
}
$config->game_disable_reason = addslashes( $_POST['game_disable_reason'] );

// Y a un News Frame ? !
if (isset($_POST['newsframe']) && $_POST['newsframe'] == 'on') {
Expand Down Expand Up @@ -119,8 +118,10 @@ function DisplayGameSettingsPage ( $CurrentUser ) {
}

// Activation du jeu
doquery("UPDATE {{table}} SET `config_value` = '". $game_config['game_disable'] ."' WHERE `config_name` = 'game_disable';", 'config');
doquery("UPDATE {{table}} SET `config_value` = '". $game_config['close_reason'] ."' WHERE `config_name` = 'close_reason';", 'config');
// doquery("UPDATE {{table}} SET `config_value` = '". $config->game_disable ."' WHERE `config_name` = 'game_disable';", 'config');
// doquery("UPDATE {{table}} SET `config_value` = '". $config->game_disable_reason ."' WHERE `config_name` = 'game_disable_reason';", 'config');
$config->db_saveItem('game_disable');
$config->db_saveItem('game_disable_reason');

// Configuration du Jeu
doquery("UPDATE {{table}} SET `config_value` = '". $game_config['game_name'] ."' WHERE `config_name` = 'game_name';", 'config');
Expand Down Expand Up @@ -168,8 +169,8 @@ function DisplayGameSettingsPage ( $CurrentUser ) {
$parse['deuterium_basic_income'] = $game_config['deuterium_basic_income'];
$parse['energy_basic_income'] = $game_config['energy_basic_income'];

$parse['closed'] = ($game_config['game_disable'] == 1) ? " checked = 'checked' ":"";
$parse['close_reason'] = stripslashes( $game_config['close_reason'] );
$parse['closed'] = ($config->game_disable == 1) ? " checked = 'checked' ":"";
$parse['game_disable_reason'] = stripslashes( $config->game_disable_reason );

$parse['newsframe'] = ($game_config['OverviewNewsFrame'] == 1) ? " checked = 'checked' ":"";
$parse['NewsTextVal'] = stripslashes( $game_config['OverviewNewsText'] );
Expand Down
21 changes: 9 additions & 12 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@
include_once('includes/init.inc');

if (INSTALL != true) {
if ($InLogin != true) {
if (!$InLogin) {
$Result = CheckTheUser ( $IsUserChecked );
$IsUserChecked = $Result['state'];
$user = $Result['record'];
} elseif ($InLogin == false) {

// Jeux en mode 'clos' ???
if( $game_config['game_disable']) {
if( $config->game_disable) {
if ($user['authlevel'] < 1) {
message ( stripslashes ( $game_config['close_reason'] ), $game_config['game_name'] );
message ( stripslashes ( $config->game_disable_reason ), $config->game_name );
die();
} else {
print( "<div align=center style='font-size: 24; font-weight: bold; color:red;'>" . $config->game_disable_reason . '</div><br>' );
}
}
}

if ( isset ($user) ) {
$_lastupdate = doquery("SELECT `lastupdate` FROM {{table}} LIMIT 1;", 'update');
$row = mysql_fetch_row($_lastupdate);

if(($time_now-$row[0]>8)&&(!$doNotUpdateFleet)){
// doquery("LOCK TABLE {{table}} WRITE", 'update');
doquery("UPDATE {{table}} SET `lastupdate` = ".$time_now."", 'update');
// doquery("UNLOCK TABLES", '');
$_lastupdate = $time_now;
if(($time_now - $config->flt_lastUpdate > 8 ) && (!$doNotUpdateFleet)){
$config->db_saveItem('flt_lastUpdate', $time_now);

$_fleets = doquery("SELECT DISTINCT fleet_start_galaxy, fleet_start_system, fleet_start_planet, fleet_start_type FROM {{table}} WHERE `fleet_start_time` <= '{$time_now}' ORDER BY fleet_start_time;", 'fleets');
while ($row = mysql_fetch_array($_fleets)) {
Expand Down
2 changes: 1 addition & 1 deletion docs/supernova.sql
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ INSERT INTO `sn_config` VALUES ('BannerURL', '/scripts/createbanner.php');
INSERT INTO `sn_config` VALUES ('banner_source_post', '../images/bann.png');
INSERT INTO `sn_config` VALUES ('BuildLabWhileRun', '0');
INSERT INTO `sn_config` VALUES ('chat_admin_msgFormat', '[c=purple]$2[/c]');
INSERT INTO `sn_config` VALUES ('close_reason', 'Извините, производится техобслуживание.');
INSERT INTO `sn_config` VALUES ('game_disable_reason', 'Извините, производится техобслуживание.');
INSERT INTO `sn_config` VALUES ('COOKIE_NAME', 'supernova0');
INSERT INTO `sn_config` VALUES ('crystal_basic_income', '20');
INSERT INTO `sn_config` VALUES ('dbVersion', '1');
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ class classConfig extends classPersistent {
protected $defaults = array(
'BannerOverviewFrame' => 1,
'BuildLabWhileRun' => 0,
'close_reason' => "SuperNova is in maintenance mode! Please return later!",
'COOKIE_NAME' => "SuperNova",
'crystal_basic_income' => 20,
'debug' => 0,
Expand All @@ -214,6 +213,7 @@ class classConfig extends classPersistent {
'ForumUserBarFrame' => 1,
'forum_url' => "/forum/",
'game_disable' => 0,
'game_disable_reason' => "SuperNova is in maintenance mode! Please return later!",
'game_name' => "SuperNova",
'game_speed' => 2500,
'initial_fields' => 163,
Expand Down
4 changes: 2 additions & 2 deletions includes/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
'BannerURL' => "/scripts/createbanner.php",
'banner_source_post' => "../images/bann.png",
'BuildLabWhileRun' => 0,
'close_reason' => "gGame is in maintenance mode! Please return later!",
'COOKIE_NAME' => "gGame",
'game_disable_reason' => "SuperNova is in maintenance mode! Please return later!",
'COOKIE_NAME' => "SuperNova",
'crystal_basic_income' => 20,
'debug' => 0,
'Defs_Cdr' => 30,
Expand Down
4 changes: 2 additions & 2 deletions includes/functions/FlyingFleetHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function FlyingFleetHandler (&$planet) {
// $dbg_msg .= "&nbsp;&nbsp;FleetHandler for planet ".PrintPlanetCoords($planet)."<br />";
$process_delay = 10; //seconds

// doquery("LOCK TABLE {{table}}aks WRITE, {{table}}rw WRITE, {{table}}errors WRITE, {{table}}messages WRITE, {{table}}fleets WRITE, {{table}}planets WRITE, {{table}}galaxy WRITE ,{{table}}users WRITE", "");
doquery("LOCK TABLE {{table}}aks WRITE, {{table}}rw WRITE, {{table}}errors WRITE, {{table}}messages WRITE, {{table}}fleets WRITE, {{table}}planets WRITE, {{table}}galaxy WRITE ,{{table}}users WRITE", "");

$QryFleet = "SELECT * FROM `{{table}}` ";
$QryFleet .= "WHERE (";
Expand Down Expand Up @@ -102,7 +102,7 @@ function FlyingFleetHandler (&$planet) {
}

// $dbg_msg .= "&nbsp;&nbsp;Fleet ".$CurrentFleet['fleet_id'].". EndOf FleetHandler<br />";
// doquery("UNLOCK TABLES", "");
doquery("UNLOCK TABLES", "");
}

?>
4 changes: 2 additions & 2 deletions install/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
$Result = CheckTheUser ( $IsUserChecked );
$IsUserChecked = $Result['state'];
$user = $Result['record'];
} elseif ($InLogin == false) {

if( $config->game_disable)
if ($user['authlevel'] < 1)
message ( stripslashes ( $game_config['close_reason'] ), $game_config['game_name'] );
message ( stripslashes ( $config->game_disable_reason ), $config->game_name );
}
}

Expand Down
2 changes: 1 addition & 1 deletion language/ru/admin/settings.mo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $lang['adm_opt_game_fspeed'] = "
$lang['adm_opt_game_pspeed'] = "Ñêîðîñòü ïðîèçâîäèòåëüíîñòè<br>(íîðìàëüíàÿ = 1)";
$lang['adm_opt_game_forum'] = "Àäðåñ ôîðóìà";
$lang['adm_opt_game_copyrigh'] = "Copyright";
$lang['adm_opt_game_online'] = "On-line ñòàòóñ";
$lang['adm_opt_game_online'] = "Îòêëþ÷èòü èãðó";
$lang['adm_opt_game_offreaso'] = "Ïðè÷èíà îòêëþ÷åíèÿ";
$lang['adm_opt_plan_settings'] = "Ïàðàìåòðû ïëàíåò";
$lang['adm_opt_plan_initial'] = "Ðàçìåð ãëàâíîé ïëàíåòû";
Expand Down
2 changes: 1 addition & 1 deletion templates/OpenGame/admin/options_body.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<th><input name="closed"{closed} type="checkbox" /></th>
</tr><tr>
<th>{adm_opt_game_offreaso}<br></th>
<th><textarea name="close_reason" cols="80" rows="5" size="80" >{close_reason}</textarea></th>
<th><textarea name="game_disable_reason" cols="80" rows="5" size="80" >{game_disable_reason}</textarea></th>
</tr><tr>
<td class="c" colspan="2">{adm_opt_plan_settings}</td>
</tr><tr>
Expand Down

0 comments on commit 41f0b85

Please sign in to comment.