3){ msg("error", "Access Denied", "You don't have permission to edit news"); } // ******************************************************************************** // List all news available for editing // ******************************************************************************** if($action == "list") { if (!$source) { echoheader("editnews","Edit News"); } else { echoheader("editnews","Edit Archives"); } $cat_lines = @file("./data/category.db.php"); foreach($cat_lines as $single_line){ $cat_arr = explode("|", $single_line); $cat[$cat_arr[0]] = $cat_arr[1]; } // How Many News to show on one page if($news_per_page == ""){ $news_per_page = 21; } $all_db = array(); if($source == ""){ $all_db = file("./data/news.txt"); } else{ $all_db = file("./data/archives/${source}.news.arch"); } // choose only needed news items if ($category != "" or $author != "" or $member_db[1] == 3){ foreach($all_db as $raw_line){ $raw_arr = explode("|", $raw_line); if (($category == "" or $raw_arr[6] == $category) and ($author == "" or $raw_arr[1] == $author) and( $member_db[1] != 3 or $raw_arr[1] == $member_db[2] )){ $all_db_tmp[] = $raw_line; } } $all_db = $all_db_tmp; } // Prelist Entries $flag = 1; if($start_from == "0"){ $start_from = ""; } $i = $start_from; $entries_showed = 0; if(!empty($all_db)){ // Three lines to type, Three lines to sort alphabetically (by actual date in this case) asort($all_db); reset($all_db); $all_db = array_reverse($all_db); foreach ($all_db as $line){ if($j < $start_from){ $j++; continue; } $i++; $item_db = explode("|",$line); $itemdate = date("d/m/y",$item_db[0]); if($flag == 1){ $bg="alternate"; $flag = 0; } else {$bg = "alternate2"; $flag = 1;} if(strlen($item_db[2]) > 74){ $title = substr($item_db[2],0,70)." ..."; } $title = stripslashes( preg_replace(array("'\|'", "'\"'", "'\''"), array("I", """, "'"), $item_db[2]) ); $entries .= " $title "; $count_comments = countComments($item_db[0], $source); if($count_comments == 0){$entries .= "$count_comments";} else{$entries .= "$count_comments";} $entries .= "       "; if($item_db[6] == ""){ $my_cat = "---"; } elseif($cat[$item_db[6]] == ""){ $my_cat = "ID $item_db[6]"; } else{ $my_cat = $cat[$item_db[6]]; } $entries .= "$my_cat  $itemdate $item_db[1] "; $entries_showed ++; if($i >= $news_per_page + $start_from){ break; } }//foreach news line } // End prelisting $all_count_news = count($all_db); if($category != ""){ $cat_msg = "Category: $cat[$category];"; } if($source != ""){ $news_lines = file("./data/archives/$source.news.arch"); $count = count($news_lines); $last = $count-1; $first_news_arr = explode("|", $news_lines[$last]); $last_news_arr = explode("|", $news_lines[0]); $first_timestamp = $first_news_arr[0]; $last_timestamp = $last_news_arr[0]; $source_msg = "Archive: ". date("d M Y",$first_timestamp) ." - ". date("d M Y",$last_timestamp) .";"; } /////////////////////////////////////////// // Options Bar echo"
Showing $entries_showed articles from a total of $all_count_news; $cat_msg $source_msg show options 
"; // End Options Bar //////////////////////////////////////////////////////////////////////////////// Showing List of News if($entries_showed == 0){ echo"
- No articles found -
"; } else{ echo<< JSCRIPT; echo" HTML; } echo<<
Title Comments  Category  Date Author "; } ##################################################################################################################### echo $entries; ##################################################################################################################### if($start_from > 0) { $previous = $start_from - $news_per_page; $npp_nav .= "<< Previous"; //$tmp = 1; } // pagination if(count($all_db) > $news_per_page){ $npp_nav .= " [ "; $enpages_count = @ceil($all_count_news/$news_per_page); $enpages_start_from = 0; $enpages = ""; for($j=1;$j<=$enpages_count;$j++){ if($enpages_start_from != $start_from){ $enpages .= "$j "; } else{ $enpages .= " $j "; } $enpages_start_from += $news_per_page; } $npp_nav .= $enpages; $npp_nav .= " ] "; } // pagination if(count($all_db) > $i) { $how_next = count($all_db) - $i; if($how_next > $news_per_page){ $how_next = $news_per_page; } $npp_nav .= "Next $how_next >>"; } if($entries_showed != 0){ echo<<  
$npp_nav With selected:
HTML; echofooter(); } // ******************************************************************************** // Edit News Article // ******************************************************************************** elseif($action == "editnews") { // Show The Article for Editing if($source == ""){ $all_db = file("./data/news.txt"); } else{ $all_db = file("./data/archives/$source.news.arch"); } $found = FALSE; foreach ($all_db as $line) { $item_db=explode("|",$line); if ($id == $item_db[0]){ $found = TRUE; break;} }//foreach news line $have_perm = 0; if(($member_db[1] == 1) or ($member_db[1] == 2)){$have_perm = 1;} elseif($member_db[1] == 3 and $item_db[1] == $member_db[2]) {$have_perm = 1;} if(!$have_perm){ msg("error", "NO Access", "You dont have access for this action", "$PHP_SELF?mod=editnews&action=list"); } if (!$found){ msg("error","Error !!!","The selected news item can not be found."); } $newstime = date("D, d F Y h:i:s",$item_db[0]); $item_db[2] = stripslashes( preg_replace(array("'\|'", "'\"'", "'\''"), array("I", """, "'"), $item_db[2]) ); $item_db[3] = replace_news("admin", $item_db[3]); $item_db[4] = replace_news("admin", $item_db[4]); echoheader("editnews","Edit "$item_db[2]""); $aorg_currentdate = date("D, d F Y H:i:s",$item_db[0]); if ($config_update_edit_time == "yes") { // if automatic dateupdates is set in config, change date to current time. $aorg_currentdate = date("D, d F Y H:i:s"); } echo"

posted by $item_db[1], timestamp: $item_db[0].

Extra Options

Convert newlines to <br />
Use HTML

Delete this article

"; echo""; // ADD Hack: Edit music block echo" "; if($config_use_avatar == "yes"){ echo" "; } // XFields Call $xfieldsaction = "list"; $xfieldsid = $id; include("xfields.mdu"); // End XFields Call echo"




[ image / bbcode / smilies: "; echo insertSmilies('short', 4); echo " ]

"; echo" [ image / bbcode / smilies: "; echo insertSmilies('full', 4); echo " ]

"; echo"

 

"; // Show the Comments for Editing if($source == ""){ $all_comments_db = file("./data/comments.txt"); } else{ $all_comments_db = file("./data/archives/${source}.comments.arch"); } $found_newsid = FALSE; foreach($all_comments_db as $comment_line) { $comment_line = trim($comment_line); $comments_arr = explode("|>|",$comment_line); if($comments_arr[0] == $id) {//if these are comments for our story $found_newsid = TRUE; if ($comments_arr[1] != "") { echo""; $flag = 1; $different_posters = explode("||",$comments_arr[1]); foreach($different_posters as $individual_comment) { if($flag == 1){ $bg = "alternate"; $flag = 0;} else{$bg = "alternate2"; $flag = 1;} $comment_arr = explode("|",$individual_comment); $comtime = date("D, d F Y h:i:s",$comment_arr[0]); if($comment_arr[1]) { if(strlen($comment_arr[1]) > 25){ $comment_arr[1] = substr($comment_arr[1],0,22)."..."; } echo""; }//if not blank }//foreach comment echo"

Comments

Name submitted by commenter

Date the comment was written

$comment_arr[1] $comtime

delete all?

"; break;//foreach comment line }//if there are any comments else { echo"

No Comments

"; } }//if these are comments for our story }//foreach comments line if($found_newsid == FALSE){ echo"

No Comments

"; } echofooter(); } // ******************************************************************************** // Do Edit News // ******************************************************************************** elseif($action == "doeditnews") { if(trim($title) == "" and $ifdelete != "yes"){ msg("error","Error !!!","The title can not be blank.", "javascript:history.go(-1)"); } if($short_story == "" and $ifdelete != "yes"){ msg("error","Error !!!","The story can not be blank.", "javascript:history.go(-1)"); } if($if_convert_new_lines == "yes"){ $n_to_br = TRUE; } if($if_use_html == "yes"){ $use_html = TRUE; } $short_story = replace_news("add", rtrim($short_story), $n_to_br, $use_html); $full_story = replace_news("add", rtrim($full_story), $n_to_br, $use_html); // ADD Hack: Replace music block $listening_to = replace_news("add", rtrim($listening_to), $n_to_br, $use_html); // END Hack: Replace music $title = stripslashes( preg_replace(array("'\|'", "'\n'", "''"), array("I", "
", ""), $title) ); $avatar = stripslashes( preg_replace(array("'\|'", "'\n'", "''"), array("I", "
", ""), $avatar) ); $aorg_newdate = strtotime($aorg_newdate); 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";} // XFields Call if ($ifdelete != "yes") { $xfieldsaction = "init"; $xfieldsid = $id; include("xfields.mdu"); } // End XFields Call $old_db = file("$news_file"); $new_db = fopen("$news_file", w); foreach($old_db as $old_db_line){ $old_db_arr = explode("|", $old_db_line); if($id != $old_db_arr[0]){ fwrite($new_db,"$old_db_line"); } else { $have_perm = 0; 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;} if($have_perm){ // XFields Call $xfieldsaction = ($ifdelete == "yes" ? "delete" : "save"); $xfieldsid = $id; include("xfields.mdu"); // End XFields Call if($ifdelete != "yes") { $okchanges = TRUE; // ADD Hack: a) DATE updates if changed. b) MUSIC also updated. fwrite($new_db,"$aorg_newdate|$old_db_arr[1]|$title|$short_story|$full_story|$editavatar|$category|$listening_to|||||\n"); // END Hack DATE + MUSIC update. // ADD Hack: Reassign comments/xfields if the news date has changed if ($aorg_newdate != $old_db_arr[0]) { // Comments Updater $aj_update_file = file("$com_file"); $aj_update_file_updated = str_replace($old_db_arr[0], $aorg_newdate, $aj_update_file); $aj_update_file_updated = implode("", $aj_update_file_updated); $updatehandler = fopen("$com_file", "w"); fwrite($updatehandler, "$aj_update_file_updated"); fclose($updatehandler); $commentsupdated = TRUE; // END Commentsupdate // Xfields2 Updater $aj_xf_file = file("./data/xfieldsdata.txt"); $aj_xf_file_ud = str_replace($old_db_arr[0], $aorg_newdate, $aj_xf_file); $aj_xf_file_ud = implode("", $aj_xf_file_ud); $aj_xf_handler = fopen("./data/xfieldsdata.txt", "w"); fwrite($aj_xf_handler, "$aj_xf_file_ud"); fclose($aj_xf_handler); $xfieldsupdated = TRUE; // END Xfieldsupdate } else { $commentsupdated = FALSE; } // END Hack: Reassign } else { $okdeleted = TRUE; $all_file = file("$com_file"); $new_com=fopen("$com_file","w"); foreach($all_file as $line) { $line_arr = explode("|>|",$line); if($line_arr[0] == $id){ $okdelcom = TRUE; } else{ fwrite($new_com,"$line"); } } fclose($new_com); } }else{ fwrite($new_db,"$old_db_line"); $no_permission = TRUE; } } } fclose($new_db); if($no_permission){ msg("error", "NO Access", "You dont have access for this action", "$PHP_SELF?mod=editnews&action=list"); } if($okdeleted and $okdelcom){ msg("info","News Deleted","The news item successfully was deleted.
If there were comments for this article they are also deleted."); } if($okdeleted and !$okdelcom){ msg("info","News Deleted","The news item successfully was deleted.
If there were comments for this article they are also deleted.
But can not delete comments of this article !!!"); } elseif($okchanges && !$commentsupdated){ msg("info","Changes Saved","The changes were successfully saved", "$PHP_SELF?mod=editnews&action=editnews&id=$aorg_newdate&source=$source"); } elseif($okchanges && $commentsupdated && $xfieldsupdated){ msg("info","Changes Saved","The changes were successfully saved, and the comments/xfields reassigned sucessfully.", "$PHP_SELF?mod=editnews&action=editnews&id=$aorg_newdate&source=$source"); } else{ msg("error","Error !!!","The news item can not be found or there is an error with the news database file."); } } ?>