[ Index ]

PHP Cross Reference of e107 v1


title

Body

[close]

/ -> install.php (source)

   1  <?php
   2  /**
   3   * e107 website system
   4   * 
   5   * Copyright (C) e107 Inc (e107.org)
   6   * 
   7   * Released under the terms and conditions of the
   8   * GNU General Public License (http://gnu.org).
   9   * 
  10   * $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.7/install_.php $
  11   * $Id: install_.php 12477 2011-12-28 03:12:22Z e107coders $
  12   */
  13  
  14  define('MAKE_INSTALL_LOG', true);  # Set this to 'true' if you want a log file to be created during the installation process
  15  
  16  #
  17  # Default Options and Paths for Installer
  18  #
  19  
  20  $e107_paths['MySQLPrefix']            = 'e107_';
  21  $e107_paths['ADMIN_DIRECTORY']     = 'e107_admin/';
  22  $e107_paths['FILES_DIRECTORY']     = 'e107_files/';
  23  $e107_paths['IMAGES_DIRECTORY']    = 'e107_images/';
  24  $e107_paths['THEMES_DIRECTORY']    = 'e107_themes/';
  25  $e107_paths['PLUGINS_DIRECTORY']   = 'e107_plugins/';
  26  $e107_paths['HANDLERS_DIRECTORY']  = 'e107_handlers/';
  27  $e107_paths['LANGUAGES_DIRECTORY'] = 'e107_languages/';
  28  $e107_paths['HELP_DIRECTORY']      = 'e107_docs/help/';
  29  $e107_paths['DOWNLOADS_DIRECTORY'] = 'e107_files/downloads/';
  30  
  31  #
  32  # --- End of configurable variables ---
  33  #
  34  
  35  define('e107_INIT',  TRUE);
  36  define('e_UC_ADMIN', 254);
  37  define('MIN_MYSQL_UTF8_VERSION', '4.1.2');
  38  
  39  error_reporting(E_ALL);
  40  
  41  if (!function_exists('file_get_contents'))  die('e107 requires PHP 4.3 or greater to work correctly.');
  42  if (!function_exists('mysql_connect'))      die('e107 requires PHP to be installed or compiled with the MySQL extension to work correctly, please see the MySQL manual for more information.');
  43  
  44  function e107_ini_set($var, $value)
  45  {
  46      if (function_exists('ini_set'))  ini_set($var, $value);
  47  }
  48  
  49  # Setup some PHP options
  50  e107_ini_set('magic_quotes_sybase',      0);
  51  e107_ini_set('magic_quotes_runtime',     0);
  52  e107_ini_set('arg_separator.output',     '&amp;');
  53  e107_ini_set('session.use_trans_sid',    0);
  54  e107_ini_set('session.use_only_cookies', 1);
  55  
  56  
  57  # Ensure that '.' is the first part of the include path
  58  $inc_path = explode(PATH_SEPARATOR, ini_get('include_path'));
  59  if ($inc_path[0] != '.')
  60  {
  61      array_unshift($inc_path, '.');
  62      $inc_path = implode(PATH_SEPARATOR, $inc_path);
  63      e107_ini_set('include_path', $inc_path);
  64  }
  65  unset($inc_path);
  66  
  67  
  68  # Check for the realpath(). Some hosts (I'm looking at you, Awardspace) are totally dumb and
  69  # they think that disabling realpath() will somehow (I'm assuming) help improve their pathetic
  70  # local security. Fact is, it just prevents apps from doing their proper local inclusion security
  71  # checks. So, we refuse to work with these people.
  72  $functions_ok = true;
  73  $disabled_functions = ini_get('disable_functions');
  74  
  75  if (trim($disabled_functions) != '')
  76  {
  77      $disabled_functions = explode( ',', $disabled_functions );
  78      
  79      foreach ($disabled_functions as $function)  if (trim($function) == 'realpath')  $functions_ok = false;
  80  }
  81  
  82  if (false === $functions_ok || false === function_exists('realpath'))
  83  {
  84      die('e107 requires the realpath() function to be enabled and your host appears to have disabled it. This function is required for some <b>important</b> security checks and <b>There is NO workaround</b>. Please contact your host for more information.');
  85  }
  86  
  87  if (!function_exists('print_a'))
  88  {
  89  	function print_a($var)
  90      {
  91          return '<pre>'.htmlentities(print_r($var, true), null, 'UTF-8').'</pre>';
  92      }
  93  }
  94  
  95  if (!isset($_POST['stage']))  $_POST['stage'] = 1;
  96  
  97  header('Content-type: text/html; charset=utf-8');
  98  
  99  $e_install = new e_install($e107_paths);
 100  $e_install->run_stage(intval($_POST['stage']));
 101  $e_install->set_messages();
 102  
 103  echo $e_install->template->ParseTemplate($e_install->stage_template());
 104  
 105  #
 106  #    End of installation handler        ------------
 107  #
 108  
 109  class e_install
 110  {
 111      var        $e107;
 112      var        $stage;
 113      var        $logFile        = '';
 114      var        $template;
 115      var        $post_data      = array();
 116      var        $debug_info     = '';
 117      var        $required_php   = '4.3';
 118      var        $previous_steps = array();
 119      var     $required_field;
 120      
 121      var    $_error         = '';
 122      var    $_messages      = array('error'=>array(), 'info'=>array(), 'debug'=>array());
 123      var    $_mark_required = false;
 124      var    $_prefix_accept = false;
 125      
 126      
 127  	public function __construct($e107_paths)
 128      {
 129          include_once "./{$e107_paths['HANDLERS_DIRECTORY']}e107_class.php";
 130          
 131          while (@ob_end_clean());
 132          
 133          if (MAKE_INSTALL_LOG)  $this->logFile = dirname(__FILE__).'/e107InstallLog.log';
 134          
 135          if (isset($_POST['previous_steps']))
 136          {
 137              $this->previous_steps = unserialize(base64_decode($_POST['previous_steps']));
 138              unset($_POST['previous_steps']);
 139          }
 140          
 141          $this->e107      = new e107($e107_paths, realpath(dirname(__FILE__)));
 142          $this->template  = new SimpleTemplate();
 143          $this->post_data = $_POST;
 144          
 145          $e107info = array();
 146          include_once "./{$e107_paths['ADMIN_DIRECTORY']}ver.php";
 147          
 148          //$this->e107->e107_dirs['INSTALLER'] = $install_folder.'/';
 149          $this->template->SetTag('files_dir_http',        e_FILE_ABS);
 150          $this->template->SetTag('image_dir_http',        e_FILE_ABS.'install/images/');
 151          $this->template->SetTag('app_version',            $e107info['e107_version']);
 152          //$this->template->SetTag('installer_css_http',    $_SERVER['PHP_SELF'].'?object=stylesheet');
 153          //$this->template->SetTag('installer_folder_http', e_HTTP.$install_folder.'/');
 154          
 155          $this->required_field = '<span class="rfield">*&nbsp;</span>';
 156      }
 157      
 158  	public function e_install($e107_paths)
 159      {    # PHP 4 compat
 160          $this->__construct($e107_paths);
 161      }
 162      
 163  	public function run_stage($stage)
 164      {
 165          $stage = 'stage_'.$stage;
 166          
 167          if (!method_exists($this, $stage))  $stage='stage_invalid';
 168          
 169          $this->$stage();
 170      }
 171      
 172  	public function stage_1()
 173      {
 174          $this->stage = 1;
 175          $this->get_lan_file();
 176          $this->logLine("\n".LANINS_002.' '.LANINS_003.' [ '.LANINS_004.' ]: --- '.LANINS_109.' ---');
 177          
 178          # Prepare HTML
 179          $this->set_message(LANINS_005);
 180          $html =            '<form method="post" id="language_select" action="'.$_SERVER['PHP_SELF'].('debug' == $_SERVER['QUERY_STRING'] ? '?debug' : '').'">
 181                              <table>
 182                                  <colgroup>
 183                                      <col style="width: 50%;" />
 184                                      <col style="width: 50%;" />
 185                                  </colgroup>
 186                                  <tbody>
 187                                      <tr>
 188                                          <td class="stage right v-mid">
 189                                              '.LANINS_004.'
 190                                          </td>
 191                                          <td class="stage">
 192                                              <select name="language" id="language" class="tbox focusme">';
 193          foreach ($this->get_languages() as $v)  $html.= '
 194                                                  <option value="'.$v.'"'.('English' == $v ? ' selected="selected"' : '').'>'.$v.'&nbsp;</option>';
 195          $html.= '
 196                                              </select>
 197                                          </td>
 198                                      </tr>
 199                                  </tbody>
 200                              </table>
 201                              <div class="navigation">
 202                                  <input type="hidden" name="stage" value="'.($this->stage+1).'" />'.(!$this->previous_steps ? '' : '
 203                                  <input type="hidden" name="previous_steps" value="'.base64_encode(serialize($this->previous_steps)).'" />').'
 204                                  <input type="submit" id="submit" class="button" value="'.LANINS_006.'" />
 205                              </div>
 206                          </form>';
 207          
 208          # Set contents
 209          $this->template->SetTag('installation_heading', sprintf(LANINS_001, $this->template->getTag('app_version')));
 210          $this->template->SetTag('stage_num',            LANINS_003);
 211          $this->template->SetTag('stage',                $this->stage);
 212          $this->template->SetTag('stage_step',           sprintf(LANINS_002a, LANINS_003));
 213          $this->template->SetTag('stage_title',          LANINS_004);
 214          $this->template->SetTag('static_title',         LANINS_004b);
 215          $this->template->SetTag('stage_content',        $html);
 216      }
 217      
 218  	public function stage_2()
 219      {
 220          $this->stage = 2;
 221          
 222          if (!$this->_error)
 223          {
 224              $this->previous_steps['language'] = $_POST['language'];
 225              $this->get_lan_file();
 226              $this->logLine("\t\t".LANINS_004a.': '.$_POST['language']."\n".LANINS_002.' '.LANINS_003.' [ '.LANINS_004.' ]: --- '.LANINS_110.' ---'."\n\n".LANINS_002.' '.LANINS_021.' [ '.LANINS_022.' ]: --- '.LANINS_109.' ---');
 227              $this->set_message(nl2br(LANINS_023));
 228          }
 229          else
 230          {
 231              $this->logLine("\t\t".LANINS_011.":\n\t\t\t".implode(":\n\t\t\t", $this->_messages['error']));
 232          }
 233          
 234          # Prepare HTML
 235          $html =            '<form method="post" id="versions" action="'.$_SERVER['PHP_SELF'].('debug' == $_SERVER['QUERY_STRING'] ? '?debug' : '').'">
 236                              <table>
 237                                  <colgroup>
 238                                      <col style="width: 20%;" />
 239                                      <col style="width: 40%;" />
 240                                      <col style="width: 40%;" />
 241                                  </colgroup>
 242                                  <tbody>
 243                                      <tr>
 244                                          <td class="stage">'.$this->required_field.LANINS_024.'</td>
 245                                          <td class="stage"><input class="tbox focusme'.($this->_mark_required && !$_POST['server'] ? ' required' : '').'" id="server" name="server" size="40" value="localhost" maxlength="100" type="text" /></td>
 246                                          <td class="stage"><div class="hint">'.LANINS_030.'</div></td>
 247                                      </tr>
 248                                      <tr>
 249                                          <td class="stage">'.$this->required_field.LANINS_025.'</td>
 250                                          <td class="stage"><input class="tbox'.($this->_mark_required && !$_POST['name'] ? ' required' : '').'" id="name" name="name"'.(isset($_POST['name']) ? 'value="'.$this->previous_steps['mysql']['user'].'"' : '').' size="40" maxlength="100" type="text" /></td>
 251                                          <td class="stage"><div class="hint">'.LANINS_031.'</div></td>
 252                                      </tr>
 253                                      <tr>
 254                                          <td class="stage">'.LANINS_026.'</td>
 255                                          <td class="stage"><input class="tbox" id="password" name="password" size="40"'.(isset($_POST['password']) ? 'value="'.$this->previous_steps['mysql']['password'].'"' : '').' maxlength="100" type="password" /></td>
 256                                          <td class="stage"><div class="hint">'.LANINS_032.'</div></td>
 257                                      </tr>
 258                                      <tr>
 259                                          <td class="stage">'.$this->required_field.LANINS_027.'</td>
 260                                          <td class="stage"><input class="tbox'.($this->_mark_required && !$_POST['db'] ? ' required' : '').'" name="db"'.(isset($_POST['db']) ? 'value="'.$this->previous_steps['mysql']['db'].'"' : '').' size="40" id="db" maxlength="100" type="text" /><br /><label class="defaulttext"><input name="createdb" value="1" type="checkbox" '.(isset($_POST['createdb']) && $this->previous_steps['mysql']['createdb'] ? ' checked="checked"' : '').' /> '.LANINS_028.'</label></td>
 261                                          <td class="stage"><div class="hint">'.LANINS_033.'</div></td>
 262                                      </tr>
 263                                      <tr>
 264                                          <td class="stage">'.LANINS_DB_UTF8_CAPTION.'</td>
 265                                          <td class="stage"><label class="defaulttext"><input class="MT05" id="db_utf8" name="db_utf8" value="1" type="checkbox"'.(!isset($this->previous_steps['mysql']['db_utf8']) || true === $this->previous_steps['mysql']['db_utf8'] ? ' checked="checked"' : '').' /> '.LANINS_DB_UTF8_LABEL.'</label></td>
 266                                          <td class="stage"><div class="hint">'.LANINS_DB_UTF8_TOOLTIP.'</div></td>
 267                                      </tr>
 268                                      <tr>
 269                                          <td class="stage">'.LANINS_029.'</td>
 270                                          <td class="stage"><input class="tbox'.($this->_mark_required && false === $this->_prefix_accept ? ' required' : '').'" name="prefix" size="40" id="prefix" value="'.(isset($_POST['prefix']) ? $this->previous_steps['mysql']['prefix'] : 'e107_').'" maxlength="100" type="text" /></td>
 271                                          <td class="stage"><div class="hint">'.($this->_mark_required && false === $this->_prefix_accept ? LANINS_105 : LANINS_034).'</div></td>
 272                                      </tr>
 273                                  </tbody>
 274                              </table>
 275                              <div class="navigation">
 276                                  <input type="hidden" name="stage" value="'.($this->stage+1).'" />'.(!$this->previous_steps ? '' : '
 277                                  <input type="hidden" name="previous_steps" value="'.base64_encode(serialize($this->previous_steps)).'" />').'
 278                                  <input type="submit" id="submit" class="button" value="'.LANINS_035.'" />
 279                              </div>
 280                          </form>';
 281          
 282          # Set contents
 283          $this->template->SetTag('installation_heading', sprintf(LANINS_001, $this->template->getTag('app_version')));
 284          $this->template->SetTag('stage_num',            LANINS_021);
 285          $this->template->SetTag('stage',                $this->stage);
 286          $this->template->SetTag('stage_step',           sprintf(LANINS_002a, LANINS_021));
 287          $this->template->SetTag('stage_title',          LANINS_022);
 288          $this->template->SetTag('static_title',         LANINS_022a);
 289          $this->template->SetTag('stage_content',        $html);
 290      }
 291      
 292  	public function stage_3()
 293      {
 294          $this->stage = 3;
 295          $this->get_lan_file();
 296          
 297          $this->previous_steps['mysql']['db']       = trim($_POST['db']);
 298          $this->previous_steps['mysql']['user']     = trim($_POST['name']);
 299          $this->previous_steps['mysql']['server']   = trim($_POST['server']);
 300          $this->previous_steps['mysql']['prefix']   = trim($_POST['prefix']);
 301          $this->previous_steps['mysql']['db_utf8']  = (isset($_POST['db_utf8'])  && $_POST['db_utf8']  ? true : false);
 302          $this->previous_steps['mysql']['createdb'] = (isset($_POST['createdb']) && $_POST['createdb'] ? true : false);
 303          $this->previous_steps['mysql']['password'] = $_POST['password'];
 304          
 305          $success = $this->_check_name($this->previous_steps['mysql']['db']) && $this->_check_name($this->previous_steps['mysql']['prefix']) ? $this->_checkDbFields($this->previous_steps['mysql']) : false;
 306          
 307          if (!$success || '' == $this->previous_steps['mysql']['server'] || '' == $this->previous_steps['mysql']['db'] || '' == $this->previous_steps['mysql']['user'])
 308          {    # Required fields empty - gettings back to step 2
 309              $this->_error         = true;
 310              $this->_mark_required = true;
 311              $this->_prefix_accept = $success;
 312              $this->set_message(LANINS_039, 'error');
 313              
 314              $this->stage_2();
 315              
 316              $this->template->SetTag('stage_title',      LANINS_022.' - '.LANINS_040);
 317              
 318              return;
 319          }
 320          
 321          if (!@mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']))
 322          {    # Invalid mySQL credentials
 323              $this->_error         = true;
 324              $this->_mark_required = true;
 325              $this->_prefix_accept = true;
 326              $this->set_message(LANINS_041.'<br /><br /><b>'.LANINS_083.':</b><br /><i>'.mysql_error().'</i>', 'error');
 327              
 328              $this->stage_2();
 329              
 330              $this->template->SetTag('stage_title',      LANINS_022.' - '.LANINS_040);
 331              
 332              return;
 333          }
 334          
 335          $query = '';
 336          
 337          preg_match('/^(.*?)($|-)/', mysql_get_server_info(), $mysql_version);
 338          
 339          if (version_compare($mysql_version[1], MIN_MYSQL_UTF8_VERSION, '>='))
 340          {    # Attempt to create utf8 database if requested
 341              $db_utf8 = '';
 342              if ($this->previous_steps['mysql']['db_utf8'])
 343              {
 344                  $db_utf8 = ' CHARACTER SET `utf8` ';
 345                  @mysql_query('SET NAMES `utf8`');
 346              }
 347              
 348              if ($this->previous_steps['mysql']['createdb'])
 349              {    # Create new UTF-8 DB
 350                  $query = 'CREATE DATABASE '.$this->previous_steps['mysql']['db'].$db_utf8;
 351              }
 352              elseif($db_utf8)
 353              {    # Set existing non-UTF-8 DB to UTF-8 charset
 354                  $query = 'ALTER DATABASE '.$this->previous_steps['mysql']['db'].$db_utf8;
 355              }
 356          }
 357          else
 358          {    # MySQL is not UTF-8 compatible - reset db_utf8
 359              $this->previous_steps['mysql']['db_utf8'] = 0;
 360              
 361              if ($this->previous_steps['mysql']['createdb'] == 1)
 362              {    # Create non-UTF-8 DB
 363                  $query = 'CREATE DATABASE '.$this->previous_steps['mysql']['db'];
 364              }
 365          }
 366          
 367          $success = (bool) ($query ? mysql_query($query) : mysql_select_db($this->previous_steps['mysql']['db']));
 368          
 369          if (!$success)
 370          {
 371              $this->_error         = true;
 372              $this->_mark_required = true;
 373              $this->_prefix_accept = true;
 374              $this->set_message(($this->previous_steps['mysql']['createdb'] ? LANINS_043.'<br /><br />' : '').nl2br('<b>'.LANINS_083.':</b><br /><i>'.mysql_error().'</i>'), 'error');
 375              
 376              $this->stage_2();
 377              
 378              $this->template->SetTag('stage_title',      LANINS_022.' - '.LANINS_040);
 379              
 380              return;
 381          }
 382          
 383          $this->logLine("\t\t\t".print_a($this->previous_steps['mysql'])."\n".LANINS_002.' '.LANINS_021.' [ '.LANINS_022.' ]: --- '.LANINS_110.' ---'."\n\n".LANINS_002.' '.LANINS_036.' [ '.LANINS_037.LANINS_038.' ]: --- '.LANINS_109.' ---');
 384          
 385          $this->set_message(LANINS_042.'<br /><br />
 386                          '.($this->previous_steps['mysql']['createdb'] ? LANINS_044 : LANINS_054).'<br /><br />
 387                          '.LANINS_045);
 388          
 389          $html =            '<form method="post" id="language_select" action="'.$_SERVER['PHP_SELF'].('debug' == $_SERVER['QUERY_STRING'] ? '?debug' : '').'">
 390                              <div class="navigation-top"><!-- --></div>
 391                              <div class="navigation">
 392                                  <input type="hidden" name="stage" value="'.($this->stage+1).'" />'.(!$this->previous_steps ? '' : '
 393                                  <input type="hidden" name="previous_steps" value="'.base64_encode(serialize($this->previous_steps)).'" />').'
 394                                  <input type="submit" class="button" value="'.LANINS_035.'" />
 395                              </div>
 396                          </form>';
 397          
 398          # Set contents
 399          $this->template->SetTag('installation_heading', sprintf(LANINS_001, $this->template->getTag('app_version')));
 400          $this->template->SetTag('stage_num',            LANINS_036);
 401          $this->template->SetTag('stage',                $this->stage);
 402          $this->template->SetTag('stage_step',           sprintf(LANINS_002a, LANINS_036));
 403          $this->template->SetTag('stage_title',          LANINS_037.(isset($this->previous_steps['mysql']['createdb']) && $this->previous_steps['mysql']['createdb'] ? LANINS_038 : ''));
 404          $this->template->SetTag('static_title',         LANINS_038a);
 405          $this->template->SetTag('stage_content',        $html);
 406      }
 407      
 408  	public function stage_4()
 409      {
 410          $this->stage = 4;
 411          $this->get_lan_file();
 412          
 413          if (!isset($_POST['retest_perms']))  $this->logLine("\n".LANINS_002.' '.LANINS_036.' [ '.LANINS_037.LANINS_038.' ]: --- '.LANINS_110.' ---'."\n\n".LANINS_002.' '.LANINS_007.' [ '.LANINS_008.' ]: --- '.LANINS_109.' ---');
 414          else                                 $this->logLine("\n\t\t".LANINS_009);
 415          
 416          $version_fail = false;
 417          $perms_errors = array();
 418          $not_writable = $this->_check_writable_perms('must_write');    # Some directories MUST be writable
 419          $opt_writable = $this->_check_writable_perms('can_write');    # Some directories CAN optionally be writable
 420          
 421          if ($not_writable)
 422          {
 423              $perms_pass   = false;
 424              $perms_notes  = '<div class="error">'.LANINS_018.'</div>';
 425              foreach ($not_writable as $file)  $perms_errors[] = (substr($file, -1) == '/' ? LANINS_010a : LANINS_010).'<br /><b>'.$file.'</b>';
 426          }
 427          elseif ($opt_writable)
 428          {
 429              $perms_pass   = true;
 430              $perms_notes  = '<div class="warning">'.LANINS_106.'</div>';
 431              foreach ($opt_writable as $file)  $perms_errors[] = (substr($file, -1) == '/' ? LANINS_010a : LANINS_010).'<br /><b>'.$file.'</b>';
 432          }
 433          elseif (filesize('e107_config.php') > 1)
 434          {    # Must start from an empty e107_config.php
 435              $perms_pass   = false;
 436              $perms_notes  = '<div class="error">'.LANINS_122.'</div>';
 437              $perms_errors = '<div class="error-text">'.LANINS_121.'</div>';
 438          }
 439          else
 440          {
 441              $perms_pass   = true;
 442              $perms_notes  = '<div class="success">'.LANINS_017.'</div>';
 443              $perms_errors = LANINS_104;
 444          }
 445          
 446          if (!function_exists('mysql_connect'))
 447          {
 448              $version_fail = true;
 449              $mysql_note   = '<div class="error-text">'.LANINS_011.'</div>';
 450              $mysql_help   = '<div class="error">'.LANINS_012.'</div>';
 451          }
 452          elseif (!@mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']))
 453          {
 454              $mysql_note   = '<div class="error-text">'.LANINS_011.'</div>';
 455              $mysql_help   = '<div class="error">'.LANINS_013.'</div>';
 456          }
 457          else
 458          {
 459              $mysql_note   = mysql_get_server_info();
 460              $mysql_help   = '<div class="success">'.LANINS_017.'</div>';
 461          }
 462          
 463          if (is_array($perms_errors))  $perms_errors = '<div class="error-text">'.implode($perms_errors).'</div>';
 464          
 465          $xml_installed    = function_exists('utf8_encode');
 466          $php_version      = phpversion();
 467          $php_help         = version_compare($php_version, $this->required_php, '>=') ? '<div class="success">'.LANINS_017.'</div>' : '<div class="error">'.LANINS_019.'</div>';
 468          
 469          if (!$perms_pass)     $this->logLine("\n\t\t".LANINS_011.': '.$perms_errors);
 470          if ($version_fail)    $this->logLine("\n\t\t".LANINS_011.': '.$mysql_help);
 471          if (!$xml_installed)  $this->logLine("\n\t\t".LANINS_011.': '.LANINS_053);
 472          
 473          $html             =
 474                          '<form method="post" id="versions" action="'.$_SERVER['PHP_SELF'].('debug' == $_SERVER['QUERY_STRING'] ? '?debug' : '').'">
 475                              <table>
 476                                  <tbody>
 477                                      <colgroup>
 478                                          <col style="width: 20%;" />
 479                                          <col style="width: 40%;" />
 480                                          <col style="width: 40%;" />
 481                                      </colgroup>
 482                                      <tr>
 483                                          <td class="stage v-mid">'.LANINS_014.':</td>
 484                                          <td class="stage v-mid">'.$perms_errors.'</td>
 485                                          <td class="stage v-mid">'.$perms_notes.'</td>
 486                                      </tr>
 487                                      <tr>
 488                                          <td class="stage v-mid">'.LANINS_015.':</td>
 489                                          <td class="stage v-mid">'.$php_version.'</td>
 490                                          <td class="stage v-mid">'.$php_help.'</td>
 491                                      </tr>
 492                                      <tr>
 493                                          <td class="stage v-mid">'.LANINS_016.':</td>
 494                                          <td class="stage v-mid">'.$mysql_note.'</td>
 495                                          <td class="stage v-mid">'.$mysql_help.'</td>
 496                                      </tr>
 497                                      <tr>
 498                                          <td class="stage v-mid">'.LANINS_050.':</td>
 499                                          <td class="stage v-mid">'.($xml_installed ? LANINS_051 : '<div class="error-text">'.LANINS_052.'</div>').'</td>
 500                                          <td class="stage v-mid"><div class="'.($xml_installed ? 'success">'.LANINS_017 : 'error">'.LANINS_053).'</div></td>
 501                                      </tr>
 502                                  </tbody>
 503                              </table>
 504                              <div class="navigation">
 505                                  <input type="hidden" name="stage" value="'.($perms_pass ? $this->stage+1 : $this->stage).'" />'.(!$this->previous_steps ? '' : '
 506                                  <input type="hidden" name="previous_steps" value="'.base64_encode(serialize($this->previous_steps)).'" />').''.($perms_pass && !$version_fail && $xml_installed ? '
 507                                  <input type="submit" name="continue_install" class="button" value="'.LANINS_020.'" />' : '
 508                                  <input type="submit" name="retest_perms" class="button" value="'.LANINS_009.'" />').'
 509                              </div>
 510                          </form>';
 511          
 512          # Set contents
 513          $this->template->SetTag('installation_heading', sprintf(LANINS_001, $this->template->getTag('app_version')));
 514          $this->template->SetTag('stage_num',            LANINS_007);
 515          $this->template->SetTag('stage',                $this->stage);
 516          $this->template->SetTag('stage_step',           sprintf(LANINS_002a, LANINS_007));
 517          $this->template->SetTag('stage_title',          LANINS_008);
 518          $this->template->SetTag('static_title',         LANINS_008a);
 519          $this->template->SetTag('stage_content',        $html);
 520      }
 521      
 522  	public function stage_5()
 523      {
 524          $this->stage = 5;
 525          $this->get_lan_file();
 526          
 527          if (!$this->_error)  $this->logLine("\n".LANINS_002.' '.LANINS_007.' [ '.LANINS_008.' ]: --- '.LANINS_110.' ---'."\n\n".LANINS_002.' '.LANINS_046.' [ '.LANINS_047.' ]: --- '.LANINS_109.' ---');
 528          else                 { $this->logLine("\n\t\t".LANINS_011.": \n\t\t\t".implode("\n\t\t\t", $this->_messages['error'])); $this->_mark_required = true; } 
 529          
 530          $html =            '<form method="post" id="admin_info" action="'.$_SERVER['PHP_SELF'].('debug' == $_SERVER['QUERY_STRING'] ? '?debug' : '').'">
 531                              <table cellspacing="0">
 532                                  <tbody>
 533                                      <colgroup>
 534                                          <col style="width: 25%;" />
 535                                          <col style="width: 25%;" />
 536                                          <col style="width: 50%;" />
 537                                      </colgroup>
 538                                      <tr>
 539                                          <td class="stage"><label for="u_name">'.$this->required_field.LANINS_072.'</label></td>
 540                                          <td class="stage"><input class="tbox'.($this->_mark_required && !$_POST['u_name'] ? ' focusme required' : '').'" name="u_name" id="u_name" size="30" value="'.(isset($_POST['u_name']) ? $this->previous_steps['admin']['user'] : 'admin').'" maxlength="60" type="text" /></td>
 541                                          <td class="stage">'.LANINS_073.'</td>
 542                                      </tr>
 543                                      <tr>
 544                                          <td class="stage"><label for="d_name">'.$this->required_field.LANINS_074.'</label></td>
 545                                          <td class="stage"><input class="tbox'.($this->_mark_required && !$_POST['d_name'] ? ' required' : '').'" name="d_name" id="d_name" size="30" value="'.(isset($_POST['d_name']) ? $this->previous_steps['admin']['display'] : 'Administrator').'" maxlength="60" type="text" /></td>
 546                                          <td class="stage">'.LANINS_075.'</td>
 547                                      </tr>
 548                                      <tr>
 549                                          <td class="stage"><label for="pass1">'.$this->required_field.LANINS_076.'</label></td>
 550                                          <td class="stage"><input class="tbox focusme'.($this->_mark_required && !$_POST['pass1'] ? ' required' : '').'" name="pass1" size="30" id="pass1" value="" maxlength="60" type="password" /></td>
 551                                          <td class="stage">'.LANINS_077.'</td>
 552                                      </tr>
 553                                      <tr>
 554                                          <td class="stage"><label for="pass2">'.$this->required_field.LANINS_078.'</label></td>
 555                                          <td class="stage"><input class="tbox'.($this->_mark_required && !$_POST['pass2'] ? ' required' : '').'" name="pass2" size="30" id="pass2" value="" maxlength="60" type="password" /></td>
 556                                          <td class="stage">'.LANINS_079.'</td>
 557                                      </tr>
 558                                      <tr>
 559                                          <td class="stage"><label for="email">'.$this->required_field.LANINS_080.'</label></td>
 560                                          <td class="stage"><input class="tbox'.($this->_mark_required && !$_POST['email'] ? ' required' : '').'" name="email" size="30" id="email" value="'.(isset($_POST['email']) ? $this->previous_steps['admin']['email'] : LANINS_082).'" maxlength="100" type="text" /></td>
 561                                          <td class="stage">'.LANINS_081.'</td>
 562                                      </tr>
 563                                  </tbody>
 564                              </table>
 565                              <div class="navigation">
 566                                  <input type="hidden" name="stage" value="'.($this->stage+1).'" />'.(!$this->previous_steps ? '' : '
 567                                  <input type="hidden" name="previous_steps" value="'.base64_encode(serialize($this->previous_steps)).'" />').'
 568                                  <input id="submit" class="button" value="'.LANINS_035.'" type="submit" />
 569                              </div>
 570                          </form>';
 571          
 572          # Set contents
 573          $this->template->SetTag('installation_heading', sprintf(LANINS_001, $this->template->getTag('app_version')));
 574          $this->template->SetTag('stage_num',            LANINS_046);
 575          $this->template->SetTag('stage',                $this->stage);
 576          $this->template->SetTag('stage_step',           sprintf(LANINS_002a, LANINS_046));
 577          $this->template->SetTag('stage_title',          LANINS_047);
 578          $this->template->SetTag('static_title',         LANINS_047a);
 579          $this->template->SetTag('stage_content',        $html);
 580      }
 581      
 582  	public function stage_6()
 583      {
 584          $this->stage = 6;
 585          $this->get_lan_file();
 586          
 587          $_POST['u_name'] = str_replace(array("'", '"'), '', $_POST['u_name']);
 588          $_POST['d_name'] = str_replace(array("'", '"'), '', $_POST['d_name']);
 589          
 590          $this->previous_steps['admin']['user']     = $_POST['u_name'];
 591          $this->previous_steps['admin']['display']  = $_POST['d_name'] ? $_POST['d_name'] : $_POST['u_name'];
 592          $this->previous_steps['admin']['email']    = $_POST['email'];
 593          $this->previous_steps['admin']['password'] = $_POST['pass1'];
 594          
 595          if ('' == trim($_POST['u_name']) || '' == trim($_POST['email']) || '' == trim($_POST['pass1']))
 596          {
 597              if ('debug' == $_SERVER['QUERY_STRING'])  $this->set_message(print_a($_POST, true), 'debug');
 598              
 599              $this->_error = true;
 600              $this->set_message(LANINS_086, 'error');
 601              
 602              $this->stage_5();
 603              
 604              $this->template->SetTag('stage_title',      LANINS_047.' - '.LANINS_040);
 605              
 606              return;
 607          }
 608          elseif($_POST['pass1'] != $_POST['pass2'])
 609          {
 610              if ('debug' == $_SERVER['QUERY_STRING'])  $this->set_message(print_a($_POST, true), 'debug');
 611              
 612              $this->_error = true;
 613              $this->set_message(LANINS_049, 'error');
 614              
 615              $this->stage_5();
 616              
 617              $this->template->SetTag('stage_title',      LANINS_047.' - '.LANINS_040);
 618              
 619              return;
 620          }
 621          
 622          $this->logLine("\n".LANINS_002.' '.LANINS_046.' [ '.LANINS_047.' ]: --- '.LANINS_110.' ---'."\n\n".LANINS_002.' '.LANINS_056.' [ '.LANINS_055.' ]: --- '.LANINS_109.' ---');
 623          
 624          $this->set_message(LANINS_057);
 625          
 626          $html =         '<form method="post" id="admin_info" action="'.$_SERVER['PHP_SELF'].('debug' == $_SERVER['QUERY_STRING'] ? '?debug' : '').'">
 627                              <div class="navigation-top"><!-- --></div>
 628                              <div class="navigation">
 629                                  <input type="hidden" name="stage" value="'.($this->stage+1).'" />'.(!$this->previous_steps ? '' : '
 630                                  <input type="hidden" name="previous_steps" value="'.base64_encode(serialize($this->previous_steps)).'" />').'
 631                                  <input id="submit" class="button" value="'.LANINS_035.'" type="submit" />
 632                              </div>
 633                          </form>';
 634          
 635          # Set contents
 636          $this->template->SetTag('installation_heading', sprintf(LANINS_001, $this->template->getTag('app_version')));
 637          $this->template->SetTag('stage_num',            LANINS_056);
 638          $this->template->SetTag('stage',                $this->stage);
 639          $this->template->SetTag('stage_step',           sprintf(LANINS_002a, LANINS_056));
 640          $this->template->SetTag('stage_title',          LANINS_055);
 641          $this->template->SetTag('static_title',         LANINS_055a);
 642          $this->template->SetTag('stage_content',        $html);
 643      }
 644      
 645  	public function stage_7()
 646      {
 647          $this->stage = 7;
 648          $this->get_lan_file();
 649          $this->logLine("\n".LANINS_002.' '.LANINS_056.' [ '.LANINS_055.' ]: --- '.LANINS_109.' ---'."\n\n".LANINS_002.' '.LANINS_058.' [ '.LANINS_071.' ]: --- '.LANINS_109.' ---');
 650          
 651          $config_result = $this->_write_config();
 652          
 653          if ($config_result) 
 654          {
 655              $html = '';
 656              $this->set_message($config_result, 'error'); 
 657              $this->_error = true;
 658              $this->logLine("\t".'Error writing e107_config.php config file: '.$config_result);
 659          } 
 660          else 
 661          {
 662              $this->logLine("\t".'The e107_config.php config file is written successfully');
 663              $errors = $this->_create_tables();
 664              
 665              if ($errors) 
 666              {
 667                  $this->set_message($errors, 'error');
 668                  $html = '';
 669                  $this->_error = true;
 670                  $this->logLine("\t".'Error writing database content: '.$errors);
 671              }
 672              else 
 673              {
 674                  $this->logLine("\t".'Database content successfully created');
 675                  $this->set_message(LANINS_069);
 676                  
 677                  $html = '<form method="post" id="confirmation" action="index.php">
 678                              <div class="navigation-top"><!-- --></div>
 679                              <div class="navigation">
 680                                  <input type="hidden" name="stage" value="'.($this->stage+1).'" />'.(!$this->previous_steps ? '' : '
 681                                  <input type="hidden" name="previous_steps" value="'.base64_encode(serialize($this->previous_steps)).'" />').'
 682                                  <input type="submit" id="submit" class="button" value="'.LANINS_035.'" />
 683                              </div>
 684                          </form>';
 685              }
 686          }
 687          
 688          # Set contents
 689          $this->template->SetTag('installation_heading', sprintf(LANINS_001, $this->template->getTag('app_version')));
 690          $this->template->SetTag('stage_num',            LANINS_058);
 691          $this->template->SetTag('stage',                $this->stage);
 692          $this->template->SetTag('stage_step',           sprintf(LANINS_002a, LANINS_058));
 693          $this->template->SetTag('stage_title',          $this->_error ? LANINS_071b : LANINS_071);
 694          $this->template->SetTag('static_title',         $this->_error ? LANINS_071c : LANINS_071a);
 695          $this->template->SetTag('stage_content',        $html);
 696          
 697          $this->logLine("\n".LANINS_002.' '.LANINS_058.' [ '.LANINS_071.' ]: --- '.LANINS_110.' ---');
 698      }
 699      
 700  	public function stage_invalid()
 701      {
 702          $this->set_message(LANINS_000, 'error');
 703          
 704          $this->template->SetTag('installation_heading', LANINS_001);
 705          $this->template->SetTag('stage_num',            LANINS_011);
 706          $this->template->SetTag('stage',                0);
 707          $this->template->SetTag('stage_step',           '');
 708          $this->template->SetTag('stage_title',          LANINS_125);
 709          $this->template->SetTag('static_title',         LANINS_125a);
 710          $this->template->SetTag('stage_content',        '');
 711      }
 712      
 713  	public function stage_template()
 714      { 
 715          // <span class="tinytext">{stage_step}</span>
 716          //{stage_num}
 717          //<h1>{installation_heading}</h1>
 718          return 
 719  '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 720  <html xmlns="http://www.w3.org/1999/xhtml">
 721  <head>
 722      <title>'.LANINS_TITLE.' {installation_heading} - {static_title}</title>
 723      <link rel="icon" href="'.e_HTTP.'favicon.ico" type="image/x-icon" />
 724      <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
 725      <meta http-equiv="content-style-type" content="text/css" />
 726      <style type="text/css">
 727          html, body                    { width:100%; }
 728          html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr,
 729          acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub,
 730          sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead,
 731          tr, th, td                    { margin:0; padding:0; border:0; }
 732          h1, h2, h3, h4, h5, h6        { line-height:normal; }
 733          ol, ul                        { list-style:none; }
 734          body                        { line-height:1; }
 735          q:before, q:after,
 736          blockquote:before,
 737          blockquote:after            { content:\'\'; content:none; }
 738          :focus                        { outline:0; }
 739          ins                            { text-decoration:none; }
 740          del                            { text-decoration:line-through; }
 741          table                        { border-collapse:collapse; border-spacing:0; }
 742          textarea.tbox,
 743          input.input-text            { width:auto; padding:5px; color:#111111; background-color:#FFFFFF; border:1px solid #CCCCCC; }
 744          textarea.tbox:focus,
 745          input.input-text:focus        { background-color:#EEEEEE; border:1px solid #CCCCCC; }
 746          body                        { background:#FFFFFF url(e107_files/install/images/mainbg.png) repeat-x 0 0; font:12px/16px Arial,Helvetica,sans-serif; color:#656565; }
 747          h1                            { font:normal 26px Arial,Helvetica,sans-serif; }
 748          h2                            { font:normal 22px Arial,Helvetica,sans-serif; }
 749          h3                            { font:normal 18px Arial,Helvetica,sans-serif; }
 750          h4                            { font:normal 16px Arial,Helvetica,sans-serif; }
 751          img                            { border:0; }
 752          a                            { color:#3399CC; text-decoration:none; cursor:pointer; }
 753          a:hover                        { color:#333333; text-decoration:underline; }
 754          *                            { margin:0; padding:0; }
 755          * .clearfix                    { display:block; }
 756          * html .clearfix            { height:1%; }
 757          .MT05                        { margin-top:5px; }
 758          .MT20                        { margin-top:15px; }
 759          .clear                        { clear:both; }
 760          .clearfix                    { display:inline-block; }
 761          .clearfix:after                { width:0; height:0; clear:both; content:\' \'; display:block; font-size:0; line-height:0; visibility:hidden; }
 762          .tbold                        { font-weight:bold; }
 763          .tnormal                    { font-weight:normal; }
 764          .fitalic                    { font-style:italic; }
 765          .fnormal                    { font-style:normal; }
 766          .right                        { text-align:right !important; }
 767          .smalltext                    { font-size:12px; font-weight:normal; }
 768          .smallblacktext                { font-size:12px; font-weight:bold; }
 769          .f-left                    { float:left; }
 770          .caption,
 771          .bodytable,
 772          .mediumtext,
 773          .defaulttext                { font-size:13px; font-weight:normal; }
 774          .fborder                    { padding:3px; margin-top:3px; text-align:left; background-color:transparent; border:0px none; }
 775          .v-top                        { vertical-align:top; }
 776          .v-mid                        { vertical-align:middle; }
 777          .install-logo                { padding:38px 0px 15px 25px; }
 778          .install-heading            { font-size:14px; margin-top:117px; margin-left:125px; }
 779          .wrapper                    { width:1000px; margin:0 auto; }
 780          .headerbg                     { background:url(e107_files/install/images/headerbg.png) repeat-x scroll 0 0 transparent; height:238px; width:100%; position:relative; z-index:10; }
 781          .stage-1                    { height:300px; position:relative; z-index:10; background:url(e107_files/install/images/1.png) no-repeat 100% 0; }
 782          .stage-2                    { height:300px; position:relative; z-index:10; background:url(e107_files/install/images/2.png) no-repeat 100% 0; }
 783          .stage-3                    { height:300px; position:relative; z-index:10; background:url(e107_files/install/images/3.png) no-repeat 100% 0; }
 784          .stage-4                    { height:300px; position:relative; z-index:10; background:url(e107_files/install/images/4.png) no-repeat 100% 0; }
 785          .stage-5                    { height:300px; position:relative; z-index:10; background:url(e107_files/install/images/5.png) no-repeat 100% 0; }
 786          .stage-6                    { height:300px; position:relative; z-index:10; background:url(e107_files/install/images/6.png) no-repeat 100% 0; }
 787          .stage-7                    { height:300px; position:relative; z-index:10; background:url(e107_files/install/images/7.png) no-repeat 100% 0; }
 788          .stage-7-finished            { height:300px; position:relative; z-index:10; background:url(e107_files/install/images/8.png) no-repeat 100% 0; }
 789          .hint                        { background-color:#FFFFD5; border:1px solid #FFCC00; font-size:12px; padding:7px; margin-top:5px; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; }
 790          .info                        { font-size:14px; padding:10px 25px 15px 25px; }
 791          .orange                        { font-size:22px; color:#ED7700; font-style:italic; }
 792          .tinytext                    { font-size:12px; margin-top:10px; padding:0px 35px; }
 793          .smalltext                    { font-size:14px; }
 794          .headerbg h1                 { padding-left:0px;  font-style:italic; font-weight:bold; font-size: 20px }
 795          .stage-title                { margin:30px 35px 0px 40px; font-size:22px;}
 796          .main-container                { background:#FFFFFF url(e107_files/install/images/contentbg.png) repeat-x 0 0; margin:0 auto ; width:100%; margin:10px 0; padding:20px 0px; }
 797          .main-content                { padding:0 0px 10px; }
 798          .main-content table            { width:100%; margin:0 auto ; }
 799          .top-content                { margin:0 20px 30px 20px; background-color:#FFFFFF; padding:20px 20px; display:block; }
 800          .top-content-title            { font-size:16px; font-weight:bold; padding-bottom:10px; margin-bottom:10px; text-shadow:2px 2px 2px #CCCCCC; background:url(e107_files/install/images/rightbox_title_bg.png) repeat-x 0 100%; }
 801          .stage                        { padding:10px 5px 10px; text-align:left; background-color:transparent; border-bottom:1px solid #CCCCCC; }
 802          .tbox                        { margin:5px 5px; padding:5px 10px; font-size:14px; font-weight:normal; color:#111111; background-color:#FFFFFF; border:1px solid #CCCCCC; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; }
 803          .tbox:focus                    { border:1px solid #CCCCCC; background-color:#EEEEEE; }
 804          .button, .button:focus        { margin:5px 0; padding:5px 10px; text-align:center; font-weight:bold; cursor:pointer; background-color:#FFFFFF; border:1px #CCCCCC solid; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; }
 805          .button:hover                { color:#3399CC; border:1px #EEEEEE solid; }
 806          .error                        { color:#FF5C5C; background-color:#FFCECE; border:1px solid #FF5C5C; padding:10px 20px; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; }
 807          .warning                    { color:#FF9900 }
 808          .rfield                        { color:#FF9900; font-weight: bolder !important; }
 809          .success                    { color:green; }
 810          .required                    { border:1px solid #FF5C5C; }
 811          .error-text                    { color:#FF5C5C; }
 812          .navigation                    { padding:8px 3px; font-weight:bold; text-align:center; vertical-align:middle; border:1px solid #CCCCCC; border-top:0px none; background-color:#F9F9F9; z-index:10; }
 813          .navigation-top                { width:100%; height:1px; background-color:#CCCCCC; }
 814          select.tbox, option.tbox    { padding:3px; margin: 3px 5px }
 815          checkbox, label                { margin:0 5px; }
 816          blockquote, q                { quotes:none; }
 817      </style>
 818  </head>
 819  <body>
 820      <div class="wrapper">
 821          <div class="headerbg">
 822              <div class="stage-{stage}'.(!$this->_error && 7 == $this->template->getTag('stage') ? '-finished' : '').'">
 823                  <div class="install-logo f-left"><img src="e107_files/install/images/e_logo.png" alt="" /></div>
 824                  <div class="install-heading f-left">{installation_heading}</div>
 825                  <div class="clear"><!-- --></div>
 826                  <div class="stage-title">'.LANINS_002.' / <span class="orange">{static_title}</span></div>
 827              </div>
 828          </div>
 829          <div class="main-container">
 830              <div id="content" class="top-content clearfix">
 831                  <div class="top-content-title clearfix">
 832                      {stage_title}
 833                  </div>
 834                  {stage_errors}
 835                  {stage_info}
 836                  <div class="main-content">
 837                      {stage_content}
 838                  </div>
 839                  {debug_info}
 840              </div>
 841          </div>
 842      </div>
 843      <script type="text/javascript">
 844          var e107_install = {
 845             init: function() {
 846                // Focus the first available to be focused element on the page
 847                if (document.getElementsByClassName(\'focusme\')[\'length\']) {
 848                   document.getElementsByClassName(\'focusme\')[0].focus();
 849                }
 850             }
 851          }
 852          
 853          e107_install.init();
 854      </script>
 855  </body>
 856  </html>';
 857      }
 858      
 859      
 860      /**
 861       * Language loader - loads the language file or raises an error on failure
 862       * 
 863       * @return    void
 864       */
 865  	public function get_lan_file()
 866      {
 867          if (!isset($this->previous_steps['language']))
 868              $this->previous_steps['language'] = 'English';
 869          
 870          $this->lan_file = $this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language'].'/lan_installer.php';
 871          
 872          if (is_readable($this->lan_file))
 873              include_once $this->lan_file;
 874          elseif (is_readable($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].'English/lan_installer.php'))
 875              include_once $this->e107->e107_dirs['LANGUAGES_DIRECTORY'].'English/lan_installer.php';
 876          else
 877              $this->set_message('Fatal: Could not get valid language file for installation.', 'error');
 878      }
 879      
 880      /**
 881       * Available languages getter
 882       *
 883       * @return    array    Available languages array
 884       */
 885  	public function get_languages()
 886      {
 887          $handle  = opendir($this->e107->e107_dirs['LANGUAGES_DIRECTORY']);
 888          $lan_dir = $this->e107->e107_dirs['LANGUAGES_DIRECTORY'];
 889          
 890          while ($file = readdir($handle))
 891          {
 892              if (!in_array($file, array('.','..','/','CVS','.svn')) && file_exists("./{$lan_dir}{$file}/lan_installer.php"))
 893                  $lanlist[] = $file;
 894          }
 895          closedir($handle);
 896          return $lanlist;
 897      }
 898      
 899      /**
 900       * Log writer - writes a line to the log file
 901       *
 902       * @param    string    $logLine
 903       * @return    void
 904       */
 905  	public function logLine($logLine)
 906      {
 907          if (!MAKE_INSTALL_LOG || '' == $this->logFile)  return;
 908          
 909          if (!is_file($this->logFile))  file_put_contents($this->logFile, '[ '.($now = time()).', '.gmstrftime('%y-%m-%d %H:%M:%S', $now)."]\n");
 910          
 911          $logfp = fopen($this->logFile, 'a+');
 912          fwrite($logfp, $logLine."\n");
 913          fclose($logfp);
 914      }
 915      
 916      /**
 917       * Messages handler
 918       *
 919       * @param    string    $message    The message
 920       * @param    string    $type        Type of the message - defines where should it go and how to be shown
 921       * @return    void
 922       */
 923  	public function set_message($message, $type='info')
 924      {
 925          if (!in_array($type, array_keys($this->_messages)))  return;
 926          
 927          if ('debug' != $type)  $this->_messages[$type][] = $message;
 928          
 929          $this->_messages['debug'][] = array (
 930              'info'      => $message,
 931              'backtrace' => debug_backtrace(),
 932          );
 933      }
 934      
 935      /**
 936       * Prepares and sets debug info for output
 937       * 
 938       * @return    void
 939       */
 940  	public function set_messages()
 941      {
 942          $this->template->SetTag('stage_errors', (empty($this->_messages['error']) ? '' :
 943                  '<div class="error">
 944                      '.implode("\n\t\t\t\t\t", $this->_messages['error']).'
 945                  </div>'
 946          ));
 947          $this->template->SetTag('stage_info', (empty($this->_messages['info']) ? '' :
 948                  '<div class="info">
 949                      '.implode("\n\t\t\t\t\t", $this->_messages['info']).'
 950                  </div>'
 951          ));
 952          $this->template->SetTag('debug_info', ('debug' != $_SERVER['QUERY_STRING'] ? '' :
 953                  '<div class="debug-container">
 954                      <div class="debug-info">
 955                          <h3>'.LANINS_123.':</h3>
 956                          '.print_a($e_install->debug_info).'
 957                      </div>
 958                      <div class="backtrace-info">
 959                          <h3>'.LANINS_124.':</h3>
 960                          '.print_a($e_install).'
 961                      </div>
 962                  </div>'
 963          ));
 964      }
 965      
 966      /**
 967       * DB name or table prefix validator - anything starting with a numeric followed by 'e' causes problems
 968       *
 969       * @param    string    $str        The name to be checked
 970       * @param    bool    $blank_ok    Whether to accept blank value (should be set TRUE for prefix, FALSE for DB name)
 971       * @return    bool                Valid or not
 972       */
 973  	protected function _check_name($str, $blank_ok=false)
 974      {
 975          if ('' == $str)                       return $blank_ok;
 976          if (preg_match('#^\d+[e|E]#', $str))  return false;
 977          return true;
 978      }
 979      
 980      /**
 981       * Check an array of db-related fields for illegal characters
 982       *
 983       * @param    array    $fields
 984       * @return    bool    true=OK, false=invalid char
 985       */
 986  	protected function _checkDbFields($fields)
 987      {
 988          if (!is_array($fields))  return false;
 989          
 990          foreach (array('db', 'user', 'server', 'prefix') as $key)
 991          {
 992              if (isset($fields[$key]) && strtr($fields[$key], "';", '    ') != $fields[$key])  return false; # Invalid character found
 993          }
 994          
 995          return true;
 996      }
 997      
 998      /**
 999       * Check whether files/directories are writable
1000       * 
1001       * @param    str        $list    List type [can_write|must_write]
1002       * @return    array            Failed files/directories list
1003       */
1004  	protected function _check_writable_perms($list='must_write')
1005      {
1006          $bad_files = array();
1007          $data['must_write'] = 'e107_config.php';
1008          $data['can_write']  = '{$FILES_DIRECTORY}cache/|{$FILES_DIRECTORY}public/|{$FILES_DIRECTORY}public/avatars/|{$PLUGINS_DIRECTORY}|{$THEMES_DIRECTORY}';
1009          
1010          if (!isset($data[$list]))  return $bad_files;
1011          
1012          foreach ($this->e107->e107_dirs as $dir_name=>$value) 
1013          {
1014              $find[]    = "{\${$dir_name}}";
1015              $replace[] = './'.$value;
1016          }
1017          
1018          $data[$list] = str_replace($find, $replace, $data[$list]);
1019          $files       = explode('|', trim($data[$list]));
1020          
1021          foreach ($files as $file)  if (!is_writable($file))  $bad_files[] = str_replace('./', '', $file);
1022          
1023          return $bad_files;
1024      }
1025      
1026      /**
1027       * DB tables creator - creates all necessary DB tables and content
1028       *
1029       * @return    mixed    bool false on success (no errors) | string (error message) on error
1030       */
1031  	protected function _create_tables()
1032      {
1033          $link = mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']);
1034          
1035          if (!$link)  return nl2br(LANINS_084."\n\n<b>".LANINS_083.":\n</b><i>".mysql_error($link)."</i>");
1036          
1037          $db_selected = mysql_select_db($this->previous_steps['mysql']['db'], $link);
1038          
1039          if (!$db_selected)  return nl2br(LANINS_085." '{$this->previous_steps['mysql']['db']}'\n\n<b>".LANINS_083.":\n</b><i>".mysql_error($link).'</i>');
1040          
1041          $filename = $this->e107->e107_dirs['ADMIN_DIRECTORY'].'sql/core_sql.php';
1042          $fd       = fopen ($filename, 'r');
1043          $sql_data = fread($fd, filesize($filename));
1044          
1045          fclose ($fd);
1046          
1047          if (!$sql_data)  return nl2br(LANINS_060).'<br /><br />';
1048          
1049          preg_match_all('/create(.*?)(?:myisam|innodb);/si', $sql_data, $result );
1050          
1051          # Force UTF-8 again
1052          if ($this->previous_steps['mysql']['db_utf8'])  @mysql_query('SET NAMES `utf8`');
1053          
1054          foreach ($result[0] as $sql_table)
1055          {
1056  //            preg_match("/CREATE TABLE\s(.*?)\s\(/si", $sql_table, $match);
1057  //            $tablename = $match[1];
1058  //            
1059  //            preg_match_all("/create(.*?)myisam;/si", $sql_data, $result );
1060              $sql_table = preg_replace("/create table\s/si", "CREATE TABLE {$this->previous_steps['mysql']['prefix']}", $sql_table);
1061              
1062              if (!mysql_query($sql_table, $link))  return nl2br(LANINS_061."\n\n<b>".LANINS_083.":\n</b><i>".mysql_error($link)."</i>");
1063          }
1064          $this->logLine('All tables created');
1065          $datestamp = time();
1066          
1067          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}news VALUES (0, '".LANINS_063."', '".LANINS_NEWS."', '', '{$datestamp}', '0', '1', 1, 0, 0, 0, 0, '0', '', 'welcome.png', 0) ");
1068          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}news_category VALUES (0, '".LANINS_087."', 'icon26.png') ");
1069          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_088."', 'index.php', '', '', 1, 1, 0, 0, 0) ");
1070          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_098."', 'news.php', '', '', 1, 2, 0, 0, 0) ");
1071          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_089."', 'download.php', '', '', 1, 3, 0, 0, 0) ");
1072          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_092."', 'contact.php', '', '', 1, 4, 0, 0, 0) ");
1073          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_090."', 'user.php', '', '', 2, 1, 0, 0, 0) ");
1074          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_091."', 'submitnews.php', '', '', 2, 2, 0, 0, 0) ");
1075          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_099."', 'http://e107.org/', '', '', 3, 1, 0, 0, 0) ");
1076          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_103."', 'http://e107.org/plugins/', '', '', 3, 2, 0, 0, 0) ");
1077          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_111."', 'http://e107.org/themes/', '', '', 3, 3, 0, 0, 0) ");
1078          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}links VALUES (0, '".LANINS_112."', 'http://wiki.e107.org/', '', '', 3, 4, 0, 0, 0) ");
1079          
1080          $udirs  = 'admin/|plugins/|temp';
1081          $e_SELF = $_SERVER['PHP_SELF'];
1082          $e_HTTP = preg_replace('#'.$udirs.'#i', '', substr($e_SELF, 0, strrpos($e_SELF, '/')).'/');
1083          
1084          $pref_language = isset($this->previous_steps['language']) ? $this->previous_steps['language'] : 'English';
1085          
1086          if (file_exists($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$pref_language.'/lan_prefs.php'))
1087              include_once $this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$pref_language.'/lan_prefs.php';
1088          else
1089              include_once $this->e107->e107_dirs['LANGUAGES_DIRECTORY'].'English/lan_prefs.php';
1090          
1091          $site_admin_user  = $this->previous_steps['admin']['display'];
1092          $site_admin_email = $this->previous_steps['admin']['email'];
1093          
1094          require_once $this->e107->e107_dirs['FILES_DIRECTORY'].'def_e107_prefs.php';
1095          include_once $this->e107->e107_dirs['HANDLERS_DIRECTORY'].'arraystorage_class.php';
1096          
1097          $tmp = ArrayData::WriteArray($pref);
1098          
1099          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs', '{$tmp}')");
1100          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs_Backup', '{$tmp}')");
1101          
1102          $emote = 'a:60:{i:0;a:1:{s:2:"&|";s:7:"cry.png";}i:1;a:1:{s:3:"&-|";s:7:"cry.png";}i:2;a:1:{s:3:"&o|";s:7:"cry.png";}i:3;a:1:{s:3:":((";s:7:"cry.png";}i:4;a:1:{s:3:"~:(";s:7:"mad.png";}i:5;a:1:{s:4:"~:o(";s:7:"mad.png";}i:6;a:1:{s:4:"~:-(";s:7:"mad.png";}i:7;a:1:{s:2:":)";s:9:"smile.png";}i:8;a:1:{s:3:":o)";s:9:"smile.png";}i:9;a:1:{s:3:":-)";s:9:"smile.png";}i:10;a:1:{s:2:":(";s:9:"frown.png";}i:11;a:1:{s:3:":o(";s:9:"frown.png";}i:12;a:1:{s:3:":-(";s:9:"frown.png";}i:13;a:1:{s:2:":D";s:8:"grin.png";}i:14;a:1:{s:3:":oD";s:8:"grin.png";}i:15;a:1:{s:3:":-D";s:8:"grin.png";}i:16;a:1:{s:2:":?";s:12:"confused.png";}i:17;a:1:{s:3:":o?";s:12:"confused.png";}i:18;a:1:{s:3:":-?";s:12:"confused.png";}i:19;a:1:{s:3:"%-6";s:11:"special.png";}i:20;a:1:{s:2:"x)";s:8:"dead.png";}i:21;a:1:{s:3:"xo)";s:8:"dead.png";}i:22;a:1:{s:3:"x-)";s:8:"dead.png";}i:23;a:1:{s:2:"x(";s:8:"dead.png";}i:24;a:1:{s:3:"xo(";s:8:"dead.png";}i:25;a:1:{s:3:"x-(";s:8:"dead.png";}i:26;a:1:{s:2:":@";s:7:"gah.png";}i:27;a:1:{s:3:":o@";s:7:"gah.png";}i:28;a:1:{s:3:":-@";s:7:"gah.png";}i:29;a:1:{s:2:":!";s:8:"idea.png";}i:30;a:1:{s:3:":o!";s:8:"idea.png";}i:31;a:1:{s:3:":-!";s:8:"idea.png";}i:32;a:1:{s:2:":|";s:11:"neutral.png";}i:33;a:1:{s:3:":o|";s:11:"neutral.png";}i:34;a:1:{s:3:":-|";s:11:"neutral.png";}i:35;a:1:{s:2:"?!";s:12:"question.png";}i:36;a:1:{s:2:"B)";s:12:"rolleyes.png";}i:37;a:1:{s:3:"Bo)";s:12:"rolleyes.png";}i:38;a:1:{s:3:"B-)";s:12:"rolleyes.png";}i:39;a:1:{s:2:"8)";s:10:"shades.png";}i:40;a:1:{s:3:"8o)";s:10:"shades.png";}i:41;a:1:{s:3:"8-)";s:10:"shades.png";}i:42;a:1:{s:2:":O";s:12:"suprised.png";}i:43;a:1:{s:3:":oO";s:12:"suprised.png";}i:44;a:1:{s:3:":-O";s:12:"suprised.png";}i:45;a:1:{s:2:":p";s:10:"tongue.png";}i:46;a:1:{s:3:":op";s:10:"tongue.png";}i:47;a:1:{s:3:":-p";s:10:"tongue.png";}i:48;a:1:{s:2:":P";s:10:"tongue.png";}i:49;a:1:{s:3:":oP";s:10:"tongue.png";}i:50;a:1:{s:3:":-P";s:10:"tongue.png";}i:51;a:1:{s:2:";)";s:8:"wink.png";}i:52;a:1:{s:3:";o)";s:8:"wink.png";}i:53;a:1:{s:3:";-)";s:8:"wink.png";}i:54;a:1:{s:4:"!ill";s:7:"ill.png";}i:55;a:1:{s:7:"!amazed";s:10:"amazed.png";}i:56;a:1:{s:4:"!cry";s:7:"cry.png";}i:57;a:1:{s:6:"!dodge";s:9:"dodge.png";}i:58;a:1:{s:6:"!alien";s:9:"alien.png";}i:59;a:1:{s:6:"!heart";s:9:"heart.png";}}';
1103          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('emote', '{$emote}') ");
1104          
1105          # Set up menu prefs so they can be 'lanned'
1106          $new_block = Array ( 
1107              'comment_caption'             => LANINS_096,    # 'Latest Comments'
1108              'comment_display'             => '10',
1109              'comment_characters'         => '50',
1110              'comment_postfix'             => LANINS_097,    # '[more ...]'
1111              'comment_title'             => 0,
1112  // obsolete    'article_caption'             => LANINS_098,    # 'Articles'
1113  // obsolete    'articles_display'             => '10',
1114  // obsolete    'articles_mainlink'         => LANINS_099,    # 'Articles Front Page ...'
1115              'newforumposts_caption'     => LANINS_100,    # 'Latest Forum Posts'
1116              'newforumposts_display'     => '10',
1117              'forum_no_characters'         => '20',
1118              'forum_postfix'             => LANINS_097,    # '[more ...]'
1119              'update_menu'                 => LANINS_101,    # 'Update menu Settings'
1120              'forum_show_topics'         => '1',
1121              'newforumposts_characters'    => '50',
1122              'newforumposts_postfix'     => LANINS_097,    # '[more ...]'
1123              'newforumposts_title'         => 0,
1124              'clock_caption'             => LANINS_102,    # 'Date / Time'
1125  // obsolete    'reviews_caption'            => LANINS_103,    # 'Reviews'
1126  // obsolete    'reviews_display'            => '10',
1127  // obsolete    'reviews_parents'            => '1',
1128  // obsolete    'reviews_mainlink'            => LANINS_104,    # 'Review Front Page ...'
1129  // obsolete    'articles_parents'             => '1'
1130          );
1131          
1132          $menu_conf    = serialize($new_block);
1133          $notify_prefs = mysql_real_escape_string("array ('event' => array ('usersup' => array ('type' => 'off', 'class' => '254', 'email' => '',),'userveri' => array ( 'type' => 'off', 'class' => '254', 'email' => '', ), 'login' => array ( 'type' => 'off', 'class' => '254', 'email' => '', ), 'logout' => array ( 'type' => 'off', 'class' => '254', 'email' => '', ), 'flood' => array ( 'type' => 'off', 'class' => '254', 'email' => '', ), 'subnews' => array ( 'type' => 'off', 'class' => '254', 'email' => '', ), 'newspost' => array ( 'type' => 'off', 'class' => '254', 'email' => '', ), 'newsupd' => array ( 'type' => 'off', 'class' => '254', 'email' => '', ), 'newsdel' => array ( 'type' => 'off', 'class' => '254', 'email' => '', ), ), )");
1134          
1135          preg_match('/^(.*?)($|-)/', mysql_get_server_info(), $mysql_version);
1136          
1137          if (version_compare($mysql_version[1], '4.0.1', '<'))
1138              $search_prefs = 'a:12:{s:11:\"user_select\";s:1:\"1\";s:9:\"time_secs\";s:2:\"60\";s:13:\"time_restrict\";s:1:\"0\";s:8:\"selector\";s:1:\"2\";s:9:\"relevance\";s:1:\"0\";s:13:\"plug_handlers\";N;s:10:\"mysql_sort\";b:0;s:11:\"multisearch\";s:1:\"1\";s:6:\"google\";s:1:\"0\";s:13:\"core_handlers\";a:5:{s:4:\"news\";a:6:{s:5:\"class\";s:1:\"0\";s:9:\"pre_title\";s:1:\"0\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:5:\"order\";s:1:\"1\";}s:8:\"comments\";a:6:{s:5:\"class\";s:1:\"0\";s:9:\"pre_title\";s:1:\"1\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:5:\"order\";s:1:\"2\";}s:5:\"users\";a:6:{s:5:\"class\";s:1:\"0\";s:9:\"pre_title\";s:1:\"1\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:5:\"order\";s:1:\"3\";}s:9:\"downloads\";a:6:{s:5:\"class\";s:1:\"0\";s:9:\"pre_title\";s:1:\"1\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:5:\"order\";s:1:\"4\";}s:5:\"pages\";a:6:{s:5:\"class\";s:1:\"0\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:9:\"pre_title\";s:1:\"0\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"order\";s:1:\"5\";}}s:17:\"comments_handlers\";a:2:{s:4:\"news\";a:3:{s:2:\"id\";i:0;s:3:\"dir\";s:4:\"core\";s:5:\"class\";s:1:\"0\";}s:8:\"download\";a:3:{s:2:\"id\";i:2;s:3:\"dir\";s:4:\"core\";s:5:\"class\";s:1:\"0\";}}s:9:\"php_limit\";s:0:\"\";}';
1139          else
1140              $search_prefs = 'a:12:{s:11:\"user_select\";s:1:\"1\";s:9:\"time_secs\";s:2:\"60\";s:13:\"time_restrict\";s:1:\"0\";s:8:\"selector\";s:1:\"2\";s:9:\"relevance\";s:1:\"0\";s:13:\"plug_handlers\";N;s:10:\"mysql_sort\";b:1;s:11:\"multisearch\";s:1:\"1\";s:6:\"google\";s:1:\"0\";s:13:\"core_handlers\";a:5:{s:4:\"news\";a:6:{s:5:\"class\";s:1:\"0\";s:9:\"pre_title\";s:1:\"0\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:5:\"order\";s:1:\"1\";}s:8:\"comments\";a:6:{s:5:\"class\";s:1:\"0\";s:9:\"pre_title\";s:1:\"1\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:5:\"order\";s:1:\"2\";}s:5:\"users\";a:6:{s:5:\"class\";s:1:\"0\";s:9:\"pre_title\";s:1:\"1\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:5:\"order\";s:1:\"3\";}s:9:\"downloads\";a:6:{s:5:\"class\";s:1:\"0\";s:9:\"pre_title\";s:1:\"1\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:5:\"order\";s:1:\"4\";}s:5:\"pages\";a:6:{s:5:\"class\";s:1:\"0\";s:5:\"chars\";s:3:\"150\";s:7:\"results\";s:2:\"10\";s:9:\"pre_title\";s:1:\"0\";s:13:\"pre_title_alt\";s:0:\"\";s:5:\"order\";s:1:\"5\";}}s:17:\"comments_handlers\";a:2:{s:4:\"news\";a:3:{s:2:\"id\";i:0;s:3:\"dir\";s:4:\"core\";s:5:\"class\";s:1:\"0\";}s:8:\"download\";a:3:{s:2:\"id\";i:2;s:3:\"dir\";s:4:\"core\";s:5:\"class\";s:1:\"0\";}}s:9:\"php_limit\";s:0:\"\";}';
1141          
1142          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('menu_pref', '{$menu_conf}') ");
1143          
1144          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('search_prefs', '{$search_prefs}') ");
1145          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('notify_prefs', '{$notify_prefs}') ");
1146          
1147          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}banner VALUES (0, 'e107', 'e107login', 'e107password', 'banner1.png', 'http://e107.org', 0, 0, 0, 0, 0, 0, '', 'campaign_one') ");
1148          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}banner VALUES (0, 'e107', 'e107login', 'e107password', 'banner2.png', 'http://e107.org', 0, 0, 0, 0, 0, 0, '', 'campaign_one') ");
1149          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}banner VALUES (0, 'e107', 'e107login', 'e107password', 'banner3.png', 'http://e107.org', 0, 0, 0, 0, 0, 0, '', 'campaign_one') ");
1150          
1151          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (1, 'login_menu', 0, 0, '0', '', 'login_menu/')");
1152          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (3, 'online_menu', 0, 0, '0', '', 'online_menu/')");
1153          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (4, 'blogcalendar_menu', 0, 0, '0', '', 'blogcalendar_menu/')");
1154          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (5, 'tree_menu', 0, 0, '0', '', 'tree_menu/')");
1155          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (6, 'search_menu', 0, 0, '0', '', 'search_menu/')");
1156          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (7, 'compliance_menu', 0, 0, '0', '', 'compliance_menu/')");
1157          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (8, 'userlanguage_menu', 0, 0, '0', '', 'userlanguage_menu/')");
1158          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (9, 'powered_by_menu', 1, 1, '0', '2-index.php', 'powered_by_menu/')");
1159          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (10, 'counter_menu', 0, 0, '0', '', 'counter_menu/')");
1160          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (11, 'usertheme_menu', 0, 0, '0', '', 'usertheme_menu/')");
1161          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (12, 'banner_menu', 0, 0, '0', '', 'banner_menu/')");
1162          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (13, 'online_extended_menu', 0, 0, '0', '', 'online_extended_menu/')");
1163          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (14, 'clock_menu', 0, 0, '0', '', 'clock_menu/')");
1164          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (15, 'sitebutton_menu', 0, 0, '0', '', 'sitebutton_menu/')");
1165          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (16, 'comment_menu', 0, 0, '0', '', 'comment_menu/')");
1166          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (17, 'lastseen_menu', 0, 0, '0', '', 'lastseen/')");
1167          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (18, 'other_news_menu', 0, 0, '0', '', 'other_news_menu/')");
1168          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (19, 'other_news2_menu', 0, 0, '0', '', 'other_news_menu/')");
1169          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (20, 'admin_menu', 0, 0, '0', '', 'admin_menu/')");
1170  //        mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (21, 'rss_menu', 5, 1, '0', '', 'rss_menu/')");
1171  //        mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (22, 'PCMag', 3, 1, '0', '', '1')");
1172          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (21, 'e107_plugins', 2, 1, '0', '', '1')");
1173          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (22, 'e107_themes', 3, 1, '0', '', '2')");
1174          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}menus VALUES (23, 'e107_handbook', 4, 1, '0', '', '3')");
1175  
1176          
1177          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}userclass_classes VALUES (1, 'PRIVATEMENU', '".LANINS_093."',".e_UC_ADMIN.")");
1178          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}userclass_classes VALUES (2, 'PRIVATEFORUM1', '".LANINS_094."',".e_UC_ADMIN.")");
1179  //        mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}plugin VALUES (0, '".LANINS_095."', '0.03', 'Integrity Check', 1, '') ");
1180          
1181          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}generic VALUES (0, 'wmessage', {$datestamp}, 1, '', 0, '[img=style=float: left; margin-right: 20px]{e_IMAGE}splash.jpg[/img]".LANINS_WELCOME."')");
1182          
1183          // TODO - more and better custom menus
1184          //mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}page VALUES (1, '', '[img]{e_IMAGE}pcmag.png[/img] ', 0, 1145843485, 0, 0, '', '', '', 'PCMag')");
1185          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}page VALUES (1, '".LANINS_103."', '[link=http://e107.org/plugins][img]{e_IMAGE}e107_plugins.png[/img][/link]', 0, {$datestamp}, 0, 0, '', '', '', 'e107_plugins')");
1186          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}page VALUES (2, '".LANINS_111."', '[link=http://e107.org/themes][img]{e_IMAGE}e107_themes.png[/img][/link]', 0, {$datestamp}, 0, 0, '', '', '', 'e107_themes')");
1187          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}page VALUES (3, '".LANINS_112."', '[link=http://e107.org/handbook][img]{e_IMAGE}e107_handbook.png[/img][/link]', 0, {$datestamp}, 0, 0, '', '', '', 'e107_handbook')");
1188          $this->logLine('Sample custom menu added');
1189          
1190          # Create the admin user
1191          $ip    = $_SERVER['REMOTE_ADDR'];
1192          $userp = "1, '{$this->previous_steps['admin']['display']}', '{$this->previous_steps['admin']['user']}', '', '".md5($this->previous_steps['admin']['password'])."', '', '{$this->previous_steps['admin']['email']}', '', '', '', 0, ".time().", 0, 0, 0, 0, 0, 0, '{$ip}', 0, '', '', '', 0, 1, '', '', '0', '', ".time().", ''";
1193          
1194          mysql_query("INSERT INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})" );
1195          
1196          $this->logLine('User record added');
1197          
1198          if (mysql_close($link))    # $link should be specified due to PHP5.3 (http://bugs.php.net/bug.php?id=48754)
1199          {
1200              $this->logLine('Database manipulation complete');
1201          }
1202          else
1203          {
1204              $this->logLine('Error closing database: '.mysql_error());
1205              return 'Error closing database: '.mysql_error();
1206          }
1207          
1208          return false;
1209      }
1210      
1211      /**
1212       * e107_config.php Config file generator
1213       *
1214       * @return    mixed    bool false on success (no errors) | string (error message) on error
1215       */
1216  	protected function _write_config()
1217      {
1218          $fp   = @fopen('e107_config.php', 'w');
1219          $data = 
1220  "<?php
1221  /**
1222   *  e107 Website Content Management System
1223   *  
1224   *  ©e107 Inc 2008-2012
1225   *  http://e107.org
1226   *  
1227   *  Released under the terms and conditions of the
1228   *  GNU General Public License (http://gnu.org).
1229   *  
1230   *  This file has been auto-generated during installation process
1231   *  
1232   *  e107_config.php
1233   */
1234  
1235  \$mySQLserver         = '{$this->previous_steps['mysql']['server']}';
1236  \$mySQLuser           = '{$this->previous_steps['mysql']['user']}';
1237  \$mySQLpassword       = '{$this->previous_steps['mysql']['password']}';
1238  \$mySQLdefaultdb      = '{$this->previous_steps['mysql']['db']}';
1239  \$mySQLprefix         = '{$this->previous_steps['mysql']['prefix']}';
1240  \$mySQLcharset        = '".($this->previous_steps['mysql']['db_utf8'] ? 'utf8' : '')."';    # \$mySQLcharset can only contain 'utf8' or ''
1241  
1242  \$ADMIN_DIRECTORY     = '{$this->e107->e107_dirs['ADMIN_DIRECTORY']}';
1243  \$FILES_DIRECTORY     = '{$this->e107->e107_dirs['FILES_DIRECTORY']}';
1244  \$IMAGES_DIRECTORY    = '{$this->e107->e107_dirs['IMAGES_DIRECTORY']}';
1245  \$THEMES_DIRECTORY    = '{$this->e107->e107_dirs['THEMES_DIRECTORY']}';
1246  \$PLUGINS_DIRECTORY   = '{$this->e107->e107_dirs['PLUGINS_DIRECTORY']}';
1247  \$HANDLERS_DIRECTORY  = '{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}';
1248  \$LANGUAGES_DIRECTORY = '{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}';
1249  \$HELP_DIRECTORY      = '{$this->e107->e107_dirs['HELP_DIRECTORY']}';
1250  \$DOWNLOADS_DIRECTORY = '{$this->e107->e107_dirs['DOWNLOADS_DIRECTORY']}';";
1251          
1252          if (!@fwrite($fp, $data))
1253          {
1254              @fclose ($fp);
1255              return nl2br(LANINS_070);
1256          }
1257          @fclose ($fp);
1258          return false;
1259      }
1260  }
1261  
1262  class SimpleTemplate
1263  {
1264      public    $Tags      = array();
1265      public    $open_tag  = '{';
1266      public    $close_tag = '}';
1267      
1268  	public function GetTag($TagName, $Default='')
1269      {
1270          return isset($this->Tags[$TagName]) ? $this->Tags[$TagName]['Data'] : $Default;
1271      }
1272      
1273  	public function SetTag($TagName, $Data)
1274      {
1275          $this->Tags[$TagName] = array(
1276              'Tag'  => $TagName,
1277              'Data' => $Data
1278          );
1279          
1280          return $this;
1281      }
1282      
1283  	public function RemoveTag($TagName)
1284      {
1285          if (isset($this->Tags[$TagName]))  unset($this->Tags[$TagName]);
1286          
1287          return $this;
1288      }
1289      
1290  	public function ClearTags()
1291      {
1292          $this->Tags = array();
1293          
1294          return $this;
1295      }
1296      
1297  	public function ParseTemplate($Template, $from_file=false)
1298      {
1299          $TemplateData = $from_file ? file_get_contents($Template) : $Template;
1300          
1301          foreach ($this->Tags as $Tag)  $TemplateData = str_replace($this->open_tag.$Tag['Tag'].$this->close_tag, $Tag['Data'], $TemplateData);
1302          
1303          return $TemplateData;
1304      }
1305  }


Generated: Mon Mar 12 16:28:38 2012 Cross Reference PHPXref