<?
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
________________________________________________________________________
*/
$today = date("Ymd");
if ( (!isset($DELETE)) || ($submit =="Go") ){
$title ="List Most Recent Postings";
$content .="<P><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>$title</b></font><br>
<FORM NAME=\"Newlist\" ACTION=\"$PHP_SELF\" METHOD=POST>
Display the latest entries that are <select name=\"Length\" size=\"1\">";
if ( (!isset($Length)) ||($Length ==01) ){$Length=01;$content .= "<option value=\"01\" selected>1 month</option><option value=\"02\">2 month</option><option value=\"03\">3 month</option>";}
elseif ($Length ==02){$content .= "<option value=\"01\">1 month</option><option value=\"02\" selected>2 month</option><option value=\"03\">3 month</option>";}
elseif ($Length ==03){$content .= "<option value=\"01\">1 month</option><option value=\"02\">2 month</option><option value=\"03\" selected>3 month</option>";}
$content .="</select> Old. <input type=\"submit\" name=\"submit\" value=\"Go\"><br><hr><ul>
<FORM NAME=\"Newlist\" ACTION=\"$PHP_SELF\" METHOD=POST>
";
$lines = file ($noticeB_file);
rsort($lines);
$i=0;
for ($L=0; $L< count ($lines);$L++){
$entry = explode("\t" , $lines[$L]);
for ($k=0; $k<count($entry); $k++) {
$digitM =substr("$today",4,2);
$YYYY =substr("$today",0,4);
$digit=$digitM - $Length;
if($digit <= 00){ $YEAR = $YYYY - 1;$MONT= 12 + $digit;}
else {$YEAR = $YYYY; $MONT= $digit;}
if ($MONT <10){$MONTH ="0".$digit;} else {$MONTH =$MONT;}
$EndTime = "$YEAR"."$MONTH".date("d");
if ($entry[0] > $EndTime ){
$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]);
$content.= "<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>";
$i++;break;}
else {$content.="";}
}
}
if (($i ==0)&&($Length==01)){$content.="There are no entries that are one month old";}
if (($i ==0)&&($Length==02)){$content.="There are no entries that are two months old";}
if (($i ==0)&&($Length==03)){$content.="There are no entries that are three months old";}
if (!isset($Length)){ $content .= "";}
else{$content .= "<br><br><INPUT TYPE=\"button\" VALUE=\"Back\" onClick=\"history.go(-1)\"> || <input type=\"submit\" name=\"submit\" value=\"Delete Posting\"><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>";}
$content.="</ul></form>";
}
if ( ($submit =="Delete Posting")&&(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)
?>
|