root/dev/install/install_step3.php @ 397

Revision 397, 4.2 KB (checked in by kovell, 13 years ago)

Fixes: autoupgrade works, problem with db.php includes removed. Admin cache menu now has option to clear caches. Install hides passwords

Line 
1<?php
2$stoppage = true;
3
4if ($_REQUEST['submit'] != '')
5{
6    $_SESSION['sql']['host'] = $_POST['host'];
7    $_SESSION['sql']['user'] = $_POST['user'];
8    $_SESSION['sql']['pass'] = $_POST['dbpass'];
9    $_SESSION['sql']['db'] = $_POST['db'];
10    $_SESSION['sql']['engine'] = $_POST['engine'];
11}
12
13if (!$host = $_SESSION['sql']['host'])
14{
15    $host = 'localhost';
16}
17if (file_exists('../config.php'))
18{
19    echo '<div class="block-header2">Found old config</div>';
20    echo 'We will just reuse the data and create a new one.<br/>';
21    include_once('../config.php');
22    $_SESSION['sql'] = array();
23    $_SESSION['sql']['host'] = DB_HOST;
24    $_SESSION['sql']['user'] = DB_USER;
25    $_SESSION['sql']['pass'] = DB_PASS;
26    $_SESSION['sql']['db'] = DB_NAME;
27}
28else
29{
30?>
31<form id="options" name="options" method="post" action="?step=3">
32<input type="hidden" name="step" value="3">
33<div class="block-header2">MySQL Database</div>
34<table class="kb-subtable">
35<tr><td width="120"><b>MySQL Host:</b></td><td><input type=text name=host id=host size=20 maxlength=80 value="<?php echo $host; ?>"></td></tr>
36<tr><td width="120"><b>User:</b></td><td><input type=text name=user id=user size=20 maxlength=80 value="<?php echo $_SESSION['sql']['user']; ?>"></td></tr>
37<tr><td width="120"><b>Password:</b></td><td><input type=password name=dbpass id=pass size=20 maxlength=80 value="<?php echo $_SESSION['sql']['pass']; ?>"></td></tr>
38<tr><td width="120"><b>Database:</b></td><td><input type=text name=db id=db size=20 maxlength=80 value="<?php echo $_SESSION['sql']['db']; ?>"></td></tr>
39<tr><td width="120"><b>Engine:</b></td><td><input type=radio name=engine id=engine value="InnoDB"  <?php if ($_SESSION['sql']['engine'] != "MyISAM") echo "CHECKED"; ?>> InnoDB <input <?php if ($_SESSION['sql']['engine'] == "MyISAM") echo "CHECKED"; ?> type=radio name=engine id=engine value="MyISAM">MyISAM</tr>
40<tr><td width="120"></td><td><input type=submit name=submit value="Test"></td></tr>
41</table>
42<?php
43}
44
45if ($_SESSION['sql']['db'])
46{
47    echo '<div class="block-header2">Testing Settings</div>';
48    echo 'Got the data you supplied, trying to connect to that sql server now...<br/>';
49    $db = mysql_pconnect($_SESSION['sql']['host'], $_SESSION['sql']['user'], $_SESSION['sql']['pass']);
50    if (is_resource($db))
51    {
52        echo 'Connected to MySQl';
53        $result = mysql_query('SELECT VERSION() AS version');
54        $result = mysql_fetch_assoc($result);
55        if (!$result)
56        {
57            echo '<br/>Something went wrong:<br/>';
58            echo mysql_error();
59        }
60        else
61        {
62            echo ' running Version '.$result['version'].'.<br/>';
63            if (mysql_select_db($_SESSION['sql']['db']))
64            {
65                echo 'Successfully selected database "'.$_SESSION['sql']['db'].'", everything seems fine to continue.<br/>';
66                $stoppage = false;
67               
68                //InnoDB check
69                if ($stoppage == false && $_SESSION['sql']['engine'] == 'InnoDB'){
70                        echo "</br>Checking Database Engine InnoDB.. <br/>";
71                        $stoppage = true;
72                        $result = mysql_query('SHOW ENGINES;');
73                        while (($row = mysql_fetch_row($result)) &&  $stoppage == true){
74                                if ($row[0] == 'InnoDB'){ 
75                                        if ($row[1] == 'YES' || $row[1] == 'DEFAULT'){ // (YES / NO / DEFAULT)
76                                                $stoppage = false;
77                                        }
78                                }
79                        }
80                        if ($stoppage){
81                                echo 'Error: InnoDB is not supported on your MySQL Server.</br>'; 
82                        }else{
83                                echo 'InnoDB is supported on your MySQL Server.</br>'; 
84                        }
85                }
86               
87               
88            }
89            else
90            {
91                echo 'Could not select the database: '.mysql_error().'<br/>';
92            }
93        }
94    }
95    else
96    {
97        echo 'Could not connect to the server: '.mysql_error().'<br/>';
98    }
99}
100?>
101
102<?php if ($stoppage)
103{
104    return;
105}?>
106<p><a href="?step=<?php echo ($_SESSION['state']+1); ?>">Next Step</a></p>
Note: See TracBrowser for help on using the browser.