| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Install instructions 4 * @package Mambo 5 * @author Mambo Foundation Inc see README.php 6 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 7 * See COPYRIGHT.php for copyright notices and details. 8 * @license GNU/GPL Version 2, see LICENSE.php 9 * 10 * Redistributions of files must retain the above copyright notice. 11 * 12 * Mambo is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; version 2 of the License. 15 */ 16 17 // Set flag that this is a parent file 18 if (!defined('_VALID_MOS')) define( '_VALID_MOS', 1 ); 19 20 // Include common.php 21 require_once ( 'common.php' ); 22 require_once ( '../includes/database.php' ); 23 include_once ( 'langconfig.php' ); 24 25 $DBhostname = mosGetParam( $_POST, 'DBhostname', '' ); 26 $DBuserName = mosGetParam( $_POST, 'DBuserName', '' ); 27 $DBpassword = mosGetParam( $_POST, 'DBpassword', '' ); 28 $DBverifypassword = mosGetParam( $_POST, 'DBverifypassword', '' ); 29 $DBname = mosGetParam( $_POST, 'DBname', '' ); 30 $DBPrefix = mosGetParam( $_POST, 'DBPrefix', '' ); 31 $DBDel = intval( mosGetParam( $_POST, 'DBDel', 0 ) ); 32 $DBBackup = intval( mosGetParam( $_POST, 'DBBackup', 0 ) ); 33 $DBSample = intval( mosGetParam( $_POST, 'DBSample', 0 ) ); 34 $DBcreated = intval( mosGetParam( $_POST, 'DBcreated', 0 ) ); 35 $BUPrefix = 'old_'; 36 $configArray['sitename'] = trim( mosGetParam( $_POST, 'sitename', '' ) ); 37 38 $database = null; 39 40 $errors = array(); ?> 41 42 <?php 43 echo "<?xml version=\"1.0\" encoding=\"".$charset."\"?".">"; 44 ?> 45 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 46 <html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $text_direction;?>"> 47 <head> 48 <title><?php echo T_('Mambo - Web Installer') ?></title> 49 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset ?>" /> 50 <link rel="shortcut icon" href="../images/favicon.ico" /> 51 <link rel="stylesheet" href="install<?php if($text_direction=='rtl') echo '_'.$text_direction ?>.css" type="text/css" /> 52 53 <?php 54 if (!$DBcreated){ 55 if (!isset($DBhostname) || !$DBuserName || !$DBname) { 56 db_err ("stepBack3", T_('The database details provided are incorrect and/or empty.')); 57 } 58 59 if ($DBpassword !== $DBverifypassword) { 60 db_err ("stepBack3", T_("The database passwords provided do not match. Please try again.")); 61 } 62 63 if (!($mysql_link = @mysql_connect( $DBhostname, $DBuserName, $DBpassword ))) { 64 db_err ("stepBack2", T_("The password and username provided are incorrect.")); 65 } 66 67 if($DBname == "") { 68 db_err ("stepBack", T_("The database name provided is empty.")); 69 } 70 71 // Does this code actually do anything??? 72 $configArray['DBhostname'] = $DBhostname; 73 $configArray['DBuserName'] = $DBuserName; 74 $configArray['DBpassword'] = $DBpassword; 75 $configArray['DBname'] = $DBname; 76 $configArray['DBPrefix'] = $DBPrefix; 77 78 $sql = "CREATE DATABASE `$DBname`"; 79 $mysql_result = mysql_query( $sql ); 80 $test = mysql_errno(); 81 82 if ($test <> 0 && $test <> 1007) { 83 db_err( "stepBack", T_("A database error occurred: ") . (mysql_error()) ); 84 } 85 86 // db is now new or existing, create the db object connector to do the serious work 87 $database = new database( $DBhostname, $DBuserName, $DBpassword, $DBname, $DBPrefix ); 88 89 //Delete existing tables from a previous installation if found. Backup tables if requested. 90 $database->setQuery( "SHOW TABLES FROM `$DBname`" ); 91 $errors = array(); 92 if ($tables = $database->loadResultArray()) { 93 foreach ($tables as $table) { 94 //Check for the existance of tables with the same prefix 95 if (strpos( $table, $DBPrefix ) === 0) { 96 //Check to see if the user requested a backup 97 if ($DBBackup==1) { 98 //if they requested a backup then replace the org table prefix with old_ 99 $butable = str_replace( $DBPrefix, $BUPrefix, $table ); 100 //if a prior backup table exists with the same name then drop it before the rename 101 $database->setQuery( "DROP TABLE IF EXISTS `$butable`" ); 102 $database->query(); 103 if ($database->getErrorNum()) { 104 $errors[$database->getQuery()] = $database->getErrorMsg(); 105 } 106 //Perform the actual table rename 107 $database->setQuery( "RENAME TABLE `$table` TO `$butable`" ); 108 $database->query(); 109 if ($database->getErrorNum()) { 110 $errors[$database->getQuery()] = $database->getErrorMsg(); 111 } 112 } else { //No backup was requested so just drop the original table 113 $database->setQuery( "DROP TABLE IF EXISTS `$table`" ); 114 $database->query(); 115 if ($database->getErrorNum()) { 116 $errors[$database->getQuery()] = $database->getErrorMsg(); 117 } 118 } 119 } 120 } //end foreach 121 } //end if 122 123 populate_db($DBname,$DBPrefix,'mambo.sql'); 124 if ($DBSample) { 125 populate_db($DBname,$DBPrefix,'sample_data.sql'); 126 } 127 $DBcreated = 1; 128 } 129 130 function db_err($step, $alert) { 131 global $DBhostname,$DBuserName,$DBpassword,$DBDel,$DBname; 132 echo "<body><form name=\"$step\" method=\"post\" action=\"install1.php\"> 133 <input type=\"hidden\" name=\"DBhostname\" value=\"$DBhostname\"> 134 <input type=\"hidden\" name=\"DBuserName\" value=\"$DBuserName\"> 135 <input type=\"hidden\" name=\"DBpassword\" value=\"$DBpassword\"> 136 <input type=\"hidden\" name=\"DBDel\" value=\"$DBDel\"> 137 <input type=\"hidden\" name=\"DBname\" value=\"$DBname\"> 138 </form>\n"; 139 //echo "<script>alert(\"$alert\"); document.$step.submit();</script>"; 140 //echo "<script>alert(\"$alert\"); window.history.go(-1);</script>"; //this wasn't working 141 echo "<script>alert(\"".$alert."\"); document.".$step.".submit(); </script></body></html>"; 142 exit(); 143 } 144 145 function populate_db($DBname, $DBPrefix, $sqlfile='mambo.sql') { 146 global $errors; 147 148 mysql_select_db($DBname); 149 $mqr = @get_magic_quotes_runtime(); 150 @set_magic_quotes_runtime(0); 151 $query = fread(fopen("sql/".$sqlfile, "r"), filesize("sql/".$sqlfile)); 152 @set_magic_quotes_runtime($mqr); 153 $pieces = split_sql($query); 154 155 for ($i=0; $i<count($pieces); $i++) { 156 $pieces[$i] = trim($pieces[$i]); 157 if(!empty($pieces[$i]) && $pieces[$i] != "#") { 158 $pieces[$i] = str_replace( "#__", $DBPrefix, $pieces[$i]); 159 if (!$result = mysql_query ($pieces[$i])) { 160 $errors[] = array ( mysql_error(), $pieces[$i] ); 161 } 162 } 163 } 164 } 165 166 function split_sql($sql) { 167 $sql = trim($sql); 168 $sql = ereg_replace("\n#[^\n]*\n", "\n", $sql); 169 170 $buffer = array(); 171 $ret = array(); 172 $in_string = false; 173 174 for($i=0; $i<strlen($sql)-1; $i++) { 175 if($sql[$i] == ";" && !$in_string) { 176 $ret[] = substr($sql, 0, $i); 177 $sql = substr($sql, $i + 1); 178 $i = 0; 179 } 180 181 if($in_string && ($sql[$i] == $in_string) && $buffer[1] != "\\") { 182 $in_string = false; 183 } 184 elseif(!$in_string && ($sql[$i] == '"' || $sql[$i] == "'") && (!isset($buffer[0]) || $buffer[0] != "\\")) { 185 $in_string = $sql[$i]; 186 } 187 if(isset($buffer[1])) { 188 $buffer[0] = $buffer[1]; 189 } 190 $buffer[1] = $sql[$i]; 191 } 192 193 if(!empty($sql)) { 194 $ret[] = $sql; 195 } 196 return($ret); 197 } 198 199 $isErr = intval( count( $errors ) ); ?> 200 <script type="text/javascript"> 201 <!-- 202 function check() { 203 // form validation check 204 var formValid = true; 205 var f = document.form; 206 if ( f.sitename.value == '' ) { 207 alert('<?php echo T_('Please enter a Site Name') ?>'); 208 f.sitename.focus(); 209 formValid = false 210 } 211 return formValid; 212 } 213 //--> 214 </script> 215 </head> 216 <body onload="document.form.sitename.focus();"> 217 <div id="wrapper"> 218 <div id="header"> 219 <div id="mambo"><img src="header_install.png" alt="<?php echo T_('Mambo Installation') ?>" /></div> 220 </div> 221 </div> 222 223 <div id="ctr" align="center"> 224 <form action="install3.php" method="post" name="form" id="form" onsubmit="return check();"> 225 <input type="hidden" name="DBhostname" value="<?php echo "$DBhostname"; ?>" /> 226 <input type="hidden" name="DBuserName" value="<?php echo "$DBuserName"; ?>" /> 227 <input type="hidden" name="DBpassword" value="<?php echo "$DBpassword"; ?>" /> 228 <input type="hidden" name="DBname" value="<?php echo "$DBname"; ?>" /> 229 <input type="hidden" name="DBPrefix" value="<?php echo "$DBPrefix"; ?>" /> 230 <input type="hidden" name="DBcreated" value="<?php echo "$DBcreated"; ?>" /> 231 <div class="install"> 232 <div id="stepbar"> 233 <div class="step-off"><?php echo T_('pre-installation check') ?></div> 234 <div class="step-off"><?php echo T_('license') ?></div> 235 <div class="step-off"><?php echo T_('step 1') ?></div> 236 <div class="step-on"><?php echo T_('step 2') ?></div> 237 <div class="step-off"><?php echo T_('step 3') ?></div> 238 <div class="step-off"><?php echo T_('step 4') ?></div> 239 <div class="far-right"> 240 <?php if (!$isErr) { ?> 241 <input class="button" type="submit" name="next" value="<?php echo T_('Next') ?> >>"/> 242 <?php } ?> 243 </div> 244 </div> 245 <div id="right"> 246 <div id="step"> 247 <?php 248 if (!$isErr) { 249 echo T_('Step 2'); 250 } else 251 { 252 echo T_('Step 1 - Error Report'); 253 } 254 ?></div> 255 <div id="steposi"></div> 256 <div class="clr"></div> 257 258 <h1><?php if (!$isErr) { echo T_('Enter the name of your Mambo site:'); } ?></h1> 259 <div class="install-text"> 260 <?php if ($isErr) { ?> 261 <?php echo T_('Looks like there have been some errors with inserting data into your database!<br /><br /> 262 You cannot continue.') ?> 263 <?php } else { ?> 264 <?php echo T_('SUCCESS!') ?> 265 <br /> 266 <br /> 267 <?php echo T_('Type in the name for your Mambo site. This name is used in email messages so make it something meaningful.') ?> 268 <?php } ?> 269 </div> 270 <div class="install-form"> 271 <div class="form-block"> 272 <table class="content2"> 273 <?php 274 if ($isErr) { 275 echo '<tr><td colspan="2">'; 276 echo '<strong></strong>'; 277 echo "<br /><br />".T_('Error log:')."<br />\n"; 278 // abrupt failure 279 echo '<textarea rows="10" cols="50">'; 280 foreach($errors as $error) { 281 echo "SQL=$error[0]:\n- - - - - - - - - -\n$error[1]\n= = = = = = = = = =\n\n"; 282 } 283 echo '</textarea>'; 284 echo "</td></tr>\n"; 285 } else { 286 ?> 287 <tr> 288 <td width="100"><?php echo T_('Site name') ?></td> 289 <td align="center"><input class="inputbox" type="text" name="sitename" size="50" value="<?php echo "{$configArray['sitename']}"; ?>" /></td> 290 </tr> 291 <tr> 292 <td width="100"> </td> 293 <td align="center" class="small"><?php echo T_('e.g. The Home of Mambo') ?></td> 294 </tr> 295 </table> 296 <?php 297 } // if 298 ?> 299 </div> 300 </div> 301 </div> 302 <div class="clr"></div> 303 </div> 304 <div class="clr"></div> 305 </form> 306 </div> 307 <div class="ctr"> 308 <?php echo T_('<a href="http://www.mambo-foundation.org" target="_blank">Mambo </a> is Free Software released under the <a href="http://www.opensource.org/licenses/gpl-2.0.php" target="_blank">GNU/GPL License</a>.') ?> 309 </div> 310 </body> 311 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |