[Mapbender-commits] r7134 - in trunk/mapbender: core http/classes http/frames

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Nov 16 05:06:02 EST 2010


Author: christoph
Date: 2010-11-16 02:06:01 -0800 (Tue, 16 Nov 2010)
New Revision: 7134

Modified:
   trunk/mapbender/core/globalSettings.php
   trunk/mapbender/core/system.php
   trunk/mapbender/http/classes/class_checkInput.php
   trunk/mapbender/http/classes/class_json.php
   trunk/mapbender/http/classes/class_mb_log.php
   trunk/mapbender/http/frames/login.php
Log:
#720

Modified: trunk/mapbender/core/globalSettings.php
===================================================================
--- trunk/mapbender/core/globalSettings.php	2010-11-16 10:04:40 UTC (rev 7133)
+++ trunk/mapbender/core/globalSettings.php	2010-11-16 10:06:01 UTC (rev 7134)
@@ -89,15 +89,6 @@
 
 if (!defined("LOAD_JQUERY_FROM_GOOGLE")) define("LOAD_JQUERY_FROM_GOOGLE", false);
 
-//
-// database wrapper
-//
-if(SYS_DBTYPE=="mysql") {
-	require_once(dirname(__FILE__) . "/../lib/database-mysql.php"); 
-}
-else {
-	require_once(dirname(__FILE__) . "/../lib/database-pgsql.php"); 
-}
 
 //
 // class for error handling
@@ -112,14 +103,7 @@
 require_once(dirname(__FILE__) . "/../http/classes/class_locale.php");
 $localeObj = new Mb_locale(Mapbender::session()->get("mb_lang"));
 
-
 //
-// establish database connection
-//
-$con = db_connect($DBSERVER, $OWNER, $PW);
-db_select_db(DB, $con);
-
-//
 // Do not display PHP errors
 //
 ini_set("display_errors", "0");

Modified: trunk/mapbender/core/system.php
===================================================================
--- trunk/mapbender/core/system.php	2010-11-16 10:04:40 UTC (rev 7133)
+++ trunk/mapbender/core/system.php	2010-11-16 10:06:01 UTC (rev 7134)
@@ -63,7 +63,7 @@
 	"repaint,changeEPSG,User,AdminTabs,GroupEditor,GuiEditor,UserEditor,".
 	"scalebar,addWMSfromTree,mousewheelZoom,mapframe1_mousewheelZoom,doubleclickZoom," .
 	"overviewToggle,resizeMapsize,coordsLookup,selArea1,loadwmc,savewmc," . 
-	"resultList,mb_featureList_digitize,md_editor_container,md_editor_data," . 
+	"resultList,mb_featureList_digitize,md_editor_container,md_editor_data," .
 	"md_editor_navigation,md_editor_search_data,md_editor_result_data,metadata_create_data,".
 	"metadata_create_service,metadata_create_application,mb_md_selectAction,mb_md_editMetadataByData,mb_md_path," . 
 	"mb_md_editMetadataByService,mb_md_editMetadataByApplication,md_editor_xml_import," . 
@@ -110,4 +110,15 @@
     }
 }
 
+//
+// database wrapper
+//
+require_once(dirname(__FILE__) . "/../lib/database-pgsql.php");
+
+//
+// establish database connection
+//
+$con = db_connect(DBSERVER, OWNER, PW);
+db_select_db(DB, $con);
+
 ?>

Modified: trunk/mapbender/http/classes/class_checkInput.php
===================================================================
--- trunk/mapbender/http/classes/class_checkInput.php	2010-11-16 10:04:40 UTC (rev 7133)
+++ trunk/mapbender/http/classes/class_checkInput.php	2010-11-16 10:06:01 UTC (rev 7134)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
 
 class checkInput{
 	var $v;

Modified: trunk/mapbender/http/classes/class_json.php
===================================================================
--- trunk/mapbender/http/classes/class_json.php	2010-11-16 10:04:40 UTC (rev 7133)
+++ trunk/mapbender/http/classes/class_json.php	2010-11-16 10:06:01 UTC (rev 7134)
@@ -17,8 +17,6 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-
 define("JSON_PEAR", "json_pear");
 define("JSON_NATIVE", "json_native");
 

Modified: trunk/mapbender/http/classes/class_mb_log.php
===================================================================
--- trunk/mapbender/http/classes/class_mb_log.php	2010-11-16 10:04:40 UTC (rev 7133)
+++ trunk/mapbender/http/classes/class_mb_log.php	2010-11-16 10:06:01 UTC (rev 7134)
@@ -18,7 +18,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-require_once dirname(__FILE__) . "/../../core/globalSettings.php";
+require_once dirname(__FILE__) . "/../../conf/mapbender.conf";
 require_once(dirname(__FILE__)."/../classes/class_mb_notice.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_warning.php");
 require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");

Modified: trunk/mapbender/http/frames/login.php
===================================================================
--- trunk/mapbender/http/frames/login.php	2010-11-16 10:04:40 UTC (rev 7133)
+++ trunk/mapbender/http/frames/login.php	2010-11-16 10:06:01 UTC (rev 7134)
@@ -16,6 +16,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+ob_start();
+
 require_once dirname(__FILE__) . "/../../conf/mapbender.conf";
 
 function auth_user($name,$pw){
@@ -42,6 +44,16 @@
 		}
 	}
 }
+
+function redirectToLogin ($name = "") {
+	if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
+		header ("Location: https://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/login.php?name=".$name);
+	}
+	else {
+		header ("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/login.php?name=".$name);
+	}
+	die;
+}
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
@@ -120,7 +132,7 @@
 if(!isset($name) || $name == '' || !isset($password) || $password == ''){
 	echo "<form name='loginForm' action ='" . $_SERVER["SCRIPT_NAME"] . "' method='POST'>";
 	echo "<table>";
-	echo "<tr><td>Name: </td><td><input type='text' name='name' class='login_text' value=''></td></tr>";
+	echo "<tr><td>Name: </td><td><input type='text' name='name' class='login_text' value='" . htmlentities($name, ENT_QUOTES, "UTF-8") . "'></td></tr>";
 	echo "<tr><td>Password: </td><td><input type='password' name='password' class='login_text'></td></tr>";
 	echo "<tr><td></td><td><input type='submit' class='myButton' value='login' title='anmelden'>";
 	echo "&nbsp;&nbsp;<a href='../php/mod_forgottenPassword.php' title='Passwort vergessen?' target='_blank'>Forgot your password?</a>";
@@ -128,10 +140,8 @@
 	echo "</form>";
 }
 if(isset($name) && $name != '' && isset($password) && $password != ''){
-	require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-	require_once(dirname(__FILE__)."/../../lib/class_Mapbender_session.php");
+	require_once dirname(__FILE__)."/../../core/system.php";
 
-
 	$sql_count = "SELECT mb_user_login_count FROM mb_user WHERE mb_user_name = $1";
 	$params = array($name);
 	$types = array('s');
@@ -143,12 +153,18 @@
 		}
 	}
 	
+	require_once dirname(__FILE__)."/../../lib/class_Mapbender.php";
+	require_once dirname(__FILE__)."/../../lib/class_Mapbender_session.php";
 	$row = auth_user($name, $password);
 	
 	// if given user data is found in database, set session data (db_fetch_array returns false if no row is found)
 	if($row){
+		require_once dirname(__FILE__)."/../../core/globalSettings.php";
 		include(dirname(__FILE__)."/../../conf/session.conf");
-	}	
+	}
+	else {
+		redirectToLogin($name);
+	}
 	if(Mapbender::session()->get("mb_user_id")){
 		if($row["mb_user_login_count"] <= MAXLOGIN){
 			$sql_del_cnt =  "UPDATE mb_user SET mb_user_login_count = 0 WHERE mb_user_id = $1";
@@ -191,17 +207,12 @@
 		}
 	}
 	else{
+		Mapbender::session()->kill();
 		$sql_set_cnt = "UPDATE mb_user SET mb_user_login_count = (mb_user_login_count + 1) WHERE mb_user_name = $1";
 		$v = array($name);
 		$t = array('s');
 		db_prep_query($sql_set_cnt,$v,$t);				
-		if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
-			header ("Location: https://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/login.php?name=".$name);
-		}
-		else {
-			header ("Location: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/login.php?name=".$name);
-		}
-		die;
+		redirectToLogin($name);
 	}
 }
 ?>



More information about the Mapbender_commits mailing list