Not Solved Portal Help
#1
Not Solved
Hello...
I'm trying to integrate MyBB with my new CMS and I've been having some problems. First off, I'm trying to display a few things on my main page... the login box, who's online, and some forum statistics. I've got them all displayed on my page and everything seems to work fine with one exception. When I login it redirects me successfully but it doesn't show me as being logged in. Instead it just shows me the login boxes. It shows me as being online (browsing the forums) in the stats area... but does not show the welcome message or PM information. Any ideas?

Here is the code I'm including in my left navigation... Note that I changed the path for security reasons. Also note that my forums is located in my root directory and my main site is in a sub directory. Any help would be appreciated.

I've stored the below code in a php file named login.php
If I view this file directly it seems to work fine.. showing me logged in and displaying my account information. But once I include it within my header file using PHP includes it gives me problems. Sad


Code:
<?php
/**
* MyBB 1.0
* Copyright � 2005 MyBulletinBoard Group, All Rights Reserved
*
* Website: http://www.mybboard.com
* License: http://www.mybboard.com/eula.html
*
* $Id: portal.php 604 2005-08-22 09:46:23Z chris $
*/

define("KILL_GLOBALS", 1);

// set the path to your forums directory here (without trailing slash)
$forumdir = "/my/path/public_html/";

// end editing

if(!chdir($forumdir) && $forumdir)
{
    die("\$forumdir is invalid!");
}

$templatelist = "portal_welcome,portal_welcome_membertext,portal_stats,portal_search,portal_whosonline_memberbit,portal_whosonline,portal_latestthreads_thread_lastpost,portal_latestthreads_thread,portal_latestthreads,portal_announcement_numcomments_no,portal_announcement,portal_announcement_numcomments,portal";

require "/my/path/global.php";
require "/my/path/inc/functions_post.php";
require "/my/path/inc/functions_user.php";

global $settings, $theme, $templates;

// Load global language phrases
$lang->load("portal");

addnav($lang->nav_portal, "portal.php");

// This allows users to login if the portal is stored offsite or in a different directory
if($mybb->input['action'] == "do_login")
{
    if(!username_exists($mybb->input['username']))
    {
        error($lang->error_invalidusername);
    }
    $user = validate_password_from_username($mybb->input['username'], $mybb->input['password']);
    if(!$user['uid'])
    {
        error($lang->error_invalidpassword);
    }

    $db->query("DELETE FROM ".TABLE_PREFIX."sessions WHERE ip='".$session->ipaddress."' AND sid<>'".$session->sid."'");
    $newsession = array(
        "uid" => $user['uid'],
        );
    $db->update_query(TABLE_PREFIX."sessions", $newsession, "sid='".$session->sid."'");
    
    mysetcookie("mybbuser", $user['uid']."_".$user['loginkey']);
    mysetcookie("sid", $session->sid, -1);

    if(function_exists("loggedIn"))
    {
        loggedIn($user['uid']);
    }

    $plugins->run_hooks("logged_in", $user['uid']);

    redirect("http://www.zerovision.net/project/index.php", $lang->redirect_loggedin);
}

$plugins->run_hooks("portal_start");


// get forums user cannot view
$unviewable = getunviewableforums();
if($unviewable)
{
    $unviewwhere = " AND fid NOT IN ($unviewable)";
}
// If user is known, welcome them
if($mybb->settings['portal_showwelcome'] != "no")
{
    if($mybb->user['uid'] != 0)
    {
        if($mybb->user['receivepms'] != "no" && $mybb->usergroup['canusepms'] != "no" && $mybb->settings['portal_showpms'] != "no")
        {
            $query = $db->query("SELECT COUNT(*) AS pms_total, SUM(IF(dateline>'".$mybb->user['lastvisit']."' AND folder='1','1','0')) AS pms_new, SUM(IF(status='0' AND folder='1','1','0')) AS pms_unread FROM ".TABLE_PREFIX."privatemessages WHERE uid='".$mybb->user['uid']."'");
            $messages = $db->fetch_array($query);
            if(!$messages['pms_new'])
            {
                $messages['pms_new'] = 0;
            }
            // the SUM() thing returns "" instead of 0
            if($messages['pms_unread'] == "")
            {
                $messages['pms_unread'] = 0;
            }
            $lang->pms_received_new = sprintf($lang->pms_received_new, $mybb->user['username'], $messages['pms_new']);
            eval("\$pms = \"".$templates->get("portal_pms")."\";");
        }
        // get number of new posts, threads, announcements
        $query = $db->query("SELECT COUNT(pid) AS newposts FROM ".TABLE_PREFIX."posts WHERE dateline>'".$mybb->user['lastvisit']."' $unviewwhere");
        $newposts = $db->result($query, 0);
        if($newposts)
        { // if there aren't any new posts, there is no point in wasting two more queries
            $query = $db->query("SELECT COUNT(tid) AS newthreads FROM ".TABLE_PREFIX."threads WHERE dateline>'".$mybb->user['lastvisit']."' $unviewwhere");
            $newthreads = $db->result($query, 0);
            $query = $db->query("SELECT COUNT(tid) AS newann FROM ".TABLE_PREFIX."threads WHERE dateline>'".$mybb->user['lastvisit']."' AND fid='".$mybb->settings['portal_announcementsfid']."' $unviewwhere");
            $newann = $db->result($query, 0);
            if(!$newthreads) { $newthreads = 0; }
            if(!$newann) { $newann = 0; }
        }
        else
        {
            $newposts = 0;
            $newthreads = 0;
            $newann = 0;
        }
        $lang->new_announcements = sprintf($lang->new_announcements, $newann);
        $lang->new_threads = sprintf($lang->new_threads, $newthreads);
        $lang->new_posts = sprintf($lang->new_posts, $newposts);
        eval("\$welcometext = \"".$templates->get("portal_welcome_membertext")."\";");

    }
    else
    {
        $lang->guest_welcome_registration = sprintf($lang->guest_welcome_registration, $mybb->settings['bburl'] . '/member.php?action=register');
        $mybb->user['username'] = $lang->guest;
        eval("\$welcometext = \"".$templates->get("portal_welcome_guesttext")."\";");
    }
    $lang->welcome = sprintf($lang->welcome, $mybb->user['username']);
    eval("\$welcome = \"".$templates->get("portal_welcome")."\";");
    if($mybb->user['uid'] == 0)
    {
        $mybb->user['username'] = "";
    }
}
// Get Forum Statistics
if($mybb->settings['portal_showstatsh'] != "no")
{
    $stats = $cache->read("stats");
    $threadsnum = $stats['numthreads'];
    $postsnum = $stats['numposts'];
    $membersnum = $stats['numusers'];
    if(!$stats['lastusername'])
    {
        $newestmember = "<b>no-one</b>";
    }
    else
    {
        $newestmember = "<a href=\"".$mybb->settings[bburl]."/member.php?action=profile&uid=$stats[lastuid]\">$stats[lastusername]</a>";
    }
    eval("\$stats = \"".$templates->get("portal_stats")."\";");
}

// Get the online users
if($mybb->settings['portal_showwol'] != "no")
{
    $timesearch = time() - $mybb->settings['wolcutoff'];
    $comma = "";
    $guestcount = 0;
    $membercount = 0;
    $query = $db->query("SELECT s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup FROM ".TABLE_PREFIX."sessions s LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid) WHERE s.time>'$timesearch' ORDER BY u.username ASC, s.time DESC");
    while($user = $db->fetch_array($query))
    {
        if($user['uid'] == "0")
        {
            $guestcount++;
        }
        else
        {
            if($doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']])
            {
                $doneusers[$user['uid']] = $user['time'];
                $membercount++;
                if($user['invisible'] != "yes" || $mybb->usergroup['canviewwolinvis'] == "yes")
                {
                    if($user['invisible'] == "yes")
                    {
                        $invisiblemark = "*";
                    }
                    else
                    {
                        $invisiblemark = "";
                    }
                    $user['username'] = formatname($user['username'], $user['usergroup'], $user['displaygroup']);
                    eval("\$onlinemembers .= \"".$templates->get("portal_whosonline_memberbit", 1, 0)."\";");
                    $comma = ", ";
                }
            }
        }
    }
    $onlinecount = $membercount + $guestcount + $anoncount;

    // Most users online
    $mostonline = $cache->read("mostonline");
    if($onlinecount > $mostonline['numusers'])
    {
        $time = time();
        $mostonline['numusers'] = $onlinecount;
        $mostonline['time'] = $time;
        $cache->update("mostonline", $mostonline);
    }
    $recordcount = $mostonline['numusers'];
    $recorddate = mydate($mybb->settings['dateformat'], $mostonline['time']);
    $recordtime = mydate($mybb->settings['timeformat'], $mostonline['time']);

    $lang->online_users = sprintf($lang->online_users, $onlinecount);
    $lang->online_counts = sprintf($lang->online_counts, $membercount, $guestcount);
    eval("\$whosonline = \"".$templates->get("portal_whosonline")."\";");
}

// Latest forum discussions
if($mybb->settings['portal_showdiscussions'] != "no" && $mybb->settings['portal_showdiscussionsnum'])
{
    $altbg = "trow1";
    $query = $db->query("SELECT t.*, u.username FROM ".TABLE_PREFIX."threads t LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid) WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%' ORDER BY t.lastpost DESC  LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']);
    while($thread = $db->fetch_array($query))
    {

        if($thread['lastpost'] != "" && $thread['lastposter'] != "")
        {
            $lastpostdate = mydate($mybb->settings['dateformat'], $thread['lastpost']);
            $lastposttime = mydate($mybb->settings['timeformat'], $thread['lastpost']);
            eval("\$lastpost = \"".$templates->get("portal_latestthreads_thread_lastpost")."\";");
        }
        else
        {
            $lastpost = "";
        }
        $thread['subject'] = stripslashes($thread['subject']);
        if(strlen($thread['subject']) > 25)
        {
            $thread['subject'] = substr($thread['subject'], 0, 25) . "...";
        }
        $thread['subject'] = htmlspecialchars_uni($thread['subject']);
        eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
        if($altbg == "trow1")
        {
            $altbg = "trow2";
        }
        else
        {
            $altbg = "trow1";
        }
    }
    if($threadlist)
    { // show the table only if there are threads
        eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
    }
}


eval("\$portal = \"".$templates->get("portal")."\";");

$plugins->run_hooks("portal_end");

outputpage($portal);

?>
Community Coming Soon
Reply
#2
Not Solved
Do you get any error messages? If so, could you paste them here.

Also what is in your "header file"?
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
Reply
#3
Not Solved
I don't receive no error messages... logs me in... redirects.. and shows the login boxes again. My header file contains HTML, PHP, JavaScript, and CSS. It has includes for my search engine to search my site and display the search box, search button and search stats. I don't want to post it here but if you have msn I could possibly provide you with the code.

I have the above mybb code in login.php that I include in my header file using a php include.
Community Coming Soon
Reply
#4
Not Solved
Okay... I've decided to include the information through an Iframe as that seems like the only method I can use without getting major problems. Everything works fine when I include through an Iframe.... only problem I get is one error at the very top of the page.

Quote:Warning: Cannot modify header information - headers already sent by (output started at /home2/silver/public_html/mainsite/login.php:4) in /home2/silver/public_html/inc/functions.php on line 849
Community Coming Soon
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)