Changeset 75
- Timestamp:
- Aug 24, 2009, 1:18:40 PM (15 years ago)
- Location:
- trunk/www
- Files:
-
- 3 added
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/Application/Include.php
r71 r75 2 2 3 3 include('Application/CustomTypes.php'); 4 4 5 if(file_exists('Application/Config/Config.php')) include('Application/Config/Config.php'); 5 6 else die('Nenalezen soubor Application/Config/Config.php. Vytvořte jej kopií ze souboru Application/Config/ConfigSample.php.'); 7 8 if(file_exists('Application/Localization/'.$Config['Web']['Locale'].'.php') 9 include('Application/Localization/'.$Config['Web']['Locale'].'.php'); 10 else die('Nenalezen soubor Application/Localization/'.$Config['Web']['Locale'].'.php. Buď máte špatně nastaven jazyk nebo vám chybí jazykový soubor.'); 11 6 12 include('Application/Model/Include.php'); 7 13 include('Application/View/Include.php'); -
trunk/www/Application/Model/Backup.php
r69 r75 1 1 <?php 2 2 3 class Backup extends Mod ule3 class Backup extends Model 4 4 { 5 5 var $Id; -
trunk/www/Application/Model/Cluster.php
r74 r75 1 1 <?php 2 2 3 class Cluster extends Mod ule3 class Cluster extends Model 4 4 { 5 5 function __construct($System, $Id) -
trunk/www/Application/Model/ClusterList.php
r69 r75 1 1 <?php 2 2 3 class ClusterList extends Mod ule3 class ClusterList extends Model 4 4 { 5 function __construct($System)6 {7 $this->System = $System;8 $this->Database = $System->Database;9 }10 11 5 function Add() 12 6 { -
trunk/www/Application/Model/Emulator.php
r69 r75 1 1 <?php 2 2 3 class Emulator extends Mod ule3 class Emulator extends Model 4 4 { 5 5 var $Id; -
trunk/www/Application/Model/History.php
r69 r75 1 1 <?php 2 2 3 class History extends Mod ule3 class History extends Model 4 4 { 5 5 var $ServerId; -
trunk/www/Application/Model/MangosConfigurationFile.php
r69 r75 1 1 <?php 2 2 3 class MangosConfigurationFile extends Mod ule3 class MangosConfigurationFile extends Model 4 4 { 5 5 var $ParameterList; -
trunk/www/Application/Model/MangosDebug.php
r69 r75 1 1 <?php 2 2 3 class MangosDebug extends Mod ule3 class MangosDebug extends Model 4 4 { 5 5 var $ItemPerPage = 35; -
trunk/www/Application/Model/Platform.php
r69 r75 1 1 <?php 2 2 3 class Platform extends Mod ule3 class Platform extends Model 4 4 { 5 5 var $Id; -
trunk/www/Application/Model/Realm.php
r69 r75 1 1 <?php 2 2 3 class Realm extends Mod ule3 class Realm extends Model 4 4 { 5 5 var $Id; -
trunk/www/Application/Model/Server.php
r69 r75 1 1 <?php 2 2 3 class Server extends Mod ule3 class Server extends Model 4 4 { 5 5 var $Id; -
trunk/www/Application/Model/Shell.php
r74 r75 1 1 <?php 2 2 3 class Shell extends Mod ule3 class Shell extends Model 4 4 { 5 5 var $Database; -
trunk/www/Application/Model/Task.php
r69 r75 1 1 <?php 2 2 3 class Task extends Mod ule3 class Task extends Model 4 4 { 5 5 var $TempScript = 'temp/wowhosting_script.sh'; -
trunk/www/Application/Model/User.php
r74 r75 1 1 <?php 2 2 3 define('LOGIN_USED', 'Přihlašovací jméno již použito.'); 4 define('NAME_USED', 'Jméno uživatele již použito'); 5 define('EMAIL_USED', 'Email je již použitý. Použijte jiný email nebo si můžete nechat zaslat nové heslo na email.'); 6 define('USER_REGISTRATED', 'Uživatel registrován. Na zadanou emailovou adresu byl poslán mail s odkazem pro aktivování účtu.'); 7 define('USER_REGISTRATION_CONFIRMED', 'Vaše registrace byla potvrzena.'); 8 define('DATA_MISSING', 'Chybí emailová adresa, přezdívka, nebo některé z hesel.'); 9 define('PASSWORDS_UNMATCHED', 'Hesla si neodpovídají.'); 10 define('ACCOUNT_LOCKED', 'Účet je uzamčen. Po registraci je nutné provést aktivaci účtu pomocí odkazu zaslaného v aktivačním emailu.'); 11 define('USER_NOT_LOGGED', 'Nejste přihlášen.'); 12 define('USER_LOGGED', 'Uživatel přihlášen.'); 13 define('USER_NOT_REGISTRED', 'Uživatel neregistrován.'); 14 define('USER_ALREADY_LOGGED', 'Uživatel již přihlášen.'); 15 define('USER_LOGGED_IN', 'Byl jste přihlášen.'); 16 define('USER_LOGGED_OUT', 'Byl jste odhlášen.'); 17 define('BAD_PASSWORD', 'Špatné heslo.'); 18 define('USER_NOT_FOUND', 'Uživatel nenalezen.'); 19 define('USER_PASSWORD_RECOVERY_SUCCESS', 'Přihlašovací údaje byly odeslány na zadanou emailovou adresu.'); 20 define('USER_PASSWORD_RECOVERY_FAIL', 'Podle zadaných údajů nebyl nalezen žádný uživatel.'); 21 define('USER_PASSWORD_RECOVERY_CONFIRMED', 'Nové heslo bylo aktivováno.'); 22 23 define('USER_BAD_ROLE', 'Nemáte dostatečná oprávnění'); 24 25 define('USER_EVENT_REGISTER', 1); 26 define('USER_EVENT_LOGIN', 2); 27 define('USER_EVENT_LOGOUT', 3); 28 define('USER_EVENT_OPTIONS_CHANGED', 4); 29 30 define('USER_ROLE_ANONYMOUS', 1); 31 define('USER_ROLE_USER', 2); 32 define('USER_ROLE_ADMINISTRATOR', 3); 33 34 class User extends Module 3 class User extends Model 35 4 { 36 5 var $Dependencies = array('Log'); 37 var $Roles = array(); 38 var $User = array(); 6 var $Data = array(); 39 7 var $DefaultRole = 2; 40 8 var $OnlineStateTimeout = 600; // in seconds 41 9 10 var $Roles = array('Unknown', 'Anonymous', 'User', 'Administrator'); 11 12 function PasswordHash($Name, $Password) 13 { 14 return(sha1(strtoupper($Name.':'.$Password))); 15 } 16 42 17 function Check() 43 18 { … … 48 23 while($DbRow = $DbResult->fetch_array()) 49 24 { 50 $this->System->Modules['User']-> User['Id'] = $DbRow['User'];25 $this->System->Modules['User']->Data['Id'] = $DbRow['User']; 51 26 if($DbRow['User'] != $this->Config['Web']['UserAnonymousId']) $this->System->Modules['Log']->NewRecord('User', 'Logout'); 52 27 $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']); … … 65 40 { 66 41 $Query = $this->Database->select('User', '*', 'Id='.$Row['User']); 67 $this-> User= $Query->fetch_assoc();68 $Result = USER_LOGGED;42 $this->Data = $Query->fetch_assoc(); 43 $Result = $this->System->Translate('UserLogged'); 69 44 } else 70 45 { 71 46 $Query = $this->Database->select('User', '*', 'Id='.$this->Config['Web']['UserAnonymousId']); 72 $this-> User= $Query->fetch_assoc();73 $Result = USER_NOT_LOGGED;47 $this->Data = $Query->fetch_assoc(); 48 $Result = $this->System->Translate('UserNotLogged'); 74 49 } 75 50 … … 77 52 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('ActivityTime' => 'NOW()')); 78 53 79 //$this->LoadPermission($this-> User['Role']);54 //$this->LoadPermission($this->Data['Role']); 80 55 81 56 // Role and permission … … 87 62 global $Options, $Config; 88 63 89 if(($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = DATA_MISSING;90 else if($Password != $Password2) $Result = PASSWORDS_UNMATCHED;64 if(($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '') || ($Name == '')) $Result = $this->System->Translate('MissingData'); 65 else if($Password != $Password2) $Result = $this->System->Translate('PasswordsUnmatched'); 91 66 else 92 67 { 93 68 // Je uživatel registrován? 94 69 $Query = $this->Database->select('User', '*', 'Login = "'.$Login.'"'); 95 if($Query->num_rows > 0) $Result = LOGIN_USED;70 if($Query->num_rows > 0) $Result = $this->System->Translate('LoginUsed'); 96 71 else 97 72 { 98 73 $Query = $this->Database->select('User', '*', 'Name = "'.$Name.'"'); 99 if($Query->num_rows > 0) $Result = NAME_USED;74 if($Query->num_rows > 0) $Result = $this->System->Translate('NameUsed'); 100 75 else 101 76 { 102 77 $Query = $this->Database->select('User', '*', 'Email = "'.$Email.'"'); 103 if($Query->num_rows > 0) $Result = EMAIL_USED;78 if($Query->num_rows > 0) $Result = $this->System->Translate('EmailUsed'); 104 79 else 105 80 { 106 $this->Database->insert('User', array('Name' => $Name, 'Login' => $Login, 'Password' => sha1($Password), 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1, 'Role' => 2));81 $this->Database->insert('User', array('Name' => $Name, 'Login' => $Login, 'Password' => $this->PasswordHash($Login, $Password), 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1, 'Role' => 2)); 107 82 $UserId = $this->Database->insert_id; 108 83 109 84 $Subject = FromUTF8('Registrace nového účtu', 'iso2'); 110 $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder']."/</a>.<br>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br><br>\n\nVáš účet je: ".$Login."\n<br>Pro dokončení registrace klikněte na tento odkaz: ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='. sha1($Password).'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.sha1($Password).'</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte.";85 $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder']."/</a>.<br>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br><br>\n\nVáš účet je: ".$Login."\n<br>Pro dokončení registrace klikněte na tento odkaz: ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte."; 111 86 $AdditionalHeaders = "To: ".$Name." <".$Email.">\n"."From: ".FromUTF8($Config['Web']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8"; 112 87 mail($Email, $Subject, $Message, $AdditionalHeaders); 113 $Result = USER_REGISTRATED;88 $Result = $this->System->Translate('UserRegistrated'); 114 89 $this->System->Modules['Log']->NewRecord('User', 'NewRegistration', $Login); 115 90 } … … 129 104 { 130 105 $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0)); 131 $Output = USER_REGISTRATION_CONFIRMED;106 $Output = $this->System->Translate('UserRegistrationConfirmed'); 132 107 $this->System->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='.$Row['Login'].', Id='.$Row['Id']); 133 } else $Output = PASSWORDS_UNMATCHED;134 } else $Output = USER_NOT_FOUND;108 } else $Output = $this->System->Translate('PasswordsUnmatched'); 109 } else $Output = $this->System->Translate('UserNotFound'); 135 110 return($Output); 136 111 } … … 143 118 { 144 119 $Row = $Query->fetch_assoc(); 145 if($Row['Password'] != sha1($Password)) $Result = BAD_PASSWORD;146 else if($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED;120 if($Row['Password'] != $this->PasswordHash($Login, $Password)) $Result = $this->System->Translate('BadPassword'); 121 else if($Row['Locked'] == 1) $Result = $this->System->Translate('AccountLocked'); 147 122 else 148 123 { … … 150 125 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id'])); 151 126 // načtení stavu stromu 152 $Result = USER_LOGGED_IN;127 $Result = $this->System->Translate('UserLoggedIn'); 153 128 $this->System->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress())); 154 129 } 155 } else $Result = USER_NOT_REGISTRED;130 } else $Result = $this->System->Translate('UserNotRegistred'); 156 131 $this->Check(); 157 132 return($Result); … … 162 137 $SID = session_id(); 163 138 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $this->Config['Web']['UserAnonymousId'])); 164 $this->System->Modules['Log']->NewRecord('User', 'Logout', $this-> User['Login']);139 $this->System->Modules['Log']->NewRecord('User', 'Logout', $this->Data['Login']); 165 140 $this->Check(); 166 return( USER_LOGGED_OUT);141 return($this->System->Translate('UserLoggedOut')); 167 142 } 168 143 … … 177 152 function LoadPermission($Role) 178 153 { 179 $this-> User['Permission'] = array();154 $this->Data['Permission'] = array(); 180 155 $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role); 181 156 if($DbResult->num_rows > 0) 182 157 while($DbRow = $DbResult->fetch_array()) 183 $this-> User['Permission'][$DbRow['Operation']] = $DbRow;158 $this->Data['Permission'][$DbRow['Operation']] = $DbRow; 184 159 } 185 160 … … 222 197 223 198 // Check user-operation relation 224 $DbResult = $this->Database->select('PermissionUserAssignment', '*', '`User`="'.$this-> User['Id'].'" AND `GroupOrOperation`="'.$OperationId.'" AND `Type`="Operation"');199 $DbResult = $this->Database->select('PermissionUserAssignment', '*', '`User`="'.$this->Data['Id'].'" AND `GroupOrOperation`="'.$OperationId.'" AND `Type`="Operation"'); 225 200 if($DbResult->num_rows > 0) return(true); 226 201 227 202 // Check user-group relation 228 $DbResult = $this->Database->select('PermissionUserAssignment', 'GroupOrOperation', '`User`="'.$this-> User['Id'].'" AND `Type`="Group"');203 $DbResult = $this->Database->select('PermissionUserAssignment', 'GroupOrOperation', '`User`="'.$this->Data['Id'].'" AND `Type`="Group"'); 229 204 while($DbRow = $DbResult->fetch_array()) 230 205 { … … 249 224 $AdditionalHeaders = "To: ".$Row['Name']." <".$Row['Email'].">\n"."From: ".FromUTF8($Config['Web']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8"; 250 225 mail($Row['Email'], $Subject, $Message, $AdditionalHeaders); 251 $Output = USER_PASSWORD_RECOVERY_SUCCESS;226 $Output = $this->System->Translate('UserPasswordRecoverySuccess'); 252 227 $this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email); 253 } else $Output = USER_PASSWORD_RECOVERY_FAIL;228 } else $Output = $this->System->Translate('UserPasswordRecoveryFail'); 254 229 return($Output); 255 230 } … … 265 240 { 266 241 $this->Database->update('User', 'Id='.$Row['Id'], array('Password' => sha1($NewPassword), 'Locked' => 0)); 267 $Output = USER_PASSWORD_RECOVERY_CONFIRMED;242 $Output = $this->System->Translate('UserPasswordRecoveryConfirmed'); 268 243 $this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']); 269 } else $Output = PASSWORDS_UNMATCHED;270 } else $Output = USER_NOT_FOUND;244 } else $Output = $this->System->Translate('UserPasswordUnmatched'); 245 } else $Output = $this->System->Translate('UserNotFound'); 271 246 return($Output); 272 247 } … … 274 249 function ServerCount() 275 250 { 276 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this-> User['Id']);251 $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->Data['Id']); 277 252 $DbRow = $DbResult->fetch_row(); 278 253 return($DbRow[0]); -
trunk/www/Base/Include.php
r69 r75 4 4 include('Base/Error.php'); 5 5 include('Base/Database.php'); 6 include('Base/ Code.php');6 include('Base/UTF8.php'); 7 7 include('Base/System.php'); 8 8 include('Base/Global.php'); -
trunk/www/Base/System.php
r69 r75 193 193 return((float)$Usec + (float)$Sec); 194 194 } 195 196 function Translate($Text) 197 { 198 global $Translation; 199 200 if(array_key_exists($Text, $Translation)) return($Translation[$Text]); 201 else return('#'.$Text); 202 } 195 203 } 196 204
Note:
See TracChangeset
for help on using the changeset viewer.