Online users help

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

    Online users help

    Please help... this code only display online users who are browsing on the same directory,... i need to display all users who are browsing in all directory...

    PHP Code:
    <?php
    $data
    ="online1.dat";
    //print date('his A',time()-((10*60*60)+(30*60)));
    $time=time()-((10*60*60)+(30*60));
    $past_time=$time-1200;
    $readdata=@fopen($data,"r") or die("? ? ? ? $data");
    $data_array=file($data);
    @
    fclose($readdata);
    if (
    getenv('HTTP_X_FORWARDED_FOR'))
    $user getenv('HTTP_X_FORWARDED_FOR');
    else
    $user getenv('REMOTE_ADDR');
    $page getenv('REQUEST_URI');
    $agent getenv('HTTP_USER_AGENT');
    $d=count($data_array);
    for(
    $i=0;$i<$d;$i++)
    {
    list(
    $live_agent,$live_user,$live_page,$last_time)=explode("::","$data_array[$i]");
    if(
    $live_user!=""&&$last_time!=""&&$live_agent!=""&&$live_page!=""):
    if(
    $last_time<$past_time):
    $live_user="";
    $last_time="";
    $live_agent="";
    endif;
    if(
    $live_user!=""&&$last_time!=""&&$live_agent!="")
    {
    if(
    $user==$live_user&&$agent==$live_agent)
    {
    $online_array[]="$agent::$user::$page::$time\r\n";
    }
    else
    $online_array[]="$live_agent::$live_user::$live_page::$last_time";
    }
    endif;
    }
    if(isset(
    $online_array)):
    foreach(
    $online_array as $i=>$str)
    {
    if(
    $str=="$agent::$user::$page::$time\r\n")
    {
    $ok=$i;
    break;
    }
    }
    foreach(
    $online_array as $j=>$str)
    {
    if(
    $ok==$j) { $online_array[$ok]="$agent::$user::$page::$time\r\n"; break;}
    }
    endif;
    $writedata=@fopen($data,"w") or die("? ? ? ? $data");
    @
    flock($writedata,2);
    if(
    $online_array==""$online_array[]="$agent::$user::$page::$time\r\n";
    foreach(
    $online_array as $str)
    fputs($writedata,"$str");
    @
    flock($writedata,3);
    @
    fclose($writedata);
    $readdata=@fopen($data,"r") or die("? ? ? ? $data");
    $data_array=@file($data);
    @
    fclose($readdata);
    $online=count($data_array);
    print 
    "<a href='who.php' class='index'>Online:" .$online."</a>";
    ?>

    #2
    something like this:
    PHP Code:
    <?php 
    $cwd 
    getcwd();
    chdir('Your Folder Name');
    $data="online1.dat"
    //print date('his A',time()-((10*60*60)+(30*60))); 
    $time=time()-((10*60*60)+(30*60)); 
    $past_time=$time-1200
    $readdata=@fopen($data,"r") or die("? ? ? ? $data"); 
    $data_array=file($data); 
    @
    fclose($readdata); 
    if (
    getenv('HTTP_X_FORWARDED_FOR')) 
    $user getenv('HTTP_X_FORWARDED_FOR'); 
    else 
    $user getenv('REMOTE_ADDR'); 
    $page getenv('REQUEST_URI'); 
    $agent getenv('HTTP_USER_AGENT'); 
    $d=count($data_array); 
    for(
    $i=0;$i<$d;$i++) 

    list(
    $live_agent,$live_user,$live_page,$last_time)=explode("::","$data_array[$i]"); 
    if(
    $live_user!=""&&$last_time!=""&&$live_agent!=""&&$live_page!=""): 
    if(
    $last_time<$past_time): 
    $live_user=""
    $last_time=""
    $live_agent=""
    endif; 
    if(
    $live_user!=""&&$last_time!=""&&$live_agent!=""

    if(
    $user==$live_user&&$agent==$live_agent

    $online_array[]="$agent::$user::$page::$time\r\n"

    else 
    $online_array[]="$live_agent::$live_user::$live_page::$last_time"

    endif; 

    if(isset(
    $online_array)): 
    foreach(
    $online_array as $i=>$str

    if(
    $str=="$agent::$user::$page::$time\r\n"

    $ok=$i
    break; 


    foreach(
    $online_array as $j=>$str

    if(
    $ok==$j) { $online_array[$ok]="$agent::$user::$page::$time\r\n"; break;} 

    endif; 
    $writedata=@fopen($data,"w") or die("? ? ? ? $data"); 
    @
    flock($writedata,2); 
    if(
    $online_array==""$online_array[]="$agent::$user::$page::$time\r\n"
    foreach(
    $online_array as $str
    fputs($writedata,"$str"); 
    @
    flock($writedata,3); 
    @
    fclose($writedata); 
    $readdata=@fopen($data,"r") or die("? ? ? ? $data"); 
    $data_array=@file($data); 
    @
    fclose($readdata); 
    $online=count($data_array); 
    print 
    "<a href='who.php' class='index'>Online:" .$online."</a>";
    chdir($cwd); 
    ?>

    Comment


      #3
      Originally posted by something else View Post
      something like this:
      PHP Code:
      <?php 
      $cwd 
      getcwd();
      chdir('Your Folder Name');
      $data="online1.dat"
      //print date('his A',time()-((10*60*60)+(30*60))); 
      $time=time()-((10*60*60)+(30*60)); 
      $past_time=$time-1200
      $readdata=@fopen($data,"r") or die("? ? ? ? $data"); 
      $data_array=file($data); 
      @
      fclose($readdata); 
      if (
      getenv('HTTP_X_FORWARDED_FOR')) 
      $user getenv('HTTP_X_FORWARDED_FOR'); 
      else 
      $user getenv('REMOTE_ADDR'); 
      $page getenv('REQUEST_URI'); 
      $agent getenv('HTTP_USER_AGENT'); 
      $d=count($data_array); 
      for(
      $i=0;$i<$d;$i++) 

      list(
      $live_agent,$live_user,$live_page,$last_time)=explode("::","$data_array[$i]"); 
      if(
      $live_user!=""&&$last_time!=""&&$live_agent!=""&&$live_page!=""): 
      if(
      $last_time<$past_time): 
      $live_user=""
      $last_time=""
      $live_agent=""
      endif; 
      if(
      $live_user!=""&&$last_time!=""&&$live_agent!=""

      if(
      $user==$live_user&&$agent==$live_agent

      $online_array[]="$agent::$user::$page::$time\r\n"

      else 
      $online_array[]="$live_agent::$live_user::$live_page::$last_time"

      endif; 

      if(isset(
      $online_array)): 
      foreach(
      $online_array as $i=>$str

      if(
      $str=="$agent::$user::$page::$time\r\n"

      $ok=$i
      break; 


      foreach(
      $online_array as $j=>$str

      if(
      $ok==$j) { $online_array[$ok]="$agent::$user::$page::$time\r\n"; break;} 

      endif; 
      $writedata=@fopen($data,"w") or die("? ? ? ? $data"); 
      @
      flock($writedata,2); 
      if(
      $online_array==""$online_array[]="$agent::$user::$page::$time\r\n"
      foreach(
      $online_array as $str
      fputs($writedata,"$str"); 
      @
      flock($writedata,3); 
      @
      fclose($writedata); 
      $readdata=@fopen($data,"r") or die("? ? ? ? $data"); 
      $data_array=@file($data); 
      @
      fclose($readdata); 
      $online=count($data_array); 
      print 
      "<a href='who.php' class='index'>Online:" .$online."</a>";
      chdir($cwd); 
      ?>
      something wrong in this code... it only display the users online on specific folder not the whole...

      Comment


        #4
        it set up so your whole site runs off of one folder .... so it doesnt have to open hundreds of directories to see if someone is online... all you have to do is replace this script with every original script on server but change the line:
        chdir('Your Folder Name');
        so it works off of one folder .... so could be:

        chdir('./data/'); // root folder to folder called data

        or

        chdir('../data/'); // secondary folder .. back to root folder .. and to folder called data.

        chdir('../../data/'); //3rd folder to 2nd folder to root folder to data folder
        Last edited by something else; 18.04.11, 08:01.

        Comment


          #5
          do i have to put online1.dat in every folder??

          Comment


            #6
            add that function to online.php
            and add to your pages
            <? include "online.php"; ?>

            and just edit
            online1.dat

            by adding
            "../"

            sample

            $online = "../online1.dat";
            wherein online1.dat is located from a folder so that , it will be the same storage of the data

            .
            Originally posted by poporopop25 View Post
            do i have to put online1.dat in every folder??
            the author should add just 1 online1.dat
            Last edited by wapmetal; 19.04.11, 02:45.
            com site: http://vampist.net
            download site: http://wapdloads.net
            fb: http://www.facebook.com/pmplx

            Comment


              #7
              got it.. thanks...

              Comment

              Working...
              X