Changeset 800 for trunk/includes


Ignore:
Timestamp:
Mar 16, 2014, 11:15:43 AM (11 years ago)
Author:
chronos
Message:
  • Added: Module Redirection responsible for redirection of old pages to new valid address.
  • Fixed: Error on client version item display if id was not specified.
  • Fixed: Error on silent application module reregistration.
  • Removed: White space on end of lines in some files.
Location:
trunk/includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/AppModule.php

    r545 r800  
    66  var $Name;
    77  var $Version;
    8   var $License; 
     8  var $License;
    99  var $Creator;
    1010  var $Description;
     
    1919  var $Manager;
    2020  var $OnChange;
    21  
     21
    2222  function __construct($System)
    2323  {
     
    2727    $this->Dependencies = array();
    2828  }
    29  
     29
    3030  function Install()
    3131  {
    3232  }
    33  
     33
    3434  function Uninstall()
    3535  {
    3636  }
    37  
     37
    3838  function Start()
    3939  {
    4040  }
    41  
     41
    4242  function Stop()
    4343  {
    44   } 
     44  }
    4545}
    4646
    47 class AppModuleManager 
     47class AppModuleManager
    4848{
    4949  var $Modules;
    50  
     50
    5151  function __construct()
    5252  {
    53     $this->Modules = array();     
     53    $this->Modules = array();
    5454  }
    55  
     55
    5656  function StartAll()
    5757  {
     
    7171    }
    7272  }
    73  
     73
    7474  function ModulePresent($Name)
    7575  {
    7676    return(array_key_exists($Name, $this->Modules));
    7777  }
    78  
     78
    7979  function RegisterModule(AppModule $Module)
    8080  {
    81     $this->Modules[$Module->Name] = &$Module; 
    82     $Module->Manager = &$this;
    83     $Module->OnChange = &$this->OnModuleChange;
     81    if(!isset($this->Modules[$Module->Name]))
     82    {
     83      $this->Modules[$Module->Name] = &$Module;
     84      $Module->Manager = &$this;
     85      $Module->OnChange = &$this->OnModuleChange;
     86    } else throw new Exception('Module '.$Module->Name.' redefined');
    8487  }
    85  
     88
    8689  function UnregisterModule($Module)
    8790  {
    88     unset($this->Modules[array_search($Module, $this->Modules)]); 
     91    unset($this->Modules[array_search($Module, $this->Modules)]);
    8992  }
    90  
     93
    9194  /* @return Module */
    9295  function SearchModuleById($Id)
     
    98101    }
    99102    return('');
    100   } 
     103  }
    101104}
  • trunk/includes/Database.php

    r770 r800  
    88  var $PDOStatement;
    99  var $num_rows = 0;
    10  
     10
    1111  function fetch_assoc()
    1212  {
    1313    return($this->PDOStatement->fetch(PDO::FETCH_ASSOC));
    1414  }
    15  
     15
    1616  function fetch_array()
    1717  {
     
    2929  var $Prefix;
    3030  var $Functions;
    31   var $Type; 
     31  var $Type;
    3232  var $PDO;
    3333  var $Error;
     
    3737  var $ShowSQLQuery;
    3838  var $LogFile;
    39  
     39
    4040  function __construct()
    41   {   
     41  {
    4242        $this->Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()');
    4343        $this->Type = 'mysql'; // mysql, pgsql
     
    4747        $this->LogFile = dirname(__FILE__).'/../Query.log';
    4848  }
    49  
     49
    5050  function Connect($Host, $User, $Password, $Database)
    51   {   
     51  {
    5252    if($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;
    5353      else if($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host;
     
    5555    $this->PDO = new PDO($ConnectionString, $User, $Password);
    5656  }
    57  
     57
    5858  function select_db($Database)
    5959  {
    6060    $this->query('USE `'.$Database.'`');
    6161  }
    62  
     62
    6363  function query($Query)
    6464  {
     
    6767    $Result = new DatabaseResult();
    6868    $Result->PDOStatement = $this->PDO->query($Query);
    69     if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) 
    70       $Duration = ' ; '.round(microtime() - $QueryStartTime, 3). ' s';
     69    if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
     70      $Duration = ' ; '.round(microtime() - $QueryStartTime, 4). ' s';
    7171    if($this->LogSQLQuery == true)
    7272      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
     
    8181      $this->Error = $this->PDO->errorInfo();
    8282      $this->Error = $this->Error[2];
    83       if(($this->Error != '') and ($this->ShowSQLError == true)) 
     83      if(($this->Error != '') and ($this->ShowSQLError == true))
    8484        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
    8585        throw new Exception('SQL Error: '.$this->Error);
    8686    }
    87     return($Result); 
     87    return($Result);
    8888  }
    8989
    9090  function select($Table, $What = '*', $Condition = 1)
    91   {   
    92     return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition)); 
     91  {
     92    return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));
    9393  }
    9494
    9595  function delete($Table, $Condition)
    9696  {
    97     $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 
    98   }
    99  
     97    $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition);
     98  }
     99
    100100  function insert($Table, $Data)
    101101  {
     
    105105    {
    106106      $Name .= ',`'.$Key.'`';
    107       if(!in_array($Value, $this->Functions)) 
     107      if(!in_array($Value, $this->Functions))
    108108      {
    109109        if(is_null($Value)) $Value = 'NULL';
     
    114114    $Name = substr($Name, 1);
    115115    $Values = substr($Values, 1);
    116     $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 
     116    $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    117117    $this->insert_id = $this->PDO->lastInsertId();
    118118  }
    119  
     119
    120120  function update($Table, $Condition, $Data)
    121121  {
     
    123123    foreach($Data as $Key => $Value)
    124124    {
    125       if(!in_array($Value, $this->Functions)) 
     125      if(!in_array($Value, $this->Functions))
    126126      {
    127127        if(is_null($Value)) $Value = 'NULL';
     
    130130      $Values .= ', `'.$Key.'`='.$Value;
    131131    }
    132     $Values = substr($Values, 2); 
     132    $Values = substr($Values, 2);
    133133    $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
    134134  }
    135  
     135
    136136  function replace($Table, $Data)
    137137  {
     
    140140    foreach($Data as $Key => $Value)
    141141    {
    142       if(!in_array($Value, $this->Functions)) 
     142      if(!in_array($Value, $this->Functions))
    143143      {
    144144        if(is_null($Value)) $Value = 'NULL';
     
    154154    //echo($this->error().'<br>');
    155155  }
    156  
     156
    157157  function charset($Charset)
    158158  {
    159159    $this->query('SET NAMES "'.$Charset.'"');
    160160  }
    161  
     161
    162162  function real_escape_string($Text)
    163163  {
    164164    return(addslashes($Text));
    165165  }
    166  
     166
    167167  function quote($Text)
    168168  {
    169169        return($this->PDO->quote($Text));
    170170  }
    171  
     171
    172172  function __sleep()
    173173  {
     
    177177  function __wakeup()
    178178  {
    179   } 
     179  }
    180180}
    181181
     
    183183{
    184184  if($Time == NULL) return(NULL);
    185     else return(date('Y-m-d H:i:s', $Time)); 
     185    else return(date('Y-m-d H:i:s', $Time));
    186186}
    187187
     
    189189{
    190190  if($Time == NULL) return(NULL);
    191     else return(date('Y-m-d', $Time)); 
     191    else return(date('Y-m-d', $Time));
    192192}
    193193
     
    195195{
    196196  if($Time == NULL) return(NULL);
    197     else return(date('H:i:s', $Time)); 
     197    else return(date('H:i:s', $Time));
    198198}
    199199
    200200function MysqlDateTimeToTime($DateTime)
    201201{
    202   if($DateTime == '') return(0);     
     202  if($DateTime == '') return(0);
    203203  $Parts = explode(' ', $DateTime);
    204   $DateParts = explode('-', $Parts[0]); 
     204  $DateParts = explode('-', $Parts[0]);
    205205  $TimeParts = explode(':', $Parts[1]);
    206   $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 
    207   return($Result); 
     206  $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
     207  return($Result);
    208208}
    209209
     
    211211{
    212212  if($Date == '') return(0);
    213   return(MysqlDateTimeToTime($Date.' 0:0:0')); 
     213  return(MysqlDateTimeToTime($Date.' 0:0:0'));
    214214}
    215215
     
    217217{
    218218  if($Time == '') return(0);
    219   return(MysqlDateTimeToTime('0000-00-00 '.$Time)); 
    220 }
     219  return(MysqlDateTimeToTime('0000-00-00 '.$Time));
     220}
  • trunk/includes/Version.php

    r799 r800  
    66// and system will need database update.
    77
    8 $Revision = 799; // Subversion revision
     8$Revision = 800; // Subversion revision
    99$DatabaseRevision = 787; // Database structure revision
    10 $ReleaseTime = '2014-03-09';
     10$ReleaseTime = '2014-03-16';
  • trunk/includes/global.php

    r798 r800  
    1111include_once(dirname(__FILE__).'/AppModule.php');
    1212include_once(dirname(__FILE__).'/Locale.php');
     13require_once(dirname(__FILE__).'/../HTML/BBCodeParser2.php');
    1314
    1415// Include application modules
     
    3334include_once(dirname(__FILE__).'/../Modules/Download/Download.php');
    3435include_once(dirname(__FILE__).'/../Modules/Forum/Forum.php');
    35 require_once(dirname(__FILE__).'/../HTML/BBCodeParser2.php');
     36include_once(dirname(__FILE__).'/../Modules/Redirection/Redirection.php');
    3637
    3738
  • trunk/includes/system.php

    r798 r800  
    158158    $this->ModuleManager->RegisterModule(new ModuleDownload($System));
    159159    $this->ModuleManager->RegisterModule(new ModuleForum($System));
     160    $this->ModuleManager->RegisterModule(new ModuleRedirection($System));
    160161    $this->ModuleManager->StartAll();
    161162
     
    203204  function SearchPage($PathItems, $Pages)
    204205  {
    205     if(count($PathItems) > 0) $PathItem = $PathItems[0];
    206       else $PathItem = '';
     206    if(count($PathItems) == 0) $PathItems = array('');
     207    $PathItem = $PathItems[0];
    207208    if(array_key_exists($PathItem, $Pages))
    208209    {
     
    237238    /* @var $Page Page */
    238239    $ClassName = $this->SearchPage($this->PathItems, $this->Pages);
    239     if($ClassName != '')
     240    if(($ClassName != '') and (class_exists($ClassName)))
    240241    {
    241242      $Page = new $ClassName($this);
Note: See TracChangeset for help on using the changeset viewer.