Guest User

Untitled

a guest
Jun 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.11 KB | None | 0 0
  1. class Content
  2. {
  3.  
  4.     private $require;
  5.  
  6.     public function __construct($action = "system", $argument = "default") {
  7.         if(method_exists($this, $action ))
  8.             $this->$action($argument);
  9.         else
  10.             echo "Bad function call";
  11.  
  12.         if($this->require != null) {
  13.             require_once("class.forms.php");
  14.             $forms = new forms();
  15.             require_once($this->require);
  16.         }else{
  17.             $this->error(404);
  18.         }
  19.  
  20.     }
  21.  
  22.     private function page($page) {
  23.  
  24.         $this->require = is_numeric($page) ? "views/system/articles.php" : (file_exists("views/user/".$page.".html") ? "views/user/".$page.".html" : $this->error(404));
  25.  
  26.     }
  27.  
  28.     private function system($system) {
  29.  
  30.         $this->require = file_exists("views/system/".$system.".php") ? "views/system/".$system.".php" : $this->error(404);
  31.  
  32.     }
  33.  
  34.     private function admin($admin) {
  35.  
  36.         $this->require = (file_exists("views/admin/".$admin.".php") && $_SESSION['user']['level'] == '3') ? "views/admin/".$admin.".php" : $this->error(404);
  37.  
  38.     }
  39.  
  40.     private function action($argument) {
  41.  
  42.  
  43.         $argument = array(
  44.             registered      => 'Successfully Registered',
  45.             added           => 'Successfully Added Article',
  46.             edited          => 'Successfully Edited Article',            
  47.             success         => 'Successfully Logged In',
  48.             login-failure   => 'User Cancelled Login',
  49.         );
  50.  
  51.         $status     = $argument[$argument][0];
  52.         $message    = $argument[$argument][1];
  53.  
  54.         if ($status == false)
  55.             $message = 'Please supply a valid status code.';
  56.  
  57.         $Message = new Page_Content();
  58.         $Message->message($message);
  59.  
  60.         header("refresh:2;url=".URLADDR);
  61.  
  62.         /*
  63.         } elseif ( $action == 'logout' ) {
  64.  
  65.             logout();
  66.  
  67.         }*/
  68.  
  69.  
  70.     }
  71.  
  72.     private function error($error) {
  73.  
  74.         $error = array(
  75.             403 => array('403 Forbidden', 'The server has refused to fulfill your request.'),
  76.             404 => array('404 Not Found', 'The document/file requested was not found on this server.'),
  77.             405 => array('405 Method Not Allowed', 'The method specified in the Request-Line is not allowed for the specified resource.'),
  78.             408 => array('408 Request Timeout', 'Your browser failed to send a request in the time allowed by the server.'),
  79.             500 => array('500 Internal Server Error', 'The request was unsuccessful due to an unexpected condition encountered by the server.'),
  80.             502 => array('502 Bad Gateway', 'The server received an invalid response from the upstream server while trying to fulfill the request.'),
  81.             504 => array('504 Gateway Timeout', 'The upstream server failed to send a request in the time allowed by the server.'),
  82.         );
  83.  
  84.         $title      = $error[$error][0];
  85.         $message    = $error[$error][1];
  86.  
  87.  
  88.         if ($title == false || strlen($error) != 3) {
  89.             $message = 'Please supply a valid status code.';
  90.         }
  91.  
  92.         echo "<h1>".$title."</h1> <p>".$message."</p>";
  93.  
  94.     }
  95.  
  96. }
Add Comment
Please, Sign In to add comment