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

Přihlášení

Location:
branches/3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3

    • Property svn:ignore set to
      config.php
  • 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 
Note: See TracChangeset for help on using the changeset viewer.