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

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php

    r861 r873  
    4040    } else if ($Length >= 0x10000000)
    4141      $Length = chr(0xF0).chr(($Length >> 24) & 0xFF).chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF);
    42     return($Length);
     42    return ($Length);
    4343  }
    4444
    4545  function ConnectOnce($IP, $Login, $Password)
    4646  {
    47     if($this->Connected) $this->Disconnect();
    48     if($this->SSL)
     47    if ($this->Connected) $this->Disconnect();
     48    if ($this->SSL)
    4949    {
    5050      $IP = 'ssl://'.$IP;
    5151    }
    5252    $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout);
    53     if($this->Socket)
     53    if ($this->Socket)
    5454    {
    5555      socket_set_timeout($this->Socket, $this->Timeout);
     
    5858      $this->Write('=password='.$Password);
    5959      $Response = $this->Read(false);
    60       if((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true;
    61       if(!$this->Connected) fclose($this->Socket);
     60      if ((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true;
     61      if (!$this->Connected) fclose($this->Socket);
    6262    }
    6363  }
     
    6565  function Connect($IP, $Login, $Password)
    6666  {
    67     for($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)
     67    for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)
    6868    {
    6969      $this->ConnectOnce($IP, $Login, $Password);
    70       if($this->Connected) break;
     70      if ($this->Connected) break;
    7171      sleep($this->Delay);
    7272    }
    73     return($this->Connected);
     73    return ($this->Connected);
    7474  }
    7575
    7676  function Disconnect()
    7777  {
    78     if($this->Connected)
     78    if ($this->Connected)
    7979    {
    8080      fclose($this->Socket);
     
    183183        $Response[] = $Line;
    184184      }
    185       if($this->Debug) echo($Line);
     185      if ($this->Debug) echo($Line);
    186186      // If we get a !done, make a note of it.
    187187      if ($Line == "!done") $ReceivedDone = true;
     
    192192        break;
    193193    }
    194     if($Parse) $Response = $this->ParseResponse($Response);
     194    if ($Parse) $Response = $this->ParseResponse($Response);
    195195    return $Response;
    196196  }
     
    198198  function Write($Command, $Param2 = true)
    199199  {
    200     if($Command)
     200    if ($Command)
    201201    {
    202202      $Data = explode("\n", $Command);
     
    234234      $this->Write($el, $Last);
    235235    }
    236     return($this->Read());
     236    return ($this->Read());
    237237  }
    238238}
Note: See TracChangeset for help on using the changeset viewer.