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>";
 echo "<input type='button' value='Preview Capabilities' onclick='window.open(this.form.myURL.value,\"\",\"\")'>&nbsp;";
 echo "<input type='button' value='Upload Capabilities' onclick='validate()'><br>";
 if (isset($myURL) && $myURL != '') {
     $mywms = new wms();
     $mywms->createObjFromXML($myURL);
     $mywms->optimizeWMS();
     echo "<br />";
     if (!MD_OVERWRITE) {
         $mywms->overwrite = false;
     }
     $mywms->updateObjInDB($myWMS);
     $mywms->displayWMS();
     // start (owners of the updated wms will be notified by email)
     if ($use_php_mailing) {
         $owner_ids = $admin->getOwnerByWms($myWMS);
         if ($owner_ids && count($owner_ids) > 0) {
             $owner_mail_addresses = array();
             $j = 0;
             for ($i = 0; $i < count($owner_ids); $i++) {
                 $adr_tmp = $admin->getEmailByUserId($owner_ids[$i]);
                 if (!in_array($adr_tmp, $owner_mail_addresses) && $adr_tmp) {
                     $owner_mail_addresses[$j] = $adr_tmp;
                     $j++;
                 }
             }
             $replyto = $admin->getEmailByUserId(Mapbender::session()->get("mb_user_id"));
 $v = array($upd_wmsid);
 $t = array("i");
 $res = db_prep_query($sql, $v, $t);
 $row = db_fetch_array($res);
 $uploadUrl = $row["wms_upload_url"];
 $wmsOwner = $row["wms_owner"];
 if ($wmsOwner !== $user->id) {
     echo "<br>Skipped: " . $upd_wmsid . "<br>";
     continue;
 }
 // update WMS from upload URL
 $mywms = new wms();
 $mywms->createObjFromXML($uploadUrl);
 $mywms->optimizeWMS();
 echo "<br />";
 $mywms->updateObjInDB($upd_wmsid);
 echo "<br>Updated: " . $upd_wmsid . "<br>";
 /*
 		// start new monitoring for this WMS
 		$now = time();
 		$sql = "UPDATE mb_monitor SET status = '-2', status_comment = 'Monitoring is still in progress...', " . 
 			"timestamp_begin = $1, timestamp_end = $2 WHERE upload_id = $3 AND fkey_wms_id = $4";
 		$v = array($now, $now, $upload_id, $upd_wmsid);
 		$t = array('s', 's', 's', 'i');
 		$res = db_prep_query($sql,$v,$t);
 
 		$currentFilename = "wms_monitor_report_" . $upload_id . "_" . 
 			$upd_wmsid . "_" . $wmsOwner . ".xml";		
 		$exec = PHP_PATH . "php5 ../../tools/mod_monitorCapabilities_write.php " . 
 			$currentFilename. " 0";
 		echo exec(escapeshellcmd($exec));
                        $layer->{$c} = $value;
                    }
                } else {
                    if (!is_null($value)) {
                        $layer->{$c} = $value;
                    }
                }
            }
        }
        if ($wms->wms_network_access == "on") {
            $wms->wms_network_access = intval('1');
        } else {
            $wms->wms_network_access = intval('0');
        }
        //try {
        $wms->updateObjInDB($wmsId);
        //}
        //catch (Exception $e) {
        //	$ajaxResponse->setSuccess(false);
        //	$ajaxResponse->setMessage(_mb("Could not update wms object in database!"));
        //	$ajaxResponse->send();
        //}
        $ajaxResponse->setMessage("Updated WMS metadata for ID " . $wmsId);
        $ajaxResponse->setSuccess(true);
        break;
    case "getContactMetadata":
        $mbGroupId = $ajaxResponse->getParameter("id");
        $sql = <<<SQL
\t
SELECT mb_group_name, mb_group_title, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_logo_path, mb_group_voicetelephone FROM mb_group WHERE mb_group_id = \$1