function _b_wp_archives_monthly_show($options, $wp_num = '')
 {
     $block_style = $options[0] ? $options[0] : 0;
     $with_count = $options[1] == 0 ? false : true;
     $tpl_file = empty($options[2]) ? 'wp_archives_monthly.html' : $options[2];
     $sel_value = '';
     if (current_wp()) {
         if (!empty($_SERVER['PATH_INFO'])) {
             permlink_to_param();
         }
         init_param('GET', 'm', 'string', '');
         init_param('GET', 'year', 'integer', '');
         init_param('GET', 'monthnum', 'integer', '');
         init_param('GET', 'day', 'integer', '');
         if (strlen(get_param('m')) == 6) {
             $sel_value = get_param('m');
         } else {
             if (test_param('year') && test_param('monthnum') && !test_param('day')) {
                 $sel_value = get_param('year') . zeroise(get_param('monthnum'), 2);
             }
         }
     }
     $block['wp_num'] = $wp_num;
     $block['divid'] = 'wpArchive' . $wp_num;
     $block['siteurl'] = wp_siteurl();
     $block['style'] = block_style_get(false);
     $block['block_style'] = $block_style;
     $block['with_count'] = $with_count;
     $now = current_time('mysql');
     $postHandler =& wp_handler('Post');
     $criteria =& new CriteriaCompo(new Criteria('post_date', $now, '<'));
     $criteria->add(new Criteria('post_status', 'publish'));
     $criteria->setSort('post_date');
     $criteria->setOrder('DESC');
     $criteria->setGroupby('YEAR(post_date), MONTH(post_date)');
     $postObjects =& $postHandler->getObjects($criteria, false, 'DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts');
     $block['records'] = array();
     if ($postObjects) {
         foreach ($postObjects as $postObject) {
             $this_year = $postObject->getExtraVar('year');
             $this_month = $postObject->getExtraVar('month');
             $_record['url'] = get_month_link($this_year, $this_month);
             $_record['text'] = format_month($this_year, $GLOBALS['month'][zeroise($this_month, 2)]);
             if ($with_count) {
                 $_record['count'] = '&nbsp;(' . $postObject->getExtraVar('posts') . ')';
             } else {
                 $_record['count'] = '';
             }
             $_record['select'] = $sel_value == $this_year . zeroise($this_month, 2) ? 'selected="selected"' : '';
             $block['records'][] = $_record;
         }
     }
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     if (!$_wpTpl->tpl_exists($tpl_file)) {
         $tpl_file = 'wp_archives_monthly.html';
     }
     $block['content'] = $_wpTpl->fetch($tpl_file);
     return $block;
 }
 function b_wp_authors_show($options, $wp_num = "")
 {
     $with_count = empty($options[0]) ? 0 : $options[0];
     $idmode = empty($options[1]) ? '' : $options[1];
     $show_rss2_icon = empty($options[2]) ? 0 : $options[2];
     $id = 1;
     $GLOBALS['use_cache'] = 1;
     if ($wp_num == "") {
         $GLOBALS['wp_id'] = $wp_num;
         $GLOBALS['wp_inblock'] = 1;
         require dirname(__FILE__) . '/../wp-config.php';
         $GLOBALS['wp_inblock'] = 0;
     }
     $optioncount = $with_count == 1;
     $exclude_admin = false;
     $show_fullname = false;
     $hide_empty = true;
     $feed = $show_rss2_icon == 1 ? 'rss2' : '';
     $feed_image = $show_rss2_icon == 1 ? wp_siteurl() . '/wp-images/rss-mini.gif' : '';
     ob_start();
     block_style_get($wp_num);
     echo "<ul class='wpBlockList'>\n";
     list_authors2($optioncount, $exclude_admin, $idmode, $hide_empty, $feed, $feed_image);
     echo "</ul>\n";
     $block['content'] = ob_get_contents();
     ob_end_clean();
     return $block;
 }
 function _b_wp_search_show($option, $wp_num = "")
 {
     $block['wp_num'] = $wp_num;
     $block['divid'] = 'wpSearch' . $wp_num;
     $block['style'] = block_style_get(false);
     $block['act_url'] = wp_siteurl() . '/';
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     $block['content'] = $_wpTpl->fetch('wp_search.html');
     return $block;
 }
    function _b_wp_search_show($option, $wp_num = "")
    {
        $act_url = wp_siteurl() . '/';
        $block['content'] = <<<EOD
\t\t<form name="searchform{$wp_num}" id="searchform{$wp_num}" method="get" action="{$act_url}">
\t\t<div>
\t\t\t<input type="text" name="s" size="12" /> <input type="submit" name="submit" value="search" />
\t\t</div>
\t\t</form>
EOD;
        return $block;
    }
 function _b_wp_categories_show($options, $wp_num = "")
 {
     $block_style = $options[0] ? $options[0] : 0;
     $with_count = $options[1] ? $options[1] : 0;
     $sorting_key = $options[2] ? $options[2] : 'name';
     $sorting_order = $options[3] ? $options[3] : 'asc';
     if (current_wp()) {
         if (!empty($_SERVER['PATH_INFO'])) {
             permlink_to_param();
         }
         init_param('GET', 'cat', 'string', '');
         init_param('GET', 'category_name', 'string', '');
         if (!empty($GLOBALS['category_name']) && empty($GLOBALS['cat'])) {
             if (stristr($GLOBALS['category_name'], '/')) {
                 $GLOBALS['category_name'] = explode('/', $GLOBALS['category_name']);
                 if ($GLOBALS['category_name'][count($GLOBALS['category_name']) - 1]) {
                     $GLOBALS['category_name'] = $GLOBALS['category_name'][count($GLOBALS['category_name']) - 1];
                     // no trailing slash
                 } else {
                     $GLOBALS['category_name'] = $GLOBALS['category_name'][count($GLOBALS['category_name']) - 2];
                     // there was a trailling slash
                 }
             }
             $categoryHandler =& wp_handler('Category');
             $categoryObject =& $categoryHandler->getByNiceName($GLOBALS['category_name']);
             if ($categoryObject) {
                 $GLOBALS['cat'] = $categoryObject->getVar('cat_ID');
             }
         }
     } else {
         $GLOBALS['cat'] = '';
     }
     $block['wp_num'] = $wp_num;
     $block['divid'] = 'wpCategory' . $wp_num;
     $block['siteurl'] = wp_siteurl();
     $block['style'] = block_style_get(false);
     $block['block_style'] = $block_style;
     $block['with_count'] = $with_count;
     if ($block_style == 0) {
         $cat_block = _b_wp_categories_list($sorting_key, $sorting_order, $with_count, 0, null, true);
     } else {
         $cat_block = _b_wp_categories_list($sorting_key, $sorting_order, $with_count, 0, null, false, '&#8211;', 0, $GLOBALS['cat']);
     }
     $block['records'] = $cat_block['records'];
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     $block['content'] = $_wpTpl->fetch('wp_categories.html');
     return $block;
 }
 function wp_xoops_search($queryarray, $andor, $limit, $offset, $userid, $wp_num = "")
 {
     $GLOBALS['use_cache'] = 1;
     if ($wp_num == "") {
         $GLOBALS['wp_id'] = $wp_num;
         $GLOBALS['wp_inblock'] = 1;
         require XOOPS_ROOT_PATH . "/modules/wordpress/wp-config.php";
         $GLOBALS['wp_inblock'] = 0;
     }
     $now = date('Y-m-d H:i:s', time() + get_settings('time_difference') * 3600);
     $where = "(post_status = 'publish') AND (post_date <= '" . $now . "')";
     if (is_array($queryarray) && ($count = count($queryarray))) {
         $where .= " AND ((post_title LIKE '%{$queryarray['0']}%' OR post_content LIKE '%{$queryarray['0']}%')";
         for ($i = 1; $i < $count; $i++) {
             $where .= " {$andor} ";
             $where .= "(post_title LIKE '%{$queryarray[$i]}%' OR post_content LIKE '%{$queryarray[$i]}%')";
         }
         $where .= ") ";
     }
     if ($userid) {
         $userid = intval($userid);
         $where .= " AND (post_author=" . $userid . ")";
     }
     $request = "SELECT * FROM " . wp_table('posts') . " WHERE " . $where;
     $request .= " ORDER BY post_date DESC";
     $result = $GLOBALS['xoopsDB']->query($request, $limit, $offset);
     $ret = array();
     $i = 0;
     while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) {
         $ret[$i]['link'] = str_replace(wp_siteurl() . "/", "", get_permalink($myrow['ID']));
         $ret[$i]['title'] = htmlspecialchars($myrow['post_title'], ENT_QUOTES);
         $ret[$i]['image'] = "wp-images/search.png";
         $date_str = $myrow['post_date'];
         $yyyy = substr($date_str, 0, 4);
         $mm = substr($date_str, 5, 2);
         $dd = substr($date_str, 8, 2);
         $hh = substr($date_str, 11, 2);
         $nn = substr($date_str, 15, 2);
         $ss = substr($date_str, 17, 2);
         $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy);
         $ret[$i]['uid'] = $myrow['post_author'];
         $ret[$i]['page'] = $myrow['post_title'];
         if (!empty($myrow['post_content']) && function_exists('xoops_make_context')) {
             $ret[$i]['context'] = xoops_make_context(strip_tags($myrow['post_content']), $queryarray);
         }
         $i++;
     }
     return $ret;
 }
 function _wp_xoops_search($queryarray, $andor, $limit, $offset, $userid)
 {
     $now = current_time('mysql');
     $where = '(post_status = \'publish\') AND (post_date <= \'' . $now . '\')';
     if (is_array($queryarray) && ($count = count($queryarray))) {
         $where .= " AND ((post_title LIKE '%{$queryarray['0']}%' OR post_content LIKE '%{$queryarray['0']}%')";
         for ($i = 1; $i < $count; $i++) {
             $where .= " {$andor} ";
             $where .= "(post_title LIKE '%{$queryarray[$i]}%' OR post_content LIKE '%{$queryarray[$i]}%')";
         }
         $where .= ') ';
     }
     if ($userid) {
         $userid = intval($userid);
         $where .= ' AND (post_author=' . $userid . ')';
     }
     $request = 'SELECT * FROM ' . wp_table('posts') . ' WHERE ' . $where;
     $request .= ' ORDER BY post_date DESC';
     $result = $GLOBALS['xoopsDB']->query($request, $limit, $offset);
     $ret = array();
     $i = 0;
     while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) {
         $ret[$i]['link'] = str_replace(wp_siteurl() . '/', '', get_permalink($myrow['ID']));
         $ret[$i]['title'] = htmlspecialchars($myrow['post_title'], ENT_QUOTES);
         $ret[$i]['image'] = 'wp-images/search.png';
         $date_str = $myrow['post_date'];
         $yyyy = substr($date_str, 0, 4);
         $mm = substr($date_str, 5, 2);
         $dd = substr($date_str, 8, 2);
         $hh = substr($date_str, 11, 2);
         $nn = substr($date_str, 15, 2);
         $ss = substr($date_str, 17, 2);
         $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy);
         $ret[$i]['uid'] = $myrow['post_author'];
         $ret[$i]['page'] = $myrow['post_title'];
         if (!empty($myrow['post_content']) && function_exists('xoops_make_context')) {
             $ret[$i]['context'] = xoops_make_context(strip_tags($myrow['post_content']), $queryarray);
         }
         if (!empty($myrow['post_content']) && function_exists('search_make_context')) {
             if (!empty($_GET['showcontext']) && $_GET['showcontext'] == 1) {
                 $ret[$i]['context'] = search_make_context(strip_tags($myrow['post_content']), $queryarray);
             }
         }
         $i++;
     }
     return $ret;
 }
 function _b_wp_authors_show($options, $wp_num = "")
 {
     $with_count = empty($options[0]) ? 0 : $options[0];
     $idmode = empty($options[1]) ? '' : $options[1];
     $show_rss2_icon = empty($options[2]) ? 0 : $options[2];
     $optioncount = $with_count == 1;
     $exclude_admin = false;
     $show_fullname = false;
     $hide_empty = true;
     $feed = $show_rss2_icon == 1 ? 'rss2' : '';
     $feed_image = $show_rss2_icon == 1 ? wp_siteurl() . '/wp-images/rss-mini.gif' : '';
     ob_start();
     block_style_get();
     echo "<ul class='wpBlockList'>\n";
     list_authors2($optioncount, $exclude_admin, $idmode, $hide_empty, $feed, $feed_image);
     echo "</ul>\n";
     $block['content'] = ob_get_contents();
     ob_end_clean();
     return $block;
 }
 function _b_wp_authors_show($options, $wp_num = "")
 {
     $with_count = empty($options[0]) ? 0 : $options[0];
     $idmode = empty($options[1]) ? '' : $options[1];
     $show_rss2_icon = empty($options[2]) ? 0 : $options[2];
     $optioncount = $with_count == 1;
     $exclude_admin = false;
     $show_fullname = false;
     $hide_empty = true;
     $feed = $show_rss2_icon == 1 ? 'rss2' : '';
     $feed_image = $show_rss2_icon == 1 ? wp_siteurl() . '/wp-images/rss-mini.gif' : '';
     $block['wp_num'] = $wp_num;
     $block['divid'] = 'wpAuthor' . $wp_num;
     $block['style'] = block_style_get(false);
     $block['authors'] = list_authors2($optioncount, $exclude_admin, $idmode, $hide_empty, $feed, $feed_image, false);
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     $block['content'] = $_wpTpl->fetch('wp_authors.html');
     return $block;
 }
 function _b_wp_archives_monthly_show($options, $wp_num = '')
 {
     $block_style = $options[0] ? $options[0] : 0;
     $with_count = $options[1] == 0 ? false : true;
     $sel_value = '';
     if (current_wp()) {
         if (!empty($_SERVER['PATH_INFO'])) {
             permlink_to_param();
         }
         init_param('GET', 'm', 'string', '');
         init_param('GET', 'year', 'integer', '');
         init_param('GET', 'monthnum', 'integer', '');
         if (strlen(get_param('m')) == 6) {
             $sel_value = get_param('m');
         } else {
             if (test_param('year') && test_param('monthnum')) {
                 $sel_value = get_param('year') . zeroise(get_param('monthnum'), 2);
             }
         }
     }
     ob_start();
     block_style_get($wp_num);
     if ($block_style == 0) {
         // Simple Listing
         echo '<ul class="wpBlockList">' . "\n";
         get_archives('monthly', '', 'html', '', '', $with_count);
         echo '</ul>' . "\n";
     } else {
         // Dropdown Listing
         echo '<form name="archiveform' . $wp_num . '" id="archiveform' . $wp_num . '" action="#">';
         echo '<select name="archive_chrono" onchange="window.location = (document.forms.archiveform' . $wp_num . '.archive_chrono[document.forms.archiveform' . $wp_num . '.archive_chrono.selectedIndex].value);"> ';
         echo '<option value="' . wp_siteurl() . '">' . _WP_BY_MONTHLY . '</option>';
         get_archives('monthly', '', 'option', '', '', $with_count, $sel_value);
         echo '</select>';
         echo '</form>';
     }
     $block['content'] = ob_get_contents();
     ob_end_clean();
     return $block;
 }
function add_referer()
{
    if (!empty($GLOBALS['single'])) {
        if (isset($_SERVER['HTTP_REFERER'])) {
            $url = $_SERVER['HTTP_REFERER'];
            if (not_excluded($url)) {
                require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
                $snoopy = new Snoopy();
                if ($snoopy->fetch($url)) {
                    $page = $snoopy->results;
                    $matched = false;
                    $page = mb_conv($page, $GLOBALS['blog_charset'], 'auto');
                    if (preg_match_all('/<a\\s[^>]*?href=[\\"\']([^\\"\']*?)[\\"\'][^>]*>/', $page, $matches, PREG_PATTERN_ORDER)) {
                        foreach ($matches[1] as $match) {
                            if (strstr($match, wp_siteurl())) {
                                $matched = true;
                            }
                        }
                    }
                    if (!$matched) {
                        return;
                    }
                    preg_match('/<title>(.+)<\\/title>/is', $page, $title);
                    $title = $title[1];
                    if (!$title) {
                        preg_match('/^(http:\\/\\/)?([^\\/]+)/i', $url, $matches);
                        $host = $matches[2];
                        preg_match('/[^\\.\\/]+\\.[^\\.\\/]+$/', $host, $matches);
                        $title = $matches[0];
                    }
                    $new_entry = addslashes($title . ":!-!:" . $url);
                    add_post_meta($GLOBALS['wp_post_id'], 'wp-refer', $new_entry);
                    $GLOBALS['post_meta_cache'][wp_id()][$GLOBALS['wp_post_id']]['wp-refer'][] = $new_entry;
                }
            }
        }
    }
}
 function edit_comment_link($link = _WP_TPL_EDIT_THIS, $before = '', $after = '', $echo = true)
 {
     get_currentuserinfo();
     if (!user_can_edit($GLOBALS['post']->post_author)) {
         return "";
     }
     $location = wp_siteurl() . "/wp-admin/post.php?action=editcomment&amp;comment={$GLOBALS['comment']->comment_ID}";
     return _echo("{$before} <a href='{$location}'>{$link}</a> {$after}", $echo);
 }
function pingback_ping($m)
{
    // original code by Mort
    // (http://mort.mine.nu:8080)
    global $wpdb;
    global $wp_version;
    if (!get_settings('use_pingback')) {
        return new xmlrpcresp(new xmlrpcval('Sorry, this weblog does not allow you to pingback its posts.'));
    }
    $title = '';
    $pagelinkedfrom = $m->getParam(0);
    $pagelinkedfrom = $pagelinkedfrom->scalarval();
    $pagelinkedto = $m->getParam(1);
    $pagelinkedto = $pagelinkedto->scalarval();
    $pagelinkedfrom = addslashes(str_replace('&amp;', '&', $pagelinkedfrom));
    $pagelinkedto = preg_replace('#&([^amp\\;])#is', '&amp;$1', $pagelinkedto);
    $messages = array(htmlentities('Pingback from ' . $pagelinkedfrom . ' to ' . $pagelinkedto . ' registered. Keep the web talking! :-)'), htmlentities("We can't find the URL to the post you are trying to " . "link to in your entry. Please check how you wrote the post's permalink in your entry."), htmlentities("We can't find the post you are trying to link to." . " Please check the post's permalink."));
    $message = $messages[0];
    // Check if the page linked to is in our site
    $pos1 = strpos($pagelinkedto, str_replace('http://', '', str_replace('www.', '', wp_siteurl())));
    if ($pos1) {
        // let's find which post is linked to
        $urltest = parse_url($pagelinkedto);
        if ($post_ID = url_to_postid($pagelinkedto)) {
            $way = 'url_to_postid()';
        } elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
            // the path defines the post_ID (archives/p/XXXX)
            $blah = explode('/', $match[0]);
            $post_ID = $blah[1];
            $way = 'from the path';
        } elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
            // the querystring defines the post_ID (?p=XXXX)
            $blah = explode('=', $match[0]);
            $post_ID = $blah[1];
            $way = 'from the querystring';
        } elseif (isset($urltest['fragment'])) {
            // an #anchor is there, it's either...
            if (intval($urltest['fragment'])) {
                // ...an integer #XXXX (simpliest case)
                $post_ID = $urltest['fragment'];
                $way = 'from the fragment (numeric)';
            } elseif (preg_match('/post-[0-9]+/', $urltest['fragment'])) {
                // ...a post id in the form 'post-###'
                $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
                $way = 'from the fragment (post-###)';
            } elseif (is_string($urltest['fragment'])) {
                // ...or a string #title, a little more complicated
                $title = preg_replace('/[^a-zA-Z0-9]/', '.', $urltest['fragment']);
                $sql = "SELECT ID FROM " . wp_table('posts') . " WHERE post_title RLIKE '" . addslashes($title) . "'";
                $post_ID = $wpdb->get_var($sql) or die("Query: {$sql}\n\nError: ");
                $way = 'from the fragment (title)';
            }
        } else {
            // TODO: Attempt to extract a post ID from the given URL
            $post_ID = -1;
            $way = 'no match';
        }
        logIO('O', "(PB) URI='{$pagelinkedto}' ID='{$post_ID}' Found='{$way}'");
        $sql = "SELECT post_author FROM " . wp_table('posts') . " WHERE ID = {$post_ID}";
        $result = $wpdb->get_results($sql);
        if ($wpdb->num_rows) {
            // Let's check that the remote site didn't already pingback this entry
            $sql = 'SELECT * FROM ' . wp_table('comments') . ' 
				WHERE comment_post_ID = ' . $post_ID . ' 
					AND comment_author_url = \'' . $pagelinkedfrom . '\' 
					AND comment_content LIKE \'%<pingback />%\'';
            $result = $wpdb->get_results($sql);
            if ($wpdb->num_rows || 1 == 1) {
                // very stupid, but gives time to the 'from' server to publish !
                sleep(1);
                // Let's check the remote site
                require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
                $snoopy = new Snoopy();
                if ($snoopy->fetch($pagelinkedfrom)) {
                    $linea = $snoopy->results;
                } else {
                    $linea = '';
                }
                logIO('O', "(PB) CHARSET='" . $GLOBALS['blog_charset']);
                $linea = mb_conv($linea, $GLOBALS['blog_charset'], 'auto');
                // Work around bug in strip_tags():
                $linea = str_replace('<!DOCTYPE', '<DOCTYPE', $linea);
                $linea = strip_tags($linea, '<title><a>');
                $linea = strip_all_but_one_link($linea, $pagelinkedto);
                // I don't think we need this? -- emc3
                if (empty($matchtitle)) {
                    preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
                }
                $pos2 = strpos($linea, $pagelinkedto);
                $pos3 = strpos($linea, str_replace('http://www.', 'http://', $pagelinkedto));
                logIO('O', "(PB) POS='{$pos2}, {$pos3}'");
                if (is_integer($pos2) || is_integer($pos3)) {
                    //debug_fwrite($log, 'The page really links to us :)'."\n");
                    $pos4 = is_integer($pos2) ? $pos2 : $pos3;
                    $start = $pos4 - 50;
                    if (function_exists('mb_convert_encoding')) {
                        $tmp1 = mb_strcut($linea, 0, $start, $GLOBALS['blog_charset']);
                    } else {
                        $tmp1 = substr($linea, 0, $start);
                    }
                    if (preg_match('/<[^>]*?$/', $tmp1, $match)) {
                        logIO('O', "(PB) MATCH='{$match[0]}");
                        $offset = strlen($match[0]);
                    } else {
                        $offset = 0;
                    }
                    if (function_exists('mb_convert_encoding')) {
                        $context = mb_strcut($linea, $start - $offset, 150 + $offset, $GLOBALS['blog_charset']);
                    } else {
                        $context = substr($linea, $star - $offsett, 150 + $offset);
                    }
                    $context = str_replace("\n", ' ', $context);
                    $context = str_replace('&amp;', '&', $context);
                    logIO('O', "(PB) CONTENT='{$context}");
                } else {
                    logIO('O', "(PB) CONTEXT=The page doesn't link to us, here's an excerpt");
                    exit;
                }
                //				fclose($fp);
                if (!empty($context)) {
                    // Check if pings are on, inelegant exit
                    $pingstatus = $wpdb->get_var("SELECT ping_status FROM " . wp_table('posts') . " WHERE ID = {$post_ID}");
                    if ('closed' == $pingstatus) {
                        logIO('O', '(PB) Sorry, pings are turned off for this post.');
                        exit;
                    }
                    $pagelinkedfrom = preg_replace('#&([^amp\\;])#is', '&amp;$1', $pagelinkedfrom);
                    $title = !strlen($matchtitle[1]) ? $pagelinkedfrom : $matchtitle[1];
                    $context = strip_tags($context);
                    $context = '<pingback />[...] ' . htmlspecialchars(trim($context)) . ' [...]';
                    $context = format_to_post($context);
                    $original_pagelinkedfrom = $pagelinkedfrom;
                    $pagelinkedfrom = addslashes($pagelinkedfrom);
                    $original_title = $title;
                    $title = addslashes(strip_tags(trim($title)));
                    $now = current_time('mysql', 0);
                    if (get_settings('comment_moderation') == 'manual') {
                        $approved = 0;
                    } else {
                        if (get_settings('comment_moderation') == 'auto') {
                            $approved = 0;
                        } else {
                            // none
                            $approved = 1;
                        }
                    }
                    $consulta = $wpdb->query("INSERT INTO " . wp_table('comments') . " \n\t\t\t\t\t\t(comment_post_ID, comment_author, comment_author_url, comment_date, comment_content,comment_approved, comment_type) \n\t\t\t\t\t\tVALUES \n\t\t\t\t\t\t({$post_ID}, '{$title}', '{$pagelinkedfrom}', '{$now}', '{$context}', '{$approved}', 'pingback')\n\t\t\t\t\t\t");
                    $comment_ID = $wpdb->get_var('SELECT last_insert_id()');
                    do_action('pingback_post', $comment_ID);
                    if (get_settings('moderation_notify') && !$approved) {
                        wp_notify_moderator($comment_ID, 'pingback');
                    }
                    if (get_settings('comments_notify') && $approved) {
                        wp_notify_postauthor($comment_ID, 'pingback');
                    }
                } else {
                    // URL pattern not found
                    $message = "Page linked to: {$pagelinkedto}\nPage linked from:" . " {$pagelinkedfrom}\nTitle: {$title}\nContext: {$context}\n\n" . $messages[1];
                }
            } else {
                // We already have a Pingback from this URL
                $message = "Sorry, you already did a pingback to {$pagelinkedto} from {$pagelinkedfrom}.";
            }
        } else {
            // Post_ID not found
            $message = $messages[2];
            //debug_fwrite($log, 'Post doesn\'t exist'."\n");
        }
    }
    return new xmlrpcresp(new xmlrpcval($message));
}
    function tkzy_get_recent_comments($limit = 10, $cat_date = 1, $show_type = 1)
    {
        $comment_lenth = 30;
        $request = 'SELECT ID, post_title, post_date, 
		comment_ID, comment_author, comment_author_url, comment_author_email, comment_date, comment_content 
		FROM ' . wp_table('posts') . ', ' . wp_table('comments') . ' WHERE ' . wp_table('posts') . '.ID=' . wp_table('comments') . '.comment_post_ID AND ' . wp_table('comments') . '.comment_approved=\'1\'';
        if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) {
            $request .= ' AND (comment_content like \'<trackback />%\' OR comment_content like \'<pingkback />%\') ';
        }
        $request .= ' ORDER BY ' . wp_table('comments') . '.comment_date DESC LIMIT ' . $limit;
        $lcomments = $GLOBALS['wpdb']->get_results($request);
        $output = '';
        if ($lcomments) {
            usort($lcomments, 'sort_comment_by_date');
        }
        $new_post_ID = -1;
        if ($lcomments) {
            $output .= '<ul class="wpBlockList">';
            foreach ($lcomments as $lcomment) {
                if ($lcomment->ID != $new_post_ID) {
                    // next post
                    if ($new_post_ID != -1) {
                        $output .= '</ul></li>';
                    }
                    $post_title = stripslashes($lcomment->post_title);
                    if (trim($post_title) == "") {
                        $post_title = _WP_POST_NOTITLE;
                    }
                    $comment_content = strip_tags($lcomment->comment_content);
                    $comment_content = stripslashes($comment_content);
                    if (function_exists('mb_substr')) {
                        $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth);
                    } else {
                        $comment_excerpt = substr($comment_content, 0, $comment_lenth);
                    }
                    $permalink = wp_siteurl() . '/index.php?p=' . $lcomment->ID . '&amp;c=1';
                    $output .= '<li>';
                    $output .= '<span class="comment-title"><a href="' . $permalink . '">' . $post_title . '</a></span>';
                    $output .= '<ul class="children" style="list-style-type: none;">';
                    $new_post_ID = $lcomment->ID;
                }
                $output .= "\t\t<li>";
                if ($cat_date) {
                    $comment_date = $lcomment->comment_date;
                    if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) {
                        # within 24 hours
                        $comment_date = mysql2date('H:i', $comment_date);
                    } else {
                        $comment_date = mysql2date('m/d', $comment_date);
                    }
                    $output .= '<span class="post-date">' . $comment_date . '</span> : ';
                }
                $output .= '<span class="comment_author">' . tkzy_get_comment_author_link($lcomment, 25) . '</span></li>';
                if (preg_match('|<trackback />|', $lcomment->comment_content)) {
                    $type = '[TrackBack]';
                } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) {
                    $type = '[Ping]';
                } else {
                    $type = '[Comment]';
                }
                if ($show_type) {
                    $output .= '<span style="font-size:90%"> - ' . $type . '</span>';
                }
            }
        }
        $output .= '</ul></li></ul>';
        return $output;
    }
    function _b_wp_recent_comments_show($options, $wp_num = "")
    {
        $block_style = $options[0] ? $options[0] : 0;
        $num_of_list = !isset($options[1]) ? 10 : $options[1];
        $show_rss_icon = !isset($options[2]) ? 0 : $options[2];
        $cat_date = !isset($options[3]) ? $block_style ? 1 : 0 : $options[3];
        $show_type = !isset($options[4]) ? 1 : $options[4];
        $tpl_file = empty($options[5]) ? 'wp_recent_comments.html' : $options[5];
        $block['style'] = block_style_get(false);
        $block['divid'] = 'wpRecentComment' . $wp_num;
        $block['block_style'] = $block_style;
        $block['cat_date'] = $cat_date;
        $block['show_type'] = $show_type;
        $comment_lenth = 30;
        if ($block_style == 0) {
            $skip_posts = 0;
            $request = "SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, comment_date, comment_type\n\t\t\t\t\t\tFROM " . wp_table('posts') . ", " . wp_table('comments') . "\n\t\t\t\t\t\tWHERE " . wp_table('posts') . ".ID=" . wp_table('comments') . ".comment_post_ID\n\t\t\t\t\t\tAND post_status = 'publish' AND comment_approved = '1' ";
            if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) {
                $request .= "AND (comment_content like '<trackback />%' \n\t\t\t\t                  OR comment_content like '<pingkback />%'\n\t\t\t\t                  OR comment_type = 'trackback'\n\t\t\t\t                  OR comment_type = 'pingback'\n\t\t\t\t                  ) ";
            }
            $request .= "ORDER BY " . wp_table('comments') . ".comment_date DESC LIMIT {$num_of_list}";
            $lcomments = $GLOBALS['wpdb']->get_results($request);
            $output = '';
            $pdate = "";
            $block['records'] = array();
            if ($lcomments) {
                foreach ($lcomments as $lcomment) {
                    if ($cat_date) {
                        $date = mysql2date("Y-n-j", $lcomment->comment_date);
                        if ($date != $pdate) {
                            $_record['date'] = $date;
                            $_record['pdate'] = $pdate;
                            $pdate = $date;
                        } else {
                            $_record['date'] = '';
                        }
                    }
                    if (empty($lcomment->comment_type)) {
                        if (preg_match('|<trackback />|', $lcomment->comment_content)) {
                            $type = '[TrackBack]';
                        } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) {
                            $type = '[PingBack]';
                        } else {
                            $type = '[Comment]';
                        }
                    } else {
                        if ($lcomment->comment_type == 'trackback') {
                            $type = '[TrackBack]';
                        } elseif ($lcomment->comment_type == 'pingback') {
                            $type = '[PingBack]';
                        } else {
                            $type = '[Comment]';
                        }
                    }
                    $_record['comment_author'] = apply_filters('comment_author', $lcomment->comment_author);
                    $_record['comment_author_link'] = _get_comment_author_link($lcomment, 25);
                    $_record['comment_content'] = strip_tags($lcomment->comment_content);
                    if (function_exists('mb_substr')) {
                        $_record['comment_excerpt'] = mb_substr($_record['comment_content'], 0, $comment_lenth);
                    } else {
                        $_record['comment_excerpt'] = substr($_record['comment_content'], 0, $comment_lenth);
                    }
                    $_record['comment_excerpt'] = preg_replace('/([a-zA-Z0-9\\.\\/\\:\\%\\?\\-\\+\\&\\;]{15})/ms', '\\1&#8203;', $_record['comment_excerpt']);
                    $_record['permalink'] = get_permalink($lcomment->ID) . '#comment-' . $lcomment->comment_ID;
                    if ($show_type) {
                        $_record['type'] = $type;
                    }
                    $block['records'][] = $_record;
                }
            }
        } else {
            $request = 'SELECT ID, post_title, post_date, comment_ID, comment_author, comment_author_url,
						comment_date, comment_content, comment_type
						FROM ' . wp_table('posts') . ', ' . wp_table('comments') . '
						WHERE ' . wp_table('posts') . '.ID=' . wp_table('comments') . '.comment_post_ID
						AND ' . wp_table('comments') . '.comment_approved=\'1\'';
            if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) {
                $request .= "AND (comment_content like '<trackback />%' \n\t\t\t\t                  OR comment_content like '<pingkback />%'\n\t\t\t\t                  OR comment_type = 'trackback'\n\t\t\t\t                  OR comment_type = 'pingback'\n\t\t\t\t                  ) ";
            }
            $request .= ' ORDER BY ' . wp_table('comments') . '.comment_date DESC LIMIT ' . $num_of_list;
            $lcomments = $GLOBALS['wpdb']->get_results($request);
            $output = '';
            if ($lcomments) {
                usort($lcomments, 'sort_comment_by_date');
            }
            $new_post_ID = -1;
            $block['records'] = array();
            if ($lcomments) {
                foreach ($lcomments as $lcomment) {
                    $_record['new_post_ID'] = $new_post_ID;
                    $_record['ID'] = $lcomment->ID;
                    if ($lcomment->ID != $new_post_ID) {
                        // next post
                        $_record['post_title'] = $lcomment->post_title;
                        if (trim($_record['post_title']) == "") {
                            $_record['post_title'] = _WP_POST_NOTITLE;
                        }
                        $_record['comment_content'] = strip_tags($lcomment->comment_content);
                        if (function_exists('mb_substr')) {
                            $_record['comment_excerpt'] = mb_substr($_record['comment_content'], 0, $comment_lenth);
                        } else {
                            $_record['comment_excerpt'] = substr($_record['comment_content'], 0, $comment_lenth);
                        }
                        $_record['comment_excerpt'] = preg_replace('/([a-zA-Z0-9\\.\\/\\:\\?\\-\\+%&;]{15})/ms', '\\1&#8203;', $_record['comment_excerpt']);
                        $_record['permalink'] = wp_siteurl() . '/index.php?p=' . $lcomment->ID . '&amp;c=1';
                        $new_post_ID = $lcomment->ID;
                    }
                    if ($cat_date) {
                        $comment_date = $lcomment->comment_date;
                        if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) {
                            # within 24 hours
                            $_record['comment_date'] = mysql2date('H:i', $comment_date);
                        } else {
                            $_record['comment_date'] = mysql2date('m/d', $comment_date);
                        }
                    }
                    $_record['comment_author'] = apply_filters('comment_author', $lcomment->comment_author);
                    $_record['comment_author_link'] = _get_comment_author_link($lcomment, 25);
                    if (empty($lcomment->comment_type)) {
                        if (preg_match('|<trackback />|', $lcomment->comment_content)) {
                            $type = '[TrackBack]';
                        } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) {
                            $type = '[PingBack]';
                        } else {
                            $type = '[Comment]';
                        }
                    } else {
                        if ($lcomment->comment_type == 'trackback') {
                            $type = '[TrackBack]';
                        } elseif ($lcomment->comment_type == 'pingback') {
                            $type = '[PingBack]';
                        } else {
                            $type = '[Comment]';
                        }
                    }
                    if ($show_type) {
                        $_record['type'] = $type;
                    }
                    $block['records'][] = $_record;
                }
            }
        }
        if ($show_rss_icon) {
            $block['feed_icon'] = array('url' => get_bloginfo('comments_rss2_url'), 'icon' => wp_siteurl() . '/wp-images/rss_comment.gif', 'alt' => 'Comment RSS');
        } else {
            $block['feed_icon'] = array();
        }
        $_wpTpl =& new WordPresTpl('theme');
        $_wpTpl->assign('block', $block);
        if (!$_wpTpl->tpl_exists($tpl_file)) {
            $tpl_file = 'wp_recent_comments.html';
        }
        $block['content'] = $_wpTpl->fetch($tpl_file);
        return $block;
    }
        $_form->addElement(new XoopsFormText(_LANG_WPF_SUBT_NICK, 'newuser_nickname', 50, 150, $userObject->getVar('user_nickname', 'e')), true);
        $_form->addElement(new XoopsFormText(_LANG_WPF_SUBT_MAIL, 'newuser_email', 50, 150, $userObject->getVar('user_email', 'e')), true);
        $_form->addElement(new XoopsFormText(_LANG_WPF_SUBT_URL, 'newuser_url', 50, 150, $userObject->getVar('user_url', 'e')));
        $_form->addElement(new XoopsFormText(_LANG_WPF_SUBT_ICQ, 'newuser_icq', 50, 150, $userObject->getVar('user_icq', 'e') ? $userObject->getVar('user_icq', 'e') : ''));
        $_form->addElement(new XoopsFormText(_LANG_WPF_SUBT_AIM, 'newuser_aim', 50, 150, $userObject->getVar('user_aim', 'e')));
        $_form->addElement(new XoopsFormText(_LANG_WPF_SUBT_MSN, 'newuser_msn', 50, 150, $userObject->getVar('user_msn', 'e')));
        $_form->addElement(new XoopsFormText(_LANG_WPF_SUBT_YAHOO, 'newuser_yim', 50, 150, $userObject->getVar('user_yim', 'e')));
        $_form_idmode = new XoopsFormSelect(_LANG_WPF_SUBT_IDENTITY, 'newuser_idmode', $userObject->getVar('user_idmode', 'e'));
        $_form_idmode->addOption('nickname', $userObject->getVar('user_nickname'));
        $_form_idmode->addOption('login', $userObject->getVar('user_login'));
        $_form_idmode->addOption('firstname', $userObject->getVar('user_firstname'));
        $_form_idmode->addOption('lastname', $userObject->getVar('user_lastname'));
        $_form_idmode->addOption('namefl', $userObject->getVar('user_firstname') . ' ' . $userObject->getVar('user_lastname'));
        $_form_idmode->addOption('namelf', $userObject->getVar('user_lastname') . ' ' . $userObject->getVar('user_firstname'));
        $_form->addElement($_form_idmode);
        $_form->addElement(new XoopsFormButton('', 'submit', _LANG_WPF_SUBT_UPDATE, 'submit'));
        $_form->addElement(new XoopsFormHidden('checkuser_id', $GLOBALS['user_ID']));
        $_form->addElement(new XoopsFormHidden('action', 'update'));
        $_form->addElement($GLOBALS['xoopsWPTicket']->getTicketXoopsForm(__LINE__, 600));
        $_formHTML = $_form->render();
        $_wpTpl =& new WordPresTpl('wp-admin');
        $_wpTpl->assign('updated', get_param('updated'));
        $_wpTpl->assign('formHTML', $_formHTML);
        $_wpTpl->assign('blogname', get_settings('blogname'));
        $_wpTpl->assign('siteurl', wp_siteurl());
        $_wpTpl->assign('is_gecko', $GLOBALS['is_gecko']);
        $_wpTpl->assign('is_IE', $GLOBALS['is_winIE'] || $GLOBALS['is_macIE']);
        $_wpTpl->display('profile.html');
        include 'admin-footer.php';
        break;
}
         $linkCategory->setVar('text_before_link', $text_before_link, true);
         $linkCategory->setVar('text_after_link', $text_after_link, true);
         $linkCategory->setVar('text_after_all', $text_after_all, true);
         $linkCategory->setVar('list_limit', $list_limit, true);
         if (!$linkCategoryHandler->insert($linkCategory)) {
             redirect_header(wp_siteurl() . '/wp-admin/' . $this_file, 3, $linkCategoryHandler->getErrors());
         }
     }
     header('Location: ' . $this_file);
     break;
 default:
     $standalone = 0;
     $title = 'Link Categories';
     include_once "./admin-header.php";
     if ($user_level < get_settings('links_minadminlevel')) {
         redirect_header(wp_siteurl() . '/wp-admin/', 5, _LANG_WLC_RIGHT_PROM);
         exit;
     }
     $criteria = new Criteria(1, 1);
     $criteria->setSort('cat_id');
     $linkCats = $linkCategoryHandler->getObjects($criteria);
     $linkCat_rows = array();
     $style = "";
     foreach ($linkCats as $linkCat) {
         $style = 'class="odd"' == $style ? 'class="even"' : 'class="odd"';
         $row = $linkCat->getVarArray();
         $row['style'] = $style;
         if ($row['list_limit'] == -1) {
             $row['list_limit'] = 'none';
         }
         $linkCat_rows[] = $row;
<?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 list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children = FALSE, $child_of = 0, $categoryObjects = null, $recurse = 0, $feed = '', $feed_image = '', $exclude = '', $hierarchical = FALSE, $echo = true)
    {
        $list_cats = '';
        // Optiondates now works
        if ('' == $file) {
            $file = wp_siteurl() . '/index.php';
        }
        $excludeCriteria = null;
        if (!empty($exclude)) {
            $excats = preg_split('/[\\s,]+/', $exclude);
            if (count($excats)) {
                $excludeCriteria = new CriteriaCompo();
                foreach ($excats as $excat) {
                    $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
                    $excludeCriteria->add(new Criteria('cat_ID', $excat, '!='));
                    $catc = trim(get_category_children($excat, '', ' '));
                    $catc_array = explode(' ', $catc);
                    for ($i = 0; $i < count($catc_array); $i++) {
                        $excludeCriteria->add(new Criteria('category_id', intval($catc_array[$i]), '!='));
                    }
                }
            }
        }
        $categoryHandler =& wp_handler('Category');
        if (!$categoryObjects) {
            $criteria =& new CriteriaCompo(new Criteria('cat_ID', 0, '>'));
            if ($excludeCriteria) {
                $criteria->add($excludeCriteria);
            }
            $criteria->setSort('cat_' . $sort_column);
            $criteria->setOrder($sort_order);
            $categoryObjects =& $categoryHandler->getObjects($criteria, false, 'cat_ID, cat_name, category_nicename, category_description cat_description, category_parent');
        }
        if (empty($GLOBALS['category_posts']) || !count($GLOBALS['category_posts'])) {
            $criteria =& new CriteriaCompo('post_status', 'publish');
            if ($excludeCriteria) {
                $criteria->add($excludeCriteria);
            }
            $criteria->setGroupBy('category_id');
            $joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'cat_ID', 'category_id', 'INNER');
            $joinCriteria->cascade(new XoopsJoinCriteria(wp_table('posts'), 'post_id', 'ID', 'INNER'));
            $categoryPostsObjects =& $categoryHandler->getObjects($criteria, false, 'cat_ID, COUNT(' . wp_table('post2cat') . '.post_id) AS cat_count', false, $joinCriteria);
            if ($categoryPostsObjects) {
                foreach ($categoryPostsObjects as $categoryObject) {
                    if (intval($hide_empty) != 1 || $categoryObject->getExtraVar('cat_count') > 0) {
                        $GLOBALS['category_posts'][$categoryObject->getVar('cat_ID')] = $categoryObject->getExtraVar('cat_count');
                    }
                }
            }
        }
        if (intval($optiondates) == 1) {
            $criteria =& new CriteriaCompo('post_status', 'publish');
            if ($excludeCriteria) {
                $criteria->add($excludeCriteria);
            }
            $criteria->setGroupBy('category_id');
            $joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'cat_ID', 'category_id', 'INNER');
            $joinCriteria->cascade(new XoopsJoinCriteria(wp_table('posts'), 'post_id', 'ID', 'INNER'));
            $categoryDateObjects =& $categoryHandler->getObjects($criteria, false, 'cat_ID, DAYOFMONTH(MAX(post_date)) AS lastday,
		                                                     MONTH(MAX(post_date)) AS lastmonth', false, $joinCriteria);
            foreach ($categoryDateObjects as $categoryObject) {
                $category_lastday["" . $categoryObject->getVar('cat_ID')] = $categoryObject->getExtraVar('lastday');
                $category_lastmonth["" . $categoryObject->getVar('cat_ID')] = $categoryObject->getExtraVar('lastmonth');
            }
        }
        if (intval($optionall) == 1 && !$child_of && $categoryObjects) {
            $all = apply_filters('list_cats', $all);
            $link = "<a href=\"" . $file . '?cat=all">' . $all . "</a>";
            if ($list) {
                $list_cats .= "\n\t<li>{$link}</li>";
            } else {
                $list_cats .= "\t{$link}<br />\n";
            }
        }
        $num_found = 0;
        $thelist = "";
        foreach ($categoryObjects as $categoryObject) {
            $category = $categoryObject->exportWpObject();
            $child_list = '';
            if ((!$hierarchical || $category->category_parent == $child_of) && ($children || $category->category_parent == 0)) {
                if ($hierarchical && $children) {
                    $child_list = list_cats($optionall, $all, $sort_column, $sort_order, $file, $list, $optiondates, $optioncount, $hide_empty, $use_desc_for_title, $hierarchical, $category->cat_ID, $categoryObjects, 1, $feed, $feed_image, $exclude, $hierarchical);
                }
                if (intval($hide_empty) == 0 || isset($GLOBALS['category_posts']["{$category->cat_ID}"]) || $child_list) {
                    $num_found++;
                    $link = '<a href="' . get_category_link(0, $category->cat_ID, $category->category_nicename) . '" ';
                    if ($use_desc_for_title == 0 || empty($category->cat_description)) {
                        $link .= 'title="' . sprintf("View all posts filed under %s", htmlspecialchars($category->cat_name)) . '"';
                    } else {
                        $link .= 'title="' . htmlspecialchars(strip_tags($category->cat_description)) . '"';
                    }
                    $link .= '>';
                    $link .= apply_filters('list_cats', $category->cat_name) . '</a>';
                    if (!empty($feed_image) || !empty($feed)) {
                        $link .= ' ';
                        if (empty($feed_image)) {
                            $link .= '(';
                        }
                        $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
                        if (!empty($feed)) {
                            $title = ' title="' . $feed . '"';
                            $alt = ' alt="' . $feed . '"';
                            $name = $feed;
                            $link .= $title;
                        }
                        $link .= '>';
                        if (!empty($feed_image)) {
                            $link .= "<img src=\"{$feed_image}\" border=\"0\"{$alt}{$title}" . ' />';
                        } else {
                            $link .= $name;
                        }
                        $link .= '</a>';
                        if (empty($feed_image)) {
                            $link .= ')';
                        }
                    }
                    if (intval($optioncount) == 1) {
                        $link .= ' (' . intval($GLOBALS['category_posts']["{$category->cat_ID}"]) . ')';
                    }
                    if (intval($optiondates) == 1) {
                        $link .= ' ' . $category_lastday["{$category->cat_ID}"] . '/' . $category_lastmonth["{$category->cat_ID}"];
                    }
                    if ($list) {
                        $thelist .= "\t<li>{$link}\n";
                    } else {
                        $thelist .= "\t{$link}<br />\n";
                    }
                    if ($hierarchical && $children) {
                        $thelist .= $child_list;
                    }
                    if ($list) {
                        $thelist .= "</li>\n";
                    }
                }
            }
        }
        if (!$num_found && !$child_of) {
            if ($list) {
                $before = '<li>';
                $after = '</li>';
            }
            return _echo($before . "No categories" . $after . "\n", $echo);
        }
        if ($list && $child_of && $num_found && $recurse) {
            $pre = "\t\t<ul class='children'>";
            $post = "\t\t</ul>\n";
        } else {
            $pre = $post = '';
        }
        $thelist = $pre . $thelist . $post;
        if ($recurse) {
            return $thelist;
        }
        $list_cats .= apply_filters('list_cats', $thelist);
        return _echo($list_cats, $echo);
    }
// accessing a single global $all_settings var
if (get_xoops_option(wp_mod(), 'wp_use_xoops_smilies')) {
    $GLOBALS['smilies_directory'] = XOOPS_URL . "/uploads";
} else {
    $GLOBALS['smilies_directory'] = get_settings('smilies_directory');
}
//WordPressプラグイン互換性確保用
$GLOBALS['siteurl'] = wp_siteurl();
update_option('siteurl', $GLOBALS['siteurl'], true);
$GLOBALS['querystring_start'] = '?';
$GLOBALS['querystring_equal'] = '=';
$GLOBALS['querystring_separator'] = '&amp;';
$GLOBALS['dateformat'] = stripslashes(get_settings('date_format'));
$GLOBALS['timeformat'] = stripslashes(get_settings('time_format'));
// Used to guarantee unique cookies
$GLOBALS['cookiehash'] = md5(wp_siteurl());
require wp_base() . '/wp-includes/vars.php';
require wp_base() . '/wp-includes/wp-filter-setup.php';
if (empty($GLOBALS['wp_inblock']) || $GLOBALS['wp_inblock'] != 1) {
    if (!defined('XOOPS_PULUGIN' . wp_id())) {
        define('XOOPS_PULUGIN' . wp_id(), 1);
        if (get_settings('active_plugins')) {
            $check_plugins = explode("\n", get_settings('active_plugins'));
            foreach ($check_plugins as $check_plugin) {
                if (file_exists(wp_base() . '/wp-content/plugins/' . $check_plugin)) {
                    if (!defined(md5('WP_PLUGIN_' . strtoupper($check_plugin) . '_INCLUDED'))) {
                        define(md5('WP_PLUGIN_' . strtoupper($check_plugin) . '_INCLUDED'), 1);
                        require_once wp_base() . '/wp-content/plugins/' . $check_plugin;
                    } else {
                        // It is very tricky!!
                        if (!defined(md5('WP_PLUGIN_' . strtoupper($check_plugin) . wp_base() . '_DEFINED'))) {
    function show_bookmarklet_link()
    {
        ?>
<div class="wrap">
	<h2>WordPress bookmarklet</h2>
	<p><?php 
        echo _LANG_P_WP_BOOKMARKLET;
        ?>
</p>
	<p>
<?php 
        $bookmarklet_height = get_settings('use_trackback') ? 540 : 480;
        $bookmarklet_tbpb = get_settings('use_trackback') ? '&amp;trackback=1' : '';
        $bookmarklet_tbpb .= get_settings('use_pingback') ? '&amp;pingback=1' : '';
        if ($GLOBALS['is_NS4'] || $GLOBALS['is_gecko']) {
            ?>
		<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}void(window.open('<?php 
            echo wp_siteurl();
            ?>
/wp-admin/bookmarklet.php?text='+escape(Q)+'<?php 
            echo $bookmarklet_tbpb;
            ?>
&amp;popupurl='+escape(location.href)+'&amp;popuptitle='+escape(document.title),'WordPress bookmarklet','scrollbars=yes,width=600,height=<?php 
            echo $bookmarklet_height;
            ?>
,left=100,top=150,status=yes'));">Press It - <?php 
            echo get_settings('blogname');
            ?>
</a>
<?php 
        } else {
            if ($GLOBALS['is_winIE']) {
                if ($GLOBALS['wp_use_spaw']) {
                    $range_text = "htmlText";
                } else {
                    $range_text = "text";
                }
                ?>
		<a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().<?php 
                echo $range_text;
                ?>
;void(btw=window.open('<?php 
                echo wp_siteurl();
                ?>
/wp-admin/bookmarklet.php?text='+escape(Q)+'<?php 
                echo $bookmarklet_tbpb;
                ?>
&amp;popupurl='+escape(location.href)+'&amp;popuptitle='+escape(document.title),'bookmarklet','scrollbars=yes,width=600,height=<?php 
                echo $bookmarklet_height;
                ?>
,left=100,top=50,status=yes'));btw.focus();">Press it - <?php 
                echo get_settings('blogname');
                ?>
</a>
		<script type="text/javascript" language="JavaScript">
		<!--
		function oneclickbookmarklet(blah) {
			window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=680, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=120, left=120, screenY=120, top=120");
		}
		// -->
		</script>
		<br /><br />One-click bookmarklet:<br />
		<a href="javascript:oneclickbookmarklet(0);">click here</a>
<?php 
            } else {
                if ($GLOBALS['is_opera']) {
                    ?>
		<a href="javascript:void(window.open('<?php 
                    echo wp_siteurl();
                    ?>
/wp-admin/bookmarklet.php?popupurl='+escape(location.href)+'&amp;popuptitle='+escape(document.title)+'<?php 
                    echo $bookmarklet_tbpb;
                    ?>
','bookmarklet','scrollbars=yes,width=600,height=<?php 
                    echo $bookmarklet_height;
                    ?>
,left=100,top=150,status=yes'));">Press it - <?php 
                    echo get_settings('blogname');
                    ?>
</a> 
<?php 
                } else {
                    if ($GLOBALS['is_macIE']) {
                        ?>
		<a href="javascript:Q='';if(top.frames.length==0);void(btw=window.open('<?php 
                        echo wp_siteurl();
                        ?>
/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&amp;popupurl='+escape(location.href)+'&amp;popuptitle='+escape(document.title)+'<?php 
                        echo $bookmarklet_tbpb;
                        ?>
','bookmarklet','scrollbars=yes,width=600,height=<?php 
                        echo $bookmarklet_height;
                        ?>
,left=100,top=150,status=yes'));btw.focus();">Press it - <?php 
                        echo get_settings('blogname');
                        ?>
</a>
<?php 
                    }
                }
            }
        }
        ?>
	</p>
</div>
<?php 
    }
 function _b_wp_recent_posts_show($options, $wp_num = "")
 {
     $no_posts = empty($options[0]) ? 10 : $options[0];
     $cat_date = empty($options[1]) ? 0 : $options[1];
     $show_rss_icon = empty($options[2]) ? 0 : $options[2];
     $show_rdf_icon = empty($options[3]) ? 0 : $options[3];
     $show_rss2_icon = empty($options[4]) ? 0 : $options[4];
     $show_atom_icon = empty($options[5]) ? 0 : $options[5];
     $rss_num = empty($options[6]) ? "" : $options[6];
     $category = intval(empty($options[7]) ? "all" : $options[7]);
     $new_flg = empty($options[8]) ? 0 : $options[8];
     $tpl_file = empty($options[9]) ? 'wp_recent_posts.html' : $options[9];
     $new1_span = 1 * 60 * 60 * 24;
     $new2_span = 7 * 60 * 60 * 24;
     if (empty($category) || $category == 'all' || $category == '0') {
         $whichcat = '';
         $join = '';
         $cat_param = '';
     } else {
         $join = ' LEFT JOIN ' . wp_table('post2cat') . ' ON (' . wp_table('posts') . '.ID = ' . wp_table('post2cat') . '.post_id) ';
         $whichcat = ' AND (category_id = ' . $category . ')';
         $cat_param = 'cat=' . $category;
     }
     $now = current_time('mysql');
     $request = 'SELECT * FROM ' . wp_table('posts') . $join . ' WHERE post_status = \'publish\'';
     $request .= ' AND post_date <= \'' . $now . '\'' . $whichcat;
     $request .= ' ORDER BY post_date DESC LIMIT 0, ' . $no_posts;
     $lposts = $GLOBALS['wpdb']->get_results($request);
     $date = "";
     $pdate = "";
     $block['style'] = block_style_get(false);
     $block['divid'] = 'wpRecentPost' . $wp_num . '_' . $category;
     $block['cat_date'] = $cat_date;
     $block['records'] = array();
     if ($lposts) {
         foreach ($lposts as $lpost) {
             if ($cat_date) {
                 $date = mysql2date('Y-n-j', $lpost->post_date);
                 if ($date != $pdate) {
                     $_record['date'] = $date;
                     $_record['pdate'] = $pdate;
                     $pdate = $date;
                 } else {
                     $_record['date'] = '';
                 }
             }
             $_record['new'] = 0;
             $_record['newstr'] = '';
             if ($new_flg) {
                 $m = $lpost->post_date;
                 $elapse = current_time('timestamp') - mktime(substr($m, 11, 2), substr($m, 14, 2), substr($m, 17, 2), substr($m, 5, 2), substr($m, 8, 2), substr($m, 0, 4));
                 if ($elapse < $new1_span) {
                     $_record['new'] = 1;
                     $_record['newstr'] = ' <span class="new1">New!</span>';
                 } else {
                     if ($elapse < $new2_span) {
                         $_record['new'] = 2;
                         $_record['newstr'] = ' <span class="new2">New</span>';
                     } else {
                         $_record['new'] = 0;
                         $_record['newstr'] = '';
                     }
                 }
             }
             $_record['post_title'] = htmlspecialchars($lpost->post_title);
             $_record['post_author'] = htmlspecialchars(get_author_name($lpost->post_author));
             if (trim($_record['post_title']) == '') {
                 $_record['post_title'] = _WP_POST_NOTITLE;
             }
             $_record['permalink'] = get_permalink($lpost->ID);
             $block['records'][] = $_record;
         }
     }
     $feed_param = $rss_num ? "?num=" . $rss_num : "";
     $block['feed_icons'] = array();
     if (empty($category) || $category == 'all' || $category == '0') {
         if ($show_rss_icon) {
             $block['feed_icons'][] = array('url' => get_bloginfo('rss_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss.gif', 'alt' => 'rss');
         }
         if ($show_rdf_icon) {
             $block['feed_icons'][] = array('url' => get_bloginfo('rdf_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rdf.gif', 'alt' => 'rdf');
         }
         if ($show_rss2_icon) {
             $block['feed_icons'][] = array('url' => get_bloginfo('rss2_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss2.gif', 'alt' => 'rss2');
         }
         if ($show_atom_icon) {
             $block['feed_icons'][] = array('url' => get_bloginfo('atom_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/atom.gif', 'alt' => 'atom');
         }
     } else {
         if ($show_rss_icon) {
             $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rss') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss.gif', 'alt' => 'rss');
         }
         if ($show_rdf_icon) {
             $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rdf') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rdf.gif', 'alt' => 'rdf');
         }
         if ($show_rss2_icon) {
             $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rss2') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss2.gif', 'alt' => 'rss2');
         }
         if ($show_atom_icon) {
             $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'atom') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/atom.gif', 'alt' => 'atom');
         }
     }
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     if (!$_wpTpl->tpl_exists($tpl_file)) {
         $tpl_file = 'wp_recent_posts.html';
     }
     $block['content'] = $_wpTpl->fetch($tpl_file);
     return $block;
 }
 function get_custom_url($filename)
 {
     if (file_exists(wp_base() . '/themes/' . $GLOBALS['xoopsConfig']['theme_set'] . '/' . $filename)) {
         $themes = $GLOBALS['xoopsConfig']['theme_set'];
     } else {
         $themes = "default";
     }
     return wp_siteurl() . '/themes/' . $themes . '/' . $filename;
 }
 function previous_posts($echo = true)
 {
     // original by cfactor at cooltux.org
     if (empty($GLOBALS['p']) && get_settings('what_to_show') == 'paged') {
         $qstr = $_SERVER['QUERY_STRING'];
         if (!empty($qstr)) {
             $qstr = preg_replace("/&paged=\\d{0,}/", "", $qstr);
             $qstr = preg_replace("/paged=\\d{0,}/", "", $qstr);
         } elseif (stristr($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])) {
             if ('' != ($qstr = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['REQUEST_URI']))) {
                 $qstr = preg_replace("/^\\//", "", $qstr);
                 $qstr = preg_replace("/paged\\/\\d{0,}\\//", "", $qstr);
                 $qstr = preg_replace("/paged\\/\\d{0,}/", "", $qstr);
                 $qstr = preg_replace("/\\/\$/", "", $qstr);
             }
         }
         $nextpage = intval($GLOBALS['paged']) - 1;
         if ($nextpage < 1) {
             $nextpage = 1;
         }
         return _echo(wp_siteurl() . '/' . $GLOBALS['pagenow'] . '?' . ($qstr == '' ? '' : $qstr . '&amp;') . 'paged=' . $nextpage, $echo);
     }
     return _echo('', $echo);
 }
    ?>
<ul id="adminmenu2">
<?php 
    foreach ($submenu["{$parent_file}"] as $item) {
        if ($user_level < $item[1]) {
            continue;
        }
        if ($parent_file != 'options.php' || !preg_match('/^options.php/', $item[2])) {
            if (substr($self, -10) == substr($item[2], -10) || isset($plugin_page) && $plugin_page == $item[2]) {
                $class = ' class="current"';
            } else {
                $class = '';
            }
        } else {
            if (isset($_GET['option_group_id']) && $item[2] == 'options.php?option_group_id=' . $_GET['option_group_id']) {
                $class = ' class="current"';
            } else {
                $class = '';
            }
        }
        if (file_exists(wp_base() . "/wp-content/plugins/{$item[2]}")) {
            echo "\n\t<li><a href='" . wp_siteurl() . "/wp-admin/admin.php?page={$item[2]}'{$class}>{$item[0]}</a></li>";
        } else {
            echo "\n\t<li><a href='" . wp_siteurl() . "/wp-admin/{$item[2]}'{$class}>{$item[0]}</a></li>";
        }
    }
    ?>

</ul>
<?php 
}
 $_use_session = get_param('use_session');
 if (!is_email($_email)) {
     $_email = '';
 }
 $_url_struct = parse_url($_url);
 if (!$_url_struct['path']) {
     $_url = '';
 } elseif (!isset($_url_struct['scheme'])) {
     $_url = 'http://' . $_url;
 } elseif (!preg_match('/^http[s]?$/', $_url_struct['scheme'])) {
     $_url = '';
 }
 $_location = !$_redirect_to ? $_SERVER['HTTP_REFERER'] : $_redirect_to;
 $_url_struct = parse_url($_location);
 if (isset($_url_struct['scheme']) && !preg_match('/^http[s]?$/', $_url_struct['scheme'])) {
     $_location = wp_siteurl();
 }
 $_user_ip = $_SERVER['REMOTE_ADDR'];
 if ($_use_session) {
     if (!$xoopsWPTicket->check()) {
         display_error($_location, 3, $xoopsWPTicket->getErrors());
     }
 }
 $postHandler =& wp_handler('Post');
 $postObject =& $postHandler->get($_comment_post_ID);
 if (!$postObject) {
     display_error($_location, 5, _LANG_P_OOPS_IDCOM);
 }
 if ($postObject->getVar('comment_status') == 'closed') {
     display_error($_location, 5, _LANG_WPCP_SORRY_ITEM);
 }
         $commentObject =& $commentHandler->get(intval($key));
         $postObject =& $postHandler->get($commentObject->getVar('comment_post_ID'));
         if (user_can_edit($postObject->getVar('post_author'))) {
             switch ($value) {
                 case 'later':
                     ++$item_ignored;
                     break;
                 case 'delete':
                     if (!$commentHandler->delete($commentObject)) {
                         redirect_header(wp_siteurl() . '/wp-admin/' . $this_file, 3, $categoryHandler->getErrors());
                     }
                     ++$item_deleted;
                     break;
                 case 'approve':
                     if (!$commentObject->approve()) {
                         redirect_header(wp_siteurl() . '/wp-admin/' . $this_file, 3, $categoryHandler->getErrors());
                     }
                     if (get_settings('comments_notify') == true) {
                         wp_notify_postauthor($key);
                     }
                     ++$item_approved;
                     break;
             }
         }
     }
     header("Location: {$this_file}?ignored={$item_ignored}&deleted={$item_deleted}&approved={$item_approved}");
     exit;
     break;
 default:
     //Check User_Level
     user_level_check();
	<!-- /comment -->
<?php 
                }
                ?>
	</ol>
<?php 
            }
            if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 0) {
                ?>
<h3><?php 
                echo _LANG_E_TITLE_LEAVECOM;
                ?>
</h3>
	<!-- form to add a comment -->
	<form action="<?php 
                echo wp_siteurl() . '/wp-comments-post.php';
                ?>
" method="post">
		<input type="hidden" name="comment_post_ID" value="<?php 
                echo $wp_post_id;
                ?>
" />
		<input type="hidden" name="redirect_to" value="<?php 
                echo $_SERVER["REQUEST_URI"];
                ?>
" />
		<input type="text" name="author" class="textarea" value="<?php 
                echo $user_nickname;
                ?>
" size="20" tabindex="1" /><br />
		<input type="text" name="email" class="textarea" value="<?php 
<?php

require_once 'admin.php';
$mode = 'sidebar';
$standalone = 1;
$title = "";
require_once 'admin-header.php';
if ($user_level <= 0) {
    redirect_header(wp_siteurl() . '/wp-admin/', 5, _LANG_P_CHEATING_ERROR);
}
init_param('GET', 'action', 'string', '');
require_once XOOPS_ROOT_PATH . '/class/template.php';
$wpTpl =& new XoopsTpl();
$wpTpl->error_reporting = error_reporting();
$wpTpl->assign('action', $action);
$wpTpl->assign('admin_area_charset', $admin_area_charset);
if ($action != 'done') {
    $category_select = categories_nested_select(array(get_settings('default_post_category')));
    $ticket = $xoopsWPTicket->getTicketHtml(__LINE__, 10800);
    $wpTpl->assign('user_ID', $user_ID);
    $wpTpl->assign('category_select', $category_select);
    $wpTpl->assign('ticket', $ticket);
}
$wpTpl->template_dir = wp_base() . '/wp-admin/templates/';
$wpTpl->display('sidebar.html');
require_once 'admin-footer.php';
 function trackback_url($echo = true)
 {
     $trackback_filename = get_settings('trackback_filename') ? get_settings('trackback_filename') : 'wp-trackback.php';
     $tb_url = wp_siteurl() . '/' . $trackback_filename . '/' . $GLOBALS['wp_post_id'];
     if ('' != get_settings('permalink_structure')) {
         $tb_url = trailingslashit(get_permalink()) . 'trackback/';
     }
     return _echo($tb_url, $echo);
 }