Changeset 28 for branches/3/class/user.php
- Timestamp:
- Oct 13, 2008, 8:01:02 PM (16 years ago)
- Location:
- branches/3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3
-
Property svn:ignore
set to
config.php
-
Property svn:ignore
set to
-
branches/3/class/user.php
r27 r28 4 4 { // BEGIN class User 5 5 // variables 6 var $ID,$ Permission, $user,$Database;6 var $ID,$user,$Database; 7 7 var $AnonymousUserId = 1; 8 var $DefaultRole = 1;8 var $DefaultRole = 2; 9 9 var $IPAddress = ' '; 10 10 … … 46 46 $this->user = $Query->fetch_array(); 47 47 $Result = USER_NOT_LOGGED; 48 $this->LoadPermission(1); 48 49 } 49 50 return $Result; 50 51 } 51 52 52 function Register($Dat e)53 function Register($Data) 53 54 { 54 55 global $Options; 55 if(($Dat e['Email'] == '') || ($Date['Nick'] == '') || ($Date['Password'] == '') || ($Date['Password2'] == '')) $Result = DATA_MISSING;56 else if($Dat e['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; 57 58 else 58 59 { 59 60 // Je uživatel registrován? 60 $Query = $this->Database->select('User', '*', 'Name = "'.$Dat e['Nick'].'"');61 $Query = $this->Database->select('User', '*', 'Name = "'.$Data['Nick'].'"'); 61 62 if($this->Database->Last_num_rows > 0) $Result = NICK_USED; 62 63 else 63 64 { 64 $this->Database->insert('User', array('Name' => addslashes($Dat e['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()')); 65 66 //echo $this->Database->LastQuery; 66 67 $Result = USER_REGISTRATED; … … 70 71 } 71 72 72 function Login($ Nick, $Password)73 function Login($Data) 73 74 { 74 75 $SID = session_id(); 75 76 // Je uživatel registrován? 76 $Query = $this->Database->select('User', '*', 'Name="'.$ Nick.'"');77 $Query = $this->Database->select('User', '*', 'Name="'.$Data['Nick'].'"'); 77 78 if($Query->num_rows > 0) 78 79 { 79 80 $Row = $Query->fetch_array(); 80 if($Row['Password'] != $ Password) $Result = BAD_PASSWORD;81 if($Row['Password'] != $Data['Password']) $Result = BAD_PASSWORD; 81 82 else 82 83 { 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)); 84 85 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id'])); 85 86 // načtení stavu stromu 86 87 $Result = USER_LOGGED_IN; 88 $this->Check(); 87 89 } 88 90 } else $Result = USER_NOT_REGISTRED; 91 89 92 return($Result); 90 93 } … … 110 113 echo '<h2>'.REGISTRATION_PAGE_TITLE.'</h2> 111 114 <form action="" method="post"> 112 <table >115 <table cellspacing="0"> 113 116 <tr><td>'.REGISTRATION_PAGE_NAME.'</td><td><input name="Nick" type="text" /></td></tr> 114 117 <tr><td>'.REGISTRATION_PAGE_PASS.'</td><td><input name="Password" type="password" /></td></tr> … … 125 128 } 126 129 echo '</select></td></tr> 127 <tr><td></td><td ><inputvalue="'.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> 128 131 </table> 129 132 </form>'; 130 133 } // END function WriteRegistration 131 134 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 132 157 } // END class User 133 158
Note:
See TracChangeset
for help on using the changeset viewer.