Jump to content
Sign in to follow this  
boxturt

Track Folder Hits

Recommended Posts

PDFs are hard to track, I know. I also know that I will not ask this question very well. I'll try.

 

 

PDF reports are prepared for clients and uploaded to a single folder. All pdf reports go here. The customer can login and retrieve only their report. This is done securely (fingers crossed) via a seperate window with a user / password combination. The file opens and the client has the option to save it. (I would rather it be a download only but... not my site)

 

Is there a way to get notified when this (either) event happens? A cron job that shoots the owner an email perhaps? Something similar. Perhaps I'm in way over my head? ;)

 

Thanks,

 

Ty

Share this post


Link to post
Share on other sites

Without writing your own download manager you should be able to find a suitable script on hotscripts.com

Share this post


Link to post
Share on other sites

Hi Ty.

Without knowing your site structure or exactly how you plan to organize the PDFs, I will say that it would be pretty easy to insert a PHP line in the top of the page. Let's pretend that you come in knowing the filename of the PDF in question. Something like this should do it:

 

<?php mail(Your_Email_Address, "PDF Accessed", PDF_File_Name, "From: PDF@yourdomain.tld"); ?>

 

Again, I don't know how the functionality is organized, but the notification is pretty straightforward. If you're concerned about the security of your email address you can put the actual code in a file in protected space and do an include. Put the above code in a file called PDFNotify.php in a safe place. Then in the top of your web page put:

 

<?php include("/your/safe/place/PDFNotify.php"); ?>

 

Make sense?

 

Of course if you have questions please ask. I'll help if I can.

Share this post


Link to post
Share on other sites

Um, what's that now? ;) Thanks. I think you're on the right track and I need to think along those lines. Each pdf is created uniquely for each customer and he/she doesn't know the filename. They just get to log in and they are served the correct document.

 

I shall now go put my grind to the nose-stone and see what shakes out! Thank you - I may be back. :(

 

Ty

Share this post


Link to post
Share on other sites

Phooey. I'm not having any luck. What I do have is another idea (though I still like the idea of being notified at the time of sign-in event better). The login script does have a log file and creates an entry every time someone signs in. Can I get that log automatically emailed once or twice a day? Granted the owner could just log on and view the file but it would be nicer if no user interaction were required.

 

Does that make sense? I've been looking for scripts but I seem to be out of luck or looking for the wrong thing. Probably the latter. :(

 

As always, thanks for any input. Much appreciated. ;)

Share this post


Link to post
Share on other sites

If it's just a text log file, and not too big, you can simply do the following in a cron job (which you can set to say once per day)

>/bin/mail -s "latest log file"  email@whatever.com < /home/username/mylogfile.log

where "latest log file" is the email subject and /home/username/mylogfile.log is the location of the log file.

 

If you want a little bit more finesse about it, so that for example it sends the email, then archives the log, so that each day you only get the days log. I'd write a small php script to send the email, and then call that from the cron job.

Share this post


Link to post
Share on other sites

ooh ooh ooh! I'll try that. :) The file is a small text file. I think this is exactly what I want. I like the idea of "finessing" it up but that may not be necessary. I think the owner would just be happy he doesn't need to log in every day to see it (the log).

 

Thanks! I'll try it now.

Share this post


Link to post
Share on other sites

(wouldn't let me edit...)

 

 

Didn't work but I think I set the path wrong.

 

 

"No such file or directory"

 

 

The log is in the cgi-bin so wouldn't the path be

 

>/bin/mail -s "latest log file"  email@whatever.com < /home/username/public_html/cgi-bin/folder/folder/access.log

 

What is the email@whatever.com for? Nothing went to the address I entered there. I entered a separate one in cpanel

 

Yup, changed the path (I forgot the public_html part) and it works. Thanks. :)

 

Also answered the question of 2 emails. The cpanel entry was where the error message went. The email@whatever.com is where the file was sent after a successful run. Good to know.

Edited by boxturt

Share this post


Link to post
Share on other sites

Glad it worked :)

 

Sorry, should have said that email@whatever.com was the email address you wanted to send it to

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...