本文整理汇总了PHP中Universe::availableUniverses方法的典型用法代码示例。如果您正苦于以下问题:PHP Universe::availableUniverses方法的具体用法?PHP Universe::availableUniverses怎么用?PHP Universe::availableUniverses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Universe
的用法示例。
在下文中一共展示了Universe::availableUniverses方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
function show()
{
global $LNG;
$referralID = HTTP::_GP('ref', 0);
if (!empty($referralID)) {
$this->redirectTo('index.php?page=register&referralID=' . $referralID);
}
$universeSelect = array();
foreach (Universe::availableUniverses() as $uniId) {
$config = Config::get($uniId);
$universeSelect[$uniId] = $config->uni_name . ($config->game_disable == 0 ? $LNG['uni_closed'] : '');
}
$Code = HTTP::_GP('code', 0);
$loginCode = false;
if (isset($LNG['login_error_' . $Code])) {
$loginCode = $LNG['login_error_' . $Code];
}
$config = Config::get();
$this->assign(array('universeSelect' => $universeSelect, 'code' => $loginCode, 'descHeader' => sprintf($LNG['loginWelcome'], $config->game_name), 'descText' => sprintf($LNG['loginServerDesc'], $config->game_name), 'loginInfo' => sprintf($LNG['loginInfo'], '<a href="index.php?page=rules">' . $LNG['menu_rules'] . '</a>')));
$screenshots = array();
$directoryIterator = new DirectoryIterator('styles/resource/images/login/screens/');
foreach ($directoryIterator as $fileInfo) {
/** @var $fileInfo DirectoryIterator */
if (!$fileInfo->isFile()) {
continue;
}
$thumbnail = 'styles/resource/images/login/screens/' . $fileInfo->getFilename();
if (file_exists('styles/resource/images/login/screens/thumbnails/' . $fileInfo->getFilename())) {
$thumbnail = 'styles/resource/images/login/screens/thumbnails/' . $fileInfo->getFilename();
}
$screenshots[] = array('path' => 'styles/resource/images/login/screens/' . $fileInfo->getFilename(), 'thumbnail' => $thumbnail);
}
$this->assign(array('screenshots' => $screenshots));
$this->display('page.index.default.tpl');
}
示例2: ShowTopnavPage
/**
* 2Moons
* Copyright (C) 2012 Jan Kröpke
*
* For the full copyright and license information, please view the LICENSE
*
* @package 2Moons
* @author Jan Kröpke <info@2moons.cc>
* @copyright 2012 Jan Kröpke <info@2moons.cc>
* @licence MIT
* @version 1.7.2 (2013-03-18)
* @info $Id$
* @link http://2moons.cc/
*/
function ShowTopnavPage()
{
global $LNG, $USER;
$template = new template();
$universeSelect = array();
foreach (Universe::availableUniverses() as $uniId) {
$config = Config::get($uniId);
$universeSelect[$uniId] = sprintf('%s (ID: %d)', $config->uni_name, $uniId);
}
ksort($universeSelect);
$template->assign_vars(array('ad_authlevel_title' => $LNG['ad_authlevel_title'], 're_reset_universe' => $LNG['re_reset_universe'], 'mu_universe' => $LNG['mu_universe'], 'mu_moderation_page' => $LNG['mu_moderation_page'], 'adm_cp_title' => $LNG['adm_cp_title'], 'adm_cp_index' => $LNG['adm_cp_index'], 'adm_cp_logout' => $LNG['adm_cp_logout'], 'sid' => session_id(), 'id' => $USER['id'], 'authlevel' => $USER['authlevel'], 'AvailableUnis' => $universeSelect, 'UNI' => Universe::getEmulated()));
$template->show('ShowTopnavPage.tpl');
}
示例3: show
function show()
{
global $LNG;
$universeSelect = array();
$referralData = array('id' => 0, 'name' => '');
$accountName = "";
$externalAuth = HTTP::_GP('externalAuth', array());
$referralID = HTTP::_GP('referralID', 0);
foreach (Universe::availableUniverses() as $uniId) {
$config = Config::get($uniId);
$universeSelect[$uniId] = $config->uni_name . ($config->game_disable == 0 || $config->reg_closed == 1 ? $LNG['uni_closed'] : '');
}
if (!isset($externalAuth['account'], $externalAuth['method'])) {
$externalAuth['account'] = 0;
$externalAuth['method'] = '';
} else {
$externalAuth['method'] = strtolower(str_replace(array('_', '\\', '/', '.', ""), '', $externalAuth['method']));
}
if (!empty($externalAuth['account']) && file_exists('includes/extauth/' . $externalAuth['method'] . '.class.php')) {
$path = 'includes/extauth/' . $externalAuth['method'] . '.class.php';
require $path;
$methodClass = ucwords($externalAuth['method']) . 'Auth';
/** @var $authObj externalAuth */
$authObj = new $methodClass();
if (!$authObj->isActiveMode()) {
$this->redirectTo('index.php?code=5');
}
if (!$authObj->isValid()) {
$this->redirectTo('index.php?code=4');
}
$accountData = $authObj->getAccountData();
$accountName = $accountData['name'];
}
$config = Config::get();
if ($config->ref_active == 1 && !empty($referralID)) {
$db = Database::get();
$sql = "SELECT username FROM %%USERS%% WHERE id = :referralID AND universe = :universe;";
$referralAccountName = $db->selectSingle($sql, array(':referralID' => $referralID, ':universe' => Universe::current()), 'username');
if (!empty($referralAccountName)) {
$referralData = array('id' => $referralID, 'name' => $referralAccountName);
}
}
$this->assign(array('referralData' => $referralData, 'accountName' => $accountName, 'externalAuth' => $externalAuth, 'universeSelect' => $universeSelect, 'registerRulesDesc' => sprintf($LNG['registerRulesDesc'], '<a href="index.php?page=rules">' . $LNG['menu_rules'] . '</a>')));
$this->display('page.register.default.tpl');
}
示例4: run
function run()
{
$config = Config::get(ROOT_UNI);
$unis = Universe::availableUniverses();
//Delete old messages
$del_before = TIMESTAMP - $config->del_oldstuff * 86400;
$del_inactive = TIMESTAMP - $config->del_user_automatic * 86400;
$del_deleted = TIMESTAMP - $config->del_user_manually * 86400;
if ($del_inactive === TIMESTAMP) {
$del_inactive = 2147483647;
}
$sql = 'DELETE FROM %%MESSAGES%% WHERE `message_time` < :time;';
Database::get()->delete($sql, array(':time' => $del_before));
$sql = 'DELETE FROM %%ALLIANCE%% WHERE `ally_members` = 0;';
Database::get()->delete($sql);
$sql = 'DELETE FROM %%PLANETS%% WHERE `destruyed` < :time AND `destruyed` != 0;';
Database::get()->delete($sql, array(':time' => TIMESTAMP));
$sql = 'DELETE FROM %%SESSION%% WHERE `lastonline` < :time;';
Database::get()->delete($sql, array(':time' => TIMESTAMP - SESSION_LIFETIME));
$sql = 'DELETE FROM %%FLEETS_EVENT%% WHERE fleetID NOT IN (SELECT fleet_id FROM %%FLEETS%%);';
Database::get()->delete($sql);
$sql = 'UPDATE %%USERS%% SET `email_2` = `email` WHERE `setmail` < :time;';
Database::get()->update($sql, array(':time' => TIMESTAMP));
$sql = 'SELECT `id` FROM %%USERS%% WHERE `authlevel` = :authlevel
AND ((`db_deaktjava` != 0 AND `db_deaktjava` < :timeDeleted) OR `onlinetime` < :timeInactive);';
$deleteUserIds = Database::get()->select($sql, array(':authlevel' => AUTH_USR, ':timeDeleted' => $del_deleted, ':timeInactive' => $del_inactive));
if (empty($deleteUserIds)) {
foreach ($deleteUserIds as $dataRow) {
PlayerUtil::deletePlayer($dataRow['id']);
}
}
foreach ($unis as $uni) {
$sql = 'SELECT units FROM %%TOPKB%% WHERE `universe` = :universe ORDER BY units DESC LIMIT 99,1;';
$battleHallLowest = Database::get()->selectSingle($sql, array(':universe' => $uni), 'units');
if (!is_null($battleHallLowest)) {
$sql = 'DELETE %%TOPKB%%, %%TOPKB_USERS%%
FROM %%TOPKB%%
INNER JOIN %%TOPKB_USERS%% USING (rid)
WHERE `universe` = :universe AND `units` < :battleHallLowest;';
Database::get()->delete($sql, array(':universe' => $uni, ':battleHallLowest' => $battleHallLowest));
}
}
$sql = 'DELETE FROM %%RW%% WHERE `time` < :time AND `rid` NOT IN (SELECT `rid` FROM %%TOPKB%%);';
Database::get()->delete($sql, array(':time' => $del_before));
}
示例5: show
function show()
{
global $LNG;
$referralID = HTTP::_GP('ref', 0);
if (!empty($referralID)) {
$this->redirectTo('index.php?page=register&referralID=' . $referralID);
}
$universeSelect = array();
foreach (Universe::availableUniverses() as $uniId) {
$config = Config::get($uniId);
$universeSelect[$uniId] = $config->uni_name . ($config->game_disable == 0 ? $LNG['uni_closed'] : '');
}
$Code = HTTP::_GP('code', 0);
$loginCode = false;
if (isset($LNG['login_error_' . $Code])) {
$loginCode = $LNG['login_error_' . $Code];
}
$config = Config::get();
$this->assign(array('universeSelect' => $universeSelect, 'code' => $loginCode, 'descHeader' => sprintf($LNG['loginWelcome'], $config->game_name), 'descText' => sprintf($LNG['loginServerDesc'], $config->game_name), 'loginInfo' => sprintf($LNG['loginInfo'], '<a href="index.php?page=rules">' . $LNG['menu_rules'] . '</a>')));
$this->display('page.index.default.tpl');
}
示例6: array
$sql = "SELECT \n\tuser.*,\n\tCOUNT(message.message_id) as messages\n\tFROM %%USERS%% as user\n\tLEFT JOIN %%MESSAGES%% as message ON message.message_owner = user.id AND message.message_unread = :unread\n\tWHERE user.id = :userId\n\tGROUP BY message.message_owner;";
$USER = $db->selectSingle($sql, array(':unread' => 1, ':userId' => $session->userId));
if (empty($USER)) {
HTTP::redirectTo('index.php?code=3');
}
$LNG = new Language($USER['lang']);
$LNG->includeData(array('L18N', 'INGAME', 'TECH', 'CUSTOM'));
$THEME->setUserTheme($USER['dpath']);
if ($config->game_disable == 0 && $USER['authlevel'] == AUTH_USR) {
ShowErrorPage::printError($LNG['sys_closed_game'] . '<br><br>' . $config->close_reason, false);
}
if ($USER['bana'] == 1) {
ShowErrorPage::printError("<font size=\"6px\">" . $LNG['css_account_banned_message'] . "</font><br><br>" . sprintf($LNG['css_account_banned_expire'], _date($LNG['php_tdformat'], $USER['banaday'], $USER['timezone'])) . "<br><br>" . $LNG['css_goto_homeside'], false);
}
if (MODE === 'INGAME') {
$universeAmount = count(Universe::availableUniverses());
if (Universe::current() != $USER['universe'] && $universeAmount > 1) {
HTTP::redirectToUniverse($USER['universe']);
}
$session->selectActivePlanet();
$sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
$PLANET = $db->selectSingle($sql, array(':planetId' => $session->planetId));
if (empty($PLANET)) {
$sql = "SELECT * FROM %%PLANETS%% WHERE id = :planetId;";
$PLANET = $db->selectSingle($sql, array(':planetId' => $USER['id_planet']));
if (empty($PLANET)) {
throw new Exception("Main Planet does not exist!");
} else {
$session->planetId = $USER['id_planet'];
}
}
示例7: display
protected function display($file)
{
global $LNG;
$this->save();
if ($this->getWindow() !== 'ajax') {
$this->getPageData();
}
$this->assign(array('lang' => $LNG->getLanguage(), 'bodyclass' => $this->getWindow(), 'basepath' => PROTOCOL . HTTP_HOST . HTTP_BASE, 'isMultiUniverse' => count(Universe::availableUniverses()) > 1));
$this->assign(array('LNG' => $LNG), false);
$this->tplObj->display('extends:layout.' . $this->getWindow() . '.tpl|' . $file);
exit;
}
示例8: ShowUniversePage
function ShowUniversePage()
{
global $LNG, $USER;
$template = new template();
$action = HTTP::_GP('action', '');
$universe = HTTP::_GP('uniID', 0);
switch ($action) {
case 'open':
$config = Config::get($universe);
$config->game_disable = 1;
$config->save();
break;
case 'closed':
$config = Config::get($universe);
$config->game_disable = 0;
$config->save();
break;
case 'delete':
if (!empty($universe) && $universe != ROOT_UNI && $universe != Universe::current()) {
$GLOBALS['DATABASE']->query("DELETE FROM " . ALLIANCE . ", " . ALLIANCE_RANK . ", " . ALLIANCE_REQUEST . " \n\t\t\t\tUSING " . ALLIANCE . " \n\t\t\t\tLEFT JOIN " . ALLIANCE_RANK . " ON " . ALLIANCE . ".id = " . ALLIANCE_RANK . ".allianceID\n\t\t\t\tLEFT JOIN " . ALLIANCE_REQUEST . " ON " . ALLIANCE . ".id = " . ALLIANCE_REQUEST . " .allianceID\n\t\t\t\tWHERE ally_universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . BANNED . " WHERE universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . BUDDY . ", " . BUDDY_REQUEST . "\n\t\t\t\tUSING " . BUDDY . "\n\t\t\t\tLEFT JOIN " . BUDDY_REQUEST . " ON " . BUDDY . ".id = " . BUDDY_REQUEST . ".id\n\t\t\t\tWHERE " . BUDDY . ".universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . CONFIG . " WHERE uni = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . DIPLO . " WHERE universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . FLEETS . ", " . FLEETS_EVENT . ", " . AKS . ", " . LOG_FLEETS . "\n\t\t\t\tUSING " . FLEETS . "\n\t\t\t\tLEFT JOIN " . FLEETS_EVENT . " ON " . FLEETS . ".fleet_id = " . FLEETS_EVENT . ".fleetID\n\t\t\t\tLEFT JOIN " . AKS . " ON " . FLEETS . ".fleet_group = " . AKS . ".id\n\t\t\t\tLEFT JOIN " . LOG_FLEETS . " ON " . FLEETS . ".fleet_id = " . LOG_FLEETS . ".fleet_id\n\t\t\t\tWHERE " . FLEETS . ".fleet_universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . MESSAGES . " WHERE message_universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . NOTES . " WHERE universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . PLANETS . " WHERE universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . STATPOINTS . " WHERE universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . TICKETS . ", " . TICKETS_ANSWER . "\n\t\t\t\tUSING " . TICKETS . "\n\t\t\t\tLEFT JOIN " . TICKETS_ANSWER . " ON " . TICKETS . ".ticketID = " . TICKETS_ANSWER . ".ticketID\n\t\t\t\tWHERE universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . TOPKB . " WHERE universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . USERS . ", " . USERS_ACS . ", " . USERS_AUTH . ", " . TOPKB_USERS . ", " . SESSION . ", " . SHORTCUTS . ", " . RECORDS . "\n\t\t\t\tUSING " . USERS . "\n\t\t\t\tLEFT JOIN " . USERS_ACS . " ON " . USERS . ".id = " . USERS_ACS . ".userID\n\t\t\t\tLEFT JOIN " . USERS_AUTH . " ON " . USERS . ".id = " . USERS_AUTH . ".id\n\t\t\t\tLEFT JOIN " . TOPKB_USERS . " ON " . USERS . ".id = " . TOPKB_USERS . ".uid\n\t\t\t\tLEFT JOIN " . SESSION . " ON " . USERS . ".id = " . SESSION . ".userID\n\t\t\t\tLEFT JOIN " . SHORTCUTS . " ON " . USERS . ".id = " . SHORTCUTS . ".ownerID\n\t\t\t\tLEFT JOIN " . RECORDS . " ON " . USERS . ".id = " . RECORDS . ".userID\n\t\t\t\tLEFT JOIN " . LOSTPASSWORD . " ON " . USERS . ".id = " . LOSTPASSWORD . ".userID\n\t\t\t\tWHERE " . USERS . ".universe = " . $universe . ";");
$GLOBALS['DATABASE']->query("DELETE FROM " . USERS_VALID . " WHERE universe = " . $universe . ";");
if (Universe::getEmulated() == $universe) {
Universe::setEmulated(Universe::current());
}
if (count(Universe::availableUniverses()) == 2) {
// Hack The Session
setcookie(session_name(), session_id(), SESSION_LIFETIME, HTTP_BASE, NULL, HTTPS, true);
HTTP::redirectTo("../admin.php?reload=r");
}
}
break;
case 'create':
$universeCount = count(Universe::availableUniverses());
// Check Multiuniverse Support
$ch = curl_init();
if ($universeCount == 1) {
curl_setopt($ch, CURLOPT_URL, PROTOCOL . HTTP_HOST . HTTP_BASE . "uni" . ROOT_UNI . "/");
} else {
curl_setopt($ch, CURLOPT_URL, PROTOCOL . HTTP_HOST . HTTP_BASE);
}
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; 2Moons/" . Config::get()->VERSION . "; +http://2moons.cc)");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3", "Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4"));
curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode != 302) {
$template = new template();
$template->message(str_replace(array('{NGINX-CODE}'), array('rewrite /(.*)/?uni[0-9]+/?(.*) /$1/$2 break;'), $LNG->getTemplate('createUniverseInfo')) . '<a href="javascript:window.history.back();"><button>' . $LNG['uvs_back'] . '</button></a>' . '<a href="javascript:window.location.reload();"><button>' . $LNG['uvs_reload'] . '</button></a>');
exit;
}
$config = Config::get();
$configSQL = array();
foreach (Config::getGlobalConfigKeys() as $basicConfigKey) {
$configSQL[] = '`' . $basicConfigKey . '` = "' . $config->{$basicConfigKey} . '"';
}
$configSQL[] = '`uni_name` = "' . $LNG['fcm_universe'] . ' ' . ($universeCount + 1) . '"';
$configSQL[] = '`close_reason` = ""';
$configSQL[] = '`OverviewNewsText` = "' . $GLOBALS['DATABASE']->escape($config->OverviewNewsText) . '"';
$GLOBALS['DATABASE']->query("INSERT INTO " . CONFIG . " SET " . implode(', ', $configSQL) . ";");
$newUniverse = $GLOBALS['DATABASE']->GetInsertID();
Config::reload();
list($userID, $planetID) = PlayerUtil::createPlayer($newUniverse, $USER['username'], '', $USER['email'], $USER['lang'], 1, 1, 1, NULL, AUTH_ADM);
$GLOBALS['DATABASE']->query("UPDATE " . USERS . " SET password = '" . $USER['password'] . "' WHERE id = " . $userID . ";");
if ($universeCount === 1) {
// Hack The Session
setcookie(session_name(), session_id(), SESSION_LIFETIME, HTTP_ROOT . 'uni' . $USER['universe'] . '/', NULL, HTTPS, true);
HTTP::redirectTo("uni" . $USER['universe'] . "/admin.php?reload=r");
}
break;
}
$uniList = array();
$uniResult = $GLOBALS['DATABASE']->query("SELECT uni, users_amount, game_disable, energySpeed, halt_speed, resource_multiplier, fleet_speed, game_speed, uni_name, COUNT(DISTINCT inac.id) as inactive, COUNT(planet.id) as planet\n\tFROM " . CONFIG . " conf\n\tLEFT JOIN " . USERS . " as inac ON uni = inac.universe AND inac.onlinetime < " . (TIMESTAMP - INACTIVE) . "\n\tLEFT JOIN " . PLANETS . " as planet ON uni = planet.universe\n\tGROUP BY conf.uni, inac.universe, planet.universe\n\tORDER BY uni ASC;");
while ($uniRow = $GLOBALS['DATABASE']->fetch_array($uniResult)) {
$uniList[$uniRow['uni']] = $uniRow;
}
$template->assign_vars(array('uniList' => $uniList, 'SID' => session_id()));
$template->show('UniversePage.tpl');
}
示例9: save
public function save($options = NULL)
{
if (empty($this->updateRecords)) {
// Do nothing here.
return true;
}
if (is_null($options)) {
$options = array();
}
$options += array('noGlobalSave' => false);
$updateData = array();
$params = array();
foreach ($this->updateRecords as $columnName) {
$updateData[] = '`' . $columnName . '` = :' . $columnName;
$params[':' . $columnName] = $this->configData[$columnName];
//TODO: find a better way ...
if (!$options['noGlobalSave'] && in_array($columnName, self::$globalConfigKeys)) {
foreach (Universe::availableUniverses() as $universeId) {
if ($universeId != $this->configData['uni']) {
$config = Config::get();
$config->{$columnName} = $this->configData[$columnName];
$config->save(array('noGlobalSave' => true));
}
}
}
}
$sql = 'UPDATE %%CONFIG%% SET ' . implode(', ', $updateData) . ' WHERE `UNI` = :universe';
$params[':universe'] = $this->configData['uni'];
$db = Database::get();
$db->update($sql, $params);
$this->updateRecords = array();
return true;
}