-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquery.php
62 lines (50 loc) · 1.11 KB
/
query.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
<?php
ob_start();
error_reporting(E_ALL & ~E_NOTICE);
require_once(__DIR__.'\vendor\autoload.php');
require_once(__DIR__.'\config.php');
class serverQuery
{
private $_address;
private $_key;
public function __construct()
{
global $config;
$this->_address = $_GET['address'];
if(empty($this->_address))
{
$this->error = 1;
$this->error_message = "Please specify a server address for the query!";
}
if($config['enable_key'] == true)
{
$this->_key = $_GET['key'];
if(!empty($this->_key))
{
if($this->_key != $config['app_key'])
{
$this->error = 1;
$this->error_message = "The specified key is invalid!";
}
}
else
{
$this->error = 1;
$this->error_message = "Please specify the app key!";
}
}
if($this->error != 1)
{
$this->api = file_get_contents($config['query_api'].$this->_address);
echo $this->api;
}
else
{
echo json_encode([
'error' => $this->error_message
]);
}
}
}
$query = new serverQuery;
ob_end_flush();