aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/web/register.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--web/register.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/web/register.php b/web/register.php
new file mode 100644
index 0000000..70f42a6
--- /dev/null
+++ b/web/register.php
@@ -0,0 +1,61 @@
1<?php
2//////////////////////////////////////////////////////////////////////////////
3// register.php //
4// (C) 2008, Fly-man- //
5// This file contains the registration of a simulator to the database //
6// and checks if the simulator is new in the database or a reconnected one //
7// //
8// If the simulator is old, check if the nextcheck date > registration //
9// When the date is older, make a request to the Parser to grab new data //
10//////////////////////////////////////////////////////////////////////////////
11
12include("../config/os_modules_mysql.php");
13//establish connection to master db server
14mysql_connect ($DB_HOST, $DB_USER, $DB_PASSWORD);
15mysql_select_db ($DB_NAME);
16
17$hostname = $_GET['host'];
18$port = $_GET['port'];
19$service = $_GET['service'];
20
21if ($hostname != "" && $port != "" && $service == "online")
22{
23 // Check if there is already a database row for this host
24 $checkhost = mysql_query("SELECT register FROM hostsregister WHERE " .
25 "host = '" . mysql_real_escape_string($hostname) . "' AND " .
26 "port = '" . mysql_real_escape_string($port) . "'");
27
28 // Get the request time as a timestamp for later
29 $timestamp = $_SERVER['REQUEST_TIME'];
30
31 // if greater than 1, check the nextcheck date
32 if (mysql_num_rows($checkhost) > 0)
33 {
34 $update = "UPDATE hostsregister SET " .
35 "register = '" . mysql_real_escape_string($timestamp) . "', " .
36 "nextcheck = '0', checked = '0', " .
37 "failcounter = '0' " .
38 "WHERE host = '" . mysql_real_escape_string($hostname) . "' AND " .
39 "port = '" . mysql_real_escape_string($port) . "'";
40
41 $runupdate = mysql_query($update);
42 }
43 else
44 {
45 $register = "INSERT INTO hostsregister VALUES ".
46 "('" . mysql_real_escape_string($hostname) . "', " .
47 "'" . mysql_real_escape_string($port) . "', " .
48 "'" . mysql_real_escape_string($timestamp) . "', 0, 0, 0)";
49
50 $runupdate = mysql_query($register);
51 }
52}
53elseif ($hostname != "" && $port != "" && $service = "offline")
54{
55 $delete = "DELETE FROM hostsregister " .
56 "WHERE host = '" . mysql_real_escape_string($hostname) . "' AND " .
57 "port = '" . mysql_real_escape_string($port) . "'";
58
59 $rundelete = mysql_query($delete);
60}
61?>