News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

deny direct access to SMF

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

Previous topic - Next topic

Gianni_T

Hi all,
how can I deny direct access to my SMF and allow only to see it wrappend in Mambo?

xenovanis

Enter this at line 1 of smf's index.php:


defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
"Insanity: doing the same thing over and over again and expecting different results."

Gianni_T

Quote from: xenovanis on May 07, 2005, 03:57:04 AM
Enter this at line 1 of smf's index.php:


defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

Does this trick works also for attached files?

xenovanis

Quote from: Gianni_T on May 07, 2005, 04:00:31 AM
Does this trick works also for attached files?

I dont know, just try it out.  :)
"Insanity: doing the same thing over and over again and expecting different results."


chadness

You might try this, if you want to display avatars in your login box:
if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
defined('_VALID_MOS') or die('Direct Access to this location is not allowed.');
}

Firefrog

Is this literally line one above the file info stuff or just at the start of the actual code.


xenovanis

It's just this peace of code, you'd better use the one Chadness posted in the post above you. You'll need to add  it in your SMF's index.php on line 2 just after <?php

And not on line 1, as I said earlier.
"Insanity: doing the same thing over and over again and expecting different results."

Firefrog


Nitro

i have anothe rquestion, first, i wanted to say this little code has been working great! thank you!
now, instead of showing a message, is there a way to redirect automaticaly the direct access and send them to the actual main index ?

how would i go and do this? thanks a bunch!!!
MPF Rocks!!!

Aravot


Orstio

if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
if(!defined('_VALID_MOS')){ redirectexit('http://www.where-you-want-to-go.com/folder',false); }
}

Nitro

Quote from: Orstio on August 02, 2005, 09:40:59 PM
if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
if(!defined('_VALID_MOS')){ redirectexit('http://www.where-you-want-to-go.com/folder',false); }
}


this code gave me en error:


Fatal error: Call to undefined function: redirectexit() in /homepages/20/d107436098/htdocs/bb/bb/index.php on line 4


i just replaced the 'where-you-want-to-go with my url, any suggestions?

thank you.
MPF Rocks!!!

Orstio

Quote from: NitroRich on August 02, 2005, 09:56:21 PM
being charter member i guess it has some advantages.

nice!

i will look forward to become one charter member pretty soon and i am tired of waiting for a random answer.

thank you man!!!

While I'm sure everyone here would appreciate your charter membership, it isn't required to receive a quicker reply.  I think something similar to what I posted above has already been suggested somewhere.

Quotethis code gave me en error:

Code:

Fatal error: Call to undefined function: redirectexit() in /homepages/20/d107436098/htdocs/bb/bb/index.php on line 4
i just replaced the 'where-you-want-to-go with my url, any suggestions?

thank you.

It is best to place that code after Line 51. ;)

Orstio

Hmmm... once Subs.php is called, it should be good.  ???

Nitro

on subs.php you mean, to put that code in the subs.php? is that right? because i have it on the index.php for the SMF board
MPF Rocks!!!

Orstio

Yes, it goes in index.php.  But there is a "require" to Subs.php:

require_once($sourcedir . '/Subs.php');

The function named redirectexit is inside Subs.php, so the code added to index.php must be after that require_once statement.

Phoenixoverlord

Hmmm still no love here...

I've placed this after the require_once line in index.php (around 54 or so)

if (strpos($_SERVER['QUERY_STRING'], 'dlattach') === false)
{
if(!defined('_VALID_MOS')){ redirectexit('http://url/mambo/index.php',false); }
}


And then get this for an answer:

Notice: Use of undefined constant WIRELESS - assumed 'WIRELESS' in /home/flaming/public_html/smftest/Sources/Subs.php on line 1228

Notice: Use of undefined constant WIRELESS_PROTOCOL - assumed 'WIRELESS_PROTOCOL' in /home/flaming/public_html/smftest/Sources/Subs.php on line 1238

Warning: Cannot modify header information - headers already sent by (output started at /home/flaming/public_html/smftest/Sources/Subs.php:1228) in /home/flaming/public_html/smftest/Sources/Subs.php on line 1257

Orstio

What version of the bridge are you using?  Do you have a URL?

Phoenixoverlord

I'm using v3.19a  and SMF 1.0.5. I'll PM you the link. :) Thanks for the help!

Advertisement: