forked from wwng2333/server_limited
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
52 lines (49 loc) · 1.68 KB
/
api.php
File metadata and controls
52 lines (49 loc) · 1.68 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
<?php
function curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$r = curl_exec($ch);
$curl_errno = curl_errno($ch);
curl_close($ch);
if($curl_errno > 0) {
return false;
} else {
return $r;
}
}
$url = 'https://console.online.net/en/order/server_limited';
$html = explode("\n", curl($url));
for($i=0;$i<count($html);$i++) {
$linenow = $html[$i];
if(strstr($linenow, '<span class="highlight">')) {
$lineneed = $linenow;
break;
}
}
$offer = explode('<table class="server-availability col-striped"><colgroup><col class="coloffer" /><col class="colcpu" /><col class="colram" /><col class="colhdd" /><col class="colconnect" /><col class="colavailability" /><col class="colprice" /><col class="colaction" /></colgroup><thead>', $lineneed);
for($i=0;$i<count($offer);$i++) {
$offer[$i] = explode('</td></tr><tr ><td>', $offer[$i]);
for($x=0;$x<count($offer[$i]);$x++) {
if(strstr($offer[$i][$x], '</thead><tbody>')) {
$temp = explode('</thead><tbody><tr ><td>', $offer[$i][$x]);
$offer[$i][$x] = $temp[1];
} elseif(strstr($offer[$i][$x], '</td><td></td></tr></tbody></table>')) {
$temp = explode('</td><td></td></tr></tbody></table>', $offer[$i][$x]);
$offer[$i][$x] = $temp[0];
}
}
}
$result = array();
for($i=0;$i<count($offer);$i++) {
for($x=0;$x<count($offer[$i]);$x++) {
$offer[$i][$x] = explode('</td><td>', $offer[$i][$x]);
for($t=0;$t<count($offer[$i][$x]);$t++) {
$offer[$i][$x][$t] = trim($offer[$i][$x][$t]);
if($offer[$i][$x][$t] == '') unset($offer[$i][$x][$t]);
}
}
if($i>0) $result = array_merge($result, $offer[$i]);
}
echo json_encode($result)."\n";