function recent_posts_list_block($options)
{
    $mydirname = empty($options[0]) ? 'xpress' : $options[0];
    $this_template = empty($options[1]) ? 'db:' . $mydirname . '_recent_posts_list_block.html' : trim($options[1]);
    $disp_count = empty($options[2]) ? '10' : $options[2];
    $disp_red = empty($options[3]) ? '1' : $options[3];
    $disp_green = empty($options[4]) ? '7' : $options[4];
    $date_format = empty($options[5]) ? '' : $options[5];
    $time_format = empty($options[6]) ? '' : $options[6];
    $tag_select = $options[7];
    $cat_select = empty($options[8]) ? '0' : $options[8];
    $selected = explode(',', $cat_select);
    $mydirpath = get_xpress_dir_path();
    if (empty($date_format)) {
        $date_format = get_settings('date_format');
    }
    if (empty($time_format)) {
        $time_format = get_settings('time_format');
    }
    if (empty($tag_select)) {
        $tag_where = '';
    } else {
        $tag_where = "tag='{$tag_select}'&";
    }
    if (array_search(0, $selected) === 0) {
        $cat_select = 0;
    }
    $selected_author_id = xpress_selected_author_id('echo=0');
    if (!empty($selected_author_id)) {
        $author_where = "author={$selected_author_id}&";
    } else {
        $author_where = '';
    }
    global $wpdb, $wp_query;
    $block = array();
    $item_no = 0;
    if (!is_null($wpdb)) {
        $wp_query->in_the_loop = true;
        //for use the_tags() in multi lopp
        if ($cat_select) {
            $r = new WP_Query($author_where . $tag_where . "cat={$cat_select}&showposts={$disp_count}&what_to_show=posts&nopaging=0&post_status=publish");
        } else {
            $r = new WP_Query($author_where . $tag_where . "showposts={$disp_count}&what_to_show=posts&nopaging=0&post_status=publish");
        }
        while ($r->have_posts()) {
            $r->the_post();
            ob_start();
            the_ID();
            $post_id = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_title();
            $title = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_permalink();
            $permalink = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_author_posts_link();
            $author = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_category(' • ');
            $category = ob_get_contents();
            ob_end_clean();
            if (function_exists('the_tags')) {
                ob_start();
                the_tags(__('Tags:', 'xpress') . ' ', ' • ', '');
                $tags = ob_get_contents();
                ob_end_clean();
            } else {
                $tags = '';
            }
            ob_start();
            the_modified_date($date_format);
            $post_modified_date = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_modified_date($time_format);
            $post_modified_time = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_time($date_format);
            $post_date = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_time($time_format);
            $post_time = ob_get_contents();
            ob_end_clean();
            ob_start();
            comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
            $comments_popup_link = ob_get_contents();
            ob_end_clean();
            $red_sec = $disp_red * 60 * 60 * 24;
            $green_sec = $disp_green * 60 * 60 * 24;
            ob_start();
            the_time('U');
            $check_time = ob_get_contents();
            ob_end_clean();
            $elapse = time() - $check_time;
            $new_mark = '';
            if ($elapse < $red_sec) {
                $new_mark = '<em style="color: red; font-size: small;">New! </em>';
            } else {
                if ($elapse < $green_sec) {
                    $new_mark = '<em style="color: green; font-size: small;">New! </em>';
                }
            }
            $post_title = '<a href="' . $permalink . '">' . $title . '</a>';
            $post_date_time = $post_date . ' ' . $post_time;
            $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time;
            $trackback_url = trackback_url(false);
            $post_viwes = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress') . '&echo=0');
            //			if (empty($tags)) $tags = __('Not Tag');
            $row_data = array('post_id' => $post_id, 'new_mark' => $new_mark, 'post_title' => $post_title, 'post_date' => $post_date, 'post_time' => $post_time, 'post_date_time' => $post_date_time, 'post_modified_date' => $post_modified_date, 'post_modified_time' => $post_modified_time, 'post_modified_date_time' => $post_modified_date_time, 'post_author' => $author, 'post_category' => $category, 'post_tags' => $tags, 'post_views' => $post_viwes, 'comment_link' => $comments_popup_link, 'trackback_url' => $trackback_url);
            $block['contents']['item' . $item_no] = $row_data;
            $item_no++;
        }
        $block['data_count'] = $item_no;
        //xml unserialise error
    }
    return $block;
}
function popular_posts_block($options)
{
    $mydirname = empty($options[0]) ? 'xpress' : $options[0];
    $this_template = empty($options[1]) ? 'db:' . $mydirname . '_block_popular.html' : trim($options[1]);
    $disp_count = empty($options[2]) ? '10' : $options[2];
    $show_month_range = empty($options[3]) ? '0' : $options[3];
    $date_format = empty($options[4]) ? '' : $options[4];
    $time_format = empty($options[5]) ? '' : $options[5];
    $tag_select = $options[6];
    $cat_select = empty($options[7]) ? '0' : $options[7];
    $selected = explode(',', $cat_select);
    $mydirpath = get_xpress_dir_path();
    if (empty($date_format)) {
        $date_format = get_settings('date_format');
    }
    if (empty($time_format)) {
        $time_format = get_settings('time_format');
    }
    if (array_search(0, $selected) === 0) {
        $cat_select = 0;
    }
    $cat_select;
    $block = array();
    $item_no = 0;
    $selected_author_id = xpress_selected_author_id('echo=0');
    global $wpdb, $wp_query, $xoops_db;
    $db_prefix = get_wp_prefix();
    $post_tb = $wpdb->posts;
    $view_tb = $db_prefix . 'views';
    $user_tb = $db_prefix . 'users';
    $term_relationships_tb = $wpdb->term_relationships;
    // upper 2.3
    $term_taxonomy = $wpdb->term_taxonomy;
    // upper 2.3
    $terms_tb = $wpdb->terms;
    // upper 2.3
    $post2cat_tb = $wpdb->post2cat;
    //under 2.3
    $categories_tb = $wpdb->categories;
    //under 2.3
    include $mydirpath . '/wp-includes/version.php';
    $select = "SELECT {$view_tb}.post_views, {$post_tb}.ID, {$post_tb}.post_title, {$post_tb}.post_date";
    if ($wp_db_version >= 6124) {
        $from = " FROM (((";
        $from .= " {$post_tb} LEFT JOIN {$view_tb} ON {$post_tb}.ID = {$view_tb}.post_id)";
        $from .= " INNER JOIN {$term_relationships_tb} ON {$post_tb}.ID = {$term_relationships_tb}.object_id)";
        $from .= " INNER JOIN {$term_taxonomy} ON {$term_relationships_tb}.term_taxonomy_id = {$term_taxonomy}.term_taxonomy_id)";
        $from .= " INNER JOIN {$terms_tb} ON {$term_taxonomy}.term_id = {$terms_tb}.term_id ";
        $where = " WHERE {$post_tb}.post_type = 'post' AND {$post_tb}.post_status = 'publish'";
        //		if (!empty($selected_author_id)){
        //			$where  .= " AND ($post_tb.post_author = $selected_author_id) ";
        //			$where  .= " AND ($post_tb.post_author = 2) ";
        //		}
        if ($cat_select) {
            $where .= " AND ({$term_taxonomy}.term_id IN ({$cat_select}))";
        }
        if (!empty($tag_select)) {
            $tag_id_list = get_tag_id($tag_select);
            if (!empty($tag_id_list)) {
                $where .= " AND ({$term_taxonomy}.term_id IN ({$tag_id_list}))";
            }
        }
    } else {
        $from = " FROM ((";
        $from .= " {$post_tb} LEFT JOIN {$view_tb} ON {$post_tb}.ID = {$view_tb}.post_id)";
        $from .= " LEFT JOIN {$post2cat_tb} ON {$post_tb}.ID = {$post2cat_tb}.post_id)";
        $from .= " INNER JOIN {$user_tb} ON {$post_tb}.post_author = {$user_tb}.ID";
        $where = " WHERE ({$post_tb}.post_status = 'publish') AND  (UNIX_TIMESTAMP({$post_tb}.post_date) <= UNIX_TIMESTAMP())";
        if ($cat_select) {
            $where .= " AND ({$post2cat_tb}.category_id IN ({$cat_select}))";
        }
    }
    if ($show_month_range > 0) {
        $where .= " AND (UNIX_TIMESTAMP({$post_tb}.post_date) >= UNIX_TIMESTAMP(DATE_ADD(CURRENT_DATE, INTERVAL -{$show_month_range} month)))";
    }
    $order_limmit = " GROUP BY {$post_tb}.ID ORDER BY {$view_tb}.post_views DESC LIMIT 0, {$disp_count}";
    $sql = $select . $from . $where . $order_limmit;
    $populars = $wpdb->get_results($sql);
    foreach ($populars as $popular) {
        $wp_query->in_the_loop = true;
        //for use the_tags() in multi lopp
        $r = new WP_Query("p={$popular->ID}");
        if ($r->have_posts()) {
            $r->the_post();
            ob_start();
            the_ID();
            $post_id = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_title();
            $title = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_permalink();
            $permalink = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_author_posts_link();
            $author = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_category(' &bull; ');
            $category = ob_get_contents();
            ob_end_clean();
            if (function_exists('the_tags')) {
                ob_start();
                the_tags(__('Tags:', 'xpress') . ' ', ' &bull; ', '');
                $tags = ob_get_contents();
                ob_end_clean();
            } else {
                $tags = '';
            }
            ob_start();
            the_modified_date($date_format);
            $post_modified_date = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_modified_date($time_format);
            $post_modified_time = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_time($date_format);
            $post_date = ob_get_contents();
            ob_end_clean();
            ob_start();
            the_time($time_format);
            $post_time = ob_get_contents();
            ob_end_clean();
            ob_start();
            comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
            $comments_popup_link = ob_get_contents();
            ob_end_clean();
            $post_title = '<a href="' . $permalink . '">' . $title . '</a>';
            $post_date_time = $post_date . ' ' . $post_time;
            $post_modified_date_time = $post_modified_date . ' ' . $post_modified_time;
            $trackback_url = trackback_url(false);
            $post_viwes = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress') . '&echo=0');
            //			if (empty($tags)) $tags = __('Not Tag');
            $row_data = array('post_id' => $post_id, 'post_title' => $post_title, 'post_date' => $post_date, 'post_time' => $post_time, 'post_date_time' => $post_date_time, 'post_modified_date' => $post_modified_date, 'post_modified_time' => $post_modified_time, 'post_modified_date_time' => $post_modified_date_time, 'post_author' => $author, 'post_category' => $category, 'post_tags' => $tags, 'post_views' => $post_viwes, 'comment_link' => $comments_popup_link, 'trackback_url' => $trackback_url);
            $block['contents']['item' . $item_no] = $row_data;
            $item_no++;
        }
    }
    // end of foreach
    $block['data_count'] = $item_no;
    //xml unserialise error
    return $block;
}
Example #3
0
</head>
<body <?php 
if (function_exists('body_class')) {
    body_class();
}
?>
>
<div id="xpress_page">
	<div id="xpress-header-bar">
		<!-- <div id="xpress_header" role="banner"> -->
		<div id="xpress_header">
			<div id="xpress-header-bar-top">
				<div class="xpress-header-title">
					<?php 
if (xpress_selected_author_id('echo=0') && function_exists('get_avatar')) {
    echo get_avatar(xpress_selected_author_id('echo=0'), $size = '32');
}
?>
					<a href="<?php 
echo get_option('home');
?>
/"><?php 
bloginfo('name');
?>
</a>
				</div>
				<div class="xpress-conditional-title">
					&nbsp; <?php 
xpress_conditional_title();
?>
 
Example #4
0
function xpress_conditional_title($args ='')
{
	$defaults = array(
		'echo' => 1
	);
	$r = wp_parse_args( $args, $defaults );

	extract( $r );
	
	$selected_author = xpress_selected_author('echo=0');
	
	$output = __('Main', 'xpressme');
	$output = '';
	if (is_category())
		$output = sprintf(__('Archive for the &#8216;%s&#8217; Category', 'xpressme'), single_cat_title('', false));
	if (function_exists( 'is_tag' )){
		if (is_tag())
			$output = sprintf(__('Posts Tagged &#8216;%s&#8217;', 'xpressme'), single_tag_title('', false) );
	}
	if (is_day())
		$output = sprintf(__('Archive for %s|Daily archive page', 'xpressme'), get_the_time(__('F jS, Y', 'xpressme')));
	if (is_month())
		$output = sprintf(__('Archive for %s|Monthly archive page', 'xpressme'), get_the_time(__('F, Y', 'xpressme')));
	if (is_year())
		$output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme')));
	if (is_author()){
		if (empty($selected_author))
			$output = sprintf(__('Archive for the &#8216;%s&#8217; Author', 'xpressme'), get_author_name( get_query_var('author')));
	}
	if (is_search())
		$output = sprintf(__('Search Results of word &#8216;%s&#8217;', 'xpressme'), get_search_query());
	
	if (!empty($selected_author)){
		$selected_id = xpress_selected_author_id('echo=0');
//		$output = get_avatar($selected_id,$size = '32') . sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
		if (empty($output))
			$output = sprintf(__('Article of %s', 'xpressme'), $selected_author) ;
		else
			$output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output;
	}	
	if ($echo)
		echo $output;
	else
		return $output;
}
Example #5
0
if (function_exists('wp_enqueue_script')) { // not function Ver2.0
	if ( is_singular() ){  //not function Ver2.0
		wp_enqueue_script( 'comment-reply' );
	}
}
?>
<?php wp_head(); ?>
</head>
<body <?php if(function_exists('body_class')) body_class(); ?>>
<div id="xpress_page">
	<div id="xpress-header-bar">
		<!-- <div id="xpress_header" role="banner"> -->
		<div id="xpress_header">
			<div id="xpress-header-bar-top">
				<div class="xpress-header-title">
					<?php  if (xpress_selected_author_id('echo=0') && function_exists('get_avatar')) echo get_avatar(xpress_selected_author_id('echo=0'),$size = '32'); ?>
					<a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a>
				</div>
				<div class="xpress-conditional-title">
					&nbsp; <?php xpress_conditional_title();?> 
				</div>
				<div class="xpress-description">
					<?php bloginfo('description'); ?>
				</div>
			</div><!-- #xpress-header-bar-top -->
	
			<!-- <div id="menu_div" role="navigation"> -->
			<div id="menu_div">
				<div id="access">
					<?php if (function_exists('wp_nav_menu')) wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-aheader' ) ); ?> 
				</div><!-- #access -->
function recent_posts_content_block($options)
{
	$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
	$this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_recent_posts_content_block.html' : trim( $options[1] );
	$disp_count =  ($options[2])?intval($options[2]):10;
	$excerpt = empty( $options[3] ) ? false : true ;
	$excerpt_size =  ($options[4])?intval($options[4]):100;
	$date_format = empty( $options[5] ) ? '' : $options[5] ;
	$time_format = empty( $options[6] ) ? '' : $options[6] ;
	$tag_select = $options[7] ;
	$cat_select = empty( $options[8] ) ? '0' : $options[8] ;
	$day_select = ($options[9])?intval($options[9]):0;
	$day_size = ($options[10])?intval($options[10]):0;

	$selected = explode(',' , $cat_select);
	
	$mydirpath = get_xpress_dir_path();
	
	if (empty($date_format)) $date_format = get_settings('date_format');
	if (empty($time_format)) $time_format = get_settings('time_format');
	if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&";
	if (array_search(0,$selected)===0) $cat_select = 0;

	$selected_author_id = xpress_selected_author_id('echo=0');	
	if (!empty($selected_author_id)){
		$author_where ="author=$selected_author_id&";
	} else {
		$author_where = '';
	}
	
	$date_today = mktime (0, 0, 0, date("m"), date("d"), date("Y"));
	$between_days = $day_size * 60 * 60 * 24;
	
	global $wpdb,$wp_query;
	$block = array();
	$item_no = 0;	
	if (!is_null($wpdb)){
		$wp_query->in_the_loop = true;		//for use the_tags() in multi lopp 
		if ($cat_select) {
			$r = new WP_Query($author_where . $tag_where ."cat=$cat_select&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
		} else {
			$r = new WP_Query($author_where . $tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish");
		}
		while($r->have_posts()){			
			$r->the_post();
			if ($day_select == 1){
				$post_date = mktime (0, 0, 0, get_the_time("m"), get_the_time("d"), get_the_time("Y"));
				$base_date = $date_today - $between_days;
				if ($post_date < $base_date) continue;
			}
			if ($day_select == 2){
				$post_date = mktime (0, 0, 0, get_the_time("m"), get_the_time("d"), get_the_time("Y"));
				if (empty($latest_date)) $latest_date = $post_date;
				$base_date = $latest_date - $between_days;
				if ($post_date < $base_date) continue;
			}
			
			ob_start();
				the_ID();
				$post_id = ob_get_contents();
			ob_end_clean();
			
			$title = xpress_the_title('echo=0');
			
			ob_start();
				the_permalink();
				$permalink = ob_get_contents();
			ob_end_clean();					
			
			ob_start();
				the_author_posts_link();
				$author = ob_get_contents();
			ob_end_clean();
			
			ob_start();
				the_category(' &bull; ');
				$category = ob_get_contents();
			ob_end_clean();	
			
			if (function_exists('the_tags')){
				ob_start();
					the_tags(__('Tags:', 'xpress') . ' ',' &bull; ','');
					$tags = ob_get_contents();
				ob_end_clean();	
			} else {
				$tags = '';
			}

			$param = array(
				'configration_select' => 0, 
				'do_excerpt' => $excerpt,
				'excerpt_length_word' => $excerpt_size, 
				'excerpt_length_character' => $excerpt_size, 
				'echo' => 0
			);

			$post_content = xpress_the_content($param);
			
			ob_start();
				the_modified_date($date_format);
				$post_modified_date = ob_get_contents();
			ob_end_clean();
				
			ob_start();
				the_modified_date($time_format);
				$post_modified_time = ob_get_contents();
			ob_end_clean();
			
			ob_start();
				the_time($date_format);
				$post_date = ob_get_contents();
			ob_end_clean();
			
			ob_start();
				the_time($time_format);
				$post_time = ob_get_contents();
			ob_end_clean();
			
			
			ob_start();
				comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
				$comments_popup_link = ob_get_contents();
			ob_end_clean();

// all_in_one			
			ob_start();
?>
				<div class="xpress-post" id="post-<?php the_ID(); ?>">
					<div class ="xpress-post-header">
						<?php if (function_exists('hotDates')) { hotDates(); }?>
						<div class ="xpress-post-title">
							<?php if(function_exists('the_title_attribute')) : ?>			
								<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2>
							<?php else : ?>
								<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'xpress'), the_title('','',false)); ?>"><?php the_title(); ?></a></h2>
							<?php endif; ?>

						</div>
					</div>
					<div class="xpress-post-entry">
					<?php	echo $post_content; ?>							
					</div>
					<div class="xpress-link-pages"><?php wp_link_pages() ?></div>
					<div class ="xpress-post-footer">
<?php
						the_time('Y/m/d l');
						echo ' - ';
						the_author_posts_link();
						echo ' (' . xpress_post_views_count('post_id=' . $post->ID . '&format=' . __('Views :%d', 'xpress'). '&echo=0') . ')'; 
						
						echo ' | ';
						// echo the_tags(__('Tags:', 'xpress') . ' ', ', ', ' | ');
						printf(__('Posted in %s', 'xpress'), get_the_category_list(', '));
						echo ' | ';
						edit_post_link(__('Edit', 'xpress'), '', ' | ');
						comments_popup_link(__('No Comments &#187;', 'xpress'), __('1 Comment &#187;', 'xpress'), __('% Comments &#187;', 'xpress'), '', __('Comments Closed', 'xpress') );
?>
					</div>
				</div>
<?php
			$all_in_one = ob_get_contents();
			ob_end_clean();
						
			
			$post_title = '<a href="' . $permalink . '">' . $title . '</a>';
			$post_date_time = $post_date . ' ' . $post_time ;
			$post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
			$trackback_url = trackback_url(false);
			$post_viwes = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');

//			if (empty($tags)) $tags = __('Not Tag');

			$row_data = array(
				'post_id'		=> $post_id ,
				'post_title'	=> $post_title ,
				'post_content' 		=> $post_content ,
				'post_date' => $post_date ,
				'post_time' => $post_time ,
				'post_date_time' => $post_date_time ,
				'post_modified_date' => $post_modified_date ,
				'post_modified_time' => $post_modified_time ,
				'post_modified_date_time' => $post_modified_date_time ,
				'post_author' 	=> $author ,
				'post_category' 	=> $category ,	
				'post_tags' 		=> $tags,
				'post_views' 		=> $post_viwes,
				'comment_link' 	=> $comments_popup_link ,
				'trackback_url' => $trackback_url ,
				'all_in_one' => $all_in_one
			);
			
			$block['contents']['item'.$item_no] = $row_data;
			$item_no++;
		}
		$block['data_count'] = $item_no;  //xml unserialise error
	}
	return $block ;
}
function global_popular_posts_block($options)
{
	$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
	$this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_grobal_popular_posts_block.html' : trim( $options[1] );
	$disp_count = empty( $options[2] ) ? '10' : $options[2] ;
	$show_month_range = empty( $options[3] ) ? '0' : $options[3] ;
	$date_format = empty( $options[4] ) ? '' : $options[4] ;
	$time_format = empty( $options[5] ) ? '' : $options[5] ;
	
	$selected = explode(',' , $cat_select);

	$mydirpath = get_xpress_dir_path();
	
	if (empty($date_format)) $date_format = get_settings('date_format');
	if (empty($time_format)) $time_format = get_settings('time_format');
	
	$cat_select;
	$block = array();
	$item_no = 0;	
	
	$selected_author_id = xpress_selected_author_id('echo=0');	
	
	$data_array = array();

	global $wpdb,$wp_query,$xoops_db,$wp_rewrite;
	
	if (xpress_is_multiblog()){
		$blogs = get_blog_list(0,'all');
		foreach ($blogs AS $blog) {
			switch_to_blog($blog['blog_id']);
			$wp_rewrite->init();
			
			$blog_title = get_bloginfo('name');
			$blog_link = get_bloginfo('url');
			$blog_title_link = '<a href="' . $blog_link . '">' . $blog_title . '</a>' ;

			$db_prefix = get_wp_prefix();
			
			$post_tb = $wpdb->posts;
			$view_tb = $db_prefix . 'views';
			$user_tb = $db_prefix . 'users';
			
			$term_relationships_tb = $wpdb->term_relationships;	// upper 2.3
			$term_taxonomy = $wpdb->term_taxonomy;				// upper 2.3
			$terms_tb = $wpdb->terms;							// upper 2.3

			$post2cat_tb = $wpdb->post2cat; 					//under 2.3
			$categories_tb = $wpdb->categories; 				//under 2.3
			
			include ($mydirpath . '/wp-includes/version.php');
				
			$select = "SELECT $view_tb.post_views, $post_tb.ID, $post_tb.post_title, $post_tb.post_date";				
			if ($wp_db_version >= 6124){
		 		$from  = " FROM (((";
		 		$from .= " $post_tb LEFT JOIN $view_tb ON $post_tb.ID = $view_tb.post_id)";
		 		$from .= " INNER JOIN $term_relationships_tb ON $post_tb.ID = $term_relationships_tb.object_id)";
		 		$from .= " INNER JOIN $term_taxonomy ON $term_relationships_tb.term_taxonomy_id = $term_taxonomy.term_taxonomy_id)";
		 		$from .= " INNER JOIN $terms_tb ON $term_taxonomy.term_id = $terms_tb.term_id ";
		 		
			 	$where = " WHERE $post_tb.post_type = 'post' AND $post_tb.post_status = 'publish'";
			} else {
				$from  = " FROM ((";
				$from .= " $post_tb LEFT JOIN $view_tb ON $post_tb.ID = $view_tb.post_id)";
				$from .= " LEFT JOIN $post2cat_tb ON $post_tb.ID = $post2cat_tb.post_id)";
				$from .= " INNER JOIN $user_tb ON $post_tb.post_author = $user_tb.ID";
				
				$where = " WHERE ($post_tb.post_status = 'publish') AND  (UNIX_TIMESTAMP($post_tb.post_date) <= UNIX_TIMESTAMP())" ;
				
			}
				

			if ($show_month_range > 0) {
			 		$where .= " AND (UNIX_TIMESTAMP($post_tb.post_date) >= UNIX_TIMESTAMP(DATE_ADD(CURRENT_DATE, INTERVAL -$show_month_range month)))";
			}
			$order_limmit = " GROUP BY $post_tb.ID ORDER BY $view_tb.post_views DESC LIMIT 0, $disp_count";
			$sql = $select . $from . $where . $order_limmit;

			$populars = $wpdb->get_results($sql);
			
			foreach ($populars as $popular){
				$wp_query->in_the_loop = true;		//for use the_tags() in multi lopp 
				$r = new WP_Query("p=$popular->ID");
				if($r->have_posts()){
					$r->the_post();
					ob_start();
						the_ID();
						$post_id = ob_get_contents();
					ob_end_clean();
					
					ob_start();
						the_title();
						$title = ob_get_contents();
					ob_end_clean();
					
					ob_start();
						the_permalink();
						$permalink = ob_get_contents();
					ob_end_clean();					
					
					ob_start();
						the_author_posts_link();
						$author = ob_get_contents();
					ob_end_clean();
					
					ob_start();
						the_category(' &bull; ');
						$category = ob_get_contents();
					ob_end_clean();	
					
					if (function_exists('the_tags')){
						ob_start();
							the_tags(__('Tags:', 'xpress') . ' ',' &bull; ','');
							$tags = ob_get_contents();
						ob_end_clean();	
					} else {
						$tags = '';
					}
					
					ob_start();
						the_modified_date($date_format);
						$post_modified_date = ob_get_contents();
					ob_end_clean();
						
					ob_start();
						the_modified_date($time_format);
						$post_modified_time = ob_get_contents();
					ob_end_clean();
					
					ob_start();
						the_time($date_format);
						$post_date = ob_get_contents();
					ob_end_clean();
					
					ob_start();
						the_time($time_format);
						$post_time = ob_get_contents();
					ob_end_clean();
					
					
					ob_start();
						comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)'));
						$comments_popup_link = ob_get_contents();
					ob_end_clean();
					

					$post_title = '<a href="' . $permalink . '">' . $title . '</a>';
					$post_date_time = $post_date . ' ' . $post_time ;
					$post_modified_date_time = $post_modified_date . ' ' . $post_modified_time ;
					$trackback_url = trackback_url(false);
					$post_views = xpress_post_views_count('post_id=' . $post_id . '&format=' . __('Views :%d', 'xpress'). '&echo=0');
					$post_views_num = (int) xpress_post_views_count("post_id={$post_id}&format=%d&echo=0");
					$row_data = array(
						'blog_title' => $blog_title ,
						'blog_link' => $blog_link ,
						'blog_title_link' => $blog_title_link ,
						'post_id'		=> $post_id ,
						'post_title'	=> $post_title ,
						'post_date' => $post_date ,
						'post_time' => $post_time ,
						'post_date_time' => $post_date_time ,
						'post_modified_date' => $post_modified_date ,
						'post_modified_time' => $post_modified_time ,
						'post_modified_date_time' => $post_modified_date_time ,
						'post_author' 	=> $author ,
						'post_category' 	=> $category ,	
						'post_tags' 		=> $tags,
						'post_views' 		=> $post_views,
						'post_views_num'	=> $post_views_num,
						'comment_link' 	=> $comments_popup_link ,
						'trackback_url' => $trackback_url
					);
					$data_array[] = $row_data;
				}
			}  // end of foreach
			restore_current_blog();
			$wp_rewrite->init();
		}
		usort($data_array, "post_views_cmp");
		if (!empty($disp_count)){
			$data_array = array_slice($data_array,0,$disp_count);
		}

		$item_no = 0;
		foreach ($data_array as $data) {
			$block['contents']['item'.$item_no] = $data;
			$item_no++;
		}
		$block['data_count'] = $item_no;
	} else {
		$block['err_message'] = __('This blog is not set to the multi blog.', 'xpress');
	}
	return $block ;
}