Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Content
- {
- private $require;
- public function __construct($action = "system", $argument = "default") {
- if(method_exists($this, $action ))
- $this->$action($argument);
- else
- echo "Bad function call";
- if($this->require != null) {
- require_once("class.forms.php");
- $forms = new forms();
- require_once($this->require);
- }else{
- $this->error(404);
- }
- }
- private function page($page) {
- $this->require = is_numeric($page) ? "views/system/articles.php" : (file_exists("views/user/".$page.".html") ? "views/user/".$page.".html" : $this->error(404));
- }
- private function system($system) {
- $this->require = file_exists("views/system/".$system.".php") ? "views/system/".$system.".php" : $this->error(404);
- }
- private function admin($admin) {
- $this->require = (file_exists("views/admin/".$admin.".php") && $_SESSION['user']['level'] == '3') ? "views/admin/".$admin.".php" : $this->error(404);
- }
- private function action($argument) {
- $argument = array(
- registered => 'Successfully Registered',
- added => 'Successfully Added Article',
- edited => 'Successfully Edited Article',
- success => 'Successfully Logged In',
- login-failure => 'User Cancelled Login',
- );
- $status = $argument[$argument][0];
- $message = $argument[$argument][1];
- if ($status == false)
- $message = 'Please supply a valid status code.';
- $Message = new Page_Content();
- $Message->message($message);
- header("refresh:2;url=".URLADDR);
- /*
- } elseif ( $action == 'logout' ) {
- logout();
- }*/
- }
- private function error($error) {
- $error = array(
- 403 => array('403 Forbidden', 'The server has refused to fulfill your request.'),
- 404 => array('404 Not Found', 'The document/file requested was not found on this server.'),
- 405 => array('405 Method Not Allowed', 'The method specified in the Request-Line is not allowed for the specified resource.'),
- 408 => array('408 Request Timeout', 'Your browser failed to send a request in the time allowed by the server.'),
- 500 => array('500 Internal Server Error', 'The request was unsuccessful due to an unexpected condition encountered by the server.'),
- 502 => array('502 Bad Gateway', 'The server received an invalid response from the upstream server while trying to fulfill the request.'),
- 504 => array('504 Gateway Timeout', 'The upstream server failed to send a request in the time allowed by the server.'),
- );
- $title = $error[$error][0];
- $message = $error[$error][1];
- if ($title == false || strlen($error) != 3) {
- $message = 'Please supply a valid status code.';
- }
- echo "<h1>".$title."</h1> <p>".$message."</p>";
- }
- }
Add Comment
Please, Sign In to add comment