<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 1.0.2

Copyright (C) 2006-2015  Sylvain FATOME
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.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr

Web : http://smi.no-ip.org
 ****************************************************************************************/

session_start();

require_once("../lib/gettext/gettext.inc");
include_once("../inc/config.inc.php");
include_once("../inc/fic_droits.inc.php");
include_once("../inc/func_log.inc.php");
if (CheckURLLog(FALSE) == FALSE) header("Location: ../index.php");
if (CheckNivLog("9") == FALSE) header("Location: ../index.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/lst.inc.php");
include_once("../classes/ezSQL/shared/ez_sql_core.php");
include_once("../classes/ezSQL/mysqli/ez_sql_mysqli.php");
include_once("../inc/func_sql.inc.php");

$_SESSION["typ_filtres"] = "flog";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>SMI - <?PHP echo _("ESPACE PRIVE"); ?> : <?PHP echo _("Liste Logs téléchargements"); ?></title>

    <?PHP include_once("../inc/header.inc.php"); ?>

    <script language="javascript">
        <!--
        var tab_champ = ["nom:date1f ; format:date ; req:Y ; txt:<?PHP echo _("Date de début"); ?> ; masque:<?PHP echo $_SESSION['date_fmtfull']; ?> ; stok:frmok ; stbad:frmbad",
            "nom:date2f ; format:date ; req:Y ; txt:<?PHP echo _("Date de fin"); ?> ; masque:<?PHP echo $_SESSION['date_fmtfull']; ?> ; stok:frmok ; stbad:frmbad"];
        //-->
    </script>

    <script type="text/javascript">
        <!--
        function init_datepicker() {
            $.datepicker.setDefaults({
                closeText: "<?PHP echo _("Fermer"); ?>",
                prevText: "<?PHP echo _("Précédent"); ?>",
                nextText: "<?PHP echo _("Suivant"); ?>",
                currentText: "<?PHP echo _("Aujourd'hui"); ?>",
                monthNames: ["<?PHP echo implode('","',$lng_tmoisf); ?>"],
                monthNamesShort: ["<?PHP echo implode('","',$lng_tmoism); ?>"],
                dayNames: ["<?PHP echo implode('","',$lng_tjourf); ?>"],
                dayNamesShort: ["<?PHP echo implode('","',$lng_tjourm); ?>"],
                dayNamesMin: ["<?PHP echo implode('","',$lng_tjours); ?>"],
                weekHeader: "<?PHP echo _("Sem."); ?>",
                dateFormat: "<?PHP echo $_SESSION['date_fmtshort']; ?>",
                firstDay: 1,
                isRTL: !1,
                changeMonth: true,
                changeYear: true,
                showMonthAfterYear: !1,
                yearSuffix: "",
                showButtonPanel: true,
                showOn: "both",
                buttonImageOnly: true,
                buttonImage: "../img/calendar.png",
                buttonText: "<?PHP echo _("Calendrier"); ?>"
            });
            $("#date1f").datepicker({
                onSelect: function (datesel) {
                    $("#date1f").blur();
                    chk_datedif(datesel, this.id, '<?PHP echo $_SESSION['date_fmtshort']; ?>', true, '', '', 'date2f',false);
                }
            });
            $("#date2f").datepicker({
                onSelect: function (datesel) {
                    $("#date2f").blur();
                    chk_datedif(datesel, this.id, '<?PHP echo $_SESSION['date_fmtshort']; ?>', true, 'date1f', '', 'today',false);
                }
            });
        }

        function init_all() {
            init_Body();
            init_autohref_classe('falselnkimg','');
            init_datepicker();
            init_autoraz('razdate1f','date1f','click');
            init_autoraz('razdate2f','date2f','click');
            init_valid_form('purge','log_purge','<?PHP echo $_SESSION['date_fmtshort']; ?>',tab_champ,'','');
            init_valid_form('purgea','log_purge','<?PHP echo $_SESSION['date_fmtshort']; ?>',tab_champ,'','');
            Focus_first();
        }

        $(document).ready(function () {
            init_all();
        });
        //-->
    </script>

</head>

<body>

<?php
include_once("../inc/entete.inc.php");
?>
<p align="center"><span class="titrepage"><?PHP echo _("LOGS TELECHARGEMENTS"); ?></span></p>
<?PHP
$fic_imp = "flog_lsti.php";

// Détermination du nombre total d'enregistrements
$db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

$rech = cree_strrechlstflog();
$rech .= crestr_triord($flog_titre_col, "ficlog_date", FALSE, $limitlog);

$rows = $db->get_results($rech, ARRAY_A);
$db->disconnect();

// *** Pagination d'entête
pagine_lst($numrows, $limit);

if ($rows) {
    include_once("../inc/formr.inc.php");

    $numrows = count($rows);

    $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST);

    $rech = modstr_triord($rech, $flog_titre_col, "ficlog_date", TRUE, $limitlog);

    $rows = $db->get_results($rech, ARRAY_A);

    // *** Pagination de pied
    pagine_lst($numrows, $limit);

    // *** Affichage de la table
    echo "<span class=\"annot_petit_it\">" . _("Cliquez sur les IP pour les détails.") . "</span>";
    echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";

    // création entête
    titlst($flog_titre_col);

    $i = 0;

    foreach ($rows as $row) {
        $row = encode_str($row);
        // création de l'entête de ligne (TR)
        creetrlst($i);

        echo "<td align=\"center\">" . datetolocal($row["ficlog_date"]) . "</td>\n";
        echo "<td align=\"center\">" . $row["ficlog_heure"] . "</td>\n";
        echo "<td align=\"center\">";
        $url_detlog = 'log_trace.php?ip='.$row["ficlog_ip"];
        echo $row["ficlog_ip"];
        cre_falselnk_img('', 'det_ip_'.$row["ficlog_id"], 'span', 'center', _("Détail"), 'lnkpop', $url_detlog , '../img/eye.png',1024,600);
        echo "</td>\n";
        echo "<td>" . $row["ficlog_ref"] . "</td>\n";
        echo "<td>" . $row["ficlog_fic"] . "</td>\n";
        echo "<td align=\"center\">";
        echo $typ_flog[intval($row["ficlog_type"])];
        echo "</td>\n";

        echo "</tr>\n";

        $i++;
    }
    echo "</table>\n";
    // *** Fin affichage de la table

    $db->disconnect();

    // *** Pagination de pied
    pagine_lst($numrows, $limit);

    $taille_piedla = "";
    include_once("../inc/piedla.inc.php");
} else
    retpp();

if ($numrows > 0) {
    ?>
    <!-- Permet de purger des logs sur une fourchette de dates -->
    <form name="log_purge" id="log_purge" method="post" action="flog_enr.php?td=del">
        <input name="today" type="hidden" id="today" value="<?PHP echo $datef; ?>">
        <p align="center" class="titre_gras_soul"><?PHP echo _("PURGE DES LOGS"); ?></p>
        <table width="400" border="0" align="center">
            <tr>
                <td width="30" class="rubfrm" id="f_date1f" align="right"><?PHP echo _("Du"); ?>...</td>
                <td>
                    <input name="date1f" type="text" id="date1f" size="10" maxlength="10" readonly>
                     <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
                     <img src="../img/raz.png" id="razdate1f" border="0" align="absmiddle">
                </td>
                <td width="30" class="rubfrm" id="f_date2f" align="right"><?PHP echo _("Au"); ?>...</td>
                <td>
                    <input name="date2f" type="text" id="date2f" size="10" maxlength="10" readonly>
                     <img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo _("Champ obligatoire"); ?>">
                     <img src="../img/raz.png" id="razdate1f" border="0" align="absmiddle">
                </td>
            </tr>
        </table>
        <p align="center">
            <input name="purge" type="button" class="bton_std" id="purge" value="<?PHP echo _("Purger"); ?>">
            <input name="purgea" type="button" class="bton_std" id="purgea" value="<?PHP echo _("Tout Purger"); ?>">
        </p>
    </form>
<?php
}
include_once("pied.php");
?>
</body>

</html>