Changeset 578


Ignore:
Timestamp:
Oct 10, 2013, 8:50:31 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Hlavní spouštěcí kód přesunut z jednotky Global do aplikace System.
Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Global.php

    r576 r578  
    2121include_once(dirname(__FILE__).'/../FormClasses.php');
    2222
    23 function GlobalInit()
    24 {
    25   global $Config, $Database, $System, $ScriptTimeStart, $ConfigFileName, $Mail, $Type,
    26     $DatabaseRevision;
    27  
    28   date_default_timezone_set('Europe/Prague');
    29   mb_internal_encoding("UTF-8");
    30   $ScriptTimeStart = GetMicrotime();
    31  
    32   if(!isset($Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/">zde</a>.');
    33    
    34   // SQL injection hack protection
    35   foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
    36   foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
    37 
    38   if(isset($_SERVER['REMOTE_ADDR'])) session_start();
    39 
    40   $System = new System();
    41   // TODO: unset general global variable $Config after setting is loaded to objects
    42   $System->Config = &$Config;
    43   $System->Database->Connect($Config['Database']['Host'], $Config['Database']['User'],
    44     $Config['Database']['Password'], $Config['Database']['Database']);
    45   $System->Database->Prefix = $Config['Database']['Prefix'];
    46   $System->Database->charset($Config['Database']['Charset']);
    47   $System->Database->ShowSQLError = $Config['Web']['ShowSQLError'];
    48   $System->Database->ShowSQLQuery = $Config['Web']['ShowSQLQuery'];
    49   $System->RootURLFolder = $Config['Web']['RootFolder'];
    50   $System->FormManager->Root = $Config['Web']['RootFolder'];
    51  
    52   // Check database persistence structure
    53   $UpdateManager = new UpdateManager();
    54   $UpdateManager->Database = &$System->Database;
    55   $UpdateManager->Revision = $DatabaseRevision;
    56   if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze.');
    57   if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.');
    58  
    59   $Database = $System->Database;
    60   RegisterFormClasses($System->FormManager); 
    61  
    62   // Register and start existing modules
    63   include_once(dirname(__FILE__).'/../Modules/System/System.php');
    64   $System->ModuleManager->RegisterModule(new ModuleSystem($System));
    65   $System->ModuleManager->Modules['System']->Start();
    66   $System->ModuleManager->LoadModules();
    67   $System->ModuleManager->StartAll();
    68 }
    69 
    7023$MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen',
    7124        'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
     
    389342  return($PathItems);
    390343}
    391 
    392 GlobalInit();
  • trunk/Common/Page.php

    r571 r578  
    2020    $this->FormatHTML = $this->System->Config['Web']['FormatHTML'];
    2121    $this->ShowRuntimeInfo = $this->System->Config['Web']['ShowRuntimeInfo'];
     22  }
     23 
     24  function Show()
     25  {
     26        return('');
    2227  }
    2328
  • trunk/Common/System.php

    r577 r578  
    11<?php
    22
    3 class System
     3include_once(dirname(__FILE__).'/Application.php');
     4include_once(dirname(__FILE__).'/Global.php');
     5
     6class System extends Application
    47{
    58  /** @var Database */
     
    1316  var $PathItems;
    1417  var $RootURLFolder;
     18  var $ShowPage;
    1519
    1620  function __construct()
     
    2125    $this->Database = new Database();
    2226    $this->FormManager = new FormManager($this->Database);
     27    $this->ShowPage = true;
    2328  } 
    2429 
     
    8792  {
    8893    return($this->RootURLFolder.$Target);
    89   }   
     94  }
     95 
     96  function Run()
     97  {
     98        global $Config, $Database, $ScriptTimeStart, $ConfigFileName, $Mail, $Type,
     99      $DatabaseRevision;
     100 
     101    date_default_timezone_set('Europe/Prague');
     102    mb_internal_encoding("UTF-8");
     103    $ScriptTimeStart = GetMicrotime();
     104 
     105    if(!isset($Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/">zde</a>.');
     106   
     107    // SQL injection hack protection
     108    foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
     109    foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
     110
     111    if(isset($_SERVER['REMOTE_ADDR'])) session_start();
     112
     113    // TODO: unset general global variable $Config after setting is loaded to objects
     114    $this->Config = &$Config;
     115    $this->Database->Connect($Config['Database']['Host'], $Config['Database']['User'],
     116      $Config['Database']['Password'], $Config['Database']['Database']);
     117    $this->Database->Prefix = $Config['Database']['Prefix'];
     118    $this->Database->charset($Config['Database']['Charset']);
     119    $this->Database->ShowSQLError = $Config['Web']['ShowSQLError'];
     120    $this->Database->ShowSQLQuery = $Config['Web']['ShowSQLQuery'];
     121    $this->RootURLFolder = $Config['Web']['RootFolder'];
     122    $this->FormManager->Root = $Config['Web']['RootFolder'];
     123 
     124    // Check database persistence structure
     125    $UpdateManager = new UpdateManager();
     126    $UpdateManager->Database = &$this->Database;
     127    $UpdateManager->Revision = $DatabaseRevision;
     128    if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze.');
     129    if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.');
     130 
     131    $Database = $this->Database;
     132    RegisterFormClasses($this->FormManager); 
     133 
     134    // Register and start existing modules
     135    //include_once(dirname(__FILE__).'/../Modules/Setup/Setup.php');
     136    //$this->ModuleManager->RegisterModule(new ModuleSetup($this));
     137    //$this->ModuleManager->Modules['Setup']->Start();
     138    $this->ModuleManager->LoadModules();
     139    $this->ModuleManager->StartAll();
     140    if($this->ShowPage)
     141    {
     142      $this->PathItems = ProcessURL();
     143      $this->ShowPage();
     144    }   
     145  }
    90146}
  • trunk/Common/Version.php

    r577 r578  
    11<?php
    22
    3 $Revision = 577; // Subversion revision
     3$Revision = 578; // Subversion revision
    44$DatabaseRevision = 574; // SQL structure revision
    5 $ReleaseTime = '2013-10-03';
     5$ReleaseTime = '2013-10-10';
  • trunk/block/index.php

    r548 r578  
    11<?php
    22
    3 include_once('../Common/Global.php');
     3include_once('../Common/System.php');
    44
    55class BlockPage extends Page
     
    4242}
    4343
     44$System = new System();
     45$System->ShowPage = false;
     46$System->Run();
    4447$System->AddModule(new BlockPage($System));
    4548$System->Modules['BlockPage']->GetOutput();
     49
  • trunk/index.php

    r548 r578  
    11<?php
    22
    3 include_once('Common/Global.php');
    4 $System->PathItems = ProcessURL();
    5 $System->ShowPage();
     3include_once('Common/System.php');
     4
     5$System = new System();
     6$System->Run();
  • trunk/missing.php

    r548 r578  
    11<?php
    2 include_once('Common/Global.php');
     2include_once('Common/System.php');
    33
    44class MissingPage extends Page
     
    1313}
    1414
     15$System = new System();
     16$System->ShowPage = false;
     17$System->Run();
    1518$System->AddModule(new MissingPage($System));
    1619$System->Modules['MissingPage']->GetOutput();
     20
Note: See TracChangeset for help on using the changeset viewer.