[Mapbender-commits] r2290 - in branches/nimix_dev: http/classes
http/frames owsproxy/http owsproxy/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Mar 25 09:48:53 EDT 2008
Author: nimix
Date: 2008-03-25 09:48:53 -0400 (Tue, 25 Mar 2008)
New Revision: 2290
Modified:
branches/nimix_dev/http/classes/class_administration.php
branches/nimix_dev/http/frames/login.php
branches/nimix_dev/owsproxy/http/classes/class_QueryHandler.php
branches/nimix_dev/owsproxy/http/index.php
Log:
add external owsproxy access
Modified: branches/nimix_dev/http/classes/class_administration.php
===================================================================
--- branches/nimix_dev/http/classes/class_administration.php 2008-03-25 11:07:20 UTC (rev 2289)
+++ branches/nimix_dev/http/classes/class_administration.php 2008-03-25 13:48:53 UTC (rev 2290)
@@ -29,6 +29,48 @@
* @uses phpmailer
*/
class administration{
+ /**
+ * authentificates a user
+ * @param string name of the user
+ * @param string passwort for the user
+ * @return mixed row of the user in db if authentification was successful or false otherwise
+ */
+ function authUser($name,$pw){
+ $setEncPw = false;
+ $sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_password = $2";
+ $v = array($name,md5($pw));
+ $t = array('s','s');
+ $res = db_prep_query($sql,$v,$t);
+ if($row = db_fetch_array($res)){
+ return $row;
+ }
+ else if(SYS_DBTYPE == 'pgsql' && $setEncPw == true){
+ // unencrypted pw in postgres without md5-support?
+ $sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_password = $2";
+ $v = array($name,$pw);
+ $t = array('s','s');
+ $resn = db_prep_query($sql,$v,$t);
+ if($rown = db_fetch_array($resn)){
+ $sqlu = "UPDATE mb_user SET mb_user_password = $1 WHERE mb_user_id = $2";
+ $vu = array(md5($pw),$rown["mb_user_id"]);
+ $tu = array('s','i');
+ $rowu = db_prep_query($sqlu,$vu,$tu);
+ return $rown;
+ }
+ }
+ else if(SYS_DBTYPE == 'mysql' && $setEncPw == true){
+ $sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_password = password($2)";
+ $v = array($name,$pw);
+ $resn = db_prep_query($sql,$v,$t);
+ if($rown = db_fetch_array($resn)){
+ $sqlu = "UPDATE mb_user SET mb_user_password = $1 WHERE mb_user_id = $2";
+ $vu = array(md5($pw),$rown["mb_user_id"]);
+ $tu = array('s','i');
+ $rowu = db_prep_query($sqlu,$vu,$tu);
+ return $rown;
+ }
+ }
+ }
/**
* checks whether the passed email-address is valid / following a pattern
* @todo is this an exact representation of the RFC 2822?
Modified: branches/nimix_dev/http/frames/login.php
===================================================================
--- branches/nimix_dev/http/frames/login.php 2008-03-25 11:07:20 UTC (rev 2289)
+++ branches/nimix_dev/http/frames/login.php 2008-03-25 13:48:53 UTC (rev 2290)
@@ -18,45 +18,11 @@
ob_start();
include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__) . "/../classes/class_administration.php");
$con = db_connect(DBSERVER,OWNER,PW);
db_select_db(DB,$con);
-function auth_user($name,$pw){
- $setEncPw = false;
- $sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_password = $2";
- $v = array($name,md5($pw));
- $t = array('s','s');
- $res = db_prep_query($sql,$v,$t);
- if($row = db_fetch_array($res)){
- return $row;
- }
- else if(SYS_DBTYPE == 'pgsql' && $setEncPw == true){
- // unencrypted pw in postgres without md5-support?
- $sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_password = $2";
- $v = array($name,$pw);
- $t = array('s','s');
- $resn = db_prep_query($sql,$v,$t);
- if($rown = db_fetch_array($resn)){
- $sqlu = "UPDATE mb_user SET mb_user_password = $1 WHERE mb_user_id = $2";
- $vu = array(md5($pw),$rown["mb_user_id"]);
- $tu = array('s','i');
- $rowu = db_prep_query($sqlu,$vu,$tu);
- return $rown;
- }
- }
- else if(SYS_DBTYPE == 'mysql' && $setEncPw == true){
- $sql = "SELECT * FROM mb_user WHERE mb_user_name = $1 AND mb_user_password = password($2)";
- $v = array($name,$pw);
- $resn = db_prep_query($sql,$v,$t);
- if($rown = db_fetch_array($resn)){
- $sqlu = "UPDATE mb_user SET mb_user_password = $1 WHERE mb_user_id = $2";
- $vu = array(md5($pw),$rown["mb_user_id"]);
- $tu = array('s','i');
- $rowu = db_prep_query($sqlu,$vu,$tu);
- return $rown;
- }
- }
-}
+
function setSession(){
session_start();
}
@@ -143,7 +109,8 @@
}
}
- $row = auth_user($name, $password);
+ $n = new administration();
+ $row = $n->authUser($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){
Modified: branches/nimix_dev/owsproxy/http/classes/class_QueryHandler.php
===================================================================
--- branches/nimix_dev/owsproxy/http/classes/class_QueryHandler.php 2008-03-25 11:07:20 UTC (rev 2289)
+++ branches/nimix_dev/owsproxy/http/classes/class_QueryHandler.php 2008-03-25 13:48:53 UTC (rev 2290)
@@ -73,6 +73,12 @@
if($key == 'sid'){
return false;
}
+ if($key == 'name'){
+ return false;
+ }
+ if($key == 'password'){
+ return false;
+ }
else if($key == $this->owsproxyServiceKey){
return false;
}
Modified: branches/nimix_dev/owsproxy/http/index.php
===================================================================
--- branches/nimix_dev/owsproxy/http/index.php 2008-03-25 11:07:20 UTC (rev 2289)
+++ branches/nimix_dev/owsproxy/http/index.php 2008-03-25 13:48:53 UTC (rev 2290)
@@ -35,20 +35,38 @@
$owsproxyService = $_REQUEST['wms']; //ToDo: change this to 'service' in the apache url-rewriting
$query = new QueryHandler();
+$n = new administration();
// an array with keys and values toLoserCase -> caseinsensitiv
$reqParams = $query->getRequestParams();
$notice = new mb_notice("owsproxy id:".$query->getOwsproxyServiceId());
-// check session
-session_id($_REQUEST["sid"]);
-session_start();
-if(!$_SESSION['mb_user_id']){
- $notice = new mb_notice("Permission denied");
- throwE("Permission denied");
- die();
-}
+$user_id = '';
+$name = $_REQUEST["name"];
+$password = $_REQUEST["password"];
+
+//look if username and password is given
+if(isset($name) && $name != '' && isset($password) && $password != ''){
+ $user_row = $n->authUser($_REQUEST["name"], $_REQUEST["password"]);
+ if(!$user_row){
+ $notice = new mb_notice("Permission denied");
+ throwE("Permission denied");
+ die();
+ }
+ $user_id = $user_row["mb_user_id"];
+}
+else{
+ // check session
+ session_id($_REQUEST["sid"]);
+ session_start();
+ if(!$_SESSION['mb_user_id']){
+ $notice = new mb_notice("Permission denied");
+ throwE("Permission denied");
+ die();
+ }
+ $user_id = $_SESSION['mb_user_id'];
+}
//if($_SESSION['mb_user_ip'] != $_SERVER['REMOTE_ADDR']){
// throwE(array("No session data available.","Permission denied.","Please authenticate."));
@@ -56,7 +74,6 @@
//}
/************* workflow ************/
-$n = new administration();
switch (strtolower($reqParams['request'])) {
case 'getcapabilities':
$arrayOnlineresources = checkWmsPermission($query->getOwsproxyServiceId());
@@ -428,8 +445,8 @@
* @return array array with detailed information about requested wms
*/
function checkWmsPermission($wms){
- global $con, $n;
- $myguis = $n->getGuisByPermission($_SESSION["mb_user_id"],true);
+ global $con, $n, $user_id;
+ $myguis = $n->getGuisByPermission($user_id,true);
$mywms = $n->getWmsByOwnGuis($myguis);
$sql = "SELECT * FROM wms WHERE wms_owsproxy = $1";
@@ -464,8 +481,8 @@
* @return array array with detailed information on reqested wfs
*/
function checkWfsPermission($wfsOws, $features){
- global $con, $n;
- $myconfs = $n->getWfsConfByPermission($_SESSION["mb_user_id"]);
+ global $con, $n, $user_id;
+ $myconfs = $n->getWfsConfByPermission($user_id);
//check if we know the features requested
if(count($features) == 0){
@@ -522,12 +539,12 @@
}
function checkLayerPermission($wms_id,$l){
- global $n, $owsproxyService;
+ global $n, $owsproxyService, $user_id;
// $notice = new mb_notice("owsproxy: checkLayerpermission: wms: ".$wms_id.", layer: ".$l);
$myl = split(",",$l);
$r = array();
foreach($myl as $mysl){
- if($n->getLayerPermission($wms_id, $mysl, $_SESSION["mb_user_id"]) === true){
+ if($n->getLayerPermission($wms_id, $mysl, $user_id) === true){
array_push($r, $mysl);
}
}
More information about the Mapbender_commits
mailing list