Changeset 202 for trunk/index.php


Ignore:
Timestamp:
Apr 30, 2009, 11:30:37 PM (15 years ago)
Author:
george
Message:
  • Upraveno: Při chybně vyplněném formuláři zobraz chybové hlášení i obsah formuláře, aby nebylo nutné vše vyplňovat znovu.
  • Přidáno: Možnost povolit v konfiguraci webu formátování výstupního HTML kódu.
  • Opraveno: Validace HTML kódu generování formulářů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r197 r202  
    6868    'fun' => array('Zábava',
    6969            array('Youtube', 'http://www.youtube.com/', ''),
     70            array('Stream.cz', 'http://www.stream.cz/', ''),
    7071      array('Last.fm', 'http://www.last.fm/', ''),   
    7172    ),
     
    100101  function InfoBar()
    101102  {
    102     $this->Database->select_db('is');
     103    global $Config;
     104   
     105    $Database->select_db($Config['Database']['Database']);
    103106
    104107    $Output2 = '';
     
    197200  function GetServerUptime()
    198201  {
    199     $Data = explode(' ',exec('uptime'));
     202    $Data = explode(' ', exec('uptime'));
    200203    $Data = array_slice($Data, 3, -8);
    201204    $Uptime = '';
     
    227230      if($_GET['Action'] == 'LoginForm')
    228231      {
    229         $Output .= '<form action="?Action=Login" method="post"><center><fieldset style="width: 500px;"><legend>Přihlašovací údaje</legend>'.
    230         '<table class="hidden">'.
    231         '<tr align="left"><td colspan="2">Jméno:</td></tr>'.
    232         '<tr align="left"><td colspan="2"><input type="text" name="Username" size="40" maxlength="16" /></td></tr>'.
    233               '<tr align="left"><td colspan="2">Heslo:</td></tr>'.
    234               '<tr align="left"><td colspan="2"><input type="password" name="Password" size="40" maxlength="16" /></td></tr>'.
    235               '<tr><td colspan="2">&nbsp;</td></tr>'.
    236               '<tr align="left">'.
    237                   //<td><input type="checkbox" name="remember" value="1" checked="checked" /> Trvalé přihlášení</td>
    238                     '<td align="center" colspan="2"><input type="submit" value="Přihlásit" /></td>'.
    239               '</tr>'.
    240         '<tr align="left">'.
    241                     '<td><a href="?Action=UserRegister">Registrovat se</a></td>'.
    242                     '<td><a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></td>'.
    243               '</tr>'.
    244         '</table>'.
    245         '</fieldset></center>'.
    246         '</form>';
    247 //        $Output .= $this->SystemMessage('Test', $Output);
     232        $Form = new Form('UserLogin');
     233        $Form->OnSubmit = '?Action=Login';
     234        $Output .= $Form->ShowEditForm();
     235        $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '.
     236                    '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
    248237      } else
    249238      if($_GET['Action'] == 'Login')
    250239      {
    251         $Output .= $this->SystemMessage('Přihlášení', $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']));
     240        $Form = new Form('UserLogin');
     241        $Form->OnSubmit = '?Action=Login';
     242        $Result = $this->System->Modules['User']->Login($_POST['Username'], $_POST['Password']);
     243        $Output .= $this->SystemMessage('Přihlášení', $Result);
     244        if($Result <> USER_LOGGED_IN)
     245        {
     246          $Form->LoadValuesFromForm();
     247          $Form->Values['Password'] = '';
     248          $Output .= $Form->ShowEditForm();
     249          $Output .= '<div class="Centred"><a href="?Action=UserRegister">Registrovat se</a> '.
     250                    '<a href="?Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>';
     251        }
    252252      } else
    253253      if($_GET['Action'] == 'Logout')
     
    275275      if($_GET['Action'] == 'UserRegister')
    276276      {
    277         $UserRegister = new Form('UserRegister');
    278         $UserRegister->OnSubmit = '?Action=UserRegisterSave';
    279         $Output .= $UserRegister->ShowEditForm();
     277        $Form = new Form('UserRegister');
     278        $Form->LoadValuesFromForm();
     279        $Form->OnSubmit = '?Action=UserRegisterSave';
     280        $Output .= $Form->ShowEditForm();
    280281      } else
    281282      if($_GET['Action'] == 'UserRegisterConfirm')
    282283      {
    283           $Output .= $this->SystemMessage('Potvrzení registrace', $this->System->Modules['User']->RegisterConfirm($_GET['User'], $_GET['H']));
     284        $Output .= $this->SystemMessage('Registrace nového účtu', $this->System->Modules['User']->RegisterConfirm($_GET['User'], $_GET['H']));
    284285      } else
    285286      if($_GET['Action'] == 'PasswordRecovery')
     
    293294        $Form = new Form('PasswordRecovery');
    294295        $Form->LoadValuesFromForm();
    295 
    296         $Output .= $this->SystemMessage('Obnova hesla', $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']));
     296        $Result = $this->System->Modules['User']->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
     297        $Output .= $this->SystemMessage('Obnova hesla', $Result);
     298        if($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
     299        {
     300          $Output .= $Form->ShowEditForm();
     301        }       
    297302      } else
    298303      if($_GET['Action'] == 'PasswordRecoveryConfirm')
     
    302307      if($_GET['Action'] == 'UserRegisterSave')
    303308      {
    304         $UserRegister = new Form('UserRegister', array());
    305         $UserRegister->LoadValuesFromForm();
    306         $Output .= $this->SystemMessage('Nastavení', $this->System->Modules['User']->Register($UserRegister->Values['Login'], $UserRegister->Values['Password'], $UserRegister->Values['Password2'], $UserRegister->Values['Email'], $UserRegister->Values['Name'], $UserRegister->Values['PhoneNumber'], $UserRegister->Values['ICQ']));
     309        $Form = new Form('UserRegister', array());
     310        $Form->LoadValuesFromForm();
     311        $Result = $this->System->Modules['User']->Register($Form->Values['Login'], $Form->Values['Password'], $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name'], $Form->Values['PhoneNumber'], $Form->Values['ICQ']);
     312        $Output .= $this->SystemMessage('Nastavení', $Result);
     313        if($Result <> USER_REGISTRATED)
     314        {
     315          $Form->OnSubmit = '?Action=UserRegisterSave';
     316          $Output .= $Form->ShowEditForm();
     317        }
    307318      } else
    308319      if($_GET['Action'] == 'MemberOptions')
     
    344355    }
    345356
    346     $Database->select_db('is');
     357    $Database->select_db($Config['Database']['Database']);
    347358
    348359    //$Output .= $this->InfoBar();
Note: See TracChangeset for help on using the changeset viewer.