Last change
on this file since 3 was 3, checked in by george, 18 years ago |
První pracovní verze nového webu.
|
-
Property svn:executable
set to
*
|
File size:
1.3 KB
|
Line | |
---|
1 | <?
|
---|
2 | include_once('db.php');
|
---|
3 | include_once('error.php');
|
---|
4 | DB_Init('localhost','root','','is');
|
---|
5 |
|
---|
6 | DB_Select('hosts', 'id,name,IP');
|
---|
7 | while($Row = DB_Row())
|
---|
8 | {
|
---|
9 | //echo($Row['name'].'('.$Row['IP'].'): ');
|
---|
10 | if($Row['IP'] != '')
|
---|
11 | {
|
---|
12 | DB_Save();
|
---|
13 | $Output = array();
|
---|
14 | exec('ping '.$Row['IP'].' -c 1 | grep received',$Output);
|
---|
15 | $Status = 0;
|
---|
16 | if(count($Output)==1)
|
---|
17 | {
|
---|
18 | $Output = explode(" ",$Output[0]);
|
---|
19 | if($Output[3]=='1') $Status = 1;
|
---|
20 | }
|
---|
21 | //if($Row['name']=='CLZVONICEK') $Status = 0;
|
---|
22 |
|
---|
23 | //echo($Status."\n");
|
---|
24 |
|
---|
25 | if($Status == 1)
|
---|
26 | {
|
---|
27 | DB_Update('hosts', 'id = '.$Row['id'], array('online' => $Status, 'last_online' => 'NOW()'));
|
---|
28 |
|
---|
29 | DB_Select('stat_hosts', '*', '(host_id="'.$Row['id'].'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
|
---|
30 | if(Db_NumRows() == 0) Db_Query('REPLACE INTO stat_hosts (host_id, time) VALUES ("'.$Row['id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
|
---|
31 | DB_Query('UPDATE stat_hosts SET count = count + 1 WHERE (host_id="'.$Row['id'].'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
|
---|
32 | } else DB_Update('hosts', 'id = '.$Row['id'], array('online' => $Status));
|
---|
33 |
|
---|
34 | DB_Load();
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | ?>
|
---|
Note:
See
TracBrowser
for help on using the repository browser.