forked from sdc/xerte_2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
page2.php
94 lines (69 loc) · 3 KB
/
page2.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
<?php
echo file_get_contents("page_top");
if(!isset($_POST['database_file'])) {
$mysql_connect_id = mysql_connect($_POST['host'], $_POST['username'], $_POST['password']);
// Check for connection and error if failed
if(!$mysql_connect_id) {
?>
<p>Sorry, the attempt to connect to the host has failed. MySQL reports the following error -
<?php echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id); ?></p>
<?php
}
$query = "create database if not exists " . $_POST['database_name'];
$query_response = mysql_query($query);
if(!$query_response){
?>
<p>Sorry, the attempt to create the database to the database has failed. MySQL reports the following error -
<?php
echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id);?>
</p>
<?php
}
$query = "USE " . $_POST['database_name'];
$query_response = mysql_query($query);
if(!$query_response){
?>
<p>Sorry, the attempt to specify which database we need to work on (the MySQL keyword - USE) has failed. MySQL reports the following error -
<?php
echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id); echo "The query response was " . $query_response . "<br></p>";
}
$temp = explode(";", file_get_contents("basic.sql"));
$x=0;
while($x!=count($temp)){
if($_POST['database_prefix']!=""){
$query = str_replace("$",$_POST['database_prefix'],ltrim($temp[$x++]));
}else{
$query = str_replace("$","",ltrim($temp[$x++]));
}
if($query!=""){
$query_response = mysql_query($query);
}
if(!$query_response){
?>
<p>Sorry, The query <?php echo $query; ?> has failed. MySQL reports the following error -
<?php echo mysql_errno($mysql_connect_id) . " - " . mysql_error($mysql_connect_id); ?></p>
<?php
}
}
session_start();
$_SESSION['DATABASE_HOST'] = $_POST['host'];
$_SESSION['DATABASE_NAME'] = $_POST['database_name'];
$_SESSION['DATABASE_PREFIX'] = $_POST['database_prefix'];
}
?>
<h2 style="margin-top:15px">
MySQL Database Account Set up page
</h2>
<p>
Your Xerte Online Toolkits database has been successfully created. When users are creating work on the site, the PHP will need a MySQL username with select,insert,update and delete privileges.
</p>
<p>
<form action="page_password.php" method="post" enctype="multipart/form-data">
<label for="account">Database account name for users of the site. People following the XAMPP path / or testing locally should type in root.</label><br /><br /><input type="text" width="100" name="account" id="account" /><br /><br />
<label for="password">Database password for the account above. People following the XAMPP path / or testing locally should leave this field blank.</label><br /><br /><input type="password" width="100" name="password" id="password"/><br /><br />
<input type="image" src="next.gif" />
</form>
</p>
</div>
</body>
</html>