PDA

View Full Version : Version 4.0 Beta Discussion


tomB
10-31-2003, 06:12 PM
I have found an anomaly in the escalAE.php script.

On line 106 for saving new data to MySql:
if the 'description' contains an apostrophe (single quote) MySql thinks the variable has been
terminated but there is another apostrophe hanging around and an error is generated.
I discovered the error by adding " or die (mysql_error()); " at the end of line 107.

I solved that problem by using switched double quotes (\") around the variable names in line 106. However that leads to a second problem, in that if I enter double quotes in the description MySql thinks the entry is complete with no errors (?). This can be handled by using \" in the description but it is messy and not obvious to a new user.

The real solution would be to inspect the description data and handle both ' and " automatically.

Thoughts?

tomB

Brian
10-31-2003, 06:36 PM
Thanks for pointing that out.

The script checks for this in flat file databases but not for the SQL code. I'll add that in the next limited-beta release.

Brian
10-31-2003, 07:43 PM
The code to fix this is:

$description = eregi_replace("\"","''",stripslashes($description));

Insert this at line 70 of the escalAE.php file.

tomB
10-31-2003, 08:21 PM
Great! In and fixed.

tomB

ve9gra
10-31-2003, 08:28 PM
Here's another one... if you have any double quotes in your description and you only have one event in the day, the title of the td doesn't get set properly and stops at the "...

here's how I fixed mine (line 290, escal.php)

echo " title=\"".htmlspecialchars($et[$daycount],ENT_QUOT ES)."\" onClick=\"popupEvent($daycount,$popupWidth,$popupH eight)\" style=\"cursor:hand;\"";

ve9gra
10-31-2003, 08:32 PM
One more thing... correct me if i'm wrong...

line 110 or 111, escalAE.php is useless... ?
$description = stripslashes($description);
it's at the end of the if and doesn't get used afterwards.

tomB
10-31-2003, 08:40 PM
I wondered about that, but I hadn't investigated to see if it where used again later in the script.
Maybe it could be used before the $sql assignment to strip un-wanted characters off. Other than that I don't see any use for it. :)

I am also looking into a script that will parse an Outlook exported calendar file. Will let you know the results.

tomB

BTW: I have the updated calendar running at:

My Calendar (http://www.holyspirit-sr.org/calendar/hscalendar.php)

Brian
10-31-2003, 08:53 PM
Originally posted by ve9gra@Oct 31 2003, 08:32 PM
One more thing... correct me if i'm wrong...

line 110 or 111, escalAE.php  is useless... ?
$description = stripslashes($description);
it's at the end of the if and doesn't get used afterwards.
Yes. It is useless! B)

That is the remains of code that I use for internal testing that is in the limited beta. It will be taken out in a later beta version and version 4.0 final.

Brian
10-31-2003, 08:53 PM
Originally posted by tomB@Oct 31 2003, 08:40 PM
I wondered about that, but I hadn't investigated to see if it where used again later in the script.
Maybe it could be used before the $sql assignment to strip un-wanted characters off. Other than that I don't see any use for it. :)
BTW: I have the calendar running at:
My Calendar (http://www.holyspirit-sr.org/escalbeta/hscalendar.php)

I am also looking into a script that will parse an Outlook exported calendar file. Will let you know the results.

tomB
Lookin' good! :D

ve9gra
10-31-2003, 08:54 PM
Papa, have you tried the other fix. I'd just like a confirmation that it is in fact working on more than just my server...

ve9gra
10-31-2003, 08:56 PM
oh shoot... my fix from before about the td title... you also have to edit line 298... forgot to point that out in my post.

Brian
10-31-2003, 08:57 PM
Originally posted by ve9gra@Oct 31 2003, 08:28 PM
Here's another one... if you have any double quotes in your description and you only have one event in the day, the title of the td doesn't get set properly and stops at the "...

here's how I fixed mine (line 290, escal.php)

echo " title=\"".htmlspecialchars($et[$daycount],ENT_QUOT ES)."\" onClick=\"popupEvent($daycount,$popupWidth,$popupH eight)\" style=\"cursor:hand;\"";
If you implement the third post in this topic, does it fix this problem? It will not correct old entries but it should fix any new entries.

ve9gra
10-31-2003, 09:02 PM
well it does look as if it was a double quote.. but it's using two single quotes...

so if you have a funky font, it won't look right...

ve9gra
10-31-2003, 09:17 PM
if you change line 70, escalAE.php (your previous fix) to
$description = htmlspecialchars(stripslashes($description),ENT_QU OTES);
then it keeps the double quote as a double quote then you only have to do my other fix in order to show the double quotes in the TD title also...

if you look at my edit page for my test calendar (http://www.chaotic-concepts.org/ESCal40Beta/escalAE.php?event=edit) you can see the difference... Oct 5 is using my fix (if you edit it you can see that it's still double quotes), Oct 27 and 28 were using your fix and you can see a difference with the quotes... and Oct 29 and 31 were from before either fix...

then if you look at the calendar itself, all the descriptions are acurately displayed in the "hover"....

Brian
11-02-2003, 10:21 PM
There is a new private beta available that addresses all of the issues in this thread.

Brian
11-02-2003, 10:43 PM
If you just downloaded the beta, there is another update that was just made. Please download again to make sure you are using the latest beta.

Thanks! :D

tomB
11-05-2003, 03:53 PM
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'>:


////////////////////////////////////////////////////////////////////////////////////
// &nbsp;Import and parse Outlook Calendar data from CSV file
//
// &nbsp;Outlook Calendar fields available:
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 "Subject",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2 "Start Date",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3 "Start Time", &nbsp;
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 4 "End Date",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 5 "End Time",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 6 "All day event",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 7 "Reminder on/off",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 8 "Reminder Date",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 9 "Reminder Time",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10 "Meeting Organizer",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 11 "Required Attendees",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 12 "Optional Attendees",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 13 "Meeting Resources",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 14 "Billing Information",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 15 "Categories",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 16 "Description",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 17 "Location",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 18 "Mileage",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 19 "Priority",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 20 "Private",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 21 "Sensitivity",
// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 22 "Show time as"
//
// &nbsp;The file created is a comma delimited text file with the extension '.CSV'
// &nbsp;The user has the choice to use any or all of the fields and chnage the
// &nbsp;order as they appear in the file. Outlook also includes the field names
// &nbsp;present, in the order sent, as the first line in the text file. This script
// &nbsp;will first read that line and save the array key for each element that
// &nbsp;is to be used. The other items are ignored. Then the rest of the calendar
// &nbsp;file is read, and parsed.
////////////////////////////////////////////////////////////////////////////////////
if($readCSV==1){
&nbsp;if(file_exists("outlook.CSV")){ // does the file exist?
&nbsp; &nbsp;$fp=fopen("outlook.CSV","r"); // open it for reading
&nbsp;$ndxRow=1; // the first row of data is always the field index
&nbsp; unset($strd, $endd, $subj, $strt, $loct); // initialize key variables
&nbsp;Do{
&nbsp; $cal_dat = fgetcsv($fp,10000,","); // start reading the file one row at a time
&nbsp;if(!$cal_dat) break; // if the file is empty; abort!
&nbsp;if($ndxRow){ // first time through
&nbsp; foreach($cal_dat as $key=>$fieldName){ // loop through all array elements
&nbsp; &nbsp;switch($fieldName){ // find the desired field names
&nbsp; &nbsp; &nbsp; &nbsp;case "Start Date": $strd=$key;
&nbsp; &nbsp; &nbsp; &nbsp;case "End Date": &nbsp; $endd=$key;
&nbsp; &nbsp; &nbsp; &nbsp;case "Subject": &nbsp; &nbsp;$subj=$key;
&nbsp; &nbsp; &nbsp; &nbsp;case "Start Time": $srtt=$key;
&nbsp; &nbsp; &nbsp; &nbsp;case "Location": &nbsp; $loct=$key;
&nbsp; &nbsp;} // end switch
&nbsp; } // end foreach element
&nbsp; $ndxRow--; // decrement this variable, allow parsing the rest
&nbsp;}
&nbsp;else{ // all the rest of the data file
&nbsp; $es .= "$cal_dat[$strd]x"; // event start date
&nbsp; if($cal_dat[$endd]!=""){ &nbsp; // event end date
&nbsp; &nbsp;$ee .= "$cal_dat[$endd]x";
&nbsp; }
&nbsp; else{ // if no end date, make it the same as start date
&nbsp; &nbsp;$ee .= "$cal_dat[$strd]x";
&nbsp; } // end set start and end date
&nbsp; if(IsSet($subj) && ($cal_dat[$subj]!="")){ // what is the subject <aka. description>
&nbsp; &nbsp;$cal_dat[$subj]=htmlspecialchars($cal_dat[$subj], ENT_QUOTES);
&nbsp; &nbsp;$eTitle .= "$cal_dat[$subj]";
&nbsp; &nbsp;if(IsSet($loct) && ($cal_dat[$loct]!="")){ // append the event location
&nbsp; &nbsp; &nbsp; $eTitle .= " &nbsp;at" . $cal_dat[$loct];
&nbsp; &nbsp; &nbsp;} // end if location is set
&nbsp; &nbsp;if(IsSet($srtt)){ // append the start time for the event
&nbsp; &nbsp; &nbsp; $eTitle .= date(" -- g:i A",strtotime($cal_dat[$srtt]));
&nbsp; &nbsp; &nbsp;} // end if start time is set
&nbsp; &nbsp;$eTitle .= "||";
&nbsp; }
&nbsp; else{
&nbsp; &nbsp;$eTitle .=" ||"; // There is no subject <description> for this event
&nbsp; }// end if a subject exists
&nbsp;}// end if row on or rest of data
&nbsp;}WHILE($cal_dat);
&nbsp;fclose($fp);
&nbsp;} // end if file exists
} // end if read CSV is set &nbsp; &nbsp; &nbsp;


Let me know if there are any problems. I have tested it out for my requirements and may not have caught or thought of other problems.

tomB

Brian
11-05-2003, 04:23 PM
Would you repost this under Hacks and Modifications? Thanks for doing this as I was wanting to look into it myself.! :D

Brian
11-05-2003, 06:39 PM
The final (hopefully) beta version is ready for download to beta testers only.

Only one file has changed, the AE file. Please post your findings.

ve9gra
11-05-2003, 10:40 PM
I'm liking the new edit section... I diff'd the AE files and checked up the changed code, and it all seems good to me. Functionality is bang on.

You did change the escal.php file though.. that section that edits the title of the days to convert " to " and the other special chars...

But everything is working just great now... and it's on my website at the moment...


http://www.chaotic-concepts.org/

I think v4 is now ready for distribution.

tomB
11-06-2003, 05:24 PM
All is well! :)

BTW: reposted the hack for reading Outlook calendar dumps as you requested.

tomB

Brian
11-06-2003, 07:25 PM
Thanks to all of the beta testers!

It looks like next week we'll see the release of EScalendar Version 4.0!

Brian
11-12-2003, 02:26 PM
Download and preview the new Version 4.0 at http://calendar.esscripts.com/site40/ESCal40b.zip.

Please post your comments in the forum.