Login   Register  
PHP Classes
elePHPant
Icontem

File: del_list.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of nanou morgan  >  noticeboard  >  del_list.html  >  Download  
File: del_list.html
Role: ???
Content type: text/plain
Description: Admin folder..To delete an entry via the list of category
Class: noticeboard
Author: By
Last change:
Date: 2001-02-11 09:34
Size: 5,703 bytes
 

Contents

Class file image Download
<?

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
________________________________________________________________________

*/

//$Categ=$Category;
$CategoryN = strtr($Category, "_", " ");
$title ="$CategoryN";
$today = date("Ymd");


if(!isset($submit)){

$content .="<P><font face=\"Helvetica,Arial,Geneva\"><font size=\"2\"><b>$title</b><br><br>
You can verify that it is the right entry by clicking on the outline words<br></font></font>
<FORM ACTION=\"$PHP_SELF\" METHOD=POST><ul>";
$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++) {
	
	$AN =substr("$entry[0]",0,4);
	$MOIS =substr("$entry[0]",4,2);
	$JOUR =substr("$entry[0]",6,2);
						
	$Duration =$entry[0] + $entry[12];
	$digit =substr("$Duration",4,2);
	if($digit >12){	$YEAR = substr("$Duration",0,4)  +1;
					$MONTH= $digit -12;
	$EndTime = "$YEAR"."0"."$MONTH".substr("$Duration",6,2);
	}
	else{$EndTime =$Duration;}
	
	
	if ($today > $EndTime){ 
	
			$SAVE_NEW="YES";
			if($entry[8]){ unlink($path_pix."$entry[8]");}
			unset($entry); 
							}
	else{

		$cat = explode("," , $entry[2]);
		for ($i=0; $i<count($cat); $i++) {
				if ($cat[$i] == "$Category"){ 
				$VERIFY ="YES";
				$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=$Category&ID=$entry[1]\">$entry[6]</a> - <i>(Posted on : $JOUR-$MOIS-$AN)</i></li></font></font><br>";
					}
				}
		 }
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 ($VERIFY !="YES"){$content.= "There are no entry under this category. <br>";}
		
$content .="<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>";
		


		if($SAVE_NEW =="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($fd); 


		
			}
	
}


if(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($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) 


?>