here's one for you...

cowboysdude 27 Jul, 2008
I am trying to protect a file [php] from direct access... I've tried .htaccess but not gonna work so I went with sessions within joomla.

what I would like to do is valid the session in joomla to allow a user to load the chat.php file... so if someone tries direct access they get thrown back to the index.php and must register and/or login to gain access.

Suggestions? I've tried so many things I can't even list them here..lol

<?php
session_start();
$session = &JSession::getInstance();
If (!isset($session = 'active'))
Else
{
// It hasn't, they must go to index.php.
header('Location: http://' . getenv('HTTP_HOST') . '/', true, 302);
exit();
}
?>

I've tried that but no good... it gives me an error about using jsession....
GreyHead 28 Jul, 2008
Hi cowboysdude,

Why don't you just use the same code as Joomla does and put
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
at the beginning of the file (this is the Joomla 1.5.x version). This file will only then execute if included or required from inside Joomla.

Bob
cowboysdude 28 Jul, 2008
Great idea! it's certainly easy...lol

Ok I'm going to give that a shot... be right back :-)

Ok tried that...it does work but... it doesn't stop anyone from using the direct link to the chat... so the issue I have is that I need also include it in the main chat file too but when I do that it will not load. It just sits there ... because it's following the rule of die... not sure why unless I need to call the chat file itself from within joomla but then with the chat mod I thought I was doing that.

Then I got thinking about it and realized that I wasn't. I need to protect the main chat.php file itself and not the mod so there's my problem. If I include the code in the main chat file it won't load no matter what because it's not within joomla itself which would explain why I couldn't get a session code to work either.. :-(.... I know there has to be a way to do this...
GreyHead 28 Jul, 2008
Hi cowboysdude,

Sorry, but what on earth has this got to do with ChronoForms???

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger