diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 7986723..c04f35e 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -244,4 +244,5 @@ php_value[mail.add_x_header] = Off php_value[max_execution_time] = 600 php_value[max_input_time] = 300 php_value[memory_limit] = 256M +php_value[short_open_tag] = On diff --git a/sources/backend/imap/mime_calendar.php b/sources/backend/imap/mime_calendar.php index c3e9689..9592ba8 100644 --- a/sources/backend/imap/mime_calendar.php +++ b/sources/backend/imap/mime_calendar.php @@ -158,8 +158,25 @@ function parse_meeting_calendar($part, &$output, $is_sent_folder) { $uid = $props[0]->Value(); } - if (isset($part->ctype_parameters["method"])) { - switch (strtolower($part->ctype_parameters["method"])) { + $method = false; + $props = $ical->GetPropertiesByPath("VCALENDAR/METHOD"); + if (count($props) > 0) { + $method = strtolower($props[0]->Value()); + ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->parse_meeting_calendar(): Using method from vcalendar object: %s", $method)); + } + else { + if (isset($part->ctype_parameters["method"])) { + $method = strtolower($part->ctype_parameters["method"]); + ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->parse_meeting_calendar(): Using method from mime part object: %s", $method)); + } + } + + if ($method === false) { + ZLog::Write(LOGLEVEL_WARN, sprintf("BackendIMAP->parse_meeting_calendar() - No method header, please report it to the developers")); + $output->messageclass = "IPM.Appointment"; + } + else { + switch ($method) { case "cancel": $output->messageclass = "IPM.Schedule.Meeting.Canceled"; $output->meetingrequest->disallownewtimeproposal = 1; @@ -227,10 +244,6 @@ function parse_meeting_calendar($part, &$output, $is_sent_folder) { break; } } - else { - ZLog::Write(LOGLEVEL_WARN, sprintf("BackendIMAP->parse_meeting_calendar() - No method header, please report it to the developers")); - $output->messageclass = "IPM.Appointment"; - } $props = $ical->GetPropertiesByPath('VEVENT/DTSTAMP'); if (count($props) == 1) { @@ -291,7 +304,7 @@ function parse_meeting_calendar($part, &$output, $is_sent_folder) { else { $tz = TimezoneUtil::GetFullTZ(); } - $output->meetingrequest->timezone = base64_encode(TimezoneUtil::getSyncBlobFromTZ($tz)); + $output->meetingrequest->timezone = base64_encode(TimezoneUtil::GetSyncBlobFromTZ($tz)); // Fixed values $output->meetingrequest->instancetype = 0; @@ -341,4 +354,4 @@ function reply_meeting_calendar($part, $response, $username) { $ical->SetCPParameterValue("VEVENT", "ATTENDEE", "RSVP", null, sprintf("MAILTO:%s", $username)); return $ical->Render(); -} \ No newline at end of file +} diff --git a/sources/backend/zarafa/exporter.php b/sources/backend/zarafa/exporter.php index 76ad075..ee40092 100644 --- a/sources/backend/zarafa/exporter.php +++ b/sources/backend/zarafa/exporter.php @@ -234,7 +234,7 @@ class ExportChangesICS implements IExportChanges{ $changes = mapi_exportchanges_getchangecount($this->exporter); if($changes || !($this->flags & BACKEND_DISCARD_DATA)) - ZLog::Write(LOGLEVEL_DEBUG, sprintf("ExportChangesICS->InitializeExporter() successfully. %d changes ready to sync.", $changes)); + ZLog::Write(LOGLEVEL_DEBUG, sprintf("ExportChangesICS->InitializeExporter() successfully. %d changes ready to sync for '%s'.", $changes, ($this->folderid)?bin2hex($this->folderid) : 'hierarchy')); return $ret; } diff --git a/sources/backend/zarafa/importer.php b/sources/backend/zarafa/importer.php index 370c5a6..4ed209b 100644 --- a/sources/backend/zarafa/importer.php +++ b/sources/backend/zarafa/importer.php @@ -453,7 +453,6 @@ class ImportChangesICS implements IImportChanges { return true; } - /** * Imports a move of a message. This occurs when a user moves an item to another folder * @@ -694,4 +693,4 @@ class ImportChangesICS implements IImportChanges { return $ret; } -} \ No newline at end of file +} diff --git a/sources/backend/zarafa/mapiprovider.php b/sources/backend/zarafa/mapiprovider.php index 6664cb3..afec67f 100644 --- a/sources/backend/zarafa/mapiprovider.php +++ b/sources/backend/zarafa/mapiprovider.php @@ -2679,4 +2679,4 @@ class MAPIProvider { } return $this->inboxProps; } -} \ No newline at end of file +} diff --git a/sources/backend/zarafa/zarafa.php b/sources/backend/zarafa/zarafa.php index 335fd4a..72864bd 100644 --- a/sources/backend/zarafa/zarafa.php +++ b/sources/backend/zarafa/zarafa.php @@ -63,7 +63,6 @@ include_once('backend/zarafa/mapi/class.meetingrequest.php'); include_once('backend/zarafa/mapi/class.freebusypublish.php'); // processing of RFC822 messages -include_once('include/mimeDecode.php'); require_once('include/z_RFC822.php'); // components of Zarafa backend @@ -167,7 +166,7 @@ class BackendZarafa implements IBackend, ISearchProvider { // send Z-Push version and user agent to ZCP - ZP-589 if (Utils::CheckMapiExtVersion('7.2.0')) { $zpush_version = 'Z-Push_' . @constant('ZPUSH_VERSION'); - $user_agent = $_SERVER['HTTP_USER_AGENT']; + $user_agent = ZPush::GetDeviceManager()->GetUserAgent(); $this->session = @mapi_logon_zarafa($user, $pass, MAPI_SERVER, null, null, 0, $zpush_version, $user_agent); } else { diff --git a/sources/include/z_syslog.php b/sources/include/z_syslog.php index a599b6d..0a16d7b 100644 --- a/sources/include/z_syslog.php +++ b/sources/include/z_syslog.php @@ -26,6 +26,8 @@ * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of Leon van Kammen / Coder of Salvation + * + * https://github.com/coderofsalvation/syslog-flexible */ class ZSyslog { @@ -103,4 +105,4 @@ class ZSyslog { case LOGLEVEL_WBXMLSTACK: return LOG_DEBUG; break; } } -} \ No newline at end of file +} diff --git a/sources/index.php b/sources/index.php index 1568a87..dceced5 100644 --- a/sources/index.php +++ b/sources/index.php @@ -247,15 +247,7 @@ if (defined('LOG_MEMORY_PROFILER') && LOG_MEMORY_PROFILER) { ZPush::GetDeviceManager()->Save(); // end gracefully - if (version_compare(phpversion(), '5.4.0') < 0) { - $time_used = number_format(time() - $_SERVER["REQUEST_TIME"], 4); - } - else { - $time_used = number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 4); - } - - ZLog::Write(LOGLEVEL_DEBUG, sprintf("-------- End - max mem: %s/%s - time: %s - code: %s", memory_get_peak_usage(false), memory_get_peak_usage(true), $time_used, http_response_code())); - + ZLog::WriteEnd(); if (defined('LOG_MEMORY_PROFILER') && LOG_MEMORY_PROFILER) { if (function_exists('memprof_enable')) { diff --git a/sources/lib/core/statemanager.php b/sources/lib/core/statemanager.php index afc6f9d..0b7e7ed 100644 --- a/sources/lib/core/statemanager.php +++ b/sources/lib/core/statemanager.php @@ -316,8 +316,8 @@ class StateManager { */ public function SetBackendStorage($data, $type = self::BACKENDSTORAGE_PERMANENT) { if ($type == self::BACKENDSTORAGE_STATE) { - if (!$this->uuid) - throw new StateNotYetAvailableException(); + if (!$this->uuid) + throw new StateNotYetAvailableException(); // TODO serialization should be done in the StateMachine return $this->statemachine->SetState($data, $this->device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, $this->uuid, $this->newStateCounter); diff --git a/sources/lib/core/streamimporter.php b/sources/lib/core/streamimporter.php index 877cf4a..0db17f5 100644 --- a/sources/lib/core/streamimporter.php +++ b/sources/lib/core/streamimporter.php @@ -44,7 +44,6 @@ class ImportChangesStream implements IImportChanges { private $encoder; private $objclass; - private $classAsString; private $seenObjects; private $importedMsgs; private $checkForIgnoredMessages; diff --git a/sources/lib/core/zlog.php b/sources/lib/core/zlog.php index a4b7481..26b03b4 100644 --- a/sources/lib/core/zlog.php +++ b/sources/lib/core/zlog.php @@ -172,6 +172,27 @@ class ZLog { return (isset(self::$lastLogs[$loglevel]))?self::$lastLogs[$loglevel]:false; } + + /** + * Writes info at the end of the request but only if the LOGLEVEL is DEBUG or more verbose + * + * @access public + * @return + */ + static public function WriteEnd() { + if (LOGLEVEL_DEBUG <= LOGLEVEL) { + if (version_compare(phpversion(), '5.4.0') < 0) { + $time_used = number_format(time() - $_SERVER["REQUEST_TIME"], 4); + } + else { + $time_used = number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 4); + } + + ZLog::Write(LOGLEVEL_DEBUG, sprintf("Memory usage information: %s/%s - Execution time: %s - HTTP responde code: %s", memory_get_peak_usage(false), memory_get_peak_usage(true), $time_used, http_response_code())); + ZLog::Write(LOGLEVEL_DEBUG, "-------- End"); + } + } + /**---------------------------------------------------------------------------------------------------------- * private log stuff */ diff --git a/sources/lib/core/zpush.php b/sources/lib/core/zpush.php index 1fb4383..463b79b 100644 --- a/sources/lib/core/zpush.php +++ b/sources/lib/core/zpush.php @@ -529,7 +529,7 @@ class ZPush { $loaded = false; foreach (self::$autoloadBackendPreference as $autoloadBackend) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZPush::GetBackend(): trying autoload backend '%s'", $autoloadBackend)); - $loaded = self::IncludeBackend($autoloadBackend); + $loaded = class_exists($autoloadBackend) || self::IncludeBackend($autoloadBackend); if ($loaded) { $ourBackend = $autoloadBackend; break; @@ -538,7 +538,7 @@ class ZPush { if (!$ourBackend || !$loaded) throw new FatalMisconfigurationException("No Backend provider can not be loaded. Check your installation and configuration!"); } - else + elseif (!class_exists($ourBackend)) self::IncludeBackend($ourBackend); if (class_exists($ourBackend)) diff --git a/sources/lib/default/diffbackend/exportchangesdiff.php b/sources/lib/default/diffbackend/exportchangesdiff.php index c3a3a89..e159229 100644 --- a/sources/lib/default/diffbackend/exportchangesdiff.php +++ b/sources/lib/default/diffbackend/exportchangesdiff.php @@ -110,7 +110,7 @@ class ExportChangesDiff extends DiffState implements IExportChanges{ $this->changes = $this->getDiffTo($folderlist); } - ZLog::Write(LOGLEVEL_INFO, sprintf("ExportChangesDiff->InitializeExporter(): Found %d changes", count($this->changes))); + ZLog::Write(LOGLEVEL_INFO, sprintf("ExportChangesDiff->InitializeExporter(): Found '%d' changes for '%s'", count($this->changes), ($this->folderid)?$this->folderid : 'hierarchy' )); } /** diff --git a/sources/testing/samples/meeting_reply_rim.txt b/sources/testing/samples/meeting_reply_rim.txt new file mode 100644 index 0000000..b0eb1eb --- /dev/null +++ b/sources/testing/samples/meeting_reply_rim.txt @@ -0,0 +1,43 @@ +BEGIN:VCALENDAR +PRODID:-//Research In Motion//RIM App//EN +VERSION:2.0 +CALSCALE:GREGORIAN +METHOD:REPLY +BEGIN:VTIMEZONE +TZID:Europe/London +BEGIN:STANDARD +DTSTART:20001029T020000 +RRULE:FREQ=YEARLY;BYDAY=4SU;BYMONTH=10 +TZNAME:GMT +TZOFFSETFROM:+0100 +TZOFFSETTO:+0000 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20000326T010000 +RRULE:FREQ=YEARLY;BYDAY=4SU;BYMONTH=3 +TZNAME:BST +TZOFFSETFROM:+0000 +TZOFFSETTO:+0100 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CN=User1;PARTSTAT=ACCEPTED:mailto:user1 + @domain1.tld +COMMENT:ok for me +CREATED:20150823T184526Z +DTEND;TZID=Europe/London:20150823T220000 +DTSTAMP:20150823T184527Z +DTSTART;TZID=Europe/London:20150823T210000 +ORGANIZER:mailto:user3@domain3.tld +SEQUENCE:0 +STATUS:CONFIRMED +SUMMARY:Test of meeting with Z-push +TRANSP:OPAQUE +UID:f503ce50-49c6-11e5-9533-693764eab43f +BEGIN:VALARM +ACTION:DISPLAY +DESCRIPTION:Test of meeting with Z-push in 15 minutes. +TRIGGER;RELATED=START:-PT15M +END:VALARM +END:VEVENT +END:VCALENDAR diff --git a/sources/testing/testing-imap_meeting_method.php b/sources/testing/testing-imap_meeting_method.php new file mode 100644 index 0000000..5c45dab --- /dev/null +++ b/sources/testing/testing-imap_meeting_method.php @@ -0,0 +1,25 @@ +ParseFrom($body); + + $props = $ical->GetPropertiesByPath("VCALENDAR/METHOD"); + if (count($props) > 0) { + printf("METHOD %s\n", $props[0]->Value()); + } +} + + +testing_get_method('testing/samples/meeting_request.txt'); +testing_get_method('testing/samples/meeting_request_rim.txt'); +testing_get_method('testing/samples/meeting_reply_rim.txt'); \ No newline at end of file