-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#940: Fix referrer confirmation for forums installed in subdirectories.
- Loading branch information
1 parent
0301098
commit d0ceb4e
Showing
6 changed files
with
25 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1041,10 +1041,13 @@ function random_key($len, $readable = false, $hash = false) | |
// | ||
// Make sure that HTTP_REFERER matches base_url/script | ||
// | ||
function confirm_referrer($script, $error_msg = false) | ||
function confirm_referrer($scripts, $error_msg = false) | ||
{ | ||
global $pun_config, $lang_common; | ||
|
||
if (!is_array($script)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
franzliedke
Author
Member
|
||
$scripts = array($scripts); | ||
|
||
// There is no referrer | ||
if (empty($_SERVER['HTTP_REFERER'])) | ||
message($error_msg ? $error_msg : $lang_common['Bad referrer']); | ||
|
@@ -1054,14 +1057,21 @@ function confirm_referrer($script, $error_msg = false) | |
if (strpos($referrer['host'], 'www.') === 0) | ||
$referrer['host'] = substr($referrer['host'], 4); | ||
|
||
$valid = parse_url(strtolower(get_base_url().'/'.$script)); | ||
// Remove www subdomain if it exists | ||
if (strpos($valid['host'], 'www.') === 0) | ||
$valid['host'] = substr($valid['host'], 4); | ||
$valid_paths = array(); | ||
foreach ($scripts as $script) | ||
{ | ||
$valid = parse_url(strtolower(get_base_url().'/'.$script)); | ||
// Remove www subdomain if it exists | ||
if (strpos($valid['host'], 'www.') === 0) | ||
$valid['host'] = substr($valid['host'], 4); | ||
|
||
$valid_host = $valid['host']; | ||
$valid_paths[] = $valid['path']; | ||
} | ||
|
||
// Check the host and path match. Ignore the scheme, port, etc. | ||
if ($referrer['host'] != $valid['host'] || ($referrer['path'] != $valid['path'] && $valid['path'] != '/')) | ||
message($error_msg ? $error_msg : $lang_common['Bad referrer']); | ||
if ($referrer['host'] != $valid_host || !in_array($referrer['path'], $valid_paths)) | ||
message($error_msg ? $error_msg : $lang_common['Bad referrer']);} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Just in case you don't notice this, add
s
.