total online

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    total online

    i m getting error while using this codes. the below codes working good in old users in their profile. but when new user registers then it shows 42 years 8 months in user profile. anybody please help me


    core.php
    PHP Code:
    function addonline($uid,$place,$plclink)
    {
    /////delete inactive users
    $tm time();
    $timeout $tm 1800//time out = 5 minutes
    $deloff mysql_query("DELETE FROM ibwf_online WHERE actvtime <'".$timeout."'");
    $cloak mysql_fetch_array(mysql_query("SELECT hidden FROM ibwf_users WHERE id = '".$uid."'"));
    if(
    $cloak[0]==1){
    mysql_query("UPDATE ibwf_online SET hidden = 1 WHERE userid = $uid");    
    }else if(
    $cloak[0]==0){
    mysql_query("UPDATE ibwf_online SET hidden = 0 WHERE userid = $uid");    
    }
    ///now try to add user to online list and add total time online
    $lastactive mysql_fetch_array(mysql_query("SELECT lastact FROM ibwf_users WHERE id='".$uid."'"));
    $tolsla time() - $lastactive[0];
    $totaltimeonline mysql_fetch_array(mysql_query("SELECT tottimeonl FROM ibwf_users WHERE id='".$uid."'"));
    $totaltimeonline $totaltimeonline[0] + $tolsla;
    $ttime time();
    $res mysql_query("UPDATE ibwf_users SET lastact='".$ttime."' WHERE id='".$uid."'");
    $res mysql_query("UPDATE ibwf_users SET tottimeonl='".$totaltimeonline."' WHERE id='".$uid."'");
    $res mysql_query("INSERT INTO ibwf_online SET userid='".$uid."', actvtime='".$ttime."', place='".$place."', placedet='".$plclink."'");
    if(!
    $res)
    {
    //most probably userid already in the online list
    //so just update the place and time
    $res mysql_query("UPDATE ibwf_online SET actvtime='".$ttime."', place='".$place."', placedet='".$plclink."' WHERE userid='".$uid."'");
    }
    $maxmem=mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE id='2'"));
    $result mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_online"));
    if(
    $result[0]>=$maxmem[0])
    {
    $tnow date("D d M Y - H:i"time());
    mysql_query("UPDATE ibwf_settings set name='".$tnow."', value='".$result[0]."' WHERE id='2'");
    }
    $maxtoday mysql_fetch_array(mysql_query("SELECT ppl FROM ibwf_mpot WHERE ddt='".date("d m y")."'"));
    if(
    $maxtoday[0]==0||$maxtoday=="")
    {
    mysql_query("INSERT INTO ibwf_mpot SET ddt='".date("d m y")."', ppl='1', dtm='".date("H:i:s")."'");
    $maxtoday[0]=1;
    }
    if(
    $result[0]>=$maxtoday[0])
    {
    mysql_query("UPDATE ibwf_mpot SET ppl='".$result[0]."', dtm='".date("H:i:s")."' WHERE ddt='".date("d m y")."'");
    }
    }
    function 
    getnumonline(){
    $nouo mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_online "));
    return 
    $nouo[0];

    list.php

    PHP Code:
    ///////////////////Top online



    else if($action=="toponline")

    {

        
    addonline(getuid_sid($sid),"Top Online Users","");

           

        echo 
    "<head>";
        echo 
    "<title>Top Online Users</title>";
        echo 
    "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
        echo 
    "</head>";
        echo 
    "<body>";


       
    //////ALL LISTS SCRIPT <<



        
    if($page=="" || $page<=0)$page=1;

        
    $num_items regmemcount(); //changable

        
    $items_per_page10;

        
    $num_pages ceil($num_items/$items_per_page);

        if((
    $page>$num_pages)&&$page!=1)$page$num_pages;

        
    $limit_start = ($page-1)*$items_per_page;



        
    //changable sql



            
    $sql "SELECT id, name, tottimeonl, sex FROM ibwf_users ORDER BY tottimeonl DESC LIMIT $limit_start$items_per_page";





        echo 
    "<p>";

        
    $items mysql_query($sql);

        echo 
    mysql_error();

        if(
    mysql_num_rows($items)>0)

        {

        while (
    $item mysql_fetch_array($items))

        {

            if(
    $item[3]=='M'){

            
    $atxt="<img src=\"images/male.gif\" alt=\"M\"/>";

        }

        else if(
    $item[3]=='F'){

            
    $atxt="<img src=\"images/female.gif\" alt=\"F\"/>";

        }



          
    $lnk "$atxt<a href=\"index.php?action=viewuser&amp;who=$item[0]&amp;sid=$sid\">$item[1]</a> Online Time: $item[2] seconds = ".gettimemsg($item[2])."";

          echo 
    "$lnk<br/>";

        }

        }

        echo 
    "</p>";

        echo 
    "<p align=\"center\">";

        if(
    $page>1)

        {

          
    $ppage $page-1;

          echo 
    "<a href=\"lists.php?action=$action&amp;page=$ppage&amp;sid=$sid&amp;view=$view\">«PREV</a> ";

        }

        if(
    $page<$num_pages)

        {

          
    $npage $page+1;

          echo 
    "<a href=\"lists.php?action=$action&amp;page=$npage&amp;sid=$sid&amp;view=$view\">Next»</a>";

        }

        echo 
    "<br/>$page/$num_pages<br/>";

        if(
    $num_pages>2)

        {

          
    $rets "Jump to page<form action=\"lists.php\" method=\"get\"><input id=\"inputText\" name=\"page\" format=\"*N\" size=\"3\"/>";

             
    $rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\"/>";

            
    $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";

            
    $rets .= "<input id=\"inputButton\" type=\"submit\" value=\"Go\"/></form>";

        echo 
    $rets;

        }

        echo 
    "</p>";

      
    ////// UNTILL HERE >>
        
    echo "<p align=\"center\">";
        echo 
    "<b>9 </b><a accesskey=\"9\" href=\"index.php?action=stats&amp;sid=$sid\"><img src=\"../images/stat.gif\" alt=\"\"/>Site Stats</a><br/>";
      echo 
    "<b>0 </b><a accesskey=\"0\" href=\"index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
      echo 
    "</p>";
        echo 
    "</body>";


    user profile

    PHP Code:
    $totaltimeonline mysql_fetch_array(mysql_query("SELECT tottimeonl FROM ibwf_users WHERE id='".$who."'"));
    echo 
    "<b>Total Time Online: </b>".gettimemsg($totaltimeonline[0]).""
    sql
    PHP Code:
    `tottimeonlint(100NOT NULL default '0'

    #2
    the solution was already posted somewhere around here.....

    but i wont made u use a search button lol

    its easy, go 2 core.php, find function register() and INSERT time() function for "lastact"...

    something like this
    PHP Code:
    mysql_query("INSERT INTO USERS_TABLE SET lastact='".time()."', name='".$name."', password='".$password."'......etc 
    anyway its all there already, just put lastact='".time()."' in that query in register() function:p

    ohhh btw after u put tht in query it will work good for the newly registered users, but the users already registered without it will still have 42 years 8 months tot online lol so make those users register again lol or reset it manualy
    Last edited by alesh; 10.05.09, 10:43.
    sigpiceeeeerrr....

    Comment


      #3
      thank you so much bro. it is working now

      Comment

      Working...
      X