<?
include ('template.inc');
include ('variable.inc');
/*
------------------------------------------------------------------------
* Nanou Morgan Web http://www.vmedia.com.au
* NoticeBoard version 1.1 Personal Web http://www.nanou.com.au
* January 2001 Email: nanou@nanou.com.au
________________________________________________________________________
*/
if(!isset($submit)){
$title= "Search The Community Noticeboard";
$content .="<P><font face=\"Helvetica,Arial,Geneva\" size=\"2\"><b>$title</b></font><br><br>
<blockquote>
<form action=\"$PHP_SELF\" method=\"post\">
<input type=\"text\" name=\"keyword\" size=\"35\"><br>
<input type=\"reset\" name=\"reset\" value=\"Clear Keyword\"> || <input type=\"submit\" name=\"submit\" value=\"Search\">
</form></blockquote>";
}
if( (isset($submit))&&(!isset($DELETE)) ){
$title= "Results of your search";
$content .="<form action=\"$PHP_SELF\" method=\"post\">";
$database = fopen ($noticeB_file, "r");
while (!(feof($database) ) ) {
$buffer = fgets($database, 4096);
$entry = explode("\t" , $buffer);
for ($k=0; $k<count($entry); $k++) {
$CategoryN = strtr($entry[2], "_", " ");
$AN =substr("$entry[0]",0,4);
$MOIS =substr("$entry[0]",4,2);
$JOUR =substr("$entry[0]",6,2);
$entry[6]=stripslashes($entry[6]);
if (eregi("$keyword","$entry[$k]") == true){ $NewContent .= "<font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><li><input type=\"radio\" name=\"DELETE\" value=\"$entry[1]\"><a href=\"../list.html?Category=$entry[2]&ID=$entry[1]\">$entry[6]</a> - <i>(Posted on : $JOUR-$MOIS-$AN)</i></li></font></font><br>";
break;}
}
}
if ($NewContent==""){$NoContent .= "<font face=\"Helvetica,Arial,Geneva\" size=\"2\">There was no match to your keyword</font>";}
$title= "You have searched for $keyword";
$content .="<P><font face=\"Helvetica,Arial,Geneva\" size=\"2\"><b>$title</b><br><br>
You can verify it is the right entry by clicking on the outline words<br></font>
<ul>$NewContent</blockquote>
<b>$NoContent </b>
<br><br><br><INPUT TYPE=\"button\" VALUE=\"Back\" onClick=\"history.go(-1)\"> || <input type=\"submit\" name=\"submit\" value=\"Delete Posting\"></form></ul><center><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b><a href=\"index.html\">Back To the Administration Entry Page</a></b></font></font></center>
</center></form></ul>
<hr size=2 width=80%>
<font face=\"Helvetica,Arial,Geneva\" size=\"2\"><b>You can perform a new search</b></font><br><br>
<form action=\"$PHP_SELF\" method=\"post\">
<input type=\"text\" name=\"keyword\" value=\"keyword\" size=\"35\"><br>
<input type=\"reset\" name=\"reset\" value=\"Clear Keyword\"> || <input type=\"submit\" name=\"submit\" value=\"Search\">
</form></blockquote>";
}
if( (isset($submit))&&(isset($DELETE)) ){
$database = fopen ($noticeB_file, "r");
flock($database,1);
while (!(feof($database) ) ) {
$buffer = fgets($database, 4096);
//clean old entries out
$entry = explode("\t" , $buffer);
for ($k=0; $k<count($entry); $k++) {
if ($entry[1] == $DELETE){
$SAVE_DATA="YES";
if($entry[8]){ unlink($path_pix."$entry[8]");}
unset($entry);
}
if(!isset($entry[0])){$NewContent .="";}else
{$NewContent .= ("$entry[0]\t$entry[1]\t$entry[2]\t$entry[3]\t$entry[4]\t$entry[5]\t$entry[6]\t$entry[7]\t$entry[8]\t$entry[9]\t$entry[10]\t$entry[11]\t$entry[12]\r");}
break;}
}
fclose($database);
if($SAVE_DATA =="YES"){
//Dummy initial filehandle to obtain lock via
$fd = fopen($noticeB_file,"w");
$locked = flock($fd,2); #Exclusive blocking lock
if (!$locked) {
print "Error: timeout obtaining lock"; exit;
}
//Second (actually used) filehandle
$database = fopen($noticeB_file ,"w");
if (!($database)){
print ("Error:\n");
print ("File '$database' could not be opened\n");
exit;
}
$NewCont = chop($NewContent);
$NewEntries = explode("\r" , $NewCont);
for ($x=0; $x<count($NewEntries); $x++) {
fputs($database, "$NewEntries[$x]");
}
fputs($database, "\n");
fclose($database);
fclose($fd);
}
$title= "Deleting this posting";
$content .="<p> This ID $DELETE has been deleted</p><br><br>
<center><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b><a href=\"index.html\">Back To the Administration Entry Page</a></b></font></font></center>";
}
/* parse to template */
$t = new Template( $path);
// create a template object named $t
$t->set_file( "MyFileHandle", "$template");
// set MyFileHandle = our template file
$t->set_var(array( "TITLE" => $title,
"FOOTER" => $bot,
"CONTENT" => $content));
// set template variable
$t->parse( "MyOutput", "MyFileHandle");
// set template variable MyOutput = parsed file
$t->p( "MyOutput"); // output the value of MyOutput (our parsed data)
?>
|