The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
AbyssWS Log Splitter v0.1
Posted by: Joshua H. (TRUSTAbyss) | February 10, 2007 @ 10:27pm
Revision 1 - Original post on February 8, 2007 @ 4:13am
PHP Code
[
Download
]
<?php /** * AbyssWS Log Splitter: v0.1b3 * Created by: Josh (TRUSTAbyss) * * Provided by: trustabyss.com and * sourceforge.net * * AbyssWS Log Splitter * Copyright (C) 2007 Joshua H. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * License Information: * http://www.gnu.org/licenses/gpl.txt */ // Please provide the full path to your log file, using forward // slashes in the path. Default is given. $log_file = "C:/Program Files/Abyss Web Server/log/access.log"; // Please provide the Output Directory where your seperated log files // will be stored. Default is given. $output_dir = "C:/Program Files/Abyss Web Server/log"; // Warning! Don't Edit Anthing Else! // No more configuration is needed. Enjoy! print "Reading log file. Please wait...\n"; $start = time(); $date_array = array(); $fp = fopen($log_file, "r"); while (!feof($fp)) { $buffer = fgets($fp, 1024); if (preg_match("/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s.+\s.+\s\[[0-9]+\/([a-zA-Z]+)\/([0-9]+)/", $buffer, $match)) { if (!in_array("$match[1]-$match[2]", $date_array)) { $date_array[] = "$match[1]-$match[2]"; } } } fclose($fp); $base_file = basename($log_file); print "Your log file is being seperated. Please wait...\n"; foreach ($date_array as $month_year) { $fp = fopen($log_file, "r"); $nfp = fopen("$output_dir/$month_year-$base_file", "a"); while (!feof($fp)) { $buffer = fgets($fp, 1024); $date_part = explode("-", $month_year); if (preg_match("/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s.+\s.+\s\[[0-9]+\/$date_part[0]\/$date_part[1]/", $buffer, $match)) { fwrite($nfp, $buffer); } } fclose($nfp); } fclose($fp); $stop = time(); $uptime = $stop - $start; $day = floor($uptime/86400); $hour = floor(($uptime%86400)/3600); $min = floor(($uptime%3600)/60); $sec = ($uptime % 60); $time = "$day Day(s), $hour Hour(s), $min Min(s), $sec Sec(s)"; print "\n\nFinished!\n\nTotal Time: " . $time . "\n\n"; ?>
Syntax Highlighting
[
Open in new window
]
Author Comments
This is a full PHP Application that should only be ran through the Command Line Interface. It will split your log files by month. (Open Source)
Rating
4.45 / 8
478 Votes