} else { $order = 'asc'; } if ($xpress_config->is_d3forum_desc) { $order = 'desc'; } else { $order = 'asc'; } if ($xpress_config->is_d3forum_flat) { $view = 'listposts_flat'; } else { $view = 'listtopics'; } $posts_num = $xpress_config->d3forum_views_num; // force UPDATE forums.forum_external_link_format "(dirname)::(classname)::(trustdirname)" $xoops_db->query("UPDATE " . get_xoops_prefix() . $dir_name . "_forums SET forum_external_link_format='" . $external_link_format . "' WHERE forum_id= {$forum_id}"); $d3comment =& new xpressD3commentContent($dir_name, $xpress_dirname); $post_title = get_the_title(); if (function_exists('get_the_ID')) { // upper wordpress 2.1 $post_id = get_the_ID(); } else { // lower wordpress 2.1 ob_start(); the_ID(); $post_id = ob_get_contents(); ob_end_clean(); } if (empty($_GET['p'])) { $_GET['p'] = $post_id; }
function wp_comment_author_to_xoops_uid($name = '', $email = '') { global $xoopsDB, $xoops_db; if (empty($name) || empty($email)) { return 0; } if (empty($xoops_db)) { // not load XPressME $xoops_user_tbl = $xoopsDB->prefix('users'); $wp_user_tbl = $xoopsDB->prefix($wp_prefix . "_users"); $xoops_uid = 0; $xoops_user_SQL = "SELECT uid FROM {$xoops_user_tbl} WHERE uname = '{$name}' AND email = '{$email}'"; $xoops_user_Res = $xoopsDB->query($xoops_user_SQL, 0, 0); if ($xoopsDB->getRowsNum($xoops_user_Res) > 0) { $xoops_user_Row = $xoopsDB->fetchArray($xoops_user_Res); $xoops_uid = $xoops_user_Row['uid']; } return $xoops_uid; } else { // load XPressME or not Load XOOPS $xoops_user_tbl = get_xoops_prefix() . 'users'; $xoops_uid = $xoops_db->get_var("SELECT uid FROM {$xoops_user_tbl} WHERE uname = '{$name}' AND email = '{$email}'"); if (empty($xoops_uid)) { return 0; } return $xoops_uid; } }
function xpress_unnecessary_block_cache_delete($mydirname) { global $xoops_db, $xoops_config; $mid = get_xpress_modid(); $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = {$mid} AND visible = 1"; $blocks = $xoops_db->get_results($sql); require_once get_xpress_dir_path() . '/include/xpress_block_render.php'; $pattern = $mydirname . '_block_header'; foreach ($blocks as $block) { $cache_file_name = $mydirname . '_' . str_replace(".php", "", $block->func_file) . $block->bid; if (!empty($pattern)) { $pattern .= '|'; } $pattern .= $cache_file_name; } $pattern = '(' . $pattern . ')'; $cache_dir = $xoops_config->xoops_cache_path . '/'; $cache_time = 0; if ($dh = opendir($cache_dir)) { while (($file = readdir($dh)) !== false) { if (preg_match('/^' . preg_quote($mydirname) . '_/', $file)) { if (!preg_match('/' . $pattern . '/', $file)) { unlink($cache_dir . $file); } } } closedir($dh); } }
function d3forum_option($do_message = '') { global $xoops_db, $xoops_config; $multi_blog_use_d3forum = true; $d3frum_list = array(); $module_dir_path = get_xoops_root_path(); $forum_list = '<select name="ch_d3forum">' . "\n"; if ($this->is_use_d3forum != true) { $selected = ' selected="selected"'; } else { $selected = ''; } if (xpress_is_multiblog() && !$multi_blog_use_d3forum) { $forum_list .= '<option value="none"' . $selected . '>' . __('WordPress MultiBlog cannot integrate the comments.', 'xpressme') . "</option>\n"; } else { $forum_list .= '<option value="none"' . $selected . '>' . __('Do Not Comment Integration.', 'xpressme') . "</option>\n"; // Form making for forum selection of D3forum $modules_table = get_xoops_prefix() . 'modules'; $sql = "SELECT mid,name,isactive,dirname FROM {$modules_table} WHERE isactive = 1"; $modules = $xoops_db->get_results($sql); foreach ($modules as $module) { $file_path = $module_dir_path . '/modules/' . $module->dirname . '/mytrustdirname.php'; if (!file_exists($file_path)) { continue; } $array_files = file($file_path); // It is checked whether there is character string "$mytrustdirname ='d3forum'"in the file. foreach ($array_files as $aeey_file) { if (preg_match("/\\s*(mytrustdirname)\\s*(=)\\s*([\"'])(d3forum)([\"'])/", $aeey_file)) { $forums_tb = get_xoops_prefix() . $module->dirname . '_forums'; $cat_tb = get_xoops_prefix() . $module->dirname . '_categories'; $cat_sql = "SELECT * FROM {$cat_tb}"; $cats = $xoops_db->get_results($cat_sql); foreach ($cats as $cat) { $sql = "SELECT * FROM {$forums_tb} WHERE {$forums_tb}.cat_id = {$cat->cat_id}"; $forums = $xoops_db->get_results($sql); foreach ($forums as $forum) { if ($module->dirname == $this->d3forum_module_dir && $forum->forum_id == $this->d3forum_forum_id) { $selected = ' selected="selected"'; $forum_div = 'forum|' . $module->dirname . '|' . $forum->forum_id; $forum_select = "{$module->name}({$module->dirname}) {$cat->cat_title}-{$forum->forum_title}(ID={$forum->forum_id})"; $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n"; } else { if (empty($forum->forum_external_link_format)) { $selected = ''; $forum_div = 'forum|' . $module->dirname . '|' . $forum->forum_id; $forum_select = "{$module->name}({$module->dirname}) {$cat->cat_title}-{$forum->forum_title}(ID={$forum->forum_id})"; $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n"; } } } $selected = ''; $forum_div = 'forum|' . $module->dirname . '|Create New In Cat=' . $cat->cat_id; $forum_select = "{$module->name}({$module->dirname}) {$cat->cat_title}-" . __('Create New Forum', 'xpressme'); $forum_list .= '<option value="' . $forum_div . '" ' . $selected . '>' . $forum_select . "</option>\n"; } break; } } $forum_list .= '<br>'; } } $forum_list .= '</select>' . "\n"; $form = '<tr>' . "\n"; $form .= '<th><label for="d3forum">' . __('Comment integration with D3Forum', 'xpressme') . '</label></th>' . "\n"; $form .= "<td>\n"; $form .= __('Select the forum of D3Forum that does the comment integration from the following lists.', 'xpressme') . "<br />\n"; $form .= $forum_list . "\n"; $form .= '<br /><br />'; if ($this->is_use_d3forum) { if ($this->is_use_d3forum) { $disible = ''; } else { $disible = 'disabled'; } $form .= __('Select the Type of display of D3Forum comment.', 'xpressme') . " \n&emsp"; if ($this->is_d3forum_flat) { $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_flat' value='1' checked='checked' />" . __('Flat', 'xpressme') . "</label>\n"; $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_flat' value='0' />" . __('Threaded', 'xpressme') . "</label>\n"; } else { $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_flat' value='1' />" . __('Flat', 'xpressme') . "</label>\n"; $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_flat' value='0' checked='checked' />" . __('Threaded', 'xpressme') . "</label>\n"; } $form .= '<br />'; $form .= __('Select the order of display of D3Forum comment.', 'xpressme') . " \n&emsp"; if ($this->is_d3forum_desc) { $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_desc' value='1' checked='checked' />" . __('DESC', 'xpressme') . "</label>\n"; $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_desc' value='0' />" . __('ASC', 'xpressme') . "</label>\n"; } else { $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_desc' value='1' />" . __('DESC', 'xpressme') . "</label>\n"; $form .= "&ensp<label><input type='radio' name='ch_is_d3forum_desc' value='0' checked='checked' />" . __('ASC', 'xpressme') . "</label>\n"; } $form .= '<br />'; $form .= __('Number of displays of D3Forum comments.', 'xpressme') . " \n"; $form .= '&emsp<label> <input name="ch_d3forum_views_num" type="text" size="3" maxlength="3" value="' . $this->d3forum_views_num . '" /></label>' . "\n"; $form .= '<div class="submit">' . "\n"; $form .= __('The import and the export between Wordpress Comments and the D3Forum Posts can be done. ', 'xpressme') . "<br />\n"; $form .= '<input type="submit" value= "' . __('Export to D3Forum', 'xpressme') . '" name="export_d3f" ' . $disible . ' >' . "\n"; $form .= '<input type="submit" value= "' . __('Import from D3Forum', 'xpressme') . '" name="inport_d3f" ' . $disible . ' >' . "<br />\n"; $form .= '</div>' . "\n"; if (!empty($do_message)) { $form .= '<div>' . $do_message . '</div>'; } } $form .= "</td>\n"; $form .= "</tr><tr>\n"; return $form; }
function user_sync_to_xoops($user_ID) { global $xoops_db; $user_info = get_userdata($user_ID); $xoops_uid = get_xoops_user_id($user_info->user_login); $db_xoops_users = get_xoops_prefix() . "users"; $user_regdate = strtotime($user_info->user_registered); $aim = get_usermeta($user_ID, 'aim'); $yim = get_usermeta($user_ID, 'yim'); if ($xoops_uid) { $wu_sql = "UPDATE {$db_xoops_users} "; $wu_sql .= 'SET '; $wu_sql .= "uname = '{$user_info->user_login}', "; $wu_sql .= "pass = '******', "; $wu_sql .= "email = '{$user_info->user_email}', "; $wu_sql .= "url = '{$user_info->user_url}', "; $wu_sql .= "name = '{$user_info->display_name}', "; $wu_sql .= "user_aim = '{$aim}', "; $wu_sql .= "user_yim = '{$yim}', "; $wu_sql .= "user_regdate = {$user_regdate} "; $wu_sql .= "WHERE (uid = {$xoops_uid} )"; $xoops_db->query($wu_sql); } else { $wu_sql = "INSERT INTO {$db_xoops_users} "; $wu_sql .= "(uname , pass ,email , url , name , user_aim , user_yim , user_regdate) "; $wu_sql .= "VALUES "; $wu_sql .= "('{$user_info->user_login}', '{$user_info->user_pass}', '{$user_info->user_email}', '{$user_info->user_url}', '{$user_info->display_name}' "; $wu_sql .= " , '{$aim}' , '{$yim}' , {$user_regdate} )"; $xoops_db->query($wu_sql); // get xoops users default groupe ID $db_xoops_group = get_xoops_prefix() . 'groups'; $default_xoops_group_id = $xoops_db->get_var("SELECT groupid FROM {$db_xoops_group} WHERE group_type = 'User'"); // get insert users ID $db_xoops_group = get_xoops_prefix() . 'users'; $user_id = $xoops_db->get_var("SELECT uid FROM {$db_xoops_group} WHERE uname = '{$user_info->user_login}'"); // insert groups_users_link $db_xoops_group_users_link = get_xoops_prefix() . 'groups_users_link'; $default_xoops_group_id = $xoops_db->get_var("INSERT INTO {$db_xoops_group_users_link} (groupid , uid ) VALUES ({$default_xoops_group_id} , {$user_id})"); } }
function wp_d3forum_transact_make_post_history($d3forum_dirname, $post_id, $full_backup = false) { global $xoops_db; $d3forum_prefix = get_xoops_prefix() . $d3forum_dirname . '_'; $post_id = intval($post_id); $results = $xoops_db->get_results("SELECT * FROM " . $d3forum_prefix . "posts WHERE post_id={$post_id}"); if (empty($results)) { return; } $post_row = $results; $data = array(); $indexes = $full_backup ? array_keys($post_row) : array('subject', 'post_text'); foreach ($indexes as $index) { $data[$index] = $post_row[$index]; } // check the latest data in history $old_data_serialized = $xoops_db->get_var("SELECT data FROM " . $d3forum_prefix . "post_histories WHERE post_id={$post_id} ORDER BY history_time DESC"); if (!empty($old_data_serialized)) { $old_data = unserialize($old_data_serialized); if ($old_data == $data) { return; } } $xoops_db->query("INSERT INTO " . $d3forum_prefix . "post_histories SET post_id={$post_id}, history_time=UNIX_TIMESTAMP(), data='" . mysql_real_escape_string(serialize($data)) . "'"); }
<?php /* Plugin Name: Plugin for XPressME Plugin URI: http://ja.xpressme.info Description: Plugin for XPressME (custom function,filter,action) Author: toemon Version: 1.0 Author URI: http://ja.xpressme.info */ require_once 'xpressme_class.php'; require_once dirname(__FILE__) . '/include/custom_functions.php'; // XPressME functions for themes require_once dirname(__FILE__) . '/include/xpress_common_functions.php'; $xoops_db = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); $xoops_db->prefix = get_xoops_prefix(); $xoops_db->tables = array('modules', 'newblocks', 'users'); $xpress_config = new XPressME_Class(); require_once dirname(__FILE__) . '/include/pluggable-override.php'; require_once dirname(__FILE__) . '/include/functions_for_wp_old.php'; if (!is_wordpress_style() && (!empty($xpress_config->theme_select) || $xpress_config->theme_select != 'use_wordpress_select')) { add_filter('stylesheet', 'xpress_Stylesheet'); add_filter('template', 'xpress_ThemeTemplate'); } function xpress_Stylesheet($stylesheet) { global $xpress_config; $theme = $xpress_config->theme_select; $theme = get_theme($theme); if (empty($theme)) { return $stylesheet;
function block_cache_refresh() { global $xoops_db; $mid = get_xpress_modid(); $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = {$mid}"; $blocks = $xoops_db->get_results($sql); $mydirname = get_xpress_dir_name(); require_once get_xpress_dir_path() . '/include/xpress_block_render.php'; foreach ($blocks as $block) { $func_file = $block->func_file; // Avoid the failure of the operation when switch_to_blog() and other plugin code is called on the admin page. $excludes = 'global_recent_posts_list_block\\.php|enhanced_block\\.php|global_recent_comments_block\\.php|global_popular_posts_block\\.php'; if (preg_match('/' . $excludes . '/', $func_file)) { continue; } $call_theme_function_name = str_replace(".php", "", $func_file); $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php'; $cache_title = str_replace(".php", "", $func_file); $blockID = $block->bid; $options = explode("|", $block->options); $block_theme_file = get_block_file_path($mydirname, $inc_theme_file_name); require_once $block_theme_file['file_path']; $block_render = $call_theme_function_name($options); //The block name and the called function name should be assumed to be the same name. $xml['block'] = $block_render; $xml['block']['options'] = $block->options; xpress_block_cache_write($mydirname, $cache_title . $blockID, $xml); } }