A component for this might be possible

June Taylor Posted in Component Development 5 years ago

Should I assume that the operator of a website is capable of tracking your every action at that site. I had a Forum once (SMF) that logged the IP address from which an account was created and most recently logged in from. This log is often retained for a substantial time, often indefinitely. In addition, most web server applications log all accesses in a master webserver log, which invariably includes the IP address, and a competent admin can correlate any activity on the website (even just viewing) with an IP address by examining that logfile. My question is ; I want to be able to do this with OSSN. Your thoughts on this may put me in the right direction to do this

Replies
us Rishi B Replied 5 years ago

if you really want full details, look at your Apache (webserver's) accesslog and errorlog files. That contains the ip performing the request, timestamp, user-agent, request string, and more. If you're using the provided VM image for OSSN or a standard Linux installation, the accesslog file will be /var/log/apache2 and errorlog will be in your OSSN root, as long as you've enabled error logging via the ossn admin interface.

you could of course write a component to do some more tracking and then nicely display everything if you want. personally I'm with Z-Man on this though - I hate that kind of tracking.

Indonesian Arsalan Shah Replied 5 years ago

Please don't edit the core files, you may write your own component below is just a example that :

<?php
function log_init(){
        ossn_register_callback('action', 'load', 'log_actions');
        ossn_add_hook('page', 'load', 'page_log');
}
function log_main(){
        $url = ...
        $ip  = ...
}
function log_actions(){
        log_main();
}
function page_log($hook, $type, $return, $params){
        log_main();
        return $return;
}
ossn_register_callback('ossn', 'init', 'log_init');
us June Taylor Replied 5 years ago

Just a follow up. I got it to work by adding some code to the index.php. The log file will be created in the same directory.

   if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $ipaddress = $_SERVER['HTTP_CLIENT_IP']."\r\n";
    }
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check if ip is pass from proxy
    {
      $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']."\r\n";
    }
else
    {
      $ipaddress = $_SERVER['REMOTE_ADDR']."\r\n";
    }

$file = 'log.txt';  //this is the file to which the IP address will be written; name it your way.

$fp = fopen($file, 'a');

fwrite($fp, $ipaddress);

fclose($fp);
German Michael Zülsdorff Replied 5 years ago

Personally, I hate that kind of tracking - but technically there would be no reason not to implement it.