Last visit MOD
MOD .
: , , , .
. .

Last visit MOD
MOD 1.2.10em, phpbb2 ver. 2.0.21
: 13
index.php
memberlist.php
admin/admin_board.php
includes/functions.php
includes/page_header.php
includes/sessions.php
includes/usercp_viewprofile.php
language/lang_bulgarian/lang_admin.php
language/lang_bulgarian/lang_main.php
templates/ /index_body.tpl
templates/ /member_body.tpl
templates/ /profile_view_body.tpl
templates/ /admin/board_config_body.tpl

!!!
MOD , , MOD !!!


#
#-----[ ]------------------------------------------------
#
index.php

#
#-----[ ]------------------------------------------------
#
//
// Start output of page

#
#-----[ ]-----------------------------------------
#

// Start add - Last visit 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'] = '<b>' . $todayrow['username'] . '</b>';
$style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
break;
case MOD :
$todayrow['username'] = '<b>' . $todayrow['username'] . '</b>';
$style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
break;
}
$users_today_list.=( $todayrow['user_allow_viewonline'])?' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $todayrow['user_id']) . '"' . $style_color .'>' . $todayrow['username'] . '</a>,' : (($userdata[user_level]==ADMIN) ? ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $todayrow['user_id']) . '"' . $style_color .'><i>' . $todayrow['username'] . '</i></a>,' : '');
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);
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
'FORUM_LOCKED_IMG' =>

#
#-----[ ]------------------------------------------
#

// Start add - Last visit MOD
'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,
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
memberlist.php

#
#-----[ ]------------------------------------------------
#
$mode_types_text =

#
#-----[ ]----------------------------------------
#
$lang['Sort_Joined']

#
#-----[ ]----------------------------------
#
, $lang['Last_logon']

#
#-----[ ]------------------------------------------------
#
$mode_types =

#
#-----[ ]----------------------------------------
#
'joined'

#
#-----[ ]----------------------------------
#
, 'lastlogon'

#
#-----[ ]------------------------------------------------
#
for($i = 0

#
#-----[ ]----------------------------------------
#
0

#
#-----[ ]--------------------------------
#
($userdata['user_level'] == ADMIN ) ? 0:1

#
#-----[ ]------------------------------------------------
#
'L_JOINED' =>

#
#-----[ ]------------------------------------------
#

// Start add - Last visit MOD
'L_LOGON' => $lang['Last_logon'],
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
case 'joined':
$order_by =
break;

#
#-----[ ]------------------------------------------
#

// Start add - Last visit MOD
case 'lastlogon':
$order_by = ($userdata['user_level'] == ADMIN ) ? "user_lastlogon $sort_order LIMIT $start, " . $board_config['topics_per_page'] : "username $sort_order LIMIT $start, " . $board_config['topics_per_page'];
break;
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
$sql = "SELECT username

#
#-----[ ]----------------------------------------
#
, user_regdate

#
#-----[ ]----------------------------------
#
, user_lastlogon, user_allow_viewonline

#
#-----[ ]------------------------------------------------
#
'JOINED' =>

#
#-----[ ]------------------------------------------
#

// Start add - Last visit MOD
'LAST_LOGON' => ($userdata['user_level'] == ADMIN || (!$board_config['hidde_last_logon'] && $row['user_allow_viewonline'])) ? (($row['user_lastlogon'])? create_date($board_config['default_dateformat'], $row['user_lastlogon'], $board_config['board_timezone']):$lang['Never_last_logon']):$lang['Hidde_last_logon'],
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
admin/admin_board.php

#
#-----[ ]------------------------------------------------
#
$prune_no = (

#
#-----[ ]------------------------------------------
#

// Start add - Last visit MOD
$hidde_last_logon_yes = ( $new['hidde_last_logon'] ) ? "checked=\"checked\"" : "";
$hidde_last_logon_no = ( !$new['hidde_last_logon'] ) ? "checked=\"checked\"" : "";
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
"L_ENABLE_PRUNE" =>

#
#-----[ ]------------------------------------------
#

// Start add - Last visit MOD
"L_HIDDE_LAST_LOGON" => $lang['Hidde_last_logon'],
"L_HIDDE_LAST_LOGON_EXPLAIN" => $lang['Hidde_last_logon_expain'],
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
"PRUNE_NO" =>

#
#-----[ ]------------------------------------------
#

// Start add - Last visit MOD
"HIDDE_LAST_LOGON_YES" => $hidde_last_logon_yes,
"HIDDE_LAST_LOGON_NO" => $hidde_last_logon_no,
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
includes/functions.php

#
#-----[ ]------------------------------------------------
#
?>

#
#-----[ ]-----------------------------------------
#

// Start add - Last visit MOD
function make_hours($base_time)
{
global $lang;
$years = floor($base_time/31536000);
$base_time = $base_time - ($years*31536000);
$weeks = floor($base_time/604800);
$base_time = $base_time - ($weeks*604800);
$days = floor($base_time/86400);
$base_time = $base_time - ($days*86400);
$hours = floor($base_time/3600);
$base_time = $base_time - ($hours*3600);
$min = floor($base_time/60);
$sek = $base_time - ($min*60);
if ($sek<10) $sek ='0'.$sek;
if ($min<10) $min ='0'.$min;
if ($hours<10) $hours ='0'.$hours;
$result=(($years)?$years.' '.(($years==1)?$lang['Year']:$lang['Years']).', ':'').
(($years || $weeks)?$weeks.' '.(($weeks==1)?$lang['Week']:$lang['Weeks']).', ':'').
(($years || $weeks || $days) ? $days.' '.(($days==1)?$lang['Day']:$lang['Days']).', ':'').
(($hours)?$hours.':':'00:').(($min)?$min.':' :'00:').$sek;
return ($result)?$result:$lang['None'];
}
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
includes/page_header.php

#
#-----[ ]------------------------------------------------
#
//
// Get basic

#
#-----[ ]-----------------------------------------
#

// Start add - Last visit MOD
if ( !$userdata['user_level']==MOD )
{
$template->assign_block_vars('switch_user_is_not_moderator', array());
} else
{
$template->assign_block_vars('switch_user_is_moderator', array());
}
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
includes/sessions.php

#
#-----[ ]------------------------------------------------
#
if (
{
$last_visit = (

#
#-----[ ]----------------------------------------
#
if

#
#-----[ ]---------------------------------
#
//

#
#-----[ ]----------------------------------------
#
{

#
#-----[ ]---------------------------------
#
//

#
#-----[ ]------------------------------------------------
#
if (!$admin)
{
$sql = "UPDATE " . USERS_TABLE . "
SET

#
#-----[ ]----------------------------------------
#
user_lastvisit = $last_visit

#
#-----[ ]----------------------------------
#
, user_lastlogon = " . time() . ", user_totallogon=user_totallogon+1

#
#-----[ ]------------------------------------------------
#
$sessiondata['userid'] = $user_id;
}

#
#-----[ ]----------------------------------------
#
}

#
#-----[ ]---------------------------------
#
//

#
#-----[ ]------------------------------------------------
#
if ( !empty($session_id) )
{

#
#-----[ ]------------------------------------------
#

// Start add - Last visit MOD
$expiry_time = $current_time - $board_config['session_length'] ;
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
$sql = "SELECT u.*, s.*
FROM
WHERE
AND

#
#-----[ ]----------------------------------------
#
";

#
#-----[ ]---------------------------------
#
AND session_time > $expiry_time

#
#-----[ ]------------------------------------------------
#
if ( $userdata['user_id'] != ANONYMOUS )
{

#
#-----[ ]----------------------------------------
#
if

#
#-----[ ]---------------------------------
#
//

#
#-----[ ]----------------------------------------
#
{

#
#-----[ ]---------------------------------
#
//

#
#-----[ ]----------------------------------------
#
$sql = "UPDATE " . USERS_TABLE . "
SET user_session_time = $current_time, user_session_page = $thispage_id

#
#-----[ ]----------------------------------------
#
$thispage_id

#
#-----[ ]----------------------------------
#
, user_totalpages = user_totalpages+1, user_totaltime = user_totaltime+($current_time-".$userdata['session_time'].")

#
#-----[ ]----------------------------------------
#
message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
}
}

#
#-----[ ]---------------------------------
#
message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
}
//}

#
#-----[ ]------------------------------------------------
#
WHERE session_time < ' . (time() - (int) $board_config['session_length']) . "

#
#-----[ ]----------------------------------------
#
session_time < ' . (time() - (int) $board_config['session_length']) . "

#
#-----[ ]--------------------------------
#
' . "UNIX_TIMESTAMP() - session_time >=172800

#
#-----[ ]------------------------------------------------
#
includes/usercp_viewprofile.php

#
#-----[ ]------------------------------------------------
#
'JOINED' =>

#
#-----[ ]------------------------------------------
#

// Start add - Last visit MOD
'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'],

'L_TOTAL_ONLINE_TIME' => $lang['Total_online_time'],
'TOTAL_ONLINE_TIME' => make_hours($profiledata['user_totaltime']),
'L_LAST_ONLINE_TIME' => $lang['Last_online_time'],
'LAST_ONLINE_TIME' => make_hours($profiledata['user_session_time']-$profiledata['user_lastlogon']),
'L_NUMBER_OF_VISIT' => $lang['Number_of_visit'],
'NUMBER_OF_VISIT' => ($profiledata['user_totallogon']>0) ? $profiledata['user_totallogon']: $lang['None'],
'L_NUMBER_OF_PAGES' => $lang['Number_of_pages'],
'NUMBER_OF_PAGES' => ($profiledata['user_totalpages']) ? $profiledata['user_totalpages']: $lang['None'],
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
language/lang_english/lang_admin.php

#
#-----[ ]------------------------------------------------
#
?>

#
#-----[ ]-----------------------------------------
#

// Start add - Last visit MOD
$lang['Hidde_last_logon'] = "Hidden last logon time";
$lang['Hidde_last_logon_expain'] = "If this is set to yes, users last logon time, is hidden to other users except administrators";
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ ]------------------------------------------------
#
?>

#
#-----[ ]-----------------------------------------
#

// Start add - Last visit MOD
$lang['Last_logon'] = 'Last Visit';
$lang['Hidde_last_logon'] = '';
$lang['Never_last_logon'] = '';
$lang['Users_today_zero_total'] = ' <b>0</b> :: ';
$lang['Users_today_total'] = ' <b>%d</b> :: ';
$lang['User_today_total'] = ' <b>%d</b> :: ';
$lang['Users_lasthour_explain'] = ', %d .';
$lang['Users_lasthour_none_explain'] = ''; //showen of none have visited the last hour, fill if you like

$lang['Years'] = 'Years';
$lang['Year'] = 'Year';
$lang['Weeks'] = 'Weeks';
$lang['Week'] = 'Week';
$lang['Day'] = 'Day';
$lang['Total_online_time'] = 'Total Online Duration';
$lang['Last_online_time'] = 'Last Online Duration';
$lang['Number_of_visit'] = 'Number of visits';
$lang['Number_of_pages'] = 'Number of page hits';
// End add - Last visit MOD

#
#-----[ ]------------------------------------------------
#
templates/subSilver/index_body.tpl

#
#-----[ ]------------------------------------------------
#
rowspan

#
#-----[ ]----------------------------------------
#
rowspan="2"

#
#-----[ ]--------------------------------
#
rowspan="3"

#
#-----[ ]------------------------------------------------
#
{NEWEST_USER}</span>
</td>
</tr>

#
#-----[ ]------------------------------------------
#

<!-- Start add - Last visit MOD -->
<tr>
<td class="row1" align="left"><span class="gensmall">{L_USERS_TODAY} {L_USERS_LASTHOUR}<br />{USERS_TODAY_LIST}</br></span></td>
</tr>
<!-- Start add - Last visit MOD -->

#
#-----[ ]------------------------------------------------
#
templates/subSilver/memberlist_body.tpl

#
#-----[ ]------------------------------------------------
#
{L_POSTS}

#
#-----[ ]------------------------------------------
#

<!-- Start add - Last visit MOD -->
<th class="thTop" nowrap="nowrap">{L_LOGON}</th>
<!-- End add - Last visit MOD -->

#
#-----[ ]------------------------------------------------
#
{memberrow.POSTS}

#
#-----[ ]------------------------------------------
#

<!-- Start add - Last visit MOD -->
<td class="{memberrow.ROW_CLASS}" align="center" valign="middle"><span class="gensmall">{memberrow.LAST_LOGON}</span></td>
<!-- End add - Last visit MOD -->

#
#-----[ ]------------------------------------------------
#
<td class="catBottom"

#
#-----[ ]----------------------------------------
#
colspan="8"

#
#-----[ ]--------------------------------
#
colspan="9"

#
#-----[ ]------------------------------------------------
#
templates/subSilver/profile_view_body.tpl

#
#-----[ ]------------------------------------------------
#
<td width="100%"><b><span class="gen">{JOINED}</span></b></td>
</tr>

#
#-----[ ]------------------------------------------
#

<!-- Start add - Last visit MOD -->
<tr>
<td valign="middle" align="right"><span class="gen">{L_LOGON}: </span></td>
<td width="100%"><b><span class="gen">{LAST_LOGON}</span></b></td>
</tr>
<!-- BEGIN switch_user_is_moderator -->
<tr>
<td valign="middle" align="right"><span class="gen">{L_TOTAL_ONLINE_TIME}: </span></td>
<td width="100%"><b><span class="gen">{TOTAL_ONLINE_TIME}</span></b></td>
</tr>
<tr>
<td valign="middle" align="right"><span class="gen">{L_LAST_ONLINE_TIME}: </span></td>
<td width="100%"><b><span class="gen">{LAST_ONLINE_TIME}</span></b></td>
</tr>
<tr>
<td valign="middle" align="right"><span class="gen">{L_NUMBER_OF_VISIT}: </span></td>
<td width="100%"><b><span class="gen">{NUMBER_OF_VISIT}</span></b></td>
</tr>
<tr>
<td valign="middle" align="right"><span class="gen">{L_NUMBER_OF_PAGES}: </span></td>
<td width="100%"><b><span class="gen">{NUMBER_OF_PAGES}</span></b></td>
</tr>
<!-- END switch_user_is_moderator -->
<!-- End add - Last visit MOD -->

#
#-----[ ]------------------------------------------------
#
templates/subSilver/admin/board_config_body.tpl

#
#-----[ ]------------------------------------------------
#
{PRUNE_NO} /> {L_NO}</td>
</tr>

#
#-----[ ]------------------------------------------
#

<!-- Start add - Last visit MOD -->
<tr>
<td class="row1">{L_HIDDE_LAST_LOGON}<br /><span class="gensmall">{L_HIDDE_LAST_LOGON_EXPLAIN}</span></td>
<td class="row2"><input type="radio" name="hidde_last_logon" value="1" {HIDDE_LAST_LOGON_YES} /> {L_YES} <input type="radio" name="hidde_last_logon" value="0" {HIDDE_LAST_LOGON_NO} /> {L_NO}</td>
</tr>
<!-- End add - Last visit MOD -->

#
#-----[ ]--------------------------------
#

MOD .

last_visit_update.php .

, .

http://www. .xxx/ /last_visit_update.php

, !

, .

!!!
MOD , , MOD !!!


DEMO

:)





/ /