Changeset 28 for branches


Ignore:
Timestamp:
Oct 13, 2008, 8:01:02 PM (16 years ago)
Author:
maron
Message:

Přihlášení

Location:
branches/3
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/3

    • Property svn:ignore set to
      config.php
  • branches/3/class/database.php

    r27 r28  
    1919  {
    2020    $this->LastQuery = "SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition;
    21     $count = $this->query($this->LastQuery);
    22     $count = $count->fetch_array();
    23     $this->Last_num_rows = count($count);
    2421    return($this->query($this->LastQuery)); 
    2522  }
  • branches/3/class/user.php

    r27 r28  
    44  { // BEGIN class User
    55        // variables
    6         var $ID,$Permission, $user,$Database;
     6        var $ID,$user,$Database;
    77          var $AnonymousUserId = 1;
    8         var $DefaultRole = 1;
     8        var $DefaultRole = 2;
    99        var $IPAddress = ' ';
    1010 
     
    4646      $this->user = $Query->fetch_array();
    4747      $Result = USER_NOT_LOGGED;
     48      $this->LoadPermission(1);
    4849    }   
    4950    return $Result;
    5051  }
    5152
    52   function Register($Date)
     53  function Register($Data)
    5354  {
    5455    global $Options;
    55     if(($Date['Email'] == '') || ($Date['Nick'] == '') || ($Date['Password'] == '') || ($Date['Password2'] == '')) $Result = DATA_MISSING;
    56     else if($Date['Password'] != $Date['Password2']) $Result = PASSWORDS_UNMATCHED;
     56    if(($Data['Email'] == '') || ($Data['Nick'] == '') || ($Data['Password'] == '') || ($Data['Password2'] == '')) $Result = DATA_MISSING;
     57    else if($Data['Password'] != $Data['Password2']) $Result = PASSWORDS_UNMATCHED;
    5758    else
    5859    {
    5960      // Je uživatel registrován?
    60       $Query = $this->Database->select('User', '*', 'Name = "'.$Date['Nick'].'"');
     61      $Query = $this->Database->select('User', '*', 'Name = "'.$Data['Nick'].'"');
    6162      if($this->Database->Last_num_rows > 0) $Result = NICK_USED;
    6263      else
    6364      {
    64         $this->Database->insert('User', array('Name' => addslashes($Date['Nick']), 'FullName' => addslashes($Date['FullName']), 'Password' => addslashes($Date['Password']), 'Email' => htmlspecialchars($Date['Email']), 'Permission' => $this->DefaultRole, 'TranslationLanguage' => $Date['Language'], 'LastIpAddress' => $this->IPAddress, 'LastLoginTime' => 'NOW()'));
     65        $this->Database->insert('User', array('Name' => addslashes($Data['Nick']), 'FullName' => addslashes($Data['FullName']), 'Password' => addslashes($Data['Password']), 'Email' => htmlspecialchars($Data['Email']), 'Permission' => $this->DefaultRole, 'TranslationLanguage' => $Data['Language'], 'LastIpAddress' => $this->IPAddress, 'LastLoginTime' => 'NOW()'));
    6566      //echo $this->Database->LastQuery;
    6667        $Result = USER_REGISTRATED;
     
    7071  }
    7172
    72   function Login($Nick, $Password)
     73  function Login($Data)
    7374  {
    7475    $SID = session_id();
    7576    // Je uživatel registrován?
    76     $Query = $this->Database->select('User', '*', 'Name="'.$Nick.'"');
     77    $Query = $this->Database->select('User', '*', 'Name="'.$Data['Nick'].'"');
    7778    if($Query->num_rows > 0)
    7879    {
    7980      $Row = $Query->fetch_array();
    80       if($Row['Password'] != $Password) $Result = BAD_PASSWORD;
     81      if($Row['Password'] != $Data['Password']) $Result = BAD_PASSWORD;
    8182      else
    8283      {
    83         $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()'));   
     84        $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()', 'LastIpAddress' => $this->IPAddress));   
    8485        $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id']));
    8586        // načtení stavu stromu
    8687        $Result = USER_LOGGED_IN;   
     88        $this->Check();
    8789      }
    8890    } else $Result = USER_NOT_REGISTRED;
     91
    8992    return($Result);
    9093  }
     
    110113        echo '<h2>'.REGISTRATION_PAGE_TITLE.'</h2>
    111114    <form action="" method="post">
    112     <table>
     115    <table cellspacing="0">
    113116    <tr><td>'.REGISTRATION_PAGE_NAME.'</td><td><input name="Nick" type="text" /></td></tr>
    114117    <tr><td>'.REGISTRATION_PAGE_PASS.'</td><td><input name="Password" type="password" /></td></tr>
     
    125128      }
    126129      echo '</select></td></tr>
    127     <tr><td></td><td><input value="'.REGISTRATION_PAGE_BUTTON.'" type="submit" /></td></tr>
     130    <tr><td></td><td align="right"><input name="Register" value="'.REGISTRATION_PAGE_BUTTON.'" type="submit" /></td></tr>
    128131     </table>
    129132    </form>';
    130133  } // END function WriteRegistration
    131134 
     135  function WriteLogin()
     136  { // BEGIN function WriteLogin
     137        echo '<h2>'.LOGIN_PAGE_TITLE.'</h2>
     138    <form action="" method="post">
     139    <table cellspacing="0">
     140    <tr><td>'.LOGIN_PAGE_NAME.'</td><td><input name="Nick" type="text" /></td></tr>
     141    <tr><td>'.LOGIN_PAGE_PASS.'</td><td><input name="Password" type="password" /></td></tr>
     142    <tr><td></td><td align="right"><input name="Login" value="'.LOGIN_PAGE_BUTTON.'" type="submit" /></td></tr>
     143     </table>
     144    </form>';
     145  } // END function WriteLogin
     146 
     147  function Role()
     148  { // BEGIN function State
     149        return $this->user['Permission']['Title'];
     150  } // END function State
     151 
     152  function Permission()
     153  { // BEGIN function Permission
     154        return $this->user['Permission']['Id'];
     155  } // END function Permission
     156 
    132157  } // END class User
    133158 
  • branches/3/events.php

    r27 r28  
    11<?php
    22
    3   if (array_key_exists('Email', $_POST)) {
     3  if (array_key_exists('Register', $_POST)) {
    44    $Result = $user->Register($_POST);
    5 
     5  }
     6  if (array_key_exists('Login', $_POST)) {
     7    $Result = $user->Login($_POST);
    68  }
    79
  • branches/3/functions.php

    r27 r28  
    33  function ShowHeader()
    44  { // BEGIN function ShowHeader
    5     global $Config,$menu,$User;
    6         echo '<?xml version="1.0" encoding="'.$Config['Charset'].'"?>
     5    global $Config,$menu,$user;
     6        echo '<?xml version="1.0" encoding="'.$Config['Charset'].'"?'.'>
    77    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    88    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
     
    3030       
    3131          echo '</ul>';
     32          if ($user->Permission() > 0) {
     33            echo $user->Role();
     34          } else {
     35            $user->WriteLogin();
     36          }
    3237          echo '
    3338        </div>
    3439      </div>
    3540';
    36 
    3741  } // END function ShowHeader
    3842
  • branches/3/global.php

    r27 r28  
    1111
    1212//include('error.php');
    13 $database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
     13$database = new database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']);
    1414$database->Prefix = $Config['Database']['Prefix'];
    1515$database->charset($Config['Database']['Charset']);
  • branches/3/language_cz.php

    r27 r28  
    6060define('REGISTRATION_PAGE_TITLE', 'Registrace');
    6161
     62define('LOGIN_PAGE_NAME', REGISTRATION_PAGE_NAME);
     63define('LOGIN_PAGE_PASS', REGISTRATION_PAGE_PASS);
     64define('LOGIN_PAGE_BUTTON', 'Přihlásit');
     65define('LOGIN_PAGE_TITLE', ' ');
     66
    6267
    6368//menu
  • branches/3/style.css

    r27 r28  
    139139 input, textarea, select {
    140140   background-color: #E8E8E8;
    141    border: thin #c43300 solid;
     141   border: 1px #c43300 solid;
    142142   font-size: 11px;
    143143   font-family: Verdana, Arial, SunSans-Regular, Sans-Serif;
     
    146146 td,tr {
    147147   border-spacing: 0;
    148    border: thin #c43300 solid;
     148   border: 1px #c43300 solid;
     149        padding: 0;
    149150 }
    150151 
     
    152153   margin: 10px;
    153154   border-spacing: 0;
    154    border: thin #c43300 solid;
     155   border: 1px #c43300 solid;
     156        padding: 0;
    155157 }
Note: See TracChangeset for help on using the changeset viewer.