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); + } +} - $query = ' +function pwg_log_login( $username ) +{ + global $conf; + if ( $conf['login_history'] ) + { + insert_into_history($username, 'login', '', ''); + } +} + +// 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.
history table. Visits will be shown in Administration, General, History.history table. Visits will be shown in Administration, General, History.history table.history. Les visites sont affichées dans l'écran Administration, Général, Historique.history. Les visites sont affichées
+dans l'écran Administration, Général, Historique.history.