Ok I succeed.
Thanks
You are not logged in. Please login or register.
PunBB Forums → Posts by Limerick
Ok I succeed.
Thanks
Hello, it's me again...
I managed to do what I wanted but I still have a very little problem.
Connorhd proposed to put that code
$ip=$_SERVER['REMOTE_ADDR'];
if (@$_SERVER["HTTP_X_FORWARDED_FOR"])
$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];
$sCookieValue=md5($_SERVER['HTTP_HOST'].$ip);
if (!isset($_COOKIE['DAlbum_Connection']) ||
$_COOKIE['DAlbum_Connection']!=$sCookieValue)
{
// Check referrer. If referrer is our domain -
// allow access even if cookie is not set
if (isset($_SERVER['HTTP_REFERER']))
{
$ref=parse_url($_SERVER['HTTP_REFERER']);
$sHost=basename($ref['host'] );
if (isset($_SERVER['HTTP_HOST']) &&
strcasecmp($_SERVER['HTTP_HOST'],$sHost)==0)
return;
}
exit("404 Not found");
}
So people arrive on a page where is written "404 Not found"
I can change this to set a redirect link to my website with this
exit('<a href="http://www.mywebsite.com/index.php" target="_blank">mywebsite.com</a>') ;
But I don't know how to write a little sentence just before the link.
I'm able to put the link or to write a sentence, but not both together.
So can someone help me to change the "exit code" in order to have something like :
"You should go to my www.mywebsite.com prior to access to this page"
Thanks to all.
Maybe just a last easy point (for you), which does not specially belongs to DAlbum.
Do you know how to exclude just one page from the domain referer accepted by the implemented code in common.php : the login page of my website which URL is www.mywebsite.com/login.php ?
Thanks,
Lim.
Ok, understood Connorhd. This is kind from you for your previous help.
I don't know exactly what's happened with the cookie, but as I reduced it's time to live to 10mn, it seems to work even if I don't reboot or close the browser.
Do you thing it would be possible to exclude the login page of the website from the authorized referer ? (Don't know if it's the best way to explain what I'm thinking of... ?)
Edit : I deleted the cookie so I recover the "404 not found" text, but now I've error on line 51 which is the last "}" of your code.
However we are getting closer to the goal
Ok let's say what happens.
If I've never been on any page of my website, it works : I can't see any page of the forum, only a little text saying "404 Not found". (Maybe I could change this to sent people to the login page of the website. I'll see it later).
But, if people has only been on the login page of the website (even if they didn't logged in, only displayed the page), they can go on the register page of the forum.
And more over, even if I reboot the computer, user can still acces the register or login page of the forum.
Cookie is not destroyed.
As far as I can see, it seems to work quite well
I'm currently performing some tests to see if it's like I wish.
Thank you so far
Thanks Connorhd
If I put this code at the top (real top) of common.php, the code is displayed as is on the page...
If I put this code after <?php, I've a fatal error : "Call to undefined function: hdr() in /home/... etc.. on line 50
Line 50 : hdr("404 Not found");
I've certainly make a mistake
that could be easily adapted
Hello Connorhd,
Can't you help me a little ?
AAAARRRRGGGHHHH !!!!!!!!
The code I've quoted above seems to do exactly what I want, without changing anything !!!!
I've been looking after this for days and days, and it was just in front of my face (or quite in front).
So, excuse me, I've to go : I'm just going to hang myself...
Thanks to all,
Lim
Edit : NO, sorry, I've made a mistake, it does not work as I want. Something must be changed to this code, but what, and how ???
I think the part that should be changed is the following
$ip=$_SERVER['REMOTE_ADDR'];
if (@$_SERVER["HTTP_X_FORWARDED_FOR"])
$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];
$sCookieValue=md5($_SERVER['HTTP_HOST'].$ip);
if (stristr($_SERVER['PHP_SELF'],"photo.php"))
Isn't it ?
Would you mind helping me... a little bit ?
that could be easily adapted
... hum ... easily ?
DisableDirectLinking();
function DisableDirectLinking()
{
$ip=$_SERVER['REMOTE_ADDR'];
if (@$_SERVER["HTTP_X_FORWARDED_FOR"])
$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];
$sCookieValue=md5($_SERVER['HTTP_HOST'].$ip);
if (stristr($_SERVER['PHP_SELF'],"photo.php"))
{
if (!isset($_COOKIE['DAlbum_Connection']) ||
$_COOKIE['DAlbum_Connection']!=$sCookieValue)
{
// Check referrer. If referrer is our domain -
// allow access even if cookie is not set
if (isset($_SERVER['HTTP_REFERER']))
{
$ref=parse_url($_SERVER['HTTP_REFERER']);
$sHost=basename($ref['host'] );
if (isset($_SERVER['HTTP_HOST']) &&
strcasecmp($_SERVER['HTTP_HOST'],$sHost)==0)
return;
}
hdr("404 Not found");
exit();
}
}
else
{
// Set cookie for one hour.
setcookie("DAlbum_Connection",$sCookieValue,time()+3600);
}
}
Is there a place where I should change to the URL of the Forum, or is more difficult than that ?
Hey guys !
Can you have a look at this (at the bottom).
Do you think it would be possible to slightly change this code to reach the goal I'm looking to ?
It may be possible to force to come on the site before going to the forum, as it seems to be possible to do so for hotlink, isn't it ?
This punBB post on user registration lists a few tutorials on php sessions. When in doubt, it's always a good idea to check out the php.net manual.
Ok, thanks D9r. I'll see it
people won't be able to access the forum at all without the cookie
Ok, fine. Thank you Connorhd.
I know, Google is my friend, but do you know a place where I could see (learn) what kind of file (or code part inside a file) I must take over and how to insert inside common.php, the easyest way ?
just add a little check for the DAlbum session cookie at the beginning of PunBBs common.php
Yes.... well, well, well
I'll try to find how to do it...
And by the way, with this check, people won't be able to register if they don't have this DAlbum's cookie ?
simple solution is to set a session or even better a cookie on the homepage then make punbb check for it, if you do it with a cookie then they will only have to visit the main site once which would probably be less annoyiing for your users
Yes DAlbum set a session cookie
Access control modes
DAlbum can authenticate users in two modes: session mode and Basic HTTP Authentication.Session mode (default) is used when $g_bHTTPAuth is set to false in config.php. In this case users are authenticated by using a custom logon page, which will set a session cookie to authenticate a user. The good thing is that session mode works on any web-server and any PHP configuration (CGI or Apache module), and there is a nice "Log out" button. However, this mode is slower than "Basic HTTP Authentication" and does not work with browser cookies disabled.
But I don't know exactly how it works.
And does this cookie can check for each page from the forum I want ?
No. If you look in the administrator rights in your instilation of Punbb, you can set that guests cannot see the forum, they can only login or register.
Yes, but I don't want anybody to be able to register if they don't come directly from my website.
So this option is not exactly what I want.
It's why I wanted to change the .htaccess, which seems to be impossible, Connorhd says
I'm not sure to understand exactly what you mean...
You mean that version 1.2 (which I use) allows to take .htaccess/.htpassword originally used by my website ?
But the .htaccess/.htpassword used by DAlbum is not on the root folder...
Connorhd wrote:no i mean how can anyone find the forum without knowing the URL to it?
I think thats exactly the point. He wants to have a site that is invitation only, including the forums. He dosen't want it open to the world, only to the members he wants. Sort of a members only.
You're right zc923. I thing Connorhd caught this point at the previous post
Is it difficult to create a two-places access system, but keeping my login page form ? (There's a login and password windows).
IT IS IMPOSSIBLE TO ADD REFERRER DETAILS TO .HTACCESS
sorry i just need to get my point accross here
No problem Connorhd
I did simply not read you saying that before.
But, I don't know if the following deals with your quoted sentence above, but I confirm that the .htaccess below works fine, except for the "Meta Refresh".
SetEnvIfNoCase Referer "^http://www.mywebsite.com/" local_ref=1
Order deny,allow
deny from all
allow from env=local_ref
Anyway, thanks for your kind help, and I think that now, you understand what I was wanted to do...
Lim.
Limerick, if the URL to the forum is only on the site then how are people who don't go on the site going to be able to find the forum?
Ok, I may be a little paranoïd, LOL, but if you type www.mywebsite.com/forum/index.php or more directly, www.mywebsite.com/forum/register.com, you access to the register page which allows you to register then acces to the forum.
You will tell me that people must know how is organized the website/forum. You're right. What I wanted to do was just a - little bit more - secure access.
But it seems to be much more harder then I thought...
If the site is invitation only, why not have a front page that requires a log in? Then have punbb and your other site's login elements cookie based, and when a specific user logs in, it automatically sends the proper cookies.
Yes, this is a nice idea, but as I told you, the website is make dynamicaly, has its own login page (which I wish to keep the look, but I don't know how works the login stuff), and I don't know anything about coding...
But, logging once to the website and to the forum at the same time would be great, but might be more difficult then just ingrate a referer inside the "Meta Refresh"... for who knows how coding a .htaccess
Because the URL is on the website (...and works fine).
And if they are invited to the website, that means they are allowed to go to the forum (thru the link placed on the website).
but how can people find the forum except through your site?
Because I don't want anybody to find the forum if they don't come through my website first.
You've just pointed the goal
Isn't it eaiser just to have .htaccess/.htpasswd combination?
If we find how to turn around the "Meta Refresh" problem, no it's not.
Just because there is already one group login/password for the website, there will be one file user/password for the forum, and there would be another group-or-user/password file...
If I could -easily- do one file for all, why not, but it might be not very simple as both website an forum are "php-automatic" made (don't remember the name...)
Because, it's private and only people invited to the website (we give them login and password) are supposed to register to the forum (if they want to).
If the forum stays like it's now, anybody can come and register, and then go to forum.
Or if I have to acknoledge the register action (there might be this option on PunBB), I must recognize the Pseudo/e-mail or, worst, ask back : who are you ?
If I change the .htaccess, no more problem, even if they register 2 months later with any pseudo or e-mail.
See what I mean ?
PunBB Forums → Posts by Limerick
Powered by PunBB, supported by Informer Technologies, Inc.