function AJsubmitEditRequest() { global $user; $requestid = getContinuationVar('requestid'); $openend = getContinuationVar('openend'); $allownousercheck = getContinuationVar('nousercheck'); $modifystart = getContinuationVar('modifystart'); $startdays = getContinuationVar('startdays'); $lengths = getContinuationVar('lengths'); $maxextend = getContinuationVar('maxextend'); $allowindefiniteend = getContinuationVar('allowindefiniteend'); $request = getRequestInfo($requestid, 1); if (is_null($request)) { $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); sendJSON(array('status' => 'norequest', 'html' => i('The selected reservation no longer exists.') . '<br><br>', 'cont' => $cont)); return; } if ($modifystart) { $day = processInputVar('day', ARG_NUMERIC, 0); if (!in_array($day, $startdays)) { $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); sendJSON(array('status' => 'error', 'errmsg' => i('Invalid start day submitted'), 'cont' => $cont)); return; } $starttime = processInputVar('starttime', ARG_STRING); if (!preg_match('/^(([01][0-9])|(2[0-3]))([0-5][0-9])$/', $starttime, $matches)) { $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); sendJSON(array('status' => 'error', 'errmsg' => i("Invalid start time submitted"), 'cont' => $cont)); return; } preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', $day, $tmp); $startdt = "{$tmp[1]}-{$tmp[2]}-{$tmp[3]} {$matches[1]}:{$matches[4]}:00"; $startts = datetimeToUnix($startdt); } else { $startdt = $request['start']; $startts = datetimeToUnix($startdt); } $endmode = processInputVar('endmode', ARG_STRING); if ($endmode == 'length') { $length = processInputVar('length', ARG_NUMERIC); if (!in_array($length, $lengths)) { $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); sendJSON(array('status' => 'error', 'errmsg' => i("Invalid duration submitted"), 'cont' => $cont)); return; } if ($modifystart) { $endts = $startts + $length * 60; } else { $tmp = datetimeToUnix($request['end']); $endts = $tmp + $length * 60; } $enddt = unixToDatetime($endts); } elseif ($endmode == 'ending') { $ending = processInputVar('ending', ARG_NUMERIC); if (!preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})(([01][0-9])|(2[0-3]))([0-5][0-9])$/', $ending, $tmp) || !checkdate($tmp[2], $tmp[3], $tmp[1])) { $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); sendJSON(array('status' => 'error', 'errmsg' => i("Invalid end date/time submitted"), 'cont' => $cont)); return; } $enddt = "{$tmp[1]}-{$tmp[2]}-{$tmp[3]} {$tmp[4]}:{$tmp[7]}:00"; $endts = datetimeToUnix($enddt); } elseif ($allowindefiniteend && $endmode == 'indefinite') { $endts = datetimeToUnix('2038-01-01 00:00:00'); $enddt = unixToDatetime($endts); } else { $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); sendJSON(array('status' => 'error', 'errmsg' => i("Invalid data submitted"), 'cont' => $cont)); return; } $updategroups = 0; $updateservername = 0; if ($request['serverrequest']) { if ($user['showallgroups']) { $groups = getUserGroups(0); } else { $groups = getUserGroups(0, $user['affiliationid']); } $admingroupid = processInputVar('admingroupid', ARG_NUMERIC); $logingroupid = processInputVar('logingroupid', ARG_NUMERIC); if ($admingroupid != 0 && !array_key_exists($admingroupid, $groups) && $admingroupid != $request['admingroupid'] || $logingroupid != 0 && !array_key_exists($logingroupid, $groups) && $logingroupid != $request['logingroupid']) { $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); sendJSON(array('status' => 'error', 'errmsg' => i("Invalid user group submitted"), 'cont' => $cont)); return; } $testadmingroupid = $admingroupid; if ($admingroupid == 0) { $testadmingroupid = ''; } $testlogingroupid = $logingroupid; if ($logingroupid == 0) { $testlogingroupid = ''; } if ($testadmingroupid != $request['admingroupid'] || $testlogingroupid != $request['logingroupid']) { $updategroups = 1; } $servername = processInputVar('servername', ARG_STRING); if (!preg_match('/^([-a-zA-Z0-9\\.\\(\\)_ ]){3,255}$/', $servername)) { $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); sendJSON(array('status' => 'error', 'errmsg' => i("The name can only contain letters, numbers, spaces, dashes(-), and periods(.) and can be from 3 to 255 characters long"), 'cont' => $cont)); return; } if ($servername != $request['servername']) { $servername = mysql_real_escape_string($servername); $updateservername = 1; } } $h = ''; $max = getMaxOverlap($user['id']); if (checkOverlap($startts, $endts, $max, $requestid)) { if ($max == 0) { $m = i("The time you requested overlaps with another reservation you currently have. You are only allowed to have a single reservation at any given time. Please select another time for the reservation."); $h .= preg_replace("/(.{1,60}([ \n]|\$))/", '\\1<br>', $m) . "<br>"; } else { $m = sprintf(i("The time you requested overlaps with another reservation you currently have. You are allowed to have %s overlapping reservations at any given time. Please select another time for the reservation."), $max); $h .= preg_replace("/(.{1,60}([ \n]|\$))/", '\\1<br>', $m) . "<br>"; } $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); sendJSON(array('status' => 'error', 'errmsg' => $h, 'cont' => $cont)); return; } if ($request['serverrequest'] && (!empty($request['fixedIP']) || !empty($request['fixedMAC']))) { $ip = $request['fixedIP']; $mac = $request['fixedMAC']; } else { $ip = ''; $mac = ''; } $imageid = $request['reservations'][0]['imageid']; $images = getImages(); $revisions = array(); foreach ($request['reservations'] as $key => $res) { $revisions[$res['imageid']][$key] = $res['imagerevisionid']; } $rc = isAvailable($images, $imageid, $revisions, $startts, $endts, 1, $requestid, 0, 0, 0, $ip, $mac); $data = array(); if ($rc < 1) { $cdata = array('now' => 0, 'start' => $startts, 'end' => $endts, 'server' => $allowindefiniteend, 'imageid' => $imageid, 'requestid' => $requestid); if (!$modifystart) { $cdata['extendonly'] = 1; } $sugcont = addContinuationsEntry('AJshowRequestSuggestedTimes', $cdata); if (array_key_exists('subimages', $images[$imageid]) && count($images[$imageid]['subimages'])) { $data['sugcont'] = 'cluster'; } else { $data['sugcont'] = $sugcont; } addChangeLogEntry($request["logid"], NULL, $enddt, $startdt, NULL, NULL, 0); } if ($rc == -3) { $msgip = ''; $msgmac = ''; if (!empty($ip)) { $msgip = " ({$ip})"; } if (!empty($mac)) { $msgmac = " ({$mac})"; } $h .= sprintf(i("The reserved IP (%s) or MAC address (%s) conflicts with another reservation using the same IP or MAC address. Please select a different time to use the image."), $msgip, $msgmac); $h = preg_replace("/(.{1,60}([ \n]|\$))/", '\\1<br>', $h); $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); $data['status'] = 'conflict'; $data['errmsg'] = $h; $data['cont'] = $cont; sendJSON($data); return; } elseif ($rc == -2) { $m = i("The time you requested overlaps with a maintenance window. Please select a different time to use the image."); $h .= preg_replace("/(.{1,60}([ \n]|\$))/", '\\1<br>', $m) . "<br>"; $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); $data['status'] = 'conflict'; $data['errmsg'] = $h; $data['cont'] = $cont; sendJSON($data); return; } elseif ($rc == -1) { $m = i("The reservation you are modifying is for an environment limited in the number of concurrent reservations that can be made. The time or duration you have requested overlaps with too many other reservations for the same image. Please select another time or duration for the reservation."); $h .= preg_replace("/(.{1,60}([ \n]|\$))/", '\\1<br>', $m) . "<br>"; $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); $data['status'] = 'conflict'; $data['errmsg'] = $h; $data['cont'] = $cont; sendJSON($data); return; } elseif ($rc > 0) { updateRequest($requestid); $serversets = array(); $reqsets = array(); if ($updategroups && $request['laststateid'] != 24) { if ($admingroupid == 0) { $admingroupid = 'NULL'; } if ($logingroupid == 0) { $logingroupid = 'NULL'; } $serversets[] = "admingroupid = {$admingroupid}"; $serversets[] = "logingroupid = {$logingroupid}"; addChangeLogEntryOther($request['logid'], "event:usergroups|admingroupid:{$admingroupid}|logingroupid:{$logingroupid}"); $reqsets[] = "stateid = 29"; } if ($updateservername) { $serversets[] = "name = '{$servername}'"; } if ($allownousercheck) { $newnousercheck = processInputVar('newnousercheck', ARG_NUMERIC); if (($newnousercheck == 1 || $newnousercheck == 0) && $newnousercheck == $request['checkuser']) { $reqsets[] = "checkuser = (1 - checkuser)"; } } if (count($serversets)) { $sets = implode(',', $serversets); $query = "UPDATE serverrequest " . "SET {$sets} " . "WHERE requestid = {$requestid}"; doQuery($query); } if (count($reqsets)) { $sets = implode(',', $reqsets); $query = "UPDATE request " . "SET {$sets} " . "WHERE id = {$requestid}"; doQuery($query); } sendJSON(array('status' => 'success')); cleanSemaphore(); return; } else { $m = i("The time period you have requested is not available. Please select a different time."); $h .= preg_replace("/(.{1,55}([ \n]|\$))/", '\\1<br>', $m) . "<br>"; $cdata = getContinuationVar(); $cont = addContinuationsEntry('AJsubmitEditRequest', $cdata, SECINDAY, 1, 0); $data['status'] = 'conflict'; $data['errmsg'] = $h; $data['cont'] = $cont; sendJSON($data); } }
if ($this_date_tmp > $recur_data_date) { $time_key = '0000'; } # the day is not the last day of the recurrence if ($this_date_tmp < $end_date_tmp) { $display_end_tmp = '2400'; } } if ($this_date_tmp == $end_date_tmp && $end_time == '0000') { continue; } if (!isset($master_array[$this_date_tmp][$time_key][$uid]['sequence']) || $sequence > $master_array[$this_date_tmp][$time_key][$uid]['sequence']) { $master_array[$this_date_tmp][$time_key][$uid] = array('event_start' => $start_time, 'event_end' => $end_time, 'display_start' => $time_key, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => 0, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => $spans_day, 'location' => $location, 'categories' => $vtodo_categories, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'timezone' => $start_tz, 'other' => trim($other), 'geo' => $geo, 'url' => $url, 'sequence' => $sequence, 'recur' => $recur); } if ($time_key > -1) { checkOverlap($this_date_tmp, $time_key, $uid); } } } # end foreach recur_data unset($recur_data); // This should remove any exdates that were missed. // Added for version 0.9.5 modified in 2.22 remove anything that doesn't have an event_start if (is_array($except_dates)) { foreach ($except_dates as $key => $value) { if (isset($master_array[$value])) { foreach ($master_array[$value] as $time => $value2) { if (!isset($value2[$uid]['event_start'])) { unset($master_array[$value][$time][$uid]); } }
function submitEditRequest() { global $user, $submitErr, $viewmode, $mode; $data = getContinuationVar(); $request = getRequestInfo($data["requestid"]); print "<H2>Modify Reservation</H2>\n"; $hour = $data["hour"]; if ($data["hour"] == 12) { if ($data["meridian"] == "am") { $hour = 0; } } elseif ($data["meridian"] == "pm") { $hour = $data["hour"] + 12; } $tmp = explode('/', $data["day"]); $start = mktime($hour, $data["minute"], "0", $tmp[0], $tmp[1], $tmp[2]); if ($data['openend'] && $data['ending'] == 'date') { $end = datetimeToUnix($data['enddate']); } else { if (datetimeToUnix($request["start"]) < datetimeToUnix($request["daterequested"])) { $end = $start + $data["length"] * 60 + 900; } else { $end = $start + $data["length"] * 60; } } // get semaphore lock if (!semLock()) { abort(3); } $max = getMaxOverlap($user['id']); if (checkOverlap($start, $end, $max, $data["requestid"])) { if ($max == 0) { print "<font color=\"#ff0000\">The time you requested overlaps with "; print "another reservation you currently have. You are only allowed "; print "to have a single reservation at any given time. Please select "; print "another time to use the application.</font><br><br>\n"; } else { print "<font color=\"#ff0000\">The time you requested overlaps with "; print "another reservation you currently have. You are allowed "; print "to have {$max} overlapping reservations at any given time. "; print "Please select another time to use the application.</font><br>"; print "<br>\n"; } $submitErr = 1; editRequest(); return; } $rc = isAvailable(getImages(), $data["imageid"], $start, $end, $data["os"], $data["requestid"]); if ($rc == -1) { print "You have requested an environment that is limited in the number "; print "of concurrent reservations that can be made. No further "; print "reservations for the environment can be made for the time you "; print "have selected. Please select another time to use the "; print "environment.<br>"; addChangeLogEntry($request["logid"], NULL, unixToDatetime($end), unixToDatetime($start), NULL, NULL, 0); } elseif ($rc > 0) { updateRequest($data["requestid"]); if ($data["started"]) { if ($data['openend'] && $data['ending'] == 'date') { print "Your request to change the ending of your reservation for <b>"; print "{$data["prettyimage"]}</b> to {$data['enddate']} "; print "has been accepted.<br><br>\n"; } else { $remaining = ($end - time()) / 60; print "Your request to extend your reservation for <b>"; print "{$data["prettyimage"]}</b> by " . prettyLength($data["extend"]); print " has been accepted.<br><br>\n"; print "You now have " . prettyLength($remaining) . " remaining for "; print "your reservation<br>\n"; } } else { print "Your request to use <b>" . $data["prettyimage"] . "</b> on "; if (datetimeToUnix($request["start"]) < datetimeToUnix($request["daterequested"])) { print prettyDatetime($request["daterequested"]); } else { print prettyDatetime($start); } if ($data['openend'] && $data['ending'] == 'date') { print " until " . prettyDatetime($end); } else { print " for " . prettyLength($data["length"]); } print " has been accepted.<br>\n"; } } else { $cdata = array('imageid' => $data['imageid'], 'length' => $data['length'], 'requestid' => $data['requestid']); $cont = addContinuationsEntry('selectTimeTable', $cdata); print "The time you have requested is not available. You may "; print "<a href=\"" . BASEURL . SCRIPT . "?continuation={$cont}\">"; print "view a timetable</a> of free and reserved times to find "; print "a time that will work for you.<br>\n"; addChangeLogEntry($request["logid"], NULL, unixToDatetime($end), unixToDatetime($start), NULL, NULL, 0); } }
function icalToArray($filename, $fromdate, $todate) { // $filename = "/var/www/phpicalendar/calendars/pepe.ics"; $timezone = "America/Buenos_Aires"; $tz_array['America/Buenos_Aires'] = array('-0300', '-0300'); $master_array = array(); $ifile = @fopen($filename, "r"); if ($ifile == FALSE) { exit("Cant Open file: " . $filename . "\n"); } $nextline = fgets($ifile, 1024); if (trim($nextline) != 'BEGIN:VCALENDAR') { exit("It is not a valid ical file: " . $filename . "\n"); } // $master_array['-4'] = Array ( Array ( 'mtime' => 1182541233, 'filename' => './calendars/pepe.ics','webcal' => 'no')); // $master_array['-3'] = Array ( 'pepe'); // Set a value so we can check to make sure $master_array contains valid data $master_array['-1'] = 'valid cal file'; // Set default calendar name - can be overridden by X-WR-CALNAME $calendar_name = $cal_filename; $master_array['calendar_name'] = $calendar_name; $overlap_array = array(); // read file in line by line // XXX end line is skipped because of the 1-line readahead while (!feof($ifile)) { $line = $nextline; $nextline = fgets($ifile, 1024); $nextline = ereg_replace("[\r\n]", "", $nextline); #handle continuation lines that start with either a space or a tab (MS Outlook) while ($nextline[0] == " " || $nextline[0] == "\t") { $line = $line . substr($nextline, 1); $nextline = fgets($ifile, 1024); $nextline = ereg_replace("[\r\n]", "", $nextline); } $line = trim($line); switch ($line) { case 'BEGIN:VEVENT': // each of these vars were being set to an empty string unset($start_time, $end_time, $start_date, $end_date, $summary, $allday_start, $allday_end, $start, $end, $the_duration, $beginning, $rrule_array, $start_of_vevent, $description, $url, $valarm_description, $start_unixtime, $end_unixtime, $display_end_tmp, $end_time_tmp1, $recurrence_id, $uid, $class, $location, $rrule, $abs_until, $until_check, $until, $bymonth, $byday, $bymonthday, $byweek, $byweekno, $byminute, $byhour, $bysecond, $byyearday, $bysetpos, $wkst, $interval, $number); $except_dates = array(); $except_times = array(); $bymonth = array(); $bymonthday = array(); $first_duration = TRUE; $count = 1000000; $valarm_set = FALSE; $attendee = array(); $organizer = array(); break; case 'END:VEVENT': if (!isset($url)) { $url = ''; } if (!isset($type)) { $type = ''; } // Handle DURATION if (!isset($end_unixtime) && isset($the_duration)) { $end_unixtime = $start_unixtime + $the_duration; $end_time = date('Hi', $end_unixtime); } // CLASS support if (isset($class)) { if ($class == 'PRIVATE') { $summary = '**PRIVATE**'; $description = '**PRIVATE**'; } elseif ($class == 'CONFIDENTIAL') { $summary = '**CONFIDENTIAL**'; $description = '**CONFIDENTIAL**'; } } // make sure we have some value for $uid if (!isset($uid)) { $uid = $uid_counter; $uid_counter++; $uid_valid = false; } else { $uid_valid = true; } if ($uid_valid && isset($processed[$uid]) && isset($recurrence_id['date'])) { $old_start_date = $processed[$uid][0]; $old_start_time = $processed[$uid][1]; if ($recurrence_id['value'] == 'DATE') { $old_start_time = '-1'; } $start_date_tmp = $recurrence_id['date']; if (!isset($start_date)) { $start_date = $old_start_date; } if (!isset($start_time)) { $start_time = $master_array[$old_start_date][$old_start_time][$uid]['event_start']; } if (!isset($start_unixtime)) { $start_unixtime = $master_array[$old_start_date][$old_start_time][$uid]['start_unixtime']; } if (!isset($end_unixtime)) { $end_unixtime = $master_array[$old_start_date][$old_start_time][$uid]['end_unixtime']; } if (!isset($end_time)) { $end_time = $master_array[$old_start_date][$old_start_time][$uid]['event_end']; } if (!isset($summary)) { $summary = $master_array[$old_start_date][$old_start_time][$uid]['event_text']; } if (!isset($length)) { $length = $master_array[$old_start_date][$old_start_time][$uid]['event_length']; } if (!isset($description)) { $description = $master_array[$old_start_date][$old_start_time][$uid]['description']; } if (!isset($location)) { $location = $master_array[$old_start_date][$old_start_time][$uid]['location']; } if (!isset($organizer)) { $organizer = $master_array[$old_start_date][$old_start_time][$uid]['organizer']; } if (!isset($status)) { $status = $master_array[$old_start_date][$old_start_time][$uid]['status']; } if (!isset($attendee)) { $attendee = $master_array[$old_start_date][$old_start_time][$uid]['attendee']; } if (!isset($url)) { $url = $master_array[$old_start_date][$old_start_time][$uid]['url']; } removeOverlap($start_date_tmp, $old_start_time, $uid, $master_array, $overlap_array); if (isset($master_array[$start_date_tmp][$old_start_time][$uid])) { unset($master_array[$start_date_tmp][$old_start_time][$uid]); // SJBO added $uid twice here if (sizeof($master_array[$start_date_tmp][$old_start_time]) == 0) { unset($master_array[$start_date_tmp][$old_start_time]); } } $write_processed = false; } else { $write_processed = true; } if (!isset($summary)) { $summary = ''; } if (!isset($description)) { $description = ''; } if (!isset($status)) { $status = ''; } if (!isset($class)) { $class = ''; } if (!isset($location)) { $location = ''; } $mArray_begin = mktime(0, 0, 0, 12, 21, $this_year - 1); $mArray_end = mktime(0, 0, 0, 1, 12, $this_year + 1); if (isset($start_time) && isset($end_time)) { // Mozilla style all-day events or just really long events if ($end_time - $start_time > 2345) { $allday_start = $start_date; $allday_end = $start_date + 1; } } if (isset($start_unixtime, $end_unixtime) && date('Ymd', $start_unixtime) != date('Ymd', $end_unixtime)) { $spans_day = true; $bleed_check = $start_unixtime - $end_unixtime < 60 * 60 * 24 ? '-1' : '0'; } else { $spans_day = false; $bleed_check = 0; } if (isset($start_time) && $start_time != '') { preg_match('/([0-9]{2})([0-9]{2})/', $start_time, $time); preg_match('/([0-9]{2})([0-9]{2})/', $end_time, $time2); if (isset($start_unixtime) && isset($end_unixtime)) { $length = $end_unixtime - $start_unixtime; } else { $length = $time2[1] * 60 + $time2[2] - ($time[1] * 60 + $time[2]); } $drawKey = drawEventTimes($start_time, $end_time); preg_match('/([0-9]{2})([0-9]{2})/', $drawKey['draw_start'], $time3); $hour = $time3[1]; $minute = $time3[2]; } // RECURRENCE-ID Support if (isset($recurrence_d)) { $recurrence_delete["{$recurrence_d}"]["{$recurrence_t}"] = $uid; } // handle single changes in recurring events // Maybe this is no longer need since done at bottom of parser? - CL 11/20/02 if ($uid_valid && $write_processed) { if (!isset($hour)) { $hour = 00; } if (!isset($minute)) { $minute = 00; } $processed[$uid] = array($start_date, $hour . $minute, $type); } // Handling of the all day events if (isset($allday_start) && $allday_start != '') { $start = strtotime($allday_start); if ($spans_day) { $allday_end = date('Ymd', $end_unixtime); } if (isset($allday_end)) { $end = strtotime($allday_end); } else { $end = strtotime('+1 day', $start); } // Changed for 1.0, basically write out the entire event if it starts while the array is written. # while loop handles multi-day allday events to write separate master_array elements for each day. if ($start < $mArray_end && $start < $end) { while ($start != $end && $start < $mArray_end) { $start_date2 = date('Ymd', $start); $master_array[$start_date2]['-1'][$uid] = array('event_text' => $summary, 'description' => $description, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url, 'status' => $status, 'class' => $class); $start = strtotime('+1 day', $start); } if (!$write_processed) { $master_array[$start_date]['-1'][$uid]['exception'] = true; } } } // Handling regular events if (isset($start_time) && $start_time != '' && (!isset($allday_start) || $allday_start == '')) { if ($end_time >= $bleed_time && $bleed_check == '-1') { $start_tmp = strtotime(date('Ymd', $start_unixtime)); $end_date_tmp = date('Ymd', $end_unixtime); while ($start_tmp < $end_unixtime) { $start_date_tmp = date('Ymd', $start_tmp); if ($start_date_tmp == $start_date) { $time_tmp = $hour . $minute; $start_time_tmp = $start_time; } else { $time_tmp = '0000'; $start_time_tmp = '0000'; } if ($start_date_tmp == $end_date_tmp) { $end_time_tmp = $end_time; } else { $end_time_tmp = '2400'; $display_end_tmp = $end_time; } $master_array[$start_date_tmp][$time_tmp][$uid] = array('event_start' => $start_time_tmp, 'event_end' => $end_time_tmp, 'start_unixtime' => $start_unixtime, 'end_unixtime' => $end_unixtime, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => 0, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => true, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url); if (isset($display_end_tmp)) { $master_array[$start_date_tmp][$time_tmp][$uid]['display_end'] = $display_end_tmp; } checkOverlap($start_date_tmp, $time_tmp, $uid, $master_array, $overlap_array); $start_tmp = strtotime('+1 day', $start_tmp); } if (!$write_processed) { $master_array[$start_date][$hour . $minute][$uid]['exception'] = true; } } else { if ($bleed_check == '-1') { $display_end_tmp = $end_time; $end_time_tmp1 = '2400'; } if (!isset($end_time_tmp1)) { $end_time_tmp1 = $end_time; } // This if statement should prevent writing of an excluded date if its the first recurrance - CL if (!in_array($start_date, $except_dates)) { $master_array[$start_date][$hour . $minute][$uid] = array('event_start' => $start_time, 'event_end' => $end_time_tmp1, 'start_unixtime' => $start_unixtime, 'end_unixtime' => $end_unixtime, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => 0, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => false, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url); if (isset($display_end_tmp)) { $master_array[$start_date][$hour . $minute][$uid]['display_end'] = $display_end_tmp; } checkOverlap($start_date, $hour . $minute, $uid, $master_array, $overlap_array); if (!$write_processed) { $master_array[$start_date][$hour . $minute][$uid]['exception'] = true; } } } } // Handling of the recurring events, RRULE if (isset($rrule_array) && is_array($rrule_array)) { if (isset($allday_start) && $allday_start != '') { $hour = '-'; $minute = '1'; $rrule_array['START_DAY'] = $allday_start; $rrule_array['END_DAY'] = $allday_end; $rrule_array['END'] = 'end'; $recur_start = $allday_start; $start_date = $allday_start; if (isset($allday_end)) { $diff_allday_days = dayCompare($allday_end, $allday_start); } else { $diff_allday_days = 1; } } else { $rrule_array['START_DATE'] = $start_date; $rrule_array['START_TIME'] = $start_time; $rrule_array['END_TIME'] = $end_time; $rrule_array['END'] = 'end'; } $start_date_time = strtotime($start_date); if (!isset($fromdate)) { #this should happen if not in one of the rss views /* $this_month_start_time = strtotime($this_year.$this_month.'01'); if ($current_view == 'year' || ($save_parsed_cals == 'yes' && !$is_webcal)|| $current_view == 'print' && $printview == 'year') { $start_range_time = strtotime($this_year.'-01-01 -2 weeks'); $end_range_time = strtotime($this_year.'-12-31 +2 weeks'); } else { $start_range_time = strtotime('-1 month -2 day', $this_month_start_time); $end_range_time = strtotime('+2 month +2 day', $this_month_start_time); }*/ } else { $start_range_time = strtotime($fromdate); $end_range_time = strtotime($todate) + 60 * 60 * 24; } foreach ($rrule_array as $key => $val) { switch ($key) { case 'FREQ': switch ($val) { case 'YEARLY': $freq_type = 'year'; break; case 'MONTHLY': $freq_type = 'month'; break; case 'WEEKLY': $freq_type = 'week'; break; case 'DAILY': $freq_type = 'day'; break; case 'HOURLY': $freq_type = 'hour'; break; case 'MINUTELY': $freq_type = 'minute'; break; case 'SECONDLY': $freq_type = 'second'; break; } $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = strtolower($val); break; case 'COUNT': $count = $val; $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $count; break; case 'UNTIL': $until = str_replace('T', '', $val); $until = str_replace('Z', '', $until); if (strlen($until) == 8) { $until = $until . '235959'; } $abs_until = $until; ereg('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})', $until, $regs); $until = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = localizeDate($dateFormat_week, $until); break; case 'INTERVAL': if ($val > 0) { $number = $val; $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $number; } break; case 'BYSECOND': $bysecond = $val; $bysecond = split(',', $bysecond); $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $bysecond; break; case 'BYMINUTE': $byminute = $val; $byminute = split(',', $byminute); $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $byminute; break; case 'BYHOUR': $byhour = $val; $byhour = split(',', $byhour); $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $byhour; break; case 'BYDAY': $byday = $val; $byday = split(',', $byday); $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $byday; break; case 'BYMONTHDAY': $bymonthday = $val; $bymonthday = split(',', $bymonthday); $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $bymonthday; break; case 'BYYEARDAY': $byyearday = $val; $byyearday = split(',', $byyearday); $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $byyearday; break; case 'BYWEEKNO': $byweekno = $val; $byweekno = split(',', $byweekno); $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $byweekno; break; case 'BYMONTH': $bymonth = $val; $bymonth = split(',', $bymonth); $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $bymonth; break; case 'BYSETPOS': $bysetpos = $val; $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $bysetpos; break; case 'WKST': $wkst = $val; $master_array[$start_date][$hour . $minute][$uid]['recur'][$key] = $wkst; break; case 'END': $recur = $master_array[$start_date][$hour . $minute][$uid]['recur']; // Modify the COUNT based on BYDAY if (is_array($byday) && isset($count)) { $blah = sizeof($byday); $count = $count / $blah; unset($blah); } if (!isset($number)) { $number = 1; } // if $until isn't set yet, we set it to the end of our range we're looking at if (!isset($until)) { $until = $end_range_time; } if (!isset($abs_until)) { $abs_until = date('YmdHis', $end_range_time); } $end_date_time = $until; $start_range_time_tmp = $start_range_time; $end_range_time_tmp = $end_range_time; // echo date("Ymd",$until)." ".date("Ymd",$end_range_time)."<br>"; // echo date("Ymd",$end_range_time_tmp)." >= ".date("Ymd",$start_date_time)." && ".date("Ymd",$start_range_time_tmp)." <= ".date("Ymd",$end_date_time)."<br>"; // If the $end_range_time is less than the $start_date_time, or $start_range_time is greater // than $end_date_time, we may as well forget the whole thing // It doesn't do us any good to spend time adding data we aren't even looking at // this will prevent the year view from taking way longer than it needs to if ($end_range_time_tmp >= $start_date_time && $start_range_time_tmp <= $end_date_time) { // if the beginning of our range is less than the start of the item, we may as well set it equal to it if ($start_range_time_tmp < $start_date_time) { $start_range_time_tmp = $start_date_time; } if ($end_range_time_tmp > $end_date_time) { $end_range_time_tmp = $end_date_time; } // initialize the time we will increment $next_range_time = $start_range_time_tmp; // FIXME: This is a hack to fix repetitions with $interval > 1 if ($count > 1 && $number > 1) { $count = 1 + ($count - 1) * $number; } $count_to = 0; // start at the $start_range and go until we hit the end of our range. if (!isset($wkst)) { $wkst = 'SU'; } $wkst3char = two2threeCharDays($wkst); while ($next_range_time >= $start_range_time_tmp && $next_range_time <= $end_range_time_tmp && $count_to != $count) { $func = $freq_type . 'Compare'; $diff = $func(date('Ymd', $next_range_time), $start_date); if ($diff < $count) { if ($diff % $number == 0) { $interval = $number; switch ($rrule_array['FREQ']) { case 'DAILY': $next_date_time = $next_range_time; $recur_data[] = $next_date_time; break; case 'WEEKLY': // Populate $byday with the default day if it's not set. if (!isset($byday)) { $byday[] = strtoupper(substr(date('D', $start_date_time), 0, 2)); } if (is_array($byday)) { foreach ($byday as $day) { $day = two2threeCharDays($day); #need to find the first day of the appropriate week. #dateOfweek uses weekstartday as a global variable. This has to be changed to $wkst, #but then needs to be reset for other functions $week_start_day_tmp = $week_start_day; $week_start_day = $wkst3char; $the_sunday = dateOfWeek(date("Ymd", $next_range_time), $wkst3char); $next_date_time = strtotime($day, strtotime($the_sunday)) + 12 * 60 * 60; $week_start_day = $week_start_day_tmp; #see above reset to global value #reset $next_range_time to first instance in this week. if ($next_date_time < $next_range_time) { $next_range_time = $next_date_time; } // Since this renders events from $next_range_time to $next_range_time + 1 week, I need to handle intervals // as well. This checks to see if $next_date_time is after $day_start (i.e., "next week"), and thus // if we need to add $interval weeks to $next_date_time. if ($next_date_time > strtotime($week_start_day, $next_range_time) && $interval > 1) { # $next_date_time = strtotime('+'.($interval - 1).' '.$freq_type, $next_date_time); } $recur_data[] = $next_date_time; } } break; case 'MONTHLY': if (empty($bymonth)) { $bymonth = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); } $next_range_time = strtotime(date('Y-m-01', $next_range_time)); $next_date_time = $next_date_time; if (isset($bysetpos)) { /* bysetpos code from dustinbutler start on day 1 or last day. if day matches any BYDAY the count is incremented. SETPOS = 4, need 4th match SETPOS = -1, need 1st match */ $year = date('Y', $next_range_time); $month = date('m', $next_range_time); if ($bysetpos > 0) { $next_day = '+1 day'; $day = 1; } else { $next_day = '-1 day'; $day = $totalDays[$month]; } $day = mktime(0, 0, 0, $month, $day, $year); $countMatch = 0; while ($countMatch != abs($bysetpos)) { /* Does this day match a BYDAY value? */ $thisDay = $day; $textDay = strtoupper(substr(date('D', $thisDay), 0, 2)); if (in_array($textDay, $byday)) { $countMatch++; } $day = strtotime($next_day, $thisDay); } $recur_data[] = $thisDay; } elseif (isset($bymonthday) && !isset($byday)) { foreach ($bymonthday as $day) { if ($day < 0) { $day = date('t', $next_range_time) + $day + 1; } $year = date('Y', $next_range_time); $month = date('m', $next_range_time); if (checkdate($month, $day, $year)) { $next_date_time = mktime(0, 0, 0, $month, $day, $year); $recur_data[] = $next_date_time; } } } elseif (is_array($byday)) { foreach ($byday as $day) { ereg('([-\\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr); //Added for 2.0 when no modifier is set if ($byday_arr[2] != '') { $nth = $byday_arr[2] - 1; } else { $nth = 0; } $on_day = two2threeCharDays($byday_arr[3]); $on_day_num = two2threeCharDays($byday_arr[3], false); if (isset($byday_arr[1]) && $byday_arr[1] == '-') { $last_day_tmp = date('t', $next_range_time); $next_range_time = strtotime(date('Y-m-' . $last_day_tmp, $next_range_time)); $last_tmp = date('w', $next_range_time) == $on_day_num ? '' : 'last '; $next_date_time = strtotime($last_tmp . $on_day, $next_range_time) - $nth * 604800; $month = date('m', $next_date_time); if (in_array($month, $bymonth)) { $recur_data[] = $next_date_time; } #reset next_range_time to start of month $next_range_time = strtotime(date('Y-m-' . '1', $next_range_time)); } elseif (isset($bymonthday) && !empty($bymonthday)) { // This supports MONTHLY where BYDAY and BYMONTH are both set foreach ($bymonthday as $day) { $year = date('Y', $next_range_time); $month = date('m', $next_range_time); if (checkdate($month, $day, $year)) { $next_date_time = mktime(0, 0, 0, $month, $day, $year); $daday = strtolower(strftime("%a", $next_date_time)); if ($daday == $on_day && in_array($month, $bymonth)) { $recur_data[] = $next_date_time; } } } } elseif (isset($byday_arr[1]) && $byday_arr[1] != '-') { $next_date_time = strtotime($on_day, $next_range_time) + $nth * 604800; $month = date('m', $next_date_time); if (in_array($month, $bymonth)) { $recur_data[] = $next_date_time; } } $next_date = date('Ymd', $next_date_time); } } break; case 'YEARLY': if (!isset($bymonth) || sizeof($bymonth) == 0) { $m = date('m', $start_date_time); $bymonth = array("{$m}"); } foreach ($bymonth as $month) { // Make sure the month & year used is within the start/end_range. if ($month < date('m', $next_range_time)) { $year = date('Y', $next_range_time); } else { $year = date('Y', $next_range_time); } if (isset($bysetpos)) { /* bysetpos code from dustinbutler start on day 1 or last day. if day matches any BYDAY the count is incremented. SETPOS = 4, need 4th match SETPOS = -1, need 1st match */ if ($bysetpos > 0) { $next_day = '+1 day'; $day = 1; } else { $next_day = '-1 day'; $day = date("t", $month); } $day = mktime(12, 0, 0, $month, $day, $year); $countMatch = 0; while ($countMatch != abs($bysetpos)) { /* Does this day match a BYDAY value? */ $thisDay = $day; $textDay = strtoupper(substr(date('D', $thisDay), 0, 2)); if (in_array($textDay, $byday)) { $countMatch++; } $day = strtotime($next_day, $thisDay); } $recur_data[] = $thisDay; } if (isset($byday) && is_array($byday)) { $checkdate_time = mktime(0, 0, 0, $month, 1, $year); foreach ($byday as $day) { ereg('([-\\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr); if ($byday_arr[2] != '') { $nth = $byday_arr[2] - 1; } else { $nth = 0; } $on_day = two2threeCharDays($byday_arr[3]); $on_day_num = two2threeCharDays($byday_arr[3], false); if ($byday_arr[1] == '-') { $last_day_tmp = date('t', $checkdate_time); $checkdate_time = strtotime(date('Y-m-' . $last_day_tmp, $checkdate_time)); $last_tmp = date('w', $checkdate_time) == $on_day_num ? '' : 'last '; $next_date_time = strtotime($last_tmp . $on_day . ' -' . $nth . ' week', $checkdate_time); } else { $next_date_time = strtotime($on_day . ' +' . $nth . ' week', $checkdate_time); } } } else { $day = date('d', $start_date_time); $next_date_time = mktime(0, 0, 0, $month, $day, $year); //echo date('Ymd',$next_date_time).$summary.'<br>'; } $recur_data[] = $next_date_time; } if (isset($byyearday)) { foreach ($byyearday as $yearday) { ereg('([-\\+]{0,1})?([0-9]{1,3})', $yearday, $byyearday_arr); if ($byyearday_arr[1] == '-') { $ydtime = mktime(0, 0, 0, 12, 31, $this_year); $yearnum = $byyearday_arr[2] - 1; $next_date_time = strtotime('-' . $yearnum . ' days', $ydtime); } else { $ydtime = mktime(0, 0, 0, 1, 1, $this_year); $yearnum = $byyearday_arr[2] - 1; $next_date_time = strtotime('+' . $yearnum . ' days', $ydtime); } $recur_data[] = $next_date_time; } } break; default: // anything else we need to end the loop $next_range_time = $end_range_time_tmp + 100; $count_to = $count; } } else { $interval = 1; } $next_range_time = strtotime('+' . $interval . ' ' . $freq_type, $next_range_time); } else { // end the loop because we aren't going to write this event anyway $count_to = $count; } // use the same code to write the data instead of always changing it 5 times if (isset($recur_data) && is_array($recur_data)) { $recur_data_hour = @substr($start_time, 0, 2); $recur_data_minute = @substr($start_time, 2, 2); foreach ($recur_data as $recur_data_time) { $recur_data_year = date('Y', $recur_data_time); $recur_data_month = date('m', $recur_data_time); $recur_data_day = date('d', $recur_data_time); $recur_data_date = $recur_data_year . $recur_data_month . $recur_data_day; if ($recur_data_time > $start_date_time && $recur_data_time <= $end_date_time && $count_to != $count && !in_array($recur_data_date, $except_dates)) { if (isset($allday_start) && $allday_start != '') { $start_time2 = $recur_data_time; $end_time2 = strtotime('+' . $diff_allday_days . ' days', $recur_data_time); while ($start_time2 < $end_time2) { $start_date2 = date('Ymd', $start_time2); $master_array[$start_date2]['-1'][$uid] = array('event_text' => $summary, 'description' => $description, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url, 'status' => $status, 'class' => $class, 'recur' => $recur); $start_time2 = strtotime('+1 day', $start_time2); } } else { $start_unixtime_tmp = mktime($recur_data_hour, $recur_data_minute, 0, $recur_data_month, $recur_data_day, $recur_data_year); $end_unixtime_tmp = $start_unixtime_tmp + $length; if ($end_time >= $bleed_time && $bleed_check == '-1') { $start_tmp = strtotime(date('Ymd', $start_unixtime_tmp)); $end_date_tmp = date('Ymd', $end_unixtime_tmp); while ($start_tmp < $end_unixtime_tmp) { $start_date_tmp = date('Ymd', $start_tmp); if ($start_date_tmp == $recur_data_year . $recur_data_month . $recur_data_day) { $time_tmp = $hour . $minute; $start_time_tmp = $start_time; } else { $time_tmp = '0000'; $start_time_tmp = '0000'; } if ($start_date_tmp == $end_date_tmp) { $end_time_tmp = $end_time; } else { $end_time_tmp = '2400'; $display_end_tmp = $end_time; } // Let's double check the until to not write past it $until_check = $start_date_tmp . $time_tmp . '00'; if ($abs_until > $until_check) { $master_array[$start_date_tmp][$time_tmp][$uid] = array('event_start' => $start_time_tmp, 'event_end' => $end_time_tmp, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => 0, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => true, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url, 'recur' => $recur); if (isset($display_end_tmp)) { $master_array[$start_date_tmp][$time_tmp][$uid]['display_end'] = $display_end_tmp; } checkOverlap($start_date_tmp, $time_tmp, $uid, $master_array, $overlap_array); } $start_tmp = strtotime('+1 day', $start_tmp); } } else { if ($bleed_check == '-1') { $display_end_tmp = $end_time; $end_time_tmp1 = '2400'; } if (!isset($end_time_tmp1)) { $end_time_tmp1 = $end_time; } // Let's double check the until to not write past it $until_check = $recur_data_date . $hour . $minute . '00'; if ($abs_until > $until_check) { $master_array[$recur_data_date][$hour . $minute][$uid] = array('event_start' => $start_time, 'event_end' => $end_time_tmp1, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => 0, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => false, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url, 'recur' => $recur); if (isset($display_end_tmp)) { $master_array[$recur_data_date][$hour . $minute][$uid]['display_end'] = $display_end_tmp; } checkOverlap($recur_data_date, $hour . $minute, $uid, $master_array, $overlap_array); } } } } } unset($recur_data); } } } } } } // This should remove any exdates that were missed. // Added for version 0.9.5 modified in 2.22 remove anything that doesn't have an event_start if (is_array($except_dates)) { foreach ($except_dates as $key => $value) { if (isset($master_array[$value])) { foreach ($master_array[$value] as $time => $value2) { if (!isset($value2[$uid]['event_start'])) { unset($master_array[$value][$time][$uid]); } } } } } // Clear event data now that it's been saved. unset($start_time, $start_time_tmp, $end_time, $end_time_tmp, $start_unixtime, $start_unixtime_tmp, $end_unixtime, $end_unixtime_tmp, $summary, $length, $description, $status, $class, $location, $organizer, $attendee); break; case 'END:VTODO': if (!$vtodo_priority && $status == 'COMPLETED') { $vtodo_sort = 11; } elseif (!$vtodo_priority) { $vtodo_sort = 10; } else { $vtodo_sort = $vtodo_priority; } // CLASS support if (isset($class)) { if ($class == 'PRIVATE') { $summary = '**PRIVATE**'; $description = '**PRIVATE**'; } elseif ($class == 'CONFIDENTIAL') { $summary = '**CONFIDENTIAL**'; $description = '**CONFIDENTIAL**'; } } $master_array['-2']["{$vtodo_sort}"]["{$uid}"] = array('start_date' => $start_date, 'start_time' => $start_time, 'vtodo_text' => $summary, 'due_date' => $due_date, 'due_time' => $due_time, 'completed_date' => $completed_date, 'completed_time' => $completed_time, 'priority' => $vtodo_priority, 'status' => $status, 'class' => $class, 'categories' => $vtodo_categories, 'description' => $description, 'calname' => $actual_calname); unset($start_date, $start_time, $due_date, $due_time, $completed_date, $completed_time, $vtodo_priority, $status, $class, $vtodo_categories, $summary, $description); $vtodo_set = FALSE; break; case 'BEGIN:VTODO': $vtodo_set = TRUE; break; case 'BEGIN:VALARM': $valarm_set = TRUE; break; case 'END:VALARM': $valarm_set = FALSE; break; default: unset($field, $data, $prop_pos, $property); if (ereg("([^:]+):(.*)", $line, $line)) { $field = $line[1]; $data = $line[2]; $property = $field; $prop_pos = strpos($property, ';'); if ($prop_pos !== false) { $property = substr($property, 0, $prop_pos); } $property = strtoupper($property); switch ($property) { // Start VTODO Parsing // case 'DUE': $datetime = extractDateTime($data, $property, $field, $tz_array); $due_date = $datetime[1]; $due_time = $datetime[2]; break; case 'COMPLETED': $datetime = extractDateTime($data, $property, $field, $tz_array); $completed_date = $datetime[1]; $completed_time = $datetime[2]; break; case 'PRIORITY': $vtodo_priority = "{$data}"; break; case 'STATUS': $status = "{$data}"; break; case 'CLASS': $class = "{$data}"; break; case 'CATEGORIES': $vtodo_categories = "{$data}"; break; // // End VTODO Parsing // // End VTODO Parsing case 'DTSTART': $datetime = extractDateTime($data, $property, $field, $tz_array); $start_unixtime = $datetime[0]; $start_date = $datetime[1]; $start_time = $datetime[2]; $allday_start = $datetime[3]; break; case 'DTEND': $datetime = extractDateTime($data, $property, $field, $tz_array); $end_unixtime = $datetime[0]; $end_date = $datetime[1]; $end_time = $datetime[2]; $allday_end = $datetime[3]; break; case 'EXDATE': $data = split(",", $data); foreach ($data as $exdata) { $exdata = str_replace('T', '', $exdata); $exdata = str_replace('Z', '', $exdata); preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})/', $exdata, $regs); $except_dates[] = $regs[1] . $regs[2] . $regs[3]; // Added for Evolution, since they dont think they need to tell me which time to exclude. if ($regs[4] == '' && $start_time != '') { $except_times[] = $start_time; } else { $except_times[] = $regs[4] . $regs[5]; } } break; case 'SUMMARY': $data = str_replace("\\n", "<br />", $data); $data = str_replace("\\t", " ", $data); $data = str_replace("\\r", "<br />", $data); $data = str_replace('$', '$', $data); $data = stripslashes($data); // $data = htmlentities(urlencode($data)); $data = htmlentities($data); if ($valarm_set == FALSE) { $summary = $data; } else { $valarm_summary = $data; } break; case 'DESCRIPTION': $data = str_replace("\\n", "<br />", $data); $data = str_replace("\\t", " ", $data); $data = str_replace("\\r", "<br />", $data); $data = str_replace('$', '$', $data); $data = stripslashes($data); $data = htmlentities(urlencode($data)); if ($valarm_set == FALSE) { $description = $data; } else { $valarm_description = $data; } break; case 'RECURRENCE-ID': $parts = explode(';', $field); foreach ($parts as $part) { $eachval = split('=', $part); if ($eachval[0] == 'RECURRENCE-ID') { // do nothing } elseif ($eachval[0] == 'TZID') { $recurrence_id['tzid'] = parse_tz($eachval[1]); } elseif ($eachval[0] == 'RANGE') { $recurrence_id['range'] = $eachval[1]; } elseif ($eachval[0] == 'VALUE') { $recurrence_id['value'] = $eachval[1]; } else { $recurrence_id[] = $eachval[1]; } } unset($parts, $part, $eachval); $data = str_replace('T', '', $data); $data = str_replace('Z', '', $data); ereg('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs); $recurrence_id['date'] = $regs[1] . $regs[2] . $regs[3]; $recurrence_id['time'] = $regs[4] . $regs[5]; $recur_unixtime = mktime($regs[4], $regs[5], 0, $regs[2], $regs[3], $regs[1]); $dlst = date('I', $recur_unixtime); $server_offset_tmp = chooseOffset($recur_unixtime, &$timezone, &$tz_array); if (isset($recurrence_id['tzid'])) { $tz_tmp = $recurrence_id['tzid']; $offset_tmp = $tz_array[$tz_tmp][$dlst]; } elseif (isset($calendar_tz)) { $offset_tmp = $tz_array[$calendar_tz][$dlst]; } else { $offset_tmp = $server_offset_tmp; } $recur_unixtime = calcTime($offset_tmp, $server_offset_tmp, $recur_unixtime); $recurrence_id['date'] = date('Ymd', $recur_unixtime); $recurrence_id['time'] = date('Hi', $recur_unixtime); $recurrence_d = date('Ymd', $recur_unixtime); $recurrence_t = date('Hi', $recur_unixtime); unset($server_offset_tmp); break; case 'UID': $uid = $data; break; case 'X-WR-CALNAME': $actual_calname = $data; $master_array['calendar_name'] = $actual_calname; $cal_displaynames[$cal_key] = $actual_calname; #correct the default calname based on filename break; case 'X-WR-TIMEZONE': $calendar_tz = parse_tz($data); $master_array['calendar_tz'] = $calendar_tz; break; case 'DURATION': if ($first_duration == TRUE && !stristr($field, '=DURATION')) { ereg('^P([0-9]{1,2}[W])?([0-9]{1,2}[D])?([T]{0,1})?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?', $data, $duration); $weeks = str_replace('W', '', $duration[1]); $days = str_replace('D', '', $duration[2]); $hours = str_replace('H', '', $duration[4]); $minutes = str_replace('M', '', $duration[5]); $seconds = str_replace('S', '', $duration[6]); $the_duration = $weeks * 60 * 60 * 24 * 7 + $days * 60 * 60 * 24 + $hours * 60 * 60 + $minutes * 60 + $seconds; $first_duration = FALSE; } break; case 'RRULE': $data = str_replace('RRULE:', '', $data); $rrule = split(';', $data); foreach ($rrule as $recur) { ereg('(.*)=(.*)', $recur, $regs); $rrule_array[$regs[1]] = $regs[2]; } break; case 'ATTENDEE': $field = str_replace("ATTENDEE;CN=", "", $field); $data = str_replace("mailto:", "", $data); $attendee[] = array('name' => stripslashes($field), 'email' => stripslashes($data)); break; case 'ORGANIZER': $field = str_replace("ORGANIZER;CN=", "", $field); $data = str_replace("mailto:", "", $data); $organizer[] = array('name' => stripslashes($field), 'email' => stripslashes($data)); break; case 'LOCATION': $data = str_replace("\\n", "<br />", $data); $data = str_replace("\\t", " ", $data); $data = str_replace("\\r", "<br />", $data); $data = stripslashes($data); $location = $data; break; case 'URL': $url = $data; break; } } } } unset($master_array['calendar_name']); unset($master_array['-1']); unset($master_array['-3']); unset($master_array['-4']); // print_R($master_array); // print_R($overlap_array); return $master_array; }
} else { if ($bleed_check == '-1') { $display_end_tmp = $end_time; $end_time_tmp1 = '2400'; } if (!isset($end_time_tmp1)) { $end_time_tmp1 = $end_time; } // Let's double check the until to not write past it $until_check = $recur_data_date . $hour . $minute . '00'; if ($abs_until > $until_check) { $master_array[$recur_data_date][$hour . $minute][$uid] = array('event_start' => $start_time, 'event_end' => $end_time_tmp1, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => 0, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => false, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url, 'recur' => $recur); if (isset($display_end_tmp)) { $master_array[$recur_data_date][$hour . $minute][$uid]['display_end'] = $display_end_tmp; } checkOverlap($recur_data_date, $hour . $minute, $uid, $master_array, $overlap_array, $gridLength); } } } } } unset($recur_data); } } } } } } // This should remove any exdates that were missed. // Added for version 0.9.5 modified in 2.22 remove anything that doesn't have an event_start if (is_array($except_dates)) {
function submitCreateImage() { global $submitErr, $user, $viewmode, $HTMLheader, $printedHTMLheader, $mode; if ($mode == 'submitCreateTestProd') { $data = getContinuationVar(); $data["revisionid"] = processInputVar("revisionid", ARG_MULTINUMERIC); # TODO check for valid revisionid } else { $data = processRequestInput(0); $data['length'] = getContinuationVar('length'); } $showrevisions = 0; $subimages = 0; $images = getImages(); $revcount = count($images[$data['imageid']]['imagerevision']); if ($revcount > 1) { $showrevisions = 1; } if ($images[$data['imageid']]['imagemetaid'] != NULL && count($images[$data['imageid']]['subimages'])) { $subimages = 1; foreach ($images[$data['imageid']]['subimages'] as $subimage) { $revcount = count($images[$subimage]['imagerevision']); if ($revcount > 1) { $showrevisions = 1; } } } if ($data["time"] == "now") { $nowArr = getdate(); if ($nowArr["minutes"] == 0) { $subtract = 0; $add = 0; } elseif ($nowArr["minutes"] < 15) { $subtract = $nowArr["minutes"] * 60; $add = 900; } elseif ($nowArr["minutes"] < 30) { $subtract = ($nowArr["minutes"] - 15) * 60; $add = 900; } elseif ($nowArr["minutes"] < 45) { $subtract = ($nowArr["minutes"] - 30) * 60; $add = 900; } elseif ($nowArr["minutes"] < 60) { $subtract = ($nowArr["minutes"] - 45) * 60; $add = 900; } $start = time() - $subtract; $start -= $start % 60; $nowfuture = "now"; } else { $add = 0; $hour = $data["hour"]; if ($data["hour"] == 12) { if ($data["meridian"] == "am") { $hour = 0; } } elseif ($data["meridian"] == "pm") { $hour = $data["hour"] + 12; } $tmp = explode('/', $data["day"]); $start = mktime($hour, $data["minute"], "0", $tmp[0], $tmp[1], $tmp[2]); if ($start < time()) { print $HTMLheader; print "<H2>Create / Update an Image</H2>\n"; print "<font color=\"#ff0000\">The time you requested is in the past."; print " Please select \"Now\" or use a time in the future.</font><br>\n"; $submitErr = 1; createSelectImage(); return; } $nowfuture = "future"; } // FIXME hard code length to 8 hours $data["length"] = 480; $end = $start + $data["length"] * 60 + $add; // get semaphore lock if (!semLock()) { abort(3); } $max = getMaxOverlap($user['id']); if (checkOverlap($start, $end, $max)) { $printedHTMLheader = 1; print $HTMLheader; print "<H2>New Reservation</H2>\n"; if ($max == 0) { print "<font color=\"#ff0000\">The time you requested overlaps with "; print "another reservation you currently have. You are only allowed "; print "to have a single reservation at any given time. Please select "; print "another time to use the application. If you are finished with "; print "an active reservation, click \"Current Reservations\", "; print "then click the \"End\" button of your active reservation."; print "</font><br><br>\n"; } else { print "<font color=\"#ff0000\">The time you requested overlaps with "; print "another reservation you currently have. You are allowed "; print "to have {$max} overlapping reservations at any given time. "; print "Please select another time to use the application. If you are "; print "finished with an active reservation, click \"Current "; print "Reservations\", then click the \"End\" button of your active "; print "reservation.</font><br><br>\n"; } $submitErr = 1; createSelectImage(); return; } // if user is owner of the image and there is a test revision of the image # available, ask user if production or test image desired if ($mode != "submitCreateTestProd" && $showrevisions && $images[$data["imageid"]]["ownerid"] == $user["id"]) { $printedHTMLheader = 1; print $HTMLheader; print "<H2>New Reservation</H2>\n"; if ($subimages) { print "This is a cluster environment. At least one image in the "; print "cluster has more than one revision available. Please select "; print "the revision you desire for each image listed below:<br>\n"; } else { print "There are multiple revisions of this environment available. Please "; print "select the revision you would like to check out:<br>\n"; } print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post><br>\n"; if (!array_key_exists('subimages', $images[$data['imageid']])) { $images[$data['imageid']]['subimages'] = array(); } array_unshift($images[$data['imageid']]['subimages'], $data['imageid']); foreach ($images[$data['imageid']]['subimages'] as $subimage) { print "{$images[$subimage]['prettyname']}:<br>\n"; print "<table summary=\"lists revisions of the selected environment, one must be selected to continue\">\n"; print " <TR>\n"; print " <TD></TD>\n"; print " <TH>Revision</TH>\n"; print " <TH>Creator</TH>\n"; print " <TH>Created</TH>\n"; print " <TH>Currently in Production</TH>\n"; print " </TR>\n"; foreach ($images[$subimage]['imagerevision'] as $revision) { print " <TR>\n"; if (array_key_exists($subimage, $data['revisionid']) && $data['revisionid'][$subimage] == $revision['id']) { print " <TD align=center><INPUT type=radio name=revisionid[{$subimage}] value={$revision['id']} checked></TD>\n"; } elseif ($revision['production']) { print " <TD align=center><INPUT type=radio name=revisionid[{$subimage}] value={$revision['id']} checked></TD>\n"; } else { print " <TD align=center><INPUT type=radio name=revisionid[{$subimage}] value={$revision['id']}></TD>\n"; } print " <TD align=center>{$revision['revision']}</TD>\n"; print " <TD align=center>{$revision['user']}</TD>\n"; print " <TD align=center>{$revision['prettydate']}</TD>\n"; if ($revision['production']) { print " <TD align=center>Yes</TD>\n"; } else { print " <TD align=center>No</TD>\n"; } print " </TR>\n"; } print "</TABLE>\n"; } addContinuationsEntry('submitCreateImage', array(), SECINDAY, 1, 0); // we add this continuation back // so the currently displayed // page can be reloaded $cont = addContinuationsEntry('submitCreateTestProd', $data); print "<br><INPUT type=hidden name=continuation value=\"{$cont}\">\n"; print "<INPUT type=submit value=Submit>\n"; print "</FORM>\n"; return; } $rc = isAvailable($images, $data["imageid"], $start, $end, $data["os"], 0, 0, 0, 1); if ($rc == -1) { $printedHTMLheader = 1; print $HTMLheader; print "<H2>Create / Update an Image</H2>\n"; print "You have requested an environment that is limited in the number "; print "of concurrent reservations that can be made. No further "; print "reservations for the environment can be made for the time you "; print "have selected. Please select another time to use the "; print "environment.<br>"; } elseif ($rc > 0) { $requestid = addRequest(1, $data['revisionid']); if ($data["time"] == "now") { header("Location: " . BASEURL . SCRIPT . "?mode=viewRequests"); dbDisconnect(); exit; } else { $time = prettyLength($data["length"]); if ($data["minute"] == 0) { $data["minute"] = "00"; } $printedHTMLheader = 1; print $HTMLheader; print "<H2>Create / Update an Image</H2>\n"; print "Your request to use <b>" . $images[$data["imageid"]]["prettyname"]; print "</b> on " . prettyDatetime($start) . " for {$time} has been "; print "accepted.<br><br>\n"; print "When your reservation time has been reached, the "; print "<b>Current Reservations</b> page will give you more "; print "information on connecting to the reserved computer. If you "; print "would like to modify your reservation, you can do that from "; print "the <b>Current Reservations</b> page as well.<br>\n"; } } else { $printedHTMLheader = 1; print $HTMLheader; $cdata = array('imageid' => $data['imageid'], 'length' => $data['length']); $cont = addContinuationsEntry('selectTimeTable', $cdata); print "<H2>Create / Update an Image</H2>\n"; print "The reservation you have requested is not available. You may "; print "<a href=\"" . BASEURL . SCRIPT . "?continuation={$cont}\">"; print "view a timetable</a> of free and reserved times to find "; print "a time that will work for you.<br>\n"; #addLogEntry($nowfuture, unixToDatetime($start), # unixToDatetime($end), 0, $data["imageid"]); } }
$master_array[$start_date_tmp][$time_tmp][$uid] = array('event_start' => $start_time_tmp, 'event_end' => $end_time_tmp, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => true, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url); } $start_tmp = strtotime('+1 day', $start_tmp); } } else { if ($bleed_check == '-1') { $display_end_tmp = $end_time; $end_time_tmp1 = '2400'; } if (!isset($end_time_tmp1)) { $end_time_tmp1 = $end_time; } // Let's double check the until to not write past it $until_check = $recur_data_date . $hour . $minute . '00'; if ($abs_until > $until_check) { $nbrOfOverlaps = checkOverlap($recur_data_date, $start_time, $end_time_tmp1, $uid); $master_array[$recur_data_date][$hour . $minute][$uid] = array('event_start' => $start_time, 'event_end' => $end_time_tmp1, 'display_end' => $display_end_tmp, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => $nbrOfOverlaps, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => false, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url); } } } } } unset($recur_data); } } } } } } // This should remove any exdates that were missed. // Added for version 0.9.5
} else { if ($bleed_check == '-1') { $display_end_tmp = $end_time; $end_time_tmp1 = '2400'; } if (!isset($end_time_tmp1)) { $end_time_tmp1 = $end_time; } // Let's double check the until to not write past it $until_check = $recur_data_date . $hour . $minute . '00'; if ($abs_until > $until_check) { $master_array[$recur_data_date][$hour . $minute][$uid] = array('event_start' => $start_time, 'event_end' => $end_time_tmp1, 'start_unixtime' => $start_unixtime_tmp, 'end_unixtime' => $end_unixtime_tmp, 'event_text' => $summary, 'event_length' => $length, 'event_overlap' => 0, 'description' => $description, 'status' => $status, 'class' => $class, 'spans_day' => false, 'location' => $location, 'organizer' => serialize($organizer), 'attendee' => serialize($attendee), 'calnumber' => $calnumber, 'calname' => $actual_calname, 'url' => $url, 'recur' => $recur); if (isset($display_end_tmp)) { $master_array[$recur_data_date][$hour . $minute][$uid]['display_end'] = $display_end_tmp; } checkOverlap($recur_data_date, $hour . $minute, $uid); } } } } } unset($recur_data); } } } } } } // This should remove any exdates that were missed. // Added for version 0.9.5 modified in 2.22 remove anything that doesn't have an event_start if (is_array($except_dates)) {
function XMLRPCaddRequest($imageid, $start, $length, $foruser = '') { global $user; $imageid = processInputData($imageid, ARG_NUMERIC); $start = processInputData($start, ARG_STRING, 1); $length = processInputData($length, ARG_NUMERIC); #$foruser = processInputData($foruser, ARG_STRING, 1); // make sure user didn't submit a request for an image he // doesn't have access to $resources = getUserResources(array("imageAdmin", "imageCheckOut")); $validImageids = array_keys($resources['image']); if (!in_array($imageid, $validImageids)) { return array('status' => 'error', 'errorcode' => 3, 'errormsg' => "access denied to {$imageid}"); } # validate $start if ($start != 'now' && !is_numeric($start)) { return array('status' => 'error', 'errorcode' => 4, 'errormsg' => "received invalid input"); } # validate $length $maxtimes = getUserMaxTimes(); if ($maxtimes['initial'] < $length) { return array('status' => 'error', 'errorcode' => 6, 'errormsg' => "max allowed initial length is {$maxtimes['initial']} minutes"); } $nowfuture = 'future'; if ($start == 'now') { $start = time(); $nowfuture = 'now'; } else { if ($start < time() - 30) { return array('status' => 'error', 'errorcode' => 5, 'errormsg' => "start time is in the past"); } } $start = unixFloor15($start); $end = $start + $length * 60; if ($end % (15 * 60)) { $end = unixFloor15($end) + 15 * 60; } $max = getMaxOverlap($user['id']); if (checkOverlap($start, $end, $max)) { return array('status' => 'error', 'errorcode' => 7, 'errormsg' => "reservation overlaps with another one you " . "have, and you are allowed {$max} " . "overlapping reservations at a time"); } $images = getImages(); $rc = isAvailable($images, $imageid, $start, $end, ''); if ($rc < 1) { addLogEntry($nowfuture, unixToDatetime($start), unixToDatetime($end), 0, $imageid); return array('status' => 'notavailable'); } $return['requestid'] = addRequest(); $return['status'] = 'success'; return $return; }
function XMLRPCsetRequestEnding($requestid, $end) { global $user; $requestid = processInputData($requestid, ARG_NUMERIC); $userRequests = getUserRequests('all', $user['id']); $found = 0; foreach ($userRequests as $req) { if ($req['id'] == $requestid) { $request = getRequestInfo($requestid); $found = 1; break; } } if (!$found) { return array('status' => 'error', 'errorcode' => 1, 'errormsg' => 'unknown requestid'); } // make sure user is a member of the 'Specify End Time' group $groupid = getUserGroupID('Specify End Time'); $members = getUserGroupMembers($groupid); if (!$request['serverrequest'] && !array_key_exists($user['id'], $members)) { return array('status' => 'error', 'errorcode' => 35, 'errormsg' => "access denied to specify end time"); } $end = processInputData($end, ARG_NUMERIC); $maxend = datetimeToUnix("2038-01-01 00:00:00"); if ($end < 0 || $end > $maxend) { return array('status' => 'error', 'errorcode' => 36, 'errormsg' => "received invalid input for end"); } $startts = datetimeToUnix($request['start']); if ($end % (15 * 60)) { $end = unixFloor15($end) + 15 * 60; } // check that reservation has started if ($startts > time()) { return array('status' => 'error', 'errorcode' => 38, 'errormsg' => 'reservation has not started'); } // check for overlap $max = getMaxOverlap($user['id']); if (checkOverlap($startts, $end, $max, $requestid)) { return array('status' => 'error', 'errorcode' => 41, 'errormsg' => 'overlapping reservation restriction', 'maxoverlap' => $max); } // check for computer being available for extended time? $timeToNext = timeToNextReservation($request); $movedall = 1; if ($timeToNext > -1) { $lockedall = 1; if (count($request['reservations']) > 1) { # get semaphore on each existing node in cluster so that nothing # can get moved to the nodes during this process $unixend = datetimeToUnix($request['end']); $checkend = unixToDatetime($unixend + 900); $resources = getUserResources(array("imageAdmin", "imageCheckOut")); $tmp = array_keys($resources['image']); $semimageid = $tmp[0]; $semrevid = getProductionRevisionid($semimageid); foreach ($request["reservations"] as $res) { if (!retryGetSemaphore($semimageid, $semrevid, $res['managementnodeid'], $res['computerid'], $request['start'], $checkend, $requestid)) { $lockedall = 0; break; } } } if ($lockedall) { foreach ($request["reservations"] as $res) { if (!moveReservationsOffComputer($res["computerid"])) { $movedall = 0; break; } } } else { cleanSemaphore(); return array('status' => 'error', 'errorcode' => 42, 'errormsg' => 'cannot extend due to another reservation immediately after this one'); } cleanSemaphore(); } if (!$movedall) { $timeToNext = timeToNextReservation($request); if ($timeToNext >= 15) { $timeToNext -= 15; } $oldendts = datetimeToUnix($request['end']); // reservation immediately after this one, cannot extend if ($timeToNext < 15) { return array('status' => 'error', 'errorcode' => 42, 'errormsg' => 'cannot extend due to another reservation immediately after this one'); } elseif (($end - $oldendts) / 60 > $timeToNext) { $maxend = $oldendts + $timeToNext * 60; return array('status' => 'error', 'errorcode' => 43, 'errormsg' => 'cannot extend by requested amount due to another reservation', 'maxend' => $maxend); } } $rc = isAvailable(getImages(), $request['reservations'][0]["imageid"], $request['reservations'][0]['imagerevisionid'], $startts, $end, 1, $requestid); // conflicts with scheduled maintenance if ($rc == -2) { addChangeLogEntry($request["logid"], NULL, unixToDatetime($end), $request['start'], NULL, NULL, 0); return array('status' => 'error', 'errorcode' => 46, 'errormsg' => 'requested time is during a maintenance window'); } elseif ($rc == -1) { addChangeLogEntry($request["logid"], NULL, unixToDatetime($end), $request['start'], NULL, NULL, 0); return array('status' => 'error', 'errorcode' => 44, 'errormsg' => 'concurrent license restriction'); } elseif ($rc == 0) { addChangeLogEntry($request["logid"], NULL, unixToDatetime($end), $request['start'], NULL, NULL, 0); return array('status' => 'error', 'errorcode' => 45, 'errormsg' => 'cannot extend at this time'); } // success updateRequest($requestid); cleanSemaphore(); return array('status' => 'success'); }