svn commit: r227 - trunk/mapbender/http/php/mod_user_group.php

uli at osgeo.org uli at osgeo.org
Thu May 11 02:37:18 EDT 2006


Author: uli
Date: 2006-05-11 06:37:18+0000
New Revision: 227

Modified:
   trunk/mapbender/http/php/mod_user_group.php

Log:
db_prep_query included
verification of user permissions

Modified: trunk/mapbender/http/php/mod_user_group.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_user_group.php?view=diff&rev=227&p1=trunk/mapbender/http/php/mod_user_group.php&p2=trunk/mapbender/http/php/mod_user_group.php&r1=226&r2=227
==============================================================================
--- trunk/mapbender/http/php/mod_user_group.php	(original)
+++ trunk/mapbender/http/php/mod_user_group.php	2006-05-11 06:37:18+0000
@@ -18,15 +18,11 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import_request_variables("PG");
-session_start();
-
-require_once("mb_validateSession.php");
-require_once("mb_validateInput.php");
 require_once("../../conf/mapbender.conf");
-require_once("../classes/class_wms.php"); 
-$con = db_connect($DBSERVER,$OWNER,$PW);
+$con = db_connect(DBSERVER,OWNER,PW);
 db_select_db(DB,$con);
-$gui_id = $_SESSION["mb_user_gui"];
+require_once("../php/mb_validatePermission.php");
+$self = $PHP_SELF . "?".SID."&guiID=".$_REQUEST["guiID"]."&elementID=".$_REQUEST["elementID"];
 
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -80,17 +76,21 @@
 $cnt_group_group = 0;
 $exists = false;
 
-/*handle remove, update and insert**************************************************************************************/
+/*handle remove, update and insert*****************************************************************/
 if($insert){
 	if(count($selected_group)>0){
 		for($i=0; $i<count($selected_group); $i++){
 			$exists = false;
-			$sql_insert = "SELECT * from mb_user_mb_group where fkey_mb_user_id = '".$selected_user."' and fkey_mb_group_id = '".$selected_group[$i]."'";
-			$res_insert = db_query($sql_insert);
+			$sql_insert = "SELECT * from mb_user_mb_group where fkey_mb_user_id = $1 and fkey_mb_group_id = $2 ";
+			$v = array($selected_user,$selected_group[$i]);
+			$t = array('i','i');
+			$res_insert = db_prep_query($sql_insert,$v,$t);
 			while(db_fetch_row($res_insert)){$exists = true;}
 			if($exists == false){
-    			$sql_insert = "INSERT INTO mb_user_mb_group(fkey_mb_user_id, fkey_mb_group_id) VALUES('$selected_user', '".$selected_group[$i]."');";
-				$res_insert = db_query($sql_insert);
+    			$sql_insert = "INSERT INTO mb_user_mb_group(fkey_mb_user_id, fkey_mb_group_id) VALUES($1,$2)";
+    			$v = array($selected_user,$selected_group[$i]);
+    			$t = array('i','i');
+				$res_insert = db_prep_query($sql_insert,$v,$t);
 			}
 		}
 	}
@@ -98,8 +98,10 @@
 if($remove){
 	if(count($remove_group)>0){
 		for($i=0; $i<count($remove_group); $i++){
-			$sql_remove = "DELETE FROM mb_user_mb_group WHERE fkey_mb_group_id = '".$remove_group[$i]."' and fkey_mb_user_id = '$selected_user'";
-			db_query($sql_remove);
+			$sql_remove = "DELETE FROM mb_user_mb_group WHERE fkey_mb_group_id = $1 and fkey_mb_user_id = $2";
+			$v = array($remove_group[$i],$selected_user);
+			$t = array('i','i');
+			db_prep_query($sql_remove,$v,$t);
 		}
 	}
 }
@@ -125,12 +127,14 @@
 /*get all group from selected_user******************************************************************************/
 $sql_user_mb_group = "SELECT mb_group.mb_group_id, mb_group.mb_group_name, mb_user_mb_group.fkey_mb_user_id FROM mb_user_mb_group ";
 $sql_user_mb_group .= "INNER JOIN mb_group ON mb_user_mb_group.fkey_mb_group_id = mb_group.mb_group_id ";
-$sql_user_mb_group .= "WHERE mb_user_mb_group.fkey_mb_user_id='";
+$sql_user_mb_group .= "WHERE mb_user_mb_group.fkey_mb_user_id = $1 ";
+$sql_user_mb_group .= " ORDER BY mb_group.mb_group_name";
+
+if(!$selected_user){$v = array($user_id[0]);}
+if($selected_user){$v = array($selected_user);}
+$t = array('i');
 
-if(!$selected_user){$sql_user_mb_group .= $user_id[0];}
-if($selected_user){$sql_user_mb_group .= $selected_user;}
-$sql_user_mb_group .= "' ORDER BY mb_group.mb_group_name";
-$res_user_mb_group = db_query($sql_user_mb_group);
+$res_user_mb_group = db_prep_query($sql_user_mb_group,$v,$t);
 while($row = db_fetch_array($res_user_mb_group)){
 	$group_id_user[$cnt_group_user] = $row["mb_group_id"];
 	$group_name_user[$cnt_group_user] =  $row["mb_group_name"];
@@ -138,7 +142,7 @@
 }
 
 /*INSERT HTML*/
-echo "<form name='form1' action='" . $PHP_SELF . "?".SID."&e_id_css=".$_REQUEST["e_id_css"]."' method='post'>";
+echo "<form name='form1' action='" . $self ."' method='post'>";
 
 /*insert all user in selectbox*************************************************************************************/
 echo "<div class='text1'>USER: </div>";




More information about the Mapbender_commits mailing list