<?php
######################################################################
# ZW3B.Site v7.1.2 : The Web Sites Management System
# --------------------------------------------------------------------
#
# Copyright (c) 2021 by LAB3W : O.Romain Jaillet-ramey - (orj@lab3w.fr)
#
# Date Create : 2021/01/22
# Date Modify : 2021/01/22
#
# Web Site : http://www.lab3w.fr
# Web Site : http://www.lab3w.com
#
# Web Site : http://zw3b.fr
# Web Site : http://zw3b.tv
# Web Site : http://zw3b.site
# Web Site : http://zw3b.net
# Web Site : http://zw3b.blog
#
# This module is to manage ---------------------------- :: Descripton
#
# 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.
######################################################################

//----------------------------------------------------------------
// Systeme de cache

# On cache
#header("Cache-Control: max-age=300");
#header("Pragma: cache, max-age=300, max-stale=600");

# No cache
header("Cache-control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");

// Systeme de cache
//----------------------------------------------------------------


$website[] = 'www.zw3b.fr';
$website[] = 'howto.zw3b.fr';
$website[] = 'radio.zw3b.fr';
$website[] = 'api.zw3b.fr';
$website[] = 'download.zw3b.fr';
$website[] = 'www.zw3b.tv';
$website[] = 'www.zw3b.net';
$website[] = 'www.zw3b.site';
$website[] = 'www.zw3b.blog';

$website[] = 'www.lab3w.fr';
$website[] = 'admin.lab3w.fr';

$year = isset($_GET['y']) && !empty($_GET['y']) ? $_GET['y'] : date('Y');

$month 'all';



function 
awstats_resume($website$year$month null) {

    
$month = isset($month) ? $month 'all';

    
$directoryTmp '/var/pro/web_sites/lab3w_fr/admin/awstats/';
    
$file_year $website.'-'.$year;
    
$file 'awstats_'.$file_year.'.php';
    
$secondes '1800'// 30min
    /*
    echo '<br/>COURANT : '.mktime();
    echo '<br/>MODIFIE&nbsp;&nbsp; : '.filemtime($directoryTmp.$file).'';
    echo '<br/>LE CALCUL&nbsp;&nbsp; : '.((filemtime($directoryTmp.$file) + $secondes) - mktime()).'';
    echo '<br/>A MODIF&nbsp;&nbsp; : '.(filemtime($directoryTmp.$file) + $secondes).'';

    echo '<br/>'.$directoryTmp.$file;
    */

    
if( (filemtime($directoryTmp.$file) + $secondes) <= mktime()) {
        
//echo '<br/>'.'On reecrit le fichier';

    //exit;

    
$url ='http://www.zw3b.fr/pub/AWStats/awstats.pl?framename=mainright&month='.$month.'&year='.$year.'&output=main&config='.$website.'';
    
$contents file_get_contents($url);

    if(isset(
$contents) && !empty($contents)):
    if(
preg_match_all("/.{1,$s}(?=\W+)/"$contents$lines) !== false) {

        
$result['config']['caption'] = 'Awstats';
        
$result['config']['value'] = $website;

        
$find_log false;

        
$find_report false;
        
$line_report null;

        
$find_stats false;
        
$line_stats null;

        for (
$i=0$i count($lines[0]); $i++) {


            if(
$find_report == false && preg_match("/Reported period/"$lines[0][$i], $matches)) {
                
//echo '<br/>LINE Reported period '.$i;

                
$find_log true;

                
//$find_report = true;
                
$line_report $i;

                
preg_match_all("/(.*)<\/td>/Ui"$lines[0][$i], $period);

                
$result['period']['caption'] = trim(str_replace(array('<tr bgcolor="#ECECEC">''<td class="aws">'), ' '$period[1][0]));

            }

            if(
$line_report !== null) {

                
preg_match_all("/(.*)<\/td>/Ui"$lines[0][($line_report+1)], $title);

                
$result['period']['value'] = trim($title[1][0]);

                
//echo '<br/><br/>LINE report value == '.$line_report.' <pre>'.print_r($lines[0][($line_report+1)],1).'</pre><hr/>';

                
$line_report null;
            }

            if(
$find_stats == false && preg_match("/Unique visitors/"$lines[0][$i], $matches)) {
                
//echo '<br/>LINE STATS '.$i;

                
$find_stats true;
                
$line_stats $i;

                
preg_match_all("/<td(.*)>(.*)<\/td>/Ui"$lines[0][$i], $caption);

                
$result['UV']['caption'] = trim($caption[2][1]);
                
$result['NV']['caption'] = trim($caption[2][2]);
                
$result['P']['caption'] = trim($caption[2][3]);
                
$result['H']['caption'] = trim($caption[2][4]);
                
$result['B']['caption'] = trim($caption[2][5]);

            }

            if(
$line_stats !== null) {

                
preg_match_all("/<td(.*)>(.*)<\/td>/Ui"$lines[0][($line_stats+1)], $value);

                
$pattern = array('<br />''<b>''</b>''\'''<td>''</td>''&lt;= ''Exact value not available in &apos;Year&apos; view');
                
$replace = array(' ''''''&apos;''''''''');

                
$value[0][1] = trim(str_replace($pattern$replace$value[0][1]));
                
$result['UV']['value'] = explode(' '$value[0][1]);

                
$value[0][2] = trim(str_replace($pattern$replace$value[0][2]));
                
$result['NV']['value'] = explode(' '$value[0][2]);

                
$value[0][3] = trim(str_replace($pattern$replace$value[0][3]));
                
$result['P']['value'] = explode(' '$value[0][3]);

                
$value[0][4] = trim(str_replace($pattern$replace$value[0][4]));
                
$result['H']['value'] = explode(' '$value[0][4]);

                
$value[0][5] = trim(str_replace($pattern$replace$value[0][5]));
                
$result['B']['value'] = explode(' '$value[0][5]);

                
$line_stats null;
            }


            
//echo "[$i] {$lines[0][$i]}\n";
        
}


        
# ICI je met à jour le fichier PHP, seulement si c'est l'année actuelle
        # remplacer date('Y') par '2020' pour enregistrer une seule fois toutes les stats de l'année 2020 etc.
        
if($find_log == true && isset($result) && is_array($result) && $year == date('Y') )
            
awstats_resume_write($result$year);

        }
    

        endif;

        return isset(
$result) ? $result null;


    }


}



function 
awstats_resume_write($result$year null) {

    
$year = isset($year) && !empty($year) ?$year date('Y');

    
$directoryTmp '/var/pro/web_sites/lab3w_fr/admin/awstats/';

    
$website $result['config']['value'];

    
$file_year $result['config']['value'].'-'.$year;

    
//echo '<br/>Le fichier <code>'.$directoryTmp.'awstats_'.$file_year.'.php</code>';
    //if(!file_exists($directoryTmp.'awstats_'.$file_year.'.php'))
    
{

    
$write '<?php'."\n";

    
$write.= '/********************************************************************'."\n";
    
$write.= ' *'."\n";
    
$write.= ' * WebSite : '.$website.''."\n";
    
//$write.= ' * Generator : '.($this->config['apps']['conf']['title']).' v'.$this->config['apps']['conf']['vs'].''."\n";
    
$write.= ' * Description : Statistiques Annuelle (AWStats)'."\n";
    
$write.= ' * File : awstats_'.$file_year.'.php'."\n";
    
$write.= ' * Date : '.date('Y/m/d H:i:s')."\n";
    
$write.= ' *'."\n";
    
$write.= ' ************************************/'."\n\n";

    
$write.= '// STATS -----------------------------------------------------------'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'config\'][\'caption\'] = \''.$result['config']['caption'].'\';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'config\'][\'value\'] = \''.$result['config']['value'].'\';'."\n";

    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'period\'][\'caption\'] = \''.$result['period']['caption'].'\';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'period\'][\'value\'] = \''.$result['period']['value'].'\';'."\n";

    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'UV\'][\'caption\'] = \''.$result['UV']['caption'].'\';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'UV\'][\'value\'] = '.var_export($result['UV']['value'],1).';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'NV\'][\'caption\'] = \''.$result['NV']['caption'].'\';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'NV\'][\'value\'] = '.var_export($result['NV']['value'],1).';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'P\'][\'caption\'] = \''.$result['P']['caption'].'\';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'P\'][\'value\'] = '.var_export($result['P']['value'],1).';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'H\'][\'caption\'] = \''.$result['H']['caption'].'\';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'H\'][\'value\'] = '.var_export($result['H']['value'],1).';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'B\'][\'caption\'] = \''.$result['B']['caption'].'\';'."\n";
    
$write.= '$result[\''.$website.'\'][\''.$year.'\'][\'B\'][\'value\'] = '.var_export($result['B']['value'],1).';'."\n";

    
$write.= '//------------------------------------------------------------------'."\n\n";

    
$write.= "\n".'?>';

    if( 
file_exists($directoryTmp.'awstats_'.$file_year.'.php') ) {
        
//echo ' existe ';
        
$fp = @fopen($directoryTmp.'awstats_'.$file_year.'.php'"w+");
    } else {
        
//echo ' n\'existe pas ';
        //echo ' ---> on le cree (true)';
        
$fp = @fopen($directoryTmp.'awstats_'.$file_year.'.php'"x+");
    }

    
//echo ' ---> on ecrit';
    //echo fputs($fp, $write) ? ' (true)<br/>' : ' (false)<br/>';

    
@fputs($fp$write);

    @
fclose($fp);

    @
chmod($directoryTmp.'awstats_'.$file_year.'.php'octdec("664")); //exit;
    
@chgrp($directoryTmp.'awstats_'.$file_year.'.php'"1000"); //exit;

    
}

}


function 
awstats_resume_read_file($website) {

    
$directoryTmp '/var/pro/web_sites/lab3w_fr/admin/awstats/';
    
$dirhandle opendir($directoryTmp);

    while((
$file = @readdir($dirhandle)) !== false)
    {
        if ((
$file != '.') && ($file != '..') && (substr("$file"01) != '.'))
        {
            
$currentfile $directoryTmp.''.$file;
            
$currentfilefake '/'.$file;


            if (
filetype($currentfile) != 'dir' && preg_match("/awstats_".$website."/Ui"$currentfile$match))
            {
                include 
''.$currentfile;

                
//echo $currentfile.'<br/>';
            
}

        }

    }

    
asort($result[$website], SORT_REGULAR);
    
krsort($result[$website]);

    return isset(
$result) ? $result null;

}

//$awstats = awstats_resume_read_file('www.zw3b.fr');

//echo '<pre>'.print_r($awstats,1).'</pre>';


//$awstats =  awstats_resume('admin.lab3w.fr', '2020', $month = null);
#$awstats =  awstats_resume('download.zw3b.fr', '2013', $month = null);
#echo '<pre>'.print_r($awstats,1).'</pre>';
#exit;


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="fr">
<head>
<title>ZW3B :-: AWStats &copy; LAB3W</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<meta property="og:type"          content="website" />
<meta property="og:title"         content="ZW3B :-: AWStats &copy; LAB3W" />
<meta property="og:description"   content="ZW3B :-: Resume AWStats &copy; LAB3W : Web and networks laboratory - InterNet engineering" />
<meta property="og:url"           content="//<?=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>" />
<meta property="og:image"         content="//www.zw3b.fr/pub/awstats.gif" />

<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<meta name="Robots" content="index, follow" />
<meta name="Rating" content="General" />
<meta name="Distribution" content="Global" />
<meta name="Audience" content="all" />
<meta name="Revisit-after" content="1 days" />
<meta name="Title" content="ZW3B :-: AWStats &copy; LAB3W" />
<meta name="Description" content="ZW3B :-: Resume AWStats &copy; LAB3W : Web and networks laboratory - InterNet engineering" />
<meta name="Copyright" content="ZW3B" />
<meta name="Owner" content="LAB3W" />
<meta name="Author" content="O.Romain.Jaillet-ramey" />
<meta name="Reply-to" content="staff AT zw3b DOT fr" />
<meta name="Generator" content="A la mano ;p" />
<meta name="DC.Date.created" scheme="W3CDTF" content="2021-01-22" />
<meta name="DC.Date.modified" scheme="W3CDTF" content="2021-01-22" />
<meta name="Keywords" content="zw3b, lab3w, orj, kss, o.romain.jaillet-ramey" />
<meta http-equiv="Refresh" content="300" />
<meta name="Viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=yes, width=device-width" />
<meta name="Theme-color" content="#565656" />
<link rel="shortcut icon" href="//www.zw3b.fr/pub/logos/zw3b-logo-20x20.png" />
<!-- <link href="global.css" rel="stylesheet" type="text/css" /> -->
<style type="text/css">
html, body {
    font-family:Tahoma, Arial, sans-serif;
    font-size:12px;
    color:#000;
    text-align:left;
    background-color:#FFF;
    margin:0;
    padding:0 10px;
    background-image:url('zw3b-v5.8-background-default.png');
    backgrouund-repeat:repeat;
    background-position:center center;
}
h1, h2, h3, h4, h5, h6 {
    padding:0;
    margin:0;
    color:#565656;
    font-family:Impact, Tahoma, Arial, sans-serif;
    font-weight:normal;
    text-transform: none;
}

h1 {
    font-size: 30px;
}
h1 a {
    text-decoration:none;
    color:#565656;
}
h1 a:hover {
    color:#000;
}
h2 {
    margin-bottom:20px;
    text-transform:none;
}

a {
    color: #565656;
    text-decoration: none;
}
a:visited {
   color: #565656;
}
a:hover, a.active {
    color: #000;
}

.hidden {
    display: none;
}

p {
    clear: both;
}

div.awstats.body {
    border: 1px solid #565656;
    margin: 0;
    margin-bottom: 10px;
}

div.awstats.body h3 {
    margin: 0;
    padding: 5px 10px;
    background-color: #565656;
    color: #EEE;
}
div.awstats.body h3 a {
    color: #EEE;
    text-decoration: none;
}
div.awstats.body h3 a:hover {
    color: #FFF;
}

div.awstats.year {

}

div.awstats.data {
    padding: 10px;
}

div.awstats ul {
    min-height: 30px;
    margin: 0;
    margin-left: 10px;
    padding: 0;
}
div.awstats ul li {
    list-style-type: none;
    float: left;
    display: block;
    padding: 0;
    margin: 0;
    margin-bottom: 5px;
    border: 1px solid #565656;
}
div.awstats ul li a {
    display: block;
    padding: 5px 10px;
}
div.awstats ul li a:hover {
    background-color: #EEE;
}
div.awstats ul li a.active {
    background-color: #565656;
    color: #FFF;
}

div.awstats.global {
    background-color: #565656;
    color: #FFF;
    margin: auto 20%;
    padding: 1px 10px;
    border: 1px solid #565656;
}
div.awstats.logo {
    float: right;
    background-image: url("awstats.gif");
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    width: 110px;
    height: 70px;
    margin-top: -83px;
    border: 1px solid #D116B6;
    cursor: pointer;
}
div.awstats.logo {
    text-indent: -10000px;
}
ul#zw-foot-lnk {
    list-style-type: none;
    margin: 10px auto;
    padding-left: 0;
    width:auto;
    color: #EEEEEE;
    font-weight: normal;
    text-align: center;
    margin-top:50px;
    margin-bottom:100px;
}
ul#zw-foot-lnk li {
    float: left;
    margin-left: 5px;
    margin-right: 5px;
}

ul#zw-foot-lnk li a {

    font-size: 12px;
    font-weight: normal;
}
</style>

<!--
<script src="/lib/jquery/jquery.1.9.1.min.js" type="text/javascript"></script>
<script src="/lib/jquery/jquery-ui.min.js" type="text/javascript"></script>
-->

<script
      src="https://code.jquery.com/jquery-1.12.4.min.js"
      integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
      crossorigin="anonymous"></script>

<script
      src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"
      integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E="
      crossorigin="anonymous"></script>

<script type="text/javascript">
function zw3bAWStats() {

    //console.log( 'zw3bAWStats' );

    var ancre = '';
    if(window.location.hash) {
        var ancre = window.location.hash;
        ancre = ancre.substring(1);
    }

    $('ul#aws_years').delegate("li a", "click", function(e) {

      var ancre = $(this).attr('href');
      ancre = ancre.substring(1);

          if(e.type == 'click')
          {

            if( $(this).hasClass('active') )  {

                console.log( 'class active' );

            } else {

                if(ancre == "all")
                {
                    $(this).parent().parent().children().children().removeClass('active');

                    $(this).addClass('active'); // longket

                    $('div.awstats.year ul li a').removeClass('active'); // autre onglets
                    $('div.awstats.year ul li a.'+ancre).addClass('active'); // autre onglets

                    console.log( $(this) );

                    $('div.awstats.data').addClass('hidden');
                    $('div.awstats.data.'+ancre).removeClass('hidden');

                } else {
                    //console.log( $(this).parent().parent().children().children() );
                    $(this).parent().parent().children().children().removeClass('active');

                    $(this).addClass('active'); // longlet
                    $('div.awstats.year ul li a').removeClass('active'); // autre onglets
                    $('div.awstats.year ul li a.'+ancre).addClass('active'); // autre onglets

                    $('div.awstats.data').addClass('hidden');
                    $('div.awstats.data.'+ancre).removeClass('hidden');

                }
            }
            return false;
          }

    });

}



$(document).ready(function(){

    zw3bAWStats();

});

</script>


</head>
<body>
<?php


foreach($website as $k => $site):

$awstats[] = awstats_resume($site$year);

//awstats_resume_write($awstats[$k], $year);

endforeach;


echo 
'<h1><a href="//www.zw3b.fr" title="ZW3B : The Web XXI">ZW3B</a> :-: AWStats &copy; <a href="//www.lab3w.fr" title="LAB3W : Web and networks laboratory - InterNet engineering">LAB3W : Web and networks laboratory - InterNet engineering</a></h1>';

echo 
'<h2>AWstats :-: Resume Analyser Statistics logs files</h2>';


$directoryTmp '/var/pro/web_sites/lab3w_fr/admin/awstats/';
$file_year 'www.zw3b.fr-2021';
$filename $directoryTmp.'awstats_'.$file_year.'.php';

$date "" date("l, F d, Y \a\\t H:i:s."filemtime($filename));

echo 
'<p>';
echo 
'Changed <strong>AWStats</strong> generated <strong>on '.$date.'</strong>';
echo 
'</p>';

foreach(
$website as $k => $site):

    
$awstats awstats_resume_read_file($site);

    echo 
'<div class="awstats body">';

        echo 
'<h3>Web Site : <a href="//'.$site.'" title="Access to '.$site.'">http(s)://'.$site.'</a></h3>'."\n";

        
// menu ---------------------------------------------------------------------------------------
        
echo '<div class="awstats year">';
        echo 
'<ul id="aws_years">';

        echo 
'<li>';
        echo 
'<a href="#all "class="all">ALL</a>';
        echo 
'</li>';

        foreach(
$awstats[$site] as $key => $stats) {
            
$class $key == $year 'active' 'default';

            echo 
'<li>';
            echo 
'<a href="#'.$key.'" class="'.$key.' '.$class.'">'.$key.'</a>';
            echo 
'</li>';
        }

        echo 
'</ul>';
        echo 
'</div>';
        
// menu ---------------------------------------------------------------------------------------

        // alls years ----------------------------------------------------------------------------------
        // on fait les calculs pour avoir les stats globales

        
foreach($awstats[$site] as $key => $stats) {
            
//$awstats[$site]['all']['UV']['caption'] = $stats['UV']['value'][0];

            
$valeur[$site]['UV'] = isset($valeur[$site]['UV']) ? $valeur[$site]['UV'] : 0;
            
$valeur[$site]['NV'] = isset($valeur[$site]['NV']) ? $valeur[$site]['NV'] : 0;
            
$valeur[$site]['P'] = isset($valeur[$site]['P']) ? $valeur[$site]['P'] : 0;
            
$valeur[$site]['H'] = isset($valeur[$site]['H']) ? $valeur[$site]['H'] : 0;
            
$valeur[$site]['B'] = isset($valeur[$site]['B']) ? $valeur[$site]['B'] : 0;

            
$awstats[$site]['all']['period']['caption'] = $stats['period']['caption'];
            
$awstats[$site]['all']['period']['value'] = (isset($awstats[$site]['all']['period']['value']) ? $awstats[$site]['all']['period']['value'] : null).' '.$stats['period']['value'];

            
$stats['UV']['value'][0] = str_replace(','''$stats['UV']['value'][0]);
            
$valeur[$site]['UV'] = ($valeur[$site]['UV'] + $stats['UV']['value'][0]);
            
$awstats[$site]['all']['UV']['caption'] = $stats['UV']['caption'];
            
$awstats[$site]['all']['UV']['value'][0] = $valeur[$site]['UV'];

            
$stats['NV']['value'][0] = str_replace(','''$stats['NV']['value'][0]);
            
$valeur[$site]['NV'] = ($valeur[$site]['NV'] + $stats['NV']['value'][0]);
            
$awstats[$site]['all']['NV']['caption'] = $stats['NV']['caption'];
            
$awstats[$site]['all']['NV']['value'][0] = $valeur[$site]['NV'];

            
$stats['P']['value'][0] = str_replace(','''$stats['P']['value'][0]);
            
$valeur[$site]['P'] = ($valeur[$site]['P'] + $stats['P']['value'][0]);
            
$awstats[$site]['all']['P']['caption'] = $stats['P']['caption'];
            
$awstats[$site]['all']['P']['value'][0] = $valeur[$site]['P'];

            
$stats['H']['value'][0] = str_replace(','''$stats['H']['value'][0]);
            
$valeur[$site]['H'] = ($valeur[$site]['H'] + $stats['H']['value'][0]);
            
$awstats[$site]['all']['H']['caption'] = $stats['H']['caption'];
            
$awstats[$site]['all']['H']['value'][0] = $valeur[$site]['H'];

            
$awstats[$site]['all']['B']['caption'] = $stats['B']['caption'];
            
$awstats[$site]['all']['B']['value'][0] = 'todo';

            
//echo ''.str_replace(',', '', $stats['UV']['value'][0]).' + ';

            //echo '<br/>'.$valeur['UV'];

        
}

        
$awstats[$site]['all']['period']['value'] = str_replace('Year '''$awstats[$site]['all']['period']['value']);
        
$awstats[$site]['all']['period']['value'] = explode(' '$awstats[$site]['all']['period']['value']);
        
asort($awstats[$site]['all']['period']['value']);
        
$awstats[$site]['all']['period']['value'] = 'Years '.implode(' '$awstats[$site]['all']['period']['value']);


        
$awstats[$site]['all']['UV']['value'][0] = number_format($awstats[$site]['all']['UV']['value'][0], 0'.'',');
        
$awstats[$site]['all']['NV']['value'][0] = number_format($awstats[$site]['all']['NV']['value'][0], 0'.'',');
        
$awstats[$site]['all']['P']['value'][0] = number_format($awstats[$site]['all']['P']['value'][0], 0'.'',');
        
$awstats[$site]['all']['H']['value'][0] = number_format($awstats[$site]['all']['H']['value'][0], 0'.'',');

        
//echo '<pre>'.print_r($awstats[$site]['all'],1).'</pre>';

        // alls years ----------------------------------------------------------------------------------

        // years ---------------------------------------------------------------------------------------
        
foreach($awstats[$site] as $key => $stats) {

            
$class $key == $year 'active' 'hidden';

            echo 
'<div class="awstats data '.$key.' '.$class.'" id="aws_'.str_replace('.''-'$site).'_'.$key.'">';

            
//$key = '2021';

            
echo '<p>'.$awstats[$site][$key]['period']['caption'].' : '.$awstats[$site][$key]['period']['value'].'</p>'."\n";

            echo 
'<p>'."\n";
            echo 
$awstats[$site][$key]['UV']['caption'].' : <strong>'.(isset($awstats[$site][$key]['UV']['value'][0]) ? $awstats[$site][$key]['UV']['value'][0] : '').'</strong> '.(isset($awstats[$site][$key]['UV']['value'][1]) ? $awstats[$site][$key]['UV']['value'][1] : '').'<br/>'."\n"// Unique visitors
            
echo $awstats[$site][$key]['NV']['caption'].' : <strong>'.(isset($awstats[$site][$key]['NV']['value'][0]) ? $awstats[$site][$key]['NV']['value'][0] : '').'</strong> '.(isset($awstats[$site][$key]['NV']['value'][1]) ? $awstats[$site][$key]['NV']['value'][1] : '').'<br/>'."\n"// Number of visits
            
echo $awstats[$site][$key]['P']['caption'].' : <strong>'.(isset($awstats[$site][$key]['P']['value'][0]) ? $awstats[$site][$key]['P']['value'][0] : '').'</strong> '.(isset($awstats[$site][$key]['P']['value'][1]) ? $awstats[$site][$key]['P']['value'][1] : '').'<br/>'."\n"// Pages
            
echo $awstats[$site][$key]['H']['caption'].' : <strong>'.(isset($awstats[$site][$key]['H']['value'][0]) ? $awstats[$site][$key]['H']['value'][0] : '').'</strong> '.(isset($awstats[$site][$key]['H']['value'][1]) ? $awstats[$site][$key]['H']['value'][1] : '').'<br/>'."\n"// Hits
            
echo $awstats[$site][$key]['B']['caption'].' : <strong>'.(isset($awstats[$site][$key]['B']['value'][0]) ? $awstats[$site][$key]['B']['value'][0] : '').'</strong> '.(isset($awstats[$site][$key]['B']['value'][1]) ? $awstats[$site][$key]['B']['value'][1] : '').'<br/>'."\n"// Bandwidth
            
echo '</p>'."\n";

            echo 
'<p>'."\n";
            echo 
'<a href="http://www.zw3b.fr/pub/AWStats/awstats.pl?month='.$month.'&year='.($key == 'all' date('Y') : $key).'&output=main&config='.$site.'&framename=index" title="Access the AWStats log file analyzer">Access the AWStats log file analyzer</a>.'."\n";
            echo 
'</p>'."\n";

        echo 
'</div>';
        }
        
// years ---------------------------------------------------------------------------------------

    
echo '</div>';


    
$zwstats[$site] = $awstats[$site];





endforeach;


//echo '<pre>'.print_r($zwstats,1).'</pre>';

// alls sites ----------------------------------------------------------------------------------
foreach($zwstats as $key => $stats) {

    
$valeur['global']['UV'] = isset($valeur['global']['UV']) ? $valeur['global']['UV'] : 0;
    
$valeur['global']['NV'] = isset($valeur['global']['NV']) ? $valeur['global']['NV'] : 0;
    
$valeur['global']['P'] = isset($valeur['global']['P']) ? $valeur['global']['P'] : 0;
    
$valeur['global']['H'] = isset($valeur['global']['H']) ? $valeur['global']['H'] : 0;
    
$valeur['global']['B'] = isset($valeur['global']['B']) ? $valeur['global']['B'] : 0;

    
$stats['all']['UV']['value'][0] = str_replace(','''$stats['all']['UV']['value'][0]);
    
$valeur['global']['UV'] = ($valeur['global']['UV'] + $stats['all']['UV']['value'][0]);
    
$zw3bstats['global']['UV']['caption'] = $stats['all']['UV']['caption'];
    
$zw3bstats['global']['UV']['value'][0] = $valeur['global']['UV'];

    
$stats['all']['NV']['value'][0] = str_replace(','''$stats['all']['NV']['value'][0]);
    
$valeur['global']['NV'] = ($valeur['global']['NV'] + $stats['all']['NV']['value'][0]);
    
$zw3bstats['global']['NV']['caption'] = $stats['all']['NV']['caption'];
    
$zw3bstats['global']['NV']['value'][0] = $valeur['global']['NV'];

    
$stats['all']['P']['value'][0] = str_replace(','''$stats['all']['P']['value'][0]);
    
$valeur['global']['P'] = ($valeur['global']['P'] + $stats['all']['P']['value'][0]);
    
$zw3bstats['global']['P']['caption'] = $stats['all']['P']['caption'];
    
$zw3bstats['global']['P']['value'][0] = $valeur['global']['P'];

    
$stats['all']['H']['value'][0] = str_replace(','''$stats['all']['H']['value'][0]);
    
$valeur['global']['H'] = ($valeur['global']['H'] + $stats['all']['H']['value'][0]);
    
$zw3bstats['global']['H']['caption'] = $stats['all']['H']['caption'];
    
$zw3bstats['global']['H']['value'][0] = $valeur['global']['H'];

    
$zw3bstats['global']['B']['caption'] = $stats['all']['B']['caption'];
    
$zw3bstats['global']['B']['value'][0] = 'todo';

}

$zw3bstats['global']['UV']['value'][0] = number_format($zw3bstats['global']['UV']['value'][0], 0'.'',');
$zw3bstats['global']['NV']['value'][0] = number_format($zw3bstats['global']['NV']['value'][0], 0'.'',');
$zw3bstats['global']['P']['value'][0] = number_format($zw3bstats['global']['P']['value'][0], 0'.'',');
$zw3bstats['global']['H']['value'][0] = number_format($zw3bstats['global']['H']['value'][0], 0'.'',');
//$zw3bstats['global']['B']['value'][0] = number_format($zw3bstats['global']['B']['value'][0], 0, '.', ',');

// alls sites ----------------------------------------------------------------------------------

//$awstats =  awstats_resume('www.zw3b.tv', '2020', $month = null);
//echo '<pre>'.print_r($zw3bstats,1).'</pre>';






echo '<h2 style="text-align: center; margin-bottom:10px;">AWStats Global (All Web Sites all period)</h2>'."\n";

echo 
'<div class="awstats global">';

//$key = '2021';

//echo '<p>'.$zw3bstats[$site][$key]['period']['caption'].' : '.$awstats[$site][$key]['period']['value'].'</p>'."\n";

echo '<p>'."\n";
echo 
$zw3bstats['global']['UV']['caption'].' : <strong>'.$zw3bstats['global']['UV']['value'][0].'</strong><br/>'."\n"// Unique visitors
echo $zw3bstats['global']['NV']['caption'].' : <strong>'.$zw3bstats['global']['NV']['value'][0].'</strong><br/>'."\n"// Number of visits
echo $zw3bstats['global']['P']['caption'].' : <strong>'.$zw3bstats['global']['P']['value'][0].'</strong><br/>'."\n"// Pages
echo $zw3bstats['global']['H']['caption'].' : <strong>'.$zw3bstats['global']['H']['value'][0].'</strong><br/>'."\n"// Hits
echo $zw3bstats['global']['B']['caption'].' : <strong>'.$zw3bstats['global']['B']['value'][0].'</strong><br/>'."\n"// Bandwidth
echo '</p>'."\n";

//echo '<div class="awstats logo" onclick="window.open($this.children[0].getAttribute(\'href\')); return false;">';
echo '<div class="awstats logo" title="Access AWStats logs files WebSite" onclick="window.open(this.children[0].getAttribute(\'href\')); return false;">';

echo 
'<a href="http://www.awstats.org" title="Access AWStats logs files WebSite">AWStats</a>';

echo 
'</div>';

echo 
'</div>';






$html '';
$html.= '<p style="margin-top:25px;margin-bottom:20px;text-align:center;"><span><a href="http://www.zw3b.fr" title="ZW3B : The Web XXI">&copy; 2011-'.date('Y').' ZW3B : The Web XXI</a>';
$html.= '<br/><br/>';
$html.= '<a href="//www.lab3w.fr" title="LAB3W O.Romain.Jaillet-ramey : Web and networks laboratory">&copy; 2003-'.date('Y').' LAB3W O.Romain.Jaillet-ramey : Web and networks laboratory</a> - All rights reserved</a></span></p>';

$html.= '<ul class="list" id="zw-foot-lnk">'."\n";
$html.= '<li><a href="//www.zw3b.fr/contact/" title="ZW3B :-: Contact">contact</a> |</li>'."\n";
$html.= '<li><a href="//www.zw3b.fr/about/cookies" title="ZW3B :-: Cookies">cookies</a> |</li>'."\n";
$html.= '<li><a href="//www.zw3b.fr/about/privacy" title="ZW3B :-: Privacy">confidentialit&eacute;</a> |</li>'."\n";
$html.= '<li><a href="//www.zw3b.fr/about/credits" title="ZW3B :-: Cr&eacute;dits">cr&eacute;dits</a> |</li>'."\n";
$html.= '<li><a href="//howto.zw3b.fr/edito" title="ZW3B :-: &Eacute;dito">&eacute;dito</a> |</li>'."\n";
$html.= '<li><a href="//www.zw3b.fr/about/partenariats" title="ZW3B :-: Partenariats">partenariats</a> |</li>'."\n";
$html.= '<li><a href="//www.zw3b.fr/about/faq" title="ZW3B :-: FAQ">foire aux questions</a></li>'."\n";
$html.= '</ul>'."\n";

$html.= '<p style="text-align:right; padding-bottom:10px; padding-right:0px;">AWSTATS.ZW3B &copy; 2021/01/22 LAB3W.ORJ</p>'."\n";


echo 
$html;












?>