Changeset 317 for trunk/system


Ignore:
Timestamp:
Jul 15, 2011, 8:26:28 AM (13 years ago)
Author:
george
Message:
  • Uvozovky v názvech v SQL dotazech.
Location:
trunk/system
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/system/generators/firewall_mangle.php

    r288 r317  
    2323
    2424// Divide rules by subnet number
    25 $DbResult = $Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE Member=0');
     25$DbResult = $Database->query('SELECT `Id`, `Name`, `AddressRange`, `Mask` FROM `NetworkSubnet` WHERE `Member` IS NULL');
    2626while($Subnet = $DbResult->fetch_assoc())
    2727{
  • trunk/system/generators/firewall_nat.php

    r315 r317  
    3636//$Items[] = array('chain' => 'inet-in', 'dst-address' => '172.16.1.1/30', 'action' => 'accept', 'comment' => 'Local_subnet');
    3737
    38 $DbResult = $Database->query('SELECT Member.*, Subject.Name FROM Member JOIN Subject ON Member.Subject = Subject.Id');
     38$DbResult = $Database->query('SELECT `Member`.*, `Subject`.`Name` FROM `Member` JOIN `Subject` ON `Member`.`Subject` = `Subject`.`Id`');
    3939while($Member = $DbResult->fetch_assoc())
    4040{
    4141  echo($Member['Name'].': ');
    4242  // Hosts
    43   $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName, NetworkDevice.InboundNATPriority FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE (NetworkInterface.ExternalIP <> "") AND (NetworkDevice.Member = '.$Member['Id'].') AND (NetworkInterface.LocalIP != NetworkInterface.ExternalIP) ORDER BY id DESC');
     43  $DbResult2 = $Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName`, `NetworkDevice`.`InboundNATPriority` FROM `NetworkInterface`'.
     44  ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE (`NetworkInterface`.`ExternalIP` <> "")'.
     45  ' AND (`NetworkDevice`.`Member` = '.$Member['Id'].') AND (`NetworkInterface`.`LocalIP` != `NetworkInterface`.`ExternalIP`) ORDER BY `id` DESC');
    4446  while($Interface = $DbResult2->fetch_assoc())
    4547  {
     
    6062
    6163  // Subnets
    62   $DbResult2 = $Database->select('NetworkSubnet', '*', 'Member='.$Member['Id']);
     64  $DbResult2 = $Database->select('NetworkSubnet', '*', '`Member`='.$Member['Id']);
    6365  while($Subnet = $DbResult2->fetch_assoc())
    6466  {   
  • trunk/system/generators/netwatch.php

    r301 r317  
    2323    $I = explode('.', $Subnet['AddressRange']);
    2424    $I = $I[2];
    25     $DbResult2 = $Database->query('SELECT NetworkInterface.*, NetworkDevice.Name AS DeviceName FROM NetworkInterface LEFT JOIN NetworkDevice ON NetworkDevice.Id = NetworkInterface.Device WHERE CompareNetworkPrefix(INET_ATON(LocalIP), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].') AND (NetworkDevice.Used = 1) ORDER BY NetworkInterface.LocalIP');
     25    $DbResult2 = $Database->query('SELECT `NetworkInterface`.*, `NetworkDevice`.`Name` AS `DeviceName` FROM `NetworkInterface`'.
     26    ' LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` WHERE CompareNetworkPrefix(INET_ATON(`LocalIP`), INET_ATON("'.$Subnet['AddressRange'].'"), '.$Subnet['Mask'].')'.
     27    ' AND (`NetworkDevice`.`Used` = 1) ORDER BY `NetworkInterface`.`LocalIP`');
    2628    while($Interface = $DbResult2->fetch_assoc())
    2729    {
  • trunk/system/generators/netwatch_import.php

    r313 r317  
    66include('common.php');
    77$Path = array('tool', 'netwatch');
     8$Period = 60; // every 60 seconds
    89
    9 $DbResult3 = $Database->query('SELECT * FROM `NetworkSubnet`  WHERE `Member` = 0');
     10while(1)
     11{
     12  $StartTime = time();
     13
     14$DbResult3 = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` IS NULL');
     15//echo($DbResult3->num_rows);
    1016while($Subnet = $DbResult3->fetch_assoc())
    1117{
     
    3945      }
    4046
    41       $DbResult = $Database->update('NetworkInterface', 'LocalIP = "'.$Properties['host'].'"', $Values);
     47      $DbResult = $Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values);
    4248      if($Online == 1)
    4349      {
    44         $DbResult = $Database->select('NetworkInterface', 'Id', 'LocalIP = "'.$Properties['host'].'"');
     50        $DbResult = $Database->select('NetworkInterface', 'Id', '`LocalIP` = "'.$Properties['host'].'"');
    4551        $DbRow = $DbResult->fetch_assoc();
    4652        $InterfaceId = $DbRow['Id'];
    47         $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '(NetworkInterface="'.$InterfaceId.'") AND (Time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    48         if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO NetworkInterfaceStat (NetworkInterface, Time) VALUES ("'.$InterfaceId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');         
    49         $Database->query('UPDATE NetworkInterfaceStat SET PingCount = PingCount + 1 WHERE (NetworkInterface="'.$InterfaceId.'") AND (Time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
     53        $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$InterfaceId.'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
     54        if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`) VALUES ("'.$InterfaceId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');         
     55        $Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$InterfaceId.'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    5056       
    5157      }
     
    5561
    5662// Update device online state
    57 $DbResult = $Database->select('NetworkDevice', 'Id', 'Used=1');
     63$DbResult = $Database->select('NetworkDevice', 'Id', '`Used`=1');
    5864while($Device = $DbResult->fetch_assoc())
    5965{
    60   $DbResult2 = $Database->select('NetworkInterface', 'SUM(Online)', 'Device='.$Device['Id']);
     66  $DbResult2 = $Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']);
    6167  $DbRow = $DbResult2->fetch_array();
    62   if($DbRow['SUM(Online)'] > 0) $Online = 1; else $Online = 0; 
     68  if($DbRow['SumOnline'] > 0) $Online = 1; else $Online = 0; 
    6369  $Database->update('NetworkDevice', 'Id='.$Device['Id'], array('Online' => $Online));
    6470  if($Online == 1) $Database->update('NetworkDevice', 'Id='.$Device['Id'], array('LastOnline' => 'NOW()'));
    6571}
    6672
     73  $EndTime = time();
     74  $Delay = $Period - ($EndTime - $StartTime);
     75  if($Delay < 0) $Delay = 0;
     76
     77  echo('Waiting '.$Delay.' seconds...'."\n");
     78  sleep($Delay);
     79}
     80
    6781?>
  • trunk/system/generators/queue.php

    r266 r317  
    6969  $ItemsQueue[] = array('name' => $Member['Name'].'-in', 'limit-at' => $SpeedOut, 'max-limit' => $UserMaxSpeedOut, 'parent' => 'main-in');
    7070
    71   $DbResult2 = $Database->select('NetworkDevice', 'COUNT(*)', 'Used = 1 AND Member='.$Member['Id']);
     71  $DbResult2 = $Database->select('NetworkDevice', 'COUNT(*)', '(`Used` = 1) AND (`Member`='.$Member['Id'].')');
    7272  $Row = $DbResult2->fetch_row();
    7373  $HostCount = $Row[0];
  • trunk/system/routerboard.php

    r301 r317  
    4949    if($Commands != '')
    5050    {
    51       $Output = array();
    5251      $Commands = addslashes($Commands);
    5352      $Commands = str_replace('$', '\$', $Commands);
     53      //$Commands = str_replace(' ', '\ ', $Commands); 
    5454      $Command = $this->SSHPath.' -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName.' -i '.$this->PrivateKey.' '.$this->HostName.' "'.$Commands.'"';
    5555      if($this->Debug) echo($Command);
     56      $Output = array();
    5657      exec($Command, $Output);
    5758    } else $Output = '';
Note: See TracChangeset for help on using the changeset viewer.