PHP Changes to WOL for New Forum Home Page

Tags
change, functions_online.php, home, mysql, page, php, web programming, who is online

 
Thread Tools Search this Thread
# 1  
Old 12-03-2018
PHP Changes to WOL for New Forum Home Page

Wrote some PHP code today to make the Who Is Online (WOL) in the forums work properly with the new home page:

Wrote this global plugin to add the location to both the user table (for members) and session table (for guests + registered users)

Code:
<?php
if (THIS_SCRIPT != 'misc' and THIS_SCRIPT != 'ajax') { 

    $mylocation = THIS_SCRIPT; 
    if (strlen($mylocation) < 2) { 
        $mylocation = "unknown"; 
    } 

    if ($vbulletin->userinfo['userid'] > '0') { 

        $query = "UPDATE " . TABLE_PREFIX . "user SET parentemail = '" . $mylocation . "' WHERE userid = " . $vbulletin->userinfo['userid']; 
        if (false) { 
            error_log("UID: " . $vbulletin->userinfo['userid'] . ' loc_cookie ' . $mylocation . " query: " . $query . "\n", 3, '/var/log/apache2/debug/cookiesetdbupdate.log'); 
        } 

        $db->query_write($query); 
    } 

    // borrowed  unused incalendar DB column  in the session table until I have a change to create a new one

    if (isset($vbulletin->session->vars['sessionhash']) and strlen($vbulletin->session->vars['sessionhash']) > 10) { 
        $query = "UPDATE " . TABLE_PREFIX . " session SET incalendar = '" . $mylocation . "' WHERE sessionhash = '" . $vbulletin->session->vars['sessionhash'] . "'"; 
        if (false) { 
            error_log("UID: " . $vbulletin->userinfo['userid'] . ' loc_cookie ' . $mylocation . " query: " . $query . "\n", 3, '/var/log/apache2/debug/cookiesetdbupdate.log'); 
        } 

        $db->query_write($query); 

    } 

}

In addition, wrote some quick PHP code for the online.php in functions_online.php:


Code:
<?php

case 'index':

        if($userinfo[userid] > '0')
        {
            $query = "SELECT lastlocation,lastactivity FROM " . TABLE_PREFIX . "user WHERE userid = ".$userinfo[userid]." ORDER BY lastactivity DESC LIMIT 1";
            $userloc = $vbulletin->db->query_first("SELECT lastlocation,lastactivity FROM " . TABLE_PREFIX . "user WHERE userid = ".$userinfo['userid']." ORDER BY lastactivity DESC LIMIT 1");
            error_log("UID: " . $vbulletin->userinfo['userid'] . '  loc ' . $userloc['lastlocation'] . ' Query: '.$query. "\n", 3, '/var/log/apache2/debug/online_neo.log');
        }
        else
        {
            if(strlen($vbulletin->session->vars['incalendar']) > 10)
            $guestloc = $vbulletin->session->vars['incalendar'];
        }

     

        if($userloc['lastlocation'] == 'home' OR $guestloc == 'home')
        {              
             $userinfo['action'] =  'Viewing Home Page - Featured Discussion';
             $userinfo['where'] = '<a href="' . $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'] . '">' . $vbulletin->options['bbtitle'] . '</a>';
        }
        else
        {                 
            $userinfo['action'] = 'Viewing Forum Home and Stats Page';
            $userinfo['where'] = '<a href="https://www.unix.com/forum.php' . $vbulletin->session->vars['sessionurl_q'] . '">Forums: ' .$vbulletin->options['bbtitle'] . '</a>';
        }
                
       break;

PHP Changes to WOL for New Forum Home Page-screen-shot-2018-12-03-11-16-31-pm-png

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
JQuery and CSS Flex Code for Responsive Forum Home Page Neo What is on Your Mind? 1 08-11-2018 07:45 AM
JQuery and CSS Flex Code for Responsive WOL Page Neo What is on Your Mind? 0 08-10-2018 12:02 PM
Forum Update: Disabled Home Page Forum Statistics for Guests (Not Registered) Neo What is on Your Mind? 0 04-13-2015 07:39 AM
HTTPS-Home Page issue. Hari_Ganesh Web Programming 0 08-26-2010 01:08 AM
How to change home page? sbmk_design Solaris 2 07-02-2010 09:02 AM
new thread link in home page salaathi Post Here to Contact Site Administrators and Moderators 1 11-13-2007 02:59 AM