|
|
1 |
<?PHP
|
|
|
2 |
|
|
|
3 |
if($member_db[1] > 2){ msg("error", "Access Denied", "You don't have permission to edit comments"); }
|
|
|
4 |
// ********************************************************************************
|
|
|
5 |
// Edit Comment
|
|
|
6 |
// ********************************************************************************
|
|
|
7 |
if($action == "editcomment")
|
|
|
8 |
{
|
|
|
9 |
if($source == ""){ $all_comments = file("./data/comments.txt"); }
|
|
|
10 |
else{ $all_comments = file("./data/archives/${source}.comments.arch"); }
|
|
|
11 |
|
|
|
12 |
foreach($all_comments as $comment_line)
|
|
|
13 |
{
|
|
|
14 |
$comment_line_arr = explode("|>|", $comment_line);
|
|
|
15 |
if($comment_line_arr[0] == $newsid)
|
|
|
16 |
{
|
|
|
17 |
$comment_arr = explode("||", $comment_line_arr[1]);
|
|
|
18 |
foreach($comment_arr as $single_comment)
|
|
|
19 |
{
|
|
|
20 |
$single_arr = explode("|", $single_comment);
|
|
|
21 |
if($comid == $single_arr[0])
|
|
|
22 |
{
|
|
|
23 |
break;
|
|
|
24 |
}
|
|
|
25 |
}
|
|
|
26 |
}
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
$single_arr[4] = str_replace("<br />","\n",$single_arr[4]);
|
|
|
30 |
$comdate = date("D, d F Y h:i:s", $single_arr[0]);
|
|
|
31 |
|
|
|
32 |
echo"<html>
|
|
|
33 |
<head>
|
|
|
34 |
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">
|
|
|
35 |
<title>Edit user</title>
|
|
|
36 |
<style type=\"text/css\">
|
|
|
37 |
<!--
|
|
|
38 |
SELECT, option, textarea, input {
|
|
|
39 |
BORDER-RIGHT: #808080 1px dotted;
|
|
|
40 |
BORDER-TOP: #808080 1px dotted;
|
|
|
41 |
BORDER-BOTTOM: #808080 1px dotted;
|
|
|
42 |
BORDER-LEFT: #808080 1px dotted;
|
|
|
43 |
COLOR: #000000;
|
|
|
44 |
FONT-SIZE: 11px;
|
|
|
45 |
FONT-FAMILY: Verdana; BACKGROUND-COLOR: #ffffff }
|
|
|
46 |
TD {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt;}
|
|
|
47 |
BODY {text-decoration: none; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 3pt;}
|
|
|
48 |
.header { font-size : 16px; font-weight: bold; color: #808080; font-family: verdana; text-decoration: none; }
|
|
|
49 |
-->
|
|
|
50 |
</style>
|
|
|
51 |
</head>
|
|
|
52 |
<body bgcolor=\"#FFFFFF\">
|
|
|
53 |
<form method=post action=\"$PHP_SELF\">
|
|
|
54 |
<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
|
|
|
55 |
<td width=\"1108\" height=\"8%\" colspan=\"2\">
|
|
|
56 |
<div class=header>Edit Comment</div>
|
|
|
57 |
<tr>
|
|
|
58 |
<td height=20 valign=middle width=\"102\" bgcolor=\"#F9F8F7\">
|
|
|
59 |
Poster
|
|
|
60 |
<td height=20 valign=middle width=\"1002\" bgcolor=\"#F9F8F7\">
|
|
|
61 |
<input type=text name=poster value=\"$single_arr[1]\">
|
|
|
62 |
</tr>
|
|
|
63 |
|
|
|
64 |
<tr>
|
|
|
65 |
<td height=20 valign=middle valign=\"top\" width=\"102\">
|
|
|
66 |
Email
|
|
|
67 |
<td height=20 valign=middle width=\"1002\">
|
|
|
68 |
<input type=text name=mail value=\"$single_arr[2]\">
|
|
|
69 |
</tr>
|
|
|
70 |
|
|
|
71 |
<tr>
|
|
|
72 |
<td height=20 valign=middle valign=\"top\" width=\"102\" bgcolor=\"#F9F8F7\">
|
|
|
73 |
IP
|
|
|
74 |
<td height=20 valign=middle width=\"1002\" bgcolor=\"#F9F8F7\">
|
|
|
75 |
<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>
|
|
|
76 |
<a href=\"$PHP_SELF?mod=ipban&action=quickadd&add_ip=$single_arr[3]\">[ban this ip]</a>
|
|
|
77 |
</tr>
|
|
|
78 |
|
|
|
79 |
<tr>
|
|
|
80 |
<td height=20 valign=middle valign=\"top\" width=\"102\">
|
|
|
81 |
Date
|
|
|
82 |
<td height=20 valign=middle width=\"1002\">
|
|
|
83 |
$comdate
|
|
|
84 |
</tr>
|
|
|
85 |
<tr>
|
|
|
86 |
<td height=20 valign=middle width=\"102\" bgcolor=\"#F9F8F7\">
|
|
|
87 |
Comments
|
|
|
88 |
<td height=20 valign=middle width=\"1002\" bgcolor=\"#F9F8F7\">
|
|
|
89 |
<textarea rows=\"8\" name=\"comment\" cols=\"45\">$single_arr[4]</textarea>
|
|
|
90 |
</tr>
|
|
|
91 |
<tr>
|
|
|
92 |
<td valign=\"top\" width=\"1104\" colspan=\"2\">
|
|
|
93 |
<p align=\"left\"><br />
|
|
|
94 |
<input type=submit value=\"Save Changes\" accesskey=\"s\"> <input type=button value=Cencel onClick=\"window.close();\" accesskey=\"c\">
|
|
|
95 |
<input type=hidden name=mod value=editcomments>
|
|
|
96 |
<input type=hidden name=newsid value=$newsid>
|
|
|
97 |
<input type=hidden name=comid value=$comid>
|
|
|
98 |
<input type=hidden name=source value=$source>
|
|
|
99 |
<input type=hidden name=action value=doeditcomment>
|
|
|
100 |
</tr>
|
|
|
101 |
</table>
|
|
|
102 |
</form>
|
|
|
103 |
</body>
|
|
|
104 |
</html>";
|
|
|
105 |
}
|
|
|
106 |
// ********************************************************************************
|
|
|
107 |
// Do Save Comment
|
|
|
108 |
// ********************************************************************************
|
|
|
109 |
elseif($action == "doeditcomment")
|
|
|
110 |
{
|
|
|
111 |
if(!$poster and !$deletecomment){ echo"<br /><br><br />The poster can not be blank !!!"; exit(); }
|
|
|
112 |
if($mail == "" and !$deletecomment){ $mail = "none"; }
|
|
|
113 |
if($poster == "" and !$deletecomment){ $poster = "Anonymous"; }
|
|
|
114 |
if($comment == "" and !$deletecomment){ die("comment can not be blank"); }
|
|
|
115 |
|
|
|
116 |
$comment = str_replace("\r\n","<br />",$comment);
|
|
|
117 |
$comment = str_replace("|","I",$comment);
|
|
|
118 |
|
|
|
119 |
if($source == ""){ $news_file = "./data/news.txt"; $com_file = "./data/comments.txt"; }
|
|
|
120 |
else{ $news_file = "./data/archives/$source.news.arch"; $com_file = "./data/archives/$source.comments.arch";}
|
|
|
121 |
|
|
|
122 |
$old_com = file("$com_file");
|
|
|
123 |
$new_com = fopen("$com_file","w");
|
|
|
124 |
|
|
|
125 |
foreach($old_com as $line)
|
|
|
126 |
{
|
|
|
127 |
$line_arr = explode("|>|",$line);
|
|
|
128 |
if($line_arr[0] == $newsid)
|
|
|
129 |
{
|
|
|
130 |
fwrite($new_com,"$line_arr[0]|>|");
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
$comments = explode("||", $line_arr[1]);
|
|
|
134 |
foreach($comments as $single_comment)
|
|
|
135 |
{
|
|
|
136 |
$single_comment = trim($single_comment);
|
|
|
137 |
$comment_arr = explode("|", $single_comment);
|
|
|
138 |
if($comment_arr[0] == $comid and $comment_arr[0] != "" and $delcomid != "all")
|
|
|
139 |
{
|
|
|
140 |
fwrite($new_com,"$comment_arr[0]|$poster|$mail|$comment_arr[3]|$comment||");
|
|
|
141 |
}
|
|
|
142 |
elseif($delcomid[$comment_arr[0]] != 1 and $comment_arr[0] != "" and $delcomid[all] != 1){
|
|
|
143 |
fwrite($new_com,"$single_comment||");
|
|
|
144 |
}
|
|
|
145 |
}
|
|
|
146 |
fwrite($new_com,"\n");
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
}
|
|
|
150 |
else{ fwrite($new_com, "$line"); }
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
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"); }
|
|
|
154 |
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"); }
|
|
|
155 |
else{ echo"<br /><br /><br /><br /><center><b>Comment is saved."; }
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
?> |