Ejemplo n.º 1
0
 private function printResults($page, $query)
 {
     foreach ($query as $v) {
         $displayname = Neuron_URLBuilder::getInstance()->getOpenUrl('PlayerProfile', Neuron_Core_Tools::output_varchar($v['nickname']), array('plid' => $v['plid']));
         $villagename = Neuron_URLBuilder::getInstance()->getOpenUrl('VillageProfile', Neuron_Core_Tools::output_varchar($v['vname']), array('village' => $v['vid']));
         $page->addListValue('results', array('id' => $v['plid'], 'nickname' => $v['nickname'], 'displayname' => $displayname, 'village' => $v['vname'], 'displayvillage' => $villagename, 'distance' => Neuron_Core_Tools::output_distance($v['distance']), 'networth' => $v['networth']));
     }
 }
Ejemplo n.º 2
0
 public function getContent()
 {
     $map = $this->getServer()->getMap();
     if (!$map instanceof Dolumar_Underworld_Map_Map) {
         $this->reloadWindow();
         return '<p>Mission is finished.</p>';
     }
     $mission = $map->getMission();
     $sides = $mission->getSides();
     $objective = $mission->getObjective();
     // Check the victory conditions
     $objective->checkVictoryConditions();
     if ($objective instanceof Dolumar_Underworld_Models_Objectives_TakeAndHold) {
         $out = '<p>Hold the center castle until the counter reaches 0.</p>';
         $scores = $objective->getScores();
         $out .= '<ul>';
         foreach ($scores as $v) {
             $timeleft = $objective->getHoldDuration() - $v['score'];
             if ($timeleft > 0) {
                 if ($v['increasing']) {
                     $timeleft = Neuron_Core_Tools::getCountdown(NOW + $timeleft);
                 } else {
                     $timeleft = Neuron_Core_Tools::getDuration($timeleft);
                 }
             } else {
                 $timeleft = 0;
             }
             $out .= '<li>' . $v['side']->getDisplayName() . ': ' . $timeleft . '</li>';
         }
         $out .= '</ul>';
     } else {
         $out = '<p>Just explore ^^</p>';
     }
     /*
     		foreach ($sides as $v)
     		{
     
     
     			$checkpoints = $objective->getConqueredCheckpoints ($v);
     			$score = count ($checkpoints);
     
     			$out .= '<p>- Team ' . $v->getId () . ': ' . $score . '</p>';
     		}*/
     $out .= '<p>' . Neuron_URLBuilder::getInstance()->getOpenUrl('Battle', 'Battle reports', array()) . '</p>';
     return $out;
 }
Ejemplo n.º 3
0
 private static function splitInPages_getPageUrl($pagetoken, $module, $page, $data, $name)
 {
     $data[$pagetoken] = $page;
     return Neuron_URLBuilder::getInstance()->getUpdateUrl($module, $name, $data);
 }
 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);
         }
     }
 }
Ejemplo n.º 5
0
 protected function getLogHTML($page, $objLogs, $logs)
 {
     $text = Neuron_Core_Text::__getInstance();
     $text->setSection('overview');
     $text->setFile('battle');
     foreach ($logs as $v) {
         $link = Neuron_URLBuilder::getInstance()->getUpdateUrl('Battle', $text->get('watchreport'), array('report' => $v['reportid']));
         $txt = $objLogs->getLogText($v, true);
         $page->addListValue('logs', array('date' => date(DATETIME, $v['timestamp']), 'text' => $txt, 'link' => $link));
     }
     return $page->parse('logbook.phpt');
 }
Ejemplo n.º 6
0
 private function setTabUrl($page, $tab, $target)
 {
     $text = Neuron_Core_Text::getInstance();
     // Tabs
     $page->set('tab_' . $tab, Neuron_URLBuilder::getInstance()->getUpdateUrl('building', $text->get($tab, 'market-tabs', 'buildings'), array('building' => $this->getId(), 'tab' => $tab, 'target' => $target->getId(), 'action' => 'donate')));
 }
Ejemplo n.º 7
0
 private function authorize()
 {
     $player = Neuron_GameServer::getPlayer();
     if (!$player) {
         $html = '<p>' . __('This page is only available for registered users.') . '</p>';
         /*
         
         $_SESSION['after_login_redirect'] = Neuron_URLBuilder::getURL 
         (
         	'oauth/authorize', 
         	array 
         	(
         		'oauth_token' => Neuron_Core_Tools::getInput ('_GET', 'oauth_token', 'varchar')
         	)
         );
         
         header ('Location: ' . Neuron_URLBuilder::getURL ('login'));
         
         return;
         */
         return $thml;
     }
     // The current user
     $user_id = $player->getId();
     // Fetch the oauth store and the oauth server.
     $store = Neuron_Auth_OAuthStore::getStore();
     $server = new OAuthServer();
     try {
         // Check if there is a valid request token in the current request
         // Returns an array with the consumer key, consumer secret, token, token secret and token type.
         $rs = $server->authorizeVerify();
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             // See if the user clicked the 'allow' submit button (or whatever you choose)
             $authorized = true;
             // Set the request token to be authorized or not authorized
             // When there was a oauth_callback then this will redirect to the consumer
             $server->authorizeFinish($authorized, $user_id);
             // No oauth_callback, show the user the result of the authorization
             // ** your code here **
             unset($_GET['rewritepagemodule']);
             $url = Neuron_URLBuilder::getInstance()->getRawURL('oauth/authorize', $_GET);
             $html = '<form method="post" action="' . $url . '"><button>Accept</button></form>';
         } else {
             unset($_GET['rewritepagemodule']);
             $url = Neuron_URLBuilder::getInstance()->getRawURL('oauth/authorize', $_GET);
             $html = '<form method="post" action="' . $url . '"><button>Accept</button></form>';
         }
     } catch (OAuthException $e) {
         // No token to be verified in the request, show a page where the user can enter the token to be verified
         // **your code here**
         $html = 'oops';
     }
     return $html;
 }
Ejemplo n.º 8
0
 private function getMissionOverview($input)
 {
     if (isset($input['id'])) {
         $mission = Dolumar_Underworld_Mappers_MissionMapper::getFromId($input['id']);
     }
     if (!isset($mission)) {
         return '<p class="false">Mission not found.</p>';
     }
     $text = Neuron_Core_Text::getInstance();
     $page = new Neuron_Core_Template();
     $page->set('id', $mission->getId());
     $page->set('mission', $mission->getName());
     $page->set('openmission', Neuron_URLBuilder::getInstance()->getOpenUrl('Underworld', $text->get('openmission', 'clanportal', 'buildings'), array('id' => $mission->getId()), null, $mission->getUrl()));
     $page->set('return', Neuron_URLBuilder::getInstance()->getUpdateUrl('Building', $text->get('return', 'clanportal', 'buildings'), array('action' => 'overview')));
     // Get free regiments
     $units = array();
     $addunits = array();
     $unitsdata = $this->getVillage()->getSquads(false, true, true);
     foreach ($unitsdata as $v) {
         if (!$v->isIdle()) {
             continue;
         }
         $add = true;
         // Check for adding
         if (isset($input['unit_' . $v->getId()]) && $input['unit_' . $v->getId()]) {
             $addunits[] = $v;
             $add = false;
         }
         if ($add) {
             $units[] = array('id' => $v->getId(), 'name' => $v->getDisplayName());
         }
     }
     // The spawnpionts
     $side = $mission->getPlayerSide(Neuron_GameServer::getPlayer());
     $spawnpoints = $mission->getSpawnpoints($side);
     // Group the spawnpoints
     $groupedspawnpoints = array();
     foreach ($spawnpoints as $v) {
         if (!isset($groupedspawnpoints[$v->getGroup()->getId()])) {
             $groupedspawnpoints[$v->getGroup()->getId()] = $v->getGroup();
         }
     }
     $page->set('spawnpoints', $groupedspawnpoints);
     // Add the units
     if (count($addunits) > 0) {
         $spanwpointId = null;
         if (isset($input['spawnpoint'])) {
             $spanwpointId = $input['spawnpoint'];
         }
         $army = $mission->addSquads(Neuron_GameServer::getPlayer(), $side, $addunits, $spanwpointId);
     }
     $page->set('units', $units);
     return $page->parse('buildings/clanportals_mission.phpt');
 }
Ejemplo n.º 9
0
 public function getContent()
 {
     $guide_img = IMAGE_URL . 'characters/guide.png';
     $guide_icon_img = IMAGE_URL . 'characters/guide-icon.png';
     $text = Neuron_Core_Text::getInstance();
     $player = Neuron_GameServer::getPlayer();
     $input = $this->getInputData();
     $page = isset($input['page']) ? $input['page'] : null;
     if (isset($input['action'])) {
         switch ($input['action']) {
             case 'show':
                 $this->updateRequestData(array('display' => 'show'));
                 break;
             case 'hide':
                 $this->updateRequestData(array('display' => 'hide'));
                 break;
         }
     }
     $data = $this->getRequestData();
     $openup = false;
     if (isset($data['display']) && $data['display'] == 'show' || ($openup = $player && $this->hasUnreadMessages($player))) {
         $txt = $this->getRightMessage($page);
         $page = $txt['page'];
         $lastrec = isset($data['record']) ? $data['record'] : 0;
         if (!empty($txt['highlight']) && $txt['record'] != $lastrec) {
             $this->highlight($txt['highlight']);
         }
         $this->updateRequestData(array('display' => 'show', 'record' => $txt['record']));
         $hide_url = Neuron_URLBuilder::getInstance()->getUpdateUrl('Guide', $text->get('hide', 'navigation', 'guide'), array('action' => 'hide'), $text->get('hide', 'navigation', 'guide'));
         $next_url = false;
         $previous_url = false;
         if ($page > 0) {
             $next_url = Neuron_URLBuilder::getInstance()->getUpdateUrl('Guide', $text->get('next', 'navigation', 'guide'), array('page' => $page - 1), $text->get('shownext', 'navigation', 'guide'));
         }
         if ($player && $this->hasPrevious($player, $page)) {
             $previous_url = Neuron_URLBuilder::getInstance()->getUpdateUrl('Guide', $text->get('previous', 'navigation', 'guide'), array('page' => $page + 1), $text->get('showprevious', 'navigation', 'guide'));
         }
         $out = '<blockquote class="bubble triangle-right right">' . $txt['html'] . '<ul class="navigation">';
         if ($previous_url) {
             $out .= '<li>' . $previous_url . '</li>';
         }
         if ($next_url) {
             $out .= '<li>' . $next_url . '</li>';
         }
         if ($page < 1) {
             $out .= '<li>' . $hide_url . '</li>';
         }
         $out .= '</ul>' . '</blockquote><div class="avatar ' . $txt['class'] . '"></div>';
         return $out;
     } else {
         $url = Neuron_URLBuilder::getInstance()->getUpdateUrl('Guide', '<span>' . $text->get('callguide', 'navigation', 'guide') . '</span>', array('action' => 'show'), $text->get('callguide', 'navigation', 'guide'));
         return '<div class="icon">' . $url . '</div>';
     }
 }
Ejemplo n.º 10
0
 public function __construct()
 {
     Neuron_URLBuilder::getInstance()->setOpenCallback(array($this, '_getUrlCallback'));
     Neuron_URLBuilder::getInstance()->setUpdateCallback(array($this, '_getUrlCallback'));
 }
Ejemplo n.º 11
0
 public function getDisplayName()
 {
     /*
     return '<a href="javascript:void(0);" '.
     	'onclick="openWindow (\'villageProfile\',{\'village\':'.$this->getId ().'});">'.
     	Neuron_Core_Tools::output_varchar ($this->getName ()).'</a>';
     */
     $nickname = Neuron_Core_Tools::output_varchar($this->getName());
     $string = Neuron_URLBuilder::getInstance()->getOpenUrl('VillageProfile', $nickname, array('village' => $this->getId()));
     return $string;
 }
Ejemplo n.º 12
0
 public function getDisplayName()
 {
     $flags = '';
     if ($this->isProperPremium()) {
         $flags .= 'premium ';
     }
     if ($this->isModerator()) {
         $flags .= 'moderator ';
     }
     $string = '<span class="nickname ' . $flags . '">';
     $nickname = Neuron_Core_Tools::output_varchar($this->getName());
     $string .= Neuron_URLBuilder::getInstance()->getOpenUrl('player', $nickname, array('plid' => $this->getId()));
     $string .= '</span>';
     return $string;
 }