I found an old script on the internet to parse a .csv file and integrate it into version 4 of this calendar script. How can I change it and how do I integrate it so it will work for version 6?
It is as follows:
Code:
I have developed a script for parsing a MS Outlook calendar dump.
In escal.php add the following code at line 53 after the setting for $readFile:
// READ EVENTS CALENDAR FROM OUTLOOK CSV FILE
// $readCSV=1 :: Read dates and events for marking the calendar from an Outlook '.CSV' file.
// That file sould be located in the same directory as this script.
// Setting $readCSV to any number but one (1), the script will NOT attempt to read the .CSV file.
$readCSV=0;
and then add this code at line 136 <before '// LOAD MARKING INFO FROM FILE'>:
////////////////////////////////////////////////////////////////////////////////////
// Import and parse Outlook Calendar data from CSV file
//
// Outlook Calendar fields available:
// 1 "Subject",
// 2 "Start Date",
// 3 "Start Time",
// 4 "End Date",
// 5 "End Time",
// 6 "All day event",
// 7 "Reminder on/off",
// 8 "Reminder Date",
// 9 "Reminder Time",
// 10 "Meeting Organizer",
// 11 "Required Attendees",
// 12 "Optional Attendees",
// 13 "Meeting Resources",
// 14 "Billing Information",
// 15 "Categories",
// 16 "Description",
// 17 "Location",
// 18 "Mileage",
// 19 "Priority",
// 20 "Private",
// 21 "Sensitivity",
// 22 "Show time as"
//
// The file created is a comma delimited text file with the extension '.CSV'
// The user has the choice to use any or all of the fields and chnage the
// order as they appear in the file. Outlook also includes the field names
// present, in the order sent, as the first line in the text file. This script
// will first read that line and save the array key for each element that
// is to be used. The other items are ignored. Then the rest of the calendar
// file is read, and parsed.
////////////////////////////////////////////////////////////////////////////////////
if($readCSV==1){
if(file_exists("outlook.CSV")){ // does the file exist?
$fp=fopen("outlook.CSV","r"); // open it for reading
$ndxRow=1; // the first row of data is always the field index
unset($strd, $endd, $subj, $strt, $loct); // initialize key variables
Do{
$cal_dat = fgetcsv($fp,10000,","); // start reading the file one row at a time
if(!$cal_dat) break; // if the file is empty; abort!
if($ndxRow){ // first time through
foreach($cal_dat as $key=>$fieldName){ // loop through all array elements
switch($fieldName){ // find the desired field names
case "Start Date": $strd=$key;
case "End Date": $endd=$key;
case "Subject": $subj=$key;
case "Start Time": $srtt=$key;
case "Location": $loct=$key;
} // end switch
} // end foreach element
$ndxRow--; // decrement this variable, allow parsing the rest
}
else{ // all the rest of the data file
$es .= "$cal_dat[$strd]x"; // event start date
if($cal_dat[$endd]!=""){ // event end date
$ee .= "$cal_dat[$endd]x";
}
else{ // if no end date, make it the same as start date
$ee .= "$cal_dat[$strd]x";
} // end set start and end date
if(IsSet($subj) && ($cal_dat[$subj]!="")){ // what is the subject <aka. description>
$cal_dat[$subj]=htmlspecialchars($cal_dat[$subj], ENT_QUOTES);
$eTitle .= "$cal_dat[$subj]";
if(IsSet($loct) && ($cal_dat[$loct]!="")){ // append the event location
$eTitle .= " at" . $cal_dat[$loct];
} // end if location is set
if(IsSet($srtt)){ // append the start time for the event
$eTitle .= date(" -- g:i A",strtotime($cal_dat[$srtt]));
} // end if start time is set
$eTitle .= "||";
}
else{
$eTitle .=" ||"; // There is no subject <description> for this event
}// end if a subject exists
}// end if row on or rest of data
}WHILE($cal_dat);
fclose($fp);
} // end if file exists
} // end if read CSV is set
Is there any way to obtain version 4 of your script so that I can implement this function? I think it is extremely useful and will definitely help me in the future.