Who has downloaded

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)
Ideas Centre
Locked
BRUNOVC
Registered User
Posts: 11
Joined: Sat Nov 01, 2008 11:28 pm

Who has downloaded

Post by BRUNOVC »

Hi there...

Is there any function or mod that let's me know who has downloaded any attachment???

I have many attachments in my forum and the number of downloads is much bigger than the posts number, so I'd like to know who is downloading that attachments without posting something.

Thanks in advance..

PS.: sorry by my bad English.

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

Re: Who has downloaded

Post by John P »

In file file.php in map download I put before send_file_to_browser($attachment, $config['upload_path'], $display_cat); the following script using phpmailer:

Code: Select all

        require("../../js/class.phpmailer.php");
          
        $to = 'info@mydomain.nl';
        $subject = "File donwloaded";
        $message = '<br><br><table width="90%" height="90%" border="0" cellpadding="1" cellspacing="0" align="center">
                    <tr>
                    <td>'.$attachment['real_filename'].' is downloaded by'.$user->data['username'].'.<br><br>
                    <br><br><br>
                    His IP address: '.$user->data['session_ip'].'<br>
                    </td>
                    </tr>
                    </table>';
                        
        $mail = new PHPMailer();
        $mail->From = "info@mydomain.nl";
        $mail->FromName = "Info www.mydomain.nl";
        $mail->AddAddress($to);
        $mail->AddReplyTo("info@mydomain.nl", "Info www.mydomain.nl");
        $mail->Priority = 1;
        $mail->WordWrap = 50;
        $mail->IsHTML(true);
        $mail->Subject = $subject;
        $bericht = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
        $bericht .= "<HTML><BODY bgcolor=\"#FFFFFF\" text=\"#536482\" alink=\"#536482\" link=\"#536482\" vlink=\"#536482\">\n";
        $bericht .= $message;
        $bericht .= "</BODY></HTML>\n"; 
        $mail->Body = $bericht;
        $mail->Send(); 
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign

BRUNOVC
Registered User
Posts: 11
Joined: Sat Nov 01, 2008 11:28 pm

Re: Who has downloaded

Post by BRUNOVC »

Thanks for the reply, but doesn't work.

I'm getting this error when I tried to download a file:

[phpBB Debug] PHP Notice: in file /download/file.php on line 322: require(../../js/class.phpmailer.php) [function.require]: failed to open stream: No such file or directory
[phpBB Debug] PHP Notice: in file /download/file.php on line 322: require(../../js/class.phpmailer.php) [function.require]: failed to open stream: No such file or directory

Any idea?

Bruno

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

Re: Who has downloaded

Post by John P »

Download class.phpmailer.php and install it on your webserver.
Google is your friend.

Then adjust the path where you installed the class.


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

BRUNOVC
Registered User
Posts: 11
Joined: Sat Nov 01, 2008 11:28 pm

Re: Who has downloaded

Post by BRUNOVC »

Thanks for the help...

Its working fine now...

But I have one more question:

It is possible to know from what topic is the attachment?

Again, thanks for the help.

Bruno.

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

Re: Who has downloaded

Post by John P »

Sure, in the attachmentstable you will find the topic_id and post_msg_id.
Run another query to find the title of the message or topic and insert it into your email-message or expand the select query with a join to find out the topictitle in one run.
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign

BRUNOVC
Registered User
Posts: 11
Joined: Sat Nov 01, 2008 11:28 pm

Re: Who has downloaded

Post by BRUNOVC »

Could you show me how the code looks like?

I'm just beginning in php and don't know exactly how to do that !!!

Very thanks for the help...

Bruno.

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

Re: Who has downloaded

Post by John P »

Change

Code: Select all

$sql = 'SELECT attach_id, is_orphan, in_message, post_msg_id, extension, physical_filename, real_filename, mimetype
    FROM ' . ATTACHMENTS_TABLE . "
    WHERE attach_id = $download_id"; 
in

Code: Select all

$sql = 'SELECT a.attach_id, a.is_orphan, a.in_message, a.post_msg_id, a.extension, a.physical_filename, a.real_filename, a.mimetype, b.topic_title 
    FROM ' . ATTACHMENTS_TABLE . ' a 
    LEFT JOIN ' . TOPICS_TABLE . ' b ON (a.topic_id = b.topic_id)
    WHERE attach_id = ' . $download_id; 
in $attachment['topic_title'] you will find your topic_title.

Backup your file first!

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

BRUNOVC
Registered User
Posts: 11
Joined: Sat Nov 01, 2008 11:28 pm

Re: Who has downloaded

Post by BRUNOVC »

Thanks Stef775.

Your code is perfect for what I need.

It's working exactly as expecteded :D

Bruno

ximpdbydefault
Registered User
Posts: 33
Joined: Sun Feb 05, 2006 8:13 am

Re: Who has downloaded

Post by ximpdbydefault »

Pretty sweet,
I havent tried it yet but curious if one could exclude the email option and make a edit to that post.
Something like:

Users who have downloaded this file/attachment:
User1, User2, Bob, User3


Because a board of 400+ users @ 1000+ attachments, it will take me a good part of my waking hours to view these emails.

Locked

Return to “[3.0.x] MOD Requests”