[Mapbender-commits] r5912 - in branches/3_dev: core/lib http/frames

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sun Apr 11 07:05:23 EDT 2010


Author: christoph
Date: 2010-04-11 07:05:21 -0400 (Sun, 11 Apr 2010)
New Revision: 5912

Modified:
   branches/3_dev/core/lib/class_User.php
   branches/3_dev/http/frames/index.php
Log:
login and portal site will be applications as well

login is now handled in http/frames/index.php

Modified: branches/3_dev/core/lib/class_User.php
===================================================================
--- branches/3_dev/core/lib/class_User.php	2010-04-11 11:04:50 UTC (rev 5911)
+++ branches/3_dev/core/lib/class_User.php	2010-04-11 11:05:21 UTC (rev 5912)
@@ -76,6 +76,17 @@
 		return (string) $this->id;	
 	}
 
+	public static function getByNameAndPassword ($name, $pw) {
+		$setEncPw = false;
+		$sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_password = $2";
+		$v = array($name, md5($pw));
+		$t = array('s', 's');
+		$res = db_prep_query($sql,$v,$t);
+		if ($row = db_fetch_array($res)) {
+			return User::byName($name);
+		}
+		return null;
+	}
 
 	public function loginCountExceeded () {
 	
@@ -492,7 +503,7 @@
 	 * @param $ignorepublic boolean whether or not to ignore 
 	 * 								public applications (?)
 	 */
-	public function getApplicationsByPermission ($ignorepublic) {
+	public function getApplicationsByPermission ($ignorepublic = false) {
 		$mb_user_id = $this->id;
 		$arrayGuis = array();
 		$mb_user_groups = array();

Modified: branches/3_dev/http/frames/index.php
===================================================================
--- branches/3_dev/http/frames/index.php	2010-04-11 11:04:50 UTC (rev 5911)
+++ branches/3_dev/http/frames/index.php	2010-04-11 11:05:21 UTC (rev 5912)
@@ -5,21 +5,72 @@
 # and Simplified BSD license.  
 # http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
 
-require_once dirname(__FILE__)."/../../core/validateSession.php";
+require_once dirname(__FILE__)."/../../core/globalSettings.php";
 require_once dirname(__FILE__)."/../../core/lib/class_Application.php";
+require_once dirname(__FILE__)."/../../core/lib/class_User.php";
 
-Mapbender::session()->set("mb_user_gui",$gui_id);
+$name = $_GET["name"];
+$password = $_GET["password"];
+$gui_id = "";
 
-//
-// check if user is allowed to access current GUI; 
-// if not, return to login screen
-//
-if (!in_array($gui_id, Mapbender::session()->get("mb_user_guis"))) {
-	$e = new mb_exception("mb_validateSession.php: User: " . Mapbender::session()->get("mb_user_id")  . " not allowed to access GUI " . $gui_id);
-	session_write_close();
-	header("Location: ".LOGIN);
-	die();
+if (!$name || !$password) {
+	if (Mapbender::session()->get("mb_user_id")) {
+		if (Mapbender::session()->get("mb_user_gui")) {
+			// open current application
+			$gui_id = Mapbender::session()->get("mb_user_gui");
+		}
+	}
+	else {
+		// open default login application as public user
+		Mapbender::session()->kill();
+		session_start();
+	}
 }
+else {
+	Mapbender::session()->kill();
+	session_start();
+  	$user = User::byName($name);
+  	if (!is_null($user) && !$user->loginCountExceeded()) {
+		$user = User::getByNameAndPassword($name, $password);
+		if (!is_null($user)) {
+  			$userLoginFailed = User::byName($name);
+  			if (!is_null($userLoginFailed)) {
+  				$userLoginFailed->incrementLoginCount();
+  			}
+		}
+		else {
+  			// session conf
+  			include(dirname(__FILE__)."/../../conf/session.conf");
+  			
+  			if (Mapbender::session()->get("mb_user_id")) {
+				if ($user->loginCount <= MAXLOGIN) {
+					$user->resetLoginCount();
+				}
+  		  		if ($_GET["mb_user_myGui"] && in_array($_GET["mb_user_myGui"], $user->getApplicationsByPermission())) {
+	  				// open application as user
+					$gui_id = $_GET["mb_user_myGui"];			
+  		  		}
+  			}
+  			else {
+  				$user->incrementLoginCount();
+  			}
+  		}
+  	}
+}
+if (!isset($user) || is_null($user)) {
+	$user = User::byName(PUBLIC_USER);
+	Mapbender::session()->set("mb_user_id", $user->id);
+}
+if (!isset($gui_id) || $gui_id === "") {
+	$gui_id = DEFAULT_APPLICATION;
+}
+
+Mapbender::session()->set("mb_user_gui", $gui_id);
+Mapbender::session()->set("mb_user_guis", $user->getApplicationsByPermission());
+
+//require_once dirname(__FILE__)."/../../core/validateSession.php";
+
+// what if there is no PUBLIC_USER or DEFAULT_APPLICATION?
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>



More information about the Mapbender_commits mailing list