Accessing Session on My Site

i_n_k

Member
I had this code I was using on my site to include the login session site-wide, but after upgrading to 1.4.5 I'm having an issue with it breaking the page template.

Here's the code:

Code:
<?php

//ini_set('display_errors', 1);
// error_reporting(E_ALL);

$startTime = microtime(true);
$fileDir = '/messageboard/';

require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');

XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);

XenForo_Session::startPublicSession();

$visitor = XenForo_Visitor::getInstance()->toArray();

$userId = $visitor['user_id'];
$username = $visitor['username'];
$usergroup = $visitor['user_group_id'];
$email = $visitor['email'];
$secondary_group_ids = $visitor['secondary_group_ids'];

$user = XenForo_Model::create('XenForo_Model_User')->getUserById($userId);

if(!empty($username)) {
   
     echo '<table width=100% align=right cellpadding=10 cellspacing=0 border=0><tr><td align=right><span class="blacktextb"><span class="darkblue">' . $username . ', Welcome Back</span></td><td width=25><img src="/messageboard/' . XenForo_Template_Helper_Core::helperAvatarUrl($user, 's') . '" width=25></td></tr></table>'; }


else { echo "<table width=100% cellpadding=10 cellspacing=0 border=0><tr><td align=right><span class=\"darkblue\">HAVE AN ACCOUNT? - <a class=\"dkblueb\" href=\"/messageboard/login/\">LOGIN</a> or <a class=\"dkblueb\" href=\"/messageboard/register/\">REGISTER</a></span></td></tr></table>";
}

restore_error_handler();
restore_exception_handler();
error_reporting(0);
?>

I have that in a separate file for inclusion. But when I include it into the page, it wipes out code before it and around it for some reason. I'm curious if anyone can see what it is I'm doing wrong that would cause that to happen?
 
What do you mean by "wiping out all the code"?
If you are talking about the HTML output generated before including this file, it might be because when XenForo_Application initializes, the output buffer is cleared...
 
Top Bottom