コード例 #1
0
ファイル: Bonusbuildings.php プロジェクト: Toxicat/dolumar
 public function getContent($error = null)
 {
     $sUploadUrl = ABSOLUTE_URL . 'page/customsign/?sessionId=' . session_id();
     if (!file_exists(PUBLIC_PATH) || !is_writable(PUBLIC_PATH)) {
         return '<p>Error: ' . PUBLIC_PATH . ' does not exist or is not writeable.</p>';
     }
     if (!isset($this->village)) {
         return '<p class="false">No village defined.</p>';
     }
     $text = Neuron_Core_Text::getInstance();
     $text->setFile('premium');
     $text->setSection('bonusbuilding');
     $page = new Neuron_Core_Template();
     $page->set('upload_url', $sUploadUrl);
     $buildings = $this->getPublicBuildings();
     foreach ($this->getPublicBuildings() as $v) {
         $page->addListValue('buildings', $v);
     }
     $db = Neuron_DB_Database::getInstance();
     $login = Neuron_Core_Login::getInstance();
     $r = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tplayers_tiles\n\t\t\tWHERE\n\t\t\t\tt_userid = {$login->getUserId()}\n\t\t\tORDER BY\n\t\t\t\tt_id DESC\n\t\t\tLIMIT\n\t\t\t\t8\n\t\t");
     $data = array();
     foreach ($r as $v) {
         if (file_exists(PUBLIC_PATH . $v['t_imagename'])) {
             $imagename = PUBLIC_URL . $v['t_imagename'];
             $action = new Dolumar_View_SelectBuildLocation(100, 'build bonus building', null, new Neuron_GameServer_Map_Display_Sprite($imagename), $v['t_id']);
             // selectBuildLocation (this, 100, null, 'placeholder', null, <?=$v['id']
             $page->addListValue('signs', array('id' => $v['t_id'], 'image_url' => PUBLIC_URL . $v['t_imagename'], 'credits' => self::CREDIT_COST, 'action' => $action->getAction()));
         }
     }
     if (isset($error)) {
         $page->set($error);
     }
     return $page->parse('dolumar/bonusbuilding/bonusbuilding.phpt');
 }
コード例 #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
ファイル: ClanForum.php プロジェクト: Toxicat/dolumar
 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;
     }
 }
コード例 #4
0
 public function addModeratorAction($sAction, $mParams, $reason, Neuron_GameServer_Player $player, $isDone = false)
 {
     $db = Neuron_DB_Database::getInstance();
     $login = Neuron_Core_Login::getInstance();
     $userid = intval($login->getUserId());
     $isDone = $isDone ? true : false;
     $processed = $isDone ? 1 : 0;
     $executed = $isDone ? 1 : 0;
     $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tn_mod_actions\n\t\t\tSET\n\t\t\t\tma_action = '" . $db->escape($sAction) . "',\n\t\t\t\tma_data = '" . $db->escape(json_encode($mParams)) . "',\n\t\t\t\tma_plid = {$userid},\n\t\t\t\tma_date = NOW(),\n\t\t\t\tma_reason = '" . $db->escape($reason) . "',\n\t\t\t\tma_target = '{$player->getId()}',\n\t\t\t\tma_processed = {$processed},\n\t\t\t\tma_executed = {$executed}\n\t\t");
 }
コード例 #5
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>';
     }
 }
コード例 #6
0
ファイル: Statusbar.php プロジェクト: Toxicat/dolumar
 public function getContent()
 {
     //reloadStatusCounters ();
     $login = Neuron_Core_Login::__getInstance();
     if ($login->isLogin()) {
         return $this->getCounters();
     } else {
         reloadStatusCounters();
         return ' ';
     }
 }
コード例 #7
0
ファイル: Simulator.php プロジェクト: Toxicat/dolumar
 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');
 }
コード例 #8
0
ファイル: Preferences.php プロジェクト: Toxicat/dolumar
 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();
     }
 }
コード例 #9
0
ファイル: Technologies.php プロジェクト: Toxicat/dolumar
 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;
     }
 }
コード例 #10
0
ファイル: IngameForum.php プロジェクト: Toxicat/dolumar
 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;
 }
コード例 #11
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>';
     }
 }
コード例 #12
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();
 }
コード例 #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
ファイル: Language.php プロジェクト: Toxicat/dolumar
 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');
 }
コード例 #15
0
ファイル: Equipment.php プロジェクト: Toxicat/dolumar
 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();
 }
コード例 #16
0
ファイル: Formation.php プロジェクト: Toxicat/dolumar
 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();
 }
コード例 #17
0
 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();
     }
 }
コード例 #18
0
ファイル: OldMessages.php プロジェクト: Toxicat/dolumar
 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'));
     }
 }
コード例 #19
0
ファイル: Invitations.php プロジェクト: Toxicat/dolumar
 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>';
     }
 }
コード例 #20
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>';
     }
 }
コード例 #21
0
ファイル: Customsign.php プロジェクト: Toxicat/dolumar
 public function getBody()
 {
     $action = $unit = $this->getParameter(2);
     switch ($action) {
         case 'list':
             return $this->getAllImages();
             break;
     }
     $login = Neuron_Core_Login::getInstance();
     if (!$login->isLogin()) {
         $userid = 0;
     } else {
         $userid = $login->getUserId();
     }
     if (isset($_FILES['uploadfile'])) {
         $im = $this->getImageFromInput($_FILES['uploadfile']);
         if ($im) {
             $new = $this->getGeneratedImage($im);
             if (!is_dir(PUBLIC_PATH . 'signs/')) {
                 mkdir(PUBLIC_PATH . 'signs/');
                 chmod(PUBLIC_PATH . 'signs/', 0755);
             }
             $filename = $userid . '_' . date('dmYHis') . '.png';
             imagepng($new, PUBLIC_PATH . 'signs/' . $filename);
             chmod(PUBLIC_PATH . 'signs/' . $filename, 0755);
             $db = Neuron_DB_Database::getInstance();
             $db->query("\n\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\tplayers_tiles\n\t\t\t\t\tSET\n\t\t\t\t\t\tt_userid = " . intval($userid) . ",\n\t\t\t\t\t\tt_imagename = 'signs/" . $db->escape($filename) . "'\n\t\t\t\t");
             // Show confirm screen
             $page = new Neuron_Core_Template();
             $page->set('img_url', PUBLIC_URL . 'signs/' . $filename);
             return $page->parse('pages/customsign/image.phpt');
         }
     }
     $page = new Neuron_Core_Template();
     $page->set('action', ABSOLUTE_URL . 'page/customsign/');
     return $page->parse('pages/customsign/upload.phpt');
 }
コード例 #22
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>';
     }
 }
コード例 #23
0
ファイル: Bonusbuilding.php プロジェクト: Toxicat/dolumar
 public function getBody()
 {
     $myself = Neuron_GameServer::getPlayer();
     if (!$myself->isAdmin()) {
         return '<p>You are not allowed to execute the commands. Only admins are.</p>';
     }
     $page = new Neuron_Core_Template();
     $login = Neuron_Core_Login::getInstance();
     if (!$login->isLogin()) {
         $userid = 0;
     } else {
         $userid = $login->getUserId();
     }
     $text = Neuron_Core_Text::getInstance();
     $content = array();
     foreach ($text->getLanguages() as $v) {
         $page->addListValue('languages', $v);
         $content[$v] = array('title' => Neuron_Core_Tools::getInput('_POST', 'title_' . $v, 'varchar'), 'description' => Neuron_Core_Tools::getInput('_POST', 'description_' . $v, 'varchar'));
     }
     if (isset($_FILES['imagefile'])) {
         $im = $this->getImageFromInput($_FILES['imagefile']);
         if ($im) {
             $new = $this->getGeneratedImage($im);
             if (!is_dir(PUBLIC_PATH . 'signs/')) {
                 mkdir(PUBLIC_PATH . 'signs/');
                 chmod(PUBLIC_PATH . 'signs/', 0755);
             }
             $filename = $userid . '_' . date('dmYHis') . '.png';
             imagepng($new, PUBLIC_PATH . 'signs/' . $filename);
             chmod(PUBLIC_PATH . 'signs/' . $filename, 0755);
             $db = Neuron_DB_Database::getInstance();
             $db->query("\n\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\tplayers_tiles\n\t\t\t\t\tSET\n\t\t\t\t\t\tt_userid = " . intval($userid) . ",\n\t\t\t\t\t\tt_imagename = 'signs/" . $db->escape($filename) . "',\n\t\t\t\t\t\tt_isPublic = 1,\n\t\t\t\t\t\tt_description = '{$db->escape(json_encode($content))}'\n\t\t\t\t");
         }
     }
     return $page->parse('dolumar/pages/admin/bonusbuilding/bonusbuilding.phpt');
 }
コード例 #24
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);
            }
コード例 #25
0
 *
 *  This program 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 General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
$key = Neuron_Core_Tools::getInput('_REQUEST', 'key', 'md5', false);
$request = isset($sInputs[1]) ? strtolower($sInputs[1]) : null;
$parameters = array();
$xml_name = 'browsergameshub';
$xml_version = '1';
$login = Neuron_Core_Login::getInstance(0, false);
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
    $login->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
}
if ($request == 'emailcert') {
    $key = Neuron_Core_Tools::getInput('_REQUEST', 'certkey', 'varchar', false);
    $id = Neuron_Core_Tools::getInput('_REQUEST', 'id', 'int', false);
    $player = Neuron_GameServer::getPlayer($id);
    if ($player->isFound()) {
        $player->certifyEmail($key);
        echo '<p>Your E-mail adress has been verified.</p>';
    } else {
        echo '<p>Invalid input: player not found.</p>';
    }
} elseif ($request === 'unsubscribe') {
    $id = Neuron_Core_Tools::getInput('_GET', 'id', 'varchar', false);
コード例 #26
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();
     }
 }
コード例 #27
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');
 }
コード例 #28
0
 public function dispatch()
 {
     if (!isset($this->objGame)) {
         throw new Neuron_Core_Error('Neuron_GameServer did not receive a Neuron_GameServer_Game object.');
     }
     if ($this->objGame instanceof Neuron_GameServer_Interfaces_Dispatch) {
         if (!$this->getRidOfSessionID()) {
             return;
         }
         $this->objGame->dispatch();
         return;
     }
     Neuron_URLBuilder::getInstance()->setOpenCallback(array($this, 'getOpenUrl'));
     Neuron_URLBuilder::getInstance()->setUpdateCallback(array($this, 'getUpdateUrl'));
     $pgen = Neuron_Core_PGen::__getInstance();
     $pgen->start();
     // Start counter
     $sInputs = explode('/', isset($_GET['module']) ? $_GET['module'] : null);
     $sModule = $sInputs[0];
     switch ($sModule) {
         case 'openid':
             $this->openid();
             break;
         case 'gameserver':
             array_shift($sInputs);
             array_shift($sInputs);
             $assetPath = realpath(__DIR__ . '/../../assets/');
             $filename = $assetPath . '/' . implode('/', $sInputs);
             if (file_exists($filename)) {
                 $ext = explode('.', $filename);
                 $ext = array_pop($ext);
                 switch ($ext) {
                     case 'css':
                         header('Content-Type: text/css');
                         break;
                     default:
                         $finfo = finfo_open(FILEINFO_MIME_TYPE);
                         $mimetype = finfo_file($finfo, $filename);
                         finfo_close($finfo);
                         header('Content-Type: ' . $mimetype);
                         break;
                 }
                 echo file_get_contents($filename);
             } else {
                 http_response_code(404);
                 echo 'File not found: ' . implode('/', $sInputs);
             }
             break;
         case 'dialog':
             // A little overwrite
             $output = $this->objGame->getCustomOutput();
             if ($output) {
                 header("Content-Type: text/xml; charset=utf-8;");
                 echo '<?xml version="1.0" encoding="utf-8"?>';
                 echo '<root><command command="refresh"></command></root>';
                 return;
             }
             require_once self::SCRIPT_PATH . 'dialog/dialog.php';
             break;
         case 'api':
             require_once self::SCRIPT_PATH . 'api/api.php';
             break;
         case 'map':
             // Close the session (lock)
             //session_write_close ();
             require_once self::SCRIPT_PATH . 'map/map.php';
             break;
         case 'image':
             // Close the session (lock)
             session_write_close();
             require_once self::SCRIPT_PATH . 'image/image.php';
             break;
         case 'test':
             // Close the session (lock)
             session_write_close();
             // Login
             $player = Neuron_GameServer::getPlayer();
             $overwritelogin = true;
             if ((!$player || !$player->isAdmin()) && !$overwritelogin) {
                 echo 'You must login.';
             } else {
                 $file = isset($sInputs[1]) ? $sInputs[1] : null;
                 if (@(include 'scripts/tests/' . $sInputs[1] . '.php')) {
                     //include_once ('scripts/tests/' . $sInputs[1] . '.php');
                 } else {
                     if (include self::SCRIPT_PATH . 'tests/' . $file . '.php') {
                         // ok
                     } else {
                         echo "File not found: " . self::SCRIPT_PATH . 'tests/' . $file . '.php';
                     }
                 }
                 /*if (file_exists (self::SCRIPT_PATH.'tests/'.$file.'.php'))
                 		{
                 		*/
                 /*}
                 		else
                 		{
                 			echo "File not found: " . self::SCRIPT_PATH.'tests/'.$file.'.php';
                 		}*/
             }
             break;
         case 'admin':
             // Check for page
             setcookie('session_id', session_id(), 0, COOKIE_BASE_PATH . 'admin/');
             $login = Neuron_Core_Login::getInstance(1);
             if (!$login->isLogin()) {
                 $objPage = new Neuron_GameServer_Pages_Admin_Login($login);
             } else {
                 $sPage = isset($sInputs[1]) ? $sInputs[1] : 'Index';
                 $sClassname = 'Neuron_GameServer_Pages_Admin_' . ucfirst(strtolower($sPage));
                 $myself = Neuron_GameServer::getPlayer();
                 if ($myself && $myself->isChatModerator()) {
                     if ($objPage = $this->objGame->getAdminPage($sPage)) {
                     } elseif (class_exists($sClassname)) {
                         $objPage = new $sClassname();
                     } else {
                         $objPage = new Neuron_GameServer_Pages_Admin_Index();
                     }
                 } else {
                     $objPage = new Neuron_GameServer_Pages_Admin_Invalid();
                 }
             }
             echo $objPage->getHTML();
             break;
         case 'page':
             // Check for page
             $sPage = isset($sInputs[1]) ? $sInputs[1] : 'Index';
             $sClassname = 'Neuron_GameServer_Pages_' . ucfirst(strtolower($sPage));
             $myself = Neuron_GameServer::getPlayer();
             if ($objPage = $this->objGame->getPage($sPage)) {
             } else {
                 if (class_exists($sClassname)) {
                     $objPage = new $sClassname();
                 } else {
                     $objPage = new Neuron_GameServer_Pages_Index();
                 }
             }
             echo $objPage->getOutput();
             break;
         case 'time':
             echo 'time=' . round(microtime(true) * 1000);
             break;
         case '':
             $_SESSION['tmp'] = null;
             // Now, if we have a NOLOGIN_REDIRECT set, redirect here
             if (defined('NOLOGIN_REDIRECT') && !isset($_GET['DEBUG'])) {
                 $player = Neuron_GameServer::getPlayer();
                 if (!$player) {
                     header("Location: " . NOLOGIN_REDIRECT);
                     echo "Redirecting to " . NOLOGIN_REDIRECT;
                 } else {
                     $this->showIndexPage();
                 }
             } else {
                 $this->showIndexPage();
             }
             break;
         case 'favicon.ico':
         case 'favicon.icon':
             header('Content-type: image/x-icon');
             echo file_get_contents('./favicon.ico');
             break;
         default:
             //throw new Exception ('Invalid API call: module "'.$sModule.'" not found.');
             echo '<p>Invalid module: ' . $sModule . '</p>';
             break;
     }
     if (isset($profiler) && defined(USE_PROFILE) && USE_PROFILE) {
         // Dump the profiler
         if (intval($profiler->getTotalDuration()) > 2) {
             $cache = Neuron_Core_Cache::__getInstance('profiler/' . $_SERVER['REMOTE_ADDR'] . '/');
             $cache->setCache(date('dmYHis'), (string) $profiler);
         }
     }
 }
コード例 #29
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'));
             }
         }
     }
 }
コード例 #30
0
 public function processInput()
 {
     $login = Neuron_Core_Login::getInstance();
     $text = Neuron_Core_Text::getInstance();
     $input = $this->getInputData();
     if ($login->isLogin()) {
         if (isset($input['message'])) {
             $message = trim($input['message']);
             if (!empty($message)) {
                 $user = Neuron_GameServer::getPlayer();
                 if (!$user->isPlaying()) {
                     $this->alert($text->get('registerfirst'));
                 } elseif (!$user->isEmailVerified()) {
                     $this->alert($text->get('validateEmail_short', 'main', 'account'));
                 } elseif ($user->isBanned('chat')) {
                     $end = $user->getBanDuration('chat');
                     $duration = Neuron_Core_Tools::getCountdown($end);
                     $this->alert(Neuron_Core_Tools::putIntoText($text->get('banned'), array('duration' => $duration)));
                 } else {
                     // Post message
                     $this->postMessage($input['message']);
                 }
             }
         }
     }
     // Check for input: load older messages
     if (isset($input['loadprevious'])) {
         $before = $input['loadprevious'];
         if ($html = $this->getOlderMessages($before)) {
             $this->addHtmlToElement('messagecontainer', $html, 'top');
         } else {
             $this->addHtmlToElement('messagecontainer', '<div></div>', 'top');
         }
     }
     // If not using blocking, we can "safely" process it right now
     if (!self::USE_BLOCKING) {
         $this->getRefresh();
     }
 }