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_calendar_show($option, $wp_num = "")
 {
     if (current_wp()) {
         if (!empty($_SERVER['PATH_INFO'])) {
             permlink_to_param();
         }
         init_param('GET', 'p', 'integer', '');
         init_param('GET', 'm', 'integer', '');
         init_param('GET', 'w', 'integer', '');
         init_param('GET', 'monthnum', 'integer', '');
         init_param('GET', 'year', 'integer', '');
         if (test_param('p') && !(test_param('m') || test_param('monthnum') || test_param('w'))) {
             $postHandler =& wp_handler('Post');
             $postObject =& $postHandler->get(get_param('p'));
             if ($postObject) {
                 $GLOBALS['m'] = mysql2date('Ym', $postObject->getVar('post_date'));
             }
         }
     }
     $block['wp_num'] = $wp_num;
     $block['divid'] = 'wpCalendar' . $wp_num;
     $block['style'] = block_style_get(false);
     $block['calendar'] = get_calendar(1, false);
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     $block['content'] = $_wpTpl->fetch('wp_calendar.html');
     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';
     global $wpdb, $siteurl, $wp_id, $wp_inblock, $user_cache, $cache_categories, $category_name, $cat, $wp_mod, $wp_base;
     $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;
     }
     if (current_wp()) {
         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 ($category_name[count($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']);
             $cat = $categoryObject->getVar('cat_ID');
         }
     }
     if ($block_style == 0) {
         // Simple Listing
         ob_start();
         block_style_get($wp_num);
         echo "<ul class='wpBlockList'>\n";
         wp_list_cats("sort_column={$sorting_key}&sorting_order={$sorting_order}&optioncount={$with_count}");
         echo "</ul>\n";
         $block['content'] = ob_get_contents();
         ob_end_clean();
     } else {
         // Dropdown Listing
         $file = "{$siteurl}/index.php";
         $link = $file . '?cat=';
         ob_start();
         block_style_get($wp_num);
         echo '<form name="listcatform' . $wp_num . '" id="listcatform' . $wp_num . '" action="#">';
         $select_str = '<select name="cat" onchange="window.location = (document.forms.listcatform' . $wp_num . '.cat[document.forms.listcatform' . $wp_num . '.cat.selectedIndex].value);"> ';
         dropdown_cats(1, _WP_LIST_CAT_ALL, $sorting_key, $sorting_order, 0, $with_count, 0, false, 0, 0, true, 0, true, 0);
         echo '</form>';
         $block_str = ob_get_contents();
         ob_end_clean();
         $block['content'] = ereg_replace('\\<select name\\=[^\\>]*\\>', $select_str, $block_str);
     }
     return $block;
 }
 function comments_popup_link($zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $CSSclass = '', $none = 'Comments Off', $echo = true)
 {
     if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 0) {
         if (empty($GLOBALS['comment_count_cache'][wp_id()]["{$GLOBALS['wp_post_id']}"])) {
             $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
             $commentHandler =& wp_handler('Comment');
             $number = $commentHandler->getCount($criteria);
         } else {
             $number = $GLOBALS['comment_count_cache'][wp_id()]["{$GLOBALS['wp_post_id']}"];
         }
     } 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');
         $number = $commentHandler->getCount($criteria);
     }
     $comments_popup_link = "";
     if (0 == $number && 'closed' == $GLOBALS['post']->comment_status && 'closed' == $GLOBALS['post']->ping_status) {
         return _echo($none, $echo);
     } else {
         if (!empty($GLOBALS['post']->post_password)) {
             // if there's a password
             if ($_COOKIE['wp-postpass_' . $GLOBALS['cookiehash']] != $GLOBALS['post']->post_password) {
                 // and it doesn't match the cookie
                 return _echo("Enter your password to view comments", $echo);
             }
         }
         $comments_popup_link .= '<a href="';
         if (!empty($GLOBALS['wpcommentsjavascript'])) {
             $comments_popup_link .= wp_siteurl() . '/' . $GLOBALS['wpcommentspopupfile'] . '?p=' . $GLOBALS['wp_post_id'] . '&amp;c=1';
             $comments_popup_link .= '" onclick="wpopen(this.href); return false"';
         } else {
             // if comments_popup_script() is not in the template, display simple comment link
             $comments_popup_link .= comments_link('', false);
             $comments_popup_link .= '"';
         }
         $comments_popup_link .= ' title="Comment for \'\'' . apply_filters('the_title', $GLOBALS['post']->post_title) . '\'\'"';
         if (!empty($CSSclass)) {
             $comments_popup_link .= ' class="' . $CSSclass . '"';
         }
         $comments_popup_link .= '>';
         $comments_popup_link .= comments_number($zero, $one, $more, $number, false);
         $comments_popup_link .= '</a>';
         return _echo($comments_popup_link, $echo);
     }
 }
 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']);
             $GLOBALS['cat'] = $categoryObject->getVar('cat_ID');
         }
     }
     if ($block_style == 0) {
         // Simple Listing
         ob_start();
         block_style_get($wp_num);
         echo '<ul class="wpBlockList">' . "\n";
         wp_list_cats("hide_empty=0&sort_column={$sorting_key}&sorting_order={$sorting_order}&optioncount={$with_count}");
         echo '</ul>' . "\n";
         $block['content'] = ob_get_contents();
         ob_end_clean();
     } else {
         // Dropdown Listing
         $file = wp_siteurl() . '/index.php';
         $link = $file . '?cat=';
         ob_start();
         block_style_get($wp_num);
         echo '<form name="listcatform' . $wp_num . '" id="listcatform' . $wp_num . '" action="#">';
         $select_str = '<select name="cat" onchange="window.location = (document.forms.listcatform' . $wp_num . '.cat[document.forms.listcatform' . $wp_num . '.cat.selectedIndex].value);"> ';
         dropdown_cats(1, _WP_LIST_CAT_ALL, $sorting_key, $sorting_order, 0, $with_count, 0, false, 0, 0, true, 0, true, 0);
         echo '</form>';
         $block_str = ob_get_contents();
         ob_end_clean();
         $block['content'] = ereg_replace('\\<select name\\=[^\\>]*\\>', $select_str, $block_str);
     }
     return $block;
 }
 function _b_wp_recent_posts_edit($options, $wp_num = "")
 {
     $categoryHandler =& wp_handler('Category');
     $optFormCatOptions = array("0" => _WP_LIST_CAT_ALL) + $categoryHandler->getParentOptionArray();
     require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
     $optForm = new XoopsSimpleForm('Block Option Dummy Form', 'optionform', '');
     $optForm->addElement(new XoopsFormText('Number of Posts in this block:', 'options[0]', 5, 5, $options[0]));
     $optForm->addElement(new XoopsFormRadioYN('Display Posted Date:', 'options[1]', $options[1]));
     $optForm->addElement(new XoopsFormRadioYN('Display RSS Icon:', 'options[2]', $options[2]));
     $optForm->addElement(new XoopsFormRadioYN('Display RDF Icon:', 'options[3]', $options[3]));
     $optForm->addElement(new XoopsFormRadioYN('Display RSS2 Icon:', 'options[4]', $options[4]));
     $optForm->addElement(new XoopsFormRadioYN('Display ATOM Icon:', 'options[5]', $options[5]));
     $optForm->addElement(new XoopsFormText('Number of Posts in Meta Feed(RSS,RDF,ATOM):', 'options[6]', 5, 5, $options[6]));
     $optFormCat = new XoopsFormSelect('Listing only in a following categoty:', 'options[7]', $options[7]);
     $optFormCat->addOptionArray($optFormCatOptions);
     $optForm->addElement($optFormCat);
     $optForm->addElement(new XoopsFormRadioYN('Display New Flag:', 'options[8]', $options[8]));
     $optForm->addElement(new XoopsFormText('Custom Block Template File<br />(Default: wp_recent_posts.html):', 'options[9]', 25, 50, $options[9]));
     $_wpTpl =& new WordPresTpl('theme');
     $optForm->assign($_wpTpl);
     return $_wpTpl->fetch('wp_block_edit.html');
 }
 function _b_wp_calendar_show($option, $wp_num = "")
 {
     if (current_wp()) {
         if (!empty($_SERVER['PATH_INFO'])) {
             permlink_to_param();
         }
         init_param('GET', 'p', 'integer', '');
         init_param('GET', 'm', 'integer', '');
         init_param('GET', 'w', 'integer', '');
         init_param('GET', 'monthnum', 'integer', '');
         init_param('GET', 'year', 'integer', '');
         if (test_param('p') && !(test_param('m') || test_param('monthnum') || test_param('w'))) {
             $postHandler =& wp_handler('Post');
             $postObject =& $postHandler->get(get_param('p'));
             $GLOBALS['m'] = mysql2date('Ym', $postObject->getVar('post_date'));
         }
     }
     ob_start();
     block_style_get();
     get_calendar(1);
     $block['content'] = ob_get_contents();
     ob_end_clean();
     return $block;
 }
 function _b_wp_categories_list($sort_column = 'ID', $sort_order = 'asc', $optioncount = 0, $child_of = 0, $categoryObjects = null, $arraytree = true, $padchar = '&#8211;', $level = 0, $current = 0)
 {
     $categoryHandler =& wp_handler('Category');
     if (!$categoryObjects) {
         $criteria =& new CriteriaCompo(new Criteria('cat_ID', 0, '>'));
         $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');
         $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 ($categoryObject->getExtraVar('cat_count') > 0) {
                     $GLOBALS['category_posts'][$categoryObject->getVar('cat_ID')] = $categoryObject->getExtraVar('cat_count');
                 }
             }
         }
     }
     $pad = str_repeat($padchar, $level) . " ";
     $block['records'] = array();
     foreach ($categoryObjects as $categoryObject) {
         $_record = array();
         $category = $categoryObject->exportWpObject();
         if ($category->category_parent == $child_of) {
             $child_block =& _b_wp_categories_list($sort_column, $sort_order, $optioncount, $category->cat_ID, $categoryObjects, $arraytree, $padchar, $level + 1, $current);
             $num_children = count($child_block['records']);
             if ($num_children && $arraytree) {
                 $_record['children'] = $child_block['records'];
             }
             if (isset($GLOBALS['category_posts']["{$category->cat_ID}"]) || $num_children) {
                 $_record['name'] = apply_filters('list_cats', $category->cat_name);
                 if (!$arraytree) {
                     $_record['name'] = $pad . $_record['name'];
                     if ($category->cat_ID == $current) {
                         $_record['select'] = 'selected="selected"';
                     } else {
                         $_record['select'] = '';
                     }
                 }
                 $_record['url'] = get_category_link(0, $category->cat_ID, $category->category_nicename);
                 if (empty($category->cat_description)) {
                     $_record['title'] = sprintf("View all posts filed under %s", htmlspecialchars($category->cat_name));
                 } else {
                     $_record['title'] = htmlspecialchars(strip_tags($category->cat_description));
                 }
                 if (intval($optioncount)) {
                     $_record['count'] = ' (' . intval($GLOBALS['category_posts']["{$category->cat_ID}"]) . ')';
                 }
                 $block['records'][] = $_record;
             }
             if ($num_children && !$arraytree) {
                 foreach ($child_block['records'] as $_record) {
                     $block['records'][] = $_record;
                 }
             }
         }
     }
     //		if (!$level) var_dump($block);
     return $block;
 }
예제 #9
0
function wp_delete_post($post_ID = 0)
{
    $postHandler =& wp_handler('Post');
    $postObject =& $postHandler->get($post_ID);
    $result = $postHandler->delete($postObject, true);
    return $result;
}
 function posts_nav_link($sep = ' :: ', $prelabel = '<< Previous Page', $nxtlabel = 'Next Page >>', $echo = true)
 {
     if (empty($GLOBALS['p']) && get_settings('what_to_show') == 'paged') {
         $postHandler =& wp_handler('Post');
         $GLOBALS['current_posts_criteria']->setGroupBy('');
         $GLOBALS['current_posts_criteria']->setStart(0);
         $GLOBALS['current_posts_criteria']->setLimit(0);
         $postObjects =& $postHandler->getObjects($GLOBALS['current_posts_criteria'], false, 'count(DISTINCT ID) numposts', '', $GLOBALS['current_posts_join']);
         $numposts = $postObjects[0]->getExtraVar('numposts');
         $max_page = ceil($numposts / $GLOBALS['posts_per_page']);
         if ($max_page > 1) {
             return _echo(previous_posts_link($prelabel, false) . preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $sep) . next_posts_link($nxtlabel, $max_page, false), $echo);
         }
     }
     return _echo('', $echo);
 }
예제 #11
0
function wp_mail_receive()
{
    global $img_target;
    require_once wp_base() . '/wp-includes/class-pop3.php';
    timer_start();
    $use_cache = 1;
    $time_difference = get_settings('time_difference');
    error_reporting(2037);
    $GLOBALS['wp_pop3'] = new POP3();
    if (!$GLOBALS['wp_pop3']->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) {
        echo "Ooops {$GLOBALS['wp_pop3']}->ERROR <br />\n";
        return;
    }
    $mail_count = $GLOBALS['wp_pop3']->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));
    if ($mail_count == false) {
        if (!$GLOBALS['wp_pop3']->FP) {
            echo "Oooops Login Failed: {$wp_pop3->ERROR}<br />\n";
        } else {
            echo "No Message<br />\n";
            $GLOBALS['wp_pop3']->quit();
        }
        return;
    }
    // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT!
    register_shutdown_function('wp_mail_quit');
    for ($mail_num = 1; $mail_num <= $mail_count; $mail_num++) {
        $MsgOne = $GLOBALS['wp_pop3']->get($mail_num);
        if (!$MsgOne || gettype($MsgOne) != 'array') {
            echo "oops, {$GLOBALS['wp_pop3']}->ERROR<br />\n";
            $GLOBALS['wp_pop3']->quit();
            return;
        }
        $content = '';
        $content_type = '';
        $boundary = '';
        $alt_boundary = '';
        $emb_boundary = '';
        $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
        $mailMsg = '';
        while (list($lineNum, $line) = each($MsgOne)) {
            $mailMsg .= $line;
        }
        $mailParts = parse_msg($mailMsg);
        if (!empty($mailParts['header']['date'])) {
            $ddate = trim($mailParts['header']['date'][0]);
            if (strpos($ddate, ',')) {
                $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
            }
            $ddate_U = strtotime($ddate) + $time_difference * 3600;
            $post_date = date('Y-m-d H:i:s', $ddate_U);
        }
        if (!empty($mailParts['header']['subject'])) {
            $subject = trim($mailParts['header']['subject'][0]);
            if (function_exists('mb_decode_mimeheader')) {
                $subject1 = mb_decode_mimeheader($subject);
                if ($subject1 != $subject) {
                    $sub_charset = mb_internal_encoding();
                } else {
                    $sub_charset = "auto";
                }
                $subject = $subject1;
            }
            if (get_settings('use_phoneemail')) {
                $subject = explode(get_settings('phoneemail_separator'), $subject);
                $subject = trim($subject[0]);
            }
        }
        if (!ereg(get_settings('subjectprefix'), $subject)) {
            continue;
        }
        $charset = "";
        $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches);
        if ($ncharset) {
            $charset = $matches[1];
        }
        $ddate_today = time() + $time_difference * 3600;
        $ddate_difference_days = ($ddate_today - $ddate_U) / 86400;
        if ($ddate_difference_days > 14) {
            echo "Too old<br />\n";
            continue;
        }
        if (preg_match('/' . get_settings('subjectprefix') . '/', $subject)) {
            $userpassstring = '';
            echo "<div style=\"border: 1px dashed #999; padding: 10px; margin: 10px;\">\n";
            echo "<p><b>{$mail_num}</b></p><p><b>Subject: </b>{$subject}</p>\n";
            $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject));
            $attaches = array();
            if ($mailParts['type'] == 'multipart') {
                if ($mailParts['subtype'] == 'mixed') {
                    for ($i = 1; $i < count($mailParts['body']); $i++) {
                        $attaches[] = array('type' => 'mix', 'body' => $mailParts['body'][$i]);
                    }
                    if (!is_array($mailParts['body'][0]['body'])) {
                        $content = $mailParts['body'][0]['body'];
                        $charset = $mailParts['body'][0]['charset'];
                        $encoding = $mailParts['body'][0]['encodings'];
                        $content = convert_content($content, $charest, $encoding);
                    } else {
                        $mailParts = $mailParts['body'][0];
                    }
                }
                if ($mailParts['type'] == 'multipart' && $mailParts['subtype'] == 'related') {
                    if ($mailParts['body'][0]['type'] == 'multipart' && $mailParts['body'][0]['subtype'] == 'alternative') {
                        $content = $mailParts['body'][0]['body'][1]['body'];
                        $charset = $mailParts['body'][0]['body'][1]['charset'];
                        $encoding = $mailParts['body'][0]['body'][1]['encodings'];
                        $content = convert_content($content, $charest, $encoding);
                    } else {
                        $content = $mailParts['body'][0]['body'];
                        $charset = $mailParts['body'][0]['charset'];
                        $encoding = $mailParts['body'][0]['encodings'];
                        $content = convert_content($content, $charest, $encoding);
                    }
                    $content = preg_replace('/(\\<.*?\\>)/es', 'str_replace(array("\\n","\\r"), array(" ", " "), "\\1")', $content);
                    $content = preg_replace('/\\<head\\>.*\\<\\/head\\>/is', '', $content);
                    $content = preg_replace('/(\\<body\\s*[^\\>]*\\>)\\s*\\<br\\s*\\/*\\>\\s*/is', '\\1', $content);
                    $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td><category><title>');
                    $content = preg_replace('!(</div>|</p>)([^\\r\\n])!i', "\\1\n\\2", $content);
                    for ($i = 1; $i < count($mailParts['body']); $i++) {
                        $attaches[] = array('type' => 'relate', 'body' => $mailParts['body'][$i], 'id' => preg_replace('/<(.*)>/', '$1', $mailParts['body'][$i]['header']['content-id'][0]));
                    }
                }
                if ($mailParts['type'] == 'multipart' && $mailParts['subtype'] == 'alternative') {
                    if ($mailParts['body'][1]['type'] == 'multipart' && $mailParts['body'][1]['subtype'] == 'related') {
                        $content = $mailParts['body'][1]['body'][0]['body'];
                        $charset = $mailParts['body'][1]['body'][0]['charset'];
                        $encoding = $mailParts['body'][1]['body'][0]['encodings'];
                        $content = convert_content($content, $charest, $encoding);
                        for ($i = 1; $i < count($mailParts['body'][1]['body']); $i++) {
                            $attaches[] = array('type' => 'relate', 'body' => $mailParts['body'][1]['body'][$i], 'id' => preg_replace('/<(.*)>/', '$1', $mailParts['body'][1]['body'][$i]['header']['content-id'][0]));
                        }
                    } else {
                        $content = $mailParts['body'][1]['body'];
                        $charset = $mailParts['body'][1]['charset'];
                        $encoding = $mailParts['body'][1]['encodings'];
                        $content = convert_content($content, $charest, $encoding);
                    }
                    $content = preg_replace('/(\\<[^\\>]*\\>)/es', 'str_replace(array("\\n","\\r"), array(" ", " "), "\\1")', $content);
                    $content = preg_replace('/\\<head\\>.*\\<\\/head\\>/is', '', $content);
                    $content = preg_replace('/(\\<body\\s*[^\\>]*\\>)\\s*\\<br\\s*\\/*\\>\\s*/is', '\\1', $content);
                    $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td><category><title>');
                    $content = preg_replace('!(</div>|</p>)([^\\r\\n])!i', "\\1\n\\2", $content);
                }
            } else {
                $content = $mailParts['body'];
                $charset = $mailParts['charset'];
                $encoding = $mailParts['encodings'];
                $content = convert_content($content, $charest, $encoding);
            }
            $content = trim($content);
            echo "<p><b>Content-type:</b> {$content_type}, <b>boundary:</b> {$boundary}</p>\n";
            echo "<p><b>alt_boundary:</b> {$alt_boundary}, <b>emb_boundary:</b> {$emb_boundary}</p>\n";
            echo "<p><b>charset:</b>{$charset}, <b>BLOG charset:</b>" . $GLOBALS['blog_charset'] . "</p>\n";
            // echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';
            if ($charset == "" || trim(strtoupper($charset)) == "ISO-2022-JP") {
                $charset = "JIS";
            }
            if (trim(strtoupper($charset)) == "SHIFT_JIS") {
                $charset = "SJIS";
            }
            $btpos = strpos($content, get_settings('bodyterminator'));
            if ($btpos) {
                $content = substr($content, 0, $btpos);
            }
            $content = trim($content);
            $blah = explode("\n", preg_replace("/^[\n\r\\s]*/", "", strip_tags($content)));
            $firstline = preg_replace("/[\n\r]/", "", $blah[0]);
            $secondline = $blah[1];
            if (get_settings('use_phoneemail')) {
                echo "<p><b>Use Phone Mail:</b> Yes</p>\n";
                $btpos = strpos($firstline, get_settings('phoneemail_separator'));
                if ($btpos) {
                    $userpassstring = trim(substr($firstline, 0, $btpos));
                    $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
                    $btpos = strpos($content, get_settings('phoneemail_separator'));
                    if ($btpos) {
                        $userpassstring = trim(substr($content, 0, $btpos));
                        $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
                    }
                }
                $contentfirstline = $blah[1];
            } else {
                echo "<p><b>Use Phone Mail:</b> No</p>\n";
                $userpassstring = strip_tags($firstline);
                $contentfirstline = '';
            }
            $flat = 999.0;
            $flon = 999.0;
            $secondlineParts = explode(':', strip_tags($secondline));
            if (strncmp($secondlineParts[0], "POS", 3) == 0) {
                echo "Found POS:<br />\n";
                // echo "Second parts is:".$secondlineParts[1];
                // the second line is the postion listing line
                $secLineParts = explode(',', $secondlineParts[1]);
                $flatStr = $secLineParts[0];
                $flonStr = $secLineParts[1];
                // echo "String are ".$flatStr.$flonStr;
                $flat = floatval($secLineParts[0]);
                $flon = floatval($secLineParts[1]);
                // echo "values are ".$flat." and ".$flon;
                // ok remove that position... we should not have it in the final output
                $content = str_replace($secondline, '', $content);
            }
            $blah = explode(':', $userpassstring);
            $user_login = trim($blah[0]);
            $user_pass = $blah[1];
            $content = $contentfirstline . str_replace($firstline, '', $content);
            $content = trim($content);
            // Please uncomment following line, only if you want to check user and password.
            // echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>";
            echo "<p><b>Login:</b> {$user_login}, <b>Pass:</b> *********</p>";
            if (!user_pass_ok($user_login, $user_pass)) {
                echo "<p><b>Error: Wrong Login.</b></p></div>\n";
                continue;
            }
            $userdata = get_userdatabylogin($user_login);
            $user_level = $userdata->user_level;
            $post_author = $userdata->ID;
            if ($user_level > 0) {
                $post_title = xmlrpc_getposttitle($content);
                if ($post_title == '') {
                    $post_title = $subject;
                }
                echo "Subject : " . mb_conv($post_title, $GLOBALS['blog_charset'], $sub_charset) . " <br />\n";
                $post_category = get_settings('default_category');
                if (preg_match('/<category>(.+?)<\\/category>/is', $content, $matchcat)) {
                    $post_category = xmlrpc_getpostcategory($content);
                    $content = xmlrpc_removepostdata($content);
                }
                if (empty($post_category)) {
                    $post_category = get_settings('default_post_category');
                }
                echo "Category : {$post_category} <br />\n";
                $post_category = explode(',', $post_category);
                if (!get_settings('emailtestonly')) {
                    $content = preg_replace('|\\n([^\\n])|', " \$1", trim($content));
                    $content_before = "";
                    $content_after = "";
                    for ($i = 0; $i < count($attaches); $i++) {
                        $create_thumbs = $attaches[$i]['type'] == 'mix' ? 1 : 0;
                        list($file_name, $is_img, $orig_name) = wp_getattach($attaches[$i]['body'], "user-" . trim($post_author), $create_thumbs);
                        if ($file_name) {
                            if ($attaches[$i]['type'] == 'relate') {
                                $content = preg_replace("/cid:" . preg_quote($attaches[$i]['id']) . "/", get_settings('fileupload_url') . '/' . $file_name, $content);
                            } else {
                                if (isset($img_target) && $img_target) {
                                    $img_target = ' target="' . $img_target . '"';
                                } else {
                                    $img_target = '';
                                }
                                if ($is_img) {
                                    if (file_exists(get_settings('fileupload_realpath') . "/thumb-" . $file_name)) {
                                        $content_before .= "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($file_name) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src=\"" . get_settings('fileupload_url') . '/thumb-' . rawurlencode($file_name) . "\" alt=\"" . $orig_name . "\" title=\"" . $orig_name . "\" /></a>";
                                    } else {
                                        $content_before .= "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($file_name) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src=\"" . get_settings('fileupload_url') . '/' . rawurlencode($file_name) . "\" alt=\"" . $orig_name . "\" title=\"" . $orig_name . "\" /></a>";
                                    }
                                } else {
                                    $content_after .= "<a href=\"" . wp_siteurl() . "/wp-download.php?from=" . rawurlencode($file_name) . "&amp;fname=" . urlencode($orig_name) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src=\"" . wp_siteurl() . "/wp-images/file.gif\" alt=\"" . $orig_name . "\" title=\"" . $orig_name . "\" />" . $orig_name . "</a>";
                                }
                            }
                        }
                    }
                    $content = $content_before . $content . "<br clear=\"left\" />" . $content_after;
                    $postHandler =& wp_handler('Post');
                    $postObject =& $postHandler->create();
                    $postObject->setVar('post_content', $content, true);
                    $postObject->setVar('post_title', trim(mb_conv($post_title, $GLOBALS['blog_charset'], $sub_charset)), true);
                    $postObject->setVar('post_date', $post_date, true);
                    $postObject->setVar('post_author', $post_author, true);
                    $postObject->setVar('post_category', $post_category[0], true);
                    $postObject->setVar('post_name', sanitize_title($post_title), true);
                    if ($flat < 500) {
                        $postObject->setVar('post_lat', $flat, true);
                        $postObject->setVar('post_lon', $flon, true);
                    }
                    $postObject->setVar('post_status', get_settings('default_post_status'), true);
                    $postObject->setVar('ping_status', get_settings('default_ping_status'), true);
                    $postObject->setVar('comment_status', get_settings('default_comment_status'), true);
                    if (!$postHandler->insert($postObject, true)) {
                        echo "<b>Error: Insert New Post</b><br />";
                    }
                    $post_ID = $postObject->getVar('ID');
                    echo "Post ID = {$post_ID}<br />\n";
                    $postObject->assignCategories($post_category, true);
                    do_action('publish_post', $post_ID);
                    do_action('publish_phone', $post_ID);
                    if ($flat < 500) {
                        pingGeoUrl($post_ID);
                    }
                    $blog_ID = 1;
                    pingWeblogs($blog_ID);
                    pingback($content, $post_ID);
                }
                echo "\n<p><b>Posted title:</b> {$post_title}<br />\n";
                echo "<b>Posted content:</b><br /><pre>" . $content . "</pre></p>\n";
                if (!$GLOBALS['wp_pop3']->delete($mail_num)) {
                    echo "<p>Oops " . $GLOBALS['wp_pop3']->ERROR . "</p></div>\n";
                    $GLOBALS['wp_pop3']->reset();
                    return;
                } else {
                    echo "<p>Mission complete, message <strong>{$mail_num}</strong> deleted.</p>\n";
                }
            } else {
                echo "<p><strong>Level 0 users can\\'t post.</strong></p>\n";
            }
            echo "</div>\n";
        }
    }
    $GLOBALS['wp_pop3']->quit();
    timer_stop($GLOBALS['wp_mail_debug']);
    return;
}
 function get_calendar($daylength = 1, $echo = true)
 {
     $postHandler =& wp_handler('Post');
     // Quick check. If we have no posts at all, abort!
     if (empty($GLOBALS['posts'])) {
         $criteria =& new Criteria('post_status', 'publish');
         if (!$postHandler->getCount($criteria)) {
             return _echo('', $echo);
         }
     }
     // Let's figure out when we are
     if (!empty($GLOBALS['monthnum']) && !empty($GLOBALS['year'])) {
         $thismonth = '' . intval($GLOBALS['monthnum']);
         $thisyear = '' . intval($GLOBALS['year']);
     } elseif (!empty($GLOBALS['w'])) {
         $thisyear = '' . intval(substr($GLOBALS['m'], 0, 4));
         $wst = 8 - intval(date('w', mktime(0, 0, 0, 1, 1, $thisyear)));
         $d = ($GLOBALS['w'] - 1) * 7 + $wst;
         $thismonth = intval(date('m', mktime(0, 0, 0, 1, $d, $thisyear)));
     } elseif (!empty($GLOBALS['m'])) {
         $calendar = substr($GLOBALS['m'], 0, 6);
         $thisyear = '' . intval(substr($GLOBALS['m'], 0, 4));
         if (strlen($GLOBALS['m']) < 6) {
             $thismonth = '01';
         } else {
             $thismonth = '' . intval(substr($GLOBALS['m'], 4, 2));
         }
     } else {
         $thisyear = intval(date('Y', current_time('timestamp', 0)));
         $thismonth = intval(date('m', current_time('timestamp', 0)));
     }
     $unixmonth = mktime(0, 0, 0, $thismonth, 1, $thisyear);
     // Get the next and previous month and year with at least one post
     $criteria =& new CriteriaCompo(new Criteria('post_date', "{$thisyear}-{$thismonth}-01", '<'));
     $criteria->add(new Criteria('post_status', 'publish'));
     $criteria->setSort('post_date');
     $criteria->setOrder('DESC');
     $criteria->setLimit(1);
     $prevPostObjects =& $postHandler->getObjects($criteria, false, 'post_date');
     $nextyear = date('Y', mktime(0, 0, 0, $thismonth + 1, 1, $thisyear));
     $nextmonth = date('m', mktime(0, 0, 0, $thismonth + 1, 1, $thisyear));
     // this means year of next month.
     $criteria =& new CriteriaCompo(new Criteria('post_date', "{$nextyear}-{$nextmonth}-01", '>='));
     $criteria->add(new Criteria('post_status', 'publish'));
     $criteria->setSort('post_date');
     $criteria->setOrder('ASC');
     $criteria->setLimit(1);
     $nextPostObjects =& $postHandler->getObjects($criteria, false, 'post_date');
     $month_str = format_month(date('Y', $unixmonth), $GLOBALS['month'][zeroise($thismonth, 2)]);
     $get_calendar = "<table id='wp-calendar' summary='wp-calendar'>\n<caption>{$month_str}</caption>\n<thead>\n\t<tr>";
     foreach ($GLOBALS['weekday'] as $wd) {
         if (function_exists('mb_substr')) {
             $get_calendar .= "\n\t\t<th abbr='{$wd}' scope='col' title='{$wd}'>" . mb_substr($wd, 0, $daylength, $GLOBALS['blog_charset']) . '</th>';
         } else {
             $get_calendar .= "\n\t\t<th abbr='{$wd}' scope='col' title='{$wd}'>" . substr($wd, 0, $daylength) . '</th>';
         }
     }
     $get_calendar .= "\n\t</tr>\n</thead>\n<tfoot>\n\t<tr>";
     if ($prevPostObjects) {
         $prev_year = substr($prevPostObjects[0]->getVar('post_date'), 0, 4);
         $prev_month = substr($prevPostObjects[0]->getVar('post_date'), 5, 2);
         if (function_exists('mb_convert_encoding')) {
             $smonth_name = mb_substr($GLOBALS['month'][zeroise($prev_month, 2)], 0, 3, $GLOBALS['blog_charset']);
         } else {
             $smonth_name = substr($GLOBALS['month'][zeroise($prev_month, 2)], 0, 3);
         }
         $month_str = format_month(date('Y', mktime(0, 0, 0, $prev_month, 1, $prev_year)), $GLOBALS['month'][zeroise($prev_month, 2)]);
         $get_calendar .= "\n\t\t" . '<td abbr="' . $GLOBALS['month'][zeroise($prev_month, 2)] . '" colspan="3" id="prev"><a href="' . get_month_link($prev_year, $prev_month) . '" title="View posts for ' . $month_str . '">&laquo; ' . $smonth_name . '</a></td>';
     } else {
         $get_calendar .= "\n\t\t" . '<td colspan="3" id="prev" class="pad">&nbsp;</td>';
     }
     $get_calendar .= "\n\t\t" . '<td class="pad">&nbsp;</td>';
     if ($nextPostObjects) {
         $next_year = substr($nextPostObjects[0]->getVar('post_date'), 0, 4);
         $next_month = substr($nextPostObjects[0]->getVar('post_date'), 5, 2);
         if (function_exists('mb_substr')) {
             $smonth_name = mb_substr($GLOBALS['month'][zeroise($next_month, 2)], 0, 3, $GLOBALS['blog_charset']);
         } else {
             $smonth_name = substr($GLOBALS['month'][zeroise($next_month, 2)], 0, 3);
         }
         $month_str = format_month(date('Y', mktime(0, 0, 0, $next_month, 1, $next_year)), $GLOBALS['month'][zeroise($next_month, 2)]);
         $get_calendar .= "\n\t\t" . '<td abbr="' . $GLOBALS['month'][zeroise($next_month, 2)] . '" colspan="3" id="next"><a href="' . get_month_link($next_year, $next_month) . '" title="View posts for ' . $month_str . '">' . $smonth_name . ' &raquo;</a></td>';
     } else {
         $get_calendar .= "\n\t\t" . '<td colspan="3" id="next" class="pad">&nbsp;</td>';
     }
     $get_calendar .= "\n\t</tr>\n</tfoot>\n<tbody>\n\t<tr>";
     if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") || strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "camino") || strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "safari")) {
         $ak_title_separator = "\n";
     } else {
         $ak_title_separator = ", ";
     }
     // Get days with posts
     $criteria =& new CriteriaCompo(new Criteria('MONTH(post_date)', $thismonth));
     $criteria->add(new Criteria('YEAR(post_date)', $thisyear));
     $criteria->add(new Criteria('post_date', current_time('mysql'), '<'));
     $criteria->add(new Criteria('post_status', 'publish'));
     $monthlyPostObjects =& $postHandler->getObjects($criteria, false, 'post_title, post_date');
     if ($monthlyPostObjects) {
         foreach ($monthlyPostObjects as $postObject) {
             $d = intval(substr($postObject->getVar('post_date'), 8, 2));
             $daywithpost[] = $d;
             if (empty($ak_titles_for_day["day_" . $d])) {
                 $ak_titles_for_day["day_" . $d] = '';
             }
             if (empty($ak_titles_for_day["{$d}"])) {
                 // first one
                 $ak_titles_for_day["{$d}"] = htmlspecialchars($postObject->getVar('post_title'));
             } else {
                 $ak_titles_for_day["{$d}"] .= $ak_title_separator . htmlspecialchars($postObject->getVar('post_title'));
             }
         }
         $daywithpost = array_unique($daywithpost);
     } else {
         $daywithpost = array();
     }
     // See how much we should pad in the beginning
     $pad = intval(date('w', $unixmonth));
     if ($pad) {
         $get_calendar .= "\n\t\t<td colspan='{$pad}' class='pad'>&nbsp;</td>";
     }
     $daysinmonth = intval(date('t', $unixmonth));
     for ($day = 1; $day <= $daysinmonth; ++$day) {
         if (!empty($newrow)) {
             $get_calendar .= "\n\t</tr>\n\t<tr>\n\t\t";
         }
         $newrow = false;
         if ($day == date('j', current_time('timestamp', 0)) && $thismonth == date('m', current_time('timestamp', 0))) {
             $get_calendar .= '<td id="today">';
         } else {
             $get_calendar .= "<td>";
         }
         if (in_array($day, $daywithpost)) {
             // any posts today?
             $get_calendar .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"{$ak_titles_for_day[$day]}\">{$day}</a>";
         } else {
             $get_calendar .= $day;
         }
         $get_calendar .= '</td>';
         if (6 == date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear))) {
             $newrow = true;
         }
     }
     $pad = 7 - date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear));
     if ($pad != 0 && $pad != 7) {
         $get_calendar .= "\n\t\t<td class='pad' colspan='{$pad}'>&nbsp;</td>";
     }
     $get_calendar .= "\n\t</tr>\n\t</tbody>\n\t</table>";
     return _echo($get_calendar, $echo);
 }
 function list_authors2($optioncount = false, $exclude_admin = true, $idmode = '', $hide_empty = true, $feed = '', $feed_image = '', $echo = true)
 {
     $list_authors2 = '';
     if ($exclude_admin) {
         $criteria = new Criteria('ID', 1, '<>');
     } else {
         $criteria = new CriteriaCompo();
     }
     $criteria->setSort('user_nickname');
     $userHandler =& wp_handler('User');
     $userObjects =& $userHandler->getObjects($criteria);
     foreach ($userObjects as $userObject) {
         $author =& $userObject->exportWpObject($idmode);
         $name = htmlspecialchars(get_author_name($author->ID, $idmode), ENT_QUOTES);
         $posts = get_usernumposts($author->ID);
         if (!($posts == 0 && $hide_empty)) {
             $list_authors2 .= "<li>";
         }
         if ($posts == 0) {
             if (!$hide_empty) {
                 $list_authors2 .= $name;
             }
         } else {
             $link = '<a href="' . get_author_link(0, $author->ID, $author->user_login) . '" title="' . sprintf("Posts by %s", $name) . '">' . $name . '</a>';
             if (!empty($feed_image) || !empty($feed)) {
                 $link .= ' ';
                 if (empty($feed_image)) {
                     $link .= '(';
                 }
                 $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_login) . '"';
                 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\" align=\"bottom\"{$alt}{$title}" . ' />';
                 } else {
                     $link .= $name;
                 }
                 $link .= '</a>';
                 if (empty($feed_image)) {
                     $link .= ')';
                 }
             }
             if ($optioncount) {
                 $link .= ' (' . $posts . ')';
             }
         }
         if (!($posts == 0 && $hide_empty)) {
             $list_authors2 .= "{$link}</li>";
         }
     }
     return _echo($list_authors2, $echo);
 }
 function upgrade_wp_tables()
 {
     global $xoopsDB;
     require_once dirname(dirname(__FILE__)) . '/wp-config.php';
     if ($xoopsDB->query("SHOW COLUMNS FROM " . wp_table('postmeta')) == false) {
         $sql1 = "CREATE TABLE " . wp_table('postmeta') . " (\n\t\t\t\t\t\tmeta_id int(11) NOT NULL auto_increment,\n\t\t\t\t\t\tpost_id int(11) NOT NULL default '0',\n\t\t\t\t\t\tmeta_key varchar(255) default NULL,\n\t\t\t\t\t\tmeta_value text,\n\t\t\t\t\t\tPRIMARY KEY\t (meta_id),\n\t\t\t\t\t\tKEY post_id (post_id),\n\t\t\t\t\t\tKEY meta_key (meta_key)\n\t\t\t\t\t)";
         $xoopsDB->query($sql1);
         $GLOBALS['msgs'][] = "TABLE " . wp_table('postmeta') . " is added.";
     }
     if (!$xoopsDB->getRowsNum($xoopsDB->query("SHOW COLUMNS FROM " . wp_table('comments') . " LIKE 'comment_type'"))) {
         $sql1 = "ALTER TABLE " . wp_table('comments') . " ADD (\n\t\t\t\t\t\tcomment_agent varchar(255) NOT NULL default '',\n\t\t\t\t\t\tcomment_type varchar(20) NOT NULL default '',\n\t\t\t\t\t\tcomment_parent int(11) NOT NULL default '0',\n\t\t\t\t\t\tuser_id int(11) NOT NULL default '0'\n\t\t\t\t\t)";
         $xoopsDB->query($sql1);
         $GLOBALS['msgs'][] = "TABLE " . wp_table('comments') . " is modified.";
     }
     $sql1 = "ALTER TABLE " . wp_table('options') . " CHANGE \n\t\t\t\t\toption_value option_value longtext NOT NULL default ''\n\t\t\t\t";
     $xoopsDB->query($sql1);
     $GLOBALS['msgs'][] = "TABLE " . wp_table('options') . " is modified.";
     $xoopsDB->query("DELETE FROM " . wp_table('optiongroup_options') . " WHERE group_id=6 AND option_id=1");
     $xoopsDB->query("DELETE FROM " . wp_table('optiongroup_options') . " WHERE group_id=6 AND option_id=2");
     $xoopsDB->query("UPDATE " . wp_table('optiongroup_options') . " SET seq=1 WHERE group_id=6 AND option_id=3");
     $xoopsDB->query("UPDATE " . wp_table('optiongroup_options') . " SET seq=2 WHERE group_id=6 AND option_id=4");
     $xoopsDB->query("UPDATE " . wp_table('optiongroup_options') . " SET seq=3 WHERE group_id=6 AND option_id=54");
     # --------------------------------------------------------
     if ($xoopsDB->query("DELETE FROM " . wp_table('options') . " WHERE option_id =7 AND option_name ='new_users_can_blog'")) {
         $xoopsDB->query("DELETE FROM " . wp_table('optiongroup_options') . " WHERE group_id=6 AND option_id =7");
     }
     if ($xoopsDB->query("DELETE FROM " . wp_table('options') . " WHERE option_id =8 AND option_name ='users_can_register'")) {
         $xoopsDB->query("DELETE FROM " . wp_table('optiongroup_options') . " WHERE group_id=6 AND option_id =8");
     }
     if ($xoopsDB->query("DELETE FROM " . wp_table('options') . " WHERE option_id =91 AND option_name ='gzipcompression'")) {
         $xoopsDB->query("DELETE FROM " . wp_table('optiongroup_options') . " WHERE group_id=6 AND option_id =91");
     }
     if ($xoopsDB->query("DELETE FROM " . wp_table('options') . " WHERE option_id =27 AND option_name ='use_blodotgsping'")) {
         $xoopsDB->query("DELETE FROM " . wp_table('optiongroup_options') . " WHERE group_id=3 AND option_id =27");
     }
     if ($xoopsDB->query("DELETE FROM " . wp_table('options') . " WHERE option_id =28 AND option_name ='blodotgsping_url'")) {
         $xoopsDB->query("DELETE FROM " . wp_table('optiongroup_options') . " WHERE group_id=3 AND option_id =28");
     }
     if (!get_settings('use_comment_preview')) {
         add_option('use_comment_preview', '0', 2, "Display Preview Screen after comment posting.", 2, 8);
     }
     if (!get_settings('active_plugins')) {
         add_option('active_plugins', "\n");
     }
     if (!get_settings('check_trackback_content')) {
         add_option('check_trackback_content', '0', 3, '_LANG_INST_BASE_VALUE95', 2, 8);
     }
     if (!get_settings('trackback_filename')) {
         add_option('trackback_filename', 'wp-trackback.php', 3, 'TrackBack File Name (default wp-trackback.php)', 3, 8);
     }
     if (!get_settings('xmlrpc_filename')) {
         add_option('xmlrpc_filename', 'xmlrpc.php', 3, 'TrackBack File Name (default xmlrpc.php)', 3, 8);
     }
     if (!get_settings('xmlrpc_autodetect')) {
         add_option('xmlrpc_autodetect', '0', 3, 'Enable XMLRPC File Auto detection', 2, 8);
     }
     $date_format = get_settings('date_format');
     $date_format = str_replace('\\\\d', '\\d', $date_format);
     update_option('date_format', $date_format);
     $postHandler =& wp_handler('Post');
     $resultSet = $postHandler->open();
     while ($postObject =& $postHandler->getNext($resultSet)) {
         $title = stripslashes($postObject->getVar('post_title', 'n'));
         $content = stripslashes($postObject->getVar('post_content', 'n'));
         $excerpt = stripslashes($postObject->getVar('post_excerpt', 'n'));
         if ($title != $postObject->getVar('post_title', 'n') || $content != $postObject->getVar('post_content', 'n') || $excerpt != $postObject->getVar('post_excerpt', 'n')) {
             $GLOBALS['msgs'][] = "Post[" . $postObject->getVar('ID') . "] is converted.";
             $postObject->setVar('post_title', $title, true);
             $postObject->setVar('post_content', $content, true);
             $postObject->setVar('post_excerpt', $excerpt, true);
             $postHandler->insert($postObject, true, true);
         }
     }
     $commentHandler =& wp_handler('Comment');
     $resultSet = $commentHandler->open();
     while ($commentObject =& $commentHandler->getNext($resultSet)) {
         $content = stripslashes($commentObject->getVar('comment_content', 'n'));
         $type = $commentObject->vars['comment_type']['value'];
         if (empty($type) || $content != $commentObject->getVar('comment_content', 'n')) {
             $GLOBALS['msgs'][] = "Comment[" . $commentObject->getVar('comment_ID') . "] is converted.";
             $commentObject->setVar('comment_content', $content, true);
             $commentObject->setVar('comment_type', $commentObject->getVar('comment_type'), true);
             $commentHandler->insert($commentObject, true, true);
         }
     }
 }
예제 #15
0
 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 post_count_exceeds()
{
    $postHandler =& wp_handler('Post');
    $GLOBALS['current_posts_criteria']->setGroupBy('');
    $postObjects =& $postHandler->getObjects($GLOBALS['current_posts_criteria'], false, 'count(DISTINCT ID) numposts', '', $GLOBALS['current_posts_join']);
    $numposts = $postObjects[0]->getExtraVar('numposts');
    if ($GLOBALS['posts_per_page'] != -1 && $numposts > $GLOBALS['posts_per_page']) {
        echo '<p><b>' . sprintf(_LANG_NKA_EXCEEDS_COUNT, $GLOBALS['posts_per_page']) . '</b></p>';
    }
}
예제 #17
0
function b2getcategories($m)
{
    $blog_ID = $m->getParam(0);
    $username = $m->getParam(1);
    $password = $m->getParam(2);
    $blog_ID = $blogid->scalarval();
    $username = $username->scalarval();
    $password = $password->scalarval();
    if (user_pass_ok($username, $password)) {
        $userdata = get_userdatabylogin($username);
        if ($userdata->user_level < 1) {
            return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 1, 'Sorry, level 0 users can not post');
        }
        $categoryHandler =& wp_handler('Category');
        $criteria =& new Criteria(1, 1);
        $criteria->setSort('cat_ID');
        $criteria->setOrder('ACS');
        $categoryObjects =& $categoryHandler->getObjects($criteria);
        if (!$categoryObjects) {
            die('Error getting data');
        }
        $i = 0;
        foreach ($categoryObjects as $categoryObject) {
            $struct[$i++] = new xmlrpcval(array('categoryID' => new xmlrpcval($categoryObject->getVar('cat_ID')), 'categoryName' => new xmlrpcval(mb_conv($categoryObject->getVar('cat_name'), 'UTF-8', $GLOBALS['blog_charset']))), 'struct');
        }
        $data = array($struct[0]);
        for ($j = 1; $j < $i; $j++) {
            array_push($data, $struct[$j]);
        }
        $resp = new xmlrpcval($data, 'array');
        return new xmlrpcresp($resp);
    } else {
        return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
    }
}
            }
        }
        $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');
    }
}
예제 #19
0
<?php

require_once 'admin.php';
$_this_file = 'profile.php';
$GLOBALS['parent_file'] = 'profile.php';
$userHandler =& wp_handler('User');
init_param('', 'action', 'string', '');
switch (get_param('action')) {
    case 'update':
        //Check Ticket
        if (!$GLOBALS['xoopsWPTicket']->check()) {
            redirect_header(wp_siteurl() . '/wp-admin/' . $_this_file, 3, $GLOBALS['xoopsWPTicket']->getErrors());
        }
        //Check Paramaters
        init_param('POST', 'newuser_firstname', 'string', '', true);
        init_param('POST', 'newuser_lastname', 'string', '', true);
        init_param('POST', 'newuser_nickname', 'string', NO_DEFAULT_PARAM, true);
        init_param('POST', 'newuser_icq', 'string', '', true);
        init_param('POST', 'newuser_aim', 'string', '', true);
        init_param('POST', 'newuser_msn', 'string', '', true);
        init_param('POST', 'newuser_yim', 'string', '', true);
        init_param('POST', 'newuser_email', 'string', true, true);
        init_param('POST', 'newuser_url', 'string', '', true);
        init_param('POST', 'newuser_idmode', 'string', '', true);
        init_param('POST', 'user_description', 'html', '', true);
        $userObject =& $userHandler->create(false);
        $userObject->setVar('ID', $GLOBALS['user_ID']);
        $userObject->setVar('user_firstname', get_param('newuser_firstname'));
        $userObject->setVar('user_lastname', get_param('newuser_lastname'));
        $userObject->setVar('user_nickname', get_param('newuser_nickname'));
        $userObject->setVar('user_icq', get_param('newuser_icq'));
<?php

// Links
// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
require_once 'admin.php';
$linkHandler =& wp_handler('Link');
$userHandler =& wp_handler('User');
$linkCategoryHandler =& wp_handler('LinkCategory');
$title = 'Manage Links';
$this_file = 'link-manager.php';
$parent_file = 'link-manager.php';
init_param(array('POST', 'GET'), 'action2', 'string', '');
init_param(array('POST', 'GET'), 'action', 'string', $action2);
switch ($action) {
    case _LANG_WLM_ASSIGN_TEXT:
        //Check Ticket
        if (!$xoopsWPTicket->check()) {
            redirect_header($siteurl . '/wp-admin/' . $this_file, 3, $xoopsWPTicket->getErrors());
        }
        //Check User_Level
        if ($user_level < get_settings('links_minadminlevel')) {
            redirect_header($siteurl . '/wp-admin/', 5, _LANG_P_CHEATING_ERROR);
        }
        //Check Paramaters
        init_param('POST', 'linkcheck', 'array-int', array(), true);
        init_param('POST', 'newowner', 'integer', -1, true);
        if (count($linkcheck) == 0) {
            header('Location: ' . $this_file);
            exit;
        }
        if (!$userHandler->get($newowner)) {
 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;
 }
예제 #22
0
function wp_mail_receive()
{
    global $wpdb, $wp_pop3, $img_target;
    require_once ABSPATH . WPINC . '/class-pop3.php';
    timer_start();
    $use_cache = 1;
    $time_difference = get_settings('time_difference');
    $blog_charset = get_settings('blog_charset');
    error_reporting(2037);
    $wp_pop3 = new POP3();
    if (!$wp_pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) {
        echo "Ooops {$wp_pop3->ERROR} <br />\n";
        return;
    }
    $mail_count = $wp_pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass'));
    if ($mail_count == false) {
        if (!$wp_pop3->FP) {
            echo "Oooops Login Failed: {$wp_pop3->ERROR}<br />\n";
        } else {
            echo "No Message<br />\n";
            $wp_pop3->quit();
        }
        return;
    }
    // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT!
    register_shutdown_function('wp_mail_quit');
    for ($mail_num = 1; $mail_num <= $mail_count; $mail_num++) {
        $MsgOne = $wp_pop3->get($mail_num);
        if (!$MsgOne || gettype($MsgOne) != 'array') {
            echo "oops, {$wp_pop3->ERROR}<br />\n";
            $wp_pop3->quit();
            return;
        }
        $content = '';
        $content_type = '';
        $boundary = '';
        $att_boundary = '';
        $hatt_boundary = '';
        $bodysignal = 0;
        $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
        while (list($lineNum, $line) = each($MsgOne)) {
            if (strlen($line) < 3) {
                $bodysignal = 1;
            }
            if ($bodysignal) {
                $content .= $line;
            } else {
                if (preg_match('/^Content-Type:\\s+(.*?)\\;/i', $line, $match)) {
                    $content_type = $match[1];
                    $content_type = strtolower($match[1]);
                }
                if ($content_type == 'multipart/mixed' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $att_boundary == '') {
                    $att_boundary = trim($match[1]);
                }
                if ($content_type == 'multipart/alternative' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $boundary == '') {
                    $boundary = trim($match[1]);
                }
                if ($content_type == 'multipart/related' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $hatt_boundary == '') {
                    $hatt_boundary = trim($match[1]);
                }
                if (preg_match('/Subject: /', $line)) {
                    $subject = trim($line);
                    $subject = substr($subject, 9, strlen($subject) - 9);
                    if (function_exists('mb_decode_mimeheader')) {
                        $subject1 = mb_decode_mimeheader($subject);
                        if ($subject != $subject) {
                            $sub_charset = mb_internal_encoding();
                        } else {
                            $sub_charset = "auto";
                        }
                        $subject = $subject1;
                    }
                    if (get_settings('use_phoneemail')) {
                        $subject = explode(get_settings('phoneemail_separator'), $subject);
                        $subject = trim($subject[0]);
                    }
                }
                if (preg_match('/Date: /', $line)) {
                    // of the form '20 Mar 2002 20:32:37'
                    $ddate = trim($line);
                    $ddate = str_replace('Date: ', '', $ddate);
                    if (strpos($ddate, ',')) {
                        $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
                    }
                    $ddate_U = strtotime($ddate) + $time_difference * 3600;
                    $post_date = date('Y-m-d H:i:s', $ddate_U);
                }
            }
        }
        if (!ereg(get_settings('subjectprefix'), $subject)) {
            continue;
        }
        $charset = "";
        $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches);
        if ($ncharset) {
            $charset = $matches[1];
        }
        $ddate_today = time() + $time_difference * 3600;
        $ddate_difference_days = ($ddate_today - $ddate_U) / 86400;
        if ($ddate_difference_days > 14) {
            echo "Too old<br />\n";
            continue;
        }
        if (preg_match('/' . get_settings('subjectprefix') . '/', $subject)) {
            $userpassstring = '';
            echo "<div style=\"border: 1px dashed #999; padding: 10px; margin: 10px;\">\n";
            echo "<p><b>{$mail_num}</b></p><p><b>Subject: </b>{$subject}</p>\n";
            $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject));
            $attachment = false;
            if ($att_boundary) {
                $contents = explode('--' . $att_boundary, $content);
                $content = $contents[1];
                $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches);
                if ($ncharset) {
                    $charset = $matches[1];
                }
                $content = explode("\r\n\r\n", $content, 2);
                $content = $content[1];
            }
            if ($hatt_boundary) {
                $contents = explode('--' . $hatt_boundary, $content);
                $content = $contents[1];
                if (preg_match('/Content-Type: multipart\\/alternative\\;\\s*boundary\\=(?:")?([^";\\s\\n]*?)(?:")?\\s*(?:;|\\n|$)"/i', $content, $matches)) {
                    $boundary = trim($matches[1]);
                    $content = explode('--' . $boundary, $content);
                    $content = $content[2];
                }
                $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches);
                if ($ncharset) {
                    $charset = $matches[1];
                }
                $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
                $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>');
            } else {
                if ($boundary) {
                    $content = explode('--' . $boundary, $content);
                    $content = $content[2];
                    if (preg_match('/Content-Type: multipart\\/related\\;\\s*boundary=(?:")?([^";\\s\\n]*?)(?:")?\\s*(?:;|\\n|$)/i', $content, $matches)) {
                        $hatt_boundary = trim($matches[1]);
                        $contents = explode('--' . $hatt_boundary, $content);
                        $content = $contents[1];
                    }
                    $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches);
                    if ($ncharset) {
                        $charset = $matches[1];
                    }
                    $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
                    $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>');
                }
            }
            $content = trim($content);
            echo "<p><b>Content-type:</b> {$content_type}, <b>boundary:</b> {$boundary}</p>\n";
            echo "<p><b>att_boundary:</b> {$att_boundary}, <b>hatt_boundary:</b> {$hatt_boundary}</p>\n";
            echo "<p><b>charset:</b>{$charset}, <b>BLOG charset:</b>{$blog_charset}</p>\n";
            // echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>';
            if ($charset == "" || trim(strtoupper($charset)) == "ISO-2022-JP") {
                $charset = "JIS";
            }
            if (trim(strtoupper($charset)) == "SHIFT_JIS") {
                $charset = "SJIS";
            }
            $btpos = strpos($content, get_settings('bodyterminator'));
            if ($btpos) {
                $content = substr($content, 0, $btpos);
            }
            $content = trim($content);
            $blah = explode("\n", preg_replace("/^[\n\r\\s]*/", "", strip_tags($content)));
            $firstline = preg_replace("/[\n\r]/", "", $blah[0]);
            $secondline = $blah[1];
            if (get_settings('use_phoneemail')) {
                echo "<p><b>Use Phone Mail:</b> Yes</p>\n";
                $btpos = strpos($firstline, get_settings('phoneemail_separator'));
                if ($btpos) {
                    $userpassstring = trim(substr($firstline, 0, $btpos));
                    $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
                    $btpos = strpos($content, get_settings('phoneemail_separator'));
                    if ($btpos) {
                        $userpassstring = trim(substr($content, 0, $btpos));
                        $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content)));
                    }
                }
                $contentfirstline = $blah[1];
            } else {
                echo "<p><b>Use Phone Mail:</b> No</p>\n";
                $userpassstring = strip_tags($firstline);
                $contentfirstline = '';
            }
            $flat = 999.0;
            $flon = 999.0;
            $secondlineParts = explode(':', strip_tags($secondline));
            if (strncmp($secondlineParts[0], "POS", 3) == 0) {
                echo "Found POS:<br />\n";
                // echo "Second parts is:".$secondlineParts[1];
                // the second line is the postion listing line
                $secLineParts = explode(',', $secondlineParts[1]);
                $flatStr = $secLineParts[0];
                $flonStr = $secLineParts[1];
                // echo "String are ".$flatStr.$flonStr;
                $flat = floatval($secLineParts[0]);
                $flon = floatval($secLineParts[1]);
                // echo "values are ".$flat." and ".$flon;
                // ok remove that position... we should not have it in the final output
                $content = str_replace($secondline, '', $content);
            }
            $blah = explode(':', $userpassstring);
            $user_login = $blah[0];
            $user_pass = $blah[1];
            $user_login = mb_conv(trim($user_login), $blog_charset, $charset);
            $content = $contentfirstline . str_replace($firstline, '', $content);
            $content = trim($content);
            // Please uncomment following line, only if you want to check user and password.
            // echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>";
            echo "<p><b>Login:</b> {$user_login}, <b>Pass:</b> *********</p>";
            if (!user_pass_ok($user_login, $user_pass)) {
                echo "<p><b>Error: Wrong Login.</b></p></div>\n";
                continue;
            }
            $userdata = get_userdatabylogin($user_login);
            $user_level = $userdata->user_level;
            $post_author = $userdata->ID;
            if ($user_level > 0) {
                $post_title = xmlrpc_getposttitle($content);
                if ($post_title == '') {
                    $post_title = $subject;
                }
                echo "Subject : " . mb_conv($post_title, $blog_charset, $sub_charset) . " <br />\n";
                $post_category = get_settings('default_category');
                if (preg_match('/<category>(.+?)<\\/category>/is', $content, $matchcat)) {
                    $post_category = xmlrpc_getpostcategory($content);
                }
                if (empty($post_category)) {
                    $post_category = get_settings('default_post_category');
                }
                echo "Category : {$post_category} <br />\n";
                $post_category = explode(',', $post_category);
                if (!get_settings('emailtestonly')) {
                    // Attaching Image Files Save
                    if ($att_boundary != "") {
                        $attachment = wp_getattach($contents[2], "user-" . trim($post_author), 1);
                    }
                    if ($boundary != "" && $hatt_boundary != "") {
                        for ($i = 2; $i < count($contents); $i++) {
                            $hattachment = wp_getattach($contents[$i], "user-" . trim($post_author), 0);
                            if ($hattachment) {
                                if (preg_match("/Content-Id: \\<([^\\>]*)>/i", $contents[$i], $matches)) {
                                    $content = preg_replace("/(cid:" . preg_quote($matches[1]) . ")/", get_settings('fileupload_url') . '/' . $hattachment, $content);
                                }
                            }
                        }
                    }
                    if ($boundary != "") {
                        $content = preg_replace("/\\=[\r\n]/", "", $content);
                        $content = preg_replace("/[\r\n]/", " ", $content);
                    }
                    $content = preg_replace("|\n([^\n])|", " \$1", $content);
                    $content = preg_replace("/\\=([0-9a-fA-F]{2,2})/e", "pack('c',base_convert('\\1',16,10))", $content);
                    $content = mb_conv(trim($content), $blog_charset, $charset);
                    // If we find an attachment, add it to the post
                    if ($attachment) {
                        if (isset($img_target) && $img_target) {
                            $img_target = ' target="' . $img_target . '"';
                        } else {
                            $img_target = '';
                        }
                        if (file_exists(get_settings('fileupload_realpath') . "/thumb-" . $attachment)) {
                            $content = "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($attachment) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src = \"" . get_settings('fileupload_url') . '/thumb-' . rawurlencode($attachment) . "\" alt=\"" . $attachment . "\" title=\"" . $attachment . "\" /></a>" . $content . "<br clear=\"left\" />";
                        } else {
                            $content = "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($attachment) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src = \"" . get_settings('fileupload_url') . '/' . rawurlencode($attachment) . "\" alt=\"" . $attachment . "\" title=\"" . $attachment . "\" /></a>" . $content . "<br clear=\"left\" />";
                        }
                    }
                    $postHandler =& wp_handler('Post');
                    $postObject =& $postHandler->create();
                    $postObject->setVar('post_content', $content);
                    $postObject->setVar('post_title', trim(mb_conv($post_title, $blog_charset, $sub_charset)));
                    $postObject->setVar('post_date', $post_date);
                    $postObject->setVar('post_author', $post_author);
                    $postObject->setVar('post_category', $post_category[0]);
                    $postObject->setVar('post_name', sanitize_title($post_title));
                    if ($flat < 500) {
                        $postObject->setVar('post_lat', $flat);
                        $postObject->setVar('post_lon', $flon);
                    }
                    if (!$postHandler->insert($postObject, true)) {
                        echo "<b>Error: Insert New Post</b><br />";
                    }
                    $post_ID = $postObject->getVar('ID');
                    echo "Post ID = {$post_ID}<br />\n";
                    $postObject->assignCategories($post_category);
                    do_action('publish_post', $post_ID);
                    do_action('publish_phone', $post_ID);
                    if ($flat < 500) {
                        pingGeoUrl($post_ID);
                    }
                    $blog_ID = 1;
                    pingWeblogs($blog_ID);
                    pingBlogs($blog_ID);
                    pingback($content, $post_ID);
                }
                echo "\n<p><b>Posted title:</b> {$post_title}<br />\n";
                echo "<b>Posted content:</b><br /><pre>" . $content . "</pre></p>\n";
                if (!$wp_pop3->delete($mail_num)) {
                    echo "<p>Oops " . $wp_pop3->ERROR . "</p></div>\n";
                    $wp_pop3->reset();
                    return;
                } else {
                    echo "<p>Mission complete, message <strong>{$mail_num}</strong> deleted.</p>\n";
                }
            } else {
                echo "<p><strong>Level 0 users can\\'t post.</strong></p>\n";
            }
            echo "</div>\n";
        }
    }
    $wp_pop3->quit();
    timer_stop($output_debugging_info);
    return;
}
<?php

require_once 'admin.php';
$this_file = 'moderation.php';
$parent_file = 'edit.php';
$commentHandler =& wp_handler('Comment');
$postHandler =& wp_handler('Post');
init_param(array('POST', 'GET'), 'action', 'string', '');
switch ($action) {
    case 'update':
        //Check Ticket
        if (!$xoopsWPTicket->check()) {
            redirect_header(wp_siteurl() . '/wp-admin/' . $this_file, 3, $xoopsWPTicket->getErrors());
        }
        //Check User_Level
        user_level_check();
        //Check Paramaters
        init_param('POST', 'comment', 'array', array(), true);
        $item_ignored = 0;
        $item_deleted = 0;
        $item_approved = 0;
        foreach ($comment as $key => $value) {
            $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)) {
 function get_posts($args)
 {
     parse_str($args, $r);
     if (!isset($r['numberposts'])) {
         $r['numberposts'] = 5;
     }
     if (!isset($r['offset'])) {
         $r['offset'] = 0;
     }
     // The following not implemented yet
     if (!isset($r['category'])) {
         $r['category'] = '';
     }
     if (!isset($r['orderby'])) {
         $r['orderby'] = '';
     }
     if (!isset($r['order'])) {
         $r['order'] = '';
     }
     $now = current_time('mysql');
     $criteria =& new CriteriaCompo(new Criteria('post_date', $now, '<='));
     $criteria->add(new Criteria('post_status', 'publish'));
     $criteria->setSort('post_date');
     $criteria->setOrder('DESC');
     $criteria->setStart(intval($r['offset']));
     $criteria->setLimit(intval($r['numberposts']));
     $criteria->setGroupBy('ID');
     $postHandler =& wp_handler('Post');
     $postObjects =& $postHandler->getObjects($criteria, false, '', true);
     $posts = array();
     foreach ($postObjects as $postObject) {
         $posts[] =& $postObjects->exportWpObject();
     }
     return $posts;
 }
    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);
    }
 function veriflog()
 {
     if ($GLOBALS['xoopsUser']) {
         $userHandler =& wp_handler('User');
         $userObject =& $userHandler->get($GLOBALS['xoopsUser']->uid());
         if ($userObject) {
             return $userHandler->insert($userObject, true, true);
         } else {
             $userObject =& $userHandler->create();
             $userObject->setVar('ID', $GLOBALS['xoopsUser']->uid(), true);
             return $userHandler->insert($userObject, true, true);
         }
     }
     return false;
 }
}
require_once wp_base() . '/wp-includes/wp-tickets.php';
require_once wp_base() . '/wp-includes/functions-formatting.php';
require_once wp_base() . '/wp-includes/functions-filter.php';
require_once wp_base() . '/wp-includes/kses.php';
if (get_settings('hack_file')) {
    include_once wp_base() . '/my-hacks.php';
}
require 'wp-config-extra.php';
require_once wp_base() . '/wp-includes/template-functions.php';
require_once wp_base() . '/wp-includes/class-xmlrpc.php';
require_once wp_base() . '/wp-includes/class-xmlrpcs.php';
require_once wp_base() . '/wp-includes/links.php';
if (empty($GLOBALS['cache_categories'][wp_id()]) || count($GLOBALS['cache_categories'][wp_id()]) == 0) {
    $GLOBALS['cache_categories'][wp_id()] = array();
    $categoryHandler =& wp_handler('Category');
    $categoryObjects =& $categoryHandler->getObjects();
    foreach ($categoryObjects as $categoryObject) {
        $catt = $categoryObject->exportWpObject();
        $GLOBALS['cache_categories'][wp_id()][$catt->cat_ID] = $catt;
    }
}
// We should eventually migrate to either calling
// get_settings() wherever these are needed OR
// 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プラグイン互換性確保用
 function get_permalink($id = false)
 {
     $rewritecode = array('%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%postname%', '%post_id%', '%category%', '%author%', '%pagename%');
     $permalink = get_settings('permalink_structure');
     $postHandler =& wp_handler('Post');
     if ($id) {
         $id = intval($id);
         if ($permalink == '') {
             return wp_siteurl() . '/index.php?p=' . $id;
         }
         if (!isset($GLOBALS['permalink_cache'][wp_id()]) || !isset($GLOBALS['permalink_cache'][wp_id()][$id])) {
             $postObject =& $postHandler->get($id);
             $GLOBALS['permalink_cache'][wp_id()][$id] =& $postObject->exportWpObject();
         }
         $idpost = $GLOBALS['permalink_cache'][wp_id()][$id];
     } else {
         $idpost = $GLOBALS['post'];
     }
     if ('' != $permalink) {
         $unixtime = strtotime($idpost->post_date);
         $cats = get_the_category($idpost->ID);
         $category = $cats[0]->category_nicename;
         $authordata = get_userdata($idpost->post_author);
         $author = $authordata->user_login;
         $rewritereplace = array(date('Y', $unixtime), date('m', $unixtime), date('d', $unixtime), date('H', $unixtime), date('i', $unixtime), date('s', $unixtime), $idpost->post_name, $idpost->ID, $category, $author, $idpost->post_name);
         return wp_siteurl() . str_replace($rewritecode, $rewritereplace, $permalink);
     } else {
         return wp_siteurl() . '/index.php?p=' . $idpost->ID;
     }
 }