Changeset 42 for trunk/index.php


Ignore:
Timestamp:
Nov 24, 2009, 9:13:38 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Přepracován základový webový systém
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r40 r42  
    11<?php
    22
    3 include('Include.php');
    4 if(array_key_exists('argv', $_SERVER))
    5   $_GET = array_merge($_GET, ParseCommandLineArgs($_SERVER['argv']));
     3// Change current directory to script location
     4$BaseDir = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/'));
     5if($BaseDir != '') chdir($BaseDir);
    66
    7 // SQL injection hack protection
    8 foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);
    9 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);
     7include_once(dirname(__FILE__).'/Application/Application.php');
    108
    11 if(isset($_SERVER['REMOTE_ADDR'])) session_start();
    12 
    13 $System = new System();
    14 $ScriptTimeStart = $System->GetMicrotime();
    15 $System->Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
    16 $System->Database->Prefix = $Config['Database']['Prefix'];
    17 $System->Database->charset($Config['Database']['Charset']);
    18 $System->Config = $Config;
    19 $System->AddModule(new Log($System));
    20 $System->AddModule(new User($System));
    21 $System->AddModule(new Permission($System));
    22 if(isset($_SERVER['REMOTE_ADDR'])) $System->Modules['User']->Check();
    23   else $System->Modules['User']->Data['Id'] = $Config['Web']['UserConsoleId'];
    24 $System->Modules['Permission']->LoadForUser($System->Modules['User']->Data['Id']);
    25 //print_r($System->Modules['Permission']->Data);
    26 
    27 if(array_key_exists('Module', $_GET)) $Module = $_GET['Module'];
    28   else $Module = 'HomePage';
    29 if(array_key_exists('Action', $_GET)) $Action = $_GET['Action'];
    30   else $Action = 'Show';
    31 
    32 $ControllerName = $Module.'Controller';
    33 if(class_exists($ControllerName))
    34 {
    35   $Controller = new $ControllerName($System);
    36   if(method_exists($Controller, $Action)) $Output = $Controller->$Action();
    37     else $Output = 'Metoda '.$Action.' modulu '.$Module.' neexistuje.';
    38 } else $Output = 'Třída '.$ControllerName.' neexistuje.';
    39 
    40 echo($Output);
     9$Application = new Application();
     10$Application->Run();
    4111
    4212?>
Note: See TracChangeset for help on using the changeset viewer.