예제 #1
0
 protected function getForum()
 {
     $requestData = $this->getRequestData();
     if (isset($requestData['clan'])) {
         $clan = new Dolumar_Players_Clan($requestData['clan']);
         if ($clan) {
             $login = Neuron_Core_Login::__getInstance();
             if ($login->isLogin()) {
                 $me = Neuron_GameServer::getPlayer();
                 $isMember = $clan->isMember($me);
                 $isModerator = $clan->isModerator($me);
                 //__construct ($iForumType, $iForumId, $objUser = false, $bCanSeeAll = false, $bIsModerator = false)
                 $forum = new Neuron_Forum_Forum(1, $clan->getId(), $me, $isMember, $isModerator);
             } else {
                 $forum = new Neuron_Forum_Forum(1, $clan->getId(), false, false, false);
             }
             // Fetch thze title
             $text = Neuron_Core_Text::__getInstance();
             $forum->setTitle(Neuron_Core_Tools::putIntoText($text->get('title', 'forum', 'clan'), array('clan' => Neuron_Core_Tools::output_varchar($clan->getName()))));
             return $forum;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
예제 #2
0
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     if ($login->isLogin()) {
         $player = Neuron_GameServer::getPlayer();
         $pos = $player->getPreferences();
         $pos = $pos['minimapPosition'];
     } else {
         $pos = Neuron_Core_Tools::getInput('_COOKIE', COOKIE_PREFIX . 'prefMP', 'int', 0);
     }
     if ($pos == 4) {
         $this->setPosition('auto', 'auto', '0px', '0px');
     } elseif ($pos == 2) {
         $this->setPosition('0px', '32px', 'auto', 'auto');
     } elseif ($pos == 3) {
         $this->setPosition('auto', '32px', '0px', 'auto');
     } else {
         $this->setPosition('0px', 'auto', 'auto', '0px');
     }
     if ($pos != 5) {
         $this->setType('panel');
     } else {
         // Movable ;-)
         $this->setPosition('0px', 'auto', 'auto', '0px');
         //$this->setOnResize ('onResizeMiniMap');
     }
     // Window settings
     $this->setSize('200px', '150px');
     $this->setTitle('Mini Map');
     $this->setClass('minimap');
     $this->setType('panel');
     $this->setAllowOnlyOnce();
     $this->setPool('minimap');
 }
예제 #3
0
파일: Units.php 프로젝트: Toxicat/dolumar
 public function getContent()
 {
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     if ($this->village && $this->village->isFound() && $this->village->getOwner()->getId() == $login->getUserId()) {
         return $this->getCurrentUnits($this->village);
     } else {
         return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>';
     }
 }
예제 #4
0
 public function getContent()
 {
     //reloadStatusCounters ();
     $login = Neuron_Core_Login::__getInstance();
     if ($login->isLogin()) {
         return $this->getCounters();
     } else {
         reloadStatusCounters();
         return ' ';
     }
 }
예제 #5
0
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     $data = $this->getRequestData();
     // Window settings
     $this->setSize('558px', '650px');
     $this->setTitle($text->get('battle', 'menu', 'main'));
     // Onload
     $this->setOnload('initBattleSimulator');
     $this->setClassName('battle simulator');
 }
예제 #6
0
 protected function getForum()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     if ($login->isLogin()) {
         $me = Neuron_GameServer::getPlayer();
         $forum = new Neuron_Forum_Forum(0, 0, $me, $me->isChatModerator(), $me->isChatModerator());
     } else {
         $forum = new Neuron_Forum_Forum(0, 0, false, false, false);
     }
     $forum->setTitle($text->get('ingameForum', 'menu', 'main'));
     return $forum;
 }
예제 #7
0
 public function processInput()
 {
     $login = Neuron_Core_Login::__getInstance();
     $data = $this->getInputData();
     if ($login->isLogin() && isset($data['openBuilding']) && isset($data['minimap']) && isset($data['advertisement'])) {
         $myself = Neuron_GameServer::getPlayer();
         $myself->setPreferences($data['openBuilding'], $data['minimap'], $data['advertisement'] == '0');
         if ($data['advertisement'] == '1' && !$myself->isPremium()) {
             $this->alert('You must have a premium account to disable the advertisment.');
         }
         $this->reloadWindow();
     }
 }
예제 #8
0
 public function getContent()
 {
     $login = Neuron_Core_Login::__getInstance();
     if ($this->village->isActive() && $this->village->getOwner()->getId() == $login->getUserId()) {
         $page = new Neuron_Core_Template();
         foreach ($this->village->getTechnologies() as $v) {
             $page->addListValue('technologies', array($v->getName()));
         }
         return $page->parse('technologies.tpl');
     } else {
         return false;
     }
 }
예제 #9
0
파일: Economy.php 프로젝트: Toxicat/dolumar
 public function getContent()
 {
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('village');
     $text->setSection('economics');
     if ($login->isLogin() && $this->village && $this->village->isFound()) {
         $me = Neuron_GameServer::getPlayer();
         if ($this->village->isActive() && ($me->getId() == $this->village->getOwner()->getId() || $me->isModerator())) {
             $page = new Neuron_Core_Template();
             $page->set('resources', $text->get('resources'));
             $page->set('stock', $text->get('stock'));
             $page->set('max', $text->get('max'));
             $page->set('income', $text->get('income'));
             $page->set('norunes', $text->get('norunes'));
             $page->set('bruto', $text->get('bruto'));
             $page->set('consuming', $text->get('consuming'));
             $page->set('honour', $this->village->honour->getHonour());
             $page->set('hourly', $text->get('hourly'));
             $res = $this->village->resources->getResources();
             $income = $this->village->resources->getIncome();
             $capacity = $this->village->resources->getCapacity();
             $consumption = $this->village->resources->getUnitConsumption();
             $bruto = $this->village->resources->getBrutoIncome();
             foreach ($res as $k => $v) {
                 $page->addListValue('resources', array(ucfirst($text->get($k, 'resources', 'main')), $v, $capacity[$k], $income[$k], 'resource' => $k, 'bruto' => isset($bruto[$k]) ? $bruto[$k] : 0, 'consuming' => isset($consumption[$k]) ? $consumption[$k] : 0));
             }
             // Runes
             $page->set('runes', $text->get('runes'));
             $runes = $this->village->resources->getRuneSummary();
             foreach ($runes as $k => $v) {
                 if ($v > 0) {
                     if ($k == 'random') {
                         $k = 'randomrune';
                     }
                     $page->addListValue('runes', array('name' => ucfirst($text->get($k, 'runeDouble', 'main')), 'available' => $v['available'], 'key' => $k, 'used' => $v['used'], 'used_percentage' => $v['used_percentage'] * 100));
                 }
             }
             $page->sortList('runes');
             return $page->parse('economics.tpl');
         } else {
             return '<p>You are not authorized to view this information: ' . $this->village->getId() . ' != ' . $me->getId() . '</p>';
         }
     } else {
         return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>';
     }
 }
예제 #10
0
파일: Magic.php 프로젝트: Toxicat/dolumar
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     // Window settings
     $this->setSize('315px', '350px');
     $data = $this->getRequestData();
     // Construct village
     if (isset($data['village']) && $login->isLogin()) {
         $this->village = Dolumar_Players_Village::getMyVillage($data['village']);
         $this->setTitle($text->get($this->sTextFile, 'menu', 'main') . ' (' . Neuron_Core_Tools::output_varchar($this->village->getName()) . ')');
     } else {
         $this->village = false;
         $this->setTitle($text->get($this->sTextFile, 'menu', 'main'));
     }
     $this->setAllowOnlyOnce();
 }
예제 #11
0
 public function getContent($language = false)
 {
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     $page = new Neuron_Core_Template();
     $text->setFile('account');
     $text->setSection('language');
     $page->set('language', $text->get('language'));
     $page->set('submit', $text->get('submit'));
     $page->set('current_language', $language ? $language : $text->getCurrentLanguage());
     // Get languages
     $lang = $text->getLanguages();
     foreach ($lang as $v) {
         $text = new Neuron_Core_Text($v);
         $page->addListValue('languages', array($v, $text->get($v, 'languages', 'languages', $v)));
         $page->sortList('languages');
     }
     return $page->parse('language.tpl');
 }
예제 #12
0
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     $data = $this->getRequestData();
     if (!isset($data['vid'])) {
         $data['vid'] = 0;
     }
     $this->village = Dolumar_Players_Village::getVillage($data['vid']);
     // Window settings
     if ($login->isLogin() && $this->village->isFound()) {
         $this->setTitle($text->get('formation', 'menu', 'main') . ' (' . Neuron_Core_Tools::output_varchar($this->village->getName()) . ')');
     } else {
         $this->setTitle($text->get('formation', 'menu', 'main'));
     }
     $this->setSize(300, 300);
     $this->setClassName('formation');
     $this->setAllowOnlyOnce();
 }
예제 #13
0
 private function getClan()
 {
     $requestData = $this->getRequestData();
     if (isset($requestData['clan'])) {
         $clan = new Dolumar_Players_Clan($requestData['clan']);
         if ($clan) {
             $login = Neuron_Core_Login::__getInstance();
             if ($login->isLogin()) {
                 $me = Neuron_GameServer::getPlayer();
             } else {
                 return null;
             }
             if ($clan->isMember($me)) {
                 return $clan;
             }
         }
     }
     return null;
 }
예제 #14
0
 public function setSettings()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     $data = $this->getRequestData();
     if (isset($data['vid'])) {
         $this->village = Dolumar_Players_Village::getMyVillage($data['vid']);
     } else {
         $this->village = false;
     }
     if ($login->isLogin() && $this->village && $this->village->isActive()) {
         $this->setTitle($text->get('equipment', 'menu', 'main') . ' (' . Neuron_Core_Tools::output_varchar($this->village->getName()) . ')');
     } else {
         $this->setTitle($text->get('equipment', 'menu', 'main'));
     }
     // Window settings
     $this->setSize('250px', '300px');
     $this->setAllowOnlyOnce();
 }
 public function getContent()
 {
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     if ($login->isLogin()) {
         return $this->throwError($text->get('loggedIn', 'lostPassword', 'account'));
     }
     // Check for input
     $input = $this->getInputData();
     if (isset($input['email'])) {
         // Check if this E-mail is found
         if ($login->sendLostPassword($input['email'])) {
             return $this->throwOkay($text->get('done', 'lostPassword', 'account'));
         } else {
             return $this->showForm($login->getError());
         }
     } else {
         return $this->showForm();
     }
 }
예제 #16
0
 public function getContent()
 {
     // Fetch thze model
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     if ($login->isLogin()) {
         $player = Neuron_GameServer::getPlayer();
         if ($player->isBanned('messages')) {
             $end = $player->getBanDuration('messages');
             $duration = Neuron_Core_Tools::getCountdown($end);
             return '<p class="false">' . Neuron_Core_Tools::putIntoText($text->get('banned', 'messages', 'messages'), array('duration' => $duration)) . '</p>';
         } elseif (!$player->isEmailVerified()) {
             return '<p class="false">' . $text->get('validateEmail', 'main', 'account') . '</p>';
         } else {
             $objMessages = new Neuron_Structure_Messages($player);
             return $objMessages->getPageHTML($this->getInputData());
         }
     } else {
         $this->throwError($text->get('noLogin', 'main', 'main'));
     }
 }
예제 #17
0
 public function getContent()
 {
     $login = Neuron_Core_Login::__getInstance();
     $db = Neuron_Core_Database::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     if ($login->isLogin()) {
         // Check for invitation key
         $key = $db->select('invitation_codes', array('invCode', 'invLeft'), "plid = '" . $login->getUserId() . "'");
         if (count($key) < 1) {
             $this->generateNewKey($login->getUserId());
         } else {
             $this->invKey = $key[0]['invCode'];
             $this->invLeft = $key[0]['invLeft'];
         }
         $page = new Neuron_Core_Template();
         $page->setVariable('invKey', $this->invKey);
         $page->setVariable('invLeft', $this->invLeft);
         return $page->parse('invitations.tpl');
     } else {
         return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>';
     }
 }
예제 #18
0
파일: Squads.php 프로젝트: Toxicat/dolumar
 public function getContent()
 {
     $input = $this->getInputData();
     $login = Neuron_Core_Login::__getInstance();
     $page = isset($input['page']) ? $input['page'] : (isset($input['action']) ? $input['action'] : 'overview');
     $id = isset($input['id']) ? $input['id'] : 0;
     $text = Neuron_Core_Text::__getInstance();
     if ($this->village && $this->village->isActive() && $this->village->getOwner()->getId() == $login->getUserId()) {
         if ($id > 0) {
             $squad = $this->village->getSquads($id);
             if (count($squad) == 1) {
                 switch ($page) {
                     case 'squad':
                         return $this->getSquadOverview($squad[0]);
                         break;
                     case 'addUnits':
                         return $this->getAddUnits($squad[0]);
                         break;
                     case 'removeUnits':
                         return $this->getRemoveUnits($squad[0]);
                         break;
                     default:
                         return $this->getOverview();
                         break;
                 }
             } else {
                 return $this->getOverview();
             }
         } elseif ($page == 'add') {
             // Add a squad
             return $this->getAddSquad();
         } else {
             return $this->getOverview();
         }
     } else {
         return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>';
     }
 }
예제 #19
0
파일: Battle.php 프로젝트: Toxicat/dolumar
 public function getContent()
 {
     $text = Neuron_Core_Text::__getInstance();
     $data = $this->getRequestData();
     $input = $this->getInputData();
     if (!isset($input['report']) && isset($data['report']) && !isset($input['overview'])) {
         $input['report'] = $data['report'];
     }
     $login = Neuron_Core_Login::__getInstance();
     if ($this->village && $this->village->isActive() && $this->village->getOwner()->getId() == $login->getUserId()) {
         // Make sure you are not in vacation mode.
         if ($this->village->getOwner()->inVacationMode()) {
             $this->setAjaxPollSeconds(0);
             $this->updateRequestData(array('vid' => $this->village->getId()));
             return '<p class="false">' . $text->get('vacationMode', 'main', 'main') . '</p>';
         } elseif (isset($data['target'])) {
             $this->setAjaxPollSeconds(0);
             //$this->updateRequestData (array ('vid' => $this->village->getId ()));
             return $this->getChallenge($data['target']);
         } elseif (isset($input['action'])) {
             $this->setAjaxPollSeconds(0);
             //$this->updateRequestData (array ('vid' => $this->village->getId ()));
             return $this->getChooseTarget();
         } elseif (isset($input['report'])) {
             // Refresh this window every xx seconds
             $log = isset($input['log']) ? $input['log'] : null;
             $report = isset($input['fightlog']) ? $input['fightlog'] == 1 : false;
             return $this->getBattleReport($input['report'], $log, $report);
         } else {
             $this->setAjaxPollSeconds(0);
             $this->updateRequestData(array('vid' => $this->village->getId()));
             return $this->getBattleOverview();
         }
     } else {
         return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>';
     }
 }
예제 #20
0
파일: Menu.php 프로젝트: Toxicat/dolumar
 public function getContent()
 {
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('main');
     $text->setSection('menu');
     $page = new Neuron_Core_Template();
     // Add text elements
     $page->set('myAccount', Neuron_Core_Tools::output_varchar($text->get('myAccount')));
     $page->set('build', Neuron_Core_Tools::output_varchar($text->get('build')));
     $page->set('bonusbuild', Neuron_Core_Tools::output_varchar($text->get('bonusbuild')));
     $page->set('economy', Neuron_Core_Tools::output_varchar($text->get('economy')));
     $page->set('preferences', Neuron_Core_Tools::output_varchar($text->get('preferences')));
     $page->set('help', Neuron_Core_Tools::output_varchar($text->get('help')));
     $page->set('language', Neuron_Core_Tools::output_varchar($text->get('language')));
     $page->set('ranking', Neuron_Core_Tools::output_varchar($text->get('ranking')));
     $page->set('units', Neuron_Core_Tools::output_varchar($text->get('units')));
     $page->set('chat', Neuron_Core_Tools::output_varchar($text->get('chat')));
     $page->set('battle', Neuron_Core_Tools::output_varchar($text->get('battle')));
     $page->set('battleCalc', Neuron_Core_Tools::output_varchar($text->get('battleCalc')));
     $page->set('forum', Neuron_Core_Tools::output_varchar($text->get('forum')));
     $page->set('ingameForum', Neuron_Core_Tools::output_varchar($text->get('ingameForum')));
     $page->set('contact', Neuron_Core_Tools::output_varchar($text->get('contact')));
     $page->set('equipment', Neuron_Core_Tools::output_varchar($text->get('equipment')));
     $page->set('magic', Neuron_Core_Tools::output_varchar($text->get('magic')));
     $page->set('invite', Neuron_Core_Tools::output_varchar($text->get('friendinvite')));
     if (!defined('HIDE_IMPRINT') || !HIDE_IMPRINT) {
         $page->set('imprint', Neuron_Core_Tools::output_varchar($text->get('imprint')));
     }
     $page->set('simulator', Neuron_Core_Tools::output_varchar($text->get('simulator')));
     $localized_forum = str_replace('{lang}', $text->getCurrentLanguage(), FORUM_URL);
     $page->set('forum_url', $localized_forum);
     $page->set('ignorelist', $text->get('ignorelist'));
     $page->set('flag', $text->getCurrentLanguage());
     $noVillage = true;
     if ($login->isLogin()) {
         $me = Neuron_GameServer::getPlayer();
         $page->set('messages', $text->get('messages'));
         $villages = $me->getVillages();
         if (count($villages) > 0) {
             $noVillage = false;
             if (count($villages) > 1 || $this->SHOW_ONLY_VILLAGE && count($villages) > 0) {
                 foreach ($villages as $v) {
                     // Add the links
                     $page->addListValue('villages', array(Neuron_Core_Tools::output_varchar($v->getName()), $v->getId()));
                 }
                 $page->sortList('villages');
             }
             // Set the current village ID.
             $page->set('vid', $me->getCurrentVillage()->getId());
         }
         // Administration links
         if ($me->isModerator()) {
             $page->set('adminForum', 'Admin Forum');
         }
         // Clans
         foreach ($me->getClans() as $v) {
             $page->addListValue('clans', array('id' => $v->getId(), 'name' => Neuron_Core_Tools::output_varchar($v->getName())));
         }
         $page->set('donation', $text->get('donation'));
     }
     if ($noVillage) {
         $page->set('vid', 0);
     }
     // Premium
     /*
     $player = Neuron_GameServer::getPlayer ();
     
     if ($player)
     {
     	$credits = $player->getCredits ();
     	$page->set ('premium', $credits);
     }
     */
     return $page->parse('menu.tpl');
 }
예제 #21
0
파일: Newsbar.php 프로젝트: Toxicat/dolumar
 private function getResourcesPage()
 {
     // Fetch resources
     $login = Neuron_Core_Login::__getInstance();
     if ($login->isLogin() && Neuron_GameServer::getPlayer()->isPlaying()) {
         $me = Neuron_GameServer::getPlayer();
         $village = $me->getCurrentVillage();
         if ($village) {
             $resources = $village->resources->getResources();
             $income = $village->resources->getIncome();
             $capacity = $village->resources->getCapacity();
             return Neuron_Core_Tools::getResourceToText($resources, $income, $capacity, true);
         }
     }
     return null;
 }
예제 #22
0
 private function newAccount()
 {
     // This script should only be executed if an openid is set in the session
     if (isset($_SESSION['dolumar_openid_identity'])) {
         $email = $_SESSION['dolumar_openid_email'];
         $login = Neuron_Core_Login::__getInstance();
         $id = $login->registerAccount(null, $email);
         if ($id > 0) {
             registerWithOpenid($id, $_SESSION['dolumar_openid_identity'], $email);
         } else {
             die('Could not register a new account: ' . $login->getError());
         }
         // Skip all the login magic, combining account is now only done on a bigger level.
         /*
         
         header("Content-Type: text/html; charset=UTF-8");
         
         $page = new Neuron_Core_Template ();
         
         $server = Neuron_GameServer::getServer();
         $name = $server->getServerName ();
         
         $page->set ('name', $name);
         $page->set ('session_id', session_id ());
         
         $page->set ('showDetails', Neuron_Core_Tools::getInput ('_GET', 'details', 'varchar'));
         
         $login = Neuron_Core_Login::__getInstance ();
         $db = Neuron_Core_Database::__getInstance ();
         
         // Check for username and password. If these are found, put them in the database.
         $username = isset ($_POST['username']) ? $_POST['username'] : false;
         $password = isset ($_POST['password']) ? $_POST['password'] : false;
         
         if ($username && $password)
         {
         	// Check for details:
         	$player = $login->checkLoginDetails ($username, $password);
         	
         	if ($player)
         	{
         		registerWithOpenid ($player->getId (), $_SESSION['dolumar_openid_identity']);
         	}
         	else
         	{
         		$page->set ('error', true);
         	}
         }
         
         elseif (isset ($_GET['do']) 
         	&& $_GET['do'] == 'register' 
         	|| (
         		defined ('OPENID_SKIP_LOGIN') 
         		&& OPENID_SKIP_LOGIN
         	)
         )
         {
         	$email = isset ($_SESSION['dolumar_openid_email']) ? $_SESSION['dolumar_openid_email'] : null;
         
         	if (defined ('OPENID_SKIP_NICKNAME') 
         		&& OPENID_SKIP_NICKNAME
         		&& !empty ($_SESSION['openid_nickname'])
         	)
         	{
         		$id = $login->registerAccount ($_SESSION['openid_nickname'], $email);
         	}
         	else
         	{
         		$id = $login->registerAccount (null, $email);
         	}
         
         	if ($id > 0)
         	{
         		registerWithOpenid ($id, $_SESSION['dolumar_openid_identity']);
         	}
         	else
         	{
         		die ('Could not register a new account: '.$login->getError ());
         	}
         }
         
         $page->set ('static_client_url', BASE_URL . 'gameserver/');
         
         // Plugins
         $header = '';
         if (Neuron_Core_Template::hasTemplate ('gameserver/openid/header.phpt'))
         	$header = $page->parse ('gameserver/openid/header.phpt');
         
         $page->set ('header', $header);
         
         echo $page->parse ('openid/register.phpt');
         */
     } else {
         echo '<h2>Error in OpenID!</h2>';
         echo '<p>You shouldn\'t be here. No openid is set.</p>';
     }
 }
예제 #23
0
파일: Clan.php 프로젝트: Toxicat/dolumar
 public function processInput()
 {
     $_SESSION['clan_overview_lastrefresh'] = null;
     $login = Neuron_Core_Login::__getInstance();
     $data = $this->getRequestData();
     $input = $this->getInputData();
     if (isset($data['id']) && $data['id'] > 0) {
         $clan = new Dolumar_Players_Clan($data['id']);
         if ($clan) {
             if (!isset($input['action'])) {
                 $input['action'] = 'overview';
             }
             switch ($input['action']) {
                 case 'join':
                     $this->updateContent($this->getJoinClan($clan));
                     break;
                 case 'government':
                     $this->updateContent($this->getGovernment($clan));
                     break;
                 case 'leave':
                     $this->updateContent($this->getLeaveClan($clan));
                     break;
                 case 'overview':
                 default:
                     $this->updateContent($this->getOverview($clan));
                     break;
             }
         }
     } elseif ($login->isLogin()) {
         $profile = Neuron_GameServer::getPlayer();
         $clans = $profile->getClans();
         if (count($clans) == 0 && isset($input['clanname'])) {
             if (Neuron_Core_Tools::checkInput($input['clanname'], 'unitname')) {
                 if ($this->makeClan($input['clanname'])) {
                     $this->updateContent();
                 } else {
                     $this->updateContent($this->getNoClan($profile, $this->getError()));
                 }
             } else {
                 $this->updateContent($this->getNoClan($profile, 'err_clanname'));
             }
         }
     }
 }
예제 #24
0
 public function getRefresh()
 {
     $db = Neuron_Core_Database::__getInstance();
     $input = $this->getRequestData();
     if (!isset($input['channel'])) {
         $this->switchChannel($this->getDefaultChannel());
     } else {
         $this->channel = intval($input['channel']);
     }
     $data = $this->getRequestData();
     $newStuff = $data['lastMessage'];
     $maxtime = NOW + 25;
     // Check for new messages
     $messages = $this->getLastMessages($newStuff);
     if ($messages === false) {
         return;
     }
     // Close the session (lock)
     session_write_close();
     // Only use persistent connection if we also use memcache
     // Otherwise it would stress out the database
     $usePersistence = self::USE_PERSISTENT_CONNECTIONS && defined('MEMCACHE_IP');
     // Sleep until there are messages
     if ($usePersistence) {
         while (count($messages) == 0 && time() < $maxtime) {
             // Check again
             $messages = $this->getLastMessages($newStuff);
             if ($messages === false) {
                 return;
             }
             // Sleep half a second
             //usleep (500);
             usleep(0.5 * 1000000);
         }
     } else {
         $messages = $this->getLastMessages($newStuff);
         if ($messages == false) {
             return;
         }
     }
     // Debug check
     if (count($messages) == 0) {
         return;
     }
     $page = new Neuron_Core_Template();
     $i = 0;
     $login = Neuron_Core_Login::__getInstance();
     $plid = $login->isLogin() ? $login->getUserId() : 0;
     $player = Neuron_GameServer::getPlayer();
     foreach ($messages as $v) {
         $sender = Neuron_GameServer::getPlayer($v['plid']);
         $biggest = $v['msgId'];
         if ($player && $player->isIgnoring($v['plid'])) {
             continue;
         }
         $i++;
         $sTarget = null;
         $iTarget = null;
         $message = $v['msg'];
         /*
         	const CHAT_GROUP_ALL = 0;
         	const CHAT_GROUP_USER = 1;
         	const CHAT_GROUP_CLAN = 2;
         */
         switch ($v['target_group']) {
             case self::CHAT_GROUP_USER:
                 $sClassname = 'message';
                 $sTarget = Dolumar_Players_Player::getFromId($v['target_id'])->getDisplayName();
                 $iTarget = $v['target_id'];
                 break;
             case self::CHAT_GROUP_CLAN:
                 $sClassname = 'clan';
                 break;
             case self::CHAT_GROUP_ALL:
             default:
                 switch ($v['mtype']) {
                     case self::CHAT_CLASS_ME:
                         $sClassname = 'all me';
                         break;
                     case self::CHAT_CLASS_REGULAR:
                     default:
                         $sClassname = 'all';
                         break;
                 }
                 break;
         }
         $page->addListValue('msgs', array('message' => Neuron_Core_Tools::output_text($message, true, true, false, false), 'date' => date(self::DATE_FORMAT, $v['datum']), 'nickname' => $sender->getDisplayName(), 'plid' => $v['plid'], 'class' => $sClassname, 'target' => $sTarget, 'targetId' => $iTarget, 'isMine' => $v['plid'] == $plid));
     }
     if ($i > 0) {
         // Shouldn't ever be true... but well, just to be sure.
         if ($biggest > $this->objCache->getCache($this->sCacheKey)) {
             $this->objCache->setCache($this->sCacheKey, $biggest);
         }
         $this->addHtmlToElement('chatdiv', $page->parse('chatmsgs.tpl'), 'bottom');
     }
     if ($biggest > $newStuff) {
         $this->updateRequestData(array('lastMessage' => $biggest, 'channel' => $this->channel));
     }
 }
예제 #25
0
 public function getDonationUrl($amount = null, $currency = 'EUR')
 {
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     $url = DONATION_URL . "?amount=" . $amount . "&currency=" . $currency . "&language=" . $text->getCurrentLanguage();
     $url .= "&callback=" . urlencode(API_FULL_URL . "?action=processPayment&key=" . API_MASTER_KEY);
     if ($login->isLogin()) {
         return $url . "&userid=" . urlencode($login->getUserId());
     } else {
         return $url;
     }
 }
예제 #26
0
 private function processRegistration($username, $email, $password, $password2)
 {
     $db = Neuron_Core_Database::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('account');
     $text->setSection('register');
     // Check input
     if (!Neuron_Core_Tools::checkInput($username, 'username')) {
         $this->updateContent($this->showRegisterForm('usernameFormat'));
     } elseif (!Neuron_Core_Tools::checkInput($password, 'password')) {
         $this->updateContent($this->showRegisterForm('passwordFormat'));
     } elseif (!Neuron_Core_Tools::checkInput($email, 'email')) {
         $this->updateContent($this->showRegisterForm('emailFormat'));
     } elseif ($password != $password2) {
         $this->updateContent($this->showRegisterForm('passwordMismatch'));
     } else {
         // Next step: checking username and stuff
         $userCheck = $db->select('n_players', array('plid'), "nickname = '{$username}' AND isRemoved = 0");
         $mailCheck = $db->select('n_players', array('plid'), "email = '{$email}' AND isRemoved = 0");
         if (count($userCheck) > 0) {
             $this->updateContent($this->showRegisterForm('userFound'));
         } elseif (count($mailCheck) > 0) {
             $this->updateContent($this->showRegisterForm('emailFound'));
         } else {
             /*
             	Check for referrer.
             */
             $referrer = intval(Neuron_Core_Tools::getInput('_COOKIE', 'preferrer', 'int'));
             $user = Neuron_GameServer::getPlayer($referrer);
             $ref_id = $user ? $user->getId() : null;
             // Create the account
             $id = $login->registerAccount($username, $email, $password, $ref_id);
             $user = Neuron_GameServer::getPlayer($id);
             /*
             if (!$isInfinite)
             {
             	// Withdraw 1 invitation
             	$db->update
             	(
             		'invitation_codes',
             		array
             		(
             			'invLeft' => '--'
             		),
             		"invCode = '$invitation'"
             	);
             }
             else
             {
             	// Add 1 invitation
             	$db->update
             	(
             		'invitation_codes',
             		array
             		(
             			'invLeft' => '++'
             		),
             		"invCode = '$invitation'"
             	);
             }
             */
             // Show "finished" page
             $page = new Neuron_Core_Template();
             $page->set('done', $text->get('done'));
             $page->set('login', $text->get('login'));
             $page->set('tracker_url', htmlentities($user->getTrackerUrl('registration')));
             $this->updateContent($page->parse('register/register_done.tpl'));
         }
     }
 }
예제 #27
0
 public function processInput()
 {
     $login = Neuron_Core_Login::__getInstance();
     $data = $this->getInputData();
     if ($login->isLogin()) {
         $me = Neuron_GameServer::getPlayer();
         if ($me->isPlaying()) {
             $this->processIngameInput($data);
         } else {
             $username = $me->getNickname();
             if (empty($username)) {
                 $this->updateContent($this->chooseNickname());
             } else {
                 $this->updateContent();
             }
         }
     } elseif (isset($data['action']) && $data['action'] == 'openid') {
         return $this->updateContent($this->getOpenId());
     } elseif (isset($data['username']) && isset($data['password'])) {
         // Login form
         if ($login->login($data['username'], $data['password'])) {
             $this->onLogin();
         } else {
             // Wrong password: show form again + warnings
             $this->updateContent($this->showLoginForm($login->getWarnings()));
         }
     } else {
         $this->updateContent();
     }
 }
예제 #28
0
파일: Village.php 프로젝트: Toxicat/dolumar
 public function onDestroy($building, $log = true)
 {
     // Trigger gametrigger.
     $login = Neuron_Core_Login::__getInstance();
     $owner = $this->getOwner();
     if ($log) {
         $objLogs = Dolumar_Players_Logs::__getInstance();
         $objLogs->addDestructBuilding($this, $building);
     }
     $this->recalculateNetworth();
     $this->buildings->reloadBuildings();
     reloadStatusCounters();
 }
예제 #29
0
{
    $server = Neuron_GameServer::getInstance();
    $server->openWindow($sWindow, $aParams);
}
$javascriptAlertErrors = array();
function throwAlertError($msg)
{
    $GLOBALS['javascriptAlertErrors'][] = $msg;
}
// Creat new xml file
global $dom;
global $root;
$dom = new DOMDocument('1.0', 'utf-8');
$root = $dom->createElement('root');
// Check for map reloads
$login = Neuron_Core_Login::__getInstance();
$profiler = Neuron_Profiler_Profiler::getInstance();
$profiler->start('Processing windows');
function handleOpenWindowRequest($windows)
{
    global $dom;
    global $root;
    foreach ($windows as $window) {
        if ($window) {
            $window->setSettings();
            $window->setDom($dom);
            // Append new window xml
            $node = $window->getNewWindow();
            if ($node) {
                $root->appendChild($node);
            }
예제 #30
0
파일: Build.php 프로젝트: Toxicat/dolumar
 public function processInput()
 {
     //$this->dialog ('Dit is een kleine test.', 'Add to que', "windowAction (this, {'debug':'test'});", 'Cancel', "alert('nope');");
     $login = Neuron_Core_Login::__getInstance();
     $db = Neuron_Core_Database::__getInstance();
     if ($login->isLogin() && $this->village && $this->village->isActive()) {
         $data = $this->getInputData();
         $action = isset($data['action']) ? $data['action'] : 'build';
         switch ($action) {
             case 'queue':
                 $this->processQueue();
                 break;
             case 'build':
             default:
                 $this->processBuildInput();
                 break;
         }
     }
 }