function b_sitemap_d3forum($mydirname)
{
    $db =& Database::getInstance();
    $myts =& MyTextSanitizer::getInstance();
    $ret = array();
    include_once dirname(__FILE__) . '/common_functions.php';
    $whr_forum = 'forum_id IN (' . implode(',', d3forum_get_forums_can_read($mydirname)) . ')';
    $sql = "SELECT forum_id,forum_title FROM " . $db->prefix($mydirname . "_forums") . " WHERE ({$whr_forum})";
    $result = $db->query($sql);
    while (list($forum_id, $forum_title) = $db->fetchRow($result)) {
        $ret["parent"][] = array("id" => intval($forum_id), "title" => $myts->makeTboxData4Show($forum_title), "url" => "index.php?forum_id=" . intval($forum_id));
    }
    return $ret;
}
 function d3forum_notify_base($mydirname, $category, $item_id)
 {
     include_once dirname(__FILE__) . '/include/common_functions.php';
     $db =& Database::getInstance();
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($mydirname);
     if ($category == 'global') {
         $item['name'] = '';
         $item['url'] = '';
         return $item;
     }
     if ($category == 'category') {
         // Assume we have a valid cat_id
         $whr_cat = 'cat_id IN (' . implode(',', d3forum_get_categories_can_read($mydirname)) . ')';
         $sql = 'SELECT cat_title FROM ' . $db->prefix($mydirname . '_categories') . ' WHERE cat_id=' . $item_id . " AND ({$whr_cat})";
         $result = $db->query($sql);
         $result_array = $db->fetchArray($result);
         $item['name'] = $result_array['cat_title'];
         $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/index.php?cat_id=' . $item_id;
         return $item;
     }
     if ($category == 'forum') {
         // Assume we have a valid forum_id
         $whr_forum = 'forum_id IN (' . implode(',', d3forum_get_forums_can_read($mydirname)) . ')';
         $sql = 'SELECT forum_title FROM ' . $db->prefix($mydirname . '_forums') . ' WHERE forum_id=' . $item_id . " AND ({$whr_forum})";
         $result = $db->query($sql);
         $result_array = $db->fetchArray($result);
         $item['name'] = $result_array['forum_title'];
         $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/index.php?forum_id=' . $item_id;
         return $item;
     }
     if ($category == 'topic') {
         // Assume we have a valid topid_id
         $whr_forum = 'forum_id IN (' . implode(',', d3forum_get_forums_can_read($mydirname)) . ')';
         $sql = 'SELECT topic_title FROM ' . $db->prefix($mydirname . '_topics') . ' WHERE topic_id=' . $item_id . " AND ({$whr_forum})";
         $result = $db->query($sql);
         $result_array = $db->fetchArray($result);
         $item['name'] = $result_array['topic_title'];
         $item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/index.php?topic_id=' . $item_id;
         return $item;
     }
 }
 function d3forum_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid)
 {
     $myts =& MyTextsanitizer::getInstance();
     $db =& Database::getInstance();
     $andor = strtoupper($andor);
     $userid = intval($userid);
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "p.post_text" : "'' AS post_text";
     require_once dirname(__FILE__) . '/include/common_functions.php';
     $whr_forum = "t.forum_id IN (" . implode(",", d3forum_get_forums_can_read($mydirname)) . ")";
     $whr_uid = $userid > 0 ? "p.uid={$userid}" : "1";
     $whr_query = $andor == 'OR' ? '0' : '1';
     if (is_array($keywords)) {
         foreach ($keywords as $word) {
             // I know this is not a right escaping, but I can't believe $keywords :-)
             $word4sql = addslashes(stripslashes($word));
             $whr_query .= $andor == 'EXACT' ? ' AND' : ' ' . $andor;
             $whr_query .= " (p.subject LIKE '%{$word4sql}%' OR p.post_text LIKE '%{$word4sql}%')";
         }
     }
     $sql = "SELECT p.post_id,p.topic_id,p.post_time,p.uid,p.subject,p.html,p.smiley,p.xcode,p.br,{$select4con} FROM " . $db->prefix($mydirname . "_posts") . " p LEFT JOIN " . $db->prefix($mydirname . "_topics") . " t ON t.topic_id=p.topic_id WHERE ({$whr_forum}) AND ({$whr_uid}) AND ({$whr_query}) AND ! topic_invisible ORDER BY p.post_time DESC";
     $result = $db->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     while (list($post_id, $topic_id, $post_time, $uid, $subject, $html, $smiley, $xcode, $br, $text) = $db->fetchRow($result)) {
         // get context for module "search"
         if (function_exists('search_make_context') && $showcontext) {
             if (function_exists('easiestml')) {
                 $text = easiestml($text);
             }
             $full_context = strip_tags($myts->displayTarea($text, $html, $smiley, $xcode, 1, $br));
             $context = search_make_context($full_context, $keywords);
         }
         $ret[] = array('link' => "index.php?post_id={$post_id}", 'title' => $subject, 'time' => $post_time, 'uid' => $uid, "context" => $context);
     }
     return $ret;
 }
Example #4
0
 function d3forum_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid)
 {
     $myts =& MyTextsanitizer::getInstance();
     $db =& Database::getInstance();
     $andor = strtoupper($andor);
     $userid = intval($userid);
     // naao from
     require_once dirname(__FILE__) . '/include/main_functions.php';
     // get all forums
     $sql = "SELECT forum_id, forum_external_link_format FROM " . $db->prefix($mydirname . "_forums");
     $frs = $db->query($sql);
     $d3com = array();
     while ($forum_row = $db->fetchArray($frs)) {
         // d3comment object
         $temp_forum_id = intval($forum_row['forum_id']);
         if (!empty($forum_row['forum_external_link_format'])) {
             $d3com[$temp_forum_id] =& d3forum_main_get_comment_object($mydirname, $forum_row['forum_external_link_format']);
         } else {
             $d3com[$temp_forum_id] = false;
         }
     }
     // naao to
     $charset = strtoupper(_CHARSET);
     // XOOPS Search module
     $showcontext = empty($_GET['showcontext']) ? 0 : 1;
     $select4con = $showcontext ? "p.post_text" : "'' AS post_text";
     require_once dirname(__FILE__) . '/include/common_functions.php';
     $whr_forum = "t.forum_id IN (" . implode(",", d3forum_get_forums_can_read($mydirname)) . ")";
     $whr_uid = $userid > 0 ? "p.uid={$userid}" : "1";
     $whr_query = $andor == 'OR' ? '0' : '1';
     if (is_array($keywords)) {
         // I know this is not a right escaping, but I can't believe $keywords :-)
         $keywords = array_map('stripslashes', $keywords);
         foreach ($keywords as $word) {
             $word4sql = addslashes($word);
             $word_or = array('p.subject LIKE \'%' . $word4sql . '%\' OR p.post_text LIKE \'%' . $word4sql . '%\'');
             if (($charset === 'UTF-8' || $charset === 'EUC-JP') && function_exists('mb_convert_kana')) {
                 foreach (array('a', 'A', 'k', 'KV', 'h', 'HV', 'c', 'C') as $_op) {
                     $_word = mb_convert_kana($word, $_op, $charset);
                     if ($_word !== $word) {
                         $word4sql = addslashes($_word);
                         $word_or[] = 'p.subject LIKE \'%' . $word4sql . '%\' OR p.post_text LIKE \'%' . $word4sql . '%\'';
                     }
                 }
             }
             $word4sql = join(' OR ', $word_or);
             $whr_query .= $andor == 'EXACT' ? ' AND' : ' ' . $andor;
             $whr_query .= ' (' . $word4sql . ')';
         }
     }
     //$sql = "SELECT p.post_id,p.topic_id,p.post_time,p.uid,p.subject,p.html,p.smiley,p.xcode,p.br,$select4con FROM ".$db->prefix($mydirname."_posts")." p LEFT JOIN ".$db->prefix($mydirname."_topics")." t ON t.topic_id=p.topic_id WHERE ($whr_forum) AND ($whr_uid) AND ($whr_query) AND ! topic_invisible ORDER BY p.post_time DESC" ;
     //naao
     $sql = "SELECT p.post_id,p.topic_id,p.post_time,p.uid,p.subject,p.html,p.smiley,p.xcode,p.br,{$select4con},t.topic_external_link_id,f.forum_id FROM " . $db->prefix($mydirname . "_posts") . " p LEFT JOIN " . $db->prefix($mydirname . "_topics") . " t ON t.topic_id=p.topic_id  LEFT JOIN " . $db->prefix($mydirname . "_forums") . " f ON t.forum_id = f.forum_id WHERE ({$whr_forum}) AND ({$whr_uid}) AND ({$whr_query}) AND ! topic_invisible ORDER BY p.post_time DESC";
     $result = $db->query($sql, $limit, $offset);
     $ret = array();
     $context = '';
     // nao-pon
     $make_context_func = function_exists('xoops_make_context') ? 'xoops_make_context' : (function_exists('search_make_context') ? 'search_make_context' : '');
     while (list($post_id, $topic_id, $post_time, $uid, $subject, $html, $smiley, $xcode, $br, $text, $external_link_id, $forum_id) = $db->fetchRow($result)) {
         // naao from
         $can_display = true;
         //default
         if (is_object($d3com[intval($forum_id)])) {
             $d3com_obj = $d3com[intval($forum_id)];
             if (($external_link_id = $d3com_obj->validate_id($external_link_id)) === false) {
                 $can_display = false;
             }
         }
         if ($can_display == true) {
             // naao to
             // get context for module "search"
             // nao-pon
             //if( function_exists('search_make_context') && $showcontext ) {
             if ($make_context_func && $showcontext) {
                 if (function_exists('easiestml')) {
                     $text = easiestml($text);
                 }
                 $full_context = strip_tags($myts->displayTarea($text, $html, $smiley, $xcode, 1, $br));
                 // nao-pon
                 //$context = search_make_context( $full_context , $keywords ) ;
                 $context = $make_context_func($full_context, $keywords);
             }
             $ret[] = array('link' => "index.php?post_id={$post_id}", 'title' => htmlspecialchars($subject, ENT_QUOTES), 'time' => $post_time, 'uid' => $uid, 'context' => $context);
         }
         // naao
     }
     // for xoops search module
     $GLOBALS['md_search_flg_zenhan_support'] = true;
     return $ret;
 }
Example #5
0
function b_d3forum_list_posts_show($options)
{
    global $xoopsUser;
    $mydirname = empty($options[0]) ? 'd3forum' : $options[0];
    $max_posts = empty($options[1]) ? 10 : intval($options[1]);
    $now_order = empty($options[2]) ? 'time' : trim($options[2]);
    $categories = empty($options[3]) ? array() : explode(',', $options[3]);
    $forums = empty($options[5]) ? array() : explode(',', $options[5]);
    $this_template = empty($options[4]) ? 'db:' . $mydirname . '_block_list_posts.html' : trim($options[4]);
    if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
        die('Invalid mydirname');
    }
    $db =& Database::getInstance();
    $myts =& MyTextSanitizer::getInstance();
    $uid = is_object(@$xoopsUser) ? $xoopsUser->getVar('uid') : 0;
    $module_handler =& xoops_gethandler('module');
    $module =& $module_handler->getByDirname($mydirname);
    $config_handler =& xoops_gethandler('config');
    $configs = $config_handler->getConfigList($module->mid());
    // naao from
    // get all forums
    $sql = "SELECT forum_id, forum_external_link_format FROM " . $db->prefix($mydirname . "_forums");
    $frs = $db->query($sql);
    $d3com = array();
    while ($forum_row = $db->fetchArray($frs)) {
        // d3comment object
        $temp_forum_id = intval($forum_row['forum_id']);
        if (!empty($forum_row['forum_external_link_format'])) {
            $d3com[$temp_forum_id] =& d3forum_b_get_comment_object($mydirname, $forum_row['forum_external_link_format']);
        } else {
            $d3com[$temp_forum_id] = false;
        }
    }
    // naao to
    // order
    $whr_order = '1';
    switch ($now_order) {
        case 'votes':
            $odr = 'p.votes_count DESC';
            break;
        case 'points':
            $odr = 'p.votes_sum DESC';
            break;
        case 'average':
            $odr = 'p.votes_sum/p.votes_count DESC, p.votes_count DESC';
            $whr_order = 'p.votes_count>0';
            break;
        case 'time':
        default:
            $odr = 'p.post_time DESC';
            break;
    }
    // forums can be read by current viewer (check by forum_access)
    require_once dirname(dirname(__FILE__)) . '/include/common_functions.php';
    $whr_forum = "t.forum_id IN (" . implode(",", d3forum_get_forums_can_read($mydirname)) . ")";
    // categories
    $categories = array_map('intval', $categories);
    $categories4assign = implode(',', $categories);
    $whr_categories = empty($categories) ? '1' : 'f.cat_id IN (' . implode(',', $categories) . ')';
    // forums
    $forums = array_map('intval', $forums);
    $forums4assign = implode(',', $forums);
    $whr_forums = empty($forums) ? '1' : 'f.forum_id IN (' . implode(',', $forums) . ')';
    // naao
    $sql = "SELECT p.post_id, p.subject, p.votes_sum, p.votes_count, p.post_time, p.post_text, p.uid, \n\t\tp.guest_name, p.html, p.smiley, p.xcode, p.br, p.unique_path, \n\t\tf.forum_id, f.forum_title, t.topic_external_link_id FROM " . $db->prefix($mydirname . "_posts") . " p LEFT JOIN " . $db->prefix($mydirname . "_topics") . " t ON p.topic_id=t.topic_id LEFT JOIN " . $db->prefix($mydirname . "_forums") . " f ON f.forum_id=t.forum_id \n\t\tWHERE ! t.topic_invisible AND ({$whr_forum}) AND ({$whr_categories}) AND ({$whr_forums}) \n\t\tAND ({$whr_order}) ORDER BY {$odr}";
    //	var_dump( $sql ) ;
    if (!($result = $db->query($sql, $max_posts, 0))) {
        return array();
    }
    $constpref = '_MB_' . strtoupper($mydirname);
    $block = array('mydirname' => $mydirname, 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $mydirname . '/' . $configs['images_dir'], 'mod_config' => $configs, 'categories' => $categories4assign, 'forums' => $forums4assign, 'lang_forum' => constant($constpref . '_FORUM'), 'lang_topic' => constant($constpref . '_TOPIC'), 'lang_replies' => constant($constpref . '_REPLIES'), 'lang_views' => constant($constpref . '_VIEWS'), 'lang_votescount' => constant($constpref . '_VOTESCOUNT'), 'lang_votessum' => constant($constpref . '_VOTESSUM'), 'lang_lastpost' => constant($constpref . '_LASTPOST'), 'lang_linktosearch' => constant($constpref . '_LINKTOSEARCH'), 'lang_linktolistcategories' => constant($constpref . '_LINKTOLISTCATEGORIES'), 'lang_linktolistforums' => constant($constpref . '_LINKTOLISTFORUMS'), 'lang_linktolisttopics' => constant($constpref . '_LINKTOLISTTOPICS'));
    while ($post_row = $db->fetchArray($result)) {
        // naao from
        // d3comment overridings
        $can_display = true;
        //default
        if (is_object($d3com[intval($post_row['forum_id'])])) {
            $d3com_obj = $d3com[intval($post_row['forum_id'])];
            $external_link_id = intval($post_row['topic_external_link_id']);
            if (($external_link_id = $d3com_obj->validate_id($external_link_id)) === false) {
                $can_display = false;
            }
        }
        // naao to
        if ($can_display == true) {
            // naao
            $post4assign = array('id' => intval($post_row['post_id']), 'subject' => $myts->makeTboxData4Show($post_row['subject']), 'forum_id' => intval($post_row['forum_id']), 'forum_title' => $myts->makeTboxData4Show($post_row['forum_title']), 'votes_count' => $post_row['votes_count'], 'votes_sum' => intval($post_row['votes_sum']), 'post_time' => intval($post_row['post_time']), 'post_time_formatted' => formatTimestamp($post_row['post_time'], 'm'), 'uid' => intval($post_row['uid']), 'uname' => XoopsUser::getUnameFromId($post_row['uid'], $configs['use_name']), 'external_link_id' => intval($post_row['topic_external_link_id']), 'post_text' => strip_tags($myts->displayTarea(strip_tags($post_row['post_text']), $post_row['html'], $post_row['smiley'], $post_row['xcode'], 1, $post_row['br'])), 'guest_name' => htmlspecialchars($post_row['guest_name']));
            $block['posts'][] = $post4assign;
        }
        //naao
    }
    if (empty($options['disable_renderer'])) {
        require_once XOOPS_ROOT_PATH . '/class/template.php';
        $tpl = new XoopsTpl();
        $tpl->assign('block', $block);
        $ret['content'] = $tpl->fetch($this_template);
        return $ret;
    } else {
        return $block;
    }
}
*/
// set range (added 86400 second margin "begin" & "end")
$range_start_s = mktime(0, 0, 0, $this->month, 0, $this->year);
$range_end_s = mktime(0, 0, 0, $this->month + 1, 1, $this->year);
// options
$options = explode('|', $plugin['options']);
// options[0] : category extract
if (!empty($options[0])) {
    $cat_ids = array_map('intval', explode(',', $options[0]));
    $whr_cat = 'f.cat_id IN (' . implode(',', $cat_ids) . ')';
} else {
    $whr_cat = '1';
}
// forums can be read by current viewer (check by forum_access)
require_once XOOPS_TRUST_PATH . '/modules/d3forum/include/common_functions.php';
$whr_forum = "t.forum_id IN (" . implode(",", d3forum_get_forums_can_read($plugin['dirname'])) . ")";
// query (added 86400 second margin "begin" & "end")
$result = $db->query("SELECT p.subject,p.post_id,p.post_time FROM " . $db->prefix($plugin['dirname'] . "_posts") . " p LEFT JOIN " . $db->prefix($plugin['dirname'] . "_topics") . " t ON p.topic_id=t.topic_id LEFT JOIN " . $db->prefix($plugin['dirname'] . "_forums") . " f ON f.forum_id=t.forum_id WHERE ! p.invisible AND ! t.topic_invisible AND ({$whr_forum}) AND ({$whr_cat}) AND p.post_time >= {$range_start_s} AND p.post_time < {$range_end_s}");
while (list($title, $id, $server_time) = $db->fetchRow($result)) {
    $user_time = $server_time + $tzoffset_s2u;
    if (date('n', $user_time) != $this->month) {
        continue;
    }
    $target_date = date('j', $user_time);
    $tmp_array = array('dotgif' => $plugin['dotgif'], 'dirname' => $plugin['dirname'], 'link' => XOOPS_URL . "/modules/{$plugin['dirname']}/index.php?post_id={$id}", 'id' => $id, 'server_time' => $server_time, 'user_time' => $user_time, 'name' => 'post_id', 'title' => $myts->makeTboxData4Show($title));
    if ($just1gif) {
        // just 1 gif per a plugin & per a day
        $plugin_returns[$target_date][$plugin['dirname']] = $tmp_array;
    } else {
        // multiple gifs allowed per a plugin & per a day
        $plugin_returns[$target_date][] = $tmp_array;
function d3forum_get_submenu($mydirname)
{
    static $submenus_cache;
    if (!empty($submenus_cache[$mydirname])) {
        return $submenus_cache[$mydirname];
    }
    $module_handler =& xoops_gethandler('module');
    $module =& $module_handler->getByDirname($mydirname);
    if (!is_object($module)) {
        return array();
    }
    $config_handler =& xoops_gethandler('config');
    $mod_config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
    $db =& Database::getInstance();
    $myts =& MyTextSanitizer::getInstance();
    $whr_read4cat = '`cat_id` IN (' . implode(",", d3forum_get_categories_can_read($mydirname)) . ')';
    $whr_read4forum = '`forum_id` IN (' . implode(",", d3forum_get_forums_can_read($mydirname)) . ')';
    $categories = array(0 => array('pid' => -1, 'name' => '', 'url' => ''));
    // categories query
    $sql = "SELECT cat_id,pid,cat_title FROM " . $db->prefix($mydirname . "_categories") . " WHERE ({$whr_read4cat}) ORDER BY cat_order_in_tree";
    $crs = $db->query($sql);
    if ($crs) {
        while ($cat_row = $db->fetchArray($crs)) {
            $cat_id = intval($cat_row['cat_id']);
            $categories[$cat_id] = array('name' => $myts->makeTboxData4Show($cat_row['cat_title']), 'url' => 'index.php?cat_id=' . $cat_id, 'pid' => $cat_row['pid']);
        }
    }
    // forums query
    $frs = $db->query("SELECT cat_id,forum_id,forum_title FROM " . $db->prefix($mydirname . "_forums") . " WHERE ({$whr_read4forum}) ORDER BY forum_weight");
    if ($frs) {
        while ($forum_row = $db->fetchArray($frs)) {
            $cat_id = intval($forum_row['cat_id']);
            $categories[$cat_id]['sub'][] = array('name' => $myts->makeTboxData4Show($forum_row['forum_title']), 'url' => '?forum_id=' . intval($forum_row['forum_id']));
        }
    }
    // restruct categories
    $submenus_cache[$mydirname] = array_merge(d3forum_restruct_categories($categories, 0));
    return $submenus_cache[$mydirname];
}