Changeset 589 for trunk/Modules
- Timestamp:
- Nov 1, 2013, 4:22:59 PM (12 years ago)
- Location:
- trunk/Modules/Setup
- Files:
-
- 1 edited
- 3 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Setup/DefaultConfig.php
r583 r589 1 1 <?php 2 2 3 $IsDeveloper = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1')); 4 5 $ConfigDefinition = array 6 ( 7 array('Name' => 'SystemPassword', 'Type' => 'Password', 'Default' => '', 'Title' => 'Systémové heslo'), 8 array('Name' => 'Database/Host', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Server'), 9 array('Name' => 'Database/User', 'Type' => 'String', 'Default' => 'root', 'Title' => 'Uživatel'), 10 array('Name' => 'Database/Password', 'Type' => 'Password', 'Default' => '', 'Title' => 'Heslo'), 11 array('Name' => 'Database/Database', 'Type' => 'String', 'Default' => 'centrala', 'Title' => 'Databáze'), 12 array('Name' => 'Database/Prefix', 'Type' => 'String', 'Default' => '', 'Title' => 'Prefix'), 13 array('Name' => 'Database/Charset', 'Type' => 'String', 'Default' => 'utf8', 'Title' => 'Znaková sada'), 14 array('Name' => 'Web/Style', 'Type' => 'String', 'Default' => 'new', 'Title' => 'Styl'), 15 array('Name' => 'Web/FormatHTML', 'Type' => 'String', 'Default' => '', 'Title' => 'Formátovat HTML'), 16 array('Name' => 'Web/Charset', 'Type' => 'String', 'Default' => 'utf-8', 'Title' => 'Znaková sada'), 17 array('Name' => 'Web/RootFolder', 'Type' => 'String', 'Default' => '', 'Title' => 'Kořenová složka'), 18 array('Name' => 'Web/Host', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Doménové jméno'), 19 array('Name' => 'Web/Title', 'Type' => 'String', 'Default' => 'Síť', 'Title' => 'Titulek'), 20 array('Name' => 'Web/Description', 'Type' => 'String', 'Default' => 'Komunitní počítačová síť', 'Title' => 'Popis'), 21 array('Name' => 'Web/Admin', 'Type' => 'String', 'Default' => 'Admin', 'Title' => 'Jméno správce'), 22 array('Name' => 'Web/AdminEmail', 'Type' => 'String', 'Default' => 'admin@localhost', 'Title' => 'E-mail správce'), 23 array('Name' => 'Web/ErrorLogFile', 'Type' => 'String', 'Default' => 'php_script_error.log', 'Title' => 'Soubor záznamu chyb'), 24 array('Name' => 'Web/WebcamPassword', 'Type' => 'Password', 'Default' => '', 'Title' => 'Heslo web kamery'), 25 array('Name' => 'Web/WebcamRefresh', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Interval obnovení'), 26 array('Name' => 'Web/UserSupport', 'Type' => 'Boolean', 'Default' => '1', 'Title' => 'Podpora uživatelů'), 27 array('Name' => 'Web/UploadFileFolder', 'Type' => 'String', 'Default' => 'files', 'Title' => 'Složka načtených souborů'), 28 array('Name' => 'Web/News/DaysAgo', 'Type' => 'Integer', 'Default' => '30', 'Title' => 'Stáří zobrazovaných aktualit'), 29 array('Name' => 'Web/News/Count', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Počet zobrazovaných aktualit na skupinu'), 30 array('Name' => 'Web/News/DirectoryId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id adresáře souborů příloh aktualit'), 31 array('Name' => 'Map/GoogleMapsApiKey', 'Type' => 'String', 'Default' => '', 'Title' => 'API google map'), 32 array('Name' => 'Map/DefaultLatitude', 'Type' => 'Float', 'Default' => '49.260422', 'Title' => 'Výchozí pozice na mapě'), 33 array('Name' => 'Map/DefaultLongitude', 'Type' => 'Float', 'Default' => '18.081179', 'Title' => 'Výchozí pozice na mapě'), 34 array('Name' => 'Map/DefaultZoom', 'Type' => 'Float', 'Default' => '15', 'Title' => 'Výchozí přihlížení mapy'), 35 array('Name' => 'Web/ItemsPerPage', 'Type' => 'Integer', 'Default' => '50', 'Title' => 'Položek na stránku'), 36 array('Name' => 'Web/VisiblePagingItems', 'Type' => 'Integer', 'Default' => '20', 'Title' => 'Položek stránkování'), 37 array('Name' => 'Web/FormatHTML', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Formátovat výsledný kód'), 38 array('Name' => 'Web/ShowSQLError', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat SQL chyby'), 39 array('Name' => 'Web/ShowSQLQuery', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat SQL dotazy'), 40 array('Name' => 'Web/ShowPHPError', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat PHP chyby'), 41 array('Name' => 'Web/ShowRuntimeInfo', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat běhové informace'), 42 array('Name' => 'Finance/MainUserId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id hlavního uživatele'), 43 array('Name' => 'Finance/MainSubjectId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id hlavního subjektu'), 44 array('Name' => 'Finance/DirectoryId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id adresáře souborů dokladů'), 45 array('Name' => 'MainRouter/HostName', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Hlavní brána'), 46 array('Name' => 'MainRouter/UserName', 'Type' => 'String', 'Default' => 'admin', 'Title' => 'Uživatelské jméno'), 47 array('Name' => 'MainRouter/Password', 'Type' => 'Password', 'Default' => '', 'Title' => 'Heslo'), 48 array('Name' => 'MainRouter/InetInterface', 'Type' => 'String', 'Default' => 'ether_wan', 'Title' => 'WAN rozhraní'), 49 array('Name' => 'MainRouter/LocalInterface', 'Type' => 'String', 'Default' => 'ether_lan', 'Title' => 'LAN rozhraní'), 50 array('Name' => 'MainRouter/ConnectTimeout', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Vypršení času'), 51 array('Name' => 'MainRouter/MangleRuleSubgroupMinPrefix', 'Type' => 'Integer', 'Default' => '28', 'Title' => 'Nejmenší prefix podsítě pro mangle pravidla'), 52 ); 3 class DefaultConfig 4 { 5 function Get() 6 { 7 $IsDeveloper = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1')); 8 return(array 9 ( 10 array('Name' => 'SystemPassword', 'Type' => 'Password', 'Default' => '', 'Title' => 'Systémové heslo'), 11 array('Name' => 'Database/Host', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Server'), 12 array('Name' => 'Database/User', 'Type' => 'String', 'Default' => 'root', 'Title' => 'Uživatel'), 13 array('Name' => 'Database/Password', 'Type' => 'Password', 'Default' => '', 'Title' => 'Heslo'), 14 array('Name' => 'Database/Database', 'Type' => 'String', 'Default' => 'centrala', 'Title' => 'Databáze'), 15 array('Name' => 'Database/Prefix', 'Type' => 'String', 'Default' => '', 'Title' => 'Prefix'), 16 array('Name' => 'Database/Charset', 'Type' => 'String', 'Default' => 'utf8', 'Title' => 'Znaková sada'), 17 array('Name' => 'Web/Style', 'Type' => 'String', 'Default' => 'new', 'Title' => 'Styl'), 18 array('Name' => 'Web/FormatHTML', 'Type' => 'String', 'Default' => '', 'Title' => 'Formátovat HTML'), 19 array('Name' => 'Web/Charset', 'Type' => 'String', 'Default' => 'utf-8', 'Title' => 'Znaková sada'), 20 array('Name' => 'Web/RootFolder', 'Type' => 'String', 'Default' => '', 'Title' => 'Kořenová složka'), 21 array('Name' => 'Web/Host', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Doménové jméno'), 22 array('Name' => 'Web/Title', 'Type' => 'String', 'Default' => 'Síť', 'Title' => 'Titulek'), 23 array('Name' => 'Web/Description', 'Type' => 'String', 'Default' => 'Komunitní počítačová síť', 'Title' => 'Popis'), 24 array('Name' => 'Web/Admin', 'Type' => 'String', 'Default' => 'Admin', 'Title' => 'Jméno správce'), 25 array('Name' => 'Web/AdminEmail', 'Type' => 'String', 'Default' => 'admin@localhost', 'Title' => 'E-mail správce'), 26 array('Name' => 'Web/ErrorLogFile', 'Type' => 'String', 'Default' => 'php_script_error.log', 'Title' => 'Soubor záznamu chyb'), 27 array('Name' => 'Web/WebcamPassword', 'Type' => 'Password', 'Default' => '', 'Title' => 'Heslo web kamery'), 28 array('Name' => 'Web/WebcamRefresh', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Interval obnovení'), 29 array('Name' => 'Web/UserSupport', 'Type' => 'Boolean', 'Default' => '1', 'Title' => 'Podpora uživatelů'), 30 array('Name' => 'Web/UploadFileFolder', 'Type' => 'String', 'Default' => 'files', 'Title' => 'Složka načtených souborů'), 31 array('Name' => 'Web/News/DaysAgo', 'Type' => 'Integer', 'Default' => '30', 'Title' => 'Stáří zobrazovaných aktualit'), 32 array('Name' => 'Web/News/Count', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Počet zobrazovaných aktualit na skupinu'), 33 array('Name' => 'Web/News/DirectoryId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id adresáře souborů příloh aktualit'), 34 array('Name' => 'Map/GoogleMapsApiKey', 'Type' => 'String', 'Default' => '', 'Title' => 'API google map'), 35 array('Name' => 'Map/DefaultLatitude', 'Type' => 'Float', 'Default' => '49.260422', 'Title' => 'Výchozí pozice na mapě'), 36 array('Name' => 'Map/DefaultLongitude', 'Type' => 'Float', 'Default' => '18.081179', 'Title' => 'Výchozí pozice na mapě'), 37 array('Name' => 'Map/DefaultZoom', 'Type' => 'Float', 'Default' => '15', 'Title' => 'Výchozí přihlížení mapy'), 38 array('Name' => 'Web/ItemsPerPage', 'Type' => 'Integer', 'Default' => '50', 'Title' => 'Položek na stránku'), 39 array('Name' => 'Web/VisiblePagingItems', 'Type' => 'Integer', 'Default' => '20', 'Title' => 'Položek stránkování'), 40 array('Name' => 'Web/FormatHTML', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Formátovat výsledný kód'), 41 array('Name' => 'Web/ShowSQLError', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat SQL chyby'), 42 array('Name' => 'Web/ShowSQLQuery', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat SQL dotazy'), 43 array('Name' => 'Web/ShowPHPError', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat PHP chyby'), 44 array('Name' => 'Web/ShowRuntimeInfo', 'Type' => 'Boolean', 'Default' => '0', 'Title' => 'Ukazovat běhové informace'), 45 array('Name' => 'Finance/MainUserId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id hlavního uživatele'), 46 array('Name' => 'Finance/MainSubjectId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id hlavního subjektu'), 47 array('Name' => 'Finance/DirectoryId', 'Type' => 'Integer', 'Default' => '1', 'Title' => 'Id adresáře souborů dokladů'), 48 array('Name' => 'MainRouter/HostName', 'Type' => 'String', 'Default' => 'localhost', 'Title' => 'Hlavní brána'), 49 array('Name' => 'MainRouter/UserName', 'Type' => 'String', 'Default' => 'admin', 'Title' => 'Uživatelské jméno'), 50 array('Name' => 'MainRouter/Password', 'Type' => 'Password', 'Default' => '', 'Title' => 'Heslo'), 51 array('Name' => 'MainRouter/InetInterface', 'Type' => 'String', 'Default' => 'ether_wan', 'Title' => 'WAN rozhraní'), 52 array('Name' => 'MainRouter/LocalInterface', 'Type' => 'String', 'Default' => 'ether_lan', 'Title' => 'LAN rozhraní'), 53 array('Name' => 'MainRouter/ConnectTimeout', 'Type' => 'Integer', 'Default' => '5', 'Title' => 'Vypršení času'), 54 array('Name' => 'MainRouter/MangleRuleSubgroupMinPrefix', 'Type' => 'Integer', 'Default' => '28', 'Title' => 'Nejmenší prefix podsítě pro mangle pravidla'), 55 )); 56 } 57 } -
trunk/Modules/Setup/Setup.php
r588 r589 1 1 <?php 2 3 include_once(dirname(__FILE__).'/Update.php'); 4 include_once(dirname(__FILE__).'/DefaultConfig.php'); 5 include_once(dirname(__FILE__).'/FullInstall.php'); 6 include_once(dirname(__FILE__).'/Updates.php'); 2 7 3 8 class PageSetup extends Page … … 13 18 function Show() 14 19 { 15 return(''); 20 global $ConfigDefinition, $DatabaseRevision, $Config, $Updates; 21 22 $UpdateInterface = new UpdateInterface(); 23 $DefaultConfig = new DefaultConfig(); 24 $UpdateInterface->Database = $this->Database; 25 $UpdateInterface->ConfigDefinition = $DefaultConfig->Get(); 26 $UpdateInterface->DatabaseRevision = $DatabaseRevision; 27 $UpdateInterface->Config = &$Config; 28 $UpdateInterface->Updates = &$Updates; 29 return($UpdateInterface->Show()); 16 30 } 17 31 } … … 21 35 function Show() 22 36 { 23 return('Systém není nainstalován. Pokračujte <a href="'.$this->System->Link('/setup/').'">zde</a>'); 37 echo('s'); 38 $Output = ''; 39 if(!$this->Database->Connected()) $Output .= 'Nelze se připojit k databázi.<br>'; 40 else { 41 if(!$this->System->ModuleManager->Modules['Setup']->UpdateManager->IsInstalled()) $Output .= 'Systém vyžaduje instalaci databáze.<br>'; 42 if(!$this->System->ModuleManager->Modules['Setup']->UpdateManager->IsUpToDate()) $Output .= 'Systém vyžaduje aktualizaci databáze.<br>'; 43 } 44 $Output .= 'Pokračujte <a href="'.$this->System->Link('/setup/').'">zde</a>'; 45 return($Output); 24 46 } 25 47 } … … 27 49 class ModuleSetup extends AppModule 28 50 { 51 var $UpdateManager; 52 29 53 function __construct($System) 30 54 { … … 40 64 function DoStart() 41 65 { 66 global $DatabaseRevision; 67 42 68 $this->System->RegisterPage('', 'PageSetupRedirect'); 43 $this->System->RegisterPage('setup', 'PageSetup'); 69 $this->System->RegisterPage('setup', 'PageSetup'); 70 71 // Check database persistence structure 72 $this->UpdateManager = new UpdateManager(); 73 $this->UpdateManager->Database = &$this->Database; 74 $this->UpdateManager->Revision = $DatabaseRevision; 44 75 } 76 77 function CheckState() 78 { 79 return($this->Database->Connected() and $this->UpdateManager->IsInstalled() and 80 $this->UpdateManager->IsUpToDate()); 81 } 45 82 } -
trunk/Modules/Setup/Update.php
r583 r589 1 1 <?php 2 3 include_once('Database.php');4 2 5 3 class UpdateManager … … 30 28 function IsInstalled() 31 29 { 30 debug_backtrace(); 32 31 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"'); 33 32 return($DbResult->num_rows > 0); … … 88 87 var $Revision; 89 88 var $Updates; 89 var $Database; 90 90 91 91 function __construct() … … 108 108 { 109 109 $YesNo = array(false => 'Ne', true => 'Ano'); 110 $Output = '<h3>Správa instance</h3>'. 111 'Je instalováno: '.$YesNo[$this->UpdateManager->IsInstalled()].'<br/>'; 112 if($this->UpdateManager->IsInstalled()) 113 $Output .= 'Je aktuální: '.$YesNo[$this->UpdateManager->IsUpToDate()].'<br/>'. 114 'Verze databáze: '.$this->UpdateManager->GetDbVersion().'<br/>'; 115 $Output .= 'Verze databáze kódu: '.$this->UpdateManager->Revision.'<br/>'. 116 '<form action="" method="post">'; 117 if($this->UpdateManager->IsInstalled()) 118 { 119 if(!$this->UpdateManager->IsUpToDate()) 120 $Output .= '<input type="submit" name="update" value="Aktualizovat"/> '; 121 $Output .= '<input type="submit" name="insert_sample_data" value="Vložit vzorová data"/> '; 122 $Output .= '<input type="submit" name="uninstall" value="Odinstalovat"/> '; 123 } else $Output .= '<input type="submit" name="install" value="Instalovat"/> '; 110 $Output = '<form action="" method="post">'; 111 112 $Output .= 'Je připojení k databázi: '.$YesNo[$this->UpdateManager->Database->Connected()].'<br/>'; 113 if($this->UpdateManager->Database->Connected()) 114 { 115 $Output .= 'Je instalováno: '.$YesNo[$this->UpdateManager->IsInstalled()].'<br/>'; 116 if($this->UpdateManager->IsInstalled()) 117 $Output .= 'Je aktuální: '.$YesNo[$this->UpdateManager->IsUpToDate()].'<br/>'. 118 'Verze databáze: '.$this->UpdateManager->GetDbVersion().'<br/>'; 119 $Output .= 'Verze databáze kódu: '.$this->UpdateManager->Revision.'<br/>'; 120 if($this->UpdateManager->IsInstalled()) 121 { 122 if(!$this->UpdateManager->IsUpToDate()) 123 $Output .= '<input type="submit" name="update" value="Aktualizovat"/> '; 124 $Output .= '<input type="submit" name="insert_sample_data" value="Vložit vzorová data"/> '; 125 $Output .= '<input type="submit" name="uninstall" value="Odinstalovat"/> '; 126 } else $Output .= '<input type="submit" name="install" value="Instalovat"/> '; 127 } 124 128 $Output .= '<input type="submit" name="configure" value="Nastavit"/> '; 125 129 $Output .= '<input type="submit" name="logout" value="Odhlásit"/> '; … … 146 150 } else 147 151 { 148 date_default_timezone_set('Europe/Prague');149 // SQL injection hack protection150 foreach($_POST as $Index => $Item) $_POST[$Index] = addslashes($Item);151 foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($Item);152 153 if(isset($_SERVER['REMOTE_ADDR'])) session_start();154 155 $Database = new Database();156 $Database->Connect($this->Config['Database']['Host'], $this->Config['Database']['User'],157 $this->Config['Database']['Password'], $this->Config['Database']['Database']);158 $Database->Prefix = $this->Config['Database']['Prefix'];159 $Database->charset($this->Config['Database']['Charset']);160 $Database->ShowSQLError = $this->Config['Web']['ShowSQLError'];161 $Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery'];162 163 152 $this->UpdateManager = new UpdateManager(); 164 $this->UpdateManager->Database = $ Database;153 $this->UpdateManager->Database = $this->Database; 165 154 $this->UpdateManager->Revision = $this->DatabaseRevision; 166 155 $this->UpdateManager->Trace = $this->Updates; … … 222 211 } 223 212 $Output .= '</body></html>'; 224 echo($Output);213 return($Output); 225 214 } 226 215
Note:
See TracChangeset
for help on using the changeset viewer.