Skip to content

Commit

Permalink
Replaces uses of deprecated constant SID with calls to session_id()
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <[email protected]>
  • Loading branch information
Sesquipedalian committed Dec 25, 2024
1 parent 2c0ec23 commit 0588000
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions Sources/QueryString.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,14 +648,14 @@ function ob_sessrewrite($buffer)
{
global $scripturl, $modSettings, $context;

// If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
if ($scripturl == '' || !defined('SID'))
// If $scripturl is set to nothing, or the session ID is not defined (SSI?) just quit.
if ($scripturl == '' || session_id() === false)
return $buffer;

// Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit(). This doesn't work below PHP 4.3.0, because it makes the output buffer bigger.
// @todo smflib
if (empty($_COOKIE) && SID != '' && !isBrowser('possibly_robot'))
$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&amp;', $buffer);
if (empty($_COOKIE) && session_id() != '' && !isBrowser('possibly_robot'))
$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(session_id(), '/') . ')\\??/', '"' . $scripturl . '?' . session_id() . '&amp;', $buffer);
// Debugging templates, are we?
elseif (isset($_GET['debug']))
$buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer);
Expand All @@ -664,14 +664,14 @@ function ob_sessrewrite($buffer)
if (!empty($modSettings['queryless_urls']) && (!$context['server']['is_cgi'] || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && ($context['server']['is_apache'] || $context['server']['is_lighttpd'] || $context['server']['is_litespeed']))
{
// Let's do something special for session ids!
if (defined('SID') && SID != '')
if (session_id() != '')
$buffer = preg_replace_callback(
'~"' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#"]+?)(#[^"]*?)?"~',
'~"' . preg_quote($scripturl, '~') . '\?(?:' . session_id() . '(?:;|&|&amp;))((?:board|topic)=[^#"]+?)(#[^"]*?)?"~',
function($m)
{
global $scripturl;

return '"' . $scripturl . "/" . strtr("$m[1]", '&;=', '//,') . ".html?" . SID . (isset($m[2]) ? $m[2] : "") . '"';
return '"' . $scripturl . "/" . strtr("$m[1]", '&;=', '//,') . ".html?" . session_id() . (isset($m[2]) ? $m[2] : "") . '"';
},
$buffer
);
Expand Down
10 changes: 5 additions & 5 deletions Sources/Subs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4062,20 +4062,20 @@ function redirectexit($setLocation = '', $refresh = false, $permanent = false)
$setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : '');

// Put the session ID in.
if (defined('SID') && SID != '')
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation);
if (session_id() != '')
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(session_id(), '/') . ')\\??/', $scripturl . '?' . session_id() . ';', $setLocation);
// Keep that debug in their for template debugging!
elseif (isset($_GET['debug']))
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation);

if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed'])))
{
if (defined('SID') && SID != '')
if (session_id() != '')
$setLocation = preg_replace_callback(
'~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
'~^' . preg_quote($scripturl, '~') . '\?(?:' . session_id() . '(?:;|&|&amp;))((?:board|topic)=[^#]+?)(#[^"]*?)?$~',
function($m) use ($scripturl)
{
return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : "");
return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . session_id() . (isset($m[2]) ? "$m[2]" : "");
},
$setLocation
);
Expand Down

0 comments on commit 0588000

Please sign in to comment.