Ignore:
Timestamp:
Sep 11, 2009, 8:18:38 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Zrušeny samostatné include soubory a správně vloženy přímé závislosti pomocí include_once do všech souborů. Takto se budou načítat jen ty třídy, které jsou skutenčě potřeba.
  • Upraveno: Aplikace se nyní inicializuje přes soubor Application.php, kde je vložena třída odvozená z třídy System. Hlavní soubor index.php se pak odkazuje na soubor aplikace.
  • Objekty Database, Config a Translation jsou nyní lokální v rámci třídy System.
  • Přidáno: Třída pro odesílání pošty. Použita v třídě User.
Location:
trunk/www/Application/Model
Files:
2 added
1 deleted
15 edited

Legend:

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

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Backup extends Model
  • trunk/www/Application/Model/Cluster.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Cluster extends Model
  • trunk/www/Application/Model/ClusterList.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class ClusterList extends Model
  • trunk/www/Application/Model/Emulator.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Emulator extends Model
  • trunk/www/Application/Model/History.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class History extends Model
  • trunk/www/Application/Model/Log.php

    r76 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Log extends Model
  • trunk/www/Application/Model/MangosConfigurationFile.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class MangosConfigurationFile extends Model
  • trunk/www/Application/Model/MangosDebug.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class MangosDebug extends Model
  • trunk/www/Application/Model/Permission.php

    r76 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Permission extends Model
  • trunk/www/Application/Model/Platform.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Platform extends Model
  • trunk/www/Application/Model/Realm.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Realm extends Model
  • trunk/www/Application/Model/Server.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Server extends Model
  • trunk/www/Application/Model/Shell.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Shell extends Model
  • trunk/www/Application/Model/Task.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
    24
    35class Task extends Model
  • trunk/www/Application/Model/User.php

    r75 r78  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/Model.php');
     4include_once(dirname(__FILE__).'/../../Base/Mail.php');
     5include_once(dirname(__FILE__).'/Log.php');
    26
    37class User extends Model
     
    711  var $DefaultRole = 2;
    812  var $OnlineStateTimeout = 600; // in seconds
    9 
    10   var $Roles = array('Unknown', 'Anonymous', 'User', 'Administrator');
    1113
    1214  function PasswordHash($Name, $Password)
     
    3133    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    3234    if($Query->num_rows == 0)
    33       $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->Config['Web']['UserAnonymousId'], 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress()), 'ScriptName' => $_SERVER['PHP_SELF']));
     35      $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->Config['Web']['UserAnonymousId'], 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => $this->System->GetRemoteAddress(), 'HostName' => gethostbyaddr($this->System->GetRemoteAddress()), 'ScriptName' => $_SERVER['PHP_SELF']));
    3436    //echo($this->Database->LastQuery);
    3537
     
    5153    // Refresh time of last access
    5254    $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('ActivityTime' => 'NOW()'));
    53 
    54     //$this->LoadPermission($this->Data['Role']);
    55 
    56     // Role and permission
    57     //$this->LoadRoles();
    5855  }
    5956
     
    7976          else
    8077          {
    81             $this->Database->insert('User', array('Name' => $Name, 'Login' => $Login, 'Password' => $this->PasswordHash($Login, $Password), 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1, 'Role' => 2));
     78            $this->Database->insert('User', array('Name' => $Name, 'Login' => $Login, 'Password' => $this->PasswordHash($Login, $Password), 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1));
    8279            $UserId = $this->Database->insert_id;
    8380           
    84             $Subject = FromUTF8('Registrace nového účtu', 'iso2');
    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.";
    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";
    87             mail($Email, $Subject, $Message, $AdditionalHeaders);
     81            $Mail = new Mail();
     82            $Mail->Content = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$this->Config['Web']['Host'].$this->Config['Web']['RootFolder'].'/">http://'.$this->Config['Web']['Host'].$this->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://'.$this->Config['Web']['Host'].$this->Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'">http://'.$this->Config['Web']['Host'].$this->Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte.";
     83            $Mail->Subject = 'Registrace nového účtu';
     84            $Mail->RecipientName = $Name;
     85            $Mail->RecipientAddress = $Email;
     86            $Mail->SenderName = $this->Config['Web']['Title'];
     87            $Mail->SenderAddress = 'noreplay@zdechov.net';
     88            $Mail->Send();
     89
    8890            $Result = $this->System->Translate('UserRegistrated');
    8991            $this->System->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
     
    142144  }
    143145
    144   function LoadRoles()
    145   {
    146     $this->Roles = array();
    147     $DbResult = $this->Database->select('UserRole', '*');
    148     while($DbRow = $DbResult->fetch_array())
    149       $this->Roles[] = $DbRow;
    150   }
    151 
    152   function LoadPermission($Role)
    153   {
    154     $this->Data['Permission'] = array();
    155     $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description` FROM `UserRolePermission` JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` WHERE `UserRolePermission`.`Role` = '.$Role);
    156     if($DbResult->num_rows > 0)
    157     while($DbRow = $DbResult->fetch_array())
    158       $this->Data['Permission'][$DbRow['Operation']] = $DbRow;
    159   }
    160 
    161   function PermissionMatrix()
    162   {
    163     $Result = array();
    164     $DbResult = $this->Database->query('SELECT `UserRolePermission`.*, `PermissionOperation`.`Description`, `UserRole`.`Title` FROM `UserRolePermission` LEFT JOIN `PermissionOperation` ON `PermissionOperation`.`Id` = `UserRolePermission`.`Operation` LEFT JOIN `UserRole` ON `UserRole`.`Id` = `UserRolePermission`.`Role`');
    165     while($DbRow = $DbResult->fetch_array())
    166     {
    167       $Value = '';
    168       if($DbRow['Read']) $Value .= 'R';
    169       if($DbRow['Write']) $Value .= 'W';
    170       $Result[$DbRow['Description']][$DbRow['Title']] = $Value;
    171     }
    172     return($Result);
    173   }
    174 
    175   function CheckGroupPermission($GroupId, $OperationId)
    176   {
    177     // Check group-group relation
    178     $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `Type`="Group"');
    179     while($DbRow = $DbResult->fetch_array())
    180     {
    181        if($this->CheckGroupPermission($DbRow['GroupOrOperation'], $OperationId) == true) return(true);
    182     }
    183 
    184     // Check group-operation relation
    185     $DbResult = $this->Database->select('PermissionGroupAssignment', '*', '`Group`="'.$GroupId.'" AND `GroupOrOperation`="'.$OperationId.'" AND `Type`="Operation"');
    186     if($DbResult->num_rows > 0) return(true);
    187     return(false);
    188   }
    189 
    190   function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0)
    191   {
    192   $DbResult = $this->Database->select('PermissionOperation', 'Id', '`Module`="'.$Module.'" AND `Item`="'.$ItemType.'" AND `ItemId`='.$ItemIndex.' AND `Operation`="'.$Operation.'"');
    193     if($DbResult->num_rows > 0)
    194     {
    195       $DbRow = $DbResult->fetch_array();
    196       $OperationId = $DbRow['Id'];
    197 
    198       // Check user-operation relation
    199       $DbResult = $this->Database->select('PermissionUserAssignment', '*', '`User`="'.$this->Data['Id'].'" AND `GroupOrOperation`="'.$OperationId.'" AND `Type`="Operation"');
    200       if($DbResult->num_rows > 0) return(true);
    201 
    202       // Check user-group relation
    203       $DbResult = $this->Database->select('PermissionUserAssignment', 'GroupOrOperation', '`User`="'.$this->Data['Id'].'" AND `Type`="Group"');
    204       while($DbRow = $DbResult->fetch_array())
    205       {
    206          if($this->CheckGroupPermission($DbRow['GroupOrOperation'], $OperationId) == true) return(true);
    207       }
    208       return(false);
    209     } else return(false);
    210   }
    211 
    212146  function PasswordRecoveryRequest($Login, $Email)
    213147  {
    214     global $Config;
    215 
    216148    $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"');
    217149    if($DbResult->num_rows > 0)
     
    220152      $NewPassword = substr(sha1(strtoupper($Row['Login'])), 0, 7);
    221153
    222       $Subject = 'Obnova hesla';
    223       $Message = 'Požádali jste o zaslání nového hesla 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\nVaše nové heslo k účtu ".$Row['Login']." je: ".$NewPassword."\n<br>Pro aktivaci tohoto hesla klikněte na ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=PasswordRecoveryConfirm&User='.$Row['Id'].'&H='.$Row['Password'].'&P='.$NewPassword.'">tento odkaz</a>.'."\n<br /> Po přihlášení si prosím změňte heslo na nové.\n\n<br><br>Na tento email neodpovídejte.";
    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";
    225       mail($Row['Email'], $Subject, $Message, $AdditionalHeaders);
     154      $Mail = new Mail();
     155      $Mail->Subject = 'Obnova hesla';
     156      $Mail->Content = 'Požádali jste o zaslání nového hesla na serveru <a href="http://'.$this->Config['Web']['Host'].$this->Config['Web']['RootFolder'].'">http://'.$this->Config['Web']['Host'].$this->Config['Web']['RootFolder']."</a>.<br />\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br /><br />\n\nVaše nové heslo k účtu ".$Row['Login']." je: ".$NewPassword."\n<br>Pro aktivaci tohoto hesla klikněte na ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=PasswordRecoveryConfirm&User='.$Row['Id'].'&H='.$Row['Password'].'&P='.$NewPassword.'">tento odkaz</a>.'."\n<br /> Po přihlášení si prosím změňte heslo na nové.\n\n<br><br>Na tento email neodpovídejte.";
     157      $Mail->RecipientName = $Row['Name'];
     158      $Mail->RecipientAddress = $Row['Email'];
     159      $Mail->SenderName = $this->Config['Web']['Title'];
     160      $Mail->SenderAddress = 'noreplay@zdechov.net';
     161      $Mail->Send();
     162     
    226163      $Output = $this->System->Translate('UserPasswordRecoverySuccess');
    227164      $this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);
     
    246183    return($Output);
    247184  }
    248  
    249   function ServerCount()
    250   {
    251     $DbResult = $this->Database->query('SELECT COUNT(*) FROM Server WHERE User='.$this->Data['Id']);
    252     $DbRow = $DbResult->fetch_row();
    253     return($DbRow[0]);
    254   }
    255 
    256   function RealmCount()
    257   {
    258     $Total = 0;
    259     $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->User['Id']);
    260     while($DbRow = $DbResult->fetch_assoc())
    261     {
    262       $Server = new Server($this->Database, $DbRow['Id']);
    263       $Total += $Server->RealmCount();
    264     }
    265     return($Total);   
    266   }
    267185}
    268186
Note: See TracChangeset for help on using the changeset viewer.