Name = 'FrontPage'; $this->Version = '1.0'; $this->Creator = 'Chronos'; $this->License = 'GNU/GPL'; $this->Description = 'Main welcome page'; $this->Dependencies = array('News', 'User', 'ShoutBox', 'Translation', 'Log', 'Forum'); } function DoStart(): void { $this->System->RegisterPage([''], 'PageFrontPage'); Core::Cast($this->System)->RegisterMenuItem(array( 'Title' => T('Home'), 'Hint' => T('Main page'), 'Link' => $this->System->Link('/'), 'Permission' => LICENCE_ANONYMOUS, 'Icon' => '', ), 0); } function HandleLoginForm() { $User = ModuleUser::Cast($this->System->GetModule('User'))->User; global $Message, $MessageType; if (array_key_exists('action', $_GET)) { if ($_GET['action'] == 'login') { if (array_key_exists('LoginUser', $_POST) and array_key_exists('LoginPass', $_POST)) { if (array_key_exists('StayLogged', $_POST)) $StayLogged = true; else $StayLogged = false; $User->Login($_POST['LoginUser'], $_POST['LoginPass'], $StayLogged); if ($User->Role == LICENCE_ANONYMOUS) { $Message = T('Incorrect name or password'); $MessageType = MESSAGE_CRITICAL; } else { $Message = sprintf(T('Login successful. Welcome %s!'), $User->Name); $MessageType = MESSAGE_INFORMATION; } } else { $Message = T('User name or password was not entered'); $MessageType = MESSAGE_CRITICAL; } } else if ($_GET['action'] == 'logout') { if ($User->Role != LICENCE_ANONYMOUS) { ModuleLog::Cast($this->System->GetModule('Log'))->WriteLog('Odhlášení', LOG_TYPE_USER); $User->Logout(); $Message = T('You were logged out'); $MessageType = MESSAGE_INFORMATION; } } } } } class PageFrontPage extends Page { function Show(): string { global $Message, $MessageType; $this->Title = T('Home'); $this->System->ModuleManager->Modules['FrontPage']->HandleLoginForm(); $Output = ''; if (isset($Message)) $Output .= ShowMessage($Message, $MessageType); $Output .= ''. '
'.$this->ShowWelcome(). '
'; $Output .= '

'.T('Download files').'

'; $Output .= '
'.$this->System->ModuleManager->Modules['News']->ShowBox().'
'. '
'.$this->System->ModuleManager->Modules['ShoutBox']->ShowBox().'
'. '
'.$this->System->ModuleManager->Modules['Forum']->ShowBox().'
'. '
'.$this->System->ModuleManager->Modules['Translation']->ShowBox().'
'; return $Output; } function ShowWelcome() { // Cookies have to be used before any text is sent to output if (!array_key_exists('HideWelcome', $_COOKIE)) $_COOKIE['HideWelcome'] = 0; if (isset($_GET['Action'])) { if ($_GET['Action'] == 'HideWelcome') { $_COOKIE['HideWelcome'] = 1; setcookie('HideWelcome', $_COOKIE['HideWelcome'], time() + 3600 * 24 * 365); } if ($_GET['Action'] == 'UnHideWelcome') { $_COOKIE['HideWelcome'] = 0; setcookie('HideWelcome', $_COOKIE['HideWelcome'], time() + 3600 * 24 * 365); } } if (isset($_COOKIE['HideWelcome']) and ($_COOKIE['HideWelcome'] == 1)) { $Action = ''.T('Show welcome').''; $HideWelcome = 'display: none'; } else { $Action = ''.T('Hide welcome').''; $HideWelcome = ''; } // Echo text even if it is hidden because of caching by external searching engines return '
'. '
'.Core::Cast($this->System)->Config['Web']['Title'].'
'. T('Open web system for translation texts from game World of Warcraft (WoW).
'. '').'
'.$Action; } }