コード例 #1
0
ファイル: functions.php プロジェクト: reima/restful-vb
function fetch_subforum_list($parentid = -1)
{
    global $vbulletin;
    cache_ordered_forums(1);
    // 1 means: also cache thread/reply counts
    $result = array();
    if (!isset($vbulletin->iforumcache["{$parentid}"])) {
        return $result;
    }
    foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) {
        $forum = $vbulletin->forumcache["{$forumid}"];
        $forumperms = $vbulletin->userinfo['forumpermissions']["{$forumid}"];
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and ($vbulletin->forumcache["{$forumid}"]['showprivate'] == 1 or !$vbulletin->forumcache["{$forumid}"]['showprivate'] and !$vbulletin->options['showprivateforums'])) {
            // no permission to view current forum
            continue;
        }
        if (!$forum['displayorder'] or !($forum['options'] & $vbulletin->bf_misc_forumoptions['active'])) {
            // forum not active
            continue;
        }
        // get on/off status
        //$lastpostinfo = $vbulletin->forumcache["$lastpostarray[$forumid]"];
        //$forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
        //$show['newposticon'] = ($forum['statusicon'] ? true : false);
        $result[] = array('id' => $forum['forumid'], 'title' => str($forum['title'], true), 'description' => str($forum['description'], true), 'threadcount' => intval($forum['threadcount']), 'replycount' => intval($forum['replycount']));
    }
    return $result;
}
コード例 #2
0
 /**
  * Get available groups
  *
  * @global vB_Registry $vbulletin
  * @param array $member_group_id_list
  * @return array
  */
 public function get_avaliable_group_list($member_group_id_list)
 {
     $active_groups = $this->get_groups_list(true);
     global $vbulletin;
     if (empty($active_groups)) {
         return $active_groups;
     }
     require_once DIR . '/includes/functions.php';
     cache_ordered_forums();
     $forum_permissions = array();
     foreach (array_keys($vbulletin->forumcache) as $forumid) {
         if (!isset($forum_permissions[$forumid])) {
             $forum_permissions[$forumid] = 0;
         }
         foreach ($member_group_id_list as $user_group_id) {
             $forum_permissions[$forumid] |= $vbulletin->forumcache[$forumid]['permissions'][$user_group_id];
         }
     }
     $forum_id_list = array();
     // Get forums that allow canview access
     foreach ($forum_permissions as $forumid => $perm) {
         if ($perm & $vbulletin->bf_ugp_forumpermissions['canview'] and $perm & $vbulletin->bf_ugp_forumpermissions['canviewthreads'] and $perm & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) {
             $forum_id_list[$forumid] = $forumid;
         }
     }
     foreach ($active_groups as $nntpid => &$group) {
         if (isset($forum_id_list[$group['map_id']])) {
             $group['available'] = true;
         }
     }
     return $active_groups;
 }
コード例 #3
0
ファイル: api_forumlist.php プロジェクト: 0hyeah/yurivn
 public function output()
 {
     global $vbulletin;
     require_once DIR . '/includes/functions_forumlist.php';
     if (empty($vbulletin->iforumcache)) {
         cache_ordered_forums(1, 1);
     }
     return $this->getforumlist(-1);
 }
コード例 #4
0
/**
 * Constructs a Forum Jump Menu for use when moving an item to a new forum
 *
 * @param	integer	The "Root" ID from which to generate this Menu
 * @param	integer	A Forum ID to "exclude" from the menu
 * @param	integer	If 1, removes all previous information from the Forum Jump Menu
 * @param	string	Characters to prepend to the items in the Jump Box
 *
 * @return	string	The generated forum jump menu
 *
 */
function construct_move_forums_options($parentid = -1, $excludeforumid = NULL, $addbox = 1, $prependchars = '')
{
    global $vbulletin, $optionselected, $jumpforumid, $jumpforumtitle, $jumpforumbits, $vbphrase, $curforumid;
    if (empty($vbulletin->iforumcache)) {
        // get the vbulletin->iforumcache, as we use it all over the place, not just for forumjump
        cache_ordered_forums(0, 1);
    }
    if (empty($vbulletin->iforumcache["{$parentid}"]) or !is_array($vbulletin->iforumcache["{$parentid}"])) {
        return;
    }
    if ($addbox == 1) {
        $jumpforumbits = array();
    }
    foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) {
        $forumperms =& $vbulletin->userinfo['forumpermissions']["{$forumid}"];
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'])) {
            continue;
        } else {
            // set $forum from the $vbulletin->forumcache
            $forum = $vbulletin->forumcache["{$forumid}"];
            $optionvalue = $forumid;
            $optiontitle = $prependchars . $forum[title];
            if ($forum['link']) {
                $optiontitle .= " ({$vbphrase['link']})";
            } else {
                if (!($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads'])) {
                    $optiontitle .= " ({$vbphrase['category']})";
                } else {
                    if (!($forum['options'] & $vbulletin->bf_misc_forumoptions['allowposting'])) {
                        $optiontitle .= " ({$vbphrase['no_posting']})";
                    }
                }
            }
            $optionclass = 'd' . iif($forum['depth'] > 3, 3, $forum['depth']);
            if ($curforumid == $optionvalue) {
                $optionselected = ' ' . 'selected="selected"';
                $optionclass .= ' fjsel';
                $selectedone = 1;
            } else {
                $optionselected = '';
            }
            if ($excludeforumid == NULL or $excludeforumid != $forumid) {
                $jumpforumbits[$forumid] = array('optiontitle' => $optiontitle, 'optionvalue' => $optionvalue, 'optionselected' => $optionselected, 'optionclass' => $optionclass);
            }
            construct_move_forums_options($optionvalue, $excludeforumid, 0, $prependchars ? $prependchars . '    ' : '    ');
        }
        // if can view
    }
    // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid)
    return $jumpforumbits;
}
コード例 #5
0
ファイル: api_forumlist.php プロジェクト: 0hyeah/yurivn
 public function output()
 {
     global $vbulletin;
     //
     //	Get forum subscription info for this user
     //
     $this->subscribed_forums = array();
     if ($vbulletin->userinfo['userid']) {
         $results = $vbulletin->db->query_read_slave("\n\t\t\t\tSELECT subscribe.userid, subscribe.forumid, forum.*\n\t\t\t\tFROM " . TABLE_PREFIX . "subscribeforum AS subscribe\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "forum AS forum ON (subscribe.forumid = forum.forumid)\n\t\t\t\tWHERE subscribe.userid = " . $vbulletin->userinfo['userid']);
         while ($row = $vbulletin->db->fetch_array($results)) {
             $this->subscribed_forums[$row['forumid']] = $row;
         }
     }
     require_once DIR . '/includes/functions_forumlist.php';
     if (empty($vbulletin->iforumcache)) {
         cache_ordered_forums(1, 1);
     }
     return $this->getforumlist(-1);
 }
コード例 #6
0
ファイル: subscribeforums.php プロジェクト: holandacz/nb4
    print_no_permission();
}
if (empty($_REQUEST['action'])) {
    if (empty($_REQUEST['do'])) {
        $_REQUEST['do'] = 'list';
    }
}
// ###########################################################################
// ############################### LIST FORUMS ###############################
// ###########################################################################
if ($_REQUEST['do'] == "list") {
    if (!$vbulletin->userinfo['userid']) {
        print_no_permission();
    }
    // get all forums
    cache_ordered_forums(1, 0);
    $show['forums'] = true;
    $showallinstant = 0;
    //generate the radio button form
    foreach ($vbulletin->forumcache as $forumid => $forum) {
        if (!$forum['link']) {
            $showinstant = 0;
            //get full forum info
            $forum = fetch_foruminfo($forum["forumid"], false);
            //if the user has permission to view the given forum, and if forum is postable...
            if ($perms = fetch_permissions($forum["forumid"]) and $perms & $vbulletin->bf_ugp_forumpermissions["canview"] and $forum["cancontainthreads"] and $forum["displayorder"] > 0 and $forum["options"] & $vbulletin->bf_misc_forumoptions['active']) {
                //get the level of the subscription for the given forum
                $sub_level = $db->query_first("\r\n\t\t\t\t\tSELECT emailupdate\r\n\t\t\t\t\tFROM " . TABLE_PREFIX . "subscribeforum\r\n\t\t\t\t\tWHERE forumid = '" . $forum["forumid"] . "' AND userid = " . $vbulletin->userinfo['userid'] . " LIMIT 1\r\n\t\t\t\t");
                $usergroupids = explode(",", $forum["ei_usergroups"]);
                //if the user hits the set all none or set all instant buttons...
                if ($_REQUEST["setall"] == "none") {
コード例 #7
0
ファイル: post.php プロジェクト: 0hyeah/yurivn
function do_post_edit()
{
    global $vbulletin, $db, $foruminfo, $forumperms, $threadinfo;
    global $postinfo, $vbphrase, $stylevar, $permissions;
    $checked = array();
    $edit = array();
    $postattach = array();
    $contenttype = 'vBForum_Post';
    if (!$postinfo['postid'] or $postinfo['isdeleted'] or !$postinfo['visible'] and !can_moderate($threadinfo['forumid'], 'canmoderateposts')) {
        json_error(ERR_INVALID_TOP, RV_POST_ERROR);
    }
    if (!$threadinfo['threadid'] or $threadinfo['isdeleted'] or !$threadinfo['visible'] and !can_moderate($threadinfo['forumid'], 'canmoderateposts')) {
        json_error(ERR_INVALID_TOP, RV_POST_ERROR);
    }
    if ($vbulletin->options['wordwrap']) {
        $threadinfo['title'] = fetch_word_wrapped_string($threadinfo['title']);
    }
    // get permissions info
    $_permsgetter_ = 'edit post';
    $forumperms = fetch_permissions($threadinfo['forumid']);
    if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and ($threadinfo['postuserid'] != $vbulletin->userinfo['userid'] or $vbulletin->userinfo['userid'] == 0)) {
        json_error(ERR_NO_PERMISSION, RV_POST_ERROR);
    }
    $foruminfo = fetch_foruminfo($threadinfo['forumid'], false);
    // check if there is a forum password and if so, ensure the user has it set
    verify_forum_password($foruminfo['forumid'], $foruminfo['password']);
    // need to get last post-type information
    cache_ordered_forums(1);
    // determine if we are allowed to be updating the thread's info
    $can_update_thread = ($threadinfo['firstpostid'] == $postinfo['postid'] and (can_moderate($threadinfo['forumid'], 'caneditthreads') or $postinfo['dateline'] + $vbulletin->options['editthreadtitlelimit'] * 60 > TIMENOW));
    // otherwise, post is being edited
    if (!can_moderate($threadinfo['forumid'], 'caneditposts')) {
        // check for moderator
        if (!$threadinfo['open']) {
            $vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t={$threadinfo['threadid']}";
            json_error(fetch_error('threadclosed'), RV_POST_ERROR);
        }
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['caneditpost'])) {
            json_error(ERR_NO_PERMISSION, RV_POST_ERROR);
        } else {
            if ($vbulletin->userinfo['userid'] != $postinfo['userid']) {
                // check user owns this post
                json_error(ERR_NO_PERMISSION, RV_POST_ERROR);
            } else {
                // check for time limits
                if ($postinfo['dateline'] < TIMENOW - $vbulletin->options['edittimelimit'] * 60 and $vbulletin->options['edittimelimit'] != 0) {
                    json_error(fetch_error('edittimelimit', $vbulletin->options['edittimelimit'], $vbulletin->options['contactuslink']), RV_POST_ERROR);
                }
            }
        }
    }
    // Variables reused in templates
    $poststarttime =& $vbulletin->input->clean_gpc('r', poststarttime, TYPE_UINT);
    $posthash = md5($vbulletin->GPC['poststarttime'] . $vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt']);
    $vbulletin->input->clean_array_gpc('p', array('stickunstick' => TYPE_BOOL, 'openclose' => TYPE_BOOL, 'wysiwyg' => TYPE_BOOL, 'message' => TYPE_STR, 'title' => TYPE_STR, 'prefixid' => TYPE_NOHTML, 'iconid' => TYPE_UINT, 'parseurl' => TYPE_BOOL, 'signature' => TYPE_BOOL, 'disablesmilies' => TYPE_BOOL, 'reason' => TYPE_NOHTML, 'preview' => TYPE_STR, 'folderid' => TYPE_UINT, 'emailupdate' => TYPE_UINT, 'ajax' => TYPE_BOOL, 'advanced' => TYPE_BOOL, 'postcount' => TYPE_UINT, 'podcasturl' => TYPE_STR, 'podcastsize' => TYPE_UINT, 'podcastexplicit' => TYPE_BOOL, 'podcastkeywords' => TYPE_STR, 'podcastsubtitle' => TYPE_STR, 'podcastauthor' => TYPE_STR, 'quickeditnoajax' => TYPE_BOOL));
    if ($vbulletin->GPC['message']) {
        $vbulletin->GPC['message'] = prepare_remote_utf8_string($vbulletin->GPC['message']);
    }
    $vbulletin->GPC['signature'] = $vbulletin->GPC_exists['signature'] = true;
    // Make sure the posthash is valid
    ($hook = vBulletinHook::fetch_hook('editpost_update_start')) ? eval($hook) : false;
    if (md5($poststarttime . $vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt']) != $posthash) {
        $posthash = 'invalid posthash';
        // don't phrase me
    }
    // ### PREP INPUT ###
    if ($vbulletin->GPC['wysiwyg']) {
        require_once DIR . '/includes/functions_wysiwyg.php';
        $edit['message'] = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], $foruminfo['allowhtml']);
    } else {
        $edit['message'] =& $vbulletin->GPC['message'];
    }
    $cansubscribe = true;
    // Are we editing someone else's post? If so load that users subscription info for this thread.
    if ($vbulletin->userinfo['userid'] != $postinfo['userid']) {
        if ($postinfo['userid']) {
            $userinfo = fetch_userinfo($postinfo['userid']);
            cache_permissions($userinfo);
        }
        $cansubscribe = ($userinfo['forumpermissions']["{$foruminfo['forumid']}"] & $vbulletin->bf_ugp_forumpermissions['canview'] and $userinfo['forumpermissions']["{$foruminfo['forumid']}"] & $vbulletin->bf_ugp_forumpermissions['canviewthreads'] and ($threadinfo['postuserid'] == $userinfo['userid'] or $userinfo['forumpermissions']["{$foruminfo['forumid']}"] & $vbulletin->bf_ugp_forumpermissions['canviewothers']));
        if ($cansubscribe and $otherthreadinfo = $db->query_first_slave("\n\t\t\tSELECT emailupdate, folderid\n\t\t\tFROM " . TABLE_PREFIX . "subscribethread\n\t\t\tWHERE threadid = {$threadinfo['threadid']} AND\n\t\t\t\tuserid = {$postinfo['userid']} AND\n\t\t\t\tcanview = 1")) {
            $threadinfo['issubscribed'] = true;
            $threadinfo['emailupdate'] = $otherthreadinfo['emailupdate'];
            $threadinfo['folderid'] = $otherthreadinfo['folderid'];
        } else {
            $threadinfo['issubscribed'] = false;
            // use whatever emailupdate setting came through
        }
    }
    if ($vbulletin->GPC['ajax'] or $vbulletin->GPC['quickeditnoajax']) {
        // quick edit
        $tmpmessage = $vbulletin->GPC['ajax'] ? convert_urlencoded_unicode($edit['message']) : $edit['message'];
        $edit = $postinfo;
        $edit['message'] =& $tmpmessage;
        $edit['title'] = unhtmlspecialchars($edit['title']);
        $edit['signature'] =& $edit['showsignature'];
        $edit['enablesmilies'] =& $edit['allowsmilie'];
        $edit['disablesmilies'] = $edit['enablesmilies'] ? 0 : 1;
        $edit['parseurl'] = true;
        $edit['prefixid'] = $threadinfo['prefixid'];
        $edit['reason'] = fetch_censored_text($vbulletin->GPC['ajax'] ? convert_urlencoded_unicode($vbulletin->GPC['reason']) : $vbulletin->GPC['reason']);
    } else {
        $edit['iconid'] =& $vbulletin->GPC['iconid'];
        $edit['title'] =& $vbulletin->GPC['title'];
        $edit['prefixid'] = ($vbulletin->GPC_exists['prefixid'] and can_use_prefix($vbulletin->GPC['prefixid'])) ? $vbulletin->GPC['prefixid'] : $threadinfo['prefixid'];
        $edit['podcasturl'] =& $vbulletin->GPC['podcasturl'];
        $edit['podcastsize'] =& $vbulletin->GPC['podcastsize'];
        $edit['podcastexplicit'] =& $vbulletin->GPC['podcastexplicit'];
        $edit['podcastkeywords'] =& $vbulletin->GPC['podcastkeywords'];
        $edit['podcastsubtitle'] =& $vbulletin->GPC['podcastsubtitle'];
        $edit['podcastauthor'] =& $vbulletin->GPC['podcastauthor'];
        // Leave this off for quickedit->advanced so that a post with unparsed links doesn't get parsed just by going to Advanced Edit
        $edit['parseurl'] = true;
        $edit['signature'] =& $vbulletin->GPC['signature'];
        $edit['disablesmilies'] =& $vbulletin->GPC['disablesmilies'];
        $edit['enablesmilies'] = $edit['allowsmilie'] = $edit['disablesmilies'] ? 0 : 1;
        $edit['stickunstick'] =& $vbulletin->GPC['stickunstick'];
        $edit['openclose'] =& $vbulletin->GPC['openclose'];
        $edit['reason'] = fetch_censored_text($vbulletin->GPC['reason']);
        $edit['preview'] =& $vbulletin->GPC['preview'];
        $edit['folderid'] =& $vbulletin->GPC['folderid'];
        if (!$vbulletin->GPC['advanced']) {
            if ($vbulletin->GPC_exists['emailupdate']) {
                $edit['emailupdate'] =& $vbulletin->GPC['emailupdate'];
            } else {
                $edit['emailupdate'] = array_pop($array = array_keys(fetch_emailchecked($threadinfo)));
            }
        }
    }
    $dataman =& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
    $dataman->set_existing($postinfo);
    ($hook = vBulletinHook::fetch_hook('editpost_update_process')) ? eval($hook) : false;
    // set info
    $dataman->set_info('parseurl', $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_URL and $foruminfo['allowbbcode'] and $edit['parseurl']);
    $dataman->set_info('posthash', $posthash);
    $dataman->set_info('forum', $foruminfo);
    $dataman->set_info('thread', $threadinfo);
    $dataman->set_info('show_title_error', true);
    $dataman->set_info('podcasturl', $edit['podcasturl']);
    $dataman->set_info('podcastsize', $edit['podcastsize']);
    $dataman->set_info('podcastexplicit', $edit['podcastexplicit']);
    $dataman->set_info('podcastkeywords', $edit['podcastkeywords']);
    $dataman->set_info('podcastsubtitle', $edit['podcastsubtitle']);
    $dataman->set_info('podcastauthor', $edit['podcastauthor']);
    if ($postinfo['userid'] == $vbulletin->userinfo['userid']) {
        $dataman->set_info('user', $vbulletin->userinfo);
    }
    // set options
    $dataman->setr('showsignature', $edit['signature']);
    $dataman->setr('allowsmilie', $edit['enablesmilies']);
    // set data
    /*$dataman->setr('userid', $vbulletin->userinfo['userid']);
    	if ($vbulletin->userinfo['userid'] == 0)
    	{
    		$dataman->setr('username', $post['username']);
    	}*/
    $dataman->setr('title', $edit['title']);
    $dataman->setr('pagetext', $edit['message']);
    if ($postinfo['userid'] != $vbulletin->userinfo['userid']) {
        $dataman->setr('iconid', $edit['iconid'], true, false);
    } else {
        $dataman->setr('iconid', $edit['iconid']);
    }
    $postusername = $vbulletin->userinfo['username'];
    $dataman->pre_save();
    if ($dataman->errors) {
        $errors = $dataman->errors;
    }
    if ($dataman->info['podcastsize']) {
        $edit['podcastsize'] = $dataman->info['podcastsize'];
    }
    if (sizeof($errors) > 0) {
        fr_standard_error($errors[0]);
    } else {
        if ($edit['preview']) {
            require_once DIR . '/packages/vbattach/attach.php';
            $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post');
            $postattach = $attach->fetch_postattach($posthash, $postinfo['postid']);
            // ### PREVIEW POST ###
            $postpreview = process_post_preview($edit, $postinfo['userid'], $postattach);
            $previewpost = true;
            $_REQUEST['do'] = 'editpost';
        } else {
            if ($vbulletin->GPC['advanced']) {
                // Don't display preview on QuickEdit->Advanced as parseurl is turned off and so the preview won't be correct unless the post originally had checked to not parse links
                // If you turn on parseurl then the opposite happens and you have to go unparse your links if that is what you want. Compromise
                $_REQUEST['do'] = 'editpost';
            } else {
                // ### POST HAS NO ERRORS ###
                $dataman->save();
                $update_edit_log = true;
                // don't show edited by AND reason unchanged - don't update edit log
                if (!($permissions['genericoptions'] & $vbulletin->bf_ugp_genericoptions['showeditedby']) and $edit['reason'] == $postinfo['edit_reason']) {
                    $update_edit_log = false;
                }
                if ($update_edit_log) {
                    // ug perm: show edited by
                    if ($postinfo['dateline'] < TIMENOW - $vbulletin->options['noeditedbytime'] * 60 or !empty($edit['reason'])) {
                        // save the postedithistory
                        if ($vbulletin->options['postedithistory']) {
                            // insert original post on first edit
                            if (!$db->query_first("SELECT postedithistoryid FROM " . TABLE_PREFIX . "postedithistory WHERE original = 1 AND postid = " . $postinfo['postid'])) {
                                $db->query_write("\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "postedithistory\n\t\t\t\t\t\t\t\t(postid, userid, username, title, iconid, dateline, reason, original, pagetext)\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t({$postinfo['postid']},\n\t\t\t\t\t\t\t\t" . $postinfo['userid'] . ",\n\t\t\t\t\t\t\t\t'" . $db->escape_string($postinfo['username']) . "',\n\t\t\t\t\t\t\t\t'" . $db->escape_string($postinfo['title']) . "',\n\t\t\t\t\t\t\t\t{$postinfo['iconid']},\n\t\t\t\t\t\t\t\t" . $postinfo['dateline'] . ",\n\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t'" . $db->escape_string($postinfo['pagetext']) . "')\n\t\t\t\t\t\t");
                            }
                            // insert the new version
                            $db->query_write("\n\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "postedithistory\n\t\t\t\t\t\t\t(postid, userid, username, title, iconid, dateline, reason, pagetext)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t({$postinfo['postid']},\n\t\t\t\t\t\t\t" . $vbulletin->userinfo['userid'] . ",\n\t\t\t\t\t\t\t'" . $db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t\t\t'" . $db->escape_string($edit['title']) . "',\n\t\t\t\t\t\t\t{$edit['iconid']},\n\t\t\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t\t\t'" . $db->escape_string($edit['reason']) . "',\n\t\t\t\t\t\t\t'" . $db->escape_string($edit['message']) . "')\n\t\t\t\t\t");
                        }
                        /*insert query*/
                        $db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "editlog\n\t\t\t\t\t\t(postid, userid, username, dateline, reason, hashistory)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t({$postinfo['postid']},\n\t\t\t\t\t\t" . $vbulletin->userinfo['userid'] . ",\n\t\t\t\t\t\t'" . $db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t\t'" . $db->escape_string($edit['reason']) . "',\n\t\t\t\t\t\t" . ($vbulletin->options['postedithistory'] ? 1 : 0) . ")\n\t\t\t\t");
                    }
                }
                $date = vbdate($vbulletin->options['dateformat'], TIMENOW);
                $time = vbdate($vbulletin->options['timeformat'], TIMENOW);
                // initialize thread / forum update clauses
                $forumupdate = false;
                $threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost');
                $threadman->set_existing($threadinfo);
                $threadman->set_info('pagetext', $edit['message']);
                if ($can_update_thread and $edit['title'] != '') {
                    // need to update thread title and iconid
                    if (!can_moderate($threadinfo['forumid'])) {
                        $threadman->set_info('skip_moderator_log', true);
                    }
                    $threadman->set_info('skip_first_post_update', true);
                    if ($edit['title'] != $postinfo['title']) {
                        $threadman->set('title', unhtmlspecialchars($edit['title']));
                    }
                    if ($edit['iconid'] != $postinfo['iconid']) {
                        $threadman->set('iconid', $edit['iconid']);
                    }
                    if ($vbulletin->GPC_exists['prefixid'] and can_use_prefix($vbulletin->GPC['prefixid'])) {
                        $threadman->set('prefixid', $vbulletin->GPC['prefixid']);
                        if ($threadman->thread['prefixid'] === '' and $foruminfo['options'] & $vbulletin->bf_misc_forumoptions['prefixrequired']) {
                            // the prefix wasn't valid or was set to an empty one, but that's not allowed
                            $threadman->do_unset('prefixid');
                        }
                    }
                    // do we need to update the forum counters?
                    $forumupdate = $foruminfo['lastthreadid'] == $threadinfo['threadid'] ? true : false;
                }
                // can this user open/close this thread if they want to?
                if ($vbulletin->GPC['openclose'] and ($threadinfo['postuserid'] != 0 and $threadinfo['postuserid'] == $vbulletin->userinfo['userid'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canopenclose'] or can_moderate($threadinfo['forumid'], 'canopenclose'))) {
                    $threadman->set('open', $threadman->fetch_field('open') == 1 ? 0 : 1);
                }
                if ($vbulletin->GPC['stickunstick'] and can_moderate($threadinfo['forumid'], 'canmanagethreads')) {
                    $threadman->set('sticky', $threadman->fetch_field('sticky') == 1 ? 0 : 1);
                }
                ($hook = vBulletinHook::fetch_hook('editpost_update_thread')) ? eval($hook) : false;
                $threadman->save();
                // if this is a mod edit, then log it
                if ($vbulletin->userinfo['userid'] != $postinfo['userid'] and can_moderate($threadinfo['forumid'], 'caneditposts')) {
                    $modlog = array('threadid' => $threadinfo['threadid'], 'forumid' => $threadinfo['forumid'], 'postid' => $postinfo['postid']);
                    log_moderator_action($modlog, 'post_x_edited', $postinfo['title']);
                }
                require_once DIR . '/includes/functions_databuild.php';
                // do forum update if necessary
                if ($forumupdate) {
                    build_forum_counters($threadinfo['forumid']);
                }
                // don't do thread subscriptions if we are doing quick edit
                if (!$vbulletin->GPC['ajax'] and !$vbulletin->GPC['quickeditnoajax']) {
                    // ### DO THREAD SUBSCRIPTION ###
                    // We use $postinfo[userid] so that we update the user who posted this, not the user who is editing this
                    if (!$threadinfo['issubscribed'] and $edit['emailupdate'] != 9999) {
                        // user is not subscribed to this thread so insert it
                        /*insert query*/
                        $db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid, canview)\n\t\t\t\t\tVALUES ({$postinfo['userid']}, {$threadinfo['threadid']}, {$edit['emailupdate']}, {$edit['folderid']}, 1)\n\t\t\t\t");
                    } else {
                        // User is subscribed, see if they changed the settings for this thread
                        if ($edit['emailupdate'] == 9999) {
                            // Remove this subscription, user chose 'No Subscription'
                            /*insert query*/
                            $db->query_write("\n\t\t\t\t\t\tDELETE FROM " . TABLE_PREFIX . "subscribethread\n\t\t\t\t\t\tWHERE threadid = {$threadinfo['threadid']}\n\t\t\t\t\t\t\tAND userid = {$postinfo['userid']}\n\t\t\t\t\t");
                        } else {
                            if ($threadinfo['emailupdate'] != $edit['emailupdate'] or $threadinfo['folderid'] != $edit['folderid']) {
                                // User changed the settings so update the current record
                                /*insert query*/
                                $db->query_write("\n\t\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid, canview)\n\t\t\t\t\t\tVALUES ({$postinfo['userid']}, {$threadinfo['threadid']}, {$edit['emailupdate']}, {$edit['folderid']}, 1)\n\t\t\t\t\t");
                            }
                        }
                    }
                }
                ($hook = vBulletinHook::fetch_hook('editpost_update_complete')) ? eval($hook) : false;
            }
        }
    }
    return array('success' => true);
}
コード例 #8
0
/**
* Marks a forum as read using the appropriate method.
*
* @param	array	Array of data for the forum being marked
* @param	integer	User ID this thread is being marked read for
* @param	integer	Unix timestamp that the thread is being marked read
* @param	boolean	Whether to automatically check if the parents' read times need to be updated
*
* @return	array	Returns an array of forums that were marked as read
*/
function mark_forum_read(&$foruminfo, $userid, $time, $check_parents = true)
{
	global $vbulletin, $db;

	if (empty($foruminfo['forumid']))
	{
		// sanity check -- wouldn't work anyway
		return array();
	}

	$userid = intval($userid);
	$time = intval($time);
	$forums_marked = array($foruminfo['forumid']);

	if ($vbulletin->options['threadmarking'] AND $userid)
	{

		$db->query_write("
			REPLACE INTO " . TABLE_PREFIX . "forumread
				(forumid, userid, readtime)
			VALUES
				($foruminfo[forumid], $userid, $time)
		");

		if (!$check_parents)
		{
			return $forums_marked;
		}

		// check to see if any parent forums should be marked as read as well
		$parentarray = array_diff(explode(',', $foruminfo['parentlist']), array($foruminfo['forumid'], -1));
		if (!empty($parentarray))
		{
			// find the top most entry in the parent list -- we need its child list
			$top_parentid = end($parentarray);
			$top_foruminfo = $vbulletin->forumcache["$top_parentid"];
			if (!$top_foruminfo['childlist'])
			{
				return $forums_marked;
			}

			// fetch the effective (including children) and raw last post times
			static $lastpostset = false, $rawlastpostinfo;
			if (!$lastpostset)
			{
				$lastpostset = true;
				require_once(DIR . '/includes/functions_forumlist.php');
				cache_ordered_forums(1);
				$rawlastpostinfo = $vbulletin->forumcache;
				fetch_last_post_array();
			}

			// determine the read time for all forums that we need to consider
			$readtimes = array();
			$readtimes_query = $db->query_read_slave("
				SELECT forumid, readtime
				FROM " . TABLE_PREFIX . "forumread
				WHERE userid = $userid
					AND forumid IN ($top_foruminfo[childlist])
			");
			while ($readtime = $db->fetch_array($readtimes_query))
			{
				$readtimes["$readtime[forumid]"] = $readtime['readtime'];
			}

			$cutoff = (TIMENOW - ($vbulletin->options['markinglimit'] * 86400));

			// now work through the parent, grandparent, etc of the forum we just marked
			// and mark it read only if all direct children are marked read
			foreach ($parentarray AS $parentid)
			{
				if (empty($vbulletin->forumcache["$parentid"]))
				{
					continue;
				}

				$markread = true;

				// now look through all the children and confirm they are all read
				if (is_array($vbulletin->iforumcache["$parentid"]))
				{
					foreach ($vbulletin->iforumcache["$parentid"] AS $childid)
					{
						if (max($cutoff, $readtimes["$childid"]) < $vbulletin->forumcache["$childid"]['lastpost'])
						{
							$markread = false;
							break;
						}
					}
				}

				// if all children are read, make sure all the threads in this forum are read too
				if ($markread)
				{
					$forumread = intval(max($readtimes["$parentid"], $cutoff));
					$unread = $db->query_first("
						SELECT COUNT(*) AS count
			 			FROM " . TABLE_PREFIX . "thread AS thread
			 			LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = $userid)
			 			WHERE thread.forumid = $parentid
				      		AND thread.visible = 1
				      		AND thread.sticky IN (0,1)
				      		AND thread.lastpost > $forumread
				      		AND thread.open <> 10
				      		AND (threadread.threadid IS NULL OR threadread.readtime < thread.lastpost)
					");
					if ($unread['count'] > 0)
					{
						$markread = false;
					}
				}

				if ($markread)
				{
					// can mark as read
					$readtimes["$parentid"] = $time;
					$parents[] = "($parentid, $userid, $time)";
					$forums_marked[] = $parentid;
				}
				else
				{
					// can't mark this as read, so we have no need to continue with further generations
					break;
				}
			}

			if ($parents)
			{
				$db->query_write("
					REPLACE INTO " . TABLE_PREFIX . "forumread
						(forumid, userid, readtime)
					VALUES
						" . implode(', ', $parents)
				);
			}
		}
	}
	else
	{
		set_bbarray_cookie('forum_view', $foruminfo['forumid'], $time);
	}

	return $forums_marked;
}
コード例 #9
0
ファイル: forumdisplay.php プロジェクト: hungnv0789/vhtm
{
	$vbulletin->options['threadpreview'] = 0;
}

// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($foruminfo['forumid'], $foruminfo['password']);

// verify that we are at the canonical SEO url
// and redirect to this if not
verify_seo_url('forum', $foruminfo, array('pagenumber' => $_REQUEST['pagenumber']));

// get vbulletin->iforumcache - for use by makeforumjump and forums list
// fetch the forum even if they are invisible since its needed
// for the title but we'll unset that further down
// also fetch subscription info for $show['subscribed'] variable
cache_ordered_forums(1, 1, $vbulletin->userinfo['userid']);

$show['newthreadlink'] = iif(!$show['search_engine'] AND $foruminfo['allowposting'], true, false);
$show['threadicons'] = iif ($foruminfo['allowicons'], true, false);
$show['threadratings'] = iif ($foruminfo['allowratings'], true, false);
$show['subscribed_to_forum'] = ($vbulletin->forumcache["$foruminfo[forumid]"]['subscribeforumid'] != '' ? true : false);

if (!$daysprune)
{
	if ($vbulletin->userinfo['daysprune'])
	{
		$daysprune = $vbulletin->userinfo['daysprune'];
	}
	else
	{
		$daysprune = iif($foruminfo['daysprune'], $foruminfo['daysprune'], 30);
コード例 #10
0
function print_forums($parentid = -1, $indent = "\t")
{
    // new version - DRASTICALLY reduces queries...
    global $vbulletin, $imodcache, $accesscache, $vbphrase;
    // check to see if we need to do the queries
    if (empty($vbulletin->iforumcache)) {
        cache_ordered_forums(0, 1);
    }
    if (!is_array($imodcache)) {
        require_once DIR . '/includes/functions_forumlist.php';
        cache_moderators();
    }
    // check to see if this forum actually exists / has children
    if (empty($vbulletin->iforumcache["{$parentid}"])) {
        return;
    }
    foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) {
        $forum =& $vbulletin->forumcache["{$forumid}"];
        echo "{$indent}<ul class=\"lsq\">\n";
        // forum title and links
        echo "{$indent}<li><b><a name=\"forum{$forumid}\" href=\"forum.php?{$session['sessionurl']}do=edit&amp;f={$forumid}\">{$forum['title']}</a> <span class=\"smallfont\">(" . construct_link_code($vbphrase['reset'], "accessmask.php?{$session['sessionurl']}do=resetforum&amp;f={$forumid}&amp;hash=" . CP_SESSIONHASH) . ")</span></b>";
        // get moderators
        if (is_array($imodcache["{$forumid}"])) {
            echo "<span class=\"smallfont\"><br /> - <i>" . $vbphrase['moderators'] . ":";
            foreach ($imodcache["{$forumid}"] as $moderator) {
                // moderator username and links
                echo " <a href=\"moderator.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;moderatorid={$moderator['moderatorid']}\">{$moderator['username']}</a>";
            }
            echo "</i></span>";
        }
        $allaccessmasks = 0;
        $forbidden = '';
        $permitted = '';
        $deny = $accesscache["{$forumid}"]['0'];
        $permit = $accesscache["{$forumid}"]['1'];
        /*echo "<pre>--$forumid--\n";
        		print_r($accesscache["$forumid"]);
        		echo '</pre>';*/
        if (is_array($deny)) {
            $forbidden = "{$indent}\t<li class=\"am-deny\"><b>" . construct_phrase($vbphrase['access_denied_x_users'], $deny['count']) . '</b>' . construct_link_code($vbphrase['display_users'], "accessmask.php?" . $vbulletin->session->vars['sessionurl'] . "&do=edit&f={$forumid}&accessmask={$deny['accessmask']}") . "</li>\n";
            $allaccessmasks = $deny['count'];
        }
        if (is_array($permit)) {
            $permitted = "{$indent}\t<li class=\"am-grant\"><b>" . construct_phrase($vbphrase['access_granted_x_users'], $permit['count']) . '</b>' . construct_link_code($vbphrase['display_users'], "accessmask.php?" . $vbulletin->session->vars['sessionurl'] . "&do=edit&f={$forumid}&accessmask={$permit['accessmask']}") . "</li>\n";
            $allaccessmasks = $allaccessmasks + $permit['count'];
        }
        if ($allaccessmasks > 0) {
            echo "{$indent}\t<ul class=\"usergroups\">\n";
            echo "{$indent}\t<li>" . construct_phrase($vbphrase['x_access_masks_set'], $allaccessmasks) . ' ' . construct_link_code('<b>' . $vbphrase['display_all_users'] . '</b>', "accessmask.php?" . $vbulletin->session->vars['sessionurl'] . "&do=edit&f={$forum['forumid']}&accessmask=2") . "</li>";
            echo $permitted;
            echo $forbidden;
            echo "{$indent}\t</ul><br />\n";
        } else {
            echo "{$indent}\t\n";
            echo "{$indent}\t<br />\n";
        }
        print_forums($forumid, "{$indent}\t");
        echo "{$indent}</li>\n";
        echo "{$indent}</ul>\n";
        if ($forum['parentid'] == -1) {
            echo "<hr size=\"1\" />\n";
        }
    }
    unset($vbulletin->iforumcache["{$parentid}"]);
}
コード例 #11
0
ファイル: forum.php プロジェクト: 0hyeah/yurivn
 /**
  * Does this forum allow icons
  *
  * @return boolean
  */
 public function get_last_read_by_current_user($user)
 {
     global $vbulletin;
     if ($vbulletin->options['threadmarking'] and !$user->isGuest()) {
         //deal with the fact that the forum cache (from which we likely loaded this object)
         //doesn't have the forumread field.
         //we should consider a query to just look the value up for this forum -- it will likely
         //be faster in actual use and will almost certainly be simpler
         if (!$this->has_field('forumread')) {
             if (array_key_exists('forumread', $vbulletin->forumcache[$this->get_field('forumid')])) {
                 $this->set_field('forumread', $vbulletin->forumcache[$this->get_field('forumid')]['forumread']);
             } else {
                 //if we don't have forum read in the cache, then reload the cache.
                 //this implicitly references the current
                 cache_ordered_forums(1);
                 $this->set_field('forumread', $vbulletin->forumcache[$this->get_field('forumid')]['forumread']);
             }
         }
         return max($this->get_field('forumread'), TIMENOW - $vbulletin->options['markinglimit'] * 86400);
     } else {
         $forumview = intval(fetch_bbarray_cookie('forum_view', $this->get_field('forumid')));
         //use which one produces the highest value, most likely cookie
         return $forumview > $vbulletin->userinfo['lastvisit'] ? $forumview : $vbulletin->userinfo['lastvisit'];
     }
 }
コード例 #12
0
ファイル: moderation.php プロジェクト: 0hyeah/yurivn
function get_forums($parentid = -1, &$forums)
{
    global $vbulletin, $db, $foruminfo, $forumperms, $threadinfo, $postinfo, $vbphrase;
    if (empty($vbulletin->iforumcache)) {
        // get the vbulletin->iforumcache, as we use it all over the place, not just for forumjump
        cache_ordered_forums(0, 1);
    }
    if (is_array($vbulletin->iforumcache[$parentid])) {
        foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) {
            $forumperms =& $vbulletin->userinfo['forumpermissions']["{$forumid}"];
            if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'])) {
                continue;
            } else {
                // set $forum from the $vbulletin->forumcache
                $forum = $vbulletin->forumcache["{$forumid}"];
                $optionvalue = $forumid;
                $optiontitle = $forum[title];
                $ok = true;
                if ($forum['link']) {
                    $ok = false;
                } else {
                    if (!($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads'])) {
                        $ok = false;
                    } else {
                        if (!($forum['options'] & $vbulletin->bf_misc_forumoptions['allowposting'])) {
                            $ok = false;
                        }
                    }
                }
                if ($ok) {
                    $forums[] = array('id' => $forumid, 'title' => prepare_utf8_string($optiontitle));
                }
                get_forums($forumid, $forums);
            }
            // if can view
        }
        // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid)
    }
}
コード例 #13
0
ファイル: cv_rss_feeds.php プロジェクト: holandacz/nb4
function cv_construct_forum_list($parentid = -1, &$ret, $depth = 0)
{
    global $vbulletin, $stylevar, $vbphrase, $defaultselected, $forum_url, $debug_mode, $use_vbseo_links, $excluded_forums;
    $parent_count = 0;
    if (!($vbulletin->userinfo['permissions']['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview'])) {
        return $ret;
    }
    if (empty($vbulletin->iforumcache)) {
        require_once './includes/functions_forumlist.php';
        cache_ordered_forums(1, 1);
    }
    if (empty($vbulletin->iforumcache["{$parentid}"]) or !is_array($vbulletin->iforumcache["{$parentid}"])) {
        return $ret;
    }
    foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) {
        $forum = $vbulletin->forumcache["{$forumid}"];
        $forum_title = $forum[title_clean];
        $forum_desc = strip_tags($forum['description']);
        if ($vbulletin->options['cv_ffl_permissions_usergroupid']) {
            $forumperms = $forum['permissions'][$vbulletin->options['cv_ffl_permissions_usergroupid']];
        } else {
            $forumperms = $vbulletin->userinfo['forumpermissions']["{$forumid}"];
        }
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and !$vbulletin->options['showprivateforums'] or !$forum['displayorder'] or !($forum['options'] & $vbulletin->bf_misc_forumoptions['active']) or $forum['link'] and !$vbulletin->options['cv_ffl_show_linked'] and !$forum['nametitle'] or $excluded_forums and in_array($forum['forumid'], $excluded_forums)) {
            if ($debug_mode) {
                $debug_msg = 'SKIPPING FORUM ' . $forum[forumid] . ' - ' . $forum_title . ' ... ';
                eval('$ret .= "' . fetch_template('cv_ffl_debug_msg') . '";');
                if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and !$vbulletin->options['showprivateforums']) {
                    $debug_msg = 'User does not have permissions to view the forum';
                    eval('$ret .= "' . fetch_template('cv_ffl_debug_msg') . '";');
                }
                if (!$forum['displayorder']) {
                    $debug_msg = 'Forum does not have a display order assigned to it';
                    eval('$ret .= "' . fetch_template('cv_ffl_debug_msg') . '";');
                }
                if (!($forum['options'] & $vbulletin->bf_misc_forumoptions['active'])) {
                    $debug_msg = 'Forum is not active';
                    eval('$ret .= "' . fetch_template('cv_ffl_debug_msg') . '";');
                }
                if ($forum['link'] and !$vbulletin->options['cv_ffl_show_linked'] and !$forum['nametitle']) {
                    $debug_msg = 'Forum is a link, not a real forum';
                    eval('$ret .= "' . fetch_template('cv_ffl_debug_msg') . '";');
                }
                if ($excluded_forums and in_array($forum['forumid'], $excluded_forums)) {
                    $debug_msg = 'Forum has been specified in the ACP to be excluded.';
                    eval('$ret .= "' . fetch_template('cv_ffl_debug_msg') . '";');
                }
            }
            continue;
        } else {
            if ($depth == 1) {
                eval('$ret .= "' . fetch_template('cv_ffl_forum_category_seperator') . '";');
            }
            if ($depth >= 2) {
                for ($i = 0; $i < $depth - 2; $i++) {
                    eval('$title_prefix = "' . fetch_template('cv_ffl_forum_sub_forum_indicator') . '";');
                }
            }
            if ($use_vbseo_links) {
                $vbseo_forum_link = vbseo_forum_url($forum['forumid'], 1);
            }
            eval('$forum_link = "' . fetch_template('cv_ffl_forum_link') . '";');
            eval('$forum_feed_link = "' . fetch_template('cv_ffl_forum_feed_link') . '";');
            if ($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads'] and !$forum['link']) {
                eval('$ret .= "' . fetch_template('cv_ffl_forum_bit_posts') . '";');
            } else {
                eval('$ret .= "' . fetch_template('cv_ffl_forum_bit_noposts') . '";');
            }
            // If the current forum has any sub-forums, then create that list
            $depth++;
            cv_construct_forum_list($forumid, $ret, $depth);
            $depth--;
        }
        // if can view
    }
    // end
    return $ret;
}
コード例 #14
0
function ListForums($who, $forumid)
{
    global $db, $vbulletin, $server, $structtypes, $lastpostarray;
    $result = RegisterService($who);
    if ($result['Code'] != 0) {
        $retval['Result'] = $result;
        return $retval;
    }
    $userid = $vbulletin->userinfo['userid'];
    //$xml = new XMLexporter($vbulletin);
    // ### GET FORUMS & MODERATOR iCACHES ########################
    cache_ordered_forums(1, 1);
    if (empty($vbulletin->iforumcache)) {
        $forums = $vbulletin->db->query_read_slave("\r\n            SELECT forumid, title, link, parentid, displayorder, title_clean, description, description_clean,\r\n            (options & " . $vbulletin->bf_misc_forumoptions['cancontainthreads'] . ") AS cancontainthreads\r\n            FROM " . TABLE_PREFIX . "forum AS forum\r\n            WHERE displayorder <> 0 AND\r\n            password = '' AND\r\n            (options & " . $vbulletin->bf_misc_forumoptions['active'] . ")\r\n            ORDER BY displayorder\r\n        ");
        $vbulletin->iforumcache = array();
        while ($forum = $vbulletin->db->fetch_array($forums)) {
            $vbulletin->iforumcache["{$forum['parentid']}"]["{$forum['displayorder']}"]["{$forum['forumid']}"] = $forum;
        }
        unset($forum);
        $vbulletin->db->free_result($forums);
    }
    // define max depth for forums display based on $vbulletin->options[forumhomedepth]
    define('MAXFORUMDEPTH', 1);
    if (is_array($vbulletin->iforumcache["{$forumid}"])) {
        $childarray = $vbulletin->iforumcache["{$forumid}"];
    } else {
        $childarray = array($vbulletin->iforumcache["{$forumid}"]);
    }
    if (!is_array($lastpostarray)) {
        fetch_last_post_array();
    }
    // add the current forum info
    // get the current location title
    $current = $db->query_first("SELECT title FROM " . TABLE_PREFIX . "forum AS forum WHERE (forumid = {$forumid})");
    if (strlen($current['title']) == 0) {
        $current['title'] = 'INDEX';
    }
    $forum = fetch_foruminfo($forumid);
    $lastpostinfo = $vbulletin->forumcache["{$lastpostarray[$forumid]}"];
    $isnew = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
    $curforum['ForumID'] = $forumid;
    $curforum['Title'] = $current['title'];
    $curforum['IsNew'] = $isnew == "new";
    $curforum['IsCurrent'] = true;
    $forumlist = array();
    foreach ($childarray as $subforumid) {
        // hack out the forum id
        $forum = fetch_foruminfo($subforumid);
        if (!$forum['displayorder'] or !($forum['options'] & $vbulletin->bf_misc_forumoptions['active'])) {
            continue;
        }
        $forumperms = $vbulletin->userinfo['forumpermissions']["{$subforumid}"];
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and ($vbulletin->forumcache["{$subforumid}"]['showprivate'] == 1 or !$vbulletin->forumcache["{$subforumid}"]['showprivate'] and !$vbulletin->options['showprivateforums'])) {
            // no permission to view current forum
            continue;
        }
        $lastpostinfo = $vbulletin->forumcache["{$lastpostarray[$subforumid]}"];
        $isnew = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
        $tempforum['ForumID'] = $forum['forumid'];
        $tempforum['Title'] = $forum['title'];
        $tempforum['IsNew'] = $isnew == "new";
        $tempforum['IsCurrent'] = false;
        array_push($forumlist, $tempforum);
        unset($tempforum);
    }
    $result['RemoteUser'] = ConsumeArray($vbulletin->userinfo, $structtypes['RemoteUser']);
    $retval['Result'] = $result;
    $retval['CurrentForum'] = $curforum;
    $retval['ForumList'] = $forumlist;
    return $retval;
}
コード例 #15
0
ファイル: forumpermission.php プロジェクト: holandacz/nb4
    print_description_row("<b><a href=\"forumpermission.php?" . $vbulletin->session->vars['sessionurl'] . "do=duplicate\">" . $vbphrase['permission_duplication_tools'] . "</a> | <a href=\"forumpermission.php?" . $vbulletin->session->vars['sessionurl'] . "do=quickedit\">" . $vbphrase['permissions_quick_editor'] . "</a> | <a href=\"forumpermission.php?" . $vbulletin->session->vars['sessionurl'] . "do=quickforum\">" . $vbphrase['quick_forum_permission_setup'] . "</a></b>", 0, 2, '', 'center');
    print_table_footer();
    print_form_header('', '');
    print_table_header($vbphrase['forum_permissions']);
    print_description_row('
		<div class="darkbg" style="border: 2px inset"><ul class="darkbg">
		<li><b>' . $vbphrase['color_key'] . '</b></li>
		<li class="col-g">' . $vbphrase['standard_using_default_usergroup_permissions'] . '</li>
		<li class="col-c">' . $vbphrase['customized_using_custom_permissions_for_this_usergroup'] . '</li>
		<li class="col-i">' . $vbphrase['inherited_using_custom_permissions_inherited_from_a_parent_forum'] . '</li>
		</ul></div>
	');
    print_table_footer();
    require_once DIR . '/includes/functions_forumlist.php';
    // get forum orders
    cache_ordered_forums(0, 1);
    // get moderators
    cache_moderators();
    // query forum permissions
    $fpermscache = array();
    $forumpermissions = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "forumpermission");
    while ($fp = $db->fetch_array($forumpermissions)) {
        $fpermscache["{$fp['forumid']}"]["{$fp['usergroupid']}"] = $fp;
    }
    // get usergroup default permissions
    $permissions = array();
    foreach ($vbulletin->usergroupcache as $usergroupid => $usergroup) {
        $permissions["{$usergroupid}"] = $usergroup['forumpermissions'];
    }
    ?>
<center>
コード例 #16
0
ファイル: functions.php プロジェクト: hungnv0789/vhtm
/**
* Returns the HTML for the forum jump menu
*
* @param	array		Information about current page (id, title, and link)
* @param	integer	ID of the parent forum for the group to be shown (-1 for all)
* @param	boolean	If true, evaluate the forumjump template too
* @param	boolean	Override $complete
*/
function construct_quick_nav($navpopup = array(), $parentid = -1, $addbox = true, $override = false)
{
	global $vbulletin, $daysprune, $vbphrase, $forumjump;
	static $complete = false;

	if ($override)
	{
		$complete = false;
	}

	if (!$navpopup['id'])
	{
		$navpopup['id'] = 'navpopup';
	}

	if ($complete OR !$vbulletin->options['useforumjump'] OR !($vbulletin->userinfo['permissions']['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']))
	{
		return;
	}

	if (empty($vbulletin->iforumcache))
	{
		// get the vbulletin->iforumcache, as we use it all over the place, not just for forumjump
		cache_ordered_forums(0, 1);
	}

	if (empty($vbulletin->iforumcache["$parentid"]) OR !is_array($vbulletin->iforumcache["$parentid"]))
	{
		return;
	}

	foreach($vbulletin->iforumcache["$parentid"] AS $forumid)
	{
		$forumperms = $vbulletin->userinfo['forumpermissions']["$forumid"];
		if ((!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) AND ($vbulletin->forumcache["$forumid"]['showprivate'] == 1 OR (!$vbulletin->forumcache["$forumid"]['showprivate'] AND !$vbulletin->options['showprivateforums']))) OR !($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['showonforumjump']) OR !$vbulletin->forumcache["$forumid"]['displayorder'] OR !($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['active']))
		{
			continue;
		}
		else
		{
			// set $forum from the $vbulletin->forumcache
			$forum = $vbulletin->forumcache["$forumid"];

			$children = explode(',', trim($forum['childlist']));
			if (sizeof($children) <= 2)
			{
				$templater = vB_Template::create('forumjump_link');
					$templater->register('forum', $forum);
				$jumpforumbits .= $templater->render();
			}
			else
			{
				if ($forumbits = construct_quick_nav($navpopup, $forumid, false))
				{
					$templater = vB_Template::create('forumjump_subforum');
						$forum['depth']++;
						$templater->register('forum', $forum);
						$templater->register('forumbits', $forumbits);
					$jumpforumbits .= $templater->render();
				}
				else
				{
					$templater = vB_Template::create('forumjump_link');
						$templater->register('forum', $forum);
					$jumpforumbits .= $templater->render();
				}
			}
		} // if can view
	} // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid)

	if ($addbox)
	{
		($hook = vBulletinHook::fetch_hook('forumjump')) ? eval($hook) : false;

		$templater = vB_Template::create('forumjump');
			if ($daysprune)
			{
				$templater->register('daysprune', intval($daysprune));
			}
			$templater->register('jumpforumbits', $jumpforumbits);
			$templater->register('navpopup', $navpopup);
		$forumjump = $templater->render();

		// prevent forumjump from being built more than once
		$complete = true;
	}
	else
	{
		return $jumpforumbits;
	}
}
コード例 #17
0
ファイル: get_forum.php プロジェクト: 0hyeah/yurivn
function do_get_forum_data()
{
    global $vbulletin, $db, $show, $vbphrase;
    $vbulletin->input->clean_array_gpc('r', array('forumids' => TYPE_STR));
    if (!$vbulletin->GPC['forumids'] || strlen($vbulletin->GPC['forumids']) == 0) {
        return array('forums' => array());
    }
    cache_ordered_forums(1, 1);
    $forumids = split(',', $vbulletin->GPC['forumids']);
    $forum_data = array();
    foreach ($forumids as $forumid) {
        $foruminfo = fetch_foruminfo($forumid);
        $type = 'old';
        if (is_array($foruminfo) and !empty($foruminfo['link'])) {
            // see if it is a redirect
            $type = 'link';
        } else {
            if ($vbulletin->userinfo['lastvisitdate'] == -1) {
                $type = 'new';
            } else {
                if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) {
                    $userlastvisit = !empty($foruminfo['forumread']) ? $foruminfo['forumread'] : TIMENOW - $vbulletin->options['markinglimit'] * 86400;
                } else {
                    $forumview = intval(fetch_bbarray_cookie('forum_view', $foruminfo['forumid']));
                    //use which one produces the highest value, most likely cookie
                    $userlastvisit = $forumview > $vbulletin->userinfo['lastvisit'] ? $forumview : $vbulletin->userinfo['lastvisit'];
                }
                if ($foruminfo['lastpost'] and $userlastvisit < $foruminfo['lastpost']) {
                    $type = 'new';
                } else {
                    $type = 'old';
                }
            }
        }
        // If this forum has a password, check to see if we have
        // the proper cookie.  If so, don't prompt for one
        $password = false;
        if ($foruminfo['password']) {
            $pw_ok = verify_forum_password($foruminfo['forumid'], $foruminfo['password'], false);
            if (!$pw_ok) {
                $password = true;
            }
        }
        $out = array('id' => $foruminfo['forumid'], 'new' => $type == 'new' ? true : false, 'name' => prepare_utf8_string(strip_tags($foruminfo['title'])), 'password' => $password);
        $icon = fr_get_forum_icon($foruminfo['forumid'], $foruminfo == 'new');
        if ($icon) {
            $out['icon'] = $icon;
        }
        if ($foruminfo['link'] != '') {
            $link = fr_fix_url($foruminfo['link']);
            if (is_int($link)) {
                $out['id'] = $link;
            } else {
                $out['link'] = $link;
            }
            $linkicon = fr_get_forum_icon($foruminfo['forumid'], false, true);
            if ($linkicon) {
                $out['icon'] = $linkicon;
            }
        }
        if ($foruminfo['description'] != '') {
            $desc = prepare_utf8_string(strip_tags($foruminfo['description']));
            if (strlen($desc) > 0) {
                $out['desc'] = $desc;
            }
        }
        $forum_data[] = $out;
    }
    return array('forums' => $forum_data);
}
コード例 #18
0
ファイル: class_dm_forum.php プロジェクト: holandacz/nb4
 /**
  * Verifies that a given forum parent id is not one of its own children
  *
  * @param	integer	The ID of the current forum
  * @param	integer	The ID of the forum's proposed parentid
  *
  * @return	boolean	Returns true if the children of the given parent forum does not include the specified forum... or something
  */
 function is_subforum_of($forumid, $parentid)
 {
     if (empty($this->registry->iforumcache)) {
         cache_ordered_forums(0, 1);
     }
     if (is_array($this->registry->iforumcache["{$forumid}"])) {
         foreach ($this->registry->iforumcache["{$forumid}"] as $curforumid) {
             if ($curforumid == $parentid or !$this->is_subforum_of($curforumid, $parentid)) {
                 $this->error('cant_parent_forum_to_child');
                 return false;
             }
         }
     }
     return true;
 }
コード例 #19
0
/**
 * Constructs a Forum Jump Menu for use when moving an item to a new forum
 *
 * @param	integer	The "Root" ID from which to generate this Menu
 * @param	integer	A Forum ID to "exclude" from the menu
 * @param	integer	If 1, removes all previous information from the Forum Jump Menu
 * @param	string	Characters to prepend to the items in the Jump Box
 *
 * @return	string	The generated forum jump menu
 *
 */
function construct_move_forums_options($parentid = -1, $excludeforumid = NULL, $addbox = 1)
{
	global $vbulletin, $optionselected, $jumpforumid, $jumpforumtitle, $jumpforumbits, $vbphrase, $curforumid;
	if (empty($vbulletin->iforumcache))
	{
		// get the vbulletin->iforumcache, as we use it all over the place, not just for forumjump
		cache_ordered_forums(0, 1);
	}
	if (empty($vbulletin->iforumcache["$parentid"]) OR !is_array($vbulletin->iforumcache["$parentid"]))
	{
		return;
	}

	if ($addbox == 1)
	{
		$jumpforumbits = '';
	}

	foreach($vbulletin->iforumcache["$parentid"] AS $forumid)
	{
		$forumperms =& $vbulletin->userinfo['forumpermissions']["$forumid"];
		if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']))
		{
			continue;
		}
		else
		{
			// set $forum from the $vbulletin->forumcache
			$forum = $vbulletin->forumcache["$forumid"];

			$optionvalue = $forumid;
			$optiontitle = $forum[title];

			if ($forum['link'])
			{
				$optiontitle .= " ($vbphrase[link])";
			}
			else if (!($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads']))
			{
				$optiontitle .= " ($vbphrase[category])";
			}
			else if (!($forum['options'] & $vbulletin->bf_misc_forumoptions['allowposting']))
			{
				$optiontitle .= " ($vbphrase[no_posting])";
			}

			
			$optionclass = 'd' . iif($forum['depth'] > 3, 3, $forum['depth']);

			if ($curforumid == $optionvalue)
			{
				$optionselected = ' ' . 'selected="selected"';
				$optionclass .= ' fjsel';
				$selectedone = 1;
			}
			else
			{
				$optionselected = '';
			}
			if ($excludeforumid == NULL OR $excludeforumid != $forumid)
			{
				$jumpforumbits .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass);
			}

			construct_move_forums_options($optionvalue, $excludeforumid, 0);

		} // if can view
	} // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid)

	return $jumpforumbits;
}
コード例 #20
0
ファイル: functions_user.php プロジェクト: holandacz/nb4
/**
 * Constructs a Forum Jump Menu based on moderator permissions
 *
 * @param	integer	The "root" forum to work from
 * @param	integer	The ID of the forum that is currently selected
 * @param	integer	Characters to prepend to the item in the menu
 * @param	string	The moderator permission to check when building the Forum Jump Menu
 *
 * @return	string	The built forum Jump menu
 *
 */
function construct_mod_forum_jump($parentid = -1, $selectedid, $prependchars, $modpermission = '')
{
    global $vbulletin;
    if (empty($vbulletin->iforumcache)) {
        cache_ordered_forums();
    }
    if (empty($vbulletin->iforumcache["{$parentid}"]) or !is_array($vbulletin->iforumcache["{$parentid}"])) {
        return;
    }
    foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) {
        $forumperms = $vbulletin->userinfo['forumpermissions']["{$forumid}"];
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or $vbulletin->forumcache["{$forumid}"]['link']) {
            continue;
        }
        $children = construct_mod_forum_jump($forumid, $selectedid, $prependchars . FORUM_PREPEND, $modpermission);
        if (!can_moderate($forumid, $modpermission) and !$children) {
            continue;
        }
        // set $forum from the $vbulletin->forumcache
        $forum = $vbulletin->forumcache["{$forumid}"];
        $optionvalue = $forumid;
        $optiontitle = $prependchars . " {$forum['title_clean']} ";
        $optionclass = 'fjdpth' . iif($forum['depth'] > 4, 4, $forum['depth']);
        $optionselected = '';
        if ($selectedid == $optionvalue) {
            $optionselected = 'selected="selected"';
            $optionclass = 'fjsel';
        }
        eval('$forumjumpbits .= "' . fetch_template('option') . '";');
        $forumjumpbits .= $children;
    }
    // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid)
    return $forumjumpbits;
}
コード例 #21
0
ファイル: functions.php プロジェクト: holandacz/nb4
/**
* Returns the HTML for the forum jump menu
*
* @param	integer	ID of the parent forum for the group to be shown (-1 for all)
* @param	boolean	If true, evaluate the forumjump template too
* @param	string	Characters to prepend to forum titles to indicate depth
* @param	string	Not sure actually...
*/
function construct_forum_jump($parentid = -1, $addbox = true, $prependchars = '', $permission = '')
{
    global $vbulletin, $optionselected, $usecategories, $jumpforumid, $jumpforumtitle, $jumpforumbits, $curforumid, $daysprune;
    global $stylevar, $vbphrase, $defaultselected, $forumjump, $selectedone;
    global $frmjmpsel;
    // allows context sensitivity for non-forum areas
    global $gobutton;
    static $complete = false;
    if ($complete or !$vbulletin->options['useforumjump'] or !($vbulletin->userinfo['permissions']['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview'])) {
        return;
    }
    if (empty($vbulletin->iforumcache)) {
        // get the vbulletin->iforumcache, as we use it all over the place, not just for forumjump
        cache_ordered_forums(0, 1);
    }
    if (empty($vbulletin->iforumcache["{$parentid}"]) or !is_array($vbulletin->iforumcache["{$parentid}"])) {
        return;
    }
    foreach ($vbulletin->iforumcache["{$parentid}"] as $forumid) {
        $forumperms = $vbulletin->userinfo['forumpermissions']["{$forumid}"];
        #if ((!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) AND !$vbulletin->options['showprivateforums']) OR !($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['showonforumjump']) OR !$vbulletin->forumcache["$forumid"]['displayorder'] OR !($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['active']))
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) and ($vbulletin->forumcache["{$forumid}"]['showprivate'] == 1 or !$vbulletin->forumcache["{$forumid}"]['showprivate'] and !$vbulletin->options['showprivateforums']) or !($vbulletin->forumcache["{$forumid}"]['options'] & $vbulletin->bf_misc_forumoptions['showonforumjump']) or !$vbulletin->forumcache["{$forumid}"]['displayorder'] or !($vbulletin->forumcache["{$forumid}"]['options'] & $vbulletin->bf_misc_forumoptions['active'])) {
            continue;
        } else {
            // set $forum from the $vbulletin->forumcache
            $forum = $vbulletin->forumcache["{$forumid}"];
            $optionvalue = $forumid;
            $optiontitle = $prependchars . " {$forum['title_clean']}";
            $optionclass = 'fjdpth' . iif($forum['depth'] > 4, 4, $forum['depth']);
            if ($curforumid == $optionvalue) {
                $optionselected = 'selected="selected"';
                $optionclass = 'fjsel';
                $selectedone = 1;
            } else {
                $optionselected = '';
            }
            eval('$jumpforumbits .= "' . fetch_template('option') . '";');
            construct_forum_jump($optionvalue, 0, $prependchars . FORUM_PREPEND, $forumperms);
        }
        // if can view
    }
    // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid)
    if ($addbox) {
        if ($selectedone != 1) {
            $defaultselected = 'selected="selected"';
        }
        if (!is_array($frmjmpsel)) {
            $frmjmpsel = array();
        }
        if (empty($daysprune)) {
            $daysprune = '';
        } else {
            $daysprune = intval($daysprune);
        }
        ($hook = vBulletinHook::fetch_hook('forumjump')) ? eval($hook) : false;
        eval('$forumjump = "' . fetch_template('forumjump') . '";');
        // prevent forumjump from being built more than once
        $complete = true;
    }
}
コード例 #22
0
ファイル: moderation.php プロジェクト: holandacz/nb4
     $show['deleted'] = true;
     $posttype = 'post';
 } else {
     $type = 'moderated';
     $table = 'moderation';
     $permission = 'canmoderateposts';
     if (!can_moderate(0, 'canmoderateposts')) {
         print_no_permission();
     }
     $postselect = '';
     $postjoin = '';
     $postfrom = "FROM " . TABLE_PREFIX . "moderation AS moderation\n\t\tINNER JOIN " . TABLE_PREFIX . "post AS post ON (moderation.primaryid = post.postid)";
     $posttype = 'reply';
 }
 if ($vbulletin->options['threadmarking']) {
     cache_ordered_forums(1);
 }
 $modforums = array();
 if ($forumid) {
     require_once DIR . '/includes/functions_misc.php';
     $forums = fetch_child_forums($forumid, 'ARRAY');
     $forums[] = $forumid;
     $forums = array_flip($forums);
 } else {
     $forums = $vbulletin->forumcache;
 }
 foreach ($forums as $mforumid => $null) {
     $forumperms = $vbulletin->userinfo['forumpermissions']["{$mforumid}"];
     if (can_moderate($mforumid, $permission) and $forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) {
         $modforums[] = $mforumid;
     }
コード例 #23
0
ファイル: functions_user.php プロジェクト: hungnv0789/vhtm
/**
 * Constructs a Forum Jump Menu based on moderator permissions
 *
 * @param	integer	The "root" forum to work from
 * @param	integer	The ID of the forum that is currently selected
 * @param	integer	Characters to prepend to the item in the menu
 * @param	string	The moderator permission to check when building the Forum Jump Menu
 *
 * @return	string	The built forum Jump menu
 *
 */
function construct_mod_forum_jump($parentid = -1, $selectedid, $modpermission = '')
{
	global $vbulletin;

	if (empty($vbulletin->iforumcache))
	{
		cache_ordered_forums();
	}

	if (empty($vbulletin->iforumcache["$parentid"]) OR !is_array($vbulletin->iforumcache["$parentid"]))
	{
		return;
	}

	foreach($vbulletin->iforumcache["$parentid"] AS $forumid)
	{
		$forumperms = $vbulletin->userinfo['forumpermissions']["$forumid"];
		if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR $vbulletin->forumcache["$forumid"]['link'])
		{
			continue;
		}

		$children = construct_mod_forum_jump($forumid, $selectedid, $modpermission);

		if (!can_moderate($forumid, $modpermission) AND !$children)
		{
			continue;
		}

		// set $forum from the $vbulletin->forumcache
		$forum = $vbulletin->forumcache["$forumid"];

		$optionvalue = $forumid;
		$optiontitle = $forum[title_clean];
		$optionclass = 'd' . iif($forum['depth'] > 4, 4, $forum['depth']);
		$optionselected = '';

		if ($selectedid == $optionvalue)
		{
			$optionselected = 'selected="selected"';
			$optionclass .= ' fjsel';
		}

		$forumjumpbits .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass);

		$forumjumpbits .= $children;

	} // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid)

	return $forumjumpbits;

}
コード例 #24
0
ファイル: subscriptions.php プロジェクト: 0hyeah/yurivn
function do_get_subscriptions()
{
    global $vbulletin, $db, $show, $vbphrase, $permissions, $subscribecounters;
    $vbulletin->options['threadpreview'] = FR_PREVIEW_LEN;
    if (!$vbulletin->userinfo['userid']) {
        json_error(ERR_NO_PERMISSION);
    }
    if (!$vbulletin->userinfo['userid'] and $_REQUEST['do'] != 'removesubscription' or $vbulletin->userinfo['userid'] and !($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']) or $vbulletin->userinfo['usergroupid'] == 4 or !($permissions['genericoptions'] & $vbulletin->bf_ugp_genericoptions['isnotbannedgroup'])) {
        json_error(ERR_NO_PERMISSION);
    }
    $thread_data = array();
    $unread_subs = 0;
    // vbulletin expects folderid, but we will just get them all
    $vbulletin->input->clean_array_gpc('r', array('folderid' => TYPE_NOHTML, 'perpage' => TYPE_UINT, 'pagenumber' => TYPE_UINT, 'sortfield' => TYPE_NOHTML, 'sortorder' => TYPE_NOHTML, 'previewtype' => TYPE_INT));
    $previewtype = $vbulletin->GPC['previewtype'];
    if (!$previewtype) {
        $previewtype = 1;
    }
    $vbulletin->GPC['folderid'] = 'all';
    // Values that are reused in templates
    $sortfield =& $vbulletin->GPC['sortfield'];
    $perpage =& $vbulletin->GPC['perpage'];
    $pagenumber =& $vbulletin->GPC['pagenumber'];
    $folderid =& $vbulletin->GPC['folderid'];
    if ($folderid == 'all') {
        $getallfolders = true;
        $show['allfolders'] = true;
    } else {
        $folderid = intval($folderid);
    }
    $folderselect["{$folderid}"] = 'selected="selected"';
    // Build folder jump
    require_once DIR . '/includes/functions_misc.php';
    $folders = construct_folder_jump(1, $folderid, false, '', true);
    $templater = vB_Template::create('subscribe_folder_jump');
    $templater->register('folders', $folders);
    $folderjump = $templater->render();
    // look at sorting options:
    if ($vbulletin->GPC['sortorder'] != 'asc') {
        $vbulletin->GPC['sortorder'] = 'desc';
        $sqlsortorder = 'DESC';
        $order = array('desc' => 'selected="selected"');
    } else {
        $sqlsortorder = '';
        $order = array('asc' => 'selected="selected"');
    }
    switch ($sortfield) {
        case 'title':
        case 'lastpost':
        case 'replycount':
        case 'views':
        case 'postusername':
            $sqlsortfield = 'thread.' . $sortfield;
            break;
        default:
            $handled = false;
            if (!$handled) {
                $sqlsortfield = 'thread.lastpost';
                $sortfield = 'lastpost';
            }
    }
    $sort = array($sortfield => 'selected="selected"');
    if ($getallfolders) {
        $totalallthreads = array_sum($subscribecounters);
    } else {
        $totalallthreads = $subscribecounters["{$folderid}"];
    }
    // set defaults
    sanitize_pageresults($totalallthreads, $pagenumber, $perpage, 200, $vbulletin->options['maxthreads']);
    // display threads
    $limitlower = ($pagenumber - 1) * $perpage + 1;
    $limitupper = $pagenumber * $perpage;
    if ($limitupper > $totalallthreads) {
        $limitupper = $totalallthreads;
        if ($limitlower > $totalallthreads) {
            $limitlower = $totalallthreads - $perpage;
        }
    }
    if ($limitlower <= 0) {
        $limitlower = 1;
    }
    $hook_query_fields = $hook_query_joins = $hook_query_where = '';
    $getthreads = $db->query_read_slave("\n\t\tSELECT thread.threadid, emailupdate, subscribethreadid, thread.forumid, thread.postuserid\n\t\t\t{$hook_query_fields}\n\t\tFROM " . TABLE_PREFIX . "subscribethread AS subscribethread\n\t\tLEFT JOIN " . TABLE_PREFIX . "thread AS thread ON(thread.threadid = subscribethread.threadid)\n\t\t{$hook_query_joins}\n\t\tWHERE subscribethread.userid = " . $vbulletin->userinfo['userid'] . "\n\t\t\tAND thread.visible = 1\n\t\t\tAND canview = 1\n\t\t" . iif(!$getallfolders, "\tAND folderid = {$folderid}") . "\n\t\t\t{$hook_query_where}\n\t\tORDER BY {$sqlsortfield} {$sqlsortorder}\n\t\tLIMIT " . ($limitlower - 1) . ", {$perpage}\n\t");
    if ($totalthreads = $db->num_rows($getthreads)) {
        $forumids = array();
        $threadids = array();
        $emailupdate = array();
        $killthreads = array();
        while ($getthread = $db->fetch_array($getthreads)) {
            $forumperms = fetch_permissions($getthread['forumid']);
            if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) or $getthread['postuserid'] != $vbulletin->userinfo['userid'] and !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers'])) {
                $killthreads["{$getthread['subscribethreadid']}"] = $getthread['subscribethreadid'];
                $totalallthreads--;
                continue;
            }
            $forumids["{$getthread['forumid']}"] = true;
            $threadids[] = $getthread['threadid'];
            $emailupdate["{$getthread['threadid']}"] = $getthread['emailupdate'];
            $subscribethread["{$getthread['threadid']}"] = $getthread['subscribethreadid'];
        }
        $threadids = implode(',', $threadids);
    }
    unset($getthread);
    $db->free_result($getthreads);
    if (!empty($killthreads)) {
        // Update thread subscriptions
        $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "subscribethread\n\t\t\tSET canview = 0\n\t\t\tWHERE subscribethreadid IN (" . implode(', ', $killthreads) . ")\n\t\t");
    }
    if (!empty($threadids)) {
        cache_ordered_forums(1);
        $colspan = 5;
        $show['threadicons'] = false;
        // get last read info for each thread
        $lastread = array();
        foreach (array_keys($forumids) as $forumid) {
            if ($vbulletin->options['threadmarking']) {
                $lastread["{$forumid}"] = max($vbulletin->forumcache["{$forumid}"]['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400);
            } else {
                $lastread["{$forumid}"] = max(intval(fetch_bbarray_cookie('forum_view', $forumid)), $vbulletin->userinfo['lastvisit']);
            }
            if ($vbulletin->forumcache["{$forumid}"]['options'] & $vbulletin->bf_misc_forumoptions['allowicons']) {
                $show['threadicons'] = true;
                $colspan = 6;
            }
        }
        if ($previewtype == 1) {
            $previewfield = "post.pagetext AS preview, post.username AS lastpost_username, post.userid AS lastpost_userid,";
            $previewjoin = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)";
        } else {
            $previewfield = "post.pagetext AS preview, post.username AS lastpost_username, post.userid AS lastpost_userid,";
            $previewjoin = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.lastpostid)";
        }
        $hasthreads = true;
        $threadbits = '';
        $pagenav = '';
        $counter = 0;
        $toread = 0;
        $vbulletin->options['showvotes'] = intval($vbulletin->options['showvotes']);
        if ($vbulletin->userinfo['userid'] and in_coventry($vbulletin->userinfo['userid'], true)) {
            $lastpost_info = "IF(tachythreadpost.userid IS NULL, thread.lastpost, tachythreadpost.lastpost) AS lastpost, " . "IF(tachythreadpost.userid IS NULL, thread.lastposter, tachythreadpost.lastposter) AS lastposter, " . "IF(tachythreadpost.userid IS NULL, thread.lastposterid, tachythreadpost.lastposterid) AS lastposterid, " . "IF(tachythreadpost.userid IS NULL, thread.lastpostid, tachythreadpost.lastpostid) AS lastpostid";
            $tachyjoin = "LEFT JOIN " . TABLE_PREFIX . "tachythreadpost AS tachythreadpost ON " . "(tachythreadpost.threadid = thread.threadid AND tachythreadpost.userid = " . $vbulletin->userinfo['userid'] . ')';
        } else {
            $lastpost_info = 'thread.lastpost, thread.lastposter, thread.lastposterid, thread.lastpostid';
            $tachyjoin = '';
        }
        $hook_query_fields = $hook_query_joins = $hook_query_where = '';
        $threads = $db->query_read_slave("\n\t\t\tSELECT\n\t\t\t\tIF(thread.votenum >= " . $vbulletin->options['showvotes'] . ", thread.votenum, 0) AS votenum,\n\t\t\t\tIF(thread.votenum >= " . $vbulletin->options['showvotes'] . " AND thread.votenum > 0, thread.votetotal / thread.votenum, 0) AS voteavg,\n\t\t\t\tthread.votetotal,\n\t\t\t\t{$previewfield} thread.threadid, thread.title AS threadtitle, thread.forumid, thread.pollid,\n\t\t\t\tthread.open, thread.replycount, thread.postusername, thread.prefixid,\n\t\t\t\t{$lastpost_info}, thread.postuserid, thread.dateline, thread.views, thread.iconid AS threadiconid,\n\t\t\t\tthread.notes, thread.visible, thread.attach, thread.taglist\n\t\t\t\t" . ($vbulletin->options['threadmarking'] ? ", threadread.readtime AS threadread" : '') . "\n\t\t\t\t{$hook_query_fields}\n\t\t\tFROM " . TABLE_PREFIX . "thread AS thread\n\t\t\t{$previewjoin}\n\t\t\t" . ($vbulletin->options['threadmarking'] ? " LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = " . $vbulletin->userinfo['userid'] . ")" : '') . "\n\t\t\t{$tachyjoin}\n\t\t\t{$hook_query_joins}\n\t\t\tWHERE thread.threadid IN ({$threadids})\n\t\t\tORDER BY {$sqlsortfield} {$sqlsortorder}\n\t\t");
        unset($sqlsortfield, $sqlsortorder);
        require_once DIR . '/includes/functions_forumdisplay.php';
        // Get Dot Threads
        $dotthreads = fetch_dot_threads_array($threadids);
        if ($vbulletin->options['showdots'] and $vbulletin->userinfo['userid']) {
            $show['dotthreads'] = true;
        } else {
            $show['dotthreads'] = false;
        }
        if ($vbulletin->options['threadpreview'] and $vbulletin->userinfo['ignorelist']) {
            // Get Buddy List
            $buddy = array();
            if (trim($vbulletin->userinfo['buddylist'])) {
                $buddylist = preg_split('/( )+/', trim($vbulletin->userinfo['buddylist']), -1, PREG_SPLIT_NO_EMPTY);
                foreach ($buddylist as $buddyuserid) {
                    $buddy["{$buddyuserid}"] = 1;
                }
            }
            DEVDEBUG('buddies: ' . implode(', ', array_keys($buddy)));
            // Get Ignore Users
            $ignore = array();
            if (trim($vbulletin->userinfo['ignorelist'])) {
                $ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY);
                foreach ($ignorelist as $ignoreuserid) {
                    if (!$buddy["{$ignoreuserid}"]) {
                        $ignore["{$ignoreuserid}"] = 1;
                    }
                }
            }
            DEVDEBUG('ignored users: ' . implode(', ', array_keys($ignore)));
        }
        $foruminfo['allowratings'] = true;
        $show['notificationtype'] = true;
        $show['threadratings'] = true;
        $show['threadrating'] = true;
        while ($thread = $db->fetch_array($threads)) {
            $threadid = $thread['threadid'];
            // build thread data
            $thread = process_thread_array($thread, $lastread["{$thread['forumid']}"]);
            switch ($emailupdate["{$thread['threadid']}"]) {
                case 0:
                    $thread['notification'] = $vbphrase['none'];
                    break;
                case 1:
                    $thread['notification'] = $vbphrase['instant'];
                    break;
                case 2:
                    $thread['notification'] = $vbphrase['daily'];
                    break;
                case 3:
                    $thread['notification'] = $vbphrase['weekly'];
                    break;
                default:
                    $thread['notification'] = $vbphrase['n_a'];
            }
            $avatarurl = '';
            if ($thread['lastpost_userid'] > 0) {
                $userinfoavatar = fetch_userinfo($thread['lastpost_userid'], FETCH_USERINFO_AVATAR);
                fetch_avatar_from_userinfo($userinfoavatar, true, false);
                if ($userinfoavatar['avatarurl'] != '') {
                    $avatarurl = process_avatarurl($userinfoavatar['avatarurl']);
                }
                unset($userinfoavatar);
            }
            $tmp = array('thread_id' => $thread['threadid'], 'new_posts' => $show['gotonewpost'] ? true : false, 'forum_id' => $thread['forumid'], 'total_posts' => $thread['totalposts'] ? $thread['totalposts'] : 0, 'forum_title' => prepare_utf8_string($thread['forumtitle']), 'thread_title' => prepare_utf8_string($thread['threadtitle']), 'thread_preview' => prepare_utf8_string(preview_chop(html_entity_decode($thread['preview']), FR_PREVIEW_LEN)), 'post_userid' => $thread['lastpost_userid'], 'post_lastposttime' => prepare_utf8_string(date_trunc($thread['lastpostdate']) . ' ' . $thread['lastposttime']), 'post_username' => prepare_utf8_string(strip_tags($thread['lastpost_username'])));
            if ($avatarurl != '') {
                $tmp['avatarurl'] = $avatarurl;
            }
            if ($thread['attach']) {
                $tmp['attach'] = true;
            }
            if ($thread['pollid']) {
                $tmp['poll'] = true;
            }
            $thread_data[] = $tmp;
        }
        $db->free_result($threads);
        unset($threadids);
    } else {
        $totalallthreads = 0;
    }
    $out = array('threads' => $thread_data, 'total_threads' => $totalallthreads);
    return $out;
}
コード例 #25
0
ファイル: misc.php プロジェクト: 0hyeah/yurivn
function do_stats()
{
    global $vbulletin, $db;
    $activeusers = '';
    if (($vbulletin->options['displayloggedin'] == 1 or $vbulletin->options['displayloggedin'] == 2 or $vbulletin->options['displayloggedin'] > 2 and $vbulletin->userinfo['userid']) and !$show['search_engine']) {
        $datecut = TIMENOW - $vbulletin->options['cookietimeout'];
        $numbervisible = 0;
        $numberregistered = 0;
        $numberguest = 0;
        $hook_query_fields = $hook_query_joins = $hook_query_where = '';
        ($hook = vBulletinHook::fetch_hook('forumhome_loggedinuser_query')) ? eval($hook) : false;
        $forumusers = $db->query_read_slave("\n\t    SELECT\n\t    user.username, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.usergroupid, user.lastvisit,\n\t    session.userid, session.inforum, session.lastactivity, session.badlocation,\n\t    IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid\n\t    {$hook_query_fields}\n\t    FROM " . TABLE_PREFIX . "session AS session\n\t    LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = session.userid)\n\t    {$hook_query_joins}\n\t    WHERE session.lastactivity > {$datecut}\n\t    {$hook_query_where}\n\t    " . iif($vbulletin->options['displayloggedin'] == 1 or $vbulletin->options['displayloggedin'] == 3, "ORDER BY username ASC") . "\n\t    ");
        if ($vbulletin->userinfo['userid']) {
            // fakes the user being online for an initial page view of index.php
            $vbulletin->userinfo['joingroupid'] = iif($vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['displaygroupid'], $vbulletin->userinfo['usergroupid']);
            $userinfos = array($vbulletin->userinfo['userid'] => array('userid' => &$vbulletin->userinfo['userid'], 'username' => &$vbulletin->userinfo['username'], 'invisible' => &$vbulletin->userinfo['invisible'], 'inforum' => 0, 'lastactivity' => TIMENOW, 'lastvisit' => &$vbulletin->userinfo['lastvisit'], 'usergroupid' => &$vbulletin->userinfo['usergroupid'], 'displaygroupid' => &$vbulletin->userinfo['displaygroupid'], 'infractiongroupid' => &$vbulletin->userinfo['infractiongroupid']));
        } else {
            $userinfos = array();
        }
        $inforum = array();
        while ($loggedin = $db->fetch_array($forumusers)) {
            $userid = $loggedin['userid'];
            if (!$userid) {
                // Guest
                $numberguest++;
                if (!isset($inforum["{$loggedin['inforum']}"])) {
                    $inforum["{$loggedin['inforum']}"] = 0;
                }
                if (!$loggedin['badlocation']) {
                    $inforum["{$loggedin['inforum']}"]++;
                }
            } else {
                if (empty($userinfos["{$userid}"]) or $userinfos["{$userid}"]['lastactivity'] < $loggedin['lastactivity']) {
                    $userinfos["{$userid}"] = $loggedin;
                }
            }
        }
        if (!$vbulletin->userinfo['userid'] and $numberguest == 0) {
            $numberguest++;
        }
        foreach ($userinfos as $userid => $loggedin) {
            $numberregistered++;
            if ($userid != $vbulletin->userinfo['userid'] and !$loggedin['badlocation']) {
                if (!isset($inforum["{$loggedin['inforum']}"])) {
                    $inforum["{$loggedin['inforum']}"] = 0;
                }
                $inforum["{$loggedin['inforum']}"]++;
            }
            fetch_musername($loggedin);
            ($hook = vBulletinHook::fetch_hook('forumhome_loggedinuser')) ? eval($hook) : false;
            if (fetch_online_status($loggedin)) {
                $numbervisible++;
            }
        }
        // memory saving
        unset($userinfos, $loggedin);
        $db->free_result($forumusers);
        $totalonline = $numberregistered + $numberguest;
        $numberinvisible = $numberregistered - $numbervisible;
        // ### MAX LOGGEDIN USERS ################################
        if (intval($vbulletin->maxloggedin['maxonline']) <= $totalonline) {
            $vbulletin->maxloggedin['maxonline'] = $totalonline;
            $vbulletin->maxloggedin['maxonlinedate'] = TIMENOW;
            build_datastore('maxloggedin', serialize($vbulletin->maxloggedin), 1);
        }
        $recordusers = vb_number_format($vbulletin->maxloggedin['maxonline']);
        $recorddate = vbdate($vbulletin->options['dateformat'], $vbulletin->maxloggedin['maxonlinedate'], true);
        $recordtime = vbdate($vbulletin->options['timeformat'], $vbulletin->maxloggedin['maxonlinedate']);
        $showloggedinusers = true;
    } else {
        $showloggedinusers = false;
    }
    cache_ordered_forums(1, 1);
    // get total threads & posts from the forumcache
    $totalthreads = 0;
    $totalposts = 0;
    if (is_array($vbulletin->forumcache)) {
        foreach ($vbulletin->forumcache as $forum) {
            $totalthreads += $forum['threadcount'];
            $totalposts += $forum['replycount'];
        }
    }
    $totalthreads = vb_number_format($totalthreads);
    $totalposts = vb_number_format($totalposts);
    // get total members and newest member from template
    $numbermembers = vb_number_format($vbulletin->userstats['numbermembers']);
    $newuserinfo = array('userid' => $vbulletin->userstats['newuserid'], 'username' => $vbulletin->userstats['newusername']);
    $activemembers = vb_number_format($vbulletin->userstats['activemembers']);
    $showactivemembers = ($vbulletin->options['activememberdays'] > 0 and $vbulletin->options['activememberoptions'] & 2) ? true : false;
    $out = array('threads' => $totalthreads, 'posts' => $totalposts, 'members' => $numbermembers, 'newuser' => $newuserinfo['username']);
    $out = array_merge($out, array('record_users' => $recordusers, 'record_date' => $recorddate . ' ' . $recordtime, 'online_members' => $numberregistered, 'online_guests' => $numberguest));
    $top = $db->query_first_slave("SELECT username FROM " . TABLE_PREFIX . "user ORDER BY posts DESC LIMIT 1");
    if ($top['username']) {
        $out['top_poster'] = $top['username'];
    } else {
        $out['top_poster'] = 'N/A';
    }
    if ($showactivemembers) {
        $out['active_members'] = $activemembers;
    } else {
        $out['active_members'] = 'N/A';
    }
    return $out;
    return array('top_poster' => '');
}