Creating Timeline Citation\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.

=10 && strlen($t)<=1024 && 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['submitCitation']) ){ //they submitted data so let's check it if( isset($_POST['citation']) && isset($_POST['description']) ){ //they did include a title and description $citation=trim(strip_tags($_POST['citation'])); $description=$_POST['description']; //let's validate the description and title if(validate_citation($citation)){ if(validate_description($description)){ //the title and description are good //echo "

TITLE and DESCRIPTION are GOOD

\n"; /***************************************************** COMPUTE 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; } $citationDateTime=generate_datetime($month, $day, $year); if($citationDateTime){ //the datetime is valid //echo "

VALID: $startDateTime

\n"; } else{ //invalid date $errorArray[]="invalidDate"; } /***************************************************/ //check to make sure we are ready to add to database if( $citationDateTime ){ //everything is valid and ready to roll //format and clean the variables $citation=sanitize($citation); $description=sanitize($description); $sqlInsertString="INSERT INTO Citations (conceptID, citation, created, date, description) VALUES (0, '$citation', NOW(), '$citationDateTime', '$description')"; $result=database_query($sqlInsertString); if($result){ echo "
\n"; $citation=""; $description=""; $month=""; $day=""; $year=""; } else{ $errorArray[]="databaseInsertFail"; } } else{ //something was wrong so we refuse to insert the new object into the database $errorArray[]="citationDateTimeFormatFail"; } } else{ //description invalid $errorArray[]="invalidDescription"; } } else{ //title invalid $errorArray[]="invalidCitation"; } } else{ //they did not submit these required values so fail $errorArray[]="missingCitationOrDescription"; } } 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"; } ?>
Citation:
Description:
2000 Characters Remaining
Date:

Month

Day

Year *

Similar Citations in the Database