|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* phpBB Gallery - Core Extension |
|
4
|
|
|
* |
|
5
|
|
|
* @package phpbbgallery/core |
|
6
|
|
|
* @author satanasov |
|
7
|
|
|
* @author Leinad4Mind |
|
8
|
|
|
* @copyright 2014- satanasov, 2018- Leinad4Mind |
|
9
|
|
|
* @license GPL-2.0-only |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace phpbbgallery\core\controller; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
class comment |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var \phpbb\db\driver\driver_interface */ |
|
|
|
|
|
|
19
|
|
|
protected $db; |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
/** @var \phpbb\user */ |
|
|
|
|
|
|
23
|
|
|
protected $user; |
|
24
|
|
|
|
|
25
|
|
|
protected $language; |
|
26
|
|
|
|
|
27
|
|
|
protected $auth; |
|
28
|
|
|
|
|
29
|
|
|
protected $config; |
|
30
|
|
|
|
|
31
|
|
|
protected $template; |
|
32
|
|
|
|
|
33
|
|
|
/* @var \phpbb\request\request */ |
|
|
|
|
|
|
34
|
|
|
protected $request; |
|
35
|
|
|
|
|
36
|
|
|
/* @var \phpbb\controller\helper */ |
|
|
|
|
|
|
37
|
|
|
protected $helper; |
|
38
|
|
|
|
|
39
|
|
|
/* @var \phpbbgallery\core\image\image */ |
|
40
|
|
|
protected $image; |
|
41
|
|
|
|
|
42
|
|
|
/* @var \phpbbgallery\core\album\loader */ |
|
43
|
|
|
protected $loader; |
|
44
|
|
|
|
|
45
|
|
|
/* @var \phpbbgallery\core\album\album */ |
|
46
|
|
|
protected $album; |
|
47
|
|
|
|
|
48
|
|
|
/* @var \phpbbgallery\core\album\display */ |
|
49
|
|
|
protected $display; |
|
50
|
|
|
|
|
51
|
|
|
/* @var \phpbbgallery\core\url */ |
|
52
|
|
|
protected $url; |
|
53
|
|
|
|
|
54
|
|
|
protected $gallery_auth; |
|
55
|
|
|
|
|
56
|
|
|
protected $gallery_config; |
|
57
|
|
|
|
|
58
|
|
|
protected $misc; |
|
59
|
|
|
|
|
60
|
|
|
protected $comment; |
|
61
|
|
|
|
|
62
|
|
|
protected $gallery_user; |
|
63
|
|
|
|
|
64
|
|
|
protected $gallery_log; |
|
65
|
|
|
|
|
66
|
|
|
protected $notification_helper; |
|
67
|
|
|
|
|
68
|
|
|
protected $gallery_notification; |
|
69
|
|
|
|
|
70
|
|
|
protected $gallery_rating; |
|
71
|
|
|
|
|
72
|
|
|
protected $phpbb_container; |
|
73
|
|
|
|
|
74
|
|
|
protected $table_comments; |
|
75
|
|
|
|
|
76
|
|
|
protected $phpbb_root_path; |
|
77
|
|
|
|
|
78
|
|
|
protected $php_ext; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Constructor |
|
82
|
|
|
* |
|
83
|
|
|
* @param \phpbb\db\driver\driver_interface $db |
|
84
|
|
|
* @param \phpbb\user $user |
|
85
|
|
|
* @param \phpbb\language\language $language |
|
86
|
|
|
* @param \phpbb\auth\auth $auth |
|
87
|
|
|
* @param \phpbb\config\config $config |
|
88
|
|
|
* @param \phpbb\template\template $template |
|
89
|
|
|
* @param \phpbb\request\request $request phpBB request class |
|
90
|
|
|
* @param \phpbb\controller\helper $helper Controller helper object |
|
91
|
|
|
* @param \phpbbgallery\core\image\image $image phpBB Gallery Core image object |
|
92
|
|
|
* @param \phpbbgallery\core\album\loader $loader phpBB Gallery Core album loader |
|
93
|
|
|
* @param \phpbbgallery\core\album\album $album phpBB Gallery Core album object |
|
94
|
|
|
* @param \phpbbgallery\core\album\display $display phpBB Gallery Core album display |
|
95
|
|
|
* @param \phpbbgallery\core\url $url phpBB Gallery Core url object |
|
96
|
|
|
* @param \phpbbgallery\core\auth\auth $gallery_auth |
|
97
|
|
|
* @param \phpbbgallery\core\config $gallery_config |
|
98
|
|
|
* @param \phpbbgallery\core\misc $misc |
|
99
|
|
|
* @param \phpbbgallery\core\comment $comment |
|
100
|
|
|
* @param \phpbbgallery\core\user $gallery_user |
|
101
|
|
|
* @param \phpbbgallery\core\log $gallery_log |
|
102
|
|
|
* @param \phpbbgallery\core\notification\helper $notification_helper |
|
103
|
|
|
* @param \phpbbgallery\core\notification $gallery_notification |
|
104
|
|
|
* @param \phpbbgallery\core\rating $gallery_rating |
|
105
|
|
|
* @param ContainerInterface $phpbb_container |
|
106
|
|
|
* @param $table_comments |
|
107
|
|
|
* @param $phpbb_root_path |
|
108
|
|
|
* @param $php_ext |
|
109
|
|
|
*/ |
|
110
|
2 |
|
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\language\language $language, |
|
|
|
|
|
|
111
|
|
|
\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\template\template $template, |
|
|
|
|
|
|
112
|
|
|
\phpbb\request\request $request, \phpbb\controller\helper $helper, \phpbbgallery\core\image\image $image, |
|
113
|
|
|
\phpbbgallery\core\album\loader $loader, \phpbbgallery\core\album\album $album, |
|
114
|
|
|
\phpbbgallery\core\album\display $display, \phpbbgallery\core\url $url, \phpbbgallery\core\auth\auth $gallery_auth, |
|
115
|
|
|
\phpbbgallery\core\config $gallery_config, \phpbbgallery\core\misc $misc, \phpbbgallery\core\comment $comment, |
|
116
|
|
|
\phpbbgallery\core\user $gallery_user, \phpbbgallery\core\log $gallery_log, |
|
117
|
|
|
\phpbbgallery\core\notification\helper $notification_helper, \phpbbgallery\core\notification $gallery_notification, |
|
118
|
|
|
\phpbbgallery\core\rating $gallery_rating, ContainerInterface $phpbb_container, |
|
119
|
|
|
$table_comments, $phpbb_root_path, $php_ext) |
|
120
|
|
|
{ |
|
121
|
2 |
|
$this->db = $db; |
|
122
|
2 |
|
$this->user = $user; |
|
123
|
2 |
|
$this->language = $language; |
|
124
|
2 |
|
$this->auth = $auth; |
|
125
|
2 |
|
$this->config = $config; |
|
126
|
2 |
|
$this->template = $template; |
|
127
|
2 |
|
$this->request = $request; |
|
128
|
2 |
|
$this->helper = $helper; |
|
129
|
2 |
|
$this->image = $image; |
|
130
|
2 |
|
$this->loader = $loader; |
|
131
|
2 |
|
$this->album = $album; |
|
132
|
2 |
|
$this->display = $display; |
|
133
|
2 |
|
$this->url = $url; |
|
134
|
2 |
|
$this->gallery_auth = $gallery_auth; |
|
135
|
2 |
|
$this->gallery_config = $gallery_config; |
|
136
|
2 |
|
$this->misc = $misc; |
|
137
|
2 |
|
$this->comment = $comment; |
|
138
|
2 |
|
$this->gallery_user = $gallery_user; |
|
139
|
2 |
|
$this->gallery_log = $gallery_log; |
|
140
|
2 |
|
$this->notification_helper = $notification_helper; |
|
141
|
2 |
|
$this->gallery_notification = $gallery_notification; |
|
142
|
2 |
|
$this->gallery_rating = $gallery_rating; |
|
143
|
2 |
|
$this->phpbb_container = $phpbb_container; |
|
144
|
2 |
|
$this->table_comments = $table_comments; |
|
145
|
2 |
|
$this->phpbb_root_path = $phpbb_root_path; |
|
146
|
2 |
|
$this->php_ext = $php_ext; |
|
147
|
2 |
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* comment Controller |
|
151
|
|
|
* Route: gallery/comment/{image_id}/add |
|
152
|
|
|
* |
|
153
|
|
|
* @param int $image_id Image ID |
|
154
|
|
|
* @param $comment_id |
|
155
|
|
|
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
|
|
|
|
|
156
|
|
|
*/ |
|
157
|
2 |
|
public function add($image_id, $comment_id) |
|
158
|
|
|
{ |
|
159
|
2 |
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
160
|
2 |
|
if ($comment_id != 0) |
|
161
|
|
|
{ |
|
162
|
|
|
$sql = 'SELECT * |
|
163
|
1 |
|
FROM ' . $this->table_comments . ' |
|
164
|
1 |
|
WHERE comment_id = ' . (int) $comment_id; |
|
165
|
1 |
|
$result = $this->db->sql_query($sql); |
|
166
|
1 |
|
$comment_data = $this->db->sql_fetchrow($result); |
|
167
|
1 |
|
$this->db->sql_freeresult($result); |
|
168
|
1 |
|
$image_id = (int) $comment_data['comment_image_id']; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
2 |
|
$submit = $this->request->variable('submit', false); |
|
172
|
2 |
|
$error = $message = ''; |
|
173
|
|
|
// load Image Data |
|
174
|
2 |
|
$image_data = $this->image->get_image_data($image_id); |
|
175
|
2 |
|
$album_id = (int) $image_data['image_album_id']; |
|
176
|
2 |
|
$album_data = $this->loader->get($album_id); |
|
177
|
2 |
|
$this->display->generate_navigation($album_data); |
|
178
|
2 |
|
$page_title = $image_data['image_name']; |
|
179
|
|
|
|
|
180
|
2 |
|
$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)); |
|
181
|
2 |
|
$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id)); |
|
182
|
2 |
|
$album_loginlink = append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext . '?mode=login'); |
|
|
|
|
|
|
183
|
|
|
|
|
184
|
2 |
|
$this->gallery_auth->load_user_permissions($this->user->data['user_id']); |
|
185
|
2 |
|
if (!$this->gallery_auth->acl_check('c_post', $album_id, $album_data['album_user_id'])) |
|
186
|
|
|
{ |
|
187
|
|
|
$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD'); |
|
188
|
|
|
} |
|
189
|
2 |
|
add_form_key('gallery'); |
|
|
|
|
|
|
190
|
2 |
|
$this->language->add_lang('posting'); |
|
191
|
|
|
|
|
192
|
2 |
|
if (!function_exists('generate_smilies')) |
|
193
|
|
|
{ |
|
194
|
1 |
|
include_once($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext); |
|
195
|
|
|
} |
|
196
|
2 |
|
if (!function_exists('display_custom_bbcodes')) |
|
197
|
|
|
{ |
|
198
|
1 |
|
include_once($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
2 |
|
$bbcode_status = ($this->config['allow_bbcode']) ? true : false; |
|
202
|
2 |
|
$smilies_status = ($this->config['allow_smilies']) ? true : false; |
|
203
|
2 |
|
$img_status = ($bbcode_status) ? true : false; |
|
204
|
2 |
|
$url_status = ($this->config['allow_post_links']) ? true : false; |
|
205
|
2 |
|
$flash_status = false; |
|
206
|
2 |
|
$quote_status = true; |
|
207
|
|
|
|
|
208
|
|
|
// Build custom bbcodes array |
|
209
|
2 |
|
display_custom_bbcodes(); |
|
210
|
|
|
|
|
211
|
|
|
// Build smilies array |
|
212
|
2 |
|
generate_smilies('inline', 0); |
|
213
|
|
|
|
|
214
|
2 |
|
if (isset($album_data['contest_start'])) |
|
215
|
|
|
{ |
|
216
|
|
|
$s_hide_comment_input = (time() < ($album_data['contest_start'] + $album_data['contest_end'])) ? true : false; |
|
217
|
|
|
} |
|
218
|
|
|
else |
|
219
|
|
|
{ |
|
220
|
2 |
|
$s_hide_comment_input = false; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
2 |
|
$this->template->assign_vars(array( |
|
224
|
2 |
|
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($this->language->lang('BBCODE_IS_ON'), '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>') : sprintf($this->language->lang('BBCODE_IS_OFF'), '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>'), |
|
225
|
2 |
|
'IMG_STATUS' => ($img_status) ? $this->language->lang('IMAGES_ARE_ON') : $this->language->lang('IMAGES_ARE_OFF'), |
|
226
|
2 |
|
'FLASH_STATUS' => ($flash_status) ? $this->language->lang('FLASH_IS_ON') : $this->language->lang('FLASH_IS_OFF'), |
|
|
|
|
|
|
227
|
2 |
|
'SMILIES_STATUS' => ($smilies_status) ? $this->language->lang('SMILIES_ARE_ON') : $this->language->lang('SMILIES_ARE_OFF'), |
|
228
|
2 |
|
'URL_STATUS' => ($bbcode_status && $url_status) ? $this->language->lang('URL_IS_ON') : $this->language->lang('URL_IS_OFF'), |
|
229
|
|
|
|
|
230
|
2 |
|
'S_BBCODE_ALLOWED' => $bbcode_status, |
|
231
|
2 |
|
'S_SMILIES_ALLOWED' => $smilies_status, |
|
232
|
2 |
|
'S_LINKS_ALLOWED' => $url_status, |
|
233
|
2 |
|
'S_BBCODE_IMG' => $img_status, |
|
234
|
2 |
|
'S_BBCODE_URL' => $url_status, |
|
235
|
2 |
|
'S_BBCODE_FLASH' => $flash_status, |
|
236
|
2 |
|
'S_BBCODE_QUOTE' => $quote_status, |
|
237
|
|
|
)); |
|
238
|
|
|
|
|
239
|
2 |
|
if ($this->misc->display_captcha('comment')) |
|
240
|
|
|
{ |
|
241
|
|
|
$captcha = $this->phpbb_container->get('captcha.factory')->get_instance($this->config['captcha_plugin']); |
|
242
|
|
|
$captcha->init(CONFIRM_POST); |
|
|
|
|
|
|
243
|
|
|
$s_captcha_hidden_fields = ''; |
|
|
|
|
|
|
244
|
|
|
$this->template->assign_vars(array( |
|
245
|
|
|
'S_CONFIRM_CODE' => true, |
|
246
|
|
|
'CAPTCHA_TEMPLATE' => $captcha->get_template(), |
|
247
|
|
|
)); |
|
248
|
|
|
|
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
2 |
|
$s_captcha_hidden_fields = ''; |
|
252
|
2 |
|
$comment_username_req = ($this->user->data['user_id'] == ANONYMOUS); |
|
|
|
|
|
|
253
|
|
|
|
|
254
|
2 |
|
if ($submit) |
|
255
|
|
|
{ |
|
256
|
|
|
if (!check_form_key('gallery')) |
|
|
|
|
|
|
257
|
|
|
{ |
|
258
|
|
|
trigger_error('FORM_INVALID'); |
|
259
|
|
|
} |
|
260
|
|
|
if ($this->misc->display_captcha('comment')) |
|
261
|
|
|
{ |
|
262
|
|
|
$captcha_error = $captcha->validate(); |
|
|
|
|
|
|
263
|
|
|
if ($captcha_error) |
|
264
|
|
|
{ |
|
265
|
|
|
$error .= (($error) ? '<br />' : '') . $captcha_error; |
|
266
|
|
|
} |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
$comment_plain = $this->request->variable('message', '', true); |
|
270
|
|
|
$comment_username = $this->request->variable('username', '', true); |
|
271
|
|
|
|
|
272
|
|
|
if ($comment_username_req) |
|
273
|
|
|
{ |
|
274
|
|
|
if (!function_exists('validate_username')) |
|
275
|
|
|
{ |
|
276
|
|
|
include_once($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
if ($comment_username == '') |
|
280
|
|
|
{ |
|
281
|
|
|
$error .= (($error) ? '<br />' : '') . $this->language->lang('MISSING_USERNAME'); |
|
282
|
|
|
} |
|
283
|
|
|
if ($result = validate_username($comment_username)) |
|
284
|
|
|
{ |
|
285
|
|
|
$this->language->add_lang('ucp'); |
|
286
|
|
|
$error .= (($error) ? '<br />' : '') . $this->language->lang($result . '_USERNAME'); |
|
287
|
|
|
$submit = false; |
|
288
|
|
|
} |
|
289
|
|
|
} |
|
290
|
|
|
if (($comment_plain == '') && !$s_user_rated) |
|
|
|
|
|
|
291
|
|
|
{ |
|
292
|
|
|
$error .= (($error) ? '<br />' : '') . $this->language->lang('MISSING_COMMENT'); |
|
293
|
|
|
} |
|
294
|
|
|
if (utf8_strlen($comment_plain) > $this->gallery_config->get('comment_length')) |
|
|
|
|
|
|
295
|
|
|
{ |
|
296
|
|
|
$error .= (($error) ? '<br />' : '') . $this->language->lang('COMMENT_TOO_LONG'); |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
if (!class_exists('bbcode')) |
|
300
|
|
|
{ |
|
301
|
|
|
include($this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext); |
|
302
|
|
|
} |
|
303
|
|
|
if (!class_exists('parse_message')) |
|
304
|
|
|
{ |
|
305
|
|
|
include_once($this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext); |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
|
|
$message_parser = new \parse_message(); |
|
|
|
|
|
|
309
|
|
|
$message_parser->message = utf8_normalize_nfc($comment_plain); |
|
|
|
|
|
|
310
|
|
|
if ($message_parser->message) |
|
311
|
|
|
{ |
|
312
|
|
|
$message_parser->parse(true, true, true, true, false, true, true, true); |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
$sql_ary = array( |
|
316
|
|
|
'comment_image_id' => (int) $image_id, |
|
317
|
|
|
'comment' => $message_parser->message, |
|
318
|
|
|
'comment_uid' => $message_parser->bbcode_uid, |
|
319
|
|
|
'comment_bitfield' => $message_parser->bbcode_bitfield, |
|
320
|
|
|
'comment_signature' => ($this->auth->acl_get('u_sig') && isset($_POST['attach_sig'])), |
|
321
|
|
|
); |
|
322
|
|
|
if ((!$error) && ($sql_ary['comment'] != '')) |
|
323
|
|
|
{ |
|
324
|
|
|
if ($this->misc->display_captcha('comment')) |
|
325
|
|
|
{ |
|
326
|
|
|
$captcha->reset(); |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
$comment_post_id = $this->comment->add($sql_ary, $comment_username); |
|
330
|
|
|
if ($this->gallery_user->get_data('watch_com')) |
|
331
|
|
|
{ |
|
332
|
|
|
$this->gallery_notification->add($image_id); |
|
333
|
|
|
} |
|
334
|
|
|
$data = array( |
|
335
|
|
|
'image_id' => (int) $image_id, |
|
336
|
|
|
'comment_id' => $comment_post_id, |
|
337
|
|
|
'poster_id' => $this->user->data['user_id'], |
|
338
|
|
|
); |
|
339
|
|
|
$this->notification_helper->notify('new_comment', $data); |
|
340
|
|
|
//$phpbb_gallery_notification->send_notification('image', $image_id, $image_data['image_name']); |
|
341
|
|
|
$message .= $this->language->lang('COMMENT_STORED') . '<br />'; |
|
342
|
|
|
} |
|
343
|
|
|
else if ($this->misc->display_captcha('comment')) |
|
344
|
|
|
{ |
|
345
|
|
|
$s_captcha_hidden_fields = ($captcha->is_solved()) ? build_hidden_fields($captcha->get_hidden_fields()) : ''; |
|
|
|
|
|
|
346
|
|
|
} |
|
347
|
|
|
$sig_checked = ($this->auth->acl_get('u_sig') && isset($_POST['attach_sig'])); |
|
348
|
|
|
} |
|
349
|
|
|
else |
|
350
|
|
|
{ |
|
351
|
2 |
|
if ($comment_id != 0) |
|
352
|
|
|
{ |
|
353
|
1 |
|
$comment_ary = generate_text_for_edit($comment_data['comment'], $comment_data['comment_uid'], (int) $comment_data['comment_bitfield']); |
|
|
|
|
|
|
354
|
1 |
|
$comment_plain = '[quote="' . $comment_data['comment_username'] . '"]' . $comment_ary['text'] . '[/quote]'; |
|
355
|
|
|
} |
|
356
|
2 |
|
$sig_checked = $this->user->optionget('attachsig'); |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
2 |
|
$preview = $this->request->variable('preview', false); |
|
360
|
2 |
|
if ($preview) |
|
361
|
|
|
{ |
|
362
|
|
|
$comment_plain = $this->request->variable('message', '', true); |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
2 |
|
if ($this->misc->display_captcha('comment')) |
|
366
|
|
|
{ |
|
367
|
|
|
if (!$submit || !$captcha->is_solved()) |
|
368
|
|
|
{ |
|
369
|
|
|
$this->template->assign_vars(array( |
|
370
|
|
|
'S_CONFIRM_CODE' => true, |
|
371
|
|
|
'CAPTCHA_TEMPLATE' => $captcha->get_template(), |
|
372
|
|
|
)); |
|
373
|
|
|
} |
|
374
|
|
|
$this->template->assign_vars(array( |
|
375
|
|
|
'S_CAPTCHA_HIDDEN_FIELDS' => $s_captcha_hidden_fields, |
|
376
|
|
|
)); |
|
377
|
|
|
} |
|
378
|
2 |
|
$this->template->assign_vars(array( |
|
379
|
2 |
|
'ERROR' => $error, |
|
380
|
2 |
|
'MESSAGE' => (isset($comment_plain)) ? $comment_plain : '', |
|
381
|
2 |
|
'USERNAME' => (isset($comment_username)) ? $comment_username : '', |
|
382
|
2 |
|
'REQ_USERNAME' => (!empty($comment_username_req)) ? true : false, |
|
383
|
2 |
|
'L_COMMENT_LENGTH' => sprintf($this->language->lang('COMMENT_LENGTH'), $this->gallery_config->get('comment_length')), |
|
384
|
|
|
|
|
385
|
2 |
|
'IMAGE_RSZ_WIDTH' => $this->gallery_config->get('medium_width'), |
|
386
|
2 |
|
'IMAGE_RSZ_HEIGHT' => $this->gallery_config->get('medium_height'), |
|
387
|
2 |
|
'U_IMAGE' => append_sid($this->url->path('full') . 'image/' . (int) $image_id . '/medium'), |
|
388
|
2 |
|
'U_VIEW_IMAGE' => append_sid($this->url->path('full') . 'image/' . (int) $image_id), |
|
389
|
2 |
|
'IMAGE_NAME' => $image_data['image_name'], |
|
390
|
|
|
|
|
391
|
2 |
|
'S_SIGNATURE_CHECKED' => (isset($sig_checked) && $sig_checked) ? ' checked="checked"' : '', |
|
392
|
2 |
|
'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_core_comment_add', array('image_id' => (int) $image_id, 'comment_id' => 0)), |
|
393
|
|
|
//'S_ALBUM_ACTION' => append_sid($this->url->path('full') . 'comment/' . $image_id . '/add/0'), |
|
394
|
|
|
)); |
|
395
|
|
|
|
|
396
|
2 |
|
if ($submit && !$error) |
|
397
|
|
|
{ |
|
398
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_IMAGE'), '<a href="' . $image_backlink . '">', '</a>'); |
|
399
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_ALBUM'), '<a href="' . $album_backlink . '">', '</a>'); |
|
400
|
|
|
|
|
401
|
|
|
$this->url->meta_refresh(3, $image_backlink); |
|
402
|
|
|
trigger_error($message); |
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
2 |
|
return $this->helper->render('gallery/comment_body.html', $page_title); |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
/** |
|
409
|
|
|
* comment Controller |
|
410
|
|
|
* Route: gallery/comment/{image_id}/edit/{comment_id} |
|
411
|
|
|
* |
|
412
|
|
|
* @param int $image_id Image ID |
|
413
|
|
|
* @param $comment_id |
|
414
|
|
|
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
415
|
|
|
*/ |
|
416
|
|
|
public function edit($image_id, $comment_id) |
|
417
|
|
|
{ |
|
418
|
|
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
419
|
|
|
add_form_key('gallery'); |
|
|
|
|
|
|
420
|
|
|
|
|
421
|
|
|
$submit = $this->request->variable('submit', false); |
|
422
|
|
|
$error = $message = ''; |
|
423
|
|
|
// load Image Data |
|
424
|
|
|
$image_data = $this->image->get_image_data($image_id); |
|
425
|
|
|
$album_id = (int) $image_data['image_album_id']; |
|
426
|
|
|
$album_data = $this->loader->get($album_id); |
|
427
|
|
|
$this->display->generate_navigation($album_data); |
|
428
|
|
|
$page_title = $image_data['image_name']; |
|
429
|
|
|
|
|
430
|
|
|
$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)); |
|
431
|
|
|
$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id)); |
|
432
|
|
|
$image_loginlink = $this->url->append_sid('relative', 'image_page', "album_id=$album_id&image_id=$image_id"); |
|
433
|
|
|
$album_loginlink = append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext . '?mode=login'); |
|
|
|
|
|
|
434
|
|
|
if ($comment_id != 0) |
|
435
|
|
|
{ |
|
436
|
|
|
$sql = 'SELECT * |
|
437
|
|
|
FROM ' . $this->table_comments . ' |
|
438
|
|
|
WHERE comment_id = ' . (int) $comment_id; |
|
439
|
|
|
$result = $this->db->sql_query($sql); |
|
440
|
|
|
$comment_data = $this->db->sql_fetchrow($result); |
|
441
|
|
|
$this->db->sql_freeresult($result); |
|
442
|
|
|
$image_id = (int) $comment_data['comment_image_id']; |
|
443
|
|
|
} |
|
444
|
|
|
else |
|
445
|
|
|
{ |
|
446
|
|
|
$this->misc->not_authorised($image_backlink, $image_loginlink); |
|
447
|
|
|
} |
|
448
|
|
|
$this->gallery_auth->load_user_permissions($this->user->data['user_id']); |
|
449
|
|
|
if (!$this->gallery_auth->acl_check('c_edit', $album_id, $album_data['album_user_id']) /*&& $mode == 'add'*/) |
|
450
|
|
|
{ |
|
451
|
|
|
if (!$this->gallery_auth->acl_check('m_comments', $album_id, $album_data['album_user_id'])) |
|
452
|
|
|
{ |
|
453
|
|
|
$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD'); |
|
454
|
|
|
} |
|
455
|
|
|
} |
|
456
|
|
|
else if (($comment_data['comment_user_id'] != $this->user->data['user_id']) && !$this->gallery_auth->acl_check('m_comments', $album_id, $album_data['album_user_id'])) |
|
|
|
|
|
|
457
|
|
|
{ |
|
458
|
|
|
$this->misc->not_authorised($image_backlink, $image_loginlink); |
|
459
|
|
|
} |
|
460
|
|
|
|
|
461
|
|
|
$this->language->add_lang('posting'); |
|
462
|
|
|
|
|
463
|
|
|
if (!function_exists('generate_smilies')) |
|
464
|
|
|
{ |
|
465
|
|
|
include_once($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext); |
|
466
|
|
|
} |
|
467
|
|
|
|
|
468
|
|
|
$bbcode_status = ($this->config['allow_bbcode']) ? true : false; |
|
469
|
|
|
$smilies_status = ($this->config['allow_smilies']) ? true : false; |
|
470
|
|
|
$img_status = ($bbcode_status) ? true : false; |
|
471
|
|
|
$url_status = ($this->config['allow_post_links']) ? true : false; |
|
472
|
|
|
$flash_status = false; |
|
473
|
|
|
$quote_status = true; |
|
474
|
|
|
|
|
475
|
|
|
if (!function_exists('display_custom_bbcodes')) |
|
476
|
|
|
{ |
|
477
|
|
|
include_once($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
// Build custom bbcodes array |
|
481
|
|
|
display_custom_bbcodes(); |
|
482
|
|
|
|
|
483
|
|
|
// Build smilies array |
|
484
|
|
|
generate_smilies('inline', 0); |
|
485
|
|
|
|
|
486
|
|
|
if (isset($album_data['contest_start'])) |
|
487
|
|
|
{ |
|
488
|
|
|
$s_hide_comment_input = (time() < ($album_data['contest_start'] + $album_data['contest_end'])) ? true : false; |
|
489
|
|
|
} |
|
490
|
|
|
else |
|
491
|
|
|
{ |
|
492
|
|
|
$s_hide_comment_input = false; |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
$this->template->assign_vars(array( |
|
496
|
|
|
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($this->language->lang('BBCODE_IS_ON'), '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>') : sprintf($this->language->lang('BBCODE_IS_OFF'), '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>'), |
|
497
|
|
|
'IMG_STATUS' => ($img_status) ? $this->language->lang('IMAGES_ARE_ON') : $this->language->lang('IMAGES_ARE_OFF'), |
|
498
|
|
|
'FLASH_STATUS' => ($flash_status) ? $this->language->lang('FLASH_IS_ON') : $this->language->lang('FLASH_IS_OFF'), |
|
|
|
|
|
|
499
|
|
|
'SMILIES_STATUS' => ($smilies_status) ? $this->language->lang('SMILIES_ARE_ON') : $this->language->lang('SMILIES_ARE_OFF'), |
|
500
|
|
|
'URL_STATUS' => ($bbcode_status && $url_status) ? $this->language->lang('URL_IS_ON') : $this->language->lang('URL_IS_OFF'), |
|
501
|
|
|
|
|
502
|
|
|
'S_BBCODE_ALLOWED' => $bbcode_status, |
|
503
|
|
|
'S_SMILIES_ALLOWED' => $smilies_status, |
|
504
|
|
|
'S_LINKS_ALLOWED' => $url_status, |
|
505
|
|
|
'S_BBCODE_IMG' => $img_status, |
|
506
|
|
|
'S_BBCODE_URL' => $url_status, |
|
507
|
|
|
'S_BBCODE_FLASH' => $flash_status, |
|
508
|
|
|
'S_BBCODE_QUOTE' => $quote_status, |
|
509
|
|
|
)); |
|
510
|
|
|
|
|
511
|
|
|
$comment_username_req = ($comment_data['comment_user_id'] == ANONYMOUS) ? true : false; |
|
|
|
|
|
|
512
|
|
|
|
|
513
|
|
|
if ($submit) |
|
514
|
|
|
{ |
|
515
|
|
|
if (!check_form_key('gallery')) |
|
|
|
|
|
|
516
|
|
|
{ |
|
517
|
|
|
trigger_error('FORM_INVALID'); |
|
518
|
|
|
} |
|
519
|
|
|
|
|
520
|
|
|
$sql_ary = array(); |
|
521
|
|
|
$comment_plain = $this->request->variable('message', '', true); |
|
522
|
|
|
|
|
523
|
|
|
if ($comment_username_req) |
|
524
|
|
|
{ |
|
525
|
|
|
$comment_username = $this->request->variable('username', ''); |
|
526
|
|
|
if ($comment_username == '') |
|
527
|
|
|
{ |
|
528
|
|
|
$error .= (($error) ? '<br />' : '') . $this->language->lang('MISSING_USERNAME'); |
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
if (validate_username($comment_username)) |
|
|
|
|
|
|
532
|
|
|
{ |
|
533
|
|
|
$error .= (($error) ? '<br />' : '') . $this->language->lang('INVALID_USERNAME'); |
|
534
|
|
|
$comment_username = ''; |
|
535
|
|
|
} |
|
536
|
|
|
|
|
537
|
|
|
$sql_ary = array( |
|
538
|
|
|
'comment_username' => $comment_username, |
|
539
|
|
|
); |
|
540
|
|
|
} |
|
541
|
|
|
|
|
542
|
|
|
if ($comment_plain == '') |
|
543
|
|
|
{ |
|
544
|
|
|
$error .= (($error) ? '<br />' : '') . $this->language->lang('MISSING_COMMENT'); |
|
545
|
|
|
} |
|
546
|
|
|
if (utf8_strlen($comment_plain) > $this->gallery_config->get('comment_length')) |
|
|
|
|
|
|
547
|
|
|
{ |
|
548
|
|
|
$error .= (($error) ? '<br />' : '') . $this->language->lang('COMMENT_TOO_LONG'); |
|
549
|
|
|
} |
|
550
|
|
|
if (!class_exists('bbcode')) |
|
551
|
|
|
{ |
|
552
|
|
|
include($this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext); |
|
553
|
|
|
} |
|
554
|
|
|
if (!class_exists('parse_message')) |
|
555
|
|
|
{ |
|
556
|
|
|
include_once($this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext); |
|
557
|
|
|
} |
|
558
|
|
|
$message_parser = new \parse_message(); |
|
559
|
|
|
$message_parser->message = utf8_normalize_nfc($comment_plain); |
|
|
|
|
|
|
560
|
|
|
if ($message_parser->message) |
|
561
|
|
|
{ |
|
562
|
|
|
$message_parser->parse(true, true, true, true, false, true, true, true); |
|
563
|
|
|
} |
|
564
|
|
|
|
|
565
|
|
|
$sql_ary = array_merge($sql_ary, array( |
|
566
|
|
|
'comment' => $message_parser->message, |
|
567
|
|
|
'comment_uid' => $message_parser->bbcode_uid, |
|
568
|
|
|
'comment_bitfield' => $message_parser->bbcode_bitfield, |
|
569
|
|
|
'comment_edit_count' => $comment_data['comment_edit_count'] + 1, |
|
570
|
|
|
'comment_signature' => ($this->auth->acl_get('u_sig') && isset($_POST['attach_sig'])), |
|
571
|
|
|
)); |
|
572
|
|
|
|
|
573
|
|
|
if (!$error) |
|
574
|
|
|
{ |
|
575
|
|
|
$this->comment->edit($comment_id, $sql_ary); |
|
576
|
|
|
$message .= $this->language->lang('COMMENT_STORED') . '<br />'; |
|
577
|
|
|
if ($this->user->data['user_id'] != $comment_data['comment_user_id']) |
|
578
|
|
|
{ |
|
579
|
|
|
$this->gallery_log->add_log('moderator', 'c_edit', $image_data['image_album_id'], $image_data['image_id'], array('LOG_GALLERY_COMMENT_EDITED', $image_data['image_name'])); |
|
580
|
|
|
} |
|
581
|
|
|
} |
|
582
|
|
|
} |
|
583
|
|
|
else |
|
584
|
|
|
{ |
|
585
|
|
|
$sig_checked = (bool) $comment_data['comment_signature']; |
|
586
|
|
|
|
|
587
|
|
|
$comment_ary = generate_text_for_edit($comment_data['comment'], $comment_data['comment_uid'], (int) $comment_data['comment_bitfield']); |
|
|
|
|
|
|
588
|
|
|
$comment_plain = $comment_ary['text']; |
|
589
|
|
|
$comment_username = $comment_data['comment_username']; |
|
590
|
|
|
} |
|
591
|
|
|
|
|
592
|
|
|
$this->template->assign_vars(array( |
|
593
|
|
|
'ERROR' => $error, |
|
594
|
|
|
'MESSAGE' => (isset($comment_plain)) ? $comment_plain : '', |
|
595
|
|
|
'USERNAME' => (isset($comment_username)) ? $comment_username : '', |
|
596
|
|
|
'REQ_USERNAME' => (!empty($comment_username_req)) ? true : false, |
|
597
|
|
|
'L_COMMENT_LENGTH' => sprintf($this->language->lang('COMMENT_LENGTH'), $this->gallery_config->get('comment_length')), |
|
598
|
|
|
|
|
599
|
|
|
'IMAGE_RSZ_WIDTH' => $this->gallery_config->get('medium_width'), |
|
600
|
|
|
'IMAGE_RSZ_HEIGHT' => $this->gallery_config->get('medium_height'), |
|
601
|
|
|
'U_IMAGE' => append_sid($this->url->path('full') . 'image/' . (int) $image_id . '/medium'), |
|
602
|
|
|
'U_VIEW_IMAGE' => append_sid($this->url->path('full') . 'image/' . (int) $image_id), |
|
603
|
|
|
'IMAGE_NAME' => $image_data['image_name'], |
|
604
|
|
|
|
|
605
|
|
|
'S_SIGNATURE_CHECKED' => (isset($sig_checked) && $sig_checked) ? ' checked="checked"' : '', |
|
606
|
|
|
'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_core_comment_edit', array('image_id' => (int) $image_id, 'comment_id' => (int) $comment_id)), |
|
607
|
|
|
//'S_ALBUM_ACTION' => append_sid($this->url->path('full') . 'comment/' . $image_id . '/edit/'. $comment_id), |
|
608
|
|
|
)); |
|
609
|
|
|
|
|
610
|
|
|
if ($submit && !$error) |
|
611
|
|
|
{ |
|
612
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_IMAGE'), '<a href="' . $image_backlink . '">', '</a>'); |
|
613
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_ALBUM'), '<a href="' . $album_backlink . '">', '</a>'); |
|
614
|
|
|
|
|
615
|
|
|
$this->url->meta_refresh(3, $image_backlink); |
|
616
|
|
|
trigger_error($message); |
|
617
|
|
|
} |
|
618
|
|
|
|
|
619
|
|
|
return $this->helper->render('gallery/comment_body.html', $page_title); |
|
620
|
|
|
} |
|
621
|
|
|
|
|
622
|
|
|
/** |
|
623
|
|
|
* comment Controller |
|
624
|
|
|
* Route: gallery/comment/{image_id}/delete/{comment_id} |
|
625
|
|
|
* |
|
626
|
|
|
* @param int $image_id Image ID |
|
627
|
|
|
* @param $comment_id |
|
628
|
|
|
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
629
|
|
|
*/ |
|
630
|
|
|
public function delete($image_id, $comment_id) |
|
631
|
|
|
{ |
|
632
|
|
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
633
|
|
|
add_form_key('gallery'); |
|
|
|
|
|
|
634
|
|
|
|
|
635
|
|
|
$submit = $this->request->variable('submit', false); |
|
636
|
|
|
$error = $message = ''; |
|
637
|
|
|
// load Image Data |
|
638
|
|
|
$image_data = $this->image->get_image_data($image_id); |
|
639
|
|
|
$album_id = (int) $image_data['image_album_id']; |
|
640
|
|
|
$album_data = $this->loader->get($album_id); |
|
641
|
|
|
$this->display->generate_navigation($album_data); |
|
642
|
|
|
$page_title = $image_data['image_name']; |
|
643
|
|
|
|
|
644
|
|
|
$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)); |
|
645
|
|
|
$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id)); |
|
646
|
|
|
$image_loginlink = $this->url->append_sid('relative', 'image_page', "album_id=$album_id&image_id=$image_id"); |
|
647
|
|
|
$album_loginlink = append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext . '?mode=login'); |
|
|
|
|
|
|
648
|
|
|
if ($comment_id != 0) |
|
649
|
|
|
{ |
|
650
|
|
|
$sql = 'SELECT * |
|
651
|
|
|
FROM ' . $this->table_comments . ' |
|
652
|
|
|
WHERE comment_id = ' . (int) $comment_id; |
|
653
|
|
|
$result = $this->db->sql_query($sql); |
|
654
|
|
|
$comment_data = $this->db->sql_fetchrow($result); |
|
655
|
|
|
$this->db->sql_freeresult($result); |
|
656
|
|
|
$image_id = (int) $comment_data['comment_image_id']; |
|
657
|
|
|
} |
|
658
|
|
|
else |
|
659
|
|
|
{ |
|
660
|
|
|
$this->misc->not_authorised($image_backlink, $image_loginlink); |
|
661
|
|
|
} |
|
662
|
|
|
$this->gallery_auth->load_user_permissions($this->user->data['user_id']); |
|
663
|
|
|
if (!$this->gallery_auth->acl_check('c_edit', $album_id, $album_data['album_user_id']) /*&& $mode == 'add'*/) |
|
664
|
|
|
{ |
|
665
|
|
|
if (!$this->gallery_auth->acl_check('m_comments', $album_id, $album_data['album_user_id'])) |
|
666
|
|
|
{ |
|
667
|
|
|
$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD'); |
|
668
|
|
|
} |
|
669
|
|
|
} |
|
670
|
|
|
else if (($comment_data['comment_user_id'] != $this->user->data['user_id']) && !$this->gallery_auth->acl_check('m_comments', $album_id, $album_data['album_user_id'])) |
|
|
|
|
|
|
671
|
|
|
{ |
|
672
|
|
|
$this->misc->not_authorised($image_backlink, $image_loginlink); |
|
673
|
|
|
} |
|
674
|
|
|
|
|
675
|
|
|
$this->language->add_lang('posting'); |
|
676
|
|
|
|
|
677
|
|
|
if (!function_exists('generate_smilies')) |
|
678
|
|
|
{ |
|
679
|
|
|
include_once($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext); |
|
680
|
|
|
} |
|
681
|
|
|
|
|
682
|
|
|
$bbcode_status = ($this->config['allow_bbcode']) ? true : false; |
|
683
|
|
|
$smilies_status = ($this->config['allow_smilies']) ? true : false; |
|
684
|
|
|
$img_status = ($bbcode_status) ? true : false; |
|
685
|
|
|
$url_status = ($this->config['allow_post_links']) ? true : false; |
|
686
|
|
|
$flash_status = false; |
|
687
|
|
|
$quote_status = true; |
|
688
|
|
|
|
|
689
|
|
|
if (!function_exists('display_custom_bbcodes')) |
|
690
|
|
|
{ |
|
691
|
|
|
include_once($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); |
|
692
|
|
|
} |
|
693
|
|
|
|
|
694
|
|
|
// Build custom bbcodes array |
|
695
|
|
|
display_custom_bbcodes(); |
|
696
|
|
|
|
|
697
|
|
|
// Build smilies array |
|
698
|
|
|
generate_smilies('inline', 0); |
|
699
|
|
|
|
|
700
|
|
|
$contest_start = $album_data['contest_start'] ?? 0; |
|
701
|
|
|
$contest_end = $album_data['contest_end'] ?? 0; |
|
702
|
|
|
$s_hide_comment_input = (time() < ($contest_start + $contest_end)) ? true : false; |
|
|
|
|
|
|
703
|
|
|
|
|
704
|
|
|
$this->template->assign_vars(array( |
|
705
|
|
|
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($this->language->lang('BBCODE_IS_ON'), '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>') : sprintf($this->language->lang('BBCODE_IS_OFF'), '<a href="' . $this->url->append_sid('phpbb', 'faq', 'mode=bbcode') . '">', '</a>'), |
|
706
|
|
|
'IMG_STATUS' => ($img_status) ? $this->language->lang('IMAGES_ARE_ON') : $this->language->lang('IMAGES_ARE_OFF'), |
|
707
|
|
|
'FLASH_STATUS' => ($flash_status) ? $this->language->lang('FLASH_IS_ON') : $this->language->lang('FLASH_IS_OFF'), |
|
|
|
|
|
|
708
|
|
|
'SMILIES_STATUS' => ($smilies_status) ? $this->user->lang['SMILIES_ARE_ON'] : $this->user->lang['SMILIES_ARE_OFF'], |
|
709
|
|
|
'URL_STATUS' => ($bbcode_status && $url_status) ? $this->language->lang('URL_IS_ON') : $this->language->lang('URL_IS_OFF'), |
|
710
|
|
|
|
|
711
|
|
|
'S_BBCODE_ALLOWED' => $bbcode_status, |
|
712
|
|
|
'S_SMILIES_ALLOWED' => $smilies_status, |
|
713
|
|
|
'S_LINKS_ALLOWED' => $url_status, |
|
714
|
|
|
'S_BBCODE_IMG' => $img_status, |
|
715
|
|
|
'S_BBCODE_URL' => $url_status, |
|
716
|
|
|
'S_BBCODE_FLASH' => $flash_status, |
|
717
|
|
|
'S_BBCODE_QUOTE' => $quote_status, |
|
718
|
|
|
)); |
|
719
|
|
|
|
|
720
|
|
|
$s_hidden_fields = build_hidden_fields(array( |
|
|
|
|
|
|
721
|
|
|
'album_id' => $album_id, |
|
722
|
|
|
'image_id' => $image_id, |
|
723
|
|
|
'comment_id' => $comment_id, |
|
724
|
|
|
'mode' => 'delete', |
|
725
|
|
|
)); |
|
726
|
|
|
|
|
727
|
|
|
if (confirm_box(true)) |
|
|
|
|
|
|
728
|
|
|
{ |
|
729
|
|
|
$this->comment->delete_comments($comment_id); |
|
730
|
|
|
if ($this->user->data['user_id'] != $comment_data['comment_user_id']) |
|
731
|
|
|
{ |
|
732
|
|
|
$this->gallery_log->add_log('moderator', 'c_delete', $image_data['image_album_id'], $image_data['image_id'], array('LOG_GALLERY_COMMENT_DELETED', $image_data['image_name'])); |
|
733
|
|
|
} |
|
734
|
|
|
|
|
735
|
|
|
$message = $this->language->lang('DELETED_COMMENT') . '<br />'; |
|
736
|
|
|
$submit = true; |
|
737
|
|
|
} |
|
738
|
|
|
else |
|
739
|
|
|
{ |
|
740
|
|
|
if (isset($_POST['cancel'])) |
|
741
|
|
|
{ |
|
742
|
|
|
$message = $this->language->lang('DELETED_COMMENT_NOT') . '<br />'; |
|
743
|
|
|
$submit = true; |
|
744
|
|
|
} |
|
745
|
|
|
else |
|
746
|
|
|
{ |
|
747
|
|
|
confirm_box(false, 'DELETE_COMMENT2', $s_hidden_fields); |
|
748
|
|
|
} |
|
749
|
|
|
} |
|
750
|
|
|
|
|
751
|
|
|
$this->template->assign_vars(array( |
|
752
|
|
|
'ERROR' => $error, |
|
753
|
|
|
'MESSAGE' => (isset($comment_plain)) ? $comment_plain : '', |
|
|
|
|
|
|
754
|
|
|
'USERNAME' => (isset($comment_username)) ? $comment_username : '', |
|
|
|
|
|
|
755
|
|
|
'REQ_USERNAME' => (!empty($comment_username_req)) ? true : false, |
|
|
|
|
|
|
756
|
|
|
'L_COMMENT_LENGTH' => sprintf($this->language->lang('COMMENT_LENGTH'), $this->gallery_config->get('comment_length')), |
|
757
|
|
|
|
|
758
|
|
|
'IMAGE_RSZ_WIDTH' => $this->gallery_config->get('medium_width'), |
|
759
|
|
|
'IMAGE_RSZ_HEIGHT' => $this->gallery_config->get('medium_height'), |
|
760
|
|
|
'U_IMAGE' => append_sid($this->url->path('full') . 'image/' . (int) $image_id . '/medium'), |
|
761
|
|
|
'U_VIEW_IMAGE' => append_sid($this->url->path('full') . 'image/' . (int) $image_id), |
|
762
|
|
|
'IMAGE_NAME' => $image_data['image_name'], |
|
763
|
|
|
|
|
764
|
|
|
'S_SIGNATURE_CHECKED' => (isset($sig_checked) && $sig_checked) ? ' checked="checked"' : '', |
|
|
|
|
|
|
765
|
|
|
'S_ALBUM_ACTION' => append_sid($this->url->path('full') . 'comment/' . (int) $image_id . '/edit/'. (int) $comment_id), |
|
766
|
|
|
)); |
|
767
|
|
|
|
|
768
|
|
|
if ($submit && !$error) |
|
769
|
|
|
{ |
|
770
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_IMAGE'), '<a href="' . $image_backlink . '">', '</a>'); |
|
771
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_ALBUM'), '<a href="' . $album_backlink . '">', '</a>'); |
|
772
|
|
|
|
|
773
|
|
|
$this->url->meta_refresh(3, $image_backlink); |
|
774
|
|
|
trigger_error($message); |
|
775
|
|
|
} |
|
776
|
|
|
|
|
777
|
|
|
return $this->helper->render('gallery/comment_body.html', $page_title); |
|
778
|
|
|
} |
|
779
|
|
|
|
|
780
|
|
|
public function rate($image_id) |
|
781
|
|
|
{ |
|
782
|
|
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
783
|
|
|
add_form_key('gallery'); |
|
|
|
|
|
|
784
|
|
|
|
|
785
|
|
|
$submit = $this->request->variable('submit', false); |
|
|
|
|
|
|
786
|
|
|
$error = $message = ''; |
|
|
|
|
|
|
787
|
|
|
// load Image Data |
|
788
|
|
|
$image_data = $this->image->get_image_data($image_id); |
|
789
|
|
|
$album_id = (int) $image_data['image_album_id']; |
|
790
|
|
|
$album_data = $this->loader->get($album_id); |
|
791
|
|
|
$this->display->generate_navigation($album_data); |
|
792
|
|
|
$page_title = $image_data['image_name']; |
|
793
|
|
|
|
|
794
|
|
|
$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)); |
|
795
|
|
|
$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id)); |
|
796
|
|
|
$image_loginlink = $this->url->append_sid('relative', 'image_page', "album_id=$album_id&image_id=$image_id"); |
|
797
|
|
|
|
|
798
|
|
|
$this->gallery_auth->load_user_permissions($this->user->data['user_id']); |
|
799
|
|
|
$rating = $this->gallery_rating; |
|
800
|
|
|
$rating->loader($image_id, $image_data, $album_data); |
|
801
|
|
|
if (!($this->gallery_config->get('allow_rates') && $rating->is_able())) |
|
802
|
|
|
{ |
|
803
|
|
|
// The user is unable to rate. |
|
804
|
|
|
$this->misc->not_authorised($image_backlink, $image_loginlink); |
|
805
|
|
|
} |
|
806
|
|
|
|
|
807
|
|
|
$this->language->add_lang('posting'); |
|
808
|
|
|
|
|
809
|
|
|
if (!function_exists('generate_smilies')) |
|
810
|
|
|
{ |
|
811
|
|
|
include_once($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext); |
|
812
|
|
|
} |
|
813
|
|
|
|
|
814
|
|
|
$bbcode_status = ($this->config['allow_bbcode']) ? true : false; |
|
815
|
|
|
$smilies_status = ($this->config['allow_smilies']) ? true : false; |
|
|
|
|
|
|
816
|
|
|
$img_status = ($bbcode_status) ? true : false; |
|
|
|
|
|
|
817
|
|
|
$url_status = ($this->config['allow_post_links']) ? true : false; |
|
|
|
|
|
|
818
|
|
|
$flash_status = false; |
|
|
|
|
|
|
819
|
|
|
$quote_status = true; |
|
|
|
|
|
|
820
|
|
|
|
|
821
|
|
|
if (!function_exists('display_custom_bbcodes')) |
|
822
|
|
|
{ |
|
823
|
|
|
include_once($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); |
|
824
|
|
|
}// Build custom bbcodes array |
|
825
|
|
|
display_custom_bbcodes(); |
|
826
|
|
|
|
|
827
|
|
|
// Build smilies array |
|
828
|
|
|
generate_smilies('inline', 0); |
|
829
|
|
|
|
|
830
|
|
|
/** |
|
831
|
|
|
* Rating-System: now you can comment and rate in one form |
|
832
|
|
|
*/ |
|
833
|
|
|
$s_user_rated = false; |
|
|
|
|
|
|
834
|
|
|
if ($this->gallery_config->get('allow_rates')) |
|
835
|
|
|
{ |
|
836
|
|
|
$user_rating = $rating->get_user_rating($this->user->data['user_id']); |
|
837
|
|
|
|
|
838
|
|
|
// Check: User didn't rate yet, has permissions, it's not the users own image and the user is logged in |
|
839
|
|
|
if (!$user_rating && $rating->is_allowed()) |
|
840
|
|
|
{ |
|
841
|
|
|
$rating->display_box(); |
|
842
|
|
|
|
|
843
|
|
|
// User just rated the image, so we store it |
|
844
|
|
|
$rate_point = $this->request->variable('rating', 0); |
|
845
|
|
|
if ($rating->rating_enabled && $rate_point > 0) |
|
846
|
|
|
{ |
|
847
|
|
|
$rating->submit_rating(); |
|
848
|
|
|
$s_user_rated = true; |
|
849
|
|
|
|
|
850
|
|
|
$message .= $this->language->lang('RATING_SUCCESSFUL') . '<br />'; |
|
851
|
|
|
} |
|
852
|
|
|
$this->template->assign_vars(array( |
|
853
|
|
|
'S_ALLOWED_TO_RATE' => $rating->is_allowed(), |
|
854
|
|
|
)); |
|
855
|
|
|
} |
|
856
|
|
|
|
|
857
|
|
|
} |
|
858
|
|
|
|
|
859
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_IMAGE'), '<a href="' . $image_backlink . '">', '</a>'); |
|
860
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_ALBUM'), '<a href="' . $album_backlink . '">', '</a>'); |
|
861
|
|
|
|
|
862
|
|
|
$this->url->meta_refresh(3, $image_backlink); |
|
863
|
|
|
trigger_error($message); |
|
864
|
|
|
|
|
865
|
|
|
return $this->helper->render('gallery/comment_body.html', $page_title); |
|
866
|
|
|
} |
|
867
|
|
|
} |
|
868
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths