This repository has been archived by the owner on Jan 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
webview.php
66 lines (53 loc) · 1.62 KB
/
webview.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
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/*
* SIF Private server
* The webview.
*/
/** @@ Configuration @@ **/
// Requires "Authorize" header? Comment to disable
//define("REQUIRE_AUTHORIZE", true);
/** !! Configuration !! **/ /* End configuration */
define("WEBVIEW", true);
require('main.php'); // Requiring it in WebView won't load it's main function.
$DATABASE = require('database_wrapper.php');
ob_start('ob_gzhandler');
register_shutdown_function('ob_end_flush');
function main()
{
global $DATABASE;
global $REQUEST_HEADERS;
$DATABASE->initialize_environment();
$mod_act = explode('/', substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?') ?: strlen($_SERVER['REQUEST_URI'])));
$MODULE = isset($mod_act[2]) ? $mod_act[2] : exit;
$ACTION = isset($mod_act[3]) ? $mod_act[3] : exit;
// It's module/action responsibility to check if it's necessary to cache the request.
include("webview/$MODULE/$ACTION.php");
exit;
}
if(defined("REQUIRE_AUTHORIZE"))
{
if(isset($REQUEST_HEADERS["authorize"]) &&
isset($REQUEST_HEADERS["user-id"]) &&
isset($REQUEST_HEADERS["application-id"]) && strcmp($REQUEST_HEADERS["application-id"], APPLICATION_ID) == 0 &&
isset($REQUEST_HEADERS["region"]) && $REQUEST_HEADERS["region"] == REGION
)
{
$auth_data = authorize_function($REQUEST_HEADERS["authorize"]);
if($auth_data)
{
if(isset($auth_data["nonce"]) && strcmp($auth_data["nonce"], "WV0") == 0 &&
isset($auth_data["token"]) && token_exist(strval($auth_data["token"]))
)
main();
else
exit;
}
else
exit;
}
else
exit;
}
else
main();
?>