Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-07-2011, 07:40 PM
Megareus Rex's Avatar
Megareus Rex Megareus Rex is offline
 
Join Date: Feb 2004
Location: Pennsylvania, USA
Posts: 243
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Modifying a welcome panel's code? Too many queries!

For years I've been using this welcome panel hack: https://vborg.vbsupport.ru/showthread.php?t=105958

It was coded by a friend of mine (not for my site, however), and we've been using it since we opened, however I recently audited where my site's queries and realized that his adds a massive SEVEN (7) queries to forumhome.

Unfortunately, I'm not very adept with coding, and the author of the hack hasn't touched coding since he released the version in that link.

If anyone is willing to help, would it be possible to reduce the query amount? I would think several of those variables it calls for are already called for the normal "forum stats" panel that it just has you delete the html for. I would dearly love to continue using the welcome panel (and I'm sure he enjoys seeing it in sue himself), so abandoning it or switching to a different one isn't something I care to do if at all possible.

Should anyone be willing, the author would probably be fine with them re-releasing an optimized version of the hack. He'd give explicit permission first, of course.

Thanks in advance for any help offered!
Reply With Quote
  #2  
Old 09-09-2011, 04:26 AM
Megareus Rex's Avatar
Megareus Rex Megareus Rex is offline
 
Join Date: Feb 2004
Location: Pennsylvania, USA
Posts: 243
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh right, this may be easier if I posted the code for it. Here it is:

PHP Code:
// ################ Welcome Panel V1.1 - Made by SmasherMaster ################
// Checks if it is on the index, otherwise it'll error out
if (THIS_SCRIPT == "index")
{
// Require User Functions
require_once('./includes/functions_user.php');
// Cell 1 - Avatar
$vbulletin->userinfo['avatar']=fetch_avatar_url($vbulletin->userinfo['userid']);
if(
$vbulletin->userinfo['avatar']=="") {
$vbulletin->userinfo['avatar']="<a href='profile.php?{$session['sessionurl']}&do=editavatar'><img src='images/avatars/noavatar.gif' alt='Edit Your Avatar' border='0'></a>";
} else {
$vbulletin->userinfo['avatar']="<a href='profile.php?{$session['sessionurl']}&do=editavatar'><img src='{$vbulletin->userinfo['avatar'][0]}' alt='Edit Your Avatar' border='0'></a>";
}
// Cell 2 - Quick Forum Stats
$vbulletin->userinfo['newposts'] = $db->query_first("select count(*) as newposts from ".TABLE_PREFIX."post where dateline >= {$vbulletin->userinfo['lastvisit']} and visible = 1");
$vbulletin->userinfo['newposts'] = vb_number_format($vbulletin->userinfo['newposts']['newposts']);
$vbulletin->userinfo['newthreads'] = $db->query_first("select count(*) as newthreads from ".TABLE_PREFIX."thread where dateline and lastpost >= {$vbulletin->userinfo['lastvisit']} and visible = 1 and sticky in(0,1)");
$vbulletin->userinfo['newthreads'] = vb_number_format($vbulletin->userinfo['newthreads']['newthreads']);
$vbulletin->userinfo['members']=$db->query_first("select count(*) as all_users from ".TABLE_PREFIX."user");
$vbulletin->userinfo['posts']=$db->query_first("select count(*) as all_posts from ".TABLE_PREFIX."post");
$vbulletin->userinfo['topics']=$db->query_first("select count(*) as all_topics from ".TABLE_PREFIX."thread");
$vbulletin->userinfo['yourposts'] = $db->query_first("select posts as your_posts from ".TABLE_PREFIX."user where userid = {$vbulletin->userinfo['userid']}");
$vbulletin->userinfo['yourposts'] = vb_number_format($vbulletin->userinfo['yourposts']['your_posts']);
$vbulletin->userinfo['postpercent'] = vb_number_format(((str_replace(','''$vbulletin->userinfo['yourposts']['your_posts']) / $vbulletin->userinfo['posts']['all_posts'] ) * 100),2);
$welcome_members="{$vbulletin->userinfo['members']['all_users']}";
$welcome_topics="{$vbulletin->userinfo['topics']['all_topics']}";
$welcome_posts="{$vbulletin->userinfo['posts']['all_posts']}";
$welcome_pms="<if condition='$show[pmstats]'><br /><phrase 1='$vbphrase[unread_x_nav_compiled]' 2='$vbphrase[total_x_nav_compiled]' 3='$session[sessionurl]'>$vbphrase[private_messages_nav]</phrase></if>";
$welcome_newposts="<a href='search.php?{$session['sessionurl']}&do=getnew'>New Posts</a>: {$vbulletin->userinfo['newposts']}<br>New Threads: {$vbulletin->userinfo['newthreads']}";
$welcome_time="<phrase 1='$vbphrase[last_visited_x_at_y]'>";
$welcome_avatar="{$vbulletin->userinfo['avatar']}";

Reply With Quote
  #3  
Old 09-09-2011, 03:07 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

7 queries on only the index page is no big deal. VB4 has some pages with 60+ queries. This really shouldn't be an issue.
Reply With Quote
  #4  
Old 09-10-2011, 01:49 AM
Megareus Rex's Avatar
Megareus Rex Megareus Rex is offline
 
Join Date: Feb 2004
Location: Pennsylvania, USA
Posts: 243
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
7 queries on only the index page is no big deal. VB4 has some pages with 60+ queries. This really shouldn't be an issue.
Well, maybe not, but if anyone's able to help optimize it more than it is, I'd certainly appreciate it.
Reply With Quote
  #5  
Old 09-10-2011, 12:28 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What version of vBulletin are you running? After looking at it there seems to be a lot of queries for data that should already be available without the need for a query, at least in 3.7/3.8- I'm not sure about earlier versions.
Reply With Quote
  #6  
Old 09-10-2011, 03:43 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

After experimenting if the hook for that plugin is moved from forumhome_start to forumhome_complete almost all the queries can be eliminated... however the original author (maybe because it was made for VB 3.5) overwrites valid fields of userinfo with his data so it's not just a simple edit of the plugin- but edits of the template that will be needed as well. Virtually rewriting all the PHP portion of the mod.

I will contact the original author and see if he will give permission for a release, like you suspect.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:54 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05039 seconds
  • Memory Usage 2,251KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete