Changeset 9


Ignore:
Timestamp:
Jun 1, 2023, 1:01:38 AM (11 months ago)
Author:
chronos
Message:
  • Fixed: Modules initialization.
Location:
trunk
Files:
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r8 r9  
    66// and system will need database update.
    77
    8 $Revision = 8;
    9 $DatabaseRevision = 8;
     8$Revision = 9;
     9$DatabaseRevision = 7;
    1010$ReleaseTime = strtotime('2023-06-01');
  • trunk/Global.php

    r7 r9  
    11<?php
    22
    3 function HumanDate($Time)
     3function HumanDate(?string $Time): string
    44{
    55  return date('j.n.Y', $Time);
    66}
    77
    8 function GetMicrotime()
     8function GetMicrotime(): float
    99{
    10   list($Usec, $Sec) = explode(" ", microtime());
     10  list($Usec, $Sec) = explode(' ', microtime());
    1111  return (float)$Usec + (float)$Sec;
    12 }
     12} 
    1313
    14 function MakeLink($Target, $Title)
     14function MakeLink(string $Target, string $Title): string
    1515{
    1616  return '<a href="'.$Target.'">'.$Title.'</a>';
    1717}
    1818
    19 function Table($Table)
     19function Table(array $Table): string
    2020{
    21   $Result = '<table cellspacing="0" class="BasicTable">';
    22   $Result .= '<tr>';
    23   foreach ($Table['Header'] as $Item)
    24     $Result .= '<th>'.$Item.'</th>';
    25   $Result .= '</tr>';
     21  $Result = '<table class="BasicTable">';
     22  if (array_key_exists('Header', $Table))
     23  {
     24    $Result .= '<tr>';
     25    foreach ($Table['Header'] as $Item)
     26      $Result .= '<th>'.$Item.'</th>';
     27    $Result .= '</tr>';
     28  }
    2629  foreach ($Table['Rows'] as $Row)
    2730  {
    2831    $Result .= '<tr>';
    29     foreach ($Row as $Item)
    30       $Result .= '<td>'.$Item.'</td>';
     32    foreach ($Row as $Index => $Item)
     33    {
     34      if ($Index == 0) $Class = ' class="Header"'; else $Class = '';
     35      $Result .= '<td'.$Class.' style="width: '.(floor(100 / count($Row))).'%">'.$Item.'</td>';
     36    }
    3137    $Result .= '</tr>';
    3238  }
     
    3541}
    3642
    37 function ShowEditTable($ClassName, $Values)
     43function ShowEditTable(string $ClassName, array $Values): string
    3844{
    3945  global $Classes, $Types;
     
    6874}
    6975
    70 function ProcessURL()
     76function ProcessURL(): array
    7177{
    7278  if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     
    8288}
    8389
    84 function GetQueryStringArray($QueryString)
     90function GetQueryStringArray(string $QueryString): array
    8591{
    8692  $Result = array();
     
    98104}
    99105
    100 function SetQueryStringArray($QueryStringArray)
     106function SetQueryStringArray(array $QueryStringArray): string
    101107{
    102108  $Parts = array();
     
    108114}
    109115
    110 function GetRemoteAddress()
     116function GetRemoteAddress(): string
    111117{
    112118  if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
  • trunk/Modules/Map/ModuleMap.php

    r8 r9  
    11<?php
     2
     3include_once(dirname(__FILE__).'/Map.php');
     4include_once(dirname(__FILE__).'/MapGoogle.php');
     5include_once(dirname(__FILE__).'/MapOSM.php');
     6include_once(dirname(__FILE__).'/MapSeznam.php');
    27
    38class ModuleMap extends Module
  • trunk/Modules/User/ModuleUser.php

    r8 r9  
    133133    $this->System->User = new User($this->System);
    134134    if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();
    135     $this->System->RegisterPage('userlist', 'PageUserList');
    136     $this->System->RegisterPage('user', 'PageUser');
     135    $this->System->RegisterPage(['userlist'], 'PageUserList');
     136    $this->System->RegisterPage(['user'], 'PageUser');
    137137    $this->System->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));
    138138    $this->System->FormManager->RegisterClass('UserLogin', array(
  • trunk/Modules/User/PasswordHash.php

    r8 r9  
    11<?php
     2
    23
    34class PasswordHash
    45{
    5   function Hash($Password, $Salt)
     6  function Hash(string $Password, string $Salt): string
    67  {
    78    return sha1(sha1($Password).$Salt);
    89  }
    910
    10   function Verify($Password, $Salt, $StoredHash)
     11  function Verify(string $Password, string $Salt, string $StoredHash): bool
    1112  {
    1213    return $this->Hash($Password, $Salt) == $StoredHash;
    1314  }
    1415
    15   function GetSalt()
     16  function GetSalt(): string
    1617  {
    17     mt_srand(microtime(true) * 100000 + memory_get_usage(true));
     18    mt_srand(intval(microtime(true)) * 100000 + memory_get_usage(true));
    1819    return sha1(uniqid(mt_rand(), true));
    1920  }
  • trunk/Modules/User/User.php

    r8 r9  
    143143
    144144            // Send activation mail to user email
    145             $ServerURL = 'http://'.$this->System->Config['Web']['Host'].$this->System->Config['Web']['RootFolder'];
     145            $ServerURL = 'http://'.Core::Cast($this->System)->Config['Web']['Host'].Core::Cast($this->System)->Config['Web']['RootFolder'];
    146146            $Mail = new Mail();
    147147            $Mail->Subject = 'Registrace nového účtu';
     
    154154              '<br/><br/>Na tento email neodpovídejte.", 'text/html');
    155155            $Mail->AddTo($Email, $Name);
    156             $Mail->From = $this->System->Config['Web']['Title'].' <noreplay@zdechov.net>';
     156            $Mail->From = Core::Cast($this->System)->Config['Web']['Title'].' <noreplay@zdechov.net>';
    157157            $Mail->Send();
    158158
     
    368368      $NewPassword = substr(sha1(strtoupper($Row['Login'])), 0, 7);
    369369
    370       $ServerURL = 'http://'.$this->System->Config['Web']['Host'].$this->System->Config['Web']['RootFolder'];
     370      $ServerURL = 'http://'.Core::Cast($this->System)->Config['Web']['Host'].Core::Cast($this->System)->Config['Web']['RootFolder'];
    371371      $Mail = new Mail();
    372372      $Mail->Subject = 'Obnova hesla';
    373       $Mail->From = $this->System->Config['Web']['Title'].' <noreplay@zdechov.net>';
     373      $Mail->From = Core::Cast($this->System)->Config['Web']['Title'].' <noreplay@zdechov.net>';
    374374      $Mail->AddTo($Row['Email'], $Row['Name']);
    375375      $Mail->AddBody('Požádali jste o zaslání nového hesla na serveru <a href="'.$ServerURL.'">'.$ServerURL.'"</a>.<br />\n'.
  • trunk/Packages/Common/Modules/ModuleAdmin.php

    r8 r9  
    88  {
    99    parent::__construct($System);
    10     $this->Name = 'ModuleManager';
     10    $this->Name = 'Admin';
    1111    $this->Version = '1.0';
    1212    $this->Creator = 'Chronos';
     
    4949      ),
    5050    ));
    51     $this->System->FormManager->RegisterFormType('TModule', array(
     51    Core::Cast($this->System)->FormManager->RegisterFormType('TModule', array(
    5252      'Type' => 'Reference',
    5353      'Table' => 'Module',
     
    5656      'Filter' => '1',
    5757    ));
    58     $this->System->FormManager->RegisterFormType('TModelListModule', array(
     58    Core::Cast($this->System)->FormManager->RegisterFormType('TModelListModule', array(
    5959      'Type' => 'ManyToOne',
    6060      'Table' => 'Model',
     
    6363      'Filter' => '1',
    6464    ));
    65     $this->System->FormManager->RegisterClass('Model', array(
     65    Core::Cast($this->System)->FormManager->RegisterClass('Model', array(
    6666      'Title' => 'Modely',
    6767      'Table' => 'Model',
     
    7676      ),
    7777    ));
    78     $this->System->FormManager->RegisterFormType('TModel', array(
     78    Core::Cast($this->System)->FormManager->RegisterFormType('TModel', array(
    7979      'Type' => 'Reference',
    8080      'Table' => 'Model',
     
    8383      'Filter' => '1',
    8484    ));
    85     $this->System->FormManager->RegisterFormType('TModelFieldListModel', array(
     85    Core::Cast($this->System)->FormManager->RegisterFormType('TModelFieldListModel', array(
    8686      'Type' => 'ManyToOne',
    8787      'Table' => 'ModelField',
     
    9090      'Filter' => '1',
    9191    ));
    92     $this->System->FormManager->RegisterClass('ModelField', array(
     92    Core::Cast($this->System)->FormManager->RegisterClass('ModelField', array(
    9393      'Title' => 'Pole modelu',
    9494      'Table' => 'ModelField',
     
    104104      ),
    105105    ));
    106     $this->System->FormManager->RegisterFormType('TModuleLink', array(
     106    Core::Cast($this->System)->FormManager->RegisterFormType('TModuleLink', array(
    107107      'Type' => 'Reference',
    108108      'Table' => 'ModuleLink',
     
    111111      'Filter' => '1',
    112112    ));
    113     $this->System->FormManager->RegisterFormType('TModuleLinkListModule', array(
     113    Core::Cast($this->System)->FormManager->RegisterFormType('TModuleLinkListModule', array(
    114114      'Type' => 'ManyToOne',
    115115      'Table' => 'ModuleLink',
     
    118118      'Filter' => '1',
    119119    ));
    120     $this->System->FormManager->RegisterClass('ModuleLink', array(
     120    Core::Cast($this->System)->FormManager->RegisterClass('ModuleLink', array(
    121121      'Title' => 'Vazby modulu',
    122122      'Table' => 'ModuleLink',
     
    127127      ),
    128128    ));
    129     $this->System->FormManager->RegisterFormType('TModule', array(
     129    Core::Cast($this->System)->FormManager->RegisterFormType('TModule', array(
    130130      'Type' => 'Reference',
    131131      'Table' => 'Module',
     
    250250        'Type' => ModelColumnType::GetName($Field->Type), 'Nullable' => (int)$Field->Nullable));
    251251    }
    252     if ($ModelDesc->DefaultValues != null)
    253     {
    254       $Values = call_user_func('self::'.$ModelDesc->DefaultValues);
     252    if ($ModelDesc->DefaultValuesMethod != null)
     253    {
     254      $Values = call_user_func('self::'.$ModelDesc->DefaultValuesMethod);
    255255      foreach ($Values as $Value)
    256256      {
     
    303303  {
    304304    //DebugLog('Loading modules...');
    305     $this->Modules = array();
    306305    $Query = 'SELECT `Id`, `Name`,`Installed` FROM `Module`';
    307306    $DbResult = $this->Database->query($Query);
     
    492491    $Output = '';
    493492
    494     $Pageing = new Paging();
     493    $Pageing = new Paging($this->System);
    495494    $Pageing->TotalCount = count($this->System->ModuleManager->Modules);
    496     $Table = new VisualTable();
     495    $Table = new VisualTable($this->System);
    497496    $Table->SetColumns(array(
    498497      array('Name' => 'Name', 'Title' => T('Name')),
  • trunk/Packages/Common/Paging.php

    r8 r9  
    88  public string $SQLLimit;
    99  public int $Page;
     10  private System $System;
    1011
    11   function __construct()
     12  function __construct(System $System)
    1213  {
    13     global $System;
    14 
    15     $this->ItemPerPage = $System->Config['Web']['ItemsPerPage'];
    16     $this->Around = $System->Config['Web']['VisiblePagingItems'];
     14    $this->System = $System;
     15    $this->ItemPerPage = Core::Cast($this->System)->Config['Web']['ItemsPerPage'];
     16    $this->Around = Core::Cast($this->System)->Config['Web']['VisiblePagingItems'];
    1717  }
    1818
  • trunk/Packages/Common/System.php

    r8 r9  
    3939  {
    4040    if (array_key_exists($Name, $this->ModuleManager->Modules))
     41    {
    4142      return $this->ModuleManager->Modules[$Name];
    42       else return null;
     43    }
     44    else
     45    {
     46      echo('Module '.$Name.' not registered.');
     47    }
    4348  }
    4449
  • trunk/Packages/Common/Table.php

    r8 r9  
    9999  private array $OrderDirSQL;
    100100
    101   function __construct()
     101  function __construct(System $System)
    102102  {
    103     global $System;
    104 
    105103    $this->Columns = array();
    106104    $this->Table = new TableMemory();
    107105    $this->OrderDirSQL = array('ASC', 'DESC');
    108     $this->OrderArrowImage = array($System->Link('/images/sort_asc.png'),
     106    $this->OrderArrowImage = array(Core::Cast($System)->Link('/images/sort_asc.png'),
    109107      $System->Link('/images/sort_desc.png'));
    110108    $this->DefaultOrder = 0;
Note: See TracChangeset for help on using the changeset viewer.