Changeset 766 for trunk/admin/stats.php


Ignore:
Timestamp:
Apr 25, 2005, 5:41:56 PM (19 years ago)
Author:
gweltas
Message:
  • L�g�re modification pour permettre une installation m�me si le fichier mysql.inc.php n'existe pas.
  • Introduction des statistiques mensuelles.
  • Modification des labels anglais lors de l'installation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/stats.php

    r724 r766  
    3131include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
    3232
    33 $url_img_global_report = PHPWG_ROOT_PATH.'admin/images/global_stats.img.php';
     33$url_img = PHPWG_ROOT_PATH.'admin/images/';
     34$nls_value_title = $lang['w_month'];
     35$group_clause = "DATE_FORMAT(date,'%Y-%m') DESC";
     36$where_clause = "1";
     37
     38if (isset($_GET['month']) && isset($_GET['year']) )
     39{
     40  $url_img .= 'monthly_stats.img.php?year='.$_GET['year'].'&month='.$_GET['month'];
     41  $nls_value_title = $lang['w_day'];
     42  $group_clause = "DATE_FORMAT(date,'%Y-%m-%d') ASC";
     43  $where_clause = "(YEAR(date) = ".$_GET['year']." AND MONTH(date) = ".$_GET['month']." )";
     44}
     45else
     46{
     47  $url_img .= 'global_stats.img.php';
     48}
     49
    3450//----------------------------------------------------- template initialization
    3551$template->set_filenames( array('stats'=>'admin/stats.tpl') );
    3652
    3753$template->assign_vars(array(
    38   'L_MONTH'=>$lang['w_month'],
     54  'L_VALUE'=>$nls_value_title,
    3955  'L_PAGES_SEEN'=>$lang['stats_pages_seen'],
    4056  'L_VISITORS'=>$lang['visitors'],
     
    4460  'L_STAT_MONTHLY_ALT'=>$lang['stats_global_graph_title'],
    4561 
    46   'IMG_MONTHLY_REPORT'=>add_session_id($url_img_global_report)
     62  'IMG_REPORT'=>add_session_id($url_img)
    4763  ));
    4864
     
    5066$query = '
    5167SELECT DISTINCT COUNT(*) as p,
     68       DATE(date) as d,
    5269       MONTH(date) as m,
    5370       YEAR(date) as y
    5471  FROM '.HISTORY_TABLE.'
    55   GROUP BY DATE_FORMAT(date,\'%Y-%m\') DESC
    56 ;';
     72  WHERE '.$where_clause.'
     73  GROUP BY '.$group_clause.';';
     74
    5775$result = pwg_query( $query );
    5876$i=0;
    5977while ( $row = mysql_fetch_array( $result ) )
    6078{
    61   $current_month = $row['y']."-";
    62   if ($row['m'] <10) {$current_month.='0';}
    63   $current_month .= $row['m'];
     79  $where_clause="";
     80  $value = '';
     81  if (isset($_GET['month']) && isset($_GET['year']) )
     82  {
     83    $where_clause = "DATE_FORMAT(date,'%Y-%m-%d') = '".$row['d']."'";
     84    $value = substr($row['d'],8,2);
     85  }
     86  else
     87  {
     88    $current_month = $row['y']."-";
     89    if ($row['m'] <10) {$current_month.='0';}
     90    $current_month .= $row['m'];
     91    $where_clause = "DATE_FORMAT(date,'%Y-%m') = '".$current_month."'";
     92    $value = "<a href='".PHPWG_ROOT_PATH."admin.php?page=stats";
     93    $value.= "&amp;year=".$row['y']."&amp;month=".$row['m']."'>";
     94    $value.= $lang['month'][$row['m']].' '.$row['y'];
     95    $value.= "</a>";
     96  }
     97 
    6498  // Number of pictures seen
    6599  $query = '
    66100SELECT COUNT(*) as p,
    67        FILE as f
    68   FROM '.HISTORY_TABLE.'
    69   WHERE DATE_FORMAT(date,\'%Y-%m\') = \''.$current_month.'\'
     101    FILE as f
     102    FROM '.HISTORY_TABLE.'
     103    WHERE '.$where_clause.'
    70104    AND FILE = \'picture\'
    71   GROUP BY FILE
     105    GROUP BY FILE
    72106;';
    73107  $pictures = mysql_fetch_array(pwg_query( $query ));
     
    77111SELECT COUNT(*) as p, login
    78112  FROM '.HISTORY_TABLE.'
    79   WHERE DATE_FORMAT(date,\'%Y-%m\') = \''.$current_month.'\'
     113  WHERE '.$where_clause.'
    80114  GROUP BY login, IP
    81115;';
     
    93127  $class = ($i % 2)? 'row1':'row2'; $i++;
    94128 
    95   $template->assign_block_vars('month',array(
    96     'MONTH'=>$lang['month'][$row['m']].' '.$row['y'],
     129  $template->assign_block_vars('statrow',array(
     130      'VALUE'=>$value,
    97131        'PAGES'=>$row['p'],
    98132        'VISITORS'=>$nb_visitors,
Note: See TracChangeset for help on using the changeset viewer.