Ignore:
Timestamp:
Oct 13, 2008, 6:52:24 PM (16 years ago)
Author:
maron
Message:

Registrace

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3/class/user.php

    r26 r27  
    11<?php
    22
    3   class User
     3  class user
    44  { // BEGIN class User
    55        // variables
    6         var $ID,$Permission, $User,$Database;
     6        var $ID,$Permission, $user,$Database;
    77          var $AnonymousUserId = 1;
     8        var $DefaultRole = 1;
     9        var $IPAddress = ' ';
    810 
    911        // constructor
    10         function User($Database)
     12        function user($Database)
    1113        { // BEGIN constructor
    1214                $this->Database = $Database;
     
    1820  {
    1921    $SID = session_id();
    20     $IPAddress = gethostbyaddr($_SERVER['REMOTE_ADDR']).' '.$_SERVER['REMOTE_ADDR'];
     22    $this->IPAddress = gethostbyaddr($_SERVER['REMOTE_ADDR']).' '.$_SERVER['REMOTE_ADDR'];
    2123    // Lookup user record
    2224    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
     
    2426    {
    2527      // Refresh time of last access
    26       $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('Time' => 'NOW()','IpAddress' => $IPAddress));
     28      $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('Time' => 'NOW()','IpAddress' => $this->IPAddress));
    2729    } else {
    28      $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'Time' => 'NOW()', 'IpAddress' => $IPAddress)); 
     30     $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'Time' => 'NOW()', 'IpAddress' => $this->IPAddress)); 
    2931    }
    3032    // Odeber neaktivní uživatele
     
    3739    {
    3840      $Query = $this->Database->select('User', '*', "Id=".$Row['User']."");
    39       $this->User = $Query->fetch_array();
     41      $this->user = $Query->fetch_array();
    4042      $Result = USER_LOGGED;
    41       $this->LoadPermission($this->User['Permission']);
     43      $this->LoadPermission($this->user['Permission']);
    4244    } else {
    4345      $Query = $this->Database->select('User', '*', "Id=".$this->AnonymousUserId);
    44       $this->User = $Query->fetch_array();
     46      $this->user = $Query->fetch_array();
    4547      $Result = USER_NOT_LOGGED;
    4648    }   
     
    4850  }
    4951
    50   function Register($Nick, $Password, $Password2, $Email, $FullName)
     52  function Register($Date)
    5153  {
    5254    global $Options;
    53     if(($Email == '') || ($Nick == '') || ($Password == '') || ($Password2 == '')) $Result = DATA_MISSING;
    54     else if($Password != $Password2) $Result = PASSWORDS_UNMATCHED;
     55    if(($Date['Email'] == '') || ($Date['Nick'] == '') || ($Date['Password'] == '') || ($Date['Password2'] == '')) $Result = DATA_MISSING;
     56    else if($Date['Password'] != $Date['Password2']) $Result = PASSWORDS_UNMATCHED;
    5557    else
    5658    {
    5759      // Je uživatel registrován?
    58       $Query = $this->Database->select('User', '*', 'Name = "'.$Nick.'"');
    59       if($Query->num_rows() > 0) $Result = NICK_USED;
     60      $Query = $this->Database->select('User', '*', 'Name = "'.$Date['Nick'].'"');
     61      if($this->Database->Last_num_rows > 0) $Result = NICK_USED;
    6062      else
    6163      {
    62         $this->Database->insert('User', array('Name' => addslashes($Nick), 'FullName' => addslashes($FullName), 'Password' => addslashes($Password), 'Email' => htmlspecialchars($Email), 'Role' => $this->DefaultRole));
     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      //echo $this->Database->LastQuery;
    6366        $Result = USER_REGISTRATED;
    6467      }
     
    9699  function LoadPermission($Permission)
    97100  {
    98     $this->User['Permission'] = array();
     101    $this->user['Permission'] = array();
    99102    $DbResult = $this->Database->select('Permission','*','ID='.$Permission);
    100103    if($DbResult->num_rows > 0)
    101104    while($DbRow = $DbResult->fetch_array())
    102       $this->User['Permission'] = $DbRow;
     105      $this->user['Permission'] = $DbRow;
    103106  }
    104107 
    105108  function WriteRegistration()
    106109  { // BEGIN function WriteRegistration
    107         echo '<div id="content"><h2>'.REGISTRATION_PAGE_TITLE.'</h2>
    108     <form action="?reg" method="post">
     110        echo '<h2>'.REGISTRATION_PAGE_TITLE.'</h2>
     111    <form action="" method="post">
    109112    <table>
    110     <tr><td>'.REGISTRATION_PAGE_NAME.'</td><td><input name="User" type="text" /></td></tr>
    111     <tr><td>'.REGISTRATION_PAGE_PASS.'</td><td><input name="Pass" type="password" /></td></tr>
    112     <tr><td>'.REGISTRATION_PAGE_PASS2.'</td><td><input name="Pass2" type="password" /></td></tr>
     113    <tr><td>'.REGISTRATION_PAGE_NAME.'</td><td><input name="Nick" type="text" /></td></tr>
     114    <tr><td>'.REGISTRATION_PAGE_PASS.'</td><td><input name="Password" type="password" /></td></tr>
     115    <tr><td>'.REGISTRATION_PAGE_PASS2.'</td><td><input name="Password2" type="password" /></td></tr>
    113116    <tr><td>'.REGISTRATION_PAGE_EMAIL.'</td><td><input name="Email" type="text" /></td></tr>
    114117    <tr><td>'.REGISTRATION_PAGE_FULLNAME.'</td><td><input name="FullName" type="text" /></td></tr>
     
    124127    <tr><td></td><td><input value="'.REGISTRATION_PAGE_BUTTON.'" type="submit" /></td></tr>
    125128     </table>
    126     </form></div>';
     129    </form>';
    127130  } // END function WriteRegistration
    128131 
Note: See TracChangeset for help on using the changeset viewer.