本文整理汇总了PHP中HTTP类的典型用法代码示例。如果您正苦于以下问题:PHP HTTP类的具体用法?PHP HTTP怎么用?PHP HTTP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTTP类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _xUpdateGetInstaller
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);
}
}
开发者ID:hackingman,项目名称:TradeX,代码行数:28,代码来源:xhr.php
示例2: _execute
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;
}
}
开发者ID:Laxa,项目名称:Nimda3,代码行数:35,代码来源:libHTTP.php
示例3: fetchFunctionDescription
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));
}
}
开发者ID:Laxa,项目名称:Nimda3,代码行数:35,代码来源:Plugin_PHP.php
示例4: tinyURLDecode
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'];
}
开发者ID:Laxa,项目名称:Nimda3,代码行数:12,代码来源:libInternet.php
示例5: __construct
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);
}
开发者ID:Krinkle,项目名称:xtools,代码行数:13,代码来源:base.php
示例6: isTriggered
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);
}
开发者ID:Laxa,项目名称:Nimda3,代码行数:50,代码来源:Plugin_Movie.php
示例7: setup
public function setup()
{
if (get_setting('index_per_page')) {
$this->per_page = get_setting('index_per_page');
}
HTTP::no_cache_header();
}
开发者ID:Gradven,项目名称:what3.1.7,代码行数:7,代码来源:ajax.php
示例8: action_logout
/**
*
*/
public function action_logout()
{
if (!\Registry::getCurrentUser()->isGuest()) {
\Auth\Base::destroy();
}
\HTTP::redirect(\Route::get('SystemRoute')->uri(['controller' => 'Main', 'action' => 'Login']), 302);
}
开发者ID:astar3086,项目名称:studio_logistic,代码行数:10,代码来源:Main.php
示例9: Execute
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;
}
}
开发者ID:hackingman,项目名称:TradeX,代码行数:16,代码来源:network-util.php
示例10: sendFile
/**
* 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;
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce-downloadableproduct,代码行数:35,代码来源:DownloadableFileController.php
示例11: buy
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');
}
开发者ID:Decoder1978,项目名称:Xterium,代码行数:32,代码来源:class.ShowPlanetcloakPage.php
示例12: show
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');
}
}
开发者ID:tatarysh,项目名称:2Moons,代码行数:30,代码来源:ShowLoginPage.class.php
示例13: ShowChatConfigPage
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');
}
开发者ID:tatarysh,项目名称:2Moons,代码行数:29,代码来源:ShowChatConfigPage.php
示例14: ShowFlyingFleetPage
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');
}
开发者ID:tatarysh,项目名称:2Moons,代码行数:27,代码来源:ShowFlyingFleetPage.php
示例15: ShowDisclamerPage
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');
}
开发者ID:bergi9,项目名称:2Moons,代码行数:27,代码来源:ShowDisclamerPage.php
示例16: getUserAgentLanguage
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;
}
开发者ID:tatarysh,项目名称:2Moons,代码行数:31,代码来源:Language.class.php
示例17: index_action
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');
}
开发者ID:Gradven,项目名称:what3.1.7,代码行数:30,代码来源:main.php
示例18: __construct
public function __construct()
{
if (isset(self::$current)) {
throw new ConstructionException('Cannot construct more than one instance of singleton class HTTP.');
}
self::$current = $this;
}
开发者ID:NateBrune,项目名称:bithub,代码行数:7,代码来源:HTTP.lib.php
示例19: setup
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('你没有权限进行此操作')));
}
}
开发者ID:Vizards,项目名称:HeavenSpree,代码行数:7,代码来源:ajax.php
示例20: index
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);
}
开发者ID:roopamjain01,项目名称:one_ring,代码行数:34,代码来源:PropertySearchPage.php
注:本文中的HTTP类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论