svn commit: r231 - trunk/mapbender/http/php/mod_filteredGroup_Gui.php

uli at osgeo.org uli at osgeo.org
Thu May 11 03:34:15 EDT 2006


Author: uli
Date: 2006-05-11 07:34:15+0000
New Revision: 231

Modified:
   trunk/mapbender/http/php/mod_filteredGroup_Gui.php   (contents, props changed)

Log:
keywords added
db_prep_query included
verification of user permissions

Modified: trunk/mapbender/http/php/mod_filteredGroup_Gui.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_filteredGroup_Gui.php?view=diff&rev=231&p1=trunk/mapbender/http/php/mod_filteredGroup_Gui.php&p2=trunk/mapbender/http/php/mod_filteredGroup_Gui.php&r1=230&r2=231
==============================================================================
--- trunk/mapbender/http/php/mod_filteredGroup_Gui.php	(original)
+++ trunk/mapbender/http/php/mod_filteredGroup_Gui.php	2006-05-11 07:34:15+0000
@@ -1,6 +1,7 @@
 <?php
-# $Id: mod_filteredGroup_Gui.php,v 1.15 2006/03/09 10:56:23 uli_rothstein Exp $
-# $Header: /cvsroot/mapbender/mapbender/http/php/mod_filteredGroup_Gui.php,v 1.15 2006/03/09 10:56:23 uli_rothstein Exp $
+# $Id$
+# http://www.mapbender.org/index.php/Administration
+#
 # Copyright (C) 2002 CCGIS 
 #
 # This program is free software; you can redistribute it and/or modify
@@ -17,13 +18,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-session_start();
 import_request_variables("PG");
-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>
@@ -37,8 +38,8 @@
 <script language="JavaScript">
 function validate(wert){
 	if(document.forms[0]["selected_group"].selectedIndex == -1){
-			document.getElementsByName("selected_group")[0].style.backgroundColor = '#ff0000';
-			return;
+		document.getElementsByName("selected_group")[0].style.backgroundColor = '#ff0000';
+		return;
 	}else{
 		if(wert == "remove"){
 			if(document.forms[0]["remove_gui[]"].selectedIndex == -1){
@@ -63,9 +64,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");
 
@@ -83,19 +81,24 @@
 $logged_user_id=$_SESSION["mb_user_id"];
 
 
-/*handle remove, update and insert**************************************************************************************/
+/*handle remove, update and insert*****************************************************************/
 if($insert){
 	if(count($selected_gui)>0){
 		for($i=0; $i<count($selected_gui); $i++){
 			$exists = false;
-			if($selected_group == NULL || $selected_group == '' || $selected_group < 0)
-				{$selected_group == "NULL";}
-			$sql_insert = "SELECT * from gui_mb_group where fkey_mb_group_id = '".$selected_group."' and fkey_gui_id = '".$selected_gui[$i]."'";
-			$res_insert = db_query($sql_insert);
+			if($selected_group == NULL || $selected_group == '' || $selected_group < 0){
+				$selected_group == "NULL";
+			}
+			$sql_insert = "SELECT * from gui_mb_group where fkey_mb_group_id = $1 and fkey_gui_id = $2 ";
+			$v = array($selected_group,$selected_gui[$i]);
+			$t = array('i','s');
+			$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_mb_group_id, fkey_gui_id) VALUES('$selected_group', '".$selected_gui[$i]."');";
-				$res_insert = db_query($sql_insert);
+				$sql_insert = "INSERT INTO gui_mb_group(fkey_mb_group_id, fkey_gui_id) VALUES($1, $2)";
+				$v = array($selected_group,$selected_gui[$i]);
+				$t = array('i','s');
+				$res_insert = db_prep_query($sql_insert,$v,$t);
 			}
 		}
 	}
@@ -103,8 +106,10 @@
 if($remove){
 	if(count($remove_gui)>0){
 		for($i=0; $i<count($remove_gui); $i++){
-			$sql_remove = "DELETE FROM gui_mb_group WHERE fkey_gui_id = '".$remove_gui[$i]."' and fkey_mb_group_id = '$selected_group'";
-			db_query($sql_remove);
+			$sql_remove = "DELETE FROM gui_mb_group WHERE fkey_gui_id = $1 and fkey_mb_group_id = $2";
+			$v = array($remove_gui[$i],$selected_group);
+			$t = array('s','i');
+			db_prep_query($sql_remove,$v,$t);
 		}
 	}
 }
@@ -120,9 +125,10 @@
 }
 
 /*get owner group **********************************************************************************************/
-#$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);
+$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"];
@@ -134,23 +140,24 @@
 
 $sql_group_mb_gui = "SELECT gui.gui_id, gui.gui_name, gui_mb_group.fkey_mb_group_id FROM gui_mb_group ";
 $sql_group_mb_gui .= "INNER JOIN gui ON gui_mb_group.fkey_gui_id = gui.gui_id ";
-$sql_group_mb_gui .= "WHERE gui_mb_group.fkey_mb_group_id=";
+$sql_group_mb_gui .= "WHERE gui_mb_group.fkey_mb_group_id = $1 ";
+$sql_group_mb_gui .= " ORDER BY gui.gui_name";
+
 if(!$selected_group){
 	if($group_id[0] > 0)
-		$sql_group_mb_gui .= $group_id[0];
+		$v = array($group_id[0]);
 	else
-		$sql_group_mb_gui .= "NULL";
+		$v = array("NULL");
 }
 if($selected_group){
 	if($selected_group >= 0)
-		$sql_group_mb_gui .= $selected_group;
+		$v = array($selected_group);
 	else
-		$sql_group_mb_gui .= "NULL";
+		$v = array("NULL");
 }
+$t = array('i');
 
-$sql_group_mb_gui .= " ORDER BY gui.gui_name";
-
-$res_group_mb_gui = db_query($sql_group_mb_gui);
+$res_group_mb_gui = db_prep_query($sql_group_mb_gui,$v,$t);
 while($row = db_fetch_array($res_group_mb_gui)){
 	$gui_id_group[$cnt_gui_group] = $row["gui_id"];
 	$gui_name_group[$cnt_gui_group] =  $row["gui_name"];
@@ -158,9 +165,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 all group in selectbox*************************************************************************************/
+/*insert all group in selectbox********************************************************************/
 echo "<div class='text1'>GROUP: </div>";
 echo "<select style='background:#ffffff' class='select1' name='selected_group' onChange='submit()' size='10'>";
 for($i=0; $i<$cnt_group; $i++){
@@ -172,7 +179,7 @@
 }
 echo "</select>";
 
-/*insert all gui in selectbox**************************************************************************/
+/*insert all gui in selectbox**********************************************************************/
 echo "<div class='text2'>GUI:</div>";
 echo "<select style='background:#ffffff' class='select2' multiple='multiple' name='selected_gui[]' size='$fieldHeight' >";
 for($i=0; $i<$cnt_gui; $i++){
@@ -180,7 +187,7 @@
 }
 echo "</select>";
 
-/*Button****************************************************************************************************/
+/*Button*******************************************************************************************/
 
 echo "<div class='button1'><input type='button'  value='==>' onClick='validate(\"insert\")'></div>";
 echo "<input type='hidden' name='insert'>";




More information about the Mapbender_commits mailing list