Changeset 42
- Timestamp:
- Nov 24, 2009, 9:13:38 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 20 added
- 18 deleted
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Model/User.php
r40 r42 7 7 var $DefaultRole = 2; 8 8 var $OnlineStateTimeout = 600; // in seconds 9 var $AnonymousUserId = 1; 9 10 10 11 var $Roles = array('Unknown', 'Anonymous', 'User', 'Administrator'); … … 24 25 { 25 26 $this->System->Modules['User']->Data['Id'] = $DbRow['User']; 26 if($DbRow['User'] != $this-> Config['Web']['UserAnonymousId']) $this->System->Modules['Log']->NewRecord('User', 'Logout');27 if($DbRow['User'] != $this->AnonymousUserId) $this->System->Modules['Log']->NewRecord('User', 'Logout'); 27 28 $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']); 28 29 } … … 31 32 $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"'); 32 33 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']));34 $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress()), 'ScriptName' => $_SERVER['PHP_SELF'])); 34 35 //echo($this->Database->LastQuery); 35 36 … … 37 38 $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"'); 38 39 $Row = $Query->fetch_assoc(); 39 if($Row['User'] != $this-> Config['Web']['UserAnonymousId'])40 if($Row['User'] != $this->AnonymousUserId) 40 41 { 41 42 $Query = $this->Database->select('User', '*', 'Id='.$Row['User']); … … 44 45 } else 45 46 { 46 $Query = $this->Database->select('User', '*', 'Id='.$this-> Config['Web']['UserAnonymousId']);47 $Query = $this->Database->select('User', '*', 'Id='.$this->AnonymousUserId); 47 48 $this->Data = $Query->fetch_assoc(); 48 49 $Result = $this->System->Translate('UserNotLogged'); … … 83 84 84 85 $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";86 $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/">http://'.$Config['System']['Host'].$Config['System']['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['System']['Host'].$Config['System']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'">http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$this->PasswordHash($Login, $Password).'</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte."; 87 $AdditionalHeaders = "To: ".$Name." <".$Email.">\n"."From: ".FromUTF8($Config['System']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8"; 87 88 mail($Email, $Subject, $Message, $AdditionalHeaders); 88 89 $Result = $this->System->Translate('UserRegistrated'); … … 136 137 { 137 138 $SID = session_id(); 138 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $this-> Config['Web']['UserAnonymousId']));139 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $this->AnonymousUserId)); 139 140 $this->System->Modules['Log']->NewRecord('User', 'Logout', $this->Data['Login']); 140 141 $this->Check(); … … 221 222 222 223 $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";224 $Message = 'Požádali jste o zaslání nového hesla na serveru <a href="http://'.$Config['System']['Host'].$Config['System']['RootFolder'].'">http://'.$Config['System']['Host'].$Config['System']['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['System']['Host'].$Config['System']['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."; 225 $AdditionalHeaders = "To: ".$Row['Name']." <".$Row['Email'].">\n"."From: ".FromUTF8($Config['System']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8"; 225 226 mail($Row['Email'], $Subject, $Message, $AdditionalHeaders); 226 227 $Output = $this->System->Translate('UserPasswordRecoverySuccess'); -
trunk/Application/View/User.php
r40 r42 57 57 $Output = $Form->ShowEditForm(); 58 58 $Output .= '<div class="Centred">'; 59 if($Config[' Web']['UserRegistrationEnabled'])59 if($Config['System']['UserRegistrationEnabled']) 60 60 $Output .= '<a href="?Module=User&Action=Register">Registrovat se</a> '; 61 61 $Output .= '<a href="?Module=User&Action=PasswordRecovery">Obnova zapomenutého hesla</a></div>'; … … 85 85 global $Config; 86 86 87 if($Config[' Web']['UserRegistrationEnabled'])87 if($Config['System']['UserRegistrationEnabled']) 88 88 { 89 89 $Form = new Form($this->System, $this->RegisterFormClass, array()); … … 166 166 global $Config; 167 167 168 if($Config[' Web']['UserRegistrationEnabled'])168 if($Config['System']['UserRegistrationEnabled']) 169 169 { 170 170 $Form = new Form($this->System, $this->RegisterFormClass); … … 181 181 global $Config; 182 182 183 if($Config[' Web']['UserRegistrationEnabled'])183 if($Config['System']['UserRegistrationEnabled']) 184 184 { 185 185 $Page = new PageView($this->System); -
trunk/Base/Controller.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Module.php'); 2 4 3 5 class Controller extends Module 4 6 { 7 function OnAccessDenied($Action, $Id) 8 { 9 return($this->System->Output->SystemMessage('Nemáte oprávnění provést akci "'.$Action.'" modulu "'.substr(get_class($this), 0, -10).'" na položce "'.$Id.'"')); 10 } 11 12 function Process() 13 { 14 if(array_key_exists('A', $_GET)) $Action = $_GET['A']; 15 else $Action = 'Show'; 16 if(method_exists($this, $Action)) 17 { 18 if(array_key_exists('Id', $_GET)) $Id = $_GET['Id']; 19 else $Id = ''; 20 if($this->System->Modules['Permission']->Check(substr(get_class($this), 0, -10), $Action, $Id)) 21 return($this->$Action()); 22 else return($this->OnAccessDenied($Action, $Id)); 23 } else return($this->System->Output->SystemMessage('Metoda "'.$Action.'" modulu "'.get_class($this).'" nenalezena.')); 24 } 25 26 function RequireParameter($Name) 27 { 28 //if(!array_key_exists($Name, $_GET)) return($this->System->SystemMessage('Přístup zamítnut.'); 29 } 5 30 } 6 31 -
trunk/Base/Database.php
r40 r42 4 4 // Date: 2009-02-16 5 5 6 7 6 class Database extends mysqli 8 7 { 9 8 var $Prefix = ''; 10 9 var $Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()'); 10 var $ShowSQLQuery = false; 11 var $ShowSQLError = false; 11 12 12 13 function query($Query) 13 { 14 global $Config; 15 16 if($Config['Web']['ShowSQLQuery'] == true) 14 { 15 if($this->ShowSQLQuery) 17 16 { 18 17 if(isset($_SERVER['REMOTE_ADDR'])) echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'); … … 20 19 } 21 20 $Result = parent::query($Query); 22 if(($this->error != '') and ($ Config['Web']['ShowSQLError'] == true))21 if(($this->error != '') and ($this->ShowSQLError)) 23 22 { 24 23 if(isset($_SERVER['REMOTE_ADDR'])) echo('<div><strong>SQL Error: </strong>'.$this->error.'<br />'.$Query.'</div>'); … … 87 86 $this->query('SET NAMES "'.$Charset.'"'); 88 87 } 89 88 90 89 function TimeToMysqlDateTime($Time) 91 90 { 92 return(date('Y-m-d H:i:s', $Time)); 91 return(date('Y-m-d H:i:s', $Time)); 93 92 } 94 93 … … 96 95 { 97 96 $Parts = explode(' ', $Time); 98 $DateParts = explode('-', $Parts[0]); 97 $DateParts = explode('-', $Parts[0]); 99 98 $TimeParts = explode(':', $Parts[1]); 100 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 101 return($Result); 99 $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 100 return($Result); 102 101 } 103 102 104 103 function MysqlDateToTime($Time) 105 104 { 106 return(MysqlDateTimeToTime($Time.' 0:0:0')); 107 } 105 return(MysqlDateTimeToTime($Time.' 0:0:0')); 106 } 108 107 } 109 108 -
trunk/Base/Error.php
r40 r42 5 5 global $Config; 6 6 7 $Date = date('Y-m-d H:i:s'); 7 $Date = date('Y-m-d H:i:s'); // časové razítko položky 8 8 $ErrorType = array 9 9 ( … … 53 53 //if($Config['Web']['ErrorLogFile'] != '') 54 54 //error_log($Error, 3, $Config['Web']['ErrorLogFile']); 55 55 // Pošli mi zprávu (pokud je to kritická chyba) 56 56 //mail($Config['Web']['AdminEmail'], $Config['Web']['Title'].' - Chybové hlášení', $Error); 57 58 if($Config['Web']['ShowPHPError'] == true)59 60 57 // Show error message 58 if($Config['System']['ShowPHPError'] == true) 59 { 60 echo('<?xml version="1.0" encoding="utf-8"?>'."\n". 61 61 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'. 62 62 '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">'. … … 65 65 '</head><body>'. 66 66 'Došlo k vnitřní chybě!<br /> O chybě byl uvědoměn správce webu a chybu brzy odstraní.<br /><br />'); 67 echo('<pre>'.$Error.'</pre><br />');// V případě ladění chybu i zobraz67 echo('<pre>'.$Error.'</pre><br />'); // V případě ladění chybu i zobraz 68 68 echo('</body></html>'); 69 69 } 70 70 if((E_ERROR | E_PARSE) & $Number) die(); 71 71 } -
trunk/Base/Model.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Module.php'); 2 4 3 5 class Model extends Module -
trunk/Base/System.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Database.php'); 4 include_once(dirname(__FILE__).'/HTML/XHTML.php'); 5 include_once(dirname(__FILE__).'/HTML/HTML.php'); 6 include_once(dirname(__FILE__).'/HTTP.php'); 7 include_once(dirname(__FILE__).'/Types/Type.php'); 8 include_once(dirname(__FILE__).'/Output.php'); 9 include_once(dirname(__FILE__).'/Permission.php'); 10 11 $MonthNames = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec'); 2 12 3 13 $PrefixMultipliers = array … … 76 86 class System 77 87 { 78 var $Modules = array(); 88 var $Model = array(); 89 var $View = array(); 90 var $Controller = array(); 91 var $Config; 79 92 var $Database; 80 var $Config; 93 var $HTTP; 94 var $HTML; 95 var $Type; 96 var $TimeStart; 97 var $Translation; 98 var $Output; 99 var $DefaultModule; 100 var $Modules = array(); 101 102 function __construct() 103 { 104 global $ShowPHPError; 105 106 $TimeStart = $this->GetMicrotime(); 107 108 // Change base dir to index. Helpfull if script is executed from command line with related path. 109 chdir(dirname(__FILE__)); 110 111 $this->Output = new Output($this); 112 113 $FileName = dirname(__FILE__).'/Config/Config.php'; 114 if(file_exists($FileName)) include($FileName); 115 else { 116 $this->Output->Show($this->Output->SystemMessage('Configuration file "'.$FileName.'" not found.')); 117 exit; 118 } 119 120 $FileName = dirname(__FILE__).'/../Application/Config/Config.php'; 121 if(file_exists($FileName)) include($FileName); 122 123 $this->Config = $Config; 124 125 $ShowPHPError = $this->Config['System']['ShowPHPError']; 126 127 $FileName = dirname(__FILE__).'/../Application/Locale/'.$this->Config['System']['Locale'].'.php'; 128 if(file_exists($FileName)) include($FileName); 129 else { 130 $this->Output->Show($this->Output->SystemMessage('Translation file "'.$FileName.'" not found.')); 131 exit; 132 } 133 $this->Translation = $Translation; 134 135 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 136 $this->Database = new Database($this->Config['Database']['Host'], 137 $this->Config['Database']['User'], $this->Config['Database']['Password'], 138 $this->Config['Database']['Database']); 139 $this->Database->ShowSQLQuery = $this->Config['System']['ShowSQLQuery']; 140 $this->Database->ShowSQLError = $this->Config['System']['ShowSQLError']; 141 $this->Database->Prefix = $this->Config['Database']['Prefix']; 142 $this->Database->charset($this->Config['Database']['Charset']); 143 144 $this->HTTP = new HTTP(); 145 $this->HTML = new HTML($this); 146 $this->Type = new Type($this); 147 $this->AddModule('Permission'); 148 } 149 150 function Run() 151 { 152 $this->TimeStart = $this->GetMicrotime(); 153 154 // SQL injection hack protection 155 foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); 156 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 157 158 if(array_key_exists('M', $_GET)) $Module = $_GET['M']; 159 else $Module = $this->DefaultModule; 160 161 $ControllerName = $Module.'Controller'; 162 $FileName = dirname(__FILE__).'/../Application/Controller/'.$Module.'.php'; 163 if(!file_exists($FileName)) 164 { 165 $this->Output->Show($this->Output->SystemMessage('Soubor '.$FileName.' nenalezen.')); 166 exit; 167 } else include($FileName); 168 if(class_exists($ControllerName)) 169 { 170 $Controller = new $ControllerName($this); 171 $this->Output->Show($Controller->Process()); 172 } else $this->Output->Show($this->Output->SystemMessage('Modul "'.$ControllerName.'" nenalezen.')); 173 } 81 174 82 175 function ModulePresent($Name) … … 85 178 } 86 179 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); 180 function AddModule($Name) 181 { 182 $this->Modules[$Name] = new $Name($this); 120 183 } 121 184 … … 172 235 { 173 236 set_error_handler('ErrorHandler'); 174 if($Socket = @fsockopen($Address, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout)) 237 $Socket = @fsockopen($Address, $Port, $ERROR_NO, $ERROR_STR, (float)$Timeout); 238 if($Socket) 175 239 { 176 240 fclose($Socket); … … 180 244 return($Result); 181 245 } 182 246 247 function Translate($Text) 248 { 249 if(array_key_exists($Text, $this->Translation)) return($this->Translation[$Text]); 250 else return('#'.$Text); 251 } 252 253 function MakeLink($Module, $Action, $Parameters = array()) 254 { 255 $Parameters = $this->HTTP->SetQueryStringArray($Parameters); 256 if($Parameters != '') $Parameters = '&'.$Parameters; 257 return('?M='.$Module.'&A='.$Action.$Parameters); 258 } 259 260 function GetRemoteAddress() 261 { 262 if(array_key_exists('HTTP_X_FORWARDED_FOR',$_SERVER)) $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ; 263 else if(array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR']; 264 else $IP = '0.0.0.0'; 265 return($IP); 266 } 267 183 268 function GetMicrotime() 184 269 { 185 270 list($Usec, $Sec) = explode(' ', microtime()); 186 271 return((float)$Usec + (float)$Sec); 187 } 188 189 function Translate($Text)190 { 191 global $Translation;192 193 if(array_key_exists($Text, $Translation)) return($Translation[$Text]);194 else return('#'.$Text);272 } 273 274 function RemoveDiacritic($Text) 275 { 276 return(str_replace( 277 array('á', 'č', 'ď', 'é', 'ě', 'í', 'ľ', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 'ý', 'ž', 'Á', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ľ', 'Ň', 'Ó', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ý', 'Ž'), 278 array('a', 'c', 'd', 'e', 'e', 'i', 'l', 'n', 'o', 'r', 's', 't', 'u', 'u', 'y', 'z', 'A', 'C', 'D', 'E', 'E', 'I', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'U', 'Y', 'Z'), 279 $Text)); 195 280 } 196 281 } -
trunk/Base/Types/Base.php
r40 r42 1 1 <?php 2 2 3 class TypeBase extends Module3 class TypeBase 4 4 { 5 var $System; 5 6 var $DatabaseCompareOperators = array(); 7 8 function __construct($System) 9 { 10 $this->System = $System; 11 } 6 12 7 13 function OnView($Item) -
trunk/Base/Types/Boolean.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeBoolean extends TypeBase … … 8 10 { 9 11 if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 10 return('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.' >');12 return('<input type="checkbox" name="'.$Item['Name'].'" disabled="1"'.$Checked.'/>'); 11 13 } 12 14 … … 14 16 { 15 17 if($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = ''; 16 return('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.' >');18 return('<input type="checkbox" name="'.$Item['Name'].'"'.$Checked.'/>'); 17 19 } 18 20 -
trunk/Base/Types/Date.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeDate extends TypeBase -
trunk/Base/Types/DateTime.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeDateTime extends TypeBase -
trunk/Base/Types/Enumeration.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeEnumeration extends TypeBase … … 5 7 function OnView($Item) 6 8 { 7 $Type = GetTypeDefinition($Item['Type']); 8 $Output = $Type['Parameters'][$Item['Value']]; 9 $Type = $this->System->Type->GetTypeDefinition($Item['Type']); 10 if(array_key_exists($Item['Value'], $Type['Parameters'])) 11 $Output = $Type['Parameters'][$Item['Value']]; 12 else $Output = $Item['Value']; 9 13 return($Output); 10 14 } … … 12 16 function OnEdit($Item) 13 17 { 14 $Type = GetTypeDefinition($Item['Type']);18 $Type = $this->System->Type->GetTypeDefinition($Item['Type']); 15 19 $Output = '<select name="'.$Item['Name'].'">'; 16 20 foreach($Type['Parameters'] as $Index => $StateName) -
trunk/Base/Types/Float.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeFloat extends TypeBase … … 13 15 function OnEdit($Item) 14 16 { 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'" >';17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 18 return($Output); 17 19 } -
trunk/Base/Types/GPS.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeGPS extends TypeBase … … 31 33 } else $DbRow = array('Longitude' => 0, 'Latitude' => 0); 32 34 $Value = $this->Explode($DbRow['Latitude']); 33 $Output = '<input type="text" size="3" name="'.$Item['Name'].'-lat-deg" value="'.$Value[0].'" >°';34 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-min" value="'.$Value[1].'" >\'';35 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-sec" value="'.$Value[2].'" >"<br />';35 $Output = '<input type="text" size="3" name="'.$Item['Name'].'-lat-deg" value="'.$Value[0].'"/>°'; 36 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-min" value="'.$Value[1].'"/>\''; 37 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lat-sec" value="'.$Value[2].'"/>"<br />'; 36 38 $Value = $this->Explode($DbRow['Longitude']); 37 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-deg" value="'.$Value[0].'" >°';38 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'" >\'';39 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'" >"';39 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-deg" value="'.$Value[0].'"/>°'; 40 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-min" value="'.$Value[1].'"/>\''; 41 $Output .= '<input type="text" size="3" name="'.$Item['Name'].'-lon-sec" value="'.$Value[2].'"/>"'; 40 42 return($Output); 41 43 } -
trunk/Base/Types/Hidden.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeHidden extends TypeBase … … 11 13 function OnEdit($Item) 12 14 { 13 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" >';15 $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />'; 14 16 return($Output); 15 17 } -
trunk/Base/Types/Hyperlink.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeHyperlink extends TypeBase … … 11 13 function OnEdit($Item) 12 14 { 13 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'" >';15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 14 16 return($Output); 15 17 } -
trunk/Base/Types/IPv4Address.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeIPv4Address extends TypeBase … … 11 13 function OnEdit($Item) 12 14 { 13 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'" >';15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 14 16 return($Output); 15 17 } -
trunk/Base/Types/Integer.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeInteger extends TypeBase … … 13 15 function OnEdit($Item) 14 16 { 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'" >';17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 18 return($Output); 17 19 } -
trunk/Base/Types/Password.php
r40 r42 2 2 3 3 // SHA1 hash used 4 5 include_once(dirname(__FILE__).'/Base.php'); 4 6 5 7 class TypePassword extends TypeBase … … 15 17 function OnEdit($Item) 16 18 { 17 $Output = '<input type="password" name="'.$Item['Name'].'" value="" >';19 $Output = '<input type="password" name="'.$Item['Name'].'" value=""/>'; 18 20 return($Output); 19 21 } -
trunk/Base/Types/PointerOneToMany.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypePointerOneToMany extends TypeBase -
trunk/Base/Types/PointerOneToOne.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypePointerOneToOne extends TypeBase … … 5 7 function OnView($Item) 6 8 { 7 global $TypeDefinitionList; 8 9 $Type = $TypeDefinitionList[$Item['Type']]; 10 $DbResult = $this->Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name FROM `'.$Type['Parameters']['Table'].'` WHERE `'.$Type['Parameters']['Id'].'`='.$Item['Value']); 9 $Type = $this->System->Type->TypeDefinitionList[$Item['Type']]; 10 $DbResult = $this->System->Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name FROM `'.$Type['Parameters']['Table'].'` WHERE `'.$Type['Parameters']['Id'].'`='.$Item['Value']); 11 11 $DbRow = $DbResult->fetch_assoc(); 12 $Output = $DbRow['Name']; 13 14 /* $Type = GetTypeDefinition($Item['Type']); 15 $List = GetListDefinition($Type['Parameters'][0]); 16 $TargetTable = $Type['Parameters'][0]; 17 $TargetName = $this->GetTablePointerName($Type, $Item); 18 if($TargetName != '') $Output = '<a href="?Action=ViewItem&Table='.$TargetTable.'&Item='.$TargetName[$List['IdName']].'">'.$TargetName['Name'].'</a>'; 19 else $Output = ''; 20 */ 12 if($this->System->Modules['Permission']->Check('Corporation', 'Show')) 13 $Output = $this->System->HTML->MakeLink($DbRow['Name'], $this->System->MakeLink($Type['Parameters']['Table'], 'Show', array('Id' => $Item['Value']))); 14 else $Output = $DbRow['Name']; 21 15 return($Output); 22 16 } … … 24 18 function OnEdit($Item) 25 19 { 26 global $TypeDefinitionList;27 28 20 $Output = '<select name="'.$Item['Name'].'">'; 29 $Type = $ TypeDefinitionList[$Item['Type']];21 $Type = $this->System->Type->TypeDefinitionList[$Item['Type']]; 30 22 if(array_key_exists('Condition', $Type['Parameters'])) $Where = ' WHERE '.$Type['Parameters']['Condition']; 31 23 else $Where = ''; 32 $DbResult = $this-> Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name,'.$Type['Parameters']['Id'].' AS Id FROM `'.$Type['Parameters']['Table'].'`'.$Where.' ORDER BY Name DESC');24 $DbResult = $this->System->Database->query('SELECT '.$Type['Parameters']['Name'].' AS Name,'.$Type['Parameters']['Id'].' AS Id FROM `'.$Type['Parameters']['Table'].'`'.$Where.' ORDER BY Name DESC'); 33 25 while($DbRow = $DbResult->fetch_assoc()) 34 26 { -
trunk/Base/Types/String.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeString extends TypeBase … … 13 15 function OnEdit($Item) 14 16 { 15 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'" >';17 $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>'; 16 18 return($Output); 17 19 } -
trunk/Base/Types/Text.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeText extends TypeBase -
trunk/Base/Types/Time.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Base.php'); 2 4 3 5 class TypeTime extends TypeBase -
trunk/Base/View.php
r40 r42 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Module.php'); 2 4 3 5 class View extends Module -
trunk/index.php
r40 r42 1 1 <?php 2 2 3 include('Include.php'); 4 if(array_key_exists('argv', $_SERVER)) 5 $_GET = array_merge($_GET, ParseCommandLineArgs($_SERVER['argv']));3 // Change current directory to script location 4 $BaseDir = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/')); 5 if($BaseDir != '') chdir($BaseDir); 6 6 7 // SQL injection hack protection 8 foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item); 9 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 7 include_once(dirname(__FILE__).'/Application/Application.php'); 10 8 11 if(isset($_SERVER['REMOTE_ADDR'])) session_start(); 12 13 $System = new System(); 14 $ScriptTimeStart = $System->GetMicrotime(); 15 $System->Database = new Database($Config['Database']['Host'], $Config['Database']['User'], $Config['Database']['Password'], $Config['Database']['Database']); 16 $System->Database->Prefix = $Config['Database']['Prefix']; 17 $System->Database->charset($Config['Database']['Charset']); 18 $System->Config = $Config; 19 $System->AddModule(new Log($System)); 20 $System->AddModule(new User($System)); 21 $System->AddModule(new Permission($System)); 22 if(isset($_SERVER['REMOTE_ADDR'])) $System->Modules['User']->Check(); 23 else $System->Modules['User']->Data['Id'] = $Config['Web']['UserConsoleId']; 24 $System->Modules['Permission']->LoadForUser($System->Modules['User']->Data['Id']); 25 //print_r($System->Modules['Permission']->Data); 26 27 if(array_key_exists('Module', $_GET)) $Module = $_GET['Module']; 28 else $Module = 'HomePage'; 29 if(array_key_exists('Action', $_GET)) $Action = $_GET['Action']; 30 else $Action = 'Show'; 31 32 $ControllerName = $Module.'Controller'; 33 if(class_exists($ControllerName)) 34 { 35 $Controller = new $ControllerName($System); 36 if(method_exists($Controller, $Action)) $Output = $Controller->$Action(); 37 else $Output = 'Metoda '.$Action.' modulu '.$Module.' neexistuje.'; 38 } else $Output = 'Třída '.$ControllerName.' neexistuje.'; 39 40 echo($Output); 9 $Application = new Application(); 10 $Application->Run(); 41 11 42 12 ?>
Note:
See TracChangeset
for help on using the changeset viewer.