Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > Free Torrent Source > Mods & Themes
Reply
  #1  
Old 15th September 2009, 20:18
Edgein's Avatar
Edgein Edgein is offline
Senior Member
 
Join Date: Sep 2008
Netherlands
Posts: 154
Smile [FTS 1.1] userhits in profile
this mod will show the number of times a user's profile has been viewed, and by who.

First the database

PHP Code:
CREATE TABLE `userhits` (
  `
idint(10unsigned NOT NULL auto_increment,
  `
useridint(10unsigned NOT NULL default '0',
  `
hitidint(10unsigned NOT NULL default '0',
  `
numberint(10unsigned NOT NULL default '0',
  `
addeddatetime NOT NULL default '00-00-00 00:00:00',
  
PRIMARY KEY (`id`)
); 
then add
PHP Code:
ALTER TABLE `usersADD `hitsint(10NOT NULL default '0'
then in userdetails.php find

PHP Code:
$id $_GET["id"];
int_check($id,true);
if(
$id != $CURUSER['id'])
if(
$usergroups['canviewotherprofile'] != 'yes')
 
ug();
$r = @sql_query("SELECT * FROM users WHERE id=".mysql_real_escape_string($id)) or sqlerr(__FILE____LINE__);
$user mysql_fetch_array($r) or bark(str11);
if (
$user["status"] == "pending")
    die; 
and add after it

PHP Code:
if (!$_GET["hit"] && $CURUSER["id"] <> $user["id"]) {
  
$res mysql_query("SELECT added FROM userhits WHERE userid = $CURUSER[id] AND hitid = $id LIMIT 1") or sqlerr(); // *3
  
$row mysql_fetch_row($res); // *3
  
if ($row[0] > get_date_time(gmtime() - 3600)) { // *3
        
header("Location: $BASEURL$_SERVER[REQUEST_URI]&hit=1"); // *3
  
} else { // *3
//  $hitnumber = $userhits + 1; // *1
        
$hitnumber $user["hits"] + 1// *2
        
mysql_query("UPDATE users SET hits = hits + 1 WHERE id = $id") or sqlerr(); // *2
        
mysql_query("INSERT INTO userhits (userid, hitid, number, added) VALUES($CURUSER[id]$id$hitnumber, '".get_date_time()."')") or sqlerr();
        
header("Location: $BASEURL$_SERVER[REQUEST_URI]&hit=1");
  } 
// *3

then find in userdetails.php

PHP Code:
    $ip_res sql_query("SELECT * FROM ips WHERE userid = $id") or die(mysql_error());

    print(
"<tr><td class=rowhead>".str47."</td><td align=left>");
    while (
$arr mysql_fetch_assoc($ip_res)) {
        echo 
$arr[ip] ::";
    }
    print(
"</td></tr>\n"); 
And add above

PHP Code:
print("<tr><td class=rowhead>Profile views</td><td align=left><a href=userhits.php?id=$id>".number_format($user["hits"])."</a></td></tr>\n"); 
Create userhits.php:
PHP Code:
<?
require_once("include/bittorrent.php");
dbconn();
loggedinorreturn();

$id $_GET["id"];

if (!
is_valid_id($id) || $CURUSER["id"] <> $id && get_user_class() < UC_MODERATOR)
  
$id $CURUSER["id"];

$res mysql_query("SELECT COUNT(*) FROM userhits WHERE hitid = $id") or sqlerr();
$row mysql_fetch_row($res);
$count $row[0];
$perpage 100;
list(
$pagertop$pagerbottom$limit) = pager($perpage$count"?id=$id&");

if (!
$count)
  
stderr("No views""This user has had no profile views yet.");

$res mysql_query("SELECT username FROM users WHERE id = $id") or sqlerr(); // remove 'hits' if you do NOT use the cleanup code
$user mysql_fetch_assoc($res);

stdhead("Profile views of $user[username]");
print(
"<h1>Profile views of <a href=\"userdetails.php?id=$id\">$user[username]</a></h1>\n");
print(
"<h2>In total $count views</h2>\n"); // replace $user[hits] with $count if you do NOT use the cleanup code
if ($count $perpage)
  print(
"$pagertop");
print(
"<table border=0 cellspacing=0 cellpadding=5>\n");
print(
"<tr><td class=colhead>Nr.</td><td class=colhead>Username</td><td class=colhead>Viewed at</td></tr>\n");

$res mysql_query("SELECT uh.*, username, users.id as uid FROM userhits uh LEFT JOIN users ON uh.userid = users.id WHERE hitid = $id ORDER BY uh.id DESC") or sqlerr();
while (
$arr mysql_fetch_assoc($res))
  print(
"<tr><td>".number_format($arr["number"])."</td><td><b><a href=\"userdetails.php?id=$arr[uid]\">$arr[username]</a></b></td><td>$arr[added]</td></tr>\n");

print(
"</table>\n");
if (
$count $perpage)
  print(
"$pagerbottom");
stdfoot();
?>
good luck
grtzz edgein

Big thanx to the original makers
Reply With Quote
The Following 4 Users Say Thank You to Edgein For This Useful Post:
benjaminbih (21st December 2009), Daz (4th February 2010), Moh.ElBaz (21st December 2009), Phogo (15th September 2009)
  #2  
Old 14th December 2009, 01:32
benjaminbih's Avatar
benjaminbih benjaminbih is offline
Senior Member
 
Join Date: Jul 2008
Bosnia-Herzegovina
Posts: 70
Default
thank you
Reply With Quote
  #3  
Old 21st December 2009, 04:37
yoligim's Avatar
yoligim yoligim is offline
Senior Member
 
Join Date: Nov 2009
Spain
Posts: 43
Default
Done, thank you Edgein for your posts
Reply With Quote
  #4  
Old 16th January 2010, 22:29
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default
And if you want old hits to be removed add this to cleanup.php:

Quote:
// Remove userprofile views
$days = 7;
$dt = sqlesc(get_date_time(gmtime() - ($days * 68400)));
mysql_query("DELETE FROM userhits WHERE added < $dt");
Reply With Quote
The Following User Says Thank You to elvira For This Useful Post:
Phogo (18th January 2010)
  #5  
Old 19th July 2017, 03:02
aidzis7's Avatar
aidzis7 aidzis7 is offline
Member
 
Join Date: Jan 2008
Posts: 1
Default
Thank you
But how to add (tzoffset) time zone code?
Reply With Quote
Reply

Tags
11 , fts , profile , userhits

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New profile layout in phpMyBitTorrent joeroberts Community Cafe 1 7th June 2010 00:48
Group image in user profile cop1976 Mods & Themes 0 17th February 2010 03:57
Owner change profile ciobancai Template Shares 0 4th May 2009 23:28
Hide profile PuterDude Torrent Strike 6 6th October 2008 15:58



All times are GMT +2. The time now is 08:19. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.