aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/configuration.php41
-rw-r--r--identification.php1
-rw-r--r--include/config_default.inc.php3
-rw-r--r--include/functions.inc.php51
-rw-r--r--install/config.sql4
-rw-r--r--install/db/30-database.php52
-rw-r--r--language/en_UK.iso-8859-1/admin.lang.php1
-rw-r--r--language/en_UK.iso-8859-1/help/configuration.html20
-rw-r--r--language/fr_FR.iso-8859-1/admin.lang.php1
-rw-r--r--language/fr_FR.iso-8859-1/help/configuration.html21
-rw-r--r--register.php1
-rw-r--r--template/yoga/admin/configuration.tpl31
12 files changed, 168 insertions, 59 deletions
diff --git a/admin/configuration.php b/admin/configuration.php
index 9f01849f6..c7f204db6 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -46,22 +46,6 @@ else
{
$page['section'] = $_GET['section'];
}
-//------------------------------------------------------ $conf reinitialization
-$result = pwg_query('SELECT param,value FROM '.CONFIG_TABLE);
-while ($row = mysql_fetch_array($result))
-{
- $conf[$row['param']] = $row['value'];
- // if the parameter is present in $_POST array (if a form is submited), we
- // override it with the submited value
- if (isset($_POST[$row['param']]))
- {
- $conf[$row['param']] = $_POST[$row['param']];
- if ( 'page_banner'==$row['param'] )
- { // should we do it for all ?
- $conf[$row['param']] = stripslashes( $conf[$row['param']] );
- }
- }
-}
//------------------------------ verification and registration of modifications
if (isset($_POST['submit']))
{
@@ -74,6 +58,10 @@ if (isset($_POST['submit']))
{
array_push($page['errors'], $lang['conf_gallery_url_error']);
}
+ $_POST['log'] = empty($_POST['log'])?'false':'true';
+ $_POST['history_admin'] = empty($_POST['history_admin'])?'false':'true';
+ $_POST['history_guest'] = empty($_POST['history_guest'])?'false':'true';
+ $_POST['login_history'] = empty($_POST['login_history'])?'false':'true';
break;
}
case 'comments' :
@@ -119,7 +107,7 @@ if (isset($_POST['submit']))
// updating configuration if no error found
if (count($page['errors']) == 0)
{
-// echo '<pre>'; print_r($_POST); echo '</pre>';
+ //echo '<pre>'; print_r($_POST); echo '</pre>';
$result = pwg_query('SELECT * FROM '.CONFIG_TABLE);
while ($row = mysql_fetch_array($result))
{
@@ -147,6 +135,13 @@ UPDATE '.CONFIG_TABLE.'
}
}
+//------------------------------------------------------ $conf reinitialization
+$result = pwg_query('SELECT param,value FROM '.CONFIG_TABLE);
+while ($row = mysql_fetch_array($result))
+{
+ $conf[$row['param']] = $row['value'];
+}
+
//----------------------------------------------------- template initialization
$template->set_filenames( array('config'=>'admin/configuration.tpl') );
@@ -171,16 +166,20 @@ switch ($page['section'])
{
$html_check='checked="checked"';
- $history_yes = ($conf['log']=='true')?'checked="checked"':'';
- $history_no = ($conf['log']=='false')?'checked="checked"':'';
$lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':'';
$lock_no = ($conf['gallery_locked']=='false')?'checked="checked"':'';
+ $history_users = ($conf['log']=='true')?$html_check:'';
+ $history_admin = ($conf['history_admin']=='true')?$html_check:'';
+ $history_guest = ($conf['history_guest']=='true')?$html_check:'';
+ $login_history = ($conf['login_history']=='true')?$html_check:'';
$template->assign_block_vars(
'general',
array(
- 'HISTORY_YES'=>$history_yes,
- 'HISTORY_NO'=>$history_no,
+ 'HISTORY_USERS'=>$history_users,
+ 'HISTORY_ADMIN'=>$history_admin,
+ 'HISTORY_GUEST'=>$history_guest,
+ 'LOGIN_HISTORY'=>$login_history,
'GALLERY_LOCKED_YES'=>$lock_yes,
'GALLERY_LOCKED_NO'=>$lock_no,
($conf['rate']=='true'?'RATE_YES':'RATE_NO')=>$html_check,
diff --git a/identification.php b/identification.php
index 9bfdef96f..d37434682 100644
--- a/identification.php
+++ b/identification.php
@@ -64,6 +64,7 @@ SELECT '.$conf['user_fields']['id'].' AS id,
$remember_me = true;
}
log_user($row['id'], $remember_me);
+ pwg_log_login( $username );
redirect(empty($redirect_to) ? make_index_url() : $redirect_to);
}
else
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index e906fca06..4a4bc7038 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -430,9 +430,6 @@ $conf['upload_maxwidth_thumbnail'] = 150;
// nb_logs_page : how many logs to display on a page
$conf['nb_logs_page'] = 300;
-// history_admin : history admin visits ?
-$conf['history_admin'] = false;
-
// +-----------------------------------------------------------------------+
// | urls |
// +-----------------------------------------------------------------------+
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 9c859d227..b037d8e09 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -384,15 +384,40 @@ function pwg_log( $file, $category, $picture = '' )
{
global $conf, $user;
- if ($conf['log'])
+ if ( is_admin() )
+ {
+ $doit=$conf['history_admin'];
+ }
+ elseif ( $user['is_the_guest'] )
+ {
+ $doit=$conf['history_guest'];
+ }
+ else
+ {
+ $doit = $conf['log'];
+ }
+
+ if ($doit)
{
- if (($conf['history_admin']) or ((! $conf['history_admin'])
- and (!is_admin())))
- {
$login = ($user['id'] == $conf['guest_id'])
? 'guest' : addslashes($user['username']);
+ insert_into_history($login, $file, $category, $picture);
+ }
+}
+
+function pwg_log_login( $username )
+{
+ global $conf;
+ if ( $conf['login_history'] )
+ {
+ insert_into_history($username, 'login', '', '');
+ }
+}
- $query = '
+// inserts a row in the history table
+function insert_into_history( $login, $file, $category, $picture)
+{
+ $query = '
INSERT INTO '.HISTORY_TABLE.'
(date,login,IP,file,category,picture)
VALUES
@@ -403,9 +428,7 @@ INSERT INTO '.HISTORY_TABLE.'
\''.addslashes(strip_tags($category)).'\',
\''.addslashes($picture).'\')
;';
- pwg_query($query);
- }
- }
+ pwg_query($query);
}
// format_date returns a formatted date for display. The date given in
@@ -461,7 +484,7 @@ function format_date($date, $type = 'us', $show_time = false)
return $formated_date;
}
-function pwg_stripslashes($value)
+function pwg_stripslashes($value)
{
if (get_magic_quotes_gpc())
{
@@ -470,7 +493,7 @@ function pwg_stripslashes($value)
return $value;
}
-function pwg_addslashes($value)
+function pwg_addslashes($value)
{
if (!get_magic_quotes_gpc())
{
@@ -479,7 +502,7 @@ function pwg_addslashes($value)
return $value;
}
-function pwg_quotemeta($value)
+function pwg_quotemeta($value)
{
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
@@ -699,7 +722,7 @@ function get_thumbnail_src($path, $tn_ext = '', $with_rewrite = true)
function my_error($header)
{
global $conf;
-
+
$error = '<pre>';
$error.= $header;
$error.= '[mysql error '.mysql_errno().'] ';
@@ -944,7 +967,7 @@ function get_available_upgrade_ids()
function load_conf_from_db()
{
global $conf;
-
+
$query = '
SELECT param,value
FROM '.CONFIG_TABLE.'
@@ -959,7 +982,7 @@ SELECT param,value
while ($row = mysql_fetch_array($result))
{
$conf[ $row['param'] ] = isset($row['value']) ? $row['value'] : '';
-
+
// If the field is true or false, the variable is transformed into a
// boolean value.
if ($conf[$row['param']] == 'true' or $conf[$row['param']] == 'false')
diff --git a/install/config.sql b/install/config.sql
index b69a5ca5b..22fcd428d 100644
--- a/install/config.sql
+++ b/install/config.sql
@@ -19,7 +19,9 @@ INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('gallery_url','ht
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('rate','true','Rating pictures feature is enabled');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('rate_anonymous','true','Rating pictures feature is also enabled for visitors');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('page_banner','<h1>PhpWebGallery demonstration site</h1><p>My photos web site</p>','html displayed on the top each page of your gallery');
-
+INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('history_admin','false','keep a history of administrator visits on your website');
+INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website');
+INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('login_history','true','keep a history of user logins on your website');
-- Notification by mail
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail');
diff --git a/install/db/30-database.php b/install/db/30-database.php
new file mode 100644
index 000000000..5770d425e
--- /dev/null
+++ b/install/db/30-database.php
@@ -0,0 +1,52 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2006-07-23 14:17:00 +0200 (dim, 23 jui 2006) $
+// | last modifier : $Author: nikrou $
+// | revision : $Revision: 1492 $
+// +-----------------------------------------------------------------------+
+// | 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. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die('Hacking attempt!');
+}
+
+$upgrade_description = 'Add history_guest and login_history to #config';
+
+$query = '
+INSERT INTO '.PREFIX_TABLE."config (param,value,comment) VALUES ('history_admin','false','keep a history of administrator visits on your website');";
+pwg_query($query);
+
+$query = '
+INSERT INTO '.PREFIX_TABLE."config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website');";
+pwg_query($query);
+
+$query = '
+INSERT INTO '.PREFIX_TABLE."config (param,value,comment) VALUES ('login_history','true','keep a history of user logins on your website');";
+pwg_query($query);
+
+echo
+"\n"
+. $upgrade_description
+."\n"
+;
+?>
diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php
index f81dd9b87..32857e949 100644
--- a/language/en_UK.iso-8859-1/admin.lang.php
+++ b/language/en_UK.iso-8859-1/admin.lang.php
@@ -99,6 +99,7 @@ $lang['Link all category elements to a new category'] = 'Link all category eleme
$lang['Link all category elements to some existing categories'] = 'Link all category elements to some existing categories';
$lang['Linked categories'] = 'Linked categories';
$lang['Lock gallery'] = 'Lock gallery';
+$lang['Login history'] = 'User login history';
$lang['Maintenance'] = 'Maintenance';
$lang['Manage permissions for a category'] = 'Manage permissions for a category';
$lang['Manage permissions for group "%s"'] = 'Manage permissions for group "%s"';
diff --git a/language/en_UK.iso-8859-1/help/configuration.html b/language/en_UK.iso-8859-1/help/configuration.html
index 3741207e2..cca7f1d8a 100644
--- a/language/en_UK.iso-8859-1/help/configuration.html
+++ b/language/en_UK.iso-8859-1/help/configuration.html
@@ -21,12 +21,6 @@ page.</li>
<li><strong>Gallery URL</strong>: used for the RSS feed.</li>
- <li><strong>History</strong>: visits on pages <span
- class="pwgScreen">category.php</span> and <span
- class="pwgScreen">picture.php</span> will be registered in
- <code>history</code> table. Visits will be shown in <span
- class="pwgScreen">Administration, General, History</span>.</li>
-
<li><strong>Lock gallery</strong>: Lock the entire gallery for
maintenance. Only administrator users will be able to reach the
gallery.</li>
@@ -36,6 +30,20 @@ page.</li>
<li><strong>Rating by guests</strong>: Even non registered users can
rate images.</li>
+ <li><strong>History Users</strong>: visits by registrered users on pages <span
+ class="pwgScreen">category.php</span> and <span
+ class="pwgScreen">picture.php</span> will be saved in the
+ <code>history</code> table. Visits will be shown in <span
+ class="pwgScreen">Administration, General, History</span>.</li>
+
+ <li><strong>History Administrator</strong>: page visits by administrators
+ will be saved.</li>
+
+ <li><strong>History Guests</strong>: page visits by guests will be saved.</li>
+
+ <li><strong>User login history</strong>: when a user logs in, it will be
+ logged in the <code>history</code> table.</li>
+
</ul>
diff --git a/language/fr_FR.iso-8859-1/admin.lang.php b/language/fr_FR.iso-8859-1/admin.lang.php
index 56f9ee7a4..2c80ed08a 100644
--- a/language/fr_FR.iso-8859-1/admin.lang.php
+++ b/language/fr_FR.iso-8859-1/admin.lang.php
@@ -99,6 +99,7 @@ $lang['Link all category elements to a new category'] = 'Associer tous les éléme
$lang['Link all category elements to some existing categories'] = 'Associer tous les éléments de la catégorie à des catégories existantes';
$lang['Linked categories'] = 'Catégories associées';
$lang['Lock gallery'] = 'Verrouiller la galerie';
+$lang['Login history'] = 'Historique des connexions';
$lang['Maintenance'] = 'Maintenance';
$lang['Manage permissions for a category'] = 'Gérer les permissions pour une catégorie';
$lang['Manage permissions for group "%s"'] = 'Gérer les permissions pour le groupe "%s"';
diff --git a/language/fr_FR.iso-8859-1/help/configuration.html b/language/fr_FR.iso-8859-1/help/configuration.html
index 47559a686..ba9a411f4 100644
--- a/language/fr_FR.iso-8859-1/help/configuration.html
+++ b/language/fr_FR.iso-8859-1/help/configuration.html
@@ -21,12 +21,6 @@ pages.</li>
<li><strong>URL de la galerie</strong>: utilisé pour le flux RSS.</li>
- <li><strong>Historique</strong>: visites des pages <span
-class="pwgScreen">category.php</span> et <span
-class="pwgScreen">picture.php</span> sont enregistrées dans la table
-<code>history</code>. Les visites sont affichées dans l'écran <span
-class="pwgScreen">Administration, Général, Historique</span>.</li>
-
<li><strong>Verrouiller la galerie</strong>: Verrouiller l'ensemble de la
galerie pour maintenance. Seul les administrateurs pourront accéder à la
galerie.</li>
@@ -36,6 +30,21 @@ galerie.</li>
<li><strong>Notation par les visiteurs</strong>: Même les utilisateurs
non enregistrés peuvent noter les images.</li>
+ <li><strong>Historique Utilisateurs</strong>: les visites des pages <span
+class="pwgScreen">index.php</span> et <span
+class="pwgScreen">picture.php</span> par les utilisateurs enregistrés sont
+enregistrées dans la table <code>history</code>. Les visites sont affichées
+dans l'écran <span class="pwgScreen">Administration, Général, Historique</span>.</li>
+
+ <li><strong>Historique Administrateur</strong>: les visites des pages
+ par les administrateurs sont enregistrées.</li>
+
+ <li><strong>Historique Invités</strong>: les visites des pages
+ par les invités sont enregistrées.</li>
+
+ <li><strong>Historique des connexions</strong>: chaque connexion
+ utilisateur, est enregistrée dans la table <code>history</code>.</li>
+
</ul>
diff --git a/register.php b/register.php
index c69741671..cc27dc4dc 100644
--- a/register.php
+++ b/register.php
@@ -48,7 +48,6 @@ if (isset($_POST['submit']))
if (count($errors) == 0)
{
$user_id = get_userid($_POST['login']);
- log_user( $user_id, false);
redirect(make_index_url());
}
}
diff --git a/template/yoga/admin/configuration.tpl b/template/yoga/admin/configuration.tpl
index 5cb3a56d5..99a034cf4 100644
--- a/template/yoga/admin/configuration.tpl
+++ b/template/yoga/admin/configuration.tpl
@@ -35,17 +35,11 @@
</li>
<li>
- <span class="property">{lang:History}</span>
- <label><input type="radio" class="radio" name="log" value="true" {general.HISTORY_YES} />{lang:Yes}</label>
- <label><input type="radio" class="radio" name="log" value="false" {general.HISTORY_NO} />{lang:No}</label>
- </li>
-
- <li>
<span class="property">{lang:Lock gallery}</span>
<label><input type="radio" class="radio" name="gallery_locked" value="true" {general.GALLERY_LOCKED_YES} />{lang:Yes}</label>
<label><input type="radio" class="radio" name="gallery_locked" value="false" {general.GALLERY_LOCKED_NO} />{lang:No}</label>
</li>
-
+
<li>
<span class="property">{lang:Rating}</span>
<label><input type="radio" class="radio" name="rate" value="true" {general.RATE_YES} />{lang:Yes}</label>
@@ -57,6 +51,29 @@
<label><input type="radio" class="radio" name="rate_anonymous" value="true" {general.RATE_ANONYMOUS_YES} />{lang:Yes}</label>
<label><input type="radio" class="radio" name="rate_anonymous" value="false" {general.RATE_ANONYMOUS_NO} />{lang:No}</label>
</li>
+
+ <li>
+ <fieldset>
+ <legend>{lang:History}</legend>
+ <ul>
+ <li>
+ <label><span class="property">{lang:Users}</span><input type="checkbox" name="log" {general.HISTORY_USERS} /></label>
+ </li>
+
+ <li>
+ <label><span class="property">{lang:user_status_admin}</span><input type="checkbox" name="history_admin" {general.HISTORY_ADMIN} /></label>
+ </li>
+
+ <li>
+ <label><span class="property">{lang:Guests}</span><input type="checkbox" name="history_guest" {general.HISTORY_GUEST} /></label>
+ </li>
+
+ <li>
+ <label><span class="property">{lang:Login history}</span><input type="checkbox" name="login_history" {general.LOGIN_HISTORY} /></label>
+ </li>
+ </ul>
+ </fieldset>
+ </li>
</ul>
</fieldset>
<!-- END general -->