Changeset 513


Ignore:
Timestamp:
Feb 16, 2013, 7:58:18 PM (11 years ago)
Author:
chronos
Message:
  • Přidáno: Zabezpečení správy instalace heslem.
Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/DefaultConfig.php

    r512 r513  
    3737  'MaxExportPerUser' => 10,
    3838  'AoWoWExportId' => 1,
     39  'SystemPassword' => '',
    3940);
    4041
  • trunk/admin/install.php

    r512 r513  
    2121    'Verze databáze: '.$UpdateManager->GetDbVersion().'<br/>';
    2222  $Output .= 'Verze kódu: '.$UpdateManager->Revision.'<br/>'.
    23     '<form action="?" method="post">';
     23    '<form action="" method="post">';
    2424  if($UpdateManager->IsInstalled())
    2525  {
    2626    if(!$UpdateManager->IsUpToDate())
    27       $Output .= '<input type="submit" name="update" value="Aktualizovat"/>';
    28     $Output .= '<input type="submit" name="uninstall" value="Odinstalovat"/>';
    29   } else $Output .= '<input type="submit" name="install" value="Instalovat"/>';
    30   $Output .= '<input type="submit" name="configure" value="Nastavit"/>';
     27      $Output .= '<input type="submit" name="update" value="Aktualizovat"/> ';
     28    $Output .= '<input type="submit" name="uninstall" value="Odinstalovat"/> ';
     29  } else $Output .= '<input type="submit" name="install" value="Instalovat"/> ';
     30  $Output .= '<input type="submit" name="configure" value="Nastavit"/> ';
     31  $Output .= '<input type="submit" name="logout" value="Odhlásit"/> ';
    3132  $Output .= '</form>';
    3233  return($Output);
     
    3536function PrepareConfig($Config)
    3637{
    37   $Output = '<h3>Nastavení systému</h3>'.
     38        $Output = '';
     39  if(!file_exists('../includes/config.php') and !is_writable('../includes'))
     40        $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože složka includes není povolená pro zápis!';
     41  if(file_exists('../includes/config.php') and !is_writable('../includes/config.php'))
     42        $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor config.php není povolen pro zápis!';
     43  $Output .= '<h3>Nastavení systému</h3>'.
    3844    '<form action="" method="post">'.
    3945    '<table>'. 
     46    '<tr><td>Systémové heslo:</td><td> <input type="password" name="SystemPassword" value=""/></td></tr>'.
    4047    '<tr><td>Adresa serveru:</td><td> <input type="text" name="Host" value="'.$Config['Database']['Host'].'"/></td></tr>'.
    4148    '<tr><td>Přihlašovací jméno:</td><td> <input type="text" name="User" value="'.$Config['Database']['User'].'"/></td></tr>'.
     
    5764{
    5865  $Config = $DefaultConfig;
     66  if(array_key_exists('SystemPassword', $_POST) and ($_POST['SystemPassword'] != ''))
     67        $Config['SystemPassword'] = sha1($_POST['SystemPassword']);
    5968  if(array_key_exists('Host', $_POST)) $Config['Database']['Host'] = $_POST['Host'];
    6069  if(array_key_exists('User', $_POST)) $Config['Database']['User'] = $_POST['User'];
    61   if(array_key_exists('Password', $_POST) and ($_POST['Password'] != '')) $Config['Database']['Password'] = $_POST['Password'];
     70  if(array_key_exists('Password', $_POST) and ($_POST['Password'] != ''))
     71        $Config['Database']['Password'] = $_POST['Password'];
    6272  if(array_key_exists('Schema', $_POST)) $Config['Database']['Database'] = $_POST['Schema'];
    6373  if(array_key_exists('Title', $_POST)) $Config['Web']['Title'] = $_POST['Title'];
     
    6878  $ConfigText = CreateConfig($Config);
    6979  file_put_contents('../includes/config.php', $ConfigText);
    70   $Output .= 'Konfigurace nastavena';
     80  $Output .= 'Konfigurace nastavena<br/>';
    7181  return($Output);     
    7282}
     
    112122  'MaxExportPerUser' => 10,
    113123  'AoWoWExportId' => 1,
     124  'SystemPassword' => '".$Config['SystemPassword']."',
    114125);
    115126
     
    117128  return($Output);
    118129}
     130
     131function LoginPanel()
     132{
     133        $Output = '<h3>Přihlášení k instalaci</h3>'.
     134                        '<form action="" method="post">'.
     135                        '<table>'.
     136                        '<tr><td>Systémové heslo:</td><td> <input type="password" name="SystemPassword" value=""/></td></tr>'.
     137                        '</table>'.
     138                        '<input type="submit" name="login" value="Přihlásit"/>'.
     139                        '</form>';     
     140        return($Output);
     141}
     142
     143session_start();
    119144
    120145$Output = '<?xml version="1.0" encoding="utf-8"?>
     
    127152if(isset($Config))
    128153{
     154        if(!array_key_exists('SystemPassword', $_SESSION)) $_SESSION['SystemPassword'] = '';
     155        if(array_key_exists('login', $_POST)) $_SESSION['SystemPassword'] = $_POST['SystemPassword'];
     156        if(sha1($_SESSION['SystemPassword']) != $Config['SystemPassword'])
     157        {
     158                $Output .= LoginPanel();
     159        } else
     160        {
    129161  $System = new System();
    130162  $System->Init();
     
    135167  $UpdateManager->InstallMethod = 'FullInstall';
    136168
     169if(array_key_exists('logout', $_POST))
     170{
     171        $_SESSION['SystemPassword'] = '';
     172        $Output .= 'Odhlášen';
     173  $Output .= LoginPanel();
     174} else
    137175if(array_key_exists('update', $_POST))
    138176{
     
    165203  $Output .= ControlPanel();   
    166204}
     205        }
    167206} else
    168207{
    169208  if(array_key_exists('configure_save', $_POST))
    170209  {
    171     $Output .= PrepareConfig($Config);
    172     $Output .= ControlPanel()
     210    $Output .= ConfigSave($DefaultConfig);
     211    $Output .= 'Pokračujte k přihlášení <a href="">zde</a>';   
    173212  } else {
    174213        $Output .= PrepareConfig($DefaultConfig);
Note: See TracChangeset for help on using the changeset viewer.