Commit 02851d49 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Change beginexp_html.php3 to invoke xml backend with a POST instead of

GET to avoid GET size limitations. This should have been easy, but PHP
has no native support for doing this, so takes a bit of mucking around
with a direct socket connection to the server, and sending it the
right headers, blah, blah, blah.

Will make this live soon!
parent c81a35d7
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -79,26 +79,62 @@ else {
PAGEARGERROR();
}
#
# We are going to invoke the XML backend, and read back an XML representation
# of the results.
#
$url = "$TBBASE/beginexp_xml.php3?".
"nocookieuid=$uid&nocookieauth=" . $_COOKIE[$TBAUTHCOOKIE] .
"&xmlcode=" . urlencode($xmlcode);
$reply = "";
# TBERROR(urldecode($url), 0);
$uriargs = "nocookieuid=$uid&nocookieauth=" . $_COOKIE[$TBAUTHCOOKIE];
$postdata = "xmlcode=" . urlencode($xmlcode);
$fp = @fopen($url, "r");
if ($fp == FALSE) {
TBERROR("Could not invoke XML backend script. URL was:<br><br>\n".
"$url\n<br>", 1);
#
# Yuck, no good support for sending POST requests. Must use fsockopen, which
# is not so bad, except you have to specify the port. Okay, ssl is on port
# 443, but at home I do not use ssl and I use a non-standard port since my
# ISP blocks port 80 and 8080. Also, devel trees are in a subdir, and so need
# to pull that out. Did I say Yuck?
#
if (preg_match("/^([-\w\.]+):(\d+)(.*)$/", $WWW, $matches)) {
$host = $matches[1];
$port = $matches[2];
$base = $matches[3];
$targ = $host;
}
while (!feof($fp)) {
$reply .= fgets($fp, 1024);
elseif (preg_match("/^([-\w\.]+)(.*)$/", $WWW, $matches)) {
$host = $matches[1];
$base = $matches[2];
$port = 443;
$targ = "ssl://" . $host;
}
fclose($fp);
else {
TBERROR("Could not parse $WWW for host/port/base!", 1);
}
#TBERROR("$host $port $base\n$uriargs\n". urldecode($postdata), 0);
$sock = fsockopen($targ, $port, $errno, $errstr, 30);
if ($sock == FALSE) {
TBERROR("Could not invoke XML backend script.\n".
"$host $port $base\n".
"$errno: $errstr\n".
"$uriargs\n" . urldecode($postdata), 1);
}
fputs($sock, "POST $base/beginexp_xml.php3?" . $uriargs . " HTTP/1.0\r\n");
fputs($sock, "Host: $host\r\n");
fputs($sock, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($sock, "Content-length: " . strlen($postdata) . "\r\n");
fputs($sock, "Accept: */*\r\n");
fputs($sock, "\r\n");
fputs($sock, "$postdata\r\n");
fputs($sock, "\r\n");
$headers = "";
while ($str = trim(fgets($sock, 4096)))
$headers .= "$str\n";
$reply = "";
while (!feof($sock))
$reply .= fgets($sock, 4096);
fclose($sock);
#
# Error reporting is not well thought out yet. If the backend page gets
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -280,7 +280,7 @@ $exp_id = $formfields[exp_id];
# Verify permissions. We do this here since pid/eid/gid could be bogus above.
#
if (! TBProjAccessCheck($uid, $exp_pid, $exp_gid, $TB_PROJECT_CREATEEXPT)) {
$errors["Project/Group"] = "Not enough permission to create experiment";
$errors["Project/Group"] = "Not $exp_gid enough permission to create experiment";
XMLERROR();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment