| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,899
|
easy to view php source of php page?
How easy is it for a savvy website user to view the unprocessed source code of a php? How secure is any sensitive data stored within the php code of a web page? |
|
|
|
|
|
#3 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,899
|
So, this is safe to use then? Code:
I'm just concerned that there may be an app that can download a php file as source (i.e. bypassing the parse instruction of the server) The above idea seemed a good idea for a quick and easy solution to the problem of establishing basic password protection for a page. Not saying I'm planning to use it, just that it made me wonder about the level of inate security in a php file. |
|
|
|
#4 (permalink) |
|
Magazines™
Join Date: Mar 2003
Location: Glasgow..
Posts: 11,275
|
I think you may be worrying too much Bill. As for the above code - fine I believe as there is nothing there in the rendered page. I dont think you can crack something that hasnt been rendered (as such) - dont quote me though. There are ways of cracking mysql databases but do you think your at risk? |
|
|
|
#5 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,899
|
I may well be over-thinking things though I'm not particularly expecting any threats. Security just seems to be one of those things that is constantly harped on about throughout the reading I've been doing in the past few days. I've been looking at some prefab php script sites. Some handy (read: genuinely useful) stuff to be found. Takes me back to the 'kid in a candy shop' feeling I had when I very first became interested in javascript and found all those javascript download sites. Now if I can just locate a php script to make snow flakes fall down the screen… |
|
|
|
#6 (permalink) |
|
I Ain't Losing Any Sleep™
Join Date: Apr 2003
Posts: 5,236
|
The only problem you'd have would be in the unlikely event of the php support on your server failing. As added protection it's wise to seperate any sensitive info from the actual script using includes. Amend your includes path so that it is above the root directory and away from prying eyes. PHP Code:
PHP Code:
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
|
|
|
|
#8 (permalink) |
|
Registered User
Join Date: Mar 2004
Location: Derby, UK
Posts: 24
|
yep, php source is as safe as anything in plain text connected to a worldwide network can be Couple more things to watch out for: When using includes remember to always use .php as extension or it may render when called directly (e.g. if you called an include file password.inc or less likely password.txt) depending on how that extension is handled by your server. Ideally you should trap and log (or at the very least suppress) errors, otherwise when something goes wrong with your code/site the error message itself may give away useful info on your code. Also if you trap and log errors you may well spot attempted hacks before they succeed (or after they succeed but before they do too much damage). HTH |
|
|
|
#9 (permalink) | |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,899
|
Quote:
I actually do use .php for all site files now as most already contain php instructions and the few that don't simply look neater to me when viewing the directories. (There's not so many that the additional redundant hits to the php parser hurt the performance) The reason I ask is to increase my understanding of the php malarky. I'll look into trapping/surpressing errors as you mentioned. Is there some way of doing that site-wide or will it need to be done on a page-by-page/function-by-function level? |
|
|
|
|
#10 (permalink) | ||
|
Registered User
Join Date: Mar 2004
Location: Derby, UK
Posts: 24
|
Quote:
If you mean your main file is x.php and your include (with PHP code in) is y.html then that would not be a good idea as again if someone called y.html directly the PHP code would not be processed (unless .html was configured as PHP) and the php code would be shown in the html file sent back to the browser. If the include only has html anyway then that is fine, it is only files with PHP code in that you need to be careful with. Quote:
If you control the site config you can set error levels and (I think) default error reporting mechanism that way, but as I tend to use hosted accounts I 'roll my own' using set_error_handling() functions. There is a section about it in PHP manual e.g. here |
||
|
|
|
#11 (permalink) | |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,899
|
Quote:
Thanks for the link. I'll take a sneak-peek this w/end, though a v quick preview takes me to a page which will surely have my non-geek head exploding. I'll try to cherry-pick the bits I'm after, though I may have to fall-back to a 'PHP fer not-quite eejits' book. |
|
|
|
|
#13 (permalink) |
|
Senior Member
Join Date: May 2003
Posts: 658
|
Hi Guys - Funnily enough this password protection is exactly the type that I was about to search google for. I have a quick question (I have no knowledge of PHP hence this may be very easy) - I have uploaded the page - works fine but I noticed that if you put the wrong user or password details in it simply refreshes the page. Is it possible to display an error to the user that states they have supplied the wrong details and should retry. I have a feeling alot of users will be sitting for ages waiting for something to happen without realising they have to re enter. TIA feel the heat.
|
|
![]() |