Changeset 67
- Timestamp:
- Jan 3, 2016, 11:52:37 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application.php
r64 r67 3 3 class Application 4 4 { 5 var $Database; 6 5 7 function Start() 6 8 { 7 global $Config, $Database ;9 global $Config, $DatabaseRevision; 8 10 9 11 $FileName = dirname(__FILE__).'/config.php'; … … 19 21 $ErrorHandler->Start(); 20 22 21 $ Database = new Database();22 $ Database->Connect($Config['Database']['Host'], $Config['Database']['User'],23 $this->Database = new Database(); 24 $this->Database->Connect($Config['Database']['Host'], $Config['Database']['User'], 23 25 $Config['Database']['Password'], $Config['Database']['Database']); 24 $ Database->Prefix = $Config['Database']['Prefix'];25 $ Database->charset($Config['Database']['Charset']);26 $ Database->ShowSQLError = $Config['Web']['ShowSQLError'];27 $ Database->ShowSQLQuery = $Config['Web']['ShowSQLQuery'];26 $this->Database->Prefix = $Config['Database']['Prefix']; 27 $this->Database->charset($Config['Database']['Charset']); 28 $this->Database->ShowSQLError = $Config['Web']['ShowSQLError']; 29 $this->Database->ShowSQLQuery = $Config['Web']['ShowSQLQuery']; 28 30 29 31 // SQL injection hack protection … … 31 33 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item); 32 34 35 // Check database persistence structure 36 $UpdateManager = new UpdateManager(); 37 $UpdateManager->Database = $this->Database; 38 $UpdateManager->Revision = $DatabaseRevision; 39 if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze.'); 40 if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.'); 41 33 42 } 34 43 } -
trunk/Global.php
r64 r67 7 7 include_once('Measure.php'); 8 8 include_once('Application.php'); 9 include_once('Update.php'); 9 10 10 11 function HumanDate($Time) -
trunk/Graph.php
r64 r67 218 218 $Application = new Application(); 219 219 $Application->Start(); 220 $Graph = new MeasureGraph($ Database);220 $Graph = new MeasureGraph($this->Database); 221 221 $Graph->Render(); -
trunk/Version.php
r65 r67 1 1 <?php 2 2 3 $Revision = 65; 4 $ReleaseTime = strtotime('2016-01-01'); 3 // Subversion revision have to be updated always to next revision number 4 // before commiting new changes. 5 // Database revision have to be updated if database structure is changed 6 // and system will need database update. 7 8 $Revision = 67; 9 $DatabaseRevision = 67; 10 $ReleaseTime = strtotime('2016-01-03'); -
trunk/add.php
r64 r67 10 10 $MeasureId = addslashes($_GET['MeasureId']); 11 11 $Value = addslashes($_GET['Value']); 12 $Measure = new Measure($ Database);12 $Measure = new Measure($Application->Database); 13 13 $Measure->Load($MeasureId); 14 14 if(gethostbyaddr($_SERVER['REMOTE_ADDR']) == $Measure->Data['PermissionAdd']) -
trunk/admin.php
r64 r67 5 5 $Application->Start(); 6 6 7 if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = ''; 8 switch($Operation) 7 class AdminPage 9 8 { 10 case 'Add': 11 $Output = ShowAdd(); 12 break; 13 case 'Delete': 14 $Output = ShowDelete(); 15 break; 16 case 'Edit': 17 $Output = ShowEdit(); 18 break; 19 case 'RebuildCache': 20 $Output = ShowRebuildCache(); 21 break; 22 default: 23 $Output = ShowNone(); 9 function __construct($Database) 10 { 11 $this->Database = &$Database; 12 } 13 14 function Show() 15 { 16 if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = ''; 17 switch($Operation) 18 { 19 case 'Add': 20 $Output = $this->ShowAdd(); 21 break; 22 case 'Delete': 23 $Output = $this->ShowDelete(); 24 break; 25 case 'Edit': 26 $Output = $this->ShowEdit(); 27 break; 28 case 'RebuildCache': 29 $Output = $this->ShowRebuildCache(); 30 break; 31 default: 32 $Output = $this->ShowNone(); 33 } 34 ShowPage($Output); 35 } 36 37 function ShowNone() 38 { 39 $Table = array( 40 'Header' => array('Název veličiny', 'Operace'), 41 'Rows' => array(), 42 ); 43 44 $Result = $this->Database->select('measure', '*', '1 ORDER BY Description'); 45 while($Measure = $Result->fetch_array()) 46 { 47 array_push($Table['Rows'], array($Measure['Description'], MakeLink('?Operation=Edit&MeasureId='.$Measure['Id'], 'Editovat').' '.MakeLink('?Operation=Delete&MeasureId='.$Measure['Id'], 'Odstranit').' '.MakeLink('?Operation=RebuildCache&MeasureId='.$Measure['Id'], 'Přestavět cache'))); 48 } 49 $Output = '<h3>Seznam měření</h3>'.Table($Table).MakeLink('?Operation=Add', 'Přidat'); 50 return($Output); 51 } 52 53 function ShowEdit() 54 { 55 $DbResult = $this->Database->select('measure', '*', 'Id='.addslashes($_GET['MeasureId'])); 56 $Values = array(); 57 $Values = $DbResult->fetch_array(); 58 return($this->ShowEditTable('Measure', $Values)); 59 } 60 61 function ShowAdd() 62 { 63 $Values = array(); 64 return($this->ShowEditTable('Measure', $Values)); 65 } 66 67 function ShowRebuildCache() 68 { 69 echo("Vytvařím novou cache...<br>"); 70 $DbResult = $this->Database->select('measure', '*', 'Id='.addslashes($_GET['MeasureId'])); 71 $Measure = $DbResult->fetch_array(); 72 73 $Measure->RebuildMeasureCache(); 74 echo('Dokončeno<br>'); 75 } 24 76 } 25 ShowPage($Output);26 27 function ShowNone()28 {29 global $Database;30 $Table = array(31 'Header' => array('Název veličiny', 'Operace'),32 'Rows' => array(),33 );34 35 $Result = $Database->select('measure', '*', '1 ORDER BY Description');36 while($Measure = $Result->fetch_array())37 {38 array_push($Table['Rows'], array($Measure['Description'], MakeLink('?Operation=Edit&MeasureId='.$Measure['Id'], 'Editovat').' '.MakeLink('?Operation=Delete&MeasureId='.$Measure['Id'], 'Odstranit').' '.MakeLink('?Operation=RebuildCache&MeasureId='.$Measure['Id'], 'Přestavět cache')));39 }40 $Output = '<h3>Seznam měření</h3>'.Table($Table).MakeLink('?Operation=Add', 'Přidat');41 return($Output);42 }43 44 function ShowEdit()45 {46 global $Database;47 $DbResult = $Database->select('measure', '*', 'Id='.addslashes($_GET['MeasureId']));48 $Values = array();49 $Values = $DbResult->fetch_array();50 return(ShowEditTable('Measure', $Values));51 }52 53 function ShowAdd()54 {55 global $Database;56 $Values = array();57 return(ShowEditTable('Measure', $Values));58 }59 60 function ShowRebuildCache()61 {62 global $Database;63 echo("Vytvařím novou cache...<br>");64 $DbResult = $Database->select('measure', '*', 'Id='.addslashes($_GET['MeasureId']));65 $Measure = $DbResult->fetch_array();66 67 RebuildMeasureCache($Measure);68 echo('Dokončeno<br>');69 } -
trunk/index.php
r64 r67 244 244 $Application = new Application(); 245 245 $Application->Start(); 246 $MainView = new MainView($ Database);246 $MainView = new MainView($Application->Database); 247 247 $MainView->Show();
Note:
See TracChangeset
for help on using the changeset viewer.