forked from leftypol/leftypol
post.php: extract normalize _FILES
This commit is contained in:
parent
388fc2c05d
commit
811698d9ef
1 changed files with 21 additions and 18 deletions
39
post.php
39
post.php
|
@ -262,6 +262,26 @@ function send_matrix_report(
|
|||
}
|
||||
}
|
||||
|
||||
function normalize_files(array $file_array) {
|
||||
$out_files = [];
|
||||
// If more than 0 files were uploaded
|
||||
if (!empty($file_array['tmp_name'][0])) {
|
||||
$i = 0;
|
||||
$n = count($file_array['tmp_name']);
|
||||
while ($i < $n) {
|
||||
$out_files[strval($i + 1)] = array(
|
||||
'name' => $file_array['name'][$i],
|
||||
'tmp_name' => $file_array['tmp_name'][$i],
|
||||
'type' => $file_array['type'][$i],
|
||||
'error' => $file_array['error'][$i],
|
||||
'size' => $file_array['size'][$i]
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $out_files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the (single) captcha associated with the ip and code.
|
||||
*
|
||||
|
@ -924,7 +944,6 @@ function handle_post(Context $ctx)
|
|||
isset($post['thread']) ? $post['thread'] : ($config['try_smarter'] && isset($_POST['page']) ? 0 - (int) $_POST['page'] : null)
|
||||
)
|
||||
);
|
||||
//$post['antispam_hash'] = checkSpam();
|
||||
|
||||
if ($post['antispam_hash'] === true) {
|
||||
error($config['error']['spam']);
|
||||
|
@ -994,23 +1013,7 @@ function handle_post(Context $ctx)
|
|||
// Convert multiple upload format to array of files. This makes the following code
|
||||
// work the same whether we used the JS or HTML multiple file upload techniques.
|
||||
if (array_key_exists('file_multiple', $_FILES)) {
|
||||
$file_array = $_FILES['file_multiple'];
|
||||
$_FILES = [];
|
||||
// If more than 0 files were uploaded
|
||||
if (!empty($file_array['tmp_name'][0])) {
|
||||
$i = 0;
|
||||
$n = count($file_array['tmp_name']);
|
||||
while ($i < $n) {
|
||||
$_FILES[strval($i + 1)] = array(
|
||||
'name' => $file_array['name'][$i],
|
||||
'tmp_name' => $file_array['tmp_name'][$i],
|
||||
'type' => $file_array['type'][$i],
|
||||
'error' => $file_array['error'][$i],
|
||||
'size' => $file_array['size'][$i]
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$_FILES = normalize_files($_FILES['file_multiple']);
|
||||
}
|
||||
|
||||
// We must do this check now before the passowrd is hashed and overwritten.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue