示例#1
0
 /**
  * Get a forum list that a user is suspended, according to his uid and ip
  * Store the list into session if module cache is enabled
  * 
  * 
  * @param	int 	$uid user id
  * @param	string 	$ip user ip
  */
 function forumList($uid = -1, $ip = "")
 {
     static $forums = array();
     $uid = $uid < 0 ? is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("uid") : 0 : $uid;
     $ip = empty($ip) ? newbb_getIP(true) : $ip;
     if (isset($forums[$uid][$ip])) {
         return $forums[$uid][$ip];
     }
     if (!empty($GLOBALS["xoopsModuleConfig"]['cache_enabled'])) {
         $forums[$uid][$ip] = newbb_getsession("sf" . $uid . "_" . ip2long($ip), true);
         if (is_array($forums[$uid][$ip]) && count($forums[$uid][$ip])) {
             return $forums[$uid][$ip];
         }
     }
     $uid_criteria = empty($uid) ? "1=1" : "uid=" . intval($uid);
     if (!empty($ip)) {
         $ip_segs = explode(".", $ip);
         for ($i = 1; $i <= 4; $i++) {
             $ips[] = $this->db->quoteString(implode(".", array_slice($ip_segs, 0, $i)));
         }
         $ip_criteria = "ip IN(" . implode(",", $ips) . ")";
     } else {
         $ip_criteria = "1=1";
     }
     $expire_criteria = "mod_end > " . time();
     $sql = sprintf("SELECT forum_id, COUNT(*) AS count FROM %s WHERE (%s OR %s) AND (%s) GROUP BY forum_id", $this->db->prefix('bb_moderates'), $uid_criteria, $ip_criteria, $expire_criteria);
     if (!($result = $this->db->query($sql))) {
         return $forums[$uid][$ip] = array();
     }
     $_forums = array();
     while ($row = $this->db->fetchArray($result)) {
         if ($row["count"] > 0) {
             $_forums[$row["forum_id"]] = 1;
         }
     }
     $forums[$uid][$ip] = count($_forums) ? array_keys($_forums) : array(-1);
     if (!empty($GLOBALS["xoopsModuleConfig"]['cache_enabled'])) {
         newbb_setsession("sf" . $uid . "_" . ip2long($ip), $forums[$uid][$ip]);
     }
     return $forums[$uid][$ip];
 }
示例#2
0
    $user_handler->groups =& $groups_disp;
    $user_handler->status =& $online;
    foreach ($userid_array as $userid) {
        $viewtopic_users[$userid] =& $user_handler->get($userid);
        if (!$forum_obj->getVar('allow_sig')) {
            $viewtopic_users[$userid]["signature"] = "";
        }
    }
}
unset($users);
if ($xoopsModuleConfig['allow_require_reply'] && $require_reply) {
    if (!empty($xoopsModuleConfig['cache_enabled'])) {
        $viewtopic_posters = newbb_getsession("t" . $topic_id, true);
        if (!is_array($viewtopic_posters) || count($viewtopic_posters) == 0) {
            $viewtopic_posters = $topic_handler->getAllPosters($topic_obj);
            newbb_setsession("t" . $topic_id, $viewtopic_posters);
        }
    } else {
        $viewtopic_posters = $topic_handler->getAllPosters($topic_obj);
    }
} else {
    $viewtopic_posters = array();
}
if ($viewmode == "thread") {
    if (!empty($post_id)) {
        $post_handler =& xoops_getmodulehandler('post', 'newbb');
        $currentPost = $post_handler->get($post_id);
        if (!$isadmin && $currentPost->getVar('approved') < 0) {
            redirect_header("view.topic.php?topic_id=" . $topic_id, 2, _MD_NORIGHTTOVIEW);
            exit;
        }
示例#3
0
$forumCookie['prefix'] = '';
// set cookie name to avoid subsites confusion such as: domain.com, sub1.domain.com, sub2.domain.com, domain.com/xoopss, domain.com/xoops2
if (empty($forumCookie['prefix'])) {
    $cookie_prefix = preg_replace("/[^a-z_0-9]+/i", "_", preg_replace("/(http(s)?:\\/\\/)?(www.)?/i", "", XOOPS_URL));
    $cookie_userid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
    $forumCookie['prefix'] = $cookie_prefix . "_" . $xoopsModule->dirname() . $cookie_userid . "_";
}
// 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_getcookie("LVT");
$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_setcookie("LVT", $last_visit);
newbb_setsession("LV", $last_visit);
/* NewBB cookie storage
	Long term cookie: (configurable, generally one month)
		LV - Last Visit
		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
*/
示例#4
0
     $notification_handler->triggerEvent('forum', $forum_obj->getVar('forum_id'), 'new_fullpost', $tags);
 }
 // If user checked notification box, subscribe them to the
 // appropriate event; if unchecked, then unsubscribe
 if (!empty($xoopsUser) && !empty($xoopsModuleConfig['notification_enabled'])) {
     $notification_handler = xoops_gethandler('notification');
     if (empty($_POST['notify'])) {
         $notification_handler->unsubscribe('thread', $post_obj->getVar('topic_id'), 'new_post');
     } elseif ($_POST['notify'] > 0) {
         $notification_handler->subscribe('thread', $post_obj->getVar('topic_id'), 'new_post');
     }
     // elseif ($_POST['notify']<0) keep it as it is
 }
 if ($approved) {
     if (!empty($xoopsModuleConfig['cache_enabled'])) {
         newbb_setsession("t" . $post_obj->getVar("topic_id"), null);
     }
     // Update user
     if ($uid > 0) {
         $sql = "SELECT count(*)" . "\tFROM " . $xoopsDB->prefix("bb_topics") . "\tWHERE approved=1 AND topic_poster =" . $uid;
         $ret = $xoopsDB->query($sql);
         list($topics) = $xoopsDB->fetchRow($ret);
         $sql = "\tSELECT count(*)" . "\tFROM " . $xoopsDB->prefix("bb_topics") . "\tWHERE approved=1 AND topic_digest > 0 AND topic_poster =" . $uid;
         $ret = $xoopsDB->query($sql);
         list($digests) = $xoopsDB->fetchRow($ret);
         $sql = "\tSELECT count(*), MAX(post_time)" . "\tFROM " . $xoopsDB->prefix("bb_posts") . "\tWHERE approved=1 AND uid =" . $uid;
         $ret = $xoopsDB->query($sql);
         list($posts, $lastpost) = $xoopsDB->fetchRow($ret);
         $xoopsDB->queryF("\tREPLACE INTO " . $xoopsDB->prefix("bb_user_stats") . " \tSET uid = '{$uid}', user_topics = '{$topics}', user_posts = '{$posts}', user_digests = '{$digests}', user_lastpost = '{$lastpost}'");
     }
     $redirect = "viewtopic.php?post_id=" . $postid;
示例#5
0
    $user_handler->setStatus($online);
    foreach ($userid_array as $userid) {
        $viewtopic_users[$userid] =& $user_handler->get($userid);
        if (empty($forumdata['allow_sig'])) {
            $viewtopic_users[$userid]["signature"] = "";
        }
    }
}
unset($users);
unset($groups_disp);
if ($xoopsModuleConfig['allow_require_reply'] && $require_reply) {
    if (!empty($xoopsModuleConfig['cache_enabled'])) {
        $viewtopic_posters = newbb_getsession("t" . $forumtopic->getVar("topic_id"), true);
        if (!is_array($viewtopic_posters) || count($viewtopic_posters) == 0) {
            $viewtopic_posters =& $topic_handler->getAllPosters($forumtopic);
            newbb_setsession("t" . $forumtopic->getVar("topic_id"), $viewtopic_posters);
        }
    } else {
        $viewtopic_posters =& $topic_handler->getAllPosters($forumtopic);
    }
} else {
    $viewtopic_posters = array();
}
if ($viewmode == "thread") {
    if (isset($post_id) && $post_id) {
        $post_handler =& xoops_getmodulehandler('post', 'newbb');
        $currentPost = $post_handler->get($post_id);
        $topPost = $topic_handler->getTopPost($forumtopic->getVar('topic_id'));
        $top_pid = $topPost->getVar('post_id');
        unset($topPost);
    } else {
示例#6
0
        $tags['POST_NAME'] = $myts->stripSlashesGPC($_POST['subject']);
        $notification_handler->triggerEvent('global', 0, 'new_fullpost', $tags);
    }
    // If user checked notification box, subscribe them to the
    // appropriate event; if unchecked, then unsubscribe
    if (!empty($xoopsUser) && !empty($xoopsModuleConfig['notification_enabled'])) {
        $notification_handler =& xoops_gethandler('notification');
        if (!empty($_POST['notify'])) {
            $notification_handler->subscribe('thread', $forumpost->getVar('topic_id'), 'new_post');
        } else {
            $notification_handler->unsubscribe('thread', $forumpost->getVar('topic_id'), 'new_post');
        }
    }
    if ($approved) {
        if (!empty($xoopsModuleConfig['cache_enabled'])) {
            newbb_setsession("t" . $forumpost->getVar("topic_id"), null);
        }
        $redirect = "viewtopic.php?topic_id=" . $forumpost->getVar('topic_id') . "&amp;post_id=" . $postid . "#forumpost" . $postid . "";
        $message = _MD_THANKSSUBMIT . "<br />" . $error_upload;
    } else {
        $redirect = "viewforum.php?forum=" . $forumpost->getVar('forum_id');
        $message = _MD_THANKSSUBMIT . "<br />" . _MD_WAITFORAPPROVAL . "<br />" . $error_upload;
    }
    if ($op == "add") {
        redirect_header("polls.php?op=add&amp;forum=" . $forumpost->getVar('forum_id') . "&amp;topic_id=" . $forumpost->getVar('topic_id') . "", 1, _MD_ADDPOLL);
        exit;
    } else {
        redirect_header($redirect, 2, $message);
        exit;
    }
}