Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, March 29, 2024

File: [Platon] / phpWebLogAnalyzer / test.php (download)

Revision 1.20, Fri May 27 16:30:34 2005 UTC (18 years, 10 months ago) by nepto


Changes since 1.19: +4 -4 lines

Updated copyright year, e-mail address and URL.

<?php

/*
 * phpWebLogAnalyzer - powerful weblog and analyzer
 *
 * test.php - testing script
 * ____________________________________________________________
 *
 * Developed by Ondrej Jombik <nepto@platon.sk>
 * Copyright (c) 2001-2005 Platon SDG, http://platon.sk/
 * All rights reserved.
 *
 * See README file for more information about this software.
 * See COPYING file for license information.
 *
 * Download the latest version from
 * http://platon.sk/projects/phpWebLogAnalyzer/
 */

/* $Platon: phpWebLogAnalyzer/test.php,v 1.19 2003/01/27 00:58:49 nepto Exp $ */

function get_mtime()
{
    $mtime = microtime();
    $mtime = explode(" ", $mtime);
    $mtime = $mtime[1] + $mtime[0];

    return $mtime;
}

$start_time = get_mtime();

// this function will handle all errors reported by PHP
function php_error_handler($errno, $errstr, $errfile, $errline)
{
    echo "<table bgcolor=lightblue>";
    echo "<tr><th colspan=2>";
    echo "An error occured";
    echo "</th></tr>";

    foreach(array(
                'file' => $errfile,
                'line' => $errline,
                'code' => $errno,
                'message' => $errstr)
            as $key => $val) {

        echo "<tr><td align=left valign=top>";
        echo "<b>".htmlspecialchars($key)."</b>";
        echo "</td><td>";
        echo nl2br(htmlspecialchars($val));
        echo "</td></tr>";
    }

    die();
}

function pear_error_handler($err_obj)
{
    $error_string = $err_obj->getMessage() . "\n" . $err_obj->getDebugInfo();
    trigger_error($error_string, E_USER_ERROR);
}

error_reporting (E_ALL ^ E_NOTICE);
set_error_handler('php_error_handler');

require_once './phpWebLogAnalyzer.inc.php';
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'pear_error_handler');

#
# Object creation
#

$weblog = new Web_Log('mysql://test:test@localhost/test');

#
# Web log object configuration
#

$weblog->enableTruncateNames();
$weblog->enableRawLog();
//$weblog->disableRawLog();
$weblog->enablePropertyCache('remote_host');

#
# Registering access
# (in following `if' use 1 for normal log, 0 for remote log)
#

if (1) {
    //$weblog->disableProperty('session_id');
    $weblog->registerAccess(3);
    echo '<hr>Session ID: '.$weblog->getPropertyValue('session_id').'<br>';

    if (0) {
        $weblog->enableRawLog();
        echo("<hr>Raw session count: "
                . $weblog->getSessionsCount()
                . "<br>");
        $weblog->disableRawLog();
        echo("<hr>Normal session count: "
                . $weblog->getSessionsCount()
                . "<br>");

        $weblog->enableRawLog();
        echo "<hr>Raw active sessions: ";
        $active_sessions = $weblog->getActiveSessions();
        var_dump($active_sessions);
        echo "<br>";

        $weblog->disableRawLog();
        echo "<hr>Normal active sessions: ";
        $active_sessions = $weblog->getActiveSessions();
        var_dump($active_sessions);
        echo "<br>";
    }

} else  {
    echo '<hr>Remote log: ';
    $ret = $weblog->remoteLog('http://maxim.platon.sk/~ondrej/development/phpWebLogAnalyzer/utils/remote-log.php');
    if (PEAR::isError($ret)) {
        echo $ret->getMessage();
    } else {
        echo 'OK';
    }
}

#
# Processing time counting
#

echo("<hr>Processing time: ".sprintf("%.2f", get_mtime() - $start_time));

#
# Debug information printing
#

$debug = isset($HTTP_GET_VARS['debug']) ? $HTTP_GET_VARS['debug'] : 0;
if (intval($debug) > 0) {
    ob_start();
    var_dump($weblog->_props);
    $contents = ob_get_contents();
    ob_end_clean();
    echo '<hr><pre>';
    echo htmlspecialchars($contents);
    echo '</pre>';
}

#
# Navigation links
#

echo("<hr>Click <a href=\"$PHP_SELF\">here</a> to get HTTP refferer work.");
echo("<br>Click <a href=\"$PHP_SELF?debug=1\">here</a> to get <code>var_dump()</code> of all variables.");

#
# Object destroying
#

$weblog->destroy();

?>

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top