3 && $member_db[1] != 5){ msg("error", $echo['error'], $echo['moduleAccess']); } $orig_cat_lines = file("./data/category.db.php"); //only show allowed categories $allowed_cats = array(); $cat_lines = array(); foreach($orig_cat_lines as $single_line){ $ocat_arr = explode("|", $single_line); $cat[$ocat_arr[0]] = $ocat_arr[1]; if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){ $cat_lines[] = $single_line; $allowed_cats[] = $ocat_arr[0]; } } // ******************************************************************************** // List all news available for editing // ******************************************************************************** if($action == "list") { echoheader("editnews", $echo['header']); // 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"); } elseif($source == "postponed"){ $all_db = file("./data/postponed_news.txt"); ResynchronizePostponed(); } elseif($source == "unapproved"){ $all_db = file("./data/unapproved_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 or $member_db[1] == 5){ foreach($all_db as $raw_line){ $raw_arr = explode("|", $raw_line); ; if ( ($category == '' or in_array($category, explode(',',$raw_arr[6]))) and ($author == "" or $raw_arr[1] == $author) and ($member_db[1] != 5 or $raw_arr[1] == $member_db[2]) 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)){ // ######################################### // Sort news in Edit News Panel - HACK // ######################################### if (!isset($sortby)) { $sortby="0"; } if (!isset($sortad)) { $sortad="d"; } if (isset($sortby)) { if (!function_exists('sortcmp')) { function sortcmp($a, $b) { global $all_db, $sortby; $news_a = explode('|', $all_db[$a]); $news_b = explode('|', $all_db[$b]); return strnatcasecmp($news_a[$sortby], $news_b[$sortby]); } } uksort($all_db, 'sortcmp'); if ($sortad=="d") { $all_db = array_reverse($all_db); } Unset($Sortby); } // ######################################### // END - Sort news in Edit News Panel - HACK // ######################################### 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="class=\"alternate\""; $flag = 0; } else {$bg = "class=\"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]) ); $title = ereg_replace("<[^>]*>","",$title); $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] == "0"){ $my_cat = "---"; } // elseif($cat[$item_db[6]] == ""){ $my_cat = "(ID: $item_db[6])"; } elseif(strstr($item_db[6],',')){ $all_this_cats_arr = explode(',',$item_db[6]); $my_multy_cat_labels = ''; foreach($all_this_cats_arr as $this_single_cat){ $my_multy_cat_labels .= "$cat[$this_single_cat], "; } $my_cat = "".$echo['multiple'].""; } 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 = "
".$echo['fromCategory']." $cat[$category]"; } if($source == "postponed"){ $source_msg = " ".$echo['newsPostponed']." , [".$echo['refresh']."]"; $postponed_selected = " selected ";} elseif($source == "unapproved"){ $source_msg = " ".$echo['newsUnactive']." "; $unapproved_selected = " selected ";} elseif($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 = " ".$echo['fromArchive']." ". date("d/m/Y",$first_timestamp) ." - ". date("d/m/Y",$last_timestamp) .""; } /////////////////////////////////////////// // Options Bar echo"
 ".$echo['showed1']." $entries_showed ".$echo['showed2']." $all_count_news$cat_msg $source_msg

[".$echo['showOptions']."] 

"; // End Options Bar ///////////////////////// Showing List of News ///////////////////////// if($entries_showed == 0){ echo"

".$echo['notFounded']."
[".$echo['showOptions']."]

"; } else{ echo<< JSCRIPT; echo"
HTML; } echo<<
 ".$echo['showedTitle']."
  |
".$echo['showedComments']."
 
".$echo['category']."
|
".$echo['date']."
|
".$echo['showedAuthor']."
|
"; } ##################################################################################################################### echo $entries; ##################################################################################################################### if($start_from > 0) { $previous = $start_from - $news_per_page; $npp_nav .= "".$echo['prev'].""; $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 .= "".$echo['next']." $how_next >>"; } if($entries_showed != 0){ echo<<  
$npp_nav $checked
HTML; echofooter(); } // ******************************************************************************** // ******************************************************************************** // Edit News Article // ******************************************************************************** // ******************************************************************************** elseif($action == "editnews") { // Show The Article for Editing if($source == ""){ $all_db = file("./data/news.txt"); } elseif($source == "postponed"){ $all_db = file("./data/postponed_news.txt"); } elseif($source == "unapproved"){ $all_db = file("./data/unapproved_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;} elseif($member_db[1] == 5 and $item_db[1] == $member_db[2]) {$have_perm = 1;} if(!$have_perm){ msg("error", $echo['error'], $echo['errorAction'], "$PHP_SELF?mod=editnews&action=list"); } if(strstr($item_db[6], ',')){ $all_these_cats = explode(',',$item_db[6]); foreach($all_these_cats as $all_this_cat){ if($member_db[1] != 1 and !in_array($all_this_cat,$allowed_cats)) {msg("error", $echo['accessDenied'], $echo['wrongCat']);} } } elseif ($item_db[6] == "0") { $have_perm = 1; } else { if($member_db[1] != 1 and !in_array($item_db[6],$allowed_cats) ){ msg("error", $echo['accesDenied'], $echo['wrongCat']); } } if (!$found){ msg("error",$echo['error'],$echo['cannotFindNews']); } $newstime = langdate("D, d F Y H:i:s", $item_db[0]); $item_db[2] = stripslashes( preg_replace(array("'\|'", "'\"'", "'\''"), array("I", """, "'"), $item_db[2]) ); $short_story_id = 'short_story'; $full_story_id = 'full_story'; // NewDate add $aorg_currentdate = strftime("%d/%m/%Y %H:%M:%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/m/Y H:i:s"); } // NewDate add - end // Are we using the WYSIWYG ? if($config_use_wysiwyg == "yes"){ $use_wysiwyg = true; }else{ $use_wysiwyg = false; } $item_db[3] = replace_news("admin", $item_db[3], $use_wysiwyg); $item_db[4] = replace_news("admin", $item_db[4], $use_wysiwyg); echoheader("editnews",$echo['header'].""$item_db[2]""); // XFields v2.1 - addblock //$xfieldsaction = "categoryfilter"; //include("xfields.mdu"); // XFields v2.1 - End addblock $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"
".$echo['info']." ".$echo['posted']." $newstime ".$echo['by']." $item_db[1]
"; if($item_db[7] != "" and $item_db[8] != "") { $tmp_arr_date = explode(",", $item_db[7]); $tmp_arr_name = explode(",", $item_db[8]); echo $echo['newsEdited'].":
    "; for($i=1; $i < count($tmp_arr_date);$i++) { $this_edit_date = langdate("d F Y H:i:s", $tmp_arr_date[$i]); echo "
  1. ".$this_edit_date." ".$echo['newsPerson']." ".$tmp_arr_name[$i]."
  2. "; } echo "
"; if($member_db[1] == 1){ echo " ".$echo['newsEditDelete']; } } echo"
".$echo['title']."
"; // AVATAR if($config_use_avatar == "yes"){ echo"
".$echo['avatar']." ".$echo['optional']."
"; } // SHORT STORY if ($use_wysiwyg) { echo"
".$echo['short']."
"; echo insertSmilies("$short_story_id", 14, true, "$use_wysiwyg"); echo"
"; echo quickcode2(short_story,1); echo"
"; } else { echo"
".$echo['short']." "; if ($config_hide_inserttag == "true"){ echo inserttag(short); } echo"
"; echo insertSmilies("$short_story_id", 14, true, "$use_wysiwyg"); echo"
"; echo quickcode(short_story,0); echo"
"; } // FULL STORY if ($use_wysiwyg) { echo"
".$echo['full']." ".$echo['optional']."
"; echo insertSmilies("$full_story_id", 14, true, "$use_wysiwyg"); echo"
"; echo quickcode2(full_story,1); echo"
"; } else { echo"
".$echo['full']." ".$echo['optional']." "; if ($config_hide_inserttag == "true"){ echo inserttag(full); } echo"
"; echo insertSmilies("$full_story_id", 14, true, "$use_wysiwyg"); echo"
"; echo quickcode(full_story,0); echo"
"; } // XFields v2.1 - changeblock - New $xfieldsaction = "list"; $xfieldsid = $id; $xfieldscat = $item_db[6]; include("xfields.mdu"); // XFields v2.1 - End changeblock echo"
"; if($source == 'unapproved'){ echo""; } echo"
"; // Edit Form END echo"
".$echo['optionsHeader']." "; // CATEGORY if(count($cat_lines) > 0){ echo"
    "; // $cat_lines = file("./data/category.db.php"); commented-out because can lines are already opened before, and filtered with propper restrictions for user foreach($cat_lines as $single_line){ $cat_arr = explode("|", $single_line); echo"
"; } echo"
1
"; echo"
   \n \n   :
1
"; $buffer = run_actions('new-advanced-options'); if ($buffer != "") { echo"
1
"; echo $buffer; echo"
"; } echo"
"; echo"
"; echo"
".$echo['comments']." "; echo<< JSCRIPT; // Comments for Editing if($source == "" or $source == "postponed" or $source == "unapproved"){ $all_comments_db = file("./data/comments.txt"); } else { $all_comments_db = file("./data/archives/${source}.comments.arch"); } echo" "; $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 = "class=\"alternate\""; $flag = 0;} else{$bg = "class=\"alternate2\""; $flag = 1;} $comment_arr = explode("|",$individual_comment); $comment_arr[0] = (int) $comment_arr[0]; $comtime = date("d/m/y h:i:s",$comment_arr[0]); $comm_value = stripslashes(strip_tags($comment_arr[4])); $comm_excerpt_lenght = 43 - strlen($comment_arr[1]); if($comm_excerpt_lenght < strlen($comm_value)){ $comm_excerpt = substr($comm_value,0, $comm_excerpt_lenght).'...'; } else { $comm_excerpt = $comm_value; } 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"
  ".$echo['poster'].": ".$echo['commPreview']." ".$echo['date']."  
$comment_arr[1]:$comm_excerpt $comtime

".$echo['deleteAllComm']."

"; break;//foreach comment line }//if there are any comments else { echo"
".$echo['emptyComm']."
"; } } //if these are comments for our story } //foreach comments line if($found_newsid == FALSE){ echo" ".$echo['emptyComm']." "; } // Show Comments for editing - END echo"
"; echofooter(); } // ******************************************************************************** // ******************************************************************************** // Do Edit News // ******************************************************************************** // ******************************************************************************** elseif($action == "doeditnews"){ ///Format our categories variable if( is_array($category) ){ //User has selected multiple categories $nice_category = ''; $ccount = 0; foreach($category as $ckey=>$cvalue){ if( !in_array($cvalue,$allowed_cats) ){ die('niedozwolona kategoria'); } if($ccount==0){ $nice_category = $cvalue; }//first cat else{ $nice_category = $nice_category.','.$cvalue; } $ccount++; } } else{ //Not in a category if( $category !="" and isset($category) and !in_array($category,$allowed_cats) ){ die('niedozwolona kategoria'); } //don't format $nice_cats because we have not selected any. $nice_category = '0'; } ///Format our categories variable - END run_actions('edit-validate-entry'); if(trim($title) == "" and $ifdelete != "yes"){ msg("error", $echo['error'], $echo['emptyTitle'], "javascript:history.go(-1)"); } if($short_story == "" and $ifdelete != "yes"){ msg("error", $echo['error'], $echo['emptyArticle'], "javascript:history.go(-1)"); } if ($use_wysiwyg) { $n_to_br = FALSE; } else { $n_to_br = TRUE; } $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) ); $full_story = stripslashes($full_story); $short_story = stripslashes($short_story); 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 v2.1 - addblock if ($ifdelete != "yes") { $xfieldsaction = "init"; $xfieldsid = $id; include("xfields.mdu"); } // XFields v2.1 - End addblock $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 ($old_db_arr[7]==""){ $old_db_arr[8] = ""; $old_db_arr[7] = $old_db_arr[0]; } 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;} elseif($member_db[1] == 5 and $old_db_arr[1] == $member_db[2]) {$have_perm = 1;} if($have_perm){ // XFields v2.1 - addblock $xfieldsaction = ($ifdelete == "yes" ? "delete" : "save"); $xfieldsid = $id; include("xfields.mdu"); // XFields v2.1 - End addblock $item_db = $old_db_arr; if($ifdelete != "yes") { $okchanges = TRUE; if($edited_time == "yes"){ $old_db_arr[0] = mktime($from_date_hour,$from_date_minutes,0,$from_date_month,$from_date_day,$from_date_year) + ($config_date_adjust*60); $id = $old_db_arr[0]; } if($config_postdate_record == "yes") { $editdate = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y")) + ($config_date_adjust*60); $editname = $member_db[2]; $edit_times = $old_db_arr[7].",".$editdate; $edit_users = $old_db_arr[8].",".$editname; if ($clear_list && $member_db[1] == 1) { $edit_times = ""; $edit_users = ""; } } run_actions('edit-save-entry'); fwrite($new_db,"$old_db_arr[0]|$old_db_arr[1]|$title|$short_story|$full_story|$editavatar|$nice_category|$edit_times|$edit_users||\n"); // ADD Hack: Reassign comments/xfields if the news date has changed if ($item_db[0] != $old_db_arr[0]) { run_actions('post-edit-datechange'); // Comments Updater $aj_update_file = file("$com_file"); $aj_update_file_updated = str_replace($item_db[0], $old_db_arr[0], $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($item_db[0], $old_db_arr[0], $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; run_actions('edit-deleted'); $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); run_actions('deleted-single-entry'); } }else{ fwrite($new_db,"$old_db_line"); $no_permission = TRUE; } } } fclose($new_db); $old_db = file("$news_file"); $new_db = fopen("$news_file", w); foreach($old_db as $old_db_line){ $old_db_line = str_replace("\n", "||", $old_db_line)."\n"; $old_db_arr = explode("|", $old_db_line); if ($old_db_arr[7]==""){ $old_db_arr[8] = ""; $old_db_arr[7] = $old_db_arr[0]; } if ($old_db_arr[6]=="") { $old_db_arr[6] = "0"; } $base_temp = "$old_db_arr[0]|$old_db_arr[1]|$old_db_arr[2]|$old_db_arr[3]|$old_db_arr[4]|$old_db_arr[5]|$old_db_arr[6]|$old_db_arr[7]|$old_db_arr[8]||\n"; $new_base = $new_base.$base_temp; } fwrite($new_db,$new_base); fclose($new_db); if($no_permission){ msg("error", $echo['noAccess'], $echo['errorAction'], "$PHP_SELF?mod=editnews&action=list"); } if($okdeleted and $okdelcom){ msg("info", $echo['headerDelete'], $echo['deleteSuccesfull']); } if($okdeleted and !$okdelcom){ msg("info", $echo['headerDelete'], $echo['deleteSuccesfull']."
".$echo['comDeleteError'].""); } /* else if($okchanges){ msg("info", $echo['headerSaved'], $echo['savedInfo'], "$PHP_SELF?mod=editnews&action=editnews&id=$id&source=$source"); } */ else if($okchanges){ msg("info", $echo['headerSaved'], $echo['savedInfo'], "$PHP_SELF?mod=editnews&action=list"); } else{ msg("error",$echo['error'], $echo['cannotFind']); } } ?>