Changeset 1661 in ExiteCMS for trunk/setup.php


Ignore:
Timestamp:
08/21/08 18:31:24 (4 years ago)
Author:
hverton
Message:

further setup updates
new dbsetup_include file
added an option to locale_load() to override the system locale

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/setup.php

    r1660 r1661  
    113113    $locales_file = PATH_ROOT."files/locales/".(defined('LP_LOCALE')?LP_LOCALE:"en").".".$locale_name.".php"; 
    114114    if (file_exists($locales_file)) { 
    115         require_once $locales_file; 
     115        require $locales_file; 
     116    } else { 
     117        die("locales file $locales_file not found!"); 
    116118    } 
    117119    return; 
     
    126128    $msg = "<div style='font-family:Verdana;font-size:14px;text-align:center;'><b>".(empty($locale['403'])?"Unable to run the ExiteCMS setup":$locale['403']).":<br /><br /><font style='color:red;'>"; 
    127129    $msg .= $error."</font></b><br /><br />"; 
    128     $msg .= $error."</font></b><br /><br />"; 
    129130    if ($wiki) { 
    130         if (empty($locale['404')) { 
     131        if (empty($locale['404'])) { 
    131132            $msg .= "Please consult our <a href='http://exitecms.exite.eu/modules/wiki/index.php?wakka=Setup'>Wiki</a> "; 
    132133        } else { 
    133             $msg = sprintf($locale['404'], "http://exitecms.exite.eu/modules/wiki/index.php?wakka=Setup"); 
    134         } 
    135     } 
    136     $msg .= $tip."</div>"; 
     134            $msg .= sprintf($locale['404'], "http://exitecms.exite.eu/modules/wiki/index.php?wakka=Setup"); 
     135        } 
     136    } 
     137    $msg .=" ". $tip."</div>"; 
    137138    die($msg); 
    138139} 
     
    182183 
    183184// load the language pack file, to get some initial info about the language 
    184 require PATH_ADMIN."tools/language_pack_".$localeset.".php"; 
     185require_once PATH_ADMIN."tools/language_pack_".$localeset.".php"; 
    185186 
    186187// load the locale for this module 
     188$locale = array(); 
    187189locale_load("main.setup"); 
    188190 
     
    193195 
    194196// parameter validation 
    195 $step = (isset($_GET['step']) ? $_GET['step'] : "0"); 
    196 $variables['step'] = $step; 
     197$step = (isset($_POST['step']) ? $_POST['step'] : "0"); 
    197198 
    198199// check if the cache directories are writeable 
     
    230231if ($step == "1") { 
    231232    // verify the user input: hostname 
    232     $db_host = stripinput($_POST['db_host']); 
     233    $db_host = isset($_POST['db_host']) ? stripinput($_POST['db_host']) : ""; 
    233234    $variables['db_host'] = $db_host; 
    234     if ($empty($db_host) || !preg_match("/^[-0-9\.A-Z_@]+$/i", $db_host)) { 
    235         $error .= $locale['417']."<br />\n"; 
     235    if (empty($db_host) || !preg_match("/^[-0-9\.A-Z_@]+$/i", $db_host)) { 
     236        $error .= $locale['417']."<br /><br />\n"; 
    236237    } 
    237238    // verify the user input: username 
    238     $db_user = stripinput($_POST['db_user']); 
     239    $db_user = isset($_POST['db_user']) ? stripinput($_POST['db_user']) : ""; 
    239240    $variables['db_user'] = $db_user; 
    240     if ($empty($db_user) || !preg_match("/^[-0-9A-Z_@]+$/i", $db_user)) { 
    241             $error .= $locale['418']."<br />\n"; 
    242         } 
     241    if (empty($db_user) || !preg_match("/^[-0-9A-Z_@]+$/i", $db_user)) { 
     242        $error .= $locale['418']."<br /><br />\n"; 
    243243    } 
    244244    // verify the user input: password 
    245     $db_pass = stripinput($_POST['db_pass']); 
     245    $db_pass = isset($_POST['db_pass']) ? stripinput($_POST['db_pass']) : ""; 
    246246    $variables['db_pass'] = $db_pass; 
    247     if ($empty($db_pass) || !preg_match("/^[-0-9A-Z_@]+$/i", $db_pass)) { 
    248             $error .= $locale['419']."<br />\n"; 
    249         } 
     247    if (empty($db_pass) || !preg_match("/^[-0-9A-Z_@]+$/i", $db_pass)) { 
     248        $error .= $locale['419']."<br /><br />\n"; 
    250249    } 
    251250    // verify the user input: database name 
    252     $db_name = stripinput($_POST['db_name']); 
     251    $db_name = isset($_POST['db_name']) ? stripinput($_POST['db_name']) : ""; 
    253252    $variables['db_name'] = $db_name; 
    254     if ($empty($db_name) || !preg_match("/^[-0-9A-Z_@]$/i", $db_name)) { 
    255             $error .= $locale['427']."<br />\n"; 
    256         } 
     253    if (empty($db_name) || !preg_match("/^[-0-9A-Z_@]+$/i", $db_name)) { 
     254        $error .= $locale['427']."<br /><br />\n"; 
    257255    } 
    258256    // verify the user input: table prefix 
    259     $db_prefix = stripinput($_POST['db_prefix']); 
     257    $db_prefix = isset($_POST['db_prefix']) ? stripinput($_POST['db_prefix']) : ""; 
    260258    $variables['db_prefix'] = $db_prefix; 
    261259    if (!preg_match("/^[-0-9A-Z_@]*$/i", $db_prefix)) { 
    262             $error .= $locale['428']."<br />\n"; 
    263         } 
     260        $error .= $locale['428']."<br /><br />\n"; 
    264261    } 
    265262    // verify a connection to the database server can be made 
     
    267264        $db_connect = @mysql_connect($db_host, $db_user, $db_pass); 
    268265        if (!$db_connect) { 
    269             $error .= $locale['429']."<br />\n"; 
     266            $error .= $locale['401']."<br />".$locale['429']."<br /><br />\n"; 
    270267        } 
    271268    } 
     
    274271        $db_select = @mysql_select_db($db_name); 
    275272        if (!$db_select) { 
    276             $error .= sprintf($locale['434'],$db_name)."<br />\n"; 
     273            $error .= sprintf($locale['434'],$db_name)."<br /><br />\n"; 
    277274        } 
    278275    } 
     
    281278        $result = dbquery("CREATE TABLE ".$db_prefix."_test (test TINYINT(1) NOT NULL) ENGINE = MYISAM"); 
    282279        if (!$result) { 
    283             $error .= sprintf($locale['435'],$db_name)."<br />\n"; 
     280            $error .= sprintf($locale['435'],$db_name)."<br /><br />\n"; 
    284281        } else { 
    285282            $result = dbquery("DROP TABLE ".$db_prefix."_test"); 
     
    296293"."$"."db_prefix="."\"".$_POST['db_prefix']."\""."; 
    297294 
    298 // user database settings 
     295// user database settings (may be shared with another ExiteCMS DB) 
    299296"."$"."user_db_host="."\"".$_POST['db_host']."\""."; 
    300297"."$"."user_db_user="."\"".$_POST['db_user']."\""."; 
     
    310307            fclose($temp); 
    311308        } 
     309    } 
     310    if (!empty($error)) { 
     311        $step = 0; 
    312312    } 
    313313} 
     
    360360        $link = dbconnect($db_host, $db_user, $db_pass, $db_name); 
    361361        $basedir = substr($_SERVER['PHP_SELF'], 0, -9); 
    362         $username = stripinput($_POST['username']); 
    363         $password1 = stripinput($_POST['password1']); 
    364         $password2 = stripinput($_POST['password2']); 
    365         $email = stripinput($_POST['email']); 
     362        $username = isset($_POST['username']) ? stripinput($_POST['username']) : ""; 
     363        $variables['username'] = $username; 
     364        $password1 = isset($_POST['password1']) ? stripinput($_POST['password1']) : ""; 
     365        $variables['password1'] = $password1; 
     366        $password2 = isset($_POST['password2']) ? stripinput($_POST['password2']) : ""; 
     367        $variables['password2'] = $password2; 
     368        $email = isset($_POST['email']) ? stripinput($_POST['email']) : ""; 
     369        $variables['email'] = $email; 
    366370        if (!preg_match("/^[-0-9A-Z_@\s]+$/i", $username)) $error .= $locale['450']."<br /><br />\n"; 
    367371        if (preg_match("/^[0-9A-Z@]{6,20}$/i", $password1)) { 
     
    378382        require_once PATH_INCLUDES."dbsetup_include.php"; 
    379383 
    380         if ($error == "") { 
     384        if ($error != "") { 
     385 
     386            $step = 1; 
     387 
     388        } else { 
    381389 
    382390            // create the admin rights field for the webmaster, based on all admin modules available 
     
    472480$variables['error'] = $error; 
    473481 
     482$variables['step'] = $step; 
     483 
    474484// define the setup body panel variables 
    475485$template_panels[] = array('type' => 'body', 'name' => 'setup', 'template' => 'main.setup.tpl', 'locale' => "main.setup"); 
Note: See TracChangeset for help on using the changeset viewer.