Newer
Older
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
<?php
function getDirFile($dirFile) {
switch ($dirFile['srcType']) {
case 'url':
$curl = curl_init($dirFile['src']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($curl);
curl_close($curl);
break;
case 'path':
if (!file_exists($dirFile['src'])) {
return false;
}
$content = file_get_contents($dirFile['src']);
break;
default:
return false;
break;
}
// $content = preg_replace( "/\r|\n/", "", $content );
$content = json_decode($content, true);
return $content;
}
function getHostInformation($librehostJsonUrl) {
$hostInformaton = getHostJson($librehostJsonUrl);
return $hostInformaton;
}
function getHostJson($librehostJsonUrl) {
$curl = curl_init($librehostJsonUrl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
$response = json_decode($response, true);
return $response;
}