Changeset 1565 for trunk


Ignore:
Timestamp:
Oct 19, 2006, 2:41:07 AM (18 years ago)
Author:
rvelices
Message:

feature 564: logs in the history table each user login
feature 562: possibility to log page visits for any combination of
administrators/users/guests

Location:
trunk
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r1250 r1565  
    4747  $page['section'] = $_GET['section'];
    4848}
    49 //------------------------------------------------------ $conf reinitialization
    50 $result = pwg_query('SELECT param,value FROM '.CONFIG_TABLE);
    51 while ($row = mysql_fetch_array($result))
    52 {
    53   $conf[$row['param']] = $row['value'];
    54   // if the parameter is present in $_POST array (if a form is submited), we
    55   // override it with the submited value
    56   if (isset($_POST[$row['param']]))
    57   {
    58     $conf[$row['param']] = $_POST[$row['param']];
    59     if ( 'page_banner'==$row['param'] )
    60     { // should we do it for all ?
    61       $conf[$row['param']] = stripslashes( $conf[$row['param']] );
    62     }
    63   }
    64 }
    6549//------------------------------ verification and registration of modifications
    6650if (isset($_POST['submit']))
     
    7559        array_push($page['errors'], $lang['conf_gallery_url_error']);
    7660      }
     61      $_POST['log'] = empty($_POST['log'])?'false':'true';
     62      $_POST['history_admin'] = empty($_POST['history_admin'])?'false':'true';
     63      $_POST['history_guest'] = empty($_POST['history_guest'])?'false':'true';
     64      $_POST['login_history'] = empty($_POST['login_history'])?'false':'true';
    7765      break;
    7866    }
     
    120108  if (count($page['errors']) == 0)
    121109  {
    122 //    echo '<pre>'; print_r($_POST); echo '</pre>';
     110    //echo '<pre>'; print_r($_POST); echo '</pre>';
    123111    $result = pwg_query('SELECT * FROM '.CONFIG_TABLE);
    124112    while ($row = mysql_fetch_array($result))
     
    148136}
    149137
     138//------------------------------------------------------ $conf reinitialization
     139$result = pwg_query('SELECT param,value FROM '.CONFIG_TABLE);
     140while ($row = mysql_fetch_array($result))
     141{
     142  $conf[$row['param']] = $row['value'];
     143}
     144
    150145//----------------------------------------------------- template initialization
    151146$template->set_filenames( array('config'=>'admin/configuration.tpl') );
     
    172167    $html_check='checked="checked"';
    173168
    174     $history_yes = ($conf['log']=='true')?'checked="checked"':'';
    175     $history_no  = ($conf['log']=='false')?'checked="checked"':'';
    176169    $lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':'';
    177170    $lock_no = ($conf['gallery_locked']=='false')?'checked="checked"':'';
     171    $history_users = ($conf['log']=='true')?$html_check:'';
     172    $history_admin = ($conf['history_admin']=='true')?$html_check:'';
     173    $history_guest = ($conf['history_guest']=='true')?$html_check:'';
     174    $login_history = ($conf['login_history']=='true')?$html_check:'';
    178175
    179176    $template->assign_block_vars(
    180177      'general',
    181178      array(
    182         'HISTORY_YES'=>$history_yes,
    183         'HISTORY_NO'=>$history_no,
     179        'HISTORY_USERS'=>$history_users,
     180        'HISTORY_ADMIN'=>$history_admin,
     181        'HISTORY_GUEST'=>$history_guest,
     182        'LOGIN_HISTORY'=>$login_history,
    184183        'GALLERY_LOCKED_YES'=>$lock_yes,
    185184        'GALLERY_LOCKED_NO'=>$lock_no,
  • trunk/identification.php

    r1511 r1565  
    6565    }
    6666    log_user($row['id'], $remember_me);
     67    pwg_log_login( $username );
    6768    redirect(empty($redirect_to) ? make_index_url() : $redirect_to);
    6869  }
  • trunk/include/config_default.inc.php

    r1537 r1565  
    431431$conf['nb_logs_page'] = 300;
    432432
    433 // history_admin : history admin visits  ?
    434 $conf['history_admin'] = false;
    435 
    436433// +-----------------------------------------------------------------------+
    437434// |                                 urls                                  |
  • trunk/include/functions.inc.php

    r1510 r1565  
    385385  global $conf, $user;
    386386
    387   if ($conf['log'])
    388   {
    389    if (($conf['history_admin']) or ((! $conf['history_admin'])
    390        and (!is_admin())))
    391     {
     387  if ( is_admin() )
     388  {
     389    $doit=$conf['history_admin'];
     390  }
     391  elseif ( $user['is_the_guest'] )
     392  {
     393    $doit=$conf['history_guest'];
     394  }
     395  else
     396  {
     397    $doit = $conf['log'];
     398  }
     399
     400  if ($doit)
     401  {
    392402    $login = ($user['id'] == $conf['guest_id'])
    393403      ? 'guest' : addslashes($user['username']);
    394 
    395     $query = '
     404    insert_into_history($login, $file, $category, $picture);
     405  }
     406}
     407
     408function pwg_log_login( $username )
     409{
     410  global $conf;
     411  if ( $conf['login_history'] )
     412  {
     413    insert_into_history($username, 'login', '', '');
     414  }
     415}
     416
     417// inserts a row in the history table
     418function insert_into_history( $login, $file, $category, $picture)
     419{
     420  $query = '
    396421INSERT INTO '.HISTORY_TABLE.'
    397422  (date,login,IP,file,category,picture)
     
    404429  \''.addslashes($picture).'\')
    405430;';
    406     pwg_query($query);
    407   }
    408   }
     431  pwg_query($query);
    409432}
    410433
     
    462485}
    463486
    464 function pwg_stripslashes($value) 
     487function pwg_stripslashes($value)
    465488{
    466489  if (get_magic_quotes_gpc())
     
    471494}
    472495
    473 function pwg_addslashes($value) 
     496function pwg_addslashes($value)
    474497{
    475498  if (!get_magic_quotes_gpc())
     
    480503}
    481504
    482 function pwg_quotemeta($value) 
     505function pwg_quotemeta($value)
    483506{
    484507  if (get_magic_quotes_gpc()) {
     
    700723{
    701724  global $conf;
    702  
     725
    703726  $error = '<pre>';
    704727  $error.= $header;
     
    945968{
    946969  global $conf;
    947  
     970
    948971  $query = '
    949972SELECT param,value
     
    960983  {
    961984    $conf[ $row['param'] ] = isset($row['value']) ? $row['value'] : '';
    962    
     985
    963986    // If the field is true or false, the variable is transformed into a
    964987    // boolean value.
  • trunk/install/config.sql

    r1417 r1565  
    2020INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('rate_anonymous','true','Rating pictures feature is also enabled for visitors');
    2121INSERT 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');
    22 
     22INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('history_admin','false','keep a history of administrator visits on your website');
     23INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website');
     24INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('login_history','true','keep a history of user logins on your website');
    2325-- Notification by mail
    2426INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail');
  • trunk/language/en_UK.iso-8859-1/admin.lang.php

    r1538 r1565  
    100100$lang['Linked categories'] = 'Linked categories';
    101101$lang['Lock gallery'] = 'Lock gallery';
     102$lang['Login history'] = 'User login history';
    102103$lang['Maintenance'] = 'Maintenance';
    103104$lang['Manage permissions for a category'] = 'Manage permissions for a category';
  • trunk/language/en_UK.iso-8859-1/help/configuration.html

    r1071 r1565  
    2222  <li><strong>Gallery URL</strong>: used for the RSS feed.</li>
    2323
    24   <li><strong>History</strong>: visits on pages <span
    25   class="pwgScreen">category.php</span> and <span
    26   class="pwgScreen">picture.php</span> will be registered in
    27   <code>history</code> table. Visits will be shown in <span
    28   class="pwgScreen">Administration, General, History</span>.</li>
    29 
    3024  <li><strong>Lock gallery</strong>: Lock the entire gallery for
    3125  maintenance. Only administrator users will be able to reach the
     
    3630  <li><strong>Rating by guests</strong>: Even non registered users can
    3731rate images.</li>
     32
     33  <li><strong>History Users</strong>: visits by registrered users on pages <span
     34  class="pwgScreen">category.php</span> and <span
     35  class="pwgScreen">picture.php</span> will be saved in the
     36  <code>history</code> table. Visits will be shown in <span
     37  class="pwgScreen">Administration, General, History</span>.</li>
     38
     39  <li><strong>History Administrator</strong>: page visits by administrators
     40  will be saved.</li>
     41
     42  <li><strong>History Guests</strong>: page visits by guests will be saved.</li>
     43
     44  <li><strong>User login history</strong>: when a user logs in, it will be
     45  logged in the <code>history</code> table.</li>
    3846
    3947</ul>
  • trunk/language/fr_FR.iso-8859-1/admin.lang.php

    r1538 r1565  
    100100$lang['Linked categories'] = 'Catégories associées';
    101101$lang['Lock gallery'] = 'Verrouiller la galerie';
     102$lang['Login history'] = 'Historique des connexions';
    102103$lang['Maintenance'] = 'Maintenance';
    103104$lang['Manage permissions for a category'] = 'Gérer les permissions pour une catégorie';
  • trunk/language/fr_FR.iso-8859-1/help/configuration.html

    r1099 r1565  
    2222  <li><strong>URL de la galerie</strong>: utilisé pour le flux RSS.</li>
    2323
    24   <li><strong>Historique</strong>: visites des pages <span
    25 class="pwgScreen">category.php</span> et <span
    26 class="pwgScreen">picture.php</span> sont enregistrées dans la table
    27 <code>history</code>. Les visites sont affichées dans l'écran <span
    28 class="pwgScreen">Administration, Général, Historique</span>.</li>
    29 
    3024  <li><strong>Verrouiller la galerie</strong>: Verrouiller l'ensemble de la
    3125galerie pour maintenance. Seul les administrateurs pourront accéder à la
     
    3630  <li><strong>Notation par les visiteurs</strong>: Même les utilisateurs
    3731non enregistrés peuvent noter les images.</li>
     32
     33  <li><strong>Historique Utilisateurs</strong>: les visites des pages <span
     34class="pwgScreen">index.php</span> et <span
     35class="pwgScreen">picture.php</span> par les utilisateurs enregistrés sont
     36enregistrées dans la table <code>history</code>. Les visites sont affichées
     37dans l'écran <span class="pwgScreen">Administration, Général, Historique</span>.</li>
     38
     39  <li><strong>Historique Administrateur</strong>: les visites des pages
     40  par les administrateurs sont enregistrées.</li>
     41
     42  <li><strong>Historique Invités</strong>: les visites des pages
     43  par les invités sont enregistrées.</li>
     44
     45  <li><strong>Historique des connexions</strong>: chaque connexion
     46  utilisateur, est enregistrée dans la table <code>history</code>.</li>
    3847
    3948</ul>
  • trunk/register.php

    r1082 r1565  
    4949  {
    5050    $user_id = get_userid($_POST['login']);
    51     log_user( $user_id, false);
    5251    redirect(make_index_url());
    5352  }
  • trunk/template/yoga/admin/configuration.tpl

    r1491 r1565  
    3636
    3737    <li>
    38       <span class="property">{lang:History}</span>
    39       <label><input type="radio" class="radio" name="log" value="true" {general.HISTORY_YES} />{lang:Yes}</label>
    40       <label><input type="radio" class="radio" name="log" value="false" {general.HISTORY_NO} />{lang:No}</label>
    41     </li>
    42 
    43     <li>
    4438      <span class="property">{lang:Lock gallery}</span>
    4539      <label><input type="radio" class="radio" name="gallery_locked" value="true" {general.GALLERY_LOCKED_YES} />{lang:Yes}</label>
    4640      <label><input type="radio" class="radio" name="gallery_locked" value="false" {general.GALLERY_LOCKED_NO} />{lang:No}</label>
    4741    </li>
    48    
     42
    4943    <li>
    5044      <span class="property">{lang:Rating}</span>
     
    5751      <label><input type="radio" class="radio" name="rate_anonymous" value="true" {general.RATE_ANONYMOUS_YES} />{lang:Yes}</label>
    5852      <label><input type="radio" class="radio" name="rate_anonymous" value="false" {general.RATE_ANONYMOUS_NO} />{lang:No}</label>
     53    </li>
     54
     55    <li>
     56      <fieldset>
     57        <legend>{lang:History}</legend>
     58        <ul>
     59          <li>
     60            <label><span class="property">{lang:Users}</span><input type="checkbox" name="log" {general.HISTORY_USERS} /></label>
     61          </li>
     62
     63          <li>
     64            <label><span class="property">{lang:user_status_admin}</span><input type="checkbox" name="history_admin" {general.HISTORY_ADMIN} /></label>
     65          </li>
     66
     67          <li>
     68            <label><span class="property">{lang:Guests}</span><input type="checkbox" name="history_guest" {general.HISTORY_GUEST} /></label>
     69          </li>
     70
     71          <li>
     72            <label><span class="property">{lang:Login history}</span><input type="checkbox" name="login_history" {general.LOGIN_HISTORY} /></label>
     73          </li>
     74        </ul>
     75      </fieldset>
    5976    </li>
    6077  </ul>
Note: See TracChangeset for help on using the changeset viewer.