-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
68 lines (59 loc) · 2.59 KB
/
index.php
File metadata and controls
68 lines (59 loc) · 2.59 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
session_start();
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
use Steampixel\Route;
use Firebase\JWT\JWT;
$bitrixCodes = json_decode(file_get_contents("codes.json"), 1);
require_once('./vendor/autoload.php');
require_once './src/Steampixel/Route.php';
// require_once './Classes/DBClass.php';
require_once './Controllers/Auth.php';
require_once './Controllers/Bitrix.php';
require_once './Controllers/User.php';
$globalUri = "";
$_SESSION["currency"] = (isset($_SESSION["currency"])) ? $_SESSION["currency"] : "AMD";
$currency = $_SESSION["currency"];
Route::add('/eot_api', function(){
$auth = new Auth("api.eot.global", "bGS6lzFqvvSQASdLbOxatm7/Vk7mLQyzqaS34Q4oR1ew=");
$auth->validate();
}, 'post');
Route::add('/eot_api/register', function(){
global $bitrixCodes;
$credentials = json_decode(file_get_contents("php://input"), 1);
if(
!isset($credentials["username"]) || !isset($credentials["password"]) ||
$credentials["username"] == "" || $credentials["password"] == ""
){
header('HTTP/1.0 400 Bad Request');
header('Content-type: application:json');
echo json_encode(["message" => "invalid request body"]);
}else{
// $credentials["username"] = mysql_real_escape_string($credentials["username"]);
// $credentials["password"] = mysql_real_escape_string($credentials["password"]);
$login = new User("api.eot.global", "bGS6lzFqvvSQASdLbOxatm7/Vk7mLQyzqaS34Q4oR1ew=", "https://api.eot.global/rest/1/786wf8ydq2yundnt/");
$login->register($credentials["username"], $credentials["password"]);
}
}, 'post');
Route::add('/eot_api/login', function(){
global $bitrixCodes;
$credentials = json_decode(file_get_contents("php://input"), 1);
$login = new User("api.eot.global", "bGS6lzFqvvSQASdLbOxatm7/Vk7mLQyzqaS34Q4oR1ew=", "https://api.eot.global/rest/1/786wf8ydq2yundnt/");
$login->login($credentials["username"], $credentials["password"]);
// $bitrix = new Bitrix("https://api.eot.global/rest/1/786wf8ydq2yundnt/");
}, 'post');
Route::pathNotFound(function($path) {
header('HTTP/1.0 404 Not Found');
include("404.php");
});
// Add a 405 method not allowed route
Route::methodNotAllowed(function($path, $method) {
// Do not forget to send a status header back to the client
// The router will not send any headers by default
// So you will have the full flexibility to handle this case
header('HTTP/1.0 405 Method Not Allowed');
echo 'Error 405 :-(<br>';
echo 'The request method "'.$method.'" is not allowed on this path!';
});
Route::run('/');