root/dev/install/install_step3.php @ 324

Revision 254, 2.9 KB (checked in by exi, 13 years ago)

Merging 242:253 branch into dev

Line 
1<?php
2$stoppage = true;
3
4if ($_REQUEST['submit'])
5{
6    $_SESSION['sql'] = array();
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}
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=text 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"></td><td><input type=submit name=submit value="Test"></td></tr>
40</table>
41<?php
42}
43
44if ($_SESSION['sql']['db'])
45{
46    echo '<div class="block-header2">Testing Settings</div>';
47    echo 'Got the data you supplied, trying to connect to that sql server now...<br/>';
48    $db = mysql_pconnect($_SESSION['sql']['host'], $_SESSION['sql']['user'], $_SESSION['sql']['pass']);
49    if (is_resource($db))
50    {
51        echo 'Connected to MySQl';
52        $result = mysql_query('SELECT VERSION() AS version');
53        $result = mysql_fetch_assoc($result);
54        if (!$result)
55        {
56            echo '<br/>Something went wrong:<br/>';
57            echo mysql_error();
58        }
59        else
60        {
61            echo ' running Version '.$result['version'].'.<br/>';
62            if (mysql_select_db($_SESSION['sql']['db']))
63            {
64                echo 'Successfully selected database "'.$_SESSION['sql']['db'].'", everything is fine to continue.<br/>';
65                $stoppage = false;
66            }
67            else
68            {
69                echo 'Could not select the database: '.mysql_error().'<br/>';
70            }
71        }
72    }
73    else
74    {
75        echo 'Could not connect to the server: '.mysql_error().'<br/>';
76    }
77}
78?>
79
80<?php if ($stoppage)
81{
82    return;
83}?>
84<p><a href="?step=<?php echo ($_SESSION['state']+1); ?>">Next Step</a></p>
Note: See TracBrowser for help on using the browser.