summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Southall <applemansigloo@gmail.com>2017-03-20 20:19:03 +0900
committerBenjamin Southall <applemansigloo@gmail.com>2017-03-20 20:19:03 +0900
commitef41b1622d4e3d6324ecf16eaf27b6d028f83585 (patch)
tree2a22ed020f35023e5d166afe6c2b4be7a4766fd0
parent08114c44e96c05264fd7cf85c154a4aed311e9c5 (diff)
Adding support for multiple file upload using URLs, previously only one URL was supported. Also removes duplicate slack reporting merge.
-rw-r--r--post.php57
-rw-r--r--templates/post_form.html5
2 files changed, 21 insertions, 41 deletions
diff --git a/post.php b/post.php
index 2179b083..bc434a03 100644
--- a/post.php
+++ b/post.php
@@ -530,8 +530,14 @@ if (isset($_POST['delete'])) {
$_POST['subject'] = '';
}
- if ($config['allow_upload_by_url'] && isset($_POST['file_url']) && !empty($_POST['file_url'])) {
- $post['file_url'] = $_POST['file_url'];
+ if ($config['allow_upload_by_url'] && isset($_POST['file_url1']) && !empty($_POST['file_url1'])) {
+ function unlink_tmp_file($file) {
+ @unlink($file);
+ fatal_error_handler();
+ }
+
+ function upload_by_url($config,$post,$url) {
+ $post['file_url'] = $url;
if (!preg_match('@^https?://@', $post['file_url']))
error($config['error']['invalidimg']);
@@ -550,10 +556,6 @@ if (isset($_POST['delete'])) {
error($config['error']['unknownext']);
$post['file_tmp'] = tempnam($config['tmp'], 'url');
- function unlink_tmp_file($file) {
- @unlink($file);
- fatal_error_handler();
- }
register_shutdown_function('unlink_tmp_file', $post['file_tmp']);
$fp = fopen($post['file_tmp'], 'w');
@@ -576,13 +578,20 @@ if (isset($_POST['delete'])) {
fclose($fp);
- $_FILES['file'] = array(
+ $_FILES[$post['file_tmp']] = array(
'name' => basename($url_without_params),
'tmp_name' => $post['file_tmp'],
'file_tmp' => true,
'error' => 0,
'size' => filesize($post['file_tmp'])
);
+ }
+
+ for( $counter = 1; $counter <= $config['max_images']; $counter++ ) {
+ $varname = "file_url". $counter;
+ upload_by_url($config,$post,$_POST[$varname]);
+ }
+
}
$post['name'] = $_POST['name'] != '' ? $_POST['name'] : $config['anonymous'];
@@ -1001,8 +1010,7 @@ if (isset($_POST['delete'])) {
escapeshellarg($file['thumb']));
if ($error){
- $path = sprintf($config['file_thumb'],isset($config['file_icons'][$file['extension']]) ? $config['file_icons'][$file['ext
- ension']] : $config['file_icons']['default']);
+ $path = sprintf($config['file_thumb'],isset($config['file_icons'][$file['extension']]) ? $config['file_icons'][$file['extension']] : $config['file_icons']['default']);
}
$file['thumb'] = basename($file['thumb']);
@@ -1181,37 +1189,6 @@ if (isset($_POST['delete'])) {
$query->bindValue(':thread', $post['thread']);
$query->bindValue(':limit', $config['cycle_limit'], PDO::PARAM_INT);
$query->execute() or error(db_error($query));
- if ($config['slack'])
- {
- function slack($message, $room = "reports", $icon = ":no_entry_sign:")
- {
- $room = ($room) ? $room : "reports";
- $data = "payload=" . json_encode(array(
- "channel" => "#{$room}",
- "text" => urlencode($message),
- "icon_emoji" => $icon
- ));
-
- // You can get your webhook endpoint from your Slack settings
- // For some reason using the configuration key doesn't work
- $ch = curl_init($config['slack_incoming_webhook_endpoint']);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $result = curl_exec($ch);
- curl_close($ch);
-
- return $result;
- }
-
- $postcontent = mb_substr($thread['body_nomarkup'], 0, 120) . '... _*(POST TRIMMED)*_';
- $slackmessage = '<' .$config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ( $thread['thread'] ? $thread['thread'] : $id ) . ".html" . ($thread['thread'] ? '#' . $id : '') . '> \n ' . $reason . '\n ' . $postcontent . '\n';
-
- $slackresult = slack($slackmessage, $config['slack_channel']);
- }
-
-
}
if (isset($post['antispam_hash'])) {
diff --git a/templates/post_form.html b/templates/post_form.html
index 0b02dab2..0d6b388b 100644
--- a/templates/post_form.html
+++ b/templates/post_form.html
@@ -121,7 +121,10 @@
{% if config.allow_upload_by_url %}
<div style="float:none;text-align:left" id="upload_url">
<label for="file_url">{% trans %}Or URL{% endtrans %}</label>:
- <input style="display:inline" type="text" id="file_url" name="file_url" size="35">
+ {% for counter in 1..config.max_images %}
+ <input style="display:inline" type="text" id="file_url{{ counter }}" name="file_url{{ counter }}" size="35">
+ </br>
+ {% endfor %}
</div>
{% endif %}
{{ antibot.html() }}