Creating Timeline Event\n"; echo "

Return to Editing Your Timeline

\n"; $errorArray=array(); /************************************************************* Start by figuring out who is logged in *************************************************************/ if(user_logged_in() && !$doingLogout){ $username=$_COOKIE['sclcr']; } else{ // the user isn't logged in ?>

 

 

Log in up there

Not Logged In

You must be logged in before you can create timeline items.

=2 && strlen($t)<=255 && str_word_count($t)>=1 ){ return true; } else{ return false; } } //validate object descriptions function validate_description($d){ if( strlen($d)>=5 && strlen($d)<=2000 && str_word_count($d)>=2 ){ return true; } else{ return false; } } //validate a date function generate_datetime($m, $d, $y){ if($d==0) $d=1; if($m==0) $m=1; if( !is_numeric($d) || !is_numeric($m) || !is_numeric($y) || $d<1 || $d>31 || $m<1 || $m>12 || $y<1000 || $y>9999 ) return false; if( !checkdate($m, $d, $y) ) return false; if( $d<10 ){ $d="0" . $d; } else { $d="$d"; } if( $m<10 ){ $m="0" . $m; } else { $m="$m"; } //YYYY-MM-DD HH:MM:SS return "$y-$m-$d 00:00:00"; } //take a year, month, and day and format a date for DISPLAY purposes function format_display_date($y, $m, $d){ //if the month and day are both 1 then we ONLY show the year if($m==1 && $d==1) return "$y"; //if the month is other than 1 and the day is one we dispay the month as well if($m>1 && $d==1) return date("M", mktime(0, 0, 0, $m, 1, 2005)) . " " .$y; //if the day is other than 1 we show the full date if($d>1) return date("M", mktime(0, 0, 0, $m, 1, 2005)) . " $d, $y"; return false; } //let's see if they submitted any values and if so, we validate and process them if( isset($_POST['submitEvent']) ){ //they submitted data so let's check it if( isset($_POST['title']) && isset($_POST['description']) ){ //they did include a title and description $title=trim(strip_tags($_POST['title'])); $description=$_POST['description']; //let's validate the description and title if(validate_title($title)){ if(validate_description($description)){ //the title and description are good //echo "

TITLE and DESCRIPTION are GOOD

\n"; //now we check to see if this is a single event or a span if( isset($_POST['span']) && $_POST['span']=="span" ){ $span=true; } else{ $span=false; } /***************************************************** COMPUTE START DATE *****************************************************/ if( isset($_POST['day']) ){ $day=$_POST['day']; } else { $day=1; } if( isset($_POST['month']) ){ $month=$_POST['month']; } else { $month=1; } if( isset($_POST['year']) ){ $year=$_POST['year']; } else { $year=false; } $startDateTime=generate_datetime($month, $day, $year); if($startDateTime){ //the datetime is valid //echo "

VALID: $startDateTime

\n"; } else{ //invalid date $errorArray[]="invalidStartDate"; } /***************************************************/ /***************************************************** COMPUTE END DATE *****************************************************/ if($span){ if( isset($_POST['dayEnd']) ){ $dayEnd=$_POST['dayEnd']; } else { $dayEnd=1; } if( isset($_POST['monthEnd']) ){ $monthEnd=$_POST['monthEnd']; } else { $monthEnd=1; } if( isset($_POST['yearEnd']) ){ $yearEnd=$_POST['yearEnd']; } else { $yearEnd=false; } $endDateTime=generate_datetime($monthEnd, $dayEnd, $yearEnd); if($endDateTime){ //the datetime is valid //now we make sure the end date is AFTER the start date if(strtotime($endDateTime) > strtotime($startDateTime)){ //the end date comes later //echo "

VALID: $endDateTime

\n"; } else{ //they put the days in out of order $endDateTime=false; $errorArray[]="datesOutOfOrder"; } } else{ //invalid date $errorArray[]="invalidEndDate"; } } else{ $endDateTime="0000-00-00 00:00:00"; } /***************************************************/ //check to make sure we are ready to add to database if( ($startDateTime) && ( (!$span) || ($span && $endDateTime) ) ){ //everything is valid and ready to roll //format and clean the variables if($span){ $span=1; } else { $span=0; } $title=sanitize($title); $description=sanitize($description); $sqlInsertString="INSERT INTO TimelineEvents (span, start, end, title, description, contributor, submitted) VALUES ($span, '$startDateTime', '$endDateTime', '$title', '$description', '$username', NOW())"; $result=database_query($sqlInsertString); if($result){ echo "
\n"; $title=""; $description=""; $span=0; $month=""; $day=""; $year=""; $monthEnd=""; $dayEnd=""; $yearEnd=""; } else{ $errorArray[]="databaseInsertFail"; } } else{ //something was wrong so we refuse to insert the new object into the database $errorArray[]="spanDateTimeFormatFail"; } } else{ //description invalid $errorArray[]="invalidDescription"; } } else{ //title invalid $errorArray[]="invalidTitle"; } } else{ //they did not submit these required values so fail $errorArray[]="missingTitleOrDescription"; } } else{ //they didn't submit anything //$errorArray[]="noData"; } //if there were errors we need to display messages if(count($errorArray)>=1){ echo "
\n"; echo "\n
\n"; } ?>
Title:
Description:
2000 Characters Remaining
Does this event span time? (Starts and ends on different days)
Date:

Month

Day

Year *
End Date:

Month

Day

Year *

Similar Events in the Database