Ignore:
Timestamp:
Aug 24, 2009, 1:18:40 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Podpora pro překlad rozhraní.

¨

Location:
trunk/www/Application/Model
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/Application/Model/Backup.php

    r69 r75  
    11<?php
    22
    3 class Backup extends Module
     3class Backup extends Model
    44{
    55  var $Id;
  • trunk/www/Application/Model/Cluster.php

    r74 r75  
    11<?php
    22
    3 class Cluster extends Module
     3class Cluster extends Model
    44{
    55  function __construct($System, $Id)
  • trunk/www/Application/Model/ClusterList.php

    r69 r75  
    11<?php
    22
    3 class ClusterList extends Module
     3class ClusterList extends Model
    44{
    5   function __construct($System)
    6   {
    7     $this->System = $System;
    8     $this->Database = $System->Database;
    9   }
    10  
    115  function Add()
    126  {
  • trunk/www/Application/Model/Emulator.php

    r69 r75  
    11<?php
    22
    3 class Emulator extends Module
     3class Emulator extends Model
    44{
    55  var $Id;
  • trunk/www/Application/Model/History.php

    r69 r75  
    11<?php
    22
    3 class History extends Module
     3class History extends Model
    44{
    55  var $ServerId;
  • trunk/www/Application/Model/MangosConfigurationFile.php

    r69 r75  
    11<?php
    22
    3 class MangosConfigurationFile extends Module
     3class MangosConfigurationFile extends Model
    44{
    55  var $ParameterList;
  • trunk/www/Application/Model/MangosDebug.php

    r69 r75  
    11<?php
    22
    3 class MangosDebug extends Module
     3class MangosDebug extends Model
    44{
    55  var $ItemPerPage = 35;
  • trunk/www/Application/Model/Platform.php

    r69 r75  
    11<?php
    22
    3 class Platform extends Module
     3class Platform extends Model
    44{
    55  var $Id;
  • trunk/www/Application/Model/Realm.php

    r69 r75  
    11<?php
    22
    3 class Realm extends Module
     3class Realm extends Model
    44{
    55  var $Id;
  • trunk/www/Application/Model/Server.php

    r69 r75  
    11<?php
    22
    3 class Server extends Module
     3class Server extends Model
    44{
    55  var $Id;
  • trunk/www/Application/Model/Shell.php

    r74 r75  
    11<?php
    22
    3 class Shell extends Module
     3class Shell extends Model
    44{
    55  var $Database;
  • trunk/www/Application/Model/Task.php

    r69 r75  
    11<?php
    22
    3 class Task extends Module
     3class Task extends Model
    44{
    55  var $TempScript = 'temp/wowhosting_script.sh';
  • trunk/www/Application/Model/User.php

    r74 r75  
    11<?php
    22
    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
     3class User extends Model
    354{
    365  var $Dependencies = array('Log');
    37   var $Roles = array();
    38   var $User = array();
     6  var $Data = array();
    397  var $DefaultRole = 2;
    408  var $OnlineStateTimeout = 600; // in seconds
    419
     10  var $Roles = array('Unknown', 'Anonymous', 'User', 'Administrator');
     11
     12  function PasswordHash($Name, $Password)
     13  {
     14    return(sha1(strtoupper($Name.':'.$Password)));
     15  }
     16
    4217  function Check()
    4318  {
     
    4823    while($DbRow = $DbResult->fetch_array())
    4924    {
    50       $this->System->Modules['User']->User['Id'] = $DbRow['User'];
     25      $this->System->Modules['User']->Data['Id'] = $DbRow['User'];
    5126      if($DbRow['User'] != $this->Config['Web']['UserAnonymousId']) $this->System->Modules['Log']->NewRecord('User', 'Logout');
    5227      $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']);
     
    6540    {
    6641      $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');
    6944    } else
    7045    {
    7146      $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');
    7449    }
    7550
     
    7752    $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('ActivityTime' => 'NOW()'));
    7853
    79     //$this->LoadPermission($this->User['Role']);
     54    //$this->LoadPermission($this->Data['Role']);
    8055
    8156    // Role and permission
     
    8762    global $Options, $Config;
    8863
    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');
    9166    else
    9267    {
    9368      // Je uživatel registrován?
    9469      $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');
    9671      else
    9772      {
    9873        $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');
    10075        else
    10176        {
    10277          $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');
    10479          else
    10580          {
    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));
    10782            $UserId = $this->Database->insert_id;
    10883           
    10984            $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.";
    11186            $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";
    11287            mail($Email, $Subject, $Message, $AdditionalHeaders);
    113             $Result = USER_REGISTRATED;
     88            $Result = $this->System->Translate('UserRegistrated');
    11489            $this->System->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
    11590          }
     
    129104      {
    130105        $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0));
    131         $Output = USER_REGISTRATION_CONFIRMED;
     106        $Output = $this->System->Translate('UserRegistrationConfirmed');
    132107        $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');
    135110    return($Output);
    136111  }
     
    143118    {
    144119      $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');
    147122      else
    148123      {
     
    150125        $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id']));
    151126        // načtení stavu stromu
    152         $Result = USER_LOGGED_IN;
     127        $Result = $this->System->Translate('UserLoggedIn');
    153128        $this->System->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress()));
    154129      }
    155     } else $Result = USER_NOT_REGISTRED;
     130    } else $Result = $this->System->Translate('UserNotRegistred');
    156131    $this->Check();
    157132    return($Result);
     
    162137    $SID = session_id();
    163138    $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']);
    165140    $this->Check();
    166     return(USER_LOGGED_OUT);
     141    return($this->System->Translate('UserLoggedOut'));
    167142  }
    168143
     
    177152  function LoadPermission($Role)
    178153  {
    179     $this->User['Permission'] = array();
     154    $this->Data['Permission'] = array();
    180155    $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role);
    181156    if($DbResult->num_rows > 0)
    182157    while($DbRow = $DbResult->fetch_array())
    183       $this->User['Permission'][$DbRow['Operation']] = $DbRow;
     158      $this->Data['Permission'][$DbRow['Operation']] = $DbRow;
    184159  }
    185160
     
    222197
    223198      // 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"');
    225200      if($DbResult->num_rows > 0) return(true);
    226201
    227202      // 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"');
    229204      while($DbRow = $DbResult->fetch_array())
    230205      {
     
    249224      $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";
    250225      mail($Row['Email'], $Subject, $Message, $AdditionalHeaders);
    251       $Output = USER_PASSWORD_RECOVERY_SUCCESS;
     226      $Output = $this->System->Translate('UserPasswordRecoverySuccess');
    252227      $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');
    254229    return($Output);
    255230  }
     
    265240      {
    266241        $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');
    268243        $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');
    271246    return($Output);
    272247  }
     
    274249  function ServerCount()
    275250  {
    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']);
    277252    $DbRow = $DbResult->fetch_row();
    278253    return($DbRow[0]);
Note: See TracChangeset for help on using the changeset viewer.