/    Sign up×
Community /Pin to ProfileBookmark

PHP called from page or directly?

Is there anyway that I can determine if my PHP was called from another page, or directly? For example..

Say on a page i have

[code]<link rel=”stylesheet” type=”text/css” href=”code.php”>[/code]

is there anything I can put in that php file to determine whether it was called this way, or by someone typing in

[url]www.domain.com/code.php[/url]

I tried by checking if the $HTTP_REFERER == null , but this was very flakey

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsJan 26.2005 — the only way i can think of is checking the $_SERVER['HTTP_REFERER'] variable, but, that can lead to problems because the referrer can be changed by the user or is not even set
Copy linkTweet thisAlerts:
@johneboyauthorJan 26.2005 — I think i figured this one out...
[code=php]
if (eregi("code.php", $_SERVER['REQUEST_URI'])){
die('access denied');
}
[/code]


now on to more aggravating issues... :mad:

[URL=http://www.webdeveloper.com/forum/showthread.php?s=&threadid=54756]http://www.webdeveloper.com/forum/showthread.php?s=&threadid=54756[/URL]
Copy linkTweet thisAlerts:
@ShrineDesignsJan 26.2005 — why do you want to deny access to a css file?
Copy linkTweet thisAlerts:
@johneboyauthorJan 26.2005 — I saw a site that did it, so i want to learn..

learning drives me (as well as being bored at work ?)
×

Success!

Help @johneboy 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...