Changeset 78 for trunk/www/Base
- Timestamp:
- Sep 11, 2009, 8:18:38 AM (15 years ago)
- Location:
- trunk/www/Base
- Files:
-
- 2 added
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/Base/Controller.php
r69 r78 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Model.php'); 2 4 3 5 class Controller extends Module 4 6 { 7 function Process() 8 { 9 if(array_key_exists('Action', $_GET)) $Action = $_GET['Action']; 10 else $Action = 'Show'; 11 if(method_exists($this, $Action)) 12 { 13 if($this->System->Modules['Permission']->Check(substr(get_class($this), 0, -10), $Action)) 14 return($this->$Action()); 15 else return('Nemáte oprávnění provést akci '.$Action.' modulu '.substr(get_class($this), 0, -10)); 16 } else return('Metoda '.$Action.' modulu '.get_class($this).' nenalezena.'); 17 } 5 18 } 6 19 -
trunk/www/Base/Form.php
r71 r78 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Types/Type.php'); 4 include_once(dirname(__FILE__).'/Module.php'); 5 include_once(dirname(__FILE__).'/Html.php'); 2 6 3 7 class Form extends Module -
trunk/www/Base/Global.php
r74 r78 6 6 $UnitNames = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB'); 7 7 8 function HumanSize($Value)9 {10 global $UnitNames;11 12 $UnitIndex = 0;13 while($Value > 1024)14 {15 $Value = round($Value / 1024, 3);16 $UnitIndex++;17 }18 return($Value.' '.$UnitNames[$UnitIndex]);19 }20 21 function HumanDate($Time)22 {23 $Date = explode(' ', $Time);24 $Parts = explode('-', $Date[0]);25 if($Date != '0000-00-00') return(($Parts[2]*1).'.'.($Parts[1]*1).'.'.$Parts[0]);26 else return(' ');27 }28 29 8 function TimeToHumanTime($Value) 30 9 { 31 10 return(floor($Value / 3600 / 24).' dnů, '.date('H:i:s', $Value - 3600)); 32 }33 34 function GetRemoteAddress()35 {36 if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;37 else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];38 else $IP = '0.0.0.0';39 return($IP);40 11 } 41 12 -
trunk/www/Base/Model.php
r69 r78 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Module.php'); 2 4 3 5 class Model extends Module -
trunk/www/Base/Module.php
r69 r78 10 10 { 11 11 $this->Database = $System->Database; 12 $this->Config = $System->Config;12 $this->Config = &$System->Config; 13 13 $this->System = $System; 14 14 } -
trunk/www/Base/System.php
r76 r78 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Database.php'); 4 include_once(dirname(__FILE__).'/Form.php'); 5 include_once(dirname(__FILE__).'/Table.php'); 6 include_once(dirname(__FILE__).'/Error.php'); 2 7 3 8 $PrefixMultipliers = array … … 79 84 var $Database; 80 85 var $Config; 86 var $TimeStart; 87 var $Translation; 88 89 function __construct() 90 { 91 // Change current directory to script location 92 $BaseDir = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/')); 93 if($BaseDir != '') chdir($BaseDir); 94 95 if(array_key_exists('argv', $_SERVER)) 96 $_GET = array_merge($_GET, ParseCommandLineArgs($_SERVER['argv'])); 97 98 // SQL injection hack protection 99 foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); 100 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 101 102 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 103 104 $FileName = dirname(__FILE__).'/../Application/Config/Config.php'; 105 if(file_exists($FileName)) include_once($FileName); 106 else die('Nenalezen soubor '.$FileName.'. Vytvořte jej kopií ze souboru ConfigSample.php umístěném ve stejné složce.'); 107 $this->Config = $Config; 108 109 $FileName = dirname(__FILE__).'/../Application/Localization/'.$Config['Web']['Locale'].'.php'; 110 if(file_exists($FileName)) include_once($FileName); 111 else die('Nenalezen soubor '.$FileName.'. Buď máte špatně nastaven jazyk nebo vám chybí jazykový soubor.'); 112 $this->Translation = $Translation; 113 114 $this->TimeStart = $this->GetMicrotime(); 115 $this->Database = new Database($this->Config['Database']['Host'], $this->Config['Database']['User'], $this->Config['Database']['Password'], $this->Config['Database']['Database']); 116 $this->Database->Prefix = $this->Config['Database']['Prefix']; 117 $this->Database->charset($this->Config['Database']['Charset']); 118 } 119 120 function Run() 121 { 122 if(array_key_exists('Module', $_GET)) $Module = $_GET['Module']; 123 else $Module = 'HomePage'; 124 125 $ControllerName = $Module.'Controller'; 126 $FileName = dirname(__FILE__).'/../Application/Controller/'.$Module.'.php'; 127 if(!file_exists($FileName)) 128 echo('Soubor '.$FileName.' nenalezen.'); 129 else include($FileName); 130 if(class_exists($ControllerName)) 131 { 132 $Controller = new $ControllerName($this); 133 echo($Controller->Process()); 134 } else echo('Modul '.$ControllerName.' nenalezen.'); 135 } 81 136 82 137 function ModulePresent($Name) … … 85 140 } 86 141 87 function AddModule($Module) 88 { 89 global $Database; 90 91 //echo('Přidávám modul '.get_class($Module).'<br />'); 92 $this->Modules[get_class($Module)] = $Module; 93 } 94 95 function AddEmailToQueue($Address, $Subject, $Content, $Headers = '') 96 { 97 $this->Database->insert('EmailQueue', array('Address' => $Address, 'Subject' => $Subject, 'Content' => $Content, 'Time' => 'NOW()', 'Headers' => $Headers)); 98 } 99 100 function MailUTF8($To, $Subject = '(No subject)', $Message = '', $Header = '') 101 { 102 $Header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n".$Header; 103 mail($To, '=?UTF-8?B?'.base64_encode($Subject).'?=', $Message, $Header); 104 //echo('mail('.$To.', =?UTF-8?B?'.base64_encode($Subject).'?=, '.$Message.', '.$Header.')<br/>'); 105 } 106 107 function ProcessEmailQueue() 108 { 109 $Output = ''; 110 $DbResult = $this->Database->select('EmailQueue', '*', 'Archive=0'); 111 while($DbRow = $DbResult->fetch_assoc()) 112 { 113 $this->MailUTF8($DbRow['Address'], $DbRow['Subject'], $DbRow['Content'], $DbRow['Headers']); 114 //echo('mail('.$DbRow['Address'].', '.$DbRow['Subject'].', '.$DbRow['Content'].', FromUTF8('.$DbRow['Headers'].', \'iso2\'));'); 115 $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1)); 116 $this->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']); 117 $Output .= 'To: '.$DbRow['Address'].' Subject: '.$DbRow['Subject'].'<br />'; 118 } 119 return($Output); 142 function AddModule($Name) 143 { 144 $this->Modules[$Name] = new $Name($this); 120 145 } 121 146 … … 189 214 function Translate($Text) 190 215 { 191 global $Translation; 192 193 if(array_key_exists($Text, $Translation)) return($Translation[$Text]); 216 if(array_key_exists($Text, $this->Translation)) return($this->Translation[$Text]); 194 217 else return('#'.$Text); 195 218 } 219 220 function GetRemoteAddress() 221 { 222 if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ; 223 else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; 224 else $IP = '0.0.0.0'; 225 return($IP); 226 } 196 227 } 197 228 -
trunk/www/Base/Table.php
r71 r78 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Types/Type.php'); 2 4 3 5 class Table -
trunk/www/Base/Types/Base.php
r71 r78 1 1 <?php 2 3 include_once(dirname(__FILE__).'/../Module.php'); 2 4 3 5 class TypeBase extends Module -
trunk/www/Base/View.php
r69 r78 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Module.php'); 2 4 3 5 class View extends Module
Note:
See TracChangeset
for help on using the changeset viewer.