-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathimporthlstats.php
118 lines (85 loc) · 3.5 KB
/
importhlstats.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
<?php
include("config.php");
include("lib/functions.php");
$start = head();
$status = $_POST["status"];
//error_reporting(E_ALL);
//ini_set("display_errors", 1);
function data() {
$get = mysql_query("SELECT name,address,port,rcon_password from hlstats_Servers");
return $get;
}
if ($status == "verify") {
$ipp = $_POST["ip"];
if (!$ipp) { $ip = 'localhost'; }
$dbp = $_POST["db"];
$passp= $_POST["pass"];
$userp = $_POST["user"];
mysql_connect($ipp, $userp, $passp) or die(mysql_error());
mysql_select_db($dbp);
if(empty($userp) OR empty($dbp) OR empty($passp)){
echo '<b>Please go back and provide all needed data.<br />';
bottom($start);
die();
}
$get = data();
while($row = mysql_fetch_array( $get )) {
$name = $row['name'];
$ip = $row['address'];
$port = $row['port'];
$rconpass = $row['rcon_password'];
echo '<b>Server name:</b> '.$name.'<br />';
echo '<b>Ip:port:</b> '.$ip.':'.$port.'<br />';
echo '<b>Rcon Password:</b> '.$rconpass.'<br />';
}
print "<br/><b><font color=green>This will import all these entrys, you sure?</font></b><br/>\n\n";
print "</pre>";
print "<form method='post'>\n";
print "<input type='hidden' name='ip' value='$ipp' />\n";
print "<input type='hidden' name='db' value='$dbp' />\n";
print "<input type='hidden' name='user' value='$userp' />\n";
print "<input type='hidden' name='pass' value='$passp' />\n";
print "<input type='hidden' name='status' value='import' />\n";
echo '<input type=\'submit\' value=Yes /></form>';
}
elseif ($status == "import") {
$ipp = $_POST["ip"];
$dbp = $_POST["db"];
$passp= $_POST["pass"];
$userp = $_POST["user"];
mysql_connect($ipp, $userp, $passp) or die(mysql_error());
mysql_select_db($dbp);
$get = data();
mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($table) or die(mysql_error());
while($row = mysql_fetch_array( $get )) {
$servername = $row['name'];
$ip = $row['address'];
$port = $row['port'];
$rconpass = $row['rcon_password'];
// call import script...
$import = mysql_query("INSERT INTO servers (servername, ip, port, rconpass)
VALUES('$servername', '$ip','$port','$rconpass')");
if ($import) {
print "<b>Imported....</b><br>\n";
print "Added server '$servername' correctly to the database<br>\n";
}
else {
print "<font color=red>$servername, Adding failed, perhaps its already there?</font><br>";
}
}
print "<br><br><hr>\n\nMight be wise to update the information of all the servers again? Click <a href=renew.php?serverid=all>HERE</a>\n";
}
else {
echo '<table><tr>';
echo '<form method=post>';
echo '<td colspan=1>Ip / Host:</td><td><input type="text" name="ip"/></td>';
echo '<td>Db:</td><td><input type="text" name="db" size="6"/></td>';
echo '<td>User:</td><td><input type="text" name="user" size="6"/>';
echo 'Password:</td><td><input type="text" name="pass"/></td>';
echo '<td><input type="hidden" name="status" value="verify" /></td>';
echo '<td></tr><tr><td><input type=\'submit\' /></td><td>(leave host empty for localhost)</form></td>';
echo '</tr></table>';
}
bottom($start);
?>