Index: extensions/AStat/astat_aip.class.inc.php
===================================================================
--- extensions/AStat/astat_aip.class.inc.php	(revision 10264)
+++ extensions/AStat/astat_aip.class.inc.php	(revision 15342)
@@ -41,20 +41,20 @@
     $this->tabsheet->add('stats_by_period',
                           l10n('AStat_by_period'),
-                          $this->getAdminLink().'&amp;fAStat_tabsheet=stats_by_period');
+                          $this->getAdminLink().'-stats_by_period');
     $this->tabsheet->add('stats_by_ip',
                           l10n('AStat_by_ip'),
-                          $this->getAdminLink().'&amp;fAStat_tabsheet=stats_by_ip');
+                          $this->getAdminLink().'-stats_by_ip');
     $this->tabsheet->add('stats_by_category',
                           l10n('AStat_by_category'),
-                          $this->getAdminLink().'&amp;fAStat_tabsheet=stats_by_category');
+                          $this->getAdminLink().'-stats_by_category');
     $this->tabsheet->add('stats_by_image',
                           l10n('AStat_by_image'),
-                          $this->getAdminLink().'&amp;fAStat_tabsheet=stats_by_image');
+                          $this->getAdminLink().'-stats_by_image');
     $this->tabsheet->add('config',
                           l10n('AStat_config'),
-                          $this->getAdminLink().'&amp;fAStat_tabsheet=config');
+                          $this->getAdminLink().'-config');
     $this->tabsheet->add('tools',
                           l10n('AStat_tools'),
-                          $this->getAdminLink().'&amp;fAStat_tabsheet=tools');
+                          $this->getAdminLink().'-tools');
 
   }
@@ -100,5 +100,5 @@
     }
 
-    if($_REQUEST['fAStat_tabsheet']=='stats_by_period')
+    if($_GET['tab']=='stats_by_period')
     {
       $this->display_stats_by_period(
@@ -111,5 +111,5 @@
       );
     }
-    elseif($_REQUEST['fAStat_tabsheet']=='stats_by_ip')
+    elseif($_GET['tab']=='stats_by_ip')
     {
       if(isset($_REQUEST['fAStat_IP_BL']))
@@ -129,5 +129,5 @@
       );
     }
-    elseif($_REQUEST['fAStat_tabsheet']=='stats_by_category')
+    elseif($_GET['tab']=='stats_by_category')
     {
       $this->display_stats_by_category(
@@ -143,5 +143,5 @@
       );
     }
-    elseif($_REQUEST['fAStat_tabsheet']=='stats_by_image')
+    elseif($_GET['tab']=='stats_by_image')
     {
       $this->display_stats_by_image(
@@ -158,14 +158,14 @@
       );
     }
-    elseif($_REQUEST['fAStat_tabsheet']=='config')
+    elseif($_GET['tab']=='config')
     {
       $this->display_config();
     }
-    elseif($_REQUEST['fAStat_tabsheet']=='tools')
+    elseif($_GET['tab']=='tools')
     {
       $this->display_tools();
     }
 
-    $this->tabsheet->select($_REQUEST['fAStat_tabsheet']);
+    $this->tabsheet->select($_GET['tab']);
     $this->tabsheet->assign();
     $selected_tab=$this->tabsheet->get_selected();
@@ -173,5 +173,5 @@
 
     $template_plugin["ASTAT_VERSION"] = "<i>AStat</i> ".l10n('AStat_version').ASTAT_VERSION;
-    $template_plugin["ASTAT_PAGE"] = $_REQUEST['fAStat_tabsheet'];
+    $template_plugin["ASTAT_PAGE"] = $_GET['tab'];
 
     $template->assign('plugin', $template_plugin);
@@ -217,7 +217,7 @@
 
     //initialise $REQUEST values if not defined
-    if(!array_key_exists('fAStat_tabsheet', $_REQUEST))
-    {
-      $_REQUEST['fAStat_tabsheet']='stats_by_period';
+    if(!array_key_exists('tab', $_GET))
+    {
+      $_GET['tab']='stats_by_period';
     }
     if(!array_key_exists('fAStat_defper', $_REQUEST))
@@ -254,5 +254,5 @@
     }
 
-    if(($_REQUEST['fAStat_tabsheet']=='stats_by_period')&&($_REQUEST['fAStat_defper']=='Y'))
+    if(($_GET['tab']=='stats_by_period')&&($_REQUEST['fAStat_defper']=='Y'))
     {
       if($this->config['AStat_default_period']!='global')
@@ -584,5 +584,5 @@
     if($show_thumb=='true')
     {
-      $sql_thumb = ', '.IMAGES_TABLE.'.path as ThumbPath, '.IMAGES_TABLE.'.file as ThumbFile, '.IMAGES_TABLE.'.tn_ext as Extension';
+      $sql_thumb = ', '.IMAGES_TABLE.'.path as ImgPath, '.IMAGES_TABLE.'.file as ThumbFile, '.IMAGES_TABLE.'.id as ImgId';
       $sql_fromthumb = "LEFT JOIN ".IMAGES_TABLE." ON ic2.representative_picture_id = ".IMAGES_TABLE.".id  ";
     }
@@ -686,6 +686,6 @@
         ".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 ";
+        ".IMAGES_TABLE.".path as ImgPath, ".IMAGES_TABLE.".file as ThumbFile,
+        MaxImg2.somme as NbVuesMax ";
 
     $sql_from = " from ((".HISTORY_TABLE." LEFT JOIN ".IMAGES_TABLE." ON
@@ -793,18 +793,18 @@
         "day" => $this->getAdminLink()."&amp;fAStat_defper=N&amp;fAStat_all=N&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
 
-    $ip_links=array("all" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_ip",
-        "year" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_ip&amp;fAStat_year=",
-        "month" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_ip&amp;fAStat_year=$year&amp;fAStat_month=",
-        "day" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_ip&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=");
-
-    $cat_links=array("all" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_category",
-        "year" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_category&amp;fAStat_year=",
-        "month" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_category&amp;fAStat_year=$year&amp;fAStat_month=",
-        "day" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_category&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=");
-
-    $img_links=array("all" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image",
-        "year" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image&amp;fAStat_year=",
-        "month" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=",
-        "day" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=");
+    $ip_links=array("all" => $this->getAdminLink()."-stats_by_ip",
+        "year" => $this->getAdminLink()."-stats_by_ip&amp;fAStat_year=",
+        "month" => $this->getAdminLink()."-stats_by_ip&amp;fAStat_year=$year&amp;fAStat_month=",
+        "day" => $this->getAdminLink()."-stats_by_ip&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=");
+
+    $cat_links=array("all" => $this->getAdminLink()."-stats_by_category",
+        "year" => $this->getAdminLink()."-stats_by_category&amp;fAStat_year=",
+        "month" => $this->getAdminLink()."-stats_by_category&amp;fAStat_year=$year&amp;fAStat_month=",
+        "day" => $this->getAdminLink()."-stats_by_category&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=");
+
+    $img_links=array("all" => $this->getAdminLink()."-stats_by_image",
+        "year" => $this->getAdminLink()."-stats_by_image&amp;fAStat_year=",
+        "month" => $this->getAdminLink()."-stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=",
+        "day" => $this->getAdminLink()."-stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=");
 
 
@@ -976,13 +976,13 @@
         "day" => $this->getAdminLink()."&amp;fAStat_defper=N&amp;fAStat_all=N&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
 
-    $ip_links=array("all" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_ip",
-        "year" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_ip&amp;fAStat_year=$year",
-        "month" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_ip&amp;fAStat_year=$year&amp;fAStat_month=$month",
-        "day" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_ip&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
-
-    $img_links=array("all" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image",
-        "year" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image&amp;fAStat_year=$year",
-        "month" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month",
-        "day" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
+    $ip_links=array("all" => $this->getAdminLink()."-stats_by_ip",
+        "year" => $this->getAdminLink()."-stats_by_ip&amp;fAStat_year=$year",
+        "month" => $this->getAdminLink()."-stats_by_ip&amp;fAStat_year=$year&amp;fAStat_month=$month",
+        "day" => $this->getAdminLink()."-stats_by_ip&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
+
+    $img_links=array("all" => $this->getAdminLink()."-stats_by_image",
+        "year" => $this->getAdminLink()."-stats_by_image&amp;fAStat_year=$year",
+        "month" => $this->getAdminLink()."-stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month",
+        "day" => $this->getAdminLink()."-stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
 
 
@@ -1140,8 +1140,8 @@
         "day" => $this->getAdminLink()."&amp;fAStat_defper=N&amp;fAStat_all=N&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
 
-    $cat_links=array("all" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_category",
-        "year" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_category&amp;fAStat_year=$year",
-        "month" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_category&amp;fAStat_year=$year&amp;fAStat_month=$month",
-        "day" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_category&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
+    $cat_links=array("all" => $this->getAdminLink()."-stats_by_category",
+        "year" => $this->getAdminLink()."-stats_by_category&amp;fAStat_year=$year",
+        "month" => $this->getAdminLink()."-stats_by_category&amp;fAStat_year=$year&amp;fAStat_month=$month",
+        "day" => $this->getAdminLink()."-stats_by_category&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
 
     /* make navigation links */
@@ -1215,6 +1215,6 @@
       if($showthumb=='true')
       {
-        $filethumb=$this->change_file_ext($stats[$i]["ThumbFile"], $stats[$i]["Extension"]);
-        $filethumb=str_replace($stats[$i]["ThumbFile"],"thumbnail/".$conf['prefix_thumbnail'].$filethumb,$stats[$i]["ThumbPath"]); }
+        $filethumb=DerivativeImage::thumb_url(array('id'=>$stats[$i]["ImgId"], 'path'=>$stats[$i]["ImgPath"]));
+      }
       else
       {
@@ -1286,8 +1286,8 @@
         "day" => $this->getAdminLink()."&amp;fAStat_defper=N&amp;fAStat_all=N&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
 
-    $img_links=array("all" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image",
-        "year" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image&amp;fAStat_year=$year",
-        "month" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month",
-        "day" => $this->getAdminLink()."&amp;fAStat_tabsheet=stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
+    $img_links=array("all" => $this->getAdminLink()."-stats_by_image",
+        "year" => $this->getAdminLink()."-stats_by_image&amp;fAStat_year=$year",
+        "month" => $this->getAdminLink()."-stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month",
+        "day" => $this->getAdminLink()."-stats_by_image&amp;fAStat_year=$year&amp;fAStat_month=$month&amp;fAStat_day=$day");
 
     /* navigation links */
@@ -1357,6 +1357,5 @@
       if($showthumb=='true')
       {
-        $filethumb=$this->change_file_ext($stats[$i]["ThumbFile"], $stats[$i]["Extension"]);
-        $filethumb=str_replace($stats[$i]["ThumbFile"],"thumbnail/".$conf['prefix_thumbnail'].$filethumb,$stats[$i]["ThumbPath"]);
+        $filethumb=DerivativeImage::thumb_url(array('id'=>$stats[$i]["ImgId"], 'path'=>$stats[$i]["ImgPath"]));
       }
       else
@@ -2380,14 +2379,4 @@
 
   /*
-    change filename extension
-  */
-  private function change_file_ext($file, $newext)
-  {  //filename can be <filename.truc.jpeg> 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
