Changeset 800 for trunk/includes
- Timestamp:
- Mar 16, 2014, 11:15:43 AM (11 years ago)
- Location:
- trunk/includes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/AppModule.php
r545 r800 6 6 var $Name; 7 7 var $Version; 8 var $License; 8 var $License; 9 9 var $Creator; 10 10 var $Description; … … 19 19 var $Manager; 20 20 var $OnChange; 21 21 22 22 function __construct($System) 23 23 { … … 27 27 $this->Dependencies = array(); 28 28 } 29 29 30 30 function Install() 31 31 { 32 32 } 33 33 34 34 function Uninstall() 35 35 { 36 36 } 37 37 38 38 function Start() 39 39 { 40 40 } 41 41 42 42 function Stop() 43 43 { 44 } 44 } 45 45 } 46 46 47 class AppModuleManager 47 class AppModuleManager 48 48 { 49 49 var $Modules; 50 50 51 51 function __construct() 52 52 { 53 $this->Modules = array(); 53 $this->Modules = array(); 54 54 } 55 55 56 56 function StartAll() 57 57 { … … 71 71 } 72 72 } 73 73 74 74 function ModulePresent($Name) 75 75 { 76 76 return(array_key_exists($Name, $this->Modules)); 77 77 } 78 78 79 79 function RegisterModule(AppModule $Module) 80 80 { 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'); 84 87 } 85 88 86 89 function UnregisterModule($Module) 87 90 { 88 unset($this->Modules[array_search($Module, $this->Modules)]); 91 unset($this->Modules[array_search($Module, $this->Modules)]); 89 92 } 90 93 91 94 /* @return Module */ 92 95 function SearchModuleById($Id) … … 98 101 } 99 102 return(''); 100 } 103 } 101 104 } -
trunk/includes/Database.php
r770 r800 8 8 var $PDOStatement; 9 9 var $num_rows = 0; 10 10 11 11 function fetch_assoc() 12 12 { 13 13 return($this->PDOStatement->fetch(PDO::FETCH_ASSOC)); 14 14 } 15 15 16 16 function fetch_array() 17 17 { … … 29 29 var $Prefix; 30 30 var $Functions; 31 var $Type; 31 var $Type; 32 32 var $PDO; 33 33 var $Error; … … 37 37 var $ShowSQLQuery; 38 38 var $LogFile; 39 39 40 40 function __construct() 41 { 41 { 42 42 $this->Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()'); 43 43 $this->Type = 'mysql'; // mysql, pgsql … … 47 47 $this->LogFile = dirname(__FILE__).'/../Query.log'; 48 48 } 49 49 50 50 function Connect($Host, $User, $Password, $Database) 51 { 51 { 52 52 if($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database; 53 53 else if($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host; … … 55 55 $this->PDO = new PDO($ConnectionString, $User, $Password); 56 56 } 57 57 58 58 function select_db($Database) 59 59 { 60 60 $this->query('USE `'.$Database.'`'); 61 61 } 62 62 63 63 function query($Query) 64 64 { … … 67 67 $Result = new DatabaseResult(); 68 68 $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'; 71 71 if($this->LogSQLQuery == true) 72 72 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); … … 81 81 $this->Error = $this->PDO->errorInfo(); 82 82 $this->Error = $this->Error[2]; 83 if(($this->Error != '') and ($this->ShowSQLError == true)) 83 if(($this->Error != '') and ($this->ShowSQLError == true)) 84 84 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); 85 85 throw new Exception('SQL Error: '.$this->Error); 86 86 } 87 return($Result); 87 return($Result); 88 88 } 89 89 90 90 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)); 93 93 } 94 94 95 95 function delete($Table, $Condition) 96 96 { 97 $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 98 } 99 97 $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 98 } 99 100 100 function insert($Table, $Data) 101 101 { … … 105 105 { 106 106 $Name .= ',`'.$Key.'`'; 107 if(!in_array($Value, $this->Functions)) 107 if(!in_array($Value, $this->Functions)) 108 108 { 109 109 if(is_null($Value)) $Value = 'NULL'; … … 114 114 $Name = substr($Name, 1); 115 115 $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.')'); 117 117 $this->insert_id = $this->PDO->lastInsertId(); 118 118 } 119 119 120 120 function update($Table, $Condition, $Data) 121 121 { … … 123 123 foreach($Data as $Key => $Value) 124 124 { 125 if(!in_array($Value, $this->Functions)) 125 if(!in_array($Value, $this->Functions)) 126 126 { 127 127 if(is_null($Value)) $Value = 'NULL'; … … 130 130 $Values .= ', `'.$Key.'`='.$Value; 131 131 } 132 $Values = substr($Values, 2); 132 $Values = substr($Values, 2); 133 133 $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'); 134 134 } 135 135 136 136 function replace($Table, $Data) 137 137 { … … 140 140 foreach($Data as $Key => $Value) 141 141 { 142 if(!in_array($Value, $this->Functions)) 142 if(!in_array($Value, $this->Functions)) 143 143 { 144 144 if(is_null($Value)) $Value = 'NULL'; … … 154 154 //echo($this->error().'<br>'); 155 155 } 156 156 157 157 function charset($Charset) 158 158 { 159 159 $this->query('SET NAMES "'.$Charset.'"'); 160 160 } 161 161 162 162 function real_escape_string($Text) 163 163 { 164 164 return(addslashes($Text)); 165 165 } 166 166 167 167 function quote($Text) 168 168 { 169 169 return($this->PDO->quote($Text)); 170 170 } 171 171 172 172 function __sleep() 173 173 { … … 177 177 function __wakeup() 178 178 { 179 } 179 } 180 180 } 181 181 … … 183 183 { 184 184 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)); 186 186 } 187 187 … … 189 189 { 190 190 if($Time == NULL) return(NULL); 191 else return(date('Y-m-d', $Time)); 191 else return(date('Y-m-d', $Time)); 192 192 } 193 193 … … 195 195 { 196 196 if($Time == NULL) return(NULL); 197 else return(date('H:i:s', $Time)); 197 else return(date('H:i:s', $Time)); 198 198 } 199 199 200 200 function MysqlDateTimeToTime($DateTime) 201 201 { 202 if($DateTime == '') return(0); 202 if($DateTime == '') return(0); 203 203 $Parts = explode(' ', $DateTime); 204 $DateParts = explode('-', $Parts[0]); 204 $DateParts = explode('-', $Parts[0]); 205 205 $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); 208 208 } 209 209 … … 211 211 { 212 212 if($Date == '') return(0); 213 return(MysqlDateTimeToTime($Date.' 0:0:0')); 213 return(MysqlDateTimeToTime($Date.' 0:0:0')); 214 214 } 215 215 … … 217 217 { 218 218 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 6 6 // and system will need database update. 7 7 8 $Revision = 799; // Subversion revision8 $Revision = 800; // Subversion revision 9 9 $DatabaseRevision = 787; // Database structure revision 10 $ReleaseTime = '2014-03- 09';10 $ReleaseTime = '2014-03-16'; -
trunk/includes/global.php
r798 r800 11 11 include_once(dirname(__FILE__).'/AppModule.php'); 12 12 include_once(dirname(__FILE__).'/Locale.php'); 13 require_once(dirname(__FILE__).'/../HTML/BBCodeParser2.php'); 13 14 14 15 // Include application modules … … 33 34 include_once(dirname(__FILE__).'/../Modules/Download/Download.php'); 34 35 include_once(dirname(__FILE__).'/../Modules/Forum/Forum.php'); 35 require_once(dirname(__FILE__).'/../HTML/BBCodeParser2.php');36 include_once(dirname(__FILE__).'/../Modules/Redirection/Redirection.php'); 36 37 37 38 -
trunk/includes/system.php
r798 r800 158 158 $this->ModuleManager->RegisterModule(new ModuleDownload($System)); 159 159 $this->ModuleManager->RegisterModule(new ModuleForum($System)); 160 $this->ModuleManager->RegisterModule(new ModuleRedirection($System)); 160 161 $this->ModuleManager->StartAll(); 161 162 … … 203 204 function SearchPage($PathItems, $Pages) 204 205 { 205 if(count($PathItems) > 0) $PathItem = $PathItems[0];206 else $PathItem = '';206 if(count($PathItems) == 0) $PathItems = array(''); 207 $PathItem = $PathItems[0]; 207 208 if(array_key_exists($PathItem, $Pages)) 208 209 { … … 237 238 /* @var $Page Page */ 238 239 $ClassName = $this->SearchPage($this->PathItems, $this->Pages); 239 if( $ClassName != '')240 if(($ClassName != '') and (class_exists($ClassName))) 240 241 { 241 242 $Page = new $ClassName($this);
Note:
See TracChangeset
for help on using the changeset viewer.