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); }
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."; } # -------------------------------------------------------- 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 (!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"); } }
/** ** update_links() ** Update in the db the links which have been updated ($all_links[url][1] != 0) **/ function update_links() { global $all_links; reset($all_links); while (list($id, $val) = each($all_links)) { if ($val[1]) { $GLOBALS['wpdb']->query("UPDATE " . wp_table('links') . " SET link_updated = '{$val['1']}' WHERE link_id = {$val['0']}"); } } // end while }
function wpbl_notify($comment_id, $reason, $harvest) { global $wbbl_comment; $tableposts = wp_table('posts'); $sql = "SELECT * FROM {$tableposts} WHERE ID='{$wbbl_comment['comment_post_ID']}' LIMIT 1"; $post = $GLOBALS['wpdb']->get_row($sql); if (!empty($wpbl_comment['comment_author_IP'])) { $comment_author_domain = gethostbyaddr($wpbl_comment['comment_author_IP']); } else { $comment_author_domain = ''; } // create the e-mail body $notify_message = "A new "; if ($wpbl_comment['comment_type'] == '') { $notify_message .= "Comment"; } else { if ($wpbl_comment['comment_type'] == 'trackback') { $notify_message .= "TrackBack"; } else { if ($wpbl_comment['comment_type'] == 'pingback') { $notify_message .= "PingBack"; } } } $notify_message .= " on post #{$wbbl_comment['comment_post_ID']} \"" . stripslashes($post->post_title) . "\" has been automatically deleted by the WPBlacklist plugin.\r\n\r\n"; $notify_message .= "Author : {$wpbl_comment['comment_author']} (IP: {$wpbl_comment['comment_author_IP']} , {$comment_author_domain})\r\n"; $notify_message .= "E-mail : {$wpbl_comment['comment_author_email']}\r\n"; $notify_message .= "URL : {$wpbl_comment['comment_author_url']}\r\n"; $notify_message .= "Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput={$wpbl_comment['comment_author_IP']}\r\n"; $notify_message .= "Comment:\r\n" . stripslashes($wpbl_comment['comment_content']) . "\r\n\r\n"; $notify_message .= "Triggered by : {$reason}\r\n\r\n"; // add harvested info - if there is any if (!empty($harvest)) { $notify_message .= "Harvested the following information:\r\n" . stripslashes($harvest); } // e-mail header $subject = '[' . stripslashes(get_settings('blogname')) . '] Automatically deleted: "' . stripslashes($post->post_title) . '"'; $admin_email = get_settings("admin_email"); $from = "From: {$admin_email}"; if (strtolower(get_settings('blog_charset')) == "euc-jp") { $mail_charset = "iso-2022-jp"; } else { $mail_charset = get_settings('blog_charset'); } $message_headers = "MIME-Version: 1.0\r\n" . "{$from}\r\n" . "Content-Type: text/plain; charset=\"" . $mail_charset . "\"\r\n"; // send e-mail if (function_exists('mb_send_mail')) { mb_send_mail($admin_email, $subject, $notify_message, $from); } else { @mail($admin_email, $subject, $notify_message, $from); } return true; }
function show_author_select() { $users = $GLOBALS['wpdb']->get_results("SELECT * FROM " . wp_table('users') . " WHERE user_level > 0", ARRAY_A); $output = '<option value="">' . _LANG_NKA_ALL_AUTHOR . '</option>' . NL; foreach ($users as $user) { $output .= '<option value="' . $user['ID'] . '"'; if ($user['ID'] == $GLOBALS['author']) { $output .= 'selected="selected"'; } $output .= '>' . $user['user_nickname'] . '</option>' . NL; } $output = '<select name="author">' . NL . $output . '</select>' . NL; echo $output; }
function wp_xoops_search($queryarray, $andor, $limit, $offset, $userid, $wp_num = "") { $GLOBALS['use_cache'] = 1; if ($wp_num == "") { $GLOBALS['wp_id'] = $wp_num; $GLOBALS['wp_inblock'] = 1; require XOOPS_ROOT_PATH . "/modules/wordpress/wp-config.php"; $GLOBALS['wp_inblock'] = 0; } $now = date('Y-m-d H:i:s', time() + get_settings('time_difference') * 3600); $where = "(post_status = 'publish') AND (post_date <= '" . $now . "')"; if (is_array($queryarray) && ($count = count($queryarray))) { $where .= " AND ((post_title LIKE '%{$queryarray['0']}%' OR post_content LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $where .= " {$andor} "; $where .= "(post_title LIKE '%{$queryarray[$i]}%' OR post_content LIKE '%{$queryarray[$i]}%')"; } $where .= ") "; } if ($userid) { $userid = intval($userid); $where .= " AND (post_author=" . $userid . ")"; } $request = "SELECT * FROM " . wp_table('posts') . " WHERE " . $where; $request .= " ORDER BY post_date DESC"; $result = $GLOBALS['xoopsDB']->query($request, $limit, $offset); $ret = array(); $i = 0; while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { $ret[$i]['link'] = str_replace(wp_siteurl() . "/", "", get_permalink($myrow['ID'])); $ret[$i]['title'] = htmlspecialchars($myrow['post_title'], ENT_QUOTES); $ret[$i]['image'] = "wp-images/search.png"; $date_str = $myrow['post_date']; $yyyy = substr($date_str, 0, 4); $mm = substr($date_str, 5, 2); $dd = substr($date_str, 8, 2); $hh = substr($date_str, 11, 2); $nn = substr($date_str, 15, 2); $ss = substr($date_str, 17, 2); $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy); $ret[$i]['uid'] = $myrow['post_author']; $ret[$i]['page'] = $myrow['post_title']; if (!empty($myrow['post_content']) && function_exists('xoops_make_context')) { $ret[$i]['context'] = xoops_make_context(strip_tags($myrow['post_content']), $queryarray); } $i++; } return $ret; }
function show_author_select() { global $wpdb, $tableusers, $author; $users = $wpdb->get_results("SELECT * FROM " . wp_table('users') . " WHERE user_level > 0", ARRAY_A); $output .= '<option value="">全投稿者</option>' . NL; foreach ($users as $user) { $output .= '<option value="' . $user['ID'] . '"'; if ($user['ID'] == $author) { $output .= 'selected="selected"'; } $output .= '>' . $user['user_nickname'] . '</option>' . NL; } $output = '<select name="author">' . NL . $output . '</select>' . NL; echo $output; }
function _wp_xoops_search($queryarray, $andor, $limit, $offset, $userid) { $now = current_time('mysql'); $where = '(post_status = \'publish\') AND (post_date <= \'' . $now . '\')'; if (is_array($queryarray) && ($count = count($queryarray))) { $where .= " AND ((post_title LIKE '%{$queryarray['0']}%' OR post_content LIKE '%{$queryarray['0']}%')"; for ($i = 1; $i < $count; $i++) { $where .= " {$andor} "; $where .= "(post_title LIKE '%{$queryarray[$i]}%' OR post_content LIKE '%{$queryarray[$i]}%')"; } $where .= ') '; } if ($userid) { $userid = intval($userid); $where .= ' AND (post_author=' . $userid . ')'; } $request = 'SELECT * FROM ' . wp_table('posts') . ' WHERE ' . $where; $request .= ' ORDER BY post_date DESC'; $result = $GLOBALS['xoopsDB']->query($request, $limit, $offset); $ret = array(); $i = 0; while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { $ret[$i]['link'] = str_replace(wp_siteurl() . '/', '', get_permalink($myrow['ID'])); $ret[$i]['title'] = htmlspecialchars($myrow['post_title'], ENT_QUOTES); $ret[$i]['image'] = 'wp-images/search.png'; $date_str = $myrow['post_date']; $yyyy = substr($date_str, 0, 4); $mm = substr($date_str, 5, 2); $dd = substr($date_str, 8, 2); $hh = substr($date_str, 11, 2); $nn = substr($date_str, 15, 2); $ss = substr($date_str, 17, 2); $ret[$i]['time'] = mktime($hh, $nn, $ss, $mm, $dd, $yyyy); $ret[$i]['uid'] = $myrow['post_author']; $ret[$i]['page'] = $myrow['post_title']; if (!empty($myrow['post_content']) && function_exists('xoops_make_context')) { $ret[$i]['context'] = xoops_make_context(strip_tags($myrow['post_content']), $queryarray); } if (!empty($myrow['post_content']) && function_exists('search_make_context')) { if (!empty($_GET['showcontext']) && $_GET['showcontext'] == 1) { $ret[$i]['context'] = search_make_context(strip_tags($myrow['post_content']), $queryarray); } } $i++; } return $ret; }
function validate_option($option, $name, $val) { global $wpdb; $msg = ''; switch ($option->option_type) { case 6: // range // get range $range = $wpdb->get_row("SELECT optionvalue_max, optionvalue_min FROM " . wp_table('optionvalues') . " WHERE option_id = {$option->option_id}"); if ($range) { if ($val < $range->optionvalue_min || $val > $range->optionvalue_max) { $msg = "{$name} is outside the valid range ({$range->optionvalue_min} - {$range->optionvalue_max}). "; } } } // end switch return $msg; }
function apply_filters($tag, $string) { if (isset($GLOBALS['wp_filter'][wp_id()]['all'])) { foreach ($GLOBALS['wp_filter'][wp_id()]['all'] as $priority => $functions) { if (isset($GLOBALS['wp_filter'][wp_id()][$tag][$priority])) { $GLOBALS['wp_filter'][wp_id()][$tag][$priority] = array_merge($GLOBALS['wp_filter'][wp_id()]['all'][$priority], $GLOBALS['wp_filter'][wp_id()][$tag][$priority]); } else { $GLOBALS['wp_filter'][wp_id()][$tag][$priority] = array_merge($GLOBALS['wp_filter'][wp_id()]['all'][$priority], array()); } $GLOBALS['wp_filter'][wp_id()][$tag][$priority] = array_unique($GLOBALS['wp_filter'][wp_id()][$tag][$priority]); } } if (isset($GLOBALS['wp_filter'][wp_id()][$tag])) { ksort($GLOBALS['wp_filter'][wp_id()][$tag]); /* Keep Plugin Comatibility */ $tables = array('posts', 'users', 'categories', 'post2cat', 'comments', 'links', 'linkcategories', 'options', 'optiontypes', 'optionvalues', 'optiongroups', 'optiongroup_options', 'postmeta', 'settings'); $oldtables = array(); foreach ($tables as $table) { if (isset($GLOBALS['table' . $table])) { $oldtables[$table] = $GLOBALS['table' . $table]; } $GLOBALS['table' . $table] = wp_table($table); } foreach ($GLOBALS['wp_filter'][wp_id()][$tag] as $priority => $functions) { foreach ($functions as $function) { // echo "<br/>$tag - $function <br>"; $string = $function($string); // echo $string; } } foreach ($tables as $table) { unset($GLOBALS['table' . $table]); } foreach ($oldtables as $table => $value) { $GLOBALS['table' . $table] = $value; } } return $string; }
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 draft_list($user_ID) { if ($GLOBALS['user_level'] == 10) { $drafts = $GLOBALS['wpdb']->get_results("SELECT ID, post_title FROM " . wp_table('posts') . " WHERE post_status = 'draft'"); } else { $drafts = $GLOBALS['wpdb']->get_results("SELECT ID, post_title FROM " . wp_table('posts') . " WHERE post_status = 'draft' AND post_author = {$user_ID}"); } if ($drafts) { ?> <div class="wrap"> <p><strong><?php echo _LANG_P_YOUR_DRAFTS; ?> </strong> <?php $i = 0; foreach ($drafts as $draft) { $delim = 0 != $i ? ', ' : ''; $draft->post_title = $draft->post_title; if ($draft->post_title == '') { $draft->post_title = 'Post #' . $draft->ID; } ++$i; ?> <?php echo $delim; ?> <a href='post.php?action=edit&post=<?php echo $draft->ID; ?> ' title='Edit this draft'><?php echo $draft->post_title; ?> </a> <?php } ?> .</p> </div> <?php } }
} // This array constructs the admin menu bar. // // Menu item name // The minimum level the user needs to access the item: between 0 and 10 // The URL of the item's file $menu[5] = array(_LANG_ADMIN_MENU_WRITE, 1, 'post.php'); $menu[10] = array(_LANG_ADMIN_MENU_EDIT, 1, 'edit.php'); $menu[20] = array(_LANG_ADMIN_MENU_CATE, 3, 'categories.php'); $menu[25] = array(_LANG_ADMIN_MENU_LINK, 5, 'link-manager.php'); $menu[30] = array(_LANG_ADMIN_MENU_USER, 3, 'users.php'); $menu[35] = array(_LANG_ADMIN_MENU_OPTION, 6, 'options.php'); $menu[40] = array(_LANG_ADMIN_MENU_PLUG, 8, 'plugins.php'); $menu[45] = array(_LANG_ADMIN_MENU_PROFILE, 1, 'profile.php'); ksort($menu); // So other files can plugin $submenu['edit.php'][5] = array(_LANG_E_LATEST_POSTS, 1, 'edit.php'); $submenu['edit.php'][20] = array(_LANG_E_LATEST_COMMENTS, 1, 'edit-comments.php'); $awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM " . wp_table('comments') . " WHERE comment_approved = '0'"); $submenu['edit.php'][25] = array(sprintf(_LANG_E_AWAIT_MODER . " (%s)", $awaiting_mod), 1, 'moderation.php'); $submenu['link-manager.php'][5] = array(_LANG_WLA_MANAGE_LINK, 5, 'link-manager.php'); $submenu['link-manager.php'][10] = array(_LANG_WLA_ADD_LINK, 5, 'link-add.php'); $submenu['link-manager.php'][15] = array(_LANG_WLA_LINK_CATE, 5, 'link-categories.php'); $submenu['link-manager.php'][20] = array(_LANG_WLA_IMPORT_BLOG, 5, 'link-import.php'); $option_groups = $wpdb->get_results("\n\t\t\t\t\t\t\tSELECT group_id, group_name, group_desc, group_longdesc \n\t\t\t\t\t\t\tFROM " . wp_table('optiongroups') . " ORDER BY group_id\n\t\t\t\t\t\t"); $submenu['options.php'] = array(); foreach ($option_groups as $option_group) { $submenu['options.php'][] = array($option_group->group_name, 6, "options.php?option_group_id={$option_group->group_id}"); } $submenu['options.php'][] = array(_LANG_WOP_PERM_LINKS, 9, 'options-permalink.php'); do_action('admin_menu', '');
function harvest($commentID) { global $wpdb; $tableblacklist = $GLOBALS['xoopsDB']->prefix("wp_blacklist"); $info = ''; $details = $wpdb->get_row("SELECT * FROM " . wp_table('comments') . " WHERE comment_ID = {$commentID}"); if ($details) { // Add author e-mail to blacklist - if it isn't blank if (!empty($details->comment_author_email)) { $buf = sanctify($details->comment_author_email); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','url')"); $info .= "Author e-mail: {$details->comment_author_email}\r\n"; } } // Add author IP to blacklist $buf = sanctify($details->comment_author_IP); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','ip')"); $info .= "Author IP: {$details->comment_author_IP}\r\n"; } // get the author's url without the prefix stuff - if it isn't blank if (!empty($details->comment_author_url)) { $regex = "/([a-z]*)(:\\/\\/)([a-z]*\\.)?(.*)/i"; preg_match($regex, $details->comment_author_url, $matches); if (strcasecmp('www.', $matches[3]) == 0) { $buf = $matches[4]; } else { $buf = $matches[3] . $matches[4]; } $buf = remove_trailer($buf); $buf = sanctify($buf); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','url')"); $info .= "Author URL: {$buf}\r\n"; } } // harvest links found in comment $regex = "/([a-z]*)(:\\/\\/)([a-z]*\\.)?([^\"><\\s]*)/im"; preg_match_all($regex, $details->comment_content, $matches); for ($i = 0; $i < count($matches[4]); $i++) { if (strcasecmp('www.', $matches[3][$i]) == 0) { $buf = $matches[4][$i]; } else { $buf = $matches[3][$i] . $matches[4][$i]; } $ps = strrpos($buf, '/'); if ($ps) { $buf = substr($buf, 0, $ps); } $buf = remove_trailer($buf); $buf = sanctify($buf); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','url')"); $info .= "Comment URL: {$buf}\r\n"; } } // for } return $info; }
function tkzy_get_recent_comments($limit = 10, $cat_date = 1, $show_type = 1) { $comment_lenth = 30; $request = "SELECT ID, post_title, post_date, \n\t\tcomment_ID, comment_author, comment_author_url, comment_author_email, comment_date, comment_content \n\t\tFROM " . wp_table('posts') . ", " . wp_table('comments') . " WHERE " . wp_table('posts') . ".ID=" . wp_table('comments') . ".comment_post_ID AND " . wp_table('comments') . ".comment_approved='1'"; if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) { $request .= "AND (comment_content like '<trackback />%' OR comment_content like '<pingkback />%') "; } $request .= " ORDER BY " . wp_table('comments') . ".comment_date DESC LIMIT {$limit}"; $lcomments = $GLOBALS['wpdb']->get_results($request); $output = ''; if ($lcomments) { usort($lcomments, "sort_comment_by_date"); } $new_post_ID = -1; if ($lcomments) { $output .= "<ul class='wpBlockList'>"; foreach ($lcomments as $lcomment) { if ($lcomment->ID != $new_post_ID) { // next post if ($new_post_ID != -1) { $output .= "\t</ul>\n</li>\n"; } $post_title = stripslashes($lcomment->post_title); if (trim($post_title) == "") { $post_title = _WP_POST_NOTITLE; } $comment_content = strip_tags($lcomment->comment_content); $comment_content = stripslashes($comment_content); if (function_exists('mb_substr')) { $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth); } else { $comment_excerpt = substr($comment_content, 0, $comment_lenth); } $permalink = wp_siteurl() . "/index.php?p={$lcomment->ID}&c=1"; $output .= "<li>"; $output .= "<span class='comment-title'><a href=\"{$permalink}\">{$post_title}</a></span>\n"; $output .= "\t<ul class=\"children\" style=\"list-style-type: none;\">\n"; $new_post_ID = $lcomment->ID; } $output .= "\t\t<li>"; if ($cat_date) { $comment_date = $lcomment->comment_date; if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) { # within 24 hours $comment_date = mysql2date('H:i', $comment_date); } else { $comment_date = mysql2date('m/d', $comment_date); } $output .= "<span class=\"post-date\">{$comment_date}</span> : "; } $output .= "<span class=\"comment_author\">" . tkzy_get_comment_author_link($lcomment, 25) . "</span></li>\n"; if (preg_match('|<trackback />|', $lcomment->comment_content)) { $type = '[TrackBack]'; } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) { $type = '[Ping]'; } else { $type = '[Comment]'; } if ($show_type) { $output .= "<span style=\"font-size:90%\"> - {$type}</span>"; } } } $output .= "\t</ul>\n</li>\n</ul>\n"; return $output; }
$_criteria =& new CriteriaCompo(new Criteria('comment_approved', '1 ')); $_criteria->add(new Criteria('post_status', 'publish')); $_criteria->add(new Criteria('post_date', date("Y-m-d H:i:s"), '<')); if (test_param('p')) { $_criteria->add(new Criteria('comment_post_ID', $GLOBALS['wp_post_id'])); } else { $_criteria->setOrder('DESC'); } $_criteria->setSort('comment_date'); $_criteria->setLimit(get_settings('posts_per_rss')); $_criteria->setStart(1); $_joinCriteria =& new XoopsJoinCriteria(wp_table('posts'), 'comment_post_id', 'ID'); $commentHandler =& wp_handler('Comment'); $commentObjects = $commentHandler->getObjects($_criteria, false, 'comment_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_content, comment_post_ID,' . wp_table('posts') . '.ID, ' . wp_table('posts') . '.post_password', false, $_joinCriteria); // this line is WordPress' motor, do not delete it. if ($commentObjects) { foreach ($commentObjects as $commentObject) { $GLOBALS['comment'] = $commentObject->exportWpObject(); ?> <item rdf:about="<?php permalink_comments_rss(); ?> "> <title>by: <?php comment_author_rss(); ?> </title> <link><?php comment_link_rss();
function _b_wp_contents_show($options, $wp_num = "") { $no_posts = empty($options[0]) ? 10 : $options[0]; $tpl_file = empty($options[1]) ? 'wp_contents.html' : $options[1]; $category = empty($options[2]) ? "all" : intval($options[2]); $GLOBALS['dateformat'] = get_settings('date_format'); $GLOBALS['timeformat'] = get_settings('time_format'); $_criteria = new CriteriaCompo(new Criteria('post_status', 'publish')); $_criteria->add(new Criteria('post_date', current_time('mysql'), '<=')); if (empty($category) || $category == 'all' || $category == '0') { $_joinCriteria = null; } else { $_joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'ID', 'post_id'); $_wCriteria =& new CriteriaCompo(); $_wCriteria->add(new Criteria('category_id', intCriteriaVal($category)), 'OR'); $_catc = trim(get_category_children($category, '', ' ')); if ($_catc !== "") { $_catc_array = explode(' ', $_catc); for ($_j = 0; $_j < count($_catc_array); $_j++) { $_wCriteria->add(new Criteria('category_id', intCriteriaVal($_catc_array[$_j])), 'OR'); } } $_criteria->add($_wCriteria); } $_criteria->setGroupBy(wp_table('posts') . '.ID'); $_criteria->setSort('post_date'); $_criteria->setOrder('DESC'); $_criteria->setLimit($no_posts); $_criteria->setStart(0); $postHandler =& wp_handler('Post'); $postObjects =& $postHandler->getObjects($_criteria, false, '', 'DISTINCT', $_joinCriteria); // echo $postHandler->getLastSQL(); $lposts = array(); foreach ($postObjects as $postObject) { $lposts[] =& $postObject->exportWpObject(); } if ($lposts) { // Get the categories for all the posts $_post_id_list = array(); foreach ($lposts as $post) { $_post_id_list[] = $post->ID; $GLOBALS['category_cache'][wp_id()][$post->ID] = array(); } $_post_id_list = implode(',', $_post_id_list); $_post_id_criteria =& new Criteria('post_id', '(' . $_post_id_list . ')', 'IN'); $_joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'ID', 'post_id'); $_joinCriteria->cascade(new XoopsJoinCriteria(wp_table('categories'), 'category_id', 'cat_ID')); $postObjects =& $postHandler->getObjects($_post_id_criteria, false, 'ID, category_id, cat_name, category_nicename, category_description, category_parent', true, $_joinCriteria); foreach ($postObjects as $postObject) { $_cat->ID = $postObject->getVar('ID'); $_cat->category_id = $postObject->getExtraVar('category_id'); $_cat->cat_name = $postObject->getExtraVar('cat_name'); $_cat->category_nicename = $postObject->getExtraVar('category_nicename'); $_cat->category_description = $postObject->getExtraVar('category_description'); $_cat->category_parent = $postObject->getExtraVar('category_parent'); $GLOBALS['category_cache'][wp_id()][$postObject->getVar('ID')][] =& $_cat; unset($_cat); } // Do the same for comment numbers $_post_id_criteria =& new Criteria('comment_post_ID', '(' . $_post_id_list . ')', 'IN'); $_criteria =& new CriteriaCompo(new Criteria('post_status', 'publish')); $_criteria->add(new Criteria('comment_approved', '1 ')); $_criteria->add($_post_id_criteria); $_criteria->setGroupBy('ID'); $_joinCriteria =& new XoopsJoinCriteria(wp_table('comments'), 'ID', 'comment_post_ID'); $postObjects =& $postHandler->getObjects($_criteria, false, 'ID, COUNT( comment_ID ) AS ccount', false, $_joinCriteria); foreach ($postObjects as $postObject) { $GLOBALS['comment_count_cache'][wp_id()]['' . $postObject->getVar('ID')] = $postObject->getExtraVar('ccount'); } // Get post-meta info if ($meta_list = $GLOBALS['wpdb']->get_results('SELECT post_id, meta_key, meta_value FROM ' . wp_table('postmeta') . ' WHERE post_id IN(' . $_post_id_list . ') ORDER BY post_id, meta_key', ARRAY_A)) { // Change from flat structure to hierarchical: $GLOBALS['post_meta_cache'][wp_id()] = array(); foreach ($meta_list as $metarow) { $mpid = $metarow['post_id']; $mkey = $metarow['meta_key']; $mval = $metarow['meta_value']; // Force subkeys to be array type: if (!isset($GLOBALS['post_meta_cache'][wp_id()][$mpid]) || !is_array($GLOBALS['post_meta_cache'][wp_id()][$mpid])) { $GLOBALS['post_meta_cache'][wp_id()][$mpid] = array(); } if (!isset($GLOBALS['post_meta_cache'][wp_id()][$mpid]["{$mkey}"]) || !is_array($GLOBALS['post_meta_cache'][wp_id()][$mpid]["{$mkey}"])) { $GLOBALS['post_meta_cache'][wp_id()][$mpid]["{$mkey}"] = array(); } // Add a value to the current pid/key: $GLOBALS['post_meta_cache'][wp_id()][$mpid]["{$mkey}"][] = $mval; } } } $blog = 1; $block = array(); $block['use_theme_template'] = get_xoops_option(wp_mod(), 'use_theme_template'); $block['style'] = block_style_get(false); $block['divid'] = 'wpBlockContent' . $wp_num; $block['template_content'] = ""; $i = 0; $GLOBALS['previousday'] = 0; foreach ($lposts as $post) { $GLOBALS['post'] = $post; if ($block['use_theme_template'] == 0) { $content = array(); start_wp(); $content['date'] = the_date($GLOBALS['dateformat'], '', '', false); $content['time'] = the_time('', false); $content['title'] = the_title('', '', false); $content['permlink'] = get_permalink(); $content['author'] = the_author_posts_link('', false); $content['category'] = the_category('', '', false); $content['body'] = the_content(_WP_TPL_MORE, 0, '', false); $content['linkpage'] = link_pages('<br />Pages: ', '<br />', 'number', 'next page', 'previous page', '%', '', false); if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 0) { $content['comments'] = comments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS, '', 'Comments Off', false); } else { $content['comments'] = xcomments_popup_link(_WP_TPL_COMMENT0, _WP_TPL_COMMENT1, _WP_TPL_COMMENTS, '', 'Comments Off', false); $content['comments'] .= " | "; $content['comments'] .= comments_popup_link(_WP_TPL_TRACKBACK0, _WP_TPL_TRACKBACK1, _WP_TPL_TRACKBACKS, '', 'Trackback Off', false); } $content['trackback'] = trackback_rdf(0, false); $block['contents'][] = $content; } else { ob_start(); include get_custom_path('content_block-template.php'); $block['template_content'] .= ob_get_contents(); ob_end_clean(); } } $_wpTpl =& new WordPresTpl('theme'); $_wpTpl->assign('block', $block); if (!$_wpTpl->tpl_exists($tpl_file)) { $tpl_file = 'wp_contents.html'; } $block['content'] = $_wpTpl->fetch($tpl_file); $GLOBALS['previousday'] = 0; $GLOBALS['day'] = 0; $GLOBALS['comment_count_cache'][wp_id()] = array(); return $block; }
function _b_wp_recent_posts_show($options, $wp_num = "") { $no_posts = empty($options[0]) ? 10 : $options[0]; $cat_date = empty($options[1]) ? 0 : $options[1]; $show_rss_icon = empty($options[2]) ? 0 : $options[2]; $show_rdf_icon = empty($options[3]) ? 0 : $options[3]; $show_rss2_icon = empty($options[4]) ? 0 : $options[4]; $show_atom_icon = empty($options[5]) ? 0 : $options[5]; $rss_num = empty($options[6]) ? "" : $options[6]; $category = intval(empty($options[7]) ? "all" : $options[7]); $new_flg = empty($options[8]) ? 0 : $options[8]; $tpl_file = empty($options[9]) ? 'wp_recent_posts.html' : $options[9]; $new1_span = 1 * 60 * 60 * 24; $new2_span = 7 * 60 * 60 * 24; if (empty($category) || $category == 'all' || $category == '0') { $whichcat = ''; $join = ''; $cat_param = ''; } else { $join = ' LEFT JOIN ' . wp_table('post2cat') . ' ON (' . wp_table('posts') . '.ID = ' . wp_table('post2cat') . '.post_id) '; $whichcat = ' AND (category_id = ' . $category . ')'; $cat_param = 'cat=' . $category; } $now = current_time('mysql'); $request = 'SELECT * FROM ' . wp_table('posts') . $join . ' WHERE post_status = \'publish\''; $request .= ' AND post_date <= \'' . $now . '\'' . $whichcat; $request .= ' ORDER BY post_date DESC LIMIT 0, ' . $no_posts; $lposts = $GLOBALS['wpdb']->get_results($request); $date = ""; $pdate = ""; $block['style'] = block_style_get(false); $block['divid'] = 'wpRecentPost' . $wp_num . '_' . $category; $block['cat_date'] = $cat_date; $block['records'] = array(); if ($lposts) { foreach ($lposts as $lpost) { if ($cat_date) { $date = mysql2date('Y-n-j', $lpost->post_date); if ($date != $pdate) { $_record['date'] = $date; $_record['pdate'] = $pdate; $pdate = $date; } else { $_record['date'] = ''; } } $_record['new'] = 0; $_record['newstr'] = ''; if ($new_flg) { $m = $lpost->post_date; $elapse = current_time('timestamp') - mktime(substr($m, 11, 2), substr($m, 14, 2), substr($m, 17, 2), substr($m, 5, 2), substr($m, 8, 2), substr($m, 0, 4)); if ($elapse < $new1_span) { $_record['new'] = 1; $_record['newstr'] = ' <span class="new1">New!</span>'; } else { if ($elapse < $new2_span) { $_record['new'] = 2; $_record['newstr'] = ' <span class="new2">New</span>'; } else { $_record['new'] = 0; $_record['newstr'] = ''; } } } $_record['post_title'] = htmlspecialchars($lpost->post_title); $_record['post_author'] = htmlspecialchars(get_author_name($lpost->post_author)); if (trim($_record['post_title']) == '') { $_record['post_title'] = _WP_POST_NOTITLE; } $_record['permalink'] = get_permalink($lpost->ID); $block['records'][] = $_record; } } $feed_param = $rss_num ? "?num=" . $rss_num : ""; $block['feed_icons'] = array(); if (empty($category) || $category == 'all' || $category == '0') { if ($show_rss_icon) { $block['feed_icons'][] = array('url' => get_bloginfo('rss_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss.gif', 'alt' => 'rss'); } if ($show_rdf_icon) { $block['feed_icons'][] = array('url' => get_bloginfo('rdf_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rdf.gif', 'alt' => 'rdf'); } if ($show_rss2_icon) { $block['feed_icons'][] = array('url' => get_bloginfo('rss2_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss2.gif', 'alt' => 'rss2'); } if ($show_atom_icon) { $block['feed_icons'][] = array('url' => get_bloginfo('atom_url') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/atom.gif', 'alt' => 'atom'); } } else { if ($show_rss_icon) { $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rss') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss.gif', 'alt' => 'rss'); } if ($show_rdf_icon) { $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rdf') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rdf.gif', 'alt' => 'rdf'); } if ($show_rss2_icon) { $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'rss2') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/rss2.gif', 'alt' => 'rss2'); } if ($show_atom_icon) { $block['feed_icons'][] = array('url' => get_category_rss_link(false, $category, "", 'atom') . $feed_param, 'icon' => wp_siteurl() . '/wp-images/atom.gif', 'alt' => 'atom'); } } $_wpTpl =& new WordPresTpl('theme'); $_wpTpl->assign('block', $block); if (!$_wpTpl->tpl_exists($tpl_file)) { $tpl_file = 'wp_recent_posts.html'; } $block['content'] = $_wpTpl->fetch($tpl_file); return $block; }
$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'); $resultSet =& $postHandler->open($_criteria, 'ID, COUNT( comment_ID ) AS ccount', false, $_joinCriteria); while ($postObject =& $postHandler->getNext($resultSet)) { $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;
function tkzy_get_recent_comments($limit = 10, $cat_date = 1, $show_type = 1) { $comment_lenth = 30; $request = 'SELECT ID, post_title, post_date, comment_ID, comment_author, comment_author_url, comment_author_email, comment_date, comment_content FROM ' . wp_table('posts') . ', ' . wp_table('comments') . ' WHERE ' . wp_table('posts') . '.ID=' . wp_table('comments') . '.comment_post_ID AND ' . wp_table('comments') . '.comment_approved=\'1\''; if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) { $request .= ' AND (comment_content like \'<trackback />%\' OR comment_content like \'<pingkback />%\') '; } $request .= ' ORDER BY ' . wp_table('comments') . '.comment_date DESC LIMIT ' . $limit; $lcomments = $GLOBALS['wpdb']->get_results($request); $output = ''; if ($lcomments) { usort($lcomments, 'sort_comment_by_date'); } $new_post_ID = -1; if ($lcomments) { $output .= '<ul class="wpBlockList">'; foreach ($lcomments as $lcomment) { if ($lcomment->ID != $new_post_ID) { // next post if ($new_post_ID != -1) { $output .= '</ul></li>'; } $post_title = stripslashes($lcomment->post_title); if (trim($post_title) == "") { $post_title = _WP_POST_NOTITLE; } $comment_content = strip_tags($lcomment->comment_content); $comment_content = stripslashes($comment_content); if (function_exists('mb_substr')) { $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth); } else { $comment_excerpt = substr($comment_content, 0, $comment_lenth); } $permalink = wp_siteurl() . '/index.php?p=' . $lcomment->ID . '&c=1'; $output .= '<li>'; $output .= '<span class="comment-title"><a href="' . $permalink . '">' . $post_title . '</a></span>'; $output .= '<ul class="children" style="list-style-type: none;">'; $new_post_ID = $lcomment->ID; } $output .= "\t\t<li>"; if ($cat_date) { $comment_date = $lcomment->comment_date; if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) { # within 24 hours $comment_date = mysql2date('H:i', $comment_date); } else { $comment_date = mysql2date('m/d', $comment_date); } $output .= '<span class="post-date">' . $comment_date . '</span> : '; } $output .= '<span class="comment_author">' . tkzy_get_comment_author_link($lcomment, 25) . '</span></li>'; if (preg_match('|<trackback />|', $lcomment->comment_content)) { $type = '[TrackBack]'; } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) { $type = '[Ping]'; } else { $type = '[Comment]'; } if ($show_type) { $output .= '<span style="font-size:90%"> - ' . $type . '</span>'; } } } $output .= '</ul></li></ul>'; return $output; }
function _b_wp_recent_comments_show($options, $wp_num = "") { $block_style = $options[0] ? $options[0] : 0; $num_of_list = !isset($options[1]) ? 10 : $options[1]; $show_rss_icon = !isset($options[2]) ? 0 : $options[2]; $cat_date = !isset($options[3]) ? $block_style ? 1 : 0 : $options[3]; $show_type = !isset($options[4]) ? 1 : $options[4]; $tpl_file = empty($options[5]) ? 'wp_recent_comments.html' : $options[5]; $block['style'] = block_style_get(false); $block['divid'] = 'wpRecentComment' . $wp_num; $block['block_style'] = $block_style; $block['cat_date'] = $cat_date; $block['show_type'] = $show_type; $comment_lenth = 30; if ($block_style == 0) { $skip_posts = 0; $request = "SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, comment_date, comment_type\n\t\t\t\t\t\tFROM " . wp_table('posts') . ", " . wp_table('comments') . "\n\t\t\t\t\t\tWHERE " . wp_table('posts') . ".ID=" . wp_table('comments') . ".comment_post_ID\n\t\t\t\t\t\tAND post_status = 'publish' AND comment_approved = '1' "; if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) { $request .= "AND (comment_content like '<trackback />%' \n\t\t\t\t OR comment_content like '<pingkback />%'\n\t\t\t\t OR comment_type = 'trackback'\n\t\t\t\t OR comment_type = 'pingback'\n\t\t\t\t ) "; } $request .= "ORDER BY " . wp_table('comments') . ".comment_date DESC LIMIT {$num_of_list}"; $lcomments = $GLOBALS['wpdb']->get_results($request); $output = ''; $pdate = ""; $block['records'] = array(); if ($lcomments) { foreach ($lcomments as $lcomment) { if ($cat_date) { $date = mysql2date("Y-n-j", $lcomment->comment_date); if ($date != $pdate) { $_record['date'] = $date; $_record['pdate'] = $pdate; $pdate = $date; } else { $_record['date'] = ''; } } if (empty($lcomment->comment_type)) { if (preg_match('|<trackback />|', $lcomment->comment_content)) { $type = '[TrackBack]'; } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) { $type = '[PingBack]'; } else { $type = '[Comment]'; } } else { if ($lcomment->comment_type == 'trackback') { $type = '[TrackBack]'; } elseif ($lcomment->comment_type == 'pingback') { $type = '[PingBack]'; } else { $type = '[Comment]'; } } $_record['comment_author'] = apply_filters('comment_author', $lcomment->comment_author); $_record['comment_author_link'] = _get_comment_author_link($lcomment, 25); $_record['comment_content'] = strip_tags($lcomment->comment_content); if (function_exists('mb_substr')) { $_record['comment_excerpt'] = mb_substr($_record['comment_content'], 0, $comment_lenth); } else { $_record['comment_excerpt'] = substr($_record['comment_content'], 0, $comment_lenth); } $_record['comment_excerpt'] = preg_replace('/([a-zA-Z0-9\\.\\/\\:\\%\\?\\-\\+\\&\\;]{15})/ms', '\\1​', $_record['comment_excerpt']); $_record['permalink'] = get_permalink($lcomment->ID) . '#comment-' . $lcomment->comment_ID; if ($show_type) { $_record['type'] = $type; } $block['records'][] = $_record; } } } else { $request = 'SELECT ID, post_title, post_date, comment_ID, comment_author, comment_author_url, comment_date, comment_content, comment_type FROM ' . wp_table('posts') . ', ' . wp_table('comments') . ' WHERE ' . wp_table('posts') . '.ID=' . wp_table('comments') . '.comment_post_ID AND ' . wp_table('comments') . '.comment_approved=\'1\''; if (get_xoops_option(wp_mod(), 'wp_use_xoops_comments') == 1) { $request .= "AND (comment_content like '<trackback />%' \n\t\t\t\t OR comment_content like '<pingkback />%'\n\t\t\t\t OR comment_type = 'trackback'\n\t\t\t\t OR comment_type = 'pingback'\n\t\t\t\t ) "; } $request .= ' ORDER BY ' . wp_table('comments') . '.comment_date DESC LIMIT ' . $num_of_list; $lcomments = $GLOBALS['wpdb']->get_results($request); $output = ''; if ($lcomments) { usort($lcomments, 'sort_comment_by_date'); } $new_post_ID = -1; $block['records'] = array(); if ($lcomments) { foreach ($lcomments as $lcomment) { $_record['new_post_ID'] = $new_post_ID; $_record['ID'] = $lcomment->ID; if ($lcomment->ID != $new_post_ID) { // next post $_record['post_title'] = $lcomment->post_title; if (trim($_record['post_title']) == "") { $_record['post_title'] = _WP_POST_NOTITLE; } $_record['comment_content'] = strip_tags($lcomment->comment_content); if (function_exists('mb_substr')) { $_record['comment_excerpt'] = mb_substr($_record['comment_content'], 0, $comment_lenth); } else { $_record['comment_excerpt'] = substr($_record['comment_content'], 0, $comment_lenth); } $_record['comment_excerpt'] = preg_replace('/([a-zA-Z0-9\\.\\/\\:\\?\\-\\+%&;]{15})/ms', '\\1​', $_record['comment_excerpt']); $_record['permalink'] = wp_siteurl() . '/index.php?p=' . $lcomment->ID . '&c=1'; $new_post_ID = $lcomment->ID; } if ($cat_date) { $comment_date = $lcomment->comment_date; if (time() - mysql2date('U', $comment_date) < 60 * 60 * 24) { # within 24 hours $_record['comment_date'] = mysql2date('H:i', $comment_date); } else { $_record['comment_date'] = mysql2date('m/d', $comment_date); } } $_record['comment_author'] = apply_filters('comment_author', $lcomment->comment_author); $_record['comment_author_link'] = _get_comment_author_link($lcomment, 25); if (empty($lcomment->comment_type)) { if (preg_match('|<trackback />|', $lcomment->comment_content)) { $type = '[TrackBack]'; } elseif (preg_match('|<pingback />|', $lcomment->comment_content)) { $type = '[PingBack]'; } else { $type = '[Comment]'; } } else { if ($lcomment->comment_type == 'trackback') { $type = '[TrackBack]'; } elseif ($lcomment->comment_type == 'pingback') { $type = '[PingBack]'; } else { $type = '[Comment]'; } } if ($show_type) { $_record['type'] = $type; } $block['records'][] = $_record; } } } if ($show_rss_icon) { $block['feed_icon'] = array('url' => get_bloginfo('comments_rss2_url'), 'icon' => wp_siteurl() . '/wp-images/rss_comment.gif', 'alt' => 'Comment RSS'); } else { $block['feed_icon'] = array(); } $_wpTpl =& new WordPresTpl('theme'); $_wpTpl->assign('block', $block); if (!$_wpTpl->tpl_exists($tpl_file)) { $tpl_file = 'wp_recent_comments.html'; } $block['content'] = $_wpTpl->fetch($tpl_file); return $block; }
function pingback_ping($m) { // original code by Mort // (http://mort.mine.nu:8080) global $wpdb; global $wp_version; if (!get_settings('use_pingback')) { return new xmlrpcresp(new xmlrpcval('Sorry, this weblog does not allow you to pingback its posts.')); } $title = ''; $pagelinkedfrom = $m->getParam(0); $pagelinkedfrom = $pagelinkedfrom->scalarval(); $pagelinkedto = $m->getParam(1); $pagelinkedto = $pagelinkedto->scalarval(); $pagelinkedfrom = addslashes(str_replace('&', '&', $pagelinkedfrom)); $pagelinkedto = preg_replace('#&([^amp\\;])#is', '&$1', $pagelinkedto); $messages = array(htmlentities('Pingback from ' . $pagelinkedfrom . ' to ' . $pagelinkedto . ' registered. Keep the web talking! :-)'), htmlentities("We can't find the URL to the post you are trying to " . "link to in your entry. Please check how you wrote the post's permalink in your entry."), htmlentities("We can't find the post you are trying to link to." . " Please check the post's permalink.")); $message = $messages[0]; // Check if the page linked to is in our site $pos1 = strpos($pagelinkedto, str_replace('http://', '', str_replace('www.', '', wp_siteurl()))); if ($pos1) { // let's find which post is linked to $urltest = parse_url($pagelinkedto); if ($post_ID = url_to_postid($pagelinkedto)) { $way = 'url_to_postid()'; } elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) { // the path defines the post_ID (archives/p/XXXX) $blah = explode('/', $match[0]); $post_ID = $blah[1]; $way = 'from the path'; } elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) { // the querystring defines the post_ID (?p=XXXX) $blah = explode('=', $match[0]); $post_ID = $blah[1]; $way = 'from the querystring'; } elseif (isset($urltest['fragment'])) { // an #anchor is there, it's either... if (intval($urltest['fragment'])) { // ...an integer #XXXX (simpliest case) $post_ID = $urltest['fragment']; $way = 'from the fragment (numeric)'; } elseif (preg_match('/post-[0-9]+/', $urltest['fragment'])) { // ...a post id in the form 'post-###' $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']); $way = 'from the fragment (post-###)'; } elseif (is_string($urltest['fragment'])) { // ...or a string #title, a little more complicated $title = preg_replace('/[^a-zA-Z0-9]/', '.', $urltest['fragment']); $sql = "SELECT ID FROM " . wp_table('posts') . " WHERE post_title RLIKE '" . addslashes($title) . "'"; $post_ID = $wpdb->get_var($sql) or die("Query: {$sql}\n\nError: "); $way = 'from the fragment (title)'; } } else { // TODO: Attempt to extract a post ID from the given URL $post_ID = -1; $way = 'no match'; } logIO('O', "(PB) URI='{$pagelinkedto}' ID='{$post_ID}' Found='{$way}'"); $sql = "SELECT post_author FROM " . wp_table('posts') . " WHERE ID = {$post_ID}"; $result = $wpdb->get_results($sql); if ($wpdb->num_rows) { // Let's check that the remote site didn't already pingback this entry $sql = 'SELECT * FROM ' . wp_table('comments') . ' WHERE comment_post_ID = ' . $post_ID . ' AND comment_author_url = \'' . $pagelinkedfrom . '\' AND comment_content LIKE \'%<pingback />%\''; $result = $wpdb->get_results($sql); if ($wpdb->num_rows || 1 == 1) { // very stupid, but gives time to the 'from' server to publish ! sleep(1); // Let's check the remote site require_once XOOPS_ROOT_PATH . '/class/snoopy.php'; $snoopy = new Snoopy(); if ($snoopy->fetch($pagelinkedfrom)) { $linea = $snoopy->results; } else { $linea = ''; } logIO('O', "(PB) CHARSET='" . $GLOBALS['blog_charset']); $linea = mb_conv($linea, $GLOBALS['blog_charset'], 'auto'); // Work around bug in strip_tags(): $linea = str_replace('<!DOCTYPE', '<DOCTYPE', $linea); $linea = strip_tags($linea, '<title><a>'); $linea = strip_all_but_one_link($linea, $pagelinkedto); // I don't think we need this? -- emc3 if (empty($matchtitle)) { preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle); } $pos2 = strpos($linea, $pagelinkedto); $pos3 = strpos($linea, str_replace('http://www.', 'http://', $pagelinkedto)); logIO('O', "(PB) POS='{$pos2}, {$pos3}'"); if (is_integer($pos2) || is_integer($pos3)) { //debug_fwrite($log, 'The page really links to us :)'."\n"); $pos4 = is_integer($pos2) ? $pos2 : $pos3; $start = $pos4 - 50; if (function_exists('mb_convert_encoding')) { $tmp1 = mb_strcut($linea, 0, $start, $GLOBALS['blog_charset']); } else { $tmp1 = substr($linea, 0, $start); } if (preg_match('/<[^>]*?$/', $tmp1, $match)) { logIO('O', "(PB) MATCH='{$match[0]}"); $offset = strlen($match[0]); } else { $offset = 0; } if (function_exists('mb_convert_encoding')) { $context = mb_strcut($linea, $start - $offset, 150 + $offset, $GLOBALS['blog_charset']); } else { $context = substr($linea, $star - $offsett, 150 + $offset); } $context = str_replace("\n", ' ', $context); $context = str_replace('&', '&', $context); logIO('O', "(PB) CONTENT='{$context}"); } else { logIO('O', "(PB) CONTEXT=The page doesn't link to us, here's an excerpt"); exit; } // fclose($fp); if (!empty($context)) { // Check if pings are on, inelegant exit $pingstatus = $wpdb->get_var("SELECT ping_status FROM " . wp_table('posts') . " WHERE ID = {$post_ID}"); if ('closed' == $pingstatus) { logIO('O', '(PB) Sorry, pings are turned off for this post.'); exit; } $pagelinkedfrom = preg_replace('#&([^amp\\;])#is', '&$1', $pagelinkedfrom); $title = !strlen($matchtitle[1]) ? $pagelinkedfrom : $matchtitle[1]; $context = strip_tags($context); $context = '<pingback />[...] ' . htmlspecialchars(trim($context)) . ' [...]'; $context = format_to_post($context); $original_pagelinkedfrom = $pagelinkedfrom; $pagelinkedfrom = addslashes($pagelinkedfrom); $original_title = $title; $title = addslashes(strip_tags(trim($title))); $now = current_time('mysql', 0); if (get_settings('comment_moderation') == 'manual') { $approved = 0; } else { if (get_settings('comment_moderation') == 'auto') { $approved = 0; } else { // none $approved = 1; } } $consulta = $wpdb->query("INSERT INTO " . wp_table('comments') . " \n\t\t\t\t\t\t(comment_post_ID, comment_author, comment_author_url, comment_date, comment_content,comment_approved, comment_type) \n\t\t\t\t\t\tVALUES \n\t\t\t\t\t\t({$post_ID}, '{$title}', '{$pagelinkedfrom}', '{$now}', '{$context}', '{$approved}', 'pingback')\n\t\t\t\t\t\t"); $comment_ID = $wpdb->get_var('SELECT last_insert_id()'); do_action('pingback_post', $comment_ID); if (get_settings('moderation_notify') && !$approved) { wp_notify_moderator($comment_ID, 'pingback'); } if (get_settings('comments_notify') && $approved) { wp_notify_postauthor($comment_ID, 'pingback'); } } else { // URL pattern not found $message = "Page linked to: {$pagelinkedto}\nPage linked from:" . " {$pagelinkedfrom}\nTitle: {$title}\nContext: {$context}\n\n" . $messages[1]; } } else { // We already have a Pingback from this URL $message = "Sorry, you already did a pingback to {$pagelinkedto} from {$pagelinkedfrom}."; } } else { // Post_ID not found $message = $messages[2]; //debug_fwrite($log, 'Post doesn\'t exist'."\n"); } } return new xmlrpcresp(new xmlrpcval($message)); }
?> )"><?php the_author_nickname(); ?> </a>)</cite>, in <strong><?php the_category(); ?> </strong><br /> <?php the_content(); ?> </p> <?php // comments if (test_param('withcomments') or test_param('c')) { $comments = $wpdb->get_results("SELECT * FROM " . wp_table('comments') . " WHERE comment_post_ID = {$wp_post_id} ORDER BY comment_date"); if ($comments) { ?> <h3><?php echo _LANG_E_TITLE_COMMENTS; ?> </h3> <ol id="comments"> <?php foreach ($comments as $comment) { ?> <!-- comment --> <li> <?php
<?php require_once '../wp-config.php'; require_once 'auth.php'; require_once '../wp-includes/wpblfunctions.php'; $title = _('WPBlacklist - Moderate'); $parent_file = 'wpblacklist.php'; init_param('POST', 'btndeladd', 'string', ''); init_param('POST', 'btndel', 'string', ''); init_param('POST', 'btnapprove', 'string', ''); init_param('POST', 'delete_comments', 'array', ''); $GLOBALS['standalone'] = 0; require_once 'admin-header.php'; $tableblacklist = $xoopsDB->prefix("wp_blacklist"); $tablecomments = wp_table('comments'); $tableposts = wp_table('posts'); //Check User_Level user_level_check(); ?> <script type="text/javascript"> <!-- function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].checked == true) form.elements[i].checked = false; else form.elements[i].checked = true; } }
<div class="wrap"><?php echo $message; ?> </div> <?php } $option_groups = $wpdb->get_results("SELECT group_id, group_name, group_desc, group_longdesc FROM " . wp_table('optiongroups') . " WHERE group_id = {$option_group_id} "); $current_long_desc = $option_groups[0]->group_longdesc; $current_desc = $option_groups[0]->group_desc; if (defined($current_desc)) { $current_desc = constant($current_desc); } include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; $form = new XoopsThemeForm($current_desc, "form", $this_file); //Now display all the options for the selected group. $options = $wpdb->get_results("SELECT " . wp_table('options') . ".option_id, option_name, option_type, option_value, option_width, option_height, option_description, option_admin_level " . "FROM " . wp_table('options') . " " . "LEFT JOIN " . wp_table('optiongroup_options') . " ON " . wp_table('options') . ".option_id = " . wp_table('optiongroup_options') . ".option_id " . "WHERE group_id = {$option_group_id} " . "ORDER BY seq"); if ($options) { foreach ($options as $option) { $form->addElement(get_option_formElement($option, $user_level >= $option->option_admin_level)); } } $form->addElement(new XoopsFormButton("", "Update", _LANG_WOP_SUBMIT_TEXT, "submit")); $form->addElement(new XoopsFormHidden("option_group_id", $option_group_id)); $form->addElement(new XoopsFormHidden("action", "update")); $form->display(); ?> <div class="wrap"> <?php if ($current_long_desc != '') { echo $current_long_desc; } else {
function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { $order = strtolower($order); $direction = ''; // Handle link category sorting if (substr($order, 0, 1) == '_') { $direction = ' DESC'; $order = substr($order, 1); } // if 'name' wasn't specified, assume 'id': $cat_order = 'name' == $order ? 'cat_name' : 'cat_id'; // Fetch the link category data as an array of hashes $cats = $GLOBALS['wpdb']->get_results("SELECT DISTINCT link_category, cat_name, show_images,\n\t\tshow_description, show_rating, show_updated, sort_order, sort_desc, list_limit\nFROM `" . wp_table('links') . "` LEFT JOIN `" . wp_table('linkcategories') . "` ON (link_category = cat_id)\nWHERE link_visible = 'Y'\n\t\tORDER BY {$cat_order} {$direction} ", ARRAY_A); // Display each category if ($cats) { foreach ($cats as $cat) { // Handle each category. // First, fix the sort_order info $orderby = $cat['sort_order']; $orderby = (bool_from_yn($cat['sort_desc']) ? '_' : '') . $orderby; // Display the category name $cat_id = sanitize_title($cat['cat_name']); if ($cat_id == "") { $cat_id = "lcat-" . $cat['link_category']; } echo ' <li id="' . sanitize_title($cat['cat_name']) . '">' . stripslashes($cat['cat_name']) . "\n\t<ul>\n"; // Call get_links() with all the appropriate params get_links($cat['link_category'], '<li>', "</li>", "\n", bool_from_yn($cat['show_images']), $orderby, bool_from_yn($cat['show_description']), bool_from_yn($cat['show_rating']), $cat['list_limit'], bool_from_yn($cat['show_updated'])); // Close the last category echo "\n\t</ul>\n</li>\n"; } } }
$LinkColor = "#0000FF"; //コメントの表示順 //$CommentSort = "ASC"; //古いものから表示 $CommentSort = "DESC"; //新しいものから表示 //XOOPSのSESSIONを使用してコメント投稿にチケットを使用する。 if (defined('XOOPS_URL')) { $UseSession = true; } // 設定値(ここまで) // ---------------------------------------------------------------- ini_set('display_errors', '1'); ini_set('error_reporting', E_ALL); if (defined('XOOPS_URL')) { $tableposts = wp_table('posts'); $tablecomments = wp_table('comments'); } else { $siteurl = get_settings('home'); } $myurl = $siteurl . '/' . basename(__FILE__); if (preg_match('/DoCoMo/', $HTTP_USER_AGENT)) { $ua_list = explode("/", $HTTP_USER_AGENT); $is_docomo = substr($ua_list[3], 1); $is_docomo = $is_docomo * 1024; } else { $is_docomo = 0; } if ($UseSession) { $ses_param = SID ? '&' . SID : ''; $do_redir = true; } else {
function get_lastcommentmodified($p = 0, $name = '') { static $cache_lastcommentmodified; if (!isset($cache_lastcommentmodified[wp_id()][$p]) || !$GLOBALS['use_cache']) { $_criteria =& new CriteriaCompo(new Criteria('comment_approved', '1 ')); $_criteria->add(new Criteria('post_status', 'publish')); $_criteria->add(new Criteria('post_date', current_time('mysql'), '<=')); if ($p > 0) { $_criteria->add(new Criteria('comment_post_ID', $p)); } else { if ($p == -1) { $_criteria->add(new Criteria(wp_table('posts') . '.post_name', $name)); } } $_criteria->setOrder('DESC'); $_criteria->setSort('comment_date'); $_criteria->setLimit(1); $_joinCriteria =& new XoopsJoinCriteria(wp_table('posts'), 'comment_post_id', 'ID'); $commentHandler =& wp_handler('Comment'); $commentObjects = $commentHandler->getObjects($_criteria, false, 'comment_date', false, $_joinCriteria); $cache_lastcommentmodified[wp_id()][$p] = $lastcommentmodified = $commentObjects[0]->getVar('comment_date'); } else { $lastcommentmodified = $cache_lastcommentmodified[wp_id()][$p]; } return $lastcommentmodified; }
?> <em><?php trackback_url(); ?> </em></p> <?php } ?> <?php // this line is WordPress' motor, do not delete it. $comment_author = isset($_COOKIE['comment_author_' . $cookiehash]) ? trim($_COOKIE['comment_author_' . $cookiehash]) : ''; $comment_author_email = isset($_COOKIE['comment_author_email_' . $cookiehash]) ? trim($_COOKIE['comment_author_email_' . $cookiehash]) : ''; $comment_author_url = isset($_COOKIE['comment_author_url_' . $cookiehash]) ? trim($_COOKIE['comment_author_url_' . $cookiehash]) : ''; $comments = $wpdb->get_results("SELECT * FROM " . wp_table('comments') . " WHERE comment_post_ID = {$id} AND comment_approved = '1' ORDER BY comment_date"); $commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM " . wp_table('posts') . " WHERE ID = {$id}"); if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_' . $cookiehash] != $commentstatus->post_password) { // and it doesn't match the cookie echo get_the_password_form(); } else { ?> <?php if ($comments) { ?> <ol id="commentlist"> <?php foreach ($comments as $comment) { ?> <li id="comment-<?php comment_ID();
function _b_wp_recent_posts_show($options, $wp_num = "") { $no_posts = empty($options[0]) ? 10 : $options[0]; $cat_date = empty($options[1]) ? 0 : $options[1]; $show_rss_icon = empty($options[2]) ? 0 : $options[2]; $show_rdf_icon = empty($options[3]) ? 0 : $options[3]; $show_rss2_icon = empty($options[4]) ? 0 : $options[4]; $show_atom_icon = empty($options[5]) ? 0 : $options[5]; $rss_num = empty($options[6]) ? "" : $options[6]; $category = intval(empty($options[7]) ? "all" : $options[7]); $new_flg = empty($options[8]) ? 0 : $options[8]; global $wpdb; if (empty($category) || $category == 'all' || $category == '0') { $whichcat = ''; $join = ''; $cat_param = ''; } else { $join = ' LEFT JOIN ' . wp_table('post2cat') . ' ON (' . wp_table('posts') . '.ID = ' . wp_table('post2cat') . '.post_id) '; $whichcat = ' AND (category_id = ' . $category . ')'; $cat_param = 'cat=' . $category; } $now = date('Y-m-d H:i:s', time() + get_settings('time_difference') * 3600); $request = 'SELECT * FROM ' . wp_table('posts') . $join . ' WHERE post_status = \'publish\''; $request .= ' AND post_date <= \'' . $now . '\'' . $whichcat; $request .= ' ORDER BY post_date DESC LIMIT 0, ' . $no_posts; $lposts = $wpdb->get_results($request); $date = ""; $pdate = ""; ob_start(); block_style_get(); $output = ob_get_contents(); ob_end_clean(); $output .= '<div class="wpRecentPost">'; if ($lposts) { if (!$cat_date) { $output .= '<ul class="wpBlockList">' . "\n"; } else { $output .= '<ul class="wpBlockDateList">' . "\n"; } foreach ($lposts as $lpost) { if ($cat_date) { $date = mysql2date('Y-n-j', $lpost->post_date); if ($date != $pdate) { if ($pdate != "") { $output .= '</ul></li>' . "\n"; } $output .= '<li><span class="postDate">' . $date . '</span>' . "\n" . '<ul class="children">' . "\n"; $pdate = $date; } } $newstr = ""; if ($new_flg) { $m = $lpost->post_date; $elapse = time() + get_settings('time_difference') * 3600 - mktime(substr($m, 11, 2), substr($m, 14, 2), substr($m, 17, 2), substr($m, 5, 2), substr($m, 8, 2), substr($m, 0, 4)); if ($elapse < 1 * 60 * 60 * 24) { $newstr = ' <span class="new1">New!</span>'; } else { if ($elapse < 7 * 60 * 60 * 24) { $newstr = ' <span class="new2">New</span>'; } else { $newstr = ''; } } } $post_title = stripslashes($lpost->post_title); if (trim($post_title) == "") { $post_title = _WP_POST_NOTITLE; } $permalink = get_permalink($lpost->ID); $output .= '<li><span class="post-title"><a href="' . $permalink . '" rel="bookmark" title="Permanent Link: ' . $post_title . '">' . $post_title . '</a></span>' . $newstr . '<br />'; $output .= '</li>' . "\n"; } $output .= '</ul>' . "\n"; if ($cat_date) { $output .= '</li></ul>' . "\n"; } } if ($show_rss_icon || $show_rdf_icon || $show_rss2_icon || $show_atom_icon) { $output .= '<hr width="100%" />'; } $feed_param = $rss_num ? "?num=" . $rss_num : ""; if (empty($category) || $category == 'all' || $category == '0') { if ($show_rss_icon) { $output .= '<div style="text-align:right"> <a href="' . get_bloginfo('rss_url') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rss.gif" alt="rss" /></a></div>'; } if ($show_rdf_icon) { $output .= '<div style="text-align:right"> <a href="' . get_bloginfo('rdf_url') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rdf.gif" alt="rdf" /></a></div>'; } if ($show_rss2_icon) { $output .= '<div style="text-align:right"> <a href="' . get_bloginfo('rss2_url') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rss2.gif" alt="rss2" /></a></div>'; } if ($show_atom_icon) { $output .= '<div style="text-align:right"> <a href="' . get_bloginfo('atom_url') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/atom.gif" alt="atom" /></a></div>'; } } else { if ($show_rss_icon) { $output .= '<div style="text-align:right"> <a href="' . get_category_rss_link(false, $category, "", 'rss') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rss.gif" alt="rss" /></a></div>'; } if ($show_rdf_icon) { $output .= '<div style="text-align:right"> <a href="' . get_category_rss_link(false, $category, "", 'rdf') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rdf.gif" alt="rdf" /></a></div>'; } if ($show_rss2_icon) { $output .= '<div style="text-align:right"> <a href="' . get_category_rss_link(false, $category, "", 'rss2') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/rss2.gif" alt="rss2" /></a></div>'; } if ($show_atom_icon) { $output .= '<div style="text-align:right"> <a href="' . get_category_rss_link(false, $category, "", 'atom') . $feed_param . '"><img src="' . wp_siteurl() . '/wp-images/atom.gif" alt="atom" /></a></div>'; } } $output .= "</div>"; $block['content'] = $output; return $block; }