Changeset 880 for trunk/Packages/Common/Setup.php
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Setup.php
r879 r880 29 29 '<input type="submit" name="login" value="'.T('Login').'"/>'. 30 30 '</form>'; 31 return ($Output);31 return $Output; 32 32 } 33 33 … … 37 37 38 38 $Output .= 'Je připojení k databázi: '.$this->YesNo[$this->UpdateManager->Database->Connected()].'<br/>'; 39 if ($this->UpdateManager->Database->Connected())39 if ($this->UpdateManager->Database->Connected()) 40 40 { 41 41 $Output .= 'Je instalováno: '.$this->YesNo[$this->UpdateManager->IsInstalled()].'<br/>'; 42 if ($this->UpdateManager->IsInstalled())42 if ($this->UpdateManager->IsInstalled()) 43 43 $Output .= 'Je aktuální: '.$this->YesNo[$this->UpdateManager->IsUpToDate()].'<br/>'. 44 44 'Verze databáze: '.$this->UpdateManager->GetDbVersion().'<br/>'; 45 45 $Output .= 'Verze databáze kódu: '.$this->UpdateManager->Revision.'<br/>'; 46 if ($this->UpdateManager->IsInstalled())47 { 48 if (!$this->UpdateManager->IsUpToDate())46 if ($this->UpdateManager->IsInstalled()) 47 { 48 if (!$this->UpdateManager->IsUpToDate()) 49 49 $Output .= '<a href="?action=upgrade">'.T('Upgrade').'</a> '; 50 50 $Output .= '<a href="?action=insert_sample_data">Vložit vzorová data</a> '; … … 59 59 $Output .= '<a href="'.$this->System->Link('/').'">'.T('Go to main page').'</a> '; 60 60 $Output .= ''; 61 return ($Output);61 return $Output; 62 62 } 63 63 … … 73 73 74 74 $Output = ''; 75 if (isset($this->Config))76 { 77 if (!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = '';78 if (array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword'];79 if (sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword'])75 if (isset($this->Config)) 76 { 77 if (!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = ''; 78 if (array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword']; 79 if (sha1($_SESSION['SystemPassword']) != $this->Config['SystemPassword']) 80 80 { 81 81 $Output .= $this->LoginPanel(); 82 82 } else 83 83 { 84 if (array_key_exists('action', $_GET)) $Action = $_GET['action'];84 if (array_key_exists('action', $_GET)) $Action = $_GET['action']; 85 85 else $Action = ''; 86 if ($Action == 'logout')86 if ($Action == 'logout') 87 87 { 88 88 $_SESSION['SystemPassword'] = ''; … … 90 90 $Output .= $this->LoginPanel(); 91 91 } else 92 if ($Action == 'models')92 if ($Action == 'models') 93 93 { 94 94 $this->System->FormManager->UpdateSQLMeta(); 95 95 } else 96 if ($Action == 'upgrade')96 if ($Action == 'upgrade') 97 97 { 98 98 $Output .= '<h3>Povýšení</h3>'; … … 105 105 $Output .= $this->ControlPanel(); 106 106 } else 107 if ($Action == 'install')107 if ($Action == 'install') 108 108 { 109 109 $Output .= '<h3>Instalace</h3>'; … … 114 114 $Output .= $this->ControlPanel(); 115 115 } else 116 if ($Action == 'uninstall')116 if ($Action == 'uninstall') 117 117 { 118 118 $Output .= '<h3>Odinstalace</h3>'; … … 120 120 $Output .= $this->ControlPanel(); 121 121 } else 122 if ($Action == 'reload_modules')122 if ($Action == 'reload_modules') 123 123 { 124 124 $Output .= '<h3>Znovunačtení seznamu modulů</h3>'; … … 127 127 $Output .= $this->ControlPanel(); 128 128 } else 129 if ($Action == 'insert_sample_data')129 if ($Action == 'insert_sample_data') 130 130 { 131 131 $Output .= '<h3>Vložení vzorových dat</h3>'; … … 133 133 $Output .= $this->ControlPanel(); 134 134 } else 135 if ($Action == 'modules')135 if ($Action == 'modules') 136 136 { 137 137 $Output .= $this->ShowModules(); 138 138 } else 139 if ($Action == 'configure_save')139 if ($Action == 'configure_save') 140 140 { 141 141 $Output .= $this->ConfigSave($this->Config); 142 142 $Output .= $this->ControlPanel(); 143 143 } else 144 if ($Action == 'configure')144 if ($Action == 'configure') 145 145 { 146 146 $Output .= $this->PrepareConfig($this->Config); … … 152 152 } else 153 153 { 154 if (array_key_exists('configure_save', $_POST))154 if (array_key_exists('configure_save', $_POST)) 155 155 { 156 156 $Output .= $this->ConfigSave(array()); … … 160 160 } 161 161 } 162 return ($Output);162 return $Output; 163 163 } 164 164 … … 166 166 { 167 167 $Output = ''; 168 if (array_key_exists('op', $_GET)) $Operation = $_GET['op'];168 if (array_key_exists('op', $_GET)) $Operation = $_GET['op']; 169 169 else $Operation = ''; 170 if ($Operation == 'install')170 if ($Operation == 'install') 171 171 { 172 172 $this->System->ModuleManager->Modules[$_GET['name']]->Install(); … … 174 174 $Output .= 'Modul '.$_GET['name'].' instalován<br/>'; 175 175 } else 176 if ($Operation == 'uninstall')176 if ($Operation == 'uninstall') 177 177 { 178 178 $this->System->ModuleManager->Modules[$_GET['name']]->Uninstall(); … … 180 180 $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>'; 181 181 } else 182 if ($Operation == 'enable')182 if ($Operation == 'enable') 183 183 { 184 184 $this->System->ModuleManager->Modules[$_GET['name']]->Enable(); … … 186 186 $Output .= 'Modul '.$_GET['name'].' povolen<br/>'; 187 187 } else 188 if ($Operation == 'disable')188 if ($Operation == 'disable') 189 189 { 190 190 $this->System->ModuleManager->Modules[$_GET['name']]->Disable(); … … 192 192 $Output .= 'Modul '.$_GET['name'].' zakázán<br/>'; 193 193 } else 194 if ($Operation == 'upgrade')194 if ($Operation == 'upgrade') 195 195 { 196 196 $this->System->ModuleManager->Modules[$_GET['name']]->Upgrade(); … … 200 200 $Output .= '<h3>Správa modulů</h3>'; 201 201 $Output .= $this->ShowList(); 202 return ($Output);202 return $Output; 203 203 } 204 204 … … 221 221 array('Name' => '', 'Title' => 'Akce'), 222 222 )); 223 foreach ($this->System->ModuleManager->Modules as $Module)224 { 225 if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);223 foreach ($this->System->ModuleManager->Modules as $Module) 224 { 225 if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies); 226 226 else $Dependencies = ' '; 227 227 $Actions = ''; 228 if ($Module->Installed == true)228 if ($Module->Installed == true) 229 229 { 230 230 $Actions .= ' <a href="?action=modules&op=uninstall&name='.$Module->Name.'">Odinstalovat</a>'; 231 if ($Module->Enabled == true) $Actions .= ' <a href="?action=modules&op=disable&name='.$Module->Name.'">Zakázat</a>';231 if ($Module->Enabled == true) $Actions .= ' <a href="?action=modules&op=disable&name='.$Module->Name.'">Zakázat</a>'; 232 232 else $Actions .= ' <a href="?action=modules&op=enable&name='.$Module->Name.'">Povolit</a>'; 233 if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&op=upgrade&name='.$Module->Name.'">Povýšit</a>';233 if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&op=upgrade&name='.$Module->Name.'">Povýšit</a>'; 234 234 } else $Actions .= ' <a href="?action=modules&op=install&name='.$Module->Name.'">Instalovat</a>'; 235 235 … … 244 244 $Output .= $Pageing->Show(); 245 245 //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>'; 246 return ($Output);246 return $Output; 247 247 } 248 248 … … 250 250 { 251 251 $Output = ''; 252 if (!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir))252 if (!file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir)) 253 253 $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože složka "'.$this->ConfigDir.'" není povolená pro zápis!'; 254 if (file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php'))254 if (file_exists($this->ConfigDir.'/Config.php') and !is_writable($this->ConfigDir.'/Config.php')) 255 255 $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor "'.$this->ConfigDir.'/Config.php" není povolen pro zápis!'; 256 256 $Output .= '<h3>Nastavení systému</h3>'. 257 257 '<form action="?action=configure_save" method="post">'. 258 258 '<table>'; 259 foreach ($this->ConfigDefinition as $Def)259 foreach ($this->ConfigDefinition as $Def) 260 260 { 261 261 $PathParts = explode('/', $Def['Name']); 262 262 $TempConfig = &$Config; 263 foreach ($PathParts as $Part)264 if (array_key_exists($Part, $TempConfig))263 foreach ($PathParts as $Part) 264 if (array_key_exists($Part, $TempConfig)) 265 265 { 266 266 $TempConfig = &$TempConfig[$Part]; 267 267 } 268 if (!is_array($TempConfig)) $Value = $TempConfig;268 if (!is_array($TempConfig)) $Value = $TempConfig; 269 269 else $Value = $Def['Default']; 270 270 $Output .= '<tr><td>'.$Def['Title'].'</td><td>'; 271 if ($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';272 if ($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';273 if ($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>';274 if ($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';275 if ($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';276 if ($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>';277 if ($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>';271 if ($Def['Type'] == 'String') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 272 if ($Def['Type'] == 'Password') $Output .= '<input type="password" name="'.$Def['Name'].'"/>'; 273 if ($Def['Type'] == 'PasswordEncoded') $Output .= '<input type="password" name="'.$Def['Name'].'"/>'; 274 if ($Def['Type'] == 'Integer') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 275 if ($Def['Type'] == 'Float') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 276 if ($Def['Type'] == 'Boolean') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.$Value.'"/>'; 277 if ($Def['Type'] == 'Array') $Output .= '<input type="text" name="'.$Def['Name'].'" value="'.implode(',', $Value).'"/>'; 278 278 } 279 279 $Output .= '</td></tr>'. … … 281 281 '</table>'. 282 282 '</form>'; 283 return ($Output);283 return $Output; 284 284 } 285 285 … … 287 287 { 288 288 $Config = $DefaultConfig; 289 foreach ($this->ConfigDefinition as $Def)289 foreach ($this->ConfigDefinition as $Def) 290 290 { 291 291 $Value = null; 292 if ($Def['Type'] == 'String') if(array_key_exists($Def['Name'], $_POST))292 if ($Def['Type'] == 'String') if (array_key_exists($Def['Name'], $_POST)) 293 293 $Value = $_POST[$Def['Name']]; 294 if ($Def['Type'] == 'Password') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))294 if ($Def['Type'] == 'Password') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != '')) 295 295 $Value = $_POST[$Def['Name']]; 296 if ($Def['Type'] == 'PasswordEncoded') if(array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != ''))296 if ($Def['Type'] == 'PasswordEncoded') if (array_key_exists($Def['Name'], $_POST) and ($_POST[$Def['Name']] != '')) 297 297 $Value = sha1($_POST[$Def['Name']]); 298 if ($Def['Type'] == 'Integer') if(array_key_exists($Def['Name'], $_POST))298 if ($Def['Type'] == 'Integer') if (array_key_exists($Def['Name'], $_POST)) 299 299 $Value = $_POST[$Def['Name']]; 300 if ($Def['Type'] == 'Float') if(array_key_exists($Def['Name'], $_POST))300 if ($Def['Type'] == 'Float') if (array_key_exists($Def['Name'], $_POST)) 301 301 $Value = $_POST[$Def['Name']]; 302 if ($Def['Type'] == 'Boolean') if(array_key_exists($Def['Name'], $_POST))302 if ($Def['Type'] == 'Boolean') if (array_key_exists($Def['Name'], $_POST)) 303 303 $Value = $_POST[$Def['Name']]; 304 if ($Def['Type'] == 'Array') if(array_key_exists($Def['Name'], $_POST))304 if ($Def['Type'] == 'Array') if (array_key_exists($Def['Name'], $_POST)) 305 305 $Value = explode(',', $_POST[$Def['Name']]); 306 if (!is_null($Value))306 if (!is_null($Value)) 307 307 { 308 308 $PathParts = explode('/', $Def['Name']); 309 309 $TempConfig = &$Config; 310 foreach ($PathParts as $Part)310 foreach ($PathParts as $Part) 311 311 { 312 312 $TempConfig = &$TempConfig[$Part]; 313 313 } 314 if (!is_array($TempConfig)) $TempConfig = $Value;314 if (!is_array($TempConfig)) $TempConfig = $Value; 315 315 else $Value = $Def['Default']; 316 316 } … … 319 319 file_put_contents($this->ConfigDir.'/Config.php', $ConfigText); 320 320 $Output = 'Konfigurace nastavena<br/>'; 321 return ($Output);321 return $Output; 322 322 } 323 323 … … 327 327 "\$IsDeveloper = array_key_exists('REMOTE_ADDR', \$_SERVER) and in_array(\$_SERVER['REMOTE_ADDR'], array('127.0.0.1'));\n\n"; 328 328 329 foreach ($this->ConfigDefinition as $Def)329 foreach ($this->ConfigDefinition as $Def) 330 330 { 331 331 $PathParts = explode('/', $Def['Name']); 332 332 $Output .= "\$Config"; 333 foreach ($PathParts as $Part)333 foreach ($PathParts as $Part) 334 334 $Output .= "['".$Part."']"; 335 335 $TempConfig = &$Config; 336 336 $Output .= ' = '; 337 foreach ($PathParts as $Part)338 if (array_key_exists($Part, $TempConfig))337 foreach ($PathParts as $Part) 338 if (array_key_exists($Part, $TempConfig)) 339 339 { 340 340 $TempConfig = &$TempConfig[$Part]; 341 341 } 342 if (!is_array($TempConfig)) $Value = $TempConfig;342 if (!is_array($TempConfig)) $Value = $TempConfig; 343 343 else $Value = $Def['Default']; 344 if ($Def['Type'] == 'Array')344 if ($Def['Type'] == 'Array') 345 345 { 346 346 $Output .= ' array('; 347 foreach ($Value as $Index => $Item)347 foreach ($Value as $Index => $Item) 348 348 $Output .= '\''.$Item.'\', '; 349 349 $Output .= ')'; … … 353 353 } 354 354 $Output .= "\n\n"; 355 return ($Output);355 return $Output; 356 356 } 357 357 } … … 362 362 { 363 363 $Output = ''; 364 if (!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>';364 if (!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>'; 365 365 else { 366 if (!$this->System->Setup->UpdateManager->IsInstalled())366 if (!$this->System->Setup->UpdateManager->IsInstalled()) 367 367 $Output .= T('System requires database initialization').'<br>'; 368 368 else 369 if (!$this->System->Setup->UpdateManager->IsUpToDate())369 if (!$this->System->Setup->UpdateManager->IsUpToDate()) 370 370 $Output .= T('System requires database upgrade').'<br>'; 371 371 } 372 372 $Output .= sprintf(T('Front page was not configured. Continue to %s'), '<a href="'.$this->System->Link('/setup/').'">'.T('setup').'</a>'); 373 return ($Output);373 return $Output; 374 374 } 375 375 } … … 402 402 function CheckState() 403 403 { 404 return ($this->Database->Connected() and $this->UpdateManager->IsInstalled() and405 $this->UpdateManager->IsUpToDate() );404 return $this->Database->Connected() and $this->UpdateManager->IsInstalled() and 405 $this->UpdateManager->IsUpToDate(); 406 406 } 407 407 … … 435 435 { 436 436 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->UpdateManager->VersionTable.'"'); 437 return ($DbResult->num_rows > 0);437 return $DbResult->num_rows > 0; 438 438 } 439 439 … … 443 443 $this->UpdateManager->Trace = $Updates->Get(); 444 444 $Output = $this->UpdateManager->Upgrade(); 445 return ($Output);445 return $Output; 446 446 } 447 447 }
Note:
See TracChangeset
for help on using the changeset viewer.