----- Original Message ----- 
From: <[EMAIL PROTECTED]>
> ----- Original Message ----- 
> From: "Bob"
> 
> I used to use the following to log specific errors:
> <snip>
> But, this meant that sometimes there would only be a few errors shown, if 
> the file had reached it's 20000 limit and deleted itself.
> 
> So I created a rolling road log of a 100. This allows me to view trends 
> easier. I'm not sure how efficient this is, or whether it would be suitable 
> for high volume?
> <snip>
> 
> Has anyone got a better method, or can improve it?
> Regards, Bob E.
> 
> ------------------------------------
> Hi Bob,
> 
> Here is some working example code for php version 4.x.x
> 
> It is much simpler and faster in php version 5.x.x because you can just add 
> arrays together in a single php function.
> 
> As with all file access the file/folder permission's need to be set 
> correctly.
> 
> Serialize is the safest way to story php objects as TRUE, FALSE, NULL and 
> 'value not set' are stored and retrieved correctly.
> 
> Let me know what version you are running and I will write a better example.
> 
> <html><head><title>www.domainname.com</title></head><body><?php
> 
> function display($array)
>  {
>  $text = serialize($array) . "\n";
>  $text = str_replace("\n", "<br>\n", $text);
>  echo($text);
>  }
> 
> $this_request['REQUEST_DATE'] = gmdate('d/m/Y', 36000 + 
> $_SERVER['REQUEST_TIME']);
> $this_request['REQUEST_TIME'] = gmdate('h:i:s a', 36000 + 
> $_SERVER['REQUEST_TIME']);
> $this_request['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
> $this_request['REMOTE_PORT'] = $_SERVER['REMOTE_PORT'];
> $this_request['REMOTE_HOST'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
> $this_request['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'];
> 
> $data[] = $this_request;
> 
> if(file_exists('data.txt'))
>  {
>  $temp = unserialize(@file_get_contents('data.txt'));
>  foreach($temp as $this_request)
>    {
>    $data[] = $this_request;
>    }
>  }
> 
> if(isset($_GET['delete']))
>  {
>  $ip = $_GET['delete'];
>  if($ip == '')
>    {
>    $ip = $_SERVER['REMOTE_ADDR'];
>    }
>  $total = count($data);
>  for($count = 0; $count <= $total; $count++)
>    {
>    if($data[$count]['REMOTE_ADDR'] == $ip)
>       {
>       unset($data[$count]);
>       }
>    }
>  $show = TRUE;
>  }
> 
> @file_put_contents('data.txt', serialize($data));
> 
> if(isset($_GET['show']))
>  {
>  $show = TRUE;
>  }
> 
> if($show)
>  {?>
> 
> <table border="1">
> 
> <tr>
> <th>Date</th>
> <th>Time</th>
> <th>IP</th>
> <th>Port</th>
> <th>Remote Host</th>
> <th>Referer</th>
> </tr>
> <?php
>  foreach($data as $this_request)
>    {
>    echo("\n<tr>\n");
>    foreach($this_request as $key => $value)
>      {
>      echo('<td>');
>      if($key == 'HTTP_REFERER')
>        {
>        echo('<a href="' . $value . '" target="_Blank">');
>        }
>      echo($value);
>      if($key == 'HTTP_REFERER')
>        {
>        echo('</a>');
>        }
>      echo("</td>\n");
>      }
>    echo("</tr>\n");
>    }
>  echo("\n</table>\n");
>  }
> 
> ?> 

Hi Rob,
I'm using PHP 4.4.4 (shared server so no choice, other than moving) so can't 
use file_put_contents().
You don't need to write me a complete program, just the concept and main points.
I've got to do some of the work myself <grin>.

I've never bothered recorded $_SERVER['REMOTE_PORT'] before. What do you use it 
for?
Thanks, Bob E.

p.s. Sorry I'm slow at replying at the moment as I'm rewiring my son's shop.
He's got me doing it as I work cheap. A cup of tea every hour.




------------------------------------

Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to