forked from phpfaucet/faucet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
199 lines (78 loc) · 1.98 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
<?php
if(isset($_POST['install']) ){
$host=$_POST['host'];
$user=$_POST['user'];
$pass=$_POST['pass'];
$dbname=$_POST['dbname'];
$config = <<<END
<?php
class SystemComponent{
private \$settings;
function getSetting(){
\$settings['dbusername']='$user';
\$settings['dbpassword']='$pass';
\$settings['dbname']='$dbname';
\$settings['dbhost']='$host';
return \$settings;
}
}
END;
$fp = fopen('includes/system.class.php',"w");
fwrite($fp,$config);
fclose($fp);
include_once "includes/dbconnector.class.php";
$db=new DbConnector;
$filename = 'phpfaucet.sql';
$templine = '';
$lines = file($filename);
foreach ($lines as $line){
if (substr($line, 0, 2) == '--' || $line == '')
continue;
$templine .= $line;
if (substr(trim($line), -1, 1) == ';'){
$db->query($templine);
$templine = '';
}
}
echo "Tables imported successfully";
echo "<br>Do not resubmit this file.<br>DELETE IMMEDIATELY.";
}else{
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<center>
<form action="" method="post">
<table width="50%" border="1" align="center" cellpadding="5" cellspacing="0">
<tbody>
<tr>
<td width="50%">DatabaseHost:</td>
<td width="50%"><input type="text" name="host" value="localhost"></td>
</tr>
<tr>
<td>DatabaseUseranme:</td>
<td><input type="text" name="user" value=""></td>
</tr>
<tr>
<td>DatabasePassword:</td>
<td><input type="text" name="pass" value=""></td>
</tr>
<tr>
<td>DatabaseName:</td>
<td><input type="text" name="dbname" value=""></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="install" value="install"></td>
</tr>
</tbody>
</table>
<br>
</form>
</center>
</body>
</html>
<?php } ?>