Browse Source

move all session handling to fody-session_start() and add cookie path param

tkas 5 months ago
parent
commit
72a167a97f
11 changed files with 18 additions and 29 deletions
  1. 1 3
      api.php
  2. 1 3
      auth.php
  3. 6 0
      common.php
  4. 3 2
      config.php
  5. 1 3
      edit.php
  6. 1 3
      import.php
  7. 1 3
      index.php
  8. 1 3
      mirror.php
  9. 1 3
      note.php
  10. 1 3
      tags.php
  11. 1 3
      terms.php

+ 1 - 3
api.php

@@ -3,9 +3,7 @@
 require_once dirname(__FILE__).'/config.php';
 require_once dirname(__FILE__).'/common.php';
 
-ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
-session_start();
-setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT);
+fody_session_start();
 
 flush_cors_headers();
 

+ 1 - 3
auth.php

@@ -3,9 +3,7 @@
 require_once dirname(__FILE__).'/config.php';
 require_once dirname(__FILE__).'/common.php';
 
-ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
-session_start();
-setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT);
+fody_session_start();
 
 $oauth = new OAuth(OSM_CONSUMER_KEY, OSM_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
 $oauth->enableDebug();

+ 6 - 0
common.php

@@ -258,4 +258,10 @@ function terms_accepted($name){ //{{{
   return $date;
 } //}}}
 
+function fody_session_start(){ //{{{
+  ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
+  session_start();
+  setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT, WEB_DIR, "", true);
+} //}}}
+
 ?>

+ 3 - 2
config.php

@@ -14,9 +14,10 @@ const SESSION_TIMEOUT = 3600;
 const COORD_DIFF_MAX = 0.0000001;
 
 # root web URL
-const WEB_ROOT = 'https://osm.fit.vutbr.cz/fody/';
+const WEB_DIR = '/fody/';
+define('WEB_ROOT', "https://osm.fit.vutbr.cz" . WEB_DIR);
 #directory to store photos
-const PHOTOS_DIR = '/mnt/data/photodb/fody-dev/';
+const PHOTOS_DIR = '/mnt/data/photodb/fody/';
 
 #minimal size of uploaded photo file
 const PHOTO_SIZE_MIN = 102400;

+ 1 - 3
edit.php

@@ -3,9 +3,7 @@
 require_once dirname(__FILE__).'/config.php';
 require_once dirname(__FILE__).'/common.php';
 
-ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
-session_start();
-setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT);
+fody_session_start();
 
 $db = pg_connect("host=".SERVER." dbname=".DATABASE." user=".USERNAME." password=".PASSWORD);
 

+ 1 - 3
import.php

@@ -13,9 +13,7 @@ $time_start = microtime(true);
 require_once dirname(__FILE__).'/config.php';
 require_once dirname(__FILE__).'/common.php';
 
-ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
-session_start();
-setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT);
+fody_session_start();
 
 $db = pg_connect("host=".SERVER." dbname=".DATABASE." user=".USERNAME." password=".PASSWORD);
 

+ 1 - 3
index.php

@@ -5,9 +5,7 @@ $time_start = microtime(true);
 require_once dirname(__FILE__).'/config.php';
 require_once dirname(__FILE__).'/common.php';
 
-ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
-session_start();
-setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT);
+fody_session_start();
 
 $db = pg_connect("host=".SERVER." dbname=".DATABASE." user=".USERNAME." password=".PASSWORD);
 

+ 1 - 3
mirror.php

@@ -5,9 +5,7 @@ $time_start = microtime(true);
 require_once dirname(__FILE__).'/config.php';
 require_once dirname(__FILE__).'/common.php';
 
-ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
-session_start();
-setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT);
+fody_session_start();
 
 $db = pg_connect("host=".SERVER." dbname=".DATABASE." user=".USERNAME." password=".PASSWORD);
 

+ 1 - 3
note.php

@@ -3,9 +3,7 @@
 require_once dirname(__FILE__).'/config.php';
 require_once dirname(__FILE__).'/common.php';
 
-ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
-session_start();
-setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT);
+fody_session_start();
 
 $db = pg_connect("host=".SERVER." dbname=".DATABASE." user=".USERNAME." password=".PASSWORD);
 

+ 1 - 3
tags.php

@@ -3,9 +3,7 @@
 require_once dirname(__FILE__).'/config.php';
 require_once dirname(__FILE__).'/common.php';
 
-ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
-session_start();
-setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT);
+fody_session_start();
 
 $db = pg_connect("host=".SERVER." dbname=".DATABASE." user=".USERNAME." password=".PASSWORD);
 

+ 1 - 3
terms.php

@@ -10,9 +10,7 @@ https://www.openstreetmap.org/copyright
 require_once dirname(__FILE__).'/config.php';
 require_once dirname(__FILE__).'/common.php';
 
-ini_set("session.gc_maxlifetime", SESSION_TIMEOUT);
-session_start();
-setcookie(session_name(),session_id(),time()+SESSION_TIMEOUT);
+fody_session_start();
 
 $db = pg_connect("host=".SERVER." dbname=".DATABASE." user=".USERNAME." password=".PASSWORD);