Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases

Reply
 
Thread Tools
Who Downloaded This Attachment - for Gold Details »»
Who Downloaded This Attachment - for Gold
Version: 1.00, by Mr Blunt Mr Blunt is offline
Developer Last Online: Sep 2006 Show Printable Version Email this Page

Version: 3.0.0 Rating:
Released: 04-04-2004 Last Update: Never Installs: 12
 
No support by the author.

// **********************************************
// **********************************************
// Hack to track Who Downloaded attachments
// Old vb2 hack modified to vbulletin 3.0 Gold
// Credit to TWTCommish for the original vb2 hack
// https://vborg.vbsupport.ru/showthread.php?t=36900
// **********************************************
// **********************************************
4 new templates
2 modified templates
1 modified php file
1 new php file

This hack allows admins, supermods, and mods to see who downloads each file. If you want to allow other groups, just add/subtract them from whodownloaded.php on the top line as desired.

Although I rewrote and tested this myself, and it works like a charm now, I'm not offering support for this. I'm just a Joe Average. This is an old old hack. I just had to change some words like "gettemplate" to "fetch_template" and "dooutput" to "print_output" and one instance of "post" changed to "attachment". Also had to modify table structures and of course figure out where to put everything. I'm fairly certain that this is up-to-snuff but don't take my word for it.

It doesn't track IP's or how many times a user may have downloaded. It just brings up a popup window with the usernames that have downloaded this atachment. Who knows, maybe someone else will build upon this.

Forgive me if I posted this in the wrong place or if it shouldn't be here at all.
Mods, feel free to do what you wish with this.
Just trying to give a little back to those who have taught me.


// **********************************************
// create a new template - whodownloads
// **********************************************
Code:
<html>
<head>
<title>Who Downloaded This?</title>
$headinclude
<script language="JavaScript">self.focus();</script>
</head>
<body>

<table cellpadding="10" cellspacing="0" border="0" width="100%"><tr><td>

<table cellpadding="4" cellspacing="$stylevar[cellspacing]" border="0" width="100%">
	<tr>
		<td class="tcat" width="100%"><b>Total Downloads: $total</b></td>
	</tr>
	<tr>
		<td class="alt1" width="100%"><b>User</b></td>
	</tr>

$whodownloadsbit

	<tr id="cat">
		<td class="thead" width="100%" align="center"><a href="javascript:window.close();">Close Window</a></td>
	</tr>
</table>

</td></tr></table>
</body>
</html>

// **********************************************
// **********************************************
// create a new template - whodownloadsbit
// **********************************************
Code:
<tr>
		<td class="thead"><a href="member.php?s=$session[sessionhash]&action=getinfo&userid=$download[userid]" target="_blank">$download[username]</a></td>
</tr>

// **********************************************
// **********************************************
// create a new template - whodownloads_error
// **********************************************
Code:
<tr>
		<td class="thead">No downloads found.</td>
</tr>

// **********************************************
// **********************************************
// create a new template - whodownloads_error_nop
// **********************************************
Code:
<tr>
		<td class="thead">Sorry, no Permisson.</td>
</tr>

// **********************************************
// **********************************************
// Find this in template - headinclude
// **********************************************
Code:
<script type="text/javascript" src="clientscript/vbulletin_global.js"></script>
<if condition="$show['popups']"><script type="text/javascript" src="clientscript/vbulletin_menu.js"></script></if>
// **********************************************
// Change it to this
// **********************************************
Code:
<script type="text/javascript" src="clientscript/vbulletin_global.js"></script>
<if condition="$show['popups']"><script type="text/javascript" src="clientscript/vbulletin_menu.js"></script></if>
<script language="JavaScript">
	<!-- START HIDE
function whodownloaded(attachmentid)
{
	window.open
	("whodownloaded.php?s=$session[sessionhash]&attachmentid=" + attachmentid, "whodownloaded", "toolbar=no, scrollbars=yes, resizable=no, width=240, height=300, top=50, left=50");
}
  -->
</script>

// **********************************************
// **********************************************
// Find this in template - postbit_attachment
// **********************************************
Code:
<tr>
	<td><img class="inlineimg" src="$stylevar[imgdir_attach]/$attachment[attachmentextension].gif" alt="<phrase 1="$attachment[attachmentextension]">$vbphrase[file_type_x]</phrase>" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
	<td><a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank">$attachment[filename]</a> ($attachment[filesize], <phrase 1="$attachment[counter]">$vbphrase[x_views]</phrase></td>
</tr>
// **********************************************
// Change it to this
// **********************************************
Code:
<tr>
	<td><img class="inlineimg" src="$stylevar[imgdir_attach]/$attachment[attachmentextension].gif" alt="<phrase 1="$attachment[attachmentextension]">$vbphrase[file_type_x]</phrase>" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
	<td><a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank">$attachment[filename]</a> ($attachment[filesize], <phrase 1="$attachment[counter]">$vbphrase[x_views], </phrase></td>
	<td><a href="javascript:whodownloaded($attachment[attachmentid])">Who Downloaded This?</a>)</td>
</tr>

// **********************************************
// **********************************************
// create a new php file - whodownloaded.php
// place it in the main forum (upload) directory
// (same directory that has attachment.php)
// **********************************************
Code:
<?php
require("./global.php");

if (($bbuserinfo[usergroupid] == 6 OR $bbuserinfo[usergroupid] == 5 OR $bbuserinfo[usergroupid] == 7) AND $attachmentid)
{
	$downloads = $DB_site->query("SELECT u.userid, u.username FROM user u WHERE u.downloads LIKE \"$attachmentid%\" OR u.downloads LIKE \"%$attachmentid%\" OR u.downloads LIKE \"%$attachmentid\" ORDER BY u.username ASC");
	$total     = $DB_site->query_first("SELECT counter FROM attachment WHERE attachmentid = $attachmentid");
	$total     = $total[counter];

	if (!$DB_site->num_rows($downloads))
	{
		eval("\$whodownloadsbit .= \"".fetch_template("whodownloads_error",1,0)."\";");
	}
	else
	{
		while ($download = $DB_site->fetch_array($downloads))
		{
			eval("\$whodownloadsbit .= \"".fetch_template("whodownloadsbit",1,0)."\";");
		}
	}
}
else
{
	eval("\$whodownloadsbit .= \"".fetch_template("whodownloads_error_nop",1,0)."\";");
}

eval('print_output("' . fetch_template('whodownloads') . '");');

?>

// **********************************************
// **********************************************
// Find this in attachment.php
// **********************************************
Code:
			// or doing it once an hour
			$DB_site->shutdown_query("
				INSERT INTO " . TABLE_PREFIX . "attachmentviews (attachmentid)
				VALUES ($attachmentid)
			");
		}
	}
// **********************************************
// Change it to this
// **********************************************
Code:
			// or doing it once an hour
			$DB_site->shutdown_query("
				INSERT INTO " . TABLE_PREFIX . "attachmentviews (attachmentid)
				VALUES ($attachmentid)
			");
		}
	}
	// here's the who downloaded hack
	$dl    = $DB_site->query_first("SELECT downloads FROM user WHERE userid = $bbuserinfo[userid]");
	$comma = ($dl[downloads]) ? ',' : '';
	$DB_site->query("
		UPDATE user
		SET downloads = '$dl[downloads]$comma$attachmentid'
		WHERE userid = $bbuserinfo[userid]
	");

// **********************************************
// **********************************************
// Run this SQL Query from Admincp
// **********************************************
Code:
ALTER TABLE user ADD COLUMN downloads TEXT NOT NULL;
If you had this installed previously, like for vb2, then don't rerun the query.
The query didn't change so I'D SUSPECT the old and new data is compatible.

And make sure you have completely removed the old vb2 hack beforehand or I suspect this would create a conflict.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 02-07-2005, 06:43 PM
steadicamop's Avatar
steadicamop steadicamop is offline
 
Join Date: Jul 2004
Location: Lancashire, UK
Posts: 379
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I managed to get it working under 3.0.5, although I removed it as it didn't seem to be 100% functional, the link for the file also appeared twice, so I just removed a small piece of code from the bottom of it.

It's a shame as it's a handy hack to have installed.
Reply With Quote
  #23  
Old 02-23-2005, 02:22 AM
wi11ie1950 wi11ie1950 is offline
 
Join Date: Sep 2004
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It all works graet for me as it is without any fidling

Thanks Mr Blunt
Reply With Quote
  #24  
Old 04-29-2005, 09:33 PM
trulylowcarb's Avatar
trulylowcarb trulylowcarb is offline
 
Join Date: Apr 2004
Location: Colorado
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks! Working fine in vb3.07, was easy and fast to do, and I am tickled about it. Hard to gulp HARD before running that query but it looked harmless enough. I get a null error sometimes elsewhere on the forum, if only I understood what it was I did, LOL.

I do have the file name and download link repeated, after the Who Downloaded link and that seems unnecessary, so I am going to try to see if I can delete that part only -
Thanks Mr. Blunt!!
Reply With Quote
  #25  
Old 06-23-2005, 11:10 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Link14716 was absolutely right about mine being a 3.0.x duplicate.
I later found the other one which was definately released before mine.
My apologies ... I wish I had found it sooner.
Would have saved me a few days of work, lol.

https://vborg.vbsupport.ru/showthread.php?t=60500

So just in case someone gets an itch to port this into 3.5.0, you don't need MY permission. Instead you might take a look at the other thread and seek that author's permission (and/or -- TWTCommish's -- the real author's permission).

At first glance of 3.5.0 I think porting this might be over my head, but I might try soon if no one else does.
Reply With Quote
  #26  
Old 06-30-2005, 04:29 PM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, so scratch last post....
I ported this to vb3.5.0 and it appears to be working great!!


https://vborg.vbsupport.ru/showthread.php?t=93167
Reply With Quote
  #27  
Old 09-16-2005, 12:18 AM
TORON TORON is offline
 
Join Date: Jul 2002
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd like to see how many times a user has downloaded a file to catch users sharing accounts.

Does this show how many times a user downloaded?
Does this work with 3.0.9 ?
Reply With Quote
  #28  
Old 09-16-2005, 12:35 AM
Mr Blunt Mr Blunt is offline
 
Join Date: Jan 2004
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1) Yes
2) No

Check out the screenshots in the other thread.

Saves date, time, filename, fileid, userid, username, ipaddress, and alt_ip.
All this for every download.
None get overwritten, ever.

My latest version for vb350 ALSO IMPORTS all the data automatically from this old vb30x hack if you had it installed.

Honestly, I see no reason why anyone should stick with 3.0.x
3.5.0 friggin rocks!!
It's in it's final stages if you've been keeping tabs of it.

Not trying to be a jerk ... And please don't take it as me being a jerk because really I'm not .... But I think the ONLY way I would rewrite the 3.0.x version is if someone paid me money to do it .... in which case YES I WOULD because I am currently one broke mofo.
Reply With Quote
  #29  
Old 11-19-2005, 02:49 PM
LTW LTW is offline
 
Join Date: Jun 2005
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mr Blunt
My latest version for vb350 ALSO IMPORTS all the data automatically from this old vb30x hack if you had it installed.
Can i get a link to the 3.5 version please?

Can't seem to find it ...

Thanks

LTW
Reply With Quote
  #30  
Old 11-19-2005, 02:59 PM
LTW LTW is offline
 
Join Date: Jun 2005
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by LTW
Can i get a link to the 3.5 version please?

Can't seem to find it ...

Thanks

LTW
Nevermind ... found it ... https://vborg.vbsupport.ru/showthread.php?t=93167
Reply With Quote
Reply

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


All times are GMT. The time now is 02:41 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06799 seconds
  • Memory Usage 2,310KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (12)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete