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'); }
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"); }
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'); }
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'); }
* * 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);
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); } } }
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(); } }