Current location: Hot Scripts Forums » General Community » Script Requests » [PHP] any script like the "Forum Location" ?


[PHP] any script like the "Forum Location" ?

Reply
  #1 (permalink)  
Old 12-21-05, 11:52 AM
BartAfterDark BartAfterDark is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
[PHP] any script like the "Forum Location" ?

Hello and merry x-mas.

Is there any scripts out there that can tell me what site the users are viewing on my site (not only the forum) ?
Like this: http://www.programmingtalk.com/online.php?

- lars
Reply With Quote
  #2 (permalink)  
Old 12-21-05, 03:05 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Gotta be compatible with your user auth. script. Incase you have one! Do you?
Reply With Quote
  #3 (permalink)  
Old 12-21-05, 03:16 PM
BartAfterDark BartAfterDark is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
yea.
But isn't there something that can get the url from on the page the user is viewing (by there IP)
Reply With Quote
  #4 (permalink)  
Old 12-21-05, 03:25 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Yes, but you have to make it work with your current system. There won't be a pre-made script for your user auth system. Gotta be a custom job.
Or do you just want to display something like:

80.156.15.46 - viewing index
Reply With Quote
  #5 (permalink)  
Old 12-21-05, 04:11 PM
BartAfterDark BartAfterDark is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
80.156.15.46 - viewing index
That's exatly what I want

Quote:
Originally Posted by nico_swd
Yes, but you have to make it work with your current system. There won't be a pre-made script for your user auth system. Gotta be a custom job.
Or do you just want to display something like:

80.156.15.46 - viewing index
Reply With Quote
  #6 (permalink)  
Old 12-21-05, 05:15 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
I wrote qucik a crappy skipt. Since I suck at MySQL is the data stored in temporary txt files.

include this into every page:
PHP Code:

<?php


$user 
$_SERVER['REMOTE_ADDR']; // Get IP
$current_location $_SERVER['PHP_SELF']; // Get location
$date date("His"); // Time
$userlogfile "path/to/your/logs/$user.viewing.txt"// Path or URL to the logfiles

        // Log data
        
$fp fopen("$userlogfile""w");
        
$string "$current_location|$user|$date";
        
fwrite($fp$string);
        
fclose($fp);
    
?>
And save this as "online.php" or whatever.
PHP Code:



<?php

$dir 
opendir("logs/"); // Path to logfiles
$filter = array("."".."); // File filter.
$usersonline 0;

$showtime date("His") + 2000// 2000 should be 20 minutes

        // Loop through the directory
        
while (($file readdir($dir)) !== false) {
        
            
// Skip files in filter
            
if (in_array($file$filter)) {
            continue;
            }
            
            
$data file("logs/$file");
            
            
// Get data from file
            
@list($location$username$time) = explode("|"$data[0]);
            
                
// Check if it's time to show up
                
if ($time $showtime){
                
                
$usersonline++;
                
                
// Display output
                
echo "$username - Viewing: <strong>$location</strong><br />";
                
                }
                else
                {
                
// Delete old files
                
unlink("logs/$file");
                
            }
        }
        
    
closedir($dir);
    
    echo 
"<p><strong>$usersonline</strong> Users online in the past 20 minutes</p>";
?>
Reply With Quote
  #7 (permalink)  
Old 12-22-05, 03:45 AM
BartAfterDark BartAfterDark is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
wee.
It allmost is working But it need to get the url like this.
domain.com/details.php?image_id=123 etc.
Reply With Quote
  #8 (permalink)  
Old 12-22-05, 06:27 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Try this then:

PHP Code:

<?php

$user 
$_SERVER['REMOTE_ADDR']; // Get IP

$image_id $_GET["image_id"]; // Get location

if (!empty($image_id) {
$current_location "/details.php?image_id=$image_id";
}
else
{
$current_location $_SERVER['PHP_SELF']; 
}

$date date("His"); // Time
$userlogfile "path/to/your/logs/$user.viewing.txt"// Path or URL to the logfiles

        // Log data
        
$fp fopen("$userlogfile""w");
        
$string "$current_location|$user|$date";
        
fwrite($fp$string);
        
fclose($fp);
    
?>
I didn't try it but it should work!
Reply With Quote
  #9 (permalink)  
Old 12-28-05, 06:59 AM
BartAfterDark BartAfterDark is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
hey I changed it to this
Code:
<?php

$user = $_SERVER['REMOTE_ADDR']; // Get IP
$current_location = "http:/" . $_SERVER["HTTP_HOST"]. $_SERVER['REQUEST_URI']; // Get location
$date = date("His"); // Time
$userlogfile = "logs/viewing.txt"; // Path or URL to the logfiles

        // Log data
        $fp = fopen("$userlogfile", "w");
        $string = "$current_location|$user|$date";
        fwrite($fp, $string);
        fclose($fp);
    
?>
It works fine. I only have one little problem
How can I remove the sessionID from the url (?image_id=3288&sid=7e62484a2b11ef2bec1af18e7a2aee 18)

I have this code
Code:
$sid = strpos($str, "mode")-1;
if ($sid > 0) { echo substr($str,0,$sid);}
else {echo $str;}
But I don't know how to add it
Reply With Quote
  #10 (permalink)  
Old 12-28-05, 02:39 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Try this

PHP Code:

<?php


$user 
$_SERVER['REMOTE_ADDR']; // Get IP
$current_location "http:/" $_SERVER["HTTP_HOST"]. $_SERVER['REQUEST_URI']; // Get location

    
@list($good$crap) = explode("&"$current_location);

$date date("His"); // Time
$userlogfile "logs/$user.viewing.txt"// Path or URL to the logfiles

        // Log data
        
$fp fopen("$userlogfile""w");
        
$string "$good|$user|$date";
        
fwrite($fp$string);
        
fclose($fp);
    
?>
I didn't try it, but it should work!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Your Own Profitable and VERY unique eBusiness Voltaire General Advertisements 3 03-30-10 06:36 AM
Raffle/Lottery Script (Very profitable!), Coded it myself. Voltaire General Advertisements 6 03-16-09 07:15 AM
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 10:17 AM
Raffle/Lottery Script (Very profitable!), Coded it myself. Voltaire General Advertisements 2 01-02-06 11:55 PM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM


All times are GMT -5. The time now is 11:53 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.