private static function _execute($url, $method, $post = null) { $data = parse_url($url); if (isset($data['user']) || isset($data['pass'])) { // TODO: not yet implemented return false; } if (isset($data['query'])) { $data['fullpath'] = $data['path'] . '?' . $data['query']; } else { $data['fullpath'] = $data['path']; } switch ($data['scheme']) { case 'http': $HTTP = new HTTP($data['host'], isset($data['port']) ? $data['port'] : 80); break; case 'https': $HTTP = new HTTP($data['host'], isset($data['port']) ? $data['port'] : 443, true); break; default: return false; break; } switch ($method) { case 'GET': return $HTTP->GET($data['fullpath']); break; case 'POST': return $HTTP->POST($data['fullpath'], $post); break; default: return false; break; } }
function _xUpdateGetInstaller() { global $C; $post_data = array('upgrade' => true, 'version' => $_REQUEST['version'], 'key' => LIC_KEY, 'domain' => domain_from_url($C['base_url'])); require_once 'http.php'; $http = new HTTP(); if ($http->POST(URL_DOWNLOAD, $post_data)) { if (preg_match('~X-SHA1: ([a-z0-9]+)~i', $http->response_headers, $matches)) { $installer_file = DIR_DATA . '/install.dat'; $sha1 = $matches[1]; file_write($installer_file, $http->body); if ($sha1 != sha1_file($installer_file)) { file_delete($installer_file); JSON::Error('File hash does not match, possible corrupted data. Please try again.'); } else { JSON::Success(); } } else { if (preg_match('~X-Error: ([a-z0-9_]+)~i', $http->response_headers, $matches)) { JSON::Error('Unable to locate a license for this domain'); } else { JSON::Error('Download from jmbsoft.com failed, please try again'); } } } else { JSON::Error('Unable to connect to jmbsoft.com for update: ' + $http->error); } }
private function fetchFunctionDescription($func) { $HTTP = new HTTP('php.net'); $html = $HTTP->GET('/' . $this->getConfig('language') . '/' . $func); if ($html === false) { $this->reply('Timeout on contacting ' . $host); return; } if (preg_match('/<span class=\\"refname\\">(.*?)<\\/span> — <span class=\\"dc\\-title\\">(.*?)<\\/span>/si', $html, $match)) { $match[2] = str_replace(array("\n", "\r"), ' ', strip_tags($match[2])); preg_match('/<div class=\\"methodsynopsis dc\\-description\\">(.*?)<\\/div>/si', $html, $descmatch); $decl = isset($descmatch[1]) ? strip_tags($descmatch[1]) : $match[1]; $decl = html_entity_decode(str_replace(array("\n", "\r"), ' ', $decl)); while (strstr($decl, ' ')) { $decl = str_replace(' ', ' ', $decl); } $decl = str_replace($func, "" . $func . "", $decl); $output = $decl . ' - ' . html_entity_decode($match[2]) . ' ( http://php.net/' . $func . ' )'; $this->reply(libString::isUTF8($output) ? $output : utf8_encode($output)); } else { // if several possibilities $output = ''; if (preg_match_all('/<a href=\\"\\/manual\\/[a-z]+\\/(?:.*?)\\.php\\">(?:<b>)?(.*?)(?:<\\/b>)?<\\/a><br/i', $html, $matches, PREG_SET_ORDER)) { if ($this->redirects++ < 2) { $this->fetchFunctionDescription($matches[0][1]); } else { $this->reply($this->notfoundtext . ' http://php.net/search.php?show=wholesite&pattern=' . $this->data['text']); } return; } else { $output = $this->notfoundtext . ' http://php.net/search.php?show=wholesite&pattern=' . $func; } $this->reply(libString::isUTF8($output) ? $output : utf8_encode($output)); } }
static function tinyURLDecode($tinyurl) { $parts = parse_url($tinyurl); $HTTP = new HTTP('tinyurl.com'); $HTTP->set('auto-follow', false); $HTTP->GET($parts['path']); $header = $HTTP->getHeader(); if (!isset($header['Location'])) { return false; } return $header['Location']; }
public function __construct() { $pgHTTP = new HTTP(); $text = $pgHTTP->get('http://meta.wikimedia.org/w/index.php?title=IRC/Quotes&action=raw&ctype=text/css', false); $text = explode('<pre><nowiki>', $text); $text = explode('</nowiki></pre>', $text[1]); $text = explode('%%', $text[0]); $text = substr($text[0], 2); $text = htmlspecialchars($text); $text = trim($text); $text = preg_replace('/\\n/', '<br />', $text); $this->quotes = explode("%<br />", $text); }
function isTriggered() { if (!isset($this->data['text'])) { $this->printUsage(); return; } $HTTP = new HTTP('api.themoviedb.org'); $html = $HTTP->GET('/2.1/Movie.search/' . $this->getConfig('language') . '/xml/' . $this->api_key . '/' . urlencode($this->data['text'])); $XML = simplexml_load_string($html); if (!$XML) { $this->reply('Error on contacting themoviedb.org'); return; } $tmp = $XML->xpath('opensearch:totalResults'); $results = (int) $tmp[0]; if (!$results) { if ($this->getConfig('language') != 'en') { $html = $HTTP->GET('/2.1/Movie.search/en/xml/' . $this->api_key . '/' . urlencode($this->data['text'])); $XML = new SimpleXMLElement($html); if (!$XML) { $this->reply('Error on contacting themoviedb.org'); return; } $tmp = $XML->xpath('opensearch:totalResults'); $results = (int) $tmp[0]; } } if (!$results) { $this->reply('There is no information available about this movie.'); return; } $tmp = $XML->children()->children(); $Movie = $tmp[0]; $text = "" . $Movie->name . ""; if ((string) $Movie->original_name != (string) $Movie->name) { $text .= ' (' . $Movie->original_name . ')'; } if (!empty($Movie->released)) { $text .= " | Released: " . $Movie->released; } if ($Movie->rating != '0.0') { $text .= " | Press Rating: " . $Movie->rating . '/10'; } if (!empty($Movie->certification)) { $text .= " | Rated: " . $Movie->certification; } $text .= ' (' . $Movie->url . ')'; $this->reply($text); $this->reply($Movie->overview); }
function ShowMultiIPPage() { global $LNG; switch ($_GET['action']) { case 'known': $GLOBALS['DATABASE']->query("INSERT INTO " . MULTI . " SET userID = " . (int) $_GET['id'] . ";"); HTTP::redirectTo("admin.php?page=multiips"); break; case 'unknown': $GLOBALS['DATABASE']->query("DELETE FROM " . MULTI . " WHERE userID = " . (int) $_GET['id'] . ";"); HTTP::redirectTo("admin.php?page=multiips"); break; } $Query = $GLOBALS['DATABASE']->query("SELECT id, username, email, register_time, onlinetime, user_lastip, IFNULL(multiID, 0) as isKnown FROM " . USERS . " LEFT JOIN " . MULTI . " ON userID = id WHERE `universe` = '" . Universe::getEmulated() . "' AND user_lastip IN (SELECT user_lastip FROM " . USERS . " WHERE `universe` = '" . Universe::getEmulated() . "' GROUP BY user_lastip HAVING COUNT(*)>1) ORDER BY user_lastip, id ASC;"); $IPs = array(); while ($Data = $GLOBALS['DATABASE']->fetch_array($Query)) { if (!isset($IPs[$Data['user_lastip']])) { $IPs[$Data['user_lastip']] = array(); } $Data['register_time'] = _date($LNG['php_tdformat'], $Data['register_time']); $Data['onlinetime'] = _date($LNG['php_tdformat'], $Data['onlinetime']); $IPs[$Data['user_lastip']][$Data['id']] = $Data; } $template = new template(); $template->assign_vars(array('multiGroups' => $IPs)); $template->show('MultiIPs.tpl'); }
function ShowTeamspeakPage() { global $LNG, $USER; $CONF = Config::getAll(NULL, $_SESSION['adminuni']); if ($_POST) { $config_before = array('ts_timeout' => $CONF['ts_timeout'], 'ts_modon' => $CONF['ts_modon'], 'ts_server' => $CONF['ts_server'], 'ts_tcpport' => $CONF['ts_tcpport'], 'ts_udpport' => $CONF['ts_udpport'], 'ts_version' => $CONF['ts_version'], 'ts_login' => $CONF['ts_login'], 'ts_password' => $CONF['ts_password'], 'ts_cron_interval' => $CONF['ts_cron_interval']); $ts_modon = isset($_POST['ts_on']) && $_POST['ts_on'] == 'on' ? 1 : 0; $ts_server = HTTP::_GP('ts_ip', ''); $ts_tcpport = HTTP::_GP('ts_tcp', 0); $ts_udpport = HTTP::_GP('ts_udp', 0); $ts_timeout = HTTP::_GP('ts_to', 0); $ts_version = HTTP::_GP('ts_v', 0); $ts_login = HTTP::_GP('ts_login', ''); $ts_password = HTTP::_GP('ts_password', '', true); $ts_cron_interval = HTTP::_GP('ts_cron', 0); $config_after = array('ts_timeout' => $ts_timeout, 'ts_modon' => $ts_modon, 'ts_server' => $ts_server, 'ts_tcpport' => $ts_tcpport, 'ts_udpport' => $ts_udpport, 'ts_version' => $ts_version, 'ts_login' => $ts_login, 'ts_password' => $ts_password, 'ts_cron_interval' => $ts_cron_interval); Config::update($config_after); $GLOBALS['DATABASE']->query("UPDATE " . CRONJOBS . " SET isActive = " . $ts_modon . ", `lock` = NULL, nextTime = 0 WHERE name = 'teamspeak';"); $CONF = Config::getAll(NULL, $_SESSION['adminuni']); $LOG = new Log(3); $LOG->target = 4; $LOG->old = $config_before; $LOG->new = $config_after; $LOG->save(); } $template = new template(); $template->assign_vars(array('se_save_parameters' => $LNG['se_save_parameters'], 'ts_tcpport' => $LNG['ts_tcpport'], 'ts_serverip' => $LNG['ts_serverip'], 'ts_version' => $LNG['ts_version'], 'ts_active' => $LNG['ts_active'], 'ts_settings' => $LNG['ts_settings'], 'ts_udpport' => $LNG['ts_udpport'], 'ts_timeout' => $LNG['ts_timeout'], 'ts_server_query' => $LNG['ts_server_query'], 'ts_sq_login' => $LNG['ts_login'], 'ts_sq_pass' => $LNG['ts_pass'], 'ts_lng_cron' => $LNG['ts_cron'], 'ts_to' => $CONF['ts_timeout'], 'ts_on' => $CONF['ts_modon'], 'ts_ip' => $CONF['ts_server'], 'ts_tcp' => $CONF['ts_tcpport'], 'ts_udp' => $CONF['ts_udpport'], 'ts_v' => $CONF['ts_version'], 'ts_login' => $CONF['ts_login'], 'ts_password' => $CONF['ts_password'], 'ts_cron' => $CONF['ts_cron_interval'])); $template->show('TeamspeakPage.tpl'); }
function view() { global $USER, $LNG, $TICKET; require_once 'includes/functions/BBCode.php'; $ticketID = HTTP::_GP('id', 0); $answerResult = $GLOBALS['DATABASE']->query("SELECT a.*, t.categoryID, t.status FROM " . TICKETS_ANSWER . " a INNER JOIN " . TICKETS . " t USING(ticketID) WHERE a.ticketID = " . $ticketID . " ORDER BY a.answerID;"); $answerList = array(); $rr = $USER['id']; $qtip = $GLOBALS['DATABASE']->query("SELECT `ownerID` FROM " . TICKETS . " WHERE ticketID = " . $ticketID . ";"); $row = $GLOBALS['DATABASE']->fetch_array($qtip); $ownercheck = $row['ownerID']; if ($GLOBALS['DATABASE']->numRows($answerResult) == 0) { $this->printMessage(sprintf($LNG['ti_not_exist'], $ticketID)); } if ($ownercheck != $USER['id'] && $USER['authlevel'] == 0) { $this->printMessage(sprintf($LNG['ebo_notadmin'], $ticketID)); } while ($answerRow = $GLOBALS['DATABASE']->fetch_array($answerResult)) { $subjecttest = $answerRow['subject']; $answerRow['time'] = _date($LNG['php_tdformat'], $answerRow['time'], $USER['timezone']); $answerRow['message'] = bbcode($answerRow['message']); $answerRow['userid'] = $answerRow['ownerID']; $answerList[$answerRow['answerID']] = $answerRow; $ticket_status = $answerRow['status']; } $GLOBALS['DATABASE']->free_result($answerResult); $categoryList = $this->ticketObj->getCategoryList(); $this->tplObj->assign_vars(array('subjecttest' => $subjecttest, 'ticketID' => $ticketID, 'categoryList' => $categoryList, 'answerList' => $answerList, 'status' => $ticket_status)); $this->display('page.ticket.view.tpl'); }
public function __construct() { if (isset(self::$current)) { throw new ConstructionException('Cannot construct more than one instance of singleton class HTTP.'); } self::$current = $this; }
function ShowChatConfigPage() { global $LNG; $config = Config::get(Universe::getEmulated()); if (!empty($_POST)) { $config_before = array('chat_closed' => $config->chat_closed, 'chat_allowchan' => $config->chat_allowchan, 'chat_allowmes' => $config->chat_allowmes, 'chat_allowdelmes' => $config->chat_allowdelmes, 'chat_logmessage' => $config->chat_logmessage, 'chat_nickchange' => $config->chat_nickchange, 'chat_botname' => $config->chat_botname, 'chat_channelname' => $config->chat_channelname); $chat_allowchan = isset($_POST['chat_allowchan']) && $_POST['chat_allowchan'] == 'on' ? 1 : 0; $chat_allowmes = isset($_POST['chat_allowmes']) && $_POST['chat_allowmes'] == 'on' ? 1 : 0; $chat_allowdelmes = isset($_POST['chat_allowdelmes']) && $_POST['chat_allowdelmes'] == 'on' ? 1 : 0; $chat_logmessage = isset($_POST['chat_logmessage']) && $_POST['chat_logmessage'] == 'on' ? 1 : 0; $chat_nickchange = isset($_POST['chat_nickchange']) && $_POST['chat_nickchange'] == 'on' ? 1 : 0; $chat_closed = isset($_POST['chat_closed']) && $_POST['chat_closed'] == 'on' ? 1 : 0; $chat_channelname = HTTP::_GP('chat_channelname', '', true); $chat_botname = HTTP::_GP('chat_botname', '', true); $config_after = array('chat_closed' => $chat_closed, 'chat_allowchan' => $chat_allowchan, 'chat_allowmes' => $chat_allowmes, 'chat_allowdelmes' => $chat_allowdelmes, 'chat_logmessage' => $chat_logmessage, 'chat_nickchange' => $chat_nickchange, 'chat_botname' => $chat_botname, 'chat_channelname' => $chat_channelname); foreach ($config_after as $key => $value) { $config->{$key} = $value; } $config->save(); $LOG = new Log(3); $LOG->target = 3; $LOG->old = $config_before; $LOG->new = $config_after; $LOG->save(); } $template = new template(); $template->assign_vars(array('chat_closed' => $config->chat_closed, 'chat_allowchan' => $config->chat_allowchan, 'chat_allowmes' => $config->chat_allowmes, 'chat_logmessage' => $config->chat_logmessage, 'chat_nickchange' => $config->chat_nickchange, 'chat_botname' => $config->chat_botname, 'chat_channelname' => $config->chat_channelname, 'se_server_parameters' => $LNG['se_server_parameters'], 'se_save_parameters' => $LNG['se_save_parameters'], 'ch_closed' => $LNG['ch_closed'], 'ch_allowchan' => $LNG['ch_allowchan'], 'ch_allowmes' => $LNG['ch_allowmes'], 'ch_allowdelmes' => $LNG['ch_allowdelmes'], 'ch_logmessage' => $LNG['ch_logmessage'], 'ch_nickchange' => $LNG['ch_nickchange'], 'ch_botname' => $LNG['ch_botname'], 'ch_channelname' => $LNG['ch_channelname'])); $template->show('ChatConfigBody.tpl'); }
function ShowFlyingFleetPage() { global $LNG; $id = HTTP::_GP('id', 0); if (!empty($id)) { $lock = HTTP::_GP('lock', 0); $GLOBALS['DATABASE']->query("UPDATE " . FLEETS . " SET `fleet_busy` = '" . $lock . "' WHERE `fleet_id` = '" . $id . "' AND `fleet_universe` = '" . Universe::getEmulated() . "';"); $SQL = $lock == 0 ? "NULL" : "'ADM_LOCK'"; $GLOBALS['DATABASE']->query("UPDATE " . FLEETS_EVENT . " SET `lock` = " . $SQL . " WHERE `fleetID` = " . $id . ";"); } $orderBy = "fleet_id"; $fleetResult = $GLOBALS['DATABASE']->query("SELECT \n\tfleet.*,\n\tevent.`lock`,\n\tCOUNT(event.fleetID) as error,\n\tpstart.name as startPlanetName,\n\tptarget.name as targetPlanetName,\n\tustart.username as startUserName,\n\tutarget.username as targetUserName,\n\tacs.name as acsName\n\tFROM " . FLEETS . " fleet\n\tLEFT JOIN " . FLEETS_EVENT . " event ON fleetID = fleet_id\n\tLEFT JOIN " . PLANETS . " pstart ON pstart.id = fleet_start_id\n\tLEFT JOIN " . PLANETS . " ptarget ON ptarget.id = fleet_end_id\n\tLEFT JOIN " . USERS . " ustart ON ustart.id = fleet_owner\n\tLEFT JOIN " . USERS . " utarget ON utarget.id = fleet_target_owner\n\tLEFT JOIN " . AKS . " acs ON acs.id = fleet_group\n\tWHERE fleet_universe = " . Universe::getEmulated() . "\n\tGROUP BY event.fleetID\n\tORDER BY " . $orderBy . ";"); $FleetList = array(); while ($fleetRow = $GLOBALS['DATABASE']->fetch_array($fleetResult)) { $shipList = array(); $shipArray = array_filter(explode(';', $fleetRow['fleet_array'])); foreach ($shipArray as $ship) { $shipDetail = explode(',', $ship); $shipList[$shipDetail[0]] = $shipDetail[1]; } $FleetList[] = array('fleetID' => $fleetRow['fleet_id'], 'lock' => !empty($fleetRow['lock']), 'count' => $fleetRow['fleet_amount'], 'error' => !$fleetRow['error'], 'ships' => $shipList, 'state' => $fleetRow['fleet_mess'], 'starttime' => _date($LNG['php_tdformat'], $fleetRow['start_time'], $USER['timezone']), 'arrivaltime' => _date($LNG['php_tdformat'], $fleetRow['fleet_start_time'], $USER['timezone']), 'stayhour' => round(($fleetRow['fleet_end_stay'] - $fleetRow['fleet_start_time']) / 3600), 'staytime' => $fleetRow['fleet_start_time'] !== $fleetRow['fleet_end_stay'] ? _date($LNG['php_tdformat'], $fleetRow['fleet_end_stay'], $USER['timezone']) : 0, 'endtime' => _date($LNG['php_tdformat'], $fleetRow['fleet_end_time'], $USER['timezone']), 'missionID' => $fleetRow['fleet_mission'], 'acsID' => $fleetRow['fleet_group'], 'acsName' => $fleetRow['acsName'], 'startUserID' => $fleetRow['fleet_owner'], 'startUserName' => $fleetRow['startUserName'], 'startPlanetID' => $fleetRow['fleet_start_id'], 'startPlanetName' => $fleetRow['startPlanetName'], 'startPlanetGalaxy' => $fleetRow['fleet_start_galaxy'], 'startPlanetSystem' => $fleetRow['fleet_start_system'], 'startPlanetPlanet' => $fleetRow['fleet_start_planet'], 'startPlanetType' => $fleetRow['fleet_start_type'], 'targetUserID' => $fleetRow['fleet_target_owner'], 'targetUserName' => $fleetRow['targetUserName'], 'targetPlanetID' => $fleetRow['fleet_end_id'], 'targetPlanetName' => $fleetRow['targetPlanetName'], 'targetPlanetGalaxy' => $fleetRow['fleet_end_galaxy'], 'targetPlanetSystem' => $fleetRow['fleet_end_system'], 'targetPlanetPlanet' => $fleetRow['fleet_end_planet'], 'targetPlanetType' => $fleetRow['fleet_end_type'], 'resource' => array(901 => $fleetRow['fleet_resource_metal'], 902 => $fleetRow['fleet_resource_crystal'], 903 => $fleetRow['fleet_resource_deuterium'], 921 => $fleetRow['fleet_resource_darkmatter'])); } $GLOBALS['DATABASE']->free_result($fleetResult); $template = new template(); $template->assign_vars(array('FleetList' => $FleetList)); $template->show('FlyingFleetPage.tpl'); }
function ShowDisclamerPage() { global $LNG; $config = Config::get(Universe::getEmulated()); if (!empty($_POST)) { $config_before = array('disclamerAddress' => $config->disclamerAddress, 'disclamerPhone' => $config->disclamerPhone, 'disclamerMail' => $config->disclamerMail, 'disclamerNotice' => $config->disclamerNotice); $disclaimerAddress = HTTP::_GP('disclaimerAddress', '', true); $disclaimerPhone = HTTP::_GP('disclaimerPhone', '', true); $disclaimerMail = HTTP::_GP('disclaimerMail', '', true); $disclaimerNotice = HTTP::_GP('disclaimerNotice', '', true); $config_after = array('disclamerAddress' => $disclaimerAddress, 'disclamerPhone' => $disclaimerPhone, 'disclamerMail' => $disclaimerMail, 'disclamerNotice' => $disclaimerNotice); foreach ($config_after as $key => $value) { $config->{$key} = $value; } $config->save(); $LOG = new Log(3); $LOG->target = 5; $LOG->old = $config_before; $LOG->new = $config_after; $LOG->save(); } $template = new template(); $template->loadscript('../base/jquery.autosize-min.js'); $template->execscript('$(\'textarea\').autosize();'); $template->assign_vars(array('disclaimerAddress' => $config->disclamerAddress, 'disclaimerPhone' => $config->disclamerPhone, 'disclaimerMail' => $config->disclamerMail, 'disclaimerNotice' => $config->disclamerNotice, 'se_server_parameters' => $LNG['mu_disclaimer'], 'se_save_parameters' => $LNG['se_save_parameters'], 'se_disclaimerAddress' => $LNG['se_disclaimerAddress'], 'se_disclaimerPhone' => $LNG['se_disclaimerPhone'], 'se_disclaimerMail' => $LNG['se_disclaimerMail'], 'se_disclaimerNotice' => $LNG['se_disclaimerNotice'])); $template->show('DisclamerConfigBody.tpl'); }
function buy() { global $USER, $LNG, $THEME; $days = HTTP::_GP('planetcloak', ''); if ($days == '') { $this->printMessage('<span class="rouge">please select the option you want to purchase</span>', true, array('game.php?page=Planetcloak', 2)); } elseif ($days == 'one') { if ($USER['darkmatter'] < 1) { $this->printMessage('<span class="rouge">You dont have enough credits to purchase this option</span>', true, array('game.php?page=Planetcloak', 2)); } elseif ($USER['planet_cloak_countdown'] > TIMESTAMP) { $this->printMessage('<span class="rouge">Countdown is not finished</span>', true, array('game.php?page=Planetcloak', 2)); } else { $USER['darkmatter'] -= 1; $GLOBALS['DATABASE']->query("Update " . USERS . " SET `planet_cloak` = " . (TIMESTAMP + 24 * 60 * 60) . ", `planet_cloak_countdown` = " . (TIMESTAMP + 8 * 24 * 60 * 60) . " WHERE `id` = " . $USER['id'] . ";"); //$GLOBALS['DATABASE']->query("INSERT INTO uni1_planetcloak_log VALUES ('".$GLOBALS['DATABASE']->GetInsertID()."','".$USER['id']."','".TIMESTAMP."','1');"); $GLOBALS['DATABASE']->query("INSERT INTO `uni1_achats_log` VALUES (null, '" . TIMESTAMP . "', '" . $USER['id'] . "', 'Pcloak(1)', '1');"); $this->printMessage('<span class="vert">You succesfully activated planet cloak for 1 days</span>', true, array('game.php?page=Planetcloak', 2)); } } elseif ($days == 'seven') { if ($USER['darkmatter'] < 3) { $this->printMessage('<span class="rouge">You dont have enough credits to purchase this option</span>', true, array('game.php?page=Planetcloak', 2)); } elseif ($USER['planet_cloak_countdown'] > TIMESTAMP) { $this->printMessage('<span class="rouge">Countdown is not finished</span>', true, array('game.php?page=Planetcloak', 2)); } else { $USER['darkmatter'] -= 3; $GLOBALS['DATABASE']->query("Update " . USERS . " SET `planet_cloak` = " . (TIMESTAMP + 7 * 24 * 60 * 60) . ", `planet_cloak_countdown` = " . (TIMESTAMP + 37 * 24 * 60 * 60) . " WHERE `id` = " . $USER['id'] . ";"); //$GLOBALS['DATABASE']->query("INSERT INTO uni1_planetcloak_log VALUES ('".$GLOBALS['DATABASE']->GetInsertID()."','".$USER['id']."','".TIMESTAMP."','5');"); $GLOBALS['DATABASE']->query("INSERT INTO `uni1_achats_log` VALUES (null, '" . TIMESTAMP . "', '" . $USER['id'] . "', 'Pcloak(7)', '3');"); $this->printMessage('<span class="vert">You succesfully activated planet cloak for 7 days</span>', true, array('game.php?page=Planetcloak', 2)); } } $this->tplObj->assign_vars(array()); $this->display('page.planetcloak.default.tpl'); }
function ShowUpdatePage() { global $LNG, $CONF; $template = new template(); $template->message('<p>This Site is currently under construction, because the update system brings somtimes inconsistent game installations.</p><p>Alternate update process: <a href="http://2moons.cc/b4-support/b7-installation-update-und-konvertierung/t1721-howto-update-your-2moons-game-with-private-modifications-without-edit-files-one-by-one/" target="blank"><u>2moons.cc Board</u></a></p><p>We apologize for any inconvenience.</p>'); exit; if (!function_exists('curl_init')) { $template = new template(); $template->message($LNG['up_need_curl']); } if (isset($_REQUEST['version'])) { $Temp = explode('.', $_REQUEST['version']); $Temp = array_map('intval', $Temp); if (count(GetLogs($Temp[2]), COUNT_RECURSIVE) > 8) { Config::update(array('VERSION' => $Temp[0] . '.' . $Temp[1] . '.' . $Temp[2])); } } $ACTION = HTTP::_GP('action', ''); switch ($ACTION) { case "download": DownloadUpdates(); break; case "check": CheckPermissions(); break; case "update": ExecuteUpdates(); break; default: DisplayUpdates(); break; } }
public function setup() { if (get_setting('index_per_page')) { $this->per_page = get_setting('index_per_page'); } HTTP::no_cache_header(); }
public function on_page_load() { $username = Auth::get_username(); Auth::instance()->logout(TRUE); Observer::notify('admin_after_logout', $username); HTTP::redirect($this->get('next_url', Request::current()->referrer())); }
/** * */ public function action_logout() { if (!\Registry::getCurrentUser()->isGuest()) { \Auth\Base::destroy(); } \HTTP::redirect(\Route::get('SystemRoute')->uri(['controller' => 'Main', 'action' => 'Login']), 302); }
function ShowNewsPage() { global $LNG, $USER; if ($_GET['action'] == 'send') { $edit_id = HTTP::_GP('id', 0); $title = $GLOBALS['DATABASE']->sql_escape(HTTP::_GP('title', '', true)); $text = $GLOBALS['DATABASE']->sql_escape(HTTP::_GP('text', '', true)); $query = $_GET['mode'] == 2 ? "INSERT INTO " . NEWS . " (`id` ,`user` ,`date` ,`title` ,`text`) VALUES ( NULL , '" . $USER['username'] . "', '" . TIMESTAMP . "', '" . $title . "', '" . $text . "');" : "UPDATE " . NEWS . " SET `title` = '" . $title . "', `text` = '" . $text . "', `date` = '" . TIMESTAMP . "' WHERE `id` = '" . $edit_id . "' LIMIT 1;"; $GLOBALS['DATABASE']->query($query); } elseif ($_GET['action'] == 'delete' && isset($_GET['id'])) { $GLOBALS['DATABASE']->query("DELETE FROM " . NEWS . " WHERE `id` = '" . HTTP::_GP('id', 0) . "';"); } $query = $GLOBALS['DATABASE']->query("SELECT * FROM " . NEWS . " ORDER BY id ASC"); while ($u = $GLOBALS['DATABASE']->fetch_array($query)) { $NewsList[] = array('id' => $u['id'], 'title' => $u['title'], 'date' => _date($LNG['php_tdformat'], $u['date'], $USER['timezone']), 'user' => $u['user'], 'confirm' => sprintf($LNG['nws_confirm'], $u['title'])); } $template = new template(); if ($_GET['action'] == 'edit' && isset($_GET['id'])) { $News = $GLOBALS['DATABASE']->getFirstRow("SELECT id, title, text FROM " . NEWS . " WHERE id = '" . $GLOBALS['DATABASE']->sql_escape($_GET['id']) . "';"); $template->assign_vars(array('mode' => 1, 'nws_head' => sprintf($LNG['nws_head_edit'], $News['title']), 'news_id' => $News['id'], 'news_title' => $News['title'], 'news_text' => $News['text'])); } elseif ($_GET['action'] == 'create') { $template->assign_vars(array('mode' => 2, 'nws_head' => $LNG['nws_head_create'])); } $template->assign_vars(array('NewsList' => $NewsList, 'button_submit' => $LNG['button_submit'], 'nws_total' => sprintf($LNG['nws_total'], count($NewsList)), 'nws_news' => $LNG['nws_news'], 'nws_id' => $LNG['nws_id'], 'nws_title' => $LNG['nws_title'], 'nws_date' => $LNG['nws_date'], 'nws_from' => $LNG['nws_from'], 'nws_del' => $LNG['nws_del'], 'nws_create' => $LNG['nws_create'], 'nws_content' => $LNG['nws_content'])); $template->show('NewsPage.tpl'); }
function Execute() { require_once 'http.php'; $http = new HTTP(); if ($http->POST($this->url, $this->post_data)) { if (strpos($http->body, NETWORK_SUCCESS) === 0) { return substr($http->body, strlen(NETWORK_SUCCESS)); } else { $this->error = substr(strip_tags($http->body), 0, 100); return false; } } else { $this->error = $http->error; return false; } }
/** * Update new forum */ public function action_update() { Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Topic'))); $topic = new Model_Topic($this->request->param('id')); $get_all = Model_Forum::get_all(); //get all forums to build forum parents in select $forum_parents = array(); foreach ($get_all[0] as $parent) { $forum_parents[$parent['id']] = $parent['name']; } $this->template->content = View::factory('oc-panel/pages/forum/topic', array('topic' => $topic, 'forum_parents' => $forum_parents)); if ($_POST) { $topic->title = core::post('title'); $topic->id_forum = core::post('id_forum'); $topic->description = core::post('description'); if (core::post('seotitle') != $topic->seotitle) { $topic->seotitle = $topic->gen_seotitle(core::post('seotitle')); } if (core::post('status') == 'on') { $topic->status = 1; } else { $topic->status = 0; } try { $topic->save(); Alert::set(Alert::SUCCESS, __('Topic is updated.')); } catch (Exception $e) { Alert::set(Alert::ERROR, $e->getMessage()); } HTTP::redirect(Route::url('oc-panel', array('controller' => 'topic', 'action' => 'index'))); } }
/** * Output file to the browser. * For performance reasons, we avoid SS_HTTPResponse and just output the contents instead. */ public function sendFile($file) { $path = $file->getFullPath(); if (SapphireTest::is_running_test()) { return file_get_contents($path); } header('Content-Description: File Transfer'); // Quotes needed to retain spaces (http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download) header('Content-Disposition: inline; filename="' . basename($path) . '"'); header('Content-Length: ' . $file->getAbsoluteSize()); header('Content-Type: ' . HTTP::get_mime_type($file->getRelativePath())); header('Content-Transfer-Encoding: binary'); // Fixes IE6,7,8 file downloads over HTTPS bug (http://support.microsoft.com/kb/812935) header('Pragma: '); if ($this->config()->min_download_bandwidth) { // Allow the download to last long enough to allow full download with min_download_bandwidth connection. increase_time_limit_to((int) (filesize($path) / ($this->config()->min_download_bandwidth * 1024))); } else { // Remove the timelimit. increase_time_limit_to(0); } // Clear PHP buffer, otherwise the script will try to allocate memory for entire file. while (ob_get_level() > 0) { ob_end_flush(); } // Prevent blocking of the session file by PHP. Without this the user can't visit another page of the same // website during download (see http://konrness.com/php5/how-to-prevent-blocking-php-requests/) session_write_close(); readfile($path); die; }
public function action_index() { if (!Auth::instance()->logged_in() && isset($_POST['login'])) { $user = ORM::factory('User'); $status = Auth::instance()->login($_POST['username'], $_POST['password'], true); if ($status) { HTTP::redirect('/'); } } if (Auth::instance()->logged_in() && isset($_POST['logout'])) { Auth::instance()->logout(); } if (!Auth::instance()->logged_in()) { Guestid::factory()->get_id(); } $templateData['title'] = 'Главная.'; $templateData['description'] = ''; $template = View::factory('template')->set('templateData', $templateData); $content = View::factory("catalog"); $content->get = $_GET; $content->shopArr = Model::factory('Shop')->getShop(); $root_page = "index"; $template->root_page = $root_page; $template->content = $content; $this->response->body($template); }
function buy() { global $USER, $LNG, $THEME, $UNI; $days = HTTP::_GP('hide', 1); if ($days == 1) { if ($USER['planet_cloak_countdown'] > TIMESTAMP) { $this->printMessage($LNG['planetcloak_cntdown'], true, array('game.php?page=overview', 2)); } elseif ($USER['darkmatter'] < 500000) { $this->printMessage($LNG['gover_notres'], true, array('game.php?page=overview', 2)); } else { $USER['darkmatter'] -= 500000; $GLOBALS['DATABASE']->query("Update " . USERS . " SET `planet_cloak` = " . (TIMESTAMP + 3 * 24 * 60 * 60) . " WHERE `id` = " . $USER['id'] . " AND universe = " . $UNI . ";"); $GLOBALS['DATABASE']->query("Update " . USERS . " SET `planet_cloak_countdown` = " . (TIMESTAMP + 11 * 24 * 60 * 60) . " WHERE `id` = " . $USER['id'] . " AND universe = " . $UNI . ";"); $GLOBALS['DATABASE']->query("INSERT INTO uni1_planetcloak_log VALUES ('" . $GLOBALS['DATABASE']->GetInsertID() . "','" . $USER['id'] . "','" . TIMESTAMP . "','20000');"); $this->printMessage($LNG['planetcloak_activate_one'], true, array('game.php?page=overview', 2)); } } elseif ($days == 2) { if ($USER['planet_cloak_countdown'] > TIMESTAMP) { $this->printMessage($LNG['planetcloak_cntdown'], true, array('game.php?page=overview', 2)); } elseif ($USER['darkmatter'] < 2000000) { $this->printMessage($LNG['gover_notres'], true, array('game.php?page=overview', 2)); } else { $USER['darkmatter'] -= 2000000; $GLOBALS['DATABASE']->query("Update " . USERS . " SET `planet_cloak` = " . (TIMESTAMP + 14 * 24 * 60 * 60) . " WHERE `id` = " . $USER['id'] . " AND universe = " . $UNI . ";"); $GLOBALS['DATABASE']->query("Update " . USERS . " SET `planet_cloak_countdown` = " . (TIMESTAMP + 44 * 24 * 60 * 60) . " WHERE `id` = " . $USER['id'] . " AND universe = " . $UNI . ";"); $GLOBALS['DATABASE']->query("INSERT INTO uni1_planetcloak_log VALUES ('" . $GLOBALS['DATABASE']->GetInsertID() . "','" . $USER['id'] . "','" . TIMESTAMP . "','100000');"); $this->printMessage($LNG['planetcloak_activate_seven'], true, array('game.php?page=overview', 2)); } } $this->tplObj->assign_vars(array()); $this->display('page.planetcloak.default.tpl'); }
function show() { global $USER, $PLANET, $LNG, $UNI, $CONF, $resource, $pricelist; $mode = HTTP::_GP('y', ''); $table = ""; $range = $PLANET['hangar'] * 3 - 2; if ($range < 0) { $range = 0; } if ($mode == '1') { $cautare = $GLOBALS['DATABASE']->query("SELECT *from " . PLANETS . " where (`der_metal` >0 OR `der_crystal` >0) AND (`system` > '" . ($PLANET['system'] - $range) . "' AND `system` < '" . ($PLANET['system'] + $range) . "') AND `galaxy` = '" . $PLANET['galaxy'] . "' and `planet_type` = '1' AND universe = " . $UNI . " ;"); $table = "<tr><th>" . $LNG['debris_action_1'] . "</th><th>" . $LNG['debris_action_2'] . "</th><th>" . $LNG['debris_action_3'] . "</th><th>" . $LNG['debris_action_4'] . "</th><th>" . $LNG['debris_action_5'] . "</th><th>" . $LNG['debris_action_6'] . "\n\t\t\t</th></tr>"; //print_r($cautare); if ($GLOBALS['DATABASE']->numRows($cautare) > 0) { while ($GalaxyRowPlanet = $GLOBALS['DATABASE']->fetch_array($cautare)) { $GRecNeeded = min(ceil(($GalaxyRowPlanet['der_metal'] + $GalaxyRowPlanet['der_crystal']) / $pricelist[219]['capacity']), $PLANET[$resource[219]]); $table .= "<tr><td>" . $GalaxyRowPlanet['galaxy'] . "</td><td>" . $GalaxyRowPlanet['system'] . "</td><td>" . $GalaxyRowPlanet['planet'] . "</td><td>" . pretty_number($GalaxyRowPlanet['der_metal']) . "</td><td>" . pretty_number($GalaxyRowPlanet['der_crystal']) . "</td><td><a href='javascript:doit(8," . $GalaxyRowPlanet['id'] . ");'>" . $LNG['debris_action_6'] . "</a></td></tr>"; } } else { $table .= "<tr><td colspan='6'>" . $LNG['debris_action_7'] . "</td></tr>"; } } $this->tplObj->assign_vars(array('range' => $range, 'debris' => $table, 'user_maxfleetsettings' => $USER['settings_fleetactions'])); $this->display("page.finddebris.default.tpl"); }
public function setup() { HTTP::no_cache_header(); if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator']) { H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你没有权限进行此操作'))); } }
function show() { if (empty($_POST)) { HTTP::redirectTo('index.php'); } $db = Database::get(); $username = HTTP::_GP('username', '', UTF8_SUPPORT); $password = HTTP::_GP('password', '', true); $sql = "SELECT id, password FROM %%USERS%% WHERE universe = :universe AND username = :username;"; $loginData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $username)); if (isset($loginData)) { $hashedPassword = PlayerUtil::cryptPassword($password); if ($loginData['password'] != $hashedPassword) { // Fallback pre 1.7 if ($loginData['password'] == md5($password)) { $sql = "UPDATE %%USERS%% SET password = :hashedPassword WHERE id = :loginID;"; $db->update($sql, array(':hashedPassword' => $hashedPassword, ':loginID' => $loginData['id'])); } else { HTTP::redirectTo('index.php?code=1'); } } $session = Session::create(); $session->userId = (int) $loginData['id']; $session->adminAccess = 0; $session->save(); HTTP::redirectTo('game.php'); } else { HTTP::redirectTo('index.php?code=1'); } }
public function index_action() { if (is_digits($_GET['id'])) { $feature_info = $this->model('feature')->get_feature_by_id($_GET['id']); } else { $feature_info = $this->model('feature')->get_feature_by_url_token($_GET['id']); } if (!$feature_info) { header('HTTP/1.1 404 Not Found'); H::redirect_msg(AWS_APP::lang()->_t('专题不存在'), '/'); } if (!$feature_info['enabled']) { H::redirect_msg(AWS_APP::lang()->_t('专题未启用'), '/'); } if ($feature_info['url_token'] != $_GET['id'] and !$_GET['sort_type'] and !$_GET['is_recommend']) { HTTP::redirect('/feature/' . $feature_info['url_token']); } if (!($topic_list = $this->model('topic')->get_topics_by_ids($this->model('feature')->get_topics_by_feature_id($feature_info['id'])))) { H::redirect_msg(AWS_APP::lang()->_t('专题下必须包含一个以上话题'), '/'); } if ($feature_info['seo_title']) { TPL::assign('page_title', $feature_info['seo_title']); } else { $this->crumb($feature_info['title'], '/feature/' . $feature_info['url_token']); } TPL::assign('sidebar_hot_topics', $topic_list); TPL::assign('feature_info', $feature_info); TPL::import_js('js/app/feature.js'); TPL::output('feature/detail'); }
public function getUserAgentLanguage() { if (isset($_REQUEST['lang']) && in_array($_REQUEST['lang'], self::getAllowedLangs())) { HTTP::sendCookie('lang', $_REQUEST['lang'], 2147483647); $this->setLanguage($_REQUEST['lang']); return true; } if ((MODE === 'LOGIN' || MODE === 'INSTALL') && isset($_COOKIE['lang']) && in_array($_COOKIE['lang'], self::getAllowedLangs())) { $this->setLanguage($_COOKIE['lang']); return true; } if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { return false; } $accepted_languages = preg_split('/,\\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $language = $this->getLanguage(); foreach ($accepted_languages as $accepted_language) { $isValid = preg_match('!^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$!i', $accepted_language, $matches); if ($isValid !== 1) { continue; } list($code) = explode('-', strtolower($matches[1])); if (in_array($code, self::getAllowedLangs())) { $language = $code; break; } } HTTP::sendCookie('lang', $language, 2147483647); $this->setLanguage($language); return $language; }
public function index(SS_HTTPRequest $request) { $properties = Property::get(); $filters = ArrayList::create(); if ($search = $request->getVar('Keywords')) { $filters->push(ArrayData::create(array('Label' => "Keywords: '{$search}'", 'RemoveLink' => HTTP::setGetVar('Keywords', null)))); $properties = $properties->filter(array('Title:PartialMatch' => $search)); } if ($arrival = $request->getVar('ArrivalDate')) { $arrivalStamp = strtotime($arrival); $nightAdder = '+' . $request->getVar('Nights') . ' days'; $startDate = date('Y-m-d', $arrivalStamp); $endDate = date('Y-m-d', strtotime($nightAdder, $arrivalStamp)); $properties = $properties->filter(array('AvailableStart:GreaterThanOrEqual' => $startDate, 'AvailableEnd:LessThanOrEqual' => $endDate)); } if ($bedrooms = $request->getVar('Bedrooms')) { $filters->push(ArrayData::create(array('Label' => "{$bedrooms} bedrooms", 'RemoveLink' => HTTP::setGetVar('Bedrooms', null)))); $properties = $properties->filter(array('Bedrooms:GreaterThanOrEqual' => $bedrooms)); } if ($bathrooms = $request->getVar('Bathrooms')) { $filters->push(ArrayData::create(array('Label' => "{$bathrooms} bathrooms", 'RemoveLink' => HTTP::setGetVar('Bathrooms', null)))); $properties = $properties->filter(array('Bathrooms:GreaterThanOrEqual' => $bathrooms)); } if ($minPrice = $request->getVar('MinPrice')) { $filters->push(ArrayData::create(array('Label' => "Min. \${$minPrice}", 'RemoveLink' => HTTP::setGetVar('MinPrice', null)))); $properties = $properties->filter(array('PricePerNight:GreaterThanOrEqual' => $minPrice)); } if ($maxPrice = $request->getVar('MaxPrice')) { $filters->push(ArrayData::create(array('Label' => "Max. \${$maxPrice}", 'RemoveLink' => HTTP::setGetVar('MaxPrice', null)))); $properties = $properties->filter(array('PricePerNight:LessThanOrEqual' => $maxPrice)); } $paginatedProperties = PaginatedList::create($properties, $request)->setPageLength(15)->setPaginationGetVar('s'); return array('Results' => $paginatedProperties, 'ActiveFilters' => $filters); }