Exemplo n.º 1
0
	public static function create_array($ids)
	{
		global $vbulletin;

		$set = $vbulletin->db->query_read_slave("
			SELECT announcementid, startdate, title, announcement.views, forumid,
				user.username, user.userid, user.usertitle, user.customtitle, user.usergroupid,
				IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
			FROM " . TABLE_PREFIX . "announcement AS announcement
			LEFT JOIN " . TABLE_PREFIX . "user AS user USING (userid)
			WHERE announcementid IN (" . implode(',', array_map('intval', $ids)) . ")
		");

		$items = array();
		while ($record = $vbulletin->db->fetch_array($set))
		{
			fetch_musername($record);
			$record['title'] = fetch_censored_text($record['title']);
			$record['postdate'] = vbdate($vbulletin->options['dateformat'], $record['startdate']);
			$record['statusicon'] = 'new';
			$record['views'] = vb_number_format($record['views']);
			$record['forumtitle'] = $vbulletin->forumcache["$record[forumid]"]['title'];
			$show['forumtitle'] = ($record['forumid'] == -1) ? false : true;

			$announcement = new vBForum_Search_Result_Announcement();
			$announcement->record = $record;
			$items[$record['announcementid']] = $announcement;
		}
		return $items;
	}
Exemplo n.º 2
0
 /**
  * Create the results based on a list of ids return from the search implmentation
  *
  * @param vB_Current_User $user
  * @param vB_Search_Criteria criteria for the search
  * @return vB_Search_Results
  */
 public static function create_from_criteria($user, $criteria, $searchcontroller = null)
 {
     global $vbulletin;
     $results = new vB_Search_Results();
     $results->user = $user;
     $results->criteria = $criteria;
     $start = microtime();
     if (is_null($searchcontroller)) {
         $searchcontroller = vB_Search_Core::get_instance()->get_search_controller();
         $searchcontroller->clear();
     }
     $results->results = $searchcontroller->get_results($user, $criteria);
     //move log_search call after get_results to allow for any changes to the $criteria
     //object that might be made by the searchcontroller
     $results->searchid = $results->log_search();
     $results->dateline = TIMENOW;
     $results->cache_results();
     $searchtime = vb_number_format(fetch_microtime_difference($start), 2);
     $results->searchtime = $searchtime;
     $results->complete_search($searchtime);
     //log tag search
     $filter = $criteria->get_filters('tag');
     if (isset($filter[vB_Search_Core::OP_EQ])) {
         $dm = datamanager_init('tag', $vbulletin, ERRTYPE_ARRAY);
         $dm->log_tag_search($filter[vB_Search_Core::OP_EQ]);
     }
     return $results;
 }
Exemplo n.º 3
0
/**
* Creates the milestone stats array (target date, total issues, progress).
* Array contains formatted data.
*
* @param	array	Array of milestone info
* @param	array	Array of raw count info
*
* @return	array	Formatted stats data
*/
function prepare_milestone_stats($milestone, $raw_counts)
{
    global $vbulletin;
    $stats = array('total_issues' => vb_number_format($raw_counts['total_issues']), 'total_completed' => vb_number_format($raw_counts['total_completed']), 'total_active' => vb_number_format($raw_counts['total_active']), 'percent_completed' => vb_number_format($raw_counts['percent_completed']));
    if ($milestone['completeddate']) {
        $stats['completed_date'] = vbdate($vbulletin->options['dateformat'], $milestone['completeddate']);
        $stats['milestone_overdue'] = false;
    } else {
        $stats['target_date'] = vbdate($vbulletin->options['dateformat'], $milestone['targetdate']);
        $stats['milestone_overdue'] = ($milestone['targetdate'] and $milestone['targetdate'] < TIMENOW);
    }
    return $stats;
}
Exemplo n.º 4
0
 /**
  * Verify that the name doesn't already exists
  *
  * @param	string	Group Name
  *
  * @return	boolean
  */
 function verify_name(&$name)
 {
     // replace html-encoded spaces with actual spaces
     $name = preg_replace('/&#(0*32|x0*20);/', ' ', $name);
     $name = trim($name);
     if (!$this->condition or $name != $this->existing['name']) {
         $dupegroup = $this->registry->db->query_first("\n\t\t\t\tSELECT *\n\t\t\t\tFROM " . TABLE_PREFIX . "socialgroup\n\t\t\t\tWHERE name = '" . $this->registry->db->escape_string($name) . "'\n\t\t\t\t\tAND groupid <> " . intval($this->fetch_field('groupid')));
         if ($dupegroup) {
             $this->error('group_already_exists_view_x', 'group.php?' . $this->registry->session->vars['sessionurl'] . 'do=view&amp;groupid=' . $dupegroup['groupid']);
             return false;
         }
     }
     if (empty($name)) {
         $this->error('must_enter_group_name');
         return false;
     }
     if (vbstrlen($name, true) > $this->registry->options['sg_name_maxchars']) {
         $this->error('name_too_long_max_x', vb_number_format($this->registry->options['sg_name_maxchars']));
         return false;
     }
     return true;
 }
Exemplo n.º 5
0
 }
 $photoplog['select_row'] = htmlspecialchars_uni(photoplog_get_category_title($photoplog_file_catid));
 $photoplog['title'] = $photoplog_file_info['title'];
 $photoplog['title'] = photoplog_process_text($photoplog['title'], $photoplog_file_catid, true, false);
 if ($photoplog['title'] == $vbphrase['photoplog_untitled']) {
     $photoplog['title'] = '';
 }
 $photoplog['description'] = $photoplog_file_info['description'];
 $photoplog['description'] = photoplog_process_text($photoplog['description'], $photoplog_file_catid, false, false);
 $photoplog_fielddata = $photoplog_file_info['fielddata'];
 $photoplog_fielddata = $photoplog_fielddata == '' ? array() : unserialize($photoplog_fielddata);
 if (!is_array($photoplog_fielddata)) {
     $photoplog_fielddata = array();
 }
 $photoplog['maxfilesize'] = intval($permissions['photoplogmaxfilesize']);
 $photoplog['maxfilesize'] = vb_number_format($photoplog['maxfilesize'], 1, true);
 $do_html = 0;
 $do_smilies = 0;
 $do_bbcode = 0;
 $do_imgcode = 0;
 if ($photoplog_file_catid > 0 && in_array($photoplog_file_catid, array_keys($photoplog_ds_catopts))) {
     $photoplog_categorybit = $photoplog_ds_catopts["{$photoplog_file_catid}"]['options'];
     $photoplog_catoptions = convert_bits_to_array($photoplog_categorybit, $photoplog_categoryoptions);
     $do_html = $photoplog_catoptions['allowhtml'] ? 1 : 0;
     $do_smilies = $photoplog_catoptions['allowsmilies'] ? 1 : 0;
     $do_bbcode = $photoplog_catoptions['allowbbcode'] ? 1 : 0;
     // this is to show the little image toolbar icon
     $do_imgcode = $photoplog_catoptions['allowimgcode'] ? 1 : 0;
     $vbulletin->options['allowbbimagecode'] = $do_imgcode;
 } else {
     photoplog_output_page('photoplog_error_page', $vbphrase['photoplog_error'], $vbphrase['photoplog_no'] . ' ' . $vbphrase['photoplog_category']);
Exemplo n.º 6
0
            // build group template
            eval('$messagelist_periodgroups .= "' . fetch_template('pm_messagelist_periodgroup') . '";');
        }
        // build pagenav
        $pagenav = construct_page_nav($vbulletin->GPC['pagenumber'], $vbulletin->GPC['perpage'], $totalmessages, 'private.php?' . $vbulletin->session->vars['sessionurl'] . 'folderid=' . $vbulletin->GPC['folderid'] . '&amp;pp=' . $vbulletin->GPC['perpage']);
    }
    if ($vbulletin->GPC['folderid'] == -1) {
        $show['sentto'] = true;
        $show['movetofolder'] = false;
    } else {
        $show['sentto'] = false;
        $show['movetofolder'] = true;
    }
    $totalmessages = vb_number_format($totalmessages);
    $pmtotal = vb_number_format($vbulletin->userinfo['pmtotal']);
    $pmquota = vb_number_format($vbulletin->userinfo['permissions']['pmquota']);
    $templatename = 'pm_messagelist';
}
// #############################################################################
if ($templatename != '') {
    // draw cp nav bar
    construct_usercp_nav($templatename);
    // build navbar
    $navbits = construct_navbits($navbits);
    eval('$navbar = "' . fetch_template('navbar') . '";');
    ($hook = vBulletinHook::fetch_hook('private_complete')) ? eval($hook) : false;
    // print page
    eval('$HTML = "' . fetch_template($templatename) . '";');
    eval('print_output("' . fetch_template('USERCP_SHELL') . '");');
}
/*======================================================================*\
Exemplo n.º 7
0
    }
    if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and ($threadinfo['postuserid'] != $vbulletin->userinfo['userid'] or !$vbulletin->userinfo['userid'])) {
        print_no_permission();
    }
    $attachs = $db->query_read_slave("\n\t\tSELECT attachment.*\n\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\tINNER JOIN " . TABLE_PREFIX . "attachment AS attachment ON (attachment.postid=post.postid AND attachment.visible=1)\n\t\tWHERE threadid = {$threadinfo['threadid']}\n\t\t\tAND post.visible = 1\n\t\tORDER BY filename DESC\n\t");
    if ($db->num_rows($attachs)) {
        require_once DIR . '/includes/functions_bigthree.php';
        while ($attachment = $db->fetch_array($attachs)) {
            // hide users in Coventry
            $ast = '';
            if (in_coventry($attachment['userid']) and !can_moderate($threadinfo['forumid'])) {
                continue;
            }
            $attachment['filename'] = fetch_censored_text(htmlspecialchars_uni($attachment['filename']));
            $attachment['attachmentextension'] = strtolower(file_extension($attachment['filename']));
            $attachment['filesize'] = vb_number_format($attachment['filesize'], 1, true);
            exec_switch_bg();
            eval('$attachments .= "' . fetch_template('attachmentbit') . '";');
        }
        ($hook = vBulletinHook::fetch_hook('misc_showattachments_complete')) ? eval($hook) : false;
        eval('print_output("' . fetch_template('ATTACHMENTS') . '");');
    } else {
        eval(standard_error(fetch_error('noattachments')));
    }
}
// ############################### start show avatars ###############################
if ($_REQUEST['do'] == 'showavatars') {
    $vbulletin->input->clean_array_gpc('r', array('pagenumber' => TYPE_UINT));
    ($hook = vBulletinHook::fetch_hook('misc_avatars_start')) ? eval($hook) : false;
    $perpage = $vbulletin->options['numavatarsperpage'];
    $totalavatars = $db->query_first_slave("\n\t\tSELECT COUNT(*) AS count\n\t\tFROM " . TABLE_PREFIX . "avatar AS avatar\n\t\tLEFT JOIN " . TABLE_PREFIX . "imagecategorypermission AS perm ON (perm.imagecategoryid=avatar.imagecategoryid AND perm.usergroupid=" . $vbulletin->userinfo['usergroupid'] . ")\n\t\tWHERE ISNULL(perm.imagecategoryid)\n\t");
Exemplo n.º 8
0
 $totalpages = ceil($totalinf / $vbulletin->GPC['perpage']);
 $args = '&status=' . $vbulletin->GPC['status'] . '&u=' . $vbulletin->GPC['userid'] . '&whoadded=' . $vbulletin->GPC['whoadded'] . '&startstamp=' . $vbulletin->GPC['start'] . '&endstamp=' . $vbulletin->GPC['end'] . '&pp=' . $vbulletin->GPC['perpage'] . '&page=' . $vbulletin->GPC['pagenumber'] . '&infractionlevelid=' . $vbulletin->GPC['infractionlevelid'] . '&orderby=';
 $infractions = $db->query_read("\n\t\tSELECT infraction.*,\n\t\t\tuser2.username,\n\t\t\tuser.username AS leftby_username,\n\t\t\tIF(ISNULL(post.postid) AND infraction.postid != 0, 1, 0) AS postdeleted\n\t\tFROM " . TABLE_PREFIX . "infraction AS infraction\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (infraction.whoadded = user.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user2 ON (infraction.userid = user2.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "post AS post ON (infraction.postid = post.postid)\n\t\tWHERE {$condition}\n\t\tORDER BY {$orderby}\n\t\tLIMIT {$startat}, " . $vbulletin->GPC['perpage']);
 if ($db->num_rows($infractions)) {
     if ($vbulletin->GPC['pagenumber'] != 1) {
         $prv = $vbulletin->GPC['pagenumber'] - 1;
         $firstpage = "<input type=\"button\" class=\"button\" tabindex=\"1\" value=\"&laquo; " . $vbphrase['first_page'] . "\" onclick=\"window.location='admininfraction.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . $args . $vbulletin->GPC['orderby'] . "&page=1'\">";
         $prevpage = "<input type=\"button\" class=\"button\" tabindex=\"1\" value=\"&lt; " . $vbphrase['prev_page'] . "\" onclick=\"window.location='admininfraction.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . $args . $vbulletin->GPC['orderby'] . "&page={$prv}'\">";
     }
     if ($vbulletin->GPC['pagenumber'] != $totalpages) {
         $nxt = $vbulletin->GPC['pagenumber'] + 1;
         $nextpage = "<input type=\"button\" class=\"button\" tabindex=\"1\" value=\"" . $vbphrase['next_page'] . " &gt;\" onclick=\"window.location='admininfraction.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . $args . $vbulletin->GPC['orderby'] . "&page={$nxt}'\">";
         $lastpage = "<input type=\"button\" class=\"button\" tabindex=\"1\" value=\"" . $vbphrase['last_page'] . " &raquo;\" onclick=\"window.location='admininfraction.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . $args . $vbulletin->GPC['orderby'] . "&page={$totalpages}'\">";
     }
     print_form_header('admininfraction', 'remove');
     print_table_header(construct_phrase($vbphrase['infraction_viewer_page_x_y_there_are_z_total_log_entries'], vb_number_format($vbulletin->GPC['pagenumber']), vb_number_format($totalpages), vb_number_format($counter['total'])), 8);
     $headings = array();
     $headings[] = "<a href=\"admininfraction.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . $args . "\" title=\"" . $vbphrase['order_by_username'] . "\">" . $vbphrase['user_name'] . "</a>";
     $headings[] = "<a href=\"admininfraction.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . $args . "leftby_username\" title=\"" . $vbphrase['order_by_username'] . "\">" . $vbphrase['left_by'] . "</a>";
     $headings[] = "<a href=\"admininfraction.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . $args . "date\" title=\"" . $vbphrase['order_by_date'] . "\">" . $vbphrase['date'] . "</a>";
     $headings[] = $vbphrase['infraction_type'];
     $headings[] = "<a href=\"admininfraction.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . $args . "points\" title=\"" . $vbphrase['order_by_points'] . "\">" . $vbphrase['points'] . "</a>";
     $headings[] = "<a href=\"admininfraction.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . $args . "expires\" title=\"" . $vbphrase['order_by_expiration'] . "\">" . $vbphrase['expires'] . "</a>";
     $headings[] = $vbphrase['post'];
     $headings[] = $vbphrase['controls'];
     print_cells_row($headings, 1);
     while ($infraction = $db->fetch_array($infractions)) {
         $cell = array();
         $cell[] = "<a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;u={$infraction['userid']}\"><b>{$infraction['username']}</b></a>";
         $cell[] = "<a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;u={$infraction['whoadded']}\"><b>{$infraction['leftby_username']}</b></a>";
         $cell[] = '<span class="smallfont">' . vbdate($vbulletin->options['logdateformat'], $infraction['dateline']) . '</span>';
Exemplo n.º 9
0
 }
 $option['number'] = $counter;
 //number of the option
 //Now we check if the user has voted or not
 if ($showresults or $uservoted) {
     // user did vote or poll is closed
     if ($value <= 0) {
         $option['percentraw'] = 0;
     } else {
         if ($pollinfo['multiple']) {
             $option['percentraw'] = $value < $pollinfo['voters'] ? $value / $pollinfo['voters'] * 100 : 100;
         } else {
             $option['percentraw'] = $value < $pollinfo['numbervotes'] ? $value / $pollinfo['numbervotes'] * 100 : 100;
         }
     }
     $option['percent'] = vb_number_format($option['percentraw'], 2);
     $option['graphicnumber'] = $option['number'] % 6 + 1;
     $option['barnumber'] = round($option['percent']) * 2;
     $option['remainder'] = 201 - $option['barnumber'];
     // Phrase parts below
     if ($nopermission) {
         $pollstatus = $vbphrase['you_may_not_vote_on_this_poll'];
     } else {
         if ($showresults) {
             $pollstatus = $vbphrase['this_poll_is_closed'];
         } else {
             if ($uservoted) {
                 $pollstatus = $vbphrase['you_have_already_voted_on_this_poll'];
             }
         }
     }
Exemplo n.º 10
0
            print_form_header('user', 'dopruneusers');
            construct_hidden_code('usergroupid', $vbulletin->GPC['usergroupid']);
            construct_hidden_code('daysprune', $vbulletin->GPC['daysprune']);
            construct_hidden_code('minposts', $vbulletin->GPC['minposts']);
            construct_hidden_code('joindate[day]', $vbulletin->GPC['joindate']['day']);
            construct_hidden_code('joindate[month]', $vbulletin->GPC['joindate']['month']);
            construct_hidden_code('joindate[year]', $vbulletin->GPC['joindate']['year']);
            construct_hidden_code('order', $order);
            print_table_header(construct_phrase($vbphrase['showing_users_x_to_y_of_z'], 1, $numusers, $numusers), 7);
            print_cells_row(array('Userid', $vbphrase['username'], $vbphrase['email'], $vbphrase['post_count'], $vbphrase['last_activity'], $vbphrase['join_date'], '<input type="checkbox" name="allbox" onclick="js_check_all(this.form)" title="' . $vbphrase['check_all'] . '" checked="checked" />'), 1);
            while ($user = $db->fetch_array($users)) {
                $cell = array();
                $cell[] = $user['userid'];
                $cell[] = "<a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&u={$user['userid']}\" target=\"_blank\">{$user['username']}</a><br /><span class=\"smallfont\">{$user['title']}" . iif($user['moderatorid'], ', Moderator', '') . "</span>";
                $cell[] = "<a href=\"mailto:{$user['email']}\">{$user['email']}</a>";
                $cell[] = vb_number_format($user['posts']);
                $cell[] = vbdate($vbulletin->options['dateformat'], $user['lastactivity']);
                $cell[] = vbdate($vbulletin->options['dateformat'], $user['joindate']);
                if ($user['userid'] == $vbulletin->userinfo['userid'] or $user['usergroupid'] == 6 or $user['usergroupid'] == 5 or $user['moderatorid'] or is_unalterable_user($user['userid'])) {
                    $cell[] = '<input type="button" class="button" value=" ! " onclick="js_alert_no_permission()" />';
                } else {
                    $cell[] = "<input type=\"checkbox\" name=\"users[{$user['userid']}]\" value=\"1\" checked=\"checked\" tabindex=\"1\" />";
                }
                print_cells_row($cell);
            }
            print_description_row('<center><span class="smallfont">
				<b>' . $vbphrase['action'] . ':
				<label for="dw_delete"><input type="radio" name="dowhat" value="delete" id="dw_delete" tabindex="1" />' . $vbphrase['delete'] . '</label>
				<label for="dw_move"><input type="radio" name="dowhat" value="move" id="dw_move" tabindex="1" />' . $vbphrase['move'] . '</label>
				<select name="movegroup" tabindex="1" class="bginput">' . $groupslist . '</select></b>
				</span></center>', 0, 7);
Exemplo n.º 11
0
    if ($vbulletin->GPC['product']) {
        if ($vbulletin->GPC['product'] == 'vbulletin') {
            $sqlconds[] = "product IN ('', 'vbulletin')";
        } else {
            $sqlconds[] = "product = '" . $db->escape_string($vbulletin->GPC['product']) . "'";
        }
    }
    $logs = $db->query_first("\n\t\tSELECT COUNT(*) AS total\n\t\tFROM " . TABLE_PREFIX . "moderatorlog\n\t\tWHERE " . (!empty($sqlconds) ? implode("\r\n\tAND ", $sqlconds) : "") . "\n\t");
    if ($logs['total']) {
        print_form_header('modlog', 'doprunelog');
        construct_hidden_code('datecut', $datecut);
        construct_hidden_code('modaction', $vbulletin->GPC['modaction']);
        construct_hidden_code('userid', $vbulletin->GPC['userid']);
        construct_hidden_code('product', $vbulletin->GPC['product']);
        print_table_header($vbphrase['prune_moderator_log']);
        print_description_row(construct_phrase($vbphrase['are_you_sure_you_want_to_prune_x_log_entries_from_moderator_log'], vb_number_format($logs['total'])));
        print_submit_row($vbphrase['yes'], 0, 0, $vbphrase['no']);
    } else {
        print_stop_message('no_logs_matched_your_query');
    }
}
// ###################### Start do prune log #######################
if ($_POST['do'] == 'doprunelog' and can_access_logs($vbulletin->config['SpecialUsers']['canpruneadminlog'], 0, '<p>' . $vbphrase['control_panel_log_pruning_permission_restricted'] . '</p>')) {
    $vbulletin->input->clean_array_gpc('p', array('datecut' => TYPE_UINT, 'modaction' => TYPE_STR, 'userid' => TYPE_UINT, 'product' => TYPE_STR));
    $sqlconds = array("dateline < " . $vbulletin->GPC['datecut']);
    if (!empty($vbulletin->GPC['modaction'])) {
        $sqlconds[] = "action LIKE '%" . $db->escape_string_like($vbulletin->GPC['modaction']) . "%'";
    }
    if (!empty($vbulletin->GPC['userid'])) {
        $sqlconds[] = "userid = " . $vbulletin->GPC['userid'];
    }
Exemplo n.º 12
0
 public function cropImg($imgInfo, $maxwidth = 100, $maxheight = 100, $forceResize = false)
 {
     $thumbnail = array('filedata' => '', 'filesize' => 0, 'dateline' => 0, 'imageerror' => '');
     $filename = $imgInfo['filename'];
     $imgInfo['extension'] = strtoupper($imgInfo['extension']);
     if ($imgInfo['extension'] == 'JPG') {
         $imgInfo['extension'] = 'JPEG';
     }
     if ($validfile = $this->isValidThumbnailExtension($imgInfo['extension'])) {
         $thumbnail['source_width'] = $new_width = $width = $imgInfo['width'];
         $thumbnail['source_height'] = $new_height = $height = $imgInfo['height'];
         if ($forceResize or $width >= $maxwidth or $height >= $maxheight) {
             $memoryok = true;
             $checkmem = false;
             if (function_exists('memory_get_usage') and $memory_limit = @ini_get('memory_limit') and $memory_limit != -1) {
                 $memorylimit = vb_number_format($memory_limit, 0, false, null, '');
                 $memoryusage = memory_get_usage();
                 $freemem = $memorylimit - $memoryusage;
                 $checkmem = true;
                 $tmemory = $width * $height * ($imgInfo['extension'] == 'JPEG' ? 5 : 2) + 7372.8 + sqrt(sqrt($width * $height));
                 $tmemory += 166000;
                 // fudge factor, object overhead, etc
                 if ($freemem > 0 and $tmemory > $freemem and $tmemory <= $memorylimit * 3) {
                     // attempt to increase memory within reason, no more than triple
                     if (($current_memory_limit = vB_Utilities::ini_size_to_bytes(@ini_get('memory_limit'))) < $memorylimit + $tmemory and $current_memory_limit > 0) {
                         @ini_set('memory_limit', $memorylimit + $tmemory);
                     }
                     $memory_limit = @ini_get('memory_limit');
                     $memorylimit = vb_number_format($memory_limit, 0, false, null, '');
                     $memoryusage = memory_get_usage();
                     $freemem = $memorylimit - $memoryusage;
                 }
             }
             $fh = fopen($filename, 'w');
             fwrite($fh, $imgInfo['filedata']);
             fclose($fh);
             switch ($imgInfo['extension']) {
                 case 'GIF':
                     if (function_exists('imagecreatefromgif')) {
                         if ($checkmem) {
                             if ($freemem > 0 and $tmemory > $freemem) {
                                 throw new vB_Exception_Api('thumbnail_notenoughmemory');
                             }
                         }
                         if ($memoryok and !($image = @imagecreatefromgif($filename))) {
                             throw new vB_Exception_Api('thumbnail_nocreateimage_gif');
                         }
                     } else {
                         throw new vB_Exception_Api('thumbnail_nosupport');
                     }
                     break;
                 case 'JPEG':
                     if (function_exists('imagecreatefromjpeg')) {
                         if ($checkmem) {
                             if ($freemem > 0 and $tmemory > $freemem) {
                                 throw new vB_Exception_Api('thumbnail_notenoughmemory');
                             }
                         }
                         if ($memoryok and !($image = @imagecreatefromjpeg($filename))) {
                             throw new vB_Exception_Api('thumbnail_nocreateimage_jpeg');
                         }
                     } else {
                         throw new vB_Exception_Api('thumbnail_nosupport');
                     }
                     break;
                 case 'PNG':
                     if (function_exists('imagecreatefrompng')) {
                         if ($checkmem) {
                             if ($freemem > 0 and $tmemory > $freemem) {
                                 throw new vB_Exception_Api('thumbnail_notenoughmemory');
                             }
                         }
                         if ($memoryok and !($image = @imagecreatefrompng($filename))) {
                             throw new vB_Exception_Api('thumbnail_nocreateimage_png');
                         }
                     } else {
                         throw new vB_Exception_Api('thumbnail_nosupport');
                     }
                     break;
             }
             if ($image) {
                 $xratio = $maxwidth == 0 ? 1 : $width / $maxwidth;
                 $yratio = $maxheight == 0 ? 1 : $height / $maxheight;
                 if ($xratio > $yratio) {
                     $new_width = round($width / $xratio);
                     $new_height = round($height / $xratio);
                 } else {
                     $new_width = round($width / $yratio);
                     $new_height = round($height / $yratio);
                 }
             }
             if (!($finalimage = @imagecreatetruecolor($new_width, $new_height))) {
                 imagedestroy($image);
                 throw new vB_Exception_Api('thumbnail_nocreateimage_truecolor');
             }
             $bgcolor = imagecolorallocate($finalimage, 255, 255, 255);
             imagefill($finalimage, 0, 0, $bgcolor);
             imagecopyresampled($finalimage, $image, 0, 0, $imgInfo['x1'], $imgInfo['y1'], $new_width, $new_height, $imgInfo['width'], $imgInfo['height']);
             imagedestroy($image);
             if ($imgInfo['extension'] != 'GIF') {
                 $this->unsharpmask($finalimage);
             }
             ob_start();
             $new_extension = $this->printImage($finalimage, $imgInfo['extension'], false, 75);
             $thumbnail['filedata'] = ob_get_contents();
             ob_end_clean();
             $thumbnail['width'] = $new_width;
             $thumbnail['height'] = $new_height;
             $extension = $imgInfo['extension'];
             if ($new_extension != $extension) {
                 $thumbnail['filename'] = preg_replace('#' . preg_quote($extension, '#') . '$#', $new_extension, $filename);
             }
         } else {
             // image is a thumbnail size already
             if ($imgInfo['width'] > 0 and $imgInfo['height'] > 0) {
                 $thumbnail['filedata'] = @file_get_contents($filename);
                 $thumbnail['width'] = $imgInfo['width'];
                 $thumbnail['height'] = $imgInfo['height'];
             } else {
                 throw new vB_Exception_Api('thumbnail_nogetimagesize');
             }
         }
     } else {
         if (!$validfile) {
             throw new vB_Exception_Api('thumbnail_nosupport');
         }
     }
     if (!empty($thumbnail['filedata'])) {
         $thumbnail['filesize'] = strlen($thumbnail['filedata']);
         $thumbnail['dateline'] = vB::getRequest()->getTimeNow();
     }
     @unlink($filename);
     return $thumbnail;
 }
/**
 * Takes information regardign a group, and prepares the information within it
 * for display
 *
 * @param	array	Group Array
 * @param	bool	Whether to fetch group members and avatars
 *
 * @return	array	Group Array with prepared information
 *
 */
function prepare_socialgroup($group, $fetchmembers = false)
{
    global $vbulletin;
    if (!is_array($group)) {
        return array();
    }
    if ($fetchmembers) {
        $membersinfo = cache_group_members();
        $group['membersinfo'] = $membersinfo[$group['groupid']];
    }
    $group['joindate'] = !empty($group['joindate']) ? vbdate($vbulletin->options['dateformat'], $group['joindate'], true) : '';
    $group['createtime'] = !empty($group['createdate']) ? vbdate($vbulletin->options['timeformat'], $group['createdate'], true) : '';
    $group['createdate'] = !empty($group['createdate']) ? vbdate($vbulletin->options['dateformat'], $group['createdate'], true) : '';
    $group['lastupdatetime'] = !empty($group['lastupdate']) ? vbdate($vbulletin->options['timeformat'], $group['lastupdate'], true) : '';
    $group['lastupdatedate'] = !empty($group['lastupdate']) ? vbdate($vbulletin->options['dateformat'], $group['lastupdate'], true) : '';
    $group['visible'] = vb_number_format($group['visible']);
    $group['moderation'] = vb_number_format($group['moderation']);
    $group['members'] = vb_number_format($group['members']);
    $group['moderatedmembers'] = vb_number_format($group['moderatedmembers']);
    $group['categoryname'] = htmlspecialchars_uni($group['categoryname']);
    $group['discussions'] = vb_number_format($group['discussions']);
    $group['lastdiscussion'] = fetch_word_wrapped_string(fetch_censored_text($group['lastdiscussion']));
    $group['trimdiscussion'] = fetch_trimmed_title($group['lastdiscussion']);
    if (!($group['options'] & $vbulletin->bf_misc_socialgroupoptions['enable_group_albums'])) {
        // albums disabled in this group - force 0 pictures
        $group['picturecount'] = 0;
    }
    $group['rawpicturecount'] = $group['picturecount'];
    $group['picturecount'] = vb_number_format($group['picturecount']);
    $group['rawname'] = $group['name'];
    $group['rawdescription'] = $group['description'];
    $group['name'] = fetch_word_wrapped_string(fetch_censored_text($group['name']));
    if ($group['description']) {
        $group['shortdescription'] = fetch_word_wrapped_string(fetch_censored_text(fetch_trimmed_title($group['description'], 185)));
    } else {
        $group['shortdescription'] = $group['name'];
    }
    $group['mediumdescription'] = fetch_word_wrapped_string(fetch_censored_text(fetch_trimmed_title($group['description'], 1000)));
    $group['description'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($group['description'])));
    $group['is_owner'] = $group['creatoruserid'] == $vbulletin->userinfo['userid'];
    $group['is_automoderated'] = ($group['options'] & $vbulletin->bf_misc_socialgroupoptions['owner_mod_queue'] and $vbulletin->options['sg_allow_owner_mod_queue'] and !$vbulletin->options['social_moderation']);
    $group['canviewcontent'] = (!($group['options'] & $vbulletin->bf_misc_socialgroupoptions['join_to_view']) or !$vbulletin->options['sg_allow_join_to_view'] or $group['membertype'] == 'member' or can_moderate(0, 'canmoderategroupmessages') or can_moderate(0, 'canremovegroupmessages') or can_moderate(0, 'candeletegroupmessages') or fetch_socialgroup_perm('canalwayspostmessage') or fetch_socialgroup_perm('canalwascreatediscussion'));
    $group['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $group['lastpost'], true);
    $group['lastposttime'] = vbdate($vbulletin->options['timeformat'], $group['lastpost']);
    $group['lastposterid'] = $group['canviewcontent'] ? $group['lastposterid'] : 0;
    $group['lastposter'] = $group['canviewcontent'] ? $group['lastposter'] : '';
    // check read marking
    //remove notice and make readtime determination a bit more clear
    if (!empty($group['readtime'])) {
        $readtime = $group['readtime'];
    } else {
        $readtime = fetch_bbarray_cookie('group_marking', $group['groupid']);
        if (!$readtime) {
            $readtime = $vbulletin->userinfo['lastvisit'];
        }
    }
    // get thumb url
    $group['iconurl'] = fetch_socialgroupicon_url($group, true);
    // check if social group is moderated to join
    $group['membermoderated'] = 'moderated' == $group['type'];
    // posts older than markinglimit days won't be highlighted as new
    $oldtime = TIMENOW - $vbulletin->options['markinglimit'] * 24 * 60 * 60;
    $readtime = max((int) $readtime, $oldtime);
    $group['readtime'] = $readtime;
    $group['is_read'] = $readtime >= $group['lastpost'];
    // Legacy Hook 'group_prepareinfo' Removed //
    return $group;
}
Exemplo n.º 14
0
 function print_usergroup_row($usergroup, $options)
 {
     global $usergroupleaders, $vbphrase, $promotions, $vbulletin;
     if ($promotions["{$usergroup['usergroupid']}"]) {
         $options['promote'] .= " ({$promotions[$usergroup[usergroupid]]})";
     }
     $cell = array();
     $cell[] = "<b>{$usergroup['title']}" . iif($usergroup['canoverride'], '*') . "</b>" . iif($usergroup['ispublicgroup'], '<br /><span class="smallfont">' . $usergroup['description'] . '</span>');
     $cell[] = iif($usergroup['count'], vb_number_format($usergroup['count']), '-');
     $cell[] = iif($usergroup['secondarycount'], vb_number_format($usergroup['secondarycount']), '-');
     if ($usergroup['ispublicgroup']) {
         $cell[] = iif($usergroup['requests'], vb_number_format($usergroup['requests']), '0');
     }
     if ($usergroup['ispublicgroup']) {
         $cell_out = '<span class="smallfont">';
         if (is_array($usergroupleaders["{$usergroup['usergroupid']}"])) {
             foreach ($usergroupleaders["{$usergroup['usergroupid']}"] as $usergroupleader) {
                 $cell_out .= "<a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;u={$usergroupleader['userid']}\"><b>{$usergroupleader['username']}</b></a>" . construct_link_code($vbphrase['delete'], "usergroup.php?" . $vbulletin->session->vars['sessionurl'] . "do=removeleader&amp;usergroupleaderid={$usergroupleader['usergroupleaderid']}") . '<br />';
             }
         }
         $cell[] = $cell_out . '</span>';
     }
     $options['edit'] .= " (id: {$usergroup['usergroupid']})";
     $cell[] = "\n\t<select name=\"u{$usergroup['usergroupid']}\" onchange=\"js_usergroup_jump({$usergroup['usergroupid']});\" class=\"bginput\">\n" . construct_select_options($options) . "\t</select><input type=\"button\" class=\"button\" value=\"" . $vbphrase['go'] . "\" onclick=\"js_usergroup_jump({$usergroup['usergroupid']});\" />\n\t";
     print_cells_row($cell);
 }
Exemplo n.º 15
0
/**
* Reads XML style file and imports data from it into the database
*
* @param	string	XML data
* @param	integer	Style ID
* @param	integer	Parent style ID
* @param	string	New style title
* @param	boolean	Allow vBulletin version mismatch
* @param	integer	Display order for new style
* @param	boolean	Allow user selection of new style
* @param  int|null Starting template group index for this run of importing templates (0 based).
*		Null means all templates (single run)
* @paream int|null
*
* @return	array	Array of information about the imported style
*/
function xml_import_style(
	$xml = false,
	$styleid = -1,
	$parentid = -1,
	$title = '',
	$anyversion = false,
	$displayorder = 1,
	$userselect = true,
	$startat = null,
	$perpage = null
)
{
	// $GLOBALS['path'] needs to be passed into this function or reference $vbulletin->GPC['path']

	global $vbulletin, $vbphrase;

	print_dots_start('<b>' . $vbphrase['importing_style'] . "</b>, $vbphrase[please_wait]", ':', 'dspan');

	require_once(DIR . '/includes/class_xml.php');

	//where is this used?  I hate having this random global value in the middle of this function
	$xmlobj = new vB_XML_Parser($xml, $vbulletin->GPC['path']);
	if ($xmlobj->error_no == 1)
	{
			print_dots_stop();
			print_stop_message('no_xml_and_no_path');
	}
	else if ($xmlobj->error_no == 2)
	{
			print_dots_stop();
			print_stop_message('please_ensure_x_file_is_located_at_y', 'vbulletin-style.xml', $vbulletin->GPC['path']);
	}

	if(!$parsed_xml = $xmlobj->parse())
	{
		print_dots_stop();
		print_stop_message('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line());
	}

	$version = $parsed_xml['vbversion'];
	$master = ($parsed_xml['type'] == 'master' ? 1 : 0);
	$title = (empty($title) ? $parsed_xml['name'] : $title);
	$product = (empty($parsed_xml['product']) ? 'vbulletin' : $parsed_xml['product']);


	$one_pass = (is_null($startat) AND is_null($perpage));
	if (!$one_pass AND (!is_numeric($startat) OR !is_numeric($perpage) OR $perpage <= 0 OR $startat < 0))
	{
			print_dots_stop();
			print_stop_message('');
	}

	if ($one_pass OR ($startat == 0))
	{
		// version check
		$full_product_info = fetch_product_list(true);
		$product_info = $full_product_info["$product"];

		if ($version != $product_info['version'] AND !$anyversion AND !$master)
		{
			print_dots_stop();
			print_stop_message('upload_file_created_with_different_version', $product_info['version'], $version);
		}

		//Initialize the style -- either init the master, create a new style, or verify the style to overwrite.
		if ($master)
		{
			$import_data = @unserialize(fetch_adminutil_text('master_style_import'));
			if (!empty($import_data) AND (TIMENOW - $import_data['last_import']) <= 30)
			{
				print_dots_stop();
				print_stop_message('must_wait_x_seconds_master_style_import', vb_number_format($import_data['last_import'] + 30 - TIMENOW));
			}

			// overwrite master style
			echo "<h3>$vbphrase[master_style]</h3>\n<p>$vbphrase[please_wait]</p>";
			vbflush();

			$vbulletin->db->query_write("
				DELETE FROM " . TABLE_PREFIX . "template
				WHERE styleid = -10 AND (product = '" . $vbulletin->db->escape_string($product) . "'" .
					iif($product == 'vbulletin', " OR product = ''") . ")"
			);

			$vbulletin->db->query_write("
				UPDATE " . TABLE_PREFIX . "template
				SET styleid = -10 WHERE styleid = -1 AND (product = '" . $vbulletin->db->escape_string($product) . "'" .
					iif($product == 'vbulletin', " OR product = ''") . ")
			");
			$styleid = -1;
		}
		else
		{
			if ($styleid == -1)
			{
				// creating a new style
				$test = $vbulletin->db->query_first("
					SELECT styleid FROM " . TABLE_PREFIX . "style
					WHERE title = '" . $vbulletin->db->escape_string($title) . "'"
				);

				if ($test)
				{
					print_dots_stop();
					print_stop_message('style_already_exists', $title);
				}
				else
				{
					echo "<h3><b>" . construct_phrase($vbphrase['creating_a_new_style_called_x'], $title) . "</b></h3>\n<p>$vbphrase[please_wait]</p>";
					vbflush();
					/*insert query*/
					$styleresult = $vbulletin->db->query_write("
						INSERT INTO " . TABLE_PREFIX . "style
						(title, parentid, displayorder, userselect)
						VALUES
						('" . $vbulletin->db->escape_string($title) . "', $parentid, $displayorder, " . ($userselect ? 1 : 0) . ")
					");
					$styleid = $vbulletin->db->insert_id($styleresult);
				}
			}
			else
			{
				// overwriting an existing style
				if ($getstyle = $vbulletin->db->query_first("SELECT title FROM " . TABLE_PREFIX . "style WHERE styleid = $styleid"))
				{
					echo "<h3><b>" . construct_phrase($vbphrase['overwriting_style_x'], $getstyle['title']) . "</b></h3>\n<p>$vbphrase[please_wait]</p>";
					vbflush();
				}
				else
				{
					print_dots_stop();
					print_stop_message('cant_overwrite_non_existent_style');
				}
			}
		}
	}

	//load the templates
	if ($arr = $parsed_xml['templategroup'])
	{
		if (empty($arr[0]))
		{
			$arr = array($arr);
		}

		$templates_done = (is_numeric($startat) AND (count($arr) < $startat));
		if ($one_pass OR !$templates_done)
		{
			if (!$one_pass)
			{
				$arr = array_slice($arr, $startat, $perpage);
			}
			xml_import_template_groups($styleid, $product, $arr, !$one_pass);
		}
	}
	else
	{
		$templates_done = true;
	}

	//note that templates may actually be done at this point, but templates_done is
	//only true if templates were completed in a prior step. If we are doing a multi-pass
	//process, we don't want to install stylevars in the same pass.  We aren't really done
	//until we hit a pass where the templates are done before processing.
	$done = ($one_pass OR $templates_done);
	if ($done)
	{
		//load stylevars and definitions
		// re-import any stylevar definitions
		if ($master AND !empty($parsed_xml['stylevardfns']['stylevargroup']))
		{
			xml_import_stylevar_definitions($parsed_xml['stylevardfns'], 'vbulletin');
		}

		//if the tag is present but empty we'll end up with a string with whitespace which
		//is a non "empty" value.
		if (!empty($parsed_xml['stylevars']) AND is_array($parsed_xml['stylevars']))
		{
			xml_import_stylevars($parsed_xml['stylevars'], $styleid);
		}

		if ($master)
		{
			xml_import_restore_adsense_templates();
			build_adminutil_text('master_style_import', serialize(array('last_import' => TIMENOW)));
		}

		print_dots_stop();
	}

	return array(
		'version' => $version,
		'master'  => $master,
		'title'   => $title,
		'product' => $product,
		'done'    => $done
	);
}
Exemplo n.º 16
0
 /**
  * Prepares Information regarding the Users's usernotes
  *
  */
 function prepare_usernote()
 {
     global $show;
     if (!($this->prepared['userperms']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canbeusernoted'])) {
         $this->prepared['usernotecount'] = 0;
         $this->prepared['usernoteinfo'] = array();
         $show['usernoteview'] = false;
         return;
     }
     if ($this->prepared['userid'] == $this->registry->userinfo['userid'] and $this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canviewownusernotes'] or $this->prepared['userid'] != $this->registry->userinfo['userid'] and $this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->userinfo->bf_ugp_genericpermissions['canviewothersusernotes']) {
         $show['usernotes'] = true;
     }
     if ($this->prepared['userid'] == $this->registry->userinfo['userid'] and $this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canpostownusernotes'] or $this->prepared['userid'] != $this->registry->userinfo['userid'] and $this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canpostothersusernotes']) {
         $show['usernotes'] = true;
         $show['usernotepost'] = true;
     }
     $usernote = $this->registry->db->query_first_slave("\n\t\t\tSELECT MAX(dateline) AS lastpost, COUNT(*) AS total\n\t\t\tFROM " . TABLE_PREFIX . "usernote AS usernote\n\t\t\tWHERE userid = " . $this->userinfo['userid']);
     $this->prepared['usernotecount'] = vb_number_format($usernote['total']);
     $show['usernoteview'] = intval($usernote['total']) ? true : false;
     $usernote['lastpostdate'] = vbdate($this->registry->options['dateformat'], $usernote['lastpost'], true);
     $usernote['lastposttime'] = vbdate($this->registry->options['timeformat'], $usernote['lastpost'], true);
     $this->prepared['usernoteinfo'] = $usernote;
 }
Exemplo n.º 17
0
                     $expiretime = 0;
                     break;
                 case 'H':
                 default:
                     $expiretime += mktime(date('H') + $infraction['expires'], date('i'), date('s'), date('m'), date('d'), date('y'));
                     break;
             }
             $timeleft = $expiretime - TIMENOW;
             $decimal = $vbulletin->userinfo['lang_decimalsep'];
             if ($timeleft < 86400) {
                 $expires = construct_phrase($vbphrase['x_hours'], preg_replace('#^(\\d+)' . $decimal . '0#', '\\1', vb_number_format($timeleft / 3600, 1)));
             } else {
                 if ($timeleft < 2592000) {
                     $expires = construct_phrase($vbphrase['x_days'], preg_replace('#^(\\d+)' . $decimal . '0#', '\\1', vb_number_format($timeleft / 86400, 1)));
                 } else {
                     $expires = construct_phrase($vbphrase['x_months'], preg_replace('#^(\\d+)' . $decimal . '0#', '\\1', vb_number_format($timeleft / 2592000, 1)));
                 }
             }
         }
     }
 }
 if (!$expires) {
     switch ($infraction['period']) {
         case 'H':
             $period = 'x_hours';
             break;
         case 'D':
             $period = 'x_days';
             break;
         case 'M':
             $period = 'x_months';
Exemplo n.º 18
0
 if ($show['inlinemod']) {
     $threadcolspan++;
     $announcecolspan++;
 }
 if (!$show['threadicons']) {
     $threadcolspan--;
     $announcecolspan--;
 }
 if (!empty($search['announceids']) and $vbulletin->GPC['pagenumber'] == 1) {
     $announcements = $db->query_read_slave("\n\t\t\tSELECT announcementid, startdate, title, announcement.views, forumid,\n\t\t\t\tuser.username, user.userid, user.usertitle, user.customtitle, user.usergroupid,\n\t\t\t\tIF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid\n\t\t\tFROM " . TABLE_PREFIX . "announcement AS announcement\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user USING (userid)\n\t\t\tWHERE announcementid IN ({$search['announceids']})\n\t\t\tORDER BY startdate DESC\n\t\t");
     while ($announcement = $db->fetch_array($announcements)) {
         fetch_musername($announcement);
         $announcement['title'] = fetch_censored_text($announcement['title']);
         $announcement['postdate'] = vbdate($vbulletin->options['dateformat'], $announcement['startdate']);
         $announcement['statusicon'] = 'new';
         $announcement['views'] = vb_number_format($announcement['views']);
         $announcementidlink = "&amp;a={$announcement['announcementid']}";
         $announcement['forumtitle'] = $vbulletin->forumcache["{$announcement['forumid']}"]['title'];
         $show['forumtitle'] = $announcement['forumid'] == -1 ? false : true;
         eval('$announcebits .= "' . fetch_template('threadbit_announcement') . '";');
     }
 }
 // get highlight words
 if (!empty($display['highlight'])) {
     $highlightwords = '&amp;highlight=' . urlencode(implode(' ', $display['highlight']));
 } else {
     $highlightwords = '';
 }
 // initialize counters and template bits
 $searchbits = '';
 $itemcount = $startat;
Exemplo n.º 19
0
/**
* Fetches the HTML for the tag cloud.
*
* @param	string	Type of cloud. Supports search, usage
*
* @return	string	Tag cloud HTML (nothing if no cloud)
*/
function fetch_tagcloud($type = 'usage')
{
    global $vbulletin, $stylevar, $vbphrase, $show, $template_hook;
    if ($vbulletin->options['tagcloud_usergroup'] > 0 and !isset($vbulletin->usergroupcache[$vbulletin->options['tagcloud_usergroup']])) {
        // handle a usergroup being deleted: default to live permission checking
        $vbulletin->options['tagcloud_usergroup'] = -1;
    }
    $cacheable = $vbulletin->options['tagcloud_usergroup'] != -1;
    if (!$cacheable) {
        $cloud = null;
    } else {
        switch ($type) {
            case 'search':
                $cloud = $vbulletin->searchcloud;
                break;
            case 'usage':
            default:
                $cloud = $vbulletin->tagcloud;
                break;
        }
    }
    if (!is_array($cloud) or $cloud['dateline'] < TIMENOW - 60 * $vbulletin->options['tagcloud_cachetime']) {
        if ($type == 'search') {
            $tags_result = $vbulletin->db->query_read_slave("\n\t\t\t\tSELECT tagsearch.tagid, tag.tagtext, COUNT(*) AS searchcount\n\t\t\t\tFROM " . TABLE_PREFIX . "tagsearch AS tagsearch\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagsearch.tagid = tag.tagid)\n\t\t\t\t" . ($vbulletin->options['tagcloud_searchhistory'] ? "WHERE tagsearch.dateline > " . (TIMENOW - 60 * 60 * 24 * $vbulletin->options['tagcloud_searchhistory']) : '') . "\n\t\t\t\tGROUP BY tagsearch.tagid, tag.tagtext\n\t\t\t\tORDER BY searchcount DESC\n\t\t\t\tLIMIT " . $vbulletin->options['tagcloud_tags']);
        } else {
            if (!$vbulletin->options['tagcloud_usergroup']) {
                $perm_limit = false;
            } else {
                $forums = array();
                $perm_limit = true;
                foreach ($vbulletin->forumcache as $forumid => $forum) {
                    // -1 for live permission checking
                    $perm_array = $vbulletin->options['tagcloud_usergroup'] == -1 ? $vbulletin->userinfo['forumpermissions']["{$forumid}"] : $forum['permissions'][$vbulletin->options['tagcloud_usergroup']];
                    if ($perm_array & $vbulletin->bf_ugp_forumpermissions['canview'] and $perm_array & $vbulletin->bf_ugp_forumpermissions['canviewthreads'] and $perm_array & $vbulletin->bf_ugp_forumpermissions['canviewothers']) {
                        $forums[] = intval($forumid);
                    }
                }
            }
            if (!$perm_limit or $forums) {
                $tags_result = $vbulletin->db->query_read_slave("\n\t\t\t\t\tSELECT tagthread.tagid, tag.tagtext, COUNT(*) AS searchcount\n\t\t\t\t\tFROM " . TABLE_PREFIX . "tagthread AS tagthread\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "tag AS tag ON (tagthread.tagid = tag.tagid)\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "thread AS thread ON (tagthread.threadid = thread.threadid)\n\t\t\t\t\tWHERE thread.open <> 10\n\t\t\t\t\t\tAND thread.visible = 1\n\t\t\t\t\t" . ($perm_limit ? "AND thread.forumid IN (" . implode(',', $forums) . ")" : '') . "\n\t\t\t\t\t" . ($vbulletin->options['tagcloud_usagehistory'] ? "AND tagthread.dateline > " . (TIMENOW - 60 * 60 * 24 * $vbulletin->options['tagcloud_usagehistory']) : '') . "\n\t\t\t\t\tGROUP BY tagthread.tagid, tag.tagtext\n\t\t\t\t\tORDER BY searchcount DESC\n\t\t\t\t\tLIMIT " . $vbulletin->options['tagcloud_tags']);
            }
        }
        $total = 0;
        $count = 0;
        if (!empty($tags_result)) {
            $count = $vbulletin->db->num_rows($tags_result);
            while ($currenttag = $vbulletin->db->fetch_array($tags_result)) {
                $tags["{$currenttag['tagtext']}"] = $currenttag;
                $total += $currenttag['searchcount'];
            }
            $vbulletin->db->free_result($tags_result);
        }
        $final_tags = array();
        if ($count > 0) {
            // calculate the standard deviation
            $mean = $total / $count;
            $summation = 0;
            foreach ($tags as $tagtext => $tagvalue) {
                $summation += pow($tagvalue['searchcount'] - $mean, 2);
            }
            $sd = sqrt($summation / $count);
            uksort($tags, 'strnatcasecmp');
            if ($sd) {
                $sdtags = array();
                $lowestsds = 0;
                $highestsds = 0;
                // find the max and min standard deviations
                foreach ($tags as $tagtext => $currenttag) {
                    $tags["{$tagtext}"]['deviation'] = $currenttag['searchcount'] - $mean;
                    $tags["{$tagtext}"]['sds'] = $tags["{$tagtext}"]['deviation'] / $sd;
                    $sdtags[] = $tags["{$tagtext}"];
                    if ($tags["{$tagtext}"]['sds'] < $lowestsds) {
                        $lowestsds = $tags["{$tagtext}"]['sds'];
                    }
                    if ($tags["{$tagtext}"]['sds'] > $highestsds) {
                        $highestsds = $tags["{$tagtext}"]['sds'];
                    }
                }
                $levels = $vbulletin->options['tagcloud_levels'];
                foreach ($sdtags as $thistag) {
                    // normalize the std devs to 0 - 1, then map back to 1 - #levls
                    $thistag['level'] = round(($thistag['sds'] - $lowestsds) / ($highestsds - $lowestsds) * ($levels - 1)) + 1;
                    $thistag['tagtext_url'] = urlencode(unhtmlspecialchars($thistag['tagtext']));
                    $final_tags[] = $thistag;
                }
            } else {
                foreach ($tags as $tagtext => $tagarr) {
                    $final_tags[] = array('tagid' => $tagarr['tagid'], 'tagtext' => $tagtext, 'tagtext_url' => urlencode(unhtmlspecialchars($tagtext)), 'level' => round($vbulletin->options['tagcloud_levels'] / 2));
                }
            }
        }
        $cloud = array('tags' => $final_tags, 'count' => sizeof($final_tags), 'dateline' => TIMENOW);
        if ($cacheable) {
            if ($type == 'search') {
                $vbulletin->searchcloud = $cloud;
                build_datastore('searchcloud', serialize($cloud), 1);
            } else {
                $vbulletin->tagcloud = $cloud;
                build_datastore('tagcloud', serialize($cloud), 1);
            }
        }
    }
    if (empty($cloud['tags'])) {
        return '';
    }
    $cloud['links'] = '';
    foreach ($cloud['tags'] as $thistag) {
        ($hook = vBulletinHook::fetch_hook('tag_cloud_bit')) ? eval($hook) : false;
        eval('$cloud[\'links\'] .= "' . fetch_template('tag_cloud_link') . '";');
    }
    $cloud['count'] = vb_number_format($cloud['count']);
    if ($type == 'search') {
        eval('$cloud_html .= "' . fetch_template('tag_cloud_box_search') . '";');
    } else {
        eval('$cloud_html .= "' . fetch_template('tag_cloud_box') . '";');
    }
    return $cloud_html;
}
Exemplo n.º 20
0
 function check_overage()
 {
     require_once DIR . '/includes/functions_album.php';
     if ($this->userinfo['permissions']['albummaxpics']) {
         $overage = fetch_count_overage($this->userinfo['userid'], $this->userinfo['permissions']['albummaxpics'], 1);
         if ($overage > 0) {
             $this->set_error('upload_total_album_pics_countfull', vb_number_format($overage));
             return false;
         }
     }
     if ($this->userinfo['permissions']['albummaxsize']) {
         $overage = fetch_size_overage($this->userinfo['userid'], $this->userinfo['permissions']['albummaxsize'], $this->upload['filesize']);
         if ($overage > 0) {
             $this->set_error('upload_album_sizefull', vb_number_format($overage, 0, true));
             return false;
         }
     }
     return true;
 }
Exemplo n.º 21
0
 /**
  *	Parses the appropriate template for contenttype that is to be updated on the calling window during an upload
  *
  * @param	array	Attachment information
  * @param	array	Values array pertaining to contenttype
  * @param	boolean	Disable template comments
  *
  * @return	string
  */
 public function process_display_template($attach, $values = array(), $disablecomment = true)
 {
     $attach['extension'] = strtolower(file_extension($attach['filename']));
     $attach['filename'] = fetch_censored_text(htmlspecialchars_uni($attach['filename'], false));
     $attach['filesize'] = vb_number_format($attach['filesize'], 1, true);
     $attach['imgpath'] = $this->fetch_imgpath($attach['extension']);
     $templater = vB_Template::create('newpost_attachmentbit');
     $templater->register('attach', $attach);
     return $templater->render($disablecomment);
 }
Exemplo n.º 22
0
 $sub['title'] = $vbphrase['sub' . $sub['subscriptionid'] . '_title'];
 $sub['description'] = $vbphrase['sub' . $sub['subscriptionid'] . '_desc'];
 $currency = $vbulletin->GPC['currency']["{$subscriptionid}"];
 $tmp = explode('_', $currency);
 $currency = $tmp[1];
 $subscriptionsubid = intval($tmp[0]);
 unset($tmp);
 $costs = unserialize($sub['cost']);
 if ($costs["{$subscriptionsubid}"]['length'] == 1) {
     $subscription_units = $lengths[$costs["{$subscriptionsubid}"]['units']];
 } else {
     $subscription_units = $lengths[$costs["{$subscriptionsubid}"]['units'] . 's'];
 }
 $subscription_length = construct_phrase($vbphrase['length_x_units_y_recurring_z'], $costs["{$subscriptionsubid}"]['length'], $subscription_units, $costs["{$subscriptionsubid}"]['recurring'] ? ' *' : '');
 $subscription_title = $sub['title'];
 $subscription_cost = $subobj->_CURRENCYSYMBOLS["{$currency}"] . vb_number_format($costs["{$subscriptionsubid}"]['cost']["{$currency}"], 2);
 $orderbits = '';
 if (empty($costs["{$subscriptionsubid}"]['cost']["{$currency}"])) {
     eval(standard_error(fetch_error('invalid_currency')));
 }
 // These phrases are constant since they are the name of a service
 $tmp = array('paypal' => 'PayPal', 'nochex' => 'NOCHEX', 'worldpay' => 'WorldPay', '2checkout' => '2Checkout', 'moneybookers' => 'MoneyBookers', 'authorizenet' => 'Authorize.Net', 'ccbill' => 'CCBill');
 $vbphrase += $tmp;
 ($hook = vBulletinHook::fetch_hook('paidsub_order_start')) ? eval($hook) : false;
 $hash = md5($vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt'] . $subscriptionid . uniqid(microtime(), 1));
 /* insert query */
 $db->query_write("\n\t\tINSERT INTO " . TABLE_PREFIX . "paymentinfo\n\t\t\t(hash, completed, subscriptionid, subscriptionsubid, userid)\n\t\tVALUES\n\t\t\t('" . $db->escape_string($hash) . "', 0, {$subscriptionid}, {$subscriptionsubid}, " . $vbulletin->userinfo['userid'] . ")\n\t");
 $methods = $db->query_read_slave("SELECT * FROM " . TABLE_PREFIX . "paymentapi WHERE active = 1 AND FIND_IN_SET('" . $db->escape_string($currency) . "', currency)");
 while ($method = $db->fetch_array($methods)) {
     if (empty($costs["{$subscriptionsubid}"]['ccbillsubid']) and $method['classname'] == 'ccbill') {
         continue;
Exemplo n.º 23
0
 sanitize_pageresults($totalrep, $vbulletin->GPC['pagenumber'], $vbulletin->GPC['perpage']);
 $startat = ($vbulletin->GPC['pagenumber'] - 1) * $vbulletin->GPC['perpage'];
 $totalpages = ceil($totalrep / $vbulletin->GPC['perpage']);
 $comments = $db->query_read("\n\t\tSELECT post.postid, rep.userid AS userid, whoadded, rep.reason, rep.dateline, rep.reputationid, rep.reputation,\n\t\t\tleftfor_user.username AS leftfor_username,\n\t\t\tleftby_user.username AS leftby_username,\n\t\t\tpost.title, post.threadid\n\t\tFROM " . TABLE_PREFIX . "reputation AS rep\n\t\tLEFT JOIN " . TABLE_PREFIX . "post AS post ON (rep.postid = post.postid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS leftby_user ON (rep.whoadded = leftby_user.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS leftfor_user ON (rep.userid = leftfor_user.userid)\n\t\t{$condition}\n\t\tORDER BY {$orderbysql}\n\t\tLIMIT {$startat}, " . $vbulletin->GPC['perpage']);
 if ($vbulletin->GPC['pagenumber'] != 1) {
     $prv = $vbulletin->GPC['pagenumber'] - 1;
     $firstpage = "<input type=\"button\" class=\"button\" value=\"&laquo; " . $vbphrase['first_page'] . "\" tabindex=\"1\" onclick=\"window.location='adminreputation.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . "&u=" . $vbulletin->GPC['userid'] . "&whoadded=" . $vbulletin->GPC['whoadded'] . "&pp=" . $vbulletin->GPC['perpage'] . "&page=1" . "&startstamp=" . $vbulletin->GPC['start'] . "&endstamp=" . $vbulletin->GPC['end'] . "&orderby=" . $vbulletin->GPC['orderby'] . "'\">";
     $prevpage = "<input type=\"button\" class=\"button\" value=\"&lt; " . $vbphrase['prev_page'] . "\" tabindex=\"1\" onclick=\"window.location='adminreputation.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . "&u=" . $vbulletin->GPC['userid'] . "&whoadded=" . $vbulletin->GPC['whoadded'] . "&pp=" . $vbulletin->GPC['perpage'] . "&page=" . $prv . "&startstamp=" . $vbulletin->GPC['start'] . "&endstamp=" . $vbulletin->GPC['end'] . "&orderby=" . $vbulletin->GPC['orderby'] . "'\">";
 }
 if ($vbulletin->GPC['pagenumber'] != $totalpages) {
     $nxt = $vbulletin->GPC['pagenumber'] + 1;
     $nextpage = "<input type=\"button\" class=\"button\" value=\"" . $vbphrase['next_page'] . " &gt;\" tabindex=\"1\" onclick=\"window.location='adminreputation.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . "&u=" . $vbulletin->GPC['userid'] . "&whoadded=" . $vbulletin->GPC['whoadded'] . "&pp=" . $vbulletin->GPC['perpage'] . "&page=" . $nxt . "&startstamp=" . $vbulletin->GPC['start'] . "&endstamp=" . $vbulletin->GPC['end'] . "&orderby=" . $vbulletin->GPC['orderby'] . "'\">";
     $lastpage = "<input type=\"button\" class=\"button\" value=\"" . $vbphrase['last_page'] . " &raquo;\" tabindex=\"1\" onclick=\"window.location='adminreputation.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . "&u=" . $vbulletin->GPC['userid'] . "&whoadded=" . $vbulletin->GPC['whoadded'] . "&pp=" . $vbulletin->GPC['perpage'] . "&page=" . $totalpages . "&startstamp=" . $vbulletin->GPC['start'] . "&endstamp=" . $vbulletin->GPC['end'] . "&orderby=" . $vbulletin->GPC['orderby'] . "'\">";
 }
 print_form_header('adminreputation', 'dolist');
 print_table_header(construct_phrase($vbphrase['x_reputation_comments_page_y_z'], vb_number_format($totalrep), $vbulletin->GPC['pagenumber'], vb_number_format($totalpages)), 7);
 $headings = array();
 $headings[] = "<a href='adminreputation.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . "&amp;u=" . $vbulletin->GPC['userid'] . "&amp;whoadded=" . $vbulletin->GPC['whoadded'] . "&amp;pp=" . $vbulletin->GPC['perpage'] . "&amp;orderby=leftbyuser" . "&amp;page=" . $vbulletin->GPC['pagenumber'] . "&amp;startstamp=" . $vbulletin->GPC['start'] . "&amp;endstamp=" . $vbulletin->GPC['end'] . "' title='" . $vbphrase['order_by_username'] . "'>" . $vbphrase['leftby'] . "</a>";
 $headings[] = "<a href='adminreputation.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . "&amp;u=" . $vbulletin->GPC['userid'] . "&amp;whoadded=" . $vbulletin->GPC['whoadded'] . "&amp;pp=" . $vbulletin->GPC['perpage'] . "&amp;orderby=leftforuser" . "&amp;page=" . $vbulletin->GPC['pagenumber'] . "&amp;startstamp=" . $vbulletin->GPC['start'] . "&amp;endstamp=" . $vbulletin->GPC['end'] . "' title='" . $vbphrase['order_by_username'] . "'>" . $vbphrase['leftfor'] . "</a>";
 $headings[] = "<a href='adminreputation.php?" . $vbulletin->session->vars['sessionurl'] . "do=dolist" . "&amp;u=" . $vbulletin->GPC['userid'] . "&amp;whoadded=" . $vbulletin->GPC['whoadded'] . "&amp;pp=" . $vbulletin->GPC['perpage'] . "&amp;orderby=date" . "&amp;page=" . $vbulletin->GPC['pagenumber'] . "&amp;startstamp=" . $vbulletin->GPC['start'] . "&amp;endstamp=" . $vbulletin->GPC['end'] . "' title='" . $vbphrase['order_by_date'] . "'>" . $vbphrase['date'] . "</a>";
 $headings[] = $vbphrase['reputation'];
 $headings[] = $vbphrase['reason'];
 $headings[] = $vbphrase['post'];
 $headings[] = $vbphrase['controls'];
 print_cells_row($headings, 1);
 while ($comment = $db->fetch_array($comments)) {
     $postlink = '';
     if (!empty($comment['postid'])) {
         //deliberately don't use the title.  We don't have it in our result set (or
         //in any of the tables in our result set) and we'll catch it on redirect.
         //Plus the admincp isn't a big SEO issue -- we just want to get the links
Exemplo n.º 24
0
        $cell[] = '<span class="smallfont">' . construct_link_code($vbphrase['view_content'], $attachmultiple->fetch_content_url($attachment, '../'), true) . construct_link_code($vbphrase['edit'], "attachment.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;attachmentid={$attachment['attachmentid']}") . construct_link_code($vbphrase['delete'], "attachment.php?" . $vbulletin->session->vars['sessionurl'] . "do=delete&amp;attachmentid={$attachment['attachmentid']}") . '</span>';
        print_cells_row($cell);
    }
    print_table_break();
    $content = array();
    $largestuser = $db->query_read("\n\t\tSELECT COUNT(*) AS count, SUM(filesize) AS totalsize, user.userid, username\n\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\tINNER JOIN " . TABLE_PREFIX . "filedata AS fd ON (a.filedataid = fd.filedataid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (a.userid = user.userid)\n\t\tGROUP BY a.userid\n\t\tHAVING totalsize > 0\n\t\tORDER BY totalsize DESC\n\t\tLIMIT 5\n\t");
    $position = 0;
    print_table_header($vbphrase['five_users_most_attachment_space'], 5);
    print_cells_row(array('&nbsp;', $vbphrase['username'], $vbphrase['attachments'], $vbphrase['total_size'], '&nbsp;'), 1);
    while ($thispop = $db->fetch_array($largestuser)) {
        $position++;
        $cell = array();
        $cell[] = $position . '.';
        $cell[] = "<a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;u={$thispop['userid']}\">{$thispop['username']}</a>";
        $cell[] = vb_number_format($thispop['count']);
        $cell[] = vb_number_format($thispop['totalsize'], 1, true);
        $cell[] = '<span class="smallfont">' . construct_link_code($vbphrase['view_attachments'], "attachment.php?" . $vbulletin->session->vars['sessionurl'] . "do=search&amp;search[attachedby]=" . urlencode($thispop['username'])) . '</span>';
        print_cells_row($cell);
    }
    print_table_footer();
}
// ###################### Introduction ####################
if ($_REQUEST['do'] == 'intro') {
    print_form_header('attachment', 'search');
    print_table_header($vbphrase['quick_search']);
    print_description_row("\n\t<ul style=\"margin:0px; padding:0px; list-style:none\">\n\t\t<li><a href=\"attachment.php?" . $vbulletin->session->vars['sessionurl'] . "do=search&amp;search[orderby]=filesize&amp;search[ordering]=DESC\">" . $vbphrase['view_largest_attachments'] . "</a></li>\n\t\t<li><a href=\"attachment.php?" . $vbulletin->session->vars['sessionurl'] . "do=search&amp;search[orderby]=counter&amp;search[ordering]=DESC\">" . $vbphrase['view_most_popular_attachments'] . "</a></li>\n\t\t<li><a href=\"attachment.php?" . $vbulletin->session->vars['sessionurl'] . "do=search&amp;search[orderby]=dateline&amp;search[ordering]=DESC\">" . $vbphrase['view_newest_attachments'] . "</a></li>\n\t\t<li><a href=\"attachment.php?" . $vbulletin->session->vars['sessionurl'] . "do=search&amp;search[orderby]=dateline&amp;search[ordering]=ASC\">" . $vbphrase['view_oldest_attachments'] . "</a></li>\n\t</ul>\n\t");
    print_table_break();
    print_table_header($vbphrase['prune_attachments']);
    print_input_row($vbphrase['find_all_attachments_older_than_days'], 'prunedate', 30);
    print_submit_row($vbphrase['search'], 0);
    print_form_header('attachment', 'search');
Exemplo n.º 25
0
                construct_hidden_code('query', $query);
                construct_hidden_code('perpage', $vbulletin->GPC['perpage']);
                construct_hidden_code('confirmquery', 1);
                print_table_header($vbphrase['confirm_query_execution']);
                print_description_row($vbphrase['query_may_modify_database']);
                print_submit_row($vbphrase['continue'], false, 2, $vbphrase['go_back']);
            } else {
                $time_before = microtime();
                $db->query_write($query);
                $time_taken = fetch_microtime_difference($time_before);
                print_form_header('queries', 'doquery');
                print_table_header($vbphrase['vbulletin_message']);
                if ($errornum = $db->errno()) {
                    print_description_row(construct_phrase($vbphrase['an_error_occured_while_attempting_to_run_your_query'], $errornum, nl2br(htmlspecialchars_uni($db->error()))));
                } else {
                    print_description_row(construct_phrase($vbphrase['affected_rows'], vb_number_format($db->affected_rows()), vb_number_format($time_taken, 4)));
                }
                print_table_footer();
            }
            break;
    }
}
// ##################### START MODIFY #####################
if ($_REQUEST['do'] == 'modify') {
    print_form_header('queries', 'doquery');
    print_table_header($vbphrase['execute_sql_query']);
    print_select_row($vbphrase['auto_query'], 'autoquery', $queryoptions, -1);
    print_textarea_row($vbphrase['manual_query'], 'query', '', 10, 55);
    print_input_row($vbphrase['results_to_show_per_page'], 'perpage', 20);
    print_submit_row($vbphrase['continue']);
}
Exemplo n.º 26
0
 $usergroups = array();
 // query usergroups of which bbuser is a leader
 $joinrequests = $db->query_read_slave("\n\t\tSELECT usergroupleader.usergroupid, COUNT(usergrouprequestid) AS requests\n\t\tFROM " . TABLE_PREFIX . "usergroupleader AS usergroupleader\n\t\tLEFT JOIN " . TABLE_PREFIX . "usergrouprequest AS usergrouprequest USING(usergroupid)\n\t\tWHERE usergroupleader.userid = " . $vbulletin->userinfo['userid'] . "\n\t\tGROUP BY usergroupleader.usergroupid\n\t");
 while ($joinrequest = $db->fetch_array($joinrequests)) {
     $usergroups["{$joinrequest['usergroupid']}"] = intval($joinrequest['requests']);
 }
 unset($joinrequest);
 $db->free_result($joinrequests);
 // if we got no results, or if the specified usergroupid was not returned, show no permission
 if (empty($usergroups)) {
     print_no_permission();
 }
 $usergroupbits = '';
 foreach ($vbulletin->usergroupcache as $optionvalue => $usergroup) {
     if (isset($usergroups["{$optionvalue}"])) {
         $optiontitle = construct_phrase($vbphrase['x_y_requests'], $vbulletin->usergroupcache["{$optionvalue}"]['title'], vb_number_format($usergroups["{$optionvalue}"]));
         $optionselected = iif($optionvalue == $vbulletin->GPC['usergroupid'], 'selected="selected"', '');
         $optionclass = '';
         $usergroupbits .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass);
     }
 }
 // set a shortcut to the vbulletin->usergroupcache entry for this group
 $usergroup =& $vbulletin->usergroupcache["{$vbulletin->GPC['usergroupid']}"];
 // initialize $joinrequestbits
 $joinrequestbits = '';
 $numrequests =& $usergroups["{$vbulletin->GPC['usergroupid']}"];
 // if there are some requests for this usergroup, display them
 if ($numrequests > 0) {
     // set defaults
     sanitize_pageresults($numrequests, $vbulletin->GPC['pagenumber'], $vbulletin->GPC['perpage'], 100, 20);
     $startat = ($vbulletin->GPC['pagenumber'] - 1) * $vbulletin->GPC['perpage'];
Exemplo n.º 27
0
/**
* Fetch the valid tags from a list. Filters are length, censorship, perms (if desired).
*
* @param	array			Array of existing thread info (including the existing tags)
* @param	string|array	List of tags to add (comma delimited, or an array as is). If array, ensure there are no commas.
* @param	array			(output) List of errors that happens
* @param	boolean		Whether to check the browsing user's create tag perms
* @param	boolean		Whether to expand the error phrase
*
* @return	array			List of valid tags
*/
function fetch_valid_tags($threadinfo, $taglist, &$errors, $check_browser_perms = true, $evalerrors = true)
{
    global $vbulletin;
    static $tagbadwords, $taggoodwords;
    $errors = array();
    if (!is_array($taglist)) {
        $taglist = split_tag_list($taglist);
    }
    if (!trim($threadinfo['taglist'])) {
        $existing_tags = array();
    } else {
        // this will always be delimited by a comma
        $existing_tags = explode(',', trim($threadinfo['taglist']));
    }
    if ($vbulletin->options['tagmaxthread'] and count($existing_tags) >= $vbulletin->options['tagmaxthread']) {
        $errors['threadmax'] = $evalerrors ? fetch_error('thread_has_max_allowed_tags') : 'thread_has_max_allowed_tags';
        return array();
    }
    if ($vbulletin->options['tagmaxlen'] <= 0 or $vbulletin->options['tagmaxlen'] >= 100) {
        $vbulletin->options['tagmaxlen'] = 100;
    }
    $valid_raw = array();
    // stop words: too common
    require DIR . '/includes/searchwords.php';
    // get the stop word list; allow multiple requires
    // filter the stop words by adding custom stop words (tagbadwords) and allowing through exceptions (taggoodwords)
    if (!is_array($tagbadwords)) {
        $tagbadwords = preg_split('/\\s+/s', vbstrtolower($vbulletin->options['tagbadwords']), -1, PREG_SPLIT_NO_EMPTY);
    }
    if (!is_array($taggoodwords)) {
        $taggoodwords = preg_split('/\\s+/s', vbstrtolower($vbulletin->options['taggoodwords']), -1, PREG_SPLIT_NO_EMPTY);
    }
    // merge hard-coded badwords and tag-specific badwords
    $badwords = array_merge($badwords, $tagbadwords);
    foreach ($taglist as $tagtext) {
        $tagtext = trim(preg_replace('#[ \\r\\n\\t]+#', ' ', $tagtext));
        if ($tagtext === '') {
            continue;
        }
        if (!in_array(vbstrtolower($tagtext), $taggoodwords)) {
            $char_strlen = vbstrlen($tagtext, true);
            if ($vbulletin->options['tagminlen'] and $char_strlen < $vbulletin->options['tagminlen']) {
                $errors['min_length'] = $evalerrors ? fetch_error('tag_too_short_min_x', $vbulletin->options['tagminlen']) : array('tag_too_short_min_x', $vbulletin->options['tagminlen']);
                continue;
            }
            if ($char_strlen > $vbulletin->options['tagmaxlen']) {
                $errors['max_length'] = $evalerrors ? fetch_error('tag_too_long_max_x', $vbulletin->options['tagmaxlen']) : array('tag_too_long_max_x', $vbulletin->options['tagmaxlen']);
                continue;
            }
            if (strlen($tagtext) > 100) {
                // only have 100 bytes to store a tag
                $errors['max_length'] = $evalerrors ? fetch_error('tag_too_long_max_x', $vbulletin->options['tagmaxlen']) : array('tag_too_long_max_x', $vbulletin->options['tagmaxlen']);
                continue;
            }
            $censored = fetch_censored_text($tagtext);
            if ($censored != $tagtext) {
                // can't have tags with censored text
                $errors['censor'] = $evalerrors ? fetch_error('tag_no_censored') : 'tag_no_censored';
                continue;
            }
            if (count(split_tag_list($tagtext)) > 1) {
                // contains a delimiter character
                $errors['comma'] = $evalerrors ? fetch_error('tag_no_comma') : 'tag_no_comma';
                continue;
            }
            if (in_array(strtolower($tagtext), $badwords)) {
                $errors['common'] = $evalerrors ? fetch_error('tag_x_not_be_common_words', $tagtext) : array('tag_x_not_be_common_words', $tagtext);
                continue;
            }
        }
        $valid_raw[] = $vbulletin->options['tagforcelower'] ? vbstrtolower($tagtext) : $tagtext;
    }
    // we need to essentially do a case-insensitive array_unique here
    $valid_unique = array_unique(array_map('vbstrtolower', $valid_raw));
    $valid = array();
    foreach (array_keys($valid_unique) as $key) {
        $valid[] = $valid_raw["{$key}"];
    }
    $valid_unique = array_values($valid_unique);
    // make the keys jive with $valid
    if ($valid) {
        $existing_sql = $vbulletin->db->query_read("\n\t\t\tSELECT tag.tagtext, IF(tagthread.tagid IS NULL, 0, 1) AS taginthread\n\t\t\tFROM " . TABLE_PREFIX . "tag AS tag\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "tagthread AS tagthread ON\n\t\t\t\t(tag.tagid = tagthread.tagid AND tagthread.threadid = " . intval($threadinfo['threadid']) . ")\n\t\t\tWHERE tag.tagtext IN ('" . implode("','", array_map(array(&$vbulletin->db, 'escape_string'), $valid)) . "')\n\t\t");
        if ($check_browser_perms and !($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cancreatetag'])) {
            // can't create tags, need to throw errors about bad ones
            $new_tags = array_flip($valid_unique);
            while ($tag = $vbulletin->db->fetch_array($existing_sql)) {
                unset($new_tags[vbstrtolower($tag['tagtext'])]);
            }
            if ($new_tags) {
                // trying to create tags without permissions. Remove and throw an error
                $errors['no_create'] = $evalerrors ? fetch_error('tag_no_create') : 'tag_no_create';
                foreach ($new_tags as $new_tag => $key) {
                    // remove those that we can't add from the list
                    unset($valid["{$key}"], $valid_unique["{$key}"]);
                }
            }
        }
        $vbulletin->db->data_seek($existing_sql, 0);
        // determine which tags are already in the thread and just ignore them
        while ($tag = $vbulletin->db->fetch_array($existing_sql)) {
            if ($tag['taginthread']) {
                // tag is in thread, find it and remove
                if (($key = array_search(vbstrtolower($tag['tagtext']), $valid_unique)) !== false) {
                    unset($valid["{$key}"], $valid_unique["{$key}"]);
                }
            }
        }
        $user_tags_remain = null;
        if ($vbulletin->options['tagmaxthread']) {
            // check global limit
            $user_tags_remain = $vbulletin->options['tagmaxthread'] - count($existing_tags) - count($valid);
        }
        if (!can_moderate($threadinfo['forumid'], 'caneditthreads')) {
            $my_tag_count_array = $vbulletin->db->query_first("\n\t\t\t\tSELECT COUNT(*) AS count\n\t\t\t\tFROM " . TABLE_PREFIX . "tagthread\n\t\t\t\tWHERE threadid = " . intval($threadinfo['threadid']) . "\n\t\t\t\t\tAND userid = " . $vbulletin->userinfo['userid']);
            $my_tag_count = $my_tag_count_array['count'] + count($valid);
            $tags_remain = null;
            if ($vbulletin->options['tagmaxstarter'] and $threadinfo['postuserid'] == $vbulletin->userinfo['userid']) {
                $tags_remain = $vbulletin->options['tagmaxstarter'] - $my_tag_count;
            } else {
                if ($vbulletin->options['tagmaxuser']) {
                    $tags_remain = $vbulletin->options['tagmaxuser'] - $my_tag_count;
                }
            }
            if ($tags_remain !== null) {
                $user_tags_remain = $user_tags_remain == null ? $tags_remain : min($tags_remain, $user_tags_remain);
            }
        }
        if ($user_tags_remain < 0) {
            $errors['threadmax'] = $evalerrors ? fetch_error('number_tags_add_exceeded_x', vb_number_format($user_tags_remain * -1)) : array('number_tags_add_exceeded_x', vb_number_format($user_tags_remain * -1));
            $allowed_tag_count = count($valid) + $user_tags_remain;
            if ($allowed_tag_count > 0) {
                $valid = array_slice($valid, 0, count($valid) + $user_tags_remain);
            } else {
                $valid = array();
            }
        }
    }
    return $valid;
}
Exemplo n.º 28
0
	unset($customfieldsheader);
	if ($show['customfields'] AND is_array($profileinfo))
	{
		foreach ($profileinfo AS $index => $customfield)
		{
			$totalcols++;
			$customfield = $customfield['title'];
			$templater = vB_Template::create('memberlist_results_header');
				$templater->register('customfield', $customfield);
			$customfieldsheader .= $templater->render();
		}
	}
	// build navbar
	$navbits = array('' => $vbphrase['members_list']);

	$searchtime = vb_number_format(fetch_microtime_difference($searchstart), 2);
	$totalcols += !empty($usergroupid) ? 2 : 1;

	$page_templater = vB_Template::create('memberlist');
	$page_templater->register('customfieldsheader', $customfieldsheader);
	$page_templater->register('first', $first);
	$page_templater->register('forumjump', $forumjump);
	$page_templater->register('gobutton', $gobutton);
	$page_templater->register('last', $last);
	$page_templater->register('leadergroup', $leadergroup);
	$page_templater->register('letterbits', $letterbits);
	$page_templater->register('ltr', $ltr);
	$page_templater->register('memberlistbits', $memberlistbits);
	$page_templater->register('pagenav', $pagenav);
	$page_templater->register('perpage', $perpage);
	$page_templater->register('searchtime', $searchtime);
Exemplo n.º 29
0
             }
             ($hook = vBulletinHook::fetch_hook('profile_editattachments_bit')) ? eval($hook) : false;
             eval('$template[\'attachmentlistbits\'] .= "' . fetch_template('modifyattachmentsbit') . '";');
         }
         $sorturl = 'profile.php?' . $vbulletin->session->vars['sessionurl'] . 'do=editattachments';
         if ($userid != $vbulletin->userinfo['userid']) {
             $sorturl .= "&amp;u={$userid}";
         }
         if ($perpage != $defaultperpage) {
             $sorturl .= "&amp;pp={$perpage}";
         }
         if ($showthumbs) {
             $sorturl .= "&amp;showthumbs=1";
         }
         $pagenav = construct_page_nav($pagenumber, $perpage, $totalattachments, $sorturl);
         $totalattachments = vb_number_format($totalattachments);
         $show['attachlimit'] = $permissions['attachlimit'];
         $show['currentattachsize'] = $attachsize;
         $show['totalattachsize'] = $totalsize;
         $show['thumbnails'] = $showthumbs;
     }
 }
 $show['lightbox'] = ($vbulletin->options['lightboxenabled'] and $vbulletin->options['usepopups'] and $showthumbs);
 ($hook = vBulletinHook::fetch_hook('profile_editattachments_complete')) ? eval($hook) : false;
 if ($userid == $vbulletin->userinfo['userid']) {
     // show $vbulletin->userinfo's attachments in usercp
     construct_usercp_nav('attachments');
     $navbits[''] = construct_phrase($vbphrase['attachments_posted_by_x'], $vbulletin->userinfo['username']);
 } else {
     // show some other user's attachments
     $pagetitle = construct_phrase($vbphrase['attachments_posted_by_x'], $username);
Exemplo n.º 30
0
/**
* Deletes all private messages belonging to the specified user
*
* @param	integer	User ID
* @param	boolean	If true, update the user record in the database to reflect their new number of private messages
*
* @return	mixed	If messages are deleted, will return a string to be printed out detailing work done by this function
*/
function delete_user_pms($userid, $updateuser = true)
{
    global $vbulletin, $vbphrase;
    $userid = intval($userid);
    // array to store pm ids message ids
    $pms = array();
    // array to store the number of pmtext records used by this user
    $pmTextCount = array();
    // array to store the ids of any pmtext records that are used soley by this user
    $deleteTextIDs = array();
    // array to store results
    $out = array();
    // first zap all receipts belonging to this user
    $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "pmreceipt WHERE userid = {$userid}");
    $out['receipts'] = $vbulletin->db->affected_rows();
    // now find all this user's private messages
    $messages = $vbulletin->db->query_read("\n\t\tSELECT pmid, pmtextid\n\t\tFROM " . TABLE_PREFIX . "pm\n\t\tWHERE userid = {$userid}\n\t");
    while ($message = $vbulletin->db->fetch_array($messages)) {
        // stick this record into our $pms array
        $pms["{$message['pmid']}"] = $message['pmtextid'];
        // increment the number of PMs that use the current PMtext record
        $pmTextCount["{$message['pmtextid']}"]++;
    }
    $vbulletin->db->free_result($messages);
    if (!empty($pms)) {
        // zap all pm records belonging to this user
        $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "pm WHERE userid = {$userid}");
        $out['pms'] = $vbulletin->db->affected_rows();
        $out['pmtexts'] = 0;
        // update the user record if necessary
        if ($updateuser and $user = fetch_userinfo($userid)) {
            $updateduser = true;
            $userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
            $userdm->set_existing($user);
            $userdm->set('pmtotal', 0);
            $userdm->set('pmunread', 0);
            $userdm->set('pmpopup', 'IF(pmpopup=2, 1, pmpopup)', false);
            $userdm->save();
            unset($userdm);
        }
    } else {
        $out['pms'] = 0;
        $out['pmtexts'] = 0;
    }
    // in case the totals have been corrupted somehow
    if (!isset($updateduser) and $updateuser and $user = fetch_userinfo($userid)) {
        $userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
        $userdm->set_existing($user);
        $userdm->set('pmtotal', 0);
        $userdm->set('pmunread', 0);
        $userdm->set('pmpopup', 'IF(pmpopup=2, 1, pmpopup)', false);
        $userdm->save();
        unset($userdm);
    }
    foreach ($out as $k => $v) {
        $out["{$k}"] = vb_number_format($v);
    }
    return $out;
}