Changeset 942


Ignore:
Timestamp:
Aug 26, 2022, 11:04:38 PM (20 months ago)
Author:
chronos
Message:
  • Fixed: Do not terminate script with error if fsockopen fails.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Global.php

    r938 r942  
    397397  return $Data;
    398398}
     399
     400function ExeceuteNoError(callable $Function): void
     401{
     402  try
     403  {
     404    $LastErrorReporting = error_reporting();
     405    error_reporting(0);
     406    $function();
     407  }
     408  finally
     409  {
     410    error_reporting($LastErrorReporting);
     411  }
     412}
  • trunk/Modules/NetworkConfigLinux/Generators/DNS.php

    r931 r942  
    158158    $MinimumTime = 10800;
    159159    $TTL = 86400;
    160     if ($this->System->Config['DNS']['BaseDir'])
     160    if (isset($this->System->Config['DNS']['BaseDir']))
    161161      $BaseDir = $this->System->Config['DNS']['BaseDir'];
    162162      else $BaseDir = '/var/cache/bind';
  • 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.