PHP Changes to WOL for New Forum Home Page


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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-111631-pmpng
Login or Register to Reply

|
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
So far, I have completed making the home page more responsive (except for the forum stats at the top and the WOL box at the bottom, they still use scroll bars). xevV3_iZ8-s For full screen use the link below and set your YT resolution to 1080p60 HD https://youtu.be/xevV3_iZ8-s Here is...... What is on Your Mind?
1
What is on Your Mind?
JQuery and CSS Flex Code for Responsive WOL Page
Neo
I have just wrote this jQuery to the WOL page, so the table of users on line will not need scrollbars and will instead transform into a responsive table: <script> jQuery(document).ready(function (){ jQuery("#neo-who-flex-tcat"). css({"display":"flex","flex-flow":"row wrap", ...... What is on Your Mind?
0
What is on Your Mind?
Forum Update: Disabled Home Page Forum Statistics for Guests (Not Registered)
Neo
Just a quick update; to speed up the forums, I have disabled the forum statistics on the home page for non registered users. No changes for registered users.... What is on Your Mind?
0
What is on Your Mind?