PHP Classes

File: log.consult.php

Recommend this page to a friend!
  Classes of Johan Barbier   Logger class oLogger   log.consult.php   Download  
File: log.consult.php
Role: Example script
Content type: text/plain
Description: Exemple
Class: Logger class oLogger
Generate and process logs files in XML format
Author: By
Last change:
Date: 17 years ago
Size: 5,481 bytes
 

Contents

Class file image Download
<?php
require_once 'class/class.oLogger.php';

/**-----------------------------------------------------------------------------
 * Check Param and assign default values
 */

$oLogger = new oLogger;

if (!isset (
$_POST['ordID'])) {
   
$_POST['ordID'] = 0;
}
if (!isset (
$_POST['ordDAY'])) {
   
$_POST['ordDAY'] = 0;
}
if (!isset (
$_POST['nom'])) {
   
$_POST['nom'] = '-1';
}
if (!isset (
$_POST['jour'])) {
   
$_POST['jour'] = '';
}
if (isset (
$_POST['toDelete']) && !empty ($_POST['toDelete'])) {
    @
unlink ('logs/'.$_POST['toDelete']);
}
$ordID = (1 == $_POST['ordID'])?true:false;
$oLogger -> getaDir ($ordID);

$sOutput = $sNomSelect = $sSearchContext = $sDaySelect = '';
$aDays = $aUsers = array ();

foreach (
$oLogger -> aDir as $clef => $val) {
   
/*
    if ($clef != 0) {
        $sQuery = 'SELECT dest_nom FROM destinataires WHERE dest_id = '.$clef;
        $oDB -> query ($sQuery);
        $aRes = $oDB -> fetch_assoc ();
        $nomUser = $aRes['dest_nom'];
    } else {
        $nomUser = 'unknown';
    }
    */
   
$nomUser = $clef;
    if (!empty (
$val)) {
       
$aUsers[$clef] = $nomUser;
    }
    if (
'-1' != $_POST['nom'] && $clef != $_POST['nom']) {
        continue;
    }
   
sort ($val, SORT_NUMERIC);
    if (
$_POST['ordDAY'] == 1) {
       
$val = array_reverse ($val);
    }
    foreach (
$val as $file) {
       
$myDay = substr ($file, 0, -4);
        if (!empty (
$_POST['jour']) && $myDay != $_POST['jour']) {
            continue;
        }
       
$aDays[] = $myDay;
       
$sOutput .= <<<HTML
<tr>
            <td>
$clef</td>
            <td>
{$nomUser}</td>
            <td><a href="javascript:go('
$clef/$file');">$file</a></td>
            <td><a href="javascript:suppr('
$clef/$file');">Supprimer</a></td>
        </tr>
HTML;
    }
}

$sNomSelect .= '<select name="noms" onchange="filtreNom (this.value);">';
$sNomSelect .= '<option value="-1">TOUS UTILISATEURS</option>';
if (!empty (
$aUsers)) {
   
asort ($aUsers, SORT_STRING);
    foreach (
$aUsers as $clef => $nomUser) {
       
$selected = ($_POST['nom'] == $clef)?'selected="selected"':'';
       
$sNomSelect .= '<option value="'.$clef.'" '.$selected.'>'.$nomUser.'</option>';
    }
}
$sNomSelect .= '</select>';

$sDaySelect .= '<select name="jours" onchange="filtreJour (this.value);">';
$sDaySelect .= '<option value="">TOUS LES JOURS</option>';
if (!empty (
$aDays)) {
   
$aDays = array_unique ($aDays);
   
sort ($aDays, SORT_NUMERIC);
    foreach (
$aDays as $day) {
       
$selected = ($_POST['jour'] == $day)?'selected="selected"':'';
       
$sDaySelect .= '<option value="'.$day.'" '.$selected.'>'.$day.'</option>';
    }
}
$sDaySelect .= '</select>';


$appPath = "Gestion / Logs / Consultation /";
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Template site logistique</title>
<link rel="stylesheet" href="css/main.css" />
<style type="text/css">
/* local style */
</style>
<script language="Javascript" type="text/javascript">
function go (f) {
    with (document.getElementById('hid')) {
        action='log.detail.php';
        fichier.value = f;
        submit ();
    }
}
function suppr (f) {
    with (document.getElementById('hid')) {
        action='log.consult.php';
        toDelete.value = f;
        submit ();
    }
}

function filtreNom (n) {
    with (document.getElementById('hid')) {
        action='log.consult.php';
        nom.value = n;
        submit ();
    }
}

function filtreJour (j) {
    with (document.getElementById('hid')) {
        action='log.consult.php';
        jour.value = j;
        submit ();
    }
}

function sortID () {
    with (document.getElementById('hid')) {
        action='log.consult.php';
        ordID.value = (ordID.value == 1)?0:1;
        submit ();
    }
}

function sortDAY () {
    with (document.getElementById('hid')) {
        action='log.consult.php';
        ordDAY.value = (ordDAY.value == 1)?0:1;
        submit ();
    }
}

function _blank () {
    with (document.getElementById('hid')) {
        action='log.consult.php';
        nom.value = -1;
        jour.value = '';
        submit ();
    }
}
</script>
</head>

<body>

<div id="main">
<div id="search">
        <h3>Search</h3>
        <form id="hid" action="" method="post">
        <label for="types">Nom Utilisateur</label>
        <?php echo $sNomSelect; ?>
<label for="jours">Journées</label>
        <?php echo $sDaySelect; ?>
<input type="hidden" name="fichier" value="" />
        <input type="hidden" name="toDelete" value="" />
        <input type="hidden" name="ordID" value="<?php echo $_POST['ordID']; ?>" />
        <input type="hidden" name="ordDAY" value="<?php echo $_POST['ordDAY']; ?>" />
        <input type="hidden" name="nom" value="<?php echo $_POST['nom']; ?>" />
        <input type="hidden" name="jour" value="<?php echo $_POST['jour']; ?>" />
        </form>
        <br />
        <br />
        <center><input type="button" value=" Annuler " onclick="_blank('hid');" class="bt" style="cursor:pointer;"/></center>
        <br />
    </div>
    <div id="cont">
        <!-- START:search module -->
        <div id="asearch">
            <span class="context"><?php echo $sSearchContext;?></span>
        </div>
        <div id="path"><?php echo $appPath; ?></div>
        <!-- END:search module -->
        <table class="result" cellpadding="0" cellspacing="0">
            <th colspan="4">Liste des logs</th>
            <tr>
                <td style="width: 50px;"><div class="title"><a href="javascript:sortID ();">#ID</a></div></td>
                <td style="width: 150px;"><div class="title">NOM</div></td>
                <td style="width: 250px;"><div class="title"><a href="javascript:sortDAY ();">FICHIER</a></div></td>
                <td style="width: 50px;"><div class="title">ACTION</div></td>
            </tr>
                <?php echo $sOutput; ?>
</table>
    </div>
</div>