source: trunk/index.php@ 22

Last change on this file since 22 was 22, checked in by george, 15 years ago
  • Přidáno: Skript pro import ze databáze centrály.
  • Přidáno: Zprovozněno přihalšování a odhlašování uživatelů, prohlížení a změna profilu.
  • Property svn:executable set to *
File size: 4.5 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/Base/System.php');
4include_once(dirname(__FILE__).'/Base/User.php');
5include_once(dirname(__FILE__).'/Base/UserOnline.php');
6include_once(dirname(__FILE__).'/Base/HTTP.php');
7include_once(dirname(__FILE__).'/Base/PrefixMultiplier.php');
8include_once(dirname(__FILE__).'/Base/URL.php');
9include_once(dirname(__FILE__).'/Base/HTML/HTML.php');
10include_once(dirname(__FILE__).'/Base/Types/Type.php');
11$ConfigFile = dirname(__FILE__).'/Configuration/Config.php';
12if(file_exists($ConfigFile)) include($ConfigFile);
13 else die('Missing configuration file "'.$ConfigFile.'"');
14include_once(dirname(__FILE__).'/CustomOutput.php');
15
16include_once(dirname(__FILE__).'/Module/User/Controller.php');
17include_once(dirname(__FILE__).'/Module/Main/Controller.php');
18include_once(dirname(__FILE__).'/Module/Network/Controller.php');
19
20class MyApplication extends Application
21{
22 var $User;
23 var $UserOnline;
24 var $HTTP;
25 var $HTML;
26 var $Output;
27 var $PrefixMultiplier;
28 var $BaseURL;
29 var $Type;
30 var $DefaultModule;
31
32 function __construct()
33 {
34 parent::__construct();
35
36 $this->HTTP = new HTTP($this);
37 $this->User = new User($this);
38 $this->UserOnline = new UserOnline($this);
39 $this->PrefixMultiplier = new PrefixMultiplier();
40 $this->Output = new CustomOutput($this);
41 $this->HTML = new HTML($this);
42 $this->BaseURL = new URL();
43
44 $this->DefaultModule = 'Main';
45 $this->BaseURL->Scheme = 'http';
46 $this->BaseURL->Host = $_SERVER['SERVER_NAME'];
47 $this->BaseURL->Path = $_SERVER['REQUEST_URI'];
48 //echo($this->BaseURL->GetString());
49 $this->Type = new Type($this);
50 /*$this->Type->RegisterType('YesNo', 'Enumeration', array('Yes', 'No'));
51 $this->Type->RegisterType('NoYes', 'Enumeration', array('No', 'Yes'));
52 $this->Type->RegisterType('TaskState', 'Enumeration', array('Waiting', 'Running', 'Finished'));
53 $this->Type->RegisterType('OnlineState', 'Enumeration', array('Offline', 'Online'));
54 $this->Type->RegisterType('EventType', 'Enumeration', array('Information', 'Warning', 'Critical'));
55 $this->Type->RegisterType('PointerToCompany', 'PointerOneToOne', array('Table' => 'Company', 'Id' => 'Id', 'Name' => 'Name'));
56 $this->Type->RegisterType('PointerToAddress', 'PointerOneToOne', array('Table' => 'Address', 'Id' => 'Id', 'Name' => 'CONCAT(Street, ", ", City)'));
57 $this->Type->RegisterType('PointerToControlCard', 'PointerOneToOne', array('Table' => 'ControlCard', 'Id' => 'Id', 'Name' => 'Name'));
58 $this->Type->RegisterType('PointerToLiftEventCode', 'PointerOneToOne', array('Table' => 'LiftEventCode', 'Id' => 'Id', 'Name' => 'Name'));
59 $this->Type->RegisterType('PointerToLiftGroup', 'PointerOneToOne', array('Table' => 'LiftGroup', 'Id' => 'Id', 'Name' => 'Name'));
60 $this->Type->RegisterType('PointerToLift', 'PointerOneToOne', array('Table' => 'Lift', 'Id' => 'Id', 'Name' => 'Name'));
61 */
62 }
63
64 function GetModuleOutput()
65 {
66 if(!array_key_exists('M', $_GET)) $_GET['M'] = $this->DefaultModule;
67 $ModuleName = $_GET['M'];
68 $ModuleName .= 'Controller';
69 if(class_exists($ModuleName))
70 {
71 $Module = new $ModuleName($this);
72 if(array_key_exists('Panel', $_GET)) $Output = $Module->Show();
73 else $Output = $this->Output->Show($Module->Show());
74 } else
75 throw new Exception('Module not found');
76 return($Output);
77 }
78
79 function Run()
80 {
81 parent::Run();
82 $this->UserOnline->Update();
83 $this->User->Id = $this->UserOnline->User;
84 $this->User->LoadData();
85 echo($this->GetModuleOutput());
86 }
87}
88
89$Application = new MyApplication();
90$Application->Database->HostName = $Config['Database']['HostName'];
91$Application->Database->UserName = $Config['Database']['UserName'];
92$Application->Database->Password = $Config['Database']['Password'];
93$Application->Database->Schema = $Config['Database']['Schema'];
94$Application->Database->ShowSQLError = $Config['Database']['ShowError'];
95$Application->Database->ShowSQLQuery = $Config['Database']['ShowQuery'];
96$Application->Output->Style = $Config['Web']['Style'];
97$Application->Output->Charset = $Config['Web']['Charset'];
98$Application->Output->FormatHTML = $Config['Web']['FormatHTML'];
99$Application->Output->Admin = $Config['Web']['Admin'];
100$Application->Output->AdminEmail = $Config['Web']['AdminEmail'];
101$Application->Output->ShowRuntimeInfo = $Config['Web']['ShowRuntimeInfo'];
102$Application->Output->GlobalTitle = $Config['Web']['Title'];
103$Application->Output->Keywords = $Config['Web']['Keywords'];
104$Application->Localization->Locale = $Config['Web']['Locale'];
105$Application->Run();
106
107?>
Note: See TracBrowser for help on using the repository browser.