|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* phpBB Gallery - Core Extension |
|
4
|
|
|
* |
|
5
|
|
|
* @package phpbbgallery/core |
|
6
|
|
|
* @author nickvergessen |
|
7
|
|
|
* @author satanasov |
|
8
|
|
|
* @author Leinad4Mind |
|
9
|
|
|
* @copyright 2007-2012 nickvergessen, 2014- satanasov, 2018- Leinad4Mind |
|
10
|
|
|
* @license GPL-2.0-only |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace phpbbgallery\core\controller; |
|
14
|
|
|
|
|
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
class image |
|
18
|
|
|
{ |
|
19
|
|
|
/** @var \phpbb\request\request */ |
|
|
|
|
|
|
20
|
|
|
protected $request; |
|
21
|
|
|
|
|
22
|
|
|
/** @var \phpbb\auth\auth */ |
|
|
|
|
|
|
23
|
|
|
protected $auth; |
|
24
|
|
|
|
|
25
|
|
|
/** @var \phpbb\config\config */ |
|
|
|
|
|
|
26
|
|
|
protected $config; |
|
27
|
|
|
|
|
28
|
|
|
/** @var \phpbb\controller\helper */ |
|
|
|
|
|
|
29
|
|
|
protected $helper; |
|
30
|
|
|
|
|
31
|
|
|
/** @var \phpbb\db\driver\driver|\phpbb\db\driver\driver_interface */ |
|
|
|
|
|
|
32
|
|
|
protected $db; |
|
33
|
|
|
|
|
34
|
|
|
/** @var \phpbb\event\dispatcher */ |
|
|
|
|
|
|
35
|
|
|
protected $dispatcher; |
|
36
|
|
|
|
|
37
|
|
|
/** @var \phpbb\pagination */ |
|
|
|
|
|
|
38
|
|
|
protected $pagination; |
|
39
|
|
|
|
|
40
|
|
|
/** @var \phpbb\template\template */ |
|
|
|
|
|
|
41
|
|
|
protected $template; |
|
42
|
|
|
|
|
43
|
|
|
/** @var \phpbb\user */ |
|
|
|
|
|
|
44
|
|
|
protected $user; |
|
45
|
|
|
|
|
46
|
|
|
/** @var \phpbb\profilefields\manager */ |
|
|
|
|
|
|
47
|
|
|
protected $cpf_manager; |
|
48
|
|
|
|
|
49
|
|
|
/** @var \phpbb\language\language */ |
|
|
|
|
|
|
50
|
|
|
protected $language; |
|
51
|
|
|
|
|
52
|
|
|
/** @var \phpbbgallery\core\album\display */ |
|
53
|
|
|
protected $display; |
|
54
|
|
|
|
|
55
|
|
|
/** @var \phpbbgallery\core\album\loader */ |
|
56
|
|
|
protected $loader; |
|
57
|
|
|
|
|
58
|
|
|
/** @var \phpbbgallery\core\album\album */ |
|
59
|
|
|
protected $album; |
|
60
|
|
|
|
|
61
|
|
|
/** @var \phpbbgallery\core\image\image */ |
|
62
|
|
|
protected $image; |
|
63
|
|
|
|
|
64
|
|
|
/** @var \phpbbgallery\core\auth\auth */ |
|
65
|
|
|
protected $gallery_auth; |
|
66
|
|
|
|
|
67
|
|
|
/** @var \phpbbgallery\core\user */ |
|
68
|
|
|
protected $gallery_user; |
|
69
|
|
|
|
|
70
|
|
|
/** @var \phpbbgallery\core\config */ |
|
71
|
|
|
protected $gallery_config; |
|
72
|
|
|
|
|
73
|
|
|
/** @var \phpbbgallery\core\auth\level */ |
|
74
|
|
|
protected $auth_level; |
|
75
|
|
|
|
|
76
|
|
|
/** @var \phpbbgallery\core\url */ |
|
77
|
|
|
protected $url; |
|
78
|
|
|
|
|
79
|
|
|
/** @var \phpbbgallery\core\misc */ |
|
80
|
|
|
protected $misc; |
|
81
|
|
|
|
|
82
|
|
|
/** @var \phpbbgallery\core\comment */ |
|
83
|
|
|
protected $comment; |
|
84
|
|
|
|
|
85
|
|
|
/** @var \phpbbgallery\core\report */ |
|
86
|
|
|
protected $report; |
|
87
|
|
|
|
|
88
|
|
|
/** @var \phpbbgallery\core\notification\helper */ |
|
89
|
|
|
protected $notification_helper; |
|
90
|
|
|
|
|
91
|
|
|
/** @var \phpbbgallery\core\log */ |
|
92
|
|
|
protected $gallery_log; |
|
93
|
|
|
|
|
94
|
|
|
/** @var \phpbbgallery\core\moderate */ |
|
95
|
|
|
protected $moderate; |
|
96
|
|
|
|
|
97
|
|
|
/** @var \phpbbgallery\core\rating */ |
|
98
|
|
|
protected $gallery_rating; |
|
99
|
|
|
|
|
100
|
|
|
/** @var \phpbbgallery\core\block */ |
|
101
|
|
|
protected $block; |
|
102
|
|
|
|
|
103
|
|
|
/** @var ContainerInterface */ |
|
104
|
|
|
protected $phpbb_container; |
|
105
|
|
|
|
|
106
|
|
|
/** @var */ |
|
107
|
|
|
protected $albums_table; |
|
108
|
|
|
|
|
109
|
|
|
/** @var */ |
|
110
|
|
|
protected $images_table; |
|
111
|
|
|
|
|
112
|
|
|
/** @var */ |
|
113
|
|
|
protected $users_table; |
|
114
|
|
|
|
|
115
|
|
|
/** @var */ |
|
116
|
|
|
protected $table_comments; |
|
117
|
|
|
|
|
118
|
|
|
/** @var */ |
|
119
|
|
|
protected $phpbb_root_path; |
|
120
|
|
|
|
|
121
|
|
|
/** @var */ |
|
122
|
|
|
protected $php_ext; |
|
123
|
|
|
|
|
124
|
|
|
/* @var $data * */ |
|
|
|
|
|
|
125
|
|
|
protected $data; |
|
126
|
|
|
|
|
127
|
|
|
protected $users_id_array; |
|
128
|
|
|
protected $users_data_array; |
|
129
|
|
|
protected $profile_fields_data; |
|
130
|
|
|
protected $can_receive_pm_list; |
|
131
|
|
|
protected $table_albums; |
|
132
|
|
|
protected $table_images; |
|
133
|
|
|
protected $table_users; |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* Constructor |
|
137
|
|
|
* |
|
138
|
|
|
* @param \phpbb\request\request $request |
|
139
|
|
|
* @param \phpbb\auth\auth $auth Gallery auth object |
|
140
|
|
|
* @param \phpbb\config\config $config Config object |
|
141
|
|
|
* @param \phpbb\controller\helper $helper Controller helper object |
|
142
|
|
|
* @param \phpbb\db\driver\driver|\phpbb\db\driver\driver_interface $db Database object |
|
143
|
|
|
* @param \phpbb\event\dispatcher $dispatcher Event dispatcher object |
|
144
|
|
|
* @param \phpbb\pagination $pagination Pagination object |
|
145
|
|
|
* @param \phpbb\template\template $template Template object |
|
146
|
|
|
* @param \phpbb\user $user User object |
|
147
|
|
|
* @param \phpbb\profilefields\manager $cpf_manager |
|
148
|
|
|
* @param \phpbb\language\language $language |
|
149
|
|
|
* @param \phpbbgallery\core\album\display $display Albums display object |
|
150
|
|
|
* @param \phpbbgallery\core\album\loader $loader Albums display object |
|
151
|
|
|
* @param \phpbbgallery\core\album\album $album |
|
152
|
|
|
* @param \phpbbgallery\core\image\image $image |
|
153
|
|
|
* @param \phpbbgallery\core\auth\auth $gallery_auth |
|
154
|
|
|
* @param \phpbbgallery\core\user $gallery_user |
|
155
|
|
|
* @param \phpbbgallery\core\config $gallery_config |
|
156
|
|
|
* @param \phpbbgallery\core\auth\level $auth_level Gallery auth level object |
|
157
|
|
|
* @param \phpbbgallery\core\url $url |
|
158
|
|
|
* @param \phpbbgallery\core\misc $misc |
|
159
|
|
|
* @param \phpbbgallery\core\comment $comment |
|
160
|
|
|
* @param \phpbbgallery\core\report $report |
|
161
|
|
|
* @param \phpbbgallery\core\notification\helper $notification_helper |
|
162
|
|
|
* @param \phpbbgallery\core\log $gallery_log |
|
163
|
|
|
* @param \phpbbgallery\core\moderate $moderate |
|
164
|
|
|
* @param \phpbbgallery\core\rating $gallery_rating |
|
165
|
|
|
* @param \phpbbgallery\core\block $block |
|
166
|
|
|
* @param ContainerInterface $phpbb_container |
|
167
|
|
|
* @param string $albums_table Gallery albums table |
|
168
|
|
|
* @param string $images_table Gallery images table |
|
169
|
|
|
* @param string $users_table Gallery users table |
|
170
|
|
|
* @param $table_comments |
|
171
|
|
|
* @param $phpbb_root_path |
|
172
|
|
|
* @param $php_ext |
|
173
|
|
|
* @internal param \phpbbgallery\core\comment $gallery_comment Gallery comment class |
|
174
|
|
|
*/ |
|
175
|
|
|
public function __construct(\phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\config\config $config, |
|
176
|
|
|
\phpbb\controller\helper $helper, \phpbb\db\driver\driver_interface $db, |
|
177
|
|
|
\phpbb\event\dispatcher $dispatcher, \phpbb\pagination $pagination, |
|
178
|
|
|
\phpbb\template\template $template, \phpbb\user $user, \phpbb\profilefields\manager $cpf_manager, |
|
179
|
|
|
\phpbb\language\language $language, \phpbbgallery\core\album\display $display, |
|
180
|
|
|
\phpbbgallery\core\album\loader $loader, \phpbbgallery\core\album\album $album, |
|
181
|
|
|
\phpbbgallery\core\image\image $image, \phpbbgallery\core\auth\auth $gallery_auth, |
|
182
|
|
|
\phpbbgallery\core\user $gallery_user, \phpbbgallery\core\config $gallery_config, |
|
183
|
|
|
\phpbbgallery\core\auth\level $auth_level, \phpbbgallery\core\url $url, \phpbbgallery\core\misc $misc, |
|
184
|
|
|
\phpbbgallery\core\comment $comment, \phpbbgallery\core\report $report, |
|
185
|
|
|
\phpbbgallery\core\notification\helper $notification_helper, \phpbbgallery\core\log $gallery_log, |
|
186
|
|
|
\phpbbgallery\core\moderate $moderate, \phpbbgallery\core\rating $gallery_rating, |
|
187
|
|
|
\phpbbgallery\core\block $block, ContainerInterface $phpbb_container, |
|
188
|
|
|
$albums_table, $images_table, $users_table, $table_comments, $phpbb_root_path, $php_ext) |
|
189
|
|
|
{ |
|
190
|
|
|
$this->request = $request; |
|
191
|
|
|
$this->auth = $auth; |
|
192
|
|
|
$this->config = $config; |
|
193
|
|
|
$this->helper = $helper; |
|
194
|
|
|
$this->db = $db; |
|
195
|
|
|
$this->dispatcher = $dispatcher; |
|
196
|
|
|
$this->pagination = $pagination; |
|
197
|
|
|
$this->template = $template; |
|
198
|
|
|
$this->user = $user; |
|
199
|
|
|
$this->cpf_manager = $cpf_manager; |
|
200
|
|
|
$this->language = $language; |
|
201
|
|
|
$this->display = $display; |
|
202
|
|
|
$this->loader = $loader; |
|
203
|
|
|
$this->album = $album; |
|
204
|
|
|
$this->image = $image; |
|
205
|
|
|
$this->gallery_auth = $gallery_auth; |
|
206
|
|
|
$this->gallery_user = $gallery_user; |
|
207
|
|
|
$this->gallery_config = $gallery_config; |
|
208
|
|
|
$this->auth_level = $auth_level; |
|
209
|
|
|
$this->url = $url; |
|
210
|
|
|
$this->misc = $misc; |
|
211
|
|
|
$this->comment = $comment; |
|
212
|
|
|
$this->report = $report; |
|
213
|
|
|
$this->notification_helper = $notification_helper; |
|
214
|
|
|
$this->gallery_log = $gallery_log; |
|
215
|
|
|
$this->moderate = $moderate; |
|
216
|
|
|
$this->gallery_rating = $gallery_rating; |
|
217
|
|
|
$this->block = $block; |
|
218
|
|
|
$this->phpbb_container = $phpbb_container; |
|
219
|
|
|
$this->table_albums = $albums_table; |
|
220
|
|
|
$this->table_images = $images_table; |
|
221
|
|
|
$this->table_users = $users_table; |
|
222
|
|
|
$this->table_comments = $table_comments; |
|
223
|
|
|
$this->phpbb_root_path = $phpbb_root_path; |
|
224
|
|
|
$this->php_ext = $php_ext; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* Image Controller |
|
229
|
|
|
* Route: gallery/image_id/{image_id} |
|
230
|
|
|
* |
|
231
|
|
|
* @param int $image_id Image ID |
|
232
|
|
|
* @param int $page |
|
233
|
|
|
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object |
|
|
|
|
|
|
234
|
|
|
*/ |
|
235
|
|
|
public function base($image_id, $page = 0) |
|
236
|
|
|
{ |
|
237
|
|
|
|
|
238
|
|
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
239
|
|
|
try |
|
240
|
|
|
{ |
|
241
|
|
|
$sql = 'SELECT * |
|
242
|
|
|
FROM ' . $this->table_images . ' |
|
243
|
|
|
WHERE image_id = ' . (int) $image_id; |
|
244
|
|
|
$result = $this->db->sql_query($sql); |
|
245
|
|
|
$this->data = $this->db->sql_fetchrow($result); |
|
246
|
|
|
$this->db->sql_freeresult($result); |
|
247
|
|
|
|
|
248
|
|
|
if (!$this->data) |
|
249
|
|
|
{ |
|
250
|
|
|
// Image does not exist |
|
251
|
|
|
throw new \OutOfBoundsException('INVALID_IMAGE'); |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
$this->loader->load($this->data['image_album_id']); |
|
255
|
|
|
} |
|
256
|
|
|
catch (\Exception $e) |
|
257
|
|
|
{ |
|
258
|
|
|
throw new \phpbb\exception\http_exception(404, 'INVALID_IMAGE'); |
|
|
|
|
|
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
$album_id = (int) $this->data['image_album_id']; |
|
262
|
|
|
$album_data = $this->loader->get($album_id); |
|
263
|
|
|
$this->check_permissions($album_id, $album_data['album_user_id'], $this->data['image_status'], $album_data['album_auth_access'], $this->data); |
|
264
|
|
|
$this->display->generate_navigation($album_data); |
|
265
|
|
|
|
|
266
|
|
|
if ($this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id'])) |
|
267
|
|
|
{ |
|
268
|
|
|
$image_status_check = ''; |
|
269
|
|
|
} |
|
270
|
|
|
else |
|
271
|
|
|
{ |
|
272
|
|
|
$user_id = (int) $this->user->data['user_id']; |
|
273
|
|
|
$image_status_check = ' AND (image_status = ' . (int) \phpbbgallery\core\block::STATUS_APPROVED . ' OR image_user_id = ' . $user_id . ')'; |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
if (!$this->user->data['is_bot'] && isset($this->user->data['session_page']) && (strpos($this->user->data['session_page'], '&image_id=' . $image_id) === false || isset($this->user->data['session_created']))) |
|
277
|
|
|
{ |
|
278
|
|
|
$sql = 'UPDATE ' . $this->table_images . ' |
|
279
|
|
|
SET image_view_count = image_view_count + 1 |
|
280
|
|
|
WHERE image_id = ' . (int) $image_id; |
|
281
|
|
|
$this->db->sql_query($sql); |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
// Do stuff here |
|
285
|
|
|
|
|
286
|
|
|
$page_title = $this->data['image_name']; |
|
287
|
|
|
if ($page > 1) |
|
288
|
|
|
{ |
|
289
|
|
|
$page_title .= ' - ' . $this->language->lang('PAGE_TITLE_NUMBER', $page); |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
$s_allowed_delete = $s_allowed_edit = $s_allowed_status = false; |
|
293
|
|
|
if (($this->gallery_auth->acl_check('m_', $album_id, $album_data['album_user_id']) || ($this->data['image_user_id'] == $this->user->data['user_id'])) && ($this->user->data['user_id'] != ANONYMOUS)) |
|
|
|
|
|
|
294
|
|
|
{ |
|
295
|
|
|
$s_user_allowed = (($this->data['image_user_id'] == $this->user->data['user_id']) && ($album_data['album_status'] != 1)); |
|
296
|
|
|
|
|
297
|
|
|
$s_allowed_delete = (($this->gallery_auth->acl_check('i_delete', $album_id, $album_data['album_user_id']) && $s_user_allowed) || $this->gallery_auth->acl_check('m_delete', $album_id, $album_data['album_user_id'])); |
|
298
|
|
|
$s_allowed_edit = (($this->gallery_auth->acl_check('i_edit', $album_id, $album_data['album_user_id']) && $s_user_allowed) || $this->gallery_auth->acl_check('m_edit', $album_id, $album_data['album_user_id'])); |
|
299
|
|
|
$s_quick_mod = ($s_allowed_delete || $s_allowed_edit || $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']) || $this->gallery_auth->acl_check('m_move', $album_id, $album_data['album_user_id'])); |
|
300
|
|
|
|
|
301
|
|
|
$this->language->add_lang(array('gallery_mcp'), 'phpbbgallery/core'); |
|
302
|
|
|
$this->template->assign_vars(array( |
|
303
|
|
|
'S_MOD_ACTION' => $this->helper->route('phpbbgallery_core_moderate_image', array('image_id' => (int) $image_id)), |
|
304
|
|
|
'S_QUICK_MOD' => $s_quick_mod, |
|
305
|
|
|
'S_QM_MOVE' => $this->gallery_auth->acl_check('m_move', $album_id, $album_data['album_user_id']), |
|
306
|
|
|
'S_QM_EDIT' => $s_allowed_edit, |
|
307
|
|
|
'S_QM_DELETE' => $s_allowed_delete, |
|
308
|
|
|
'S_QM_REPORT' => $this->gallery_auth->acl_check('m_report', $album_id, $album_data['album_user_id']), |
|
309
|
|
|
'S_QM_STATUS' => $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']), |
|
310
|
|
|
|
|
311
|
|
|
'S_IMAGE_REPORTED' => $this->data['image_reported'] ? true : false, |
|
312
|
|
|
'U_IMAGE_REPORTED' => ($this->data['image_reported']) ? $this->helper->route('phpbbgallery_core_moderate_image', array('image_id' => (int) $image_id)) : '', |
|
313
|
|
|
'S_STATUS_APPROVED' => ($this->data['image_status'] == (int) \phpbbgallery\core\block::STATUS_APPROVED), |
|
314
|
|
|
'S_STATUS_UNAPPROVED' => ($this->data['image_status'] == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED), |
|
315
|
|
|
'S_STATUS_LOCKED' => ($this->data['image_status'] == (int) \phpbbgallery\core\block::STATUS_LOCKED), |
|
316
|
|
|
)); |
|
317
|
|
|
} |
|
318
|
|
|
$image_desc = generate_text_for_display($this->data['image_desc'], $this->data['image_desc_uid'], $this->data['image_desc_bitfield'], 7); |
|
|
|
|
|
|
319
|
|
|
|
|
320
|
|
|
// Let's see if we can get next end prev |
|
321
|
|
|
$sort_key = $this->request->variable('sk', ($album_data['album_sort_key']) ? $album_data['album_sort_key'] : $this->config['phpbb_gallery_default_sort_key']); |
|
322
|
|
|
$sort_dir = $this->request->variable('sd', ($album_data['album_sort_dir']) ? $album_data['album_sort_dir'] : $this->config['phpbb_gallery_default_sort_dir']); |
|
323
|
|
|
|
|
324
|
|
|
if (in_array($sort_key, array('r', 'ra'))) |
|
325
|
|
|
{ |
|
326
|
|
|
$sql_help_sort = ', image_id ' . (($sort_dir == 'd') ? 'ASC' : 'DESC'); |
|
327
|
|
|
} |
|
328
|
|
|
else |
|
329
|
|
|
{ |
|
330
|
|
|
$sql_help_sort = ', image_id ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
$limit_days = array(); |
|
334
|
|
|
$sort_by_text = array( |
|
335
|
|
|
't' => $this->language->lang('TIME'), |
|
336
|
|
|
'n' => $this->language->lang('IMAGE_NAME'), |
|
337
|
|
|
'vc' => $this->language->lang('GALLERY_VIEWS'), |
|
338
|
|
|
'u' => $this->language->lang('SORT_USERNAME'), |
|
339
|
|
|
); |
|
340
|
|
|
$sort_by_sql = array( |
|
341
|
|
|
't' => 'image_time', |
|
342
|
|
|
'n' => 'image_name_clean', |
|
343
|
|
|
'vc' => 'image_view_count', |
|
344
|
|
|
'u' => 'image_username_clean', |
|
345
|
|
|
); |
|
346
|
|
|
|
|
347
|
|
|
if ($this->config['phpbb_gallery_allow_rates']) |
|
348
|
|
|
{ |
|
349
|
|
|
$sort_by_text['ra'] = $this->language->lang('RATING'); |
|
350
|
|
|
$sort_by_sql['ra'] = 'image_rate_points'; |
|
351
|
|
|
$sort_by_text['r'] = $this->language->lang('RATES_COUNT'); |
|
352
|
|
|
$sort_by_sql['r'] = 'image_rates'; |
|
353
|
|
|
} |
|
354
|
|
|
if ($this->config['phpbb_gallery_allow_comments']) |
|
355
|
|
|
{ |
|
356
|
|
|
$sort_by_text['c'] = $this->language->lang('COMMENTS'); |
|
357
|
|
|
$sort_by_sql['c'] = 'image_comments'; |
|
358
|
|
|
$sort_by_text['lc'] = $this->language->lang('NEW_COMMENT'); |
|
359
|
|
|
$sort_by_sql['lc'] = 'image_last_comment'; |
|
360
|
|
|
} |
|
361
|
|
|
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); |
|
|
|
|
|
|
362
|
|
|
$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); |
|
363
|
|
|
$sql_sort_order .= $sql_help_sort; |
|
364
|
|
|
|
|
365
|
|
|
// Let's see if there is previous image |
|
366
|
|
|
$sql = 'SELECT * |
|
367
|
|
|
FROM ' . $this->table_images . ' |
|
368
|
|
|
WHERE image_album_id = ' . (int) $album_id . ' |
|
369
|
|
|
AND image_status <> ' . (int) \phpbbgallery\core\block::STATUS_ORPHAN . ' |
|
370
|
|
|
' . $image_status_check . ' |
|
371
|
|
|
ORDER BY ' . $sql_sort_order . $sql_help_sort; |
|
372
|
|
|
$result = $this->db->sql_query($sql); |
|
373
|
|
|
$images_array = []; |
|
374
|
|
|
while ($row = $this->db->sql_fetchrow($result)) |
|
375
|
|
|
{ |
|
376
|
|
|
$images_array[] = $row; |
|
377
|
|
|
} |
|
378
|
|
|
$cur = 0; |
|
379
|
|
|
foreach ($images_array as $id => $var) |
|
380
|
|
|
{ |
|
381
|
|
|
if ($var['image_id'] == $image_id) |
|
382
|
|
|
{ |
|
383
|
|
|
$cur = $id; |
|
384
|
|
|
} |
|
385
|
|
|
} |
|
386
|
|
|
$next = $prev = false; |
|
387
|
|
|
if (count($images_array) > $cur + 1) |
|
388
|
|
|
{ |
|
389
|
|
|
$next = array( |
|
390
|
|
|
'image_id' => $images_array[$cur + 1]['image_id'], |
|
391
|
|
|
'image_name' => $images_array[$cur + 1]['image_name'], |
|
392
|
|
|
); |
|
393
|
|
|
} |
|
394
|
|
|
if ($cur > 0) |
|
395
|
|
|
{ |
|
396
|
|
|
$prev = array( |
|
397
|
|
|
'image_id' => $images_array[$cur - 1]['image_id'], |
|
398
|
|
|
'image_name' => $images_array[$cur - 1]['image_name'], |
|
399
|
|
|
); |
|
400
|
|
|
} |
|
401
|
|
|
$this->db->sql_freeresult($result); |
|
402
|
|
|
|
|
403
|
|
|
$this->template->assign_vars(array( |
|
404
|
|
|
'UC_NEXT_IMAGE' => ($next ? ($this->gallery_config->get('disp_nextprev_thumbnail') ? '<a href="' . $this->helper->route('phpbbgallery_core_image', array('image_id' => $next['image_id'])) . '"><img style="max-width: 70px; max-height: 70px;" src="' . $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => $next['image_id'])) . '" alt="' . htmlspecialchars_decode($next['image_name'], ENT_COMPAT) . '"></a>' : '<a href="' . $this->helper->route('phpbbgallery_core_image', array('image_id' => $next['image_id'])) . '">' . htmlspecialchars_decode($next['image_name'], ENT_COMPAT) . ' »»</a>') : ''), |
|
405
|
|
|
'UC_PREV_IMAGE' => ($prev ? ($this->gallery_config->get('disp_nextprev_thumbnail') ? '<a href="' . $this->helper->route('phpbbgallery_core_image', array('image_id' => $prev['image_id'])) . '"><img style="max-width: 70px; max-height: 70px;" src="' . $this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => $prev['image_id'])) . '" alt="' . htmlspecialchars_decode($prev['image_name'], ENT_COMPAT) . '"></a>' : '<a href="' . $this->helper->route('phpbbgallery_core_image', array('image_id' => $prev['image_id'])) . '">«« ' . htmlspecialchars_decode($prev['image_name'], ENT_COMPAT) . '</a>') : ''), |
|
406
|
|
|
'U_VIEW_ALBUM' => $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id)), |
|
407
|
|
|
'UC_IMAGE' => $this->helper->route('phpbbgallery_core_image_file_medium', array('image_id' => (int) $image_id)), |
|
408
|
|
|
//'UC_IMAGE_ACTION' => $this->gallery_config->get('link_imagepage') == 'none' ? '' : $this->gallery_config->get('link_imagepage') == 'image' ? $this->helper->route('phpbbgallery_core_image_file_source', array('image_id' => $image_id)) : $next && $this->gallery_config->get('link_imagepage') == 'next' ? $this->helper->route('phpbbgallery_core_image', array('image_id' => $next['image_id'])) : '', |
|
409
|
|
|
|
|
410
|
|
|
'U_DELETE' => ($s_allowed_delete) ? $this->helper->route('phpbbgallery_core_image_delete', array('image_id' => $image_id)) : '', |
|
411
|
|
|
'U_EDIT' => ($s_allowed_edit) ? $this->helper->route('phpbbgallery_core_image_edit', array('image_id' => $image_id)) : '', |
|
412
|
|
|
'U_REPORT' => ($this->gallery_auth->acl_check('i_report', $album_id, $album_data['album_user_id']) && ($this->data['image_user_id'] != $this->user->data['user_id'])) ? $this->helper->route('phpbbgallery_core_image_report', array('image_id' => $image_id)) : '', |
|
413
|
|
|
'U_STATUS' => ($s_allowed_status) ? $this->helper->route('phpbbgallery_core_moderate_image', array('image_id' => $image_id)) : '', |
|
|
|
|
|
|
414
|
|
|
|
|
415
|
|
|
'CONTEST_RANK' => ($this->data['image_contest_rank']) ? $this->language->lang('CONTEST_RESULT_' . $this->data['image_contest_rank']) : '', |
|
416
|
|
|
'IMAGE_NAME' => htmlspecialchars_decode($this->data['image_name'], ENT_COMPAT), |
|
417
|
|
|
'IMAGE_DESC' => $image_desc, |
|
418
|
|
|
'IMAGE_BBCODE' => ($this->config['allow_bbcode']) ? '[image]' . (int) $image_id . '[/image]' : '', |
|
419
|
|
|
'IMAGE_IMGURL_BBCODE' => ($this->config['phpbb_gallery_disp_image_url']) ? '[url=' . $this->url->get_uri($this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id))) . '][img]' . $this->url->get_uri($this->helper->route('phpbbgallery_core_image_file_mini', array('image_id' => $image_id))) . '[/img][/url]' : '', |
|
420
|
|
|
'IMAGE_URL' => ($this->config['phpbb_gallery_disp_image_url']) ? $this->url->get_uri($this->helper->route('phpbbgallery_core_image_file_medium', array('image_id' => $image_id))) : '', |
|
421
|
|
|
'IMAGE_TIME' => $this->user->format_date($this->data['image_time']), |
|
422
|
|
|
'IMAGE_VIEW' => $this->data['image_view_count'], |
|
423
|
|
|
'POSTER_IP' => ($this->auth->acl_get('a_')) ? $this->data['image_user_ip'] : '', |
|
424
|
|
|
|
|
425
|
|
|
'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)), |
|
426
|
|
|
|
|
427
|
|
|
'U_RETURN_LINK' => $this->helper->route('phpbbgallery_core_album', array('album_id' => $album_id)), |
|
428
|
|
|
'S_RETURN_LINK' => $this->language->lang('RETURN_TO', $album_data['album_name']), |
|
429
|
|
|
)); |
|
430
|
|
|
|
|
431
|
|
|
switch ($this->gallery_config->get('link_imagepage')) |
|
432
|
|
|
{ |
|
433
|
|
|
case 'image': |
|
434
|
|
|
$this->template->assign_vars(array( |
|
435
|
|
|
'UC_IMAGE_ACTION' => $this->helper->route('phpbbgallery_core_image_file_source', array('image_id' => $image_id)), |
|
436
|
|
|
)); |
|
437
|
|
|
break; |
|
438
|
|
|
case 'next': |
|
439
|
|
|
if ($next) |
|
440
|
|
|
{ |
|
441
|
|
|
$this->template->assign_vars(array( |
|
442
|
|
|
'UC_IMAGE_ACTION' => $this->helper->route('phpbbgallery_core_image', array('image_id' => $next['image_id'])), |
|
443
|
|
|
)); |
|
444
|
|
|
} |
|
445
|
|
|
break; |
|
446
|
|
|
} |
|
447
|
|
|
$image_data = $this->data; |
|
448
|
|
|
|
|
449
|
|
|
/** |
|
450
|
|
|
* Event view image |
|
451
|
|
|
* |
|
452
|
|
|
* @event phpbbgallery.core.viewimage |
|
453
|
|
|
* @var int image_id id of the image we are viewing |
|
454
|
|
|
* @var array image_data All the data related to the image |
|
455
|
|
|
* @var array album_data All the data related to the album image is part of |
|
456
|
|
|
* @var string page_title Page title |
|
457
|
|
|
* @since 1.2.0 |
|
458
|
|
|
*/ |
|
459
|
|
|
$vars = array('image_id', 'image_data', 'album_data', 'page_title'); |
|
460
|
|
|
extract($this->dispatcher->trigger_event('phpbbgallery.core.viewimage', compact($vars))); |
|
461
|
|
|
|
|
462
|
|
|
$this->data = $image_data; |
|
463
|
|
|
|
|
464
|
|
|
$this->users_id_array[$this->data['image_user_id']] = $this->data['image_user_id']; |
|
465
|
|
|
|
|
466
|
|
|
$this->load_users_data(); |
|
467
|
|
|
|
|
468
|
|
|
$user_id = $this->data['image_user_id']; |
|
469
|
|
|
$this->users_data_array[$user_id]['username'] = ($this->data['image_username']) ? $this->data['image_username'] : $this->language->lang('GUEST'); |
|
470
|
|
|
$user_data = $this->users_data_array[$user_id] ?? []; |
|
471
|
|
|
$this->template->assign_vars(array( |
|
472
|
|
|
'POSTER_FULL' => get_username_string('full', $user_id, $user_data['username'] ?? '', $user_data['user_colour'] ?? ''), |
|
|
|
|
|
|
473
|
|
|
'POSTER_COLOUR' => get_username_string('colour', $user_id, $user_data['username'] ?? '', $user_data['user_colour'] ?? ''), |
|
474
|
|
|
'POSTER_USERNAME' => get_username_string('username', $user_id, $user_data['username'] ?? '', $user_data['user_colour'] ?? ''), |
|
475
|
|
|
'U_POSTER' => get_username_string('profile', $user_id, $user_data['username'] ?? '', $user_data['user_colour'] ?? ''), |
|
476
|
|
|
|
|
477
|
|
|
'POSTER_SIGNATURE' => $user_data['sig'] ?? '', |
|
478
|
|
|
'POSTER_RANK_TITLE' => $user_data['rank_title'] ?? '', |
|
479
|
|
|
'POSTER_RANK_IMG' => $user_data['rank_image'] ?? '', |
|
480
|
|
|
'POSTER_RANK_IMG_SRC' => $user_data['rank_image_src'] ?? '', |
|
481
|
|
|
'POSTER_JOINED' => $user_data['joined'] ?? '', |
|
482
|
|
|
'POSTER_POSTS' => $user_data['posts'] ?? 0, |
|
483
|
|
|
'POSTER_AVATAR' => $user_data['avatar'] ?? '', |
|
484
|
|
|
'POSTER_WARNINGS' => $user_data['warnings'] ?? 0, |
|
485
|
|
|
'POSTER_AGE' => $user_data['age'] ?? '', |
|
486
|
|
|
|
|
487
|
|
|
'POSTER_ONLINE_IMG' => ($user_id == ANONYMOUS || !$this->config['load_onlinetrack']) ? '' : ($user_data['online'] ? $this->user->img('icon_user_online', 'ONLINE') : $this->user->img('icon_user_offline', 'OFFLINE')), |
|
488
|
|
|
'S_POSTER_ONLINE' => ($user_id == ANONYMOUS || !$this->config['load_onlinetrack']) ? false : $user_data['online'], |
|
489
|
|
|
|
|
490
|
|
|
//'U_POSTER_PROFILE' => $user_data['profile'] ?? '', |
|
491
|
|
|
'U_POSTER_SEARCH' => $user_data['search'] ?? '', |
|
492
|
|
|
'U_POSTER_PM' => ($user_id != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && (($user_data['allow_pm'] ?? false) || $this->auth->acl_gets('a_', 'm_'))) ? append_sid('./ucp.php', 'i=pm&mode=compose&u=' . $user_id) : '', |
|
|
|
|
|
|
493
|
|
|
'U_POSTER_EMAIL' => ($this->auth->acl_gets('a_') || !$this->config['board_hide_emails']) ? ($user_data['email'] ?? false) : false, |
|
494
|
|
|
'U_POSTER_JABBER' => $user_data['jabber'] ?? '', |
|
495
|
|
|
|
|
496
|
|
|
//'U_POSTER_GALLERY' => $user_data['gallery_album'] ?? '', |
|
497
|
|
|
//'POSTER_GALLERY_IMAGES' => $user_data['gallery_images'] ?? '', |
|
498
|
|
|
//'U_POSTER_GALLERY_SEARCH' => $user_data['gallery_search'] ?? '', |
|
499
|
|
|
)); |
|
500
|
|
|
|
|
501
|
|
|
// Add ratings |
|
502
|
|
|
if ($this->gallery_config->get('allow_rates')) |
|
503
|
|
|
{ |
|
504
|
|
|
$rating = $this->gallery_rating; |
|
505
|
|
|
$rating->loader($image_id, $image_data, $album_data); |
|
506
|
|
|
|
|
507
|
|
|
$user_rating = $rating->get_user_rating($this->user->data['user_id']); |
|
508
|
|
|
|
|
509
|
|
|
// Check: User didn't rate yet, has permissions, it's not the users own image and the user is logged in |
|
510
|
|
|
if (!$user_rating && $rating->is_allowed()) |
|
511
|
|
|
{ |
|
512
|
|
|
$rating->display_box(); |
|
513
|
|
|
} |
|
514
|
|
|
$this->template->assign_vars(array( |
|
515
|
|
|
'IMAGE_RATING' => $rating->get_image_rating($user_rating), |
|
516
|
|
|
'S_ALLOWED_TO_RATE' => (!$user_rating && $rating->is_allowed()), |
|
517
|
|
|
'S_VIEW_RATE' => ($this->gallery_auth->acl_check('i_rate', $album_id, $album_data['album_user_id'])) ? true : false, |
|
518
|
|
|
'S_RATE_ACTION' => $this->helper->route('phpbbgallery_core_image_rate', array('image_id' => $image_id)), |
|
519
|
|
|
)); |
|
520
|
|
|
unset($rating); |
|
521
|
|
|
} |
|
522
|
|
|
/** |
|
523
|
|
|
* Posting comment |
|
524
|
|
|
*/ |
|
525
|
|
|
$comments_disabled = (!$this->gallery_config->get('allow_comments') || ($this->gallery_config->get('comment_user_control') && !$image_data['image_allow_comments'])); |
|
526
|
|
|
if (!$comments_disabled && $this->gallery_auth->acl_check('c_post', $album_id, $album_data['album_user_id']) && ($album_data['album_status'] != $this->block->get_album_status_locked()) && (($image_data['image_status'] != $this->block->get_image_status_locked()) || $this->gallery_auth->acl_check('m_status', $album_id, $album_data['album_user_id']))) |
|
527
|
|
|
{ |
|
528
|
|
|
add_form_key('gallery'); |
|
|
|
|
|
|
529
|
|
|
$this->language->add_lang('posting'); |
|
530
|
|
|
$this->url->_include('functions_posting', 'phpbb'); |
|
531
|
|
|
|
|
532
|
|
|
$bbcode_status = ($this->config['allow_bbcode']) ? true : false; |
|
533
|
|
|
$smilies_status = ($this->config['allow_smilies']) ? true : false; |
|
534
|
|
|
$img_status = ($bbcode_status) ? true : false; |
|
535
|
|
|
$url_status = ($this->config['allow_post_links']) ? true : false; |
|
536
|
|
|
$flash_status = false; |
|
537
|
|
|
$quote_status = true; |
|
538
|
|
|
|
|
539
|
|
|
if (!function_exists('generate_smilies')) |
|
540
|
|
|
{ |
|
541
|
|
|
include_once($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext); |
|
542
|
|
|
} |
|
543
|
|
|
if (!function_exists('display_custom_bbcodes')) |
|
544
|
|
|
{ |
|
545
|
|
|
include_once($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); |
|
546
|
|
|
} |
|
547
|
|
|
// Build custom bbcodes array |
|
548
|
|
|
display_custom_bbcodes(); |
|
549
|
|
|
|
|
550
|
|
|
// Build smilies array |
|
551
|
|
|
generate_smilies('inline', 0); |
|
552
|
|
|
|
|
553
|
|
|
if (isset($album_data['contest_start'])) |
|
554
|
|
|
{ |
|
555
|
|
|
$s_hide_comment_input = (time() < ($album_data['contest_start'] + $album_data['contest_end'])) ? true : false; |
|
556
|
|
|
} |
|
557
|
|
|
else |
|
558
|
|
|
{ |
|
559
|
|
|
$s_hide_comment_input = false; |
|
560
|
|
|
} |
|
561
|
|
|
|
|
562
|
|
|
$this->template->assign_vars(array( |
|
563
|
|
|
'S_ALLOWED_TO_COMMENT' => true, |
|
564
|
|
|
'S_HIDE_COMMENT_INPUT' => $s_hide_comment_input, |
|
565
|
|
|
'CONTEST_COMMENTS' => ($s_hide_comment_input ? sprintf($this->language->lang_raw('CONTEST_COMMENTS_STARTS'), $this->user->format_date(($album_data['contest_start'] + $album_data['contest_end']), false, true)) : ''), |
|
566
|
|
|
|
|
567
|
|
|
'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>'), |
|
568
|
|
|
'IMG_STATUS' => ($img_status) ? $this->language->lang('IMAGES_ARE_ON') : $this->language->lang('IMAGES_ARE_OFF'), |
|
569
|
|
|
'FLASH_STATUS' => ($flash_status) ? $this->language->lang('FLASH_IS_ON') : $this->language->lang('FLASH_IS_OFF'), |
|
|
|
|
|
|
570
|
|
|
'SMILIES_STATUS' => ($smilies_status) ? $this->language->lang('SMILIES_ARE_ON') : $this->language->lang('SMILIES_ARE_OFF'), |
|
571
|
|
|
'URL_STATUS' => ($bbcode_status && $url_status) ? $this->language->lang('URL_IS_ON') : $this->language->lang('URL_IS_OFF'), |
|
572
|
|
|
'S_SIGNATURE_CHECKED' => ($this->user->optionget('attachsig')) ? ' checked="checked"' : '', |
|
573
|
|
|
|
|
574
|
|
|
'S_BBCODE_ALLOWED' => $bbcode_status, |
|
575
|
|
|
'S_SMILIES_ALLOWED' => $smilies_status, |
|
576
|
|
|
'S_LINKS_ALLOWED' => $url_status, |
|
577
|
|
|
'S_BBCODE_IMG' => $img_status, |
|
578
|
|
|
'S_BBCODE_URL' => $url_status, |
|
579
|
|
|
'S_BBCODE_FLASH' => $flash_status, |
|
580
|
|
|
'S_BBCODE_QUOTE' => $quote_status, |
|
581
|
|
|
'L_COMMENT_LENGTH' => sprintf($this->language->lang('COMMENT_LENGTH'), $this->gallery_config->get('comment_length')), |
|
582
|
|
|
)); |
|
583
|
|
|
|
|
584
|
|
|
if ($this->misc->display_captcha('comment')) |
|
585
|
|
|
{ |
|
586
|
|
|
$captcha = $this->phpbb_container->get('captcha.factory')->get_instance($this->config['captcha_plugin']) |
|
587
|
|
|
; |
|
588
|
|
|
$captcha->init(CONFIRM_POST); |
|
|
|
|
|
|
589
|
|
|
$s_captcha_hidden_fields = ''; |
|
|
|
|
|
|
590
|
|
|
$this->template->assign_vars(array( |
|
591
|
|
|
'S_CONFIRM_CODE' => true, |
|
592
|
|
|
'CAPTCHA_TEMPLATE' => $captcha->get_template(), |
|
593
|
|
|
)); |
|
594
|
|
|
|
|
595
|
|
|
} |
|
596
|
|
|
|
|
597
|
|
|
// Different link, when we rate and don't comment |
|
598
|
|
|
if (!$s_hide_comment_input) |
|
599
|
|
|
{ |
|
600
|
|
|
//$this->template->assign_var('S_COMMENT_ACTION', append_sid($this->url->path('full') . 'comment/' . $image_id . '/add/0')); |
|
601
|
|
|
$this->template->assign_var('S_COMMENT_ACTION', $this->helper->route('phpbbgallery_core_comment_add', array('image_id' => $image_id, 'comment_id' => 0))); |
|
602
|
|
|
} |
|
603
|
|
|
} |
|
604
|
|
|
else if ($this->gallery_config->get('comment_user_control') && !$image_data['image_allow_comments']) |
|
605
|
|
|
{ |
|
606
|
|
|
$this->template->assign_var('S_COMMENTS_DISABLED', true); |
|
607
|
|
|
} |
|
608
|
|
|
|
|
609
|
|
|
/** |
|
610
|
|
|
* Listing comment |
|
611
|
|
|
*/ |
|
612
|
|
|
if (($this->gallery_config->get('allow_comments') && $this->gallery_auth->acl_check('c_read', $album_id, $album_data['album_user_id'])) /*&& (time() > ($album_data['contest_start'] + $album_data['contest_end']))*/) |
|
613
|
|
|
{ |
|
614
|
|
|
$this->display_comments($image_id, $this->data, $album_id, $album_data, ($page - 1) * $this->gallery_config->get('items_per_page'), $this->gallery_config->get('items_per_page')); |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
return $this->helper->render('gallery/viewimage_body.html', $page_title); |
|
618
|
|
|
} |
|
619
|
|
|
|
|
620
|
|
|
protected function display_comments($image_id, $image_data, $album_id, $album_data, $start, $limit) |
|
621
|
|
|
{ |
|
622
|
|
|
$sort_order = ($this->request->variable('sort_order', 'ASC') == 'ASC') ? 'ASC' : 'DESC'; |
|
623
|
|
|
$this->template->assign_vars(array( |
|
624
|
|
|
'S_ALLOWED_READ_COMMENTS' => true, |
|
625
|
|
|
'IMAGE_COMMENTS' => $image_data['image_comments'], |
|
626
|
|
|
'SORT_ASC' => ($sort_order == 'ASC') ? true : false, |
|
627
|
|
|
)); |
|
628
|
|
|
|
|
629
|
|
|
if ($image_data['image_comments'] > 0) |
|
630
|
|
|
{ |
|
631
|
|
|
if (!class_exists('bbcode')) |
|
632
|
|
|
{ |
|
633
|
|
|
$this->url->_include('bbcode', 'phpbb'); |
|
634
|
|
|
} |
|
635
|
|
|
|
|
636
|
|
|
$bbcode = new \bbcode(); |
|
|
|
|
|
|
637
|
|
|
|
|
638
|
|
|
$comments = array(); |
|
639
|
|
|
$sql = 'SELECT * |
|
640
|
|
|
FROM ' . $this->table_comments . ' |
|
641
|
|
|
WHERE comment_image_id = ' . (int) $image_id . ' |
|
642
|
|
|
ORDER BY comment_id ' . $sort_order; |
|
643
|
|
|
$result = $this->db->sql_query_limit($sql, $limit, $start); |
|
644
|
|
|
|
|
645
|
|
|
while ($row = $this->db->sql_fetchrow($result)) |
|
646
|
|
|
{ |
|
647
|
|
|
$comments[] = $row; |
|
648
|
|
|
$this->users_id_array[$row['comment_user_id']] = $row['comment_user_id']; |
|
649
|
|
|
if ($row['comment_edit_count'] > 0) |
|
650
|
|
|
{ |
|
651
|
|
|
$this->users_id_array[$row['comment_edit_user_id']] = $row['comment_edit_user_id']; |
|
652
|
|
|
} |
|
653
|
|
|
} |
|
654
|
|
|
$this->db->sql_freeresult($result); |
|
655
|
|
|
|
|
656
|
|
|
$this->load_users_data(); |
|
657
|
|
|
|
|
658
|
|
|
foreach ($comments as $row) |
|
659
|
|
|
{ |
|
660
|
|
|
$edit_info = ''; |
|
661
|
|
|
|
|
662
|
|
|
// Let's deploy new profile |
|
663
|
|
|
$poster_id = $row['comment_user_id']; |
|
664
|
|
|
$user_data = $this->users_data_array[$poster_id] ?? []; |
|
665
|
|
|
if ($row['comment_edit_count'] > 0) |
|
666
|
|
|
{ |
|
667
|
|
|
$edit_info = ($row['comment_edit_count'] == 1) ? $this->language->lang('IMAGE_EDITED_TIME_TOTAL') : $this->language->lang('IMAGE_EDITED_TIMES_TOTAL'); |
|
668
|
|
|
$edit_info = sprintf($edit_info, get_username_string('full', $row['comment_edit_user_id'], $this->users_data_array[$row['comment_edit_user_id']]['username'], $this->users_data_array[$row['comment_edit_user_id']]['user_colour']), $this->user->format_date($row['comment_edit_time'], false, true), $row['comment_edit_count']); |
|
|
|
|
|
|
669
|
|
|
} |
|
670
|
|
|
$user_deleted = (isset($user_data) ? false : true); |
|
671
|
|
|
// End signature parsing, only if needed |
|
672
|
|
|
if ($user_data['sig'] && empty($user_data['sig_parsed'])) |
|
673
|
|
|
{ |
|
674
|
|
|
$parse_flags = ($user_data['sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; |
|
|
|
|
|
|
675
|
|
|
$user_cache[$poster_id]['sig'] = generate_text_for_display($user_data['sig'], $user_data['sig_bbcode_uid'], $user_data['sig_bbcode_bitfield'], $parse_flags, true); |
|
|
|
|
|
|
676
|
|
|
$user_cache[$poster_id]['sig_parsed'] = true; |
|
677
|
|
|
} |
|
678
|
|
|
|
|
679
|
|
|
$cp_row = array(); |
|
680
|
|
|
//CPF |
|
681
|
|
|
if ($this->config['load_cpf_viewtopic']) |
|
682
|
|
|
{ |
|
683
|
|
|
$cp_row = (isset($this->profile_fields_data[$poster_id])) ? $this->cpf_manager->generate_profile_fields_template_data($this->profile_fields_data[$poster_id]) : array(); |
|
684
|
|
|
} |
|
685
|
|
|
$can_receive_pm = ( |
|
686
|
|
|
// They must be a "normal" user |
|
687
|
|
|
$user_data['user_type'] != USER_IGNORE && |
|
|
|
|
|
|
688
|
|
|
// They must not be deactivated by the administrator |
|
689
|
|
|
($user_data['user_type'] != USER_INACTIVE || $user_data['user_inactive_reason'] != INACTIVE_MANUAL) && |
|
|
|
|
|
|
690
|
|
|
// They must be able to read PMs |
|
691
|
|
|
in_array($poster_id, $this->can_receive_pm_list) && |
|
692
|
|
|
// They must allow users to contact via PM |
|
693
|
|
|
(($this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) || $user_data['allow_pm']) |
|
694
|
|
|
); |
|
695
|
|
|
$u_pm = ''; |
|
696
|
|
|
if ($this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $can_receive_pm) |
|
697
|
|
|
{ |
|
698
|
|
|
$u_pm = append_sid("{$this->phpbb_root_path}ucp.$this->php_ext", 'i=pm&mode=compose'); |
|
|
|
|
|
|
699
|
|
|
} |
|
700
|
|
|
|
|
701
|
|
|
$user_data = $this->users_data_array[$poster_id] ?? []; |
|
702
|
|
|
$comment_row = array( |
|
703
|
|
|
'U_COMMENT' => $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)) . '#comment_' . $row['comment_id'], |
|
704
|
|
|
'COMMENT_ID' => $row['comment_id'], |
|
705
|
|
|
'TIME' => $this->user->format_date($row['comment_time']), |
|
706
|
|
|
'TEXT' => generate_text_for_display($row['comment'], $row['comment_uid'], $row['comment_bitfield'], 7), |
|
707
|
|
|
'EDIT_INFO' => $edit_info, |
|
708
|
|
|
'U_DELETE' => ($this->gallery_auth->acl_check('m_comments', $album_id, $album_data['album_user_id']) || ($this->gallery_auth->acl_check('c_delete', $album_id, $album_data['album_user_id']) && ($row['comment_user_id'] == $this->user->data['user_id']) && $this->user->data['is_registered'])) ? $this->helper->route('phpbbgallery_core_comment_delete', array('image_id' => $image_id, 'comment_id' => $row['comment_id'])) : '', |
|
709
|
|
|
'U_QUOTE' => ($this->gallery_auth->acl_check('c_post', $album_id, $album_data['album_user_id'])) ? $this->helper->route('phpbbgallery_core_comment_add', array('image_id' => $image_id, 'comment_id' => $row['comment_id'])) : '', |
|
710
|
|
|
'U_EDIT' => ($this->gallery_auth->acl_check('m_comments', $album_id, $album_data['album_user_id']) || ($this->gallery_auth->acl_check('c_edit', $album_id, $album_data['album_user_id']) && ($row['comment_user_id'] == $this->user->data['user_id']) && $this->user->data['is_registered'])) ? $this->helper->route('phpbbgallery_core_comment_edit', array('image_id' => $image_id, 'comment_id' => $row['comment_id'])) : '', |
|
711
|
|
|
// TODO Whois link |
|
712
|
|
|
// 'U_WHOIS' => ($this->auth->acl_get('a_')) ? $this->url->append_sid('mcp', 'mode=whois&ip=' . $row['comment_user_ip']) : '', |
|
713
|
|
|
|
|
714
|
|
|
'POSTER_FULL' => get_username_string('full', $poster_id, $user_data['username'], $user_data['user_colour']), |
|
715
|
|
|
'POSTER_COLOUR' => get_username_string('colour', $poster_id, $user_data['username'], $user_data['user_colour']), |
|
716
|
|
|
'POSTER_USERNAME' => get_username_string('username', $poster_id, $user_data['username'], $user_data['user_colour']), |
|
717
|
|
|
'U_POSTER' => get_username_string('profile', $poster_id, $user_data['username'], $user_data['user_colour']), |
|
718
|
|
|
'POSTER_IP' => ($this->auth->acl_get('a_')) ? $row['comment_user_ip'] : '', |
|
719
|
|
|
|
|
720
|
|
|
'POSTER_SIGNATURE' => ($row['comment_signature'] && !$user_deleted) ? generate_text_for_display($user_data['sig'], $row['comment_uid'], $row['comment_bitfield'], 7) : '', |
|
721
|
|
|
'POSTER_RANK_TITLE' => $user_deleted ? '' : $user_data['rank_title'], |
|
722
|
|
|
'POSTER_RANK_IMG' => $user_deleted ? '' : $user_data['rank_image'], |
|
723
|
|
|
'POSTER_RANK_IMG_SRC' => $user_deleted ? '' : $user_data['rank_image_src'], |
|
724
|
|
|
'POSTER_JOINED' => $user_deleted ? '' : $user_data['joined'], |
|
725
|
|
|
'POSTER_POSTS' => $user_deleted ? '' : $user_data['posts'], |
|
726
|
|
|
'POSTER_FROM' => isset($user_data['from']) ? $user_data['from'] : '', |
|
727
|
|
|
'POSTER_AVATAR' => $user_deleted ? '' : $user_data['avatar'], |
|
728
|
|
|
'POSTER_WARNINGS' => $user_deleted ? '' : $user_data['warnings'], |
|
729
|
|
|
'POSTER_AGE' => $user_deleted ? '' : $user_data['age'], |
|
730
|
|
|
|
|
731
|
|
|
// 'MINI_POST_IMG' => $this->user->img('icon_post_target', 'POST'), |
|
732
|
|
|
// 'ICQ_STATUS_IMG' => isset($user_data['icq_status_img']) ? $user_data['icq_status_img'] : '', |
|
733
|
|
|
'POSTER_ONLINE_IMG' => ($poster_id == ANONYMOUS || !$this->config['load_onlinetrack']) ? '' : ($user_deleted ? '' : ($user_data['online'] ? $this->user->img('icon_user_online', 'ONLINE') : $this->user->img('icon_user_offline', 'OFFLINE'))), |
|
|
|
|
|
|
734
|
|
|
'S_POSTER_ONLINE' => ($poster_id == ANONYMOUS || !$this->config['load_onlinetrack']) ? false : ($user_deleted ? '' : $user_data['online']), |
|
735
|
|
|
|
|
736
|
|
|
'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && count($cp_row['row'])) ? true : false, |
|
737
|
|
|
); |
|
738
|
|
|
|
|
739
|
|
|
if (isset($cp_row['row']) && count($cp_row['row'])) |
|
740
|
|
|
{ |
|
741
|
|
|
$comment_row = array_merge($comment_row, $cp_row['row']); |
|
742
|
|
|
} |
|
743
|
|
|
$this->template->assign_block_vars('commentrow', $comment_row); |
|
744
|
|
|
|
|
745
|
|
|
$contact_fields = array( |
|
746
|
|
|
array( |
|
747
|
|
|
'ID' => 'pm', |
|
748
|
|
|
'NAME' => $this->language->lang('SEND_PRIVATE_MESSAGE'), |
|
749
|
|
|
'U_CONTACT' => $u_pm, |
|
750
|
|
|
), |
|
751
|
|
|
array( |
|
752
|
|
|
'ID' => 'email', |
|
753
|
|
|
'NAME' => $this->language->lang('SEND_EMAIL'), |
|
754
|
|
|
'U_CONTACT' => $user_data['email'], |
|
755
|
|
|
), |
|
756
|
|
|
array( |
|
757
|
|
|
'ID' => 'jabber', |
|
758
|
|
|
'NAME' => $this->language->lang('JABBER'), |
|
759
|
|
|
'U_CONTACT' => $user_data['jabber'], |
|
760
|
|
|
), |
|
761
|
|
|
); |
|
762
|
|
|
|
|
763
|
|
|
foreach ($contact_fields as $field) |
|
764
|
|
|
{ |
|
765
|
|
|
if ($field['U_CONTACT']) |
|
766
|
|
|
{ |
|
767
|
|
|
$this->template->assign_block_vars('commentrow.contact', $field); |
|
768
|
|
|
} |
|
769
|
|
|
} |
|
770
|
|
|
|
|
771
|
|
|
if (!empty($cp_row['blockrow'])) |
|
772
|
|
|
{ |
|
773
|
|
|
foreach ($cp_row['blockrow'] as $field_data) |
|
774
|
|
|
{ |
|
775
|
|
|
if ($field_data['S_PROFILE_CONTACT']) |
|
776
|
|
|
{ |
|
777
|
|
|
$this->template->assign_block_vars('commentrow.contact', array( |
|
778
|
|
|
'ID' => $field_data['PROFILE_FIELD_IDENT'], |
|
779
|
|
|
'NAME' => $field_data['PROFILE_FIELD_NAME'], |
|
780
|
|
|
'U_CONTACT' => $field_data['PROFILE_FIELD_CONTACT'], |
|
781
|
|
|
)); |
|
782
|
|
|
} |
|
783
|
|
|
else |
|
784
|
|
|
{ |
|
785
|
|
|
$this->template->assign_block_vars('commentrow.custom_fields', $field_data); |
|
786
|
|
|
} |
|
787
|
|
|
} |
|
788
|
|
|
} |
|
789
|
|
|
|
|
790
|
|
|
} |
|
791
|
|
|
//$this->db->sql_freeresult($result); |
|
792
|
|
|
|
|
793
|
|
|
$this->pagination->generate_template_pagination(array( |
|
794
|
|
|
'routes' => array( |
|
795
|
|
|
'phpbbgallery_core_image', |
|
796
|
|
|
'phpbbgallery_core_image_page', |
|
797
|
|
|
), |
|
798
|
|
|
'params' => array( |
|
799
|
|
|
'image_id' => (int) $image_id, |
|
800
|
|
|
), |
|
801
|
|
|
), 'pagination', 'page', $image_data['image_comments'], $limit, $start); |
|
802
|
|
|
|
|
803
|
|
|
$this->template->assign_vars(array( |
|
804
|
|
|
'TOTAL_COMMENTS' => $this->language->lang('VIEW_IMAGE_COMMENTS', $image_data['image_comments']), |
|
805
|
|
|
//'S_SELECT_SORT_DIR' => $s_sort_dir, |
|
806
|
|
|
//'S_SELECT_SORT_KEY' => $s_sort_key, |
|
807
|
|
|
)); |
|
808
|
|
|
} |
|
809
|
|
|
} |
|
810
|
|
|
|
|
811
|
|
|
// Edit image |
|
812
|
|
|
public function edit($image_id) |
|
813
|
|
|
{ |
|
814
|
|
|
//we cheat a little but we will make good later |
|
815
|
|
|
$image_data = $this->image->get_image_data($image_id); |
|
816
|
|
|
$album_id = $image_data['image_album_id']; |
|
817
|
|
|
$album_data = $this->album->get_info($album_id); |
|
818
|
|
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
819
|
|
|
$this->display->generate_navigation($album_data); |
|
820
|
|
|
add_form_key('gallery'); |
|
|
|
|
|
|
821
|
|
|
$submit = $this->request->variable('submit', false); |
|
822
|
|
|
$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)); |
|
823
|
|
|
$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $image_data['image_album_id'])); |
|
824
|
|
|
$disp_image_data = $image_data; |
|
825
|
|
|
$owner_id = $image_data['image_user_id']; |
|
826
|
|
|
$album_loginlink = './ucp.php?mode=login'; |
|
827
|
|
|
$this->gallery_auth->load_user_permissions($this->user->data['user_id']); |
|
828
|
|
|
if (!$this->gallery_auth->acl_check('i_edit', $album_id, $album_data['album_user_id']) || ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_ORPHAN)) |
|
829
|
|
|
{ |
|
830
|
|
|
if (!$this->gallery_auth->acl_check('m_edit', $album_id, $album_data['album_user_id'])) |
|
831
|
|
|
{ |
|
832
|
|
|
$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD'); |
|
833
|
|
|
} |
|
834
|
|
|
} |
|
835
|
|
|
if ($submit) |
|
836
|
|
|
{ |
|
837
|
|
|
if (!check_form_key('gallery')) |
|
|
|
|
|
|
838
|
|
|
{ |
|
839
|
|
|
trigger_error('FORM_INVALID'); |
|
840
|
|
|
} |
|
841
|
|
|
|
|
842
|
|
|
$image_desc = $this->request->variable('message', array(''), true); |
|
843
|
|
|
$image_desc = $image_desc[0]; |
|
844
|
|
|
$image_name = $this->request->variable('image_name', array(''), true); |
|
845
|
|
|
$image_name = $image_name[0]; |
|
846
|
|
|
if (strlen($image_desc) > $this->gallery_config->get('description_length')) |
|
847
|
|
|
{ |
|
848
|
|
|
trigger_error($this->language->lang('DESC_TOO_LONG')); |
|
849
|
|
|
} |
|
850
|
|
|
// Create message parser instance |
|
851
|
|
|
if (!class_exists('parse_message')) |
|
852
|
|
|
{ |
|
853
|
|
|
include_once($this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext); |
|
854
|
|
|
} |
|
855
|
|
|
$message_parser = new \parse_message(); |
|
|
|
|
|
|
856
|
|
|
$message_parser->message = utf8_normalize_nfc($image_desc); |
|
|
|
|
|
|
857
|
|
|
if ($message_parser->message) |
|
858
|
|
|
{ |
|
859
|
|
|
$message_parser->parse(true, true, true, true, false, true, true, true); |
|
860
|
|
|
} |
|
861
|
|
|
|
|
862
|
|
|
$sql_ary = array( |
|
863
|
|
|
'image_name' => $image_name, |
|
864
|
|
|
'image_name_clean' => utf8_clean_string($image_name), |
|
|
|
|
|
|
865
|
|
|
'image_desc' => $message_parser->message, |
|
866
|
|
|
'image_desc_uid' => $message_parser->bbcode_uid, |
|
867
|
|
|
'image_desc_bitfield' => $message_parser->bbcode_bitfield, |
|
868
|
|
|
'image_allow_comments' => $this->request->variable('allow_comments', 0), |
|
869
|
|
|
); |
|
870
|
|
|
|
|
871
|
|
|
/** |
|
872
|
|
|
* Event edit image |
|
873
|
|
|
* |
|
874
|
|
|
* @event phpbbgallery.core.image_edit |
|
875
|
|
|
* @var array sql_ary sql array that should be populated. |
|
876
|
|
|
* @since 3.2.2 |
|
877
|
|
|
*/ |
|
878
|
|
|
$vars = array('sql_ary'); |
|
879
|
|
|
extract($this->dispatcher->trigger_event('phpbbgallery.core.image_edit', compact($vars))); |
|
880
|
|
|
|
|
881
|
|
|
$errors = array(); |
|
882
|
|
|
if (empty($sql_ary['image_name_clean'])) |
|
883
|
|
|
{ |
|
884
|
|
|
$errors[] = $this->language->lang('MISSING_IMAGE_NAME'); |
|
885
|
|
|
} |
|
886
|
|
|
|
|
887
|
|
|
if (!$this->gallery_config->get('allow_comments') || !$this->gallery_config->get('comment_user_control')) |
|
888
|
|
|
{ |
|
889
|
|
|
unset($sql_ary['image_allow_comments']); |
|
890
|
|
|
} |
|
891
|
|
|
|
|
892
|
|
|
$change_image_count = false; |
|
893
|
|
|
if ($this->gallery_auth->acl_check('m_edit', $album_id, $album_data['album_user_id'])) |
|
894
|
|
|
{ |
|
895
|
|
|
$user_data = $this->image->get_new_author_info($this->request->variable('change_author', '', true)); |
|
896
|
|
|
if ($user_data) |
|
|
|
|
|
|
897
|
|
|
{ |
|
898
|
|
|
$sql_ary = array_merge($sql_ary, array( |
|
899
|
|
|
'image_user_id' => $user_data['user_id'], |
|
900
|
|
|
'image_username' => $user_data['username'], |
|
901
|
|
|
'image_username_clean' => utf8_clean_string($user_data['username']), |
|
902
|
|
|
'image_user_colour' => $user_data['user_colour'], |
|
903
|
|
|
)); |
|
904
|
|
|
|
|
905
|
|
|
if ($image_data['image_status'] != $this->block->get_image_status_unapproved()) |
|
906
|
|
|
{ |
|
907
|
|
|
$change_image_count = true; |
|
908
|
|
|
} |
|
909
|
|
|
} |
|
910
|
|
|
else if ($this->request->variable('change_author', '', true)) |
|
911
|
|
|
{ |
|
912
|
|
|
$errors[] = $this->language->lang('INVALID_USERNAME'); |
|
913
|
|
|
} |
|
914
|
|
|
} |
|
915
|
|
|
|
|
916
|
|
|
$move_to_personal = $this->request->variable('move_to_personal', 0); |
|
917
|
|
|
if ($move_to_personal) |
|
918
|
|
|
{ |
|
919
|
|
|
$personal_album_id = 0; |
|
920
|
|
|
if ($this->user->data['user_id'] != $image_data['image_user_id']) |
|
921
|
|
|
{ |
|
922
|
|
|
$image_user = $this->gallery_user; |
|
923
|
|
|
$image_user->set_user_id($image_data['image_user_id']); |
|
924
|
|
|
$personal_album_id = $image_user->get_data('personal_album_id'); |
|
925
|
|
|
|
|
926
|
|
|
// The User has no personal album, moderators can created that without the need of permissions |
|
927
|
|
|
if (!$personal_album_id) |
|
928
|
|
|
{ |
|
929
|
|
|
$personal_album_id = $this->album->generate_personal_album($image_data['image_username'], $image_data['image_user_id'], $image_data['image_user_colour'], $image_user); |
|
930
|
|
|
} |
|
931
|
|
|
} |
|
932
|
|
|
else |
|
933
|
|
|
{ |
|
934
|
|
|
$personal_album_id = $this->gallery_user->get_data('personal_album_id'); |
|
935
|
|
|
if (!$personal_album_id && $this->gallery_auth->acl_check('i_upload', $this->gallery_auth->get_own_album())) |
|
936
|
|
|
{ |
|
937
|
|
|
$personal_album_id = $this->album->generate_personal_album($image_data['image_username'], $image_data['image_user_id'], $image_data['image_user_colour'], phpbb_gallery::$user); |
|
|
|
|
|
|
938
|
|
|
} |
|
939
|
|
|
} |
|
940
|
|
|
|
|
941
|
|
|
if ($personal_album_id) |
|
942
|
|
|
{ |
|
943
|
|
|
$sql_ary['image_album_id'] = $personal_album_id; |
|
944
|
|
|
} |
|
945
|
|
|
} |
|
946
|
|
|
|
|
947
|
|
|
$rotate = $this->request->variable('rotate', array(0)); |
|
948
|
|
|
$rotate = (isset($rotate[0])) ? $rotate[0] : 0; |
|
949
|
|
|
if ($this->gallery_config->get('allow_rotate') && ($rotate > 0) && (($rotate % 90) == 0)) |
|
950
|
|
|
{ |
|
951
|
|
|
$image_tools = new \phpbbgallery\core\file\file($this->request, $this->url, $this->gallery_config, 2); |
|
952
|
|
|
$image_tools->set_image_options($this->gallery_config->get('max_filesize'), $this->gallery_config->get('max_height'), $this->gallery_config->get('max_width')); |
|
953
|
|
|
$image_tools->set_image_data($this->url->path('upload') . $image_data['image_filename']); |
|
954
|
|
|
|
|
955
|
|
|
// Rotate the image |
|
956
|
|
|
$image_tools->rotate_image($rotate, $this->gallery_config->get('allow_rotate')); |
|
957
|
|
|
if ($image_tools->rotated) |
|
958
|
|
|
{ |
|
959
|
|
|
$image_tools->write_image($image_tools->image_source, $this->gallery_config->get('jpg_quality'), true); |
|
960
|
|
|
} |
|
961
|
|
|
@unlink($this->url->path('thumbnail') . $image_data['image_filename']); |
|
|
|
|
|
|
962
|
|
|
@unlink($this->url->path('medium') . $image_data['image_filename']); |
|
963
|
|
|
} |
|
964
|
|
|
|
|
965
|
|
|
$error = implode('<br />', $errors); |
|
966
|
|
|
|
|
967
|
|
|
if (!$error) |
|
968
|
|
|
{ |
|
969
|
|
|
$sql = 'UPDATE ' . $this->table_images . ' |
|
970
|
|
|
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' |
|
971
|
|
|
WHERE image_id = ' . (int) $image_id; |
|
972
|
|
|
$this->db->sql_query($sql); |
|
973
|
|
|
|
|
974
|
|
|
$this->album->update_info($album_data['album_id']); |
|
975
|
|
|
if ($move_to_personal && $personal_album_id) |
|
976
|
|
|
{ |
|
977
|
|
|
$this->album->update_info($personal_album_id); |
|
978
|
|
|
} |
|
979
|
|
|
|
|
980
|
|
|
if ($change_image_count) |
|
|
|
|
|
|
981
|
|
|
{ |
|
982
|
|
|
$new_user = new \phpbbgallery\core\user($this->db, $this->dispatcher, $this->user, $this->cpf_manager, $this->config, $this->auth, $this->table_users, $this->phpbb_root_path, $this->php_ext); |
|
983
|
|
|
$new_user->set_user_id($user_data['user_id']); |
|
984
|
|
|
$new_user->update_images(1); |
|
985
|
|
|
$old_user = new \phpbbgallery\core\user($this->db, $this->dispatcher, $this->user, $this->cpf_manager, $this->config, $this->auth, $this->table_users, $this->phpbb_root_path, $this->php_ext); |
|
986
|
|
|
$old_user->set_user_id($image_data['image_user_id']); |
|
987
|
|
|
$old_user->update_images(-1); |
|
988
|
|
|
} |
|
989
|
|
|
|
|
990
|
|
|
if ($this->user->data['user_id'] != $image_data['image_user_id']) |
|
991
|
|
|
{ |
|
992
|
|
|
$this->gallery_log->add_log('moderator', 'edit', $image_data['image_album_id'], $image_id, array('LOG_GALLERY_EDITED', $image_name)); |
|
993
|
|
|
} |
|
994
|
|
|
|
|
995
|
|
|
$message = $this->language->lang('IMAGES_UPDATED_SUCCESSFULLY'); |
|
996
|
|
|
$message .= '<br /><br />' . sprintf($this->language->lang('CLICK_RETURN_IMAGE'), '<a href="' . $image_backlink . '">', '</a>'); |
|
997
|
|
|
$message .= '<br /><br />' . sprintf($this->language->lang('CLICK_RETURN_ALBUM'), '<a href="' . $album_backlink . '">', '</a>'); |
|
998
|
|
|
$this->url->meta_refresh(3, $image_backlink); |
|
999
|
|
|
trigger_error($message); |
|
1000
|
|
|
} |
|
1001
|
|
|
$disp_image_data = array_merge($disp_image_data, $sql_ary); |
|
|
|
|
|
|
1002
|
|
|
} |
|
1003
|
|
|
|
|
1004
|
|
|
if (!class_exists('bbcode')) |
|
1005
|
|
|
{ |
|
1006
|
|
|
include($this->phpbb_root_path . 'includes/bbcode.' . $this->php_ext); |
|
1007
|
|
|
} |
|
1008
|
|
|
if (!class_exists('parse_message')) |
|
1009
|
|
|
{ |
|
1010
|
|
|
include_once($this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext); |
|
1011
|
|
|
} |
|
1012
|
|
|
$message_parser = new \parse_message(); |
|
1013
|
|
|
$message_parser->message = $disp_image_data['image_desc']; |
|
1014
|
|
|
$message_parser->decode_message($disp_image_data['image_desc_uid']); |
|
1015
|
|
|
|
|
1016
|
|
|
$page_title = $disp_image_data['image_name']; |
|
1017
|
|
|
|
|
1018
|
|
|
$template_vars = array( |
|
1019
|
|
|
'U_IMAGE' => $this->image->generate_link('thumbnail', 'plugin', $image_id, $image_data['image_name'], $album_id), |
|
1020
|
|
|
'IMAGE_NAME' => $disp_image_data['image_name'], |
|
1021
|
|
|
'IMAGE_DESC' => $message_parser->message, |
|
1022
|
|
|
); |
|
1023
|
|
|
|
|
1024
|
|
|
/** |
|
1025
|
|
|
* Event edit image display |
|
1026
|
|
|
* |
|
1027
|
|
|
* @event phpbbgallery.core.image_edit_display |
|
1028
|
|
|
* @var array template_vars Template array. |
|
1029
|
|
|
* @var array disp_image_data Display image array. |
|
1030
|
|
|
* @since 3.2.2 |
|
1031
|
|
|
*/ |
|
1032
|
|
|
$vars = array('template_vars', 'disp_image_data'); |
|
1033
|
|
|
extract($this->dispatcher->trigger_event('phpbbgallery.core.image_edit_display', compact($vars))); |
|
1034
|
|
|
$this->template->assign_block_vars('image', $template_vars); |
|
1035
|
|
|
|
|
1036
|
|
|
$this->template->assign_vars(array( |
|
1037
|
|
|
'L_DESCRIPTION_LENGTH' => $this->language->lang('DESCRIPTION_LENGTH', $this->gallery_config->get('description_length')), |
|
1038
|
|
|
'S_EDIT' => true, |
|
1039
|
|
|
'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_core_image_edit', array('image_id' => $image_id)), |
|
1040
|
|
|
'ERROR' => (isset($error)) ? $error : '', |
|
1041
|
|
|
|
|
1042
|
|
|
'U_VIEW_IMAGE' => $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)), |
|
1043
|
|
|
'IMAGE_NAME' => $image_data['image_name'], |
|
1044
|
|
|
|
|
1045
|
|
|
'S_CHANGE_AUTHOR' => $this->gallery_auth->acl_check('m_edit', $album_id, $album_data['album_user_id']), |
|
1046
|
|
|
'U_FIND_USERNAME' => $this->url->append_sid('phpbb', 'memberlist', 'mode=searchuser&form=postform&field=change_author&select_single=true'), |
|
1047
|
|
|
'S_COMMENTS_ENABLED' => $this->gallery_config->get('allow_comments') && $this->gallery_config->get('comment_user_control'), |
|
1048
|
|
|
'S_ALLOW_COMMENTS' => $image_data['image_allow_comments'], |
|
1049
|
|
|
|
|
1050
|
|
|
'NUM_IMAGES' => 1, |
|
1051
|
|
|
'S_ALLOW_ROTATE' => ($this->gallery_config->get('allow_rotate') && function_exists('imagerotate')), |
|
1052
|
|
|
//'S_MOVE_PERSONAL' => (($this->galley_auth->acl_check('i_upload', $this->galley_auth::OWN_ALBUM) || phpbb_gallery::$user->get_data('personal_album_id')) || ($user->data['user_id'] != $image_data['image_user_id'])) ? true : false, |
|
1053
|
|
|
'S_MOVE_MODERATOR' => ($this->user->data['user_id'] != $image_data['image_user_id']) ? true : false, |
|
1054
|
|
|
)); |
|
1055
|
|
|
|
|
1056
|
|
|
return $this->helper->render('gallery/posting_body.html', $page_title); |
|
1057
|
|
|
} |
|
1058
|
|
|
|
|
1059
|
|
|
// Delete image |
|
1060
|
|
|
public function delete($image_id) |
|
1061
|
|
|
{ |
|
1062
|
|
|
$image_data = $this->image->get_image_data($image_id); |
|
1063
|
|
|
$album_id = $image_data['image_album_id']; |
|
1064
|
|
|
$album_data = $this->album->get_info($album_id); |
|
1065
|
|
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
1066
|
|
|
$album_loginlink = './ucp.php?mode=login'; |
|
1067
|
|
|
$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)); |
|
1068
|
|
|
$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $image_data['image_album_id'])); |
|
1069
|
|
|
$this->gallery_auth->load_user_permissions($this->user->data['user_id']); |
|
1070
|
|
|
if (!$this->gallery_auth->acl_check('i_delete', $album_id, $album_data['album_user_id']) || ($image_data['image_status'] == (int) \phpbbgallery\core\block::STATUS_ORPHAN)) |
|
1071
|
|
|
{ |
|
1072
|
|
|
if (!$this->gallery_auth->acl_check('m_delete', $album_id, $album_data['album_user_id'])) |
|
1073
|
|
|
{ |
|
1074
|
|
|
$this->misc->not_authorised($album_backlink, $album_loginlink, 'LOGIN_EXPLAIN_UPLOAD'); |
|
1075
|
|
|
} |
|
1076
|
|
|
} |
|
1077
|
|
|
$s_hidden_fields = build_hidden_fields(array( |
|
|
|
|
|
|
1078
|
|
|
'album_id' => $album_id, |
|
1079
|
|
|
'image_id' => $image_id, |
|
1080
|
|
|
'mode' => 'delete', |
|
1081
|
|
|
)); |
|
1082
|
|
|
|
|
1083
|
|
|
if (confirm_box(true)) |
|
|
|
|
|
|
1084
|
|
|
{ |
|
1085
|
|
|
$this->image->handle_counter($image_id, false); |
|
1086
|
|
|
$this->moderate->delete_images(array($image_id), array($image_id => $image_data['image_filename'])); |
|
1087
|
|
|
$this->album->update_info($album_id); |
|
1088
|
|
|
|
|
1089
|
|
|
$message = $this->language->lang('DELETED_IMAGE') . '<br />'; |
|
1090
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_ALBUM'), '<a href="' . $album_backlink . '">', '</a>'); |
|
1091
|
|
|
|
|
1092
|
|
|
if ($this->user->data['user_id'] != $image_data['image_user_id']) |
|
1093
|
|
|
{ |
|
1094
|
|
|
$this->gallery_log->add_log('moderator', 'delete', $image_data['image_album_id'], $image_id, array('LOG_GALLERY_DELETED', $image_data['image_name'])); |
|
1095
|
|
|
} |
|
1096
|
|
|
// So we need to see if there are still unapproved images in the album |
|
1097
|
|
|
$this->notification_helper->read('approval', $album_id); |
|
1098
|
|
|
$this->url->meta_refresh(3, $album_backlink); |
|
1099
|
|
|
trigger_error($message); |
|
1100
|
|
|
} |
|
1101
|
|
|
else |
|
1102
|
|
|
{ |
|
1103
|
|
|
if (isset($_POST['cancel'])) |
|
1104
|
|
|
{ |
|
1105
|
|
|
$message = $this->language->lang('DELETED_IMAGE_NOT') . '<br />'; |
|
1106
|
|
|
$message .= '<br />' . sprintf($this->language->lang('CLICK_RETURN_IMAGE'), '<a href="' . $image_backlink . '">', '</a>'); |
|
1107
|
|
|
$this->url->meta_refresh(3, $image_backlink); |
|
1108
|
|
|
trigger_error($message); |
|
1109
|
|
|
} |
|
1110
|
|
|
else |
|
1111
|
|
|
{ |
|
1112
|
|
|
confirm_box(false, 'DELETE_IMAGE2', $s_hidden_fields); |
|
1113
|
|
|
} |
|
1114
|
|
|
} |
|
1115
|
|
|
} |
|
1116
|
|
|
|
|
1117
|
|
|
// Report image |
|
1118
|
|
|
public function report($image_id) |
|
1119
|
|
|
{ |
|
1120
|
|
|
$image_data = $this->image->get_image_data($image_id); |
|
1121
|
|
|
$album_id = $image_data['image_album_id']; |
|
1122
|
|
|
$album_data = $this->album->get_info($album_id); |
|
1123
|
|
|
$this->language->add_lang(array('gallery'), 'phpbbgallery/core'); |
|
1124
|
|
|
$album_loginlink = './ucp.php?mode=login'; |
|
|
|
|
|
|
1125
|
|
|
$image_backlink = $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)); |
|
1126
|
|
|
$album_backlink = $this->helper->route('phpbbgallery_core_album', array('album_id' => $image_data['image_album_id'])); |
|
1127
|
|
|
$this->gallery_auth->load_user_permissions($this->user->data['user_id']); |
|
1128
|
|
|
if (!$this->gallery_auth->acl_check('i_report', $album_id, $album_data['album_user_id']) || ($image_data['image_user_id'] == $this->user->data['user_id'])) |
|
1129
|
|
|
{ |
|
1130
|
|
|
$this->misc->not_authorised($image_backlink, ''); |
|
1131
|
|
|
} |
|
1132
|
|
|
add_form_key('gallery'); |
|
|
|
|
|
|
1133
|
|
|
$submit = $this->request->variable('submit', false); |
|
1134
|
|
|
$error = ''; |
|
1135
|
|
|
if ($submit) |
|
1136
|
|
|
{ |
|
1137
|
|
|
if (!check_form_key('gallery')) |
|
|
|
|
|
|
1138
|
|
|
{ |
|
1139
|
|
|
trigger_error('FORM_INVALID'); |
|
1140
|
|
|
} |
|
1141
|
|
|
|
|
1142
|
|
|
$report_message = $this->request->variable('message', '', true); |
|
1143
|
|
|
$error = ''; |
|
1144
|
|
|
if ($report_message == '') |
|
1145
|
|
|
{ |
|
1146
|
|
|
$error = $this->language->lang('MISSING_REPORT_REASON'); |
|
1147
|
|
|
$submit = false; |
|
|
|
|
|
|
1148
|
|
|
} |
|
1149
|
|
|
|
|
1150
|
|
|
if (!$error && $image_data['image_reported']) |
|
1151
|
|
|
{ |
|
1152
|
|
|
$error = $this->language->lang('IMAGE_ALREADY_REPORTED'); |
|
1153
|
|
|
} |
|
1154
|
|
|
|
|
1155
|
|
|
if (!$error) |
|
1156
|
|
|
{ |
|
1157
|
|
|
$data = array( |
|
1158
|
|
|
'report_album_id' => (int) $album_id, |
|
1159
|
|
|
'report_image_id' => (int) $image_id, |
|
1160
|
|
|
'report_note' => $report_message, |
|
1161
|
|
|
); |
|
1162
|
|
|
|
|
1163
|
|
|
$this->report->add($data); |
|
1164
|
|
|
|
|
1165
|
|
|
$message = $this->language->lang('IMAGES_REPORTED_SUCCESSFULLY'); |
|
1166
|
|
|
$message .= '<br /><br />' . sprintf($this->language->lang('CLICK_RETURN_IMAGE'), '<a href="' . $image_backlink . '">', '</a>'); |
|
1167
|
|
|
$message .= '<br /><br />' . sprintf($this->language->lang('CLICK_RETURN_ALBUM'), '<a href="' . $album_backlink . '">', '</a>'); |
|
1168
|
|
|
|
|
1169
|
|
|
$this->url->meta_refresh(3, $image_backlink); |
|
1170
|
|
|
trigger_error($message); |
|
1171
|
|
|
} |
|
1172
|
|
|
|
|
1173
|
|
|
} |
|
1174
|
|
|
|
|
1175
|
|
|
$this->template->assign_vars(array( |
|
1176
|
|
|
'ERROR' => $error, |
|
1177
|
|
|
'U_IMAGE' => ($image_id) ? $this->helper->route('phpbbgallery_core_image_file_medium', array('image_id' => $image_id)) : '', |
|
1178
|
|
|
'IMAGE_NAME' => $image_data['image_name'], |
|
1179
|
|
|
'U_VIEW_IMAGE' => ($image_id) ? $this->helper->route('phpbbgallery_core_image', array('image_id' => $image_id)) : '', |
|
1180
|
|
|
'IMAGE_RSZ_WIDTH' => $this->gallery_config->get('medium_width'), |
|
1181
|
|
|
'IMAGE_RSZ_HEIGHT' => $this->gallery_config->get('medium_height'), |
|
1182
|
|
|
|
|
1183
|
|
|
'S_REPORT' => true, |
|
1184
|
|
|
'S_ALBUM_ACTION' => $this->helper->route('phpbbgallery_core_image_report', array('image_id' => $image_id)), |
|
1185
|
|
|
)); |
|
1186
|
|
|
|
|
1187
|
|
|
$page_title = $this->language->lang('REPORT_IMAGE'); |
|
1188
|
|
|
|
|
1189
|
|
|
return $this->helper->render('gallery/posting_body.html', $page_title); |
|
1190
|
|
|
} |
|
1191
|
|
|
|
|
1192
|
|
|
/** |
|
1193
|
|
|
* @param int $album_id |
|
1194
|
|
|
* @param $owner_id |
|
1195
|
|
|
* @param $image_status |
|
1196
|
|
|
* @param $album_auth_level |
|
1197
|
|
|
* @internal param array $album_data |
|
1198
|
|
|
*/ |
|
1199
|
|
|
protected function check_permissions($album_id, $owner_id, $image_status, $album_auth_level, $user_data) |
|
1200
|
|
|
{ |
|
1201
|
|
|
$this->gallery_auth->load_user_permissions($this->user->data['user_id']); |
|
1202
|
|
|
$zebra_array = $this->gallery_auth->get_user_zebra($this->user->data['user_id']); |
|
1203
|
|
|
if (!$this->gallery_auth->acl_check('i_view', $album_id, $owner_id) || ($image_status == (int) \phpbbgallery\core\block::STATUS_ORPHAN) || $this->gallery_auth->get_zebra_state($zebra_array, (int) $owner_id, (int) $album_id) < (int) $album_auth_level) |
|
1204
|
|
|
{ |
|
1205
|
|
|
if ($this->user->data['is_bot']) |
|
1206
|
|
|
{ |
|
1207
|
|
|
// Redirect bots back to the index |
|
1208
|
|
|
redirect($this->helper->route('phpbbgallery_core_index')); |
|
|
|
|
|
|
1209
|
|
|
} |
|
1210
|
|
|
|
|
1211
|
|
|
// Display login box for guests and an error for users |
|
1212
|
|
|
if (!$this->user->data['is_registered']) |
|
1213
|
|
|
{ |
|
1214
|
|
|
// @todo Add "redirect after login" url |
|
1215
|
|
|
login_box(); |
|
|
|
|
|
|
1216
|
|
|
} |
|
1217
|
|
|
else |
|
1218
|
|
|
{ |
|
1219
|
|
|
//return $this->error('NOT_AUTHORISED', 403); |
|
1220
|
|
|
redirect('gallery/album/' . $album_id); |
|
1221
|
|
|
} |
|
1222
|
|
|
} |
|
1223
|
|
|
if (!$this->gallery_auth->acl_check('m_status', $album_id, $owner_id) && $user_data['image_user_id'] != $this->user->data['user_id'] && ($image_status == (int) \phpbbgallery\core\block::STATUS_UNAPPROVED)) |
|
1224
|
|
|
{ |
|
1225
|
|
|
//return $this->error('NOT_AUTHORISED', 403); |
|
1226
|
|
|
redirect('gallery/album/' . $album_id); |
|
1227
|
|
|
} |
|
1228
|
|
|
} |
|
1229
|
|
|
|
|
1230
|
|
|
protected function load_users_data() |
|
1231
|
|
|
{ |
|
1232
|
|
|
|
|
1233
|
|
|
$sql = $this->db->sql_build_query('SELECT', array( |
|
1234
|
|
|
'SELECT' => 'u.*, gu.personal_album_id, gu.user_images', |
|
1235
|
|
|
'FROM' => array(USERS_TABLE => 'u'), |
|
|
|
|
|
|
1236
|
|
|
|
|
1237
|
|
|
'LEFT_JOIN' => array( |
|
1238
|
|
|
array( |
|
1239
|
|
|
'FROM' => array($this->table_users => 'gu'), |
|
1240
|
|
|
'ON' => 'gu.user_id = u.user_id', |
|
1241
|
|
|
), |
|
1242
|
|
|
), |
|
1243
|
|
|
|
|
1244
|
|
|
'WHERE' => $this->db->sql_in_set('u.user_id', $this->users_id_array), |
|
1245
|
|
|
)); |
|
1246
|
|
|
$result = $this->db->sql_query($sql); |
|
1247
|
|
|
|
|
1248
|
|
|
while ($row = $this->db->sql_fetchrow($result)) |
|
1249
|
|
|
{ |
|
1250
|
|
|
$this->gallery_user->add_user_to_cache($this->users_data_array, $row); |
|
1251
|
|
|
} |
|
1252
|
|
|
$this->db->sql_freeresult($result); |
|
1253
|
|
|
|
|
1254
|
|
|
// Load CPF's |
|
1255
|
|
|
$profile_fields_tmp = $this->cpf_manager->grab_profile_fields_data($this->users_id_array); |
|
1256
|
|
|
foreach ($profile_fields_tmp as $profile_user_id => $profile_fields) |
|
1257
|
|
|
{ |
|
1258
|
|
|
$this->profile_fields_data[$profile_user_id] = array(); |
|
1259
|
|
|
foreach ($profile_fields as $used_ident => $profile_field) |
|
1260
|
|
|
{ |
|
1261
|
|
|
if ($profile_field['data']['field_show_on_vt']) |
|
1262
|
|
|
{ |
|
1263
|
|
|
$this->profile_fields_data[$profile_user_id][$used_ident] = $profile_field; |
|
1264
|
|
|
} |
|
1265
|
|
|
} |
|
1266
|
|
|
} |
|
1267
|
|
|
unset($profile_fields_tmp); |
|
1268
|
|
|
|
|
1269
|
|
|
// Get the list of users who can receive private messages |
|
1270
|
|
|
$this->can_receive_pm_list = []; |
|
1271
|
|
|
if (is_array($this->users_data_array)) |
|
1272
|
|
|
{ |
|
1273
|
|
|
$this->can_receive_pm_list = $this->auth->acl_get_list(array_keys($this->users_data_array), 'u_readpm'); |
|
1274
|
|
|
} |
|
1275
|
|
|
$this->can_receive_pm_list = (empty($this->can_receive_pm_list) || !isset($this->can_receive_pm_list[0]['u_readpm'])) ? array() : $this->can_receive_pm_list[0]['u_readpm']; |
|
1276
|
|
|
|
|
1277
|
|
|
// Load online-information |
|
1278
|
|
|
if ($this->config['load_onlinetrack'] && sizeof($this->users_id_array)) |
|
1279
|
|
|
{ |
|
1280
|
|
|
$sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline |
|
1281
|
|
|
FROM ' . SESSIONS_TABLE . ' |
|
|
|
|
|
|
1282
|
|
|
WHERE ' . $this->db->sql_in_set('session_user_id', $this->users_id_array) . ' |
|
1283
|
|
|
GROUP BY session_user_id'; |
|
1284
|
|
|
$result = $this->db->sql_query($sql); |
|
1285
|
|
|
|
|
1286
|
|
|
$update_time = $this->config['load_online_time'] * 60; |
|
1287
|
|
|
while ($row = $this->db->sql_fetchrow($result)) |
|
1288
|
|
|
{ |
|
1289
|
|
|
$this->users_data_array[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $this->auth->acl_get('u_viewonline'))) ? true : false; |
|
1290
|
|
|
} |
|
1291
|
|
|
$this->db->sql_freeresult($result); |
|
1292
|
|
|
} |
|
1293
|
|
|
} |
|
1294
|
|
|
} |
|
1295
|
|
|
|
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