From: Ian T. <ian...@gm...> - 2004-05-15 03:28:15
|
Hi everyone, I'm pretty close to being done with a reminder script. And would like peoples feedback. I had to find a way to do it using the 1.1 parser and Mozilla Calendar that doesn't use standard alarm features. Take a look. I haven't gotten to try it out since my FTP access to my server is down. If you see a correction, just e-mail me. To use the scripts: To add a reminder: 1. Enter in the URL field of your calendaring program the following realurl; e-mail address; units; length The real url is a regular url that you want to include E-mail address is the address you want to send the reminder to Units is the units of length, ex: DAY, MONTH, YEAR Length is how many of the units before do you want the reminder. 2. Set up your Cron Tab to run the script at a nice interval, like 1 day for me Also if you have any questions jest e-mail me. The three files are: remind.php - The reminder script function.str.split.php - The str_split function if you don't have php5 sent.php - The place where the sent reminders are stored sent.php should have CHMOD 777 or write access by the server. Thanks, Ian |
From: Chad L. <ch...@ch...> - 2004-05-16 20:35:05
|
I didn't see any files attached? -C On May 14, 2004, at 8:29 PM, Ian Turner wrote: > > Units is the units of length, ex: DAY, MONTH, YEAR > Length is how many of the units before do you want the reminder. > 2. Set up your Cron Tab to run the script at a nice interval, like > 1 day for me > > Also if you have any questions jest e-mail me. > > The three files are: > remind.php - The reminder script > function.str.split.php - The str_split function if you don't have php5 > sent.php - The place where the sent reminders are stored > > sent.php should have CHMOD 777 or write access by the server. > > Thanks, |
From: Ian T. <ian...@gm...> - 2004-05-17 04:23:07
|
For some reason my reply got spit back so here it is. That is weird, because Thunderbird says there are attached files in the send message. Here is the contents of the remind.php: <?php # make sure we have the str_split function require('function.str.split.php'); # Get the sent reminders include('sent.php'); # Set the place where the sent reminder places are stored, CHMOD to 0777 for write access by everyone $filename = 'sentreminders.txt'; # php iCalendar script includes and setup $current_view = "month"; define('BASE', '../'); include(BASE.'functions/ical_parser.php'); # Just to make sure unset($eventdate, $eventtype, $event, $place); # Useless as for as i know, neat though $tomorrow = date("Ymd", (mktime(0, 0, 0, date("m") , date("d")+1, date("Y")))); foreach ($master_array as $key => $eventdate) { # Add the new place key $place['date'] = $key; foreach ($eventdate as $key => $eventtype){ # Add the new place key $place['type'] = $key; # Get the type of event, -1 means all day event if ($place['type'] == "-1") { $realeventtype = "All Day Event"; $allday = TRUE; # everything else if normal } else { $allday = FALSE; $realeventtype = "Normal"; } foreach ($eventtype as $key => $event) { # Add the new place key, we now know the extact place the event is in the array $place['uid'] = $key; # Check to see if a reminder has been sent for ($i = 0; $i < count($sent); $i++) { # If everything is the same, they continue twice, one for this foreach, then another for the event if ($sent[$i]['date'] == $place['date'] && $sent[$i]['type'] == $place['type'] && $sent[$i]['uid'] == $place['uid']) { // ****************************************************** continue 2; // This is what I'm not sure about, I want it to continue the next event type for loop // ****************************************************** } } unset($i); # Get the URL $url = $event[$place['uid']][url]; # Explode the text array into variables if ($url != '') { list($url, $email, $a_units, $a_length) = explode(";", $url); } # If there is no e-mail to send the message to, nothing will happen, continue with next event if ($email == '') { continue; } # Creating the Date for the event $tmp = $place['date']; $temp_date_array = str_split("$tmp", 4); $tmp = $temp_date_array[1]; $tmp_date_array = str_split("$tmp", 2); # Get the date of the event, normal mode $e_date = array('year' => $temp_date_array[0], 'month' => $tmp_date_array[0], 'day' => $tmp_date_array[1]); if ($a_length != '' && $a_units != '' && $email != '') { //create event date<br> # When the event takes place, Unix Timestamp $day_of_event = mktime(0, 0, 0, $e_date['month'], $e_date['day'], $e_date['year']); # Calculate whem the reminder needs to be sent, Unix Timestamp switch($a_units) { case 'DAY': $a_time = mktime(0, 0, 0, $e_date['month'], $e_date['day']-$a_length, $e_date['year']); break; case 'MONTH': $a_time = mktime(0, 0, 0, $e_date['month']-$a_length, $e_date['day'], $e_date['year']); break; case 'HOUR': # Right now I don't support Hour reminders, in future releases I may have support break; case 'YEAR': $a_time = mktime(0, 0, 0, $e_date['month'], $e_date['day'], $e_date['year']-$a_length); break; default: # If it isn't one of these, it doesn't need a reminder $a_need = FALSE; } # Get the server time, you might want to calculate for time zone differences, not supported at the moment $now = getdate(); # Compare if a reminder is needed if ($now['year'] == date("Y", $a_time) && $now['mon'] == date("n", $a_time) && $now['mday'] == date("j", $a_time)) { $a_need = TRUE; } } # Create the E-mail and format if needed, specified by the $a_need vaiable if ($a_need == TRUE) { # Format the date in long format using the , ex: January 1st $d_f = date("F jS", mktime(0, 0, 0, $e_date['month'], $e_date['day'], $e_date['year'])); # Get the name of the event, and format it correctly $e_name = urldecode($event[$place['uid']][event_text]); $e_name = str_replace("\,", ",", $e_name); # Add the descriptions (Notes) if there are any if ($event[$place['uid']][description] != '') { $description = urldecode($event[$place['uid']][description]); $display = "Notes - ".str_replace("\,", ",", $description)."\n"; } # Add the location if there is one if ($event[$place['uid']][location] != '') { $location = urldecode($event[$place['uid']][location]); $display .= "Location - ".str_replace("\,", ",", $location)."\n"; } # Add the URL field if there is one if ($url != '') { $display .= "Extra Information - $url\n"; } # Create the time iniatly $when = "When - $d_f (All day Event)"; # Recreate the time if it isn't an all day event if ($allday == FALSE) { $e_start = date("g:i A", $event[$place['uid']][start_unixtime]); $e_end = date("g:i A", $event[$place['uid']][end_unixtime]); $when = "When - $d_f from $e_start to $e_end"; } # Create the message subject $subject = 'Reminder: '.$e_name.' - '.$d_f; # Create the message $message = "Troop 3 Event Reminder:\n\n$event_name\n$when\n\n$display\n\nThis e-mail message was automaticly sent\nby the php iCalendar 1.1 Reminder"; # Mail the message to any email address with headers mail($email, $subject, $message, "From: Troop 3 Calendar Reminder <bs...@li...>\r\n" . "Reply-To: bs...@li...\r\n" . "X-Mailer: php iCalendar 1.1/Digital Solutions reminder mod/PHP" . phpversion()); //echo "E-mail Sent\n"; #Open file and write the place, so that we know not to send this reminder again $fp = fopen($filename, "a+"); $num_reminders = count($sent); $sentreminder = "<?php # Reminder Number ".$num_reminders." \$sent[$num_reminders]['date'] = ".$place['date']." \$sent[$num_reminders]['type'] = ".$place['type']." \$sent[$num_reminders]['uid'] = ".$place['uid']." ?>\n\n"; fwrite($fp, $sentreminder); fclose($fp); } # Delete all the variables used during the process unset($url, $email, $a_units, $a_length, $tmp, $temp_date_array, $e_date, $tmp_date_array, $day_of_event, $a_time, $a_need, $now, $d_f, $e_name, $description, $display, $location, $when, $allday, $e_start, $e_end, $subject, $message, $fp, $num_reminders, $sentreminder); } # close event } # close type } # close date ?> And here is the contents of function.str.split.php: <?php // Define str_split(), if one isn't using PHP5. if (!function_exists('str_split')) { function str_split($str, $length = 1) { // Return false if parameter isn't string, length isn't numeric, or length is 0. if (!is_string($str)|| !is_numeric($length) || $length == 0) { return FALSE; } // Define array to be used to split. $strArr = array(); // Loop through all characters and stick them in the array. for ($i = 0; $i < strlen($str); $i += $length) { if (strlen(substr($str, $i)) < $length) { $strArr[] = substr($str, $i); } else { $strArr[] = substr($str, $i, $length); } } // Return the array. return $strArr; } } ?> For the sent.php just make a new php file that is empty. Ian Chad Little wrote: > I didn't see any files attached? > > -C > > On May 14, 2004, at 8:29 PM, Ian Turner wrote: > >> >> Units is the units of length, ex: DAY, MONTH, YEAR >> Length is how many of the units before do you want the reminder. >> 2. Set up your Cron Tab to run the script at a nice interval, like >> 1 day for me >> >> Also if you have any questions jest e-mail me. >> >> The three files are: >> remind.php - The reminder script >> function.str.split.php - The str_split function if you don't have php5 >> sent.php - The place where the sent reminders are stored >> >> sent.php should have CHMOD 777 or write access by the server. >> >> Thanks, > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: SourceForge.net Broadband > Sign-up now for SourceForge Broadband and get the fastest > 6.0/768 connection for only $19.95/mo for the first 3 months! > http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click > _______________________________________________ > Phpicalendar-devel mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpicalendar-devel > > |