function write()
 {
     if (PluginAccesslog::is_admin(NULL, PLUGIN_ACCESSLOG_USE_SESSION, PLUGIN_ACCESSLOG_THROUGH_IF_ADMIN)) {
         return;
     }
     global $vars, $defaultpage;
     $page = isset($vars['refer']) ? $vars['refer'] : (isset($vars['page']) ? $vars['page'] : $defaultpage);
     $cmd = isset($vars['cmd']) ? $vars['cmd'] : (isset($vars['plugin']) ? $vars['plugin'] : '');
     // logdata format
     $logdata = array();
     $logdata['time'] = strftime('%y/%m/%d %H:%M:%S');
     $logdata['ip'] = $_SERVER['REMOTE_ADDR'];
     $logdata['host'] = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : gethostbyaddr($_SERVER['REMOTE_ADDR']);
     $logdata['referer'] = $_SERVER['HTTP_REFERER'];
     $logdata['agent'] = $_SERVER['HTTP_USER_AGENT'];
     $logdata['page'] = $page;
     $logdata['cmd'] = $cmd;
     $line = serialize($logdata) . "\n";
     if (ereg(PLUGIN_ACCESSLOG_EXCEPT_AGENT, $logdata['agent'])) {
         return TRUE;
     }
     if (ereg(PLUGIN_ACCESSLOG_EXCEPT_HOST, $logdata['host'])) {
         return TRUE;
     }
     $date = date('Ymd', time());
     // use localtime simply because time handling ways in pukiwiki plus! and official are different.
     if (file_exists(PLUGIN_ACCESSLOG_FILENAME)) {
         $logdate = rtrim(array_shift(file_head(PLUGIN_ACCESSLOG_FILENAME, 1)));
         if ($logdate != $date) {
             slide_rename(PLUGIN_ACCESSLOG_FILENAME, PLUGIN_ACCESSLOG_KEEPLOG_DAYS, '.%d');
             @move(PLUGIN_ACCESSLOG_FILENAME, PLUGIN_ACCESSLOG_FILENAME . '.1');
             file_put_contents(PLUGIN_ACCESSLOG_FILENAME, $date . "\n");
         }
     } else {
         file_put_contents(PLUGIN_ACCESSLOG_FILENAME, $date . "\n");
     }
     return file_put_contents(PLUGIN_ACCESSLOG_FILENAME, $line, FILE_APPEND);
 }
 function spamlog_write($vars, $comment = array(), $filename = '')
 {
     if ($filename === '') {
         $filename = PLUGIN_AKISMET_SPAMLOG_FILENAME;
     }
     $page = isset($vars['refer']) ? $vars['refer'] : (isset($vars['page']) ? $vars['page'] : $defaultpage);
     $cmd = isset($vars['cmd']) ? $vars['cmd'] : '';
     // logdata format
     $logdata = array();
     $logdata['time'] = strftime('%y/%m/%d %H:%M:%S');
     $logdata['ip'] = $_SERVER['REMOTE_ADDR'];
     $logdata['host'] = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : gethostbyaddr($_SERVER['REMOTE_ADDR']);
     $logdata['agent'] = $_SERVER['HTTP_USER_AGENT'];
     $logdata['page'] = $page;
     $logdata['cmd'] = $cmd;
     $logdata['body'] = isset($comment['body']) ? str_replace("\n", '<br />', $comment['body']) : '';
     $line = serialize($logdata) . "\n";
     $date = (int) (time() / 3600 / 24);
     // use localtime simply because time handling ways in pukiwiki plus! and official are different.
     if (file_exists($filename)) {
         $logdate = rtrim(array_shift(file_head($filename, 1)));
         if ($date - PLUGIN_AKISMET_ONELOG_DAYS >= $logdate) {
             slide_rename($filename, PLUGIN_AKISMET_KEEPLOG, '.%d');
             @move($filename, $filename . '.1');
             file_put_contents($filename, $date . "\n");
         }
     } else {
         file_put_contents($filename, $date . "\n");
     }
     return file_put_contents($filename, $line, FILE_APPEND);
 }