Go Back   vb.org Archive > Community Central > Community Lounge
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 10-28-2004, 08:13 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

there may be people who like hacking more than editing templates

also if he made some scriptspecific things in phpinclude it doesn't look that well
Reply With Quote
  #12  
Old 10-29-2004, 12:36 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Heh heh,

Well, another reason it's so long is I LOVE whitespace and making the code both nice to look at as well as functioning. Many of the lines are simply { because I leave those to themselves.

I also have a LOT of commentary text so that if anyone comes in after me they can see what it does.

As an example, here's the first section...

PHP Code:
/*==============================================*\
|| ############################################ ||
|| # Startup Proceedures for Vbulletin Boards # ||
|| #         at Wizards of the Coast          # ||
|| # ---------------------------------------- # ||
|| #   Created for Wizards of the Coast by    # ||
|| #           Michael Lloyd Morris           # ||
|| #           email mlmorr0@uky.edu          # ||
|| # ---------------------------------------- # ||
|| #    This is a PHPINCLUDE_START template   # ||
|| ############################################ ||
\*==============================================*/

// ###############################################
// ##### HANDLE $_REQUESTs #######################
// ###############################################

// Launch Did You Know Pop Up
if (($_REQUEST['do'] == 'didyouknow') AND (THIS_SCRIPT == 'index'))
    {
        
$tip rand(1,15);
        
$tip 'didyouknow_' $tip;
        eval(
'$tipoftheday = "' fetch_template($tip) . '";');    
        eval(
'print_output("' fetch_template('DIDYOUKNOW') . '");');        
    }

// Move thread to Admin Forum preset
if (($_REQUEST['do'] == 'moveadmin') AND (THIS_SCRIPT == 'postings'))
    {
        
$_REQUEST['do'] = 'domovethread';
        
$_POST['do'] = 'domovethread';
        
$_POST['forumid'] = '399';
        
$_POST['method'] = 'move';
    } 
I've found that since PHP_INCLUDE start runs before any other templates or the remainder of the various vbulletin scripts it's the perfect time to intercept special $_REQUEST and $_POST variables and reassign them. The pop-up launcher is the cleanest example of this since it terminates the execution of the rest of the index script immediately when it makes the Print Output call. You can actually create whole new pages that way if you really want to. From a processing standpoint the pop-up makes sense in the PHPINCLUDE_START template since it doesn't need the $header, $footer or any other templates - just the custom DIDYOUKNOW templates.

The second item more cleanly allows the move thread presets. It's actually the 2nd version of a hack I've released and if you make a lot of thread moves it comes highly recommended.

The rest of the script does these things (just copying the commentary text...)

PHP Code:
// ###############################################
// ##### DEFINE FUNCTIONS USED IN TEMPLATE #######
// ###############################################

// ###############################################
// ##### MAIN PAGES INITIALIZATION  ##############
// ###############################################

// #### Prepare $banner array #########################

// #### Merge custom display information into $show ##########

// #### Set Defaults ################################

// ##### PARSE GLOBAL MENU TEMPLATE  #################

// ###############################################
// ##### START ANNOUNCMENTS  #####################
// ###############################################

// ###############################################
// ##### START USER SETTINGS  ####################
// ###############################################

    // #### Set Postbit ##########################
            
    // #### Set Left Column ######################

    // #### Set New Posts in Bold ################

    // #### Set Subscribed in Italics ############

    // #### Set Thread Previews ######################

    // #### Set Display Member Info at top ###########
            
    // #### Set Variable Display Width ###############

    // #### Set Forum Icon Display ###################
            
    // #### Set Tip Launcher ###################

    // #### FORUMHOME User Info ######################
        
// ###############################################
// ##### MISC ACTIONS B4 PARSING HEADERS  ########
// ###############################################

// Turn Left Columns off if we're on an editor interface

// ###############################################
// ##### START HEADERS  ##########################
// ###############################################

// ##### Forumhome ###############################

        // Parse the Forumhome greeting

        //Set the left column to false - this page has a left colum, but unlike 
        //other pages the forumhome template creates the column without the header template doing so.
        //This page is also unaffected by the status of $show['leftcolumn']

// ##### RPGA ####################################

        //Set the Banner

        //RPGA has multiple subforums with slightly different heights
        //and not all allow the navbar to slide under them.
        
        //Living Greyhawk

        //Living Force

        //RPGA Default

        //Set Items which apply to all three banners

// ##### Dungeons & Dragons #######################

        //Set the Banner

        //Set the Left Column if required

                //The D&D styleset has multiple left menus depending on the header
                //The code below changes the left menu depending on the header called.
                
                //Forgotten Realms

                //Eberron

                //D&D Miniatures

                //D&D Main

// ##### Magic: The Gathering #####################

                //This small program determines the date of the Monday that started this week.
                //We need it to determine the file name of the MtG header used in most MtG areas.
                //I think this is going to be good but it might screw up during a change of year.


                // The file name requires leading zeros, so let's add them as necessary.    
            
                // Done. Spit out the filename and evaluate the rest of the MtG header.

        // MtG: Online has a different header that doesn't change weekly.

        // Now let's attend to the prep shared by MtG and MtG Online
        //Parse the lower Magic Menu.

// ##### Duel Masters #############################

// ##### NeoPets ##################################

// ##### MLB Showdown ##############################

// ##### Star Wars TCG ##############################

// ##### Star Wars RPG ##############################

// ##### Star Wars Minis ##############################

// ##### d20 Modern #################################

// ##### d20 System #################################

// ##### GI Joe ##############################

// ##### Other banners ################################# 
And that's just the major commentary text. As I've said before, these boards are much like having 12 different boards tied at the hip - but somehow it works. I've very proud of my PHPINCLUDE_START template even if it's the one part of the boards the users never see.
Reply With Quote
  #13  
Old 10-29-2004, 01:49 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looks intriguing. There are some load liabilities using phpinclude when you could be using global.php but if you're wanting to maintain Jelsoft official vB.com support, you do what you can.
Reply With Quote
  #14  
Old 10-29-2004, 01:51 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by filburt1
57 in php_include_start, 80 in php_include_end. However, both of those have require() statements in which the required files are hundreds of lines long. I also haven't modified a single line of vB code.
Really? How do you integrate your points system without file modification?
Reply With Quote
  #15  
Old 10-29-2004, 02:00 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The Jelsoft support concern is definitely a valid one, but we have modified the code to allow forum banners. The changes are minor and can be undone in an hour or so if need be, but they are there.

I suppose I could require it in global.php, but I'm constantly upgrading the thing and as I said I don't have FTP access to the server, which I sorta would need to put it in an include file.
Reply With Quote
  #16  
Old 10-29-2004, 02:46 PM
Logikos Logikos is offline
 
Join Date: Jan 2003
Posts: 2,924
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I never touch my include template. Everything is file modded for me. ^^
Reply With Quote
  #17  
Old 10-29-2004, 04:01 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i think the combination is best

phpinclude can be a strong way to make some changes, but there are things which shouldn't be in that template
Reply With Quote
  #18  
Old 10-29-2004, 06:25 PM
AlexanderT's Avatar
AlexanderT AlexanderT is offline
 
Join Date: Mar 2003
Posts: 294
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

perhaps we should make a list of when phpinclude is especially useful and when definitely not Thinking in more practical terms; it is obvious that mysql queries should be left out from phpinclude, but is it obvious to everyone why phpinclude could be still useful?
Reply With Quote
  #19  
Old 10-29-2004, 06:30 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Phpinclude should not be used for calling templates imho, seeing how you have to hack the files to get the new template in the cache list anyway. Query's are fine in phpinclude, it just boils down to what the query dose as with hacking.

We really need to do some testing with phpinclude to see how much of an impact it has on resources over placing code directly into the files.
Reply With Quote
  #20  
Old 10-29-2004, 06:40 PM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok I re-applied some stock vB code for de-buging to the phpinclude_start template, try this little hacket out and see how much time/memory your phpinclude_start template is eating up.

In /forumroot/global.php find:

PHP Code:
// #############################################################################
// parse PHP include
if (!is_demo_mode())
{
    @
ob_start();
    eval(
fetch_template('phpinclude_start', -10));
    
$phpinclude_output = @ob_get_contents();
    @
ob_end_clean();

Replace with:

PHP Code:
// #############################################################################
// parse PHP include
if (!is_demo_mode())
{
    if (
DB_QUERIES)
    {
        
// Time for phpinclude_start template
        
echo('Parsing phpinclude_start\n');
        
$pageendtime microtime();
        
$starttime explode(' '$pagestarttime);
        
$endtime explode(' '$pageendtime);
        
$beforetime $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1];
        echo(
'Time before: $beforetime\n');
        if (
function_exists('memory_get_usage'))
        {
            echo(
'Memory Before Phpinclude_start: ' number_format((memory_get_usage() / 1024)) . 'KB' ' \n');
        }
    }

        @
ob_start();
        eval(
fetch_template('phpinclude_start', -10));
        
$phpinclude_output = @ob_get_contents();
        @
ob_end_clean();

    if (
DB_QUERIES)
    {
        
// end phpinclude_start parse timer
        
$pageendtime microtime();
        
$starttime explode(' '$pagestarttime);
        
$endtime explode(' '$pageendtime);
        
$aftertime $endtime[0] - $starttime[0] + $endtime[1] - $starttime[1];
        echo(
'Time after:  $aftertime\n');
        echo(
'Time taken: ' . ($aftertime $beforetime) . '\n');
        if (
function_exists('memory_get_usage'))
        {
            echo(
'Memory After Phpinclude_start: ' number_format((memory_get_usage() / 1024)) . 'KB' ' \n');
        }
        echo(
'\n<hr />\n\n');
    }

Go into debug mode and get the stats per normal method.
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 07:36 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04709 seconds
  • Memory Usage 2,305KB
  • Queries Executed 11 (?)
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
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete