[Mapbender-commits] r7135 - in trunk/mapbender/http: geoportal php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Nov 16 05:50:55 EST 2010


Author: armin11
Date: 2010-11-16 02:50:55 -0800 (Tue, 16 Nov 2010)
New Revision: 7135

Added:
   trunk/mapbender/http/geoportal/authentication.php
   trunk/mapbender/http/geoportal/forgotten_password.php
   trunk/mapbender/http/geoportal/insertUserDataIntoDb.php
   trunk/mapbender/http/geoportal/mod_logout.php
   trunk/mapbender/http/geoportal/updateUserDataIntoDb.php
Modified:
   trunk/mapbender/http/php/tagCloud.php
Log:
some bugfixing and modules from geoportal.rlp project

Added: trunk/mapbender/http/geoportal/authentication.php
===================================================================
--- trunk/mapbender/http/geoportal/authentication.php	                        (rev 0)
+++ trunk/mapbender/http/geoportal/authentication.php	2010-11-16 10:50:55 UTC (rev 7135)
@@ -0,0 +1,93 @@
+<?php
+include_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../../lib/class_Mapbender_session.php");
+#$_SESSION["mb_wmc"] = "";
+$pw = $_REQUEST['password'];
+$name = $_REQUEST['name'];
+
+$e = new mb_exception('SESSION[mb_user_name]: '.$_SESSION['mb_user_name']);
+
+
+# Q4U - Michael Spitz - 16.08.2006 - Falls Cookies deaktiviert sind, muss die Session-ID an die Folgeseiten weitergereicht werden
+$URLAdd="";
+if($_COOKIE[session_name()]=="") {
+	$URLAdd="?".session_name()."=".$_REQUEST[session_name()];
+}
+
+$isAuthenticated = authenticate ($name,$pw);
+
+if($isAuthenticated != false) {
+	setSession();
+	#$_SESSION = array();
+	Mapbender::session()->set("mb_user_password",$pw); 
+  	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("mb_user_email",$isAuthenticated["mb_user_email"]);
+	Mapbender::session()->set("mb_user_department",$isAuthenticated["mb_user_department"]);
+	Mapbender::session()->set("mb_user_organisation_name",$isAuthenticated["mb_user_organisation_name"]);
+	Mapbender::session()->set("mb_user_position_name",$isAuthenticated["mb_user_position_name"]);
+	Mapbender::session()->set("mb_user_phone",$isAuthenticated["mb_user_phone"]);
+	Mapbender::session()->set("Textsize",$isAuthenticated["mb_user_textsize"]);
+	Mapbender::session()->set("Glossar",$isAuthenticated["mb_user_glossar"]);
+	Mapbender::session()->set("mb_user_description",$isAuthenticated["mb_user_description"]);
+	Mapbender::session()->set("mb_user_city",$isAuthenticated["mb_user_city"]);
+	Mapbender::session()->set("mb_user_postal_code",$isAuthenticated["mb_user_postal_code"]);
+#if(!isset($_SESSION["mb_wmc"]))
+#{
+#$_SESSION["mb_wmc"] = NULL;
+#}
+	Mapbender::session()->set("epsg","EPSG:31466");
+	Mapbender::session()->set("HTTP_HOST",$_SERVER["HTTP_HOST"]);
+	#Mapbender::session()->set("layer_preview",0);
+#$_SESSION["mb_myBBOX"] = "";
+
+//INSERT LAST LOGIN DATE AND TIME
+//NEW Filed required "ALTER TABLE mapbender.mb_user ADD COLUMN mb_user_last_login_date date;"
+	$sql = "UPDATE mb_user SET";
+	$sql .= " mb_user_last_login_date = now()";
+	$V[0] = Mapbender::session()->get('mb_user_id');
+	$T[0] = 'i';
+	$sql .= 'WHERE mb_user_id = $1';
+	$res = db_prep_query($sql, $V, $T);
+	//UPDATE USER LOGIN DATE and TIME	
+	require_once(dirname(__FILE__)."/../php/mb_getGUIs.php");
+	$arrayGUIs = mb_getGUIs($isAuthenticated["mb_user_id"]);
+	Mapbender::session()->set("mb_user_guis",$arrayGUIs);
+	header ("Location: http://".$_SERVER['HTTP_HOST']."/portal/success.html".$URLAdd);
+	session_write_close();
+} else {
+	header ("Location: http://".$_SERVER['HTTP_HOST']."/portal/failed.html".$URLAdd);
+}
+
+
+function authenticate ($name,$pw){
+ $con = db_connect(DBSERVER,OWNER,PW);
+ db_select_db(DB,$con);
+
+ $sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_password = $2";
+ $v = array($name,md5($pw)); // wird in unserer Lösung immer md5 genutzt?
+ $t = array('s','s');
+ $res = db_prep_query($sql,$v,$t);
+
+ if($row = db_fetch_array($res)){
+   $e = new mb_exception('row mb_user_name: '.$row['mb_user_name']);
+   return $row;	
+  }
+  else 
+  {
+  return false;
+  }
+}
+function setSession(){
+	session_start();
+	session_write_close();
+}
+function killSession(){
+	Mapbender::session()->kill();
+}
+
+
+
+
+?>

Added: trunk/mapbender/http/geoportal/forgotten_password.php
===================================================================
--- trunk/mapbender/http/geoportal/forgotten_password.php	                        (rev 0)
+++ trunk/mapbender/http/geoportal/forgotten_password.php	2010-11-16 10:50:55 UTC (rev 7135)
@@ -0,0 +1,53 @@
+<?php
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__)."/../classes/class_administration.php");
+
+
+import_request_variables("PG");
+
+function forgotten_password() {
+	if(
+		!isset($_REQUEST["Benutzername"]) || !isset($_REQUEST["EMail"]) || ($_REQUEST["Benutzername"] == 'guest') || 
+		empty($_REQUEST["Benutzername"]) || empty($_REQUEST["EMail"]) || 
+		!(bool)trim($_REQUEST["Benutzername"]) || !(bool)trim($_REQUEST["EMail"])
+	) {
+		return -1;
+	}
+
+	if(!USE_PHP_MAILING) {
+		return -4;
+	}
+
+	$administration = new administration();
+	define("USER_NAME", trim($_REQUEST["Benutzername"]));
+	define("USER_EMAIL",trim($_REQUEST["EMail"]));
+
+	if(
+		!$administration->getUserIdByUserName(USER_NAME) || 
+		USER_EMAIL != $administration->getEmailByUserId($administration->getUserIdByUserName(USER_NAME))
+	) {
+		return -2;
+	}
+
+	$new_password  = $administration->getRandomPassword();
+
+	$sql_update = "UPDATE mb_user SET mb_user_password = $1, mb_user_digest = $3 WHERE mb_user_id = $2";
+	$v          = array(md5($new_password),$administration->getUserIdByUserName(USER_NAME),md5(USER_NAME.";".USER_EMAIL.":".REALM.":".$new_password));
+	$t          = array("s","i");		      
+
+	if(!db_prep_query($sql_update,$v,$t)) {
+		return -3;
+	}
+
+	$email_subject = "New GeoPortal.rlp Password";
+	$email_body    = sprintf("Your new GeoPortal.rlp password is: %s",$new_password);
+
+	if(!$administration->sendEmail(NULL,NULL,USER_EMAIL,USER_NAME,$email_subject,$email_body,$error_msg)) {
+		return -4;
+	}
+
+	return 1;
+}
+
+$success = forgotten_password();
+?>

Added: trunk/mapbender/http/geoportal/insertUserDataIntoDb.php
===================================================================
--- trunk/mapbender/http/geoportal/insertUserDataIntoDb.php	                        (rev 0)
+++ trunk/mapbender/http/geoportal/insertUserDataIntoDb.php	2010-11-16 10:50:55 UTC (rev 7135)
@@ -0,0 +1,86 @@
+<?php
+# $Id: 
+# http://www.mapbender.org/index.php/Monitor_Capabilities
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# 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__)."/../../conf/mapbender.conf");
+
+	require_once(dirname(__FILE__)."/../classes/class_administration.php");
+	require_once(dirname(__FILE__)."/../../core/globalSettings.php");	
+	$mb_user_password = '';
+	$adm = new administration();
+	$con = db_connect(DBSERVER,OWNER,PW);
+	db_select_db(DB,$con);
+	///Passort generieren
+	$pool = "qwertzupasdfghkyxcvbnm";
+	$pool .= "23456789";
+	$pool .= "WERTZUPLKJHGFDSAYXCVBNM";
+	srand ((double)microtime()*1000000);
+	for($index = 0; $index < 7; $index++)	
+	{
+	    $mb_user_password .= substr($pool,(rand()%(strlen ($pool))), 1);
+	}
+	//Check if user will register as 'guest'
+	$registerAsGuest = false;	
+	if ($mb_user_name == 'guest') {
+		$registerAsGuest = true;
+	}
+	//// �berpr�fen ob User und oder Mail bereits existieren
+		$sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_email = $2";
+ 		$v = array($mb_user_name,$mb_user_email); // wird in unserer L�sung immer md5 genutzt?
+		 $t = array('s','s');
+ 		$res = db_prep_query($sql,$v,$t);
+ 		//$row = db_fetch_array($res);
+ 	$emailValid = 1;
+	if(db_numrows($res) == 0 and !($registerAsGuest)){
+	
+		$userAlreadyExists = 0;
+		/// pr�fen auf email und richtigkeit
+		if($adm->isValidEmail($mb_user_email))
+		{
+			$emailValid = 1;	
+			/////INSERT
+			if(!isset($mb_user_postal_code) || $mb_user_postal_code == ''){ $mb_user_postal_code = 0;}
+			$sql = "INSERT INTO mb_user (mb_user_name,mb_user_password,mb_user_digest,mb_user_owner,mb_user_description,mb_user_email,mb_user_phone,mb_user_department,mb_user_organisation_name,mb_user_position_name,mb_user_city,mb_user_postal_code, mb_user_textsize, mb_user_glossar) VALUES ($1, $2,$13, '1', $3, $4, $5, $6, $7, $8, $9, $10,$11,$12)";
+			$v = array($mb_user_name, md5($mb_user_password), $mb_user_description, $mb_user_email, $mb_user_phone, $mb_user_department, $mb_user_organisation_name, $mb_user_position_name, $mb_user_city, $mb_user_postal_code, 'textsize1' ,'ja',md5($mb_user_name.";".$mb_user_email.":".REALM.":".$mb_user_password));
+			$t = array('s', 's', 's', 's', 's', 's', 's', 's', 's', 'i', 's', 's');
+			$res = db_prep_query($sql, $v, $t);
+	
+			$sql = "SELECT mb_group_id FROM mb_group WHERE mb_group_name = 'guest' LIMIT 1";
+			$res = db_prep_query($sql, array(), array());
+			$row = db_fetch_array($res);
+			$group_id = $row['mb_group_id'];
+			$sql = "INSERT INTO mb_user_mb_group (fkey_mb_user_id, fkey_mb_group_id) VALUES ($1, $2)";
+			$v = array($adm->getUserIdByUserName($mb_user_name), $group_id);
+			$t = array('i', 'i');
+			$res = db_prep_query($sql, $v, $t);
+	
+			//Mailversand
+			$mailBody=$mailBody1." ".$mb_user_password." ".$mailBody2;
+			$success = $adm->sendEmail(MAILADMIN, MAILADMINNAME, $mb_user_email, $mb_user_name, 'Ihre Registrierung', $mailBody, $error_msg );
+		}
+		else
+		{
+			$emailValid = 0;	
+		}
+
+	}
+	else
+	{
+		$userAlreadyExists = 1;	
+	}
+?>

Added: trunk/mapbender/http/geoportal/mod_logout.php
===================================================================
--- trunk/mapbender/http/geoportal/mod_logout.php	                        (rev 0)
+++ trunk/mapbender/http/geoportal/mod_logout.php	2010-11-16 10:50:55 UTC (rev 7135)
@@ -0,0 +1,64 @@
+<?php
+# $Id: mod_logout.php 6728 2010-08-10 08:31:29Z christoph $
+# http://www.mapbender.org/index.php/Administration
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# 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__)."/../php/mb_validateSession.php");
+
+ob_start();
+
+require_once(dirname(__FILE__)."/../include/dyn_php.php");
+
+ignore_user_abort();
+
+if (isset($_COOKIE[session_name()])) {
+    setcookie(session_name(), '', time()-42000, '/');
+}
+
+session_destroy();
+
+$dir = preg_replace("/\\\/","/", dirname($_SERVER['SCRIPT_NAME']));
+
+if ($_GET['L'] == "en") {
+	$logout_location = "/portal/en/logout.html";
+}
+else {
+	$logout_location = "/portal/logout.html";
+}
+
+if (isset($logout_location) && $logout_location != ''){
+	header("Location: ".$logout_location);     
+}
+else {
+	if (is_file(dirname($_SERVER['SCRIPT_NAME'])."/login.php")) {
+		if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
+			header("Location: https://".$_SERVER['HTTP_HOST'].$dir."/login.php");      
+		}
+		else {
+			header("Location: http://".$_SERVER['HTTP_HOST'].$dir."/login.php");      
+		}
+	}
+	else {
+		if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
+			header("Location: https://".$_SERVER['HTTP_HOST'].preg_replace("/\/php/","/frames",$dir)."/login.php");
+		}
+		else {
+			header("Location: http://".$_SERVER['HTTP_HOST'].preg_replace("/\/php/","/frames",$dir)."/login.php");
+		}
+	}
+}
+?>

Added: trunk/mapbender/http/geoportal/updateUserDataIntoDb.php
===================================================================
--- trunk/mapbender/http/geoportal/updateUserDataIntoDb.php	                        (rev 0)
+++ trunk/mapbender/http/geoportal/updateUserDataIntoDb.php	2010-11-16 10:50:55 UTC (rev 7135)
@@ -0,0 +1,112 @@
+<?php
+#  
+# 
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#Script which is included by a typo3 script to register the users
+
+	require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+	require_once(dirname(__FILE__)."/../classes/class_administration.php");
+	$adm = new administration();
+	$con = db_connect(DBSERVER,OWNER,PW);
+	db_select_db(DB,$con);
+	// fields which should be updated
+	$fields = array();
+	// entries
+        $v = array();
+        // types
+        $t = array();
+	// start sql statement
+	$sql = "UPDATE mb_user SET";
+        $sql .= " mb_user_owner = 1"; #all users belong to the central administrator
+         //change username if field is not empty - the variables are from the calling script
+        if ($mb_user_name != '') {
+            $fields[] = array('mb_user_name', $mb_user_name, 's');
+        }
+	else
+	{
+		$mb_user_name = $_SESSION['mb_user_name'];
+	}
+        // change password if it was set
+        if ($mb_user_password != '') {
+            $fields[] = array('mb_user_password', md5($mb_user_password), 's');
+	    #$fields[] = array('mb_user_digest', md5($mb_user_name.";".$mb_user_email.":".REALM.":".$mb_user_password), 's');
+        }
+	#else
+	#{
+	#	$mb_user_password = $_SESSION['mb_user_password']; # Don't update the password for a guest user - cause no one can get a anonymous user any more - this is done with password guest!
+	#}
+  
+        //update other fields
+        $fields[] = array('mb_user_description', $mb_user_description, 's');
+        $fields[] = array('mb_user_email', $mb_user_email, 's');
+        $fields[] = array('mb_user_phone', $mb_user_phone, 's');
+        #$fields[] = array('mb_user_department', $mb_user_department, 's'); # don't update department cause it is used for some relation - TODO uncomment it when relation is obsolet
+        $fields[] = array('mb_user_organisation_name', $mb_user_organisation_name, 's');
+        $fields[] = array('mb_user_position_name', $mb_user_position_name, 's');
+        $fields[] = array('mb_user_city', $mb_user_city, 's');
+	#$e = new mb_exception("x_geoportal/updateUserIntoDb.php: digest new: ".md5($mb_user_name.";".$mb_user_email.":".REALM.":".$mb_user_password));
+	$fields[] = array('mb_user_digest', md5($mb_user_name.";".$mb_user_email.":".REALM.":".$mb_user_password), 's');
+        if(is_int($mb_user_postal_code) && $mb_user_postal_code >= 0){
+        	$fields[] = array('mb_user_postal_code', $mb_user_postal_code, 'i'); //postal_code als integer?
+	}
+        $fields[] = array('mb_user_textsize', $Textsize, 's');
+        $fields[] = array('mb_user_glossar', $Glossar, 's');
+        // build sql statement
+        foreach ($fields as $idx => $field) {
+            $sql .= ', '.$field[0].' = $'.($idx + 1);
+            $v[] = $field[1];
+            $t[] = $field[2];
+        }
+        // + where condition
+	
+        $v[] = $_SESSION["mb_user_id"];
+        $t[] = 'i';
+        $sql .= 'WHERE mb_user_id = $'.count($v);//.' AND mb_user_name != \'guest\'';
+	if  ($_SESSION["mb_user_id"] != ANONYMOUS_USER) {   	
+		$res = db_prep_query($sql, $v, $t);
+	}
+	if(!$res)
+	{
+		$e = new mb_exception("db_query($qstring)=$ret db_error=".db_error());	
+	}
+	//UPDATE of the SESSION VARS
+	$_SESSION["mb_user_email"] = $mb_user_email; 
+	$_SESSION["mb_user_department"] = $mb_user_department; 
+	$_SESSION["mb_user_organisation_name"] = $mb_user_organisation_name; 
+	$_SESSION["mb_user_position_name"] = $mb_user_position_name; 
+	$_SESSION["mb_user_phone"] = $mb_user_phone; 
+	$_SESSION["Textsize"] = $Textsize;
+	$_SESSION["Glossar"] = $Glossar;	
+	$_SESSION["mb_user_description"]= $mb_user_description;
+	$_SESSION["mb_user_city"]= $mb_user_city;
+	$_SESSION["mb_user_postal_code"]= $mb_user_postal_code;
+	
+	
+	
+	
+/*	//Push registrated user into ANONYMOUS_GROUP guest????
+	$sql = "SELECT mb_group_id FROM mb_group WHERE mb_group_name = 'guest' LIMIT 1";
+	$res = db_prep_query($sql, array(), array());
+	$row = db_fetch_array($res);
+	$group_id = $row['mb_group_id'];
+	$sql = "INSERT INTO mb_user_mb_group (fkey_mb_user_id, fkey_mb_group_id) VALUES ($1, $2)";
+	$v = array($adm->getUserIdByUserName($mb_user_name), $group_id);
+	$t = array('i', 'i');
+	$res = db_prep_query($sql, $v, $t);
+*/
+?>

Modified: trunk/mapbender/http/php/tagCloud.php
===================================================================
--- trunk/mapbender/http/php/tagCloud.php	2010-11-16 10:06:01 UTC (rev 7134)
+++ trunk/mapbender/http/php/tagCloud.php	2010-11-16 10:50:55 UTC (rev 7135)
@@ -8,6 +8,7 @@
 $pathToSearchScript = '/portal/servicebereich/suche.html?cat=dienste&searchfilter=';
 $languageCode = 'de';
 $maxFontSize = 40;
+$minFontSize = 10;
 $maxObjects = 10;
 $outputFormat = 'html';
 $hostName = $_SERVER['HTTP_HOST'];
@@ -123,7 +124,7 @@
 $i = 0;
 //max pixelsize
 
-$inc = $maxFontSize/$maxObjects;//maybe 10 or 5 or ...
+$inc = ($maxFontSize-$minFontSize)/$maxObjects;//maybe 10 or 5 or ...
 $maxWeight = 0;
 
 while($row = db_fetch_array($res)){
@@ -143,7 +144,7 @@
 
 for($i=0; $i<count($tags); $i++){
 	if ($scale == 'linear'){
-		$tags[$i]['weight'] = $maxFontSize-($i*$inc);
+		$tags[$i]['weight'] = $minFontSize+($i*$inc);
 	} else {
 		$tags[$i]['weight'] = $tags[$i]['weight']*$maxFontSize/$maxWeight;
 	}



More information about the Mapbender_commits mailing list