This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. skb-liab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the GNU C Library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Define const $time_interval = 1; // (minute) // List the variables. $port1 = $HTTP_GET_VARS["port1"]; $port2 = $HTTP_GET_VARS["port2"]; $md5 = $HTTP_GET_VARS["md5"]; // print("port1: $port1
\n"); // print("port2: $port2
\n"); // print("md5: $md5
\n"); // Check the encoding, by calling port_encode // print("Doing: --./port_encode $port1 $port2 $md5--"); $check = system(EscapeShellCmd("./port_encode $port1 $port2 $md5"), $return); print("check:$check
\n"); if (0 == $return) { // print("OK - register in database
"); include("vaskeri.conf"); // Combine the two port values to one 16 bit value $status = 256*hexdec($port2) + hexdec($port1); $query_conn = mysql_pconnect($hostname, $user, $pass) or die ("Unable to connect to MySQL database at $hostname!"); $update_conn = mysql_pconnect($hostname, $user, $pass) or die ("Unable to connect to MySQL database at $hostname!"); $query = "SELECT id, time FROM machine"; $query_res = mysql_db_query($database, $query, $query_conn) or die ("Error in query: $query_res. " . mysql_error()); while (list($id, $time) = mysql_fetch_row($query_res)) { // Check the machine's bit $machine_on = $status & pow(2, $id); if ($machine_on) { // Machine is just started or still running, increase time $time = $time + $time_interval; $query = "UPDATE machine SET time=$time WHERE id=$id"; $update_res = mysql_db_query($database, $query, $update_conn) or die ("Error in query: $update_res. " . mysql_error()); } else { if ($time > 0) { // Machine just finished, set time to null $query = "UPDATE machine SET time=0 WHERE id=$id"; $update_res = mysql_db_query($database, $query, $update_conn) or die ("Error in query: $update_res. " . mysql_error()); } } } // while mysql_fetch_row } else { print("VALUE NOT OK - discard value
"); } ?>