<html>
<head>
<link rel="stylesheet" type="text/css" href="bswstyle.css">
</head>
<?php
include('functions.php');
$name=$_POST["name"];
$msg=$_POST["message"];
$comment=$_POST["comment"];
$capacha =rand(100000,1000000);
$displ="<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">
<table align=\"center\"><input type=\"hidden\" name=\"name\"value=\"$name\">
<input type=\"hidden\" name=\"message\"value=\"$msg\">
<input type=\"hidden\" name=\"comment\"value=\"$comment\">
<tr><td width=\"150\"></td><td align=\center\" class=\"capacha\"><input class=\"capacha\" style=\"text-align:center\"type=\"text\"name=\"capacha\" value=\"$capacha\"></td></tr>
<tr><td width=\"150\" align=\"right\">Write the number:</td><td align=\"center\"><input style=\"text-align:center\"type=\"text\" name=\"secur\"></td></tr>
</table><table align=\"center\">
<tr><th width=\"300\"align=\"right\"><input class=\"bar\"type=\"submit\" name=\"submit\" value=\"Submit \"></tr></th>
</table></form>";
echo $displ;
if($_POST["secur"]!=$_POST["capacha"]){exit;}
?>
<?php
global $sf;
//include('functions.php');
$sf=capacha();
while($_POST["secur"]!=$_POST["capacha"]){
echo "incorrect try again";exit;}
$File = "count.txt";
$handle = fopen($File, 'r+') ;
$data = fread($handle, 512) ;
//Actully get the count from the file
$count = $data + 1;
fseek($handle, 0) ;
fwrite($handle, $count) ;
fclose($handle) ;
//**********************Do HTML********************
global $File,$name,$msg,$comment,$string;
$File = "topics/$count.html";
$Handle = fopen($File, 'w');
$name=$_POST["name"];
$msg=$_POST["message"];
$comment=$_POST["comment"];
dohtml($msg,$name,$comment,$string);
fwrite($Handle, $string);
fseek($Handle, 0) ;
fclose($Handle);
//header("location:board.php");
//**************************************************
//*************** Do abstract **********************
$File = "message.html";
$handle1=fopen($File, 'r');
$fsize=filesize($File);
$data1 = fread($handle1, $fsize);
$dataa=explode("<td>",$data1);
fclose($handle1);
?><?php
$File="message.html";
$Handle = fopen($File, 'wb');
$abst=substr($comment,0,150);
doabst($abst,$count,$name,$msg,$string1);
array_unshift($dataa,$string1);
$newmsg=implode("<td>",$dataa);
//*****************************************************
fwrite($Handle, $newmsg);
fclose($Handle);
header("location:index.php");
?>