summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--config.php.example5
-rwxr-xr-x[-rw-r--r--]upload_file.php18
3 files changed, 24 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4f4773f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+config.php
diff --git a/config.php.example b/config.php.example
index 4c46215..08e2ac5 100644
--- a/config.php.example
+++ b/config.php.example
@@ -19,4 +19,9 @@
# An array of filenames to omit from the index
$indexignore = array(".htaccess", "config.php", "index.php", "upload_file.php", "upload.html", "css", "icons", ".git", "config.php.example");
+ # An URL to send a POST to when an upload is successful
+ $posturl = "http://url.to/post/to";
+
+ # The IRC channel notified by uploads when using the notification URL
+ $postchannel = "ircchannel";
?>
diff --git a/upload_file.php b/upload_file.php
index 890078a..f1ed597 100644..100755
--- a/upload_file.php
+++ b/upload_file.php
@@ -51,8 +51,26 @@ if ($_FILES["file"]["error"] > 0) {
$fileurl = "$url" . $_FILES["file"]["name"];
echo "URL: <a href=\"$fileurl\">$fileurl</a><br>";
echo "Size: " . size_readable($_FILES["file"]["size"], null, "bi");
+ if (isset($posturl)) {
+ send_upload_notification($fileurl, $posturl, $postchannel);
+ }
}
}
+
+function send_upload_notification($fileurl, $posturl, $channel) {
+ $data = array('url' => $fileurl, 'channel' => $channel);
+
+ $options = array(
+ 'http' => array(
+ 'header' => "Content-type: application/x-www-form-urlencoded\r\n" .
+ "X-Blaears-Event: blaupload\r\n",
+ 'method' => 'POST',
+ 'content' => http_build_query($data),
+ ),
+ );
+ $context = stream_context_create($options);
+ file_get_contents($posturl, false, $context);
+}
?>
</p>
<p>