-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.inc.php
52 lines (40 loc) · 1 KB
/
nodes.inc.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
<?php
require_once("auth.php");
?>
<?php
require_once('cbsd.php');
// return 0 when no lock file_exists
// $idle=check_locktime("199.48.133.74");
// if ( $idle > 0 ) echo "ONLINE";
function check_locktime($nodeip)
{
global $workdir;
$lockfile="${workdir}/ftmp/shmux_${nodeip}.lock";
if (!file_exists($lockfile)) {
return 0;
}
$cur_time = time();
$st_time=filemtime($lockfile);
$difftime=(( $cur_time - $st_time ) / 60 );
if ( $difftime > 1 ) {
return round($difftime);;
} else {
return 0; //lock exist but too fresh
}
}
// $ip=get_node_info("n0.olevole.ru","ip");
// echo $ip;
function get_node_info($nodename,$value)
{
global $workdir;
$db = new SQLite3("$workdir/var/db/nodes.sqlite"); $db->busyTimeout(5000);
if (!$db) return;
$sql = "SELECT $value FROM nodelist WHERE nodename=\"$nodename\"";
$result = $db->query($sql);//->fetchArray(SQLITE3_ASSOC);
$row = array();
while($res = $result->fetchArray(SQLITE3_ASSOC)){
if(!isset($res["$value"])) return;
return $res["$value"];
}
}
?>