<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

include_once("auth.php");

## mysql verbindung aufbauen
db_connect($db_host, $db_user, $db_pass);
## /mysql verbindung aufbauen

$id = db_query("select seriennummer, lizenz, ablauf, hwaddr, ip, version from register");
$werte = db_fetch_array($id);
$ip = $werte["ip"];
$hwaddr = $werte["hwaddr"];
if ((istleer($ip)) || (istleer($hwaddr)))
	{
	 echo "Fehler: Registrierung nicht möglich. Bitte confixx_counterscript.pl ausführen\n";
	 db_close();
	 exit();
	}
$serverid = bin2hex("$seriennummer:-:$hwaddr:-:$ip:-:");

$request = 'sn=' . urlencode($seriennummer);
$request .= '&key=' . urlencode($snkey);
$request .= '&serverid=' . urlencode($serverid);
$request .= '&auto=1';

$header = "POST /register2.php HTTP/1.1\r\n";
$header .= "Host: register.confixx.de\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "Content-length: " . strlen($request) . "\r\n";
$header .= "Connection: close\r\n\r\n";

$fp = fsockopen('register.confixx.de', 80);
if ($fp)
	{
	 fputs($fp, $header . $request);
	 while (!feof($fp))
		{
		 $line = fgets($fp, 512);
		 if (substr($line, 0, 6) == "FEHLER") $fehler = trim(str_replace("FEHLER:", "", $line));
		 if (($start == 1) || ($line == "CONFIXX-REGOK\n"))
			{
			 $start = 1;
			 if (substr($line, 0, 3) == "SN:") $sn = trim(str_replace("SN:", "", $line));
			 if (substr($line, 0, 4) == "KEY:") $key = trim(str_replace("KEY:", "", $line));
			 if (substr($line, 0, 7) == "ABLAUF:") $ablauf = trim(str_replace("ABLAUF:", "", $line));
			 if (substr($line, 0, 8) == "VERSION:") $ver = trim(str_replace("VERSION:", "", $line));
			 if (substr($line, 0, 7) == "LIZENZ:") $lizenz = trim(str_replace("LIZENZ:", "", $line));
			}
		}
	} else die("FEHLER:could not connect to register.confixx.de");

if (!istleer($fehler))
	{
	 echo "FEHLER:$fehler";
	 exit();
	}

$lizenz = str_replace("-", "\n", $lizenz);
$lizenz .= "\n";

db_query("update register set lizenz = '$lizenz', ablauf = '$ablauf', seriennummer = '$seriennummer', version = '$ver'");
echo "OK\n";
?>
