Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Stream/CHANGEDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,8 @@
++$count;
$sql[$count][0] = '1.2.00';
$sql[$count][1] = "";

//v1.2.02
++$count;
$sql[$count][0] = '1.2.02';
$sql[$count][1] = "";
4 changes: 4 additions & 0 deletions Stream/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
CHANGELOG
=========
v1.2.00
-------
Added error message to detect if uploaded images exceed server's limit

v1.2.00
-------
Gibbon v28 compatibility
Expand Down
2 changes: 1 addition & 1 deletion Stream/manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$entryURL = 'stream.php';
$type = 'Additional';
$category = 'Other';
$version = '1.2.00';
$version = '1.2.02';
$author = "Gibbon Foundation";
$url = "https://gibbonedu.org";

Expand Down
5 changes: 5 additions & 0 deletions Stream/posts_manage_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
}
$page->return->setEditLink($editLink);

$page->return->addReturns([
'error11' => __m('Your post could not be submitted because the uploaded images exceed the server\'s size limit. Please upload fewer images at a time or try again.'),
'error12' => __m('Your post could not be submitted because one or more uploaded files are not a valid image type. Accepted formats: JPG, GIF, PNG.'),
]);

$form = Form::create('post', $session->get('absoluteURL').'/modules/'.$session->get('module').'/posts_manage_addProcess.php');
$form->setFactory(DatabaseFormFactory::create($pdo));

Expand Down
18 changes: 17 additions & 1 deletion Stream/posts_manage_addProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/

use Gibbon\FileUploader;
use Gibbon\Services\Format;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Module\Stream\Domain\PostGateway;
use Gibbon\Module\Stream\Domain\PostTagGateway;
Expand Down Expand Up @@ -52,6 +51,14 @@

$partialFail = false;

// Detect if PHP silently dropped all POST/FILE data because the combined upload size exceeded the server's post_max_size limit.
$contentLength = intval($_SERVER['CONTENT_LENGTH'] ?? 0);
if ($contentLength > 0 && !isset($_POST['post'])) {
$URL .= '&return=error11';
header("Location: {$URL}");
exit;
}

// Sanitize the whole $_POST array
$_POST = $container->get(Validator::class)->sanitize($_POST);

Expand Down Expand Up @@ -98,6 +105,15 @@

foreach ($_FILES['attachments']['name'] as $index => $name) {
$file = array_combine(array_keys($_FILES['attachments']), array_column($_FILES['attachments'], $index));

// Reject non-image MIME types before attempting upload
$allowedMimes = ['image/jpeg', 'image/jpg', 'image/gif', 'image/png'];
if (!empty($file['type']) && !in_array(strtolower($file['type']), $allowedMimes)) {
$URL .= '&return=error12';
header("Location: {$URL}");
exit;
}

$attachment = $fileUploader->uploadAndResizeImage($file, 'streamPhoto', $maxImageSize, 90);

if (!empty($attachment)) {
Expand Down
2 changes: 1 addition & 1 deletion Stream/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
/**
* Sets version information.
*/
$moduleVersion = '1.2.00';
$moduleVersion = '1.2.02';