Changeset 671 for trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
- Timestamp:
- Jul 19, 2014, 1:21:24 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
r548 r671 11 11 var $Timeout; // Connection attempt timeout and data read timeout 12 12 var $Socket; // Variable for storing socket resource 13 13 14 14 function __construct() 15 15 { … … 43 43 if($this->Connected) $this->Disconnect(); 44 44 $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout); 45 if($this->Socket) 45 if($this->Socket) 46 46 { 47 47 socket_set_timeout($this->Socket, $this->Timeout); … … 59 59 } 60 60 } 61 if(!$this->Connected) fclose($this->Socket); 62 } 63 } 64 61 if(!$this->Connected) fclose($this->Socket); 62 } 63 } 64 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); … … 182 182 $Response[] = $Line; 183 183 } 184 echo($Line."\n"); 184 185 // If we get a !done, make a note of it. 185 186 if ($Line == "!done") $ReceivedDone = true; 187 else $ReceivedDone = false; 186 188 $Status = socket_get_status($this->Socket); 187 if ((!$this->Connected && !$Status['unread_bytes']) || 189 if ((!$this->Connected && !$Status['unread_bytes']) || 188 190 ($this->Connected && !$Status['unread_bytes'] && $ReceivedDone)) 189 191 break; … … 195 197 function Write($Command, $Param2 = true) 196 198 { 197 if($Command) 199 if($Command) 198 200 { 199 201 $Data = explode("\n", $Command); 200 202 foreach ($Data as $Com) { 201 203 $Com = trim($Com); 202 fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com); 204 fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com); 203 205 } 204 206 if (gettype($Param2) == 'integer') {
Note:
See TracChangeset
for help on using the changeset viewer.