Prefix Domain Translation -- UserInterface
No password supplied";
exit;
}
$link = mysql_connect($host, $user, $pass)
or die("Could not connect to mysql");
mysql_select_db($database) or die("Could not select database");
$query = "SELECT * FROM ".$table." WHERE name=\"".$admin."\" and passwd=\"".$passwd."\"";
$result = mysql_query($query) or die("Query failed: ".mysql_error());
$num_rows = mysql_num_rows($result);
if($num_rows>0)
$authorized="1";
else
echo "Authentication failed. No right to register a new domain.
";
mysql_free_result($result);
mysql_close($link);
}
$response_file = "rf".session_id();
$reply = "/tmp/".$response_file;
@system("mkfifo -m 666 ".$reply);
$new_line ="\n";
$fifo_command = ":get_domainprefix:";
$fifo_command = $fifo_command.$response_file.$new_line;
$fifo_command = $fifo_command.$domain_name;
if($domain_port)
$fifo_command = $fifo_command.":".$domain_port;
$fifo_command = $fifo_command.$new_line;
$fifo_command = $fifo_command.$authorized.$new_line.$new_line;
$fp = fopen($input_file, "w");
if(!$fp)
{
echo "Cannot open fifo
";
exit;
}
if( fwrite($fp, $fifo_command) == -1)
{
@unlink($reply);
@fclose($fp);
echo "fifo writing error
";
exit;
}
fclose($fp);
$fr = fopen($reply, "r");
if(!$fr)
{
@unlink($reply);
echo "Cannot open reply file";
exit;
}
$count = 1000;
$str = fread($fr, $count);
if(!$str)
{
@fclose($fr);
@unlink($reply);
echo "response fifo reading error";
exit;
}
$domain_code = "";
list($return_code, $description) = explode("|", $str);
if(!strcmp("$return_code","400 "))
{
echo "ERROR: Cannot read from fifo. Try again.
";
exit;
}
list($garbage1, $garbage2, $domain_code) = explode("=", $str);
list($domain_code, $garbage3) = explode("\n", $domain_code);
fclose($fr);
@unlink("/tmp/".$response_file);
if(!strcmp("$return_code","204 "))
{
$domain_code = "registration failed";
}
if(!strcmp("$return_code","203 "))
{
$domain_code = "not registered";
}
?>