summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-03-13 18:02:56 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-03-13 18:02:56 +0000
commite99d11e3efa63723491b1b302ba0cf953a41f141 (patch)
tree50382f8aa53225fb858cfe3c44e4bc56f8cb9d9b /etc
parent2e564f1aab191ac45b9733ee2679169fbb3340c3 (diff)
downloadpfsense-e99d11e3efa63723491b1b302ba0cf953a41f141.zip
pfsense-e99d11e3efa63723491b1b302ba0cf953a41f141.tar.gz
Add nf@bigpond.net.au http_post function.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pfsense-utils.inc47
1 files changed, 45 insertions, 2 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index df8367a..c837a56 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -764,8 +764,51 @@ function restore_config_section($section, $new_contents) {
write_config();
conf_mount_ro();
config_unlock();
- return;
+ return
}
+/*
+ * http_post($server, po$port, $url, $vars): does an http post to a web server
+ * posting the vars array.
+ * written by nf@bigpond.net.au
+ */
+function http_post($server, $port, $url, $vars) {
+ $user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)";
+ $urlencoded = "";
+ while (list($key,$value) = each($vars))
+ $urlencoded.= urlencode($key) . "=" . urlencode($value) . "&";
+ $urlencoded = substr($urlencoded,0,-1);
+
+ $content_length = strlen($urlencoded);
+
+ $headers = "POST $url HTTP/1.1
+Accept: */*
+Accept-Language: en-au
+Content-Type: application/x-www-form-urlencoded
+User-Agent: $user_agent
+Host: $server
+Connection: Keep-Alive
+Cache-Control: no-cache
+Content-Length: $content_length
+
+";
+
+ $fp = fsockopen($server, $port, $errno, $errstr);
+ if (!$fp) {
+ return false;
+ }
+
+ fputs($fp, $headers);
+ fputs($fp, $urlencoded);
+
+ $ret = "";
+ while (!feof($fp))
+ $ret.= fgets($fp, 1024);
+
+ fclose($fp);
+
+ return $ret;
+
+}
-?>
+?> \ No newline at end of file
OpenPOWER on IntegriCloud