svn commit: r247 - trunk/mapbender/http/php/mod_gui_filteredGroup.php

uli at osgeo.org uli at osgeo.org
Thu May 11 09:49:01 EDT 2006


Author: uli
Date: 2006-05-11 13:49:00+0000
New Revision: 247

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

Log:
db_prep_query included
verification of user permissions

Modified: trunk/mapbender/http/php/mod_gui_filteredGroup.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_gui_filteredGroup.php?view=diff&rev=247&p1=trunk/mapbender/http/php/mod_gui_filteredGroup.php&p2=trunk/mapbender/http/php/mod_gui_filteredGroup.php&r1=246&r2=247
==============================================================================
--- trunk/mapbender/http/php/mod_gui_filteredGroup.php	(original)
+++ trunk/mapbender/http/php/mod_gui_filteredGroup.php	2006-05-11 13:49:00+0000
@@ -18,13 +18,11 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import_request_variables("PG");
-session_start();
-
-require_once("../php/mb_validateSession.php");
 require_once("../../conf/mapbender.conf");
-$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">
 <html>
@@ -63,9 +61,6 @@
 </head>
 <body>
 <?php
-require_once("../../conf/mapbender.conf");
-$con = db_connect($DBSERVER,$OWNER,$PW);
-db_select_db(DB,$con);
 
 require_once("../php/mb_getGUIs.php");
 
@@ -82,17 +77,21 @@
 $logged_user_name=$_SESSION["mb_user_name"];
 $logged_user_id=$_SESSION["mb_user_id"];
 
-/*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 gui_mb_group where fkey_gui_id = '".$selected_gui."' and fkey_mb_group_id = '".$selected_group[$i]."'";
-			$res_insert = db_query($sql_insert);
+			$sql_insert = "SELECT * from gui_mb_group where fkey_gui_id = $1 and fkey_mb_group_id = $2";
+			$v = array($selected_gui,$selected_group[$i]);
+			$t = array('s','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 gui_mb_group(fkey_gui_id, fkey_mb_group_id) VALUES('$selected_gui', '".$selected_group[$i]."');";
-				$res_insert = db_query($sql_insert);
+				$sql_insert = "INSERT INTO gui_mb_group(fkey_gui_id, fkey_mb_group_id) VALUES($1, $2)";
+				$v = array($selected_gui,$selected_group[$i]);
+				$t = array('s','i');
+				$res_insert = db_prep_query($sql_insert,$v,$t);
 			}
 		}
 	}
@@ -100,14 +99,16 @@
 if($remove){
 	if(count($remove_group)>0){
 		for($i=0; $i<count($remove_group); $i++){
-			$sql_remove = "DELETE FROM gui_mb_group WHERE fkey_mb_group_id = '".$remove_group[$i]."' and fkey_gui_id = '$selected_gui'";
-			db_query($sql_remove);
+			$sql_remove = "DELETE FROM gui_mb_group WHERE fkey_mb_group_id = $1 and fkey_gui_id = $2";
+			$v = array($remove_group[$i],$selected_gui);
+			$t = array('i','s');
+			db_prep_query($sql_remove,$v,$t);
 		}
 	}
 }
 
 
-/*get all gui  ********************************************************************************************/
+/*get all gui  ************************************************************************************/
 $sql_gui = "SELECT * FROM gui ORDER BY gui_name";
 
 $res_gui = db_query($sql_gui);
@@ -117,26 +118,30 @@
 	$cnt_gui++;
 }
 
-/*get owner groups **********************************************************************************************/
-#$sql_group = "SELECT * FROM mb_group ORDER BY mb_group_name";
-$sql_group = "SELECT * FROM mb_group WHERE mb_group_owner='".$logged_user_id."' ORDER BY mb_group_name";
-$res_group = db_query($sql_group);
+/*get owner groups ********************************************************************************/
+
+$sql_group = "SELECT * FROM mb_group WHERE mb_group_owner = $1 ORDER BY mb_group_name";
+$v = array($logged_user_id);
+$t = array('i');
+$res_group = db_prep_query($sql_group,$v,$t);
 while($row = db_fetch_array($res_group)){
 	$group_id[$cnt_group] = $row["mb_group_id"];
 	$group_name[$cnt_group] =  $row["mb_group_name"];
 	$cnt_group++;
 }
 
-/*get owner groups from selected gui******************************************************************************/
+/*get owner groups from selected gui***************************************************************/
 $sql_gui_group = "SELECT mb_group.mb_group_id, mb_group.mb_group_name, gui_mb_group.fkey_gui_id FROM gui_mb_group ";
 $sql_gui_group .= "INNER JOIN mb_group ON gui_mb_group.fkey_mb_group_id = mb_group.mb_group_id ";
-$sql_gui_group .= "WHERE gui_mb_group.fkey_gui_id= '";
-
-if(!$selected_gui){$sql_gui_group .= $gui_id_array[0];}
-if($selected_gui){$sql_gui_group .= $selected_gui;}
-$sql_gui_group .= "' AND mb_group.mb_group_owner = '".$logged_user_id."'";
+$sql_gui_group .= "WHERE gui_mb_group.fkey_gui_id = $1 ";
+if(!$selected_gui){$v = array($gui_id_array[0]);}
+if($selected_gui){$v = array($selected_gui);}
+$t = array('s');
+$sql_gui_group .= " AND mb_group.mb_group_owner = $2 ";
+array_push($v,$logged_user_id);
+array_push($t,'i');
 $sql_gui_group .= " ORDER BY mb_group.mb_group_name";
-$res_gui_group = db_query($sql_gui_group);
+$res_gui_group = db_prep_query($sql_gui_group,$v,$t);
 while($row = db_fetch_array($res_gui_group)){
 	$group_id_gui[$cnt_gui_group] = $row["mb_group_id"];
 	$group_name_gui[$cnt_gui_group] =  $row["mb_group_name"];
@@ -145,9 +150,9 @@
 
 
 /*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 guis in selectbox*************************************************************************************/
+/*insert guis in selectbox*************************************************************************/
 echo "<div class='text1'>GUI: </div>";
 echo "<select style='background:#ffffff' class='select1' name='selected_gui' onChange='submit()' size='10'>";
 for($i=0; $i<$cnt_gui; $i++){
@@ -159,7 +164,7 @@
 }
 echo "</select>";
 
-/*insert all groups in selectbox**************************************************************************/
+/*insert all groups in selectbox******************************************************************/
 echo "<div class='text2'>GROUP:</div><br>";
 echo "<select style='background:#ffffff' class='select2' multiple='multiple' name='selected_group[]' size='$fieldHeight' >";
 for($i=0; $i<$cnt_group; $i++){




More information about the Mapbender_commits mailing list