mkprop('creationdate', $stat['ctime']); $file['props'][] = $this->mkprop('getlastmodified', $stat['mtime']); if (is_dir($absolutePath)) { $file['props'][] = $this->mkprop('resourcetype', 'collection'); if ($depth < $options['depth'] || $options['depth'] == 'infinity') { $handle = opendir($absolutePath); if (!$handle) { return; } while (($pathComponent = readdir($handle)) !== false) { if ($pathComponent != '.' && $pathComponent != '..') { $paths[] = array($path != '' ? "$path/$pathComponent" : $pathComponent, $depth + 1); } } closedir($handle); } } else { $file['props'][] = $this->mkprop('getcontentlength', $stat['size']); $file['props'][] = $this->mkprop('resourcetype', null); } $files[] = $file; } 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(array($options['path'], 0)); while (!empty($paths)) { list ($path, $depth) = array_pop($paths); $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'); if ($depth < $options['depth'] || $options['depth'] == 'infinity') { $handle = opendir($absolutePath); if (!$handle) { return; } while (($pathComponent = readdir($handle)) !== false) { if ($pathComponent != '.' && $pathComponent != '..') { $paths[] = array($path != '' ? "$path/$pathComponent" : $pathComponent, $depth + 1); } } closedir($handle); } } else { $file['props'][] = $this->mkprop('getcontentlength', $stat['size']); $file['props'][] = $this->mkprop('resourcetype', null); } $files[] = $file; } return true; } } $server = new HTTP_CalDAV_Server_PHPiCalendar(); $server->ServeRequest(); ?>