Пример #1
0
    # On retourne le resultat
    return $referer_light;
}
require_once dirname(__FILE__) . '/inc/prepend.php';
include dirname(__FILE__) . '/tpl.php';
#
header('Content-type: text/html; charset=utf-8');
# Nombre de ligne a afficher
$nb = 15;
$sql = "SELECT\n\t\t" . $core->prefix . "user.user_id AS user_id,\n\t\tuser_fullname AS fullname,\n\t\tsite_url,\n\t\tCOUNT( post_id ) AS nb_post\n\tFROM " . $core->prefix . "post, " . $core->prefix . "user, " . $core->prefix . "site\n\tWHERE\n\t\t" . $core->prefix . "site.user_id = " . $core->prefix . "user.user_id\n\t\tAND " . $core->prefix . "user.user_id = " . $core->prefix . "post.user_id\n\t\tAND user_status = 1\n\tGROUP BY user_fullname\n\tORDER BY nb_post DESC\n\tLIMIT {$nb}";
$rs = $core->con->select($sql);
while ($rs->fetch()) {
    $core->tpl->setVar("active", array("fullname" => $rs->fullname, "site_url" => $rs->site_url, "domain_url" => domain($rs->site_url), "nb_posts" => $rs->nb_post));
    $core->tpl->render('stats.main.line');
}
if ($blog_settings->get('planet_vote')) {
    # On recupere la liste et on affiche
    $sql = "SELECT\n\t\t\t" . $core->prefix . "user.user_id as user_id,\n\t\t\tuser_fullname as fullname,\n\t\t\tsite_url,\n\t\t\tSUM(post_score) AS score\n\t\tFROM " . $core->prefix . "post, " . $core->prefix . "user, " . $core->prefix . "site \n\t\tWHERE\n\t\t\t" . $core->prefix . "site.user_id = " . $core->prefix . "user.user_id\n\t\t\tAND " . $core->prefix . "user.user_id = " . $core->prefix . "post.user_id\n\t\t\tAND user_status = 1\n\t\tGROUP BY user_fullname\n\t\tORDER BY score DESC\n\t\tLIMIT {$nb}";
    $rs = $core->con->select($sql);
    while ($rs->fetch()) {
        $core->tpl->setVar("votes", array("fullname" => $rs->fullname, "site_url" => $rs->site_url, "domain_url" => domain($rs->site_url), "score" => $rs->score));
        $core->tpl->render('stats.votes.line');
    }
    $core->tpl->render('stats.votes');
    $core->tpl->setVar('nb_votes', getNbVotes($core->con));
    $core->tpl->render('stats.votes.resume');
}
$core->tpl->setVar('nb', array("nb_users" => getNbUsers($core->con), "nb_feeds" => getNbFeeds($core->con), "nb_posts" => getNbPosts($core->con)));
$core->tpl->setVar('params', $params);
$core->tpl->render('content.stats');
$core->renderTemplate();
Пример #2
0
function showSinglePost($rs, $tpl, $search_value, $multiview = true, $strip_tags = false)
{
    global $blog_settings, $core, $user_settings;
    $avatar = $blog_settings->get('planet_avatar');
    $post_permalink = $rs->f('permalink');
    if ($blog_settings->get('internal_links')) {
        $post_permalink = BP_PLANET_URL . "/index.php?post_id=" . $rs->f('post_id') . "&go=external";
    }
    $title = html_entity_decode($rs->f('title'), ENT_QUOTES, 'UTF-8');
    $content = html_entity_decode($rs->f('content'), ENT_QUOTES, 'UTF-8');
    $short_content = html_entity_decode($rs->f('short_content'), ENT_QUOTES, 'UTF-8');
    $short = true;
    if (strlen($content) < 1200) {
        $short = false;
        $short_content = $content;
    }
    $post = array("id" => $rs->f('post_id'), "date" => mysqldatetime_to_date("d/m/Y", $rs->f('pubdate')), "day" => mysqldatetime_to_date("d", $rs->f('pubdate')), "month" => mysqldatetime_to_date("m", $rs->f('pubdate')), "year" => mysqldatetime_to_date("Y", $rs->f('pubdate')), "hour" => mysqldatetime_to_date("H:i", $rs->f('pubdate')), "permalink" => urldecode($post_permalink), "title" => $title, "content" => $content, "short_content" => $short_content, "image" => $rs->f('image'), "author_id" => $rs->f('user_id'), "author_fullname" => $rs->f('user_fullname'), "author_email" => $rs->f('user_email'), "nbview" => $rs->f('nbview'), "last_viewed" => mysqldatetime_to_date('d/m/Y H:i', $rs->f('last_viewed')), "user_votes" => getNbVotes(null, $rs->f('user_id')), "user_posts" => getNbPosts(null, $rs->f('user_id')));
    $post['description'] = sprintf(T_('By %s, on %s at %s.'), '<a href="#" onclick="javascript:add_user(\'' . $rs->f('user_id') . '\')">' . $rs->f('user_fullname') . '</a>', $post["date"], $post["hour"]);
    $post['description'] .= ' <a href="' . BP_PLANET_URL . '/index.php?post_id=' . $rs->f('post_id') . '" title="' . $post['title'] . '">' . T_("View post detail") . '</a>';
    if (!empty($search_value)) {
        # Format the occurences of the search request in the posts list
        $post['content'] = split_balise($search_value, '<span class="search-content">' . $search_value . '</span>', $post['content'], 'str_ireplace', 1);
        # Format the occurences of the search request in the posts title
        $post['title'] = split_balise($search_value, '<span class="search_title">' . $search_value . '</span>', $post['title'], 'str_ireplace', 1);
    }
    if ($short) {
        $last_space = strripos($post['short_content'], ' ');
        $post['short_content'] = substr($post['short_content'], 0, $last_space);
        $post['short_content'] = '<span class="short-content">' . strip_tags($post['short_content']) . "&nbsp;[...] </span>" . '<br /><span class="read-more"><a href="' . BP_PLANET_URL . '/?post_id=' . $post['id'] . '" title="' . $title . '">' . T_('Read more') . '</a></span>';
    }
    if ($strip_tags) {
        $post['content'] = $post['short_content'];
    }
    $post_tags = getPostTags($rs->f('post_id'));
    $tpl->setVar('post', $post);
    # Gravatar
    if ($avatar) {
        $libravatar = getUserIcon($post['author_email']);
        $tpl->setVar('avatar_url', $libravatar);
        $tpl->render('post.block.gravatar');
    }
    if ($multiview) {
        if ($post['image'] != '') {
            $tpl->render('post.image');
        }
        $tpl->render('post.multi');
    }
    if ($blog_settings->get('planet_vote')) {
        $votes = array("html" => afficheVotes($rs->f('score'), $rs->f('post_id')));
        $tpl->setVar('votes', $votes);
        $tpl->render('post.block.votes');
    }
    if (!empty($post_tags)) {
        foreach ($post_tags as $tag) {
            $tpl->setVar('post_tag', $tag);
            $tpl->render('post.tags');
        }
    }
    if ($blog_settings->get('allow_post_modification')) {
        if ($blog_settings->get('allow_tagging_everything')) {
            $tpl->render('post.action.tags');
        } else {
            if ($core->auth->userID() == $rs->f('user_id')) {
                $tpl->render('post.action.tags');
            }
        }
    }
    if ($user_settings != null) {
        if ($user_settings->get("social.twitter")) {
            $tpl->render('social.twitter');
        }
        if ($user_settings->get("social.shaarli")) {
            $simple_title = $post['title'];
            $tpl->setVar('stripped_title', addslashes($simple_title));
            $tpl->render('social.shaarli');
        }
        if ($user_settings->get("social.google")) {
            $tpl->render('social.google');
        }
        if ($user_settings->get("social.statusnet")) {
            $tpl->setVar('stripped_title', urlencode($rs->f('title')));
            $tpl->render('social.statusnet');
        }
        if ($user_settings->get("social.reddit")) {
            $tpl->setVar('stripped_title', addslashes($simple_title));
            $tpl->setVar('encoded_url', urlencode(BP_PLANET_URL . '/?post_id=' . $post['id']));
            $tpl->render('social.reddit');
        }
    }
    if ($blog_settings->get('show_similar_posts') && !empty($post_tags)) {
        $sql_sim = getSimilarPosts_SQL($rs->f('post_id'), $post_tags);
        $rsimilar = $core->con->select($sql_sim);
        if ($rsimilar->count() > 0) {
            while ($rsimilar->fetch()) {
                $post_permalink = $rsimilar->permalink;
                if ($blog_settings->get('internal_links')) {
                    $post_permalink = BP_PLANET_URL . "/index.php?post_id=" . $rsimilar->post_id;
                }
                $similar = array("author" => $rsimilar->user_fullname, "title" => $rsimilar->post_title, "permalink" => urldecode($post_permalink), "pubdate" => mysqldatetime_to_date("d/m/Y", $rsimilar->post_pubdate));
                $tpl->setVar('similar', $similar);
                $tpl->render("post.similar.item");
            }
            $tpl->render("post.similar.block");
        }
    }
    if ($blog_settings->get('allow_post_comments')) {
        if ($core->auth->userID() == $rs->f('user_id') || $core->hasRole('manager')) {
            if ($rs->f('comment')) {
                $tpl->render('post.action.uncomment');
            } else {
                $tpl->render('post.action.comment');
            }
        }
    }
    if ($blog_settings->get('allow_post_comments') && $rs->f('comment') == 1) {
        $sql = "SELECT * FROM " . $core->prefix . "comment\n\t\t\tWHERE post_id=" . $rs->f('post_id');
        //		print $sql;
        //		exit;
        $rs_comment = $core->con->select($sql);
        while ($rs_comment->fetch()) {
            $fullname = $rs_comment->user_fullname;
            if (!empty($rs_comment->user_site)) {
                $fullname = '<a href="' . $rs_comment->user_site . '">' . $fullname . '</a>';
            }
            $content = $core->wikiTransform($rs_comment->content);
            $comment = array("id" => $rs_comment->comment_id, "post_id" => $rs_comment->post_id, "user_fullname_link" => $fullname, "user_fullname" => $rs_comment->user_fullname, "user_site" => $rs_comment->user_site, "content" => $content, "pubdate" => mysqldatetime_to_date("d/m/Y", $rs_comment->created));
            $tpl->setVar("comment", $comment);
            $tpl->render('post.comment.element');
        }
        $tpl->render('post.comment.block');
    }
    if ($rs->count() > 1) {
        $tpl->render('post.backsummary');
    }
    return $tpl;
}