-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
executable file
·144 lines (136 loc) · 5.65 KB
/
install.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
<?php
session_start();
$sprache = isset($_POST['sprache']) ? $_POST['sprache'] : 'english';
include "includes/language/lang_".$sprache.".php";
function db_connect() {
$conn = mysql_connect($_SESSION['dbhost'], $_SESSION['dbuser'], $_SESSION['dbpass']);
return $conn;
}
$db_file="config.php";
echo "<table cellpadding=4 cellspacing=4 bgcolor=#DDEEDD width=400 height=300><tr valign=top><td>";
if (isset($_REQUEST['step'])) {
echo "<b>Step " . $_REQUEST['step'] . "</b><br>";
switch ($_REQUEST['step']) {
case 1:
if (isset($_REQUEST['dbcred'])) {
$_SESSION['dbhost'] = $_REQUEST['dbhost'];
$_SESSION['dbname'] = $_REQUEST['dbname'];
$_SESSION['dbuser'] = $_REQUEST['dbuser'];
$_SESSION['dbpass'] = $_REQUEST['dbpass'];
echo "verify account: ";
if (!db_connect()) {
echo "wrong. Please correct.";
exit;
}
echo "OK<br>";
$file_size = filesize($db_file);
if ($file_size != '0' || ((mysql_query("USE ".$_SESSION['dbname'])))) {
echo "<br>Installation alread complete.<br> Please <a href=uninstall.php>uninstall</a> all.</i>";
exit();
}
echo "</td></tr><tr><td align=right>";
echo "<input type=button value=Next onclick=\"window.location.href='?step=2'\">";
} else {
echo "Account for database administrator:<p>";
echo "<form method=post action=".$_SERVER['PHP_SELF']."?step=1>";
echo "<tab>";
echo "<tr><td>Host:</td><td><input type=text size=12 name=dbhost value='localhost'></td></tr>";
echo "<tr><td>Database:</td><td><input type=text size=12 name=dbname value='dbJoorgportal'></td></tr>";
echo "<tr><td>User:</td><td><input type=text size=12 name=dbuser value='root'></td></tr>";
echo "<tr><td>Password:</td><td><input type=password size=12 name=dbpass></td></tr>";
echo "<tr><td align=right>";
echo "<input type=submit name=dbcred value=Next>";
echo "</td></tr>";
echo "</tab>";
echo "</form>";
}
break;
case 2:
$conf = "\$dbhost=\"".$_SESSION['dbhost']."\";\r\n";
$conf = $conf."\$dbuser=\"".$_SESSION['dbuser']."\";\r\n";
$conf = $conf."\$dbpass=\"".$_SESSION['dbpass']."\";\r\n";
$conf = $conf."\$dbname=\"".$_SESSION['dbname']."\";\r\n";
$conf = $conf."\$res = mysql_connect(\$dbhost,\$dbuser,\$dbpass) or die(mysql_error());\r\n";
$conf = $conf."\$res = mysql_select_db(\$dbname) or die(mysql_error());\r\n";
$content = "<?php\r\n";
$content = $content.$conf."?>";
if (!is_writable($db_file)) {
echo "Database file ".$db_file." not writeable. Please modify perms to 777.<br>";
echo "<a href='index.php'>Restart</a><br>";
echo "Or modify the sample file 'config_sample.php' and rename it to the database file.<br>";
//exit;
} else {
$handle = fopen($db_file,'w');
if (fwrite($handle,$content)) {
echo "write successfully.<br>";
} else {
echo "$db_file not created!<br>";
exit;
}
fclose($handle);
}
$conn = mysql_connect($_SESSION['dbhost'], $_SESSION['dbuser'], $_SESSION['dbpass']) or die('Could not connect: ' . mysql_error());
$sql = "CREATE Database ".$_SESSION['dbname'];
$retval = mysql_query( $sql, $conn ) or die('Could not create database: ' . mysql_error());
echo "<br>Database ".$_SESSION['dbname']." created successfully.<br>";
echo "</td></tr><tr><td align=right>";
echo "<input type=button value=Next onclick=\"window.location.href='?step=3'\">";
break;
case 3:
echo "dbhost:".$_SESSION['dbhost']."<br>";
// mysql_connect($_SESSION['dbhost'],$_SESSION['dbuser'],$_SESSION['dbpass']);
// if ( mysql_create_db ( $_SESSION['dbname'] ) ) {
// echo 'Datenbank ' . $_SESSION['dbname'] . ' wurde erstellt!<br>';
// } else {
// echo 'Datenbank ' . $_SESSION['dbname'] . ' konnte NICHT erstellt werden!<br>';
// echo "<a href='index.php'>Restart</><br>";
// echo "<a href='install.php?step=3'>Try again</><br>";
// exit;
// }
mysql_connect($_SESSION['dbhost'],$_SESSION['dbuser'],$_SESSION['dbpass']);
mysql_select_db($_SESSION['dbname']);
$lines = file('sites/install/dbjoorgportal.sql');
$newquery="";
$remark='false';
$cntlin=0;
foreach ($lines as $line_num => $query) {
$cntlin=$cntlin+1;
//echo "query:".$query.",remark=".$remark.",".substr(rtrim($query),-3)."<br>";
if ($remark=='false') {
if (trim($query)=="" || substr($query,0,2)=="--" || substr($query,0,2)=="/*") {
} else {
$newquery=$newquery.$query;
//echo $query."<br>";
if (substr(trim($query),-1)==";") {
//echo "query:".$newquery."<br>";
$result = @mysql_query($newquery) or die(mysql_error().",cntlin=".$cntlin);
$newquery="";
}
}
}
if (substr(ltrim($query),0,2)=="/*") {
$remark='true';
}
if (substr(rtrim($query),-3)=="*/;") {
$remark='false';
}
if (substr(rtrim($query),-2)=="*/") {
$remark='false';
}
}
echo "Database successful created.<br>";
echo "<input type=button value=Next onclick=\"window.location.href='?step=final'\">";
break;
case "final":
session_destroy();
echo "Installation completed.<br>";
echo "<a href='index.php'>Finished</>";
break;
}
} else {
echo $txtinstall1."<br>";
echo "</td></tr><tr><td align=right>";
echo "<input type=button value='".$txtnext."' onclick=\"window.location.href='?step=1'\">";
}
echo "</td></tr></table>";
?>