tweak year/agency modifer for queries
[contractdashboard.git] / cutenews / inc / editcomments.mdu
blob:a/cutenews/inc/editcomments.mdu -> blob:b/cutenews/inc/editcomments.mdu
<?PHP <?PHP
if($member_db[1] > 2){ msg("error", "Access Denied", "You don't have permission to edit comments"); } if($member_db[1] > 2){ msg("error", "Access Denied", "You don't have permission to edit comments"); }
// ******************************************************************************** // ********************************************************************************
// Edit Comment // Edit Comment
// ******************************************************************************** // ********************************************************************************
if($action == "editcomment") if($action == "editcomment")
{ {
if($source == ""){ $all_comments = file("./data/comments.txt"); } if($source == ""){ $all_comments = file("./data/comments.txt"); }
else{ $all_comments = file("./data/archives/${source}.comments.arch"); } else{ $all_comments = file("./data/archives/${source}.comments.arch"); }
foreach($all_comments as $comment_line) foreach($all_comments as $comment_line)
{ {
$comment_line_arr = explode("|>|", $comment_line); $comment_line_arr = explode("|>|", $comment_line);
if($comment_line_arr[0] == $newsid) if($comment_line_arr[0] == $newsid)
{ {
$comment_arr = explode("||", $comment_line_arr[1]); $comment_arr = explode("||", $comment_line_arr[1]);
foreach($comment_arr as $single_comment) foreach($comment_arr as $single_comment)
{ {
$single_arr = explode("|", $single_comment); $single_arr = explode("|", $single_comment);
if($comid == $single_arr[0]) if($comid == $single_arr[0])
{ {
break; break;
} }
} }
} }
} }
$single_arr[4] = str_replace("<br />","\n",$single_arr[4]); $single_arr[4] = str_replace("<br />","\n",$single_arr[4]);
$comdate = date("D, d F Y h:i:s", $single_arr[0]); $comdate = date("D, d F Y h:i:s", $single_arr[0]);
echo"<html> echo"<html>
<head> <head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\"> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">
<title>Edit user</title> <title>Edit user</title>
<style type=\"text/css\"> <style type=\"text/css\">
<!-- <!--
SELECT, option, textarea, input { SELECT, option, textarea, input {
BORDER-RIGHT: #808080 1px dotted; BORDER-RIGHT: #808080 1px dotted;
BORDER-TOP: #808080 1px dotted; BORDER-TOP: #808080 1px dotted;
BORDER-BOTTOM: #808080 1px dotted; BORDER-BOTTOM: #808080 1px dotted;
BORDER-LEFT: #808080 1px dotted; BORDER-LEFT: #808080 1px dotted;
COLOR: #000000; COLOR: #000000;
FONT-SIZE: 11px; FONT-SIZE: 11px;
FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffff } FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffff }
TD {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;} TD {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;}
BODY {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 3pt;} BODY {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 3pt;}
.header { font-size : 16px; font-weight: bold; color: #808080; font-family: verdana; text-decoration: none; } .header { font-size : 16px; font-weight: bold; color: #808080; font-family: verdana; text-decoration: none; }
--> -->
</style> </style>
</head> </head>
<body bgcolor=\"#FFFFFF\"> <body bgcolor=\"#FFFFFF\">
<form method=post action=\"$PHP_SELF\"> <form method=post action=\"$PHP_SELF\">
<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"> <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
<td width=\"1108\" height=\"8%\" colspan=\"2\"> <td width=\"1108\" height=\"8%\" colspan=\"2\">
<div class=header>Edit Comment</div> <div class=header>Edit Comment</div>
<tr> <tr>
<td height=20 valign=middle width=\"102\" bgcolor=\"#F9F8F7\"> <td height=20 valign=middle width=\"102\" bgcolor=\"#F9F8F7\">
Poster Poster
<td height=20 valign=middle width=\"1002\" bgcolor=\"#F9F8F7\"> <td height=20 valign=middle width=\"1002\" bgcolor=\"#F9F8F7\">
<input type=text name=poster value=\"$single_arr[1]\"> <input type=text name=poster value=\"$single_arr[1]\">
</tr> </tr>
<tr> <tr>
<td height=20 valign=middle valign=\"top\" width=\"102\"> <td height=20 valign=middle valign=\"top\" width=\"102\">
Email Email
<td height=20 valign=middle width=\"1002\"> <td height=20 valign=middle width=\"1002\">
<input type=text name=mail value=\"$single_arr[2]\"> <input type=text name=mail value=\"$single_arr[2]\">
</tr> </tr>
<tr> <tr>
<td height=20 valign=middle valign=\"top\" width=\"102\" bgcolor=\"#F9F8F7\"> <td height=20 valign=middle valign=\"top\" width=\"102\" bgcolor=\"#F9F8F7\">
IP IP
<td height=20 valign=middle width=\"1002\" bgcolor=\"#F9F8F7\"> <td height=20 valign=middle width=\"1002\" bgcolor=\"#F9F8F7\">
<a href=\"http://www.ripe.net/perl/whois?searchtext=$single_arr[3]\" target=_blank title=\"Get more information about this ip\">$single_arr[3]</a> &nbsp; <a href=\"http://www.ripe.net/perl/whois?searchtext=$single_arr[3]\" target=_blank title=\"Get more information about this ip\">$single_arr[3]</a> &nbsp;
<a href=\"$PHP_SELF?mod=ipban&action=quickadd&add_ip=$single_arr[3]\">[ban this ip]</a> <a href=\"$PHP_SELF?mod=ipban&action=quickadd&add_ip=$single_arr[3]\">[ban this ip]</a>
</tr> </tr>
<tr> <tr>
<td height=20 valign=middle valign=\"top\" width=\"102\"> <td height=20 valign=middle valign=\"top\" width=\"102\">
Date Date
<td height=20 valign=middle width=\"1002\"> <td height=20 valign=middle width=\"1002\">
$comdate $comdate
</tr> </tr>
<tr> <tr>
<td height=20 valign=middle width=\"102\" bgcolor=\"#F9F8F7\"> <td height=20 valign=middle width=\"102\" bgcolor=\"#F9F8F7\">
Comments&nbsp; Comments&nbsp;
<td height=20 valign=middle width=\"1002\" bgcolor=\"#F9F8F7\"> <td height=20 valign=middle width=\"1002\" bgcolor=\"#F9F8F7\">
<textarea rows=\"8\" name=\"comment\" cols=\"45\">$single_arr[4]</textarea> <textarea rows=\"8\" name=\"comment\" cols=\"45\">$single_arr[4]</textarea>
</tr> </tr>
<tr> <tr>
<td valign=\"top\" width=\"1104\" colspan=\"2\"> <td valign=\"top\" width=\"1104\" colspan=\"2\">
<p align=\"left\"><br /> <p align=\"left\"><br />
<input type=submit value=\"Save Changes\" accesskey=\"s\">&nbsp; <input type=button value=Cencel onClick=\"window.close();\" accesskey=\"c\"> <input type=submit value=\"Save Changes\" accesskey=\"s\">&nbsp; <input type=button value=Cencel onClick=\"window.close();\" accesskey=\"c\">
<input type=hidden name=mod value=editcomments> <input type=hidden name=mod value=editcomments>
<input type=hidden name=newsid value=$newsid> <input type=hidden name=newsid value=$newsid>
<input type=hidden name=comid value=$comid> <input type=hidden name=comid value=$comid>
<input type=hidden name=source value=$source> <input type=hidden name=source value=$source>
<input type=hidden name=action value=doeditcomment> <input type=hidden name=action value=doeditcomment>
</tr> </tr>
</table> </table>
</form> </form>
</body> </body>
</html>"; </html>";
} }
// ******************************************************************************** // ********************************************************************************
// Do Save Comment // Do Save Comment
// ******************************************************************************** // ********************************************************************************
elseif($action == "doeditcomment") elseif($action == "doeditcomment")
{ {
if(!$poster and !$deletecomment){ echo"<br /><br><br />The poster can not be blank !!!"; exit(); } if(!$poster and !$deletecomment){ echo"<br /><br><br />The poster can not be blank !!!"; exit(); }
if($mail == "" and !$deletecomment){ $mail = "none"; } if($mail == "" and !$deletecomment){ $mail = "none"; }
if($poster == "" and !$deletecomment){ $poster = "Anonymous"; } if($poster == "" and !$deletecomment){ $poster = "Anonymous"; }
if($comment == "" and !$deletecomment){ die("comment can not be blank"); } if($comment == "" and !$deletecomment){ die("comment can not be blank"); }
$comment = str_replace("\r\n","<br />",$comment); $comment = str_replace("\r\n","<br />",$comment);
$comment = str_replace("|","I",$comment); $comment = str_replace("|","I",$comment);
if($source == ""){ $news_file = "./data/news.txt"; $com_file = "./data/comments.txt"; } 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";} else{ $news_file = "./data/archives/$source.news.arch"; $com_file = "./data/archives/$source.comments.arch";}
$old_com = file("$com_file"); $old_com = file("$com_file");
$new_com = fopen("$com_file","w"); $new_com = fopen("$com_file","w");
foreach($old_com as $line) foreach($old_com as $line)
{ {
$line_arr = explode("|>|",$line); $line_arr = explode("|>|",$line);
if($line_arr[0] == $newsid) if($line_arr[0] == $newsid)
{ {
fwrite($new_com,"$line_arr[0]|>|"); fwrite($new_com,"$line_arr[0]|>|");
$comments = explode("||", $line_arr[1]); $comments = explode("||", $line_arr[1]);
foreach($comments as $single_comment) foreach($comments as $single_comment)
{ {
$single_comment = trim($single_comment); $single_comment = trim($single_comment);
$comment_arr = explode("|", $single_comment); $comment_arr = explode("|", $single_comment);
if($comment_arr[0] == $comid and $comment_arr[0] != "" and $delcomid != "all") if($comment_arr[0] == $comid and $comment_arr[0] != "" and $delcomid != "all")
{ {
fwrite($new_com,"$comment_arr[0]|$poster|$mail|$comment_arr[3]|$comment||"); 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){ elseif($delcomid[$comment_arr[0]] != 1 and $comment_arr[0] != "" and $delcomid[all] != 1){
fwrite($new_com,"$single_comment||"); fwrite($new_com,"$single_comment||");
} }
} }
fwrite($new_com,"\n"); fwrite($new_com,"\n");
} }
else{ fwrite($new_com, "$line"); } 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"); } 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"); } 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"<br /><br /><br /><br /><center><b>Comment is saved."; } else{ echo"<br /><br /><br /><br /><center><b>Comment is saved."; }
} }
?> ?>