Kod: Tümünü seç
##############################################################
## MOD Title: Profile views
## MOD Author: Manipe < admin@manipef1.com > (N/A) http://www.manipef1.com
## MOD Description: Shows how many times a user's profile has been viewed, just above the joined date. Only shows individual visitors. Visitors who visit the same profile more than once in a day are only counted as one view.
## MOD Version: 1.1.1
##
## Installation Level: Easy
## Installation Time: ~ 3 Minutes
## Files To Edit:
## includes/usercp_viewprofile.php
## language/lang_english/lang_main.php
## templates/subSilver/profile_view_body.tpl
## includes/constants.php
##
## Included Files:
## update_to_1.1.1.txt
## License: http://opensource.org/licenses/gpl-license.php GNU Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
## Made by request from this topic: http://www.phpbb.com/phpBB/viewtopic.php?t=242939
##
## If you previously installed version 1.0.0 of this MOD, use update_to_1.1.0.txt to update this MOD to the most recent version
##
##############################################################
## MOD History:
##
##
## 2004-12-22 - Version 1.1.1
## - Fixed a few mistakes to make it Easy Mod compliant
##
## 2004-12-13 - Version 1.1.0
## - Now only shows individual visitors. Visitors who visit the same profile more than once in a day are only counted as one view.
##
## 2004-11-28 - Version 1.0.0
## - First version, seems to work perfectly
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ SQL ]-------------------------------------------
#
ALTER TABLE phpbb_users ADD user_profile_views mediumint( 8 ) NOT NULL;
#
#-----[ SQL ]-------------------------------------------
#
CREATE TABLE phpbb_profile_views ( user_id mediumint( 8 ) NOT NULL,
time int( 11 ) NOT NULL,
ip_address char( 20 ) NOT NULL );
#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_viewprofile.php
#
#-----[ FIND ]------------------------------------------
#
if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
{
message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
}
$profiledata = get_userdata($HTTP_GET_VARS[POST_USERS_URL]);
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Profile views MOD, By Manipe (Begin)
$current_time = time();
$delete_time = $current_time - 86400;
//
// Delete old entries
//
$sql = "DELETE FROM " . PROFILE_VIEWS_TABLE . "
WHERE time < '$delete_time'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update profile views', '', __LINE__, __FILE__, $sql);
}
//
// Find out if the same person has visited the same user profile
//
$sql = "SELECT ip_address
FROM " . PROFILE_VIEWS_TABLE . "
WHERE ip_address = '$user_ip'
AND user_id = '" . $profiledata['user_id'] . "'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update profile views', '', __LINE__, __FILE__, $sql);
}
$is_ip_there = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
//
// If so, don't incriment the profile views counter
//
if ( empty($is_ip_there['ip_address'][0]))
{
$sql = "INSERT INTO " . PROFILE_VIEWS_TABLE . " (user_id, time, ip_address)
VALUES ('" . $profiledata['user_id'] . "', '$current_time', '$user_ip')";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update profile views', '', __LINE__, __FILE__, $sql);
}
$sql = "UPDATE " . USERS_TABLE . "
SET user_profile_views = user_profile_views + 1
WHERE user_id = '" . $profiledata['user_id'] . "'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update profile views', '', __LINE__, __FILE__, $sql);
}
}
//
// Retrieve the number of views
//
$sql = "SELECT user_profile_views
FROM " . USERS_TABLE . "
WHERE user_id = " . $profiledata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not retreive profile views', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$total_profile_views = ( $row['user_profile_views'] ) ? $row['user_profile_views'] : 0;
$db->sql_freeresult($result);
// Profile views MOD, By Manipe (End)
#
#-----[ FIND ]------------------------------------------
#
'YIM_IMG' => $yim_img,
'YIM' => $yim,
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Profile views MOD, By Manipe (Begin)
'L_PROFILE_VIEWS' => $lang['Profile_views'],
'PROFILE_VIEWS' => $total_profile_views,
// Profile views MOD, By Manipe (End)
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// That's all, Folks!
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Profile views MOD, By Manipe (Begin)
$lang['Profile_views'] = 'Profile Views';
// Profile views MOD, By Manipe (End)
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profile_view_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<tr>
<td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_JOINED}: </span></td>
<td width="100%"><b><span class="gen">{JOINED}</span></b></td>
</tr>
#
#-----[ BEFORE, ADD ]------------------------------------------
#
<tr>
<td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_PROFILE_VIEWS}: </span></td>
<td width="100%"><b><span class="gen">{PROFILE_VIEWS}</span></b></td>
</tr>
#
#-----[ OPEN ]------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]------------------------------------------
#
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Profile views MOD, By Manipe (Begin)
define('PROFILE_VIEWS_TABLE', $table_prefix.'profile_views');
// Profile views MOD, By Manipe (End)
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM