Redirects in Zope (ZMS)
I'm doing a new version of a homepage in ZMS, a content managment system for zope.
But I have also some perl CGI applications that I'd like to integrate into the new webpage.
I used to integrate them into a php menu system in the old homepage. I was using a function like the one below to redirect all get/post requests to the perl CGI application, upon a certain trigger string in a request.
Is something like this also possible in zope? And if yes, how? Thanks for any help!
This is the old request redirect function for php:
Code:
function post_upload($url) {
$up=parse_url($url);if(!isset($up["port"])) {$up["port"]=80;}
$boundary=md5(mt_rand());$data="--$boundary\r\n";
$_REQUEST["ip"]=find_ip();
foreach($_REQUEST as $key=>$value) {
if (!is_array($value)) { // arrays contain files
if ($makLF1) {$data.="\r\n";}
$data.="Content-Disposition: form-data; ";
$data.="name=\"$key\"\r\n\r\n";
$data.="$value\r\n--$boundary";$makLF1++;
}
}
foreach($_FILES as $key=>$value) {
$fn=basename($_FILES[$key]['name']);$ufn="tmp/".$fn;
move_uploaded_file($_FILES[$key]['tmp_name'],$ufn);
$h=fopen($ufn,"r");$bindat=fread($h,filesize($ufn));
fclose($h);
if (($makLF1) and (!$makLF2)) {$data.="\r\n";}
if ($makLF2) {$data.="\r\n";}
$data.="Content-Disposition: form-data; ";
$data.="name=\"$key\"; filename=\"$fn\"";
$data.="\r\n\r\n$bindat\r\n--$boundary";$makLF2++;
}
$data.="--\r\n\r\n";$lenga=strlen($data);
$msg ="POST ".$up["path"]." HTTP/1.0\r\n";
$msg.="Content-Type: multipart/form-data; ";
$msg.="boundary=$boundary\r\n";
$msg.="Connection: close\r\n";
$msg.="Content-Length: $lenga\r\n\r\n";
$f=fsockopen($up["host"],$up["port"]);fputs($f,$msg.$data);
while(!feof($f)) {
$buf=fgets($f,128);
if ($ok) {$result.=$buf;}
if (preg_match("/^Content-Type/",$buf)) {$ok=1;}
}
fclose($f);return $result;
}
|