/    Sign up×
Community /Pin to ProfileBookmark

Indivdual page security, how?

I have 1 page that calls content from other pages inside another dir.

index.php?call_mod=1

the problem is if you were to type in the adress to that page, you could see it’s contents or the page would try to perform it’s function, this is very bad!

[url]http://www.mysite.com/moduledirectory/modulename.php[/url]

if you type that into the address bar, you will get the page. How do I stop this?

will chmod do this, if so which one allows scripts to call teh page but keeps a surfer from getting to the page?

I’ve tried using sessions and if statements and also defined(blah) but if you hit the page that sets teh session or definition, you can then locate the page, kinda useless.

what’s the way to do this? i thought about maybe an if else that would checking the referring page, and if it’s not the index page then you would be redirected, but I am not sure the best way, so could give me some advice?

thx!

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYApr 14.2006 — if you define a variable on that page (e.g.: $curr_page = "access") on the module page, check if $curr_page is equal to "access", if not, display an error message, if it is, display the content
Copy linkTweet thisAlerts:
@NogDogApr 14.2006 — If we're talking about a file which is only to be included by other PHP pages but is not to be accessed directly, the simplest thing is to put that file in a directory which is outside of the http document root. For instance, if on a Linux/UNIX system and your web documents are in or below the directory /home/yourname/public_html/, then you could create a directory such as /home/yourname/includes/ and put your include files there. Your scripts can still include files from a directory such as that, but web browsers cannot access it directly.
Copy linkTweet thisAlerts:
@rch10007authorApr 14.2006 — i would, but i pay for hosting so i dont have access to another folder outside my public folder.

teh problem with defining variables, is that as soon as it's defined, you have access to the page so that doesnt do much good.

some of the pages have functions, not just content, so i can't restrict them??

what about the idea of checking the referral page to see if its the index page?
Copy linkTweet thisAlerts:
@bathurst_guyApr 14.2006 — i would, but i pay for hosting so i dont have access to another folder outside my public folder.[/QUOTE]
You still should have access to at least one directory above public_html.

Meaning you can create a folder that is in the same folder as public_html

ie:

/public_html/

--/images/

----/logo.gif

--/index.php

--/contact.php

/includes/

--/filetoinclude.php

I have paid hosting and have this.
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYApr 14.2006 — You still should have access to at least one directory above public_html.

Meaning you can create a folder that is in the same folder as public_html

ie:

/public_html/

--/images/

----/logo.gif

--/index.php

--/contact.php

/includes/

--/filetoinclude.php

I have paid hosting and have this.[/QUOTE]


erm, yes, never heard of anyone not having access to above-root even in shared hostings
Copy linkTweet thisAlerts:
@NogDogApr 14.2006 — If for some reason you can't access any directories outside of the public_html area, if you are able to password-protect a directory (such as with .htaccess), then you could put your includes there for at least some degree of security.
Copy linkTweet thisAlerts:
@rch10007authorApr 14.2006 — yea, i think .htaccess is the way to go here, i guess it's really better that way so i don't have to edit a bunch of pages anyways, lol!

thx guys.
Copy linkTweet thisAlerts:
@bokehApr 14.2006 — If the [I].htaccess[/I] doesn't work for you just put the following at the top of the pages you wish to mask:[code=php]<?php (basename(__FILE__) != basename($_SERVER['PHP_SELF'])) or die(); ?>[/code]
Copy linkTweet thisAlerts:
@rch10007authorApr 14.2006 — that's the lil script i was looking for!

i know i've seen it here before but i couldnt figure it out, i must have run a 1000 searches looking for it, lol!
×

Success!

Help @rch10007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...