-
Notifications
You must be signed in to change notification settings - Fork 5
/
APIShift.php
39 lines (34 loc) · 1.29 KB
/
APIShift.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
<?php
/**
* APIShift Engine v1.0.0
* (c) 2020-present Sapir Shemer, DevShift (devshift.biz)
* Released under the MIT License with the additions present in the LICENSE.md
* file in the root folder of the APIShift Engine original release source-code
* @author Sapir Shemer
*/
/**
* If the request mode wasn't set beforehand then assume we work using PHP mode
* true = http api request
* false = hardcoded
*/
if(!isset($REQUEST_MODE)) $GLOBALS['REQUEST_MODE'] = false;
// Step 1: Define the autoloader to load the needed functions without hardcoding
require_once "core/Autoloader.php";
// Step 2: Define main dependencies for the API to function
use APIShift\Core\CacheManager;
use APIShift\Core\DatabaseManager;
use APIShift\Core\SessionState;
use APIShift\Core\Configurations;
// Step 3: Redirect to HTTPS connection only
if (Configurations::USE_HTTPS && (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off")) {
$location = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $location);
exit;
}
// Step 4: Start main connection & load default cache & session if not present
if(Configurations::INSTALLED) {
DatabaseManager::loadDefaults();
CacheManager::loadDefaults();
SessionState::loadDefaults();
}