-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
53 lines (49 loc) · 1.55 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/** Include the needed files.*/
include "autoload.php";
/** @var $result
* Define errors in here
*/
$result = (new Result)->setErrorsList([
0 => "Please control inputs.",
1 => "The User is dead."
]);
/** Routes */
$route = (new Route(__DIR__ . "/app/functions"));
/// Check the usual input field e.g. Fingerprint.
$route = $route->checkAuth('ValidateInputs', VALIDATOR_PATTERN['USUAL']);
/// Create Action Path You can use CheckAuth after another CheckAuth and if the all checkAuth return true then we get to Route to load page;
$route->Route("/login", function () {
global $route;
$route->checkAuth('ValidateInputs', VALIDATOR_PATTERN['LOGIN']);
return $route->loadFunction("LoginFunction");
});
$route->Route("/signup", function () {
global $route;
$route->checkAuth('ValidateInputs', VALIDATOR_PATTERN['SIGNUP']);
return $route->loadFunction("LoginFunction");
});
/// Display The results from function in the way you like.
$route->show(function ($data) {
if (isset($data['html'])) {
echo $data['html'];
} else {
header("Content-type: application/json");
/// Default Parameters.
$data['request']['time'] = time();
print json_encode($data, 128);
}
});
/** Routes */
/// Validate the inputs and use theme as safe value :)
function ValidateInputs($pattern)
{
global $result;
/// Validate inputs
$validator = new InputValidator($pattern, $_POST);
if ($validator->validate()) {
return true;
} else {
return $result->error(-1000, $validator->showError());
}
}