2){ msg("error", "Access Denied", "You don't have permission to edit comments"); } // ******************************************************************************** // Edit Comment // ******************************************************************************** if($action == "editcomment") { if($source == ""){ $all_comments = file("./data/comments.txt"); } else{ $all_comments = file("./data/archives/${source}.comments.arch"); } foreach($all_comments as $comment_line) { $comment_line_arr = explode("|>|", $comment_line); if($comment_line_arr[0] == $newsid) { $comment_arr = explode("||", $comment_line_arr[1]); foreach($comment_arr as $single_comment) { $single_arr = explode("|", $single_comment); if($comid == $single_arr[0]) { break; } } } } $single_arr[4] = str_replace("
","\n",$single_arr[4]); $comdate = date("D, d F Y h:i:s", $single_arr[0]); echo" Edit user
Edit Comment
Poster
Email
IP $single_arr[3]
Date $comdate
Comments 


 

"; } // ******************************************************************************** // Do Save Comment // ******************************************************************************** elseif($action == "doeditcomment") { if(!$poster and !$deletecomment){ echo"


The poster can not be blank !!!"; exit(); } if($mail == "" and !$deletecomment){ $mail = "none"; } if($poster == "" and !$deletecomment){ $poster = "Anonymous"; } if($comment == "" and !$deletecomment){ die("comment can not be blank"); } $comment = str_replace("\r\n","
",$comment); $comment = str_replace("|","I",$comment); if($source == ""){ $news_file = "./data/news.txt"; $com_file = "./data/comments.txt"; } else{ $news_file = "./data/archives/$source.news.arch"; $com_file = "./data/archives/$source.comments.arch";} $old_com = file("$com_file"); $new_com = fopen("$com_file","w"); foreach($old_com as $line) { $line_arr = explode("|>|",$line); if($line_arr[0] == $newsid) { fwrite($new_com,"$line_arr[0]|>|"); $comments = explode("||", $line_arr[1]); foreach($comments as $single_comment) { $single_comment = trim($single_comment); $comment_arr = explode("|", $single_comment); if($comment_arr[0] == $comid and $comment_arr[0] != "" and $delcomid != "all") { fwrite($new_com,"$comment_arr[0]|$poster|$mail|$comment_arr[3]|$comment||"); } elseif($delcomid[$comment_arr[0]] != 1 and $comment_arr[0] != "" and $delcomid[all] != 1){ fwrite($new_com,"$single_comment||"); } } fwrite($new_com,"\n"); } else{ fwrite($new_com, "$line"); } } if(isset($deletecomment) and $delcomid[all] == 1){ msg("info", "Comments Deleted", "All comments were deleted.", "$PHP_SELF?mod=editnews&action=editnews&id=$newsid&source=$source"); } elseif(isset($deletecomment) and isset($delcomid)){ msg("info", "Comment Deleted", "The selected comment(s) has been deleted.", "$PHP_SELF?mod=editnews&action=editnews&id=$newsid&source=$source"); } else{ echo"



Comment is saved."; } } ?>