Browse Source

[svn r9904] update for the implementation of the total connection time

Eric Marguin 18 years ago
parent
commit
b0ead33045
2 changed files with 16 additions and 0 deletions
  1. 15 0
      main/inc/global.inc.php
  2. 1 0
      main/install/install_db.inc.php

+ 15 - 0
main/inc/global.inc.php

@@ -377,4 +377,19 @@ foreach($language_files as $index => $language_file)
 	include(api_get_path(SYS_CODE_PATH).'lang/english/'.$language_file.'.inc.php');
 	include(api_get_path(SYS_CODE_PATH).'lang/'.$language_interface.'/'.$language_file.'.inc.php');
 }
+
+
+//Update of the logout_date field in the table track_e_login (needed for the calculation of the total connection time)
+
+$tbl_track_login = Database :: get_statistic_table(STATISTIC_TRACK_E_LOGIN_TABLE);
+	
+$sql_last_connection="SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id='".$_SESSION["_uid"]."' ORDER BY login_date DESC LIMIT 0,1";
+
+$q_last_connection=mysql_query($sql_last_connection);
+$i_id_last_connection=mysql_result($q_last_connection,0,"login_id");
+
+$s_sql_update_logout_date="UPDATE $tbl_track_login SET logout_date=NOW() WHERE login_id='$i_id_last_connection'";
+
+api_sql_query($s_sql_update_logout_date);
+
 ?>

+ 1 - 0
main/install/install_db.inc.php

@@ -363,6 +363,7 @@ mysql_query("CREATE TABLE `track_e_login` (
 			`login_user_id` int unsigned NOT NULL default '0',
 			`login_date` datetime NOT NULL default '0000-00-00 00:00:00',
 			`login_ip` varchar(39) NOT NULL default '',
+			`logout_date` datetime NULL default NULL,
 			PRIMARY KEY  (`login_id`),
 			KEY `login_user_id` (`login_user_id`)
 			) TYPE=MyISAM") or die(mysql_error());