[ PHPXref.com ] [ Generated: Sun Jul 20 18:22:43 2008 ] [ Joomla! 1.0.8 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/installation/ -> install4.php (source)

   1  <?php
   2  /**
   3  * @version $Id: install4.php 2622 2006-02-26 04:16:09Z stingrey $
   4  * @package Joomla
   5  * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
   6  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
   7  * Joomla! is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.php for copyright notices and details.
  12  */
  13  
  14  // Set flag that this is a parent file
  15  define( "_VALID_MOS", 1 );
  16  
  17  // Include common.php
  18  require_once ( 'common.php' );
  19  require_once ( '../includes/database.php' );
  20  
  21  $DBhostname = mosGetParam( $_POST, 'DBhostname', '' );
  22  $DBuserName = mosGetParam( $_POST, 'DBuserName', '' );
  23  $DBpassword = mosGetParam( $_POST, 'DBpassword', '' );
  24  $DBname      = mosGetParam( $_POST, 'DBname', '' );
  25  $DBPrefix      = mosGetParam( $_POST, 'DBPrefix', '' );
  26  $sitename      = mosGetParam( $_POST, 'sitename', '' );
  27  $adminEmail = mosGetParam( $_POST, 'adminEmail', '');
  28  $siteUrl      = mosGetParam( $_POST, 'siteUrl', '' );
  29  $absolutePath = mosGetParam( $_POST, 'absolutePath', '' );
  30  $adminPassword = mosGetParam( $_POST, 'adminPassword', '');
  31  
  32  $filePerms = '';
  33  if (mosGetParam($_POST,'filePermsMode',0))
  34      $filePerms = '0'.
  35          (mosGetParam($_POST,'filePermsUserRead',0) * 4 +
  36           mosGetParam($_POST,'filePermsUserWrite',0) * 2 +
  37           mosGetParam($_POST,'filePermsUserExecute',0)).
  38          (mosGetParam($_POST,'filePermsGroupRead',0) * 4 +
  39           mosGetParam($_POST,'filePermsGroupWrite',0) * 2 +
  40           mosGetParam($_POST,'filePermsGroupExecute',0)).
  41          (mosGetParam($_POST,'filePermsWorldRead',0) * 4 +
  42           mosGetParam($_POST,'filePermsWorldWrite',0) * 2 +
  43           mosGetParam($_POST,'filePermsWorldExecute',0));
  44  
  45  $dirPerms = '';
  46  if (mosGetParam($_POST,'dirPermsMode',0))
  47      $dirPerms = '0'.
  48          (mosGetParam($_POST,'dirPermsUserRead',0) * 4 +
  49           mosGetParam($_POST,'dirPermsUserWrite',0) * 2 +
  50           mosGetParam($_POST,'dirPermsUserSearch',0)).
  51          (mosGetParam($_POST,'dirPermsGroupRead',0) * 4 +
  52           mosGetParam($_POST,'dirPermsGroupWrite',0) * 2 +
  53           mosGetParam($_POST,'dirPermsGroupSearch',0)).
  54          (mosGetParam($_POST,'dirPermsWorldRead',0) * 4 +
  55           mosGetParam($_POST,'dirPermsWorldWrite',0) * 2 +
  56           mosGetParam($_POST,'dirPermsWorldSearch',0));
  57  
  58  if ((trim($adminEmail== "")) || (preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $adminEmail )==false)) {
  59      echo "<form name=\"stepBack\" method=\"post\" action=\"install3.php\">
  60          <input type=\"hidden\" name=\"DBhostname\" value=\"$DBhostname\" />
  61          <input type=\"hidden\" name=\"DBuserName\" value=\"$DBuserName\" />
  62          <input type=\"hidden\" name=\"DBpassword\" value=\"$DBpassword\" />
  63          <input type=\"hidden\" name=\"DBname\" value=\"$DBname\" />
  64          <input type=\"hidden\" name=\"DBPrefix\" value=\"$DBPrefix\" />
  65          <input type=\"hidden\" name=\"DBcreated\" value=\"1\" />
  66          <input type=\"hidden\" name=\"sitename\" value=\"$sitename\" />
  67          <input type=\"hidden\" name=\"adminEmail\" value=\"$adminEmail\" />
  68          <input type=\"hidden\" name=\"siteUrl\" value=\"$siteUrl\" />
  69          <input type=\"hidden\" name=\"absolutePath\" value=\"$absolutePath\" />
  70          <input type=\"hidden\" name=\"filePerms\" value=\"$filePerms\" />
  71          <input type=\"hidden\" name=\"dirPerms\" value=\"$dirPerms\" />
  72          </form>";
  73      echo "<script>alert('You must provide a valid admin email address.'); document.stepBack.submit(); </script>";
  74      return;
  75  }
  76  
  77  if($DBhostname && $DBuserName && $DBname) {
  78      $configArray['DBhostname']    = $DBhostname;
  79      $configArray['DBuserName']    = $DBuserName;
  80      $configArray['DBpassword']    = $DBpassword;
  81      $configArray['DBname']         = $DBname;
  82      $configArray['DBPrefix']    = $DBPrefix;
  83  } else {
  84      echo "<form name=\"stepBack\" method=\"post\" action=\"install3.php\">
  85          <input type=\"hidden\" name=\"DBhostname\" value=\"$DBhostname\" />
  86          <input type=\"hidden\" name=\"DBuserName\" value=\"$DBuserName\" />
  87          <input type=\"hidden\" name=\"DBpassword\" value=\"$DBpassword\" />
  88          <input type=\"hidden\" name=\"DBname\" value=\"$DBname\" />
  89          <input type=\"hidden\" name=\"DBPrefix\" value=\"$DBPrefix\" />
  90          <input type=\"hidden\" name=\"DBcreated\" value=\"1\" />
  91          <input type=\"hidden\" name=\"sitename\" value=\"$sitename\" />
  92          <input type=\"hidden\" name=\"adminEmail\" value=\"$adminEmail\" />
  93          <input type=\"hidden\" name=\"siteUrl\" value=\"$siteUrl\" />
  94          <input type=\"hidden\" name=\"absolutePath\" value=\"$absolutePath\" />
  95          <input type=\"hidden\" name=\"filePerms\" value=\"$filePerms\" />
  96          <input type=\"hidden\" name=\"dirPerms\" value=\"$dirPerms\" />
  97          </form>";
  98  
  99      echo "<script>alert('The database details provided are incorrect and/or empty'); document.stepBack.submit(); </script>";
 100      return;
 101  }
 102  
 103  if ($sitename) {
 104      if (!get_magic_quotes_gpc()) {
 105          $configArray['sitename'] = addslashes($sitename);
 106      } else {
 107          $configArray['sitename'] = $sitename;
 108      }
 109  } else {
 110      echo "<form name=\"stepBack\" method=\"post\" action=\"install3.php\">
 111          <input type=\"hidden\" name=\"DBhostname\" value=\"$DBhostname\" />
 112          <input type=\"hidden\" name=\"DBuserName\" value=\"$DBuserName\" />
 113          <input type=\"hidden\" name=\"DBpassword\" value=\"$DBpassword\" />
 114          <input type=\"hidden\" name=\"DBname\" value=\"$DBname\" />
 115          <input type=\"hidden\" name=\"DBPrefix\" value=\"$DBPrefix\" />
 116          <input type=\"hidden\" name=\"DBcreated\" value=\"1\" />
 117          <input type=\"hidden\" name=\"sitename\" value=\"$sitename\" />
 118          <input type=\"hidden\" name=\"adminEmail\" value=\"$adminEmail\" />
 119          <input type=\"hidden\" name=\"siteUrl\" value=\"$siteUrl\" />
 120          <input type=\"hidden\" name=\"absolutePath\" value=\"$absolutePath\" />
 121          <input type=\"hidden\" name=\"filePerms\" value=\"$filePerms\" />
 122          <input type=\"hidden\" name=\"dirPerms\" value=\"$dirPerms\" />
 123          </form>";
 124  
 125      echo "<script>alert('The sitename has not been provided'); document.stepBack2.submit();</script>";
 126      return;
 127  }
 128  
 129  if (file_exists( '../configuration.php' )) {
 130      $canWrite = is_writable( '../configuration.php' );
 131  } else {
 132      $canWrite = is_writable( '..' );
 133  }
 134  
 135  if ($siteUrl) {
 136      $configArray['siteUrl']=$siteUrl;
 137      // Fix for Windows
 138      $absolutePath= str_replace("\\\\","/", $absolutePath);
 139      $configArray['absolutePath']=$absolutePath;
 140      $configArray['filePerms']=$filePerms;
 141      $configArray['dirPerms']=$dirPerms;
 142  
 143      $config = "<?php\n";
 144      $config .= "\$mosConfig_offline = '0';\n";
 145      $config .= "\$mosConfig_host = '{$configArray['DBhostname']}';\n";
 146      $config .= "\$mosConfig_user = '{$configArray['DBuserName']}';\n";
 147      $config .= "\$mosConfig_password = '{$configArray['DBpassword']}';\n";
 148      $config .= "\$mosConfig_db = '{$configArray['DBname']}';\n";
 149      $config .= "\$mosConfig_dbprefix = '{$configArray['DBPrefix']}';\n";
 150      $config .= "\$mosConfig_lang = 'english';\n";
 151      $config .= "\$mosConfig_absolute_path = '{$configArray['absolutePath']}';\n";
 152      $config .= "\$mosConfig_live_site = '{$configArray['siteUrl']}';\n";
 153      $config .= "\$mosConfig_sitename = '{$configArray['sitename']}';\n";
 154      $config .= "\$mosConfig_shownoauth = '0';\n";
 155      $config .= "\$mosConfig_useractivation = '1';\n";
 156      $config .= "\$mosConfig_uniquemail = '1';\n";
 157      $config .= "\$mosConfig_offline_message = 'This site is down for maintenance.<br /> Please check back again soon.';\n";
 158      $config .= "\$mosConfig_error_message = 'This site is temporarily unavailable.<br /> Please notify the System Administrator';\n";
 159      $config .= "\$mosConfig_debug = '0';\n";
 160      $config .= "\$mosConfig_lifetime = '900';\n";
 161      $config .= "\$mosConfig_session_life_admin = '1800';\n";
 162      $config .= "\$mosConfig_session_type = '0';\n";
 163      $config .= "\$mosConfig_MetaDesc = 'Joomla - the dynamic portal engine and content management system';\n";
 164      $config .= "\$mosConfig_MetaKeys = 'Joomla, joomla';\n";
 165      $config .= "\$mosConfig_MetaTitle = '1';\n";
 166      $config .= "\$mosConfig_MetaAuthor = '1';\n";
 167      $config .= "\$mosConfig_locale = 'en_GB';\n";
 168      $config .= "\$mosConfig_offset = '0';\n";
 169      $config .= "\$mosConfig_offset_user = '0';\n";
 170      $config .= "\$mosConfig_hideAuthor = '0';\n";
 171      $config .= "\$mosConfig_hideCreateDate = '0';\n";
 172      $config .= "\$mosConfig_hideModifyDate = '0';\n";
 173      $config .= "\$mosConfig_hidePdf = '".intval( !is_writable( "{$configArray['absolutePath']}/media/" ) )."';\n";
 174      $config .= "\$mosConfig_hidePrint = '0';\n";
 175      $config .= "\$mosConfig_hideEmail = '0';\n";
 176      $config .= "\$mosConfig_enable_log_items = '0';\n";
 177      $config .= "\$mosConfig_enable_log_searches = '0';\n";
 178      $config .= "\$mosConfig_enable_stats = '0';\n";
 179      $config .= "\$mosConfig_sef = '0';\n";
 180      $config .= "\$mosConfig_vote = '0';\n";
 181      $config .= "\$mosConfig_gzip = '0';\n";
 182      $config .= "\$mosConfig_multipage_toc = '1';\n";
 183      $config .= "\$mosConfig_allowUserRegistration = '1';\n";
 184      $config .= "\$mosConfig_link_titles = '0';\n";
 185      $config .= "\$mosConfig_error_reporting = -1;\n";
 186      $config .= "\$mosConfig_list_limit = '30';\n";
 187      $config .= "\$mosConfig_caching = '0';\n";
 188      $config .= "\$mosConfig_cachepath = '{$configArray['absolutePath']}/cache';\n";
 189      $config .= "\$mosConfig_cachetime = '900';\n";
 190      $config .= "\$mosConfig_mailer = 'mail';\n";
 191      $config .= "\$mosConfig_mailfrom = '$adminEmail';\n";
 192      $config .= "\$mosConfig_fromname = '{$configArray['sitename']}';\n";
 193      $config .= "\$mosConfig_sendmail = '/usr/sbin/sendmail';\n";
 194      $config .= "\$mosConfig_smtpauth = '0';\n";
 195      $config .= "\$mosConfig_smtpuser = '';\n";
 196      $config .= "\$mosConfig_smtppass = '';\n";
 197      $config .= "\$mosConfig_smtphost = 'localhost';\n";
 198      $config .= "\$mosConfig_back_button = '1';\n";
 199      $config .= "\$mosConfig_item_navigation = '1';\n";
 200      $config .= "\$mosConfig_secret = '" . mosMakePassword(16) . "';\n";
 201      $config .= "\$mosConfig_pagetitles = '1';\n";
 202      $config .= "\$mosConfig_readmore = '1';\n";
 203      $config .= "\$mosConfig_hits = '1';\n";
 204      $config .= "\$mosConfig_icons = '1';\n";
 205      $config .= "\$mosConfig_favicon = 'favicon.ico';\n";
 206      $config .= "\$mosConfig_fileperms = '".$configArray['filePerms']."';\n";
 207      $config .= "\$mosConfig_dirperms = '".$configArray['dirPerms']."';\n";
 208      $config .= "\$mosConfig_helpurl = 'http://help.joomla.org';\n";
 209      $config .= "\$mosConfig_mbf_content = '0';\n";
 210      $config .= "\$mosConfig_editor = 'tinymce';\n";
 211      $config .= "setlocale (LC_TIME, \$mosConfig_locale);\n";
 212      $config .= "?>";
 213  
 214      if ($canWrite && ($fp = fopen("../configuration.php", "w"))) {
 215          fputs( $fp, $config, strlen( $config ) );
 216          fclose( $fp );
 217      } else {
 218          $canWrite = false;
 219      } // if
 220  
 221      $cryptpass=md5( $adminPassword );
 222  
 223      $database = new database( $DBhostname, $DBuserName, $DBpassword, $DBname, $DBPrefix );
 224      $nullDate = $database->getNullDate();
 225  
 226      // create the admin user
 227      $installdate = date('Y-m-d H:i:s');
 228      $query = "INSERT INTO `#__users` VALUES (62, 'Administrator', 'admin', '$adminEmail', '$cryptpass', 'Super Administrator', 0, 1, 25, '$installdate', '$nullDate', '', '')";
 229      $database->setQuery( $query );
 230      $database->query();
 231      // add the ARO (Access Request Object)
 232      $query = "INSERT INTO `#__core_acl_aro` VALUES (10,'users','62',0,'Administrator',0)";
 233      $database->setQuery( $query );
 234      $database->query();
 235      // add the map between the ARO and the Group
 236      $query = "INSERT INTO `#__core_acl_groups_aro_map` VALUES (25,'',10)";
 237      $database->setQuery( $query );
 238      $database->query();
 239  
 240      // chmod files and directories if desired
 241      $chmod_report = "Directory and file permissions left unchanged.";
 242      if ($filePerms != '' || $dirPerms != '') {
 243          $mosrootfiles = array(
 244              'administrator',
 245              'cache',
 246              'components',
 247              'images',
 248              'language',
 249              'mambots',
 250              'media',
 251              'modules',
 252              'templates',
 253              'configuration.php'
 254          );
 255          $filemode = NULL;
 256          if ($filePerms != '') $filemode = octdec($filePerms);
 257          $dirmode = NULL;
 258          if ($dirPerms != '') $dirmode = octdec($dirPerms);
 259          $chmodOk = TRUE;
 260          foreach ($mosrootfiles as $file) {
 261              if (!mosChmodRecursive($absolutePath.'/'.$file, $filemode, $dirmode)) {
 262                  $chmodOk = FALSE;
 263              }
 264          }
 265          if ($chmodOk) {
 266              $chmod_report = 'File and directory permissions successfully changed.';
 267          } else {
 268              $chmod_report = 'File and directory permissions could not be changed.<br />'.
 269                              'Please CHMOD Joomla files and directories manually.';
 270          }
 271      } // if chmod wanted
 272  } else {
 273  ?>
 274      <form action="install3.php" method="post" name="stepBack3" id="stepBack3">
 275        <input type="hidden" name="DBhostname" value="<?php echo $DBhostname;?>" />
 276        <input type="hidden" name="DBusername" value="<?php echo $DBuserName;?>" />
 277        <input type="hidden" name="DBpassword" value="<?php echo $DBpassword;?>" />
 278        <input type="hidden" name="DBname" value="<?php echo $DBname;?>" />
 279        <input type="hidden" name="DBPrefix" value="<?php echo $DBPrefix;?>" />
 280        <input type="hidden" name="DBcreated" value="1" />
 281        <input type="hidden" name="sitename" value="<?php echo $sitename;?>" />
 282        <input type="hidden" name="adminEmail" value="$adminEmail" />
 283        <input type="hidden" name="siteUrl" value="$siteUrl" />
 284        <input type="hidden" name="absolutePath" value="$absolutePath" />
 285        <input type="hidden" name="filePerms" value="$filePerms" />
 286        <input type="hidden" name="dirPerms" value="$dirPerms" />
 287      </form>
 288      <script>alert('The site url has not been provided'); document.stepBack3.submit();</script>
 289  <?php
 290  }
 291  echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">";
 292  ?>
 293  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 294  <html xmlns="http://www.w3.org/1999/xhtml">
 295  <head>
 296  <title>Joomla - Web Installer</title>
 297  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 298  <link rel="shortcut icon" href="../images/favicon.ico" />
 299  <link rel="stylesheet" href="install.css" type="text/css" />
 300  </head>
 301  <body>
 302  <div id="wrapper">
 303      <div id="header">
 304          <div id="joomla"><img src="header_install.png" alt="Joomla Installation" /></div>
 305      </div>
 306  </div>
 307  <div id="ctr" align="center">
 308      <form action="dummy" name="form" id="form">
 309      <div class="install">
 310          <div id="stepbar">
 311              <div class="step-off">pre-installation check</div>
 312              <div class="step-off">license</div>
 313              <div class="step-off">step 1</div>
 314              <div class="step-off">step 2</div>
 315              <div class="step-off">step 3</div>
 316              <div class="step-on">step 4</div>
 317          </div>
 318          <div id="right">
 319              <div id="step">step 4</div>
 320              <div class="far-right">
 321                  <input class="button" type="button" name="runSite" value="View Site"
 322  <?php
 323                  if ($siteUrl) {
 324                      echo "onClick=\"window.location.href='$siteUrl/index.php' \"";
 325                  } else {
 326                      echo "onClick=\"window.location.href='".$configArray['siteURL']."/index.php' \"";
 327                  }
 328  ?>/>
 329                  <input class="button" type="button" name="Admin" value="Administration"
 330  <?php
 331                  if ($siteUrl) {
 332                      echo "onClick=\"window.location.href='$siteUrl/administrator/index.php' \"";
 333                  } else {
 334                      echo "onClick=\"window.location.href='".$configArray['siteURL']."/administrator/index.php' \"";
 335                  }
 336  ?>/>
 337              </div>
 338              <div class="clr"></div>
 339              <h1>Congratulations! Joomla is installed</h1>
 340              <div class="install-text">
 341                  <p>Click the "View Site" button to start Joomla site or "Administration"
 342                      to take you to administrator login.</p>
 343              </div>
 344              <div class="install-form">
 345                  <div class="form-block">
 346                      <table width="100%">
 347                          <tr><td class="error" align="center">PLEASE REMEMBER TO COMPLETELY<br/>REMOVE THE INSTALLATION DIRECTORY</td></tr>
 348                          <tr><td align="center"><h5>Administration Login Details</h5></td></tr>
 349                          <tr><td align="center" class="notice"><b>Username : admin</b></td></tr>
 350                          <tr><td align="center" class="notice"><b>Password : <?php echo $adminPassword; ?></b></td></tr>
 351                          <tr><td>&nbsp;</td></tr>
 352                          <tr><td align="right">&nbsp;</td></tr>
 353  <?php                        if (!$canWrite) { ?>
 354                          <tr>
 355                              <td class="small">
 356                                  Your configuration file or directory is not writeable,
 357                                  or there was a problem creating the configuration file. You'll have to
 358                                  upload the following code by hand. Click in the textarea to highlight
 359                                  all of the code.
 360                              </td>
 361                          </tr>
 362                          <tr>
 363                              <td align="center">
 364                                  <textarea rows="5" cols="60" name="configcode" onclick="javascript:this.form.configcode.focus();this.form.configcode.select();" ><?php echo htmlspecialchars( $config );?></textarea>
 365                              </td>
 366                          </tr>
 367  <?php                        } ?>
 368                          <tr><td class="small"><?php /*echo $chmod_report*/; ?></td></tr>
 369                      </table>
 370                  </div>
 371              </div>
 372              <div id="break"></div>
 373          </div>
 374          <div class="clr"></div>
 375      </div>
 376      </form>
 377  </div>
 378  <div class="clr"></div>
 379  <div class="ctr">
 380      <a href="http://www.joomla.org" target="_blank">Joomla!</a> is Free Software released under the GNU/GPL License.
 381  </div>
 382  </html>


[ Powered by PHPXref - Served by Debian GNU/Linux ]