|
|
1 |
<?PHP
|
|
|
2 |
|
|
|
3 |
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
4 |
Mass Delete
|
|
|
5 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
|
|
6 |
if($action == "mass_delete"){
|
|
|
7 |
|
|
|
8 |
if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
|
|
|
9 |
|
|
|
10 |
echoheader("options", "Delete News");
|
|
|
11 |
echo "<form method=post action=\"$PHP_SELF\"><table border=0 cellpading=0 cellspacing=0 width=100% height=100%><tr><td >
|
|
|
12 |
Are you sure you want to delete all selected news (<b>".count($selected_news)."</b>) ?<br><br>
|
|
|
13 |
<input type=button value=\" No \" onclick=\"javascript:document.location='$PHP_SELF?mod=editnews&action=list&source=$source'\"> <input type=submit value=\" Yes \">
|
|
|
14 |
<input type=hidden name=action value=\"do_mass_delete\">
|
|
|
15 |
<input type=hidden name=mod value=\"massactions\">
|
|
|
16 |
<input type=hidden name=source value=\"$source\">";
|
|
|
17 |
foreach($selected_news as $newsid){
|
|
|
18 |
echo "<input type=hidden name=selected_news[] value=\"$newsid\">\n";
|
|
|
19 |
}
|
|
|
20 |
echo "</td></tr></table></form>";
|
|
|
21 |
|
|
|
22 |
echofooter();
|
|
|
23 |
exit;
|
|
|
24 |
|
|
|
25 |
}
|
|
|
26 |
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
27 |
Do Mass Delete
|
|
|
28 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
|
|
29 |
elseif($action == "do_mass_delete"){
|
|
|
30 |
if(!$selected_news){ msg("error", "Error", "You have not specified any articles to be deleted", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
|
|
|
31 |
if($source == ""){ $news_file = "data/news.txt"; $comm_file = "data/comments.txt";}
|
|
|
32 |
elseif($source == "postponed"){ $news_file = "data/postponed_news.txt"; $comm_file = "data/comments.txt"; }
|
|
|
33 |
elseif($source == "unapproved"){ $news_file = "data/unapproved_news.txt"; $comm_file = "data/comments.txt"; }
|
|
|
34 |
else{ $news_file = "./data/archives/$source.news.arch"; $comm_file = "./data/archives/$source.comments.arch"; }
|
|
|
35 |
|
|
|
36 |
$deleted_articles = 0;
|
|
|
37 |
|
|
|
38 |
// Delete News
|
|
|
39 |
$old_db = file("$news_file");
|
|
|
40 |
$new_db = fopen("$news_file", w);
|
|
|
41 |
foreach($old_db as $old_db_line){
|
|
|
42 |
$old_db_arr = explode("|", $old_db_line);
|
|
|
43 |
if(@!in_array($old_db_arr[0], $selected_news)){
|
|
|
44 |
fwrite($new_db,"$old_db_line");
|
|
|
45 |
}
|
|
|
46 |
else
|
|
|
47 |
{
|
|
|
48 |
$have_perm = 0;
|
|
|
49 |
if(($member_db[1] == 1) or ($member_db[1] == 2)){$have_perm = 1;}
|
|
|
50 |
elseif($member_db[1] == 3 and $old_db_arr[1] == $member_db[2]) {$have_perm = 1;}
|
|
|
51 |
if(!$have_perm){ fwrite($new_db,"$old_db_line"); }
|
|
|
52 |
else{$deleted_articles ++;}
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
fclose($new_db);
|
|
|
56 |
|
|
|
57 |
// Delete Comments
|
|
|
58 |
$old_db = file("$comm_file");
|
|
|
59 |
$new_db = fopen("$comm_file", w);
|
|
|
60 |
foreach($old_db as $old_db_line){
|
|
|
61 |
$old_db_arr = explode("|", $old_db_line);
|
|
|
62 |
if(@!in_array($old_db_arr[0], $selected_news)){
|
|
|
63 |
fwrite($new_db,"$old_db_line");
|
|
|
64 |
}
|
|
|
65 |
else
|
|
|
66 |
{
|
|
|
67 |
$have_perm = 0;
|
|
|
68 |
if(($member_db[1] == 1) or ($member_db[1] == 2)){$have_perm = 1;}
|
|
|
69 |
elseif($member_db[1] == 3 and $old_db_arr[1] == $member_db[2]) {$have_perm = 1;}
|
|
|
70 |
if(!$have_perm){ fwrite($new_db,"$old_db_line"); }
|
|
|
71 |
else{ /* Do Nothing => Delete :) */ }
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
fclose($new_db);
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
if(count($selected_news) == $deleted_articles){ msg("info", "Deleted News", "All articles that you selected (<b>$deleted_articles</b>) were deleted", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
|
|
|
78 |
else{ msg("error", "Deleted News (some errors occured !!!)", "$deleted_articles of ".count($selected_news)." articles that you selected were deleted", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
|
|
|
79 |
}
|
|
|
80 |
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
81 |
Mass Approve
|
|
|
82 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
|
|
83 |
elseif($action == "mass_approve"){
|
|
|
84 |
if($member_db[1] != 1 and $member_db[1] != 2){ msg("error", "Error", "You do not have permissions for this action.", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
|
|
|
85 |
if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
|
|
|
86 |
$news_file = "./data/unapproved_news.txt";
|
|
|
87 |
|
|
|
88 |
$approved_articles = 0;
|
|
|
89 |
$old_db = file("$news_file");
|
|
|
90 |
$new_db = fopen("$news_file", w);
|
|
|
91 |
foreach($old_db as $old_db_line){
|
|
|
92 |
$old_db_arr = explode("|", $old_db_line);
|
|
|
93 |
if(@!in_array($old_db_arr[0], $selected_news)){
|
|
|
94 |
fwrite($new_db,"$old_db_line");
|
|
|
95 |
}
|
|
|
96 |
else
|
|
|
97 |
{
|
|
|
98 |
//Move the article to Active News
|
|
|
99 |
|
|
|
100 |
$all_active_db = file("$cutepath/data/news.txt");
|
|
|
101 |
$active_news_file = fopen("$cutepath/data/news.txt", "w");
|
|
|
102 |
@flock ($active_news_file,2);
|
|
|
103 |
|
|
|
104 |
fwrite($active_news_file,"$old_db_line");
|
|
|
105 |
foreach ($all_active_db as $active_line){ fwrite($active_news_file, "$active_line");}
|
|
|
106 |
@flock ($active_news_file,3);
|
|
|
107 |
fclose($active_news_file);
|
|
|
108 |
$approved_articles++;
|
|
|
109 |
}
|
|
|
110 |
}
|
|
|
111 |
fclose($new_db);
|
|
|
112 |
if(count($selected_news) == $approved_articles){ msg("info", "News Approved", "All articles that you selected ($approved_articles) were approved and are now active", "$PHP_SELF?mod=editnews&action=list"); }
|
|
|
113 |
else{ msg("error", "News Approved (with errors)", "$approved_articles of ".count($selected_news)." articles that you selected were approved", "$PHP_SELF?mod=editnews&action=list"); }
|
|
|
114 |
|
|
|
115 |
exit;
|
|
|
116 |
}
|
|
|
117 |
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
118 |
Mass Move to Cat
|
|
|
119 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
|
|
120 |
elseif($action == "mass_move_to_cat"){
|
|
|
121 |
|
|
|
122 |
if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
|
|
|
123 |
|
|
|
124 |
$orig_cat_lines = file("./data/category.db.php");
|
|
|
125 |
//only show allowed categories
|
|
|
126 |
$allowed_cats = array();
|
|
|
127 |
$cat_lines = array();
|
|
|
128 |
foreach($orig_cat_lines as $single_line){
|
|
|
129 |
$ocat_arr = explode("|", $single_line);
|
|
|
130 |
$cat[$ocat_arr[0]] = $ocat_arr[1];
|
|
|
131 |
if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){
|
|
|
132 |
$cat_lines[] = $single_line;
|
|
|
133 |
$allowed_cats[] = $ocat_arr[0];
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
echoheader("options", "Move Articles to Category");
|
|
|
140 |
|
|
|
141 |
echo "<form action=\"$PHP_SELF\" method=post><table border=0 cellpading=0 cellspacing=0 width=100% height=100%><tr><td >Move selected articles (<b>".count($selected_news)."</b>) to category:";
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
echo'<table width="80%" border="0" cellspacing="0" cellpadding="0" class="panel">';
|
|
|
145 |
|
|
|
146 |
foreach($cat_lines as $single_line){
|
|
|
147 |
$cat_arr = explode("|", $single_line);
|
|
|
148 |
|
|
|
149 |
echo"
|
|
|
150 |
|
|
|
151 |
<td style='font-size:10px;' valign=top>
|
|
|
152 |
<label for='cat{$cat_arr[0]}'>
|
|
|
153 |
<input $if_is_selected style='background-color:transparent;border:0px;' type=checkbox name='category[]' id='cat{$cat_arr[0]}' value='{$cat_arr[0]}'>$cat_arr[1]</label>";
|
|
|
154 |
$i++;
|
|
|
155 |
if ($i%4 == 0){ echo'<tr>'; }
|
|
|
156 |
}
|
|
|
157 |
echo"</tr>";
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
echo "</table>";
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
foreach($selected_news as $newsid){
|
|
|
165 |
echo "<input type=hidden name=selected_news[] value=\"$newsid\">";
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
echo "<br><input type=hidden name=action value=\"do_mass_move_to_cat\"><input type=hidden name=source value=\"$source\"><input type=hidden name=mod value=\"massactions\"> <input type=submit value=\"Move\"></td></tr></table></form>";
|
|
|
169 |
|
|
|
170 |
echofooter();
|
|
|
171 |
exit;
|
|
|
172 |
}
|
|
|
173 |
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
174 |
DO Mass Move to One Category
|
|
|
175 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
|
|
176 |
elseif($action == "do_mass_move_to_cat"){
|
|
|
177 |
|
|
|
178 |
if($member_db[1] != 1){ msg("error", "Error", "You do not have permissions for this action.", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
|
|
|
179 |
|
|
|
180 |
/////
|
|
|
181 |
///Format our categories variable
|
|
|
182 |
/////
|
|
|
183 |
|
|
|
184 |
|
|
|
185 |
$orig_cat_lines = file("./data/category.db.php");
|
|
|
186 |
//only show allowed categories
|
|
|
187 |
$allowed_cats = array();
|
|
|
188 |
$cat_lines = array();
|
|
|
189 |
foreach($orig_cat_lines as $single_line){
|
|
|
190 |
$ocat_arr = explode("|", $single_line);
|
|
|
191 |
$cat[$ocat_arr[0]] = $ocat_arr[1];
|
|
|
192 |
if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){
|
|
|
193 |
$cat_lines[] = $single_line;
|
|
|
194 |
$allowed_cats[] = $ocat_arr[0];
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
if( is_array($category) ){ //User has selected multiple categories
|
|
|
201 |
|
|
|
202 |
$nice_category = '';
|
|
|
203 |
$ccount = 0;
|
|
|
204 |
|
|
|
205 |
foreach($category as $ckey=>$cvalue){
|
|
|
206 |
if($ccount==0){ $nice_category = $cvalue; }//first cat
|
|
|
207 |
else{ $nice_category = $nice_category.','.$cvalue; }
|
|
|
208 |
|
|
|
209 |
$ccount++;
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
}else{ //Single or Not category
|
|
|
213 |
//don't format $nice_cats because we have not selected any.
|
|
|
214 |
$nice_category = $category;
|
|
|
215 |
}
|
|
|
216 |
|
|
|
217 |
if(!$selected_news){ msg("error", "Error", "You have not specified any artic |