mkprop('creationdate', $stat['ctime']); $file['props'][] = $this->mkprop('getlastmodified', $stat['mtime']); if (is_dir($absolutePath)) { $file['props'][] = $this->mkprop('resourcetype', 'collection'); $handle = opendir($absolutePath); if (!$handle) { return; } while (($pathComponent = readdir($handle)) !== false) { if ($pathComponent != '.' && $pathComponent != '..') { $paths[] = $path != '' ? "$path/$pathComponent" : $pathComponent; } } closedir($handle); } else { $file['props'][] = $this->mkprop('getcontentlength', $stat['size']); $file['props'][] = $this->mkprop('resourcetype', null); } $files[] = $file; $path = array_pop($paths); } return true; } function put(&$options) { $absolutePath = HTTP_CalDAV_Server_PHPiCalendar::getBasePath() . '/' . $options['path']; if (!is_dir(dirname($absolutePath))) { return '409 Conflict'; } $options['new'] = !file_exists($absolutePath); $handle = @fopen($absolutePath, 'w'); if (!$handle) { return '403 Forbidden'; } return $handle; } function report($options, &$files) { $files = array(); $paths = array(); $path = $options['path']; while (isset($path)) { $file = array(); $file['path'] = $path; $absolutePath = HTTP_CalDAV_Server_PHPiCalendar::getBasePath() . '/' . $path; $stat = stat($absolutePath); $file['props'] = array(); $file['props'][] = $this->mkprop('creationdate', $stat['ctime']); $file['props'][] = $this->mkprop('getlastmodified', $stat['mtime']); if (is_dir($absolutePath)) { $file['props'][] = $this->mkprop('resourcetype', 'collection'); $handle = opendir($absolutePath); if (!$handle) { return; } while (($pathComponent = readdir($handle)) !== false) { if ($pathComponent != '.' && $pathComponent != '..') { $paths[] = $path != '' ? "$path/$pathComponent" : $pathComponent; } } closedir($handle); } else { $file['props'][] = $this->mkprop('getcontentlength', $stat['size']); $file['props'][] = $this->mkprop('resourcetype', null); } $files[] = $file; $path = array_pop($paths); } return true; } } $server = new HTTP_CalDAV_Server_PHPiCalendar(); $server->ServeRequest(); ?>