','',$content); $content = str_ireplace('
','
',$content); $content = str_ireplace('
','',$content); $content = str_ireplace('{','{',$content); $content = str_ireplace('}','}',$content); $content = str_ireplace('{','{',$content); $content = str_ireplace('}','}',$content); $content = str_ireplace('{','{',$content); $content = str_ireplace('}','}',$content); $content = preg_replace("##",'',$content); $content = db_escape_string($content); $content_type = 'E'; if ($_SESSION['UserInfo']['type'] == 'SuperUser' && $school_num == 3) $content_type = 'S'; // Insert the new email message if (!isset($post_from_date)) { $query = "insert into formatted_content " . "(school_num,content_id,date_added,date_modified,content_type,content) " . "values($school_num,'$content_id','$date_modified','$date_modified','$content_type','$content')"; } else { $query = "insert into formatted_content " . "(school_num,content_id,date_added,date_modified,content_type,content,post_from_date,post_to_date,post_active) " . "values($school_num,'$content_id','$date_modified','$date_modified','$content_type','$content','$post_from_date','$post_to_date','$post_active')"; } db_query($query); $mid = db_insert_id(); include "email-messages-list.php"; break; case "edit": case "copy": if ($record_num == 0) { $error_message = getLanguageText('TEXT-INVALID-ACCESS'); header("Location: /?error_message=".urlencode($error_message)); exit(); } $query = "select * from formatted_content where record_num = '$record_num'"; $results = db_query($query); $row = db_fetch_array($results); $content_id = stripslashes($row["content_id"]); $content_type = $row["content_type"]; $date_added = $row["date_added"]; $date_modified = date("Y-m-d",time()); $content = stripslashes($row["content"]); $post_from_date = $row['post_from_date']; $post_to_date = $row['post_to_date']; $post_active = $row['post_active']; include "email-message-edit.html"; break; case "update": extract($_POST); if ($record_num == 0) { $error_message = getLanguageText('TEXT-INVALID-ACCESS'); header("Location: /?error_message=".urlencode($error_message)); exit(); } $content_id = db_escape_string(stripslashes($_POST['content_id'])); $date_modified = date("Y-m-d",time()); $content = stripslashes($_POST['content']); if (array_key_exists('post_from_date', $_POST) && strlen($_POST['post_from_date'])) $post_from_date = db_escape_string($_POST['post_from_date']); if (array_key_exists('post_to_date', $_POST) && strlen($_POST['post_to_date'])) $post_to_date = db_escape_string($_POST['post_to_date']); if (array_key_exists('post_active', $_POST) && strlen($_POST['post_active'])) $post_active = db_escape_string($_POST['post_active']); // Cleanup the content before saving $content = str_ireplace('','',$content); $content = str_ireplace('','
',$content); $content = str_ireplace('
','',$content); $content = str_ireplace('{','{',$content); $content = str_ireplace('}','}',$content); $content = str_ireplace('{','{',$content); $content = str_ireplace('}','}',$content); $content = str_ireplace('{','{',$content); $content = str_ireplace('}','}',$content); $content = preg_replace("##",'',$content); $content = db_escape_string($content); $attachments = NULL; if (array_key_exists('attachments', $_POST)) $attachments = $_POST['attachments']; $content_type = 'E'; if ($_SESSION['UserInfo']['type'] == 'SuperUser' && $school_num == 3) $content_type = 'S'; if (!isset($post_active)) $post_active = 'N'; // Save the new content if (!isset($post_from_date)) { $query = "update formatted_content " . "set content_id = '$content_id', " . "content = '$content', " . "content_type = '$content_type', " . "date_modified = '$date_modified' " . "where record_num = '$record_num'"; } else { $query = "update formatted_content " . "set content_id = '$content_id', " . "content = '$content', " . "content_type = '$content_type', " . "post_from_date = '$post_from_date', " . "post_to_date = '$post_to_date', " . "post_active = '$post_active', " . "date_modified = '$date_modified' " . "where record_num = '$record_num'"; } db_query($query); include "email-messages-list.php"; break; case "delete": if ($record_num == 0) { $error_message = getLanguageText('TEXT-INVALID-ACCESS'); header("Location: /?error_message=".urlencode($error_message)); exit(); } $query = "select * from formatted_content where record_num = '$record_num'"; $results = db_query($query); if (db_num_rows($results) == 0) { $error_message = getLanguageText('TEXT-INVALID-ACCESS'); } $row = db_fetch_array($results); $content_id = stripslashes($row["content_id"]); $content = stripslashes($row["content"]); ?>