Changeset 873 for trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
r861 r873 40 40 } else if ($Length >= 0x10000000) 41 41 $Length = chr(0xF0).chr(($Length >> 24) & 0xFF).chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF); 42 return ($Length);42 return ($Length); 43 43 } 44 44 45 45 function ConnectOnce($IP, $Login, $Password) 46 46 { 47 if ($this->Connected) $this->Disconnect();48 if ($this->SSL)47 if ($this->Connected) $this->Disconnect(); 48 if ($this->SSL) 49 49 { 50 50 $IP = 'ssl://'.$IP; 51 51 } 52 52 $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout); 53 if ($this->Socket)53 if ($this->Socket) 54 54 { 55 55 socket_set_timeout($this->Socket, $this->Timeout); … … 58 58 $this->Write('=password='.$Password); 59 59 $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); 62 62 } 63 63 } … … 65 65 function Connect($IP, $Login, $Password) 66 66 { 67 for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)67 for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++) 68 68 { 69 69 $this->ConnectOnce($IP, $Login, $Password); 70 if ($this->Connected) break;70 if ($this->Connected) break; 71 71 sleep($this->Delay); 72 72 } 73 return ($this->Connected);73 return ($this->Connected); 74 74 } 75 75 76 76 function Disconnect() 77 77 { 78 if ($this->Connected)78 if ($this->Connected) 79 79 { 80 80 fclose($this->Socket); … … 183 183 $Response[] = $Line; 184 184 } 185 if ($this->Debug) echo($Line);185 if ($this->Debug) echo($Line); 186 186 // If we get a !done, make a note of it. 187 187 if ($Line == "!done") $ReceivedDone = true; … … 192 192 break; 193 193 } 194 if ($Parse) $Response = $this->ParseResponse($Response);194 if ($Parse) $Response = $this->ParseResponse($Response); 195 195 return $Response; 196 196 } … … 198 198 function Write($Command, $Param2 = true) 199 199 { 200 if ($Command)200 if ($Command) 201 201 { 202 202 $Data = explode("\n", $Command); … … 234 234 $this->Write($el, $Last); 235 235 } 236 return ($this->Read());236 return ($this->Read()); 237 237 } 238 238 }
Note:
See TracChangeset
for help on using the changeset viewer.