Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Limiting the way pages are accessed.
Old 03-27-2005, 11:43 AM Limiting the way pages are accessed.
Geo
Experienced Talker

Posts: 33
Trades: 0
Hi all,

I've been working on a portal system in PHP. It uses modules and blocks like most others. The problem I have is I’m trying to stop users accessing each module via /portal/modules/module_name/index.php insted of /portal/index.php?module=module_name&file=index.

I have come up with this code to go at the top of each module.
PHP Code:
<?php 
if ($REQUEST_URI == $PHP_SELF){
 echo 
"You cannot access this page directly.";
 exit;
}
?>
The problem with this is the $REQUEST_URI will not always be the same as $PHP_SELF. I have tried as many different solutions as I can think of and this is the best I can come up with.

I was wondering if any body in come up with a solution to my problem. It would be very helpful as it would mean I could get past this snag and progress on with the portal.

Thanks in advance.
Geo
Geo is offline
Reply With Quote
View Public Profile Visit Geo's homepage!
 
 
Register now for full access!
Old 03-27-2005, 03:14 PM
Geo
Experienced Talker

Posts: 33
Trades: 0
Does anyone have any ideas?
Geo is offline
Reply With Quote
View Public Profile Visit Geo's homepage!
 
Old 03-27-2005, 03:52 PM
SergioC's Avatar
Novice Talker

Posts: 11
Location: Guatemala
Trades: 0
What about using a FLAG, I mean a variable that only you will know (it could be a word), so instead of checking for "$REQUEST_URI == $PHP_SELF" check for the flag. The flag coul be written on your config.php

Just my 2 cents.

Regards,
Sergio.
__________________
"You can change the channels but you cannīt change the news."
SergioC is offline
Reply With Quote
View Public Profile
 
Old 03-27-2005, 04:22 PM
Geo
Experienced Talker

Posts: 33
Trades: 0
I'm not sure i understand what you mean. Could you explain it in more detail please.

Thanks
Geo
Geo is offline
Reply With Quote
View Public Profile Visit Geo's homepage!
 
Old 03-27-2005, 04:40 PM
SergioC's Avatar
Novice Talker

Posts: 11
Location: Guatemala
Trades: 0
Sure... add a variable in your index.php, name it for example $flag. Made $flag = "your flag word".

Then use:
PHP Code:
<?php 
if ($flag == ""){ 
echo 
"You cannot access this page directly."
exit; 

?>
Thatīs it. In my prior post I said to write the variable on your config.php but that will be of not use, because if you write your variable there the script will not work, sorry for the mistake.

Regards,
Sergio.
__________________
"You can change the channels but you cannīt change the news."

Last edited by SergioC; 03-27-2005 at 04:42 PM..
SergioC is offline
Reply With Quote
View Public Profile
 
Old 03-27-2005, 05:06 PM
Geo
Experienced Talker

Posts: 33
Trades: 0
Thats done it! Thanks for your help.

Thanks again
Geo
Geo is offline
Reply With Quote
View Public Profile Visit Geo's homepage!
 
Old 03-27-2005, 09:38 PM
SergioC's Avatar
Novice Talker

Posts: 11
Location: Guatemala
Trades: 0
No problem, I am glad it worked for you.

Regards,
Sergio.
__________________
"You can change the channels but you cannīt change the news."
SergioC is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Limiting the way pages are accessed.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25022 seconds with 12 queries