implements a renders oputput cos we will use same oouput many times
* fix http status code not property set in guachi, puff * index default page will only show welcome * not found page will show http status code and also link to repot issues * render output will show and set as must be the http status code * render output will show a minimal description message
This commit is contained in:
parent
ee82e6720d
commit
7395532339
@ -46,4 +46,49 @@ abstract class model {
|
||||
|
||||
return new $model_class($this->db, $this->auth, $this->router, $this->view);
|
||||
}
|
||||
|
||||
/* show ap[i output in json format
|
||||
*
|
||||
* INPUT: array
|
||||
* OUTPUT: string
|
||||
* ERROR: null
|
||||
*/
|
||||
protected function renderOutput($variables, $jsonout = false) {
|
||||
|
||||
$contentt = 'Content-Type: text/plain';
|
||||
$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
|
||||
$httpcode = '412';
|
||||
$sucess = false;
|
||||
$message = 'No message was specified, the server could not process the content or the page does not exist';
|
||||
$page = 1;
|
||||
$pages = 1;
|
||||
$per_page = 1;
|
||||
$data = array($message);
|
||||
|
||||
if(is_array($variables) ) {
|
||||
foreach($variables as $key => $value) {
|
||||
$$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$GLOBALS['http_response_code'] = $httpcode;
|
||||
if( !is_null($jsonout) and !empty($jsonout)) {
|
||||
$contentt = 'Content-Type: application/json; charset=utf-8';
|
||||
header($contentt);
|
||||
$jsondata = array(
|
||||
'sucess' => $sucess,
|
||||
'message' => $message,
|
||||
'page' => $page,
|
||||
'pages' => $pages,
|
||||
'per_page' => $per_page,
|
||||
'data'=> $data
|
||||
);
|
||||
print(json_encode($jsondata));
|
||||
}
|
||||
else {
|
||||
$contentt = 'Content-Type: text/html; charset=UTF-8';
|
||||
header($contentt);
|
||||
include(DIR_VIEWS."notfoundview.php");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ class index_model extends model {
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$httpcode = 200;
|
||||
include(DIR_VIEWS."index.php");
|
||||
}
|
||||
}
|
||||
|
@ -12,14 +12,9 @@ Copyright (c) 2018 Díaz Víctor aka (Máster Vitronic)
|
||||
|
||||
class notFound_model extends model {
|
||||
|
||||
public function show() {
|
||||
$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
|
||||
header($protocol . ' 404');
|
||||
$GLOBALS['http_response_code'] = '404';
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
print(json_encode([
|
||||
'msg'=>'Not Found'
|
||||
]));
|
||||
public function show($errormessage = 'The page could not be found or was moved, or your request is not valid, please consult upstream') {
|
||||
$variables = array('message'=>$errormessage,'httpcode'=>'404');
|
||||
$this->renderOutput($variables);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<body>
|
||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="https://bulma.io">
|
||||
<a class="navbar-item">
|
||||
</a>
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
|
||||
<span aria-hidden="true"></span>
|
||||
@ -28,14 +28,11 @@
|
||||
<a href="about" class="navbar-item">
|
||||
About
|
||||
</a>
|
||||
<a href="api/use" class="navbar-item is-selected">
|
||||
<a href="api/api" class="navbar-item is-selected">
|
||||
API
|
||||
</a>
|
||||
<a href="help" class="navbar-item">
|
||||
Help
|
||||
</a>
|
||||
<hr class="navbar-divider">
|
||||
<a href="about" class="navbar-item">
|
||||
<a href="https://codeberg.org/minenux/minenux-skindb-webdb/issues" class="navbar-item">
|
||||
Report an issue
|
||||
</a>
|
||||
</div>
|
||||
@ -65,9 +62,7 @@
|
||||
<main class="contain">
|
||||
<h1 class="title">Skins</h1>
|
||||
<hr>
|
||||
<?php
|
||||
echo 'Currently API database is on manteniance, please report any incident but first try to check if there any previous report at <a href="https://codeberg.org/minenux/minenux-skindb-webdb/issues">https://codeberg.org/minenux/minenux-skindb-webdb/issues</a> with code 412';
|
||||
?>
|
||||
Wellcome!
|
||||
</main>
|
||||
<br>
|
||||
<footer class="footer">
|
||||
|
81
public/views/notfoundview.php
Normal file
81
public/views/notfoundview.php
Normal file
@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>SkinsDB</title>
|
||||
<link rel="icon" href="icon.png" type="image/x-icon">
|
||||
<link rel="stylesheet" href="assets/css/bulma.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item">
|
||||
</a>
|
||||
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
</div>
|
||||
<div id="navbarBasicExample" class="navbar-menu">
|
||||
<div class="navbar-start">
|
||||
<div class="navbar-item has-dropdown is-hoverable">
|
||||
<a href="lists" class="navbar-link">
|
||||
Start
|
||||
</a>
|
||||
<div class="navbar-dropdown">
|
||||
<a href="about" class="navbar-item">
|
||||
About
|
||||
</a>
|
||||
<a href="api/api" class="navbar-item is-selected">
|
||||
API
|
||||
</a>
|
||||
<hr class="navbar-divider">
|
||||
<a href="https://codeberg.org/minenux/minenux-skindb-webdb/issues" class="navbar-item">
|
||||
Report an issue
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="navbar-end">
|
||||
<div class="navbar-item">
|
||||
<a class="field is-grouped">
|
||||
<p class="control is-expanded">
|
||||
<input class="input" type="text" placeholder="type here to Search skin">
|
||||
</p>
|
||||
<p class="control">
|
||||
<button class="button is-info is-selected">
|
||||
Search
|
||||
</button>
|
||||
</p>
|
||||
</a>
|
||||
<a href="about" class="button is-primary">
|
||||
About
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<br>
|
||||
<main class="contain">
|
||||
<h1 class="title">Skins</h1>
|
||||
<hr>
|
||||
<p>
|
||||
<?php
|
||||
if(!isset($message)) $message = "System is currently in manteniance, just wait for a moment..";
|
||||
if(!isset($httpcode)) $httpcode = 412;
|
||||
if(!isset($currentrequest)) $currentrequest = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
||||
echo $message.', please report any incident but first try to check if there any previous report at <a href="https://codeberg.org/minenux/minenux-skindb-webdb/issues">https://codeberg.org/minenux/minenux-skindb-webdb/issues</a> with code '.$httpcode.' and this link: '.$currentrequest;
|
||||
?>
|
||||
</p>
|
||||
</main>
|
||||
<br>
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p><strong>SkinsDdatabase</strong> by MinenuX</p>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user