3){ msg("error", "Access Denied", "You don't have permission to edit news"); } // ******************************************************************************** // List all news available for editing // ******************************************************************************** if($action == "list") { echoheader("editnews","Edit News"); $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)){ 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="#F7F6F4"; $flag = 0; } else {$bg = "#FFFFFF"; $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 total $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; } if(count($all_db) > $i) { if($tmp){ $npp_nav .= "  ||  ";} $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 News"); echo"
"; if($config_use_avatar == "yes"){ echo" "; } echo" "; $flag = 1; $different_posters = explode("||",$comments_arr[1]); foreach($different_posters as $individual_comment) { if($flag == 1){ $bg = "bgcolor=#F7F6F4"; $flag = 0;} else{$bg = ""; $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"
Info. Posted on $newstime by $item_db[1]
Title
Avatar URL    (optional)
Category

Short Story


[insert image]

[quick tags]

"; echo insertSmilies('short', 4); echo"


Full Story
(optional)

[insert image]
[quick tags]

"; echo insertSmilies('full', 4); echo"
    [options]   [delete]
 
Comments"; // 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"  ".strtolower(Poster)." ".strtolower(Date)."
  $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); $title = stripslashes( preg_replace(array("'\|'", "'\n'", "''"), array("I", "
", ""), $title) ); $avatar = stripslashes( preg_replace(array("'\|'", "'\n'", "''"), array("I", "
", ""), $avatar) ); 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";} $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){ if($ifdelete != "yes") { $okchanges = TRUE; fwrite($new_db,"$old_db_arr[0]|$old_db_arr[1]|$title|$short_story|$full_story|$editavatar|$category||\n"); } 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){ msg("info","Changes Saved","The changes were successfully saved", "$PHP_SELF?mod=editnews&action=editnews&id=$id&source=$source"); } else{ msg("error","Error !!!","The news item can not be found or there is an error with the news database file."); } } ?>