473,769 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2026
On 25 Jun, 15:05, Adhal <f...@email.com wrote:
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?par am=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.n etwrote:
--
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?par am=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.htm l",

readfile($_SERV ER['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*******@attgl obal.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

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

Similar topics

2
3361
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
3336
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. Those guys at xanga.com hotlink to my free desktop wallpapers, thus generating a lot of traffic. I need to block this somehow, but I have no idea how to do it on the yahoo webhosting (I am not even sure if they are running apache or IIS). Does...
1
1166
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 control2.event1? I'd like to stop the entire process and return control to the form.
14
5935
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 because of this, so I hope some of you gurus can enlighten me with this :) In what circumstances can the "&amp;" in the source code be involuntary changed to "&" by a browser when or other software, when editing and uploading the file to the web...
17
6357
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 place the values on a new line. ======================================================================= #include <stdio.h> #include <conio.h> int main(void)
19
3113
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 Nordrassil-Horde Draenor-Alliance Nordrassil-Alliance Nordrassil-Neutral Draenor-Horde
16
15568
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 faster, so I'd like to try creating multiple threads, and having them load different chunks of the file at the same time and process it asynchronously. Is it possible to do something like that, and if so, what would be needed to do so?
3
2448
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 and I decided to do hotlinking protection using php. I'm really new to php. I've seen code like the following <img src="display.php?id=1898" border="0" /> and have been trying to do this for the site based on this post <Link removed>. I'm having...
0
1954
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 to do is to (1) prevent anyone, anywhere from hotlinking my images and (2) prevent anyone from MySpace from hotlinking to my site at all (whether images or otherwise). Now I currently have my .htaccess like this: RewriteEngine on
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7404
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.