tweak year/agency modifer for queries
[contractdashboard.git] / cutenews / inc / massactions.mdu
blob:a/cutenews/inc/massactions.mdu -> blob:b/cutenews/inc/massactions.mdu
<?PHP <?PHP
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mass Delete Mass Delete
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
if($action == "mass_delete"){ if($action == "mass_delete"){
if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
echoheader("options", "Delete News"); echoheader("options", "Delete News");
echo "<form method=post action=\"$PHP_SELF\"><table border=0 cellpading=0 cellspacing=0 width=100% height=100%><tr><td > echo "<form method=post action=\"$PHP_SELF\"><table border=0 cellpading=0 cellspacing=0 width=100% height=100%><tr><td >
Are you sure you want to delete all selected news (<b>".count($selected_news)."</b>) ?<br><br> Are you sure you want to delete all selected news (<b>".count($selected_news)."</b>) ?<br><br>
<input type=button value=\" No \" onclick=\"javascript:document.location='$PHP_SELF?mod=editnews&action=list&source=$source'\"> &nbsp; <input type=submit value=\" Yes \"> <input type=button value=\" No \" onclick=\"javascript:document.location='$PHP_SELF?mod=editnews&action=list&source=$source'\"> &nbsp; <input type=submit value=\" Yes \">
<input type=hidden name=action value=\"do_mass_delete\"> <input type=hidden name=action value=\"do_mass_delete\">
<input type=hidden name=mod value=\"massactions\"> <input type=hidden name=mod value=\"massactions\">
<input type=hidden name=source value=\"$source\">"; <input type=hidden name=source value=\"$source\">";
foreach($selected_news as $newsid){ foreach($selected_news as $newsid){
echo "<input type=hidden name=selected_news[] value=\"$newsid\">\n"; echo "<input type=hidden name=selected_news[] value=\"$newsid\">\n";
} }
echo "</td></tr></table></form>"; echo "</td></tr></table></form>";
echofooter(); echofooter();
exit; exit;
} }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do Mass Delete Do Mass Delete
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
elseif($action == "do_mass_delete"){ elseif($action == "do_mass_delete"){
if(!$selected_news){ msg("error", "Error", "You have not specified any articles to be deleted", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if(!$selected_news){ msg("error", "Error", "You have not specified any articles to be deleted", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
if($source == ""){ $news_file = "data/news.txt"; $comm_file = "data/comments.txt";} if($source == ""){ $news_file = "data/news.txt"; $comm_file = "data/comments.txt";}
elseif($source == "postponed"){ $news_file = "data/postponed_news.txt"; $comm_file = "data/comments.txt"; } elseif($source == "postponed"){ $news_file = "data/postponed_news.txt"; $comm_file = "data/comments.txt"; }
elseif($source == "unapproved"){ $news_file = "data/unapproved_news.txt"; $comm_file = "data/comments.txt"; } elseif($source == "unapproved"){ $news_file = "data/unapproved_news.txt"; $comm_file = "data/comments.txt"; }
else{ $news_file = "./data/archives/$source.news.arch"; $comm_file = "./data/archives/$source.comments.arch"; } else{ $news_file = "./data/archives/$source.news.arch"; $comm_file = "./data/archives/$source.comments.arch"; }
$deleted_articles = 0; $deleted_articles = 0;
// Delete News // Delete News
$old_db = file("$news_file"); $old_db = file("$news_file");
$new_db = fopen("$news_file", w); $new_db = fopen("$news_file", w);
foreach($old_db as $old_db_line){ foreach($old_db as $old_db_line){
$old_db_arr = explode("|", $old_db_line); $old_db_arr = explode("|", $old_db_line);
if(@!in_array($old_db_arr[0], $selected_news)){ if(@!in_array($old_db_arr[0], $selected_news)){
fwrite($new_db,"$old_db_line"); fwrite($new_db,"$old_db_line");
} }
else else
{ {
$have_perm = 0; $have_perm = 0;
if(($member_db[1] == 1) or ($member_db[1] == 2)){$have_perm = 1;} if(($member_db[1] == 1) or ($member_db[1] == 2)){$have_perm = 1;}
elseif($member_db[1] == 3 and $old_db_arr[1] == $member_db[2]) {$have_perm = 1;} elseif($member_db[1] == 3 and $old_db_arr[1] == $member_db[2]) {$have_perm = 1;}
if(!$have_perm){ fwrite($new_db,"$old_db_line"); } if(!$have_perm){ fwrite($new_db,"$old_db_line"); }
else{$deleted_articles ++;} else{$deleted_articles ++;}
} }
} }
fclose($new_db); fclose($new_db);
// Delete Comments // Delete Comments
$old_db = file("$comm_file"); $old_db = file("$comm_file");
$new_db = fopen("$comm_file", w); $new_db = fopen("$comm_file", w);
foreach($old_db as $old_db_line){ foreach($old_db as $old_db_line){
$old_db_arr = explode("|", $old_db_line); $old_db_arr = explode("|", $old_db_line);
if(@!in_array($old_db_arr[0], $selected_news)){ if(@!in_array($old_db_arr[0], $selected_news)){
fwrite($new_db,"$old_db_line"); fwrite($new_db,"$old_db_line");
} }
else else
{ {
$have_perm = 0; $have_perm = 0;
if(($member_db[1] == 1) or ($member_db[1] == 2)){$have_perm = 1;} if(($member_db[1] == 1) or ($member_db[1] == 2)){$have_perm = 1;}
elseif($member_db[1] == 3 and $old_db_arr[1] == $member_db[2]) {$have_perm = 1;} elseif($member_db[1] == 3 and $old_db_arr[1] == $member_db[2]) {$have_perm = 1;}
if(!$have_perm){ fwrite($new_db,"$old_db_line"); } if(!$have_perm){ fwrite($new_db,"$old_db_line"); }
else{ /* Do Nothing => Delete :) */ } else{ /* Do Nothing => Delete :) */ }
} }
} }
fclose($new_db); fclose($new_db);
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"); } 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"); }
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"); } 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"); }
} }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mass Approve Mass Approve
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
elseif($action == "mass_approve"){ elseif($action == "mass_approve"){
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"); } 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"); }
if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
$news_file = "./data/unapproved_news.txt"; $news_file = "./data/unapproved_news.txt";
$approved_articles = 0; $approved_articles = 0;
$old_db = file("$news_file"); $old_db = file("$news_file");
$new_db = fopen("$news_file", w); $new_db = fopen("$news_file", w);
foreach($old_db as $old_db_line){ foreach($old_db as $old_db_line){
$old_db_arr = explode("|", $old_db_line); $old_db_arr = explode("|", $old_db_line);
if(@!in_array($old_db_arr[0], $selected_news)){ if(@!in_array($old_db_arr[0], $selected_news)){
fwrite($new_db,"$old_db_line"); fwrite($new_db,"$old_db_line");
} }
else else
{ {
//Move the article to Active News //Move the article to Active News
$all_active_db = file("$cutepath/data/news.txt"); $all_active_db = file("$cutepath/data/news.txt");
$active_news_file = fopen("$cutepath/data/news.txt", "w"); $active_news_file = fopen("$cutepath/data/news.txt", "w");
@flock ($active_news_file,2); @flock ($active_news_file,2);
fwrite($active_news_file,"$old_db_line"); fwrite($active_news_file,"$old_db_line");
foreach ($all_active_db as $active_line){ fwrite($active_news_file, "$active_line");} foreach ($all_active_db as $active_line){ fwrite($active_news_file, "$active_line");}
@flock ($active_news_file,3); @flock ($active_news_file,3);
fclose($active_news_file); fclose($active_news_file);
$approved_articles++; $approved_articles++;
} }
} }
fclose($new_db); fclose($new_db);
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"); } 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"); }
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"); } 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"); }
exit; exit;
} }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mass Move to Cat Mass Move to Cat
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
elseif($action == "mass_move_to_cat"){ elseif($action == "mass_move_to_cat"){
if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
$orig_cat_lines = file("./data/category.db.php"); $orig_cat_lines = file("./data/category.db.php");
//only show allowed categories //only show allowed categories
$allowed_cats = array(); $allowed_cats = array();
$cat_lines = array(); $cat_lines = array();
foreach($orig_cat_lines as $single_line){ foreach($orig_cat_lines as $single_line){
$ocat_arr = explode("|", $single_line); $ocat_arr = explode("|", $single_line);
$cat[$ocat_arr[0]] = $ocat_arr[1]; $cat[$ocat_arr[0]] = $ocat_arr[1];
if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){ if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){
$cat_lines[] = $single_line; $cat_lines[] = $single_line;
$allowed_cats[] = $ocat_arr[0]; $allowed_cats[] = $ocat_arr[0];
} }
} }
echoheader("options", "Move Articles to Category"); echoheader("options", "Move Articles to Category");
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:"; 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:";
echo'<table width="80%" border="0" cellspacing="0" cellpadding="0" class="panel">'; echo'<table width="80%" border="0" cellspacing="0" cellpadding="0" class="panel">';
foreach($cat_lines as $single_line){ foreach($cat_lines as $single_line){
$cat_arr = explode("|", $single_line); $cat_arr = explode("|", $single_line);
echo" echo"
<td style='font-size:10px;' valign=top> <td style='font-size:10px;' valign=top>
<label for='cat{$cat_arr[0]}'> <label for='cat{$cat_arr[0]}'>
<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>"; <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>";
$i++; $i++;
if ($i%4 == 0){ echo'<tr>'; } if ($i%4 == 0){ echo'<tr>'; }
} }
echo"</tr>"; echo"</tr>";
echo "</table>"; echo "</table>";
foreach($selected_news as $newsid){ foreach($selected_news as $newsid){
echo "<input type=hidden name=selected_news[] value=\"$newsid\">"; echo "<input type=hidden name=selected_news[] value=\"$newsid\">";
} }
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\">&nbsp;<input type=submit value=\"Move\"></td></tr></table></form>"; 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\">&nbsp;<input type=submit value=\"Move\"></td></tr></table></form>";
echofooter(); echofooter();
exit; exit;
} }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DO Mass Move to One Category DO Mass Move to One Category
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
elseif($action == "do_mass_move_to_cat"){ elseif($action == "do_mass_move_to_cat"){
if($member_db[1] != 1){ msg("error", "Error", "You do not have permissions for this action.", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if($member_db[1] != 1){ msg("error", "Error", "You do not have permissions for this action.", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
///// /////
///Format our categories variable ///Format our categories variable
///// /////
$orig_cat_lines = file("./data/category.db.php"); $orig_cat_lines = file("./data/category.db.php");
//only show allowed categories //only show allowed categories
$allowed_cats = array(); $allowed_cats = array();
$cat_lines = array(); $cat_lines = array();
foreach($orig_cat_lines as $single_line){ foreach($orig_cat_lines as $single_line){
$ocat_arr = explode("|", $single_line); $ocat_arr = explode("|", $single_line);
$cat[$ocat_arr[0]] = $ocat_arr[1]; $cat[$ocat_arr[0]] = $ocat_arr[1];
if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){ if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){
$cat_lines[] = $single_line; $cat_lines[] = $single_line;
$allowed_cats[] = $ocat_arr[0]; $allowed_cats[] = $ocat_arr[0];
} }
} }
if( is_array($category) ){ //User has selected multiple categories if( is_array($category) ){ //User has selected multiple categories
$nice_category = ''; $nice_category = '';
$ccount = 0; $ccount = 0;
foreach($category as $ckey=>$cvalue){ foreach($category as $ckey=>$cvalue){
if($ccount==0){ $nice_category = $cvalue; }//first cat if($ccount==0){ $nice_category = $cvalue; }//first cat
else{ $nice_category = $nice_category.','.$cvalue; } else{ $nice_category = $nice_category.','.$cvalue; }
$ccount++; $ccount++;
} }
}else{ //Single or Not category }else{ //Single or Not category
//don't format $nice_cats because we have not selected any. //don't format $nice_cats because we have not selected any.
$nice_category = $category; $nice_category = $category;
} }
if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
if($source == ""){ $news_file = "./data/news.txt";} if($source == ""){ $news_file = "./data/news.txt";}
elseif($source == "postponed"){ $news_file = "data/postponed_news.txt"; } elseif($source == "postponed"){ $news_file = "data/postponed_news.txt"; }
elseif($source == "unapproved"){ $news_file = "data/unapproved_news.txt"; } elseif($source == "unapproved"){ $news_file = "data/unapproved_news.txt"; }
else{ $news_file = "./data/archives/$source.news.arch"; } else{ $news_file = "./data/archives/$source.news.arch"; }
$moved_articles = 0; $moved_articles = 0;
$old_db = file("$news_file"); $old_db = file("$news_file");
$new_db = fopen("$news_file", w); $new_db = fopen("$news_file", w);
foreach($old_db as $old_db_line){ foreach($old_db as $old_db_line){
$old_db_arr = explode("|", $old_db_line); $old_db_arr = explode("|", $old_db_line);
if(@!in_array($old_db_arr[0], $selected_news)){ if(@!in_array($old_db_arr[0], $selected_news)){
fwrite($new_db,"$old_db_line"); fwrite($new_db,"$old_db_line");
} }
else else
{ {
$have_perm = 0; $have_perm = 0;
if(($member_db[1] == 1) or ($member_db[1] == 2)){$have_perm = 1;} if(($member_db[1] == 1) or ($member_db[1] == 2)){$have_perm = 1;}
elseif($member_db[1] == 3 and $old_db_arr[1] == $member_db[2]) {$have_perm = 1;} elseif($member_db[1] == 3 and $old_db_arr[1] == $member_db[2]) {$have_perm = 1;}
if(!$have_perm){ fwrite($new_db,"$old_db_line"); } if(!$have_perm){ fwrite($new_db,"$old_db_line"); }
else{ else{
fwrite($new_db,"$old_db_arr[0]|$old_db_arr[1]|$old_db_arr[2]|$old_db_arr[3]|$old_db_arr[4]|$old_db_arr[5]|$nice_category|||\n"); fwrite($new_db,"$old_db_arr[0]|$old_db_arr[1]|$old_db_arr[2]|$old_db_arr[3]|$old_db_arr[4]|$old_db_arr[5]|$nice_category|||\n");
$moved_articles ++; $moved_articles ++;
} }
} }
} }
fclose($new_db); fclose($new_db);
if(count($selected_news) == $moved_articles){ msg("info", "News Moved", "All articles that you selected ($moved_articles) were moved to the specified category", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if(count($selected_news) == $moved_articles){ msg("info", "News Moved", "All articles that you selected ($moved_articles) were moved to the specified category", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
else{ msg("error", "News Moved (with errors)", "$moved_articles of ".count($selected_news)." articles that you selected were moved to the specified category", "$PHP_SELF?mod=editnews&action=list&source=$source"); } else{ msg("error", "News Moved (with errors)", "$moved_articles of ".count($selected_news)." articles that you selected were moved to the specified category", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
} }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mass Archive Mass Archive
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
elseif($action == "mass_archive"){ elseif($action == "mass_archive"){
if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
if($source != ""){ msg("error", "Error", "These news are already archived or are in postpone queue", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if($source != ""){ msg("error", "Error", "These news are already archived or are in postpone queue", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
echoheader("options", "Send News To Archive"); echoheader("options", "Send News To Archive");
echo "<form method=post action=\"$PHP_SELF\"><table border=0 cellpading=0 cellspacing=0 width=100% height=100%><tr><td > echo "<form method=post action=\"$PHP_SELF\"><table border=0 cellpading=0 cellspacing=0 width=100% height=100%><tr><td >
Are you sure you want to send all selected news (<b>".count($selected_news)."</b>) to the archive ?<br><br> Are you sure you want to send all selected news (<b>".count($selected_news)."</b>) to the archive ?<br><br>
<input type=button value=\" No \" onclick=\"javascript:document.location='$PHP_SELF?mod=editnews&action=list&source=$source'\"> &nbsp; <input type=submit value=\" Yes \"> <input type=button value=\" No \" onclick=\"javascript:document.location='$PHP_SELF?mod=editnews&action=list&source=$source'\"> &nbsp; <input type=submit value=\" Yes \">
<input type=hidden name=action value=\"do_mass_archive\"> <input type=hidden name=action value=\"do_mass_archive\">
<input type=hidden name=mod value=\"massactions\">"; <input type=hidden name=mod value=\"massactions\">";
foreach($selected_news as $newsid){ foreach($selected_news as $newsid){
echo"<input type=hidden name=selected_news[] value=\"$newsid\">\n"; echo"<input type=hidden name=selected_news[] value=\"$newsid\">\n";
} }
echo"</td></tr></table></form>"; echo"</td></tr></table></form>";
echofooter(); echofooter();
exit; exit;
} }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DO Mass Send To Archive DO Mass Send To Archive
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
elseif($action == "do_mass_archive"){ elseif($action == "do_mass_archive"){
if($member_db[1] != 1){ msg("error", "Access Denied", "You can not perfor this action if you are not admin"); } if($member_db[1] != 1){ msg("error", "Access Denied", "You can not perfor this action if you are not admin"); }
if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); } if(!$selected_news){ msg("error", "Error", "You have not specified any articles", "$PHP_SELF?mod=editnews&action=list&source=$source"); }
if(!is_writable("./data/archives/")){ msg("error", "Error", "The ./data/archives/ directory is not writable, CHMOD it to 777"); } if(!is_writable("./data/archives/")){ msg("error", "Error", "The ./data/archives/ directory is not writable, CHMOD it to 777"); }
$news_file = "./data/news.txt"; $news_file = "./data/news.txt";
$comm_file = "./data/comments.txt"; $comm_file = "./data/comments.txt";
$prepeared_for_archive = array(); $prepeared_for_archive = array();
$prepeared_comments_for_archive = array(); $prepeared_comments_for_archive = array();
$archived_news = 0; $archived_news = 0;
// Prepear the news for Archiving // Prepear the news for Archiving
$old_db = file("$news_file"); $old_db = file("$news_file");
$new_db = fopen("$news_file", w); $new_db = fopen("$news_file", w);
foreach($old_db as $old_db_line){ foreach($old_db as $old_db_line){
$old_db_arr = explode("|", $old_db_line); $old_db_arr = explode("|", $old_db_line);
if(@!in_array($old_db_arr[0], $selected_news)){ if(@!in_array($old_db_arr[0], $selected_news)){