Encrypting an Html

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
FTJoe
Forum Newbie
Posts: 10
Joined: Sun Jul 17, 2005 8:00 pm

Encrypting an Html

Post by FTJoe »

I don't want to go too technical but I came up with a simple idea that will keep people away for a while. Can someone show me how to make a php code that will make all of the html addresses in any html/php documents in the ftp folder flip around, so the html address is backward. I know that will be easy, but how would I make it so it also recognizes it and automaticaly flips it around to read it..
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Can someone show me how to make a php code that will make all of the html addresses in any html/php documents in the ftp folder flip around, so the html address is backward.
strrev() flips around text, but there's several problems in implementing this:

http:// is a protocol. You can't take "http://www.google.com/" and flip it around to "/moc.elgoog.www//:ptth" and expect the server to even get the request.

Therefore, you'd probably have to flip around just the folder variables and leave the domain name alone. But I have a better idea:

Why don't you have Apache force a user to authenticate itself before it serves any requests? If you're trying to "keep people away". Or you could swamp your site with annoying ads and popups. That would keep people away too. </sarcasm>
FTJoe
Forum Newbie
Posts: 10
Joined: Sun Jul 17, 2005 8:00 pm

Post by FTJoe »

erm..no, I'm just trying to keep them from downloading things by getting the link from source codes.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Then what's the point of putting up the thing in the first place?
FTJoe
Forum Newbie
Posts: 10
Joined: Sun Jul 17, 2005 8:00 pm

Post by FTJoe »

Ambush Commander wrote:Then what's the point of putting up the thing in the first place?
....so it will screw up the adresses and they won't find it as easily.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

If you're trying to make it hard for them to find (but not impossible), and you've got lots of free time on your hands:

1. Devise a puzzle program they have to solve before they can download the file.
2. Swamp the site in ads, making them click through lots of things and vote for you in site polls and stuff, and then finally get to the end where the file is there but mispelled.
FTJoe
Forum Newbie
Posts: 10
Joined: Sun Jul 17, 2005 8:00 pm

Post by FTJoe »

*sigh* we can't go and change the urls so they link to those kind of things, there are already over 1000 urls..
FTJoe
Forum Newbie
Posts: 10
Joined: Sun Jul 17, 2005 8:00 pm

Post by FTJoe »

ok, anyways, first of all how do I tell it to flip around things that start with www. and end with /
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

If they're in HTML files, that's impossible without editing the HTML file into a PHP file (two ways, rename it PHP or have Apache parse HTML files under PHP). Then, I'd suggest at the beginning of the document do output buffering. Then, using a regexp, find the locations of all the URLs in the document. Then, with the locations, decompose the URLs, keep the http://www.domain.com/ and then reverse everything after that.

BUT IT DOESN'T WORK! If you have Apache reverse the URL obfuscation via mod_rewrite or something, they can still use the URLs! Nothing changes!

I'm still not sure what you want to do. Perhaps it would be time better spent making a PHP script that slurps up all of the links to downloads (and associated metadata), put it into a database, and then have all links generated dynamically?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

http://scriptasylum.com/tutorials/encde ... ecode.html

It'd be quite simply to write a PHP script to encode the existing HTML and then wrap it in a page that decodes it on the client side.

But if anyone has JavaScript switched off they'd not be able to view the page.
FTJoe
Forum Newbie
Posts: 10
Joined: Sun Jul 17, 2005 8:00 pm

Post by FTJoe »

onion2k I like this link, but could I make a php file like this that would automaticaly go through the files and encrypt them?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Of course you could.
FTJoe
Forum Newbie
Posts: 10
Joined: Sun Jul 17, 2005 8:00 pm

Post by FTJoe »

Is that being sarcastic because I'm stupid, or are you serious?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

FTJoe wrote:Is that being sarcastic because I'm stupid, or are you serious?
No, I'm completely serious.

Roughly speaking, the script would go something like:

Code: Select all

$dir = opendir("./directoryOfHTMLFiles/");
while ($file = readdir($dir)) {
    if ($file != "." and $file != "..") {
        //Open the file
        //Strip out the header HTML and <body> tag
        //Encode the data
        //Add the JavaScript encoding stuff
        //Save the file
    }
}
FTJoe
Forum Newbie
Posts: 10
Joined: Sun Jul 17, 2005 8:00 pm

Post by FTJoe »

hmm...cool..but I just encountered a problem..it ends up he is just storing movie files in a folder, and an html page automaticaly displays the numbers for the movies, etc. So, he did not write the movie links in the browser, so even if I did encrypt it the link would still apear how it is..
Post Reply