Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 24, 2012, 09:14:07 AM

Pages: [1]   Go Down
  Print  
Author Topic: How to prevent PHP script source code from being viewed  (Read 907 times)
aynranddlh
Space Explorer
***
Offline Offline

Posts: 9


« on: June 08, 2003, 01:24:47 PM »

Sorry if this is a dumb question.

I would like to keep my PHP source code from being directly viewed or copied.  I know this means keeping the PHP source out of the public web document tree on my website but I don't know how to do that.  

I think I need to put my PHP source in a directory that is not on the public document tree and then I need to somehow tell Apache that when it sees:

Code:
"/docs/myscript.php"


it should actually execute:

Code:
"/myhomedirectory/notpublicdirectory/myscript.php"


Can anyone please tell me how to do this?
Thanks!!![/code]
Logged

stephan
Guest
« Reply #1 on: June 08, 2003, 02:03:57 PM »

Hello,

There is no need to do this.

No one can download or view your PHP code, as whenever it is accessed, it is executed.

The only way for someone to get it is via the CPanel or FTP (and possibly frontpage) if they have your password.

What you want to do isn't needed.
Logged
magestro
Newbie
*
Offline Offline

Posts: 1


« Reply #2 on: June 09, 2003, 07:36:53 PM »

Hi Stephan,

It's probably due to the fact I've just joined, but I'm missing something here:

> The only way for someone to get it is via the CPanel
> or FTP (and possibly frontpage) if they have your password.

If someone knows which server I'm on and my username (i.e. my home directory), then can't they still browse my area since the default permissions on the directories are "world=read"?  Maybe not with an FTP program (browsing above a user's home directory can be disabled, right?), but what about a cute little PHP script that can parse higher-level directories such as /home?  Is this blocked somehow?

The reason I'm concerned is that this affects the security of mySQL passwords, which are usually sitting in ascii format within a php script.  Just the thought of ascii passwords makes me feel queasy...

Thanks,
Dan
Logged
stephan
Guest
« Reply #3 on: June 10, 2003, 03:17:19 AM »

No one can browse your area.

The default permissions are 755.

No one can get to your files, no matter what the directories' permissions are. Even 777.

No one can get above their own directory through FTP.

PHP scripts cannot do this either.

The mySQL passwords are safe in a PHP file.

Unless you write something like this of course:

<? echo ("My password is sdfsdfsd"); ?>

but I'm guessing you wouldn't do that!
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: