hide php code?

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
madspoihur
Forum Newbie
Posts: 6
Joined: Wed Oct 07, 2009 10:24 am

hide php code?

Post by madspoihur »

I wrote a website in PHP and when you option+click a link on my page you can download the entire php script, which includes sensitive information like passwords etc. Is there a way to prevent this?
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: hide php code?

Post by aravona »

You can easily google a disable right click function. But if you use it, expect massive limitations from your userbase. Personally I right click a lot on website links to open in a new tab when they're set to open in a new window. :)

Alternatively, you can put sensitive code in a seperate file and call it when needed :)
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: hide php code?

Post by andyhoneycutt »

If your source is actually being downloaded, and not the interpreted code, when someone right-clicks, save as... Then disabling right-click is not a solution at all. I could simply wget your source, or generate links to your source and save those.

Sounds like you are having trouble with apache. Make sure it's setup to run your PHP. First, are your PHP scripts actually running when you visit them? Second, if they are running, are you sure that the right-click, save as... doesn't just download the generated html source?
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Re: hide php code?

Post by Phoenixheart »

Indeed. PHP code is server-side, and it should be interpreted by the webserver before returning to the browser. If it is not, then your webserver has problems. Disabling right-click doesn't help in this case.
Post Reply