Guest
Public paste!

Untitled

By: a guest | Mar 18th, 2010 | Syntax: PHP | Size: 1.82 KB | Hits: 69 | Expires: Never
Copy text to clipboard
  1. <?
  2.         //Error Class
  3.         class error_report {
  4.                 //Predefined Variables
  5.                 public $link = 'http://knoxius.com/';
  6.                
  7.                 //Redirect
  8.                 public function redirect($sub) {
  9.                         ob_start();
  10.                         header('Location: '.$link.$sub);
  11.                         ob_end_flush();
  12.                         exit;
  13.                 }
  14.                
  15.                 //Error Codes
  16.                 public $codes_400 = array('400','401','402','403','404','405','406','407','408','409','410','411','412','413','414','415');
  17.                 public $codes_500 = array('500','501','502','503','504','505');
  18.                
  19.                 //Error
  20.                 public function error($code) {
  21.                         $code = intval($code);
  22.                        
  23.                         if(empty($code)) {
  24.                                 $this->redirect('error/404');
  25.                         } else if(!in_array($code,$this->codes_400) && !in_array($code,$this->codes_500)) {
  26.                                 $this->redirect('error/404');
  27.                         } else {
  28.                                 return true;
  29.                         }
  30.                 }
  31.                
  32.                 //Error Descriptions
  33.                 public function return_desc($code) {
  34.                         $error_desc = array();
  35.                         $error_desc[400] = 'Bad Request';
  36.                         $error_desc[401] = 'Unauthorized';
  37.                         $error_desc[402] = 'Payment Required';
  38.                         $error_desc[403] = 'Forbidden';
  39.                         $error_desc[404] = 'Not Found';
  40.                         $error_desc[405] = 'Method Not Allowed';
  41.                         $error_desc[406] = 'Not Acceptable';
  42.                         $error_desc[407] = 'Proxy Authentication Required';
  43.                         $error_desc[408] = 'Request Timeout';
  44.                         $error_desc[409] = 'Conflict';
  45.                         $error_desc[410] = 'Gone';
  46.                         $error_desc[411] = 'Length Required';
  47.                         $error_desc[412] = 'Precondition Failed';
  48.                         $error_desc[413] = 'Request Entity Too Large';
  49.                         $error_desc[414] = 'Request-URI Too Long';
  50.                         $error_desc[415] = 'Unsupported Media Type';
  51.                         $error_desc[500] = 'Internal Server Error';
  52.                         $error_desc[501] = 'Not Implemented';
  53.                         $error_desc[502] = 'Bad Gateway';
  54.                         $error_desc[503] = 'Service Unavailable';
  55.                         $error_desc[504] = 'Gateway Timeout';
  56.                         $error_desc[505] = 'HTTP Version Not Supported';
  57.                        
  58.                         return $error_desc[$code];
  59.                 }
  60.         }
  61. ?>