######################################################## ## Mod Title: Last Visit Mod ## Mod Version: 1.2.5 ## Author: Niels Chr. Rød Denmark < ncr@db9.dk > http://mods.db9.dk ## ## This mod is for phpBB2 ver 2.0.2 ## ## Description: This mod will enable logning of the users last visit time, ## after this mod, users can see when another user have last visited ## the board, this is shown in the correspondings users profile. ## This mod support, user level and hidden users ## Admin will always be able to see other users last visit, regardless of the settings ## if board config is "off", then only admin can see the information ## if board is "on", then all users kan se other users last visit ## except hidden users, who will still be "hidden" ## This mod, will also display the number of reg/hidden and guest users today on the index page ## ## ## ## Installation Level: Easy ## Installation Time: 10-15 Minutes ## Files To Edit: 6 ## language/subsilver/lang_main.php ## includes/usercp_viewprofile.php ## includes/sessions.php ## index.php ## templates/subsilver/index_body.tpl ## templates/subsilver/profile_view_body.tpl ## Include files: 1 ## db_update.php ## ## History: ## 0.9.0. - initial BETA for RC-2 ## 1.0.0. - initial release for RC-2 ## 1.0.10. - History started, change in how timezones are handled ## 1.0.11. - corrected a typo in how timezones are handled ## 1.0.12. - corection to follow phpBB2 coding guidelines ## 1.0.13. - Now includes the number of users witch have visited the board the last hour ## 1.0.14. - fixed that the language part was missing from the last hour addition ## 1.0.15. - added extra feature, that how meny guest visited the board today are also countet ## 1.0.16. - missed something in the page_header.php file ## 1.0.17. - moved some changes from page_header.php over to index.php, for incresed performance ## 1.0.18. - fixed session.php that guest users are reset from the "today list" ## 1.0.19. - guest was still beeing reset, new change to session.php $dato ## 1.2.0. - BETA for phpBB2 version 2.0.2. ## 1.2.1. - typo, missed a comma in session.php ## 1.2.2. - fixed that guest users was not counted rigth if mixed timezones ## 1.2.3. - removed som added code in session.php ## 1.2.4. - add, posibilty to log guest users time ## 1.2.5. - change the code in index.php - minor speed different ## ############################################################## ## This MOD is released under the GPL License. ## Intellectual Property is retained by the MOD Author(s) listed above ############################################################## ## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the ## latest version of this MOD. Downloading this MOD from other sites could cause malicious code ## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered ## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/ ############################################################## ## Authors Notes: ## ## Instead of runing the SQL commands your self, I have also included a db_update.php file ## if you are loged in as ADMIN, you can run this file, witch will do the neasessary changes to the DB ## the file will by it self put prefix on your tables, else ## if you are using a prefix to you DB tabels then you have to add this to ## the [ADD SQL] commands, e.g. "phpbb_users" instead of just "users" - ONLY ## in the initial [ADD SQL] commands, not in the php code ! ## ## ## The most important thing to keep in mind is, take your time, make ## sure you are finding the correct lines to modify, then take care to paste the new code. ## Please also keep in mind, if you are using more than one language file or theme at your ## site, you will need to edit the corrosponding files for each occurrence. Good Luck! ################################################################# ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD ## and the Database ################################################################# # #-----[ ADD SQL ]------------------------------------------ # SQL-query: ALTER TABLE users ADD user_lastlogon INT (11) DEFAULT '0' # #-----[ ADD SQL ]------------------------------------------ # SQL-query: UPDATE users SET user_lastlogon=user_lastvisit # #-----[ ADD SQL ]------------------------------------------ # SQL-query: INSERT INTO config (config_name, config_value) VALUES ('hidde_last_logon', '0') #################################################################### # #-----[ OPEN ]------------------------------------------ # language/lang_english/lang_main.php # #-----[ FIND ]------------------------------------------ # # AT THE BOTTOM OF THE PAGE // // That's all Folks! // ------------------------------------------------- # #-----[ BEFORE, ADD ]------------------------------------------ # //add to last visit mod $lang['Last_logon'] = 'Last Visit'; $lang['Hidde_last_logon'] = 'Hidden'; $lang['Never_last_logon'] = 'Never'; $lang['Users_today_zero_total'] = 'In total 0 users have visited this site today :: '; $lang['Users_today_total'] = 'In total %d user have visited this site today :: '; $lang['User_today_total'] = 'In total %d users have visited this site today :: '; $lang['Users_lasthour_explain'] = ', %d of them within the last hour.'; $lang['Users_lasthour_none_explain'] = ''; //showen of none have visited the last hour, fill if you like # #-----[ OPEN ]------------------------------------------ # index.php # #-----[ FIND ]------------------------------------------ # // // Start output of page # #-----[ BEFORE, ADD ]------------------------------------------ # //show dayly users mod $time_now=time(); $time1Hour=$time_now-3600; $minutes = date('is', $time_now); $hour_now = $time_now - (60*($minutes[0].$minutes[1])) - ($minutes[2].$minutes[3]); $dato=create_date('H', $time_now,$board_config['board_timezone']); $timetoday = $hour_now - (3600*$dato); $sql = 'SELECT session_ip, MAX(session_time) as session_time FROM '.SESSIONS_TABLE.' WHERE session_user_id="'.ANONYMOUS.'" AND session_time >= '.$timetoday.' AND session_time< '.($timetoday+86399).' GROUP BY session_ip'; if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, "Couldn't retrieve guest user today data", "", __LINE__, __FILE__, $sql); while( $guest_list = $db->sql_fetchrow($result)) { if ($guest_list['session_time'] >$time1Hour) $users_lasthour++; } $guests_today = $db->sql_numrows($result); $sql = 'SELECT user_id,username,user_allow_viewonline,user_level,user_lastlogon FROM ' . USERS_TABLE . ' WHERE user_id!="'.ANONYMOUS.'" AND user_session_time >= '.$timetoday.' AND user_session_time< '.($timetoday+86399).' ORDER BY username'; if (!$result = $db->sql_query($sql)) message_die(GENERAL_ERROR, "Couldn't retrieve user today data", "", __LINE__, __FILE__, $sql); while( $todayrow = $db->sql_fetchrow($result)) { $style_color = ""; if ($todayrow['user_lastlogon']>=$time1Hour) { $users_lasthour++; } switch ($todayrow['user_level']) { case ADMIN : $todayrow['username'] = '' . $todayrow['username'] . ''; $style_color = 'style="color:#' . $theme['fontcolor3'] . '"'; break; case MOD : $todayrow['username'] = '' . $todayrow['username'] . ''; $style_color = 'style="color:#' . $theme['fontcolor2'] . '"'; break; } $users_today_list.=( $todayrow['user_allow_viewonline'])?' ' . $todayrow['username'] . ',' : (($userdata[user_level]==ADMIN) ? ' ' . $todayrow['username'] . ',' : ''); if (!$todayrow['user_allow_viewonline']) $logged_hidden_today++; else $logged_visible_today++; } if ($users_today_list) { $users_today_list[ strlen( $users_today_list)-1] = ' '; } else { $users_today_list = $lang['None']; } $total_users_today = $db->sql_numrows($result)+$guests_today; $users_today_list = $lang['Registered_users'].' ' . $users_today_list; $l_today_user_s = ($total_users_today) ? ( ( $total_users_today == 1 )? $lang['User_today_total'] : $lang['Users_today_total'] ) : $lang['Users_today_zero_total']; $l_today_r_user_s = ($logged_visible_today) ? ( ( $logged_visible_today == 1 ) ? $lang['Reg_user_total'] : $lang['Reg_users_total'] ) : $lang['Reg_users_zero_total']; $l_today_h_user_s = ($logged_hidden_today) ? (($logged_hidden_today == 1) ? $lang['Hidden_user_total'] : $lang['Hidden_users_total'] ) : $lang['Hidden_users_zero_total']; $l_today_g_user_s = ($guests_today) ? (($guests_today == 1) ? $lang['Guest_user_total'] : $lang['Guest_users_total']) : $lang['Guest_users_zero_total']; $l_today_users = sprintf($l_today_user_s, $total_users_today); $l_today_users .= sprintf($l_today_r_user_s, $logged_visible_today); $l_today_users .= sprintf($l_today_h_user_s, $logged_hidden_today); $l_today_users .= sprintf($l_today_g_user_s, $guests_today); # #-----[ FIND ]------------------------------------------ # 'FORUM_LOCKED_IMG' => $images['forum_locked'], # #-----[ AFTER, ADD ]------------------------------------------ # 'USERS_TODAY_LIST' => $users_today_list, 'L_USERS_LASTHOUR' =>($users_lasthour)?sprintf($lang['Users_lasthour_explain'],$users_lasthour):$lang['Users_lasthour_none_explain'], 'L_USERS_TODAY' =>$l_today_users, # #-----[ OPEN ]------------------------------------------ # includes/sessions.php # #-----[ FIND ]------------------------------------------ # if ( !empty($session_id) ) { # #-----[ AFTER, ADD ]------------------------------------------ # $expiry_time = $current_time - $board_config['session_length'] ; # #-----[ FIND ]------------------------------------------ # $sql = "SELECT u.*, s.* FROM " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u WHERE s.session_id = '$session_id' AND u.user_id = s.session_user_id"; # #-----[ IN-LINE FIND ]------------------------------------------ # "; # #-----[ IN-LINE BEFORE, ADD ]------------------------------------------ # AND session_time > $expiry_time # #-----[ FIND ]------------------------------------------ # $sql = "DELETE FROM " . SESSIONS_TABLE . " WHERE session_time < $expiry_time # #-----[ IN-LINE FIND ]------------------------------------------ # session_time < $expiry_time # #-----[ IN-LINE REPLACE WITH ]------------------------------------------ # UNIX_TIMESTAMP() - session_time >=172800 # #-----[ FIND ]------------------------------------------ # if ( $user_id != ANONYMOUS ) { $last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time; $sql = "UPDATE " . USERS_TABLE . " # #-----[ IN-LINE FIND ]------------------------------------------ # , user_lastvisit = $last_visit # #-----[ IN-LINE AFTER, ADD ]------------------------------------------ # , user_lastlogon = " . time() . " # #-----[ OPEN ]------------------------------------------ # includes/usercp_viewprofile.php # #-----[ FIND ]------------------------------------------ # 'JOINED' => create_date($lang['DATE_FORMAT'], $profiledata['user_regdate'], $board_config['board_timezone']), # #-----[ AFTER, ADD ]------------------------------------------ # 'L_LOGON' => $lang['Last_logon'], 'LAST_LOGON' => ($userdata['user_level'] == ADMIN || (!$board_config['hidde_last_logon'] && $profiledata['user_allow_viewonline'])) ? (($profiledata['user_lastlogon'])? create_date($board_config['default_dateformat'], $profiledata['user_lastlogon'], $board_config['board_timezone']):$lang['Never_last_logon']):$lang['Hidde_last_logon'], # #-----[ OPEN ]------------------------------------------ # # (make sure to edit this file for every theme you use). templates/subsilver/index_body.tpl # #-----[ FIND ]------------------------------------------ # # #-----[ AFTER, ADD ]------------------------------------------ # {L_USERS_TODAY} {L_USERS_LASTHOUR}
{USERS_TODAY_LIST}
# #-----[ OPEN ]------------------------------------------ # (make sure to edit this file for every theme you use). templates/subsilver/profile_view_body.tpl # #-----[ FIND ]------------------------------------------ # {JOINED} # #-----[ AFTER, ADD ]------------------------------------------ # {L_LOGON}:  {LAST_LOGON} # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM