Forum Moderators: phranque

Message Too Old, No Replies

Rewrite: Challenge

         

NumberSix

8:53 pm on May 30, 2011 (gmt 0)

10+ Year Member



Here is my thing. Let's assume I have a file

sampledomain.com/files/important.zip

Now. Registered user #1 (with IP: 23.122.34.116)
logs in. I want to display a link for him to download the file. (using PHP)

sampledomain.com/some_encrypted/_combo_based/_onIP_key.zip
(ex: 47jf/2340/2340924jf.zip)

Registered user #2 (with IP: 156.12.33.1)
logs in. I want to display a link for him to download the file.
(using PHP)

sampledomain.com/some_encrypted/_combo_based/_onIP_key.zip
(ex: 234d/6743/d7896sdfh.zip)

When either of them click their respective link. ReWrite appends the 3 pieces together (Ex for user #1: 47jf23402340924jf.zip), decodes (using IP as key) and then downloads the file (wihtout revealing the true path).

User #1 can't simply send a link to a friend to download the file because their IPs are different. File won't exist for Friend of User #1.

IP is really the maximum security I need. Nothing more. Just forces people to register to get a link to the file.

Hope I am clear. It's not easy to explain.
I am probably looking at this backwards.

C.

[edited by: NumberSix at 9:03 pm (utc) on May 30, 2011]

g1smd

9:00 pm on May 30, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use "example.com" in the forum to avoid URL auto-linking.

The "owner edit" button is just below your user name.

lucy24

10:38 pm on May 30, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



User #1 can't simply send a link to a friend to download the file because their IPs are different. File won't exist for Friend of User #1.

Yes, it will, because as soon as User #1 downloads it he can attach it to an email, put it in his own www space, et cetera. So it's not the file but merely your original download link that won't exist.

NumberSix

12:41 am on May 31, 2011 (gmt 0)

10+ Year Member



"User #1 can't simply send a link to a friend to download the file because their IPs are different. File won't exist for Friend of User #1."

"Yes, it will".

I never said anything about sending attachments, or them hosting it.
All I care about is: MY LINK. File contents are not private.
What happens with the file after they get it. I don't care.

Assume a closed registration system, the package will not exist on my server to anyone outside the group. You can post my ZIP file LINK on any forum but it will not work for everyone except you (or people with your IP address).

Focus on the question. Not getting around it. I know what I need and why I need it and what the limitations are. I just need help putting it together in the .htaccess

lucy24

1:40 am on May 31, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Focus on the question.

I am. My focus tells me it may be the wrong question to ask. And so does yours, or you would not have started out by saying
I am probably looking at this backwards.

If you're talking about .htaccess I don't think IP will work at all, unless your site is restricted to people with fixed IP addresses who never travel. (This is theoretically possible for some variety of site content, but it's pretty far-fetched.) And, as you yourself say, there's the potential problem of people with the same IP address-- which can be a pretty large group if your registered user is in something like a university computer lab.

If the only IP you're interested in is the one they use at the moment of login, then it becomes superfluous in any case. The mere fact of logging in as a registered user has already given you the information you need.

The main issue is that htaccess is more concerned with moving from one page to another than with the content of a page you're already on, which is what your question implies you want to do. That is, "display a link" is not the same thing as "take them to a page containing a link". And if the link only works for registered users, then it really doesn't matter if others can see it too.

If you want to go the htaccess route, why not referrer? It's trivial to set up the link so it only works if clicked from a specific page.

Have you eliminated the possibility of doing it with cookies? If you already have user registration, you've probably got most of the necessary code in place already.

NumberSix

1:56 am on May 31, 2011 (gmt 0)

10+ Year Member



Here is an example.

From IP#1: [cs4585.vkontakte.ru...]

From IP:#2: [cs4585.vkontakte.ru...]

EXACT SAME FILE downloaded from both locations.

What do you get when you try and click these links?
No file correct? What are the chances someone gets the same IP as me.. and see it on this forum? Next to nill.

From IP 1: I got this from one PC behind my network (logged in to the site). DOwnloads an MP3.

I sent the link to a PC on the network, who has NEVER visited the site. Yet it can still download the file also. Still behind same IP.

Nothing to do with cookies.
How is this possible other than .htaccess?

These guys did it. I want to figure out how.

Leosghost

2:32 am on May 31, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



$_SESSIONS and $_SERVER['REMOTE_ADDR'] and use 'REMOTE ADDR' in the mix to write path to file ?

NumberSix

1:33 pm on May 31, 2011 (gmt 0)

10+ Year Member



RewriteMap to a Perl Script was the solution.