コード例 #1
0
/**
 * Function to respond to a trackback
 */
function newbb_trackback_response($error = 0, $error_message = '')
{
    require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
    $moduleConfig = newbb_loadConfig();
    if (!empty($moduleConfig["rss_utf8"])) {
        $charset = "utf-8";
        $error_message = xoops_utf8_encode($error_message);
    } else {
        $charset = _CHARSET;
    }
    header('Content-Type: text/xml; charset="' . $charset . '"');
    if ($error) {
        echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
        echo "<response>\n";
        echo "<error>1</error>\n";
        echo "<message>{$error_message}</message>\n";
        echo "</response>";
        die;
    } else {
        echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n";
        echo "<response>\n";
        echo "<error>0</error>\n";
        echo "</response>";
    }
}
コード例 #2
0
ファイル: module.php プロジェクト: trabisdementia/xuups
function xoops_module_update_newbb(&$module, $oldversion = null)
{
    require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
    $newbbConfig = newbb_loadConfig();
    // NewBB 1.0
    if ($oldversion == 100) {
        include_once dirname(__FILE__) . "/module.v100.php";
        xoops_module_update_newbb_v100($module);
    }
    // NewBB 2.* and CBB 1.*
    // change group permission name
    // change forum moderators
    if ($oldversion < 220) {
        include_once dirname(__FILE__) . "/module.v220.php";
        xoops_module_update_newbb_v220($module);
    }
    if ($oldversion < 230) {
        $GLOBALS['xoopsDB']->queryFromFile(XOOPS_ROOT_PATH . "/modules/" . $module->getVar("dirname", "n") . "/sql/upgrade_230.sql");
    }
    if ($oldversion < 304) {
        $GLOBALS['xoopsDB']->queryFromFile(XOOPS_ROOT_PATH . "/modules/" . $module->getVar("dirname", "n") . "/sql/mysql.304.sql");
    }
    if ($oldversion < 400) {
        $GLOBALS['xoopsDB']->queryFromFile(XOOPS_ROOT_PATH . "/modules/" . $module->getVar("dirname", "n") . "/sql/mysql.400.sql");
        include dirname(__FILE__) . "/module.v400.php";
        xoops_module_update_newbb_v400($module);
    }
    if (!empty($newbbConfig["syncOnUpdate"])) {
        require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.recon.php";
        newbb_synchronization();
    }
    return true;
}
コード例 #3
0
ファイル: readtopic.php プロジェクト: trabisdementia/xuups
 function NewbbReadtopicHandler(&$db)
 {
     $this->NewbbReadHandler($db, "topic");
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
     $newbbConfig = newbb_loadConfig();
     $this->items_per_forum = isset($newbbConfig["read_items"]) ? intval($newbbConfig["read_items"]) : 100;
 }
コード例 #4
0
function newbb_synchronization($type = "")
{
    switch ($type) {
        case "rate":
        case "report":
        case "post":
        case "topic":
        case "forum":
        case "category":
        case "moderate":
        case "read":
            $type = array($type);
            $clean = $type;
            break;
        default:
            $type = null;
            $clean = array("category", "forum", "topic", "post", "report", "rate", "moderate", "readtopic", "readforum");
            break;
    }
    foreach ($clean as $item) {
        $handler =& xoops_getmodulehandler($item, "newbb");
        $handler->cleanOrphan();
        unset($handler);
    }
    require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
    $newbbConfig = newbb_loadConfig();
    if (empty($type) || in_array("post", $type)) {
        $post_handler =& xoops_getmodulehandler("post", "newbb");
        $expires = isset($newbbConfig["pending_expire"]) ? intval($newbbConfig["pending_expire"]) : 7;
        $post_handler->cleanExpires($expires * 24 * 3600);
    }
    if (empty($type) || in_array("topic", $type)) {
        $topic_handler =& xoops_getmodulehandler("topic", "newbb");
        $expires = isset($newbbConfig["pending_expire"]) ? intval($newbbConfig["pending_expire"]) : 7;
        $topic_handler->cleanExpires($expires * 24 * 3600);
        //$topic_handler->synchronization();
    }
    /*
    if (empty($type) || in_array("forum", $type)):
    $forum_handler =& xoops_getmodulehandler("forum", "newbb");
    $forum_handler->synchronization();
    endif;
    */
    if (empty($type) || in_array("moderate", $type)) {
        $moderate_handler =& xoops_getmodulehandler("moderate", "newbb");
        $moderate_handler->clearGarbage();
    }
    if (empty($type) || in_array("read", $type)) {
        $read_handler =& xoops_getmodulehandler("readforum", "newbb");
        $read_handler->clearGarbage();
        //$read_handler->synchronization();
        $read_handler =& xoops_getmodulehandler("readtopic", "newbb");
        $read_handler->clearGarbage();
        //$read_handler->synchronization();
    }
    return true;
}
コード例 #5
0
ファイル: read.php プロジェクト: trabisdementia/xuups
 function NewbbReadHandler(&$db, $type)
 {
     $type = "forum" == $type ? "forum" : "topic";
     $this->XoopsPersistableObjectHandler($db, 'bb_reads_' . $type, 'Read' . $type, 'read_id', 'post_id');
     $this->type = $type;
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
     $newbb_config = newbb_loadConfig();
     $this->lifetime = !empty($newbbConfig["read_expire"]) ? $newbbConfig["read_expire"] * 24 * 3600 : 30 * 24 * 3600;
     $this->mode = isset($newbbConfig["read_mode"]) ? $newbbConfig["read_mode"] : 2;
 }
コード例 #6
0
function newbb_sinceSelectBox($selected = 100)
{
    require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
    $newbbConfig = newbb_loadConfig();
    $select_array = explode(',', $newbbConfig['since_options']);
    $select_array = array_map('trim', $select_array);
    $forum_selection_since = '<select name="since">';
    foreach ($select_array as $since) {
        $forum_selection_since .= '<option value="' . $since . '"' . ($selected == $since ? ' selected="selected"' : '') . '>';
        if ($since > 0) {
            $forum_selection_since .= sprintf(_MD_FROMLASTDAYS, $since);
        } else {
            $forum_selection_since .= sprintf(_MD_FROMLASTHOURS, abs($since));
        }
        $forum_selection_since .= '</option>';
    }
    $forum_selection_since .= '<option value="365"' . ($selected == 365 ? ' selected="selected"' : '') . '>' . _MD_THELASTYEAR . '</option>';
    $forum_selection_since .= '<option value="0"' . ($selected == 0 ? ' selected="selected"' : '') . '>' . _MD_BEGINNING . '</option>';
    $forum_selection_since .= '</select>';
    return $forum_selection_since;
}
コード例 #7
0
ファイル: newbb_block.php プロジェクト: trabisdementia/xuups
function b_newbb_author_show($options)
{
    global $xoopsConfig;
    global $access_forums;
    $myts =& MyTextSanitizer::getInstance();
    $block = array();
    $i = 0;
    $type = "topic";
    $order = "count";
    $extra_criteria = "";
    $time_criteria = null;
    if (!empty($options[2])) {
        require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.time.php";
        $time_criteria = time() - newbb_getSinceTime($options[2]);
        $extra_criteria = " AND topic_time > " . $time_criteria;
    }
    switch ($options[0]) {
        case 'topic':
            break;
        case 'digest':
            $extra_criteria = " AND topic_digest = 1";
            if ($time_criteria) {
                $extra_criteria .= " AND digest_time > " . $time_criteria;
            }
            break;
        case 'sticky':
            $extra_criteria .= " AND topic_sticky = 1";
            break;
        case 'post':
        default:
            $type = "post";
            if ($time_criteria) {
                $extra_criteria = " AND post_time > " . $time_criteria;
            }
            break;
    }
    $newbbConfig = newbb_loadConfig();
    if (!isset($access_forums)) {
        $perm_handler =& xoops_getmodulehandler('permission', 'newbb');
        if (!($access_forums = $perm_handler->getForums())) {
            return $block;
        }
    }
    if (!empty($options[5])) {
        $allowedforums = array_filter(array_slice($options, 5), "b_newbb_array_filter");
        // get allowed forums
        $allowed_forums = array_intersect($allowedforums, $access_forums);
    } else {
        $allowed_forums = $access_forums;
    }
    if (empty($allowed_forums)) {
        return false;
    }
    if ($type == "topic") {
        $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')';
        $approve_criteria = ' AND approved = 1';
        $query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count
                    FROM ' . $GLOBALS["xoopsDB"]->prefix('bb_topics') . '
                    WHERE topic_poster>0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC';
    } else {
        $forum_criteria = ' AND forum_id IN (' . implode(',', $allowed_forums) . ')';
        $approve_criteria = ' AND approved = 1';
        $query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count
                    FROM ' . $GLOBALS["xoopsDB"]->prefix('bb_posts') . '
                    WHERE uid > 0 ' . $forum_criteria . $approve_criteria . $extra_criteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC';
    }
    $result = $GLOBALS["xoopsDB"]->query($query, $options[1], 0);
    if (!$result) {
        //xoops_error($GLOBALS["xoopsDB"]->error());
        return $block;
    }
    $author = array();
    while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) {
        $author[$row["author"]]["count"] = $row["count"];
    }
    if (count($author) < 1) {
        return $block;
    }
    require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.user.php";
    $author_name = newbb_getUnameFromIds(array_keys($author), $newbbConfig['show_realname']);
    foreach (array_keys($author) as $uid) {
        $author[$uid]["name"] = $myts->htmlSpecialChars($author_name[$uid]);
    }
    $block['authors'] =& $author;
    $block['disp_mode'] = $options[3];
    // 0 - full view; 1 - lite view;
    $block['indexNav'] = intval($options[4]);
    return $block;
}
コード例 #8
0
ファイル: vars.php プロジェクト: trabisdementia/xuups
 M - Menu mode
 V - View mode
 G - Toggle
 Short term cookie: (same as session life time)
 ST - Stored Topic IDs for mark
 LP - Last Post
 LF - Forum Last view
 LT - Topic Last read
 LVT - Last Visit Temp
 */
/* -- Cookie settings -- */
$forumCookie['domain'] = "";
$forumCookie['path'] = "/";
$forumCookie['secure'] = false;
$forumCookie['expire'] = time() + 3600 * 24 * 30;
// one month
$forumCookie['prefix'] = 'newbb_' . (is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0);
// set LastVisitTemp cookie, which only gets the time from the LastVisit cookie if it does not exist yet
// otherwise, it gets the time from the LastVisitTemp cookie
$last_visit = newbb_getsession("LV");
$last_visit = $last_visit ? $last_visit : newbb_getcookie("LV");
$last_visit = $last_visit ? $last_visit : time();
// update LastVisit cookie.
newbb_setcookie("LV", time(), $forumCookie['expire']);
// set cookie life time to one month
newbb_setsession("LV", $last_visit);
// include customized variables
if (is_object($GLOBALS["xoopsModule"]) && "newbb" == $GLOBALS["xoopsModule"]->getVar("dirname", "n")) {
    require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
    $GLOBALS["xoopsModuleConfig"] = newbb_loadConfig();
}
コード例 #9
0
ファイル: topic.php プロジェクト: trabisdementia/xuups
 function delete(&$topic, $force = true)
 {
     $topic_id = is_object($topic) ? $topic->getVar("topic_id") : intval($topic);
     if (empty($topic_id)) {
         return false;
     }
     $post_obj =& $this->getTopPost($topic_id);
     $post_handler =& xoops_getmodulehandler('post', 'newbb');
     $post_handler->delete($post_obj, false, $force);
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
     $newbbConfig = newbb_loadConfig();
     if (!empty($newbbConfig['do_tag']) && ($tag_handler = @xoops_getmodulehandler('tag', 'tag', true))) {
         $tag_handler->updateByItem(array(), $topic_id, "newbb");
     }
     return true;
 }
コード例 #10
0
ファイル: search.inc.php プロジェクト: trabisdementia/xuups
function &newbb_search($queryarray, $andor, $limit, $offset, $userid, $forums = 0, $sortby = 0, $searchin = "both", $subquery = "")
{
    global $xoopsDB, $xoopsConfig, $myts, $xoopsUser;
    $uid = is_object($xoopsUser) && $xoopsUser->isactive() ? $xoopsUser->getVar('uid') : 0;
    $forum_handler =& xoops_getmodulehandler('forum', 'newbb');
    $valid_forums = $forum_handler->getIdsByPermission();
    if (is_array($forums) && count($forums) > 0) {
        $valid_forums = array_intersect($valid_forums, $forums);
    } elseif (is_numeric($forums) && $forums > 0) {
        $valid_forums = array_intersect($valid_forums, array($forums));
    }
    $sql = 'SELECT p.uid,f.forum_id, p.topic_id, p.poster_name, p.post_time,';
    $sql .= ' f.forum_name, p.post_id, p.subject
            FROM ' . $xoopsDB->prefix('bb_posts') . ' p,
            ' . $xoopsDB->prefix('bb_posts_text') . ' pt,
            ' . $xoopsDB->prefix('bb_forums') . ' f';
    $sql .= ' WHERE p.post_id = pt.post_id';
    $sql .= ' AND p.approved = 1';
    $sql .= ' AND p.forum_id = f.forum_id';
    //                AND p.uid = u.uid'; // In case exists a userid with which the associated user is removed, this line will block search results.  Can do nothing unless xoops changes its way dealing with user removal
    if (!empty($forum)) {
        $sql .= ' AND f.forum_id IN (' . implode(',', $valid_forums) . ')';
    }
    $isUser = false;
    if (is_numeric($userid) && $userid != 0) {
        $sql .= " AND p.uid=" . $userid . " ";
        $isUser = true;
    } else {
        // TODO
        if (is_array($userid) && count($userid) > 0) {
            $userid = array_map('intval', $userid);
            $sql .= " AND p.uid IN (" . implode(',', $userid) . ") ";
            $isUser = true;
        }
    }
    $count = count($queryarray);
    if (is_array($queryarray) && $count > 0) {
        switch ($searchin) {
            case 'title':
                $sql .= " AND ((p.subject LIKE '%{$queryarray['0']}%')";
                for ($i = 1; $i < $count; $i++) {
                    $sql .= " {$andor} ";
                    $sql .= "(p.subject LIKE '%{$queryarray[$i]}%')";
                }
                $sql .= ") ";
                break;
            case 'text':
                $sql .= " AND ((pt.post_text LIKE '%{$queryarray['0']}%')";
                for ($i = 1; $i < $count; $i++) {
                    $sql .= " {$andor} ";
                    $sql .= "(pt.post_text LIKE '%{$queryarray[$i]}%')";
                }
                $sql .= ") ";
                break;
            case 'both':
            default:
                $sql .= " AND ((p.subject LIKE '%{$queryarray['0']}%' OR pt.post_text LIKE '%{$queryarray['0']}%')";
                for ($i = 1; $i < $count; $i++) {
                    $sql .= " {$andor} ";
                    $sql .= "(p.subject LIKE '%{$queryarray[$i]}%' OR pt.post_text LIKE '%{$queryarray[$i]}%')";
                }
                $sql .= ") ";
                break;
        }
    }
    if (!$sortby) {
        $sortby = "p.post_time DESC";
    }
    $sql .= $subquery . " ORDER BY " . $sortby;
    $result = $xoopsDB->query($sql, $limit, $offset);
    $ret = array();
    $users = array();
    $i = 0;
    while ($myrow = $xoopsDB->fetchArray($result)) {
        $ret[$i]['link'] = "viewtopic.php?topic_id=" . $myrow['topic_id'] . "&amp;forum=" . $myrow['forum_id'] . "&amp;post_id=" . $myrow['post_id'] . "#forumpost" . $myrow['post_id'];
        $ret[$i]['title'] = $myrow['subject'];
        $ret[$i]['time'] = $myrow['post_time'];
        $ret[$i]['uid'] = $myrow['uid'];
        $ret[$i]['forum_name'] = $myts->htmlSpecialChars($myrow['forum_name']);
        $ret[$i]['forum_link'] = "viewforum.php?forum=" . $myrow['forum_id'];
        $users[$myrow['uid']] = 1;
        $ret[$i]['poster_name'] = $myrow['poster_name'];
        $i++;
    }
    if (count($users) > 0) {
        $member_handler =& xoops_gethandler('member');
        $userid_array = array_keys($users);
        $user_criteria = "(" . implode(",", $userid_array) . ")";
        $users = $member_handler->getUsers(new Criteria('uid', $user_criteria, 'IN'), true);
    } else {
        $users = null;
    }
    require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
    $newbbConfig = newbb_loadConfig();
    $count = count($ret);
    for ($i = 0; $i < $count; $i++) {
        if ($ret[$i]['uid'] > 0) {
            if (isset($users[$ret[$i]['uid']]) && is_object($users[$ret[$i]['uid']]) && $users[$ret[$i]['uid']]->isActive()) {
                $poster = $newbbConfig['show_realname'] && $users[$ret[$i]['uid']]->getVar('name') ? $users[$ret[$i]['uid']]->getVar('name') : $users[$ret[$i]['uid']]->getVar('uname');
                $poster = $myts->htmlSpecialChars($poster);
                $ret[$i]['poster'] = '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $poster . '</a>';
                $title = $myts->htmlSpecialChars($ret[$i]['title']);
            } else {
                $ret[$i]['poster'] = $xoopsConfig['anonymous'];
                $ret[$i]['uid'] = 0;
                // Have to force this to fit xoops search.php
            }
        } else {
            $ret[$i]['poster'] = empty($ret[$i]['poster_name']) ? $xoopsConfig['anonymous'] : $myts->htmlSpecialChars($ret[$i]['poster_name']);
            $ret[$i]['uid'] = 0;
        }
    }
    unset($users);
    return $ret;
}
コード例 #11
0
ファイル: post.php プロジェクト: trabisdementia/xuups
 function checkTimelimit($action_tag = 'edit_timelimit')
 {
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.config.php";
     $newbb_config = newbb_loadConfig();
     if (empty($newbb_config["edit_timelimit"])) {
         return true;
     }
     return $this->getVar('post_time') > time() - $newbb_config[$action_tag] * 60;
 }