aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornodiscc <nodiscc@gmail.com>2015-01-26 14:49:56 +0100
committernodiscc <nodiscc@gmail.com>2015-01-26 14:49:56 +0100
commit09850e6a20b43a50ef28ebeeeb13f27597cd7831 (patch)
tree813e6a1585f819d1fb467506e95eeb93eea65474
parent4e7b1bf6986ed99586d04aa5b7c7154089457d0f (diff)
parent2f32d0746b55243477837d5713e8d28056bb2f90 (diff)
downloadShaarli-09850e6a20b43a50ef28ebeeeb13f27597cd7831.tar.gz
Shaarli-09850e6a20b43a50ef28ebeeeb13f27597cd7831.tar.zst
Shaarli-09850e6a20b43a50ef28ebeeeb13f27597cd7831.zip
Merge pull request #98 from ArthurHoaro/port
Fix port/server config problems by using php SERVER_NAME instead of HTTP_HOST
-rw-r--r--index.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/index.php b/index.php
index 47293240..d48e388e 100644
--- a/index.php
+++ b/index.php
@@ -47,7 +47,7 @@ define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUES
47// Force cookie path (but do not change lifetime) 47// Force cookie path (but do not change lifetime)
48$cookie=session_get_cookie_params(); 48$cookie=session_get_cookie_params();
49$cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/'; 49$cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
50session_set_cookie_params($cookie['lifetime'],$cookiedir,$_SERVER['HTTP_HOST']); // Set default cookie expiration and path. 50session_set_cookie_params($cookie['lifetime'],$cookiedir,$_SERVER['SERVER_NAME']); // Set default cookie expiration and path.
51 51
52// Set session parameters on server side. 52// Set session parameters on server side.
53define('INACTIVITY_TIMEOUT',3600); // (in seconds). If the user does not access any page within this time, his/her session is considered expired. 53define('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 @@ if (isset($_POST['login']))
406 $_SESSION['expires_on']=time()+$_SESSION['longlastingsession']; // Set session expiration on server-side. 406 $_SESSION['expires_on']=time()+$_SESSION['longlastingsession']; // Set session expiration on server-side.
407 407
408 $cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/'; 408 $cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
409 session_set_cookie_params($_SESSION['longlastingsession'],$cookiedir,$_SERVER['HTTP_HOST']); // Set session cookie expiration on client side 409 session_set_cookie_params($_SESSION['longlastingsession'],$cookiedir,$_SERVER['SERVER_NAME']); // Set session cookie expiration on client side
410 // Note: Never forget the trailing slash on the cookie path! 410 // Note: Never forget the trailing slash on the cookie path!
411 session_regenerate_id(true); // Send cookie with new expiration date to browser. 411 session_regenerate_id(true); // Send cookie with new expiration date to browser.
412 } 412 }
413 else // Standard session expiration (=when browser closes) 413 else // Standard session expiration (=when browser closes)
414 { 414 {
415 $cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/'; 415 $cookiedir = ''; if(dirname($_SERVER['SCRIPT_NAME'])!='/') $cookiedir=dirname($_SERVER["SCRIPT_NAME"]).'/';
416 session_set_cookie_params(0,$cookiedir,$_SERVER['HTTP_HOST']); // 0 means "When browser closes" 416 session_set_cookie_params(0,$cookiedir,$_SERVER['SERVER_NAME']); // 0 means "When browser closes"
417 session_regenerate_id(true); 417 session_regenerate_id(true);
418 } 418 }
419 // Optional redirect after login: 419 // Optional redirect after login:
@@ -445,7 +445,7 @@ function serverUrl()
445{ 445{
446 $https = (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS'])=='on')) || $_SERVER["SERVER_PORT"]=='443'; // HTTPS detection. 446 $https = (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS'])=='on')) || $_SERVER["SERVER_PORT"]=='443'; // HTTPS detection.
447 $serverport = ($_SERVER["SERVER_PORT"]=='80' || ($https && $_SERVER["SERVER_PORT"]=='443') ? '' : ':'.$_SERVER["SERVER_PORT"]); 447 $serverport = ($_SERVER["SERVER_PORT"]=='80' || ($https && $_SERVER["SERVER_PORT"]=='443') ? '' : ':'.$_SERVER["SERVER_PORT"]);
448 return 'http'.($https?'s':'').'://'.$_SERVER['HTTP_HOST'].$serverport; 448 return 'http'.($https?'s':'').'://'.$_SERVER['SERVER_NAME'].$serverport;
449} 449}
450 450
451// Returns the absolute URL of current script, without the query. 451// Returns the absolute URL of current script, without the query.