-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnect.php
114 lines (113 loc) · 2.4 KB
/
Connect.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
<link rel="stylesheet" href="./style.css">
<script type="text/javascript" src="./fade.js"></script>
<form action="Connect.php" method="post" name="connect" OnSubmit="return config(this)" OnLoad="opacity();">
<center>
<title>Configuration</title>
<table border="1" id="configuration" width="40%" height="40%">
<tr>
<td>Server: </td>
<td><input type="text" name="server" value="Localhost"></td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="username" value=""></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td>World:</td>
<td><input type="text" name="world"></td>
</tr>
<tr>
<td>Characters:</td>
<td><input type="text" name="characters"></td>
</tr>
</table>
<table>
<tr align="center">
<td></td>
<td><input type="submit" value="Connect" OnClick=""> <input type="reset" value="Clear"></td>
</tr>
</table>
<br><br>
<br><br>
<input type="hidden" value="0" name="x">
</form>
<script type="text/javascript">
function config(form)
{
server=false;
username=false;
password=false;
world=false;
characters=false;
if (form.server.value != "")
server=true;
if (form.username.value != "")
username=true;
if (form.password.value != "")
password=true;
if (form.world.value != "")
world=true;
if (form.characters.value != "")
characters=true;
if (server && username && password && world && characters)
{
form.x.value=1;
return true;
}
else
{
form.x.value=2;
return false;
}
}
</script>
<?php
$x=$_POST['x'];
if($x==1)
{
$server=$_POST['server'];
$user=$_POST['username'];
$pwd=$_POST['password'];
$world=$_POST['world'];
$characters=$_POST['characters'];
$connect=mysql_connect($server, $user, $pwd);
$Databases=mysql_select_db($world, $connect);
if (!$connect)
{
echo "mysql_connect : " . mysql_error() . "<br />";
echo "Error code :" . mysql_errno() . "<br />";
}
else
{
if(!$Databases)
{
echo "mysql_connect : " . mysql_error() . "<br />";
echo "Error code :" . mysql_errno() . "<br />";
}
else
{
$nomefile="db-config.php";
$file = fopen($nomefile, "w+");
$testo= "<?php
\$Server=\"$server\";
\$Username=\"$user\";
\$Password=\"$pwd\";
\$Database=\"$world\";
\$Characters=\"$characters\";
\$connect=mysql_connect(\$Server, \$Username, \$Password);
\$Databases=mysql_select_db(\"\$Database\", \$connect);
?>
";
fwrite($file, $testo);
fclose($file);
header("location:index.php");
}
}
}
?>
<script type="text/javascript">opacity();</script>
</center>