• 20
  • Mar
  • I want to get logged in users and pm to display on forumdisplay. I added

    $loggedinusers
    $pminfo

    to the forumdisplay template but nothing happened. Do i need to add something in the forumdisplay php code or something?


  • You need to make those global templates. Right now they are specific to the ForumHome like they have always been.


  • Sorry to bump this, but I wish to achive the same things - however I'm not sure exactly what code to move from index.php to global.php

    Any pointers appreciated :)


  • with this i have a problem when i want to post the board says that there is allready the user in the vb
    i have put $loggedinusers in forumdisplay_threadlist template


  • do i just add in the template in this list from global.php


    $templatesused.='timezone,username_loggedout,usern ame_loggedin,phpinclude,headinclude,header,footer, toplinks,forumjumpbit,forumjump,nav_linkoff,nav_li nkon,navbar,nav_joiner';
    cachetemplates($templatesused);


  • arr i see i need to add the code as well, making sense now.

    thanks for the pointer


  • how do you make a template global?

    Also on this subject, i wanted to create a tempate which i could then call from the header (or elsewhere) how do i do this? sorry if this is a silly question but not sure.


  • I got it for anyone else thats interested.

    As mentioned above you need to copy some *stuff* from index.php to global.php

    Open index.php

    Find:

    if ($displayloggedin) {
    $datecut=time()-$cookietimeout;

    //$loggedins=$DB_site->query_first("SELECT COUNT(*) AS sessions FROM session WHERE lastactivity>$datecut");
    //$totalonline=$loggedins['sessions'];
    $loggedins=$DB_site->query_first("SELECT COUNT(*) AS sessions FROM session WHERE userid=0 AND lastactivity>$datecut");
    $numberguest=$loggedins['sessions'];
    //$numberregistered=$totalonline-$numberguest;

    $numbervisible=0;
    $numberregistered=0;
    //$loggedins=$DB_site->query("SELECT DISTINCT user.userid,username FROM user,session WHERE session.userid=user.userid AND session.userid<>0 AND invisible=0 AND session.lastactivity>$datecut ORDER BY username");
    $loggedins=$DB_site->query("SELECT DISTINCT session.userid,username,invisible
    FROM session
    LEFT JOIN user ON (user.userid=session.userid)
    WHERE session.userid>0 AND session.lastactivity>$datecut
    ORDER BY invisible, username");
    if ($loggedin=$DB_site->fetch_array($loggedins)) {
    $numberregistered++;
    if ($loggedin['invisible']==0 or $bbuserinfo['usergroupid']==6) {
    $numbervisible++;
    $userid=$loggedin['userid'];
    if ($loggedin['invisible']==1) { // Invisible User but show to Admin
    $username=$loggedin['username'];
    $invisibleuser = '*';
    } else {
    $username=$loggedin['username'];
    $invisibleuser = '';
    }
    //$location=$loggedin['location'];
    eval("$activeusers = "".gettemplate('forumhome_loggedinuser')."";");
    }

    while ($loggedin=$DB_site->fetch_array($loggedins)) {
    $numberregistered++;
    $invisibleuser = '';
    if ($loggedin['invisible']==1 and $bbuserinfo['usergroupid']!=6) {
    continue;
    }
    $numbervisible++;
    $userid=$loggedin['userid'];
    if ($loggedin['invisible']==1) { // Invisible User but show to Admin
    $username=$loggedin['username'];
    $invisibleuser = '*';
    } else {
    $username=$loggedin['username'];
    }
    $location=$loggedin['location'];
    eval("$activeusers .= ", ".gettemplate('forumhome_loggedinuser')."";");
    }
    }
    $DB_site->free_result($loggedins);

    $totalonline=$numberregistered+$numberguest;
    $numberinvisible=$numberregistered-$numbervisible;

    $maxusers=explode(" ", gettemplate('maxloggedin',0,0));
    if ((int)$maxusers[0] <= $totalonline) {
    $time = time();
    $maxloggedin = "$totalonline " . $time;
    $DB_site->query("UPDATE template SET template='$maxloggedin' WHERE title='maxloggedin'");
    $maxusers[0] = $totalonline;
    $maxusers[1] = $time;
    }
    $recordusers = $maxusers[0];
    $recorddate = vbdate($dateformat,$maxusers[1]);
    $recordtime = vbdate($timeformat,$maxusers[1]);
    eval("$loggedinusers = "".gettemplate('forumhome_loggedinusers')."";");
    }


    and cut it from this file (once you have made a backup!)

    Paste into global.php after:

    $PHP_SELF = strtolower($PHP_SELF);
    if (substr($PHP_SELF,-12)!='register.php' and substr($PHP_SELF,-10)!='member.php') {
    $permissions=getpermissions();
    if (!$permissions['canview']) {
    show_nopermission();
    }
    } else {
    if ($action!="register" and $action!="signup" and $action!="activate" and $action!="login" and $action!="logout" and $action!="lostpw" and $action!="emailpassword" and $action!="addmember" and $action!="coppaform" and $a!="act" and $a!="ver") {
    $permissions=getpermissions();
    if (!$permissions['canview']) {
    show_nopermission();
    }
    }
    }


    Upload the files. Now edit your templates.
    forumdisplay_forumslist - edit for logged in users in a forum view.

    In forumdisplay_forumslist at the end where



    $forumbits





    Change to:


    $forumbits
    $loggedinusers





    This works for me, I hope it works for anyone else that tries it - but I don't really know what I am doing, so if there are mistakes please point them out ;)

    Couldn't be easier... well it could if all these variables were made global aready - but I supposed there is a reason for that such as extra server load? I dunno :)







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about logged in and pm on forumdisplay.php? , Please add it free.