session_start();
require('../../php/functions.php');
require('pFunctions.php');
require("../../php/sharedFunctions.php");
//no direct access
if(!isset($_SESSION['GTaccount'])){
header('Location: index.php');
exit;
}
$deadline = nextWeekDay("sunday");
$now = strtotime("now");
$nextAvail = displayDateShort(nextWeekDay("monday"));
function killZeros($x){
$pieces = explode("-",$x);
$newdate = mktime(0,0,0,$pieces[0],$pieces[1],$pieces[2]);
return $newdate;
}
if(isset($_POST['submitForm'])){
/* echo "deadline: ".displayDateShort($deadline)."
";
echo "now: ".displayDateShort($now)."
";
echo "prefered Date: ".$_POST['preferred_date']."
";
echo "First in list: $nextAvail
";*/
$primary_sponsor = mysql_escape_string(trim($_POST['primary_sponsor']));
$event = mysql_escape_string(trim($_POST['event']));
$description = mysql_escape_string(strip_tags(trim($_POST['description'])));
$location = mysql_escape_string(trim($_POST['location']));
$date = mysql_escape_string(trim($_POST['date']));
$time = mysql_escape_string(trim($_POST['time']));
$contact = mysql_escape_string(trim($_POST['contact']));
$preferred_date = mysql_escape_string(trim($_POST['preferred_date']));
$submitter = mysql_escape_string(trim($_POST['submitter']));
$dateEpoch = killZeros($date);
$preferredEpoch = killZeros($preferred_date);
//errors
if($primary_sponsor == "")
$error .= "Please fill in the Primary Sponsor
";
if($event == "")
$error .= "Please fill in an event name
";
if($description == "")
$error .= "Please enter a description
";
if($date == "")
$error .= "Please enter a date
";
if($time == "")
$error .= "Please enter a time
";
if($submitter == "")
$error .= "Please enter a submitter name
";
if($dateEpoch < $preferredEpoch)
$error .= "Your Event Date is before the preferred email date
";
//$count = $description;
//check chars in description
//if( strlen(strip_tags($count)) > 400 )
//$error .= "You have gone over your 400 character count. Spaces and Returns count as well.
";
//check for past deadline and requesting the very next monday...
if( $now > $deadline && $nextAvail == $preferred_date ){
$error .= "You are past the deadline time to request this date. Please choose the next available preferred date.
";
}
//NO ERRORS
if(!$error){
$sql_insert = mysql_query("INSERT INTO ".DB_PREFIX."mm_email
(primary_sponsor, event, description, location, date, time, contact, preferred_date, submitter)
VALUES
('$primary_sponsor', '$event', '$description', '$location', '$date', '$time', '$contact', '".switchDate("backwards", $preferred_date)."', '$submitter')") or die('Could not insert data'.mysql_error());
$sql = mysql_query("SELECT * FROM ".DB_PREFIX."mm_admins");
$subject = "You have a weekly digest to approve";
while($list = mysql_fetch_assoc($sql)){
mail($list['email'],$subject,"Please log into DOS weekly digest admin area to approve this.");
}
echo '';
exit;
}
}
?>