Changeset 7445


Ignore:
Timestamp:
Oct 28, 2010, 12:19:44 AM (10 years ago)
Author:
plg
Message:

bug fixed: ability to use a Google Analytics/Piwik javascript code including a
comma.

simpler code, easier to maintain I hope.

change file format from MacOs to Unix line endings.

Location:
extensions/Statistics
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/Statistics/admin/stat_admin.php

    r3438 r7445  
    44load_language('plugin.lang', STAT_PATH);
    55
    6 
    7 
    8 $conf_statistics = explode("," , $conf['statistics']);
    9 
    10 
     6$conf_statistics = unserialize($conf['statistics']);
    117
    128$template->assign(
     9  array(
     10    'statisticsCONTENT' => $conf_statistics['content'],
     11    'STATITICS_HEADER'  => $conf_statistics['header'] ? 'checked="checked"' : '' ,
     12    'STATISTICS_TAIL'   => $conf_statistics['tail']   ? 'checked="checked"' : '' ,
     13    'STATISTICS_ADMIN'  => $conf_statistics['exclude_admin']  ? 'checked="checked"' : '' ,
     14    'STATISTICS_GUEST'  => $conf_statistics['exclude_guest']  ? 'checked="checked"' : '' ,
     15    )
     16  );
    1317
    14   array(
     18if (isset($_POST['submit']))
     19{
     20  $statistics_content = stripslashes($_POST['statistics_content']);
     21 
     22  $conf_statistics = array(
     23    'content' => $statistics_content,
     24    'header' => isset($_POST['stat_header']),
     25    'tail' => isset($_POST['stat_tail']),
     26    'exclude_admin' => isset($_POST['stat_admin']),
     27    'exclude_guest' => isset($_POST['stat_guest']),
     28    );
    1529
    16    'STATITICS_HEADER' => $conf_statistics[0] == 'on' ? 'checked="checked"' : '' ,
     30  $query = '
     31UPDATE '.CONFIG_TABLE.'
     32  SET value = \''.pwg_db_real_escape_string(serialize($conf_statistics)).'\'
     33  WHERE param = \'statistics\'
     34;';
     35  pwg_query($query);
    1736
    18    'STATISTICS_TAIL' => $conf_statistics[1] == 'on' ? 'checked="checked"' : '' ,
    19 
    20    'STATISTICS_ADMIN' => $conf_statistics[3] == 'on' ? 'checked="checked"' : '' ,
    21 
    22    'STATISTICS_GUEST' => $conf_statistics[4] == 'on' ? 'checked="checked"' : '' ,
    23 
    24                  )
    25 
    26                 );     
    27 
    28 
    29 
    30 $template->assign(array('statisticsCONTENT' => $conf_statistics[2],));
    31 
    32 
    33 
    34 if ( isset($_POST['submit']) )
    35 
    36 {
    37 
    38   $value_header = isset($_POST['stat_header']) ? $_POST['stat_header'] : '' ;
    39 
    40   $value_tail = isset($_POST['stat_tail']) ? $_POST['stat_tail'] : '' ;
    41 
    42   $value_content = isset($_POST['statistics_content']) ? $_POST['statistics_content'] : '' ;
    43 
    44   $value_admin = isset($_POST['stat_admin']) ? $_POST['stat_admin'] : '' ;
    45 
    46   $value_guest = isset($_POST['stat_guest']) ? $_POST['stat_guest'] : '' ;
    47 
    48 
    49 
    50 $query = '
    51 
    52     UPDATE '.CONFIG_TABLE.'
    53 
    54     SET value="'.$value_header. ',' .$value_tail. ',' .$value_content.',' .$value_admin. ',' .$value_guest. '"
    55 
    56     WHERE param="statistics"
    57 
    58     LIMIT 1';
    59 
    60    
    61 
    62  pwg_query($query);
    63 
    64  
    65 array_push($page['infos'], l10n('statistics_save_config'));
    66 
    67 
    68 $template->assign(
    69 
    70   array(
    71 
    72    'STATITICS_HEADER' => $value_header == 'on' ? 'checked="checked"' : '' ,
    73 
    74    'STATISTICS_TAIL' => $value_tail  == 'on' ? 'checked="checked"' : '' ,
    75 
    76    'STATISTICS_ADMIN'=> $value_admin  == 'on' ? 'checked="checked"' : '' ,
    77 
    78    'STATISTICS_GUEST'=> $value_guest  == 'on' ? 'checked="checked"' : '' ,
    79 
    80      )
    81 
    82     ); 
    83 
    84 
    85 
    86 $template->assign(array('statisticsCONTENT' => stripslashes ($value_content))); 
    87 
     37  array_push($page['infos'], l10n('statistics_save_config'));
     38  $template->assign(
     39    array(
     40      'statisticsCONTENT' => $statistics_content,
     41      'STATITICS_HEADER'  => isset($_POST['stat_header']) ? 'checked="checked"' : '' ,
     42      'STATISTICS_TAIL'   => isset($_POST['stat_tail'])   ? 'checked="checked"' : '' ,
     43      'STATISTICS_ADMIN'  => isset($_POST['stat_admin'])  ? 'checked="checked"' : '' ,
     44      'STATISTICS_GUEST'  => isset($_POST['stat_guest'])  ? 'checked="checked"' : '' ,
     45      )
     46    );
    8847}
    8948
    90 
    91 
    9249$template->set_filenames(array('plugin_admin_content' => realpath(STAT_PATH . 'admin/stat_admin.tpl')));
    93 
    9450$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    9551?>
  • extensions/Statistics/admin/stat_admin.tpl

    r3438 r7445  
    11<div class="titrePage">
    2 
    3         <h2>Statistics</h2>
    4 
     2  <h2>Statistics</h2>
    53</div>
    64
    7 
    8 
    9   <span>{'Howto'|translate}</span>
    10 
    11  
     5<span>{'Howto'|translate}</span>
    126
    137<form action="" method="post" name="form">
    14 
    15   <fieldset>
    16 
    17     <legend>{'statistics_admin'|translate}</legend>
    18 
    19 
    20 
    21    <p>{'statistics_admin_description'|translate}</p>
    22 
    23            <table>
    24 
    25            <tr>
    26 
    27             <td><textarea name="statistics_content" id="statistics_content" rows="10" cols="80">{$statisticsCONTENT}</textarea></td>
    28 
    29            </tr>
    30 
    31            </table>
    32 
    33  
    34 
    35     <table><tr>
    36 
    37       <td><input type="checkbox" name="stat_header" value="on" {$STATITICS_HEADER} />&nbsp;{'stat_header'|translate}&nbsp;&nbsp;&nbsp;
    38 
    39       <input type="checkbox" name="stat_tail" value="on" {$STATISTICS_TAIL} />&nbsp;{'stat_tail'|translate}</td></tr>
    40 
    41        <tr><td>
    42 
    43       <input type="checkbox" name="stat_admin" value="on" {$STATISTICS_ADMIN} />&nbsp;{'stat_admin'|translate}
    44 
    45       </td></tr>
    46 
    47               <tr><td>
    48 
    49        <input type="checkbox" name="stat_guest" value="on" {$STATISTICS_GUEST} />&nbsp;{'stat_guest'|translate}
    50 
    51      </td></tr>
    52 
    53      </table>
    54 
    55       <p><input class="submit" type="submit" name="submit" value="{'Submit'|translate}"/></p>
    56 
    57 </fieldset>
    58 
     8  <p style="margin-bottom:5px;">{'statistics_admin_description'|translate}</p>
     9  <p style="margin:0;"><textarea name="statistics_content" id="statistics_content" rows="10" cols="80">{$statisticsCONTENT}</textarea></p>
     10  <ul style="width:400px;margin:20px auto !important;list-style-type:none;">
     11    <li><label><input type="checkbox" name="stat_header" {$STATITICS_HEADER} /> {'stat_header'|translate}</label></li>
     12    <li><label><input type="checkbox" name="stat_tail" {$STATISTICS_TAIL} /> {'stat_tail'|translate}<label></li>
     13    <li><label><input type="checkbox" name="stat_admin" {$STATISTICS_ADMIN} />&nbsp;{'stat_admin'|translate}<label></li>
     14    <li><label><input type="checkbox" name="stat_guest" {$STATISTICS_GUEST} />&nbsp;{'stat_guest'|translate}<label></li>
     15  </ul>
     16  <p><input class="submit" type="submit" name="submit" value="{'Submit'|translate}"/></p>
    5917</form>
    6018
  • extensions/Statistics/language/en_UK/index.php

    r3438 r7445  
    11<?php
    2 
     2// +-----------------------------------------------------------------------+
     3// | PhpWebGallery - a PHP based picture gallery                           |
     4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
     5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     6// +-----------------------------------------------------------------------+
     7// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
     8// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
     9// | last modifier : $Author: rub $
     10// | revision      : $Revision: 1912 $
     11// +-----------------------------------------------------------------------+
     12// | This program is free software; you can redistribute it and/or modify  |
     13// | it under the terms of the GNU General Public License as published by  |
     14// | the Free Software Foundation                                          |
     15// |                                                                       |
     16// | This program is distributed in the hope that it will be useful, but   |
     17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     19// | General Public License for more details.                              |
     20// |                                                                       |
     21// | You should have received a copy of the GNU General Public License     |
     22// | along with this program; if not, write to the Free Software           |
     23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     24// | USA.                                                                  |
    325// +-----------------------------------------------------------------------+
    426
    5 // | PhpWebGallery - a PHP based picture gallery                           |
    6 
    7 // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    8 
    9 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    10 
    11 // +-----------------------------------------------------------------------+
    12 
    13 // | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
    14 
    15 // | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
    16 
    17 // | last modifier : $Author: rub $
    18 
    19 // | revision      : $Revision: 1912 $
    20 
    21 // +-----------------------------------------------------------------------+
    22 
    23 // | This program is free software; you can redistribute it and/or modify  |
    24 
    25 // | it under the terms of the GNU General Public License as published by  |
    26 
    27 // | the Free Software Foundation                                          |
    28 
    29 // |                                                                       |
    30 
    31 // | This program is distributed in the hope that it will be useful, but   |
    32 
    33 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    34 
    35 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    36 
    37 // | General Public License for more details.                              |
    38 
    39 // |                                                                       |
    40 
    41 // | You should have received a copy of the GNU General Public License     |
    42 
    43 // | along with this program; if not, write to the Free Software           |
    44 
    45 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    46 
    47 // | USA.                                                                  |
    48 
    49 // +-----------------------------------------------------------------------+
    50 
    51 
    52 
    5327// Recursive call
    54 
    5528$url = '../';
    56 
    5729header( 'Request-URI: '.$url );
    58 
    5930header( 'Content-Location: '.$url );
    60 
    6131header( 'Location: '.$url );
    62 
    6332exit();
    64 
    6533?>
    66 
  • extensions/Statistics/language/en_UK/plugin.lang.php

    r3438 r7445  
    11<?php
    2 $lang['Howto'] = 'This plugin allow you to insert code given by Google Analytics, PhpMyVisites and co in all pages of your gallery';
     2$lang['Howto'] = 'This plugin allow you to insert code given by Google Analytics, Piwik and others in all pages of your gallery';
    33$lang['statistics_admin'] = 'Statistics Adminstration';
    44$lang['statistics_admin_description'] = 'Paste the code here. ';
     
    66$lang['stat_tail'] = 'Insert code in the footer';
    77$lang['statistics_save_config'] = 'Data saved';
    8 $lang['stat_admin'] = 'Exclude adminstrator of statistics.';
    9 $lang['stat_admin'] = 'Exclude guest of statistics.';
     8$lang['stat_admin'] = 'Exclude administrator from statistics.';
     9$lang['stat_guest'] = 'Exclude guest from statistics.';
    1010?>
  • extensions/Statistics/language/es_ES/index.php

    r3438 r7445  
    11<?php
    2 
    32// +-----------------------------------------------------------------------+
    4 
    53// | PhpWebGallery - a PHP based picture gallery                           |
    6 
    74// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    8 
    95// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    10 
    116// +-----------------------------------------------------------------------+
    12 
    137// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
    14 
    158// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
    16 
    179// | last modifier : $Author: rub $
    18 
    1910// | revision      : $Revision: 1912 $
    20 
    2111// +-----------------------------------------------------------------------+
    22 
    2312// | This program is free software; you can redistribute it and/or modify  |
    24 
    2513// | it under the terms of the GNU General Public License as published by  |
    26 
    2714// | the Free Software Foundation                                          |
    28 
    2915// |                                                                       |
    30 
    3116// | This program is distributed in the hope that it will be useful, but   |
    32 
    3317// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    34 
    3518// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    36 
    3719// | General Public License for more details.                              |
    38 
    3920// |                                                                       |
    40 
    4121// | You should have received a copy of the GNU General Public License     |
    42 
    4322// | along with this program; if not, write to the Free Software           |
    44 
    4523// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    46 
    4724// | USA.                                                                  |
    48 
    4925// +-----------------------------------------------------------------------+
    50 
    51 
    52 
    5326// Recursive call
    54 
    5527$url = '../';
    56 
    5728header( 'Request-URI: '.$url );
    58 
    5929header( 'Content-Location: '.$url );
    60 
    6130header( 'Location: '.$url );
    62 
    6331exit();
    64 
    6532?>
    66 
  • extensions/Statistics/language/fr_FR/index.php

    r3438 r7445  
    11<?php
    2 
    32// +-----------------------------------------------------------------------+
    4 
    53// | PhpWebGallery - a PHP based picture gallery                           |
    6 
    74// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    8 
    95// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    10 
    116// +-----------------------------------------------------------------------+
    12 
    137// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
    14 
    158// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
    16 
    179// | last modifier : $Author: rub $
    18 
    1910// | revision      : $Revision: 1912 $
    20 
    2111// +-----------------------------------------------------------------------+
    22 
    2312// | This program is free software; you can redistribute it and/or modify  |
    24 
    2513// | it under the terms of the GNU General Public License as published by  |
    26 
    2714// | the Free Software Foundation                                          |
    28 
    2915// |                                                                       |
    30 
    3116// | This program is distributed in the hope that it will be useful, but   |
    32 
    3317// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    34 
    3518// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    36 
    3719// | General Public License for more details.                              |
    38 
    3920// |                                                                       |
    40 
    4121// | You should have received a copy of the GNU General Public License     |
    42 
    4322// | along with this program; if not, write to the Free Software           |
    44 
    4523// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    46 
    4724// | USA.                                                                  |
    48 
    4925// +-----------------------------------------------------------------------+
    50 
    51 
    52 
    5326// Recursive call
    54 
    5527$url = '../';
    56 
    5728header( 'Request-URI: '.$url );
    58 
    5929header( 'Content-Location: '.$url );
    60 
    6130header( 'Location: '.$url );
    62 
    6331exit();
    64 
    6532?>
    66 
  • extensions/Statistics/language/fr_FR/plugin.lang.php

    r3438 r7445  
    11<?php
    2 $lang['Howto'] = 'Ce plugin permet d\'inserer le code fournie par Google Analytics, PhpMyVisites and co dans toutes les pages de votre galerie';
     2$lang['Howto'] = 'Ce plugin permet d\'inserer le code fournie par Google Analytics, Piwik ou autres dans toutes les pages de votre galerie';
    33$lang['statistics_admin'] = 'Administration de Statistics';
    44$lang['statistics_admin_description'] = 'Coller ci dessous le code fourni. ';
     
    88$lang['Link'] = 'Lien vers votre logiciel de statistiques et de mesure d\'audience.';
    99$lang['stat_admin'] = 'Exclure l\'administrateur des statistiques.';
    10 $lang['stat_guest'] = 'Exclure le guest des statistiques.';
     10$lang['stat_guest'] = 'Exclure l\'utilisateur non connecté des statistiques.';
    1111?>
  • extensions/Statistics/language/index.php

    r3438 r7445  
    11<?php
    2 
     2// +-----------------------------------------------------------------------+
     3// | PhpWebGallery - a PHP based picture gallery                           |
     4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
     5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     6// +-----------------------------------------------------------------------+
     7// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
     8// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
     9// | last modifier : $Author: rub $
     10// | revision      : $Revision: 1912 $
     11// +-----------------------------------------------------------------------+
     12// | This program is free software; you can redistribute it and/or modify  |
     13// | it under the terms of the GNU General Public License as published by  |
     14// | the Free Software Foundation                                          |
     15// |                                                                       |
     16// | This program is distributed in the hope that it will be useful, but   |
     17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
     18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
     19// | General Public License for more details.                              |
     20// |                                                                       |
     21// | You should have received a copy of the GNU General Public License     |
     22// | along with this program; if not, write to the Free Software           |
     23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
     24// | USA.                                                                  |
    325// +-----------------------------------------------------------------------+
    426
    5 // | PhpWebGallery - a PHP based picture gallery                           |
    6 
    7 // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    8 
    9 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    10 
    11 // +-----------------------------------------------------------------------+
    12 
    13 // | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
    14 
    15 // | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
    16 
    17 // | last modifier : $Author: rub $
    18 
    19 // | revision      : $Revision: 1912 $
    20 
    21 // +-----------------------------------------------------------------------+
    22 
    23 // | This program is free software; you can redistribute it and/or modify  |
    24 
    25 // | it under the terms of the GNU General Public License as published by  |
    26 
    27 // | the Free Software Foundation                                          |
    28 
    29 // |                                                                       |
    30 
    31 // | This program is distributed in the hope that it will be useful, but   |
    32 
    33 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    34 
    35 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    36 
    37 // | General Public License for more details.                              |
    38 
    39 // |                                                                       |
    40 
    41 // | You should have received a copy of the GNU General Public License     |
    42 
    43 // | along with this program; if not, write to the Free Software           |
    44 
    45 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    46 
    47 // | USA.                                                                  |
    48 
    49 // +-----------------------------------------------------------------------+
    50 
    51 
    52 
    5327// Recursive call
    54 
    5528$url = '../';
    56 
    5729header( 'Request-URI: '.$url );
    58 
    5930header( 'Content-Location: '.$url );
    60 
    6131header( 'Location: '.$url );
    62 
    6332exit();
    64 
    6533?>
    66 
  • extensions/Statistics/language/it_IT/index.php

    r3492 r7445  
    11<?php
    2 
    32// +-----------------------------------------------------------------------+
    4 
    53// | PhpWebGallery - a PHP based picture gallery                           |
    6 
    74// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    8 
    95// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    10 
    116// +-----------------------------------------------------------------------+
    12 
    137// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
    14 
    158// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
    16 
    179// | last modifier : $Author: rub $
    18 
    1910// | revision      : $Revision: 1912 $
    20 
    2111// +-----------------------------------------------------------------------+
    22 
    2312// | This program is free software; you can redistribute it and/or modify  |
    24 
    2513// | it under the terms of the GNU General Public License as published by  |
    26 
    2714// | the Free Software Foundation                                          |
    28 
    2915// |                                                                       |
    30 
    3116// | This program is distributed in the hope that it will be useful, but   |
    32 
    3317// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    34 
    3518// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    36 
    3719// | General Public License for more details.                              |
    38 
    3920// |                                                                       |
    40 
    4121// | You should have received a copy of the GNU General Public License     |
    42 
    4322// | along with this program; if not, write to the Free Software           |
    44 
    4523// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    46 
    4724// | USA.                                                                  |
    48 
    4925// +-----------------------------------------------------------------------+
    50 
    51 
    52 
    5326// Recursive call
    54 
    5527$url = '../';
    56 
    5728header( 'Request-URI: '.$url );
    58 
    5929header( 'Content-Location: '.$url );
    60 
    6130header( 'Location: '.$url );
    62 
    6331exit();
    64 
    6532?>
    66 
  • extensions/Statistics/main.inc.php

    r3438 r7445  
    22/*
    33Plugin Name: Statistics
    4 Version: 2.0.b
     4Version: 2.0.c
    55Description: Add source code like Google Analytics on each page.
    66Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=174
     
    1010if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1111define('STAT_DIR' , basename(dirname(__FILE__)));
    12 
    1312define('STAT_PATH' , PHPWG_PLUGINS_PATH . STAT_DIR . '/');
    1413
    1514function statistics_admin_menu($menu)
    16 
    1715{
    18 
    19     array_push($menu, array('NAME' => 'Statistics',
    20 
    21       'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')));
    22 
    23     return $menu;
    24 
     16  array_push(
     17    $menu,
     18    array(
     19      'NAME' => 'Statistics',
     20      'URL' => get_admin_plugin_menu_link(STAT_PATH . 'admin/stat_admin.php')
     21      )
     22    );
     23  return $menu;
    2524}
    2625
     26function stat_candoit($type)
     27{
     28  global $conf, $user;
     29
     30  $conf_statistics = unserialize($conf['statistics']);
     31
     32  if (is_admin() and $conf_statistics['exclude_admin'])
     33  {
     34    return false;
     35  }
     36
     37  if (is_a_guest() and $conf_statistics['exclude_guest'])
     38  {
     39    return false;
     40  }
    2741
    2842
    29 function stat_candoit($type)
    30 
    31 {
    32 
    33   global $conf, $user;
    34 
    35 
    36 
    37   $conf_statistics = explode("," , $conf['statistics']);
    38 
    39 
    40 
    41   $is_guest = (function_exists('is_a_guest') ? is_a_guest() : $user['is_the_guest']);
    42 
    43 
    44 
    45   if
    46 
    47   (
    48 
    49     (
    50 
    51       (($conf_statistics[0] == 'on') and ($type == 'header')) or
    52 
    53       (($conf_statistics[1] == 'on') and ($type == 'tail'))
    54 
    55     ) and
    56 
    57     (($conf_statistics[3] == 'on' and !is_admin()) or (empty($conf_statistics[3]))) and
    58 
    59     (($conf_statistics[4] == 'on' and !$is_guest) or (empty($conf_statistics[4])))
    60 
    61   )
    62 
     43  $show_htmlcontent = false;
     44  if ($conf_statistics['header'] and $type == 'header')
    6345  {
    64 
    65     return '
    66 
    67 <!-- Plugin Statitics -->
    68 
    69 '.$conf_statistics[2].'
    70 
    71 <!-- Plugin Statitics -->';
    72 
     46    $show_htmlcontent = true;
     47  }
     48  if ($conf_statistics['tail'] and $type == 'tail')
     49  {
     50    $show_htmlcontent = true;
    7351  }
    7452
    75   else
    76 
     53  if (!$show_htmlcontent)
    7754  {
    78 
    7955    return false;
    80 
    8156  }
    8257
     58  return '
     59<!-- Plugin Statistics -->
     60'.$conf_statistics['content'].'
     61<!-- Plugin Statistics -->
     62';
    8363}
     64
    8465function stat_tail()
    8566{
     67  global $template;
    8668
    87   global $template;
    8869  if ($code_stat = stat_candoit('tail'))
    89 
    9070  {
    91 
    9271    $template->append('footer_elements', $code_stat);
    93 
    9472  }
    95 
    9673}
    9774
    98 
    99 
    10075function stat_header()
    101 
    10276{
    103 
    10477  global $template;
    10578
     79  if ($code_stat = stat_candoit('header'))
     80  {
     81    $template->append('head_elements', $code_stat);
     82  }
     83}
    10684
    107 
    108   if ($code_stat = stat_candoit('header'))
    109 
    110   {
    111 
    112     $template->append('head_elements', $code_stat);
    113 
    114   }
    115 
    116 }
    11785add_event_handler('get_admin_plugin_menu_links', 'statistics_admin_menu');
    11886add_event_handler('loc_end_page_tail', 'stat_tail');
    11987add_event_handler('loc_end_page_header', 'stat_header');
    120 
    12188?>
  • extensions/Statistics/maintain.inc.php

    r3438 r7445  
    11<?php
    22
    3  
     3function plugin_activate()
     4{
     5  $query = '
     6SELECT
     7    value
     8  FROM '.CONFIG_TABLE.'
     9  WHERE param=\'statistics\'
     10;';
     11  $result = pwg_query($query);
     12  if ($row = pwg_db_fetch_assoc($result))
     13  {
     14    if (!preg_match('/^a:/', $row['value']))
     15    {
     16      $old_conf = explode("," , $row['value']);
     17     
     18      $conf_statistics = array(
     19        'content'       => $old_conf[2],
     20        'header'        => ($old_conf[0] == 'on'),
     21        'tail'          => ($old_conf[1] == 'on'),
     22        'exclude_admin' => ($old_conf[3] == 'on'),
     23        'exclude_guest' => ($old_conf[4] == 'on'),
     24        );
    425
    5   function plugin_install()
     26      $query = '
     27UPDATE '.CONFIG_TABLE.'
     28  SET value = \''.pwg_db_real_escape_string(serialize($conf_statistics)).'\'
     29  WHERE param=\'statistics\'
     30;';
     31      pwg_query($query);
     32    }
     33  }
     34}
    635
    7   {
     36function plugin_install()
     37{
     38  $conf_statistics = array(
     39    'content' => '',
     40    'header' => false,
     41    'tail' => true,
     42    'exclude_admin' => false,
     43    'exclude_guest' => false,
     44    );
     45 
     46  $query = '
     47INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
     48  VALUES (
     49    \'statistics\',
     50    \''.pwg_db_real_escape_string(serialize($conf_statistics)).'\',
     51    \'Parameters of Statistics plugin\'
     52  )
     53;';
     54  pwg_query($query);
     55}
    856
    9       global $prefixeTable;
    10 
    11     $q = '
    12 
    13       INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
    14 
    15       VALUES ("statistics","off,on, ,off,off","Parameters of Statistics plugin");
    16 
    17     ';
    18 
    19      
    20 
    21     pwg_query($q);
    22 
    23  
    24 
    25   }
    26 
    27  
    28 
    29   function plugin_uninstall()
    30 
    31   {
    32 
    33     global $prefixeTable;
    34 
    35       $q = '
    36 
    37         DELETE FROM '.CONFIG_TABLE.'
    38 
    39         WHERE param="statistics" LIMIT 1;
    40 
    41       ';
    42 
    43    
    44 
    45       pwg_query($q);
    46 
    47    
    48 
    49     } 
    50 
     57function plugin_uninstall()
     58{
     59  $query = '
     60DELETE FROM '.CONFIG_TABLE.'
     61  WHERE param=\'statistics\'
     62;';
     63  pwg_query($query);
     64}
    5165?>
Note: See TracChangeset for help on using the changeset viewer.