deny direct access to SMF

Started by Gianni_T, May 07, 2005, 03:49:43 AM

Previous topic - Next topic

BCCZeus

I'm running 3.19a and 1.1 Beta 3 and am getting pretty much the same issues as Phoenix.

BCCZeus

Any update or ideas on this.  Previously my members would just go to my forum url, but now that it's integrated, I'd really love to deny and redirect.

Thanks in advance.

Orstio

How about something like this:

if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
if(!defined('_VALID_MOS')){ header("Location: http://www.example.com/");}
}

BCCZeus

Sweet work Orstio.  Very slick.

BTW I fixed the DiscussBot so it allows you to edit the post when you click the "Discuss" link for the first time.  PM me if you want the updated bot for your next bridge version.

Orstio

QuoteBTW I fixed the DiscussBot so it allows you to edit the post when you click the "Discuss" link for the first time.  PM me if you want the updated bot for your next bridge version.

That's how the original bot worked, actually (I didn't know there was another way at that time).  I will make it optional in future releases, set by param.

BCCZeus

Hmm.  Maybe something screwed up with the last version I got with the bridge.  It would only quote the article and not allow you to edit it. . . weird.  Either way.  Thanks for the deny and redirect.

Orstio

QuoteHmm.  Maybe something screwed up with the last version I got with the bridge.  It would only quote the article and not allow you to edit it. . . weird.  Either way.

QuoteThat's how the original bot worked, actually (I didn't know there was another way at that time).  I will make it optional in future releases, set by param.

To rephrase:  Older versions of the bot worked as you describe.  Nothing is screwed up.  That is just not the way this version of the bot happens to work.  In future releases of the bot, there will be a param to decide whether you wish the bot to behave as you asked, or the way it does now.  Not in this version;  In future versions.

jrfuda

Guys, thanks for this bit of code. I have the redirect working well!

exrace

#28
Thanks for this snippet.
I hacked it a bit to work better with multi-named sites using Location: /index.php? instead of a full url.

// Redirect users who try to access /forum directly
if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
        if(!defined('_VALID_MOS')){ header("Location: /index.php?option=com_smf&Itemid=yourItemidNum");}
}


Then if you change your url or use multiple names for your site it won't redirect them to a hardcoded name on the redirect.

Naesstrom

Ok... I'm not getting this to work at all... tried every version of code in this thread and nothing happends, not even a errormessage... just redirected to SMF when loggin in...
I have this setup:
joomla: http://portal.myurl.com
SMF: http://forum2.myurl.com

the newest versions of everything, joomla, smf and the bridge... anyone got any suggestions....

Kindred

if you want to use wrapped, you have to have smf and joomla on the same subdomain.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Orstio

Quote from: Naesstrom on December 15, 2005, 04:32:22 PM
Ok... I'm not getting this to work at all... tried every version of code in this thread and nothing happends, not even a errormessage... just redirected to SMF when loggin in...
I have this setup:
joomla: http://portal.myurl.com
SMF: http://forum2.myurl.com

the newest versions of everything, joomla, smf and the bridge... anyone got any suggestions....

Putting this in your SMF index.php does not work?

// Redirect users who try to access /forum directly
if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
        if(!defined('_VALID_MOS')){ header("Location: http://portal.myurl.com//index.php?option=com_smf&Itemid=yourItemidNum");}
}


Make sure to change "yourItemidNum" to your Itemid number of your bridge component.

Naesstrom

Quote from: Kindred on December 15, 2005, 04:43:36 PM
if you want to use wrapped, you have to have smf and joomla on the same subdomain.

The wrapper works great... it's just that I don't want it to go directly to the SMF index...

Naesstrom

#33
Quote from: Orstio on December 15, 2005, 04:50:31 PM
Putting this in your SMF index.php does not work?

// Redirect users who try to access /forum directly
if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
        if(!defined('_VALID_MOS')){ header("Location: http://portal.myurl.com//index.php?option=com_smf&Itemid=yourItemidNum");}
}


Make sure to change "yourItemidNum" to your Itemid number of your bridge component.

a little confused... How do I know the itemID of the component... is that the link to the forum on the mainmenu?
btw... that code should be somewhere after
require_once($sourcedir . '/Subs.php');

[edit]
I tried and enter the URL directly in my browser and it didn't matter what ItemID I put in there... I always ended up at the SMF startpage
http://portal.sharpweaponcenter.com/index.php?option=com_smf&Itemid=26
http://portal.sharpweaponcenter.com/index.php?option=com_smf&Itemid=1
http://portal.sharpweaponcenter.com/index.php?option=com_smf&Itemid=89

Orstio

Quotea little confused... How do I know the itemID of the component... is that the link to the forum on the mainmenu?

Yes, when you click on the "Forum" link from your main menu, you will see the url something like

http://portal.myurl.com/index.php?option=com_smf&Itemid=

And the Itemid number will follow the "Itemid=" part.

Naesstrom

Quote from: Orstio on December 15, 2005, 05:02:22 PM
Yes, when you click on the "Forum" link from your main menu, you will see the url something like

http://portal.myurl.com/index.php?option=com_smf&Itemid=

And the Itemid number will follow the "Itemid=" part.

well... thats 26, but it still doesn't work...

exrace

Try a simple relative redirect first like I did in my example above - it works great and fixed many issues I had with users password resets and popups from the forums.

Could be your apache setup is not setup to support this subdomain reference.

Orstio

Quotewell... thats 26, but it still doesn't work...

Where did you put the code?

Naesstrom

Quote from: exrace on December 15, 2005, 05:13:23 PM
Try a simple relative redirect first like I did in my example above - it works great and fixed many issues I had with users password resets and popups from the forums.

Could be your apache setup is not setup to support this subdomain reference.

nope... tried that right now and that didn't work either...

Naesstrom

Quote from: Orstio on December 15, 2005, 05:15:03 PM
Quotewell... thats 26, but it still doesn't work...

Where did you put the code?

in the index.php of the SMF installation, this is how it looks...
// And important includes.
require_once($sourcedir . '/QueryString.php');
require_once($sourcedir . '/Subs.php');
require_once($sourcedir . '/Errors.php');
require_once($sourcedir . '/Load.php');
require_once($sourcedir . '/Security.php');

// Redirect users who try to access /forum directly
if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
        if(!defined('_VALID_MOS')){ header("Location: http://portal.sharpweaponcenter.com//index.php?option=com_smf&Itemid=26");}}

Advertisement: