Index: /extensions/Statistics/admin/index.php
===================================================================
--- /extensions/Statistics/admin/index.php	(revision 7444)
+++ /extensions/Statistics/admin/index.php	(revision 7445)
Index: /extensions/Statistics/admin/stat_admin.php
===================================================================
--- /extensions/Statistics/admin/stat_admin.php	(revision 7444)
+++ /extensions/Statistics/admin/stat_admin.php	(revision 7445)
@@ -4,92 +4,48 @@
 load_language('plugin.lang', STAT_PATH);
 
-
-
-$conf_statistics = explode("," , $conf['statistics']);
-
-
+$conf_statistics = unserialize($conf['statistics']);
 
 $template->assign(
+  array(
+    'statisticsCONTENT' => $conf_statistics['content'],
+    'STATITICS_HEADER'  => $conf_statistics['header'] ? 'checked="checked"' : '' ,
+    'STATISTICS_TAIL'   => $conf_statistics['tail']   ? 'checked="checked"' : '' ,
+    'STATISTICS_ADMIN'  => $conf_statistics['exclude_admin']  ? 'checked="checked"' : '' ,
+    'STATISTICS_GUEST'  => $conf_statistics['exclude_guest']  ? 'checked="checked"' : '' ,
+    )
+  );
 
-  array(
+if (isset($_POST['submit']))
+{
+  $statistics_content = stripslashes($_POST['statistics_content']);
+  
+  $conf_statistics = array(
+    'content' => $statistics_content,
+    'header' => isset($_POST['stat_header']),
+    'tail' => isset($_POST['stat_tail']),
+    'exclude_admin' => isset($_POST['stat_admin']),
+    'exclude_guest' => isset($_POST['stat_guest']),
+    );
 
-   'STATITICS_HEADER' => $conf_statistics[0] == 'on' ? 'checked="checked"' : '' ,
+  $query = '
+UPDATE '.CONFIG_TABLE.'
+  SET value = \''.pwg_db_real_escape_string(serialize($conf_statistics)).'\'
+  WHERE param = \'statistics\'
+;';
+  pwg_query($query);
 
-   'STATISTICS_TAIL' => $conf_statistics[1] == 'on' ? 'checked="checked"' : '' ,
-
-   'STATISTICS_ADMIN' => $conf_statistics[3] == 'on' ? 'checked="checked"' : '' ,
-
-   'STATISTICS_GUEST' => $conf_statistics[4] == 'on' ? 'checked="checked"' : '' ,
-
-		 )
-
-		);	
-
-
-
-$template->assign(array('statisticsCONTENT' => $conf_statistics[2],)); 
-
-
-
-if ( isset($_POST['submit']) )
-
-{
-
-  $value_header = isset($_POST['stat_header']) ? $_POST['stat_header'] : '' ;
-
-  $value_tail = isset($_POST['stat_tail']) ? $_POST['stat_tail'] : '' ;
-
-  $value_content = isset($_POST['statistics_content']) ? $_POST['statistics_content'] : '' ;
-
-  $value_admin = isset($_POST['stat_admin']) ? $_POST['stat_admin'] : '' ;
-
-  $value_guest = isset($_POST['stat_guest']) ? $_POST['stat_guest'] : '' ;
-
-
-
-$query = '
-
-    UPDATE '.CONFIG_TABLE.'
-
-    SET value="'.$value_header. ',' .$value_tail. ',' .$value_content.',' .$value_admin. ',' .$value_guest. '"
-
-    WHERE param="statistics"
-
-    LIMIT 1';
-
-    
-
- pwg_query($query);
-
- 
-array_push($page['infos'], l10n('statistics_save_config'));
-
-
-$template->assign(
-
-  array(
-
-   'STATITICS_HEADER' => $value_header == 'on' ? 'checked="checked"' : '' ,
-
-   'STATISTICS_TAIL' => $value_tail  == 'on' ? 'checked="checked"' : '' ,
-
-   'STATISTICS_ADMIN'=> $value_admin  == 'on' ? 'checked="checked"' : '' ,
-
-   'STATISTICS_GUEST'=> $value_guest  == 'on' ? 'checked="checked"' : '' ,
-
-     )
-
-    );  
-
-
-
-$template->assign(array('statisticsCONTENT' => stripslashes ($value_content)));  
-
+  array_push($page['infos'], l10n('statistics_save_config'));
+  $template->assign(
+    array(
+      'statisticsCONTENT' => $statistics_content,
+      'STATITICS_HEADER'  => isset($_POST['stat_header']) ? 'checked="checked"' : '' ,
+      'STATISTICS_TAIL'   => isset($_POST['stat_tail'])   ? 'checked="checked"' : '' ,
+      'STATISTICS_ADMIN'  => isset($_POST['stat_admin'])  ? 'checked="checked"' : '' ,
+      'STATISTICS_GUEST'  => isset($_POST['stat_guest'])  ? 'checked="checked"' : '' ,
+      )
+    );
 }
 
-
-
 $template->set_filenames(array('plugin_admin_content' => realpath(STAT_PATH . 'admin/stat_admin.tpl')));
-
 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
 ?>
Index: /extensions/Statistics/admin/stat_admin.tpl
===================================================================
--- /extensions/Statistics/admin/stat_admin.tpl	(revision 7444)
+++ /extensions/Statistics/admin/stat_admin.tpl	(revision 7445)
@@ -1,60 +1,18 @@
 <div class="titrePage">
-
-	<h2>Statistics</h2>
-
+  <h2>Statistics</h2>
 </div>
 
-
-
-  <span>{'Howto'|translate}</span>
-
-  
+<span>{'Howto'|translate}</span>
 
 <form action="" method="post" name="form">
-
-  <fieldset>
-
-    <legend>{'statistics_admin'|translate}</legend>
-
-
-
-   <p>{'statistics_admin_description'|translate}</p>
-
-           <table>
-
-           <tr>
-
-	    <td><textarea name="statistics_content" id="statistics_content" rows="10" cols="80">{$statisticsCONTENT}</textarea></td>
-
-           </tr> 
-
-           </table>
-
- 
-
-    <table><tr>
-
-      <td><input type="checkbox" name="stat_header" value="on" {$STATITICS_HEADER} />&nbsp;{'stat_header'|translate}&nbsp;&nbsp;&nbsp;
-
-      <input type="checkbox" name="stat_tail" value="on" {$STATISTICS_TAIL} />&nbsp;{'stat_tail'|translate}</td></tr>
-
-       <tr><td>
-
-      <input type="checkbox" name="stat_admin" value="on" {$STATISTICS_ADMIN} />&nbsp;{'stat_admin'|translate}
-
-      </td></tr>
-
-              <tr><td>
-
-       <input type="checkbox" name="stat_guest" value="on" {$STATISTICS_GUEST} />&nbsp;{'stat_guest'|translate}
-
-     </td></tr> 
-
-     </table>
-
-      <p><input class="submit" type="submit" name="submit" value="{'Submit'|translate}"/></p>
-
-</fieldset>
-
+  <p style="margin-bottom:5px;">{'statistics_admin_description'|translate}</p>
+  <p style="margin:0;"><textarea name="statistics_content" id="statistics_content" rows="10" cols="80">{$statisticsCONTENT}</textarea></p>
+  <ul style="width:400px;margin:20px auto !important;list-style-type:none;">
+    <li><label><input type="checkbox" name="stat_header" {$STATITICS_HEADER} /> {'stat_header'|translate}</label></li>
+    <li><label><input type="checkbox" name="stat_tail" {$STATISTICS_TAIL} /> {'stat_tail'|translate}<label></li>
+    <li><label><input type="checkbox" name="stat_admin" {$STATISTICS_ADMIN} />&nbsp;{'stat_admin'|translate}<label></li>
+    <li><label><input type="checkbox" name="stat_guest" {$STATISTICS_GUEST} />&nbsp;{'stat_guest'|translate}<label></li>
+  </ul>
+  <p><input class="submit" type="submit" name="submit" value="{'Submit'|translate}"/></p>
 </form>
 
Index: /extensions/Statistics/index.php
===================================================================
--- /extensions/Statistics/index.php	(revision 7444)
+++ /extensions/Statistics/index.php	(revision 7445)
Index: /extensions/Statistics/language/en_UK/index.php
===================================================================
--- /extensions/Statistics/language/en_UK/index.php	(revision 7444)
+++ /extensions/Statistics/language/en_UK/index.php	(revision 7445)
@@ -1,66 +1,33 @@
 <?php
-
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
 // +-----------------------------------------------------------------------+
 
-// | PhpWebGallery - a PHP based picture gallery                           |
-
-// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-
-// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
-
-// +-----------------------------------------------------------------------+
-
-// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
-
-// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
-
-// | last modifier : $Author: rub $
-
-// | revision      : $Revision: 1912 $
-
-// +-----------------------------------------------------------------------+
-
-// | This program is free software; you can redistribute it and/or modify  |
-
-// | it under the terms of the GNU General Public License as published by  |
-
-// | the Free Software Foundation                                          |
-
-// |                                                                       |
-
-// | This program is distributed in the hope that it will be useful, but   |
-
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-
-// | General Public License for more details.                              |
-
-// |                                                                       |
-
-// | You should have received a copy of the GNU General Public License     |
-
-// | along with this program; if not, write to the Free Software           |
-
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-
-// | USA.                                                                  |
-
-// +-----------------------------------------------------------------------+
-
-
-
 // Recursive call
-
 $url = '../';
-
 header( 'Request-URI: '.$url );
-
 header( 'Content-Location: '.$url );
-
 header( 'Location: '.$url );
-
 exit();
-
 ?>
-
Index: /extensions/Statistics/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/Statistics/language/en_UK/plugin.lang.php	(revision 7444)
+++ /extensions/Statistics/language/en_UK/plugin.lang.php	(revision 7445)
@@ -1,4 +1,4 @@
 <?php
-$lang['Howto'] = 'This plugin allow you to insert code given by Google Analytics, PhpMyVisites and co in all pages of your gallery';
+$lang['Howto'] = 'This plugin allow you to insert code given by Google Analytics, Piwik and others in all pages of your gallery';
 $lang['statistics_admin'] = 'Statistics Adminstration';
 $lang['statistics_admin_description'] = 'Paste the code here. ';
@@ -6,5 +6,5 @@
 $lang['stat_tail'] = 'Insert code in the footer';
 $lang['statistics_save_config'] = 'Data saved';
-$lang['stat_admin'] = 'Exclude adminstrator of statistics.';
-$lang['stat_admin'] = 'Exclude guest of statistics.';
+$lang['stat_admin'] = 'Exclude administrator from statistics.';
+$lang['stat_guest'] = 'Exclude guest from statistics.';
 ?>
Index: /extensions/Statistics/language/es_ES/index.php
===================================================================
--- /extensions/Statistics/language/es_ES/index.php	(revision 7444)
+++ /extensions/Statistics/language/es_ES/index.php	(revision 7445)
@@ -1,66 +1,32 @@
 <?php
-
 // +-----------------------------------------------------------------------+
-
 // | PhpWebGallery - a PHP based picture gallery                           |
-
 // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-
 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
-
 // +-----------------------------------------------------------------------+
-
 // | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
-
 // | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
-
 // | last modifier : $Author: rub $
-
 // | revision      : $Revision: 1912 $
-
 // +-----------------------------------------------------------------------+
-
 // | This program is free software; you can redistribute it and/or modify  |
-
 // | it under the terms of the GNU General Public License as published by  |
-
 // | the Free Software Foundation                                          |
-
 // |                                                                       |
-
 // | This program is distributed in the hope that it will be useful, but   |
-
 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-
 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-
 // | General Public License for more details.                              |
-
 // |                                                                       |
-
 // | You should have received a copy of the GNU General Public License     |
-
 // | along with this program; if not, write to the Free Software           |
-
 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-
 // | USA.                                                                  |
-
 // +-----------------------------------------------------------------------+
-
-
-
 // Recursive call
-
 $url = '../';
-
 header( 'Request-URI: '.$url );
-
 header( 'Content-Location: '.$url );
-
 header( 'Location: '.$url );
-
 exit();
-
 ?>
-
Index: /extensions/Statistics/language/es_ES/plugin.lang.php
===================================================================
--- /extensions/Statistics/language/es_ES/plugin.lang.php	(revision 7444)
+++ /extensions/Statistics/language/es_ES/plugin.lang.php	(revision 7445)
Index: /extensions/Statistics/language/fr_FR/index.php
===================================================================
--- /extensions/Statistics/language/fr_FR/index.php	(revision 7444)
+++ /extensions/Statistics/language/fr_FR/index.php	(revision 7445)
@@ -1,66 +1,32 @@
 <?php
-
 // +-----------------------------------------------------------------------+
-
 // | PhpWebGallery - a PHP based picture gallery                           |
-
 // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-
 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
-
 // +-----------------------------------------------------------------------+
-
 // | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
-
 // | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
-
 // | last modifier : $Author: rub $
-
 // | revision      : $Revision: 1912 $
-
 // +-----------------------------------------------------------------------+
-
 // | This program is free software; you can redistribute it and/or modify  |
-
 // | it under the terms of the GNU General Public License as published by  |
-
 // | the Free Software Foundation                                          |
-
 // |                                                                       |
-
 // | This program is distributed in the hope that it will be useful, but   |
-
 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-
 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-
 // | General Public License for more details.                              |
-
 // |                                                                       |
-
 // | You should have received a copy of the GNU General Public License     |
-
 // | along with this program; if not, write to the Free Software           |
-
 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-
 // | USA.                                                                  |
-
 // +-----------------------------------------------------------------------+
-
-
-
 // Recursive call
-
 $url = '../';
-
 header( 'Request-URI: '.$url );
-
 header( 'Content-Location: '.$url );
-
 header( 'Location: '.$url );
-
 exit();
-
 ?>
-
Index: /extensions/Statistics/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/Statistics/language/fr_FR/plugin.lang.php	(revision 7444)
+++ /extensions/Statistics/language/fr_FR/plugin.lang.php	(revision 7445)
@@ -1,4 +1,4 @@
 <?php
-$lang['Howto'] = 'Ce plugin permet d\'inserer le code fournie par Google Analytics, PhpMyVisites and co dans toutes les pages de votre galerie';
+$lang['Howto'] = 'Ce plugin permet d\'inserer le code fournie par Google Analytics, Piwik ou autres dans toutes les pages de votre galerie';
 $lang['statistics_admin'] = 'Administration de Statistics';
 $lang['statistics_admin_description'] = 'Coller ci dessous le code fourni. ';
@@ -8,4 +8,4 @@
 $lang['Link'] = 'Lien vers votre logiciel de statistiques et de mesure d\'audience.';
 $lang['stat_admin'] = 'Exclure l\'administrateur des statistiques.';
-$lang['stat_guest'] = 'Exclure le guest des statistiques.';
+$lang['stat_guest'] = 'Exclure l\'utilisateur non connecté des statistiques.';
 ?>
Index: /extensions/Statistics/language/index.php
===================================================================
--- /extensions/Statistics/language/index.php	(revision 7444)
+++ /extensions/Statistics/language/index.php	(revision 7445)
@@ -1,66 +1,33 @@
 <?php
-
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery                           |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
+// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
+// | last modifier : $Author: rub $
+// | revision      : $Revision: 1912 $
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
 // +-----------------------------------------------------------------------+
 
-// | PhpWebGallery - a PHP based picture gallery                           |
-
-// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-
-// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
-
-// +-----------------------------------------------------------------------+
-
-// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
-
-// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
-
-// | last modifier : $Author: rub $
-
-// | revision      : $Revision: 1912 $
-
-// +-----------------------------------------------------------------------+
-
-// | This program is free software; you can redistribute it and/or modify  |
-
-// | it under the terms of the GNU General Public License as published by  |
-
-// | the Free Software Foundation                                          |
-
-// |                                                                       |
-
-// | This program is distributed in the hope that it will be useful, but   |
-
-// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-
-// | General Public License for more details.                              |
-
-// |                                                                       |
-
-// | You should have received a copy of the GNU General Public License     |
-
-// | along with this program; if not, write to the Free Software           |
-
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-
-// | USA.                                                                  |
-
-// +-----------------------------------------------------------------------+
-
-
-
 // Recursive call
-
 $url = '../';
-
 header( 'Request-URI: '.$url );
-
 header( 'Content-Location: '.$url );
-
 header( 'Location: '.$url );
-
 exit();
-
 ?>
-
Index: /extensions/Statistics/language/it_IT/index.php
===================================================================
--- /extensions/Statistics/language/it_IT/index.php	(revision 7444)
+++ /extensions/Statistics/language/it_IT/index.php	(revision 7445)
@@ -1,66 +1,32 @@
 <?php
-
 // +-----------------------------------------------------------------------+
-
 // | PhpWebGallery - a PHP based picture gallery                           |
-
 // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-
 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
-
 // +-----------------------------------------------------------------------+
-
 // | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
-
 // | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
-
 // | last modifier : $Author: rub $
-
 // | revision      : $Revision: 1912 $
-
 // +-----------------------------------------------------------------------+
-
 // | This program is free software; you can redistribute it and/or modify  |
-
 // | it under the terms of the GNU General Public License as published by  |
-
 // | the Free Software Foundation                                          |
-
 // |                                                                       |
-
 // | This program is distributed in the hope that it will be useful, but   |
-
 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
-
 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
-
 // | General Public License for more details.                              |
-
 // |                                                                       |
-
 // | You should have received a copy of the GNU General Public License     |
-
 // | along with this program; if not, write to the Free Software           |
-
 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-
 // | USA.                                                                  |
-
 // +-----------------------------------------------------------------------+
-
-
-
 // Recursive call
-
 $url = '../';
-
 header( 'Request-URI: '.$url );
-
 header( 'Content-Location: '.$url );
-
 header( 'Location: '.$url );
-
 exit();
-
 ?>
-
Index: /extensions/Statistics/main.inc.php
===================================================================
--- /extensions/Statistics/main.inc.php	(revision 7444)
+++ /extensions/Statistics/main.inc.php	(revision 7445)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: Statistics
-Version: 2.0.b
+Version: 2.0.c
 Description: Add source code like Google Analytics on each page.
 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=174
@@ -10,112 +10,79 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 define('STAT_DIR' , basename(dirname(__FILE__)));
-
 define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/');
 
 function statistics_admin_menu($menu)
-
 {
-
-    array_push($menu, array('NAME' => 'Statistics',
-
-      'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')));
-
-    return $menu;
-
+  array_push(
+    $menu,
+    array(
+      'NAME' => 'Statistics',
+      'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')
+      )
+    );
+  return $menu;
 }
 
+function stat_candoit($type)
+{
+  global $conf, $user;
+
+  $conf_statistics = unserialize($conf['statistics']);
+
+  if (is_admin() and $conf_statistics['exclude_admin'])
+  {
+    return false;
+  }
+
+  if (is_a_guest() and $conf_statistics['exclude_guest'])
+  {
+    return false;
+  }
 
 
-function stat_candoit($type)
-
-{
-
-  global $conf, $user;
-
-
-
-  $conf_statistics = explode("," , $conf['statistics']);
-
-
-
-  $is_guest = (function_exists('is_a_guest') ? is_a_guest() : $user['is_the_guest']);
-
-
-
-  if
-
-  (
-
-    (
-
-      (($conf_statistics[0] == 'on') and ($type == 'header')) or 
-
-      (($conf_statistics[1] == 'on') and ($type == 'tail'))
-
-    ) and 
-
-    (($conf_statistics[3] == 'on' and !is_admin()) or (empty($conf_statistics[3]))) and
-
-    (($conf_statistics[4] == 'on' and !$is_guest) or (empty($conf_statistics[4])))
-
-  )
-
+  $show_htmlcontent = false;
+  if ($conf_statistics['header'] and $type == 'header')
   {
-
-    return '
-
-<!-- Plugin Statitics -->
-
-'.$conf_statistics[2].'
-
-<!-- Plugin Statitics -->';
-
+    $show_htmlcontent = true;
+  }
+  if ($conf_statistics['tail'] and $type == 'tail')
+  {
+    $show_htmlcontent = true;
   }
 
-  else
-
+  if (!$show_htmlcontent)
   {
-
     return false;
-
   }
 
+  return '
+<!-- Plugin Statistics -->
+'.$conf_statistics['content'].'
+<!-- Plugin Statistics -->
+';
 }
+
 function stat_tail()
 {
+  global $template;
 
-  global $template;
   if ($code_stat = stat_candoit('tail'))
-
   {
-
     $template->append('footer_elements', $code_stat);
-
   }
-
 }
 
-
-
 function stat_header()
-
 {
-
   global $template;
 
+  if ($code_stat = stat_candoit('header'))
+  {
+    $template->append('head_elements', $code_stat);
+  }
+}
 
-
-  if ($code_stat = stat_candoit('header'))
-
-  {
-
-    $template->append('head_elements', $code_stat);
-
-  }
-
-}
 add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu');
 add_event_handler('loc_end_page_tail', 'stat_tail');
 add_event_handler('loc_end_page_header', 'stat_header');
-
 ?>
Index: /extensions/Statistics/maintain.inc.php
===================================================================
--- /extensions/Statistics/maintain.inc.php	(revision 7444)
+++ /extensions/Statistics/maintain.inc.php	(revision 7445)
@@ -1,51 +1,65 @@
 <?php
 
- 
+function plugin_activate()
+{
+  $query = '
+SELECT
+    value
+  FROM '.CONFIG_TABLE.'
+  WHERE param=\'statistics\'
+;';
+  $result = pwg_query($query);
+  if ($row = pwg_db_fetch_assoc($result))
+  {
+    if (!preg_match('/^a:/', $row['value']))
+    {
+      $old_conf = explode("," , $row['value']);
+      
+      $conf_statistics = array(
+        'content'       => $old_conf[2],
+        'header'        => ($old_conf[0] == 'on'),
+        'tail'          => ($old_conf[1] == 'on'),
+        'exclude_admin' => ($old_conf[3] == 'on'),
+        'exclude_guest' => ($old_conf[4] == 'on'),
+        );
 
-  function plugin_install()
+      $query = '
+UPDATE '.CONFIG_TABLE.'
+  SET value = \''.pwg_db_real_escape_string(serialize($conf_statistics)).'\'
+  WHERE param=\'statistics\'
+;';
+      pwg_query($query);
+    }
+  }
+}
 
-  {
+function plugin_install()
+{
+  $conf_statistics = array(
+    'content' => '',
+    'header' => false,
+    'tail' => true,
+    'exclude_admin' => false,
+    'exclude_guest' => false,
+    );
+  
+  $query = '
+INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
+  VALUES (
+    \'statistics\',
+    \''.pwg_db_real_escape_string(serialize($conf_statistics)).'\',
+    \'Parameters of Statistics plugin\'
+  )
+;';
+  pwg_query($query);
+}
 
-      global $prefixeTable;
-
-    $q = '
-
-      INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
-
-      VALUES ("statistics","off,on, ,off,off","Parameters of Statistics plugin");
-
-    ';
-
-      
-
-    pwg_query($q);
-
-  
-
-  }
-
-  
-
-  function plugin_uninstall()
-
-  {
-
-    global $prefixeTable;
-
-      $q = '
-
-        DELETE FROM '.CONFIG_TABLE.'
-
-        WHERE param="statistics" LIMIT 1;
-
-      ';
-
-   
-
-      pwg_query($q);
-
-    
-
-    }  
-
+function plugin_uninstall()
+{
+  $query = '
+DELETE FROM '.CONFIG_TABLE.'
+  WHERE param=\'statistics\'
+;';
+  pwg_query($query);
+}
 ?>
