Location: PHPKode > projects > TxtForum > txtforum/library/editing.php
<?php 
if (!defined("SKIN")) die("Hack attempt!<br />You can't access directly to this file");
global $tid;
if (file_exists("data/$tid.data/locked.txt") AND !$arraj[a]) {
	die("You can't edit, topic is locked!");
} 
$msg_id=$_POST['msg_id'];
$file = "data/$msg_id.txt";
if (is_file($file)) {
	list($id,$user,$ip,$sub,$ctime,$text,$loc,$browser,$os,$o_smile,$o_reg,$status,$sig) = file("$file");
	$user = rtrim($user); #let's rtrim all variable that will be used
} 
else { die("This post has been deleted!$msg_id"); }
# FUNCIONS START
function detect_user_sig($user) {
	include ("users/$user.php");
	return $r_sig;
}
# FUNCIONS END
if (($arraj[u]==(strtolower($user)) AND $arraj[r]==yes) OR ${arraj}[a]) { #if it's same User and if_admin
	$file_edit = "data/$msg_id.txt";
	$edit_time_format='M d Y, H:i:s';
	$datum_e = date("$edit_time_format");
	// Write to file edited by line
	$edited = "<font color='black'><b><small>[ Edited by $b_user at $datum_e ]</b></small></font>";
	$edit_file = "data/$tid.data/edited-$msg_id.txt";
	$fp2 = fopen($edit_file, "w");
	fwrite($fp2, "$edited");
	fclose($fp2);
	if ($_POST[show_signature]==on) { #if "Show signature" is checked
		if($o_reg==1) { #if it's registed user
			$sig=detect_user_sig($user); #find users sig tru the function
#			echo "$user's old signature is $sig";
		}
		else { $sig =''; } #the user is not register therfore he can't have signature
	}
	else { $sig=''; } # 2.If "show sig" is unckecked then remove signature
	$text_2_write = "$id$user\n$ip$subject\n$ctime$msg\n$loc$browser$os$o_smile$o_reg$status$sig";  #file() gives as \n so we don't need to add \n after every variable
	$fp = fopen($file_edit, "w") or die("I can't open $file_edit file");
	fwrite($fp, "$text_2_write");
	fclose($fp);
	header("Location:view_topic.php?pid=$msg_id");
}
else { die ("You don't have permission to edit this message!"); }
?>
Return current item: TxtForum