本文整理汇总了PHP中set_status_header函数的典型用法代码示例。如果您正苦于以下问题:PHP set_status_header函数的具体用法?PHP set_status_header怎么用?PHP set_status_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_status_header函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: process
public function process($slug = NULL)
{
if (!$slug) {
show_404();
}
$form = $this->fuel->forms->get($slug);
$return_url = $this->input->get_post('return_url') ? $this->input->get_post('return_url') : $form->get_return_url();
$form_url = $this->input->get_post('form_url');
if ($form and $form->process()) {
if (is_ajax()) {
// Set a 200 (okay) response code.
set_status_header('200');
echo $form->after_submit_text;
exit;
} else {
$this->session->set_flashdata('success', TRUE);
redirect($return_url);
}
} else {
$this->session->set_flashdata('posted', $this->input->post());
if (is_ajax()) {
// Set a 500 (bad) response code.
set_status_header('500');
echo display_errors(NULL, '');
exit;
} else {
if (!empty($form_url) && $form_url != $return_url) {
$return_url = $form_url;
// update to post back to the correct page when there's an error
}
$this->session->set_flashdata('error', $form->errors());
redirect($return_url);
}
}
}
开发者ID:daylightstudio,项目名称:FUEL-CMS-Forms-Module,代码行数:35,代码来源:Forms.php
示例2: show_exception
public function show_exception(Exception $exception)
{
$templates_path = config_item('error_views_path');
if (empty($templates_path)) {
$tpl = config_item('data');
$templates_path = VIEWPATH . $tpl['theme'] . DIRECTORY_SEPARATOR . 'errors' . DIRECTORY_SEPARATOR;
}
$message = $exception->getMessage();
if (empty($message)) {
$message = '(null)';
}
if (is_cli()) {
$templates_path .= 'cli' . DIRECTORY_SEPARATOR;
} else {
set_status_header(500);
$templates_path .= 'html' . DIRECTORY_SEPARATOR;
}
if (ob_get_level() > $this->ob_level + 1) {
ob_end_flush();
}
ob_start();
include $templates_path . 'error_exception.php';
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
}
开发者ID:skubbs-chuck,项目名称:emr,代码行数:26,代码来源:MY_Exceptions.php
示例3: show_error
/**
* General Error Page
*
* This function takes an error message as input
* (either as a string or an array) and displays
* it using the specified template.
*
* @param string the heading
* @param string the message
* @param string the template name
* @param int the status code
* @return string
*/
public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
$theme_path = WWW_FOLDER . 'public/themes/jakarta/';
// if CI_Controller has been loaded,
// this check is used for MyHookClass
if (class_exists('CI_Controller')) {
$CI =& get_instance();
if (method_exists($CI, 'template')) {
$theme_path = $CI->template->get_theme_path();
}
}
set_status_header($status_code);
$message = '<p>' . implode('</p><p>', is_array($message) ? $message : array($message)) . '</p>';
if (ob_get_level() > $this->ob_level + 1) {
ob_end_flush();
}
ob_start();
if (file_exists($theme_path . 'views/layouts/' . $template . '.php')) {
include $theme_path . 'views/layouts/' . $template . '.php';
} else {
include VIEWPATH . 'errors/html/' . $template . '.php';
}
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
开发者ID:biladina,项目名称:pusakacms,代码行数:39,代码来源:MY_Exceptions.php
示例4: show_error
/**
* Show an error, attempting to output the correct response type. If CI
* base classes cannot be found, the error is simply printed as plain text.
*
* @param string $heading
* @param string $message
* @param string $template
* @param int $status_code (optional)
*/
function show_error($heading, $message, $template = null, $status_code = 500)
{
// set different headers for some status codes
$std_err = preg_match('/an error was encountered/i', $heading);
if ($std_err && isset(self::$HTML_MSGS[$status_code])) {
$heading = self::$HTML_MSGS[$status_code][0];
}
if ($status_code == 415) {
set_status_header(415);
header('Content-type: text/plain', true);
$def = 'Error: Unsupported HTTP_ACCEPT format requested: ' . $_SERVER['HTTP_ACCEPT'];
echo $message && strlen($message) ? $message : $def;
} else {
if (class_exists('CI_Base')) {
$CI =& get_instance();
if (is_subclass_of($CI, 'AIR2_Controller')) {
$CI->airoutput->write_error($status_code, $heading, $message);
} else {
// non-AIR2_Controller
set_status_header($status_code);
echo "{$status_code} - {$message}";
}
} else {
// not called from a controller! Just use plaintext
set_status_header($status_code);
echo "{$message}";
}
}
}
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:38,代码来源:AIR2_Exceptions.php
示例5: index
public function index()
{
// Just show the default image.
$size = (int) $this->input->get('s');
if ($size <= 0) {
$size = 80;
}
$default_image = $this->input->get('d');
$force_default_image = $this->input->get('f') == 'y';
if (!$force_default_image) {
if ($default_image == '404') {
set_status_header(404);
exit;
}
$force_default_image = true;
}
if ($force_default_image) {
$file = $this->default_file;
$file_path = $this->default_base_path;
if ($default_image == 'blank') {
$file = $this->blank_file;
$file_path = $this->blank_base_path;
}
}
$config['source_image'] = $file_path . $file;
$config['maintain_ratio'] = true;
$config['create_thumb'] = false;
$config['height'] = $size;
$config['width'] = $size;
$config['dynamic_output'] = true;
$this->load->library('image_lib');
$this->image_lib->initialize($config);
$this->image_lib->fit();
}
开发者ID:Qnatz,项目名称:starter-public-edition-4,代码行数:34,代码来源:Home_controller.php
示例6: show_404
/**
* 404 Not Found Handler
*
* @access private
* @param string
* @return string
*/
function show_404($page = '')
{
// if cURL doesn't exist we just send them to the 404 page
if ( ! function_exists('curl_init'))
{
redirect('404');
}
// if cURL does exist we insert the 404 content into the current page
// so the url doesn't change to domain.com/404
$ch = curl_init();
// Set the HTTP Status header
set_status_header(404);
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, BASE_URL . config_item('index_page').'/404');
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
}
开发者ID:JamieLomas,项目名称:pyrocms,代码行数:32,代码来源:MY_Exceptions.php
示例7: show_404
function show_404($page = '', $log_error = TRUE)
{
include APPPATH . 'config/routes.php';
$heading = "404 Page Not Found";
$message = "The page you requested was not found.";
// By default we log this, but allow a dev to skip it
if ($log_error) {
log_message('error', '404 Page Not Found --> ' . $page);
}
if (!empty($route['404_override'])) {
set_status_header(404);
$CI =& get_instance();
$CI->auth = new stdClass();
$CI->load->library('flexi_auth');
$CI->load->helper('url');
$CI->load->helper('form');
$data['title'] = "Page Not Found";
$data['extraJS'] = '<style>.content {background-image:url(/images/404.jpg);}</style>';
$CI->load->view('templates/header', $data);
$CI->load->view('templates/menu', $data);
$CI->load->view('templates/menu_mall', $data);
$CI->load->view('errors/not_found', $data);
echo $CI->output->get_output();
exit;
} else {
echo $this->show_error($heading, $message, 'error_404', 404);
exit;
}
}
开发者ID:hasssammalik,项目名称:Pretastyler,代码行数:29,代码来源:PAS_Exceptions.php
示例8: show_404
public function show_404()
{
set_status_header(404);
$data['posts'] = $this->mongo_db->post->find(array('status' => 'publish', 'content' => array('$regex' => new MongoRegex('/' . str_replace('-', ' ', $this->uri->uri_string()) . '/i'))))->sort(array('created_at' => -1))->limit(get_option('per_page'));
$data['posts'] = iterator_to_array($data['posts']);
$this->template->set_title('Sayfa Bulunamadı - 404')->view('post/show_404', $data)->render();
}
开发者ID:navruzm,项目名称:navruz.net,代码行数:7,代码来源:post.php
示例9: load
public function load($class, $param = NULL)
{
static $_classes = array();
// Does the class exist? If so, we're done...
if (isset($_classes[$class])) {
return $_classes[$class];
}
$name = FALSE;
if (file_exists(PATH_APPLICATION . '/model/' . $class . '.php')) {
$name = $class;
if (class_exists($class, FALSE) === FALSE) {
require_once PATH_APPLICATION . '/model/' . $class . '.php';
}
}
// Did we find the class?
if ($name === FALSE) {
set_status_header(503);
echo 'Unable to locate the specified class: ' . $class . '.php';
exit(5);
// EXIT_UNK_CLASS
}
// Keep track of what we just loaded
$this->is_loaded($class);
$_classes[$class] = isset($param) ? new $name($param) : new $name();
return $_classes[$class];
}
开发者ID:xuantain,项目名称:appstore-mvc,代码行数:26,代码来源:Sys_Model_Loader.php
示例10: play
function play($trackid, $albumid)
{
$userid = $this->session->userdata('userid');
if ($userid === FALSE) {
set_status_header(400);
return;
}
try {
$track = Track::load($trackid, $albumid, $userid);
} catch (Exception $e) {
echo $e->getMessage();
}
if ($track == NULL) {
set_status_header(400);
return;
}
$src = $track->getSrc();
$bought = $track->getBoughtTime();
//echo "SRC=$src, BOUGHT=$bought\n\n";
if (empty($src) || empty($bought)) {
set_status_header(400);
return;
}
if (preg_match('/^(http)(s)?/', $src)) {
header("Location: {$src}");
} else {
header("Content-Type: audio/mpeg");
header('Content-length: ' . filesize($src));
print file_get_contents($src);
}
}
开发者ID:bennetimo,项目名称:comp3013,代码行数:31,代码来源:trackmanager.php
示例11: handleDatabaseError
public function handleDatabaseError(Exception $e)
{
$errorNumber = $this->getStringAfter($e, 'error number:');
set_status_header(200);
switch ($errorNumber) {
case "1451":
$foreign_key_constraint = $this->getStringAfter($e, ', constraint');
switch ($foreign_key_constraint) {
case "broker_ibfk_2":
return $this->message("Please remove the broker from this user first");
case "broker_ibfk_1":
return $this->message("Please remove this broker as a parent broker from all other brokers first");
case "line_ibfk_1":
return $this->message("DELETE tradlines FROM this owner FIRST");
case "client_monitoring_service_ibfk_2":
return $this->message("Please remove client form the monitoring service first");
case "credit_status_ibfk_1":
return $this->message("Please remove client form the monitoring service first");
case "cart_item_ibfk_1":
return $this->message("Clear all shopping carts with this tradeline");
default:
return $this->message($e->getMessage());
}
case "1062":
$duplicate_column = $this->getStringAfter($e, 'for key');
return $this->fieldMessage($duplicate_column, "Invalid" . ' ' . strtoupper($duplicate_column));
case "1054":
return $this->message($e->getMessage());
default:
return $this->message($e->getMessage());
}
}
开发者ID:manis6062,项目名称:credituniversity,代码行数:32,代码来源:AdminController.php
示例12: show_error
/**
* 一般错误页面
*
* @param string the heading
* @param string the message
* @param string the template name
* @param int the status code
* @return string
*/
public static function show_error($message, $status_code = 500, $template = 'general', $heading = 'An Error Was Encountered')
{
set_status_header($status_code);
$message = '<p>' . implode('</p><p>', !is_array($message) ? array($message) : $message) . '</p>';
include FW_PATH . 'errors/' . $template . '.php';
die;
}
开发者ID:hubs,项目名称:yuncms,代码行数:16,代码来源:Error.php
示例13: do_error
function do_error($code, $str)
{
error_log($code . ' ' . $str . ' ' . filter_input(INPUT_SERVER, 'REMOTE_ADDR'));
set_status_header($code);
echo $str;
exit;
}
开发者ID:nikrou,项目名称:piwigo-privacy,代码行数:7,代码来源:auth.php
示例14: show_404
function show_404($page = '', $log_error = TRUE)
{
set_status_header('404');
$this->CI =& get_instance();
$error_uri = $this->CI->router->routes['404_override'];
// By default we log this, but allow a dev to skip it
if ($log_error) {
log_message('error', '404 Page Not Found --> ' . $page);
}
// get the CI base URL
$this->config =& get_config();
$base_url = $this->config['base_url'];
// Get current session
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
// Close current session
session_write_close();
// create new cURL resource
$ch = curl_init();
// set URL and other options
curl_setopt($ch, CURLOPT_URL, $base_url . $error_uri);
curl_setopt($ch, CURLOPT_HEADER, 0);
// note: the 404 header is already set in the error controller
curl_setopt($ch, CURLOPT_COOKIE, $strCookie);
// pass URL to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
}
开发者ID:mamtasingh87,项目名称:bytecode,代码行数:28,代码来源:MY_Exceptions.php
示例15: __construct
public function __construct()
{
parent::__construct();
if (!$this->session->has_userdata('username')) {
set_status_header(401);
echo "Error 401: Unauthorized";
}
}
开发者ID:mahdidham,项目名称:rsbpjs,代码行数:8,代码来源:Ajax.php
示例16: show_404
/**
* 404 Not Found Handler
*
* @param string $page The slug of the Page Missing page. Since this is handled by the Page module it is immutable
* @param bool $log_error All 404s are logged by the Page module as the page segments are not available here
*/
function show_404($page = 404, $log_error = TRUE)
{
// Set the HTTP Status header
set_status_header(404);
// clear out assets set by the first module before the 404 handler takes over
Asset::reset();
Modules::run('pages/_remap', '404');
}
开发者ID:namdum,项目名称:pyrocms,代码行数:14,代码来源:MY_Exceptions.php
示例17: show_json_error
function show_json_error($message, $status_code = 500, $status_message = '')
{
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
set_status_header($status_code, $status_message);
echo json_encode($message);
exit;
}
开发者ID:manis6062,项目名称:credituniversity,代码行数:8,代码来源:json_helper.php
示例18: _remap
public function _remap($method = '', $args = array())
{
$userID = $this->session->userdata('user_id');
if (empty($userID)) {
set_status_header(403);
} else {
call_user_func_array([$this, $method], $args);
}
}
开发者ID:borka-s,项目名称:e-learning,代码行数:9,代码来源:Comments.php
示例19: show404
function show404()
{
set_status_header('404');
$inner = array();
$page = array();
$page['title'] = 'Page Not Found';
$page['content'] = $this->CI->load->view('pages/404', $inner, true);
$this->CI->load->view('shell', $page);
}
开发者ID:ravinderphp,项目名称:landlordv2,代码行数:9,代码来源:Utility.php
示例20: delete_reservation
public function delete_reservation($reservation_id)
{
// if($this->input->get() || $this->input->is_ajax_request()){
$results = $this->sched->cancel_existing_reservation($reservation_id);
set_status_header($results['status_code']);
$success = $results['status_code'] < 300 ? true : false;
transmit_array_with_json_header($results, $results['message'], $success, $results['status_code']);
// }
}
开发者ID:kauberry,项目名称:responsive_design_testing,代码行数:9,代码来源:scheduling_2.php
注:本文中的set_status_header函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论