Ignore:
Timestamp:
Aug 26, 2022, 11:04:38 PM (21 months ago)
Author:
chronos
Message:
  • Fixed: Do not terminate script with error if fsockopen fails.
File:
1 edited

Legend:

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

    r915 r942  
    5656      $IP = 'ssl://'.$IP;
    5757    }
    58     $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout);
    59     if ($this->Socket)
    60     {
    61       socket_set_timeout($this->Socket, $this->Timeout);
    62       $this->Write('/login', false);
    63       $this->Write('=name=' . $Login, false);
    64       $this->Write('=password='.$Password);
    65       $Response = $this->Read(false);
    66       if ((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true;
    67       if (!$this->Connected) fclose($this->Socket);
     58    try
     59    {
     60      $LastErrorReporting = error_reporting();
     61      error_reporting(0);
     62
     63      $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout);
     64      if ($this->Socket)
     65      {
     66        socket_set_timeout($this->Socket, $this->Timeout);
     67        $this->Write('/login', false);
     68        $this->Write('=name=' . $Login, false);
     69        $this->Write('=password='.$Password);
     70        $Response = $this->Read(false);
     71        if ((count($Response) > 0) and ($Response[0] == '!done')) $this->Connected = true;
     72        if (!$this->Connected) fclose($this->Socket);
     73      }
     74    } finally
     75    {
     76      error_reporting($LastErrorReporting);
    6877    }
    6978  }
Note: See TracChangeset for help on using the changeset viewer.