Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkShare/online.php

    r790 r873  
    33//$Database->select_db('share');
    44echo("\n====================== Kontrola online pocitacu ============================\n\n");
    5 //while(true)
     5//while (true)
    66{
    77  echo('Nacitam strom sdileni...');
     
    1313  array_shift($Output);
    1414  $Online = array();    // Seznam online pocitacu
    15   foreach($Output as $Radek)
     15  foreach ($Output as $Radek)
    1616  {
    17     if(ord($Radek[0])!=9) continue;
     17    if (ord($Radek[0])!=9) continue;
    1818    $Host = explode(' ',substr($Radek,3));
    1919    $Host = $Host[0];
     
    2121    $Section = 0;
    2222    // Zjisti IP a MAC adresu
    23     if($Host=='CENTRALA')
     23    if ($Host=='CENTRALA')
    2424    {
    2525      $MAC = '00:E0:4C:20:64:22';
     
    2727      $Section = 0;
    2828    } else
    29     if($Host=='CENTRALA2')
     29    if ($Host=='CENTRALA2')
    3030    {
    3131      $MAC = '00:E0:4C:20:64:22';
     
    3838      //echo('arping -c 1 '.$Host);
    3939      exec('arping -c 1 '.$Host,$Output);
    40       if(count($Output)!=4)
     40      if (count($Output)!=4)
    4141      {
    4242        $Output = array();
    4343        exec('arping -I wlan0 -c 1 '.$Host,$Output);
    44         if(count($Output)!=4)
     44        if (count($Output)!=4)
    4545        {
    4646          $Output = array();
    4747          exec('arping -I wlan1 -c 1 '.$Host,$Output);
    48           if(count($Output)!=4)
     48          if (count($Output)!=4)
    4949          {
    5050            $Output = array();
    5151            exec('arping -I wlan2 -c 1 '.$Host,$Output);
    52             if(count($Output)!=4)
     52            if (count($Output)!=4)
    5353            {
    5454              $Output = array();
    5555              exec('arping -I eth2 -c 1 '.$Host,$Output);
    56               if(count($Output)!=4) continue;
     56              if (count($Output)!=4) continue;
    5757              else $Section = 4;
    5858            } else $Section = 3;
     
    7474  //print_r($Online);
    7575  // Aktivuj online pocitace
    76   foreach($Online as $Item)
     76  foreach ($Online as $Item)
    7777  {
    7878    $DbResult = $Database->query("SELECT * FROM hosts WHERE name='".$Item['host']."'");
    79     if($DbResult->num_rows > 0)
     79    if ($DbResult->num_rows > 0)
    8080    {
    8181      $Database->update('hosts',"name='".$Item['host']."'",array( 'IP' => $Item['IP'], 'MAC' => $Item['MAC'], 'online' => 1, 'lastdate' => 'NOW()', 'section' => $Section));
     
    8585  echo("\nSeznam offline pocitacu:\n");
    8686  $DbResult = $Database->query("SELECT * FROM hosts WHERE online=0");
    87   while($Row = $DbResult->fetch_array())
     87  while ($Row = $DbResult->fetch_array())
    8888  {
    8989    echo($Row['name'].", ");
Note: See TracChangeset for help on using the changeset viewer.