Advertisement:

Author Topic: Help with "load.php"  (Read 1472 times)

Offline BPDFamily.com

  • Jr. Member
  • **
  • Posts: 106
  • Gender: Male
    • BPDFamily
Help with "load.php"
« on: March 07, 2019, 08:21:07 PM »
When someone try to load a internal link that they do not have permissions for, I would like to load a 403 error page.

I presume the area to code  that is on the load page. What coding change would I need to accomplish this?

Code: [Select]
// Set the template contextual information.
$context['user']['is_mod'] = &$user_info['is_mod'];
$context['current_topic'] = $topic;
$context['current_board'] = $board;

// Hacker... you can't see this topic, I'll tell you that. (but moderators can!)
if (!empty($board_info['error']) && ($board_info['error'] != 'access' || !$user_info['is_mod']))
{
// The permissions and theme need loading, just to make sure everything goes smoothly.
loadPermissions();
loadTheme();

$_GET['board'] = '';
$_GET['topic'] = '';

// If it's a prefetching agent, just make clear they're not allowed.
if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
{
ob_end_clean();
header('HTTP/1.1 403 Forbidden');
die;
}
elseif ($user_info['is_guest'])
{
loadLanguage('Errors');
is_not_guest($txt['topic_gone']);
}
else
fatal_lang_error('topic_gone', false);
}

if ($user_info['is_mod'])
$user_info['groups'][] = 3;
}

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,200
    • StoryBB/StoryBB on GitHub
Re: Help with "load.php"
« Reply #1 on: March 08, 2019, 02:31:50 AM »
Users already get an error message, what exactly are you trying to do that’s different?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline BPDFamily.com

  • Jr. Member
  • **
  • Posts: 106
  • Gender: Male
    • BPDFamily
Re: Help with "load.php"
« Reply #2 on: March 08, 2019, 03:02:05 AM »
I want to link to a 404 page instead of the standard message.

Offline BPDFamily.com

  • Jr. Member
  • **
  • Posts: 106
  • Gender: Male
    • BPDFamily
Re: Help with "load.php"
« Reply #3 on: March 09, 2019, 12:29:39 PM »
I would really appreciate help with this.  Google struggles with that handling of unavailable links.

Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 18,403
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • LexArma on GitHub
    • aleksi-kilpinen on LinkedIn
    • There's No Place Like 127.0.0.1
Re: Help with "load.php"
« Reply #4 on: March 09, 2019, 12:40:41 PM »
I would really appreciate help with this.  Google struggles with that handling of unavailable links.
There is a mod for 2.0 that adds to thre default error handling, I am not aware of a solution for 1.1 though.
( The mod in question is 404 on Missing Topics/Boards )

I am a bit curious though, how does Google choke on the default behaviour? I never saw it as an issue when I was running 1.1.
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.
  Fooling around with an i7 990X @ 3,47Ghz / 12Gb / Win 10 x64 / 3840x2160


How you can help SMF

"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum.
 Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,200
    • StoryBB/StoryBB on GitHub
Re: Help with "load.php"
« Reply #5 on: March 09, 2019, 12:45:25 PM »
This is why I asked what you were trying to do; redirecting to a page that says something is very different to notifying Google about a page being 404.

Assuming you're not trying to do any redirection that you don't need to, and you just want to mark a page as 404, you don't touch Load.php at all, instead you change Errors.php, but that depends on whether you're really using 1.1.x or 2.0, are you definitely using 1.1.x? (And if so, are you planning on upgrading to anything that isn't 13 years old any time soon?)

This is solved in 2.1 though.

@Lex non-missing pages return HTTP 200 so Google thinks they should be indexed.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 18,403
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • LexArma on GitHub
    • aleksi-kilpinen on LinkedIn
    • There's No Place Like 127.0.0.1
Re: Help with "load.php"
« Reply #6 on: March 09, 2019, 12:59:53 PM »
@Lex non-missing pages return HTTP 200 so Google thinks they should be indexed.
Oh, right - I can see how that might grow to be an issue over time.
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.
  Fooling around with an i7 990X @ 3,47Ghz / 12Gb / Win 10 x64 / 3840x2160


How you can help SMF

"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum.
 Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Offline doug_ips

  • Jr. Member
  • **
  • Posts: 298
Re: Help with "load.php"
« Reply #7 on: March 09, 2019, 05:37:02 PM »
A bt off topic here, but may I ask why you are still using such an old version? The 2.0x version is much much better and 2.1. will be even better.

Offline BPDFamily.com

  • Jr. Member
  • **
  • Posts: 106
  • Gender: Male
    • BPDFamily
Re: Help with "load.php"
« Reply #8 on: March 09, 2019, 09:37:30 PM »
This is why I asked what you were trying to do; redirecting to a page that says something is very different to notifying Google about a page being 404.

We want to point here: https://bpdfamily.com/404.shtml

I am a bit curious though, how does Google choke on the default behaviour? I never saw it as an issue when I was running 1.1.

Google is sending us notes via webmaster tools to resolve the error handling. We recently archived 2 million posts.

A bt off topic here, but may I ask why you are still using such an old version? The 2.0x version is much much better and 2.1. will be even better.

The short answer is that the donation tracking software (Resourcez) with 1.1 is working for us and it has generated a significant amount of donations without any error or downtime.

We are operating behind the Securi firewall and have no security issues and spam is a rare.


I'm glad to hear the code exists for 2.0  Can someone lift that code and adapt to 1.1 - or share the code with me?

BPDFamily.com

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,316
  • Gender: Male
    • Kindred-999 on GitHub
Re: Help with "load.php"
« Reply #9 on: March 10, 2019, 01:37:14 AM »
Well, no...   redirecting to that specific URL is what you assumed was the solution.

In reality, as arantor said, to address the actual problem that you pointed out (what google is reporting), the best way to handle it would be to set the header to indicate a 404.

The mod, as pointed out: http://custom.simplemachines.org/mods/index.php?mod=3969
does exactly what you need...   but only works on current/modern versions.

... and you really need to upgrade off of 1.1.x, which is only receiving bare bones support at this point, since it was declared "End of Life".
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,200
    • StoryBB/StoryBB on GitHub
Re: Help with "load.php"
« Reply #10 on: March 10, 2019, 04:26:40 AM »
You know that redirecting to that page won’t actually change anything, right? It’s all about the headers, since the redirection will successfully load that page and you’ll be in the same position as you are in now.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline BPDFamily.com

  • Jr. Member
  • **
  • Posts: 106
  • Gender: Male
    • BPDFamily
Re: Help with "load.php"
« Reply #11 on: March 10, 2019, 11:31:16 PM »
you really need to upgrade off of 1.1.x, which is only receiving bare bones support at this point, since it was declared "End of Life".

I see that there is little support.

Is there a member here that will hire for minor program updates on 1.1?

Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 18,403
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • LexArma on GitHub
    • aleksi-kilpinen on LinkedIn
    • There's No Place Like 127.0.0.1
Re: Help with "load.php"
« Reply #12 on: March 10, 2019, 11:40:50 PM »
We do try to actively encourage people to adopt versions that are still officially supported.

You can ask for paid support in Help Wanted (not for support)

The code for 2.0 from the mod linked earlier is basically this

./Sources/Errors.php
Code: [Select]
$error_message = empty($sprintf) ? $txt[$error] : vsprintf($txt[$error], $sprintf);
}

// Include a error code in the header if error message is a certain type:
if ($error == 'no_board' || $error == 'wrong_forum')
{
$request = $smcFunc['db_query']('', '
SELECT MAX(id_board) AS max_board, id_board
FROM {db_prefix}boards
WHERE id_board = {int:board}',
array(
'board' => (int) $board,
)
);
$row = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
if ($row['max_board'] > $board)
header('HTTP/1.1 404 Not Found');
elseif ($row['id_board'] === null)
header('HTTP/1.1 410 Gone');
else
header('HTTP/1.1 403 Forbidden');
}
elseif ($error == 'not_a_topic' || $error == 'topic_gone')
{
$request = $smcFunc['db_query']('', '
SELECT MAX(id_topic) AS max_topic, id_topic
FROM {db_prefix}topics
WHERE id_topic = {int:topic}',
array(
'topic' => (int) $topic,
)
);
$row = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
if ($row['max_topic'] > $topic)
header('HTTP/1.1 404 Not Found');
elseif ($row['id_topic'] === null)
header('HTTP/1.1 410 Gone');
else
header('HTTP/1.1 403 Forbidden');
}

This will not work directly in 1.1, and trying will break your forum - just leaving it here as an example in case you can work with it.
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.
  Fooling around with an i7 990X @ 3,47Ghz / 12Gb / Win 10 x64 / 3840x2160


How you can help SMF

"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum.
 Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Offline BPDFamily.com

  • Jr. Member
  • **
  • Posts: 106
  • Gender: Male
    • BPDFamily
Re: Help with "load.php"
« Reply #13 on: March 11, 2019, 08:54:39 AM »
Thanks...

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,316
  • Gender: Male
    • Kindred-999 on GitHub
Re: Help with "load.php"
« Reply #14 on: March 11, 2019, 08:57:22 AM »
instead of paying for support of an outdated (and, incidentally, insecure*) system...   why not upgrade to at least 2.0.x. 

(* 1.1.21 has known security issues which were not patched because the 1.1.x version is at end of life -- those issues were patched in 2.0.x versions up to 2.0.15)
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.