Merge pull request #98 from ArthurHoaro/port
Fix port/server config problems by using php SERVER_NAME instead of HTTP_HOST
This commit is contained in:
commit
09850e6a20
1 changed files with 4 additions and 4 deletions
|
@ -47,7 +47,7 @@
|
||||||
// Force cookie path (but do not change lifetime)
|
// Force cookie path (but do not change lifetime)
|
||||||
$cookie=session_get_cookie_params();
|
$cookie=session_get_cookie_params();
|
||||||
$cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
|
$cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
|
||||||
session_set_cookie_params($cookie['lifetime'],$cookiedir,$_SERVER['HTTP_HOST']); // Set default cookie expiration and path.
|
session_set_cookie_params($cookie['lifetime'],$cookiedir,$_SERVER['SERVER_NAME']); // Set default cookie expiration and path.
|
||||||
|
|
||||||
// Set session parameters on server side.
|
// Set session parameters on server side.
|
||||||
define('INACTIVITY_TIMEOUT',3600); // (in seconds). If the user does not access any page within this time, his/her session is considered expired.
|
define('INACTIVITY_TIMEOUT',3600); // (in seconds). If the user does not access any page within this time, his/her session is considered expired.
|
||||||
|
@ -406,14 +406,14 @@ function ban_canLogin()
|
||||||
$_SESSION['expires_on']=time()+$_SESSION['longlastingsession']; // Set session expiration on server-side.
|
$_SESSION['expires_on']=time()+$_SESSION['longlastingsession']; // Set session expiration on server-side.
|
||||||
|
|
||||||
$cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
|
$cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
|
||||||
session_set_cookie_params($_SESSION['longlastingsession'],$cookiedir,$_SERVER['HTTP_HOST']); // Set session cookie expiration on client side
|
session_set_cookie_params($_SESSION['longlastingsession'],$cookiedir,$_SERVER['SERVER_NAME']); // Set session cookie expiration on client side
|
||||||
// Note: Never forget the trailing slash on the cookie path!
|
// Note: Never forget the trailing slash on the cookie path!
|
||||||
session_regenerate_id(true); // Send cookie with new expiration date to browser.
|
session_regenerate_id(true); // Send cookie with new expiration date to browser.
|
||||||
}
|
}
|
||||||
else // Standard session expiration (=when browser closes)
|
else // Standard session expiration (=when browser closes)
|
||||||
{
|
{
|
||||||
$cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
|
$cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
|
||||||
session_set_cookie_params(0,$cookiedir,$_SERVER['HTTP_HOST']); // 0 means "When browser closes"
|
session_set_cookie_params(0,$cookiedir,$_SERVER['SERVER_NAME']); // 0 means "When browser closes"
|
||||||
session_regenerate_id(true);
|
session_regenerate_id(true);
|
||||||
}
|
}
|
||||||
// Optional redirect after login:
|
// Optional redirect after login:
|
||||||
|
@ -445,7 +445,7 @@ function serverUrl()
|
||||||
{
|
{
|
||||||
$https = (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS'])=='on')) || $_SERVER["SERVER_PORT"]=='443'; // HTTPS detection.
|
$https = (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS'])=='on')) || $_SERVER["SERVER_PORT"]=='443'; // HTTPS detection.
|
||||||
$serverport = ($_SERVER["SERVER_PORT"]=='80' || ($https && $_SERVER["SERVER_PORT"]=='443') ? '' : ':'.$_SERVER["SERVER_PORT"]);
|
$serverport = ($_SERVER["SERVER_PORT"]=='80' || ($https && $_SERVER["SERVER_PORT"]=='443') ? '' : ':'.$_SERVER["SERVER_PORT"]);
|
||||||
return 'http'.($https?'s':'').'://'.$_SERVER['HTTP_HOST'].$serverport;
|
return 'http'.($https?'s':'').'://'.$_SERVER['SERVER_NAME'].$serverport;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the absolute URL of current script, without the query.
|
// Returns the absolute URL of current script, without the query.
|
||||||
|
|
Loading…
Reference in a new issue