Skip to content

Commit c6b0a0d

Browse files
committed
1.3.0-a3
- replace echo and exit_handler() with the function trigger_error()
1 parent 8bb8ebd commit c6b0a0d

File tree

4 files changed

+22
-26
lines changed

4 files changed

+22
-26
lines changed

imcger.zip

48.2 KB
Binary file not shown.

imcger/imgupload/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"type": "phpbb-extension",
44
"description": "Using ImageMagick php librarie for resize image attachments and creating thumbnails.",
55
"homepage": "https://github.com/IMC-GER/phpBB-Image-upload-use-ImageMagick/tags",
6-
"version": "1.3.0-a2",
7-
"time": "2023-10-03",
6+
"version": "1.3.0-a3",
7+
"time": "2023-10-04",
88
"license": "GPL-2.0-only",
99
"authors": [
1010
{

imcger/imgupload/core/save_rotated_img.php

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* @ignore
1515
*/
1616
define('IN_PHPBB', true);
17+
global $user, $auth, $request, $language, $db, $config;
1718
$phpbb_root_path = './../../../../';
1819
$phpEx = substr(strrchr(__FILE__, '.'), 1);
1920
include($phpbb_root_path . 'common.' . $phpEx);
@@ -22,7 +23,6 @@
2223
// Start session management
2324
$user->session_begin();
2425
$auth->acl($user->data);
25-
$user->setup('viewforum');
2626

2727
// No ajax request, redirect to forum index
2828
if (!$request->is_ajax())
@@ -33,8 +33,8 @@
3333
// No user logged in, redirect in js to login page
3434
if ($user->data['user_id'] == ANONYMOUS)
3535
{
36-
echo 'LOGIN_REQUIRED';
37-
exit_handler();
36+
// The flag E_USER_WARNING trigger a redirect to the login page
37+
trigger_error('LOGIN_REQUIRED', E_USER_WARNING);
3838
}
3939

4040
// Add language file
@@ -44,16 +44,14 @@
4444

4545
if (!$data)
4646
{
47-
echo $language->lang('IUL_NO_DATA_SEND');
48-
exit_handler();
47+
trigger_error($language->lang('IUL_NO_DATA_SEND'), E_USER_NOTICE);
4948
}
5049

5150
list($img_attach_id, $img_rotate_deg) = explode(';', $data);
5251

5352
if (!$img_attach_id || !$img_rotate_deg)
5453
{
55-
echo $language->lang('IUL_WRONG_PARAM');
56-
exit_handler();
54+
trigger_error($language->lang('IUL_WRONG_PARAM'), E_USER_NOTICE);
5755
}
5856

5957
if ($auth->acl_gets('u_attach', 'a_attach', 'f_attach'))
@@ -69,8 +67,7 @@
6967

7068
if (!isset($img_data) || $img_data == false)
7169
{
72-
echo $language->lang('IUL_NO_IMG_IN_DATABASE');
73-
exit_handler();
70+
trigger_error($language->lang('IUL_NO_IMG_IN_DATABASE'), E_USER_NOTICE);
7471
}
7572

7673
// Get image file path
@@ -79,22 +76,20 @@
7976

8077
if (file_exists($image_file_path))
8178
{
82-
$img_data['filesize'] = rotate_image($image_file_path, $img_rotate_deg);
79+
$img_data['filesize'] = rotate_image($image_file_path, $img_rotate_deg);
8380
}
8481
else
8582
{
86-
echo $language->lang('IUL_IMG_NOT_EXIST');
87-
exit_handler();
83+
trigger_error($language->lang('IUL_IMG_NOT_EXIST'), E_USER_NOTICE);
8884
}
8985

9086
if ($img_data['thumbnail'] && file_exists($thumb_file_path))
9187
{
92-
rotate_image($thumb_file_path, $img_rotate_deg);
88+
rotate_image($thumb_file_path, $img_rotate_deg);
9389
}
9490
else if ($img_data['thumbnail'])
9591
{
96-
echo $language->lang('IUL_THUMB_NOT_EXIST');
97-
exit_handler();
92+
trigger_error($language->lang('IUL_THUMB_NOT_EXIST'), E_USER_NOTICE);
9893
}
9994

10095
// Update DataBase
@@ -105,17 +100,16 @@
105100
// sql_nextid() to be removed in 4.1.0-a1, in future use sql_last_inserted_id() it exsits since 3.3.11-RC1
106101
$new_attachID = $db->sql_nextid();
107102

108-
if ($new_attachID) {
103+
if ($new_attachID)
104+
{
109105
$sql = 'DELETE FROM ' . ATTACHMENTS_TABLE . ' WHERE attach_id = ' . (int) $img_attach_id;
110106
$db->sql_query($sql);
111107

112-
echo 'UPDATE-ROW_' . $img_attach_id . '_' . $new_attachID;
113-
exit_handler();
108+
trigger_error('UPDATE-ROW_' . $img_attach_id . '_' . $new_attachID, E_USER_NOTICE);
114109
}
115110
else
116111
{
117-
echo $language->lang('IUL_DATABASE_NOT_UPDATE');
118-
exit_handler();
112+
trigger_error($language->lang('IUL_DATABASE_NOT_UPDATE'), E_USER_NOTICE);
119113
}
120114

121115

imcger/imgupload/styles/all/template/event/overall_footer_body_after.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@
105105

106106
xhr.onreadystatechange = function() {
107107
if (xhr.readyState === 4) {
108-
if (xhr.responseText) {
109-
if (xhr.responseText.startsWith('UPDATE-ROW_')) {
110-
imcgerIuplUpdateRow(xhr.responseText);
108+
if (xhr.responseText) {
109+
let respText = JSON.parse(xhr.responseText);
110+
111+
if (respText.MESSAGE_TEXT.startsWith('UPDATE-ROW_')) {
112+
imcgerIuplUpdateRow(respText.MESSAGE_TEXT);
111113
imcgerIupl.imgOrientationValue[index] = 0;
112-
} else if (xhr.responseText == 'LOGIN_REQUIRED') {
114+
} else if (respText.S_USER_WARNING == true) {
113115
window.location.assign(window.location.href.replace(window.location.hash, ''));
114116
} else {
115117
phpbb.alert('{{ IMGUPLOAD_TITLE }}', xhr.responseText);

0 commit comments

Comments
 (0)