$pmbox['lastvisitdate'] = vbdate($vbulletin->options['dateformat'], $vbulletin->userinfo['lastvisit'], 1); $pmbox['lastvisittime'] = vbdate($vbulletin->options['timeformat'], $vbulletin->userinfo['lastvisit']); $pmunread_html = construct_phrase($vbulletin->userinfo['pmunread'] ? $vbphrase['numeric_value_emphasized'] : $vbphrase['numeric_value'], $vbulletin->userinfo['pmunread']); $vbphrase['unread_x_nav_compiled'] = construct_phrase($vbphrase['unread_x_nav'], $pmunread_html); $vbphrase['total_x_nav_compiled'] = construct_phrase($vbphrase['total_x_nav'], $vbulletin->userinfo['pmtotal']); // ############################################################################# // Generate Language Chooser Dropdown $languagecount = 0; $languagechooserbits = construct_language_options('--', true); $show['languagechooser'] = ($languagecount > 1 and empty($_POST['do'])) ? true : false; unset($languagecount); // ############################################################################# // Generate Style Chooser Dropdown if ($vbulletin->options['allowchangestyles'] and empty($_POST['do'])) { $stylecount = 0; $quickchooserbits = construct_style_options(-1, '--', true, true); $show['quickchooser'] = $stylecount > 1 ? true : false; unset($stylecount); } else { $show['quickchooser'] = false; } // ############################################################################# // do cron stuff - goes into footer if ($vbulletin->cron <= TIMENOW) { $cronimage = '<img src="' . create_full_url('cron.php?' . $vbulletin->session->vars['sessionurl'] . 'rand=' . TIMENOW) . '" alt="" width="1" height="1" border="0" />'; } else { $cronimage = ''; } $show['rtl'] = $stylevar['textdirection'] == 'rtl'; $show['admincplink'] = iif($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'], true, false); // This generates an extra query for non-admins/supermods on many pages so we have chosen to only display it to supermods & admins
if ($optionvalue == $vbulletin->userinfo['maxposts']) { $optionselected = 'selected="selected"'; $foundmatch = 1; } else { $optionselected = ''; } $optiontitle = construct_phrase($vbphrase['show_x_posts_per_page'], $optionvalue); eval('$maxpostsoptions .= "' . fetch_template('option') . '";'); } if ($foundmatch == 0) { $postsdefaultselected = 'selected="selected"'; } if ($vbulletin->options['allowchangestyles']) { $stylecount = 0; if ($vbulletin->stylecache !== null) { $stylesetlist = construct_style_options(); } $show['styleoption'] = iif($stylecount > 1, true, false); } else { $show['styleoption'] = false; } // get language options $languagelist = ''; $languages = fetch_language_titles_array('', 0); if (sizeof($languages) > 1) { foreach ($languages as $optionvalue => $optiontitle) { $optionselected = iif($vbulletin->userinfo['saved_languageid'] == $optionvalue, 'selected="selected"', ''); eval('$languagelist .= "' . fetch_template('option') . '";'); } $show['languageoption'] = true; } else {
/** * Constructs a style chooser HTML menu * * @param integer Style ID * @param string String repeated before style name to indicate nesting * @param boolean Whether or not to initialize this function (this function is recursive) * @param boolean Whether or not this will build the quick chooser menu * @param integer Reference to the total number of styles available in the chooser * * @return string */ function construct_style_options($styleid = -1, $depthmark = '', $init = true, $quickchooser = false, &$stylecount = 0) { global $vbulletin, $vbphrase; $thisstyleid = ($quickchooser ? $vbulletin->userinfo['styleid'] : $vbulletin->userinfo['realstyleid']); if ($thisstyleid == 0) { $thisstyleid = ($quickchooser ? $vbulletin->userinfo['realstyleid'] : $vbulletin->userinfo['styleid']); } if ($thisstyleid == 0) { $thisstyleid = $vbulletin->options['styleid']; } // initialize various vars if ($init) { $stylesetlist = ''; // set the user's 'real style id' if (!isset($vbulletin->userinfo['realstyleid'])) { $vbulletin->userinfo['realstyleid'] = $vbulletin->userinfo['styleid']; } if (!$quickchooser) { if ($thisstyleid == 0) { $optionselected = 'selected="selected"'; } $optionvalue = 0; $optiontitle = $vbphrase['use_forum_default']; $stylesetlist .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass); } } // check to see that the current styleid exists // and workaround a very very odd bug (#2079) if (isset($vbulletin->stylecache["$styleid"]) AND is_array($vbulletin->stylecache["$styleid"])) { $cache =& $vbulletin->stylecache["$styleid"]; } else if (isset($vbulletin->stylecache[$styleid]) AND is_array($vbulletin->stylecache[$styleid])) { $cache =& $vbulletin->stylecache[$styleid]; } else { return; } // loop through the stylecache to get results foreach ($cache AS $x) { foreach ($x AS $style) { if ($style['userselect'] OR $vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) { $stylecount++; if ($thisstyleid == $style['styleid']) { $optionselected = 'selected="selected"'; } else { $optionselected = ''; } $optionvalue = $style['styleid']; $optiontitle = $depthmark . ' ' . $style['title']; $optionclass = ''; $stylesetlist .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass); $stylesetlist .= construct_style_options($style['styleid'], $depthmark . '--', false, $quickchooser, $stylecount); } else { $stylesetlist .= construct_style_options($style['styleid'], $depthmark, false, $quickchooser, $stylecount); } } } return $stylesetlist; }
$optiontitle = construct_phrase($vbphrase['show_x_posts_per_page'], $optionvalue); $maxpostsoptions .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass); } } if ($foundmatch == 0) { $postsdefaultselected = 'selected="selected"'; } $show['maxpostsoptions'] = ($vbulletin->options['usermaxposts'] ? true : false); if ($vbulletin->options['allowchangestyles']) { $stylecount = 0; if ($vbulletin->stylecache !== null) { $stylesetlist = construct_style_options(-1, '', true, false, $stylecount); } $show['styleoption'] = iif($stylecount > 1, true, false); } else { $show['styleoption'] = false; } // get language options $languagelist = ''; $languages = fetch_language_titles_array('', 0); if (sizeof($languages) > 1) { foreach ($languages AS $optionvalue => $optiontitle) {
/** * Constructs a style chooser HTML menu * * @param integer Style ID * @param string String repeated before style name to indicate nesting * @param boolean Whether or not to initialize this function (this function is recursive) * @param boolean Whether or not this will build the quick chooser menu * @param integer Reference to the total number of styles available in the chooser * * @return string */ function construct_style_options($styleid = -1, $depthmark = '', $init = true, $quickchooser = false, &$stylecount = 0) { global $vbulletin, $vbphrase, $show; $thisstyleid = $quickchooser ? $vbulletin->userinfo['styleid'] : $vbulletin->userinfo['realstyleid']; if ($thisstyleid == 0) { $thisstyleid = $quickchooser ? $vbulletin->userinfo['realstyleid'] : $vbulletin->userinfo['styleid']; } if ($thisstyleid == 0) { $thisstyleid = $vbulletin->options['styleid']; } // initialize various vars if ($init) { $stylesetlist = ''; // set the user's 'real style id' if (!isset($vbulletin->userinfo['realstyleid'])) { $vbulletin->userinfo['realstyleid'] = $vbulletin->userinfo['styleid']; } if (!$quickchooser) { if ($thisstyleid == 0) { $optionselected = 'selected="selected"'; $show['style_option_default_selected'] = true; } $show['style_option_default'] = true; } } // check to see that the current styleid exists // and workaround a very very odd bug (#2079) if (isset($vbulletin->stylecache["{$styleid}"]) and is_array($vbulletin->stylecache["{$styleid}"])) { $cache =& $vbulletin->stylecache["{$styleid}"]; } else { if (isset($vbulletin->stylecache[$styleid]) and is_array($vbulletin->stylecache[$styleid])) { $cache =& $vbulletin->stylecache[$styleid]; } else { return; } } // loop through the stylecache to get results foreach ($cache as $x) { foreach ($x as $style) { if (!$vbulletin->options['allowchangestyles']) { // Only allow the default style and any mobile styles. if (!$style['userselect'] or $style['styleid'] != $vbulletin->options['styleid'] and !isset($vbulletin->stylecache['mobile'][$style['styleid']])) { continue; } } if ($style['userselect'] or $vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) { $stylecount++; if ($thisstyleid == $style['styleid']) { $optionselected = 'selected="selected"'; } else { $optionselected = ''; } $optionvalue = $style['styleid']; $optiontitle = $depthmark . ' ' . htmlspecialchars_uni($style['title']); $optionclass = ''; $stylesetlist .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass); $stylesetlist .= construct_style_options($style['styleid'], $depthmark . '--', false, $quickchooser, $stylecount); } else { $stylesetlist .= construct_style_options($style['styleid'], $depthmark, false, $quickchooser, $stylecount); } } } return $stylesetlist; }
/** * Processes the global templates (header, footer, etc) and the variables they need. */ public function process_templates() { if ($this->called('template')) { return; } $this->called['template'] = true; $this->load_style(); global $vbulletin, $show, $vbphrase, $style, $template_hook; $this->cache_templates($style['templatelist']); // ############################################################################# // turn off popups if they are not available to this browser if ($vbulletin->options['usepopups']) { if ((is_browser('ie', 5) AND !is_browser('mac')) OR is_browser('mozilla') OR is_browser('firebird') OR is_browser('opera', 7) OR is_browser('webkit') OR is_browser('konqueror', 3.2)) { // use popups } else { // don't use popups $vbulletin->options['usepopups'] = 0; } } global $vbcollapse; $vbcollapse = self::build_vbcollapse($vbulletin->GPC['vbulletin_collapse']); // ############################################################################# // set up the vars for the private message area of the navbar global $pmbox; $pmbox = array( 'lastvisitdate' => vbdate($vbulletin->options['dateformat'], $vbulletin->userinfo['lastvisit'], 1), 'lastvisittime' => vbdate($vbulletin->options['timeformat'], $vbulletin->userinfo['lastvisit']) ); if ($vbulletin->userinfo['userid']) { $pmunread_html = construct_phrase(($vbulletin->userinfo['pmunread'] ? $vbphrase['numeric_value_emphasized'] : $vbphrase['numeric_value']), $vbulletin->userinfo['pmunread']); $vbphrase['unread_x_nav_compiled'] = construct_phrase($vbphrase['unread_x_nav'], $pmunread_html); $vbphrase['total_x_nav_compiled'] = construct_phrase($vbphrase['total_x_nav'], $vbulletin->userinfo['pmtotal']); } // ############################################################################# // Generate Language/Style Chooser Dropdowns if (empty($_POST['do'])) { $languagecount = 0; $languagechooserbits = construct_language_options('--', true, $languagecount); $show['languagechooser'] = ($languagecount > 1 ? true : false); } else { $show['languagechooser'] = false; } if ($vbulletin->options['allowchangestyles'] AND empty($_POST['do'])) { $stylecount = 0; $quickchooserbits = construct_style_options(-1, '--', true, true, $stylecount); $show['quickchooser'] = ($stylecount > 1 ? true : false); } else { $show['quickchooser'] = false; } // ############################################################################# // do cron stuff - goes into footer if ($vbulletin->cron <= TIMENOW) { $cronimage = '<img src="' . create_full_url('cron.php?' . $vbulletin->session->vars['sessionurl'] . 'rand=' . TIMENOW) . '" alt="" width="1" height="1" border="0" />'; } else { $cronimage = ''; } global $ad_location; // parse some global templates global $gobutton, $spacer_open, $spacer_close; $gobutton = vB_Template::create('gobutton')->render(); $spacer_open = vB_Template::create('spacer_open')->render(); $spacer_close = vB_Template::create('spacer_close')->render(); // facebook templates if (is_facebookenabled()) { $templater = vB_Template::create('facebook_opengraph'); $templater->register('opengrapharray', get_fbopengrapharray()); $facebook_opengraph = $templater->render(); $templater = vB_Template::create('facebook_header'); $templater->register('profileurl', get_fbprofileurl()); $templater->register('squarepicurl', get_fbprofilepicurl()); $facebook_header = $templater->render(); $templater = vB_Template::create('facebook_footer'); $templater->register('connected', (is_userfbconnected() ? 1 : 0)); $templater->register('active', (is_userfbactive() ? 1 : 0)); $facebook_footer = $templater->render(); } ($hook = vBulletinHook::fetch_hook('parse_templates')) ? eval($hook) : false; // parse headinclude, header & footer $admincpdir = $vbulletin->config['Misc']['admincpdir']; $modcpdir = $vbulletin->config['Misc']['modcpdir']; // advertising location setup $template = vB_Template::create('ad_navbar_below'); $template->register('adsense_pub_id', $vbulletin->adsense_pub_id); $template->register('adsense_host_id', $vbulletin->adsense_host_id); $ad_location['ad_navbar_below'] = $template->render(); $ad_location['global_header1'] = vB_Template::create('ad_global_header1')->render(); $ad_location['global_header2'] = vB_Template::create('ad_global_header2')->render(); $ad_location['global_below_navbar'] = vB_Template::create('ad_global_below_navbar')->render(); $ad_location['global_above_footer'] = vB_Template::create('ad_global_above_footer')->render(); $template = vB_Template::create('ad_footer_start'); $template->register('adsense_pub_id', $vbulletin->adsense_pub_id); $template->register('adsense_host_id', $vbulletin->adsense_host_id); $ad_location['ad_footer_start'] = $template->render(); // ############################################################################# // handle notices global $notices; $notices = $this->build_notices(); $show['notices'] = ($notices !== ''); // ############################################################################# // set up user notifications $notifications = $this->build_notifications(); if ($notifications) { $show['notifications'] = true; global $notifications_menubits, $notifications_total; $notifications_menubits = $notifications['bits']; $notifications_total = $notifications['total']; } else { $notifications_menubits = ''; $notifications_total = ''; $show['notifications'] = false; } $newpm = $this->check_new_pm(); // ############################################################################# // page number is used in meta tags (sometimes) global $pagenumber, $headinclude, $headinclude_bottom, $header, $footer; global $threadinfo, $foruminfo; if ($pagenumber === NULL) { $pagenumber = $vbulletin->input->clean_gpc('r', 'pagenumber', TYPE_UINT); } $templater = vB_Template::create('headinclude'); $templater->register('foruminfo', $foruminfo); $templater->register('pagenumber', $pagenumber); $templater->register('style', $style); $templater->register('basepath', $vbulletin->input->fetch_basepath()); $templater->register('this_script', THIS_SCRIPT); $templater->register('facebook_opengraph', $facebook_opengraph); $headinclude = $templater->render(); $templater = vB_Template::create('headinclude_bottom'); $templater->register('foruminfo', $foruminfo); $templater->register('pagenumber', $pagenumber); $templater->register('style', $style); $templater->register('basepath', $vbulletin->input->fetch_basepath()); $headinclude_bottom = $templater->render(); $templater = vB_Template::create('header'); $templater->register('ad_location', $ad_location); $templater->register('pmbox', $pmbox); $templater->register('notifications_menubits', $notifications_menubits); $templater->register('notifications_total', $notifications_total); $templater->register('notices', $notices); $templater->register('facebook_header', $facebook_header); $header = $templater->render(); $templater = vB_Template::create('footer'); $templater->register('admincpdir', $admincpdir); $templater->register('ad_location', $ad_location); $templater->register('cronimage', $cronimage); $templater->register('languagechooserbits', $languagechooserbits); $templater->register('modcpdir', $modcpdir); $templater->register('quickchooserbits', $quickchooserbits); $templater->register('template_hook', $template_hook); $templater->register('facebook_footer', $facebook_footer); $footer = $templater->render(); // ############################################################################# // Check for pm popup if ($newpm) { if ($vbulletin->userinfo['pmunread'] == 1) { $pmpopupurl = 'private.php?' . $vbulletin->session->vars['sessionurl_js'] . "do=showpm&pmid=$newpm[pmid]"; } else if (!empty($vbulletin->session->vars['sessionurl_js'])) { $pmpopupurl = 'private.php?' . $vbulletin->session->vars['sessionurl_js']; } else { $pmpopupurl = 'private.php'; } $templater = vB_Template::create('pm_popup_script'); $templater->register('newpm', $newpm); $templater->register('pmpopupurl', $pmpopupurl); $footer .= $templater->render(); } if (!$vbulletin->options['bbactive'] AND ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])) { // show the board disabled warning message so that admins don't leave the board turned off by accident $warning = vB_Template::create('board_inactive_warning')->render(); $header = $warning . $header; $footer .= $warning; } ($hook = vBulletinHook::fetch_hook('process_templates_complete')) ? eval($hook) : false; exec_headers(); }
} else { $optionselected = ''; } $optiontitle = construct_phrase($vbphrase['show_x_posts_per_page'], $optionvalue); $maxpostsoptions .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass); } } if ($foundmatch == 0) { $postsdefaultselected = 'selected="selected"'; } $show['maxpostsoptions'] = $vbulletin->options['usermaxposts'] ? true : false; if ($vbulletin->options['allowchangestyles'] or $vbulletin->options['mobilestyleid_advanced'] or $vbulletin->options['mobilestyleid_basic']) { $stylecount = 0; if ($vbulletin->stylecache !== null) { $stylesetlist1 = construct_style_options(-1, '', true, false, $stylecount); $stylesetlist2 = construct_style_options(-2, '', $stylesetlist1 ? false : true, false, $stylecount); } $show['styleoption'] = $stylecount > 1 ? true : false; } else { $show['styleoption'] = false; } // get language options $languagelist = ''; $languages = fetch_language_titles_array('', 0); if (sizeof($languages) > 1) { foreach ($languages as $optionvalue => $optiontitle) { $optionselected = iif($vbulletin->userinfo['saved_languageid'] == $optionvalue, 'selected="selected"', ''); $languagelist .= render_option_template($optiontitle, $optionvalue, $optionselected, $optionclass); } $show['languageoption'] = true; } else {