Location: PHPKode > scripts > WH Social > wh_social/framework/functions/online.php
<?php

    if(!isset($_SESSION['signed_in'])) {

        $sql = "DELETE FROM
                    online
                WHERE
                    DATE_SUB(NOW(), INTERVAL 5 MINUTE) > timed";

        mysql_query($sql) OR die(mysql_error());

        $sql = "SELECT
                    COUNT(*) as whoison
                FROM
                    online";

        $result = mysql_query($sql) OR die(mysql_error());
        $row = mysql_fetch_assoc($result);

        $showonline = (int)$row['whoison'];

            }else{

            $sql = "SELECT
                        COUNT(*) as whoison
                    FROM
                        online
                    WHERE
                        ip = '" . $_SERVER['REMOTE_ADDR'] . "'
                    AND
                        id = '" . (int)$_SESSION['id'] . "'";

            $result = mysql_query($sql) OR die(mysql_error());
            $row = mysql_fetch_assoc($result);

            if($row['whoison']) {

            $sql = "UPDATE
                        online
                    SET
                        timed = NOW()
                    WHERE
                        ip = '" . $_SERVER['REMOTE_ADDR'] . "'
                    AND
                        id = '" . (int)$_SESSION['id'] . "'";

            mysql_query($sql) OR die(mysql_error());

        }else{

        $sql = "INSERT INTO online
                    (id, ip, timed)
                VALUES
                    ('" . (int)$_SESSION['id'] . "', '" . $_SERVER['REMOTE_ADDR'] . "', NOW())";

        mysql_query($sql) OR die(mysql_error());
        }

        $sql = "DELETE FROM
                    online
                WHERE
                    DATE_SUB(NOW(), INTERVAL 5 MINUTE) > timed
                AND
                    id = '" . (int)$_SESSION['id'] . "'";

        mysql_query($sql) OR die(mysql_error());

        $sql = "SELECT
                    COUNT(*) as whoison
                FROM
                    online";

        $result = mysql_query($sql) OR die(mysql_error());
        $row = mysql_fetch_assoc($result);

        $showonline = (int)$row['whoison'];

        $sql_who = "SELECT
                        online.id,
                        members.id,
                        members.name
                    FROM
                        online
                    LEFT JOIN
					   members
				    ON
					   online.id =  members.id";

        $result_who = mysql_query($sql_who) OR die(mysql_error());
        }

?>
Return current item: WH Social