3){ msg("error", "Access Denied", "You don't have permission to add news"); } $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); if($member_db[1] <= $ocat_arr[3] or ($ocat_arr[3] == '0' || $ocat_arr[3] == '')){ $cat_lines[] = $single_line; $allowed_cats[] = $ocat_arr[0]; } } if ($action == "addnews"){ echoheader("addnews", "Add News"); $short_story_id = 'short_story'; $full_story_id = 'full_story'; // // Are we using the WYSIWYG ? // if($config_use_wysiwyg == "yes"){ $use_wysiwyg = true; $article_format_options = "

"; }else{ $use_wysiwyg = false; $article_format_options = "

"; } echo "
"; if($config_use_avatar == "yes"){ echo""; } /* Old Single Category Code */ if(count($cat_lines) > 0){ echo""; } /*### ##### New Multy Category Code */### if(count($cat_lines) > 0){ echo" "; } echo"
Title
Avatar URL    (optional)
Category (multiple categories)
Category "; echo''; foreach($cat_lines as $single_line){ $cat_arr = explode("|", $single_line); $if_is_selected = ""; if($category == $cat_arr[0]){ $if_is_selected = " checked "; } // echo"$cat_arr[1],\n"; echo" '; } } echo"
"; $i++; if ($i%4 == 0){ echo'

Short Story
"; if ($use_wysiwyg) { echo" "; }else{ echo" "; } echo"


[insert image]

[expand]

"; echo insertSmilies("$short_story_id", 4, true, "$use_wysiwyg"); echo"

"; echofooter(); } // ******************************************************************************** // Do add News to news.txt // ******************************************************************************** elseif($action == "doaddnews") { ///// ///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('not allowed category'); } if($ccount==0){ $nice_category = $cvalue; }//first cat else{ $nice_category = $nice_category.','.$cvalue; } $ccount++; } }else{ //Single or Not category //don't format $nice_cats because we have not selected any. if( $category !="" and isset($category) and !in_array($category,$allowed_cats) ){ die('not allowed category'); } $nice_category = $category; } // die($nice_category); if($member_db[1] == 3 or $postpone_draft == "draft"){ //if the user is Journalist, add the article as unapproved $decide_news_file = "./data/unapproved_news.txt"; $added_time = time()+ ($config_date_adjust*60); $postpone = FALSE; $unapproved_status_msg = "The article was marked as Unapproved!"; } elseif($postpone_draft == "postpone"){ if( !ereg("^[[:digit:]]{1,}$", $from_date_hour) or !ereg("^[[:digit:]]{1,}$", $from_date_minutes) ){ msg("error","Error !!!","You want to add a postponed article, but the hour format is invalid.", "javascript:history.go(-1)"); } $postpone = TRUE; $added_time = mktime($from_date_hour,$from_date_minutes,0,$from_date_month,$from_date_day,$from_date_year) + ($config_date_adjust*60); $decide_news_file = "./data/postponed_news.txt"; } else{ $postpone = FALSE; $added_time = time()+ ($config_date_adjust*60); $decide_news_file = "./data/news.txt"; } if($if_convert_new_lines == "yes"){ $n_to_br = TRUE; } if($if_use_html == "yes"){ $use_html = TRUE; } $full_story = replace_news("add", $full_story, $n_to_br, $use_html); $short_story = replace_news("add", $short_story, $n_to_br, $use_html); // $title = replace_news("add", $title, TRUE, $use_html); $title = replace_news("add", $title, TRUE, FALSE); // HTML in title is not allowed if(trim($title) == "" or !$title){ msg("error","Error !!!","The title can not be blank.", "javascript:history.go(-1)"); } if(trim($short_story) == "" or !$short_story){ msg("error","Error !!!","The story can not be blank.", "javascript:history.go(-1)"); } if($member_db[7] == 1){ $added_by_email = $member_db[5]; } else{ $added_by_email = "none"; } // Save The News Article In Active_News_File $all_db = file("$decide_news_file"); foreach($all_db as $news_line){ $news_arr = explode("|", $news_line); if($news_arr[0] == $added_time){ $added_time++; } } $news_file = fopen("$decide_news_file", "w"); fwrite($news_file, "$added_time|$member_db[2]|$title|$short_story|$full_story|$manual_avatar|$nice_category||\n"); foreach ($all_db as $line){ fwrite($news_file, "$line");} fclose($news_file); // Add Blank Comment In The Active_Comments_File $old_com_db = file("./data/comments.txt"); $new_com_db = fopen("./data/comments.txt", "w"); fwrite($new_com_db, "$added_time|>|\n"); foreach ($old_com_db as $line){ fwrite($new_com_db, "$line");} fclose($new_com_db); // Incrase By 1 The Number of Written News for Current User $old_user_db = file("./data/users.db.php"); $new_user_db = fopen("./data/users.db.php", w); foreach($old_user_db as $old_user_db_line){ $old_user_db_arr = explode("|", $old_user_db_line); if($username!=$old_user_db_arr[2]){ fwrite($new_user_db,"$old_user_db_line"); } else { $countplus = $old_user_db_arr[6]+1; fwrite($new_user_db,"$old_user_db_arr[0]|$old_user_db_arr[1]|$old_user_db_arr[2]|$old_user_db_arr[3]|$old_user_db_arr[4]|$old_user_db_arr[5]|$countplus|$old_user_db_arr[7]|$old_user_db_arr[8]|$old_user_db_arr[9]||\n"); } } fclose($new_user_db); if($member_db[1] == 3){ //user is journalist and the article needs to be approved, Notify !!! if($config_notify_unapproved == "yes" and $config_notify_status == "active"){ send_mail("$config_notify_email", "CuteNews - Unapproved article was Added", "The user $member_db[2] (journalist) posted article '$title' which needs first to be Approved."); } } if($postpone){ msg("info","News added (Postponed)", "The news item was successfully added to the database as postponed.
It will be activated at ".date("r",$added_time)); } else{ msg("info","News added", "The news item was successfully added.
$unapproved_status_msg"); } } ?>