PHP Classes

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Janne  >  PHP Apache Log Parser and Filter  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: This is a example PHP/HTML-page for using the classes
Class: PHP Apache Log Parser and Filter
Parse and filter Apache logs to discard crawlers
Author: By
Last change: Added the possibility to upload access log as file. Also added the functionality for pre-defined filters, that work with javascript - can be toggled on or off.
Date: 2 years ago
Size: 1,732 bytes


Class file image Download

include_once 'classes/ApacheAccessLogFilter.php';

$source = $_POST['pastedLog'] ? $_POST['pastedLog'] : $_FILES["file"];

$mysqli = new mysqli("localhost", "ip2nUser", "password", "ip2nDatabase");
$ip2nation = new Ip2Nation($mysqli);

$accessLogStr = new ApacheAccessLogFilter($source, explode(",", $_POST['needles']), $ip2nation);


        <link href="css/ALogFilter.css" rel="stylesheet" type="text/css" />
        <br />Needles used were:<br /><?= $accessLogStr->showNeedles(); ?>
        These are the results for parsing:
        <br />
        <?= $accessLogStr; ?>
    Or plain (please note that there can be restrictions to the size of text pasted here):
    <form action="" method="POST" enctype="multipart/form-data">
            <br />
            <?= $debugger->apacheLogClass->allButtons("<br />"); ?>
<br />
            <input type="text" name="needles" id="usingNeedles" />
            Submit access log as file:
            <input type="file" name="file" id="file">
            <br />
            Or paste access log here:
            <br />
            <textarea name='pastedLog' style="width:1200px;height:400px"></textarea>
            <br />
            <input type='submit' value="submitForm">
    <script src="js/ALogFilter.js"></script>
        <?= $debugger->apacheLogClass->defNeedlesAsJs(); ?>
needles = new Needles();