예제 #1
0
function ewiki_page_wordindex($id, $data, $action)
{
    global $ewiki_plugins;
    $o = ewiki_make_title($id, $id, 2);
    $src = "";
    $result = ewiki_db::GETALL(array("flags"));
    while ($row = $result->get()) {
        if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $uu, "view")) {
            continue;
        }
        if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) {
            $src .= " " . $row["id"];
        }
    }
    $src = ewiki_split_title($src, "SPLIT", 0);
    $chars = strtr(EWIKI_CHARS_U . EWIKI_CHARS_L, "_", " ");
    $src = preg_replace("/[^{$chars}]/", " ", $src);
    $src = explode(" ", $src);
    $src = array_unique($src);
    //@ADD: word counting
    unset($src[""]);
    natcasesort($src);
    $sorted = array();
    foreach ($src as $i => $word) {
        if (strlen($word) >= 2) {
            $sorted[] = array(EWIKI_PAGE_POWERSEARCH, array("where" => "id", "q" => $word), $word, "");
        }
    }
    unset($src);
    $pf_list_pages = $ewiki_plugins["list_dict"][0];
    $o .= ewiki_list_pages($sorted, $limit = 0, $vat = 1, $pf_list_pages);
    return $o;
}
예제 #2
0
function ewiki_dump_template($id, $content, $linksto = 0, $html_ext = ".html")
{
    $title = $head_title = ewiki_split_title($id);
    if ($linksto != 0) {
        $title = '<a href="' . urlencode(urlencode($id)) . ($linksto > 0 ? '.links' : '') . $html_ext . '">' . $title . '</a>';
    }
    $version = EWIKI_VERSION;
    return <<<EOT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <title>{$head_title}</title>
 <meta name="generator" content="WikiDump, ewiki/{$version}">
</head>
<body bgcolor="#ffffff";>
<h2>{$title}</h2>
{$content}
</body>
</html>
EOT;
}
예제 #3
0
function ewiki_calendar_page_title($id = '', $split = EWIKI_SPLIT_TITLE)
{
    strlen($id) or $id = $GLOBALS["ewiki_page"];
    static $month_names;
    if (!isset($month_names)) {
        $month_names = explode(" ", ewiki_t("MONTHS"));
    }
    if (preg_match(CALENDAR_PAGE_DATE_PARSE_REGEX, $id, $dateParts)) {
        /*Transform Parent title using plugins */
        $parentId = $dateParts[1];
        $parentTitle = $parentId;
        if ($ewiki_config["split_title"] || $split) {
            $parentTitle = ewiki_split_title($parentId);
        }
        #-- title mangling
        if ($pf_a = $ewiki_plugins["title_transform"]) {
            foreach ($pf_a as $pf) {
                $pf($parentId, $parentTitle, '');
            }
        }
        $title = ewiki_t("CALENDERENTRYFOR") . $parentTitle . ": " . $month_names[$dateParts[3] - 1] . " " . $dateParts[4] . ", " . $dateParts[2];
    }
    return $title;
}
예제 #4
0
function ewiki_make_title($id = '', $title = '', $class = 3, $action = "view", $go_action = "links", $may_split = 1)
{
    global $ewiki_config, $ewiki_plugins, $ewiki_title, $ewiki_id;
    #-- advanced handler
    if ($pf = @$ewiki_plugins["make_title"][0]) {
        return $pf($title, $class, $action, $go_action, $may_split);
    } elseif (!$ewiki_config["print_title"]) {
        return "";
    }
    #-- get id
    if (empty($id)) {
        $id = $ewiki_id;
    }
    #-- get title
    if (!strlen($title)) {
        $title = $ewiki_title;
        // already in &html; format
    } elseif ($ewiki_config["split_title"] && $may_split) {
        $title = ewiki_split_title($title, $ewiki_config["split_title"], 0 & $title != $ewiki_title);
    } else {
        $title = s($title);
    }
    #-- title mangling
    if ($pf_a = @$ewiki_plugins["title_transform"]) {
        foreach ($pf_a as $pf) {
            $pf($id, $title, $go_action);
        }
    }
    #-- clickable link or simple headline
    if ($class <= $ewiki_config["print_title"]) {
        if ($uu = @$ewiki_config["link_title_action"][$action]) {
            $go_action = $uu;
        }
        if ($uu = @$ewiki_config["link_title_url"]) {
            $href = $uu;
            unset($ewiki_config["link_title_url"]);
        } else {
            $href = ewiki_script($go_action, $id);
        }
        $o = '<a href="' . $href . '">' . $title . '</a>';
    } else {
        $o = $title;
    }
    return '<h2 class="page title">' . $o . '</h2>' . "\n";
}
예제 #5
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;
 }
예제 #6
0
파일: feed.php 프로젝트: gpuenteallott/rox
function ewiki_feed($pages, $type = "AUTO")
{
    global $ewiki_config;
    ob_end_clean();
    #-- general feed infos
    $feed_info = array("title" => EWIKI_NAME, "lang" => EWIKI_DEFAULT_LANG, "desc" => defined("EWIKI_DESC") ? EWIKI_DESC : EWIKI_NAME . " - an open hypertext site", "copyright" => defined("EWIKI_COPY") ? EWIKI_COPY : "copyrighted", "category" => defined("EWIKI_CATEGORY") ? EWIKI_CATEGORY : "None", "url" => ewiki_script_url(), "rc_url" => ewiki_script_url("", "UpdatedPages"), "ewiki" => "ewiki/" . EWIKI_VERSION, "charset" => EWIKI_CHARSET);
    #-- fix/prepare feed entries
    $lm = UNIX_MILLENNIUM;
    foreach ($pages as $i => $data) {
        if (!is_array($data)) {
            $data = ewiki_db::GET($data);
            $pages[$i] = $data;
        }
        // ...
        if ($data["id"]) {
            if (empty($data["title"])) {
                $pages[$i]["title"] = ewiki_split_title($data["id"], -1, 0);
            }
            if (empty($data["url"])) {
                $pages[$i]["url"] = ewiki_script_url("", $data["id"]);
            }
            if (empty($data["uri"])) {
                $pages[$i]["uri"] = "x-wiki:" . EWIKI_NAME . ":" . ewiki_xmlentities(urlencode($data["id"]));
            }
            if (empty($data["guid"])) {
                $pages[$i]["guid"] = ewiki_script_url("", $data["id"], "version={$data['version']}");
            }
        }
        $diff_content = ewiki_action_infoqdiff_plain($data["id"], $data, $prev = (array) $data, $ver = $data["version"]);
        $pages[$i]["content"] = strtr(ewiki_xmlentities($diff_content), "\r\n\t\f", "    ");
        // $pages[$i]["content"] = strtr(ewiki_xmlentities(substr($data["content"], 0, 300)), "\r\n\t\f", "    ");
        $pages[$i]["pdate"] = gmstrftime("%a, %d %b %G %T %Z", $data["lastmodified"]);
        $pages[$i]["idate"] = gmstrftime("%G%m%dT%TZ", $data["lastmodified"]);
        $pages[$i]["icdate"] = gmstrftime("%G%m%dT%TZ", $data["created"]);
        if ($lm < $data["lastmodified"]) {
            $lm = $data["lastmodified"];
        }
        $data["content"] = "";
    }
    $info["modified"] = $lm;
    #-- respect some common parameters
    if ($limit = $_REQUEST["limit"] or $limit = $_REQUEST["items"] or $limit = $ewiki_config["list_limit_rss"] or $limit = $ewiki_config["list_limit"]) {
        $pages = array_slice($pages, 0, $limit);
    }
    #-- encode everything into UTF-8?
    // no
    #-- engage compression
    if ($_SERVER["HTTP_ACCEPT_ENCODING"]) {
        ob_start("ob_gzhandler");
        ob_implicit_flush(0);
    }
    #-- what to return
    if (!is_string($type) || strtoupper($type) == "AUTO" || $type == "*") {
        $type = ewiki_feed_type();
    }
    header("Vary: accept,negotiate");
    header("TCN: choice");
    switch ($type) {
        case "RSS0":
            ewiki_feed_rss0($feed_info, $pages);
        case "RSS2":
            ewiki_feed_rss2($feed_info, $pages);
        case "RSS3":
            ewiki_feed_rss3($feed_info, $pages);
        case "RSS1":
            ewiki_feed_rss1($feed_info, $pages);
        case "ATOM":
            ewiki_feed_atom($feed_info, $pages);
        case "DUMB":
        default:
            header("Status: 406 Not Acceptable");
            header("Content-Type: text/plain");
            die("You are using a pretty dumb feed reader, it didn't\n" . "send any appropriate Accept: header. Go away.");
    }
    die;
}
예제 #7
0
<?php

/*
   Lists all used words inside WikiPageNames and shows a list of them
   (similar to PageIndex) - but it redirects the words to PowerSearch,
   which also needs to be installed therefore!
*/
global $ewiki_plugins;
echo ewiki_make_title($id, $id, 2);
$result = ewiki_db::GETALL(array("flags"));
$src = "";
while ($row = $result->get(0, 0x37, EWIKI_DB_F_TEXT)) {
    $src .= " " . $row["id"];
}
$src = ewiki_split_title($src, "SPLIT", 0);
$chars = strtr(EWIKI_CHARS_U . EWIKI_CHARS_L, "_", " ");
$src = preg_replace("/[^{$chars}]/", " ", $src);
$src = explode(" ", $src);
$src = array_unique($src);
//@ADD: word counting
unset($src[""]);
natcasesort($src);
$sorted = array();
foreach ($src as $i => $word) {
    if (strlen($word) >= 2) {
        $sorted[] = array(EWIKI_PAGE_POWERSEARCH, array("where" => "id", "q" => $word), $word, "");
    }
}
unset($src);
$pf_list_pages = $ewiki_plugins["list_dict"][0];
echo ewiki_list_pages($sorted, $limit = 0, $vat = 1, $pf_list_pages);
예제 #8
0
function ewiki_blog_list($n_num, $n_len, $b_sort, $b_sortrev, $b_hr, $b_more, $c_regex)
{
    global $ewiki_plugins, $ewiki_config;
    #-- fetch all page entries from DB, for sorting on pagename or lastmodified
    if ($b_sort) {
        $result = ewiki_db::GETALL(array("pagename"));
    } else {
        $result = ewiki_db::GETALL(array("lastmodified"));
    }
    $sorted = array();
    // get an array from the database
    while ($row = $result->get(0, 0x137, EWIKI_DB_F_TEXT)) {
        if ($c_regex && !preg_match($c_regex, $row["id"])) {
            continue;
        }
        if ($b_sort) {
            $sorted[$row["id"]] = $row["pagename"];
        } else {
            $sorted[$row["id"]] = $row["lastmodified"];
        }
    }
    #-- sort normal or reversed
    if ($b_sortrev) {
        asort($sorted);
    } else {
        // if we sort on lastmodified reverse sort
        arsort($sorted);
    }
    $displayed = 0;
    //$displayed will count pages successfully displayed
    #-- gen output
    $o = "";
    foreach ($sorted as $id => $uu) {
        $row = ewiki_db::GET($id);
        #-- require auth
        if (EWIKI_PROTECTED_MODE && !ewiki_auth($id, $row, "view", $ring = false, $force = 0)) {
            if (EWIKI_PROTECTED_MODE_HIDING) {
                continue;
            } else {
                $row["content"] = ewiki_t("FORBIDDEN");
            }
        }
        $text = "\n" . substr($row["content"], 0, $n_len);
        $text = str_replace("[internal://", "[  internal://", $text);
        #-- shore more link or not
        if ($b_more) {
            $text .= " [...[read more | {$id}]]\n";
        }
        #-- title mangling (from ewiki.php)
        $title = $id;
        if ($ewiki_config["split_title"] && $may_split) {
            $title = ewiki_split_title($title, $ewiki_config["split_title"], 0 & $title != $ewiki_title);
            //Why 0&?
        } else {
            $title = htmlentities($title);
        }
        if ($pf_a = @$ewiki_plugins["title_transform"]) {
            foreach ($pf_a as $pf) {
                $pf($id, $title, $go_action);
            }
        }
        if ($ewiki_config["wm_publishing_headers"]) {
            $text = preg_replace("/^!([^!])/m", "!! \$1", $text);
            $o .= "\n" . "! [\"{$title}\"{$id}]";
        } else {
            $text = preg_replace("/^!!!/m", "!!", $text);
            $o .= "\n" . "!!! [\"{$title}\"{$id}]";
        }
        $o .= " µµ" . strftime(ewiki_t("LASTCHANGED"), $row["lastmodified"]) . "µµ\n";
        $o .= " {$text}\n";
        // add a horizontal line if wanted
        if ($b_hr) {
            $o .= "----\n";
        }
        if (!$n_num--) {
            break;
        }
    }
    #-- render requested wiki page  <-- goal !!!
    $render_args = array("scan_links" => 1, "html" => EWIKI_ALLOW_HTML || @$data["flags"] & EWIKI_DB_F_HTML);
    $o = $ewiki_plugins["render"][0]($o, $render_args);
    return $o;
}