Changeset 894 for trunk/admin/stats.php


Ignore:
Timestamp:
Oct 17, 2005, 9:21:30 AM (19 years ago)
Author:
volcom
Message:
  • new: history details by month,day
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/stats.php

    r877 r894  
    3636$where_clause = "1";
    3737
    38 if (isset($_GET['month']) && isset($_GET['year']) )
     38
     39if (isset($_GET['day']) && isset($_GET['month']) && isset($_GET['year']) )
     40{
     41  $url_img .= 'dayly_stats.img.php?year='.$_GET['year'].'&month='.$_GET['month'].'&day='.$_GET['day'];
     42  $nls_value_title = $lang['w_day'];
     43  $group_clause = "DATE_FORMAT(date,'%Y-%m-%d') ASC";
     44  $where_clause = "(YEAR(date) = ".$_GET['year']." AND MONTH(date) = ".$_GET['month']." )";
     45}
     46elseif (isset($_GET['month']) && isset($_GET['year']) )
    3947{
    4048  $url_img .= 'monthly_stats.img.php?year='.$_GET['year'].'&month='.$_GET['month'];
     
    4856}
    4957
     58
    5059//----------------------------------------------------- template initialization
     60if (isset($_GET['day']) && isset($_GET['month']) && isset($_GET['year']) )
     61{
     62  $date_of_day=$_GET['day'].' '.$lang['month'][$_GET['month']].' '.$_GET['year'];
     63  $title_page=$lang['stats_day_title'].' du '.$date_of_day;
     64  $url_back = PHPWG_ROOT_PATH."admin.php?page=stats";
     65  $url_back = add_session_id($url_back);
     66  $title_details='<a href='.$url_back.'>'.$lang['stats_day_title'].'</a>';
     67  $title_day=$lang['stats_day_details_title']." ".$date_of_day;
     68}
     69elseif ( isset($_GET['month']) && isset($_GET['year']) )
     70{
     71  $date_of_day=$lang['month'][$_GET['month']].' '.$_GET['year'];
     72  $title_page=$lang['stats_month_title'].' : '.$date_of_day;
     73  $url_back = PHPWG_ROOT_PATH."admin.php?page=stats";
     74  $url_back = add_session_id($url_back);
     75  $title_details='<a href='.$url_back.'>'.$lang['stats_day_title'].'</a>';
     76  $title_day=$lang['today'];
     77}
     78else
     79{
     80  $date_of_day='';
     81  $title_page=$lang['stats_title'];
     82  $title_details=$lang['stats_month_title'];
     83  $title_day=$lang['today'];
     84}
     85
     86
    5187$template->set_filenames( array('stats'=>'admin/stats.tpl') );
    5288
     
    5995  'L_STAT_MONTH_TITLE'=>$lang['stats_month_title'],
    6096  'L_STAT_MONTHLY_ALT'=>$lang['stats_global_graph_title'],
     97  'L_STAT_TITLE'=>$title_page,
     98  'L_STAT_DETAIL_TITLE'=>$title_details,
     99  'L_DATE_TITLE'=>$title_day,
     100  'L_STAT_MONTHLY_ALT'=>$lang['stats_global_graph_title'],
     101  'L_STAT_HOUR'=>$lang['stats_hour'],
     102  'L_STAT_LOGIN'=>$lang['stats_login'],
     103  'L_STAT_ADDR'=>$lang['stats_addr'],
     104  'L_STAT_CATEGORY'=>$lang['stats_category'],
     105  'L_STAT_FILE'=>$lang['stats_file'],
     106  'L_STAT_PICTURE'=>$lang['stats_picture'],
    61107 
    62108  'IMG_REPORT'=>add_session_id($url_img)
     
    149195$max_nb_visitors = 0;
    150196$max_pages_seen = 0;
     197
     198//----------------------------------------------------------- stats / jour
     199
     200if ( isset( $_GET['month'] ) && isset( $_GET['month'] ) && isset( $_GET['day'] ) )
     201{  if ($_GET['day'] <10) {$current_day='0';
     202        $current_day.= $_GET['day'];}
     203  else {$current_day = $_GET['day'];}
     204  if ($_GET['month'] <10) {$current_month='0';
     205        $current_month.= $_GET['month'];}
     206  else {$current_month = $_GET['month'];}
     207  $current_year = $_GET['year'];
     208}
     209
     210else
     211{  $current_date = GetDate();
     212  if ($current_date['mday'] <10) {$current_day='0';
     213        $current_day.= $current_date['mday'];}
     214  else {$current_day = $current_date['mday'];}
     215  if ($current_date['mon'] <10) {$current_month='0';
     216        $current_month.= $current_date['mon'];}
     217  else {$current_month = $current_date['mon'];}
     218  $current_year = $current_date['year']; 
     219}
     220
     221// Set WHERE clause
     222$where = ' WHERE DATE_FORMAT(date,\'%Y-%m-%d\') = \''.$current_year."-".$current_month."-".$current_day.'\'';
     223 
     224// Set LIMIT clause
     225$limit = ' LIMIT ';
     226$page['start'] = 0;
     227if (isset($_GET['start']) and is_numeric($_GET['start'])) $page['start'] = abs($_GET['start']);
     228$limit .= $page['start'];
     229$limit .= ','.$conf['nb_logs_page'];
     230
     231$query = '
     232SELECT DATE_FORMAT(date,\'%H:%i:%s\') AS hour,
     233     login,
     234     IP,
     235     category,
     236     file,
     237     picture
     238  FROM '.HISTORY_TABLE.
     239  $where.'
     240  ORDER BY date DESC'.
     241  $limit.
     242  ';';
     243
     244
     245$result = pwg_query( $query );
     246
     247$i=0;
     248 
     249while ( $row = mysql_fetch_array( $result ) )
     250{
     251  $class = ($i % 2)? 'row1':'row2'; $i++;
     252    $template->assign_block_vars('detail',array(
     253    'HOUR'=>$row['hour'],
     254    'LOGIN'=>$row['login'],
     255    'IP'=>$row['IP'],
     256    'CATEGORY'=>$row['category'],
     257    'FILE'=>$row['file'],
     258    'PICTURE'=>$row['picture'],
     259    'T_CLASS'=>$class
     260  ));
     261  }
     262
     263
     264// Get total number of logs
     265$query = '
     266    SELECT COUNT(date) as nb_logs
     267     FROM '.HISTORY_TABLE.
     268  $where.'
     269    ;';
     270
     271  $result = pwg_query($query);
     272  $row = mysql_fetch_array($result);
     273  $page['nb_logs']=$row['nb_logs'];
     274
     275  //display nav bar
     276  $url = $_SERVER['PHP_SELF'].'?page=stats&year='.$_GET['year'];
     277  $url .= '&month='.$_GET['month'].'&day='.$_GET['day'];
     278  $page['navigation_bar'] =
     279  create_navigation_bar( $url, $page['nb_logs'],$page['start'],$conf['nb_logs_page'], 'admin' );
     280$template->assign_block_vars('navigation',
     281    array('NAV_BAR' => $page['navigation_bar'])
     282    );
     283
    151284//----------------------------------------------------------- sending html code
    152285$template->assign_var_from_handle('ADMIN_CONTENT', 'stats');
    153286?>
     287
Note: See TracChangeset for help on using the changeset viewer.