Changeset 15


Ignore:
Timestamp:
Dec 27, 2022, 3:11:01 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Updates and fixes.
Location:
Common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Common/Error.php

    r14 r15  
    1616  }
    1717
    18   function Start()
     18  function Start(): void
    1919  {
    2020    set_error_handler(array($this, 'ErrorHandler'));
     
    2222  }
    2323
    24   function Stop()
     24  function Stop(): void
    2525  {
    2626    restore_error_handler();
     
    2828  }
    2929
    30   function ErrorHandler($Number, $Message, $FileName, $LineNumber, $Variables)
     30  function ErrorHandler(int $Number, string $Message, string $FileName, int $LineNumber, array $Variables = array()): bool
    3131  {
    3232    $ErrorType = array
     
    6363  }
    6464
    65   function ExceptionHandler(Throwable $Exception)
     65  function ExceptionHandler(Throwable $Exception): void
    6666  {
    6767    $Backtrace = $Exception->getTrace();
     
    8888  }
    8989
    90   function Report($Backtrace)
     90  function Report(array $Backtrace): void
    9191  {
    9292    $Date = date('Y-m-d H:i:s');
  • Common/Mail.php

    r14 r15  
    2020  private array $Priorities;
    2121  private string $Boundary;
     22  public bool $TestMode;
    2223
    2324  function __construct()
     
    2627    $this->Boundary = md5(date('r', time()));
    2728    $this->AgentIdent = 'PHP/Mail';
     29    $this->TestMode = false;
    2830    $this->Clear();
    2931  }
     
    133135    if ($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent;
    134136    if ($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo;
    135     if ($this->From != '') $this->Headers['From'] = $this->From;
     137    if ($this->From != '')
     138    {
     139      $IndexStart = strpos($this->From, '<');
     140      if ($IndexStart !== false)
     141      {
     142        $this->Headers['From'] = '=?utf-8?Q?'.quoted_printable_encode(trim(substr($this->From, 0, $IndexStart))).'?= '.substr($this->From, $IndexStart);
     143      } else
     144      {
     145        $this->Headers['From'] = $this->From;
     146      }
     147    }
    136148
    137149    $Headers = '';
     
    145157    if ($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
    146158
    147     $res = mail($To, $this->Subject, $Body, $Headers);
     159    if ($this->TestMode)
     160    {
     161      echo('to: '.$To.', subject: '.$this->Subject.', body: '.$Body.', headers: '.$Headers);
     162      $res = true;
     163    } else
     164    {
     165      $res = mail($To, $this->Subject, $Body, $Headers);
     166    }
    148167    return $res;
    149168  }
  • Common/ModelDesc.php

    r14 r15  
    1616    $this->PrimaryKey = 'Id';
    1717    $this->Memory = false;
     18    $this->DefaultValuesMethod = null;
    1819  }
    1920
     
    179180{
    180181  public ?string $Default;
     182  public int $MaxLength;
    181183
    182184  function __construct(string $Name)
     
    185187    $this->HasDefault = false;
    186188    $this->Default = null;
     189    $this->MaxLength = 255;
    187190  }
    188191
  • Common/NetworkAddress.php

    r14 r15  
    102102    foreach ($Data as $Item)
    103103    {
    104 
    105104      $Result[] = dechex($Item & 15);
    106105      $Result[] = dechex(($Item >> 4) & 15);
Note: See TracChangeset for help on using the changeset viewer.