Ejemplo n.º 1
0
// Search the text of pages for a match.
rcs_id('$Id: fullsearch.php,v 1.1 2004/09/28 21:48:46 gcasse Exp $');
if (get_magic_quotes_gpc()) {
    $full = stripslashes($full);
}
$full = trim($full);
$html = "<P><B>" . sprintf(gettext("Searching for \"%s\" ....."), htmlspecialchars($full)) . "</B></P>\n<DL>\n";
$found = 0;
$count = 0;
if (strlen($full)) {
    // search matching pages
    $query = InitFullSearch($dbi, $full);
    // quote regexp chars (space are treated as "or" operator)
    $full = preg_replace("/\\s+/", "|", preg_quote($full));
    while ($pagehash = FullSearchNextMatch($dbi, $query)) {
        $html .= "<DT><B>" . LinkExistingWikiWord($pagehash["pagename"]) . "</B>\n";
        $count++;
        // print out all matching lines, highlighting the match
        for ($j = 0; $j < count($pagehash["content"]); $j++) {
            if ($hits = preg_match_all(":{$full}:i", $pagehash["content"][$j], $dummy)) {
                $matched = preg_replace(":{$full}:i", "{$FieldSeparator}OT\\0{$FieldSeparator}CT", $pagehash["content"][$j]);
                $matched = htmlspecialchars($matched);
                $matched = str_replace("{$FieldSeparator}OT", '<b>', $matched);
                $matched = str_replace("{$FieldSeparator}CT", '</b>', $matched);
                $html .= "<dd><small>{$matched}</small></dd>\n";
                $found += $hits;
            }
        }
    }
} else {
    $html .= "<dd>" . gettext("(You entered an empty search string)") . "</dd>\n";
Ejemplo n.º 2
0
<?php

// Title search: returns pages having a name matching the search term
rcs_id('$Id: search.php,v 1.1 2004/09/28 21:48:48 gcasse Exp $');
if (get_magic_quotes_gpc()) {
    $search = stripslashes($search);
}
$html = "<P><B>" . sprintf(gettext("Searching for \"%s\" ....."), htmlspecialchars($search)) . "</B></P>\n";
// quote regexp chars (backends should do this...)
//$search = preg_quote($search);
// search matching pages
$found = 0;
if (strlen($search)) {
    $query = InitTitleSearch($dbi, $search);
    while ($page = TitleSearchNextMatch($dbi, $query)) {
        $found++;
        $html .= LinkExistingWikiWord($page) . "<br>\n";
    }
} else {
    $html .= gettext("(You entered an empty search string)") . "<br>\n";
}
$html .= "<hr noshade>\n" . sprintf(gettext("%d pages match your query."), $found) . "\n";
GeneratePage('MESSAGE', $html, gettext("Title Search Results"), 0);
Ejemplo n.º 3
0
<?php

// Backlinks: returns pages which link to a given page.
rcs_id('$Id: backlinks.php,v 1.1 2004/09/28 21:48:44 gcasse Exp $');
if (get_magic_quotes_gpc()) {
    $refs = stripslashes($refs);
}
$pagename = $refs;
// No HTML markup allowed in $title.
$title = sprintf(gettext("Pages which link to %s"), htmlspecialchars($pagename));
if (IsWikiPage($dbi, $pagename)) {
    $pagelink = LinkExistingWikiWord($pagename);
} else {
    $pagelink = LinkUnknownWikiWord($pagename);
}
$html = "<p><b>" . sprintf(gettext("Pages which link to %s") . " .....", $pagelink) . "</b></p>\n<ul>\n";
// search matching pages
$query = InitBackLinkSearch($dbi, $pagename);
$found = 0;
while ($page = BackLinkSearchNextMatch($dbi, $query)) {
    $found++;
    $html .= "<li>" . LinkExistingWikiWord($page) . "<br>\n";
}
$html .= "</ul>\n<hr noshade>\n" . sprintf(gettext("%d pages link to %s."), $found, $pagelink) . "\n";
GeneratePage('MESSAGE', $html, $title, 0);
Ejemplo n.º 4
0
     } else {
         $replacements[$oldn] = LinkURL($replacements[$oldn]);
     }
     $oldn++;
 }
 //////////////////////////////////////////////////////////
 // Link Wiki words
 // Wikiwords preceeded by a '!' are not linked
 $oldn = $ntokens;
 $tmpline = tokenize($tmpline, "!?{$WikiNameRegexp}", $replacements, $ntokens);
 while ($oldn < $ntokens) {
     $old = $replacements[$oldn];
     if ($old[0] == '!') {
         $replacements[$oldn] = substr($old, 1);
     } elseif (IsWikiPage($dbi, $old)) {
         $replacements[$oldn] = LinkExistingWikiWord($old);
     } else {
         $replacements[$oldn] = LinkUnknownWikiWord($old);
     }
     $oldn++;
 }
 //////////////////////////////////////////////////////////
 // escape HTML metachars
 $tmpline = str_replace('&', '&amp;', $tmpline);
 $tmpline = str_replace('>', '&gt;', $tmpline);
 $tmpline = str_replace('<', '&lt;', $tmpline);
 // Gilles Casse (2003-01-21) for the Oralux website
 // The PhpWiki features are lowered:
 // - first because today we do not need them
 // - second to have a page which can be validated as xhtml 1.0 strict
 //
Ejemplo n.º 5
0
function LinkRelatedPages($dbi, $pagename)
{
    // currently not supported everywhere
    if (!function_exists('GetWikiPageLinks')) {
        return '';
    }
    $links = GetWikiPageLinks($dbi, $pagename);
    $txt = "<b>";
    $txt .= sprintf(gettext("%d best incoming links:"), NUM_RELATED_PAGES);
    $txt .= "</b>\n";
    for ($i = 0; $i < NUM_RELATED_PAGES; $i++) {
        if (isset($links['in'][$i])) {
            list($name, $score) = $links['in'][$i];
            if ($i > 0) {
                $txt .= ", ";
            }
            $txt .= LinkExistingWikiWord($name) . " ({$score})";
        }
    }
    $txt .= "\n<br><b>";
    $txt .= sprintf(gettext("%d best outgoing links:"), NUM_RELATED_PAGES);
    $txt .= "</b>\n";
    for ($i = 0; $i < NUM_RELATED_PAGES; $i++) {
        if (isset($links['out'][$i])) {
            list($name, $score) = $links['out'][$i];
            if (IsWikiPage($dbi, $name)) {
                if ($i > 0) {
                    $txt .= ", ";
                }
            }
            $txt .= LinkExistingWikiWord($name) . " ({$score})";
        }
    }
    $txt .= "\n<br><b>";
    $txt .= sprintf(gettext("%d most popular nearby:"), NUM_RELATED_PAGES);
    $txt .= "</b>\n";
    for ($i = 0; $i < NUM_RELATED_PAGES; $i++) {
        if (isset($links['popular'][$i])) {
            list($name, $score) = $links['popular'][$i];
            if ($i > 0) {
                $txt .= ", ";
            }
            $txt .= LinkExistingWikiWord($name) . " ({$score})";
        }
    }
    return $txt;
}