473,385 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Stop hotlinking to a specific file & keeping a counter

Hi,
How can I stop hotlinking to a specific file, and I want it to redirect it to a PHP link so I
can monitor the number of downloads.

Here is my site with the download page:
http://www.adhal.org/software/downloads.htm

And here is softpedia directly connecting to my file and bypassing the counter php.
http://www.softpedia.com/get/File-ma.../HashNET.shtml

I am new to this, so excuse the ignorance. I do plan to read on it sooner or later. :)

I have seen examples of it using the .htaccess, but it deals with mimes. I want actually stop
hotlinking to a specific file which I want to redirect to another specified link (My PHP Counter link).

Thanks for taking time to look a this

--
Adhal Freeware
http://www.adhal.org
Jun 27 '08 #1
13 1997
On 25 Jun, 15:05, Adhal <f...@email.comwrote:
Hi,
* * How can I stop hotlinking to a specific file, and I want it to redirect it to a PHP link so I
can monitor the number of downloads.

Here is my site with the download page:http://www.adhal.org/software/downloads.htm

And here is softpedia directly connecting to my file and bypassing the counter php.http://www.softpedia.com/get/File-ma.../HashNET.shtml

I am new to this, so excuse the ignorance. I do plan to read on it sooneror later. :)

I have seen examples of it using the .htaccess, but it deals with mimes. I want actually stop
hotlinking to a specific file which I want to redirect to another specified link (My PHP Counter link).

Thanks for taking time to look a this

--
Adhal Freewarehttp://www.adhal.org
You could change the location of your file and use .htaccess to map
the current file name to your php script, which would at its end,
deliver the real file as payload.
Jun 27 '08 #2
>--
>Adhal Freewarehttp://www.adhal.org

You could change the location of your file and use .htaccess to map
the current file name to your php script, which would at its end,
deliver the real file as payload.
Thanks but ahem, I don't know how to that. Would URLBar display the actual location of the file?
In truth I would prefer it, if the HTTP_REFERER is not from

http://www.adhal.org/software/downloads.htm
or
http://www.adhal.org/ccount/click.php?id=1

Then redirect it to

http://www.adhal.org/ccount/click.php?id=1

So I don't have to worry if they actually get access to the correct file path. I am I gave softpedia
my PHP link, but they connected directly to my file.

Or a better way is a cgi-script that monitors all file access. That would be cool, but I have no
clue if it is possible. I am new to web creation and trying to feel my way around.
Jun 27 '08 #3
John Smith is the me also. I should remove that card
--
Adhal Freeware
http://www.adhal.org
Jun 27 '08 #4
Adhal escribió:
How can I stop hotlinking to a specific file, and I want it to
redirect it to a PHP link so I
can monitor the number of downloads.

Here is my site with the download page:
http://www.adhal.org/software/downloads.htm

And here is softpedia directly connecting to my file and bypassing the
counter php.
http://www.softpedia.com/get/File-ma.../HashNET.shtml

I am new to this, so excuse the ignorance. I do plan to read on it
sooner or later. :)

I have seen examples of it using the .htaccess, but it deals with mimes.
I want actually stop
hotlinking to a specific file which I want to redirect to another
specified link (My PHP Counter link).
If your web server is Apache and you want a transparent redirect then
you can use mod_rewrite. If the link is...

http://www.adhal.org/files/HashNET.zip

.... you can create an .htaccess file inside "files" with something like:

RewriteEngine On

RewriteBase /
RewriteRule ^HashNET\.zip$ path/to/counter.php?param=whatever [NC,L]
The exact rule depends on how counter.php works but this should give you
an idea.

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jun 27 '08 #5
On 25 Jun, 16:13, John Smith <u...@example.netwrote:
--
Adhal Freewarehttp://www.adhal.org
You could change the location of your file and use .htaccess to map
the current file name to your php script, which would at its end,
deliver the real file as payload.

Thanks but ahem, I don't know how to that. Would URLBar display the actual location of the file?
Sorry, in future I will only answer your questions with answers that
you already know, will that help?
I would send the payload using readfile(), so the browser would
continue to show the address that was linked to.
>
In truth I would prefer it, if the HTTP_REFERER is not from
You may prefer that, but since HTTP_REFERER is not reliable (indeed
not always set), you've dipped.

Jun 27 '08 #6
Álvaro G. Vicario wrote:
like:
>
RewriteEngine On

RewriteBase /
RewriteRule ^HashNET\.zip$ path/to/counter.php?param=whatever [NC,L]
The exact rule depends on how counter.php works but this should give you
an idea.
Thanks Álvaro, works a treat. :)
--
Adhal Freeware
http://www.adhal.org
Jun 27 '08 #7
Captain Paralytic wrote:
Sorry, in future I will only answer your questions with answers that
you already know, will that help?

I am new to web creation so I was expecting a bit more detail or link. Anyhow, thanks for your reply.

--
Adhal Freeware
http://www.adhal.org
Jun 27 '08 #8
Adhal wrote:
Captain Paralytic wrote:
>Sorry, in future I will only answer your questions with answers that
you already know, will that help?


I am new to web creation so I was expecting a bit more detail or link.
Anyhow, thanks for your reply.
Welcome to the world of web programming! :-) Yes, we do get a little
terse here sometimes. We don't know how experienced you are, and it
saves what could be a lot of unnecessary typing (and our time).

Two things. First of all, if at all possible, place the file outside of
your DOCUMENT_ROOT (the root directory of your web server). Many
hosting companies allow you to have files and/or directories above the
root directory, i.e.
mysite
html otherdir

In a case like this, you would upload your web files to mysite/html, and
this would be the root directory of your website. You could place other
files in mysite, or create another directory mysite/otherdir to store
the files (my preference).

Now, any files in mysite/otherdir will be inaccessible directly from the
internet. But you can use readfile() to access the file, i.e. if the
file were "myfile.html",

readfile($_SERVER['DOCUMENT_ROOT'] . '/../otherdir/myfile.html');

($SERVER['DOCUMENT_ROOT'] always points at the root directory of your
webserver, then you go up one directory and down to otherdir).

This would go in the page with your counter; besides incrementing the
counter, it will send the file to the user. The only other thing you
need to do is set the correct content - see the header() function for
info on this.

However, there is an easier way than all this. You should have access
to the web server's logs for your site (good hosting companies will
provide this). You can see directly from the logs exactly how many
times the file has been downloaded.

However, remember one thing - these counters are not accurate. A file
or page may be cached by any server between you and the user, and the
file/page served from the cache. This cuts down on internet traffic,
but means you won't see the request.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #9
Jerry Stuckle wrote:
>
However, remember one thing - these counters are not accurate. A file
or page may be cached by any server between you and the user, and the
file/page served from the cache. This cuts down on internet traffic,
but means you won't see the request.
Thanks Jerry. I really do appreciate the input.

I am totally new to PHP, and other web scripting languages; I am coming
for windows application developer.

I do plan to study it, as soon as I get C# and .NET framework out of the
way. I already know a bit of HTML, XHTML and CSS. My level of server
scripting is about zero, I tend to do a hatch job of it.

Just out of curiosity what would you recommend the study path I take.
Once I have time I am thinking of delving deeper into HTML, XHTML, CSS
and then PHP.

I don't think I will study Perl or any other scripting language
(excluding ASP.NET). From my understanding PHP is all one needs for a
personal site hosted on linux.

--
Adhal Freeware
http://www.adhal.org
Jun 27 '08 #10
Adhal wrote:
Jerry Stuckle wrote:
>>
However, remember one thing - these counters are not accurate. A file
or page may be cached by any server between you and the user, and the
file/page served from the cache. This cuts down on internet traffic,
but means you won't see the request.

Thanks Jerry. I really do appreciate the input.

I am totally new to PHP, and other web scripting languages; I am coming
for windows application developer.

I do plan to study it, as soon as I get C# and .NET framework out of the
way. I already know a bit of HTML, XHTML and CSS. My level of server
scripting is about zero, I tend to do a hatch job of it.

Just out of curiosity what would you recommend the study path I take.
Once I have time I am thinking of delving deeper into HTML, XHTML, CSS
and then PHP.

I don't think I will study Perl or any other scripting language
(excluding ASP.NET). From my understanding PHP is all one needs for a
personal site hosted on linux.
I wouldn't worry too much about XHTML - too many browsers (i.e. IE)
don't support it well. Just stick with HTML, CSS and PHP. You'll also
want SQL for database work.

HTML is pretty easy. Some people say don't worry about CSS right off
the bat, but you can do a lot with simple CSS. It can, however, get
pretty complicated at times. So for now, just stick with simple stuff
until you're more comfortable with it.

And, of course, PHP.

Perl is nice to know - but I wouldn't worry about it much until you get
your hands around PHP.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #11
Adhal wrote:
Jerry Stuckle wrote:
>>
However, remember one thing - these counters are not accurate. A file
or page may be cached by any server between you and the user, and the
file/page served from the cache. This cuts down on internet traffic,
but means you won't see the request.

Thanks Jerry. I really do appreciate the input.

I am totally new to PHP, and other web scripting languages; I am coming
for windows application developer.

I do plan to study it, as soon as I get C# and .NET framework out of the
way. I already know a bit of HTML, XHTML and CSS. My level of server
scripting is about zero, I tend to do a hatch job of it.

Just out of curiosity what would you recommend the study path I take.
Once I have time I am thinking of delving deeper into HTML, XHTML, CSS
and then PHP.

I don't think I will study Perl or any other scripting language
(excluding ASP.NET). From my understanding PHP is all one needs for a
personal site hosted on linux.
I wouldn't worry too much about XHTML - too many browsers (i.e. IE)
don't support it well. Just stick with HTML, CSS and PHP. You'll also
want SQL for database work.

HTML is pretty easy. Some people say don't worry about CSS right off
the bat, but you can do a lot with simple CSS. It can, however, get
pretty complicated at times. So for now, just stick with simple stuff
until you're more comfortable with it.

And, of course, PHP.

Perl is nice to know - but I wouldn't worry about it much until you get
your hands around PHP.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #12
On Jun 25, 4:13 pm, John Smith <u...@example.netwrote:
--
Adhal Freewarehttp://www.adhal.org
You could change the location of your file and use .htaccess to map
the current file name to your php script, which would at its end,
deliver the real file as payload.

Thanks but ahem, I don't know how to that. Would URLBar display the actual location of the file?

In truth I would prefer it, if the HTTP_REFERER is not from

http://www.adhal.org/software/downloads.htm
orhttp://www.adhal.org/ccount/click.php?id=1

Then redirect it to

http://www.adhal.org/ccount/click.php?id=1

So I don't have to worry if they actually get access to the correct file path. I am I gave softpedia
my PHP link, but they connected directly to my file.

Or a better way is a cgi-script that monitors all file access. That would be cool, but I have no
clue if it is possible. I am new to web creation and trying to feel my way around.
You should never rely on the referer [sic] being presented or even
valid.

Use a session cookie (not neessarily a PHP session)

C.
Jun 27 '08 #13
Thanks for that. :-)

--
Adhal Freeware
http://www.adhal.org

There are only 10 types of people in the world: Those who understand binary, and those who don't.
Jun 27 '08 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Pernell Williams | last post by:
Hi all: Thank you for your responses. I have a more specific question about "file.seek() and file.readline()" versus "file.seek() and file.xreadlines". When I have the following code:
17
by: andre.gunther | last post by:
Hello, unfortunately I am a customer of Yahoo Webhosting. They don't offer scripting or any meaningful server controls. I have a photo website and I have serious problems with leachers now....
1
by: Brett | last post by:
I have several controls on a form. Each control has various events. The flow may go like this: control1.event1 control2.event1 control1.event2 control3.event1 How can I stop this chain in...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
17
by: Jonathan Pritchard | last post by:
I know this is a simple problem, but I've just included this in the title because it explains what my program tries to do. The following does not work, it for someone reason does not want to...
19
by: pkirk25 | last post by:
I wonder if anyone has time to write a small example program based on this data or to critique my own effort? A file called Realm List.html contains the following data: Bladefist-Horde...
16
by: WATYF | last post by:
Hi there... I have a huge text file that needs to be processed. At the moment, I'm loading it into memory in small chunks (x amount of lines) and processing it that way. I'd like the process to be...
3
by: blindlemon1983 | last post by:
php version - 4.4.4 mysql version - 4.1.22 Previously I tried to prevent hotlinking of images on a clients site using .htaccess and mod_rewrite. It however didn't work for some reason or other...
0
by: RobertTheProgrammer | last post by:
Hi folks, I need to combine these two functions and I'm not sure how to go about it. I know how to use .htaccess to prevent anyone from hotlinking the images on my site. What I basically want...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.