-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.php
More file actions
80 lines (79 loc) · 3.75 KB
/
installer.php
File metadata and controls
80 lines (79 loc) · 3.75 KB
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
<html>
<head><title>PaperCut Web Parser installer</title></head>
<body>
<h1><div align="center">Enter credentials for access to database</div></h1>
<form action="installer.php" method="POST" name="DBAccess">
<table WIDTH="50%" align="center">
<?php
require "config.php";
?>
<tr><td width="40%" align="right">Hostname:</td><td width="60%"><input type="text" name="hostname" value="<?php echo $DBHOST ?>"></td></tr>
<tr><td align="right">User</td><td><input type="text" name="user" value="<?php echo $DBUSER ?>"></td></tr>
<tr><td align="right">Password</td><td><input type="password" name="password" value="<?php echo $DBPASS ?>"></td></tr>
<tr><td align="right">Database name</td><td><input type="text" name="dbname" value="<?php echo $DBNAME ?>"></td></tr>
<tr><td align="right">Search directory</td><td><input type="text" name="searchdir" value="<?php echo $SEARCHDIR ?>"></td></tr>
<tr><td></td><td><button type="Clear" value="Clear">Clear</button><input type="submit" value="Submit"></td></tr>
</table>
</form>
<?php
$Query = "CREATE TABLE data ("
. "ID int NOT NULL AUTO_INCREMENT, "
. "DateTime DATETIME, "
. "User varchar(32), "
. "Pages int, "
. "Copies int, "
. "Printer varchar(32), "
. "DocumentName varchar(255), "
. "Client varchar(128), "
. "PaperSize varchar(32), "
. "Language varchar(16), "
. "Height int, "
. "Width int, "
. "Duplex varchar(16), "
. "Grayscale varchar(16), "
. "Size varchar(16), "
. "PRIMARY KEY (ID));";
$DBHOST = htmlspecialchars($_POST['hostname']);
$DBUSER = htmlspecialchars($_POST['user']);
$DBPASS = htmlspecialchars($_POST['password']);
$DBNAME = htmlspecialchars($_POST['dbname']);
$SEARCHDIR = htmlspecialchars($_POST['searchdir']);
if ( (empty($DBHOST) == false) && (empty($DBUSER) == FALSE) && (empty($DBPASS) == FALSE) && (empty($DBNAME) == FALSE) )
{
$CONFIGFILE = getcwd() . "/config.php";
$fp = fopen("config.php", "w");
fwrite($fp, "<?php\n");
fwrite($fp, "\$DBHOST = \"" . $DBHOST . "\";\n");
fwrite($fp, "\$DBUSER = \"" . $DBUSER . "\";\n");
fwrite($fp, "\$DBPASS = \"" . $DBPASS . "\";\n");
fwrite($fp, "\$DBNAME = \"" . $DBNAME . "\";\n");
fwrite($ft, "\$SEARCHDIR = \"" . $SEARCHDIR . "\";\n");
fwrite($fp, "?>\n");
fclose($fp);
$dbconnect = mysql_connect($DBHOST, $DBUSER, $DBPASS);
$err = mysql_errno();
echo $err;
if ($dbconnect)
{
if (mysql_select_db($DBNAME))
{
$res = mysql_query($Query);
mysql_close();
}
else
{
echo "<div align=\"center\"><h2>Cannot select mysql db! Please create database, and try again</h2></div>";
}
}
else
{
echo "<div align=\"center\"><h2>Cannot connect with mysql!</h2></div>";
}
}
else
{
echo "<h3><div align=\"center\">Some field is empty!</div></h3>";
}
?>
</body>
</html>