Beispiel #1
0
 protected function _content()
 {
     global $dbtable_prefix;
     global $page_last_modified_time;
     $query = "SELECT a.`post_id`,UNIX_TIMESTAMP(a.`last_changed`) as `last_changed` FROM `{$dbtable_prefix}blog_posts` a WHERE a.`is_public`=1 AND a.`status`=" . STAT_APPROVED;
     switch ($this->config['mode']) {
         case 'new':
             $query .= " ORDER BY a.`date_posted` DESC";
             break;
         case 'views':
             $query .= " AND a.`stat_views`>0 ORDER BY a.`stat_views` DESC";
             break;
         case 'comm':
             $query .= " AND a.`stat_comments`>0 ORDER BY a.`stat_comments` DESC";
             break;
     }
     $query .= " LIMIT " . $this->config['total'];
     if (!($res = @mysql_query($query))) {
         trigger_error(mysql_error(), E_USER_ERROR);
     }
     $post_ids = array();
     while ($rsrow = mysql_fetch_assoc($res)) {
         $post_ids[] = $rsrow['post_id'];
         if ($page_last_modified_time < $rsrow['last_changed']) {
             $page_last_modified_time = $rsrow['last_changed'];
         }
     }
     if (!empty($post_ids)) {
         require_once _BASEPATH_ . '/includes/classes/blog_posts_cache.class.php';
         $blog_posts_cache = new blog_posts_cache();
         $loop = $blog_posts_cache->get_tpl_array($post_ids);
         unset($blog_posts_cache);
         for ($i = 0; isset($loop[$i]); ++$i) {
             $loop[$i]['date_posted'] = strftime($_SESSION[_LICENSE_KEY_]['user']['prefs']['datetime_format'], $loop[$i]['date_posted'] + $_SESSION[_LICENSE_KEY_]['user']['prefs']['time_offset']);
             if (isset($GLOBALS['_list_of_online_members'][$loop[$i]['fk_user_id']])) {
                 $loop[$i]['is_online'] = 'is_online';
                 $loop[$i]['user_online_status'] = $GLOBALS['_lang'][102];
             } else {
                 $loop[$i]['user_online_status'] = $GLOBALS['_lang'][103];
             }
         }
         if (!empty($loop)) {
             $loop[0]['class'] = 'first';
             $loop[count($loop) - 1]['class'] = 'last';
             $this->tpl->set_file('widget.content', 'widgets/blogs/display.html');
             $this->tpl->set_loop('loop', $loop);
             $this->tpl->process('widget.content', 'widget.content', TPL_LOOP | TPL_OPTLOOP);
             $this->tpl->drop_loop('loop');
             unset($loop);
         }
     }
 }
Beispiel #2
0
        }
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
    }
}
$output['totalrows'] = count($post_ids);
// get the results from user cache for the found post_ids
$loop = array();
if (!empty($output['totalrows'])) {
    if ($o >= $output['totalrows']) {
        $o = $output['totalrows'] - $r;
    }
    $post_ids = array_slice($post_ids, $o, $r);
    require _BASEPATH_ . '/includes/classes/blog_posts_cache.class.php';
    $blog_posts_cache = new blog_posts_cache();
    $loop = $blog_posts_cache->get_tpl_array($post_ids);
    unset($blog_posts_cache);
    if (isset($input['tags'])) {
        $search_words = explode(' ', $input['tags']);
        $replace_words = array();
        for ($i = 0; isset($search_words[$i]); ++$i) {
            $replace_words[$i] = '<span class="matched_word">' . $search_words[$i] . '</span>';
        }
    }
    for ($i = 0; isset($loop[$i]); ++$i) {
        $loop[$i]['date_posted'] = strftime($_SESSION[_LICENSE_KEY_]['user']['prefs']['datetime_format'], $loop[$i]['date_posted'] + $_SESSION[_LICENSE_KEY_]['user']['prefs']['time_offset']);
        if (isset($_list_of_online_members[$loop[$i]['fk_user_id']])) {
            $loop[$i]['is_online'] = 'is_online';
            $loop[$i]['user_online_status'] = $GLOBALS['_lang'][102];
        } else {
Beispiel #3
0
require _BASEPATH_ . '/skins_site/' . get_my_skin() . '/lang/blogs.inc.php';
check_login_member('read_blogs');
$tpl = new phemplate(_BASEPATH_ . '/skins_site/' . get_my_skin() . '/', 'remove_nonjs');
$post_id = sanitize_and_format_gpc($_GET, 'pid', TYPE_INT, 0, 0);
$output = array();
$loop_comments = array();
if (!empty($post_id)) {
    // no need to check the status of the post ( AND `status`=".STAT_APPROVED)
    $query = "SELECT `fk_user_id`,`allow_comments` FROM `{$dbtable_prefix}blog_posts` WHERE `post_id`={$post_id}";
    if (!($res = @mysql_query($query))) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    if (mysql_num_rows($res)) {
        $output = mysql_fetch_assoc($res);
        require _BASEPATH_ . '/includes/classes/blog_posts_cache.class.php';
        $blog_posts_cache = new blog_posts_cache();
        if ($temp = $blog_posts_cache->get_post($post_id, false)) {
            $output = array_merge($output, $temp);
            if ($output['date_posted'] > $page_last_modified_time) {
                $page_last_modified_time = $output['date_posted'];
            }
            $output['date_posted'] = strftime($_SESSION[_LICENSE_KEY_]['user']['prefs']['datetime_format'], $output['date_posted'] + $_SESSION[_LICENSE_KEY_]['user']['prefs']['time_offset']);
            if (!empty($_SESSION[_LICENSE_KEY_]['user']['user_id']) && $output['fk_user_id'] == $_SESSION[_LICENSE_KEY_]['user']['user_id']) {
                $output['post_owner'] = true;
            }
            if (isset($_list_of_online_members[$output['fk_user_id']])) {
                $output['is_online'] = 'member_online';
                $output['user_online_status'] = $GLOBALS['_lang'][102];
            } else {
                $output['user_online_status'] = $GLOBALS['_lang'][103];
            }