Index: /extensions/AStat/admin/astat_admin.tpl
===================================================================
--- /extensions/AStat/admin/astat_admin.tpl (revision 3394)
+++ /extensions/AStat/admin/astat_admin.tpl (revision 3394)
@@ -0,0 +1,35 @@
+
+
:: {$plugin.ASTAT_VERSION} ::
+ {'AStat_title_page'|@translate} {$TABSHEET_TITLE}
+
+ {$tabsheet}
+
+
+{if isset($datas)}
+ {$datas.ASTAT_NFO_STAT}
+ {$datas.L_STAT_TITLE}
+
+ {if isset($f_AStat_catfilter_list_values) and count($f_AStat_catfilter_list_values)
+ and isset($plugin.ASTAT_PAGE) and $plugin.ASTAT_PAGE != "config" and $plugin.ASTAT_PAGE != "tools"}
+
+
+
+ {/if}
+
+{/if}
+
+{$ASTAT_BODY_PAGE}
+
Index: /extensions/AStat/admin/astat_by_category.tpl
===================================================================
--- /extensions/AStat/admin/astat_by_category.tpl (revision 3394)
+++ /extensions/AStat/admin/astat_by_category.tpl (revision 3394)
@@ -0,0 +1,74 @@
+
+{literal}
+
+{/literal}
+
+
+{$datas.ASTAT_SORT_LABEL}
+
+
+ {'CATEGORY_LABEL'|@translate}
+ {$datas.ASTAT_LABEL_pct_Pages_seen} ♦
+ {$datas.ASTAT_LABEL_pct_Pictures_seen} ♦
+ {$datas.ASTAT_LABEL_ratio_Pictures_seen}
+
+
+ {if isset($datarows) and count($datarows)}
+ {foreach from=$datarows key=name item=data}
+
+ {$data.CATEGORY}
+ {$data.PCTPAGES}
+ {$data.PCTPICTURES}
+ {$data.RATIOPICTURES}
+
+
+
+
+
+
+ {/foreach}
+ {/if}
+
+
+{$datas.NB_TOTAL_CATEGORY}
+
+{if isset($datas.ASTAT_TIME_REQUEST)}
+ {$datas.ASTAT_TIME_REQUEST}
+{/if}
+
+{if isset($datas.PAGES_LINKS)}
+ {$datas.PAGES_LINKS}
+{/if}
Index: /extensions/AStat/admin/astat_by_image.tpl
===================================================================
--- /extensions/AStat/admin/astat_by_image.tpl (revision 3394)
+++ /extensions/AStat/admin/astat_by_image.tpl (revision 3394)
@@ -0,0 +1,74 @@
+{literal}
+
+{/literal}
+
+
+{$datas.ASTAT_SORT_LABEL}
+
+
+ {$datas.ASTAT_LABEL_AStat_RefImageLabel}
+ {$datas.ASTAT_LABEL_Pictures_seen} ♦
+ {$datas.ASTAT_LABEL_pct_Pictures_seen} ♦
+
+
+ {if isset($datarows) and count($datarows)}
+ {foreach from=$datarows key=name item=data}
+
+ {$data.IMAGE}
+ {$data.NBPICTURES}
+ {$data.PCTPICTURES}
+
+
+
+
+
+
+ {/foreach}
+ {/if}
+
+
+{$datas.NB_TOTAL_IMAGE}
+
+{if isset($datas.ASTAT_TIME_REQUEST)}
+ {$datas.ASTAT_TIME_REQUEST}
+{/if}
+
+{if isset($datas.PAGES_LINKS)}
+ {$datas.PAGES_LINKS}
+{/if}
+
+
Index: /extensions/AStat/admin/astat_by_ip.tpl
===================================================================
--- /extensions/AStat/admin/astat_by_ip.tpl (revision 3394)
+++ /extensions/AStat/admin/astat_by_ip.tpl (revision 3394)
@@ -0,0 +1,31 @@
+{$datas.ASTAT_SORT_LABEL}
+
+
+ {$datas.ASTAT_LABEL_IP_label}
+ {$datas.ASTAT_LABEL_Pages_seen} ♦
+ {$datas.ASTAT_LABEL_Pictures_seen} ♦
+
+
+ {if isset($datarows) and count($datarows)}
+ {foreach from=$datarows key=name item=data}
+
+ {$data.ASTAT_IP_GEOLOCALISATION} {$data.ASTAT_IP_ADRESS}
+ {$data.PAGES}
+ {$data.PICTURES}
+
+
+
+
+
+ {/foreach}
+ {/if}
+
+{$datas.NB_TOTAL_IP}
+{if isset($datas.ASTAT_TIME_REQUEST)}
+ {$datas.ASTAT_TIME_REQUEST}
+{/if}
+
+{if isset($datas.PAGES_LINKS)}
+ {$datas.PAGES_LINKS}
+{/if}
+
Index: /extensions/AStat/admin/astat_by_period.tpl
===================================================================
--- /extensions/AStat/admin/astat_by_period.tpl (revision 3394)
+++ /extensions/AStat/admin/astat_by_period.tpl (revision 3394)
@@ -0,0 +1,32 @@
+
+
+ {$datas.PERIOD_LABEL}
+ {'Pages seen'|@translate} ♦
+ {'Pictures_seen'|@translate} ♦
+ {'Categories_seen'|@translate} ♦
+ {'IP_visit'|@translate} ♦
+
+
+
+ {if isset($datarows) and count($datarows)}
+ {foreach from=$datarows key=name item=data}
+
+ {$data.VALUE}
+ {$data.PAGES}
+ {$data.PICTURES}
+ {$data.CATEGORIES}
+ {$data.IPVISIT}
+
+
+
+
+
+
+
+ {/foreach}
+ {/if}
+
+
+{if isset($datas.ASTAT_TIME_REQUEST)}
+ {$datas.ASTAT_TIME_REQUEST}
+{/if}
Index: /extensions/AStat/admin/astat_config.tpl
===================================================================
--- /extensions/AStat/admin/astat_config.tpl (revision 3394)
+++ /extensions/AStat/admin/astat_config.tpl (revision 3394)
@@ -0,0 +1,193 @@
+{literal}
+
+{/literal}
+
+
+
+
+
Index: /extensions/AStat/admin/astat_tools.tpl
===================================================================
--- /extensions/AStat/admin/astat_tools.tpl (revision 3394)
+++ /extensions/AStat/admin/astat_tools.tpl (revision 3394)
@@ -0,0 +1,130 @@
+{literal}
+
+{/literal}
+
+{$datas.ASTAT_RESULT_OK}
+
+
+ {'AStat_tools_general_nfo'|@translate}
+ {$datas.ASTAT_GENERAL_NFO}
+
+
+
+
+
+
+
+
+ {'AStat_tools_deleted_picture'|@translate}
+ {'AStat_tools_deleted_picture_nfo0'|@translate}
+ {$datas.ASTAT_DELETED_PICTURE_NFO}
+
+
+ {'AStat_tools_deleted_picture_nfo3'|@translate}
+
+
+
+
+
+
+ {'AStat_tools_deleted_category'|@translate}
+ {'AStat_tools_deleted_category_nfo0'|@translate}
+ {$datas.ASTAT_DELETED_CATEGORY_NFO}
+
+
+
+
+
+ {'AStat_tools_purge_history'|@translate}
+ {'AStat_tools_purge_history_nfo'|@translate}
+
+
+
Index: /extensions/AStat/admin/index.php
===================================================================
--- /extensions/AStat/admin/index.php (revision 3394)
+++ /extensions/AStat/admin/index.php (revision 3394)
@@ -0,0 +1,33 @@
+
Index: /extensions/AStat/admin/plugin_admin.php
===================================================================
--- /extensions/AStat/admin/plugin_admin.php (revision 3394)
+++ /extensions/AStat/admin/plugin_admin.php (revision 3394)
@@ -0,0 +1,27 @@
+>
+ ------------------------------------------------------------------------------
+ See main.inc.php for release information
+
+ --------------------------------------------------------------------------- */
+
+if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+
+include(ASTAT_PATH."astat_aip.class.inc.php");
+
+global $prefixeTable;
+
+load_language('plugin.lang', ASTAT_PATH);
+
+$main_plugin_object = get_plugin_data($plugin_id);
+
+$plugin_ai = new AStat_AIP($prefixeTable, $main_plugin_object->get_filelocation());
+$plugin_ai->manage();
+
+?>
Index: /extensions/AStat/astat_aim.class.inc.php
===================================================================
--- /extensions/AStat/astat_aim.class.inc.php (revision 3394)
+++ /extensions/AStat/astat_aim.class.inc.php (revision 3394)
@@ -0,0 +1,199 @@
+>
+ ------------------------------------------------------------------------------
+ See main.inc.php for release information
+
+ AStat_AIM : classe to manage plugin integration into plugin menu
+
+ --------------------------------------------------------------------------- */
+
+if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+
+include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/common_plugin.class.inc.php');
+include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/css.class.inc.php');
+
+class AStat_AIM extends common_plugin
+{
+ protected $css = null;
+
+ function AStat_AIM($prefixeTable, $filelocation)
+ {
+ $this->plugin_name="AStat.2";
+ $this->plugin_name_files="astat";
+ parent::__construct($prefixeTable, $filelocation);
+ $this->css = new css(dirname($this->filelocation).'/'.$this->plugin_name_files.".css");
+ }
+
+ /*
+ initialize events call for the plugin
+ */
+ function init_events()
+ {
+ add_event_handler('get_admin_plugin_menu_links', array(&$this, 'plugin_admin_menu') );
+ }
+
+
+ /*
+ initialization of config properties
+ */
+ function init_config()
+ {
+ $this->my_config=array(
+ 'AStat_BarColor_Pages' => '6666ff',
+ 'AStat_BarColor_Img' => '66ff66',
+ 'AStat_BarColor_IP' => 'ff6666',
+ 'AStat_MouseOverColor' => '303030',
+ 'AStat_NpIPPerPages' => '25',
+ 'AStat_NpCatPerPages' => '50',
+ 'AStat_MaxBarWidth' => '400',
+ 'AStat_default_period' => 'global', //global, all, year, month, day
+ 'AStat_ShowThumbCat' => 'true',
+ 'AStat_DefaultSortCat' => 'page', //page, picture, nbpicture
+ 'AStat_ShowThumbImg' => 'true',
+ 'AStat_DefaultSortImg' => 'picture', //picture, catname
+ 'AStat_NbImgPerPages' => '100',
+ 'AStat_BarColor_Cat' => 'fff966',
+ 'AStat_DefaultSortIP' => 'page', //page, ip, picture
+ 'AStat_SeeTimeRequests' => 'false'
+ );
+
+ }
+
+ /*
+ surchage of common_plugin->save_config function
+ */
+ function load_config()
+ {
+ parent::load_config();
+ if(!$this->css->css_file_exists())
+ {
+ $this->css->make_CSS($this->generate_CSS());
+ }
+ }
+
+ /*
+ surchage of common_plugin->save_config function
+ */
+ function save_config()
+ {
+ if(parent::save_config())
+ {
+ $this->css->make_CSS($this->generate_CSS());
+ return(true);
+ }
+ return(false);
+ }
+
+ /*
+ generate the css code
+ */
+ function generate_CSS()
+ {
+ $text = ".AStatBar1, .AStatBar2, .AStatBar3, .AStatBar4, .AStatBarX {
+ border:0px;
+ height:8px;
+ display: block;
+ margin:0px;
+ padding:0px;
+ left:0;
+ position:relative;
+ }
+ .MiniSquare1, .MiniSquare2, .MiniSquare3, .MiniSquare4 {
+ border:0px;
+ height:8px;
+ width:8px;
+ margin:0px;
+ padding:0px;
+ }
+ .AStatBar1 { background-color:#".$this->my_config['AStat_BarColor_Pages']."; top:5px; }
+ .AStatBar2 { background-color:#".$this->my_config['AStat_BarColor_Img']."; top:-3px; }
+ .AStatBar3 { background-color:#".$this->my_config['AStat_BarColor_IP']."; top:-3px;}
+ .AStatBar4 { background-color:#".$this->my_config['AStat_BarColor_Cat']."; top:-3px;}
+ .AStatBarX { background-color:transparent; top:-3px; height:1px; }
+ .MiniSquare1 { color:#".$this->my_config['AStat_BarColor_Pages']."; }
+ .MiniSquare2 { color:#".$this->my_config['AStat_BarColor_Img']."; }
+ .MiniSquare3 { color:#".$this->my_config['AStat_BarColor_IP']."; }
+ .MiniSquare4 { color:#".$this->my_config['AStat_BarColor_Cat']."; }
+ .StatTableRow:hover { background-color:#".$this->my_config['AStat_MouseOverColor']."; }
+ .formtable, .formtable P { text-align:left; display:block; }
+ .window_thumb {
+ position:absolute;
+ border: none;
+ background: none;
+ left:0;
+ top:0;
+ margin:0px;
+ padding:0px;
+ z-index:100;
+ overflow:hidden;
+ visibility:hidden; }
+ .img_thumb {
+ border: solid 3px #ffffff;
+ background: #000000;
+ margin:0px;
+ padding:0px; }
+ .time_request {
+ font-size:83%;
+ text-align:right; }
+ .invisible { visibility:hidden; display:none; }
+ .littlefont { font-size:90%; }
+ table.littlefont th { padding:3px; }
+ table.littlefont td { padding:0px;padding-left:3px;padding-right:3px; }
+ ";
+
+ return($text);
+ }
+
+ /* ---------------------------------------------------------------------------
+ Function needed for plugin activation
+ --------------------------------------------------------------------------- */
+
+ /*
+ get 'section' enumeration from HISTORY_TABLE
+ */
+ function get_section_enum($add)
+ {
+ $returned=array('', false);
+ $sql = 'SHOW COLUMNS FROM '.HISTORY_TABLE.' LIKE "section"';
+ $result=pwg_query($sql);
+ if($result)
+ {
+ $row = mysql_fetch_array($result);
+ $list=substr($row['Type'], 5, strlen($row['Type'])-6);
+ $returned[0]=explode(',', $list);
+ if((strpos($list, "'$add'")===false)&&($add!=''))
+ { array_push($returned[0], "'$add'"); }
+ else
+ { $returned[1]=true; }
+ return($returned);
+ }
+ }
+
+ function alter_history_section_enum($section)
+ {
+ $sections=$this->get_section_enum('deleted_cat');
+ if(!$sections[1])
+ {
+ $enums=implode(',', $sections[0]);
+ $sql="ALTER TABLE ".HISTORY_TABLE."
+ CHANGE `section` `section`
+ ENUM (".$enums.") ;";
+ $result=pwg_query($sql);
+ if(!$result)
+ {
+ return(false);
+ }
+ }
+ return(true);
+ }
+
+} // AStat_Plugin class
+
+
+?>
Index: /extensions/AStat/astat_aip.class.inc.php
===================================================================
--- /extensions/AStat/astat_aip.class.inc.php (revision 3394)
+++ /extensions/AStat/astat_aip.class.inc.php (revision 3394)
@@ -0,0 +1,2258 @@
+>
+ ------------------------------------------------------------------------------
+ See main.inc.php for release information
+
+ AI classe => manage integration in administration interface
+
+ --------------------------------------------------------------------------- */
+if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+
+include_once('astat_aim.class.inc.php');
+include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
+
+class AStat_AIP extends AStat_AIM
+{
+ protected $tabsheet;
+ protected $list_periods = array('global', 'all', 'year', 'month', 'day');
+ protected $list_sortcat = array('page', 'picture', 'nbpicture');
+ protected $list_sortimg = array('picture', 'catname');
+ protected $list_sortip = array('page', 'picture', 'ip');
+
+ protected $catfilter; //filter on categories
+ protected $max_width;
+ protected $seetimerequest;
+
+ function AStat_AIP($prefixeTable, $filelocation)
+ {
+ parent::__construct($prefixeTable, $filelocation);
+
+ $this->load_config();
+ $this->init_events();
+
+ $this->tabsheet = new tabsheet();
+ $this->tabsheet->add('stats_by_period',
+ l10n('AStat_by_period'),
+ $this->page_link.'&fAStat_tabsheet=stats_by_period');
+ $this->tabsheet->add('stats_by_ip',
+ l10n('AStat_by_ip'),
+ $this->page_link.'&fAStat_tabsheet=stats_by_ip');
+ $this->tabsheet->add('stats_by_category',
+ l10n('AStat_by_category'),
+ $this->page_link.'&fAStat_tabsheet=stats_by_category');
+ $this->tabsheet->add('stats_by_image',
+ l10n('AStat_by_image'),
+ $this->page_link.'&fAStat_tabsheet=stats_by_image');
+ $this->tabsheet->add('config',
+ l10n('AStat_config'),
+ $this->page_link.'&fAStat_tabsheet=config');
+ $this->tabsheet->add('tools',
+ l10n('AStat_tools'),
+ $this->page_link.'&fAStat_tabsheet=tools');
+ }
+
+ /*
+ initialize events call for the plugin
+ */
+ function init_events()
+ {
+ add_event_handler('loc_end_page_header', array(&$this->css, 'apply_CSS'));
+ }
+
+
+
+ /* ---------------------------------------------------------------------------
+ Public classe functions
+ --------------------------------------------------------------------------- */
+
+ /*
+ manage plugin integration into piwigo's admin interface
+ */
+ public function manage()
+ {
+ global $template;
+
+ $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/astat_admin.tpl");
+
+ $this->init_request();
+
+ $this->make_filter_list($_REQUEST['fAStat_catfilter']);
+ if($_REQUEST['fAStat_catfilter']!="")
+ {
+ $this->page_link.="&fAStat_catfilter=".$_REQUEST['fAStat_catfilter'];
+ }
+
+ if($_REQUEST['fAStat_tabsheet']=='stats_by_period')
+ {
+ $this->display_stats_by_period(
+ $_REQUEST['fAStat_all'],
+ $_REQUEST['fAStat_year'],
+ $_REQUEST['fAStat_month'],
+ $_REQUEST['fAStat_day'],
+ $this->my_config['AStat_MaxBarWidth'],
+ $this->my_config['AStat_SeeTimeRequests']
+ );
+ }
+ elseif($_REQUEST['fAStat_tabsheet']=='stats_by_ip')
+ {
+ $this->display_stats_by_ip(
+ $_REQUEST['fAStat_year'],
+ $_REQUEST['fAStat_month'],
+ $_REQUEST['fAStat_day'],
+ $this->my_config['AStat_MaxBarWidth'],
+ $this->my_config['AStat_NpIPPerPages'],
+ $_REQUEST['fAStat_page_number'],
+ $_REQUEST['fAStat_SortIP'],
+ $this->my_config['AStat_SeeTimeRequests']
+ );
+ }
+ elseif($_REQUEST['fAStat_tabsheet']=='stats_by_category')
+ {
+ $this->display_stats_by_category(
+ $_REQUEST['fAStat_year'],
+ $_REQUEST['fAStat_month'],
+ $_REQUEST['fAStat_day'],
+ $this->my_config['AStat_MaxBarWidth'],
+ $this->my_config['AStat_NpCatPerPages'],
+ $_REQUEST['fAStat_page_number'],
+ $this->my_config['AStat_ShowThumbCat'],
+ $_REQUEST['fAStat_SortCat'],
+ $this->my_config['AStat_SeeTimeRequests']
+ );
+ }
+ elseif($_REQUEST['fAStat_tabsheet']=='stats_by_image')
+ {
+ $this->display_stats_by_image(
+ $_REQUEST['fAStat_year'],
+ $_REQUEST['fAStat_month'],
+ $_REQUEST['fAStat_day'],
+ $this->my_config['AStat_MaxBarWidth'],
+ $this->my_config['AStat_NbImgPerPages'],
+ $_REQUEST['fAStat_page_number'],
+ $this->my_config['AStat_ShowThumbImg'],
+ $_REQUEST['fAStat_SortImg'],
+ $_REQUEST['fAStat_IP'],
+ $this->my_config['AStat_SeeTimeRequests']
+ );
+ }
+ elseif($_REQUEST['fAStat_tabsheet']=='config')
+ {
+ $this->display_config();
+ }
+ elseif($_REQUEST['fAStat_tabsheet']=='tools')
+ {
+ $this->display_tools();
+ }
+
+ $this->tabsheet->select($_REQUEST['fAStat_tabsheet']);
+ $this->tabsheet->assign();
+ $selected_tab=$this->tabsheet->get_selected();
+ $template->assign($this->tabsheet->get_titlename(), "[".$selected_tab['caption']."]");
+
+ $template_plugin["ASTAT_VERSION"] = "AStat ".l10n('AStat_version').ASTAT_VERSION;
+ $template_plugin["ASTAT_PAGE"] = $_REQUEST['fAStat_tabsheet'];
+
+ $template->assign('plugin', $template_plugin);
+ $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+ }
+
+ /* ---------------------------------------------------------------------------
+ Private classe functions
+ --------------------------------------------------------------------------- */
+
+ private function init_request()
+ {
+ $default_request = array('all'=>'Y', 'year'=>'', 'month'=>'', 'day'=>'');
+
+ //initialise $REQUEST values if not defined
+ if(!array_key_exists('fAStat_tabsheet', $_REQUEST))
+ {
+ $_REQUEST['fAStat_tabsheet']='stats_by_period';
+ }
+ if(!array_key_exists('fAStat_defper', $_REQUEST))
+ {
+ $_REQUEST['fAStat_defper']='Y';
+ }
+ if(!array_key_exists('fAStat_SortCat', $_REQUEST))
+ {
+ $_REQUEST['fAStat_SortCat']=$this->my_config['AStat_DefaultSortCat'];
+ }
+ if(!array_key_exists('fAStat_SortImg', $_REQUEST))
+ {
+ $_REQUEST['fAStat_SortImg']=$this->my_config['AStat_DefaultSortImg'];
+ }
+ if(!array_key_exists('fAStat_SortIP', $_REQUEST))
+ {
+ $_REQUEST['fAStat_SortIP']=$this->my_config['AStat_DefaultSortIP'];
+ }
+ if(!array_key_exists('fAStat_page_number', $_REQUEST))
+ {
+ $_REQUEST['fAStat_page_number']='1';
+ }
+ if(!array_key_exists('fAStat_IP', $_REQUEST))
+ {
+ $_REQUEST['fAStat_IP']="";
+ }
+ if(!array_key_exists('fAStat_purge_history_date', $_REQUEST))
+ {
+ $_REQUEST['fAStat_purge_history_date']="";
+ }
+ if(!array_key_exists('fAStat_catfilter', $_REQUEST))
+ {
+ $_REQUEST['fAStat_catfilter']="";
+ }
+
+ if(($_REQUEST['fAStat_tabsheet']=='stats_by_period')&&($_REQUEST['fAStat_defper']=='Y'))
+ {
+ if($this->my_config['AStat_default_period']!='global')
+ {
+ $default_request['all'] = 'N';
+ }
+
+ if(($this->my_config['AStat_default_period']=='year')||
+ ($this->my_config['AStat_default_period']=='month')||
+ ($this->my_config['AStat_default_period']=='day'))
+ {
+ $default_request['year'] = date('Y');
+ }
+
+ if(($this->my_config['AStat_default_period']=='month')||
+ ($this->my_config['AStat_default_period']=='day'))
+ {
+ $default_request['month'] = date('n');
+ }
+
+ if($this->my_config['AStat_default_period']=='day')
+ {
+ $default_request['day'] = date('j');
+ }
+ }
+
+ if(!array_key_exists('fAStat_all', $_REQUEST))
+ {
+ $_REQUEST['fAStat_all']=$default_request['all'];
+ }
+ if(!array_key_exists('fAStat_year', $_REQUEST))
+ {
+ $_REQUEST['fAStat_year']=$default_request['year'];
+ }
+ if(!array_key_exists('fAStat_month', $_REQUEST))
+ {
+ $_REQUEST['fAStat_month']=$default_request['month'];
+ }
+ if(!array_key_exists('fAStat_day', $_REQUEST))
+ {
+ $_REQUEST['fAStat_day']=$default_request['day'];
+ }
+
+ $this->catfilter=$_REQUEST['fAStat_catfilter'];
+
+ } //init_request
+
+
+ /*
+ request functions
+
+ theses functions made SQL requests and returns datas
+ */
+
+
+ /*
+ Stat by period
+ Number of Pages
+ Number IP
+ Number of Images
+ by :
+ total
+ years
+ years/months
+ years/months/days
+ years/months/days/hours
+ */
+ private function stats_by_period($total, $year, $month, $day)
+ {
+ $returned = array();
+ $delta = 0;
+
+ $sql = " count(id) as NbPages, count(distinct IP) as NbIP,
+ count(image_id) as NbImg, count(distinct category_id) as NbCat ";
+ $sql_nfomax = ", MaxPages, MaxIP, MaxImg";
+ $sql_from = " from ".HISTORY_TABLE." ";
+ $sql_where = "";
+ $sql_order = "";
+ $sql_select = "";
+ $sql_group = "";
+ $sql_groupdef="";
+
+ if($day!="")
+ {
+ $sql_groupdef="HOUR(time) as GId,";
+ $sql_select="select HOUR(time) as GId, ";
+ $sql_where=" where YEAR(date) = $year and MONTH(date) = $month and DAY(date) = $day ";
+ $sql_group=" group by GId ";
+ $sql_order=" order by GId asc";
+
+ for($i=0;$i<24;$i++)
+ {
+ $returned[$i] = array(
+ "GId" => $i,
+ "NbPages" => 0,
+ "NbIP" => 0,
+ "NbImg" => 0,
+ "NbCat"=>0,
+ "MaxPages" => 0,
+ "MaxIP" => 0,
+ "MaxImg" => 0
+ );
+ }
+ }
+ elseif($month!="")
+ {
+ $sql_groupdef="DAY(date) as GId,";
+ $sql_select="select DAY(date) as GId, ";
+ $sql_where=" where YEAR(date) = $year and MONTH(date) = $month ";
+ $sql_group=" group by GId ";
+ $sql_order=" order by GId asc";
+
+ $delta = 1;
+ $NbDays = strftime('%d', mktime(0,0,0,$month+1,0,$year));
+ for($i=0;$i<$NbDays;$i++)
+ {
+ $returned[$i] = array(
+ "GId" => $i+1,
+ "NbPages" => 0,
+ "NbIP" => 0,
+ "NbImg" => 0,
+ "NbCat"=>0,
+ "MaxPages" => 0,
+ "MaxIP" => 0,
+ "MaxImg" => 0
+ );
+ }
+ }
+ elseif($year!="")
+ {
+ $sql_groupdef="MONTH(date) as GId,";
+ $sql_select="select MONTH(date) as GId, ";
+ $sql_where=" where YEAR(date) = $year ";
+ $sql_group=" group by GId ";
+ $sql_order=" order by GId asc ";
+
+ $delta = 1;
+ for($i=0;$i<12;$i++)
+ {
+ $returned[$i] = array(
+ "GId" => $i+1,
+ "NbPages" => 0,
+ "NbIP" => 0,
+ "NbImg" => 0,
+ "NbCat"=>0,
+ "MaxPages" => 0,
+ "MaxIP" => 0,
+ "MaxImg" => 0
+ );
+ }
+ }
+ elseif($total!="Y")
+ {
+ $sql_groupdef="YEAR(date) as GId,";
+ $sql_select="select YEAR(date) as GId, ";
+ $sql_group=" group by GId ";
+ $sql_order=" order by GId desc";
+ }
+ else
+ {
+ $sql_select="select 'Tout' as GId, "; $sql_nfomax=", 0 as MaxPages, 0 as MaxIP, 0 as MaxImg";
+ }
+
+ if($this->catfilter!="")
+ {
+ $catfilter=$this->make_where_clause($this->catfilter);
+ ($sql_where=="")?$sql_where=" where ":$sql_where.=" and ";
+ $sql_where.=" category_id IN (".$catfilter.")";
+ }
+
+ $sql_max=", (select max(n.MaxPages) as MaxPages, max(n.MaxIP) as MaxIP, max(n.MaxImg) as MaxImg
+ from (select ".$sql_groupdef." count(id) as MaxPages, count(distinct IP) as MaxIP, count(image_id) as MaxImg
+ from ".HISTORY_TABLE.$sql_where.$sql_group.") as n) as n ";
+ $sql=$sql_select.$sql.$sql_nfomax.$sql_from.$sql_max.$sql_where.$sql_group.$sql_order;
+
+ $result = pwg_query($sql);
+
+ $i=0;
+ while ($row = mysql_fetch_array($result))
+ {
+ if($year.$month.$day=="")
+ { $returned[$i] = $row; $i++; }
+ else
+ { $returned[$row["GId"]-$delta] = $row; }
+ }
+
+ return($returned);
+ } //stat by period
+
+ /*
+ Stats by IP
+ Number of Pages
+ Number of Images
+ by :
+ IP
+ IP/years
+ IP/years/months
+ IP/years/months/days
+ */
+ private function stats_by_ip($year, $month, $day, $nbipperpage, $pagenumber, $sortip)
+ {
+ $returned0 = array();
+ $sortlist = array(
+ "page" => "NbPages desc",
+ "picture" => "NbImg desc",
+ "ip" => "IP_USER asc"
+ );
+
+ $sql_select="select SQL_CALC_FOUND_ROWS ";
+ $sql= " if(".HISTORY_TABLE.".user_id = 2, IP, if(".USERS_TABLE.".username is null, ' [".l10n("AStat_deleted_user")."]', CONCAT(' ', ".USERS_TABLE.".username))) as IP_USER, count(".HISTORY_TABLE.".id) as NbPages, count(image_id) as NbImg ";
+ $sql_nfomax = ", MaxPages, MaxImg";
+ $sql_from = " from ".HISTORY_TABLE." LEFT JOIN ".USERS_TABLE." ON ".HISTORY_TABLE.".user_id = ".USERS_TABLE.".id ";
+ $sql_where = "";
+ $sql_group=" group by IP_USER ";
+ $sql_order=" order by ".$sortlist[$sortip]." ";
+ $sql_limit=" limit ".(($pagenumber-1)* $nbipperpage).", ".$nbipperpage;
+
+
+ if($day!="")
+ {
+ $sql_where=" where YEAR(date) = $year and MONTH(date) = $month and DAY(date) = $day ";
+ }
+ elseif($month!="")
+ {
+ $sql_where=" where YEAR(date) = $year and MONTH(date) = $month ";
+ }
+ elseif($year!="")
+ {
+ $sql_where=" where YEAR(date) = $year ";
+ }
+ else
+ {
+ $sql_nfomax = ", 0 as MaxPages, 0 as MaxImg";
+ }
+
+ if($this->catfilter!="")
+ {
+ $catfilter=$this->make_where_clause($this->catfilter);
+ ($sql_where=="")?$sql_where=" where ":$sql_where.=" and ";
+ $sql_where.=" category_id IN (".$catfilter.")";
+ }
+
+ $sql_max=", (select max(n.MaxPages) as MaxPages, max(n.MaxImg) as MaxImg
+ from (select if(".HISTORY_TABLE.".user_id = 2, IP, if(".USERS_TABLE.".username is null, '[".l10n("AStat_deleted_user")."]', ".USERS_TABLE.".username)) as IP_USER, count(".HISTORY_TABLE.".id) as MaxPages, count(image_id) as MaxImg
+ from ".HISTORY_TABLE." LEFT JOIN ".USERS_TABLE." ON ".HISTORY_TABLE.".user_id = ".USERS_TABLE.".id ".$sql_where.$sql_group.") as n) as n ";
+ $sql=$sql_select.$sql.$sql_nfomax.$sql_from.$sql_max.$sql_where.$sql_group.$sql_order.$sql_limit;
+
+ $result = pwg_query($sql);
+ $sql="select FOUND_ROWS()";
+
+ $i=0;
+ while ($row = mysql_fetch_array($result))
+ {
+ $returned0[$i] = $row; $i++;
+ }
+ $returned[0] = $returned0;
+
+ $result = pwg_query($sql);
+ if($result)
+ {
+ $row = mysql_fetch_array($result); $returned[1] = $row[0];
+ }
+ else
+ {
+ $returned[1] = -1;
+ }
+
+ return($returned);
+ } //stat by ip
+
+ /*
+ Stats per categories
+ %Pages
+ %Images
+ by :
+ Categories
+ Categories/years
+ Categories/years/months
+ Categories/years/months/day
+ */
+ private function stats_by_category($year, $month, $day, $nbipperpage, $pagenumber, $show_thumb, $sortcat)
+ {
+ $sortlist = array(
+ "page" => "PctPages desc, PctImg desc",
+ "picture" => "PctImg desc, PctPages desc",
+ "nbpicture" => "RatioImg desc, PctPages desc"
+ );
+ $returned0 = array();
+
+ $sql_select="select SQL_CALC_FOUND_ROWS ";
+
+ $sql= "category_id, if(category_id > 0, ".CATEGORIES_TABLE.".name, section) as IdCat,
+ count(".HISTORY_TABLE.".id) as NbPages, MaxPages.somme, 100*(count(".HISTORY_TABLE.".id)/MaxPages.somme) as PctPages,
+ count(".HISTORY_TABLE.".image_id) as NbImg, MaxImg.somme, 100*(count(".HISTORY_TABLE.".image_id)/MaxImg.somme) as PctImg, ic2.nb_images as NbImgCat, (count(".HISTORY_TABLE.".image_id)/ic2.nb_images) as RatioImg, greatest(100*(count(".HISTORY_TABLE.".id)/MaxPages.somme), 100*(count(".HISTORY_TABLE.".image_id)/MaxImg.somme)) as MaxPct ";
+
+ if($show_thumb=='true')
+ {
+ $sql_thumb = ', '.IMAGES_TABLE.'.path as ThumbPath, '.IMAGES_TABLE.'.file as ThumbFile, '.IMAGES_TABLE.'.tn_ext as Extension';
+ $sql_fromthumb = "LEFT JOIN ".IMAGES_TABLE." ON ic2.representative_picture_id = ".IMAGES_TABLE.".id ";
+ }
+ else
+ {
+ $sql_thumb = "";
+ $sql_fromthumb = "";
+ }
+
+ $sql_from = " from (".HISTORY_TABLE." LEFT JOIN ".CATEGORIES_TABLE." ON ".CATEGORIES_TABLE.".id = ".HISTORY_TABLE.".category_id),
+(select category_id as catid, count(image_id) as nb_images, representative_picture_id
+ from ".IMAGE_CATEGORY_TABLE.", ".CATEGORIES_TABLE."
+ where ".CATEGORIES_TABLE.".id = ".IMAGE_CATEGORY_TABLE.".category_id group by category_id) as ic2 ";
+ $sql_where = "";
+ $sql_group=" group by category_id, section ";
+ $sql_group2="";
+ $sql_order=" order by ".$sortlist[$sortcat];
+ $sql_limit=" limit ".(($pagenumber-1)* $nbipperpage).", ".$nbipperpage;
+
+ if($day!="")
+ {
+ $sql_where=" where YEAR(date) = $year and MONTH(date) = $month and DAY(date)= $day ";
+ }
+ elseif($month!="")
+ {
+ $sql_where=" where YEAR(date) = $year and MONTH(date) = $month ";
+ }
+ elseif($year!="")
+ {
+ $sql_where=" where YEAR(date) = $year ";
+ }
+ else { }
+
+ if($this->catfilter!="")
+ {
+ $catfilter=$this->make_where_clause($this->catfilter);
+ ($sql_where=="")?$sql_where=" where ":$sql_where.=" and ";
+ $sql_where.=" category_id IN (".$catfilter.")";
+ }
+
+ $sql_max=", (select count(id) as somme from ".HISTORY_TABLE.$sql_where.$sql_group2.") as MaxPages,
+ (select count(image_id) as somme from ".HISTORY_TABLE.$sql_where.$sql_group2.") as MaxImg ";
+
+ ($sql_where=="")?$sql_where=" where ":$sql_where.=" and ";
+ $sql_where .= " ic2.catid = ".HISTORY_TABLE.".category_id ";
+
+
+ $sql=$sql_select.$sql.$sql_thumb.$sql_from.$sql_fromthumb.$sql_max.$sql_where.$sql_group.$sql_order.$sql_limit;
+
+ $result = pwg_query($sql);
+ $sql="select FOUND_ROWS()";
+
+ $i=0;
+ while ($row = mysql_fetch_array($result))
+ {
+ $returned0[$i] = $row; $i++;
+ }
+ $returned[0] = $returned0;
+
+ $result = pwg_query($sql);
+ if($result)
+ {
+ $row = mysql_fetch_array($result); $returned[1] = $row[0];
+ }
+ else
+ {
+ $returned[1] = -1;
+ }
+
+ return($returned);
+ } // stats per categories
+
+ /*
+ Stats by image
+ Num of view per image
+ %view on period
+ by :
+ Images
+ Images/years
+ Images/years/months
+ Images/years/months/days
+ */
+ private function stats_by_image($year, $month, $day, $nbipperpage, $pagenumber, $sortimg, $ip)
+ {
+ $sortlist = array(
+ "picture" => "NbVues desc, CatName asc, ImgName asc, ImgId asc",
+ "catname" => "CatName asc, ImgName asc, ImgId asc"
+ );
+ $returned0 = array();
+
+ $sql_select="select SQL_CALC_FOUND_ROWS ";
+
+
+ $sql=" image_id as ImgId, ".IMAGES_TABLE.".name as ImgName,
+ if(category_id > 0, ".CATEGORIES_TABLE.".name, section) as CatName,
+ ".HISTORY_TABLE.".category_id as IdCat, count(".HISTORY_TABLE.".image_id) as NbVues,
+ MaxImg.somme, 100*(count(".HISTORY_TABLE.".image_id)/MaxImg.somme) as PctImg,
+ ".IMAGES_TABLE.".path as ThumbPath, ".IMAGES_TABLE.".file as ThumbFile,
+ MaxImg2.somme as NbVuesMax, ".IMAGES_TABLE.".tn_ext as Extension ";
+
+ $sql_from = " from ((".HISTORY_TABLE." LEFT JOIN ".IMAGES_TABLE." ON
+ ".IMAGES_TABLE.".id = ".HISTORY_TABLE.".image_id) LEFT JOIN ".CATEGORIES_TABLE."
+ ON ".CATEGORIES_TABLE.".id = ".HISTORY_TABLE.".category_id) ";
+ $sql_from_ip="";
+
+ $sql_where = " where ".HISTORY_TABLE.".image_id is not null ";
+ $sql_group=" group by image_id, category_id ";
+ $sql_order=" order by ".$sortlist[$sortimg];
+ $sql_limit=" limit ".(($pagenumber-1)* $nbipperpage).", ".$nbipperpage;
+
+ if($day!="")
+ {
+ $sql_where.=" and YEAR(date) = $year and MONTH(date) = $month and DAY(date)= $day ";
+ }
+ elseif($month!="")
+ {
+ $sql_where.=" and YEAR(date) = $year and MONTH(date) = $month ";
+ }
+ elseif($year!="")
+ {
+ $sql_where.=" and YEAR(date) = $year ";
+ }
+ else { }
+
+ if($ip!="")
+ {
+ $sql_where.=" and ( ((IP = '$ip') and ( user_id = 2 )) or (".USERS_TABLE.".username = '$ip') )";
+ $sql_from_ip=" LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".id = ".HISTORY_TABLE.".user_id ";
+ }
+
+ if($this->catfilter!="")
+ {
+ $catfilter=$this->make_where_clause($this->catfilter);
+ ($sql_where=="")?$sql_where=" where ":$sql_where.=" and ";
+ $sql_where.=" category_id IN (".$catfilter.")";
+ }
+
+ $sql_max=", (select count(image_id) as somme from ".HISTORY_TABLE.$sql_from_ip.$sql_where.") as MaxImg, (select count(image_id) as somme from ".HISTORY_TABLE.$sql_from_ip.$sql_where." and ".HISTORY_TABLE.".image_id is not null group by image_id order by somme desc limit 0,1) as MaxImg2 ";
+
+ $sql=$sql_select.$sql.$sql_from.$sql_from_ip.$sql_max.$sql_where.$sql_group.$sql_order.$sql_limit;
+
+ $result = pwg_query($sql);
+ $sql="select FOUND_ROWS()";
+
+ $i=0;
+ while ($row = mysql_fetch_array($result))
+ {
+ $returned0[$i] = $row; $i++;
+ }
+ $returned[0] = $returned0;
+
+ $result = pwg_query($sql);
+ if($result)
+ {
+ $row = mysql_fetch_array($result); $returned[1] = $row[0];
+ }
+ else
+ {
+ $returned[1] = -1;
+ }
+
+ return($returned);
+ } //stat by images
+
+
+ /*
+ template related functions
+
+ theses functions call stat function, and display result with template usage
+ */
+
+
+
+ private function display_stats_by_period($total, $year, $month, $day, $max_width, $seetimerequest)
+ {
+ global $template;
+
+ $template->set_filename('body_page', dirname(__FILE__)."/admin/astat_by_period.tpl");
+
+
+ $template_datas=array();
+ $template_datarows=array();
+
+
+ /* requete */
+ //calc_time(true);
+ $stats = $this->stats_by_period($total, $year, $month, $day);
+ //$timerequest=calc_time(false);
+
+ $dir_links = "";
+ $a_links=array("global" => $this->page_link."&fAStat_defper=N&fAStat_all=Y",
+ "all" => $this->page_link."&fAStat_defper=N&fAStat_all=N",
+ "year" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year",
+ "month" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=$month",
+ "day" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=$month&fAStat_day=$day");
+
+ $ip_links=array("all" => $this->page_link."&fAStat_tabsheet=stats_by_ip",
+ "year" => $this->page_link."&fAStat_tabsheet=stats_by_ip&fAStat_year=",
+ "month" => $this->page_link."&fAStat_tabsheet=stats_by_ip&fAStat_year=$year&fAStat_month=",
+ "day" => $this->page_link."&fAStat_tabsheet=stats_by_ip&fAStat_year=$year&fAStat_month=$month&fAStat_day=");
+
+ $cat_links=array("all" => $this->page_link."&fAStat_tabsheet=stats_by_category",
+ "year" => $this->page_link."&fAStat_tabsheet=stats_by_category&fAStat_year=",
+ "month" => $this->page_link."&fAStat_tabsheet=stats_by_category&fAStat_year=$year&fAStat_month=",
+ "day" => $this->page_link."&fAStat_tabsheet=stats_by_category&fAStat_year=$year&fAStat_month=$month&fAStat_day=");
+
+ $img_links=array("all" => $this->page_link."&fAStat_tabsheet=stats_by_image",
+ "year" => $this->page_link."&fAStat_tabsheet=stats_by_image&fAStat_year=",
+ "month" => $this->page_link."&fAStat_tabsheet=stats_by_image&fAStat_year=$year&fAStat_month=",
+ "day" => $this->page_link."&fAStat_tabsheet=stats_by_image&fAStat_year=$year&fAStat_month=$month&fAStat_day=");
+
+
+ /* period label + navigation links */
+ if($day!="")
+ {
+ $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_hours");
+ $template_datas["L_STAT_TITLE"] = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".$this->format_link(l10n("AStat_month_of_year_".$month), $a_links["month"])." / ".l10n("AStat_day_of_week_".date("w",mktime(0, 0, 0, $month, $day, $year)))." $day";
+ }
+ elseif($month!="")
+ {
+ $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_days");
+ $template_datas["L_STAT_TITLE"] = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".l10n("AStat_month_of_year_".$month);
+ }
+ elseif($year!="")
+ {
+ $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_months");
+ $template_datas["L_STAT_TITLE"] = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$year;
+ }
+ elseif($total!="Y")
+ {
+ $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_years");
+ $template_datas["L_STAT_TITLE"] = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".l10n("AStat_period_label_all");
+ }
+ else
+ {
+ $template_datas["PERIOD_LABEL"] = l10n("AStat_period_label_all");
+ $template_datas["L_STAT_TITLE"] = l10n("AStat_period_label_global");
+ }
+ $template_datas["MAX_WIDTH"] = $max_width+10;
+ $template_datas["ASTAT_NFO_STAT"] = l10n("AStat_Nfo_Period");
+
+ if($seetimerequest=='true')
+ {
+ $template_datas["ASTAT_TIME_REQUEST"] = l10n('AStat_time_request_label').' '.$timerequest.'s';
+ }
+
+ /* tableau de stat */
+ for($i=0;$i 0)
+ {
+ $width_pages = ceil(($stats[$i]["NbPages"] * $max_width) / $stats[$i]["MaxPages"] );
+ $width_img = ceil(($stats[$i]["NbImg"] * $max_width) / $stats[$i]["MaxPages"] );
+ $width_ip = ceil(($stats[$i]["NbIP"] * $max_width) / $stats[$i]["MaxPages"] );
+ $width_cat = ceil(($stats[$i]["NbCat"] * $max_width) / $stats[$i]["MaxPages"] );
+ }
+ else
+ {
+ $width_pages = 0;
+ $width_img = 0;
+ $width_ip = 0;
+ $width_cat = 0;
+ }
+
+
+ if($day!="")
+ { // si jours sélectionné, heures affichées
+ $value=$stats[$i]["GId"];
+ $link="";
+ $value_ip="";
+ $value_cat="";
+ $value_img="";
+ }
+ elseif($month!="")
+ { // si mois sélectionné, jours affichés
+ $value = $stats[$i]["GId"]." (".l10n("AStat_day_of_week_".date("w",mktime(0, 0, 0, $month, $stats[$i]["GId"], $year))).")";
+ $link=$this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=$month&fAStat_day=".$stats[$i]["GId"];
+ $value_ip=$ip_links["day"].$stats[$i]["GId"];
+ $value_cat=$cat_links["day"].$stats[$i]["GId"];
+ $value_img=$img_links["day"].$stats[$i]["GId"];
+ }
+ elseif($year!="")
+ { // si année sélectionnée, mois affichés
+ $value = l10n("AStat_month_of_year_".$stats[$i]["GId"]);
+ $link=$this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=".$stats[$i]["GId"];
+ $value_ip=$ip_links["month"].$stats[$i]["GId"];
+ $value_cat=$cat_links["month"].$stats[$i]["GId"];
+ $value_img=$img_links["month"].$stats[$i]["GId"];
+ }
+ elseif($total!="Y")
+ { // si total sélectionné, années affichées
+ $value = $stats[$i]["GId"];
+ $link=$this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=".$stats[$i]["GId"];
+ $value_ip=$ip_links["year"].$stats[$i]["GId"];
+ $value_cat=$cat_links["year"].$stats[$i]["GId"];
+ $value_img=$img_links["year"].$stats[$i]["GId"];
+ }
+ else
+ {
+ $value=l10n("AStat_period_label_all");
+ $link=$this->page_link."&fAStat_defper=N&fAStat_all=N";
+ $value_ip=$ip_links["all"];
+ $value_cat=$cat_links["all"];
+ $value_img=$img_links["all"];
+ }
+
+
+ if((($stats[$i]["NbPages"] + $stats[$i]["NbImg"] + $stats[$i]["NbIP"])>0)&&($link!=""))
+ { $value=$this->format_link($value, $link); }
+
+ if((($stats[$i]["NbIP"])>0)&&($value_ip!=""))
+ { $value_ip=$this->format_link($stats[$i]["NbIP"], $value_ip); }
+ else
+ { $value_ip = $stats[$i]["NbIP"]; }
+
+ if((($stats[$i]["NbCat"])>0)&&($value_cat!=""))
+ { $value_cat=$this->format_link($stats[$i]["NbCat"], $value_cat); }
+ else
+ { $value_cat= $stats[$i]["NbCat"]; }
+
+ if((($stats[$i]["NbImg"])>0)&&($value_img!=""))
+ { $value_img=$this->format_link($stats[$i]["NbImg"], $value_img); }
+ else
+ { $value_img= $stats[$i]["NbImg"]; }
+
+
+
+ $template_datarows[]=array(
+ 'VALUE' => $value,
+ 'PAGES' => $stats[$i]["NbPages"],
+ 'PICTURES' => $value_img,
+ 'CATEGORIES' => $value_cat,
+ 'IPVISIT' => $value_ip,
+ 'WIDTH1' => $width_ip,
+ 'WIDTH2' => $width_img,
+ 'WIDTH3' => $width_pages,
+ 'WIDTH4' => $width_cat,
+ );
+
+ }
+
+ $template->assign('datas', $template_datas);
+ $template->assign('datarows', $template_datarows);
+ $template->assign_var_from_handle('ASTAT_BODY_PAGE', 'body_page');
+ } //display_stats_by_period
+
+
+
+ /*
+ display stat by ip
+ */
+ private function display_stats_by_ip($year, $month, $day, $max_width, $nbipperpage, $pagenumber, $sortip, $seetimerequest)
+ {
+ global $template;
+
+ $template->set_filename('body_page', dirname(__FILE__)."/admin/astat_by_ip.tpl");
+
+
+ $template_datas=array();
+ $template_datarows=array();
+
+
+ /* requete */
+ //calc_time(true);
+ $returned = $this->stats_by_ip($year, $month, $day, $nbipperpage, $pagenumber, $sortip);
+ //$timerequest=calc_time(false);
+ $stats=$returned[0];
+ $nbfoundrows=$returned[1];
+ $nbpages=ceil($nbfoundrows / $nbipperpage);
+
+
+ $dir_links = "";
+ $page_link = "";
+ $a_links=array("global" => $this->page_link."&fAStat_defper=N&fAStat_all=Y",
+ "all" => $this->page_link."&fAStat_defper=N&fAStat_all=N",
+ "year" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year",
+ "month" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=$month",
+ "day" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=$month&fAStat_day=$day");
+
+ $ip_links=array("all" => $this->page_link."&fAStat_tabsheet=stats_by_ip",
+ "year" => $this->page_link."&fAStat_tabsheet=stats_by_ip&fAStat_year=$year",
+ "month" => $this->page_link."&fAStat_tabsheet=stats_by_ip&fAStat_year=$year&fAStat_month=$month",
+ "day" => $this->page_link."&fAStat_tabsheet=stats_by_ip&fAStat_year=$year&fAStat_month=$month&fAStat_day=$day");
+
+ $img_links=array("all" => $this->page_link."&fAStat_tabsheet=stats_by_image",
+ "year" => $this->page_link."&fAStat_tabsheet=stats_by_image&fAStat_year=$year",
+ "month" => $this->page_link."&fAStat_tabsheet=stats_by_image&fAStat_year=$year&fAStat_month=$month",
+ "day" => $this->page_link."&fAStat_tabsheet=stats_by_image&fAStat_year=$year&fAStat_month=$month&fAStat_day=$day");
+
+
+ /* periode label + navigation links */
+ if($day!="")
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".$this->format_link(l10n("AStat_month_of_year_".$month), $a_links["month"])." / ".l10n("AStat_day_of_week_".date("w",mktime(0, 0, 0, $month, $day, $year)))." $day";
+ $page_link=$ip_links["day"];
+ $img_link=$img_links["day"];
+ }
+ elseif($month!="")
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".l10n("AStat_month_of_year_".$month);
+ $page_link=$ip_links["month"];
+ $img_link=$img_links["month"];
+ }
+ elseif($year!="")
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$year;
+ $page_link=$ip_links["year"];
+ $img_link=$img_links["year"];
+ }
+ else
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".l10n("AStat_period_label_all");
+ $page_link=$ip_links["all"];
+ $img_link=$img_links["all"];
+ }
+
+
+ if($nbpages>1) { $plural="s"; } else { $plural=""; }
+ $pages_links=l10n("AStat_page".$plural."_label")." : ";
+ for($i=1;$i<=$nbpages;$i++)
+ {
+ if($i==$pagenumber)
+ { $pages_links.=" $i "; }
+ else
+ {
+ $pages_links.=$this->format_link(" $i ", $page_link."&fAStat_page_number=$i&fAStat_SortIP=$sortip");
+ }
+ }
+
+ $template_datas["L_STAT_TITLE"] = $dir_links;
+ $template_datas["MAX_WIDTH"]=$max_width+10;
+ $template_datas["NB_TOTAL_IP"] = l10n('AStat_nb_total_ip')." : $nbfoundrows";
+ $template_datas["PAGES_LINKS"] = $pages_links;
+ $template_datas["ASTAT_NFO_STAT"]= l10n("AStat_Nfo_IP");
+
+ $template_datas["ASTAT_SORT_LABEL"] = l10n("AStat_SortIPLabel").strtolower(l10n("AStat_sortip_$sortip"));
+
+ $template_datas["ASTAT_LABEL_IP_label"] = $this->format_link(l10n("AStat_RefIPLabel"), $page_link."&fAStat_SortIP=ip");
+ $template_datas["ASTAT_LABEL_Pages_seen"] = $this->format_link(l10n("Pages seen"), $page_link."&fAStat_SortIP=page");
+ $template_datas["ASTAT_LABEL_Pictures_seen"] = $this->format_link(l10n("Pictures_seen"), $page_link."&fAStat_SortIP=picture");
+
+ if($seetimerequest=='true')
+ {
+ $template_datas["ASTAT_TIME_REQUEST"] = l10n('AStat_time_request_label').' '.$timerequest.'s';
+ }
+
+ for($i=0;$i 0)
+ {
+ $width_pages = ceil(($stats[$i]["NbPages"] * $max_width) / $stats[$i]["MaxPages"] );
+ $width_img = ceil(($stats[$i]["NbImg"] * $max_width) / $stats[$i]["MaxPages"] );
+ }
+ else
+ {
+ $width_pages = 0;
+ $width_img = 0;
+ }
+
+
+ if($this->is_ip($stats[$i]["IP_USER"]))
+ {
+ $ip_geolocalisation='['.l10n('AStat_IP_geolocalisation').'] ';
+ $ip_adress=''.$stats[$i]["IP_USER"].' ';
+ }
+ else
+ {
+ $ip_geolocalisation='';
+ $ip_adress=$stats[$i]["IP_USER"];
+ }
+
+
+ $template_datarows[]=array(
+ 'ASTAT_IP_GEOLOCALISATION' => $ip_geolocalisation,
+ 'ASTAT_IP_ADRESS' => $ip_adress,
+ 'PAGES' => $stats[$i]["NbPages"],
+ 'PICTURES' => $this->format_link($stats[$i]["NbImg"], $img_link."&fAStat_IP=".trim($stats[$i]["IP_USER"])),
+ 'WIDTH1' => $width_img,
+ 'WIDTH2' => $width_pages,
+ );
+ }
+
+ $template->assign('datas', $template_datas);
+ $template->assign('datarows', $template_datarows);
+ $template->assign_var_from_handle('ASTAT_BODY_PAGE', 'body_page');
+ } // display_stat_by_ip
+
+
+
+
+
+ /*
+ display stat by category
+ */
+ private function display_stats_by_category($year, $month, $day, $max_width, $nbipperpage, $pagenumber,$showthumb, $sortcat, $seetimerequest)
+ {
+ global $template, $conf;
+
+ $template->set_filename('body_page', dirname(__FILE__)."/admin/astat_by_category.tpl");
+
+
+ /* requete */
+ //calc_time(true);
+ $returned = $this->stats_by_category($year, $month, $day, $nbipperpage, $pagenumber, $showthumb, $sortcat);
+ //$timerequest=calc_time(false);
+ $stats=$returned[0];
+ $nbfoundrows=$returned[1];
+ $nbpages=ceil($nbfoundrows / $nbipperpage);
+
+
+ $dir_links = "";
+ $page_link = "";
+ $a_links=array("global" => $this->page_link."&fAStat_defper=N&fAStat_all=Y",
+ "all" => $this->page_link."&fAStat_defper=N&fAStat_all=N",
+ "year" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year",
+ "month" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=$month",
+ "day" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=$month&fAStat_day=$day");
+
+ $cat_links=array("all" => $this->page_link."&fAStat_tabsheet=stats_by_category",
+ "year" => $this->page_link."&fAStat_tabsheet=stats_by_category&fAStat_year=$year",
+ "month" => $this->page_link."&fAStat_tabsheet=stats_by_category&fAStat_year=$year&fAStat_month=$month",
+ "day" => $this->page_link."&fAStat_tabsheet=stats_by_category&fAStat_year=$year&fAStat_month=$month&fAStat_day=$day");
+
+ /* make navigation links */
+ if($day!="")
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".$this->format_link(l10n("AStat_month_of_year_".$month), $a_links["month"])." / ".l10n("AStat_day_of_week_".date("w",mktime(0, 0, 0, $month, $day, $year)))." $day";
+ $page_link=$cat_links["day"];
+ }
+ elseif($month!="")
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".l10n("AStat_month_of_year_".$month);
+ $page_link=$cat_links["month"];
+ }
+ elseif($year!="")
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$year;
+ $page_link=$cat_links["year"];
+ }
+ else
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".l10n("AStat_period_label_all");
+ $page_link=$cat_links["all"];
+ }
+
+
+ if($nbpages>1)
+ {
+ $plural="s";
+ }
+ else
+ {
+ $plural="";
+ }
+
+ $pages_links=l10n("AStat_page".$plural."_label")." : ";
+ for($i=1;$i<=$nbpages;$i++)
+ {
+ if($i==$pagenumber)
+ {
+ $pages_links.=" $i ";
+ }
+ else
+ {
+ $pages_links.=$this->format_link(" $i ", $page_link."&fAStat_SortCat=$sortcat&fAStat_page_number=$i");
+ }
+ }
+
+
+ /* navigation */
+ $template_datas["L_STAT_TITLE"] = $dir_links;
+ $template_datas["MAX_WIDTH"] = $max_width;
+ $template_datas["NB_TOTAL_CATEGORY"] = l10n('AStat_nb_total_category')." : $nbfoundrows";
+ $template_datas["PAGES_LINKS"] = $pages_links;
+ $template_datas["ASTAT_NFO_STAT"] = l10n("AStat_Nfo_Category");
+ $template_datas["ASTAT_SORT_LABEL"] = l10n("AStat_SortCatLabel").strtolower(l10n("AStat_sortcat_$sortcat"));
+
+ $template_datas["ASTAT_LABEL_pct_Pages_seen"] = $this->format_link(l10n("pct_Pages_seen"), $page_link."&fAStat_SortCat=page");
+ $template_datas["ASTAT_LABEL_pct_Pictures_seen"] = $this->format_link(l10n("pct_Pictures_seen"), $page_link."&fAStat_SortCat=picture");
+ $template_datas["ASTAT_LABEL_ratio_Pictures_seen"] = $this->format_link(l10n("ratio_Pictures_seen"), $page_link."&fAStat_SortCat=nbpicture");
+
+ if($seetimerequest=='true')
+ {
+ $template_datas["ASTAT_TIME_REQUEST"] = l10n('AStat_time_request_label').' '.$timerequest.'s';
+ }
+
+ for($i=0;$ichange_file_ext($stats[$i]["ThumbFile"], $stats[$i]["Extension"]);
+ $filethumb=str_replace($stats[$i]["ThumbFile"],"thumbnail/".$conf['prefix_thumbnail'].$filethumb,$stats[$i]["ThumbPath"]); }
+ else
+ {
+ $filethumb='';
+ }
+
+ if($stats[$i]["category_id"]>0)
+ { $category = $this->format_link($stats[$i]["IdCat"], PHPWG_ROOT_PATH."index.php?/category/".$stats[$i]["category_id"]); }
+ else
+ {
+ $category = "".l10n('AStat_section_label').' : ';
+ if(l10n('AStat_section_'.$stats[$i]["IdCat"])!='AStat_section_'.$stats[$i]["IdCat"])
+ {
+ $category.=l10n('AStat_section_'.$stats[$i]["IdCat"]);
+ }
+ else
+ {
+ $category.=sprintf(l10n('AStat_section_unknown'), $stats[$i]["IdCat"]);
+ }
+
+ $category.=" ";
+ }
+
+ $template_datarows[]=array(
+ 'THUMBJPG' => $filethumb,
+ 'CATEGORY' => $category,
+ 'PCTPAGES' => $stats[$i]["PctPages"],
+ 'PCTPICTURES' => $stats[$i]["PctImg"],
+ 'RATIOPICTURES' => $stats[$i]["RatioImg"],
+ 'WIDTH1' => $width_img,
+ 'WIDTH2' => $width_pages,
+ );
+ }
+
+ $template->assign('datas', $template_datas);
+ $template->assign('datarows', $template_datarows);
+ $template->assign_var_from_handle('ASTAT_BODY_PAGE', 'body_page');
+ } // display_stat_by_category
+
+
+
+ /* ------------------------------------------------------------------------------------------
+ display stats for images
+ ------------------------------------------------------------------------------------------ */
+ function display_stats_by_image($year, $month, $day, $max_width, $nbipperpage, $pagenumber,$showthumb, $sortimg, $ip, $seetimerequest)
+ {
+ global $template, $conf;
+
+ $template->set_filename('body_page', dirname(__FILE__)."/admin/astat_by_image.tpl");
+
+
+ $template_datas=array();
+ $template_datarows=array();
+
+
+ //calc_time(true);
+ $returned = $this->stats_by_image($year, $month, $day, $nbipperpage, $pagenumber, $sortimg, $ip);
+ //$timerequest=calc_time(false);
+ $stats=$returned[0];
+ $nbfoundrows=$returned[1];
+ $nbpages=ceil($nbfoundrows / $nbipperpage);
+
+ $dir_links = "";
+ $page_link = "";
+ $a_links=array("global" => $this->page_link."&fAStat_defper=N&fAStat_all=Y",
+ "all" => $this->page_link."&fAStat_defper=N&fAStat_all=N",
+ "year" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year",
+ "month" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=$month",
+ "day" => $this->page_link."&fAStat_defper=N&fAStat_all=N&fAStat_year=$year&fAStat_month=$month&fAStat_day=$day");
+
+ $img_links=array("all" => $this->page_link."&fAStat_tabsheet=stats_by_image",
+ "year" => $this->page_link."&fAStat_tabsheet=stats_by_image&fAStat_year=$year",
+ "month" => $this->page_link."&fAStat_tabsheet=stats_by_image&fAStat_year=$year&fAStat_month=$month",
+ "day" => $this->page_link."&fAStat_tabsheet=stats_by_image&fAStat_year=$year&fAStat_month=$month&fAStat_day=$day");
+
+ /* navigation links */
+ if($day!="")
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".$this->format_link(l10n("AStat_month_of_year_".$month), $a_links["month"])." / ".l10n("AStat_day_of_week_".date("w",mktime(0, 0, 0, $month, $day, $year)))." $day";
+ $page_link=$img_links["day"];
+ }
+ elseif($month!="")
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$this->format_link($year, $a_links["year"])." / ".l10n("AStat_month_of_year_".$month);
+ $page_link=$img_links["month"];
+ }
+ elseif($year!="")
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".$this->format_link(l10n("AStat_period_label_all"), $a_links["all"])." / ".$year;
+ $page_link=$img_links["year"];
+ }
+ else
+ {
+ $dir_links = $this->format_link(l10n("AStat_period_label_global"), $a_links["global"])." / ".l10n("AStat_period_label_all");
+ $page_link=$img_links["all"];
+ }
+
+ if($ip!="")
+ {
+ $dir_links.= " [IP : $ip]";
+ }
+
+
+ if($nbpages>1) { $plural="s"; } else { $plural=""; }
+ $pages_links=l10n("AStat_page".$plural."_label")." : ";
+ for($i=1;$i<=$nbpages;$i++)
+ {
+ if($i==$pagenumber)
+ { $pages_links.=" $i "; }
+ else
+ {
+ if($ip!="") { $ip_link="&fAStat_IP=$ip"; } else { $ip_link=""; }
+ $pages_links.=$this->format_link(" $i ", $page_link."&fAStat_SortImg=$sortimg&fAStat_page_number=$i".$ip_link);
+ }
+ }
+
+
+ /* navigation */
+ $template_datas["L_STAT_TITLE"] = $dir_links;
+ $template_datas["MAX_WIDTH"] = $max_width;
+ $template_datas["NB_TOTAL_IMAGE"] = l10n('AStat_nb_total_image')." : $nbfoundrows";
+ $template_datas["PAGES_LINKS"] = $pages_links;
+ $template_datas["ASTAT_NFO_STAT"] = l10n("AStat_Nfo_Image");
+ $template_datas["ASTAT_SORT_LABEL"] = l10n("AStat_SortImgLabel").strtolower(l10n("AStat_sortimg_$sortimg"));
+
+ $template_datas["ASTAT_LABEL_AStat_RefImageLabel"] = $this->format_link(l10n("AStat_RefImageLabel"), $page_link."&fAStat_SortImg=catname");
+ $template_datas["ASTAT_LABEL_Pictures_seen"] = $this->format_link(l10n("Pictures_seen"), $page_link."&fAStat_SortImg=picture");
+ $template_datas["ASTAT_LABEL_pct_Pictures_seen"] = l10n("pct_Pictures_seen");
+
+ if($seetimerequest=='true')
+ {
+ $template_datas["ASTAT_TIME_REQUEST"] = l10n('AStat_time_request_label').' '.$timerequest.'s';
+ }
+
+ for($i=0;$ichange_file_ext($stats[$i]["ThumbFile"], $stats[$i]["Extension"]);
+ $filethumb=str_replace($stats[$i]["ThumbFile"],"thumbnail/".$conf['prefix_thumbnail'].$filethumb,$stats[$i]["ThumbPath"]);
+ }
+ else
+ {
+ $filethumb='';
+ }
+
+
+ if($stats[$i]["IdCat"]>0)
+ {
+ $image_links = $this->format_link($stats[$i]["CatName"], PHPWG_ROOT_PATH."index.php?/category/".$stats[$i]["IdCat"])." / ";
+ if($stats[$i]["ImgName"]!="")
+ {
+ $image_links.=$this->format_link($stats[$i]["ImgName"], PHPWG_ROOT_PATH."picture.php?/".$stats[$i]["ImgId"]."/category/".$stats[$i]["IdCat"]);
+ }
+ else
+ {
+ if($stats[$i]["ThumbFile"]!="")
+ {
+ $image_links.=$this->format_link("[ ".$stats[$i]["ThumbFile"]." ]", PHPWG_ROOT_PATH."picture.php?/".$stats[$i]["ImgId"]."/category/".$stats[$i]["IdCat"]);
+ }
+ else
+ {
+ $image_links=l10n('AStat_deleted_picture')." [ Id #".$stats[$i]["ImgId"]." ]";
+ }
+ }
+ }
+ else
+ {
+ $image_links = "".l10n('AStat_section_label').' : ';
+ if(l10n('AStat_section_'.$stats[$i]["CatName"])!='AStat_section_'.$stats[$i]["CatName"])
+ {
+ $image_links.=l10n('AStat_section_'.$stats[$i]["CatName"]);
+ }
+ else
+ {
+ $image_links.=sprintf(l10n('AStat_section_unknown'), $stats[$i]["CatName"]);
+ }
+
+ $image_links.=" / ";
+
+ if($stats[$i]["ImgName"]!="")
+ {
+ $image_links.=$stats[$i]["ImgName"];
+ }
+ else
+ {
+ if($stats[$i]["ThumbFile"]!="")
+ {
+ $image_links.="[ ".$stats[$i]["ThumbFile"]." ]";
+ }
+ else
+ {
+ $image_links=l10n('AStat_deleted_picture')." [ Id #".$stats[$i]["ImgId"]." ]";
+ }
+ }
+ }
+
+
+
+ $template_datarows[]=array(
+ 'THUMBJPG' => $filethumb,
+ 'IMAGE' => $image_links,
+ 'NBPICTURES' => $stats[$i]["NbVues"],
+ 'PCTPICTURES' => $stats[$i]["PctImg"],
+ 'WIDTH1' => $width_img,
+ 'WIDTH2' => $width_pages,
+ );
+ }
+
+ $template->assign('datas', $template_datas);
+ $template->assign('datarows', $template_datarows);
+ $template->assign_var_from_handle('ASTAT_BODY_PAGE', 'body_page');
+ } // display_stat_by_image
+
+
+
+
+
+ /*
+ display config page
+ */
+ private function display_config()
+ {
+ global $template, $page;
+
+ $save_status=false;
+
+ if(isset($_POST['submit']))
+ {
+ if(!is_adviser())
+ {
+ reset($this->my_config);
+ while (list($key, $val) = each($this->my_config))
+ {
+ if(isset($_POST['f_'.$key]))
+ {
+ $this->my_config[$key] = $_POST['f_'.$key];
+ }
+ }
+ if($this->save_config())
+ {
+ array_push($page['infos'], l10n('AStat_config_saved'));
+ }
+ else
+ {
+ array_push($page['errors'], l10n('AStat_adviser_not_authorized'));
+ }
+ }
+ else
+ {
+ array_push($page['errors'], l10n('AStat_adviser_not_authorized'));
+ }
+ }
+
+ $template->set_filename('body_page', dirname(__FILE__).'/admin/astat_config.tpl');
+
+ $template_datas=array();
+ $template_list_values=array();
+ $template_list_labels=array();
+
+ //standards inputs zones
+ reset($this->my_config);
+ while (list($key, $val) = each($this->my_config))
+ {
+ $template_datas["f_".$key]=$val;
+ }
+
+ // define selected item for lists zones
+ $template_datas['AStat_periods_selected']=$this->my_config['AStat_default_period'];
+ $template_datas['AStat_defaultsortcat_selected']=$this->my_config['AStat_DefaultSortCat'];
+ $template_datas['AStat_defaultsortip_selected']=$this->my_config['AStat_DefaultSortIP'];
+ $template_datas['AStat_defaultsortimg_selected']=$this->my_config['AStat_DefaultSortImg'];
+
+ $template_datas['AStat_showthumbcat_selected']=$this->my_config['AStat_ShowThumbCat'];
+ $template_datas['AStat_showthumbimg_selected']=$this->my_config['AStat_ShowThumbImg'];
+
+ // making lists zones
+ // default period
+ reset($this->list_periods);
+ while (list($key, $val) = each($this->list_periods))
+ {
+ $template_list_values['periods'][]=$val;
+ $template_list_labels['periods'][]=l10n('AStat_PeriodPerDefault_'.$val);
+ }
+ // default category order
+ reset($this->list_sortcat);
+ while (list($key, $val) = each($this->list_sortcat))
+ {
+ $template_list_values['sortcat'][]=$val;
+ $template_list_labels['sortcat'][]=l10n('AStat_sortcat_'.$val);
+ }
+ // default ip order
+ reset($this->list_sortip);
+ while (list($key, $val) = each($this->list_sortip))
+ {
+ $template_list_values['sortip'][]=$val;
+ $template_list_labels['sortip'][]=l10n('AStat_sortip_'.$val);
+ }
+ // default picture order
+ reset($this->list_sortimg);
+ while (list($key, $val) = each($this->list_sortimg))
+ {
+ $template_list_values['sortimg'][]=$val;
+ $template_list_labels['sortimg'][]=l10n('AStat_sortimg_'.$val);
+ }
+
+ /* yes/no lists */
+ $template_list_values['yesno'][]='true';
+ $template_list_labels['yesno'][]=l10n('AStat_yesno_true');
+ $template_list_values['yesno'][]='false';
+ $template_list_labels['yesno'][]=l10n('AStat_yesno_false');
+
+ $template_datas["L_STAT_TITLE"]=l10n('AStat_config_title');
+
+ $template->assign("datas", $template_datas);
+ $template->assign("AStat_periods_list_values", $template_list_values['periods']);
+ $template->assign("AStat_periods_list_labels", $template_list_labels['periods']);
+ $template->assign("AStat_defaultsortip_list_values", $template_list_values['sortip']);
+ $template->assign("AStat_defaultsortip_list_labels", $template_list_labels['sortip']);
+ $template->assign("AStat_defaultsortcat_list_values", $template_list_values['sortcat']);
+ $template->assign("AStat_defaultsortcat_list_labels", $template_list_labels['sortcat']);
+ $template->assign("AStat_defaultsortimg_list_values", $template_list_values['sortimg']);
+ $template->assign("AStat_defaultsortimg_list_labels", $template_list_labels['sortimg']);
+ $template->assign("AStat_yesno_list_values", $template_list_values['yesno']);
+ $template->assign("AStat_yesno_list_labels", $template_list_labels['yesno']);
+
+ $template->assign_var_from_handle('ASTAT_BODY_PAGE', 'body_page');
+ } // display_config
+
+
+
+ /*
+ display tools page
+ */
+ private function display_tools()
+ {
+ global $template, $page;
+
+ $action_result=array('result' => '', 'action' => '', 'msg' => '', 'nfo' => '');
+
+ $template->set_filename('body_page', dirname(__FILE__).'/admin/astat_tools.tpl');
+
+ $template_datas=array();
+
+ // >> PURGE HISTORY --------------------------------------------------------
+ if(isset($_POST['apply_tool_purge_history']))
+ {
+ if(!is_adviser())
+ {
+ $action_result['action']='AStat_tools_purge_history';
+ $action_result['result']='false';
+ $action_result['msg']='AStat_tools_result_ko';
+
+ $ok_to_purge=true;
+ if($_REQUEST['fAStat_purge_history_type']=='bydate')
+ {
+ // may be this functionnality could be optimized with pcre functions
+ $date=explode('/', $_REQUEST['fAStat_purge_history_date']);
+ if(!isset($date[0])) { $date[0]=0; }
+ if(!isset($date[1])) { $date[1]=0; }
+ if(!isset($date[2])) { $date[2]=0; }
+
+ $purge_date=mktime(0,0,0,$date[1],$date[0],$date[2]);
+ $fdate=date("Y-m-d", mktime(0,0,0,$date[1],$date[0],$date[2]));
+
+ if(date("d/m/Y", $purge_date)!=$_REQUEST['fAStat_purge_history_date'])
+ {
+ $action_result['nfo']='AStat_tools_invalid_date';
+ $ok_to_purge=false;
+ }
+ elseif(date("Ymd", $purge_date)>=date("Ymd"))
+ {
+ $action_result['nfo']='AStat_tools_invalid_date2';
+ $ok_to_purge=false;
+ }
+ }
+ else
+ {
+ $fdate="";
+ }
+
+ if($ok_to_purge)
+ {
+ $result=$this->do_purge_history( $fdate, $_REQUEST['fAStat_purge_history_type']);
+ if($result)
+ {
+ $action_result['result']='true';
+ $action_result['msg']='AStat_tools_result_ok';
+ }
+ }
+ }
+ else
+ {
+ array_push($page['errors'], l10n('AStat_adviser_not_authorized'));
+ }
+ }
+ // << PURGE HISTORY --------------------------------------------------------
+
+ // >> DELETED_PICTURE ------------------------------------------------------
+ elseif(isset($_POST['apply_tool_deleted_picture_resync']))
+ {
+ if(!is_adviser())
+ {
+ $action_result['action']='AStat_tools_deleted_picture';
+ $action_result['result']='false';
+ $action_result['msg']='AStat_tools_result_ko';
+
+ if($_POST['fAStat_tools_deleted_picture_action']=='prepare')
+ {
+ if($this->prepare_AStat_picture_table())
+ {
+ $action_result['result']='true';
+ $action_result['msg']='AStat_tools_result_ok';
+ $action_result['nfo']='AStat_tools_deleted_picture_ok0';
+ }
+ else
+ {
+ $action_result['nfo']='AStat_tools_deleted_picture_error0';
+ }
+ }
+ elseif($_POST['fAStat_tools_deleted_picture_action']=='apply')
+ {
+ if($this->apply_AStat_picture_table())
+ {
+ $action_result['result']='true';
+ $action_result['msg']='AStat_tools_result_ok';
+ $action_result['nfo']='AStat_tools_deleted_picture_ok1';
+ }
+ else
+ {
+ $action_result['nfo']='AStat_tools_deleted_picture_error1';
+ }
+ }
+ }
+ else
+ {
+ array_push($page['errors'], l10n('AStat_adviser_not_authorized'));
+ }
+ }
+ //
+ elseif(isset($_POST['apply_tool_deleted_picture']))
+ {
+ if(!is_adviser())
+ {
+ $action_result['action']='AStat_tools_deleted_picture';
+ $action_result['result']='false';
+ $action_result['msg']='AStat_tools_result_ko';
+
+ $nfo = $this->tools_deleted_picture('to0');
+ if($nfo[0]==1)
+ {
+ $action_result['result']='true';
+ $action_result['msg']='AStat_tools_result_ok';
+ }
+ }
+ else
+ {
+ array_push($page['errors'], l10n('AStat_adviser_not_authorized'));
+ }
+ }
+ // << DELETED_PICTURE ------------------------------------------------------
+
+ // >> DELETED_CATEGORY -----------------------------------------------------
+ elseif(isset($_POST['apply_tool_deleted_category']))
+ {
+ if(!is_adviser())
+ {
+ $action_result['action']='AStat_tools_deleted_category';
+ $action_result['result']='false';
+ $action_result['msg']='AStat_tools_result_ko';
+
+ $nfo = $this->tools_deleted_category('to0');
+ if($nfo[0]==1)
+ {
+ $action_result['result']='true';
+ $action_result['msg']='AStat_tools_result_ok';
+ }
+ }
+ else
+ {
+ array_push($page['errors'], l10n('AStat_adviser_not_authorized'));
+ }
+ }
+ // << DELETED_CATEGORY -----------------------------------------------------
+
+ // >> DELETED USER ---------------------------------------------------------
+ elseif(isset($_POST['apply_tool_deleted_user']))
+ {
+ if(!is_adviser())
+ {
+ $action_result['action']='AStat_tools_deleted_user';
+ $action_result['result']='false';
+ $action_result['msg']='AStat_tools_result_ko';
+
+ $nfo = $this->tools_deleted_user('resynchro');
+ if($nfo[0]==1)
+ {
+ $action_result['result']='true';
+ $action_result['msg']='AStat_tools_result_ok';
+ }
+ }
+ else
+ {
+ array_push($page['errors'], l10n('AStat_adviser_not_authorized'));
+ }
+ }
+ // << DELETED USER ---------------------------------------------------------
+
+
+ // >> DISPLAY DELETED_PICTURE NFO ------------------------------------------
+ $table_exists=$this->verify_AStat_picture_table_status();
+ if($table_exists==true)
+ {
+ $template_datas["ASTAT_DELETED_PICTURE_DO_ACTION"] = "checked";
+ $template_datas["ASTAT_DELETED_PICTURE_PREPARE"] = "disabled";
+ }
+ else
+ {
+ $template_datas["ASTAT_DELETED_PICTURE_PREPARE"]="checked";
+ $template_datas["ASTAT_DELETED_PICTURE_DO_ACTION"]="disabled";
+ }
+
+ $nfo=$this->count_AStat_picture_table();
+ $template_datas["ASTAT_DELETED_PICTURE_NFO_NB"] = sprintf(l10n('AStat_tools_deleted_picture_nfo_nb'), $nfo[1], $nfo[2]);
+
+ $nfo = $this->tools_deleted_picture('analyse');
+ if($nfo[0]>0)
+ {
+ $list='';
+ for($i=0;$i1) { $s='s'; } else { $s=''; }
+ $list.="image_id #".$nfo[2][$i][1]." : ".$nfo[2][$i][0]." ".l10n("AStat_event$s")." ";
+ }
+ $template_datas["ASTAT_DELETED_PICTURE_NFO"] = sprintf(l10n('AStat_tools_deleted_picture_nfo1'), $nfo[0], $nfo[1], $list);
+ //function not yet implemented
+ $template_datas['AStat_deleted_picture_submit0'] = 'yes';
+ }
+ else
+ {
+ $template_datas["ASTAT_DELETED_PICTURE_NFO"] = l10n('AStat_tools_deleted_picture_nfo2');
+ }
+ // << DISPLAY DELETED_PICTURE NFO ------------------------------------------
+
+ // >> DISPLAY DELETED_CATEGORY NFO -----------------------------------------
+ $nfo = $this->tools_deleted_category('analyse');
+ if($nfo[0]>0)
+ {
+ $list='';
+ for($i=0;$i1) { $s='s'; } else { $s=''; }
+ $list.="category_id #".$nfo[2][$i][1]." : ".$nfo[2][$i][0]." ".l10n("AStat_event$s")." ";
+ }
+ $template_datas["ASTAT_DELETED_CATEGORY_NFO"] = sprintf(l10n('AStat_tools_deleted_category_nfo1'), $nfo[0], $nfo[1], $list);
+ //function not yet implemented
+ $template_datas['AStat_deleted_category_submit0'] = 'yes';
+ }
+ else
+ {
+ $template_datas["ASTAT_DELETED_CATEGORY_NFO"] = l10n('AStat_tools_deleted_category_nfo2');
+ }
+ // << DISPLAY DELETED_CATEGORY NFO -----------------------------------------
+
+ // >> DISPLAY DELETED USER NFO ---------------------------------------------
+ $nfo = $this->tools_deleted_user('analyse');
+ if($nfo[0]>0)
+ {
+ $list='';
+ for($i=0;$i1) { $s='s'; } else { $s=''; }
+ $list.="user_id #".$nfo[2][$i][1]." : ".$nfo[2][$i][0]." ".l10n("AStat_event$s")." ";
+ }
+ $template_datas["ASTAT_DELETED_USER_NFO"] = sprintf(l10n('AStat_tools_deleted_user_nfo1'), $nfo[0], $nfo[1], $list);
+ $template_datas['AStat_deleted_user_submit'] = 'yes';
+ }
+ else
+ {
+ $template_datas["ASTAT_DELETED_USER_NFO"] = l10n('AStat_tools_deleted_user_nfo2');
+ }
+ // << DISPLAY DELETED USER NFO ---------------------------------------------
+
+
+ // >> DISPLAY GENERAL NFO --------------------------------------------------
+ $nfo = $this->tools_general_nfo();
+ if($nfo[0]>0)
+ {
+ $template_datas["ASTAT_GENERAL_NFO"] = sprintf(l10n('AStat_tools_general_nfo_nfo'),
+ $nfo[0],
+ $this->formatoctet($nfo[3]+$nfo[4], "A", " ", 2, true),
+ $this->formatoctet($nfo[3], "A", " ", 2, true),
+ $this->formatoctet($nfo[4], "A", " ", 2, true),
+ date(l10n('AStat_date_time_format'), strtotime($nfo[2])),
+ date(l10n('AStat_date_time_format'), strtotime($nfo[1])) );
+ }
+
+ $nfo=$this->purge_history_count_imageid0();
+ $template_datas["ASTAT_PURGE_HISTORY_IMAGE_NFO"] = sprintf(l10n('AStat_tools_purge_history_imageid0'), $nfo);
+ if($nfo==0)
+ {
+ $template_datas["ASTAT_PURGE_HISTORY_IMAGE_DISABLED"] = " disabled ";
+ }
+ $nfo=$this->purge_history_count_categoryid0();
+ $template_datas["ASTAT_PURGE_HISTORY_CATEGORY_NFO"] = sprintf(l10n('AStat_tools_purge_history_categoryid0'), $nfo);
+ if($nfo==0)
+ {
+ $template_datas["ASTAT_PURGE_HISTORY_CATEGORY_DISABLED"] = " disabled ";
+ }
+ // << GENERAL NFO ----------------------------------------------------------
+
+
+ if($action_result['result']!='')
+ {
+ if($action_result['result']=='true')
+ {
+ $value="";
+ }
+ else
+ {
+ $value="
";
+ }
+ $value.="".l10n($action_result['action'])." ".l10n($action_result['msg'])." ";
+
+ if($action_result['nfo']!='')
+ {
+ $value.="[".l10n($action_result['nfo'])."]
";
+ }
+
+ $template_datas["ASTAT_RESULT_OK"] = $value;
+ }
+
+ $template_datas["L_STAT_TITLE"] = l10n('AStat_tools_title');
+
+ $template->assign('datas', $template_datas);
+ $template->assign_var_from_handle('ASTAT_BODY_PAGE', 'body_page');
+ } // display_tools
+
+
+ /*
+ tools functions
+ */
+
+
+
+ /*
+ tools : deleted_user
+ allow to force HISTORY_TABLE.user_id at 2 (guest) for records with user ident
+ doesn't exist anymore in the USERS_TABLE
+
+ Two usages :
+ - analyse : return infos about records wich need to be updated
+ * number of users
+ * number of records in HISTORY_TABLE
+ * the users list
+ - resynchro : update table
+ */
+ private function tools_deleted_user($mode)
+ {
+ $returned = array(-1,0,'');
+
+ if($mode=='analyse')
+ {
+ $sql="SELECT count(id) as NbRecord, user_id ";
+ $sql.=" FROM ".HISTORY_TABLE;
+ $sql.=" WHERE ".HISTORY_TABLE.".user_id NOT IN (SELECT id FROM ".USERS_TABLE.") ";
+ $sql.=" GROUP BY user_id ORDER BY NbRecord";
+ $result=pwg_query($sql);
+ if($result)
+ {
+ $returned[0]=0;
+ while ($row = mysql_fetch_array($result))
+ {
+ $returned[2][$returned[0]][0] = $row[0];
+ $returned[2][$returned[0]][1] = $row[1];
+ $returned[0]++;
+ $returned[1]+=$row[0];
+ }
+
+ }
+ }
+ elseif($mode=='resynchro')
+ {
+ $sql="UPDATE ".HISTORY_TABLE." SET user_id = 2 ";
+ $sql.=" WHERE ".HISTORY_TABLE.".user_id NOT IN (SELECT id FROM ".USERS_TABLE.") ";
+ $result=pwg_query($sql);
+ if($result)
+ { $returned[0]=1; }
+ }
+ return($returned);
+ }
+
+
+ /*
+ tools : deleted_picture
+ analyse history to find deleted pictures
+ Two functions :
+ - analyse : return infos
+ * number of pictures
+ * number of record in HISTORY_TABLE
+ * pictures list
+ - to0 : update picture ident to 0
+ */
+ private function tools_deleted_picture($mode)
+ {
+ $returned = array(-1,0,'');
+
+ if($mode=='analyse')
+ {
+ $sql="SELECT count(id) as NbRecord, image_id ";
+ $sql.=" FROM ".HISTORY_TABLE;
+ $sql.=" WHERE ".HISTORY_TABLE.".image_id NOT IN (SELECT id FROM ".IMAGES_TABLE.") and image_id > 0 ";
+ $sql.=" GROUP BY image_id ORDER BY NbRecord";
+ $result=pwg_query($sql);
+
+ if($result)
+ {
+ $returned[0]=0;
+ while ($row = mysql_fetch_array($result))
+ {
+ $returned[2][$returned[0]][0] = $row[0];
+ $returned[2][$returned[0]][1] = $row[1];
+ $returned[0]++;
+ $returned[1]+=$row[0];
+ }
+
+ }
+ }
+ elseif($mode=='to0')
+ {
+ $sql="UPDATE ".HISTORY_TABLE."
+ SET image_id = 0
+ WHERE ".HISTORY_TABLE.".image_id > 0
+ AND ".HISTORY_TABLE.".image_id NOT IN (SELECT id FROM ".IMAGES_TABLE.")";
+ $result=pwg_query($sql);
+
+ if($result)
+ {
+ $returned[0]=1;
+ }
+ }
+ return($returned);
+ }
+
+
+ /*
+ tools : deleted_category
+ analyse history to find deleted categories
+ Two functions :
+ - analyse : return infos
+ * number of category
+ * number of record in HISTORY_TABLE
+ * catgories list
+ - to0 : update categories ident to 0
+ */
+ private function tools_deleted_category($mode)
+ {
+ $returned = array(-1,0,'');
+
+ if($mode=='analyse')
+ {
+ $sql="SELECT count(id) as NbRecord, category_id ";
+ $sql.=" FROM ".HISTORY_TABLE;
+ $sql.=" WHERE ".HISTORY_TABLE.".category_id NOT IN (SELECT id FROM ".CATEGORIES_TABLE.") and category_id > 0";
+ $sql.=" GROUP BY category_id ORDER BY NbRecord";
+ $result=pwg_query($sql);
+
+ if($result)
+ {
+ $returned[0]=0;
+ while ($row = mysql_fetch_array($result))
+ {
+ $returned[2][$returned[0]][0] = $row[0];
+ $returned[2][$returned[0]][1] = $row[1];
+ $returned[0]++;
+ $returned[1]+=$row[0];
+ }
+
+ }
+ }
+ elseif($mode=='to0')
+ {
+ $sql="UPDATE ".HISTORY_TABLE."
+ SET category_id = NULL, section = 'deleted_cat'
+ WHERE ".HISTORY_TABLE.".category_id > 0
+ AND ".HISTORY_TABLE.".category_id NOT IN (SELECT id FROM ".CATEGORIES_TABLE.")";
+ $result=pwg_query($sql);
+
+ if($result)
+ {
+ $returned[0]=1;
+ }
+ }
+ return($returned);
+ }
+
+
+ /*
+ tools : general_nfo
+ return infos about historic
+ 0 : nulber of records
+ 1 : date of newest record
+ 2 : date of oldesr record
+ 3 : table size
+ 4 : index size
+ */
+ private function tools_general_nfo()
+ {
+ $returned = array(-1,'','',0,0);
+
+ $sql="SELECT count(id) AS NbRecord, MAX(concat(date,' ', time)) AS LastDate, MIN(concat(date,' ', time)) AS FirstDate ";
+ $sql.=" FROM ".HISTORY_TABLE;
+ $result=pwg_query($sql);
+ if($result)
+ {
+ $row = mysql_fetch_array($result);
+ if(is_array($row))
+ {
+ $returned = $row;
+ $sql="SHOW TABLE STATUS LIKE '".HISTORY_TABLE."';";
+ $result=pwg_query($sql);
+ if($result)
+ {
+ $row2=mysql_fetch_array($result);
+ array_push($returned, $row2['Data_length'], $row2['Index_length']);
+ }
+ }
+ }
+ return($returned);
+ }
+
+
+ /*
+ tools : do_purge_history
+ do a purge of history table :
+ - $purgetype='bydate' : purge all record wich date is less than given date
+ - $purgetype='byimageid0' : with and image_id = 0
+ ------------------------------------------------------------------------------------ */
+ private function do_purge_history($date, $purgetype)
+ {
+ if($purgetype=='bydate')
+ {
+ $sql="DELETE FROM ".HISTORY_TABLE." WHERE date < '$date'";
+ }
+ elseif($purgetype=='byimageid0')
+ {
+ $sql="DELETE FROM ".HISTORY_TABLE." WHERE image_id = 0";
+ }
+ elseif($purgetype=='bycategoryid0')
+ {
+ $sql="DELETE FROM ".HISTORY_TABLE." WHERE category_id is null and section='deleted_cat'";
+ }
+ else
+ {
+ return(false);
+ }
+
+ $result=pwg_query($sql);
+ if($result)
+ {
+ $sql="OPTIMIZE TABLE ".HISTORY_TABLE;
+ $result=pwg_query($sql);
+ return($result);
+ }
+ return(false);
+ }
+
+ private function purge_history_count_imageid0()
+ {
+ $sql="SELECT COUNT(id) FROM ".HISTORY_TABLE." WHERE image_id = 0";
+ $result=pwg_query($sql);
+ if($result)
+ {
+ $row=mysql_fetch_array($result);
+ return($row[0]);
+ }
+ return(0);
+ }
+
+ private function purge_history_count_categoryid0()
+ {
+ $sql="SELECT COUNT(id) FROM ".HISTORY_TABLE." WHERE category_id is null and section = 'deleted_cat'" ;
+ $result=pwg_query($sql);
+ if($result)
+ {
+ $row=mysql_fetch_array($result);
+ return($row[0]);
+ }
+ return(0);
+ }
+
+
+ /*
+ tools : deleted_picture
+ > verify_AStat_picture_table_status :
+ > prepare_AStat_picture_table :
+ */
+ private function verify_AStat_picture_table_status()
+ {
+ global $prefixeTable;
+
+ $sql="SHOW TABLE STATUS LIKE '".$prefixeTable."AStat_picture'";
+ $result=pwg_query($sql);
+ if($result)
+ {
+ if(mysql_num_rows($result)==1)
+ {
+ return(true);
+ }
+ }
+ return(false);
+ }
+
+ private function prepare_AStat_picture_table()
+ {
+ global $prefixeTable;
+
+ $sql="CREATE TABLE ".$prefixeTable."AStat_picture (PRIMARY KEY (id), KEY ifile(file))
+ SELECT id, file
+ FROM ".IMAGES_TABLE;
+ $result=pwg_query($sql);
+ if($result)
+ {
+ return(true);
+ }
+ return(false);
+ }
+
+ private function count_AStat_picture_table()
+ {
+ global $prefixeTable;
+ $returned=array(false,0,0);
+
+ if($this->verify_AStat_picture_table_status())
+ {
+ $sql="SELECT count(DISTINCT ".$prefixeTable."AStat_picture.id), count(".HISTORY_TABLE.".id)
+ FROM ".HISTORY_TABLE.", ".$prefixeTable."AStat_picture
+ WHERE ".HISTORY_TABLE.".image_id = ".$prefixeTable."AStat_picture.id
+ AND ".HISTORY_TABLE.".image_id NOT IN (SELECT id FROM ".IMAGES_TABLE.")
+ ORDER BY ".$prefixeTable."AStat_picture.id";
+ $result=pwg_query($sql);
+ if($result)
+ {
+ if(mysql_num_rows($result)>0)
+ {
+ $row=mysql_fetch_row($result);
+ $returned[0]=true;
+ $returned[1]=$row[0];
+ $returned[2]=$row[1];
+ }
+ }
+ }
+ return($returned);
+ }
+
+ private function apply_AStat_picture_table()
+ {
+ global $prefixeTable;
+ $returned=false;
+
+ $sql="CREATE TABLE ".$prefixeTable."AStat_picture2 (PRIMARY KEY (OldId))
+ SELECT AStat_tmp.id as OldId , ".IMAGES_TABLE.".id as NewId, ".IMAGES_TABLE.".storage_category_id as NewCatId
+ FROM (SELECT DISTINCT ".$prefixeTable."AStat_picture.*
+ FROM ".HISTORY_TABLE.", ".$prefixeTable."AStat_picture
+ WHERE ".HISTORY_TABLE.".image_id = ".$prefixeTable."AStat_picture.id
+ AND ".HISTORY_TABLE.".image_id NOT IN (SELECT id FROM ".IMAGES_TABLE.")
+ ORDER BY ".$prefixeTable."AStat_picture.id
+ ) as AStat_tmp
+ LEFT JOIN ".IMAGES_TABLE." ON AStat_tmp.file = ".IMAGES_TABLE.".file";
+ $result=pwg_query($sql);
+ if($result)
+ {
+ $sql="UPDATE ".HISTORY_TABLE.", ".$prefixeTable."AStat_picture2, ".IMAGES_TABLE."
+ SET ".HISTORY_TABLE.".image_id = ".$prefixeTable."AStat_picture2.NewId,
+ ".HISTORY_TABLE.".category_id = ".$prefixeTable."AStat_picture2.NewCatId
+ WHERE ".$prefixeTable."AStat_picture2.OldId = ".HISTORY_TABLE.".image_id";
+ $result=pwg_query($sql);
+ if($result)
+ {
+ $returned=true;
+ }
+ $sql="DROP TABLE IF EXISTS ".$prefixeTable."AStat_picture2";
+ $result=pwg_query($sql);
+ $sql="DROP TABLE IF EXISTS ".$prefixeTable."AStat_picture";
+ $result=pwg_query($sql);
+ }
+ return($returned);
+ }
+
+
+
+
+ /*
+ generics functions
+ */
+
+ /*
+ this function make filter list and apply template
+
+ $selected : category_id of selected item ("" if none)
+ */
+ private function make_filter_list($selected="")
+ {
+ global $template;
+
+ $template_datarows_values=array();
+ $template_datarows_labels=array();
+ $template_hiddenrows=array();
+
+
+ $template_datarows_values[]="";
+ $template_datarows_labels[]=l10n("AStat_nofilter");
+
+ $sql="SELECT id, name, global_rank FROM ".CATEGORIES_TABLE." order by global_rank";
+ $result = pwg_query($sql);
+ if($result)
+ {
+ while ($row = mysql_fetch_array($result))
+ {
+ $text=str_repeat(' ', substr_count($row['global_rank'], '.'));
+ $template_datarows_values[]=$row['id'];
+ $template_datarows_labels[]=$text.$row['name'];
+ }
+ }
+
+ $query=explode('&', $_SERVER['QUERY_STRING']);
+ foreach($query as $key => $value)
+ {
+ $nfo=explode('=', $value);
+ $template_hiddenrows[]=array(
+ 'VALUE' => urldecode($nfo[1]),
+ 'NAME' => $nfo[0]
+ );
+ }
+
+ $template->assign('ASTAT_LINK', $_SERVER['SCRIPT_NAME']);
+ $template->assign('f_AStat_catfilter_list_values', $template_datarows_values);
+ $template->assign('f_AStat_catfilter_list_labels', $template_datarows_labels);
+ $template->assign('f_AStat_catfilter_selected', $selected);
+ $template->assign('f_AStat_parameters', $template_hiddenrows);
+ } //make_filter_list
+
+
+ /*
+ this function make SELECT "WHERE" clause for filter list
+
+ $selected : category_id of selected item ("" if none)
+ */
+ private function make_where_clause($catfilter)
+ {
+ $returned=array();
+ $sql="SELECT id, ".CATEGORIES_TABLE.".global_rank
+ FROM ".CATEGORIES_TABLE.",
+ (SELECT global_rank FROM ".CATEGORIES_TABLE." WHERE id = '".$catfilter."') as tmp1
+ WHERE ".CATEGORIES_TABLE.".global_rank LIKE CONCAT(tmp1.global_rank, '%')
+ ORDER BY ".CATEGORIES_TABLE.".global_rank";
+ $result = pwg_query($sql);
+
+ if($result)
+ {
+ while ($row = mysql_fetch_row($result))
+ {
+ $returned[]=$row[0];
+ }
+ }
+
+ return(implode(',', $returned));
+ }
+
+
+ /*
+ format text : $value
+ */
+ private function format_link($value, $link)
+ {
+ return("$value ");
+ }
+
+ /*
+ return true if IP adress is given
+ */
+ private function is_IP($ip)
+ { //basic test, maybe a pcre will be more appropriate...
+ $tmp=explode('.', $ip);
+ if(count($tmp)!=4)
+ { return (false); }
+
+ for($i=0;$i<4;$i++)
+ {
+ if(!is_numeric($tmp[$i])) {Â return (false); }
+ }
+ return (true);
+ }
+
+ /*
+ change filename extension
+ */
+ private function change_file_ext($file, $newext)
+ { //filename can be for example
+ $tmp = explode('.', $file);
+ if(count($tmp)>1) { $tmp[count($tmp)-1] = $newext; }
+ return implode('.', $tmp);
+ }
+
+ /*
+ format number $octets with unit
+ $format = "A" : auto
+ "O" : o
+ "K" : Ko
+ "M" : Mo
+ "G" : Go
+ $thsep = thousand separator
+ $prec = number of decimal
+ $unitevis = true/false > renvoi l'unité ou non dans le résultat
+ */
+ private function formatoctet($octets, $format="A", $thsep=" ", $prec=2, $unitevis=true)
+ {
+ if($format=="A")
+ {
+ if($octets<1024)
+ { $format="O"; }
+ elseif($octets<1024000)
+ { $format="K"; }
+ elseif($octets<1024000000)
+ { $format="M"; }
+ else
+ { $format="G"; }
+ }
+ switch($format)
+ {
+ case "O":
+ $unite="o"; $div=1;
+ break;
+ case "K":
+ $unite="Ko"; $div=1024;
+ break;
+ case "M":
+ $unite="Mo"; $div=1024000;
+ break;
+ case "G":
+ $unite="Go"; $div=1024000000;
+ break;
+ }
+
+ $retour=number_format($octets/$div, $prec, '.', $thsep);
+ if($unitevis)
+ { $retour.=" ".$unite; }
+ return($retour);
+ }
+
+} // AStat_AI class
+
+
+?>
Index: /extensions/AStat/index.php
===================================================================
--- /extensions/AStat/index.php (revision 3394)
+++ /extensions/AStat/index.php (revision 3394)
@@ -0,0 +1,33 @@
+
Index: /extensions/AStat/language/en_UK/index.php
===================================================================
--- /extensions/AStat/language/en_UK/index.php (revision 3394)
+++ /extensions/AStat/language/en_UK/index.php (revision 3394)
@@ -0,0 +1,33 @@
+
Index: /extensions/AStat/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/AStat/language/en_UK/plugin.lang.php (revision 3394)
+++ /extensions/AStat/language/en_UK/plugin.lang.php (revision 3394)
@@ -0,0 +1,207 @@
+> v1.1.1 >>
+$lang['Pictures_seen'] = 'Pictures seen';
+$lang['Categories_seen'] = 'Categories seen';
+$lang['IP_visit'] = 'IP addresses';
+$lang['AStat_title_page'] = 'Advanced Statistics';
+$lang['IP_label'] = 'IP address';
+$lang['CATEGORY_LABEL'] = 'Category';
+$lang['pct_Pictures_seen'] = '%Pictures';
+$lang['pct_Pages_seen'] = '%Pages';
+$lang['ratio_Pictures_seen'] = 'Pictures seen';
+
+$lang['AStat_period_label_hours'] = 'Hours';
+$lang['AStat_period_label_days'] = 'Days';
+$lang['AStat_period_label_months'] = 'Months';
+$lang['AStat_period_label_years'] = 'Years';
+$lang['AStat_period_label_all'] = 'All year';
+$lang['AStat_period_label_global'] = 'Global';
+
+
+$lang['AStat_day_of_week_0'] = 'Sunday'; //sunday
+$lang['AStat_day_of_week_1'] = 'Monday';
+$lang['AStat_day_of_week_2'] = 'Tuesday';
+$lang['AStat_day_of_week_3'] = 'Wednesday';
+$lang['AStat_day_of_week_4'] = 'Thursday';
+$lang['AStat_day_of_week_5'] = 'Friday';
+$lang['AStat_day_of_week_6'] = 'Saturday';
+
+$lang['AStat_month_of_year_1'] = 'January';
+$lang['AStat_month_of_year_2'] = 'February';
+$lang['AStat_month_of_year_3'] = 'Mach';
+$lang['AStat_month_of_year_4'] = 'April';
+$lang['AStat_month_of_year_5'] = 'May';
+$lang['AStat_month_of_year_6'] = 'June';
+$lang['AStat_month_of_year_7'] = 'July';
+$lang['AStat_month_of_year_8'] = 'August';
+$lang['AStat_month_of_year_9'] = 'September';
+$lang['AStat_month_of_year_10'] = 'October';
+$lang['AStat_month_of_year_11'] = 'November';
+$lang['AStat_month_of_year_12'] = 'December';
+
+$lang['AStat_by_period'] = 'By period';
+$lang['AStat_by_ip'] = 'By IP';
+$lang['AStat_by_category'] = 'By category';
+$lang['AStat_config'] = 'Settings';
+
+$lang['AStat_BarColor_Pages'] = 'Number of pages';
+$lang['AStat_BarColor_Img'] = 'Number of pictures';
+$lang['AStat_BarColor_IP'] = 'Number of IP addresses';
+$lang['AStat_MouseOverColor'] = 'Mouse over row';
+$lang['AStat_config_title'] = 'AStat settings';
+$lang['AStat_config_colors_and_graph'] = 'Color & graphics settings';
+$lang['AStat_specific_ip_config'] = 'Specifics settings for statistics by IP';
+$lang['AStat_NbIPPerPages'] = 'Number of IP per pages';
+$lang['AStat_MaxBarWidth'] = 'Maximum bar width (pixels)';
+$lang['AStat_NbCatPerPages'] = 'Number of category per page';
+$lang['AStat_specific_category_config'] = 'Specifics settings for statistics by categories';
+$lang['AStat_do_save'] = 'Save';
+
+$lang['AStat_page_label'] = 'Page';
+$lang['AStat_pages_label'] = 'Pages';
+$lang['AStat_nb_total_ip'] = 'Total number of IP adresses';
+$lang['AStat_nb_total_category'] = 'Total number of categories';
+
+$lang['AStat_Nfo_Category'] = "For the choosen period, represent in percent number of pages & pictures seen by categories, as the average number of view per picture";
+$lang['AStat_Nfo_IP'] = "For the choosen period, represent number of pages & pictures seen by an IP address";
+$lang['AStat_Nfo_Period'] = "For the choosen period, represent number of pages & pictures seen, as the number of distincts IP adresses connected";
+
+$lang['AStat_IP_geolocalisation'] = 'Geolocalisation';
+$lang['AStat_PeriodPerDefault'] = 'Default choosen period';
+$lang['AStat_specific_period_config'] = 'Specifics settings for statistics by periods';
+$lang['AStat_PeriodPerDefault_global'] = 'Global';
+$lang['AStat_PeriodPerDefault_all'] = 'All years';
+$lang['AStat_PeriodPerDefault_year'] = 'The actual year';
+$lang['AStat_PeriodPerDefault_month'] = 'The actual month';
+$lang['AStat_PeriodPerDefault_day'] = 'The actual day';
+$lang['AStat_config_saved'] = 'Settings are saved !';
+$lang['AStat_ShowThumbCat'] = 'Show the representative category\'s thumbnail';
+$lang['AStat_yesno_true'] = 'Yes';
+$lang['AStat_yesno_false'] = 'No';
+$lang['AStat_sortcat_page'] = 'Representation in percent of seen pages';
+$lang['AStat_sortcat_picture'] = 'Representation in percent of seen pictures';
+$lang['AStat_sortcat_nbpicture'] = 'Average number of view per picture';
+$lang['AStat_DefaultSortCat'] = 'Default sort';
+$lang['AStat_SortCatLabel'] = 'Sorted by ';
+$lang['AStat_version'] = 'version ';
+
+$lang['AStat_RefImageLabel'] = 'Category / Picture\'s name';
+$lang['AStat_by_image'] = 'Per pictures';
+$lang['AStat_nb_total_image'] = 'Total number of pictures';
+$lang['AStat_SortImgLabel'] = 'Sorted by ';
+$lang['AStat_sortimg_picture'] = 'Picture\'s number of view';
+$lang['AStat_sortimg_catname'] = 'Alphabetical order - Category / Picture\'s name';
+$lang['AStat_Nfo_Image'] = "For the choosen period, number of views for each pictures, as the representation in percent of number of views on the total number of view";
+$lang['AStat_specific_image_config'] = 'Specifics settings for statistics per pictures';
+$lang['AStat_NbImgPerPages'] = 'Number of pictures per page';
+$lang['AStat_ShowThumbImg'] = 'Show picture\'s thumbnail';
+$lang['AStat_DefaultSortImg'] = 'Default sort';
+
+//--- << v1.1.1 <<
+//--- >> v1.2.0 >>
+$lang['AStat_BarColor_Cat'] = 'Number of categories';
+$lang['AStat_deleted_user'] = 'Deleted user';
+$lang['AStat_SortIPLabel'] = 'Sorted by ';
+$lang['AStat_sortip_picture'] = 'Number of pictures seen';
+$lang['AStat_sortip_ip'] = 'User / IP Adress';
+$lang['AStat_sortip_page'] = 'Number of pages seen';
+$lang['AStat_RefIPLabel'] = 'User / IP Adress';
+$lang['AStat_DefaultSortIP'] = 'Default sort';
+$lang['AStat_general_config'] = 'Global settings';
+$lang['AStat_SeeTimeRequests'] = 'Show time execution of requests';
+$lang['AStat_time_request_label'] = 'Request executed in';
+
+$lang['AStat_section_categories'] = $lang['Categories'];
+$lang['AStat_section_tags'] = $lang['Tags'];
+$lang['AStat_section_search'] = $lang['search'];
+$lang['AStat_section_list'] = $lang['random_cat'] ; // correction v1.2.1
+$lang['AStat_section_favorites'] = $lang['favorites'];
+$lang['AStat_section_most_visited'] = $lang['most_visited_cat'];
+$lang['AStat_section_best_rated'] = $lang['best_rated_cat'];
+$lang['AStat_section_recent_pics'] = $lang['recent_pics_cat'];
+$lang['AStat_section_recent_cats'] = $lang['recent_cats_cat'];
+$lang['AStat_section_additional_page'] = 'Plugin Additional pages ';
+$lang['AStat_section_web_services'] = 'Plugin Web services statistics ';
+$lang['AStat_section_most_commented'] = 'Plugin Most Commented ';
+$lang['AStat_section_unknown'] = 'Unknown [%s]';
+
+$lang['AStat_date_time_format'] = 'Y/d/m H:i:s';
+$lang['AStat_event'] = 'event';
+$lang['AStat_events'] = 'events';
+$lang['AStat_section_label'] = 'Section';
+$lang['AStat_deleted_picture'] = 'Picture doesn\'t exist anymore';
+$lang['AStat_tools'] = 'Tools';
+$lang['AStat_tools_title'] = 'Maintenance tools';
+$lang['AStat_tools_result_ok'] = "Action correctly performed";
+
+$lang['AStat_tools_deleted_user'] = 'Update history with user\'s references'; //v1.3.0
+$lang['AStat_tools_deleted_user_nfo0'] = "This function forces to guest a user ID generated as event in the history whose account has been since deleted.";
+$lang['AStat_tools_deleted_user_nfo1'] = "%s unknown user ID among history events impacting %s events : ";
+$lang['AStat_tools_deleted_user_nfo2'] = "All users ID in the history of event exist, No action shall be undertaken.";
+$lang['AStat_tools_deleted_user_apply'] = 'Update';
+
+$lang['AStat_tools_general_nfo'] = 'General information on history';
+
+$lang['AStat_tools_deleted_picture'] = 'Update the history with picture referrals'; // v1.3.0
+$lang['AStat_tools_deleted_picture_nfo0'] = "Impacts events in the history referring to images that no longer exist, a picture [Id #0] no longer exists in the base "; // v1.3.0
+$lang['AStat_tools_deleted_picture_nfo1'] = "%s unknow picture Id among history of event impacting %s events : ";
+$lang['AStat_tools_deleted_picture_nfo2'] = "All pictures Id in the history of event exist, No action shall be undertaken.";
+$lang['AStat_tools_deleted_picture_apply'] = 'Update';
+
+//--- << v1.2.0 <<
+
+//--- >> v1.3.0 >>
+
+$lang['AStat_section_old_deleted_cat'] = 'Unable to be imported old category ';
+$lang['AStat_tools_general_nfo_nfo'] = "%s events are present in the history
+ Table weights %s (Table: %s ; Index: %s)
+ Date of first event : %s
+ Date of last event : %s ";
+$lang['AStat_tools_purge_history'] = "Cleaning of the history";
+$lang['AStat_tools_purge_history_nfo'] = "This function will clean the history from all past event from a given date and will optimize the table.Operation cannot be reversed .";
+$lang['AStat_tools_purge_history_apply'] = "Clean";
+$lang['AStat_tools_purge_history_date'] = "To purge all events prior (DD/MM/AAAA) ";
+$lang['AStat_tools_purge_history_imageid0'] = "To purge all events associated to deleted images (%s events in history)";
+$lang['AStat_tools_purge_history_categoryid0'] = "To purge events associated to deleted categories (%s events in history)";
+$lang['AStat_tools_result_ko'] = "An error has occurred. Action has not been correctly performed";
+$lang['AStat_tools_invalid_date'] = "Given date is not valid !";
+$lang['AStat_tools_invalid_date2'] = "Given date is upper or equal to date of the day";
+$lang['AStat_tools_deleted_picture_error0'] = "Priming has failed";
+$lang['AStat_tools_deleted_picture_error1'] = "New association of events in the history has failed";
+$lang['AStat_tools_deleted_picture_ok0'] = "Priming of the table succeeded, files can be reorganized on the server";
+$lang['AStat_tools_deleted_picture_ok1'] = "Linking event in the history has succeeded";
+
+$lang['AStat_tools_deleted_picture_nfo3'] = "When pictures are physically transferred from one directory, synchronization deletes pictures from the base and reinset then with a new reference. A transferred image then leaves in the history events linked to reference that no longer exist.Astat allows :
to memorize picture references before to synchronize link history events with exact picture reference after a synchronization Beware !
should pictures have the same file name outcome cannot be predicted this function cannot deal with picture about which file name has been changed on the server ";
+
+$lang['AStat_tools_deleted_picture_prepare_action'] = "Prior to synchronization : prepare AStat ";
+$lang['AStat_tools_deleted_picture_do_action'] = "After synchronization : link again new picture ID to events in the history";
+$lang['AStat_tools_deleted_picture_do'] = "Make the process";
+$lang['AStat_tools_deleted_picture_nfo_nb'] = "(%s picture Ids cannot be linked to %s events in the history)";
+
+
+$lang['AStat_tools_deleted_category'] = 'Update categories in the history';
+$lang['AStat_tools_deleted_category_nfo0'] = "Assigns for events in the history that no longer exist. Deleted category"; // v1.3.0
+$lang['AStat_tools_deleted_category_nfo1'] = "%s unexisting directory are listed among events in history and impact %s events : ";
+$lang['AStat_tools_deleted_category_nfo2'] = "All event categories in the history exist. No action shall be undertaken.";
+$lang['AStat_tools_deleted_category_apply'] = "Update";
+
+
+$lang['AStat_section_deleted_cat'] = "Category deleted";
+
+
+//--- << v1.3.0 <<
+//--- >> v1.3.2 >>
+$lang['AStat_adviser_not_authorized'] = "Action aborted : adviser profile dot not permit this kind of action";
+//--- << v1.3.2 <<
+//--- >> v1.4.0 >>
+$lang['AStat_catfilter_list'] = "Apply filter on categories";
+$lang['AStat_nofilter'] = "--- No filter ---";
+//--- << v1.4.0 <<
+
+//--- >> v2.0.0 >>
+$lang['AStat_confignotsaved'] = "An error has occured, settings aren't saved";
+$lang['AStat_gpc2_not_installed'] = "Plugin 'Grum Plugins Classes 2' (release >= %s) is needed to install AStat";
+
+
+?>
Index: /extensions/AStat/language/fr_FR/index.php
===================================================================
--- /extensions/AStat/language/fr_FR/index.php (revision 3394)
+++ /extensions/AStat/language/fr_FR/index.php (revision 3394)
@@ -0,0 +1,33 @@
+
Index: /extensions/AStat/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/AStat/language/fr_FR/plugin.lang.php (revision 3394)
+++ /extensions/AStat/language/fr_FR/plugin.lang.php (revision 3394)
@@ -0,0 +1,208 @@
+> v1.1.1 >>
+$lang['Pictures_seen'] = 'Images vues';
+$lang['Categories_seen'] = 'Catégories vues';
+$lang['IP_visit'] = 'Adresses IP';
+$lang['AStat_title_page'] = 'Statistiques Avancées';
+$lang['IP_label'] = 'Adresse IP';
+$lang['CATEGORY_LABEL'] = 'Catégorie';
+$lang['pct_Pictures_seen'] = '%Images';
+$lang['pct_Pages_seen'] = '%Pages';
+$lang['ratio_Pictures_seen'] = 'Images vues';
+
+$lang['AStat_period_label_hours'] = 'Heures';
+$lang['AStat_period_label_days'] = 'Jours';
+$lang['AStat_period_label_months'] = 'Mois';
+$lang['AStat_period_label_years'] = 'Années';
+$lang['AStat_period_label_all'] = 'Toutes années';
+$lang['AStat_period_label_global'] = 'Global';
+
+
+$lang['AStat_day_of_week_0'] = 'Dimanche'; //sunday
+$lang['AStat_day_of_week_1'] = 'Lundi';
+$lang['AStat_day_of_week_2'] = 'Mardi';
+$lang['AStat_day_of_week_3'] = 'Mercredi';
+$lang['AStat_day_of_week_4'] = 'Jeudi';
+$lang['AStat_day_of_week_5'] = 'Vendredi';
+$lang['AStat_day_of_week_6'] = 'Samedi';
+
+$lang['AStat_month_of_year_1'] = 'Janvier';
+$lang['AStat_month_of_year_2'] = 'Février';
+$lang['AStat_month_of_year_3'] = 'Mars';
+$lang['AStat_month_of_year_4'] = 'Avril';
+$lang['AStat_month_of_year_5'] = 'Mai';
+$lang['AStat_month_of_year_6'] = 'Juin';
+$lang['AStat_month_of_year_7'] = 'Juillet';
+$lang['AStat_month_of_year_8'] = 'Août';
+$lang['AStat_month_of_year_9'] = 'Septembre';
+$lang['AStat_month_of_year_10'] = 'Octobre';
+$lang['AStat_month_of_year_11'] = 'Novembre';
+$lang['AStat_month_of_year_12'] = 'Décembre';
+
+$lang['AStat_by_period'] = 'Par périodes';
+$lang['AStat_by_ip'] = 'Par IP';
+$lang['AStat_by_category'] = 'Par catégories';
+$lang['AStat_config'] = 'Configuration';
+
+$lang['AStat_BarColor_Pages'] = 'Nombre de pages';
+$lang['AStat_BarColor_Img'] = 'Nombre d\'images';
+$lang['AStat_BarColor_IP'] = 'Nombre d\'adresses IP';
+$lang['AStat_MouseOverColor'] = 'Ligne survolée';
+$lang['AStat_config_title'] = 'Configuration de AStat';
+$lang['AStat_config_colors_and_graph'] = 'Configuration des couleurs & graphiques';
+$lang['AStat_specific_ip_config'] = 'Configuration spécifique statistiques par IP';
+$lang['AStat_NbIPPerPages'] = 'Nombre d\'IP par pages';
+$lang['AStat_MaxBarWidth'] = 'Largeur maximale des barres (pixels)';
+$lang['AStat_NbCatPerPages'] = 'Nombre de catégories par pages';
+$lang['AStat_specific_category_config'] = 'Configuration spécifique statistiques par catégories';
+$lang['AStat_do_save'] = 'Enregistrer';
+
+$lang['AStat_page_label'] = 'Page';
+$lang['AStat_pages_label'] = 'Pages';
+$lang['AStat_nb_total_ip'] = 'Nombre total d\'adresses IP';
+$lang['AStat_nb_total_category'] = 'Nombre total de catégories';
+
+$lang['AStat_Nfo_Category'] = "Pour la période, représentation en pourcentage du nombre de pages & images vues par catégories, ainsi que du nombre moyen de visualisation par image";
+$lang['AStat_Nfo_IP'] = "Pour la période, représentation du nombre de pages & images vues par une adresse IP";
+$lang['AStat_Nfo_Period'] = "Pour la période, représentation du nombre de pages & images vues, ainsi que du nombre d'adresses IP distinctes s'étant connectées";
+
+$lang['AStat_IP_geolocalisation'] = 'Géolocalisation';
+$lang['AStat_PeriodPerDefault'] = 'Période affichée par défaut';
+$lang['AStat_specific_period_config'] = 'Configuration spécifique statistiques par périodes';
+$lang['AStat_PeriodPerDefault_global'] = 'Globale';
+$lang['AStat_PeriodPerDefault_all'] = 'Toutes les années';
+$lang['AStat_PeriodPerDefault_year'] = 'L\'année en cours';
+$lang['AStat_PeriodPerDefault_month'] = 'Le mois en cours';
+$lang['AStat_PeriodPerDefault_day'] = 'Le jour même';
+$lang['AStat_config_saved'] = 'Configuration enregistrée !';
+$lang['AStat_ShowThumbCat'] = 'Voir l\'aperçu représentatif de la catégorie';
+$lang['AStat_yesno_true'] = 'Oui';
+$lang['AStat_yesno_false'] = 'Non';
+$lang['AStat_sortcat_page'] = 'Représentation du pourcentage de pages vues ';
+$lang['AStat_sortcat_picture'] = 'Représentation du pourcentage d\'images vues';
+$lang['AStat_sortcat_nbpicture'] = 'Nombre moyen de vues par image';
+$lang['AStat_DefaultSortCat'] = 'Tri par défaut';
+$lang['AStat_SortCatLabel'] = 'Trié par ';
+$lang['AStat_version'] = 'version ';
+
+$lang['AStat_RefImageLabel'] = 'Catégorie / Nom de l\'image';
+$lang['AStat_by_image'] = 'Par images';
+$lang['AStat_nb_total_image'] = 'Nombre total d\'images';
+$lang['AStat_SortImgLabel'] = 'Trié par ';
+$lang['AStat_sortimg_picture'] = 'Nombre de visualisations de l\'image';
+$lang['AStat_sortimg_catname'] = 'Ordre alphabétique - Catégorie / Nom de l\'image';
+$lang['AStat_Nfo_Image'] = "Pour la période, nombre de visualisations pour chaque images, ainsi que le pourcentage que celà représente sur le nombre total d'images visualisées";
+$lang['AStat_specific_image_config'] = 'Configuration spécifique statistiques par images';
+$lang['AStat_NbImgPerPages'] = 'Nombre d\'images par pages';
+$lang['AStat_ShowThumbImg'] = 'Voir l\'aperçu de la photo';
+$lang['AStat_DefaultSortImg'] = 'Tri par défaut';
+
+//--- << v1.1.1 <<
+//--- >> v1.2.0 >>
+$lang['AStat_BarColor_Cat'] = 'Nombre de catégories';
+$lang['AStat_deleted_user'] = 'Utilisateur supprimé';
+$lang['AStat_SortIPLabel'] = 'Trié par ';
+$lang['AStat_sortip_picture'] = 'Nombre d\'images vues';
+$lang['AStat_sortip_ip'] = 'Utilisateur / Adresse';
+$lang['AStat_sortip_page'] = 'Nombre de pages vues';
+$lang['AStat_RefIPLabel'] = 'Utilisateur / Adresse IP';
+$lang['AStat_DefaultSortIP'] = 'Tri par défaut';
+$lang['AStat_general_config'] = 'Configuration générale';
+$lang['AStat_SeeTimeRequests'] = 'Voir la durée d\'exécution des requêtes';
+$lang['AStat_time_request_label'] = 'Exécution de la requête en';
+
+$lang['AStat_section_categories'] = $lang['Categories'];
+$lang['AStat_section_tags'] = $lang['Tags'];
+$lang['AStat_section_search'] = $lang['search'];
+$lang['AStat_section_list'] = $lang['random_cat'] ; // correction v1.2.1
+$lang['AStat_section_favorites'] = $lang['favorites'];
+$lang['AStat_section_most_visited'] = $lang['most_visited_cat'];
+$lang['AStat_section_best_rated'] = $lang['best_rated_cat'];
+$lang['AStat_section_recent_pics'] = $lang['recent_pics_cat'];
+$lang['AStat_section_recent_cats'] = $lang['recent_cats_cat'];
+$lang['AStat_section_additional_page'] = 'Plugin Additional pages ';
+$lang['AStat_section_web_services'] = 'Plugin Web services statistics ';
+$lang['AStat_section_most_commented'] = 'Plugin Most Commented ';
+$lang['AStat_section_unknown'] = 'Non gérée [%s]';
+
+$lang['AStat_date_time_format'] = 'd/m/Y H:i:s';
+$lang['AStat_event'] = 'évènement';
+$lang['AStat_events'] = 'évènements';
+$lang['AStat_section_label'] = 'Section';
+$lang['AStat_deleted_picture'] = 'La photo n\'existe plus en base';
+$lang['AStat_tools'] = 'Outils';
+$lang['AStat_tools_title'] = 'Outils de maintenance';
+$lang['AStat_tools_result_ok'] = "L'action a été correctement menée";
+
+$lang['AStat_tools_deleted_user'] = 'Mettre à jour dans l\'historique les références des utilisateurs'; //v1.3.0
+$lang['AStat_tools_deleted_user_nfo0'] = "Cette fonction force à guest l'identifiant d'un utilisateur ayant généré un évènement dans l'historique et dont le compte a été supprimé depuis.";
+$lang['AStat_tools_deleted_user_nfo1'] = "%s identifiants inconnus sont présents dans les évènements de l'historique et impactent %s évènements : ";
+$lang['AStat_tools_deleted_user_nfo2'] = "Tous les identifiants utilisateurs présents dans les évènements de l'historique existent. Aucune action n'a besoin d'être menée.";
+$lang['AStat_tools_deleted_user_apply'] = 'Effectuer la mise à jour';
+
+$lang['AStat_tools_general_nfo'] = 'Informations générales sur l\'historique';
+
+$lang['AStat_tools_deleted_picture'] = 'Mettre à jour dans l\'historique les références des images'; // v1.3.0
+$lang['AStat_tools_deleted_picture_nfo0'] = "Affecte pour les évènements de l'historique référencants des images qui n'existent plus, un identifiant photo n'existe plus en base [ Id #0 ] ."; // v1.3.0
+$lang['AStat_tools_deleted_picture_nfo1'] = "%s images inexistantes sont présentes dans les évènements de l'historique et impactent %s évènements : ";
+$lang['AStat_tools_deleted_picture_nfo2'] = "Toutes les images présentes dans les évènements de l'historique existent. Aucune action n'a besoin d'être menée.";
+$lang['AStat_tools_deleted_picture_apply'] = 'Effectuer la mise à jour';
+
+//--- << v1.2.0 <<
+
+//--- >> v1.3.0 >>
+
+$lang['AStat_section_old_deleted_cat'] = 'Ancienne catégorie n\'ayant pu être importée';
+$lang['AStat_tools_general_nfo_nfo'] = "%s évènements sont présents dans l'historique
+ La table pèse %s (Table: %s ; Index: %s)
+ Date du premier évènement : %s
+ Date du dernier évènement : %s ";
+$lang['AStat_tools_purge_history'] = "Purge de l'historique";
+$lang['AStat_tools_purge_history_nfo'] = "Cette fonction effectue sur l'historique une purge de tous les évènements antérieurs à une date donnée et optimise la table. Cette action irréversible .";
+$lang['AStat_tools_purge_history_apply'] = "Appliquer la purge";
+$lang['AStat_tools_purge_history_date'] = "Purger les évènements antérieurs à (JJ/MM/AAAA) ";
+$lang['AStat_tools_purge_history_imageid0'] = "Purger les évènements associés à des images supprimées (%s évènements dans l'historique)";
+$lang['AStat_tools_purge_history_categoryid0'] = "Purger les évènements associés à des catégories supprimées (%s évènements dans l'historique)";
+$lang['AStat_tools_result_ko'] = "Une erreur est survenue, l'action n'a pu être correctement menée";
+$lang['AStat_tools_invalid_date'] = "La date renseignée est invalide !";
+$lang['AStat_tools_invalid_date2'] = "La date renseignée est supérieure ou égale à la date du jour !";
+$lang['AStat_tools_deleted_picture_error0'] = "La préparation a échouée";
+$lang['AStat_tools_deleted_picture_error1'] = "La réassocation des évènements de l'historique a échouée";
+$lang['AStat_tools_deleted_picture_ok0'] = "La préparation de la table a réussie, vous pouvez procéder à la réorganisation des fichiers sur le serveur";
+$lang['AStat_tools_deleted_picture_ok1'] = "La réassocation des évènements de l'historique a réussie";
+
+$lang['AStat_tools_deleted_picture_nfo3'] = "Lorsque des images sont déplacées physiquement d'un répertoire, la synchronisation supprime les images de la base et les réinsère avec une nouvelle référence. Une image déplacée laisse donc dans les évènements de l'historique une trace avec des références qui n'existent plus.AStat permet :
de mémoriser les références d'images avant de procéder à la synchronisation de réassocier dans les évènements de l'historique les bonnes références d'une image après avoir procédé à une synchronisation Attention !
si des images différentes ont les mêmes noms de fichiers, le résultat est imprévisible cette fonctionnalité ne peut pas traiter les images pour lesquelles le fichier sur le serveur a été renomé ";
+
+$lang['AStat_tools_deleted_picture_prepare_action'] = "Avant de procéder à la synchronisation : préparer AStat ";
+$lang['AStat_tools_deleted_picture_do_action'] = "Après avoir procédé à la synchronisation : réassocier les nouveaux identifiant d'images aux évènements de l'historique ";
+$lang['AStat_tools_deleted_picture_do'] = "Effectuer le traitement";
+$lang['AStat_tools_deleted_picture_nfo_nb'] = "(%s identifiants d'images peuvent être réassociés à %s évènements de l'historique)";
+
+
+$lang['AStat_tools_deleted_category'] = 'Mettre à jour dans l\'historique les références de catégories';
+$lang['AStat_tools_deleted_category_nfo0'] = "Affecte pour les évènements de l'historique référencants des catégories qui n'existent plus, la section Catégorie supprimée ."; // v1.3.0
+$lang['AStat_tools_deleted_category_nfo1'] = "%s catégories inexistantes sont présentes dans les évènements de l'historique et impactent %s évènements : ";
+$lang['AStat_tools_deleted_category_nfo2'] = "Toutes les catégories présentes dans les évènements de l'historique existent. Aucune action n'a besoin d'être menée.";
+$lang['AStat_tools_deleted_category_apply'] = "Effectuer la mise à jour";
+
+$lang['AStat_section_deleted_cat'] = "Catégorie supprimée";
+
+
+//--- << v1.3.0 <<
+//--- >> v1.3.2 >>
+$lang['AStat_adviser_not_authorized'] = "Action annulée : le profil de conseiller ne permet pas d'effectuer ce type d'action";
+//--- << v1.3.2 <<
+//--- >> v1.4.0 >>
+$lang['AStat_catfilter_list'] = "Appliquer un filtre sur les catégories";
+$lang['AStat_nofilter'] = "--- Pas de filtre ---";
+//--- << v1.4.0 <<
+
+//--- >> v2.0.0 >>
+$lang['AStat_confignotsaved'] = "Une erreur s'est produite, la configuration n'a pas été enregistrée";
+$lang['AStat_gpc2_not_installed'] = "Le plugin 'Grum Plugins Classes 2' (version >= %s) est nécessaire pour que AStat puisse être installé";
+
+
+?>
Index: /extensions/AStat/language/index.php
===================================================================
--- /extensions/AStat/language/index.php (revision 3394)
+++ /extensions/AStat/language/index.php (revision 3394)
@@ -0,0 +1,33 @@
+
Index: /extensions/AStat/main.inc.php
===================================================================
--- /extensions/AStat/main.inc.php (revision 3394)
+++ /extensions/AStat/main.inc.php (revision 3394)
@@ -0,0 +1,70 @@
+>
+--------------------------------------------------------------------------------
+
+:: HISTORY
+
+2.0.0 - 13/05/07 - release for piwigo 2.0
+2.0.1 - 09/03/01 - bug corrected (can't open file because plugin directory
+ was hardcoded...)
+2.0.2 - 09/03/08 - bug referenced
+ english forum : http://piwigo.org/forum/viewtopic.php?pid=105990#p105990
+ french forum : http://fr.piwigo.org/forum/viewtopic.php?pid=107205#p107205
+ SQL request for stat by categories works with mySQL 4.1.22 and not with mySQL 5
+2.0.3 - 28/03/08 - bug referenced
+ french forum : http://fr.piwigo.org/forum/viewtopic.php?pid=107236#p107236
+ SQL request for stat by categories works with mySQL 4.1.22 and not with mySQL 5
+2.0.4 - 21/05/09 - bug on tools
+ it was not possible to use tools to manage deleted items
+
+:: TO DO
+
+--------------------------------------------------------------------------------
+
+:: NFO
+ AStat_AIM : classe to manage plugin integration into plugin menu
+ AStat_AIP : classe to manage plugin admin pages
+
+--------------------------------------------------------------------------------
+*/
+
+// pour faciliter le debug :o)
+// ini_set('error_reporting', E_ALL);
+// ini_set('display_errors', true);
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+define('ASTAT_DIR' , basename(dirname(__FILE__)));
+define('ASTAT_PATH' , PHPWG_PLUGINS_PATH . ASTAT_DIR . '/');
+
+define('ASTAT_VERSION' , '2.0.4'); // => ne pas oublier la version dans l'entête !!
+
+global $prefixeTable;
+
+//AStat loaded and active only if in admin page
+if(basename($_SERVER["PHP_SELF"])=='admin.php')
+{
+ include_once("astat_aim.class.inc.php");
+
+ $obj = new AStat_AIM($prefixeTable, __FILE__);
+ $obj->init_events();
+ set_plugin_data($plugin['id'], $obj);
+}
+
+?>
Index: /extensions/AStat/maintain.inc.php
===================================================================
--- /extensions/AStat/maintain.inc.php (revision 3394)
+++ /extensions/AStat/maintain.inc.php (revision 3394)
@@ -0,0 +1,101 @@
+>
+ ------------------------------------------------------------------------------
+ See main.inc.php for release information
+
+ --------------------------------------------------------------------------- */
+
+if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+
+define('ASTAT_DIR' , basename(dirname(__FILE__)));
+define('ASTAT_PATH' , PHPWG_PLUGINS_PATH . ASTAT_DIR . '/');
+
+//ini_set('error_reporting', E_ALL);
+//ini_set('display_errors', true);
+
+global $gpc_installed, $lang; //needed for plugin manager compatibility
+
+/* -----------------------------------------------------------------------------
+AStat-2 needs the Grum Plugin Classe
+----------------------------------------------------------------------------- */
+$gpc_installed=false;
+if(file_exists(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/common_plugin.class.inc.php'))
+{
+ @include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/main.inc.php');
+ // need GPC release greater or equal than 2.0.1
+ if(checkGPCRelease(2,0,1))
+ {
+ @include_once("astat_aim.class.inc.php");
+ $gpc_installed=true;
+ }
+}
+
+function gpcMsgError(&$errors)
+{
+ array_push($errors, sprintf(l10n('AStat_gpc2_not_installed'), "2.0.1"));
+}
+// -----------------------------------------------------------------------------
+
+
+load_language('plugin.lang', ASTAT_PATH);
+
+function plugin_install($plugin_id, $plugin_version, &$errors)
+{
+ global $prefixeTable, $gpc_installed;
+ if($gpc_installed)
+ {
+ $obj = new AStat_AIM($prefixeTable, __FILE__);
+ $obj->delete_config();
+ $obj->init_config();
+ $obj->save_config();
+ }
+ else
+ {
+ gpcMsgError($errors);
+ }
+}
+
+function plugin_activate($plugin_id, $plugin_version, &$errors)
+{
+ global $prefixeTable, $gpc_installed;
+ if($gpc_installed)
+ {
+ $obj = new AStat_AIM($prefixeTable, __FILE__);
+ $obj->init_config();
+ $obj->load_config();
+ $obj->save_config();
+ $obj->alter_history_section_enum('deleted_cat');
+ }
+ else
+ {
+ gpcMsgError($errors);
+ }
+}
+
+function plugin_deactivate($plugin_id)
+{
+}
+
+function plugin_uninstall($plugin_id)
+{
+ global $prefixeTable, $gpc_installed;
+ if($gpc_installed)
+ {
+ $obj = new AStat_AIM($prefixeTable, __FILE__);
+ $obj->delete_config();
+ }
+ else
+ {
+ gpcMsgError($errors);
+ }
+}
+
+
+
+?>