本文整理匯總了PHP中send_http_status函數的典型用法代碼示例。如果您正苦於以下問題:PHP send_http_status函數的具體用法?PHP send_http_status怎麽用?PHP send_http_status使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了send_http_status函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _empty
public function _empty()
{
$this->redirect('index/index');
exit;
send_http_status(404);
$this->display(TMPL_PATH . '404.html');
}
示例2: _denyDirectory
/**
* 禁止路徑
*
* @author mrmsl <msl-138@163.com>
* @date 2012-07-10 15:40:01
* @lastmodify 2013-01-22 10:51:46 by mrmsl
*
* @param string $path 待檢測路徑
*
* @return void 無返回值
*/
private function _denyDirectory($path)
{
if (false !== strpos($path, '..')) {
$this->_model->addLog(L('LIST_DIRECTORY_FORBIDDEN') . PACKER_JS_PATH . $path, LOG_TYPE_INVALID_PARAM);
send_http_status(HTTP_STATUS_SERVER_ERROR);
$this->_ajaxReturn(L('LIST_DIRECTORY_FORBIDDEN') . PACKER_JS_PATH . $path);
}
}
示例3: _denyDirectory
/**
* 禁止路徑
*
* @author mrmsl <msl-138@163.com>
* @date 2012-07-10 15:40:01
*
* @param string $path 待檢測路徑
*
* @return void 無返回值
*/
private function _denyDirectory($path)
{
if (false !== strpos($path, '..')) {
$log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . L('LIST_DIRECTORY_FORBIDDEN') . PACKER_JS_PATH . $path;
trigger_error($log, E_USER_ERROR);
send_http_status(HTTP_STATUS_SERVER_ERROR);
$this->_ajaxReturn(true, L('LIST_DIRECTORY_FORBIDDEN') . PACKER_JS_PATH . $path);
}
}
示例4: _404
protected function _404($url = '')
{
if ($url) {
redirect($url);
} else {
send_http_status(404);
$this->display(TMPL_PATH . '404.html');
exit;
}
}
示例5: _productNotExist
protected function _productNotExist($url = '')
{
if ($url) {
redirect($url);
} else {
send_http_status(404);
$this->display('Public/productNotExist');
exit;
}
}
示例6: _empty
/**
* 空操作,用於輸出404頁麵
*/
public function _empty()
{
//針對後台ajax請求特殊處理
if (!IS_AJAX) {
send_http_status(404);
}
if (IS_AJAX && IS_POST) {
$data = array('info' => '請求地址不存在或已經刪除', 'status' => 0, 'total' => 0, 'rows' => array());
$this->ajaxReturn($data);
} else {
$this->display('Common:404');
}
}
示例7: _initialize
public function _initialize()
{
parent::_initialize();
$this->Config = F("Member_Config");
if (!$this->Config) {
$setting = M("Module")->where(array("module" => "Member"))->getField("setting");
if (!$setting) {
//獲取不到配置,記錄錯誤日誌
$msg = "獲取不到相關配置,QQ互聯無法進行!";
if (APP_DEBUG) {
// 模塊不存在 拋出異常
throw_exception($msg);
} else {
if (C('LOG_EXCEPTION_RECORD')) {
Log::write($msg);
}
send_http_status(404);
exit;
}
}
$this->Config = unserialize($setting);
F("Member_Config", $this->Config);
}
$this->qq_akey = $this->Config['qq_akey'];
$this->qq_skey = $this->Config['qq_skey'];
if (!$this->qq_akey || !$this->qq_skey) {
$msg = "沒有進行QQ互聯的相關配置,請配置後在繼續使用!";
if (APP_DEBUG) {
// 模塊不存在 拋出異常
throw_exception($msg);
} else {
if (C('LOG_EXCEPTION_RECORD')) {
Log::write($msg);
}
send_http_status(404);
exit;
}
}
//跳轉時間
$this->assign("waitSecond", 2000);
}
示例8: prohibitAccess
/**
* 禁止非法訪問
*/
private function prohibitAccess()
{
if (!in_array(MODULE_NAME, C('MODULE_ALLOW_LIST'))) {
if (APP_DEBUG) {
E('該模塊沒有安裝,無法進行訪問!');
} else {
send_http_status(400);
exit;
}
}
$config = cache('Config');
if (MODULE_NAME == 'Admin' && isModuleInstall('Domains') && $config['domainaccess']) {
$Module_Domains_list = cache('Module_Domains_list');
$http_host = strtolower($_SERVER['HTTP_HOST']);
$domain = explode('|', $Module_Domains_list['Admin']);
if ($Module_Domains_list['Admin'] && !in_array($http_host, $domain)) {
send_http_status(404);
exit;
}
}
}
示例9: dispatch
//.........這裏部分代碼省略.........
if (is_file(MODULE_PATH . 'Conf/config' . CONF_EXT)) {
C(load_config(MODULE_PATH . 'Conf/config' . CONF_EXT));
}
// 加載應用模式對應的配置文件
if ('common' != APP_MODE && is_file(MODULE_PATH . 'Conf/config_' . APP_MODE . CONF_EXT)) {
C(load_config(MODULE_PATH . 'Conf/config_' . APP_MODE . CONF_EXT));
}
// 當前應用狀態對應的配置文件
if (APP_STATUS && is_file(MODULE_PATH . 'Conf/' . APP_STATUS . CONF_EXT)) {
C(load_config(MODULE_PATH . 'Conf/' . APP_STATUS . CONF_EXT));
}
// 加載模塊別名定義
if (is_file(MODULE_PATH . 'Conf/alias.php')) {
Think::addMap(include MODULE_PATH . 'Conf/alias.php');
}
// 加載模塊tags文件定義
if (is_file(MODULE_PATH . 'Conf/tags.php')) {
Hook::import(include MODULE_PATH . 'Conf/tags.php');
}
// 加載模塊函數文件
if (is_file(MODULE_PATH . 'Common/function.php')) {
include MODULE_PATH . 'Common/function.php';
}
// 加載模塊的擴展配置文件
load_ext_file(MODULE_PATH);
} else {
E(L('_MODULE_NOT_EXIST_') . ':' . MODULE_NAME);
}
if (!defined('__APP__')) {
$urlMode = C('URL_MODEL');
if ($urlMode == URL_COMPAT) {
// 兼容模式判斷
define('PHP_FILE', _PHP_FILE_ . '?' . $varPath . '=');
} elseif ($urlMode == URL_REWRITE) {
$url = dirname(_PHP_FILE_);
if ($url == '/' || $url == '\\') {
$url = '';
}
define('PHP_FILE', $url);
} else {
define('PHP_FILE', _PHP_FILE_);
}
// 當前應用地址
define('__APP__', strip_tags(PHP_FILE));
}
// 模塊URL地址
$moduleName = defined('MODULE_ALIAS') ? MODULE_ALIAS : MODULE_NAME;
define('__MODULE__', defined('BIND_MODULE') || !C('MULTI_MODULE') ? __APP__ : __APP__ . '/' . ($urlCase ? strtolower($moduleName) : $moduleName));
if ('' != $_SERVER['PATH_INFO'] && (!C('URL_ROUTER_ON') || !Route::check())) {
// 檢測路由規則 如果沒有則按默認規則調度URL
Hook::listen('path_info');
// 檢查禁止訪問的URL後綴
if (C('URL_DENY_SUFFIX') && preg_match('/\\.(' . trim(C('URL_DENY_SUFFIX'), '.') . ')$/i', $_SERVER['PATH_INFO'])) {
send_http_status(404);
exit;
}
// 去除URL後綴
$_SERVER['PATH_INFO'] = preg_replace(C('URL_HTML_SUFFIX') ? '/\\.(' . trim(C('URL_HTML_SUFFIX'), '.') . ')$/i' : '/\\.' . __EXT__ . '$/i', '', $_SERVER['PATH_INFO']);
$depr = C('URL_PATHINFO_DEPR');
$paths = explode($depr, trim($_SERVER['PATH_INFO'], $depr));
if (!defined('BIND_CONTROLLER')) {
// 獲取控製器
if (C('CONTROLLER_LEVEL') > 1) {
// 控製器層次
$_GET[$varController] = implode('/', array_slice($paths, 0, C('CONTROLLER_LEVEL')));
$paths = array_slice($paths, C('CONTROLLER_LEVEL'));
} else {
$_GET[$varController] = array_shift($paths);
}
}
// 獲取操作
if (!defined('BIND_ACTION')) {
$_GET[$varAction] = array_shift($paths);
}
// 解析剩餘的URL參數
$var = array();
if (C('URL_PARAMS_BIND') && 1 == C('URL_PARAMS_BIND_TYPE')) {
// URL參數按順序綁定變量
$var = $paths;
} else {
preg_replace_callback('/(\\w+)\\/([^\\/]+)/', function ($match) use(&$var) {
$var[$match[1]] = strip_tags($match[2]);
}, implode('/', $paths));
}
$_GET = array_merge($var, $_GET);
}
// 獲取控製器的命名空間(路徑)
define('CONTROLLER_PATH', self::getSpace($varAddon, $urlCase));
// 獲取控製器和操作名
define('CONTROLLER_NAME', defined('BIND_CONTROLLER') ? BIND_CONTROLLER : self::getController($varController, $urlCase));
define('ACTION_NAME', defined('BIND_ACTION') ? BIND_ACTION : self::getAction($varAction, $urlCase));
// 當前控製器的UR地址
$controllerName = defined('CONTROLLER_ALIAS') ? CONTROLLER_ALIAS : CONTROLLER_NAME;
define('__CONTROLLER__', __MODULE__ . $depr . (defined('BIND_CONTROLLER') ? '' : ($urlCase ? parse_name($controllerName) : $controllerName)));
// 當前操作的URL地址
define('__ACTION__', __CONTROLLER__ . $depr . (defined('ACTION_ALIAS') ? ACTION_ALIAS : ACTION_NAME));
//保證$_REQUEST正常取值
$_REQUEST = array_merge($_POST, $_GET, $_COOKIE);
// -- 加了$_COOKIE. 保證哦..
}
示例10: send_http_status
case "404_1":
send_http_status(404);
echo '{"request_id":100, "error_code":10000 , "error_msg":"what is that??"}';
break;
case "404_2":
send_http_status(404);
echo 'what is this??';
break;
case "200_1":
send_http_status(200);
echo '{"request_id":100, "response_params":[1,2,3,4]}';
break;
case "200_2":
send_http_status(200);
echo 'what is this??';
case "200_3":
send_http_status(200);
echo '{"request_id":100, "error_code":4567}';
break;
case 'checkSign':
send_http_status(200);
$rs = array('request_id' => 100, 'response_params' => $_REQUEST);
echo json_encode($rs);
break;
default:
send_http_status(204);
}
} else {
$log->log(print_r($_REQUEST, true));
echo json_encode($_REQUEST);
}
示例11: exec
/**
+----------------------------------------------------------
* 執行應用程序
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public static function exec()
{
// 安全檢測df
if (!preg_match('/^[A-Za-z_0-9]+$/', MODULE_NAME)) {
$module = false;
} else {
//創建Action控製器實例
$group = defined('GROUP_NAME') ? GROUP_NAME . '/' : '';
$module = A($group . MODULE_NAME);
}
if (!$module) {
if (function_exists('__hack_module')) {
// hack 方式定義擴展模塊 返回Action對象
$module = __hack_module();
if (!is_object($module)) {
// 不再繼續執行 直接返回
return;
}
} else {
// 是否定義Empty模塊
$module = A('Empty');
if (!$module) {
$msg = L('_MODULE_NOT_EXIST_') . MODULE_NAME;
if (APP_DEBUG) {
// 模塊不存在 拋出異常
throw_exception($msg);
} else {
if (C('LOG_EXCEPTION_RECORD')) {
Log::write($msg);
}
send_http_status(404);
exit;
}
}
}
}
//獲取當前操作名
$action = ACTION_NAME;
// 獲取操作方法名標簽
tag('action_name', $action);
if (method_exists($module, '_before_' . $action)) {
// 執行前置操作
call_user_func(array(&$module, '_before_' . $action));
}
//執行當前操作
call_user_func(array(&$module, $action));
if (method_exists($module, '_after_' . $action)) {
// 執行後綴操作
call_user_func(array(&$module, '_after_' . $action));
}
return;
}
示例12: _404
/**
* YourPHP 函數類
*/
function _404()
{
send_http_status(404);
exit;
}
示例13: dispatch
//.........這裏部分代碼省略.........
break;
}
}
}
if (empty($_SERVER['PATH_INFO'])) {
$_SERVER['PATH_INFO'] = '';
}
$depr = C('URL_PATHINFO_DEPR');
define('MODULE_PATHINFO_DEPR', $depr);
define('__INFO__', trim($_SERVER['PATH_INFO'], '/'));
// URL後綴
define('__EXT__', strtolower(pathinfo($_SERVER['PATH_INFO'], PATHINFO_EXTENSION)));
if (__INFO__ && C('MULTI_MODULE') && !isset($_GET[$varModule])) {
// 獲取模塊
$paths = explode($depr, __INFO__, 2);
$allowList = C('MODULE_ALLOW_LIST');
$module = preg_replace('/\\.' . __EXT__ . '$/i', '', $paths[0]);
if (empty($allowList) || is_array($allowList) && in_array_case($module, $allowList)) {
$_GET[$varModule] = $module;
$_SERVER['PATH_INFO'] = isset($paths[1]) ? $paths[1] : '';
} else {
$_SERVER['PATH_INFO'] = __INFO__;
}
} else {
$_SERVER['PATH_INFO'] = __INFO__;
}
// 獲取模塊名稱
define('MODULE_NAME', self::getModule($varModule));
// 檢測模塊是否存在
if (MODULE_NAME && (!in_array_case(MODULE_NAME, C('MODULE_DENY_LIST')) || $domainModule) && is_dir(APP_PATH . MODULE_NAME)) {
// 定義當前模塊路徑
define('MODULE_PATH', APP_PATH . MODULE_NAME . '/');
// 加載模塊配置文件
if (is_file(MODULE_PATH . 'Conf/config.php')) {
C(include MODULE_PATH . 'Conf/config.php');
}
/**加載模板公共配置文件
* 2015-5-14 13:43
* 增加模板配置文件加載 start
* @author 鄭鍾良<zzl@ourstu.com>
*/
if (is_file(OS_THEME_PATH . 'config.php')) {
$TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
C(include OS_THEME_PATH . 'config.php');
$NEW_TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
$NEW_TMPL_PARSE_STRING = array_merge($NEW_TMPL_PARSE_STRING, $TMPL_PARSE_STRING);
C('TMPL_PARSE_STRING', $NEW_TMPL_PARSE_STRING);
}
/**
* 2015-5-14 13:43
* 增加模板配置文件加載 end
* @author 鄭鍾良<zzl@ourstu.com>
*/
// 加載模塊別名定義
if (is_file(MODULE_PATH . 'Conf/alias.php')) {
Think::addMap(include MODULE_PATH . 'Conf/alias.php');
}
// 加載模塊函數文件
if (is_file(MODULE_PATH . 'Common/function.php')) {
include MODULE_PATH . 'Common/function.php';
}
} else {
E(L('_MODULE_NOT_EXIST_') . ':' . MODULE_NAME, 815);
}
if ('' != $_SERVER['PATH_INFO']) {
// 檢查禁止訪問的URL後綴
if (C('URL_DENY_SUFFIX') && preg_match('/\\.(' . trim(C('URL_DENY_SUFFIX'), '.') . ')$/i', $_SERVER['PATH_INFO'])) {
send_http_status(404);
exit;
}
if (C('URL_HTML_SUFFIX')) {
$_SERVER['PATH_INFO'] = preg_replace('/\\.(' . trim(C('URL_HTML_SUFFIX'), '.') . ')$/i', '', $_SERVER['PATH_INFO']);
} else {
$_SERVER['PATH_INFO'] = preg_replace('/\\.' . __EXT__ . '$/i', '', $_SERVER['PATH_INFO']);
}
$depr = C('URL_PATHINFO_DEPR');
$paths = explode($depr, trim($_SERVER['PATH_INFO'], $depr));
if (!isset($_GET[$varController])) {
// 獲取控製器
$_GET[$varController] = array_shift($paths);
}
// 獲取操作
$_GET[$varAction] = array_shift($paths);
// 解析剩餘的URL參數
$var = array();
if (C('URL_PARAMS_BIND') && 1 == C('URL_PARAMS_BIND_TYPE')) {
// URL參數按順序綁定變量
$var = $paths;
} else {
preg_replace_callback('/(\\w+)\\/([^\\/]+)/', function ($match) use(&$var) {
$var[$match[1]] = strip_tags($match[2]);
}, implode('/', $paths));
}
$_GET = array_merge($var, $_GET);
}
define('CONTROLLER_NAME', self::getController($varController));
define('ACTION_NAME', self::getAction($varAction));
//保證$_REQUEST正常取值
$_REQUEST = array_merge($_POST, $_GET);
}
示例14: not_found
/**
* 404
*/
public function not_found()
{
send_http_status(404);
$this->__view("home/404.php");
}
示例15: _empty
public function _empty()
{
send_http_status(404);
$this->display(TMPL_PATH . '404.html');
}