[Mapbender-commits] r8543 - branches/2.7/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Jan 18 00:56:13 PST 2013
Author: theklaw
Date: 2013-01-18 00:56:13 -0800 (Fri, 18 Jan 2013)
New Revision: 8543
Modified:
branches/2.7/http/php/mod_updateWMS.php
Log:
"Update WMS" functionality with http authentification (to update a password protected service) ticket 886
Modified: branches/2.7/http/php/mod_updateWMS.php
===================================================================
--- branches/2.7/http/php/mod_updateWMS.php 2013-01-17 14:57:50 UTC (rev 8542)
+++ branches/2.7/http/php/mod_updateWMS.php 2013-01-18 08:56:13 UTC (rev 8543)
@@ -24,6 +24,16 @@
$selWMS = $_POST["selWMS"];
$capURL = $_POST["capURL"];
$myWMS = $_POST["myWMS"];
+
+#new for HTTP Authentication
+ $imrAuthName = !empty($_POST['imrAuthName']) ? $_POST['imrAuthName'] : '';
+ $imrAuthPassword = !empty($_POST['imrAuthPassword']) ? $_POST['imrAuthPassword'] : '';
+ $imrHttpAuth = !empty($_POST['imrHttpAuth']) ? $_POST['imrHttpAuth'] : '';
+ $imrOldAuthType = !empty($_POST['imrOldAuthType']) ? $_POST['imrOldAuthType'] : '';
+ $imrOldAuthName = !empty($_POST['imrOldAuthName']) ? $_POST['imrOldAuthName'] : '';
+ $imrOldAuthPasswword = !empty($_POST['imrOldAuthPassword']) ? $_POST['imrOldAuthPassword'] : '';
+#new for HTTP Authentication
+
$myURL = $_POST["myURL"];
$secParams = SID."&guiID=".$_REQUEST["guiID"]."&elementID=".$_REQUEST["elementID"];
@@ -42,6 +52,30 @@
include '../include/dyn_css.php';
?>
<script type='text/javascript'>
+
+
+//new for HTTP Authentication
+ function toggleAuthDivVis() {
+ //alert(getRadioValue(document.form1.imrHttpAuth));
+ if (getRadioValue(document.form1.imrHttpAuth) != 'none' && getRadioValue(document.form1.imrHttpAuth) != 'keep') {
+ document.getElementById("imrAuthDiv").style.display = "block";
+ } else {
+ document.getElementById("imrAuthDiv").style.display = "none";
+ }
+ }
+
+ function getRadioValue(rObj) {
+ for (var i=0; i<rObj.length; i++) if (rObj[i].checked) return rObj[i].value;
+ return false;
+ }
+
+ function reupload(){
+ document.form1.myURL.value = document.form1.capURL.value;
+ validate();
+ }
+//new for HTTP Authentication
+
+
function validate(){
var ind = document.form1.selWMS.selectedIndex;
if(ind < 0){
@@ -55,8 +89,29 @@
function sel(){
var ind = document.form1.selWMS.selectedIndex;
var wmsData = document.form1.selWMS.options[ind].value.split("###");
+
+//new for HTTP Authentication
+ //alert(wmsData[3]);
+ if (wmsData[3] != '') {
+ document.form1.capURL.style.backgroundColor = "#ff0000";
+ document.form1.capURL.style.color = "#ffffff";
+ } else {
+ document.form1.capURL.style.backgroundColor = "#ffffff";
+ document.form1.capURL.style.color = "#000000";
+ }
+//new for HTTP Authentication
+
+
document.form1.capURL.value = wmsData[1];
document.form1.myWMS.value = wmsData[0];
+
+//new for HTTP Authentication
+ document.form1.imrOldAuthType.value = wmsData[3];
+ document.form1.imrOldAuthName.value = wmsData[4];
+ document.form1.imrOldAuthPassword.value = wmsData[5];
+//new for HTTP Authentication
+
+
//new for showing metadata - 30.05.2008 AR
document.getElementById("metadatalink").href = "mod_layerMetadata.php?id="+wmsData[2];
document.getElementById("metadatatext").firstChild.nodeValue = "WMS-ID: "+wmsData[0];
@@ -82,7 +137,13 @@
$t = array();
$c = 1;
//$sql = "SELECT wms_id, wms_title, wms_getcapabilities, wms_upload_url FROM wms ";
- $sql = "SELECT wms.wms_id, wms.wms_title, wms.wms_getcapabilities, wms.wms_upload_url, layer.layer_id FROM wms, layer ";
+
+ //new for HTTP Authentication
+ // $sql = "SELECT wms.wms_id, wms.wms_title, wms.wms_getcapabilities, wms.wms_upload_url, layer.layer_id FROM wms, layer ";
+ $sql = "SELECT wms.wms_id, wms.wms_title, wms.wms_getcapabilities, wms.wms_upload_url, wms.wms_auth_type, ";
+ $sql .= "wms.wms_username, wms.wms_password, layer.layer_id FROM wms, layer ";
+ //new for HTTP Authentication
+
$sql .= "WHERE wms_id IN(";
for($i=0; $i<count($wms_id_own); $i++){
if($wms_id_own[$i] != ''){
@@ -102,7 +163,14 @@
echo "<select name='selWMS' size='15' onchange='sel()'>";
while($row = db_fetch_array($res)){
//echo "<option value='".$row['wms_id']."###".$row['wms_upload_url']."'>".$row['wms_title']."</option>";
- echo "<option value='".$row['wms_id']."###".$row['wms_upload_url']."###".$row['layer_id']."'>".$row['wms_title']."</option>";
+
+
+ //new for HTTP Authentication
+ //echo "<option value='".$row['wms_id']."###".$row['wms_upload_url']."###".$row['layer_id']."'>".$row['wms_title']."</option>";
+ echo "<option value='".$row['wms_id']."###".$row['wms_upload_url']."###".$row['layer_id'].
+ "###".$row['wms_auth_type']."###".$row['wms_username']."###".$row['wms_password']."'>".$row['wms_title']."</option>";
+ //new for HTTP Authentication
+
$cnt++;
}
echo "</select><br /><br />";
@@ -111,28 +179,92 @@
view wms metadata: <a id='metadatalink' href='' onclick="window.open(this.href,'Metadaten','width=500,height=600,left=100,top=200,scrollbars=yes ,dependent=yes'); return false" target="_blank"><span id="metadatatext">no WMS selected</span></a><br><br>
<?php
- echo "Link to the last uploaded Online Resource URL:<br><input type='text' size='120' name='capURL'><br />";
+ //new for HTTP Authentication
+ //echo "Link to the last uploaded Online Resource URL:<br><input type='text' size='120' name='capURL'><br />";
+ echo "Link to the last uploaded Online Resource URL:<br><input type='text' size='120' name='capURL' id='capURL'><br />";
+ //new for HTTP Authentication
+
echo "<input type='hidden' name='myWMS' value=''><br>";
echo "Add the following REQUEST to the Online Resource URL to obtain the Capabilities document:<br>";
echo "<i>(Triple click to select and copy)</i><br>";
echo "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.1<br>";
echo "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=1.1.0<br>";
echo "REQUEST=capabilities&WMTVER=1.0.0<br><br>";
- echo "Link to new WMS Capabilities URL:<br><input size='120' type='text' name='myURL'><br>";
+
+//new for HTTP Authentication
+ //echo "Link to new WMS Capabilities URL:<br><input size='120' type='text' name='myURL'><br>";
+ echo "HTTP Authentication:<br>";
+ echo "<input type='radio' name='imrHttpAuth' value='none' onclick='toggleAuthDivVis();' checked='checked' /> None<br>";
+ echo "<input type='radio' name='imrHttpAuth' value='digest' onclick='toggleAuthDivVis();' /> Digest<br>";
+ echo "<input type='radio' name='imrHttpAuth' value='basic' onclick='toggleAuthDivVis();' /> Basic<br>";
+ echo "<input type='radio' name='imrHttpAuth' value='keep' onclick='toggleAuthDivVis();' /> Keep old values<br>";
+ echo "<input type='hidden' name='imrOldAuthType' />";
+ echo "<input type='hidden' name='imrOldAuthName' />";
+ echo "<input type='hidden' name='imrOldAuthPassword' />";
+ echo "<br>";
+ echo "<div id='imrAuthDiv' style='display: none;'>";
+ echo "Username : <input type='text' name='imrAuthName' /><br>";
+ echo "Password : <input type='text' name='imrAuthPassword' /><br><br>";
+ echo "</div>";
+ echo "Link to new WMS Capabilities URL:<br><input size='120' type='text' name='myURL' id='myURL'><br>";
+//new for HTTP Authentication
+
echo "<input type='button' value='Preview Capabilities' onclick='window.open(this.form.myURL.value,\"\",\"\")'> ";
- echo "<input type='button' value='Upload Capabilities' onclick='validate()'><br>";
+
+//new for HTTP Authentication
+ //echo "<input type='button' value='Upload Capabilities' onclick='validate()'><br>";
+ echo "<input type='button' value='Upload Capabilities' onclick='validate()'> ";
+ echo "<input type='button' value='Reupload old service' onclick='reupload()'><br>";
+//new for HTTP Authentication
if(isset($myURL) && $myURL != ''){
- $mywms = new wms();
- $mywms->createObjFromXML($myURL);
+
+//new for HTTP Authentication
+ //$mywms = new wms();
+ //$mywms->createObjFromXML($myURL);
+ /*$imrAuthName = !empty($_POST['imrAuthName']) ? $_POST['imrAuthName'] : '';
+ $imrAuthPassword = !empty($_POST['imrAuthPassword']) ? $_POST['imrAuthPassword'] : '';
+ $imrHttpAuth = !empty($_POST['imrHttpAuth']) ? $_POST['imrHttpAuth'] : '';*/
+
+ $mywms = new wms();
+
+ if (in_array($imrHttpAuth, array('basic','digest'))) {
+ $auth = array();
+ $auth['username'] = $imrAuthName;
+ $auth['password'] = $imrAuthPassword;
+ $auth['auth_type'] = $imrHttpAuth;
+ $mywms->createObjFromXML($myURL, $auth);
+ } elseif ($imrHttpAuth == 'keep') {
+ $auth = array();
+ $auth['username'] = $imrOldAuthName;
+ $auth['password'] = $imrOldAuthPasswword;
+ $auth['auth_type'] = $imrOldAuthType;
+ $mywms->createObjFromXML($myURL, $auth);
+ } else {
+ $mywms->createObjFromXML($myURL);
+ }
+//new for HTTP Authentication
+
+
$mywms->optimizeWMS();
echo "<br />";
if (!MD_OVERWRITE) {
$mywms->overwrite=false;
- }
- $mywms->updateObjInDB($myWMS);
+
+//new for HTTP Authentication
+ //}
+ //$mywms->updateObjInDB($myWMS);
+ }
+ if ($imrHttpAuth != 'none') {
+ $mywms->updateObjInDB($myWMS, $auth);
+ } else {
+ $mywms->updateObjInDB($myWMS);
+ }
+//new for HTTP Authentication
+
+
$mywms->displayWMS();
//if changes are made here for wms, unlink the application cache file in cache directory
More information about the Mapbender_commits
mailing list