+ed
[nethome.git] / public_html / cgi-bin / postget.php
1 <?php
2         $path_priv="/home/lace/priv/";
3         $getget=isset($_REQUEST["_getget"]);
4         $wherename=($getget ? "_getget" : "_postget");
5         $where=$_REQUEST[$wherename];
6         unset($_REQUEST[$wherename]);
7
8         foreach ($_REQUEST as $key=>$val) {
9                 if (ereg("^_priv_(postget.*)\$",$val,$matched)) {
10                         $permit=array("127.0.0.1"=>1,"::1"=>1,"192.168.192.1"=>1,"192.168.90.11"=>1,"192.168.90.12"=>1);
11                         if (!$permit[$_SERVER["REMOTE_ADDR"]])
12                                 print("Forbidden:"
13                                                 ." REMOTE_ADDR=".htmlspecialchars($_SERVER["REMOTE_ADDR"])
14                                                 .",key=".htmlspecialchars($key)
15                                                 .",val=".htmlspecialchars($val)
16                                                 ."<br />"
17                                                 );
18                         elseif ($matched[1]=="postget.time()") {
19                                 // At least 2 - time slip?
20                                 $_REQUEST[$key]=time()-131-60;
21                         }
22                         else
23                                 $_REQUEST[$key]=chop(join(" ",file($path_priv.$matched[1],false/*use_include_path*/)));
24                         }
25                 }
26
27         if ($getget) {
28                 $first='?';
29                 foreach ($_REQUEST as $key=>$val) {
30                         $where.="${first}".urlencode($key)."=".urlencode($val);
31                         $first='&';
32                         }
33                 header("Location: $where");
34                 }
35         header("Content-type: text/html");
36         print('<?xml version="1.0" encoding="iso-8859-1"?>'."\n");
37 ?>
38 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
39 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
40 <head><title>postget</title></head>
41 <?php
42
43         if ($getget) {
44                 print(""
45                                 ."<body onload=\"window.location.href=document.links[0].href;\"><p>\n"
46                                 ."<a href=\"".htmlspecialchars($where)."\">get</a>\n"
47                                 ."</p></body>\n");
48                 }
49         else {
50                 print(""
51                                 ."<body onload=\"document.forms[0].submit();\">\n"
52                                 ."<form action=\"".htmlspecialchars($where)."\" method=\"post\"><p>\n");
53                 foreach ($_REQUEST as $key=>$val)
54                         print("<input type=\"hidden\" name=\"".htmlspecialchars($key)."\" value=\"".htmlspecialchars($val)."\" />\n");
55                 print("<input type=\"submit\" />\n");
56                 print("</p></form></body>\n");
57                 }
58
59 ?>
60 </html>