示例#1
0
function ewiki_speed_abort($id, &$data, $action)
{
    $o = "";
    // unused here
    $inverse = 0;
    $yes = 0;
    $precond = 0;
    #-- ETag comparisions
    if (($if = $_SERVER["HTTP_IF_MATCH"]) || ($if = $_SERVER["HTTP_IF_NONE_MATCH"]) && ($inverse = 1)) {
        $data["version"] and $etag = ewiki_etag($data) or $etag = "never:matching:" . time();
        #-- walk through comparison values
        foreach (explode(",", $if) as $match) {
            $match = trim(trim($match), '"');
            if ($match == "*" || $match == $etag) {
                $yes = 1;
            }
            $precond = 1;
        }
    }
    #-- check against modification time
    if (($if = $_SERVER["HTTP_IF_MODIFIED_SINCE"]) || ($if = $_SERVER["HTTP_IF_UNMODIFIED_SINCE"]) && ($inverse = 1)) {
        $modif = $data["lastmodified"] or $modif = UNIX_MILLENNIUM;
        $if = strtotime(trim($if));
        if ($modif > $if) {
            $yes = 1;
        }
    }
    #-- invert result
    if ($inverse) {
        $yes = $yes ? 0 : 1;
    }
    #-- abort ewiki rendering, if matched or senseful to do so
    if ($yes || $_SERVER["REQUEST_METHOD"] == "HEAD") {
        /*      
           #ewiki_http_headers($o, $id, $data, $action);
           (It was probably bad to send the ETag and Content-Version fields
           for this http answer?)
        */
        header("Status: 304 Not Modified");
        die(304);
    } elseif ($precond) {
        if (!$inverse || $_SERVER["REQUEST_METHOD"] != "GET") {
            header("Status: 412 Precondition Failed");
            die(412);
        }
    }
}
示例#2
0
function ewiki_http_headers(&$o, $id, &$data, $action)
{
    global $ewiki_t;
    if (EWIKI_HTTP_HEADERS && !headers_sent()) {
        if (!empty($data)) {
            if ($uu = @$data["id"]) {
                @header('Content-Disposition: inline; filename="' . urlencode($uu) . '.html"');
            }
            if ($uu = @$data["version"]) {
                @header('Content-Version: ' . $uu);
            }
            if ($uu = @$data["lastmodified"]) {
                @header('Last-Modified: ' . gmstrftime($ewiki_t["C"]["DATE"], $uu));
            }
        }
        if (EWIKI_NO_CACHE) {
            header('Expires: ' . gmstrftime($ewiki_t["C"]["DATE"], UNIX_MILLENNIUM));
            header('Pragma: no-cache');
            header('Cache-Control: no-cache, private, must-revalidate');
            # change to "C-C: cache, must-revalidate" ??
            # private only for authenticated users / _PROT_MODE
        }
        #-- ETag
        if ($data["version"] && ($etag = ewiki_etag($data)) || ($etag = md5($o))) {
            $weak = "W/" . urlencode($id) . "." . $data["version"];
            header("ETag: \"{$etag}\"");
            ###, \"$weak\"");
        }
    }
}
示例#3
0
 function fileinfo(&$data)
 {
     #-- create meta/properties array
     $ct = $data["meta"]["Content-Type"] or $ct = EWIKI_PAGE_CTYPE;
     $m = array("path" => "/" . $data["id"], "resourcetype" => "", "creationdate" => $data["created"], "getcontentlength" => strlen($data["content"]), "getlastmodified" => $data["lastmodified"], "getcontenttype" => $ct, "displayname" => ewiki_split_title($data["id"]), "getetag" => ewiki_etag($data), "getcontentlanguage" => EWIKI_DEFAULT_LANG, "page:author" => $data["author"], "page:version" => $data["version"], "page:hits" => $data["hits"], "page:log" => $data["meta"]["log"], "page:user-agent" => $data["meta"]["user-agent"]);
     #-- add {meta}² entries
     if ($meta = $data["meta"]["meta"]) {
         foreach ($meta as $i => $v) {
             $m["meta:{$i}"] = implode(", ", $v);
         }
     }
     return $m;
 }
示例#4
0
function ewiki_feed_atom($info, $pages)
{
    header('Content-Type: application/atom+xml');
    $name = $info["title"];
    $ilm = gmstrftime("%G%m%dT%TZ", $info["modified"]);
    echo <<<EOT
<?xml version="1.0" encoding="{$info['charset']}"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#">
  <title>{$name}</title>
  <link rel="alternate" type="text/html" href="{$info['url']}"/>
  <modified>{$ilm}</modified>
  <author>*</author>
  <generator>{$info['ewiki']}</generator>

EOT;
    #-- write items
    foreach ($pages as $i => $data) {
        $etag = ewiki_etag($data);
        echo <<<EOT
  <entry>
    <title>{$data['title']}</title>
    <link rel="alternate" type="text/html" href="{$data['url']}"/>
    <id>{$etag}</id>
    <issued>{$data['icdate']}</issued>
    <created>{$data['icdate']}</created>
    <modified>{$data['idate']}</modified>
    <content>{$data['content']}</content>
  </entry>

EOT;
    }
    //<?
    echo "</feed>\n";
    die;
}