Mod To tell which users are downloading files

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Scam Warning
Locked
mreidiv
Registered User
Posts: 5
Joined: Mon Dec 31, 2012 7:51 pm

Mod To tell which users are downloading files

Post by mreidiv » Sun Mar 03, 2013 8:19 pm

Can we ge a mod to keep a log of which users downloaded what files. maybe put in in the acp user logs

User avatar
martin123456
I've Been Banned!
Posts: 726
Joined: Sat Mar 05, 2011 7:44 pm

Re: Mod To tell which users are downloading files

Post by martin123456 » Sun Mar 03, 2013 10:19 pm

Code: Select all

<!-- IF S_CODE_UNTIDY and S_MESS_ON_INDEX Good If_Not_TIDY_Then_SUBMIT -->

User avatar
John P
Registered User
Posts: 1237
Joined: Mon Jan 21, 2008 3:55 pm
Location: Netherlands
Name: John
Contact:

Re: Mod To tell which users are downloading files

Post by John P » Sun Mar 03, 2013 10:26 pm

In download.php in function send_file_to_browser

Code: Select all

add_log('admin', 'LOG_DOWNLOAD_SUCCES', $attachment['physical_filename']);
Think before the database connection get's closed.

Enter a language entry for 'LOG_DOWNLOAD_SUCCES'

Greetz
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign

User avatar
Jessica
Former Team Member
Posts: 4341
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: Mod To tell which users are downloading files

Post by Jessica » Mon Mar 04, 2013 2:11 am

That mod doesn't keep a log of what users downloaded
Please do not PM me for support unless it is absolutely necessary
Pro-choice, Atheist, Pro-LGBT rights

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

maxrpg
Registered User
Posts: 67
Joined: Thu Jul 30, 2009 12:33 am

Re: Mod To tell which users are downloading files

Post by maxrpg » Mon Mar 04, 2013 5:19 am

I have a similar thing on my site that keeps a log of users that have downloaded a file(s). When a user downloads a file it logs it in the database and the admin can see a "View Log" link below the attachment in a post which displays a list of users that have downloaded that file and when they downloaded it. It only logs a user once per file so you dont end up with loads of entries for a user if they download the same file several times.

May not be exactly what you were after but it does the job lol.

Image
https://camo.phpbb.com/1e54d9c99b5117b32e4ddbc0462515833cc526ba/687474703a2f2f6f6934362e74696e797069632e636f6d2f6662767063772e6a7067

You just have to create a new database table, do a few small file edits and upload.

http://sdrv.ms/XVNjTb

Hope you find it useful :)
Last edited by maxrpg on Wed Mar 06, 2013 11:40 am, edited 1 time in total.

mreidiv
Registered User
Posts: 5
Joined: Mon Dec 31, 2012 7:51 pm

Re: Mod To tell which users are downloading files

Post by mreidiv » Tue Mar 05, 2013 7:54 pm

maxrpg wrote:I have a similar thing on my site that keeps a log of users that have downloaded a file(s). When a user downloads a file it logs it in the database and the admin can see a "View Log" link below the attachment in a post which displays a list of users that have downloaded that file and when they downloaded it. It only logs a user once per file so you dont end up with loads of entries for a user if they download the same file several times.

May not be exactly what you were after but it does the job lol.

Image
https://camo.phpbb.com/1e54d9c99b5117b32e4ddbc0462515833cc526ba/687474703a2f2f6f6934362e74696e797069632e636f6d2f6662767063772e6a7067

You just have to create a new database table, do a few small file edits and upload.

http://sdrv.ms/WCqrbg

Hope you find it useful :)
Now that is what i was looking for thankyou i ll try to install it later and report back

User avatar
martin123456
I've Been Banned!
Posts: 726
Joined: Sat Mar 05, 2011 7:44 pm

Re: Mod To tell which users are downloading files

Post by martin123456 » Wed Mar 06, 2013 12:49 am

It works but kicks up a debug

Page: downloaders.php?file=79 File: [ROOT]/downloaders.php Line: 38 [PHP Notice] Undefined variable: topics_result

line 38 $db->sql_freeresult($topics_result);

Note this is with all debugs on in he config.php

Code: Select all

{
		$sql = 'SELECT d.user_id, d.down_date, u.user_id, u.username, u.user_colour
		FROM ' . DOWNLOADS_LOG . ' d, ' . USERS_TABLE . ' u
		WHERE u.user_id = d.user_id AND file_id = '. $fileid .'
		ORDER BY d.down_date DESC';
		$top_result =$db->sql_query_limit($sql, 15);


		while($row = $db->sql_fetchrow($top_result))
    	{
		      
       		$template->assign_block_vars('downloaders',array(
				'D_USERNAME'			=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
				'D_TIME'				=> $user->format_date($row['down_date'])
			
			));
			
    	
        $db->sql_freeresult($topics_result);
		}
}
Last edited by martin123456 on Wed Mar 06, 2013 1:14 am, edited 2 times in total.

Code: Select all

<!-- IF S_CODE_UNTIDY and S_MESS_ON_INDEX Good If_Not_TIDY_Then_SUBMIT -->

User avatar
ViolaF
Registered User
Posts: 1441
Joined: Tue Aug 14, 2012 11:52 pm

Re: Mod To tell which users are downloading files

Post by ViolaF » Wed Mar 06, 2013 1:05 am

Jessica wrote:
That mod doesn't keep a log of what users downloaded
But its only a line of code to do it. I think martin means that its possible with this example. OPs may can think about it or have it as an inspiration.

maxrpg
Registered User
Posts: 67
Joined: Thu Jul 30, 2009 12:33 am

Re: Mod To tell which users are downloading files

Post by maxrpg » Wed Mar 06, 2013 11:43 am

martin123456 wrote:It works but kicks up a debug

Page: downloaders.php?file=79 File: [ROOT]/downloaders.php Line: 38 [PHP Notice] Undefined variable: topics_result

line 38 $db->sql_freeresult($topics_result);

Note this is with all debugs on in he config.php

Code: Select all

{
		$sql = 'SELECT d.user_id, d.down_date, u.user_id, u.username, u.user_colour
		FROM ' . DOWNLOADS_LOG . ' d, ' . USERS_TABLE . ' u
		WHERE u.user_id = d.user_id AND file_id = '. $fileid .'
		ORDER BY d.down_date DESC';
		$top_result =$db->sql_query_limit($sql, 15);


		while($row = $db->sql_fetchrow($top_result))
    	{
		      
       		$template->assign_block_vars('downloaders',array(
				'D_USERNAME'			=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
				'D_TIME'				=> $user->format_date($row['down_date'])
			
			));
			
    	
        $db->sql_freeresult($topics_result);
		}
}
Ok I fixed the bug and changed the download link in the original post to the fix files. I put it together quite quickly so little glitches would be expected lol nothing too serious though :P

User avatar
martin123456
I've Been Banned!
Posts: 726
Joined: Sat Mar 05, 2011 7:44 pm

Re: Mod To tell which users are downloading files

Post by martin123456 » Wed Mar 06, 2013 12:51 pm

Seems ok to me i also had to add TEMPLATE to my lang common.php but yeah its working as it should now thanx.

Code: Select all

<!-- IF S_CODE_UNTIDY and S_MESS_ON_INDEX Good If_Not_TIDY_Then_SUBMIT -->

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Mod To tell which users are downloading files

Post by RMcGirr83 » Thu Mar 07, 2013 11:19 am

this

WHERE u.user_id = d.user_id AND file_id = '. $fileid .'

should be this

WHERE u.user_id = d.user_id AND d.file_id = '. (int) $fileid .'

and this

$db->sql_freeresult($topics_result);

should be this

$db->sql_freeresult($top_result);

and this

<a href="./downloaders.php?file={_file.U_FILE_ID}" onclick="popup(this.href, 480, 350); return false;" title="Downloads Log" >View Log</a>

should be using the append_sid function with this in the downloaders.php file

$user->session_begin();

set to false
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

Locked

Return to “[3.0.x] MOD Requests”

cron