[ Index ]

PHP Cross Reference of Nucleus CMS 3.32

title

Body

[close]

/ -> install.php (source)

   1  <?php
   2  /*
   3   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
   4   * Copyright (C) 2002-2007 The Nucleus Group
   5   *
   6   * This program is free software; you can redistribute it and/or
   7   * modify it under the terms of the GNU General Public License
   8   * as published by the Free Software Foundation; either version 2
   9   * of the License, or (at your option) any later version.
  10   * (see nucleus/documentation/index.html#license for more info)
  11   * This script will install the Nucleus tables in your SQL-database, and initialize the data in
  12   * those tables.
  13   *
  14   * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.
  15   * ?><div style="font-size: xx-large;">If you see this text in your browser when you open <i>install.php</i>, your web server is not able to run PHP-scripts, and therefor Nucleus will not be able to run there. </div><div style="display: none"><?php
  16   */
  17  
  18  /**
  19   * @license http://nucleuscms.org/license.txt GNU General Public License
  20   * @copyright Copyright (C) 2002-2007 The Nucleus Group
  21   * @version $Id: install.php 1184 2007-07-15 22:43:46Z kaigreve $
  22   */
  23  
  24  /*
  25      This part of the install.php code allows for customization of the install process.
  26      When distributing plugins or skins together with a Nucleus installation, the
  27      configuration below will instruct to install them
  28  
  29      -- Start Of Configurable Part --
  30  */
  31  
  32  // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/
  33  // directory.
  34  //
  35  // example:
  36  //     array('NP_TrackBack', 'NP_MemberGoodies')
  37  $aConfPlugsToInstall = array('NP_SkinFiles');
  38  
  39  
  40  // array with skins to install. skins must be present under the skins/ directory with
  41  // a subdirectory having the same name that contains a skinbackup.xml file
  42  //
  43  // example:
  44  //     array('base','rsd')
  45  $aConfSkinsToImport = array('default');
  46  
  47  /*
  48      -- End Of Configurable Part --
  49  */
  50  
  51  // don't give warnings for uninitialized vars
  52  error_reporting(E_ERROR | E_WARNING | E_PARSE);
  53  
  54  // make sure there's no unnecessary escaping:
  55  set_magic_quotes_runtime(0);
  56  
  57  // if there are some plugins or skins to import, do not include vars
  58  // in globalfunctions.php again... so set a flag
  59  if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
  60      global $CONF;
  61      $CONF['installscript'] = 1;
  62  }
  63  
  64  if (phpversion() >= '4.1.0') {
  65      include_once ('nucleus/libs/vars4.1.0.php');
  66  } else {
  67      include_once ('nucleus/libs/vars4.0.6.php');
  68  }
  69  
  70  include_once ('nucleus/libs/mysql.php');
  71  
  72  // check if mysql support is installed
  73      if (!function_exists('mysql_query') ) {
  74          _doError('Your PHP version does not have support for MySQL :(');
  75      }
  76  
  77      if (postVar('action') == 'go') {
  78          doInstall();
  79      } else {
  80          showInstallForm();
  81      }
  82  
  83      exit;
  84  
  85  function showInstallForm() {
  86      // 0. pre check if all necessary files exist
  87      doCheckFiles();
  88  
  89      ?>
  90      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  91      <html xmlns="http://www.w3.org/1999/xhtml">
  92      <head>
  93          <title>Nucleus Install</title>
  94          <style type="text/css"><!--
  95              @import url('nucleus/documentation/styles/manual.css');
  96          --></style>
  97          <script type="text/javascript"><!--
  98              var submitcount = 0;
  99  
 100              // function to make sure the submit button only gets pressed once
 101  			function checkSubmit() {
 102                  if (submitcount == 0) {
 103                      submitcount++;
 104                      return true;
 105                  } else {
 106                      return false;
 107                  }
 108              }
 109          --></script>
 110      </head>
 111      <body>
 112          <div style="text-align:center"><img src="./nucleus/styles/logo.gif" /></div> <!-- Nucleus logo -->
 113          <form method="post" action="install.php">
 114  
 115          <h1>Install Nucleus</h1>
 116  
 117          <p>This script will help you to install Nucleus. It will set up your MySQL database tables and provide you with the information you need to enter in <i>config.php</i>. In order to do all this, you need to enter some information.</p>
 118  
 119          <p>All fields are mandatory. Optional information can be set from the Nucleus admin-area when installation is completed.</p>
 120  
 121          <h1>PHP &amp; MySQL Versions</h1>
 122  
 123          <p>Below are the version numbers of the PHP interpreter and the MySQL server on your webhost. When reporting problems on the Nucleus Support Forum, please include this information.</p>
 124  
 125          <ul>
 126              <li>PHP:
 127  
 128  <?php
 129      echo phpversion();
 130      $minVersion = '4.0.6';
 131  
 132      if (phpversion() < $minVersion) {
 133          echo ' <span class="warning">WARNING: Nucleus requires at least version ', $minVersion, '</span>';
 134      }
 135  ?>
 136  
 137              </li>
 138              <li>MySQL:
 139  
 140  <?php
 141      // note: this piece of code is taken from phpMyAdmin
 142      $result = @mysql_query('SELECT VERSION() AS version');
 143  
 144      if ($result != FALSE && @mysql_num_rows($result) > 0) {
 145          $row = mysql_fetch_array($result);
 146          $match = explode('.', $row['version']);
 147      } else {
 148          $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
 149  
 150          if ($result != FALSE && @mysql_num_rows($result) > 0) {
 151              $row = mysql_fetch_row($result);
 152              $match = explode('.', $row[1]);
 153          } else {
 154              $match[0] = '?';
 155              $match[1] = '?';
 156              $match[2] = '?';
 157          }
 158      }
 159  
 160      if (!isset($match) || !isset($match[0]) ) {
 161          $match[0] = 3;
 162      }
 163  
 164      if (!isset($match[1]) ) {
 165          $match[1] = 21;
 166      }
 167  
 168      if (!isset($match[2]) ) {
 169          $match[2] = 0;
 170      }
 171  
 172      if ($match[0] != '?') {
 173          $match[0] = intval($match[0]);
 174          $match[1] = intval($match[1]);
 175      }
 176  
 177      $mysqlVersion = implode($match, '.');
 178      $minVersion = '3.23';
 179  
 180      echo $mysqlVersion;
 181  
 182      if ($mysqlVersion < $minVersion) {
 183          echo ' <span class="warning">WARNING: Nucleus requires at least version ', $minVersion, '</span>';
 184      }
 185  ?>
 186  
 187              </li>
 188          </ul>
 189  
 190  <?php
 191      // tell people how they can have their config file filled out automatically
 192      if (@file_exists('config.php') && @!is_writable('config.php') ) {
 193  ?>
 194  
 195          <h1>Automatic <i>config.php</i> Update</h1>
 196  
 197          <p>If you want Nucleus to automatically update the <em>config.php</em> file, you'll need to make it writable. You can do this by changing the file permissions to <strong>666</strong>. After Nucleus is successfully installed, you can change the permissions back to <strong>444</strong> (<a href="nucleus/documentation/tips.html#filepermissions">Quick guide on how to change file permissions</a>).</p>
 198  
 199          <p>If you choose not to make your file writable (or are unable to do so): don't worry. The installation process will provide you with the contents of the <em>config.php</em> file so you can upload it yourself.</p>
 200  
 201  <?php } ?>
 202  
 203          <h1>MySQL login data</h1>
 204  
 205          <p>Enter your MySQL data below. This install script needs it to be able to create and fill your database tables. Afterwards, you'll also need to fill it out in <i>config.php</i>.</p>
 206  
 207          <p>If you don't know this information, contact your system administrator for more info. Often, the hostname will be 'localhost'. If Nucleus found a 'default MySQL host' in the PHP settings of your server, this host is already listed in the 'hostname' field. There's no guarantee that this information is correct, though.</p>
 208  
 209          <fieldset>
 210              <legend>General Database Settings</legend>
 211              <table>
 212                  <tr>
 213                      <td>Hostname:</td>
 214                      <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" /></td>
 215                  </tr>
 216                  <tr>
 217                      <td>Username:</td>
 218                      <td><input name="mySQL_user" /></td>
 219                  </tr>
 220                  <tr>
 221                      <td>Password:</td>
 222                      <td><input name="mySQL_password" type="password" /></td>
 223                  </tr>
 224                  <tr>
 225                      <td>Database:</td>
 226                      <td><input name="mySQL_database" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create"><label for="mySQL_create" />needs to be created</label>)</td>
 227                  </tr>
 228              </table>
 229          </fieldset>
 230  
 231          <fieldset>
 232              <legend>Advanced Database Settings</legend>
 233              <table>
 234                  <tr>
 235                      <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix"><label for="mySQL_usePrefix" />Use table prefix:</label></td>
 236                      <td><input name="mySQL_tablePrefix" value="" /></td>
 237                  </tr>
 238              </table>
 239  
 240              <p>Unless you're installing multiple Nucleus installations in one single database and know what you're doing, <strong>you really shouldn't change this</strong>.</p>
 241              <p>All database tables generated by Nucleus will start with this prefix.</p>
 242          </fieldset>
 243  
 244          <h1>Directories and URLs</h1>
 245  
 246          <p>This install script has attempted to find out the directories and URLs in which Nucleus is installed. Please check the values below and correct if necessary. The URLs and file paths should end with a slash.</p>
 247  
 248  <?php
 249  
 250      // no need to this all! dirname(__FILE__) is all we need -- moraes
 251      /*
 252      // discover full path
 253      $fullPath = serverVar('PATH_TRANSLATED');
 254  
 255      if ($fullPath == '') {
 256          $fullPath = serverVar('SCRIPT_FILENAME');
 257      }
 258  
 259      $basePath = str_replace('install.php', '', $fullPath);
 260      $basePath = replaceDoubleBackslash($basePath);
 261      $basePath = replaceDoubleBackslash($basePath);
 262  
 263      // add slash at end if necessary
 264      if (!endsWithSlash($basePath) ) {
 265          $basePath .= '/';
 266      }
 267      */
 268  
 269      $basePath = dirname(__FILE__) . '/';
 270  ?>
 271  
 272          <fieldset>
 273              <legend>URLs and directories</legend>
 274              <table>
 275                  <tr>
 276                      <td>Site <strong>URL</strong>:</td>
 277                      <td><input name="IndexURL" size="60" value="<?php
 278                          $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
 279                          $url = str_replace('install.php', '', $url);
 280                          $url = replaceDoubleBackslash($url);
 281  
 282                          // add slash at end if necessary
 283                          if (!endsWithSlash($url) ) {
 284                              $url .= '/';
 285                          }
 286  
 287                          echo $url; ?>" /></td>
 288                  </tr>
 289                  <tr>
 290                      <td>Admin-area <strong>URL</strong>:</td>
 291                      <td><input name="AdminURL" size="60" value="<?php
 292                          if ($url) {
 293                              echo $url, 'nucleus/';
 294                          } ?>" /></td>
 295                  </tr>
 296                  <tr>
 297                      <td>Admin-area <strong>path</strong>:</td>
 298                      <td><input name="AdminPath" size="60" value="<?php
 299                          if($basePath) {
 300                              echo $basePath, 'nucleus/';
 301                          } ?>" /></td>
 302                  </tr>
 303                  <tr>
 304                      <td>Media files <strong>URL</strong>:</td>
 305                      <td><input name="MediaURL" size="60" value="<?php
 306                          if ($url) {
 307                              echo $url, 'media/';
 308                          } ?>" /></td>
 309                  </tr>
 310                  <tr>
 311                      <td>Media directory <strong>path</strong>:</td>
 312                      <td><input name="MediaPath" size="60" value="<?php
 313                          if ($basePath) {
 314                              echo $basePath, 'media/';
 315                          } ?>" /></td>
 316                  </tr>
 317                  <tr>
 318                      <td>Extra skin files <strong>URL</strong>:</td>
 319                      <td><input name="SkinsURL" size="60" value="<?php
 320                          if ($url) {
 321                              echo $url, 'skins/';
 322                          } ?>" />
 323                          <br />(used by imported skins)
 324                      </td>
 325                  </tr>
 326                  <tr>
 327                      <td>Extra skin files directory <strong>path</strong>:</td>
 328                      <td><input name="SkinsPath" size="60" value="<?php
 329                          if ($basePath) {
 330                              echo $basePath, 'skins/';
 331                          } ?>" />
 332                          <br />(this is where imported skins can place their extra files)
 333                      </td>
 334                  </tr>
 335                  <tr>
 336                      <td>Plugin files <strong>URL</strong>:</td>
 337                      <td><input name="PluginURL" size="60" value="<?php
 338                          if ($url) {
 339                              echo $url, 'nucleus/plugins/';
 340                          } ?>" /></td>
 341                  </tr>
 342                  <tr>
 343                      <td>Action <strong>URL</strong>:</td>
 344                      <td><input name="ActionURL" size="60" value="<?php
 345                          if ($url) {
 346                              echo $url, 'action.php';
 347                          } ?>" />
 348                          <br />(absolute location of the <tt>action.php</tt> file)
 349                      </td>
 350                  </tr>
 351              </table>
 352          </fieldset>
 353  
 354          <p class="note"><strong>Note: Use absolute paths</strong> instead of relative paths. Usually, an absolute path will start with something like <tt>/home/username/public_html/</tt>. On Unix systems (most servers), paths should start with a slash. If you have trouble filling out this information, you should ask your administrator what to fill out.</p>
 355  
 356          <h1>Administrator User</h1>
 357  
 358          <p>Below, you need to enter some information to create the first user of your site.</p>
 359  
 360          <fieldset>
 361              <legend>Administrator User</legend>
 362              <table>
 363                  <tr>
 364                      <td>Display Name:</td>
 365                      <td><input name="User_name" value="" /> <small>(allowed characters: a-z and 0-9, spaces allowed inside)</small></td>
 366                  </tr>
 367                  <tr>
 368                      <td>Real Name:</td>
 369                      <td><input name="User_realname" value="" /></td>
 370                  </tr>
 371                  <tr>
 372                      <td>Password:</td>
 373                      <td><input name="User_password" type="password" value="" /></td>
 374                  </tr>
 375                  <tr>
 376                      <td>Password Again:</td>
 377                      <td><input name="User_password2" type="password" value="" /></td>
 378                  </tr>
 379                  <tr>
 380                      <td>E-mail Address:</td>
 381                      <td><input name="User_email" value="" /> <small>(needs to be a valid e-mail address)</small></td>
 382                  </tr>
 383              </table>
 384          </fieldset>
 385  
 386          <h1>Weblog data</h1>
 387  
 388          <p>Below, you need to enter some information to create a default weblog. The name of this weblog will also be used as name for your site</p>
 389  
 390          <fieldset>
 391              <legend>Weblog Data</legend>
 392              <table>
 393                  <tr>
 394                      <td>Blog Name:</td>
 395                      <td><input name="Blog_name" size="60" value="My Nucleus CMS" /></td>
 396                  </tr>
 397                  <tr>
 398                      <td>Blog Short Name:</td>
 399                      <td><input name="Blog_shortname" value="mynucleuscms" /> <small>(allowed characters: a-z and 0-9, no spaces allowed)</small></td>
 400                  </tr>
 401              </table>
 402          </fieldset>
 403  
 404          <h1>Submit</h1>
 405  
 406          <p>Verify the data above, and click the button below to set up your database tables and initial data. This can take a while, so have patience. <strong>ONLY CLICK THE BUTTON ONCE !</strong></p>
 407  
 408          <p><input name="action" value="go" type="hidden" /> <input type="submit" value="Install Nucleus" onclick="return checkSubmit();" /></p>
 409  
 410          </form>
 411      </body>
 412  </html>
 413  
 414  <?php }
 415  
 416  function tableName($unPrefixed) {
 417      global $mysql_usePrefix, $mysql_prefix;
 418  
 419      if ($mysql_usePrefix == 1) {
 420          return $mysql_prefix . $unPrefixed;
 421      } else {
 422          return $unPrefixed;
 423      }
 424  }
 425  
 426  function doInstall() {
 427      global $mysql_usePrefix, $mysql_prefix;
 428  
 429      // 0. put all POST-vars into vars
 430      $mysql_host = postVar('mySQL_host');
 431      $mysql_user = postVar('mySQL_user');
 432      $mysql_password = postVar('mySQL_password');
 433      $mysql_database = postVar('mySQL_database');
 434      $mysql_create = postVar('mySQL_create');
 435      $mysql_usePrefix = postVar('mySQL_usePrefix');
 436      $mysql_prefix = postVar('mySQL_tablePrefix');
 437      $config_indexurl = postVar('IndexURL');
 438      $config_adminurl = postVar('AdminURL');
 439      $config_adminpath = postVar('AdminPath');
 440      $config_mediaurl = postVar('MediaURL');
 441      $config_skinsurl = postVar('SkinsURL');
 442      $config_pluginurl = postVar('PluginURL');
 443      $config_actionurl = postVar('ActionURL');
 444      $config_mediapath = postVar('MediaPath');
 445      $config_skinspath = postVar('SkinsPath');
 446      $user_name = postVar('User_name');
 447      $user_realname = postVar('User_realname');
 448      $user_password = postVar('User_password');
 449      $user_password2 = postVar('User_password2');
 450      $user_email = postVar('User_email');
 451      $blog_name = postVar('Blog_name');
 452      $blog_shortname = postVar('Blog_shortname');
 453      $config_adminemail = $user_email;
 454      $config_sitename = $blog_name;
 455  
 456      $config_indexurl = replaceDoubleBackslash($config_indexurl);
 457      $config_adminurl = replaceDoubleBackslash($config_adminurl);
 458      $config_mediaurl = replaceDoubleBackslash($config_mediaurl);
 459      $config_skinsurl = replaceDoubleBackslash($config_skinsurl);
 460      $config_pluginurl = replaceDoubleBackslash($config_pluginurl);
 461      $config_actionurl = replaceDoubleBackslash($config_actionurl);
 462      $config_adminpath = replaceDoubleBackslash($config_adminpath);
 463      $config_skinspath = replaceDoubleBackslash($config_skinspath);
 464  
 465      // 1. check all the data
 466      $errors = array();
 467  
 468      if (!$mysql_database) {
 469          array_push($errors, 'mySQL database name missing');
 470      }
 471  
 472      if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {
 473          array_push($errors, 'mySQL prefix was selected, but prefix is empty');
 474      }
 475  
 476      if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {
 477          array_push($errors, 'mySQL prefix should only contain characters from the ranges A-Z, a-z, 0-9 or underscores');
 478      }
 479  
 480      // TODO: add action.php check
 481      if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {
 482          array_push($errors, 'One of the URLs does not end with a slash, or action url does not end with \'action.php\'');
 483      }
 484  
 485      if (!endsWithSlash($config_adminpath) ) {
 486          array_push($errors, 'The path of the administration area does not end with a slash');
 487      }
 488  
 489      if (!endsWithSlash($config_mediapath) ) {
 490          array_push($errors, 'The media path does not end with a slash');
 491      }
 492  
 493      if (!endsWithSlash($config_skinspath) ) {
 494          array_push($errors, 'The skins path does not end with a slash');
 495      }
 496  
 497      if (!is_dir($config_adminpath) ) {
 498          array_push($errors, 'The path of the administration area does not exist on your server');
 499      }
 500  
 501      if (!_isValidMailAddress($user_email) ) {
 502          array_push($errors, 'Invalid e-mail address given for user');
 503      }
 504  
 505      if (!_isValidDisplayName($user_name) ) {
 506          array_push($errors, 'User name is not a valid display name (allowed chars: a-zA-Z0-9 and spaces)');
 507      }
 508  
 509      if (!$user_password || !$user_password2) {
 510          array_push($errors, 'User password is empty');
 511      }
 512  
 513      if ($user_password != $user_password2) {
 514          array_push($errors, 'User password do not match');
 515      }
 516  
 517      if (!_isValidShortName($blog_shortname) ) {
 518          array_push($errors, 'Invalid short name given for blog (allowed chars: a-z0-9, no spaces)');
 519      }
 520  
 521      if (sizeof($errors) > 0) {
 522          showErrorMessages($errors);
 523      }
 524  
 525      // 2. try to log in to mySQL
 526      global $MYSQL_CONN;
 527      $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
 528  
 529      if ($MYSQL_CONN == false) {
 530          _doError('Could not connect to mySQL server: ' . mysql_error() );
 531      }
 532  
 533      // 3. try to create database (if needed)
 534      if ($mysql_create == 1) {
 535          mysql_query('CREATE DATABASE ' . $mysql_database) or _doError('Could not create database. Make sure you have the rights to do so. SQL error was: ' . mysql_error() );
 536      }
 537  
 538      // 4. try to select database
 539      mysql_select_db($mysql_database) or _doError('Could not select database. Make sure it exists');
 540  
 541      // 5. execute queries
 542      $filename = 'install.sql';
 543      $fd = fopen($filename, 'r');
 544      $queries = fread($fd, filesize($filename) );
 545      fclose($fd);
 546  
 547      $queries = split("(;\n|;\r)", $queries);
 548  
 549      $aTableNames = array(
 550          'nucleus_actionlog',
 551          'nucleus_ban',
 552          'nucleus_blog',
 553          'nucleus_category',
 554          'nucleus_comment',
 555          'nucleus_config',
 556          'nucleus_item',
 557          'nucleus_karma',
 558          'nucleus_member',
 559          'nucleus_plugin',
 560          'nucleus_skin',
 561          'nucleus_template',
 562          'nucleus_team',
 563          'nucleus_activation',
 564          'nucleus_tickets'
 565          );
 566  // these are unneeded (one of the replacements above takes care of them)
 567  //            'nucleus_plugin_event',
 568  //            'nucleus_plugin_option',
 569  //            'nucleus_plugin_option_desc',
 570  //            'nucleus_skin_desc',
 571  //            'nucleus_template_desc',
 572  
 573      $aTableNamesPrefixed = array(
 574          $mysql_prefix . 'nucleus_actionlog',
 575          $mysql_prefix . 'nucleus_ban',
 576          $mysql_prefix . 'nucleus_blog',
 577          $mysql_prefix . 'nucleus_category',
 578          $mysql_prefix . 'nucleus_comment',
 579          $mysql_prefix . 'nucleus_config',
 580          $mysql_prefix . 'nucleus_item',
 581          $mysql_prefix . 'nucleus_karma',
 582          $mysql_prefix . 'nucleus_member',
 583          $mysql_prefix . 'nucleus_plugin',
 584          $mysql_prefix . 'nucleus_skin',
 585          $mysql_prefix . 'nucleus_template',
 586          $mysql_prefix . 'nucleus_team',
 587          $mysql_prefix . 'nucleus_activation',
 588          $mysql_prefix . 'nucleus_tickets'
 589          );
 590  // these are unneeded (one of the replacements above takes care of them)
 591  //            $mysql_prefix . 'nucleus_plugin_event',
 592  //            $mysql_prefix . 'nucleus_plugin_option',
 593  //            $mysql_prefix . 'nucleus_plugin_option_desc',
 594  //            $mysql_prefix . 'nucleus_skin_desc',
 595  //            $mysql_prefix . 'nucleus_template_desc',
 596  
 597      $count = count($queries);
 598  
 599      for ($idx = 0; $idx < $count; $idx++) {
 600          $query = trim($queries[$idx]);
 601          // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
 602  
 603          if ($query) {
 604  
 605              if ($mysql_usePrefix == 1) {
 606                      $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
 607              }
 608  
 609              mysql_query($query) or _doError('Error while executing query (<small>' . htmlspecialchars($query) . '</small>): ' . mysql_error() );
 610          }
 611      }
 612  
 613      // 6. update global settings
 614      updateConfig('IndexURL', $config_indexurl);
 615      updateConfig('AdminURL', $config_adminurl);
 616      updateConfig('MediaURL', $config_mediaurl);
 617      updateConfig('SkinsURL', $config_skinsurl);
 618      updateConfig('PluginURL', $config_pluginurl);
 619      updateConfig('ActionURL', $config_actionurl);
 620      updateConfig('AdminEmail', $config_adminemail);
 621      updateConfig('SiteName', $config_sitename);
 622  
 623      // 7. update GOD member
 624      $query = 'UPDATE ' . tableName('nucleus_member')
 625              . " SET mname='" . addslashes($user_name) . "',"
 626              . " mrealname='" . addslashes($user_realname) . "',"
 627              . " mpassword='" . md5(addslashes($user_password) ) . "',"
 628              . " murl='" . addslashes($config_indexurl) . "',"
 629              . " memail='" . addslashes($user_email) . "',"
 630              . " madmin=1, mcanlogin=1"
 631              . " WHERE mnumber=1";
 632  
 633      mysql_query($query) or _doError('Error while setting member settings: ' . mysql_error() );
 634  
 635      // 8. update weblog settings
 636      $query = 'UPDATE ' . tableName('nucleus_blog')
 637              . " SET bname='" . addslashes($blog_name) . "',"
 638              . " bshortname='" . addslashes($blog_shortname) . "',"
 639              . " burl='" . addslashes($config_indexurl) . "'"
 640              . " WHERE bnumber=1";
 641  
 642      mysql_query($query) or _doError('Error while setting weblog settings: ' . mysql_error() );
 643  
 644      // 9. update item date
 645      $query = 'UPDATE ' . tableName('nucleus_item')
 646              . " SET itime='" . date('Y-m-d H:i:s', time() ) ."'"
 647              . " WHERE inumber=1";
 648  
 649      mysql_query($query) or _doError('Error with query: ' . mysql_error() );
 650  
 651      global $aConfPlugsToInstall, $aConfSkinsToImport;
 652      $aSkinErrors = array();
 653      $aPlugErrors = array();
 654  
 655      if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
 656          // 10. set global variables
 657          global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
 658  
 659          $MYSQL_HOST = $mysql_host;
 660          $MYSQL_USER = $mysql_user;
 661          $MYSQL_PASSWORD = $mysql_password;
 662          $MYSQL_DATABASE = $mysql_database;
 663          $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';
 664  
 665          global $DIR_NUCLEUS,