Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-25-2005, 09:14 AM
Snetty Snetty is offline
 
Join Date: Feb 2005
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Display Welcome message on index.php (not boards)

I need to display the welcome block of text (Welcome, Snetty.
You last visited: Today at 10:58 AM
Private Messages: Unread 0, Total 0.) on a separate page to the forums. I've isolated the code in the template, and edited the hack that i got here to read as follows...

PHP Code:
<?php

// ########################################################################
// ####################### START CONFIGURATION ############################
// ########################################################################

// set allowed usergroups - separate with a comma
define('UGS','6,7,2,5');

// set the full path to your main forum directory
define('FWD','/home/httpd/vhosts/thecarshowcase.com/httpdocs/forums');

// set vB version you are using - use 307 or 350
define('VBN','350');

// set the name of this script - no .php extension
define('THIS_SCRIPT','example');

// ########################################################################
// ######################## END CONFIGURATION #############################
// ########################################################################

// ####################### SET PHP ENVIRONMENT ############################
// report all errors except notice level errors
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS ########################
// deglobalize variables in vB < 350 - vB 350 does deglobalize
if (VBN != '350')
{
    
define('NO_REGISTER_GLOBALS'1);
}

// ################### PRE-CACHE TEMPLATES AND DATA #######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array(
    
'header',
    
'headinclude',
    
'navbar',
    
'footer'
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END #############################
// define current directory
define('BWD', (($getcwd getcwd()) ? $getcwd '.'));

chdir(FWD);
require_once(
'./global.php');
chdir(BWD);

// ########################################################################
// ######################## START MAIN SCRIPT #############################
// ########################################################################

// ######################## SET SOME VARIABLES ############################
if (VBN == '350')
{
    
// to make compatible with vB 307 code - TMTOWTDI !
    
$vboptions['homeurl'] = $vbulletin->options['homeurl'];
    
$vboptions['bburl'] = $vbulletin->options['bburl'];
    
$vboptions['bbtitle'] = $vbulletin->options['bbtitle'];
    
$vboptions['forumhome'] = $vbulletin->options['forumhome'];
    
$vboptions['contactuslink'] = $vbulletin->options['contactuslink'];
    
$bbuserinfo['userid'] = $vbulletin->userinfo['userid'];
    
$bbuserinfo['usergroupid'] = $vbulletin->userinfo['usergroupid'];
    
$bbuserinfo['username'] = $vbulletin->userinfo['username'];
    
$bbuserinfo['email'] = $vbulletin->userinfo['email'];
    
$session['sessionurl'] = $vbulletin->session->vars['sessionurl'];
    
$session['sessionhash'] = $vbulletin->session->vars['sessionhash'];
    
// and so forth ...
}

$src_input = array(
    
'url(',
    
'var IMGDIR_MISC = "',
    
'href="',
    
'src="',
    
'action="'
);
$src_output '';
$src_link $vboptions['bburl'];

$user_groups explode(",",ereg_replace("[[:space:]]+","",UGS));
$usergroup_id $bbuserinfo['usergroupid'];

// #################### CHECK USERGROUP FOR ACCESS ########################
if (!in_array($usergroup_id,$user_groups))
// LOGIN PAGE
    
$show['permission_error'] = true;
    eval(
'$src_output = "' fetch_template('STANDARD_ERROR') . '";');
}
else
// CONTENT PAGE
    
eval('$navbar = "' fetch_template('navbar') . '";');
//    here you can set $src_output to a custom template like follows
//    eval('$src_output = "' . fetch_template('CUSTOM_TEMPLATE') . '";');
//    for this example script $src_output is set from make_page_content
//    make sure not to set $src_output to something like config.php - duh
    
$src_output make_page_content();
}
make_absolute_links($src_input,$src_output,$src_link); // prints page

// ########################################################################
// ######################### END MAIN SCRIPT ##############################
// ########################################################################

// ######################## START MAKEPAGECONTENT #########################
function make_page_content()
{
// this is an example page that could be set in a custom template instead
global $stylevar,$headinclude,$vboptions,$onload,$header,$navbar,$vbphrase,$bbuserinfo,$footer;
$src_output = <<<END
$stylevar[htmldoctype]
<html dir="
$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>
$vboptions[bbtitle]</title>
</head>
<body onload="
$onload">
<if condition="
$bbuserinfo['userid']">
    
        <td class="alt2" valign="top" nowrap="nowrap">
        <div class="smallfont">
            <strong><phrase 1="
$bbuserinfo[username]">$vbphrase[welcome_x]</phrase></strong><br />
            <phrase 1="
$pmbox[lastvisitdate]" 2="$pmbox[lastvisittime]">$vbphrase[last_visited_x_at_y]</phrase>
            <if condition="
$show['pmstats']"><br /><phrase 1="$vbphrase[unread_x_nav_compiled]" 2="$vbphrase[total_x_nav_compiled]" 3="$session[sessionurl_q]">$vbphrase[private_messages_nav]</phrase></if>
        </div>
        </td>
        
    <else />
        
        <td class="alt2" nowrap="nowrap" style="padding:0px">
            
        <!-- login form -->
        <form action="login.php" method="post" onsubmit="md5hash(vb_login_password,vb_login_md5password,vb_login_md5password_utf)">
        <script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
        <table cellpadding="0" cellspacing="
$stylevar[formspacer]" border="0">
        <tr>
            <td class="smallfont">
$vbphrase[username]</td>
            <td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="1" value="
$vbphrase[username]" onfocus="if (this.value == '$vbphrase[username]') this.value = '';" /></td>
            <td class="smallfont" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="3" id="cb_cookieuser_navbar" accesskey="c" checked="checked" />
$vbphrase[remember_me]</label></td>
        </tr>
        <tr>
            <td class="smallfont">
$vbphrase[password]</td>
            <td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" size="10" accesskey="p" tabindex="2" /></td>
            <td><input type="submit" class="button" value="
$vbphrase[log_in]" tabindex="4" title="$vbphrase[enter_username_to_login_or_register]" accesskey="s" /></td>
        </tr>
        </table>
        <input type="hidden" name="s" value="
$session[sessionhash]" />
        <input type="hidden" name="do" value="login" />        
        <input type="hidden" name="vb_login_md5password" />
        <input type="hidden" name="vb_login_md5password_utf" />
        </form>
        <!-- / login form -->
            
        </td>
        
    </if>
</body>
</html>
END;
return 
$src_output;
}

// ####################### START MAKEABSOLUTELINKS ########################
function make_absolute_links($src_input,$src_output,$src_link)
{
    
$src_output_arr explode("\n",$src_output);
    foreach (
$src_output_arr as $sopa_key => $sopa_value)
    {
        for (
$i=0$i<count($src_input); $i++)
        {
            if (
eregi("(.*)(".preg_quote($src_input[$i]).")(.*)",$sopa_value,$sopa_regs))
            {
                if (!
eregi("^(javascript:|mailto:|ftp:|news:|http[s]?:)",$sopa_regs[3]))
                {
                    
$sopa_value $sopa_regs[1].$sopa_regs[2].$src_link."/".$sopa_regs[3];
                }
            }
        }
        echo 
$sopa_value."\n";
    }
    exit();
}

?>
but unsurprisingly it doesn't work. It gives me a parse error, but A) I can't see any, and B) I copy and paste so it's impossible.

Can anyone see where i'm going wrong?
Reply With Quote
  #2  
Old 07-25-2005, 09:39 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$src_input = array( 
    
'url('
There is your first parse error.
Reply With Quote
  #3  
Old 07-25-2005, 10:01 AM
Snetty Snetty is offline
 
Join Date: Feb 2005
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sorry, found a better script (although not working is more suited to what i need..)

cheers for the input anyhoo
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 12:40 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.05353 seconds
  • Memory Usage 2,240KB
  • 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
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete