[Mapbender-commits] r10027 - trunk/mapbender/core

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jan 17 08:29:08 PST 2019


Author: armin11
Date: 2019-01-17 08:29:08 -0800 (Thu, 17 Jan 2019)
New Revision: 10027

Modified:
   trunk/mapbender/core/globalSettings.php
Log:
Give the possibility to define, that a dummy public_user session should be created, if no current session exists!

Modified: trunk/mapbender/core/globalSettings.php
===================================================================
--- trunk/mapbender/core/globalSettings.php	2019-01-17 16:28:53 UTC (rev 10026)
+++ trunk/mapbender/core/globalSettings.php	2019-01-17 16:29:08 UTC (rev 10027)
@@ -53,4 +53,51 @@
 //
 require_once dirname(__FILE__) . "/../http/php/wrappers/includes.php";
 
+//
+// sets a public user session if defined in mapbender.conf
+//
+if (defined("PUBLIC_USER_AUTO_CREATE_SESSION") && PUBLIC_USER_AUTO_CREATE_SESSION) {
+    if (defined("PUBLIC_USER") && is_numeric(PUBLIC_USER)) {
+        //try to read a mb_user_name from session
+        $mb_user_name = Mapbender::session()->get("mb_user_name");
+	$e = new mb_notice("mb_user_name from session: ".$mb_user_name);
+        if(!isset($mb_user_name) || $mb_user_name == "" || $mb_user_name == false) {
+	    $e = new mb_notice("No mb_user_name found in SESSION - initialize PUBLIC_USER SESSION");
+	    $isAuthenticated = authenticate(PUBLIC_USER);
+	    if($isAuthenticated != false){  
+		    Mapbender::session()->set("mb_user_id", $isAuthenticated["mb_user_id"]);
+		    Mapbender::session()->set("mb_user_name", $isAuthenticated["mb_user_name"]);
+		    Mapbender::session()->set("mb_user_ip", $_SERVER['REMOTE_ADDR']);
+       		    Mapbender::session()->set("HTTP_HOST", $_SERVER["HTTP_HOST"]);
+                    if (defined("PUBLIC_USER_DEFAULT_SRS") && PUBLIC_USER_DEFAULT_SRS !=="") {
+                        Mapbender::session()->set("epsg", PUBLIC_USER_DEFAULT_SRS);
+		    }
+		    Mapbender::session()->set("mb_myBBOX", "");
+                    if (defined("PUBLIC_USER_DEFAULT_GUI") && PUBLIC_USER_DEFAULT_GUI !=="") {
+                        Mapbender::session()->set("mb_user_gui", PUBLIC_USER_DEFAULT_GUI);
+		    }
+		    Mapbender::session()->set("layer_preview", 0);
+		    Mapbender::session()->set("mb_user_spatial_suggest", 'nein');
+	    }
+	    require_once(dirname(__FILE__)."/../http/php/mb_getGUIs.php");
+	    $arrayGUIs = mb_getGUIs($isAuthenticated["mb_user_id"]);
+	    Mapbender::session()->set("mb_user_guis", $arrayGUIs);
+        }
+    }
+}
+
+function authenticate ($userId){
+	$con = db_connect(DBSERVER,OWNER,PW);
+	db_select_db(DB,$con);
+	$sql = "SELECT * FROM mb_user WHERE mb_user_id = $1";
+	$v = array($userId);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	if($row = db_fetch_array($res)){
+		return $row;	
+	} else {
+		return false;
+	}
+}
+
 ?>



More information about the Mapbender_commits mailing list