function get_terms($limit = 50, $category = false)
{
    $query = "SELECT terms.term, bursts.score AS count FROM terms, bursts WHERE bursts.term = terms.term GROUP BY term ORDER BY count DESC LIMIT {$limit}";
    if ($category) {
        $blogs = get_blogs_with_tag($category);
        $blogs = "'" . implode("','", $blogs) . "'";
        $query = "SELECT terms.term, bursts.score AS count FROM terms, posts, bursts WHERE bursts.term = terms.term AND posts.post_id = terms.post_id AND posts.blog_id IN ({$blogs}) GROUP BY term ORDER BY count DESC LIMIT {$limit}";
    }
    $results = mysql_query($query);
    $terms = array();
    while ($row = mysql_fetch_array($results)) {
        $terms[$row['term']] = $row['count'];
    }
    return $terms;
}
function get_active_blogs($category = false, $timeframe = false, $limit = 50)
{
    $query = "SELECT posts.blog_id, blogs.title AS blog_name, COUNT(*) AS count FROM posts, blogs WHERE blogs.blog_id = posts.blog_id";
    if ($category) {
        $query .= " AND posts.blog_id IN (" . implode(",", get_blogs_with_tag($category)) . ")";
    }
    if ($timeframe) {
        $query .= " AND posts.pubdate >= '{$timeframe}'";
    }
    $query .= " GROUP BY posts.blog_id ORDER BY count DESC";
    if ($limit) {
        $query .= " LIMIT {$limit}";
    }
    $results = mysql_query($query);
    $blogs = array();
    $mapping = array();
    while ($row = mysql_fetch_assoc($results)) {
        $blogs[$row['blog_id']] = $row['count'];
        $mapping[$row['blog_id']] = $row['blog_name'];
    }
    return array("blogs" => $blogs, "mapping" => $mapping);
}
<input type='submit' name='submit' value='Submit'/>
</div>
</form>
<h3>Blog Workspace</h3>
<?php 
$workspace = $_GET['workspace'];
if ($_POST['workspace']) {
    $workspace = $_POST['workspace'];
}
$workspace = mysql_escape_string($workspace);
if (!$workspace) {
    $workspace = 'false';
}
$blog_ids = array();
if ($workspace != 'false') {
    $blog_ids = get_blogs_with_tag($workspace);
} else {
    $blog_ids = get_blogs_with_no_tags();
}
if (sizeof($blog_ids)) {
    $blogs = get_blogs($blog_ids, array("latest" => true, "limit" => 1000, "show_new_blogs" => true, "show_inactive" => true));
    foreach ($blogs as $blog) {
        print_blog($blog, array("add_tag" => true, "workspace" => $workspace));
    }
} else {
    print "No such blogs";
}
?>
</div>
<?php 
include "footer.php";
Beispiel #4
0
<?php

/**
*
* @package phpBB3 User Blog Tags
* @copyright (c) 2008 EXreaction
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/
$tag = request_var('tag', '', true);
$limit = 20;
if ($tag == '') {
    trigger_error('NO_TAG');
}
$blog_ids = get_blogs_with_tag($tag);
if (!sizeof($blog_ids)) {
    trigger_error('NO_TAGS');
}
$user->add_lang('mods/blog/view');
page_header($user->lang['BLOG_TAGS_TITLE'], false);
$blog_data->get_blog_data('blog', $blog_ids);
$blog_data->get_user_data(false, true);
update_edit_delete('blog');
$i = -1;
foreach ($blog_ids as $id) {
    $i++;
    if ($i < $start || !isset(blog_data::$blog[$id]['user_id'])) {
        // It is before the start or they do not have permission to view
        continue;
    } else {
        if ($i >= $start + $limit) {
function get_posts($sort_by = "published_on", $filters = array())
{
    $query = "SELECT SQL_CALC_FOUND_ROWS * FROM posts_summary ";
    $where_clause = " WHERE !ISNULL(post_id)";
    #$where_clause .= " AND p2.post_id = links.post_id AND p2.blog_id != posts.blog_id";
    $order_by = " ORDER BY pubdate DESC";
    $limit_by = "";
    if ($sort_by == "published_on") {
        $order_by = " ORDER BY pubdate DESC";
    }
    if ($sort_by == "added_on") {
        $order_by = " ORDER BY added_on DESC";
    }
    if ($sort_by == "cited") {
        $order_by = " ORDER BY linked_by DESC, pubdate DESC";
    }
    if ($sort_by == "post_freq") {
        if ($filters['post_id']) {
            # we want an order in which elements that appear most frequently in $filters['post_id'] have the highest rankings
            $post_freq = array_count_values($filters['post_id']);
            arsort($post_freq);
            $order_by = " ORDER BY FIELD(post_id";
            foreach ($post_freq as $post_id => $post_freq) {
                $order_by .= ", {$post_id}";
            }
            $order_by .= ")";
        }
    }
    $sort_by .= ", title ASC";
    if (!$filters['limit']) {
        $filters['limit'] = $GLOBALS["config"]['posts_per_page'];
    }
    if ($filters['limit']) {
        $limit_by = " LIMIT " . $filters['limit'];
    }
    if ($filters['skip']) {
        if ($filters['skip'] < 0) {
            $filters['skip'] = 0;
        }
        $limit_by = " LIMIT " . $filters['skip'] . "," . $filters['limit'];
    }
    if ($filters['base_url']) {
        $where_clause .= " AND url LIKE '" . $filters['base_url'] . "%'";
    }
    if ($filters['term']) {
        $tposts = get_posts_with_term($filters['term']);
        $tposts = "'" . implode("','", $tposts) . "'";
        $where_clause .= " AND post_id IN ({$tposts})";
    }
    if ($filters['category']) {
        $blogs = get_blogs_with_tag($filters['category']);
        $blogs = "'" . implode("','", $blogs) . "'";
        $where_clause .= " AND blog_id IN ({$blogs})";
    }
    if ($filters['tag']) {
        $tag = $filters['tag'];
        $tposts = array();
        if ($tag == "original_research") {
            $tposts = get_posts_with_research();
        } elseif ($tag == "conference") {
            $tposts = get_posts_with_conference();
        } elseif ($tag == "review") {
            $tposts = get_posts_with_review();
        } else {
            $tposts = get_posts_with_tag($filters['tag']);
        }
        $tposts = "'" . implode("','", $tposts) . "'";
        $where_clause .= " AND post_id IN ({$tposts})";
    }
    if ($filters['review']) {
        $tposts = get_posts_with_review();
        $tposts = "'" . implode("','", $tposts) . "'";
        $where_clause .= " AND post_id IN ({$tposts})";
    }
    if ($filters['conference']) {
        $tposts = get_posts_with_conference();
        $tposts = "'" . implode("','", $tposts) . "'";
        $where_clause .= " AND post_id IN ({$tposts})";
    }
    if ($filters['original_research']) {
        $tposts = get_posts_with_research();
        $tposts = "'" . implode("','", $tposts) . "'";
        $where_clause .= " AND post_id IN ({$tposts})";
    }
    if ($filters['published_before']) {
        $date = $filters['published_before'];
        $where_clause .= " AND pubdate < '{$date}'";
    }
    if ($filters['published_after']) {
        $date = $filters['published_after'];
        $where_clause .= " AND pubdate >= '{$date}'";
    }
    if ($filters['blog_id']) {
        $where_clause .= " AND blog_id = " . $filters['blog_id'];
    }
    if (isset($filters['post_id'])) {
        if ($filters['post_id']) {
            if (!is_array($filters['post_id'])) {
                $where_clause .= " AND post_id = " . $filters['post_id'];
            } else {
                if (is_array($filters['post_id'])) {
                    $where_clause .= " AND post_id IN (" . implode(",", $filters['post_id']) . ")";
                }
            }
        } else {
            return array();
        }
    }
    if ($filters['min_links']) {
        $where_clause .= " AND linked_by >= " . $filters['min_links'];
    }
    $posts = array();
    $having = "";
    $query = $query . $where_clause . $group_by . $having . $order_by . $limit_by;
    $results = mysql_query($query);
    $rows = mysql_num_rows($results);
    if ($limit_by) {
        $count_query = "SELECT FOUND_ROWS() AS rows";
        $count_results = mysql_query($count_query);
        while ($row = mysql_fetch_assoc($count_results)) {
            $rows = $row['rows'];
        }
    }
    while ($row = mysql_fetch_assoc($results)) {
        $post = $row;
        $post['rows_returned'] = $rows;
        $post['post_request_type'] = "all";
        if ($filters['conference']) {
            $post['post_request_type'] = "conference";
        }
        if ($filters['review']) {
            $post['post_request_type'] = "review";
        }
        if ($filters['originaL_research']) {
            $post['post_request_type'] = "original_research";
        }
        array_push($posts, $post);
    }
    if ($filters['order_by_filenames_array']) {
        $filenames = $filters['order_by_filenames_array'];
        $ordered_posts = array();
        # we need to do some post-ordering
        foreach ($filenames as $filename) {
            # find row with this filename, add it to the array.
            foreach ($posts as $post) {
                if ($post['filename'] == $filename) {
                    array_push($ordered_posts, $post);
                }
            }
        }
        $posts = $ordered_posts;
    }
    return $posts;
}
Beispiel #6
0
?>
</div>
</div>
<?php 
print_searchbox("Blogs");
?>
</div>
<div class='content'>
<?php 
$safe_skip = false;
$safe_skip = mysql_escape_string($_GET["skip"]);
if (!is_numeric($safe_skip)) {
    $safe_skip = false;
}
$filters = array();
$filters['limit'] = $GLOBALS["config"]['blogs_per_page'];
if ($safe_skip) {
    $filters['skip'] = $safe_skip;
} else {
    $filters['skip'] = 0;
}
$blogs = get_blogs(get_blogs_with_tag($safe_category), $filters);
print_pagination($blogs, $safe_skip, "blogs.php", $GLOBALS["config"]['blogs_per_page']);
foreach ($blogs as $blog) {
    print_blog($blog, array("tagcloud" => true));
}
print_pagination($blogs, $safe_skip, "blogs.php", $GLOBALS["config"]['blogs_per_page']);
?>
</div>
<?php 
include "footer.php";
function get_papers($sort_by = "added_on", $filters = array())
{
    $query = "SELECT SQL_CALC_FOUND_ROWS * FROM papers_summary WHERE 1";
    $where_clause = "";
    $order_by = " ORDER BY added_on";
    $group_by = "";
    $limit_by = "";
    if ($sort_by == "added_on") {
        $order_by = " ORDER BY added_on DESC";
    }
    if ($sort_by == "pubdate") {
        $order_by = " ORDER BY pubdate DESC";
    }
    # bit of a hack here - historically "pubdate" and "published_on" are both used even though they're the same thing
    if ($sort_by == "published_on") {
        $order_by = " ORDER BY pubdate DESC";
    }
    if ($sort_by == "cited") {
        $order_by = " ORDER BY cited_by DESC";
    }
    if ($sort_by == "journal") {
        $order_by = " ORDER BY journal";
    }
    if ($filters['min_links']) {
        $having_clause .= " HAVING cited_by >= " . $filters['min_links'];
    }
    if ($filters['reviews']) {
        $where_clause .= " AND reviewed >= 1";
    }
    if ($filters['limit']) {
        $limit_by = " LIMIT " . $filters['limit'];
    }
    if ($filters['comment_source']) {
        # get list of papers that have comments from this source
        $comments = get_comments_from_source($filters['comment_source']);
        if (sizeof($comments)) {
            $where_clause .= " AND paper_id IN ('" . implode("','", $comments) . "')";
        } else {
            return array();
        }
    }
    if ($filters['skip']) {
        if ($filters['skip'] < 0) {
            $filters['skip'] = 0;
        }
        $limit_by = " LIMIT " . $filters['skip'] . "," . $GLOBALS["config"]['papers_per_page'];
    }
    if ($filters['category']) {
        $blogs = get_blogs_with_tag($filters['category']);
        #$blogs = "'".implode("','", $blogs)."'";
        #$where_clause .= " AND posts.blog_id IN ($blogs)";
        $blog_counter = 0;
        if ($blogs) {
            $where_clause .= " AND (";
        }
        foreach ($blogs as $blog) {
            if ($blog_counter >= 1) {
                $where_clause .= " OR ";
            }
            #$where_clause .= "FIND_IN_SET($blog, blog_ids)";
            # try a textual IN clause to see if it's any faster:
            $where_clause .= "{$blog} IN (blog_ids)";
            $blog_counter++;
        }
        if ($blogs) {
            $where_clause .= ")";
        }
    }
    if ($filters['tag']) {
        $papers = get_papers_with_tag($filters['tag']);
        $papers = "'" . implode("','", $papers) . "'";
        $where_clause .= " AND paper_id IN ({$papers})";
    }
    if (strtolower($filters['type']) == "books") {
        $where_clause .= " AND !ISNULL(isbn_id)";
    }
    if (strtolower($filters['type']) == "papers") {
        $where_clause .= " AND ISNULL(isbn_id)";
    }
    if ($filters['journal']) {
        $journal = $filters['journal'];
        $where_clause .= " AND journal='{$journal}'";
    }
    if ($filters['published_before']) {
        $date = $filters['published_before'];
        $where_clause .= " AND pubdate < '{$date}'";
    }
    if ($filters['published_after']) {
        $date = $filters['published_after'];
        $where_clause .= " AND pubdate >= '{$date}'";
    }
    if ($filters['added_before']) {
        $date = $filters['added_before'];
        $where_clause .= " AND added_on < '{$date}'";
    }
    if ($filters['added_after']) {
        $date = $filters['added_after'];
        $where_clause .= " AND added_on >= '{$date}'";
    }
    if (isset($filters['paper_id'])) {
        if (!is_array($filters['paper_id'])) {
            $where_clause .= " AND paper_id = " . $filters['paper_id'];
        } else {
            if (is_array($filters['paper_id'])) {
                $where_clause .= " AND paper_id IN (" . implode(",", $filters['paper_id']) . ")";
            }
        }
    }
    $papers = array();
    $query = $query . $where_clause . $group_by . $having_clause . $order_by . $limit_by;
    $results = mysql_query($query);
    $rows = mysql_num_rows($results);
    if ($limit_by) {
        $count_query = "SELECT FOUND_ROWS() AS rows";
        $count_results = mysql_query($count_query);
        while ($row = mysql_fetch_assoc($count_results)) {
            $rows = $row['rows'];
        }
    }
    while ($row = mysql_fetch_assoc($results)) {
        $row['rows_returned'] = $rows;
        $paper = $row;
        array_push($papers, $paper);
    }
    return $papers;
}
    $page = download_url($url);
    # get OPML of public subscriptions
    if ($page) {
        # parse out all the feed URLs and see if they match anything in the database
        $matches = array();
        preg_match_all("/xmlUrl=[\\'\"](.*?)[\"\\']/i", $page, $matches);
        for ($i = 0; $i < sizeof($matches[1]); $i++) {
            $blog = $matches[1][$i];
            $blog_id = get_blog_id($blog);
            if ($blog_id) {
                array_push($blog_ids, $blog_id);
            }
        }
    }
} elseif ($_SAFE['category']) {
    $blog_ids = get_blogs_with_tag($_SAFE['category']);
}
if (sizeof($blog_ids) || $_SAFE['all']) {
    # at least one blog on the public blogroll is also in Postgenomic
    $blogs = get_blogs($blog_ids, array("limit" => 20, "require_portraits" => true));
    print "document.write(\"";
    $counter = 0;
    $large_images = 2;
    $small_images = sizeof($blogs) - $large_images;
    $half = ceil($small_images / 2) + $large_images;
    $width = $large_images * 64 + ceil($small_images / 2) * 32;
    print "<table border='0' cellspacing='0' cellpadding='0' width='{$width}'>";
    print "<tr>";
    for ($i = 0; $i < $large_images; $i++) {
        $blog = $blogs[$i];
        $size = 64;
Beispiel #9
0
 #	limit: override default limit
 #	category: category you want blogs from
 # any filters?
 $filters = array();
 # basics...
 $filters['limit'] = $blogs_return_limit;
 if ($limit && $limit < $max_blogs_return_limit) {
     $filters['limit'] = $limit;
 }
 if ($start && is_numeric($start)) {
     $filters['skip'] = $start;
 }
 # category
 $blog_ids = array();
 if ($category) {
     $blog_ids = get_blogs_with_tag($category);
 }
 # get blogs
 $blogs = get_blogs($blog_ids, $filters);
 # return blogs
 if ($format == "json") {
     $json = new Services_JSON();
     if ($blogs) {
         $buffer .= $json->encode($blogs);
     }
     if ($callback) {
         printf("%s(%s)", $callback, $buffer);
     } else {
         print $buffer;
     }
 } else {
function print_bloggercloud($category = false)
{
    $catclause = "";
    if ($category) {
        $blogs = get_blogs_with_tag($category);
        if ($blogs) {
            $catclause = " AND blog_id IN ('" . implode("','", $blogs) . "')";
        }
    }
    $query = "SELECT DISTINCT blog_image AS image, blog_id, blog_name AS title FROM posts_summary WHERE blog_image NOT LIKE '%default.png' {$catclause} ORDER BY pubdate DESC LIMIT 5";
    $results = mysql_query($query);
    $images = array();
    while ($row = mysql_fetch_array($results)) {
        array_push($images, $row);
    }
    print "<div style='width: 320px;'>";
    #print "<div>";
    for ($i = 0; $i < 5; $i++) {
        if (!$images[$i]) {
            continue;
        }
        if (!($i % 4)) {
            #print "</div><div>";
        }
        print "<a href='" . linkto("blog_search.php", $page_vars, array("blog_id" => $images[$i]["blog_id"])) . "'><img border='0' hspace='0' vspace='0' alt='" . $images[$i]['title'] . "' src='" . $images[$i]['image'] . "'/></a>";
    }
    #print "</div>";
    print "</div>";
}