Ignore:
Timestamp:
Feb 17, 2021, 9:27:32 PM (3 years ago)
Author:
chronos
Message:
  • Added: Documents section accessible from users panel.
  • Added: Contract model moved to separate module Contract.
  • Added: New action to generate PDF from Contract.
  • Fixed: Allow users to download files only by hash instead of direct id.
  • Added: Support for SHA1 as allowed mysql function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Database.php

    r900 r901  
    4949  {
    5050    $this->Prefix = '';
    51     $this->Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()');
     51    $this->Functions = array('NOW(', 'CURDATE(', 'CURTIME(', 'UUID(', 'SHA1(');
    5252    $this->Type = 'mysql';  // mysql, pgsql
    5353    $this->Error = '';
     
    141141  }
    142142
     143  function IsFunction(string $Text): bool
     144  {
     145    $Pos = strpos($Text, '(');
     146    return ($Pos !== false) && in_array(substr($Text, 0, $Pos + 1), $this->Functions);
     147  }
     148
    143149  function GetInsert(string $Table, array $Data): string
    144150  {
     
    148154    {
    149155      $Name .= ',`'.$Key.'`';
    150       if (!in_array($Value, $this->Functions))
     156      if (is_null($Value)) $Value = 'NULL';
     157      else if (!$this->IsFunction($Value))
    151158      {
    152         if (is_null($Value)) $Value = 'NULL';
    153         else $Value = $this->PDO->quote($Value);
     159        $Value = $this->PDO->quote($Value);
    154160      }
    155161      $Values .= ','.$Value;
     
    170176    foreach ($Data as $Key => $Value)
    171177    {
    172       if (!in_array($Value, $this->Functions))
     178      if (is_null($Value)) $Value = 'NULL';
     179      else if (!$this->IsFunction($Value))
    173180      {
    174         if (is_null($Value)) $Value = 'NULL';
    175         else $Value = $this->PDO->quote($Value);
     181        $Value = $this->PDO->quote($Value);
    176182      }
    177183      $Values .= ', `'.$Key.'`='.$Value;
     
    187193    foreach ($Data as $Key => $Value)
    188194    {
    189       if (!in_array($Value, $this->Functions))
     195      if (is_null($Value)) $Value = 'NULL';
     196      else if (!$this->IsFunction($Value))
    190197      {
    191         if (is_null($Value)) $Value = 'NULL';
    192         else $Value = $this->PDO->quote($Value);
     198        $Value = $this->PDO->quote($Value);
    193199      }
    194200      $Name .= ',`'.$Key.'`';
Note: See TracChangeset for help on using the changeset viewer.