示例#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
if (count($userid_array) > 0) {
    $user_handler =& xoops_getmodulehandler('user', 'newbb');
    $user_handler->setUsers($users);
    $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) {
示例#3
0
         $xoopsUser =& $user;
         $xoopsUserIsAdmin = $xoopsUser->isAdmin($xoopsModule->getVar('mid'));
     }
 }
 if (!is_object($xoopsUser)) {
     xoops_load("captcha");
     $xoopsCaptcha = XoopsCaptcha::getInstance();
     if (!$xoopsCaptcha->verify()) {
         $captcha_invalid = true;
         $error_message[] = $xoopsCaptcha->getMessage();
     }
 }
 $isadmin = newbb_isAdmin($forum_obj);
 $time_valid = true;
 if (!$isadmin && !empty($xoopsModuleConfig['post_timelimit'])) {
     $last_post = newbb_getsession('LP');
     if (time() - $last_post < $xoopsModuleConfig['post_timelimit']) {
         $time_valid = false;
     }
 }
 if ($captcha_invalid || !$token_valid || !$time_valid) {
     $_POST['contents_preview'] = 1;
     $_POST['contents_submit'] = null;
     $_POST['contents_upload'] = null;
     if (!$token_valid) {
         $error_message[] = _MD_INVALID_SUBMIT;
     }
     if (!$time_valid) {
         $error_message[] = sprintf(_MD_POSTING_LIMITED, $xoopsModuleConfig['post_timelimit']);
     }
 }
示例#4
0
$forumCookie['domain'] = "";
$forumCookie['path'] = "/";
$forumCookie['secure'] = false;
$forumCookie['expire'] = time() + 3600 * 24 * 30;
// one month
$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
示例#5
0
    $user_handler =& xoops_getmodulehandler('user', 'newbb');
    $user_handler->setUsers($users);
    $user_handler->setGroups($groups_disp);
    $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'));