root/dev/install/install_step3.php @ 400

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

Fixes: install is locked after first run, private cache files made inaccesible, initial summary caching removed from kill posting, board will not attempt to run on MySQL < 4.1, PILOT_ID cannot be set, legacy option removed from admin panel, pos values added to installation defaults

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