From af621d40d460dec6562664b636fc350d1d8fb9c6 Mon Sep 17 00:00:00 2001 From: rvelices Date: Thu, 19 Oct 2006 00:41:07 +0000 Subject: feature 564: logs in the history table each user login feature 562: possibility to log page visits for any combination of administrators/users/guests git-svn-id: http://piwigo.org/svn/trunk@1565 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/configuration.php | 41 +++++++++--------- identification.php | 1 + include/config_default.inc.php | 3 -- include/functions.inc.php | 51 ++++++++++++++++------ install/config.sql | 4 +- install/db/30-database.php | 52 +++++++++++++++++++++++ language/en_UK.iso-8859-1/admin.lang.php | 1 + language/en_UK.iso-8859-1/help/configuration.html | 20 ++++++--- language/fr_FR.iso-8859-1/admin.lang.php | 1 + language/fr_FR.iso-8859-1/help/configuration.html | 21 ++++++--- register.php | 1 - template/yoga/admin/configuration.tpl | 31 +++++++++++--- 12 files changed, 168 insertions(+), 59 deletions(-) create mode 100644 install/db/30-database.php 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 '
'; print_r($_POST); echo '
'; + //echo '
'; print_r($_POST); echo '
'; $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 = '
';
   $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','

PhpWebGallery demonstration site

My photos web site

','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 @@ + 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.
  • Gallery URL: used for the RSS feed.
  • -
  • History: visits on pages category.php and picture.php will be registered in - history table. Visits will be shown in Administration, General, History.
  • -
  • Lock gallery: Lock the entire gallery for maintenance. Only administrator users will be able to reach the gallery.
  • @@ -36,6 +30,20 @@ page.
  • Rating by guests: Even non registered users can rate images.
  • +
  • History Users: visits by registrered users on pages category.php and picture.php will be saved in the + history table. Visits will be shown in Administration, General, History.
  • + +
  • History Administrator: page visits by administrators + will be saved.
  • + +
  • History Guests: page visits by guests will be saved.
  • + +
  • User login history: when a user logs in, it will be + logged in the history table.
  • + 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 $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.
  • URL de la galerie: utilisé pour le flux RSS.
  • -
  • Historique: visites des pages category.php et picture.php sont enregistrées dans la table -history. Les visites sont affichées dans l'écran Administration, Général, Historique.
  • -
  • Verrouiller la galerie: Verrouiller l'ensemble de la galerie pour maintenance. Seul les administrateurs pourront accéder à la galerie.
  • @@ -36,6 +30,21 @@ galerie.
  • Notation par les visiteurs: Même les utilisateurs non enregistrés peuvent noter les images.
  • +
  • Historique Utilisateurs: les visites des pages index.php et picture.php par les utilisateurs enregistrés sont +enregistrées dans la table history. Les visites sont affichées +dans l'écran Administration, Général, Historique.
  • + +
  • Historique Administrateur: les visites des pages + par les administrateurs sont enregistrées.
  • + +
  • Historique Invités: les visites des pages + par les invités sont enregistrées.
  • + +
  • Historique des connexions: chaque connexion + utilisateur, est enregistrée dans la table history.
  • + 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 @@ -34,18 +34,12 @@ -
  • - {lang:History} - - -
  • -
  • {lang:Lock gallery}
  • - +
  • {lang:Rating} @@ -57,6 +51,29 @@
  • + +
  • +
    + {lang:History} +
      +
    • + +
    • + +
    • + +
    • + +
    • + +
    • + +
    • + +
    • +
    +
    +
  • -- cgit v1.2.3