1 | <?php
|
---|
2 |
|
---|
3 | include_once('Database.php');
|
---|
4 | include_once('Application.php');
|
---|
5 |
|
---|
6 | class System extends Application
|
---|
7 | {
|
---|
8 | var $Database;
|
---|
9 | var $Config;
|
---|
10 | var $ModuleManager;
|
---|
11 | var $PathItems;
|
---|
12 | var $Menu;
|
---|
13 | var $DoNotShowPage;
|
---|
14 |
|
---|
15 | function __construct()
|
---|
16 | {
|
---|
17 | $this->Config = array();
|
---|
18 | $this->Menu = array();
|
---|
19 | $this->RSSChannels = array();
|
---|
20 | $this->DoNotShowPage = false;
|
---|
21 | }
|
---|
22 |
|
---|
23 | function Init()
|
---|
24 | {
|
---|
25 | global $Config, $LocaleManager;
|
---|
26 |
|
---|
27 | $this->Config = $Config;
|
---|
28 | $this->Database = new Database();
|
---|
29 | $this->Database->Connect($this->Config['Database']['Host'],
|
---|
30 | $this->Config['Database']['User'], $this->Config['Database']['Password'],
|
---|
31 | $this->Config['Database']['Database']);
|
---|
32 | $this->Database->charset($this->Config['Database']['Charset']);
|
---|
33 | $this->Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery'];
|
---|
34 | $this->Database->ShowSQLError = $this->Config['Web']['ShowSQLError'];
|
---|
35 | $this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery'];
|
---|
36 | $this->ModuleManager = new AppModuleManager();
|
---|
37 |
|
---|
38 | $this->PathItems = ProcessURL();
|
---|
39 | // Initialize locale
|
---|
40 | $LocaleManager = new LocaleManager($this);
|
---|
41 | $LocaleManager->Dir = dirname(dirname(__FILE__)).'/locale';
|
---|
42 | $LocaleManager->Available = array(
|
---|
43 | 'cs' => array('Code' => 'cs', 'Title' => 'Česky'),
|
---|
44 | 'en' => array('Code' => 'en', 'Title' => 'English'),
|
---|
45 | );
|
---|
46 | $Code = $Config['Web']['Locale'];
|
---|
47 | if (isset($_SESSION))
|
---|
48 | if(array_key_exists('Locale', $_SESSION)) $Code = $_SESSION['Locale'];
|
---|
49 | if (isset($_GET))
|
---|
50 | if(array_key_exists('locale', $_GET)) $Code = $_GET['locale'];
|
---|
51 |
|
---|
52 | //echo(phpinfo());
|
---|
53 | if(!array_key_exists($Code, $LocaleManager->Available)) $Code = 'en';
|
---|
54 | $_SESSION['Locale'] = $Code;
|
---|
55 | $LocaleManager->LoadLocale($Code);
|
---|
56 |
|
---|
57 | $this->Menu = array
|
---|
58 | (
|
---|
59 | /* array(
|
---|
60 | 'Title' => T('Files'),
|
---|
61 | 'Hint' => 'Stahování různých pomocných souborů a programů',
|
---|
62 | 'Link' => $this->Link('/download.php'),
|
---|
63 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
64 | 'Icon' => '',
|
---|
65 | ),
|
---|
66 | */
|
---|
67 | array(
|
---|
68 | 'Title' => T('Instructions'),
|
---|
69 | 'Hint' => 'Informace k překladu hry',
|
---|
70 | 'Link' => $this->Link('/info.php'),
|
---|
71 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
72 | 'Icon' => '',
|
---|
73 | ),
|
---|
74 | array(
|
---|
75 | 'Title' => T('Data source'),
|
---|
76 | 'Hint' => 'Informace o překladových skupinách',
|
---|
77 | 'Link' => $this->Link('/TranslationList.php?action=grouplist'),
|
---|
78 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
79 | 'Icon' => '',
|
---|
80 | ),
|
---|
81 | array(
|
---|
82 | 'Title' => T('Presentation'),
|
---|
83 | 'Hint' => 'Prezentace a motivace překladu',
|
---|
84 | 'Link' => $this->Link('/promotion.php'),
|
---|
85 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
86 | 'Icon' => '',
|
---|
87 | ),
|
---|
88 | array(
|
---|
89 | 'Title' => T('IRC chat'),
|
---|
90 | 'Hint' => 'IRC chat pro překladatele',
|
---|
91 | 'Link' => 'http://embed.mibbit.com/?server=game.zdechov.net%3A6667&channel=%23wowpreklad&forcePrompt=true&charset=utf-8',
|
---|
92 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
93 | 'Icon' => '',
|
---|
94 | ),
|
---|
95 | array(
|
---|
96 | 'Title' => T('Administration'),
|
---|
97 | 'Hint' => 'Volby pro správu',
|
---|
98 | 'Link' => $this->Link('/admin/'),
|
---|
99 | 'Permission' => LICENCE_ADMIN,
|
---|
100 | 'Icon' => '',
|
---|
101 | ),
|
---|
102 | );
|
---|
103 | }
|
---|
104 |
|
---|
105 | function Run()
|
---|
106 | {
|
---|
107 | global $System, $ScriptStartTime, $TranslationTree, $User, $StopAfterUpdateManager,
|
---|
108 | $UpdateManager, $Config, $DatabaseRevision;
|
---|
109 |
|
---|
110 | $ScriptStartTime = GetMicrotime();
|
---|
111 |
|
---|
112 | if(GetRemoteAddress() != '') session_start();
|
---|
113 |
|
---|
114 | if(!isset($Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/install.php">zde</a>.');
|
---|
115 | date_default_timezone_set($Config['Web']['Timezone']);
|
---|
116 |
|
---|
117 | $this->Init();
|
---|
118 |
|
---|
119 | // Check database persistence structure
|
---|
120 | $UpdateManager = new UpdateManager();
|
---|
121 | $UpdateManager->Database = $this->Database;
|
---|
122 | $UpdateManager->Revision = $DatabaseRevision;
|
---|
123 | if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze.');
|
---|
124 | if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.');
|
---|
125 |
|
---|
126 | // SQL injection hack protection
|
---|
127 | foreach($_POST as $Index => $Item)
|
---|
128 | {
|
---|
129 | if(is_array($_POST[$Index]))
|
---|
130 | foreach($_POST[$Index] as $Index2 => $Item2) $_POST[$Index][$Index2] = addslashes($Item2);
|
---|
131 | else $_POST[$Index] = addslashes($_POST[$Index]);
|
---|
132 | }
|
---|
133 | foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);
|
---|
134 |
|
---|
135 | // TODO: Global initialized variable should be removed
|
---|
136 | $TranslationTree = GetTranslationTree();
|
---|
137 |
|
---|
138 | // Initialize application modules
|
---|
139 | $this->ModuleManager->RegisterModule(new ModuleError($System));
|
---|
140 | $this->ModuleManager->Modules['Error']->ShowError = $Config['Web']['ShowPHPError'];
|
---|
141 | $this->ModuleManager->RegisterModule(new ModuleLog($System));
|
---|
142 | $this->ModuleManager->RegisterModule(new ModuleUser($System));
|
---|
143 | $this->ModuleManager->RegisterModule(new ModuleAoWoW($System));
|
---|
144 | $this->ModuleManager->RegisterModule(new ModuleReferrer($System));
|
---|
145 | $this->ModuleManager->Modules['Referrer']->Excludes[] = $System->Config['Web']['Host'];
|
---|
146 | $this->ModuleManager->RegisterModule(new ModuleTeam($System));
|
---|
147 | $this->ModuleManager->RegisterModule(new ModuleDictionary($System));
|
---|
148 | $this->ModuleManager->RegisterModule(new ModuleTranslation($System));
|
---|
149 | $this->ModuleManager->RegisterModule(new ModuleImport($System));
|
---|
150 | $this->ModuleManager->RegisterModule(new ModuleExport($System));
|
---|
151 | $this->ModuleManager->RegisterModule(new ModuleServer($System));
|
---|
152 | $this->ModuleManager->RegisterModule(new ModuleClientVersion($System));
|
---|
153 | $this->ModuleManager->RegisterModule(new ModuleShoutBox($System));
|
---|
154 | $this->ModuleManager->RegisterModule(new ModuleNews($System));
|
---|
155 | $this->ModuleManager->RegisterModule(new ModuleWiki($System));
|
---|
156 | $this->ModuleManager->RegisterModule(new ModuleSearch($System));
|
---|
157 | $this->ModuleManager->RegisterModule(new ModuleFrontPage($System));
|
---|
158 | $this->ModuleManager->RegisterModule(new ModuleDownload($System));
|
---|
159 | $this->ModuleManager->RegisterModule(new ModuleForum($System));
|
---|
160 | $this->ModuleManager->RegisterModule(new ModuleRedirection($System));
|
---|
161 | $this->ModuleManager->StartAll();
|
---|
162 |
|
---|
163 | $this->BaseView = new BaseView($this);
|
---|
164 | if($this->DoNotShowPage == false)
|
---|
165 | {
|
---|
166 | $this->ShowPage();
|
---|
167 | }
|
---|
168 | }
|
---|
169 |
|
---|
170 | function GetMicrotime()
|
---|
171 | {
|
---|
172 | list($Usec, $Sec) = explode(' ', microtime());
|
---|
173 | return ((float)$Usec + (float)$Sec);
|
---|
174 | }
|
---|
175 |
|
---|
176 | function Link($Target)
|
---|
177 | {
|
---|
178 | return($this->Config['Web']['BaseURL'].$Target);
|
---|
179 | }
|
---|
180 |
|
---|
181 | function RegisterPage($Path, $Handler)
|
---|
182 | {
|
---|
183 | if(is_array($Path))
|
---|
184 | {
|
---|
185 | $Page = &$this->Pages;
|
---|
186 | $LastKey = array_pop($Path);
|
---|
187 | foreach($Path as $PathItem)
|
---|
188 | {
|
---|
189 | $Page = &$Page[$PathItem];
|
---|
190 | }
|
---|
191 | if(!is_array($Page)) $Page = array('' => $Page);
|
---|
192 | $Page[$LastKey] = $Handler;
|
---|
193 | } else $this->Pages[$Path] = $Handler;
|
---|
194 | }
|
---|
195 |
|
---|
196 | function RegisterMenuItem($MenuItem, $Pos = NULL)
|
---|
197 | {
|
---|
198 | if(is_null($Pos)) $this->Menu[] = $MenuItem;
|
---|
199 | else {
|
---|
200 | array_splice($this->Menu, $Pos, 0, array($MenuItem));
|
---|
201 | }
|
---|
202 | }
|
---|
203 |
|
---|
204 | function SearchPage($PathItems, $Pages)
|
---|
205 | {
|
---|
206 | if(count($PathItems) == 0) $PathItems = array('');
|
---|
207 | $PathItem = $PathItems[0];
|
---|
208 | if(array_key_exists($PathItem, $Pages))
|
---|
209 | {
|
---|
210 | if(is_array($Pages[$PathItem]))
|
---|
211 | {
|
---|
212 | array_shift($PathItems);
|
---|
213 | return($this->SearchPage($PathItems, $Pages[$PathItem]));
|
---|
214 | } else
|
---|
215 | {
|
---|
216 | if(count($PathItems) == 1) return($Pages[$PathItem]);
|
---|
217 | else return(''); // Unexpected subpages
|
---|
218 | }
|
---|
219 | } else return('');
|
---|
220 | }
|
---|
221 |
|
---|
222 | function PageNotFound()
|
---|
223 | {
|
---|
224 | // Send correct HTTP status code to signal unknown page
|
---|
225 | if(array_key_exists('SERVER_PROTOCOL', $_SERVER))
|
---|
226 | Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
---|
227 | if(array_key_exists('HTTP_REFERER', $_SERVER)) $Referer = ' Referer: '.$_SERVER['HTTP_REFERER'];
|
---|
228 | else $Referer = '';
|
---|
229 | if(isset($this->ModuleManager->Modules['Log']))
|
---|
230 | $this->ModuleManager->Modules['Log']->WriteLog('Stránka "'.
|
---|
231 | implode('/', $this->PathItems).'" nenalezena'.$Referer, LOG_TYPE_PAGE_NOT_FOUND);
|
---|
232 | return(ShowMessage(sprintf(T('Page "%s" not found'), implode('/', $this->PathItems)), MESSAGE_CRITICAL));
|
---|
233 | }
|
---|
234 |
|
---|
235 | function ShowPage()
|
---|
236 | {
|
---|
237 | $Output = '';
|
---|
238 | /* @var $Page Page */
|
---|
239 | $ClassName = $this->SearchPage($this->PathItems, $this->Pages);
|
---|
240 | if(($ClassName != '') and (class_exists($ClassName)))
|
---|
241 | {
|
---|
242 | $Page = new $ClassName($this);
|
---|
243 | $Output = $Page->GetOutput();
|
---|
244 | $this->BaseView->Title = $Page->Title;
|
---|
245 | if($Page->RawPage == false) $Output = $this->BaseView->ShowPage($Output);
|
---|
246 | } else {
|
---|
247 | $Output = $this->PageNotFound();
|
---|
248 | $this->BaseView->Title = T('Page not found');
|
---|
249 | $Output = $this->BaseView->ShowPage($Output);
|
---|
250 | }
|
---|
251 | echo($Output);
|
---|
252 | }
|
---|
253 | }
|
---|
254 |
|
---|
255 | class BaseView extends View
|
---|
256 | {
|
---|
257 | var $Title;
|
---|
258 |
|
---|
259 | function ShowTopBar()
|
---|
260 | {
|
---|
261 | global $LocaleManager;
|
---|
262 |
|
---|
263 | $Output = '<div class="Menu">';
|
---|
264 | if(!$this->System->User->Licence(LICENCE_USER))
|
---|
265 | $Output .= '<div class="advert">'.$this->System->Config['Web']['Advertisement'].'</div>';
|
---|
266 | $Output .= '<span class="MenuItem"></span><span class="MenuItem2">';
|
---|
267 | if($this->System->User->Licence(LICENCE_USER))
|
---|
268 | {
|
---|
269 | //$DbResult = $System->Database->query('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$this->System->User->Team);
|
---|
270 | //$Team = $DbResult->fetch_assoc();
|
---|
271 | //$Output .= ''<span class="MenuItem">Moje překlady: <a href="">Dokončené</a> <a href="">Rozpracované</a> <a href="">Exporty</a> Tým: <a href="">'.$Team['name'].'</a></span>';
|
---|
272 | $Output .= $this->System->User->Name.' <a href="'.$this->System->Link('/?action=logout').'">'.T('Logout').'</a>'.
|
---|
273 | ' <a href="'.$this->System->Link('/user.php?user='.$this->System->User->Id).'">'.T('My page').'</a>'.
|
---|
274 | ' <a href="'.$this->System->Link('/Options.php').'">'.T('Options').'</a>'.
|
---|
275 | ' <a title="Vámi přeložené texty" href="'.$this->System->Link('/TranslationList.php?user='.
|
---|
276 | $this->System->User->Id.'&group=0&state=2&text=&entry=').'">'.T('Translated').'</a>'.
|
---|
277 | ' <a title="Vaše rozpracované text" href="'.$this->System->Link('/TranslationList.php?user='.
|
---|
278 | $this->System->User->Id.'&group=0&state=3&text=&entry=').'">'.T('Unfinished').'</a>'.
|
---|
279 | ' <a title="Nikým nepřeložené texty" href="'.
|
---|
280 | $this->System->Link('/TranslationList.php?user=0&group=0&state=1&text=&entry=').'">'.T('Untranslated').'</a>';
|
---|
281 | } else
|
---|
282 | {
|
---|
283 | $Output .= '<a href="'.$this->System->Link('/login/').'">'.T('Login').'</a> '.
|
---|
284 | '<a href="'.$this->System->Link('/registrace.php').'">'.T('Registration').'</a>';
|
---|
285 | }
|
---|
286 | $Output .= ' <form action="?setlocale" method="get">';
|
---|
287 | $Output .= '<select onchange="window.location=\'?locale=\'+this.value">';
|
---|
288 | foreach($LocaleManager->Available as $Locale)
|
---|
289 | {
|
---|
290 | if($Locale['Code'] == $LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"';
|
---|
291 | else $Selected = '';
|
---|
292 | $Output .= '<option title="" value="'.$Locale['Code'].'"'.$Selected.' onchange="this.form.submit()">'.$Locale['Title'].'</option>';
|
---|
293 | }
|
---|
294 | $Output .= '</select><noscript><input type="submit" value="Submit"/></noscript></form>';
|
---|
295 | $Output .= '</span></div>';
|
---|
296 | return($Output);
|
---|
297 | }
|
---|
298 |
|
---|
299 | function ShowLoginBox()
|
---|
300 | {
|
---|
301 | $Output = '';
|
---|
302 | if($this->System->User->Licence(LICENCE_USER))
|
---|
303 | {
|
---|
304 | // $Output .= 'Jste přihlášen jako: <b>'.$tUser->Id.'</b> <a href="index.php?Logout">Odhlásit</a>';
|
---|
305 | } else
|
---|
306 | {
|
---|
307 | $Output .= '<strong>'.T('Login').':</strong>
|
---|
308 | <form action="" method="post">
|
---|
309 | <table>
|
---|
310 | <tr>
|
---|
311 | <td><input type="text" name="LoginUser" size="13" /></td>
|
---|
312 | </tr>
|
---|
313 | <tr>
|
---|
314 | <td><input type="password" name="LoginPass" size="13" /></td>
|
---|
315 | </tr>
|
---|
316 | <tr>
|
---|
317 | <th><input type="submit" value="'.T('Do login').'" /></th>
|
---|
318 | </tr>
|
---|
319 | </table>
|
---|
320 | </form>';
|
---|
321 | }
|
---|
322 | return($Output);
|
---|
323 | }
|
---|
324 |
|
---|
325 | function ShowSearchBox()
|
---|
326 | {
|
---|
327 | $Output = '<strong>'.T('Search').':</strong>'.
|
---|
328 | '<form action="'.$this->System->Link('/search/').'" method="get"><div>'.
|
---|
329 | '<table>'.
|
---|
330 | '<tr>'.
|
---|
331 | '<td><input type="text" name="text" size="13" /></td>'.
|
---|
332 | '</tr>'.
|
---|
333 | '<tr>'.
|
---|
334 | '<th><input type="submit" value="'.T('Do search').'" /></th>'.
|
---|
335 | '</tr>'.
|
---|
336 | '</table></div>'.
|
---|
337 | '</form>';
|
---|
338 | return($Output);
|
---|
339 | }
|
---|
340 |
|
---|
341 | function ShowMainMenu()
|
---|
342 | {
|
---|
343 | $Output = '<strong>'.T('Menu').':</strong>'.
|
---|
344 | '<div class="verticalmenu"><ul>';
|
---|
345 | foreach($this->System->Menu as $MenuItem)
|
---|
346 | if($this->System->User->Licence($MenuItem['Permission']))
|
---|
347 | {
|
---|
348 | if(isset($MenuItem['Click'])) $OnClick = ' onclick="'.$MenuItem['Click'].'"';
|
---|
349 | else $OnClick = '';
|
---|
350 | if($MenuItem['Icon'] != '') $Icon = '<img src="'.$this->System->Link('/images/menu/'.$MenuItem['Icon']).'"/>';
|
---|
351 | else $Icon = '';
|
---|
352 | $Output .= '<li>'.$Icon.'<a class="verticalmenua" title="'.$MenuItem['Hint'].'" href="'.
|
---|
353 | $MenuItem['Link'].'"'.$OnClick.'>'.$MenuItem['Title'].'</a></li>';
|
---|
354 | }
|
---|
355 | $Output .= '</ul></div>';
|
---|
356 | return($Output);
|
---|
357 | }
|
---|
358 |
|
---|
359 | function ShowTranslatedMenu()
|
---|
360 | {
|
---|
361 | global $TranslationTree;
|
---|
362 |
|
---|
363 | $Output = '<strong>'.T('Translate groups').':</strong><br /><div id="TranslationMenu">';
|
---|
364 | $DbResult = $this->System->Database->select('Group', '`Id`, `Name`', '1 ORDER BY `Name`');
|
---|
365 | while($Group = $DbResult->fetch_assoc())
|
---|
366 | {
|
---|
367 | $Output .= '<div id="menuitem-group'.$Group['Id'].'" onmouseover="show(\'group'.$Group['Id'].'\')" onmouseout="hide(\'group'.$Group['Id'].'\')">'.
|
---|
368 | '<a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&action=filter').'">'.str_replace(' ',' ',$Group['Name']).'</a></div>'.
|
---|
369 | '<div id="group'.$Group['Id'].'" class="hidden-menu-item" onmouseover="show(\'group'.$Group['Id'].'\')" onmouseout="hide(\'group'.$Group['Id'].'\')">';
|
---|
370 | $Output .= ' <a title="Zde můžete začít překládat" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=1&user=0&entry=&text=').'">Nepřeložené</a><br />'.
|
---|
371 | ' <a title="Přeložené texty, můžete zde hlasovat, nebo opravovat překlady" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=2&user=0&entry=&text=').'">Přeložené</a><br />';
|
---|
372 | if($this->System->User->Licence(LICENCE_USER))
|
---|
373 | {
|
---|
374 | $Output .= ' <a title="Nedokončené překlady" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=3').'">Rozepsané</a><br />
|
---|
375 | <a title="Všechny překlady, které jste přeložil" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=1&user='.$this->System->User->Id).'&entry=&text=">Vlastní</a><br />';
|
---|
376 | }
|
---|
377 | $Output .= ' <a title="Sestavit speciální filtr" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&action=filter').'">Filtr</a><br />';
|
---|
378 | $Output .= '</div>';
|
---|
379 | }
|
---|
380 | $Output .= '</div>';
|
---|
381 | return($Output);
|
---|
382 | }
|
---|
383 |
|
---|
384 | function ShowHeader()
|
---|
385 | {
|
---|
386 | $Output = '<?xml version="1.0" encoding="'.$this->System->Config['Web']['Charset'].'"?>'.
|
---|
387 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'.
|
---|
388 | '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cz">'.
|
---|
389 | '<head>'.
|
---|
390 | '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->System->Config['Web']['Charset'].'" />'.
|
---|
391 | '<meta name="keywords" content="wow, quest, questy, questů, preklad, mangos, překlad, překládání, přeložený, přeložení, čeština, world of warcraft, open source, free, addon" />'.
|
---|
392 | '<meta name="description" content="'.$this->System->Config['Web']['Description'].'" />'.
|
---|
393 | '<meta name="robots" content="all" />'.
|
---|
394 | '<link rel="stylesheet" href="'.$this->System->Link('/style/style.css').'" type="text/css" media="all" />'.
|
---|
395 | '<script type="text/javascript" src="'.$this->System->Link('/style/global.js').'"></script>'.
|
---|
396 | '<link rel="shortcut icon" href="'.$this->System->Link('/images/favicon.ico').'" />';
|
---|
397 | $Output .= $this->System->ModuleManager->Modules['News']->ShowRSSHeader();
|
---|
398 | $Title = $this->System->Config['Web']['Title'];
|
---|
399 | if($this->Title != '') $Title = $this->Title.' - '.$Title;
|
---|
400 | $Output .= '<title>'.$Title.'</title>'.
|
---|
401 | '</head><body>';
|
---|
402 |
|
---|
403 | $Output .= $this->ShowTopBar();
|
---|
404 | $Output .= '<table class="page"><tr><td class="menu">';
|
---|
405 | $Output .= $this->ShowMainMenu();
|
---|
406 | $Output .= $this->System->ModuleManager->Modules['User']->ShowOnlineList();
|
---|
407 | $Output .= '<br />';
|
---|
408 | $Output .= $this->ShowSearchBox();
|
---|
409 |
|
---|
410 | $Output .= '</td><td id="border-left"></td><td class="content">';
|
---|
411 | return($Output);
|
---|
412 | }
|
---|
413 |
|
---|
414 | function ShowFooter()
|
---|
415 | {
|
---|
416 | global $ScriptStartTime, $Revision, $ReleaseTime;
|
---|
417 |
|
---|
418 | $ScriptGenerateDuration = round(GetMicrotime() - $ScriptStartTime, 2);
|
---|
419 |
|
---|
420 | $Output = '</td>'.
|
---|
421 | '<td class="menu2">';
|
---|
422 | $Output .= $this->ShowTranslatedMenu();
|
---|
423 | $Output .= '</td>'.
|
---|
424 | '</tr><tr>'.
|
---|
425 | '<td colspan="4" class="page-bottom">'.T('Version').': '.$Revision.' ('.HumanDate($ReleaseTime).')'.
|
---|
426 | ' <a href="http://svn.zdechov.net/trac/wowpreklad/browser/trunk">'.T('Source code').'</a> '.
|
---|
427 | '<a href="http://svn.zdechov.net/trac/wowpreklad/log/trunk?verbose=on">'.T('Changelog').'</a> '.
|
---|
428 | $this->System->Config['Web']['WebCounter'];
|
---|
429 |
|
---|
430 | $Output .= '</td></tr>';
|
---|
431 | if($this->System->Config['Web']['ShowRuntimeInfo'] == true)
|
---|
432 | $Output .= '<tr><td colspan="3" style="text-align: center;">'.T('Generating duration').': '.
|
---|
433 | $ScriptGenerateDuration.' s / '.ini_get('max_execution_time').' s '.T('Used memory').': '.
|
---|
434 | HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B <a href="http://validator.w3.org/check?uri='.
|
---|
435 | htmlentities('http://'.$_SERVER['HTTP_HOST'].GetRequestURI().'?'.$_SERVER['QUERY_STRING']).'">HTML validator</a></td></tr>';
|
---|
436 | $Output .= '</table>'.
|
---|
437 | '</body>'.
|
---|
438 | '</html>';
|
---|
439 | return($Output);
|
---|
440 | }
|
---|
441 |
|
---|
442 | function ShowPage($Content)
|
---|
443 | {
|
---|
444 | $Output = $this->ShowHeader().$Content.$this->ShowFooter();
|
---|
445 | //if($this->System->Config['Web']['FormatOutput']) $Output = $this->FormatOutput($Output);
|
---|
446 | return($Output);
|
---|
447 | }
|
---|
448 |
|
---|
449 | function FormatOutput($s)
|
---|
450 | {
|
---|
451 | $out = '';
|
---|
452 | $nn = 0;
|
---|
453 | $n = 0;
|
---|
454 | while($s != '')
|
---|
455 | {
|
---|
456 | $start = strpos($s, '<');
|
---|
457 | $end = strpos($s, '>');
|
---|
458 | if($start != 0)
|
---|
459 | {
|
---|
460 | $end = $start - 1;
|
---|
461 | $start = 0;
|
---|
462 | }
|
---|
463 | $line = trim(substr($s, $start, $end + 1));
|
---|
464 | if(strlen($line) > 0)
|
---|
465 | if($line[0] == '<')
|
---|
466 | {
|
---|
467 | if($s[$start + 1] == '/')
|
---|
468 | {
|
---|
469 | $n = $n - 2;
|
---|
470 | $nn = $n;
|
---|
471 | } else
|
---|
472 | {
|
---|
473 | if(strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1);
|
---|
474 | else $cmd = substr($line, 1, strlen($line) - 2);
|
---|
475 | //echo('['.$cmd.']');
|
---|
476 | if(strpos($s, '</'.$cmd.'>')) $n = $n + 2;
|
---|
477 | }
|
---|
478 | }// else $line = '['.$line.']';
|
---|
479 | //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
|
---|
480 | if($line != '') $out .= (str_repeat(' ', $nn).$line."\n");
|
---|
481 | $s = substr($s, $end + 1, strlen($s));
|
---|
482 | $nn = $n;
|
---|
483 | }
|
---|
484 | return($out);
|
---|
485 | }
|
---|
486 | }
|
---|