C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\rodam\_installation\install2.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<?php
/**
* @version $Id: install2.php 2510 2006-02-21 04:59:41Z stingrey $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Set flag that this is a parent file
define"_VALID_MOS");

// Include common.php
require_once( 'common.php' );
require_once( 
'../includes/database.php' );

$DBhostname mosGetParam$_POST'DBhostname''' );
$DBuserName mosGetParam$_POST'DBuserName''' );
$DBpassword mosGetParam$_POST'DBpassword''' );
$DBname      mosGetParam$_POST'DBname''' );
$DBPrefix      mosGetParam$_POST'DBPrefix''' );
$DBDel      intvalmosGetParam$_POST'DBDel') );
$DBBackup      intvalmosGetParam$_POST'DBBackup') );
$DBSample    intvalmosGetParam$_POST'DBSample') );
$DBcreated    intvalmosGetParam$_POST'DBcreated') );
$BUPrefix 'old_';
$configArray['sitename'] = trimmosGetParam$_POST'sitename''' ) );

$database null;

$errors = array();
if (!
$DBcreated){
    if (!
$DBhostname || !$DBuserName || !$DBname) {
        
db_err ("stepBack3","The database details provided are incorrect and/or empty.");
    }

    
$database = new database$DBhostname$DBuserName$DBpassword''''false );
    
$test $database->getErrorMsg();

    if (!
$database->_resource) {
        
db_err ('stepBack2','The password and username provided are incorrect.');
    }

    if(
$DBname == '') {
        
db_err ('stepBack','The database name provided is empty.');
    }

    if(
$DBPrefix == '') {
        
db_err ('stepBack','You have not entered a database prefix.');
    }
    
    
// Does this code actually do anything???
    
$configArray['DBhostname'] = $DBhostname;
    
$configArray['DBuserName'] = $DBuserName;
    
$configArray['DBpassword'] = $DBpassword;
    
$configArray['DBname']     = $DBname;
    
$configArray['DBPrefix']    = $DBPrefix;

    
$sql "CREATE DATABASE `$DBname`";
    
$database->setQuery$sql );
    
$database->query();
    
$test $database->getErrorNum();

    if (
$test != && $test != 1007) {
        
db_err'stepBack''A database error occurred: ' $database->getErrorMsg() );
    }

    
// db is now new or existing, create the db object connector to do the serious work
    
$database = new database$DBhostname$DBuserName$DBpassword$DBname$DBPrefix );

    
// delete existing mos table if requested
    
if ($DBDel) {
        
$query "SHOW TABLES FROM `$DBname`";
        
$database->setQuery$query );
        
$errors = array();
        if (
$tables $database->loadResultArray()) {
            foreach (
$tables as $table) {
                if (
strpos$table$DBPrefix ) === 0) {
                    if (
$DBBackup) {
                        
$butable str_replace$DBPrefix$BUPrefix$table );
                        
$query "DROP TABLE IF EXISTS `$butable`";
                        
$database->setQuery$query );
                        
$database->query();
                        if (
$database->getErrorNum()) {
                            
$errors[$database->getQuery()] = $database->getErrorMsg();
                        }
                        
$query "RENAME TABLE `$table` TO `$butable`";
                        
$database->setQuery$query );
                        
$database->query();
                        if (
$database->getErrorNum()) {
                            
$errors[$database->getQuery()] = $database->getErrorMsg();
                        }
                    }
                    
$query "DROP TABLE IF EXISTS `$table`";
                    
$database->setQuery$query );
                    
$database->query();
                    if (
$database->getErrorNum()) {
                        
$errors[$database->getQuery()] = $database->getErrorMsg();
                    }
                }
            }
        }
    }

    
populate_db$database'joomla.sql' );
    if (
$DBSample) {
        
populate_db$database'sample_data.sql' );
    }
    
$DBcreated 1;
}

function 
db_err($step$alert) {
    global 
$DBhostname,$DBuserName,$DBpassword,$DBDel,$DBname;
    echo 
"<form name=\"$step\" method=\"post\" action=\"install1.php\">
    <input type=\"hidden\" name=\"DBhostname\" value=\"
$DBhostname\">
    <input type=\"hidden\" name=\"DBuserName\" value=\"
$DBuserName\">
    <input type=\"hidden\" name=\"DBpassword\" value=\"
$DBpassword\">
    <input type=\"hidden\" name=\"DBDel\" value=\"
$DBDel\">
    <input type=\"hidden\" name=\"DBname\" value=\"
$DBname\">
    </form>\n"
;
    
//echo "<script>alert(\"$alert\"); window.history.go(-1);</script>";
    
echo "<script>alert(\"$alert\"); document.location.href='install1.php';</script>";  
    exit();
}

/**
 * @param object
 * @param string File name
 */
function populate_db( &$database$sqlfile='mambo.sql') {
    global 
$errors;

    
$mqr = @get_magic_quotes_runtime();
    @
set_magic_quotes_runtime(0);
    
$query freadfopen'sql/' $sqlfile'r' ), filesize'sql/' $sqlfile ) );
    @
set_magic_quotes_runtime($mqr);
    
$pieces  split_sql($query);

    for (
$i=0$i<count($pieces); $i++) {
        
$pieces[$i] = trim($pieces[$i]);
        if(!empty(
$pieces[$i]) && $pieces[$i] != "#") {
            
$database->setQuery$pieces[$i] );
            if (!
$database->query()) {
                
$errors[] = array ( $database->getErrorMsg(), $pieces[$i] );
            }
        }
    }
}

/**
 * @param string
 */
function split_sql($sql) {
    
$sql trim($sql);
    
$sql ereg_replace("\n#[^\n]*\n""\n"$sql);

    
$buffer = array();
    
$ret = array();
    
$in_string false;

    for(
$i=0$i<strlen($sql)-1$i++) {
        if(
$sql[$i] == ";" && !$in_string) {
            
$ret[] = substr($sql0$i);
            
$sql substr($sql$i 1);
            
$i 0;
        }

        if(
$in_string && ($sql[$i] == $in_string) && $buffer[1] != "\\") {
            
$in_string false;
        }
        elseif(!
$in_string && ($sql[$i] == '"' || $sql[$i] == "'") && (!isset($buffer[0]) || $buffer[0] != "\\")) {
            
$in_string $sql[$i];
        }
        if(isset(
$buffer[1])) {
            
$buffer[0] = $buffer[1];
        }
        
$buffer[1] = $sql[$i];
    }

    if(!empty(
$sql)) {
        
$ret[] = $sql;
    }
    return(
$ret);
}

$isErr intvalcount$errors ) );

echo 
"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Joomla - Web Installer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="shortcut icon" href="../images/favicon.ico" />
<link rel="stylesheet" href="install.css" type="text/css" />
<script type="text/javascript">
<!--
function check() {
    // form validation check
    var formValid = true;
    var f = document.form;
    if ( f.sitename.value == '' ) {
        alert('Please enter a Site Name');
        f.sitename.focus();
        formValid = false
    }
    return formValid;
}
//-->
</script>
</head>
<body onload="document.form.sitename.focus();">
<div id="wrapper">
    <div id="header">
      <div id="joomla"><img src="header_install.png" alt="Joomla Installation" /></div>
    </div>
</div>

<div id="ctr" align="center">
    <form action="install3.php" method="post" name="form" id="form" onsubmit="return check();">
    <input type="hidden" name="DBhostname" value="<?php echo "$DBhostname"?>" />
    <input type="hidden" name="DBuserName" value="<?php echo "$DBuserName"?>" />
    <input type="hidden" name="DBpassword" value="<?php echo "$DBpassword"?>" />
    <input type="hidden" name="DBname" value="<?php echo "$DBname"?>" />
    <input type="hidden" name="DBPrefix" value="<?php echo "$DBPrefix"?>" />
    <input type="hidden" name="DBcreated" value="<?php echo "$DBcreated"?>" />
    <div class="install">
        <div id="stepbar">
              <div class="step-off">pre-installation check</div>
              <div class="step-off">license</div>
              <div class="step-off">step 1</div>
              <div class="step-on">step 2</div>
              <div class="step-off">step 3</div>
              <div class="step-off">step 4</div>
        </div>
        <div id="right">
              <div class="far-right">
<?php if (!$isErr) { ?>
                    <input class="button" type="submit" name="next" value="Next >>"/>
<?php ?>
              </div>
              <div id="step">step 2</div>
              <div class="clr"></div>

              <h1>Enter the name of your Joomla site:</h1>
            <div class="install-text">
<?php if ($isErr) { ?>
            Looks like there have been some errors with inserting data into your database!<br />
              You cannot continue.
<?php } else { ?>
            SUCCESS!
            <br/>
            <br/>
              Type in the name for your Joomla site. This
            name is used in email messages so make it something meaningful.
<?php ?>
          </div>
          <div class="install-form">
              <div class="form-block">
                  <table class="content2">
<?php
            
if ($isErr) {
                echo 
'<tr><td colspan="2">';
                echo 
'<b></b>';
                echo 
"<br/><br />Error log:<br />\n";
                
// abrupt failure
                
echo '<textarea rows="10" cols="50">';
                foreach(
$errors as $error) {
                    echo 
"SQL=$error[0]:\n- - - - - - - - - -\n$error[1]\n= = = = = = = = = =\n\n";
                }
                echo 
'</textarea>';
                echo 
"</td></tr>\n";
              } else {
?>
                  <tr>
                      <td width="100">Site name</td>
                      <td align="center"><input class="inputbox" type="text" name="sitename" size="50" value="<?php echo "{$configArray['sitename']}"?>" /></td>
                  </tr>
                  <tr>
                      <td width="100">&nbsp;</td>
                      <td align="center" class="small">e.g. The Home of Joomla</td>
                  </tr>
                  </table>
<?php
              
// if
?>
              </div>
          </div>
          <div class="clr"></div>
          <div id="break"></div>
    </div>
    <div class="clr"></div>
    </form>
</div>
<div class="clr"></div>
</div>
<div class="ctr">
    <a href="http://www.joomla.org" target="_blank">Joomla!</a> is Free Software released under the GNU/GPL License.
</div>
</body>
</html>