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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.