Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 0 years ago
Size: 1,732 bytes
 

Contents

Class file image Download
<?php

include_once 'classes/ApacheAccessLogFilter.php';
include_once 
'classes/ip2Nation.php';

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

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

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

$accessLogStr->filterAll();

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