-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
80 lines (53 loc) · 1.77 KB
/
api.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
67
68
69
70
71
72
73
74
<?php
/**
* Created by PhpStorm.
* User: machine
* Date: 04/04/2018
* Time: 06:46
*
*/
define('IN_SPYOGAME', true);
date_default_timezone_set(date_default_timezone_get());
//positionnement au niveau de lindex opour les include (cf xtense implementation)
if (preg_match('#mod#', getcwd())) chdir('../../');
$_SERVER['SCRIPT_FILENAME'] = str_replace(basename(__FILE__), 'index.php', preg_replace('#\/mod\/(.*)\/#', '/', $_SERVER['SCRIPT_FILENAME']));
include("common.php");
//todo
//verifier serveur actif
//verifier mod actif
// mise en place de droit/user ???
//include
require_once("mod/api/core/response.php");
require_once("mod/api/core/webApi.php");
require_once("mod/api/model/User_Model.php");
require_once("mod/api/model/Tokens_Model.php");
require_once("mod/api/model/Config_Model.php");
require_once("mod/api/model/Spy_Model.php");
require_once("mod/api/model/Universe_Model.php");
// attention en version 3.3.2 n 'existe pas encore
if (file_exists("includes/token.php")) {
require_once("includes/token.php");
} else {
require_once("mod/api/core/token.php");
}
//si pas de demande : heure
$api = new webApi();
//pas de webservice si pas de ssl
if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on" )
{
$api->nosecure();
}
if (isset($pub_login) && isset($pub_password)) {
$api->authenticate_by_user($pub_login, $pub_password);
} elseif (isset($pub_token) && isset($pub_data)) {
if ($api->authenticate_by_token($pub_token) === true) {
//var_dump(json_decode($pub_data));die();
$api->api_treat_command($pub_data);
}
}
//si pas de demande : heure
$api = new webApi();
$api->customData(json_encode(array('status' => 'ok', 'time' => time())));
//die();
//$web_api = new webApi();
//$web_api->authenticate_by_user($pub_user,$pub_pass);