mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-08-28 06:01:11 -05:00
Support configurable URLs (#1543)
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(__FILE__) . '/ntbb-database.lib.php';
|
||||
require_once __DIR__ . '/ntbb-database.lib.php';
|
||||
require_once __DIR__ . '/../config/config.inc.php';
|
||||
// require_once dirname(__FILE__) . '/password_compat/lib/password.php';
|
||||
|
||||
$curuser = false;
|
||||
|
||||
class NTBBSession {
|
||||
var $cookiedomain = 'pokemonshowdown.com';
|
||||
var $trustedproxies = array(
|
||||
'103.21.244.0/22',
|
||||
'103.22.200.0/22',
|
||||
@@ -253,7 +253,7 @@ class NTBBSession {
|
||||
}
|
||||
|
||||
function login($name, $pass, $timeout = false, $debug = false) {
|
||||
global $psdb, $curuser;
|
||||
global $psdb, $curuser, $psconfig;
|
||||
$ctime = time();
|
||||
|
||||
$this->logout();
|
||||
@@ -296,31 +296,33 @@ class NTBBSession {
|
||||
unset($curuser['nonce']);
|
||||
unset($curuser['passwordhash']);
|
||||
|
||||
// setcookie('sid', $this->scookie, ['expires' => time() + (363)*24*60*60, 'path' => '/', 'domain' => $this->cookiedomain, 'secure' => true, 'httponly' => true, 'samesite' => 'None']);
|
||||
// setcookie('sid', $this->scookie, ['expires' => time() + (363)*24*60*60, 'path' => '/', 'domain' => $psconfig['routes']['root'], 'secure' => true, 'httponly' => true, 'samesite' => 'None']);
|
||||
$encodedcookie = rawurlencode($this->scookie);
|
||||
header("Set-Cookie: sid=$encodedcookie; Max-Age=31363200; Domain={$this->cookiedomain}; Path=/; Secure; SameSite=None");
|
||||
header("Set-Cookie: sid=$encodedcookie; Max-Age=31363200; Domain={$psconfig['routes']['root']}; Path=/; Secure; SameSite=None");
|
||||
|
||||
return $curuser;
|
||||
}
|
||||
|
||||
function updateCookie() {
|
||||
global $psconfig;
|
||||
if (!$this->sid) {
|
||||
$this->sid = $this->mksid($this->sid);
|
||||
$this->scookie = ',,' . $this->sid;
|
||||
// setcookie('sid', $this->scookie, ['expires' => time() + (363)*24*60*60, 'path' => '/', 'domain' => $this->cookiedomain, 'secure' => true, 'httponly' => true, 'samesite' => 'None']);
|
||||
// setcookie('sid', $this->scookie, ['expires' => time() + (363)*24*60*60, 'path' => '/', 'domain' => $psconfig['routes']['root'], 'secure' => true, 'httponly' => true, 'samesite' => 'None']);
|
||||
$encodedcookie = rawurlencode($this->scookie);
|
||||
header("Set-Cookie: sid=$encodedcookie; Max-Age=31363200; Domain={$this->cookiedomain}; Path=/; Secure; SameSite=None");
|
||||
header("Set-Cookie: sid=$encodedcookie; Max-Age=31363200; Domain={$psconfig['routes']['root']}; Path=/; Secure; SameSite=None");
|
||||
}
|
||||
}
|
||||
function killCookie() {
|
||||
global $psconfig;
|
||||
if ($this->sid) {
|
||||
$this->scookie = ',,' . $this->sid;
|
||||
// setcookie('sid', $this->scookie, ['expires' => time() + (363)*24*60*60, 'path' => '/', 'domain' => $this->cookiedomain, 'secure' => true, 'httponly' => true, 'samesite' => 'None']);
|
||||
// setcookie('sid', $this->scookie, ['expires' => time() + (363)*24*60*60, 'path' => '/', 'domain' => $psconfig['routes']['root'], 'secure' => true, 'httponly' => true, 'samesite' => 'None']);
|
||||
$encodedcookie = rawurlencode($this->scookie);
|
||||
header("Set-Cookie: sid=$encodedcookie; Max-Age=31363200; Domain={$this->cookiedomain}; Path=/; Secure; SameSite=None");
|
||||
header("Set-Cookie: sid=$encodedcookie; Max-Age=31363200; Domain={$psconfig['routes']['root']}; Path=/; Secure; SameSite=None");
|
||||
} else {
|
||||
// setcookie('sid', '', ['expires' => time() - 60*60*24*2, 'path' => '/', 'domain' => $this->cookiedomain, 'secure' => true, 'httponly' => true, 'samesite' => 'None']);
|
||||
header("Set-Cookie: sid=; Max-Age=0; Domain={$this->cookiedomain}; Path=/; Secure; SameSite=None");
|
||||
// setcookie('sid', '', ['expires' => time() - 60*60*24*2, 'path' => '/', 'domain' => $psconfig['routes']['root'], 'secure' => true, 'httponly' => true, 'samesite' => 'None']);
|
||||
header("Set-Cookie: sid=; Max-Age=0; Domain={$psconfig['routes']['root']}; Path=/; Secure; SameSite=None");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user