function link_atom_entry($link)
{
    global $config;
    $link = make_array_atom_safe($link);
    if (!$link['titles']) {
        $link['titles'] = substr($link['url'], 0, 64) . "...";
    } else {
        $link['titles'] = ucfirst($link['titles']);
    }
    $posts = explode("|||", $link['post_titles']);
    foreach ($posts as $post) {
        $bits = explode("===", $post);
        $summary .= "<p> <a href='" . $bits[1] . "'>" . $bits[0] . "</a> from <a href='" . slinkto("blog_search.php", $page_vars, array("blog_id" => $bits[5])) . "'>" . $bits[3] . "</a>";
    }
    # don't strip html tags...
    $summary = reduce_to_ascii(htmlentities($summary));
    $return .= "\n<entry>\n\t<title><![CDATA[" . $link['page_title'] . "]]></title>\n\t<link rel='alternate' href=\"" . $link['url'] . "\"/>\n\t<id>" . slinkto("link.php", array(), array("url_hash" => md5($link['url']))) . "</id>\n\t<updated>" . $link['last_linked_on'] . "</updated>\n\t<content type='html'>{$summary}</content>\n\t<gd:rating value='" . $link['linked_by'] . "' min='0' max='100'/>\n</entry>\n";
    return $return;
}
function do_search($term, $safe_skip = 0, $max = false, $safe_type = "any")
{
    global $config;
    $safe_search = reduce_to_ascii($term, true);
    if (!$max) {
        $max = $config['search_results_per_page'];
    }
    # $max is per page, not the limit of the number of results
    # rather confusingly the "do_search" config variable actually means "use PyLucene?". If do_search is 0 then we use
    # MySQL's built in search functionality instead.
    if ($config['do_search']) {
        # use PyLucene
        $url = $GLOBALS['config']['pylucene_url'] . "?q=" . urlencode($safe_search) . "&start={$safe_skip}&max={$max}&type={$safe_type}";
        $results = download_url($url);
    } else {
        # use MySQL
        $results = do_mysql_search($safe_search, $safe_skip, $max, $safe_type);
    }
    return $results;
}
Beispiel #3
0
include "functions.php";
$PAGE_TYPE = "search";
$PAGE_TITLE = $config["name"] . " - Search";
include "header.php";
$safe_skip = 0;
$safe_skip = mysql_escape_string($_GET["skip"]);
$safe_type = mysql_escape_string($_GET["type"]);
if (!$safe_type) {
    $safe_type = "any";
}
if (!is_numeric($safe_skip)) {
    $safe_skip = 0;
}
if ($_GET['search']) {
    $safe_search = reduce_to_ascii($_GET['search'], true);
    $results = do_search($safe_search, $safe_skip, $max, $safe_type);
}
?>
<div class='content fullwidth'>
<?php 
$return = parse_search_results($results);
$total_results = $return["total_results"];
$num_results = $return["num_results"];
$posts = $return["posts"];
$blogs = $return["blogs"];
$papers = $return["papers"];
?>
<div class='searchbox'>
<div class='searchbox_title'>Search</div>
<div class='searchbox_content'>
Beispiel #4
0
# by default cache feed requests
$PAGE_CACHE = $config['cache_atom_requests'];
# check to see if we have a cached version
$PAGE_URL = $_SERVER['REQUEST_URI'];
if ($PAGE_CACHE) {
    $cached = get_cache($PAGE_URL);
    if ($cached) {
        print $cached;
        exit;
    }
    ob_start();
}
if ($type == "search") {
    # return OpenSearch results.
    if ($search) {
        $safe_search = reduce_to_ascii($search, true);
        if (!$search_skip) {
            $search_skip = 0;
        }
        if (!$search_limit) {
            $search_limit = false;
        }
        # $search_limit here means "how many items per page"?
        if (!$search_type) {
            $search_type = "any";
        }
        $results = do_search($safe_search, $search_skip, $search_limit, $search_type);
        $return = parse_search_results($results);
        if (isset($return["total_results"])) {
            $total_results = $return["total_results"];
            $num_results = $return["num_results"];