1 | <?php
|
---|
2 |
|
---|
3 | include_once('global.php');
|
---|
4 |
|
---|
5 | class IndexPage extends Page
|
---|
6 | {
|
---|
7 | var $Dependencies = array('News');
|
---|
8 | var $FullTitle = '';
|
---|
9 | var $ShortTitle = '';
|
---|
10 |
|
---|
11 | function Show()
|
---|
12 | {
|
---|
13 | $FormUserLogin = array(
|
---|
14 | 'Title' => 'Přihlášení',
|
---|
15 | 'SubmitButtonText' => 'Přihlásit',
|
---|
16 | 'Items' => array(
|
---|
17 | array('Name' => 'UserName', 'Type' => TypeStringId, 'Caption' => 'Jméno', 'Value' => ''),
|
---|
18 | array('Name' => 'Password', 'Type' => TypePasswordId, 'Caption' => 'Heslo', 'Value' => ''),
|
---|
19 | ),
|
---|
20 | );
|
---|
21 | $FormUserRegister = array
|
---|
22 | (
|
---|
23 | 'Title' => 'Registrace uživatele',
|
---|
24 | 'Table' => 'User',
|
---|
25 | 'SubmitButtonText' => 'Registrovat',
|
---|
26 | 'Items' => array(
|
---|
27 | array('Name' => 'UserName', 'Type' => TypeStringId, 'Caption' => 'Přihlašovací jméno', 'Value' => ''),
|
---|
28 | array('Name' => 'Password', 'Type' => TypePasswordId, 'Caption' => 'Heslo', 'Value' => ''),
|
---|
29 | array('Name' => 'Password2', 'Type' => TypePasswordId, 'Caption' => 'Potvrzení hesla', 'Value' => ''),
|
---|
30 | array('Name' => 'Email', 'Type' => TypeStringId, 'Caption' => 'E-mail', 'Value' => ''),
|
---|
31 | array('Name' => 'FirstName', 'Type' => TypeStringId, 'Caption' => 'Křestní jméno', 'Value' => ''),
|
---|
32 | array('Name' => 'SecondName', 'Type' => TypeStringId, 'Caption' => 'Příjmení', 'Value' => ''),
|
---|
33 | ),
|
---|
34 | );
|
---|
35 |
|
---|
36 | $Output = '<table class="base"><tr><td class="menu">';
|
---|
37 | if(array_key_exists('Action', $_GET))
|
---|
38 | {
|
---|
39 | if($_GET['Action'] == 'Login')
|
---|
40 | {
|
---|
41 | $Form = new Form();
|
---|
42 | $Form->Definition = $FormUserLogin;
|
---|
43 | $Form->LoadValuesFromForm();
|
---|
44 | $Output .= $this->SystemMessage('Přihlášení', $this->System->Modules['User']->Login($Form->Values['UserName'], $Form->Values['Password']));
|
---|
45 | } else
|
---|
46 | if($_GET['Action'] == 'Logout')
|
---|
47 | {
|
---|
48 | $Output .= $this->SystemMessage('Odhlášení', $this->System->Modules['User']->Logout());
|
---|
49 | } else
|
---|
50 | if($_GET['Action'] == 'LoginForm')
|
---|
51 | {
|
---|
52 | $Form = new Form();
|
---|
53 | $Form->Definition = $FormUserLogin;
|
---|
54 | $Form->OnSubmit = '?Action=Login';
|
---|
55 | $Output .= $Form->ShowEditForm();
|
---|
56 | } else
|
---|
57 | if($_GET['Action'] == 'UserRegister')
|
---|
58 | {
|
---|
59 | $Form = new Form();
|
---|
60 | $Form->Definition = $FormUserRegister;
|
---|
61 | $Form->OnSubmit = '?Action=UserRegisterSave';
|
---|
62 | $Output .= $Form->ShowEditForm();
|
---|
63 | } else
|
---|
64 | if($_GET['Action'] == 'UserRegisterConfirm')
|
---|
65 | {
|
---|
66 | $Output .= $this->SystemMessage('Potvrzení registrace', $this->System->Modules['User']->RegisterConfirm($_GET['User'], $_GET['H']));
|
---|
67 | } else
|
---|
68 | if($_GET['Action'] == 'UserRegisterSave')
|
---|
69 | {
|
---|
70 | $Form = new Form();
|
---|
71 | $Form->Definition = $FormUserRegister;
|
---|
72 | $Form->LoadValuesFromForm();
|
---|
73 | $Output .= $this->SystemMessage('Registrace', $this->System->Modules['User']->Register($Form->Values['Name'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['FirstName'], $Form->Values['SecondName']));
|
---|
74 | }
|
---|
75 | }
|
---|
76 | if($this->System->Modules['User']->User['Id'] == 0)
|
---|
77 | {
|
---|
78 | //if(!array_key_exists('Action', $_GET))
|
---|
79 | {
|
---|
80 | $Output .= '<a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=LoginForm">Přihlášení</a><br /><a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=UserRegister">Registrace</a>';
|
---|
81 | $Form = new Form();
|
---|
82 | $Form->Definition = $FormUserLogin;
|
---|
83 | $Form->OnSubmit = '?Action=Login';
|
---|
84 | $Output .= $Form->ShowEditForm();
|
---|
85 | }
|
---|
86 | }
|
---|
87 | else
|
---|
88 | {
|
---|
89 | $Output .= $this->System->Modules['User']->User['UserName'].' <a href="'.$this->System->Config['Web']['RootFolder'].'/?Action=Logout">Odhlásit</a>';
|
---|
90 | $Output .= '<br /><br />';
|
---|
91 | $Output .= ShowMenu();
|
---|
92 | $Output .= '</td><td class="main">';
|
---|
93 | $Output .= Output();
|
---|
94 | $Output .= '</td></tr></table></body></html>';
|
---|
95 | }
|
---|
96 | return($Output);
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | $System->AddModule(new IndexPage());
|
---|
101 | $System->Modules['IndexPage']->GetOutput();
|
---|
102 | //var_dump(get_defined_vars());
|
---|
103 | //print_r($_GLOBAL);
|
---|
104 |
|
---|
105 | ?>
|
---|