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?