Changeset 873 for trunk/Modules/NetworkShare/online.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkShare/online.php
r790 r873 3 3 //$Database->select_db('share'); 4 4 echo("\n====================== Kontrola online pocitacu ============================\n\n"); 5 //while (true)5 //while (true) 6 6 { 7 7 echo('Nacitam strom sdileni...'); … … 13 13 array_shift($Output); 14 14 $Online = array(); // Seznam online pocitacu 15 foreach ($Output as $Radek)15 foreach ($Output as $Radek) 16 16 { 17 if (ord($Radek[0])!=9) continue;17 if (ord($Radek[0])!=9) continue; 18 18 $Host = explode(' ',substr($Radek,3)); 19 19 $Host = $Host[0]; … … 21 21 $Section = 0; 22 22 // Zjisti IP a MAC adresu 23 if ($Host=='CENTRALA')23 if ($Host=='CENTRALA') 24 24 { 25 25 $MAC = '00:E0:4C:20:64:22'; … … 27 27 $Section = 0; 28 28 } else 29 if ($Host=='CENTRALA2')29 if ($Host=='CENTRALA2') 30 30 { 31 31 $MAC = '00:E0:4C:20:64:22'; … … 38 38 //echo('arping -c 1 '.$Host); 39 39 exec('arping -c 1 '.$Host,$Output); 40 if (count($Output)!=4)40 if (count($Output)!=4) 41 41 { 42 42 $Output = array(); 43 43 exec('arping -I wlan0 -c 1 '.$Host,$Output); 44 if (count($Output)!=4)44 if (count($Output)!=4) 45 45 { 46 46 $Output = array(); 47 47 exec('arping -I wlan1 -c 1 '.$Host,$Output); 48 if (count($Output)!=4)48 if (count($Output)!=4) 49 49 { 50 50 $Output = array(); 51 51 exec('arping -I wlan2 -c 1 '.$Host,$Output); 52 if (count($Output)!=4)52 if (count($Output)!=4) 53 53 { 54 54 $Output = array(); 55 55 exec('arping -I eth2 -c 1 '.$Host,$Output); 56 if (count($Output)!=4) continue;56 if (count($Output)!=4) continue; 57 57 else $Section = 4; 58 58 } else $Section = 3; … … 74 74 //print_r($Online); 75 75 // Aktivuj online pocitace 76 foreach ($Online as $Item)76 foreach ($Online as $Item) 77 77 { 78 78 $DbResult = $Database->query("SELECT * FROM hosts WHERE name='".$Item['host']."'"); 79 if ($DbResult->num_rows > 0)79 if ($DbResult->num_rows > 0) 80 80 { 81 81 $Database->update('hosts',"name='".$Item['host']."'",array( 'IP' => $Item['IP'], 'MAC' => $Item['MAC'], 'online' => 1, 'lastdate' => 'NOW()', 'section' => $Section)); … … 85 85 echo("\nSeznam offline pocitacu:\n"); 86 86 $DbResult = $Database->query("SELECT * FROM hosts WHERE online=0"); 87 while ($Row = $DbResult->fetch_array())87 while ($Row = $DbResult->fetch_array()) 88 88 { 89 89 echo($Row['name'].", ");
Note:
See TracChangeset
for help on using the changeset viewer.