Skip to content

Instantly share code, notes, and snippets.

@ha1t
Created April 18, 2012 01:17
Show Gist options
  • Save ha1t/2410311 to your computer and use it in GitHub Desktop.
Save ha1t/2410311 to your computer and use it in GitHub Desktop.
visitors使ってたなー
<?php
/**
* visitorsでログを作るスクリプト
*
* need nkf,visitors,apache2
*/
error_reporting(E_ALL);
ini_set('display_errors', 'On');
/**
* visitors bin path
*/
$visitors_path = '/usr/bin/visitors';
/**
* apache2 log path
*/
$date = date("Ym");
$log_path = "/var/log/apache2/access_log.{$date}*";
/**
* output path
*/
$now_date = date("Y-m-d");
$output_path = "/home/halt/public_html/admin/visitors/{$now_date}.html";
if (!file_exists($visitors_path)) {
debug_print('visitors not found');
exit();
}
$command = $visitors_path;
$command.= " -A -m 100 ";
$command.= $log_path;
$command.= " | nkf -w -m0 > ";
$command.= $output_path;
debug_print($command);
//system($command);
exec($command);
function debug_print($message)
{
//print($message . "\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment