forked from acelan/pool_monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpool.php
More file actions
79 lines (67 loc) · 1.76 KB
/
pool.php
File metadata and controls
79 lines (67 loc) · 1.76 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
69
70
71
72
73
74
75
76
77
78
79
<?php
session_start();
// refresh data after one minute
if(isset($_SESSION[$_GET["site"]."timestamp"]) && ((time()-$_SESSION[$_GET["site"]."timestamp"]) < 60))
{
echo $_SESSION[$_GET["site"]];
exit(0);
}
$json = file_get_contents('./sites.js');
$json = str_replace('var APIS = ','' ,$json);
$sites = json_decode($json);
$datatype = 0;
$apiurl = "";
foreach( $sites as $site)
{
if($site->site == $_GET["site"])
{
$apiurl = $site->apiurl.$_GET["key"];
$datatype = $site->datatype;
break;
}
}
$data = get_data($apiurl, $datatype);
$_SESSION[$_GET["site"]] = $data;
$_SESSION[$_GET["site"]."timestamp"] = time();
echo $data;
function get_data($apiurl, $datatype)
{
$ch = null;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$res = "";
if($datatype == "1")
{
curl_setopt($ch, CURLOPT_URL, $apiurl);
$res = curl_exec($ch);
}
else if($datatype == "2")
{
}
else if($datatype == "3")
{
}
else if($datatype == "4")
{
$data = array();
$url = $apiurl."&action=getuserstatus";
curl_setopt($ch, CURLOPT_URL, $url);
$res = curl_exec($ch);
$data = json_decode($res);
$url = $apiurl."&action=getuserbalance";
curl_setopt($ch, CURLOPT_URL, $url);
$res = curl_exec($ch);
$data = (object)array_merge((array)$data, (array)json_decode($res));
$url = $apiurl."&action=getuserworkers";
curl_setopt($ch, CURLOPT_URL, $url);
$res = curl_exec($ch);
$data = (object)array_merge((array)$data, (array)json_decode($res));
$res = json_encode($data);
}
return $res;
}
?>