I changed how SSO was managed - Now online members doesnt show?

Melancholy

Member
Jan 10, 2015
39
13
Hello there! I cant figure out why my online count doesnt work. I've looked at this and cant figure it out.. Hopefully its something small that I've missed for all these hours. Lol.

OnlineCount.php
Code:
<small><b><?= Game::usersOnline() ?></b> <?= $config['hotelName'] ?>'s online.</small>


Class.Game.Php
Code:
<?php
    if(!defined('BRAIN_CMS'))
    {
        die('Sorry but you cannot access this file!');
    }
    /*
        Functions list Class Game.
        ---------------
        sso();
        usersOnline();
        homeRoom();
    */
    class Game
    {
           public static function sso()
        {
            global $dbh;
            //$timeNow = strtotime("now");
            $ticket  = time().sha1(rand(10000,99999));

            $hasTicket = $dbh->prepare('SELECT COUNT(*) from `user_auth_ticket` WHERE `user_id` = ? LIMIT 1');
            $hasTicket->execute([ $_SESSION['id'] ]);

            if($hasTicket->fetchColumn() > 0)
            {
                $update = $dbh->prepare('UPDATE `user_auth_ticket` SET `auth_ticket` = :auth_ticket WHERE `user_id` = :user_id');
                $update->execute([
                    ':auth_ticket' => $ticket,
                    ':user_id'     => $_SESSION['id']
                ]);
            }
            else
            {
                $insert = $dbh->prepare('INSERT INTO `user_auth_ticket` (`user_id`, `auth_ticket`) VALUES (:user_id, :auth_ticket)'); //this is correct right yea
                $insert->execute([
                    ':user_id'     => $_SESSION['id'],
                    ':auth_ticket' => $ticket
                ]); //do you have pdo set as exception for errors dont think so wait sec
            }

            /*
            // old code
            $stmt = $dbh->prepare("UPDATE users SET auth_ticket = :sso , last_online = :timenow WHERE id = :id");
            $stmt->bindParam(':timenow', $timeNow);
            $stmt->bindParam(':id', $_SESSION['id']);
            $stmt->bindParam(':sso', $sessionKey);
            $stmt->execute();
            */
        } 






        Public static function usersOnline()
        {
            global $dbh;
            $userCount = $dbh->prepare("SELECT * FROM users WHERE online = '1'");
            $userCount->execute();
            return $userCount->RowCount();
        }
        public static function homeRoom()
        {
            global $dbh, $hotel;
            $stmt = $dbh->prepare("UPDATE users SET home_room = :homeroom WHERE id = :id");
            $stmt->bindParam(':homeroom', $hotel['homeRoom']);
            $stmt->bindParam(':id', $_SESSION['id']);
            $stmt->execute();
        }
    }
?>





Header.php
Code:
<html lang="en">
    <head>
        <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Ubuntu:regular,bold&subset=Latin">
        <link rel="stylesheet" href="/templates/brain/style/css/main2.css?v=5" type="text/css">
        <link rel="stylesheet" href="/templates/brain/style/css/home.css" type="text/css">
    </head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script src="https://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
        $(document).ready(function(e) {
            $.ajaxSetup({
                cache:true
            });
            setInterval(function() {
                $('#onlinecount').load('/onlinecount');
            }, 1500);
            $( "#onlinecount").click(function() {
                $('#onlinecount').load('/onlinecount');
            });
        });
    </script>
    <script type="text/javascript">
        $(document).ready(function(e) {
            $.ajaxSetup({
                cache:true
            });
            setInterval(function() {
                $('#roomcount').load('/roomcount');
            }, 5500);
            $( "#roomcount").click(function() {
                $('#roomcount').load('/roomcount');
            });
        });
    </script>
    <script src="/templates/brain/includes/snowstorm-min.js"></script>
<script>
    snowStorm.snowColor = '#fff';
    snowStorm.flakesMax = 128;
    snowStorm.flakesMaxActive = 96;
    snowStorm.useTwinkleEffect = 1;
    snowStorm.followMouse = 0;
    snowStorm.snowStick = 1;
    snowStorm.flakeBottom = 0;
    snowStorm.animationInterval = 0;
    snowStorm.excludeMobile = 1;
     snowStorm.zIndex = 9999;
</script>
            <body>
            <div id="site">
                <div id="body">
                    <link rel="stylesheet" href="/templates/brain/style/css/index/style.css?v=4">
                    <link rel="stylesheet" href="/templates/brain/style/css/index/StyleIndex.css?v=4">
                    <style type="text/css">
                        @import url(https://fonts.googleapis.com/css?family=Ubuntu:400,700,300);
                        @import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,700);
                    </style>
                    <?php User::Login(); ?> 
                    <header style="background-position-x: -4607px;">
                        <div id="main">
                            <div class="left">
                                <div id="banner-counter-container-box">
                                    <img src="/templates/brain/style/images/logo/header.png" style="margin-top: -20px"><br>
                                    <div class="text">
                                        <div class="animated bounceIn"><b>0</b> <?= $config['hotelName'] ?>'s Online!</div>
                                    </div>
                                </div>
                            </div>
                            <div class="animated bounceIn">
                              
                                  
                                          
                                                </div>
                                            </button>
                                            </form>
                                    </div>
                                </div>
                            </header>
                            <div id="main" class="pcon">
                                <div id="info-container-box2">
                                    <div class="ajax">
                                    </div>
                                    <div class="text">
                                        <div class="animated bounceIn">
                                            <center>
                                                <h2><b></b></h2>
                                                <p><b><?php echo $lang['Islogan3']; ?></b></p>
                                            </center>
                                        </div>
                                    </div>
                </div>
            </header>
            <nav>
                <div id="navigator">
                    <div class="center">
                        <ul>
                            <li class="blauw">
                                <a href="/"><?= User::userData('username') ?></a>
                                <div class="submenu">
                                    <a href="/me"><?= User::userData('username') ?></a>
                                    <a href="/settingspassword"><?= $lang["Naccountsettings"] ?></a>
                                    <a href="/home/<?= User::userData('username') ?>"><?= $lang["Nmyprofile"] ?></a>
                                    <a href="/logout"><?= $lang["NsignOut2"] ?></a>
                                </div>
                            </li>
                            <li class="rood">
                                <a href="/community"><?= $lang["Ncommunity"] ?></a>
                                <div class="submenu">
                                    <a href="/community"><?= $lang["Ncommunity"] ?></a>
                                    <a href="/sollicitaties"><?= $lang["Nstaffapply"] ?></a>
                                    <a href="<?php
                                        $getLastNewsId = $dbh->prepare("SELECT id FROM cms_news ORDER BY ID DESC LIMIT 1");
                                        $getLastNewsId->execute();
                                        $row = $getLastNewsId->fetch();
                                        echo "/news/".$row['id']."";
                                        ?>">
                                    <?= $lang["Nnews"] ?></a>
                                  
                                    <a href="/stats"><?= $lang["Nstatistics"] ?></a>
                                    <a href="/online"><?= $lang["Nonline"] ?> <?= $config['hotelName'] ?>'s</a>
                                </div>
                            </li>
                            <li class="paars">
                                <a href="/staff"><?= $lang["Nstaff"] ?></a>
                                <div class="submenu">
                                    <a href="/staff"><?= $lang["Nstaff"] ?></a>
                                    <a href="/teams"><?= $lang["Nteams"] ?></a>
                                </div>
                            </li>
                            </li>
                            <li class="groen">
                                <a href="/vip"><?= $lang["Sshopnaviname"] ?></a>
                                <div class="submenu">
                                    <a href="/vip"><?= $lang["Vvipnaviname"] ?></a>
                                    <a href="/diamonds"><?= $lang["Vdiamonds"] ?></a>
                                </div>
                            </li>
                            <li class="blauwthree">
                                <a href="/"><?= ('&nbsp;Radio') ?></a>
                                <div class="submenu">
                                    <a href="/radioone"  onclick="window.open('/radioone','new','toolbar=0,scrollbars=0,location=1,statusbar=1,menubar=0,resizable=1,width=350,height=130' );return false; ('&nbsp;Radio')">Top Hits Just Nu</a>
                                </div>
                            <a href="/client" onclick="window.open('/client','new','toolbar=0,scrollbars=0,location=1,statusbar=1,menubar=0,resizable=1,width=1270,height=700');return false;"><li class="blauwtwo"><?= $lang["NsignOut"] ?></li></a>
                            <a href="<?= $config['hotelUrl'] ?>/logout"><li class="logout"><?= $lang["NsignOut2"] ?></li></a>

                        </ul>

                    </div>

                </nav>



 

Users who are viewing this thread

Top