function fetch($tplfile, $cache_id = null, $compile_id = null, $display = false)
 {
     if ($this->tplbase == 'base') {
         $tpldir = wp_base() . '/templates';
     } else {
         if ($this->tplbase == 'theme') {
             $tplpath = get_custom_path('templates/' . $tplfile);
             $tpldir = dirname($tplpath);
             $tplfile = basename($tplpath);
         } else {
             $tpldir = wp_base() . '/' . $this->tplbase . '/templates';
         }
     }
     $this->template_dir = $tpldir;
     if (!$compile_id) {
         if ($this->tplbase == 'theme') {
             $compile_id = wp_prefix() . $GLOBALS['xoopsConfig']['theme_set'] . '_';
         } else {
             $compile_id = wp_prefix() . $this->tplbase . '_';
         }
     }
     return parent::fetch($tplfile, $cache_id, $compile_id, $display);
 }
<?php

/* Don't remove these lines. */
$GLOBALS['blog'] = 1;
include 'header.php';
if (preg_match('/DoCoMo/', $_SERVER['HTTP_USER_AGENT']) and file_exists(dirname(__FILE__) . '/wp-ktai.php')) {
    header('Location: ' . wp_siteurl() . '/wp-ktai.php');
}
wp_head();
include get_custom_path('index-template.php');
include XOOPS_ROOT_PATH . '/footer.php';
 function b_wp_contents_show($options, $wp_num = "")
 {
     $no_posts = empty($options[0]) ? 10 : $options[0];
     global $wpdb, $siteurl, $post, $use_cache, $category_cache, $comment_count_cache;
     global $smilies_directory, $wp_smiliessearch, $wp_smiliesreplace, $authordata;
     global $wp_bbcode, $wp_gmcode, $wp_htmltrans, $wp_htmltranswinuni, $wp_filter;
     global $wp_id, $wp_mod, $wp_base, $wp_inblock, $xoopsConfig, $previousday, $time_difference, $day;
     $id = 1;
     $use_cache = 1;
     if ($wp_num == "") {
         $wp_id = $wp_num;
         $wp_inblock = 2;
         require dirname(__FILE__) . '/../wp-config.php';
         $wp_inblock = 0;
     }
     global $dateformat, $timeformat;
     $dateformat = stripslashes(get_settings('date_format'));
     $timeformat = stripslashes(get_settings('time_format'));
     $now = date('Y-m-d H:i:s', time() + get_settings('time_difference') * 3600);
     $request = "SELECT DISTINCT * FROM {$wpdb->posts[$wp_id]} ";
     $request .= " LEFT JOIN {$wpdb->post2cat[$wp_id]} ON ({$wpdb->posts[$wp_id]}.ID = {$wpdb->post2cat[$wp_id]}.post_id) ";
     $request .= "WHERE post_status = 'publish' ";
     $request .= " AND post_date <= '" . $now . "'";
     $request .= " GROUP BY {$wpdb->posts[$wp_id]}.ID ORDER BY post_date DESC LIMIT 0, {$no_posts}";
     $lposts = $wpdb->get_results($request);
     if ($lposts) {
         // Get the categories for all the posts
         foreach ($lposts as $post) {
             $post_id_list[] = $post->ID;
             $category_cache[$wp_id][$post->ID] = array();
         }
         $post_id_list = implode(',', $post_id_list);
         $dogs = $wpdb->get_results("SELECT DISTINCT\n\t\t\t\tID, category_id, cat_name, category_nicename, category_description, category_parent\n\t\t\t\tFROM {$wpdb->categories[$wp_id]}, {$wpdb->post2cat[$wp_id]}, {$wpdb->posts[$wp_id]}\n\t\t\t\tWHERE category_id = cat_ID AND post_id = ID AND post_id IN ({$post_id_list})");
         foreach ($dogs as $catt) {
             $category_cache[$wp_id][$catt->ID][] = $catt;
         }
         // Do the same for comment numbers
         $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount\n\t\t\t\tFROM {$wpdb->posts[$wp_id]}\n\t\t\t\tLEFT JOIN {$wpdb->comments[$wp_id]} ON ( comment_post_ID = ID  AND comment_approved =  '1')\n\t\t\t\tWHERE post_status =  'publish' AND ID IN ({$post_id_list})\n\t\t\t\tGROUP BY ID");
         foreach ($comment_counts as $comment_count) {
             $comment_count_cache[$wp_id]["{$comment_count->ID}"] = $comment_count->ccount;
         }
     }
     $blog = 1;
     $block = array();
     $block['use_theme_template'] = get_xoops_option('wordpress' . $wp_num, 'use_theme_template');
     $block['style'] = block_style_get($wp_num, false);
     $block['divid'] = 'wpBlockContent' . $wp_num;
     $block['template_content'] = "";
     $i = 0;
     $previousday = 0;
     foreach ($lposts as $post) {
         if ($block['use_theme_template'] == 0) {
             $content = array();
             start_wp();
             $content['date'] = the_date($dateformat, '', '', false);
             $content['time'] = the_time('', false);
             $content['title'] = the_title('', '', false);
             $content['permlink'] = get_permalink();
             //
             ob_start();
             the_author_posts_link();
             $content['author'] = ob_get_contents();
             ob_end_clean();
             //
             ob_start();
             the_category();
             $content['category'] = ob_get_contents();
             ob_end_clean();
             //
             ob_start();
             the_content();
             $content['body'] = ob_get_contents();
             ob_end_clean();
             //
             ob_start();
             link_pages('<br />Pages: ', '<br />', 'number');
             $content['linkpage'] = ob_get_contents();
             ob_end_clean();
             //
             ob_start();
             if (get_xoops_option($wp_mod[$wp_id], 'wp_use_xoops_comments') == 0) {
                 comments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS);
             } else {
                 xcomments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS);
                 echo " | ";
                 comments_popup_link(_WP_TPL_TRACKBACK0, _WP_TPL_TRACKBACK1, _WP_TPL_TRACKBACKS);
             }
             //				comments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS);
             $content['comments'] = ob_get_contents();
             ob_end_clean();
             //
             ob_start();
             trackback_rdf();
             $content['trackback'] = ob_get_contents();
             ob_end_clean();
             //
             $block['contents'][] = $content;
         } else {
             ob_start();
             include get_custom_path('content_block-template.php');
             $block['template_content'] .= ob_get_contents();
             ob_end_clean();
         }
     }
     $previousday = 0;
     $day = 0;
     $comment_count_cache[$wp_id] = array();
     return $block;
 }
// the months, translate them if necessary - note: this isn't active everywhere yet
$GLOBALS['month']['01'] = _WP_CAL_JANUARY;
$GLOBALS['month']['02'] = _WP_CAL_FEBRUARY;
$GLOBALS['month']['03'] = _WP_CAL_MARCH;
$GLOBALS['month']['04'] = _WP_CAL_APRIL;
$GLOBALS['month']['05'] = _WP_CAL_MAY;
$GLOBALS['month']['06'] = _WP_CAL_JUNE;
$GLOBALS['month']['07'] = _WP_CAL_JULY;
$GLOBALS['month']['08'] = _WP_CAL_AUGUST;
$GLOBALS['month']['09'] = _WP_CAL_SEPTEMBER;
$GLOBALS['month']['10'] = _WP_CAL_OCTOBER;
$GLOBALS['month']['11'] = _WP_CAL_NOVEMBER;
$GLOBALS['month']['12'] = _WP_CAL_DECEMBER;
$GLOBALS['s_month_length'] = _WP_CAL_SMONTH_LEN;
$GLOBALS['wp_month_format'] = _WP_MONTH_FORMAT;
// here's the conversion table, you can modify it if you know what you're doing
if (get_xoops_option(wp_mod(), 'wp_use_xoops_smilies')) {
    // Get smilies infomation from XOOPS DB
    $_getsmiles = $GLOBALS['xoopsDB']->query("SELECT id, code, smile_url FROM " . $GLOBALS['xoopsDB']->prefix("smiles") . " ORDER BY id");
    if ($GLOBALS['xoopsDB']->getRowsNum($_getsmiles) == "0") {
        //EMPTY
    } else {
        while ($_smiles = $GLOBALS['xoopsDB']->fetchArray($_getsmiles)) {
            $GLOBALS['wpsmiliestrans'][wp_id()][$_smiles['code']] = $_smiles['smile_url'];
        }
    }
} else {
    $GLOBALS['wpsmiliestrans'][wp_id()] = array(' :)' => 'icon_smile.gif', ' :D' => 'icon_biggrin.gif', ' :-D' => 'icon_biggrin.gif', ':grin:' => 'icon_biggrin.gif', ' :)' => 'icon_smile.gif', ' :-)' => 'icon_smile.gif', ':smile:' => 'icon_smile.gif', ' :(' => 'icon_sad.gif', ' :-(' => 'icon_sad.gif', ':sad:' => 'icon_sad.gif', ' :o' => 'icon_surprised.gif', ' :-o' => 'icon_surprised.gif', ':eek:' => 'icon_surprised.gif', ' 8O' => 'icon_eek.gif', ' 8-O' => 'icon_eek.gif', ':shock:' => 'icon_eek.gif', ' :?' => 'icon_confused.gif', ' :-?' => 'icon_confused.gif', ' :???:' => 'icon_confused.gif', ' 8)' => 'icon_cool.gif', ' 8-)' => 'icon_cool.gif', ':cool:' => 'icon_cool.gif', ':lol:' => 'icon_lol.gif', ' :x' => 'icon_mad.gif', ' :-x' => 'icon_mad.gif', ':mad:' => 'icon_mad.gif', ' :P' => 'icon_razz.gif', ' :-P' => 'icon_razz.gif', ':razz:' => 'icon_razz.gif', ':oops:' => 'icon_redface.gif', ':cry:' => 'icon_cry.gif', ':evil:' => 'icon_evil.gif', ':twisted:' => 'icon_twisted.gif', ':roll:' => 'icon_rolleyes.gif', ':wink:' => 'icon_wink.gif', ' ;)' => 'icon_wink.gif', ' ;-)' => 'icon_wink.gif', ':!:' => 'icon_exclaim.gif', ':?:' => 'icon_question.gif', ':idea:' => 'icon_idea.gif', ':arrow:' => 'icon_arrow.gif', ' :|' => 'icon_neutral.gif', ' :-|' => 'icon_neutral.gif', ':neutral:' => 'icon_neutral.gif', ':mrgreen:' => 'icon_mrgreen.gif');
}
include get_custom_path('wp-config-custom.php');
            }
        }
        $comment_author = isset($_COOKIE['comment_author_' . $GLOBALS['cookiehash']]) ? trim($_COOKIE['comment_author_' . $GLOBALS['cookiehash']]) : '';
        if (!$comment_author) {
            if (!empty($xoopsUser)) {
                $comment_author = $xoopsUser->getVar('name') ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname');
            }
        }
        $comment_author_email = isset($_COOKIE['comment_author_email_' . $GLOBALS['cookiehash']]) ? trim($_COOKIE['comment_author_email_' . $GLOBALS['cookiehash']]) : '';
        $comment_author_url = isset($_COOKIE['comment_author_url_' . $GLOBALS['cookiehash']]) ? trim($_COOKIE['comment_author_url_' . $GLOBALS['cookiehash']]) : '';
        $id = $wp_post_id;
        include get_custom_path('comments-template.php');
    } else {
        $criteria =& new CriteriaCompo(new Criteria('comment_post_ID', $GLOBALS['wp_post_id']));
        $criteria->add(new Criteria('comment_approved', '1 '));
        // Trick for numeric chars only string compare
        $criteria_c =& new CriteriaCompo(new Criteria('comment_content', '<trackback />%', 'like'));
        $criteria_c->add(new Criteria('comment_content', '<pingback />%', 'like'), 'OR');
        $criteria_c->add(new Criteria('comment_type', 'trackback'), 'OR');
        $criteria_c->add(new Criteria('comment_type', 'pingback'), 'OR');
        $criteria->add($criteria_c);
        $commentHandler =& wp_handler('Comment');
        $results = $commentHandler->open($criteria);
        $comments = array();
        while ($commentObject =& $commentHandler->getNext($results)) {
            $comments[] =& $commentObject->exportWpObject();
        }
        $id = $wp_post_id;
        include get_custom_path('xoops-comments-template.php');
    }
}
    function block_style_get($echo = true, $with_tpl = true)
    {
        $wp_num = wp_id() == '-' ? '' : wp_id();
        if ($with_tpl) {
            if (get_xoops_option(wp_mod(), 'wp_use_blockcssheader') == 1) {
                $tplVars =& $GLOBALS['xoopsTpl']->get_template_vars();
                $csslink = "\n" . '<link rel="stylesheet" type="text/css" media="screen" href="' . wp_siteurl() . '/wp-blockstyle.php" />';
                if (array_key_exists('xoops_block_header', $tplVars)) {
                    if (!strstr($tplVars['xoops_block_header'], $csslink)) {
                        $GLOBALS['xoopsTpl']->assign('xoops_block_header', $tplVars['xoops_block_header'] . $csslink);
                    }
                } else {
                    $GLOBALS['xoopsTpl']->assign('xoops_block_header', $csslink);
                }
                return;
            } else {
                if (get_xoops_option(wp_mod(), 'wp_use_blockcssheader') == 2) {
                    $tplVars =& $GLOBALS['xoopsTpl']->get_template_vars();
                    $csslink = '" />' . "\n" . '<link rel="stylesheet" type="text/css" media="screen" href="' . wp_siteurl() . '/wp-blockstyle.php';
                    if (!strstr($tplVars['xoops_themecss'], $csslink)) {
                        $GLOBALS['xoopsTpl']->assign('xoops_themecss', $tplVars['xoops_themecss'] . $csslink);
                    }
                    return;
                } else {
                    if (!defined('WP_BLOCKSTYLE_READ' . $wp_num)) {
                        define('WP_BLOCKSTYLE_READ' . $wp_num, 1);
                        if ($echo) {
                            echo '<style type="text/css" media="screen">@import url(' . wp_siteurl() . '/wp-blockstyle.php);</style>' . "\n";
                        } else {
                            return '<style type="text/css" media="screen">@import url(' . wp_siteurl() . '/wp-blockstyle.php);</style>';
                        }
                    }
                    return '';
                }
            }
        }
        $wp_block_style = '';
        include_once get_custom_path('wp-blocks.css.php');
        if ($echo) {
            if (trim($wp_block_style) != "") {
                echo <<<EOD
<style type="text/css" media="screen">
    <!--
\t{$wp_block_style}
    -->
</style>
EOD;
            }
        } else {
            return trim($wp_block_style);
        }
    }
 function _b_wp_contents_show($options, $wp_num = "")
 {
     $no_posts = empty($options[0]) ? 10 : $options[0];
     $tpl_file = empty($options[1]) ? 'wp_contents.html' : $options[1];
     $category = empty($options[2]) ? "all" : intval($options[2]);
     $GLOBALS['dateformat'] = get_settings('date_format');
     $GLOBALS['timeformat'] = get_settings('time_format');
     $_criteria = new CriteriaCompo(new Criteria('post_status', 'publish'));
     $_criteria->add(new Criteria('post_date', current_time('mysql'), '<='));
     if (empty($category) || $category == 'all' || $category == '0') {
         $_joinCriteria = null;
     } else {
         $_joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'ID', 'post_id');
         $_wCriteria =& new CriteriaCompo();
         $_wCriteria->add(new Criteria('category_id', intCriteriaVal($category)), 'OR');
         $_catc = trim(get_category_children($category, '', ' '));
         if ($_catc !== "") {
             $_catc_array = explode(' ', $_catc);
             for ($_j = 0; $_j < count($_catc_array); $_j++) {
                 $_wCriteria->add(new Criteria('category_id', intCriteriaVal($_catc_array[$_j])), 'OR');
             }
         }
         $_criteria->add($_wCriteria);
     }
     $_criteria->setGroupBy(wp_table('posts') . '.ID');
     $_criteria->setSort('post_date');
     $_criteria->setOrder('DESC');
     $_criteria->setLimit($no_posts);
     $_criteria->setStart(0);
     $postHandler =& wp_handler('Post');
     $postObjects =& $postHandler->getObjects($_criteria, false, '', 'DISTINCT', $_joinCriteria);
     //		echo $postHandler->getLastSQL();
     $lposts = array();
     foreach ($postObjects as $postObject) {
         $lposts[] =& $postObject->exportWpObject();
     }
     if ($lposts) {
         // Get the categories for all the posts
         $_post_id_list = array();
         foreach ($lposts as $post) {
             $_post_id_list[] = $post->ID;
             $GLOBALS['category_cache'][wp_id()][$post->ID] = array();
         }
         $_post_id_list = implode(',', $_post_id_list);
         $_post_id_criteria =& new Criteria('post_id', '(' . $_post_id_list . ')', 'IN');
         $_joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'ID', 'post_id');
         $_joinCriteria->cascade(new XoopsJoinCriteria(wp_table('categories'), 'category_id', 'cat_ID'));
         $postObjects =& $postHandler->getObjects($_post_id_criteria, false, 'ID, category_id, cat_name, category_nicename, category_description, category_parent', true, $_joinCriteria);
         foreach ($postObjects as $postObject) {
             $_cat->ID = $postObject->getVar('ID');
             $_cat->category_id = $postObject->getExtraVar('category_id');
             $_cat->cat_name = $postObject->getExtraVar('cat_name');
             $_cat->category_nicename = $postObject->getExtraVar('category_nicename');
             $_cat->category_description = $postObject->getExtraVar('category_description');
             $_cat->category_parent = $postObject->getExtraVar('category_parent');
             $GLOBALS['category_cache'][wp_id()][$postObject->getVar('ID')][] =& $_cat;
             unset($_cat);
         }
         // Do the same for comment numbers
         $_post_id_criteria =& new Criteria('comment_post_ID', '(' . $_post_id_list . ')', 'IN');
         $_criteria =& new CriteriaCompo(new Criteria('post_status', 'publish'));
         $_criteria->add(new Criteria('comment_approved', '1 '));
         $_criteria->add($_post_id_criteria);
         $_criteria->setGroupBy('ID');
         $_joinCriteria =& new XoopsJoinCriteria(wp_table('comments'), 'ID', 'comment_post_ID');
         $postObjects =& $postHandler->getObjects($_criteria, false, 'ID, COUNT( comment_ID ) AS ccount', false, $_joinCriteria);
         foreach ($postObjects as $postObject) {
             $GLOBALS['comment_count_cache'][wp_id()]['' . $postObject->getVar('ID')] = $postObject->getExtraVar('ccount');
         }
         // Get post-meta info
         if ($meta_list = $GLOBALS['wpdb']->get_results('SELECT post_id, meta_key, meta_value FROM ' . wp_table('postmeta') . ' WHERE post_id IN(' . $_post_id_list . ') ORDER BY post_id, meta_key', ARRAY_A)) {
             // Change from flat structure to hierarchical:
             $GLOBALS['post_meta_cache'][wp_id()] = array();
             foreach ($meta_list as $metarow) {
                 $mpid = $metarow['post_id'];
                 $mkey = $metarow['meta_key'];
                 $mval = $metarow['meta_value'];
                 // Force subkeys to be array type:
                 if (!isset($GLOBALS['post_meta_cache'][wp_id()][$mpid]) || !is_array($GLOBALS['post_meta_cache'][wp_id()][$mpid])) {
                     $GLOBALS['post_meta_cache'][wp_id()][$mpid] = array();
                 }
                 if (!isset($GLOBALS['post_meta_cache'][wp_id()][$mpid]["{$mkey}"]) || !is_array($GLOBALS['post_meta_cache'][wp_id()][$mpid]["{$mkey}"])) {
                     $GLOBALS['post_meta_cache'][wp_id()][$mpid]["{$mkey}"] = array();
                 }
                 // Add a value to the current pid/key:
                 $GLOBALS['post_meta_cache'][wp_id()][$mpid]["{$mkey}"][] = $mval;
             }
         }
     }
     $blog = 1;
     $block = array();
     $block['use_theme_template'] = get_xoops_option(wp_mod(), 'use_theme_template');
     $block['style'] = block_style_get(false);
     $block['divid'] = 'wpBlockContent' . $wp_num;
     $block['template_content'] = "";
     $i = 0;
     $GLOBALS['previousday'] = 0;
     foreach ($lposts as $post) {
         $GLOBALS['post'] = $post;
         if ($block['use_theme_template'] == 0) {
             $content = array();
             start_wp();
             $content['date'] = the_date($GLOBALS['dateformat'], '', '', false);
             $content['time'] = the_time('', false);
             $content['title'] = the_title('', '', false);
             $content['permlink'] = get_permalink();
             $content['author'] = the_author_posts_link('', false);
             $content['category'] = the_category('', '', false);
             $content['body'] = the_content(_WP_TPL_MORE, 0, '', false);
             $content['linkpage'] = link_pages('<br />Pages: ', '<br />', 'number', 'next page', 'previous page', '%', '', false);
             if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 0) {
                 $content['comments'] = comments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS, '', 'Comments Off', false);
             } else {
                 $content['comments'] = xcomments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS, '', 'Comments Off', false);
                 $content['comments'] .= " | ";
                 $content['comments'] .= comments_popup_link(_WP_TPL_TRACKBACK0, _WP_TPL_TRACKBACK1, _WP_TPL_TRACKBACKS, '', 'Trackback Off', false);
             }
             $content['trackback'] = trackback_rdf(0, false);
             $block['contents'][] = $content;
         } else {
             ob_start();
             include get_custom_path('content_block-template.php');
             $block['template_content'] .= ob_get_contents();
             ob_end_clean();
         }
     }
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     if (!$_wpTpl->tpl_exists($tpl_file)) {
         $tpl_file = 'wp_contents.html';
     }
     $block['content'] = $_wpTpl->fetch($tpl_file);
     $GLOBALS['previousday'] = 0;
     $GLOBALS['day'] = 0;
     $GLOBALS['comment_count_cache'][wp_id()] = array();
     return $block;
 }
 function _b_wp_contents_show($options, $wp_num = "")
 {
     $no_posts = empty($options[0]) ? 10 : $options[0];
     $GLOBALS['dateformat'] = stripslashes(get_settings('date_format'));
     $GLOBALS['timeformat'] = stripslashes(get_settings('time_format'));
     $_criteria = new CriteriaCompo(new Criteria('post_status', 'publish'));
     $_criteria->add(new Criteria('post_date', current_time('mysql'), '<='));
     $_criteria->setGroupBy(wp_table('posts') . '.ID');
     $_criteria->setSort('post_date');
     $_criteria->setOrder('DESC');
     $_criteria->setLimit($no_posts);
     $_criteria->setStart(0);
     $postHandler =& wp_handler('Post');
     $postObjects =& $postHandler->getObjects($_criteria, false, '', 'DISTINCT');
     $lposts = array();
     foreach ($postObjects as $postObject) {
         $lposts[] =& $postObject->exportWpObject();
     }
     if ($lposts) {
         // Get the categories for all the posts
         $_post_id_list = array();
         foreach ($lposts as $post) {
             $_post_id_list[] = $post->ID;
             $GLOBALS['category_cache'][wp_id()][$post->ID] = array();
         }
         $_post_id_list = implode(',', $_post_id_list);
         $_post_id_criteria =& new Criteria('post_id', '(' . $_post_id_list . ')', 'IN');
         $_joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'ID', 'post_id');
         $_joinCriteria->cascade(new XoopsJoinCriteria(wp_table('categories'), 'category_id', 'cat_ID'));
         $postObjects =& $postHandler->getObjects($_post_id_criteria, false, 'ID, category_id, cat_name, category_nicename, category_description, category_parent', true, $_joinCriteria);
         foreach ($postObjects as $postObject) {
             $_cat->ID = $postObject->getVar('ID');
             $_cat->category_id = $postObject->getExtraVar('category_id');
             $_cat->cat_name = $postObject->getExtraVar('cat_name');
             $_cat->category_nicename = $postObject->getExtraVar('category_nicename');
             $_cat->category_description = $postObject->getExtraVar('category_description');
             $_cat->category_parent = $postObject->getExtraVar('category_parent');
             $GLOBALS['category_cache'][wp_id()][$postObject->getVar('ID')][] =& $_cat;
             unset($_cat);
         }
         // Do the same for comment numbers
         $_criteria =& new CriteriaCompo(new Criteria('post_status', 'publish'));
         $_criteria->add(new Criteria('comment_approved', '1 '));
         $_criteria->add($_post_id_criteria);
         $_criteria->setGroupBy('ID');
         $_joinCriteria =& new XoopsJoinCriteria(wp_table('comments'), 'ID', 'comment_post_ID');
         $postObjects =& $postHandler->getObjects($_criteria, false, 'ID, COUNT( comment_ID ) AS ccount', false, $_joinCriteria);
         foreach ($postObjects as $postObject) {
             $GLOBALS['comment_count_cache'][wp_id()]['' . $postObject->getVar('ID')] = $postObject->getExtraVar('ccount');
         }
     }
     $blog = 1;
     $block = array();
     $block['use_theme_template'] = get_xoops_option(wp_mod(), 'use_theme_template');
     $block['style'] = block_style_get(false);
     $block['divid'] = 'wpBlockContent' . $wp_num;
     $block['template_content'] = "";
     $i = 0;
     $GLOBALS['previousday'] = 0;
     foreach ($lposts as $post) {
         $GLOBALS['post'] = $post;
         if ($block['use_theme_template'] == 0) {
             $content = array();
             start_wp();
             $content['date'] = the_date($GLOBALS['dateformat'], '', '', false);
             $content['time'] = the_time('', false);
             $content['title'] = the_title('', '', false);
             $content['permlink'] = get_permalink();
             $content['author'] = the_author_posts_link('', false);
             $content['category'] = the_category('', '', false);
             $content['body'] = the_content(_WP_TPL_MORE, 0, '', false);
             $content['linkpage'] = link_pages('<br />Pages: ', '<br />', 'number', 'next page', 'previous page', '%', '', false);
             if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 0) {
                 $content['comments'] = comments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS, '', 'Comments Off', false);
             } else {
                 $content['comments'] = xcomments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS, '', 'Comments Off', false);
                 $content['comments'] .= " | ";
                 $content['comments'] .= comments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS, '', 'Comments Off', false);
             }
             $content['trackback'] = trackback_rdf(0, false);
             $block['contents'][] = $content;
         } else {
             ob_start();
             include get_custom_path('content_block-template.php');
             $block['template_content'] .= ob_get_contents();
             ob_end_clean();
         }
     }
     $GLOBALS['previousday'] = 0;
     $GLOBALS['day'] = 0;
     $GLOBALS['comment_count_cache'][wp_id()] = array();
     return $block;
 }
}
if ($_comment == 'comment' || $_comment == '') {
    redirect_header($_location, 5, _LANG_WPCP_ERR_TYPE);
}
if (get_settings('use_comment_preview') && $_action != 'confirm') {
    $GLOBALS['show_cblock'] = 0;
    include 'header.php';
    $_comment = balanceTags($_comment, 1);
    $_comment = convert_chars($_comment);
    $_comment = apply_filters('post_comment_text', $_comment);
    $comment_preview = apply_filters('comment_text', $_comment);
    $author_preview = apply_filters('comment_author', $_author);
    if (!empty($_url)) {
        $author_preview = '<a href="' . $_url . '" rel="external">' . $author_preview . '</a>';
    }
    include get_custom_path('confirm-template.php');
    include XOOPS_ROOT_PATH . '/footer.php';
    exit;
} else {
    if (get_settings('use_comment_preview') && $_action == 'confirm') {
        if (!$xoopsWPTicket->check()) {
            redirect_header($_location, 3, $xoopsWPTicket->getErrors());
        }
    }
    $_now = current_time('mysql');
    $_comment = balanceTags($_comment, 1);
    $_comment = convert_chars($_comment);
    $_comment = apply_filters('post_comment_text', $_comment);
    $_comment_author = $_author;
    $_comment_author_email = $_email;
    $_comment_author_url = $_url;
<?php

$GLOBALS['blog'] = 1;
$cur_PATH = $_SERVER['SCRIPT_FILENAME'];
require dirname(__FILE__) . '/wp-config.php';
error_reporting(E_ERROR);
header('Content-type: text/css; charset=' . $GLOBALS['blog_charset']);
static_content_header(filemtime(get_custom_path('wp-blocks.css.php')));
$_SERVER['SCRIPT_FILENAME'] = 'XXXXX';
//trick for force reading some style and keep comatibility.
echo block_style_get(false, false);
exit;