#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once dirname(__FILE__) . "/mb_validatePermission.php";
require_once dirname(__FILE__) . "/../classes/class_wms.php";
if (isset($_REQUEST["wms_id"]) == false) {
    echo "file: " . $_REQUEST["xml_file"];
    $gui_id = $_REQUEST["guiList"];
    $xml = $_REQUEST["xml_file"];
    if ($_REQUEST["auth_type"] == 'basic' || $_REQUEST["auth_type"] == 'digest') {
        $auth = array();
        $auth['username'] = $_REQUEST["username"];
        $auth['password'] = $_REQUEST["password"];
        $auth['auth_type'] = $_REQUEST["auth_type"];
    }
    $mywms = new wms();
    if (isset($auth)) {
        $mywms->createObjFromXML($xml, $auth);
        $mywms->writeObjInDB($gui_id, $auth);
    } else {
        $mywms->createObjFromXML($xml);
        $mywms->writeObjInDB($gui_id);
    }
    $mywms->displayWMS();
    $wms_id = $mywms->wms_id;
} else {
    $wms_id = $_REQUEST["wms_id"];
}
require_once dirname(__FILE__) . "/../php/mod_editWMS_Metadata.php";
editWMSByWMSID($wms_id);