Changeset 511


Ignore:
Timestamp:
Feb 16, 2013, 4:23:29 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Konfigurační soubor se bude dále generovat ze skriptu z vyplněného formuláře s nastavením přímo do souboru namísto kopírováním šablony config.sample.php.
Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/install.php

    r510 r511  
    11<?php
    22
    3 $StopAfterUpdateManager = true;
    4 include_once('../includes/global.php');
    5 include_once('UpdateTrace.php');
    6 $UpdateManager->Trace = $Updates;
    7 $UpdateManager->InstallMethod = 'FullInstall';
     3include_once(dirname(__FILE__).'/../includes/Database.php');
     4include_once(dirname(__FILE__).'/../includes/system.php');
     5include_once(dirname(__FILE__).'/../includes/Update.php');
     6if(file_exists(dirname(__FILE__).'/../includes/config.php'))
     7  include_once(dirname(__FILE__).'/../includes/config.php');
     8include_once(dirname(__FILE__).'/UpdateTrace.php');
     9include_once(dirname(__FILE__).'/../includes/Version.php');
    810
    911function ControlPanel()
    1012{
    11         global $UpdateManager;
     13  global $UpdateManager;
    1214       
    13         $YesNo = array(false => 'Ne', true => 'Ano');
    14         $Output = '<h3>Správa instance</h3>'.
    15                         'Je instalováno: '.$YesNo[$UpdateManager->IsInstalled()].'<br/>';
    16         if($UpdateManager->IsInstalled())
    17                 $Output .= 'Je aktuální: '.$YesNo[$UpdateManager->IsUpToDate()].'<br/>'.
    18                 'Verze databáze: '.$UpdateManager->GetDbVersion().'<br/>';
    19         $Output .= 'Verze kódu: '.$UpdateManager->Revision.'<br/>'.
    20                         '<form action="?" method="post">';
    21         if($UpdateManager->IsInstalled())
    22         {
    23                 if(!$UpdateManager->IsUpToDate())
    24                         $Output .= '<input type="submit" name="update" value="Aktualizovat"/>';
    25         $Output .= '<input type="submit" name="uninstall" value="Odinstalovat"/>';
    26         } else $Output .= '<input type="submit" name="install" value="Instalovat"/>';
    27         $Output .= '</form>';
    28         return($Output);
     15  $YesNo = array(false => 'Ne', true => 'Ano');
     16  $Output = '<h3>Správa instance</h3>'.
     17    'Je instalováno: '.$YesNo[$UpdateManager->IsInstalled()].'<br/>';
     18  if($UpdateManager->IsInstalled())
     19    $Output .= 'Je aktuální: '.$YesNo[$UpdateManager->IsUpToDate()].'<br/>'.
     20    'Verze databáze: '.$UpdateManager->GetDbVersion().'<br/>';
     21  $Output .= 'Verze kódu: '.$UpdateManager->Revision.'<br/>'.
     22    '<form action="?" method="post">';
     23  if($UpdateManager->IsInstalled())
     24  {
     25    if(!$UpdateManager->IsUpToDate())
     26      $Output .= '<input type="submit" name="update" value="Aktualizovat"/>';
     27    $Output .= '<input type="submit" name="uninstall" value="Odinstalovat"/>';
     28  } else $Output .= '<input type="submit" name="install" value="Instalovat"/>';
     29  $Output .= '</form>';
     30  return($Output);
    2931}
    3032
    31 $Output = '<?xml version="1.0" encoding="'.$System->Config['Web']['Charset'].'"?>
     33function PrepareConfig()
     34{
     35  $Output = '<h3>Nastavení systému</h3>';
     36  $Output .= '<form action="" method="post">';
     37  $Output .= 'Adresa serveru: <input type="text" name="hostname"/><br/>';
     38  $Output .= 'Přihlašovací jméno: <input type="text" name="username"/><br/>';
     39  $Output .= 'Heslo: <input type="password" name="UserName"/><br/>';
     40  $Output .= 'Schéma: <input type="password" name="Schema"/><br/>';
     41  $Output .= 'Titulek webu: <input type="text" name="Title"/><br/>';
     42  $Output .= 'Email správce: <input type="text" name="AdminEmail"/><br/>';
     43  $Output .= '<input type="submit" name="configure" value="Nastavit"/>';
     44  $Output .= '</form>';
     45  return($Output);
     46}
     47
     48function CreateConfig($Config)
     49{
     50  $Output = "<?php
     51
     52  \$IsDeveloper = in_array(\$_SERVER['REMOTE_ADDR'], array('127.0.0.1'));
     53
     54  \$Config = array(
     55  'Database' => array(
     56    'Host' => 'localhost',
     57    'User' => 'root',
     58    'Password' => '',
     59    'Database' => 'wowpreklad',
     60    'DatabaseAoWoW' => 'wowpreklad_mangos',
     61    'Prefix' => '',
     62    'Charset' => 'utf8',
     63    'MangosPrefix' => '',
     64  ),
     65  'Style' => 'maron',
     66  'Web' => array(
     67    'Title' => 'Projekt překládání textů hry WoW',
     68    'Charset' => 'utf-8',
     69    'Host' => 'localhost',
     70    'BaseURL' => '',
     71    'AdminEmail' => 'admin@localhost',
     72    'Authors' => 'autor',
     73    'ShowSQLQuery' => false,
     74    'ShowSQLError' => \$IsDeveloper,
     75    'ShowPHPError' => \$IsDeveloper,
     76    'ShowRuntimeInfo' => \$IsDeveloper,
     77    'FormatOutput' => \$IsDeveloper,
     78        'ItemsPerPage' => 40,
     79    'TempFolder' => '../tmp/',
     80    'GameVersion' => '3.3.5a',
     81    'VisiblePagingItems' => 20,
     82    'WebCounter' => '',
     83    'Timezone' => 'Europe/Prague',
     84  ),
     85  'ExportTaskProcessPeriod' => 10,
     86  'MaxExportPerUser' => 10,
     87  'AoWoWExportId' => 1,
     88);
     89
     90?>";
     91  return($Output);
     92}
     93
     94$Output = '<?xml version="1.0" encoding="utf-8"?>
    3295  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    3396<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cz">'.
    3497'<head>'.
    35 '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$System->Config['Web']['Charset'].'" />'.
     98'<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />'.
    3699'<title>Správa instance</title>'.
    37100'</head><body>';
     101if(isset($Config))
     102{
     103  $System = new System();
     104  $System->Init();
     105  $UpdateManager = new UpdateManager();
     106  $UpdateManager->Database = $System->Database;
     107  $UpdateManager->Revision = $Revision;
     108  $UpdateManager->Trace = $Updates;
     109  $UpdateManager->InstallMethod = 'FullInstall';
     110
    38111if(array_key_exists('update', $_POST))
    39112{
    40         $Output .= 'Aktualizace';
    41         $UpdateManager->Update();
    42         $Output .= ControlPanel();
     113  $Output .= '<h3>Aktualizace</h3>';
     114  $UpdateManager->Update();
     115  $Output .= ControlPanel();
    43116} else
    44117if(array_key_exists('install', $_POST))
    45118{
    46         $Output .= 'Instalace';
    47         $UpdateManager->Install();
    48         $Output .= ControlPanel();
     119  $Output .= '<h3>Instalace</h3>';
     120  $UpdateManager->Install();
     121  $Output .= ControlPanel();
    49122} else
    50123if(array_key_exists('uninstall', $_POST))
    51124{
    52         $Output .= 'Odinstalace';
    53         $UpdateManager->Uninstall();
    54         $Output .= ControlPanel();
     125  $Output .= '<h3>Odinstalace</h3>';
     126  $UpdateManager->Uninstall();
     127  $Output .= ControlPanel();
    55128} else
    56129{
    57         $Output .= ControlPanel();     
     130  $Output .= ControlPanel();   
     131}
     132} else
     133{
     134  if(array_key_exists('configure', $_POST))
     135  {
     136        $Config = array();
     137        $ConfigText = CreateConfig($Config);
     138        file_put_contents('../includes/config.php', $ConfigText);
     139        $Output .= 'Konfigurace nastavena';
     140  } else $Output .= PrepareConfig();
    58141}
    59142$Output .= '</body></html>';
  • trunk/includes/Update.php

    r507 r511  
    11<?php
    2 
    3 include_once('global.php');
    42
    53class UpdateManager
  • trunk/includes/global.php

    r510 r511  
    88include_once(dirname(__FILE__).'/Page.php');
    99include_once(dirname(__FILE__).'/error.php');
     10if(file_exists(dirname(__FILE__).'/config.php'))
     11  include_once(dirname(__FILE__).'/config.php');
     12include_once(dirname(__FILE__).'/Version.php');
    1013
    1114GlobalInit();
     
    1316function GlobalInit()
    1417{
    15         global $System, $ScriptStartTime, $TranslationTree, $User, $StopAfterUpdateManager,
    16           $UpdateManager, $Config;
     18  global $System, $ScriptStartTime, $TranslationTree, $User, $StopAfterUpdateManager,
     19        $UpdateManager, $Config;
    1720
    1821  $ScriptStartTime = GetMicrotime();
     
    2023  if(isset($_SERVER['REMOTE_ADDR'])) session_start();
    2124
    22   if(file_exists(dirname(__FILE__).'/config.php')) include_once(dirname(__FILE__).'/config.php');
    23     else die('Nenalezen konfigurační soubor config.php ve složce includes. '.
    24           'Vytvořte jej zkopírováním vzoru config.sample.php.');
     25  if(!isset($Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/install.php">zde</a>.');
    2526  date_default_timezone_set($Config['Web']['Timezone']);
    26  
    27   $Revision = 510; // Subversion revision
    28   $ReleaseTime = '2013-02-15'; 
    2927 
    3028  $System = new System();
     
    3533  $UpdateManager->Database = $System->Database;
    3634  $UpdateManager->Revision = $Revision;
    37   if(isset($StopAfterUpdateManager)) return;
    3835  if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze.');
    3936  if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze.');
  • trunk/index.php

    r510 r511  
    8181  }
    8282
    83   // Echo text even if it is hidden because of caching of external searching engines
     83  // Echo text even if it is hidden because of caching by external searching engines
    8484  return('<div style="'.$HideWelcome.'">'.
    8585  '<div id="bannertitle">'.$Config['Web']['Title'].'</div>'.
Note: See TracChangeset for help on using the changeset viewer.