/** * Reload the variables which are stored within this object specificially, ie everything * except aggregates */ function load() { global $DB; $row = $DB->sql_hash("SELECT\r\n\t\t\tg.id,\r\n\t\t\tg.variantID,\r\n\t\t\tLOWER(HEX(g.password)) as password,\r\n\t\t\tg.turn,\r\n\t\t\tg.phase,\r\n\t\t\tg.processTime,\r\n\t\t\tg.name,\r\n\t\t\tg.gameOver,\r\n\t\t\tg.attempts,\r\n\t\t\tg.pot,\r\n\t\t\tg.potType,\r\n\t\t\tg.phaseMinutes,\r\n\t\t\tg.processStatus,\r\n\t\t\tg.pauseTimeRemaining,\r\n\t\t\tg.minimumBet,\r\n\t\t\tg.anon,\r\n\t\t\tg.pressType,\r\n\t\t\tg.missingPlayerPolicy,\r\n\t\t\tg.drawType,\r\n\t\t\tg.minimumReliabilityRating\r\n\t\t\tFROM wD_Games g\r\n\t\t\tWHERE g.id=" . $this->id . ' ' . $this->lockMode); if (!isset($row['id']) or !$row['id']) { libHTML::error(l_t("Game not found; ensure a valid game ID has been given. Check that this game hasn't been canceled, you may have received a message about it on your <a href='index.php' class='light'>home page</a>.")); } $this->loadRow($row); }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Affero General Public License along with webDiplomacy. If not, see <http://www.gnu.org/licenses/>. */ /** * @package Base * @subpackage Forms */ require_once 'header.php'; require_once l_r('objects/mailer.php'); global $Mailer; $Mailer = new Mailer(); if (!$User->type['User']) { libHTML::error(l_t("You can't use the user control panel, you're using a guest account.")); } libHTML::starthtml(); if (isset($_REQUEST['optout'])) { if ($_REQUEST['optout'] == 'on' && !$User->type['Donator']) { libHTML::notice(l_t("Opt-out"), l_t("Are you sure you want to opt-out of Plura? It helps keep this place running and on " . "most modern computers is barely noticable.") . "<br />\r\n\t\t\t<form><input type='submit' class='form-submit' name='optout' value='" . l_t("Opt-out") . "' /></form>"); } elseif ($_REQUEST['optout'] == l_t('Opt-out') && !$User->type['Donator']) { $DB->sql_put("UPDATE wD_Users SET type = CONCAT_WS(',',type,'Donator') WHERE id = " . $User->id); $User->type['Donator'] = true; libHTML::notice(l_t("Opt-out"), l_t("You've opted-out of running the Plura applet. If you decide to re-enable it " . "later the <a href='faq.php' class='light'>FAQ</a> has a link to do so.")); } elseif ($_REQUEST['optout'] == 'off' && $User->type['Donator']) { libHTML::notice(l_t("Opt-out"), l_t("Would you like to opt back into running the Plura Java applet?") . "<br />\r\n\t\t\t<form><input type='submit' class='form-submit' name='optout' value='" . l_t('Opt-in') . "' /></form>"); } elseif ($_REQUEST['optout'] == l_t('Opt-in') && $User->type['Donator']) { $types = array(); foreach ($User->type as $type => $isMember) { if ($isMember && $type != 'Donator') {
/** * Logon as a user with a key. Display a notice and terminate if there is * a problem, otherwise return a $User object corresponding to the given * key. * Will also attempt to use legacy keys * * @param string $key The auth key (/legacy cookie) * @param bool[optional] $session Should the user be logged on only for the session true/false * * @return User A user object */ public static function key_User($key, $session = false) { global $DB; $userID = self::key_UserID($key); if (!$userID) { if (isset($_REQUEST['noRefresh'])) { // We have been sent back from the logoff script, and clearly not with a wiped key // Load some data that will give useful context in the trigger_error errorlog // which will occur below. if (isset($_COOKIE['wD-Key']) and $_COOKIE['wD-Key']) { $cookieKey = $_COOKIE['wD-Key']; } $user_agent = $_SERVER['HTTP_USER_AGENT']; $allCookies = print_r($_COOKIE, true); $success = self::keyWipe(); // Make sure there's no refresh loop trigger_error(l_t("An invalid log-on cookie was given, but it seems an attempt to remove it has failed.") . "<br /><br />" . l_t("This error has been logged, please e-mail %s if the problem persists, or you can't log on.", Config::$modEMail)); } else { self::keyWipe(); header('refresh: 3; url=logon.php?logoff=on'); libHTML::error(l_t("You have been logged out. " . "You are being redirected to the log-on page.") . "<br /><br />" . l_t("Inform the moderators at %s if the problem persists, or you can't log on.", Config::$modEMail)); } } // This user ID is authenticated self::keySet($userID, $session); global $User; try { $User = new User($userID); } catch (Exception $e) { self::keyWipe(); header('refresh: 3; url=logon.php?logoff=on'); libHTML::error(l_t("You are using an invalid log on cookie, which has been wiped. Please try logging on again.")); } $User->logon(); return $User; }
header('refresh: 4; url=logon.php?noRefresh=on'); libHTML::notice(l_t("Logged out"), l_t("You have been logged out, and are being redirected to the logon page.")); } global $User; $User = libAuth::auth(); if ($User->type['Admin']) { Config::$debug = true; if (isset($_REQUEST['auid']) || isset($_SESSION['auid'])) { $User = libAuth::adminUserSwitch($User); } else { define('AdminUserSwitch', $User->id); } } elseif ($Misc->Maintenance) { unset($DB); // This lets libHTML know there's a problem libHTML::error(Config::$serverMessages['Maintenance']); } } // This gets called by libHTML::footer function close() { global $DB, $Misc; // This isn't put into the database destructor in case of dieing due to an error if (is_object($DB)) { $Misc->write(); if (!defined('ERROR')) { $DB->sql_put("COMMIT"); } unset($DB); } ob_end_flush();
/** * Get a MySQL named lock, will stop the script if the lock cannot be obtained * * @param string $name The name of the lock * @param int[optional] $wait The time to wait before giving up, default is 8 seconds */ public function get_lock($name, $wait = 8) { list($success) = $this->sql_row("SELECT GET_LOCK('" . $name . "', " . $wait . ")"); if ($success != 1) { libHTML::error(l_t("A database lock (%s) is required to complete this page safely, but it could not be " . "acquired (it's being used by someone else). This usually means the server is running slowly, and " . "taking unusually long to complete tasks.", $name) . "<br /><br />" . l_t("Please wait a few moments and try again. Sorry for the inconvenience.")); } }
$Misc->Maintenance = 1; $Misc->write(); libHTML::error('Cannot update unless in maintenance mode; maintenance mode set, wait a minute for clients to finish and run again.'); } ini_set('memory_limit',"20M"); // 8M is the default ini_set('max_execution_time','120'); $DB->get_lock('install',0); // Make sure only one person performs the update $Misc->read(); // Check we haven't updated while waiting for the lock if( $Misc->Version == VERSION ) libHTML::notice('Complete','Update complete'); */ if ($Misc->Version == 98 || $Misc->Version == 99) { $Misc->Version = 100; $Misc->write(); libHTML::notice('Updated', 'Updated version number, please refresh.'); } elseif ($Misc->Version == 104 || $Misc->Version == 130) { $Misc->Version = 131; $Misc->write(); libHTML::notice('Updated', 'Updated version number, please refresh.'); } else { unset($DB); // Prevent libHTML from trying to do anything fancy if the database is out of sync with the code libHTML::error("Database version " . $Misc->Version / 100 . " and code\r\n\t\t\tversion " . VERSION / 100 . " don't match, and no\r\n\t\t\tauto-update script is available for this version.\r\n\t\t\tPlease wait while the admin runs update.sql"); } print '</div>'; libHTML::footer();
break; case 'Graph': require_once l_r('board/info/graph.php'); break; case 'Maps': require_once l_r('board/info/maps.php'); break; case 'Reports': require_once l_r('lib/modnotes.php'); libModNotes::checkDeleteNote(); libModNotes::checkInsertNote(); print libModNotes::reportBoxHTML('Game', $Game->id); print libModNotes::reportsDisplay('Game', $Game->id); break; default: libHTML::error(l_t("Invalid info parameter given.")); } print '</div>'; libHTML::footer(); } if (!$Game->Members->isJoined() && $Game->watched() && isset($_REQUEST['unwatch'])) { print '<div class="content-notice gameTimeRemaining">' . '<form method="post" action="redirect.php">' . 'Are you sure you wish to remove this game from your spectated games list? ' . '<input type="hidden" name="gameID" value="' . $Game->id . '">' . '<input type="submit" class="form-submit" name="unwatch" value="Confirm"> </form></div>'; } // Before HTML pre-generate everything and check input, so game summary header will be accurate if (isset($Member) && $Member->status == 'Playing' && $Game->phase != 'Finished') { if ($Game->phase != 'Pre-game') { if (isset($_REQUEST['Unpause'])) { $_REQUEST['Pause'] = 'on'; } // Hack because Unpause = toggle Pause
} if (!$UserProfile->type['User'] && !$UserProfile->type['Banned']) { $message = l_t('Cannot display profile: The specified account #%s is not an active user;', $userID) . ' '; if ($UserProfile->type['Guest']) { $message .= l_t('it\'s a guest account, used by unregistered people to ' . 'view the server without interacting.'); } elseif ($UserProfile->type['System']) { $message .= l_t('it\'s a system account, without a real human using it.'); } else { $message .= l_t('in fact I\'m not sure what this account is...'); } foreach ($UserProfile->type as $name => $on) { if ($on) { $message .= l_t($name) . ', '; } } libHTML::error($message); } libHTML::starthtml(); print '<div class="content">'; if (isset($searchReturn)) { print '<p class="notice">' . $searchReturn . '</p>'; } if (isset($_REQUEST['detail'])) { print '<p>(<a href="profile.php?userID=' . $UserProfile->id . '">' . l_t('Back') . '</a>)</p>'; switch ($_REQUEST['detail']) { case 'threads': $dir = User::cacheDir($UserProfile->id); if (file_exists($dir . '/profile_threads.html')) { print file_get_contents($dir . '/profile_threads.html'); } else { libAuth::resourceLimiter('view threads', 20);
along with webDiplomacy. If not, see <http://www.gnu.org/licenses/>. */ /** * @package Base * @subpackage Forms */ require_once 'header.php'; require_once l_r('objects/mailer.php'); global $Mailer; $Mailer = new Mailer(); if ($Misc->Panic) { libHTML::notice(l_t('Registration disabled'), l_t("Registration has been temporarily disabled while we take care of an " . "unexpected problem. Please try again later, sorry for the inconvenience.")); } // The user must be guest to register a new account if ($User->type['User']) { libHTML::error(l_t("You're attempting to create a " . "new user account when you already have one. Please use " . "your existing user account.")); } libHTML::starthtml(); $page = 'firstValidationForm'; if (isset($_COOKIE['imageToken']) && isset($_REQUEST['imageText']) && isset($_REQUEST['emailValidate'])) { try { // Validate and send e-mail $imageToken = explode('|', $_COOKIE['imageToken'], 2); if (count($imageToken) != 2) { throw new Exception(l_t("A bad anti-script code was given, please try again")); } list($Hash, $Time) = $imageToken; if (md5(Config::$secret . $_REQUEST['imageText'] . $_SERVER['REMOTE_ADDR'] . $Time) != $Hash) { throw new Exception(l_t("An invalid anti-script code was given, please try again")); } elseif (time() - 3 * 60 > $Time) { throw new Exception(l_t("This anti-script code has expired, please submit it within 3 minutes"));
public static function errorTimes() { global $Misc; if (!libError::isLoggingEnabled()) { return array(); } static $errorTimes; if (isset($errorTimes)) { return $errorTimes; } $dir = self::directory(); if (!($handle = @opendir($dir))) { libHTML::error("Could not open error log directory"); } $errorTimes = array(); while (false !== ($file = readdir($handle))) { list($timestamp) = explode('.', $file); if (intval($timestamp) < 1000) { continue; } else { $errorTimes[] = intval($timestamp); } } closedir($handle); sort($errorTimes, SORT_NUMERIC); $errorTimes = array_reverse($errorTimes); $Misc->ErrorLogs = count($errorTimes); return $errorTimes; }
webDiplomacy is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. webDiplomacy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Affero General Public License along with webDiplomacy. If not, see <http://www.gnu.org/licenses/>. */ require_once 'header.php'; if (!defined('FACEBOOKSCRIPT')) { libHTML::error('This page is Facebook-only.'); } libHTML::starthtml(); print '<fb:request-form action="" method="POST" invite="true" type="Diplomacy" content="' . l_t('webDiplomacy is based on the popular turn-based-strategy game of international relations. ' . 'Play with your friends and see if you can conquer Europe.') . ' ' . '<fb:req-choice url=\'' . DYNAMICSRV . '\' label=\'' . l_t('Add webDiplomacy') . '\' />"> <fb:multi-friend-selector showborder="false" actiontext="' . l_t('Invite more friends to play webDiplomacy with you:') . '"> </fb:request-form>'; print '</div>';
/** * Return a Variant object corresponding to a game ID. This has to * @param unknown_type $gameID * @return unknown_type */ public static function loadFromGameID($gameID) { global $DB; if (!isset(self::$variantIDsByGameID[$gameID])) { $gameID = (int) $gameID; list($variantID) = $DB->sql_row("SELECT variantID FROM wD_Games WHERE id=" . $gameID); if (!isset($variantID) || !$variantID) { libHTML::error(l_t("Game not found, or has an invalid variant set; ensure a valid game ID has been given. Check that this game hasn't been canceled, you may have received a message about it on your <a href='index.php' class='light'>home page</a>.")); } self::$variantIDsByGameID[$gameID] = $variantID; } return self::loadFromVariantID(self::$variantIDsByGameID[$gameID]); }