Jump to content

Recommended Posts

Hi,

I have a page/forum that I am basically embedding into my existing website.  It's possible to access the page somewhere else by typing in the specific URL of that page.  But I only want people to have access to that page if they access it through my website.  Is there a way to do this?

 

I'm thinking it's possible to check the URL using PHP and allow access only if the URL is correct, but I'm not sure.  Does anyone know how to do this or can offer suggestions?

 

Thank you!

So let me check..

 

you have a main page ie

mydomain.com/welcome.php

and

mydomain.com/other_section.php

 

and you want people to access other_section.php VIA welcome.php but NOT directly..

 

if so...

you could use sessions/cookies

 

ie

<?php
session_start();
$_SESSION['access'] = true;
?>

 

<?php
session_start();
if ($_SESSION['access'] !== true)
{
die("No access");
}else{
$_SESSION['access'] = false; //clear so they need to use the welcome.php again
}
echo "Hello world";
?>

Okay, thank you very much. I will give that a try.

 

One important thing I forgot to mention is that there are many pages within this area of the website that I don't want to people to access directly.  All of the pages (there are about 20) are in a folder called forum that I don't want people to access directly.  Is there a way to provide that kind of solution to the folder (and therefore all of the pages within it) easily or do I need to go into each individual php page and apply that code?

 

Thanks again!

well if its a typical forum 99% of the data is accesed via i file called index.php

 

 

if you add the code above excluding

}else{
$_SESSION['access'] = false; //clear so they need to use the welcome.php again

,

that should suite quite well, it really depends on the forum and the exact requirments..

 

of course you could change the boolean (true/false) for a timestamp, this will allow access (including direct access) for a time period (start from when they went to welcome.php) .. if that make sense!

 

so to sum up.. welcome.php sets the time and other_section.php checks the time

 

ie

 

<?php
session_start();
$_SESSION['access'] = time();
?>

<?php
session_start();
if (time() > $_SESSION['access']+(60*60)) //1 hour
{
die("No access");
}
?>

Thank you both for your suggestions. 

 

The forum is normally accessed through the index.php file - that is correct.  I guess what I don't want to happen is for people to access it by "getting smart," by typing in other pages in the forum, like www.mydomain.com/forum/search.php.  Because it seemed if they did that, they would be able to bypass this "security" I guess I'm trying to implement.  Any thoughts on that? 

 

Really what is happening is that I have embedded this forum into a members-only area and I only want members (after they have signed in) to view that forum.  So, they would only be able to view www.mydomain.com/forum/index through www.mydomain.com/members/forum/.

 

The forum is phpBB by the way.

 

Thanks again!  I appreciate the effort.

 

Thank you both for your suggestions. 

 

The forum is normally accessed through the index.php file - that is correct.  I guess what I don't want to happen is for people to access it by "getting smart," by typing in other pages in the forum, like www.mydomain.com/forum/search.php.  Because it seemed if they did that, they would be able to bypass this "security" I guess I'm trying to implement.  Any thoughts on that? 

well it would but most of the feature of the from relie on index.php so it will not function correct.

 

Really what is happening is that I have embedded this forum into a members-only area and I only want members (after they have signed in) to view that forum.  So, they would only be able to view www.mydomain.com/forum/index through www.mydomain.com/members/forum/.

 

The forum is phpBB by the way.

 

Thanks again!  I appreciate the effort.

 

 

humm.. phpbb has a permission for members only see here

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.