Annonce

#1 2005-09-24 17:50:43

noiry
Membre
2005-09-23
62

[1.5.0RC1] - Premier Mod : Historique détaillé

e-poussin a fait un super mod pour la 1.4.1

je sais que volcom doit travailler a son intégration, mais si ca peut servir j'ai déjà développé un nouveau mod historique.
Il y a desormais un lien sur la date du jour qui affiche l'historique en question...

Ca rajoute le filtre que e-poussin voulait faire ;)


10/10/2005 : Version 1.1

Code:

############################################################## 
## MOD Title: Stats
## MOD Author: noiry
## Thanks to e-poussin (http://www.e-poussin.com/)
##
## MOD Description: - this MOD allow you to have detailed statistics
##                  - ce MOD vous permet d'avoir des statistiques détaillés
## MOD Version: 1.1 
## phpWebGallery Version: 1.5.RC1
## 
## Installation Level: Advanced
## Installation Time: 20 Minutes 
## Files To Edit:
##    admin/stats.php
##    include/functions.inc.php
##    include/config_local.inc.php
##    language/en_UK.iso-8859-1/admin.lang.php
##    language/fr_FR.iso-8859-1/admin.lang.php
##    template/default/admin/stats.tpl
## Files To Include:
##    admin/images/dayly_stats.img.php
##
############################################################## 
## Author Notes: 
##
##    ### Francais ###
##    
##    Ce MOD permet d'obtenir la liste de toutes les connexions à votre galerie, et
##    de connaître les accès (quelle catégorie?, quelle photo?) réalisés par les
##    utilisateurs (adresse, login) pour un mois donné.
##
##    De plus, des paramètres supplémentaires vous permettent de ne pas historiser
##    l'activité de l'administrateur
##
############################################################## 
## MOD History: 
##
##   2005-09-28 - Version 1.1
##      - Link on IP (when develop_ip=false)
##      - template improved
## 
##   2005-09-24 - Version 1.0
##      - Initial Release
## 
############################################################## 
## Before Adding This MOD To Your PWG, You Should Back Up All Files Related To This MOD 
############################################################## 


# 
#-----[ OPEN ]------------------------------------------ 
#

admin/stats.php

# 
#-----[ FIND ]------------------------------------------ ~line 38
#

if (isset($_GET['month']) && isset($_GET['year']) )

# 
#-----[ REPLACE BY ]------------------------------------------
#

if (isset($_GET['day']) && isset($_GET['month']) && isset($_GET['year']) )
{
  $url_img .= 'dayly_stats.img.php?year='.$_GET['year'].'&month='.$_GET['month'].'&day='.$_GET['day'];
  $nls_value_title = $lang['w_day'];
  $group_clause = "DATE_FORMAT(date,'%Y-%m-%d') ASC";
  $where_clause = "(YEAR(date) = ".$_GET['year']." AND MONTH(date) = ".$_GET['month']." )";
}
elseif (isset($_GET['month']) && isset($_GET['year']) )

# 
#-----[ FIND ]------------------------------------------ ~line 56
#

$url_img .= 'global_stats.img.php';
}

# 
#-----[ AFTER, ADD ]------------------------------------------
#

}

# 
#-----[ FIND ]------------------------------------------ ~line 60
#

//----------------------------------------------------- template initialization

# 
#-----[ AFTER, ADD ]------------------------------------------
#

if (isset($_GET['day']) && isset($_GET['month']) && isset($_GET['year']) )
{
  $date_of_day=$_GET['day'].' '.$lang['month'][$_GET['month']].' '.$_GET['year'];
  $title_page=$lang['stats_day_title'].' du '.$date_of_day;
  $url_back = PHPWG_ROOT_PATH."admin.php?page=stats";
  $url_back = add_session_id($url_back);
  $title_details='<a href='.$url_back.'>'.$lang['stats_day_title'].'</a>';
  $title_day=$lang['stats_day_details_title']." ".$date_of_day;
}
elseif ( isset($_GET['month']) && isset($_GET['year']) )
{
  $date_of_day=$lang['month'][$_GET['month']].' '.$_GET['year'];
  $title_page=$lang['stats_month_title'].' : '.$date_of_day;
  $url_back = PHPWG_ROOT_PATH."admin.php?page=stats";
  $url_back = add_session_id($url_back);
  $title_details='<a href='.$url_back.'>'.$lang['stats_day_title'].'</a>';
  $title_day=$lang['today'];
}
else
{
  $date_of_day='';
  $title_page=$lang['stats_title'];
  $title_details=$lang['stats_month_title'];
  $title_day=$lang['today'];
}

# 
#-----[ FIND ]------------------------------------------ ~line 86
#

  'L_STAT_TITLE'=>$lang['stats_title'],
  'L_STAT_MONTH_TITLE'=>$lang['stats_month_title'],
  'L_STAT_MONTHLY_ALT'=>$lang['stats_global_graph_title'],

# 
#-----[ REPLACE BY ]------------------------------------------
#

  'L_STAT_TITLE'=>$title_page,
  'L_STAT_DETAIL_TITLE'=>$title_details,
  'L_DATE_TITLE'=>$title_day,
  'L_STAT_MONTHLY_ALT'=>$lang['stats_global_graph_title'],
  'L_STAT_HOUR'=>$lang['stats_hour'],
  'L_STAT_LOGIN'=>$lang['stats_login'],
  'L_STAT_ADDR'=>$lang['stats_addr'],
  'L_STAT_CATEGORY'=>$lang['stats_category'],
  'L_STAT_FILE'=>$lang['stats_file'],
  'L_STAT_PICTURE'=>$lang['stats_picture'],

# 
#-----[ FIND ]------------------------------------------ ~line 115
#

  if (isset($_GET['month']) && isset($_GET['year']) )
  {
    $where_clause = 'DAYOFMONTH(date) = '.$row['d'].'
    AND MONTH(date) = '.$row['m'].'
    AND YEAR(date) = '.$row['y'];
    $week_day = $lang['day'][date('w', mktime(12,0,0,$row['m'],$row['d'],$row['y']))];
    $value = $row['d'].' ('.$week_day.')';
  }
  else
  {
    $current_month = $row['y']."-";
    if ($row['m'] <10) {$current_month.='0';}
    $current_month .= $row['m'];
    $where_clause = "DATE_FORMAT(date,'%Y-%m') = '".$current_month."'";
    $value = "<a href='".PHPWG_ROOT_PATH."admin.php?page=stats";
    $value.= "&amp;year=".$row['y']."&amp;month=".$row['m']."'>";
    $value.= $lang['month'][$row['m']].' '.$row['y'];
    $value.= "</a>";
  }

# 
#-----[ REPLACE BY ]------------------------------------------ 
#

  if (isset($_GET['month']) && isset($_GET['year']) )
  {
    if ($row['d'] <10) {$current_day='0';
      $current_day.=$row['d'];}
    else {$current_day = $row['d'];}
    $where_clause = 'DAYOFMONTH(date) = '.$current_day.'
    AND MONTH(date) = '.$row['m'].'
    AND YEAR(date) = '.$row['y'];
    $week_day = $lang['day'][date('w', mktime(12,0,0,$row['m'],$row['d'],$row['y']))];
    $url_stats = PHPWG_ROOT_PATH."admin.php?page=stats";
    $url_stats.= "&amp;year=".$row['y']."&amp;month=".$row['m'];
    $url_stats.= "&amp;day=".$row['d'];
    $url_stats = add_session_id($url_stats);
    $value = "<a href='".$url_stats."'>";
    $value.= $row['d'].' ('.$week_day.')';
    $value.= "</a>";
  }
  else
  {
    if ($row['m'] <10) {$current_month='0';
      $current_month.=$row['m'];}
    else {$current_month = $row['m'];}
    $where_clause = 'MONTH(date) = '.$current_month.'
    AND YEAR(date) = '.$row['y'];
    $url_stats = PHPWG_ROOT_PATH."admin.php?page=stats";
    $url_stats.= "&amp;year=".$row['y']."&amp;month=".$row['m'];
    $url_stats = add_session_id($url_stats);
    $value = "<a href='".$url_stats."'>";
    $value.= $lang['month'][$row['m']].' '.$row['y'];
    $value.= "</a>";
  }

# 
#-----[ FIND ]------------------------------------------ ~line 188
#

$max_pages_seen = 0;

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

//----------------------------------------------------------- stats / jour

if ( isset( $_GET['month'] ) && isset( $_GET['month'] ) && isset( $_GET['day'] ) )
{
  if ($_GET['day'] <10) {$current_day='0';
    $current_day.= $_GET['day'];}
  else {$current_day = $_GET['day'];}
  if ($_GET['month'] <10) {$current_month='0';
    $current_month.= $_GET['month'];}
  else {$current_month = $_GET['month'];}
  $current_year = $_GET['year'];
}
else
{
  $current_date = GetDate();
  if ($current_date['mday'] <10) {$current_day='0';
    $current_day.= $current_date['mday'];}
  else {$current_day = $current_date['mday'];}
  if ($current_date['mon'] <10) {$current_month='0';
    $current_month.= $current_date['mon'];}
  else {$current_month = $current_date['mon'];}
  $current_year = $current_date['year'];  
}

// Set WHERE clause
$where = ' WHERE DATE_FORMAT(date,\'%Y-%m-%d\') = \''.$current_year."-".$current_month."-".$current_day.'\'';
  
// Set LIMIT clause
$limit = ' LIMIT ';
$page['start'] = 0;
if (isset($_GET['start']) and is_numeric($_GET['start'])) $page['start'] = abs($_GET['start']);
$limit .= $page['start'];
$limit .= ','.$conf['nb_logs_page'];

$query = '
SELECT DATE_FORMAT(date,\'%H:%i:%s\') AS hour,
     login,
     IP,
     category,
     file,
     picture
  FROM '.HISTORY_TABLE.
  $where.'
  ORDER BY date DESC'.
  $limit.
  ';';
$result = pwg_query( $query );
$i=0;
 
while ( $row = mysql_fetch_array( $result ) )
{
  $class = ($i % 2)? 'row1':'row2'; $i++;
  
  if ($conf['develop_ip'])
  {
    $template->assign_block_vars('detail',array(
    'HOUR'=>$row['hour'],
    'LOGIN'=>$row['login'],
    'IP'=>gethostbyaddr($row['IP']),
    'CATEGORY'=>$row['category'],
    'FILE'=>$row['file'],
    'PICTURE'=>$row['picture'],
    'T_CLASS'=>$class
  ));
  }
  else
  {
    $template->assign_block_vars('detail',array(
    'HOUR'=>$row['hour'],
    'LOGIN'=>$row['login'],
    'IP'=>'<a href="Javascript:void(0);" onClick="javascript:alert(\'Hostname : '.gethostbyaddr($row['IP']).'\');">'.$row['IP'].'</a>',
    'CATEGORY'=>$row['category'],
    'FILE'=>$row['file'],
    'PICTURE'=>$row['picture'],
    'T_CLASS'=>$class
  ));
  }
}
  
// Get total number of logs
$query = '
    SELECT COUNT(date) as nb_logs
     FROM '.HISTORY_TABLE.
  $where.'
    ;';

  $result = pwg_query($query);
  $row = mysql_fetch_array($result);
  $page['nb_logs']=$row['nb_logs'];

  //display nav bar
  $url = $_SERVER['PHP_SELF'].'?page=stats&year='.$_GET['year'];
  $url .= '&month='.$_GET['month'].'&day='.$_GET['day'];
  $page['navigation_bar'] =
  create_navigation_bar( $url, $page['nb_logs'],$page['start'],$conf['nb_logs_page'], 'admin' );
$template->assign_block_vars('navigation',
    array('NAV_BAR' => $page['navigation_bar'])
    );


# 
#-----[ OPEN ]------------------------------------------ 
#

include/config_local.inc.php

# 
#-----[ FIND ]------------------------------------------ 
#

    ?>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

// nb_logs_page : nombre de logs par page
$conf['nb_logs_page'] = 300;

// historiser les actions de l'admin
$conf['history_admin'] = false;

// developper les adresses IP 
$conf['develop_ip'] = false;

# 
#-----[ OPEN ]------------------------------------------ 
#

include/functions.inc.php

# 
#-----[ FIND ]------------------------------------------ 
#

  if ($conf['log'])
  {

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

  if (($conf['history_admin'] == 'yes') or (($conf['history_admin'] == 'no') and ($user['status'] != 'admin') ))
  {

# 
#-----[ FIND ]------------------------------------------ 
#

    \''.addslashes($picture).'\')
  ;';
    pwg_query($query);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

  }

# 
#-----[ OPEN ]------------------------------------------ 
#

language/en_UK.iso-8859-1/admin.lang.php

# 
#-----[ FIND ]------------------------------------------ 
#

$lang['stats_global_graph_title'] = 'Pages seen by month'

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

$lang['stats_dayly_graph_title'] = 'Pages seen by hour';
$lang['stats_monthly_graph_title'] = 'Pages seen by day';

# 
#-----[ AND AFTER, ADD ]------------------------------------------ 
#

$lang['stats_day_title'] = 'Dayly statistics';

# 
#-----[ FIND ]------------------------------------------ 
#

$lang['stats_title'] = 'Last year statistics';

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

$lang['stats_hour'] = 'Hour';
$lang['stats_login'] = 'Login';
$lang['stats_addr'] = 'Address';
$lang['stats_category'] = 'Category';
$lang['stats_file'] = 'File';
$lang['stats_picture'] = 'Picture';

# 
#-----[ OPEN ]------------------------------------------ 
#

language/fr_FR.iso-8859-1/admin.lang.php

# 
#-----[ FIND ]------------------------------------------ 
#

$lang['stats_global_graph_title'] = 'Pages vues par mois';

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

$lang['stats_dayly_graph_title'] = 'Pages vues par heure';
$lang['stats_monthly_graph_title'] = 'Pages vues par jour';

# 
#-----[ AND AFTER, ADD ]------------------------------------------ 
#

$lang['stats_day_title'] = 'Statistiques journalières';

# 
#-----[ FIND ]------------------------------------------ 
#

$lang['stats_title'] = 'Statistiques de la dernière année';

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

$lang['stats_hour'] = 'Heure';
$lang['stats_login'] = 'Identifiant';
$lang['stats_addr'] = 'Adresse IP';
$lang['stats_category'] = 'Categorie';
$lang['stats_file'] = 'Fichier';
$lang['stats_picture'] = 'Image';




!!! A FAIRE POUR CHAQUE TEMPLATE !!!


# 
#-----[ OPEN ]------------------------------------------ 
#

template/default/admin/stats.tpl

# 
#-----[ FIND ]------------------------------------------ 
#

<h3>{L_STAT_MONTH_TITLE}</h3>

# 
#-----[ REPLACE BY ]------------------------------------------ 
#

<h3>{L_STAT_DETAIL_TITLE}</h3>

# 
#-----[ FIND ]------------------------------------------ 
#

    <!-- END statrow -->

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

<h3>{L_DATE_TITLE}</h3>
<table class="table2" width="98%">
<tr class="throw">
    <th>{L_STAT_HOUR}</th>
  <th>{L_STAT_LOGIN}</th>
    <th>{L_STAT_ADDR}</th>
    <th>{L_STAT_CATEGORY}</th>
    <th>{L_STAT_FILE}</th>
    <th>{L_STAT_PICTURE}</th>
</tr>

<!-- BEGIN detail -->
  <tr class="{detail.T_CLASS}">
    <td nowrap>{detail.HOUR}</td>
    <td>{detail.LOGIN}</td>
    <td>{detail.IP}</td>
  <td>{detail.CATEGORY}</td>
  <td>{detail.FILE}</td>
  <td>{detail.PICTURE}</td>
  </tr>
<!-- END detail -->

</table>
<br />
<!-- BEGIN navigation -->
<div  class="admin">
{navigation.NAV_BAR}
</div>
<!-- END navigation -->
<br />


#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM

PS : e-poussin, j'ai mis ton copyright au mod ;) merci pour ton premier jet...

Dernière modification par noiry (2005-10-10 14:04:20)

Hors ligne

#2 2005-09-24 19:18:35

youppiyouppi
Membre
2005-01-22
35

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

bsr,
j'ai fais les modifs et ça parait très sympa mais ......
j'obtiens ceci :

********************************
Statistiques mensuelles
Mois Pages vues Visiteurs images
Septembre 2005 1 1 0
Août 2005 119 1 60
Juillet 2005 12 4 111
Juillet 2005 9 4 111
Juillet 2005 119 4 111
Juillet 2005 1 4 111
Juillet 2005 20 4 111
Juillet 2005 78 4 111
Juillet 2005 30 4 111
********************************

pour juillet, les nbres de pages, visiteurs et images ne sont pas cumulés !!! normal ?

et en allant dans les détails : soit j'ai la liste des IP + heure +...., soit je n'ai que ceci : (ex. : le vendredi 8)

*********************************
Statistiques mensuelles
Jour Pages vues Visiteurs images
3 (Dimanche) 30 1 5
8 (Vendredi) 78 2 27
10 (Dimanche) 20 1 8
12 (Mardi) 1 1 0
14 (Jeudi) 119 1 66
15 (Vendredi) 9 1 5
16 (Samedi) 12 1 0
Heure Identifiant Adresse IP Categorie Fichier Image
***********************************

et quand ça marche : (ex.: le dimache 10)

************************************
Statistiques mensuelles
Jour Pages vues Visiteurs images
3 (Dimanche) 30 1 5
8 (Vendredi) 78 2 27
10 (Dimanche) 20 1 8
12 (Mardi) 1 1 0
14 (Jeudi) 119 1 66
15 (Vendredi) 9 1 5
16 (Samedi) 12 1 0
Heure Identifiant Adresse IP Categorie Fichier Image
10:45:16 Robert 83.179.1.91 Fleurs & Arbres / Arbres en fleurs category 
10:44:49 Robert 83.179.1.91 Fleurs & Arbres category 
10:44:32 Robert 83.179.1.91 15 mieux notées category 
10:44:00 Robert 83.179.1.91 PICT0886 picture PICT0886.jpg
10:42:18 Robert 83.179.1.91 PICT0936 DxO picture PICT0936_DxO.jpg
10:41:27 Robert 83.179.1.91 15 mieux notées category
........ etc .......
*************************************

que faut-il faire svp ?
joli travail !!!

Hors ligne

#3 2005-09-24 20:31:58

noiry
Membre
2005-09-23
62

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

Attention, j'ai mis à jour le MOD vers 17h. (a priori ca resoudrait le problème du mois de juillet)

J'avais supprimé la modif ligne 35.

Code:

$group_clause = "DATE_FORMAT(date,'%Y-%m') DESC";

Par contre, pour le reste, c'est de ma faute. J'avais fait qq erreurs de frappes qui passaient inaperçues :)

le mod mis à jour.

Pour info, ce MOD corrige un bug de l'historique pour les admins qui n'acceptent pas les cookies ou (comme pour moi) qui passent par une frame vide pour afficher leur site.

Code:

 admin/stats.php ligne 95-96 :

    $url_stats = PHPWG_ROOT_PATH."admin.php?page=stats";
    $url_stats.= "&amp;year=".$row['y']."&amp;month=".$row['m'];
    $url_stats = add_session_id($url_stats);
    $value = "<a href='".$url_stats."'>";

Dernière modification par noiry (2005-09-24 20:33:26)

Hors ligne

#4 2005-09-24 23:18:26

youppiyouppi
Membre
2005-01-22
35

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

effectivement, pour juillet c'est corrigé ! rapide et efficace !!! bravo
mais j'ai toujours le problème pour certaines dates : pas de détails alors qu'il y a eu des images de visualisées !!! bizarre !!

Hors ligne

#5 2005-09-25 16:53:47

noiry
Membre
2005-09-23
62

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

Peux tu m'en dire plus ? Quelles sont les dates concernées ? As tu refait tout le mode (j'ai changé d'autres parties) ?

Peux tu faire en copier / coller de ton code (stats.php) ?

Dernière modification par noiry (2005-09-26 09:05:25)

Hors ligne

#6 2005-09-26 13:20:48

youppiyouppi
Membre
2005-01-22
35

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

bonjour,
voici le stats.php :

******************************************************************

<?php
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery                           |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch        : BSF (Best So Far)
// | file          : $RCSfile: stats.php,v $
// | last update   : $Date: 2005/09/18 21:56:56 $
// | last modifier : $Author: plg $
// | revision      : $Revision: 1.25 $
// +-----------------------------------------------------------------------+
// | 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                                          |
// |                                                                       |
// | 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; if not, write to the Free Software           |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA.                                                                  |
// +-----------------------------------------------------------------------+
if( !defined("PHPWG_ROOT_PATH") )
{
    die ("Hacking attempt!");
}
include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );

$url_img = PHPWG_ROOT_PATH.'admin/images/';
$nls_value_title = $lang['w_month'];
$group_clause = "DATE_FORMAT(date,'%Y-%m') DESC";

$where_clause = "1";

if (isset($_GET['month']) && isset($_GET['year']) )
{
  $url_img .= 'monthly_stats.img.php?year='.$_GET['year'].'&month='.$_GET['month'];
  $nls_value_title = $lang['w_day'];
  $group_clause = "DATE_FORMAT(date,'%Y-%m-%d') ASC";
  $where_clause = "(YEAR(date) = ".$_GET['year']." AND MONTH(date) = ".$_GET['month']." )";
}
else
{
  $url_img .= 'global_stats.img.php';
}

//----------------------------------------------------- template initialization
$template->set_filenames( array('stats'=>'admin/stats.tpl') );

$template->assign_vars(array(
  'L_VALUE'=>$nls_value_title,
  'L_PAGES_SEEN'=>$lang['stats_pages_seen'],
  'L_VISITORS'=>$lang['visitors'],
  'L_PICTURES'=>$lang['pictures'],
  'L_STAT_TITLE'=>$lang['stats_title'],
  'L_STAT_MONTH_TITLE'=>$lang['stats_month_title'],
  'L_STAT_MONTHLY_ALT'=>$lang['stats_global_graph_title'],
    'L_STAT_HOUR'=>$lang['stats_hour'],
  'L_STAT_LOGIN'=>$lang['stats_login'],
  'L_STAT_ADDR'=>$lang['stats_addr'],
  'L_STAT_CATEGORY'=>$lang['stats_category'],
  'L_STAT_FILE'=>$lang['stats_file'],
  'L_STAT_PICTURE'=>$lang['stats_picture'],

  'IMG_REPORT'=>add_session_id($url_img)
  ));

//---------------------------------------------------------------- log  history
$query = '
SELECT DISTINCT COUNT(*) as p,
       DAYOFMONTH(date) as d,
       MONTH(date) as m,
       YEAR(date) as y
  FROM '.HISTORY_TABLE.'
  WHERE '.$where_clause.'
  GROUP BY '.$group_clause.';';

$result = pwg_query( $query );
$i=0;
while ( $row = mysql_fetch_array( $result ) )
{
  $where_clause="";
  $value = '';
  if (isset($_GET['month']) && isset($_GET['year']) )
  {
    $where_clause = 'DAYOFMONTH(date) = '.$row['d'].'
    AND MONTH(date) = '.$row['m'].'
    AND YEAR(date) = '.$row['y'];
$url_stats = PHPWG_ROOT_PATH."admin.php?page=stats";
    $url_stats.= "&amp;year=".$row['y']."&amp;month=".$row['m'];
    $url_stats = add_session_id($url_stats);
    $value = "<a href='".$url_stats."'>";    $week_day = $lang['day'][date('w', mktime(12,0,0,$row['m'],$row['d'],$row['y']))];
        $value = "<a href='".PHPWG_ROOT_PATH."admin.php?page=stats";
    $value.= "&amp;year=".$row['y']."&amp;month=".$row['m'];
    $value.= "&amp;day=".$row['d']."'>";
    $value.= $row['d'].' ('.$week_day.')';
    $value.= "</a>";

  }
  else
  {
    $current_month = $row['y']."-";
    if ($row['m'] <10) {$current_month.='0';}
    $current_month .= $row['m'];
    $where_clause = "DATE_FORMAT(date,'%Y-%m') = '".$current_month."'";
    $value = "<a href='".PHPWG_ROOT_PATH."admin.php?page=stats";
    $value.= "&amp;year=".$row['y']."&amp;month=".$row['m']."'>";
    $value.= $lang['month'][$row['m']].' '.$row['y'];
    $value.= "</a>";
  }
 
  // Number of pictures seen
  $query = '
SELECT COUNT(*) as p
    FROM '.HISTORY_TABLE.'
    WHERE '.$where_clause.'
    AND FILE = \'picture\'
;';
  $pictures = mysql_fetch_array(pwg_query( $query ));
 
  // Number of different visitors
  $query = '
SELECT COUNT(*) as p, login
  FROM '.HISTORY_TABLE.'
  WHERE '.$where_clause.'
  GROUP BY login, IP
;';
  $user_results = pwg_query( $query );
  $nb_visitors = 0;
  $auth_users = array();
  while ( $user_array = mysql_fetch_array( $user_results ) )
  {
    if ($user_array['login'] == 'guest')
      $nb_visitors += 1;
    else
      array_push($auth_users, $user_array['login']);
  }
  $nb_visitors +=count(array_unique($auth_users));
  $class = ($i % 2)? 'row1':'row2'; $i++;
 
  $template->assign_block_vars('statrow',array(
      'VALUE'=>$value,
    'PAGES'=>$row['p'],
    'VISITORS'=>$nb_visitors,
    'IMAGES'=>$pictures['p'],
   
    'T_CLASS'=>$class
    ));
}
$nb_visitors = mysql_num_rows( $result );
$days = array();
$max_nb_visitors = 0;
$max_pages_seen = 0;
//----------------------------------------------------------- stats / jour

if ( isset( $_GET['month'] ) )
{
  if ($_GET['day'] <10) {$current_day.='0';}
  $current_day = $_GET['day'];
  if ($_GET['month'] <10) {$current_month.='0';}
  $current_month .= $_GET['month'];
  $current_year = $_GET['year'];
 
  // Set WHERE clause
  $where = ' WHERE DATE_FORMAT(date,\'%Y-%m-%d\') = \''.$current_year."-".$current_month."-".$current_day.'\'';
 
  // Set LIMIT clause
  $limit = ' LIMIT ';
  $page['start'] = 0;
  if (isset($_GET['start']) and is_numeric($_GET['start'])) $page['start'] = abs($_GET['start']);
  $limit .= $page['start'];
  $limit .= ','.$conf['nb_logs_page'];

  $query = '
  SELECT DATE_FORMAT(date,\'%H:%i:%s\') AS heure, login, IP, category, file, picture
    FROM '.HISTORY_TABLE.
    $where.'
    ORDER BY date DESC'.
    $limit.
    ';';
  $result = pwg_query( $query );
  $i=0;
  while ( $row = mysql_fetch_array( $result ) )
  {
    $class = ($i % 2)? 'row1':'row2'; $i++;
   
    if ($conf['develop_ip'] == 'yes')
    {
      $template->assign_block_vars('detail',array(
      'DATE'=>$row['heure'],
      'LOGIN'=>$row['login'],
      'IP'=>gethostbyaddr($row['IP']),
      'CATEGORY'=>$row['category'],
      'FILE'=>$row['file'],
      'PICTURE'=>$row['picture'],
      'T_CLASS'=>$class
    ));
    }
    else
    {
      $template->assign_block_vars('detail',array(
      'DATE'=>$row['heure'],
      'LOGIN'=>$row['login'],
      'IP'=>$row['IP'],
      'CATEGORY'=>$row['category'],
      'FILE'=>$row['file'],
      'PICTURE'=>$row['picture'],
      'T_CLASS'=>$class
    ));
    }
  }
 
  // Get total number of logs
  $query = '
      SELECT COUNT(date) as nb_logs
       FROM '.HISTORY_TABLE.
    $where.'
      ;';
 
    $result = pwg_query($query);
    $row = mysql_fetch_array($result);
    $page['nb_logs']=$row['nb_logs'];
 
    //display nav bar
    $url = $_SERVER['PHP_SELF'].'?page=stats&year='.$_GET['year'];
    $url .= '&month='.$_GET['month'].'&day='.$_GET['day'];

    $page['navigation_bar'] =
      create_navigation_bar( $url, $page['nb_logs'],$page['start'],$conf['nb_logs_page'], 'admin' );
  $template->assign_block_vars(
      'navigation',
      array('NAV_BAR' => $page['navigation_bar'])
      );
}
//----------------------------------------------------------- sending html code
$template->assign_var_from_handle('ADMIN_CONTENT', 'stats');
?>


******************************************************************

Hors ligne

#7 2005-09-26 15:04:58

noiry
Membre
2005-09-23
62

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

ton probleme est la :

//----------------------------------------------------------- stats / jour

if ( isset( $_GET['month'] ) )
{
  if ($_GET['day'] <10) {$current_day.='0';}
  $current_day = $_GET['day'];                                      // ici exactement. Il manque un . devant le =
  if ($_GET['month'] <10) {$current_month.='0';}
  $current_month .= $_GET['month'];
  $current_year = $_GET['year'];
 
  // Set WHERE clause

Remplace le par le contenu du mod. C'est plus propre :

//----------------------------------------------------------- stats / jour

if ( isset( $_GET['month'] ) )
{
  if ($_GET['day'] <10) {$current_day='0';
    $current_day.= $_GET['day'];}
  else {$current_day = $_GET['day'];}
  if ($_GET['month'] <10) {$current_month='0';
    $current_month.= $_GET['month'];}
  else {$current_month = $_GET['month'];}
  $current_year = $_GET['year'];
 
  // Set WHERE clause

Hors ligne

#8 2005-09-26 15:27:51

youppiyouppi
Membre
2005-01-22
35

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

nickel !!! encore un dieu en PHP !!! merci bcp !!!!

Hors ligne

#9 2005-10-01 13:20:53

cestludovic
Invité

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

J'ai installer l'historique amélioré mais j'ai un problème maintenant car depuis si des personnes vont sur mon site, y a plus aucune info de leur action.

sinon l'affichage améliorer lui marche

aider moi SVP

#10 2005-10-01 13:29:22

cestludovic
Invité

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

cestludovic a écrit:

J'ai installer l'historique amélioré mais j'ai un problème maintenant car depuis si des personnes vont sur mon site, y a plus aucune info de leur action.

sinon l'affichage améliorer lui marche

aider moi SVP

bon c bon , j'ai régler le probleme

#11 2005-10-03 22:31:20

20100
Membre
2003-09-23
84

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

Mais encore ?
Où peut on trouver la modif ?

Merci

Hors ligne

#12 2005-10-10 12:57:10

20100
Membre
2003-09-23
84

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

cestludovic, peux tu  m'indiquer ce qu'il faut faire pour retrouver l'historique ? depuis ma modif pour intégrer l'historique détaillé, aucun historique n'est plus logué.

Hors ligne

#13 2005-10-10 14:02:46

noiry
Membre
2005-09-23
62

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

je suis moi aussi interessé, car vous etes les seuls (enfin je crois) a perdre l'historique...
Peut etre cela vient il de l'historisation ou non des actions de l'admin.

Verifie au niveau de include/functions.inc.php, la fonction pwg_log doit avoir cette tete là :

Code:

function pwg_log( $file, $category, $picture = '' )
{
  global $conf, $user;

  if ($conf['log'])
  if ($conf['history_admin'] or (!$conf['history_admin'] and ($user['status'] != 'admin') ))
  {
  {
    $query = '
INSERT INTO '.HISTORY_TABLE.'
  (date,login,IP,file,category,picture)
  VALUES
  (NOW(),
  \''.(($user['id'] == $conf['guest_id']) ) ? 'guest' : addslashes($user['username'])).'\',
  \''.$_SERVER['REMOTE_ADDR'].'\',
  \''.addslashes($file).'\',
  \''.addslashes(strip_tags($category)).'\',
  \''.addslashes($picture).'\')
;';
    pwg_query($query);
  }
  }
}

Il faut egalement que tu penses bien à rajouter dans include/config_local.inc.php la variable :

$conf['history_admin'] = false;

Je vais mettre une nouvelle version en ligne (mais qui ne devrait pas changer le probleme)...

Je reste en contact...

Hors ligne

#14 2005-10-10 21:49:54

cestludovic
Invité

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

20100 a écrit:

cestludovic, peux tu  m'indiquer ce qu'il faut faire pour retrouver l'historique ? depuis ma modif pour intégrer l'historique détaillé, aucun historique n'est plus logué.

Aourff désolé, je me rapelle plus comment j'ai trouvé ce qu'il n'allait pas, si tu a toujours ton problème dis le moi, je regarderai.

@+

#15 2005-10-11 13:21:19

20100
Membre
2003-09-23
84

Re: [1.5.0RC1] - Premier Mod : Historique détaillé

Ca y'est ca re-fonctionne. Merci beaucoup


c'est cette ligne qui était fausse chez moi :

Code:

  if ($conf['history_admin'] or (!$conf['history_admin'] and ($user['status'] != 'admin') ))

Merci

Hors ligne

Pied de page des forums

Propulsé par FluxBB

github twitter newsletter Faire un don Piwigo.org © 2002-2024 · Contact