コード例 #1
1
 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);
         }
     }
 }
コード例 #2
1
ファイル: MY_Exceptions.php プロジェクト: skubbs-chuck/emr
 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;
 }
コード例 #3
0
ファイル: MY_Exceptions.php プロジェクト: biladina/pusakacms
 /**
  * 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;
 }
コード例 #4
0
 /**
  * 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}";
         }
     }
 }
コード例 #5
0
 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();
 }
コード例 #6
0
ファイル: MY_Exceptions.php プロジェクト: JamieLomas/pyrocms
	/**
	 * 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);
	}
コード例 #7
0
 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;
     }
 }
コード例 #8
0
ファイル: post.php プロジェクト: navruzm/navruz.net
 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();
 }
コード例 #9
0
 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];
 }
コード例 #10
0
ファイル: trackmanager.php プロジェクト: bennetimo/comp3013
 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);
     }
 }
コード例 #11
0
 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());
     }
 }
コード例 #12
0
ファイル: Error.php プロジェクト: hubs/yuncms
 /**
  * 一般错误页面
  *
  * @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;
 }
コード例 #13
0
ファイル: auth.php プロジェクト: nikrou/piwigo-privacy
function do_error($code, $str)
{
    error_log($code . ' ' . $str . ' ' . filter_input(INPUT_SERVER, 'REMOTE_ADDR'));
    set_status_header($code);
    echo $str;
    exit;
}
コード例 #14
0
 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);
 }
コード例 #15
0
ファイル: Ajax.php プロジェクト: mahdidham/rsbpjs
 public function __construct()
 {
     parent::__construct();
     if (!$this->session->has_userdata('username')) {
         set_status_header(401);
         echo "Error 401: Unauthorized";
     }
 }
コード例 #16
0
ファイル: MY_Exceptions.php プロジェクト: namdum/pyrocms
 /**
  * 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');
 }
コード例 #17
0
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;
}
コード例 #18
0
ファイル: Comments.php プロジェクト: borka-s/e-learning
 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);
     }
 }
コード例 #19
0
ファイル: Utility.php プロジェクト: ravinderphp/landlordv2
 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);
 }
コード例 #20
0
 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']);
     // }
 }
コード例 #21
0
ファイル: http.php プロジェクト: ravinderphp/skfood
 function show404($params = array())
 {
     $CI =& get_instance();
     $CI->html->addMeta($CI->load->view("themes/" . THEME . "/meta/404", array(), true));
     set_status_header('404');
     $shell = array();
     $shell['contents'] = $CI->load->view("themes/" . THEME . "/404", array(), true);
     $CI->load->view("themes/" . THEME . "/templates/default", $shell);
 }
コード例 #22
0
ファイル: MY_Exceptions.php プロジェクト: jeffdrumgod/hapia
 /**
  * Native PHP error handler
  *
  * @access  private
  * @param   string  the error severity
  * @param   string  the error string
  * @param   string  the error filepath
  * @param   string  the error line number
  * @return  string
  */
 function show_php_error($severity, $message, $filepath, $line)
 {
     header('Cache-Control: no-cache, must-revalidate');
     header('Content-type: application/json');
     // header('HTTP/1.1 500 Internal Server Error');
     set_status_header(500);
     echo json_encode(array('status' => FALSE, 'error' => 'Internal Server Error. message - ' . $message . ' - filepath: ' . $filepath . ' - line: ' . $line));
     exit;
 }
コード例 #23
0
 function show_error($message, $status)
 {
     if (!is_cli_request()) {
         set_status_header($status);
         header('Content-type: application/json');
     }
     $data = array('message' => $message);
     echo json_encode($data);
     exit;
 }
コード例 #24
0
 /**
  * Helper function to send headers to the browser for a certain status code
  * and content type.
  *
  * @param int     $status_code (optional) HTTP status code. Default is 200.
  */
 public function send_headers($status_code = 200)
 {
     set_status_header($status_code);
     // NOTE: there's a bug in CI's set_header() so use the PHP one instead!
     header('Content-type: ' . $this->format, true);
     // Absolutely NO caching of views!
     header("Cache-Control: no-store");
     // allow external requests
     header('Access-Control-Allow-Origin: *');
 }
コード例 #25
0
function show_http_error($heading, $message, $template = 'ob_general', $status_code = 500)
{
    set_status_header($status_code);
    $message = implode('<br />', !is_array($message) ? array($message) : $message);
    ob_start();
    include SYS . 'error' . DS . $template . PHP_EXT;
    $buffer = ob_get_contents();
    ob_end_clean();
    return $buffer;
}
コード例 #26
0
ファイル: Common.php プロジェクト: ricpelo/codeigniter-heroku
/**
 * Class registry
 * 
 * @staticvar array $_classes
 * @param string $class
 * @param string $directory
 * @param array $param
 * @param bool $reset
 * @param object $obj
 * @return object
 */
function &load_class($class, $directory = 'libraries', $param = NULL, $reset = FALSE, $obj = NULL)
{
    static $_classes = array();
    if ($reset) {
        // If Utf8 is instantiated twice,
        // error "Constant UTF8_ENABLED already defined" occurs
        $UTF8 = $_classes['Utf8'];
        $_classes = array('Utf8' => $UTF8);
        $obj = new stdClass();
        return $obj;
    }
    // Register object directly
    if ($obj) {
        is_loaded($class);
        $_classes[$class] = $obj;
        return $_classes[$class];
    }
    // Does the class exist? If so, we're done...
    if (isset($_classes[$class])) {
        return $_classes[$class];
    }
    $name = FALSE;
    // Look for the class first in the local application/libraries folder
    // then in the native system/libraries folder
    foreach (array(APPPATH, BASEPATH) as $path) {
        if (file_exists($path . $directory . '/' . $class . '.php')) {
            $name = 'CI_' . $class;
            if (class_exists($name, FALSE) === FALSE) {
                require_once $path . $directory . '/' . $class . '.php';
            }
            break;
        }
    }
    // Is the request a class extension? If so we load it too
    if (file_exists(APPPATH . $directory . '/' . config_item('subclass_prefix') . $class . '.php')) {
        $name = config_item('subclass_prefix') . $class;
        if (class_exists($name, FALSE) === FALSE) {
            require_once APPPATH . $directory . '/' . $name . '.php';
        }
    }
    // Did we find the class?
    if ($name === FALSE) {
        // Note: We use exit() rather then show_error() in order to avoid a
        // self-referencing loop with the Exceptions class
        set_status_header(503);
        // changed by ci-phpunit-test
        $msg = 'Unable to locate the specified class: ' . $class . '.php';
        //		exit(5); // EXIT_UNK_CLASS
        throw new CIPHPUnitTestExitException($msg);
    }
    // Keep track of what we just loaded
    is_loaded($class);
    $_classes[$class] = isset($param) ? new $name($param) : new $name();
    return $_classes[$class];
}
コード例 #27
0
 protected function _check_access()
 {
     if (!$this->session->userdata('user_logged')) {
         // Code for the real authentication system.
         //if (!$this->current_user->is_logged_in()) {
         $this->session->set_flashdata('error_message', $this->lang->line('ui_session_expired'));
         set_status_header(403);
         exit;
     }
     return true;
 }
コード例 #28
0
 /**
  * Page Not Found Page for this controller.
  */
 public function not_found()
 {
     set_status_header(404);
     $data = $this->data;
     $data['title'] = "Page Not Found";
     $data['extraJS'] = '<style>.content {background-image:url(/images/404.jpg);}</style>';
     $this->load->view('templates/header', $data);
     $this->load->view('templates/menu', $data);
     $this->load->view('templates/menu_mall', $data);
     $this->load->view('errors/not_found', $data);
 }
コード例 #29
0
ファイル: User.php プロジェクト: borka-s/e-learning
 public function _remap($method = '', $args = array())
 {
     $userID = $this->session->userdata('user_id');
     if ($method === 'login') {
         call_user_func_array([$this, $method], $args);
     } elseif (empty($userID)) {
         // redirect(base_url(),'refresh');
         set_status_header(403);
     } else {
         call_user_func_array([$this, $method], $args);
     }
 }
コード例 #30
0
 function show_error($title, $url, $template = 'error_general', $status_code = 500)
 {
     set_status_header($status_code);
     if (ob_get_level() > $this->ob_level + 1) {
         ob_end_flush();
     }
     ob_start();
     include APPPATH . '/views/errors/cli/' . $template . '.php';
     $buffer = ob_get_contents();
     ob_end_clean();
     return $buffer;
 }