Completed
Pull Request — master (#25)
by Erwan
04:33
created
controller/categories.php 1 patch
Braces   +38 added lines, -17 removed lines patch added patch discarded remove patch
@@ -103,7 +103,8 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function view($cat_id, $page, $sort_days, $sort_key, $sort_dir, $mode = '')
105 105
     {
106
-        if (false === $this->categorie->get($cat_id)) {
106
+        if (false === $this->categorie->get($cat_id))
107
+        {
107 108
             throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_CATS');
108 109
         }
109 110
 
@@ -123,7 +124,8 @@  discard block
 block discarded – undo
123 124
         $sort_by_text = ['a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME'], 'r' => $this->user->lang['DIR_COMMENTS_ORDER'], 's' =>  $this->user->lang['DIR_NAME_ORDER'], 'v' => $this->user->lang['DIR_NB_CLICKS_ORDER']];
124 125
         $sort_by_sql = ['a' => 'u.username_clean', 't' => ['l.link_time', 'l.link_id'], 'r' => 'l.link_comment', 's' => 'LOWER(l.link_name)', 'v' => 'l.link_view'];
125 126
 
126
-        if ($this->config['dir_activ_pagerank']) {
127
+        if ($this->config['dir_activ_pagerank'])
128
+        {
127 129
             $sort_by_text['p'] = $this->user->lang['DIR_PR_ORDER'];
128 130
             $sort_by_sql['p'] = 'l.link_pagerank';
129 131
         }
@@ -142,16 +144,19 @@  discard block
 block discarded – undo
142 144
             'is_watching'      => false,
143 145
         ];
144 146
 
145
-        if ($this->config['email_enable'] && $this->user->data['is_registered']) {
147
+        if ($this->config['email_enable'] && $this->user->data['is_registered'])
148
+        {
146 149
             $notify_status = (isset($this->categorie->data['notify_status'])) ? $this->categorie->data['notify_status'] : null;
147 150
 
148
-            if (($message = $this->categorie->watch_categorie($mode, $s_watching_categorie, $this->user->data['user_id'], $cat_id, $notify_status))) {
151
+            if (($message = $this->categorie->watch_categorie($mode, $s_watching_categorie, $this->user->data['user_id'], $cat_id, $notify_status)))
152
+            {
149 153
                 return $this->helper->message($message);
150 154
             }
151 155
         }
152 156
 
153 157
         // A deadline has been selected
154
-        if ($sort_days) {
158
+        if ($sort_days)
159
+        {
155 160
             $min_post_time = time() - ($sort_days * 86400);
156 161
 
157 162
             $sql = 'SELECT COUNT(link_id) AS nb_links
@@ -162,11 +167,14 @@  discard block
 block discarded – undo
162 167
             $nb_links = (int) $this->db->sql_fetchfield('nb_links');
163 168
             $this->db->sql_freeresult($result);
164 169
 
165
-            if ($this->request->is_set_post('sort')) {
170
+            if ($this->request->is_set_post('sort'))
171
+            {
166 172
                 $start = 0;
167 173
             }
168 174
             $sql_limit_time = " AND l.link_time >= $min_post_time";
169
-        } else {
175
+        }
176
+        else
177
+        {
170 178
             $sql_limit_time = '';
171 179
             $nb_links = (int) $this->categorie->data['cat_links'];
172 180
         }
@@ -209,7 +217,8 @@  discard block
 block discarded – undo
209 217
         // If the user is trying to reach late pages, start searching from the end
210 218
         $store_reverse = false;
211 219
         $sql_limit = $this->config['dir_show'];
212
-        if ($start > $nb_links / 2) {
220
+        if ($start > $nb_links / 2)
221
+        {
213 222
             $store_reverse = true;
214 223
 
215 224
             // Select the sort order
@@ -217,15 +226,20 @@  discard block
 block discarded – undo
217 226
 
218 227
             $sql_limit = $this->pagination->reverse_limit($start, $sql_limit, $nb_links);
219 228
             $sql_start = $this->pagination->reverse_start($start, $sql_limit, $nb_links);
220
-        } else {
229
+        }
230
+        else
231
+        {
221 232
             // Select the sort order
222 233
             $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');
223 234
             $sql_start = $start;
224 235
         }
225 236
 
226
-        if (is_array($sort_by_sql[$sort_key])) {
237
+        if (is_array($sort_by_sql[$sort_key]))
238
+        {
227 239
             $sql_sort_order = implode(' '.$direction.', ', $sort_by_sql[$sort_key]).' '.$direction;
228
-        } else {
240
+        }
241
+        else
242
+        {
229 243
             $sql_sort_order = $sort_by_sql[$sort_key].' '.$direction;
230 244
         }
231 245
 
@@ -249,12 +263,14 @@  discard block
 block discarded – undo
249 263
         $sql = $this->db->sql_build_query('SELECT', $sql_array);
250 264
         $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start);
251 265
 
252
-        while ($row = $this->db->sql_fetchrow($result)) {
266
+        while ($row = $this->db->sql_fetchrow($result))
267
+        {
253 268
             $link_list[] = (int) $row['link_id'];
254 269
         }
255 270
         $this->db->sql_freeresult($result);
256 271
 
257
-        if (count($link_list)) {
272
+        if (count($link_list))
273
+        {
258 274
             // We get links, informations about poster, votes and number of comments
259 275
             $sql_array = [
260 276
                 'SELECT'      => 'l.link_id, l.link_cat, l.link_url, l.link_user_id, l.link_comment, l. link_description, l.link_banner, l.link_rss, l. link_uid, l.link_bitfield, l.link_flags, l.link_vote, l.link_note, l.link_view, l.link_time, l.link_name, l.link_flag, l.link_pagerank, l.link_thumb, u.user_id, u.username, u.user_colour, v.vote_user_id',
@@ -276,7 +292,8 @@  discard block
 block discarded – undo
276 292
             $sql = $this->db->sql_build_query('SELECT', $sql_array);
277 293
             $result = $this->db->sql_query($sql);
278 294
 
279
-            while ($site = $this->db->sql_fetchrow($result)) {
295
+            while ($site = $this->db->sql_fetchrow($result))
296
+            {
280 297
                 $rowset[$site['link_id']] = $site;
281 298
             }
282 299
             $this->db->sql_freeresult($result);
@@ -286,7 +303,8 @@  discard block
 block discarded – undo
286 303
             $votes_status = ($this->categorie->data['cat_allow_votes']) ? true : false;
287 304
             $comments_status = ($this->categorie->data['cat_allow_comments']) ? true : false;
288 305
 
289
-            foreach ($link_list as $link_id) {
306
+            foreach ($link_list as $link_id)
307
+            {
290 308
                 $site = &$rowset[$link_id];
291 309
 
292 310
                 $s_flag = $this->link->display_flag($site);
@@ -328,7 +346,9 @@  discard block
 block discarded – undo
328 346
                     'U_THUMB'          => $s_thumb,
329 347
                 ]);
330 348
             }
331
-        } else {
349
+        }
350
+        else
351
+        {
332 352
             $this->template->assign_block_vars('no_draw_link', []);
333 353
         }
334 354
 
@@ -348,7 +368,8 @@  discard block
 block discarded – undo
348 368
      */
349 369
     public function return_date()
350 370
     {
351
-        if (!$this->request->is_ajax()) {
371
+        if (!$this->request->is_ajax())
372
+        {
352 373
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
353 374
         }
354 375
 
Please login to merge, or discard this patch.
controller/comments.php 1 patch
Braces   +57 added lines, -26 removed lines patch added patch discarded remove patch
@@ -95,7 +95,8 @@  discard block
 block discarded – undo
95 95
         ]);
96 96
 
97 97
         // The CAPTCHA kicks in here. We can't help that the information gets lost on language change.
98
-        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) {
98
+        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'])
99
+        {
99 100
             $this->captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']);
100 101
             $this->captcha->init(CONFIRM_POST);
101 102
         }
@@ -115,7 +116,8 @@  discard block
 block discarded – undo
115 116
     {
116 117
         $this->_check_comments_enable($link_id);
117 118
 
118
-        if ($this->request->is_set_post('cancel')) {
119
+        if ($this->request->is_set_post('cancel'))
120
+        {
119 121
             $redirect = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]);
120 122
             redirect($redirect);
121 123
         }
@@ -126,11 +128,13 @@  discard block
 block discarded – undo
126 128
         $result = $this->db->sql_query($sql);
127 129
         $value = $this->db->sql_fetchrow($result);
128 130
 
129
-        if (!$this->user->data['is_registered'] || !$this->auth->acl_get('m_delete_comment_dir') && (!$this->auth->acl_get('u_delete_comment_dir') || $this->user->data['user_id'] != $value['comment_user_id'])) {
131
+        if (!$this->user->data['is_registered'] || !$this->auth->acl_get('m_delete_comment_dir') && (!$this->auth->acl_get('u_delete_comment_dir') || $this->user->data['user_id'] != $value['comment_user_id']))
132
+        {
130 133
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
131 134
         }
132 135
 
133
-        if (confirm_box(true)) {
136
+        if (confirm_box(true))
137
+        {
134 138
             $this->comment->del($link_id, $comment_id);
135 139
 
136 140
             $meta_info = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]);
@@ -139,7 +143,9 @@  discard block
 block discarded – undo
139 143
             $message = $message.'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_COMMENT', '<a href="'.$meta_info.'">', '</a>');
140 144
 
141 145
             return $this->helper->message($message);
142
-        } else {
146
+        }
147
+        else
148
+        {
143 149
             confirm_box(false, 'DIR_COMMENT_DELETE');
144 150
         }
145 151
     }
@@ -164,7 +170,8 @@  discard block
 block discarded – undo
164 170
         $result = $this->db->sql_query($sql);
165 171
         $value = $this->db->sql_fetchrow($result);
166 172
 
167
-        if (!$this->user->data['is_registered'] || !$this->auth->acl_get('m_edit_comment_dir') && (!$this->auth->acl_get('u_edit_comment_dir') || $this->user->data['user_id'] != $value['comment_user_id'])) {
173
+        if (!$this->user->data['is_registered'] || !$this->auth->acl_get('m_edit_comment_dir') && (!$this->auth->acl_get('u_edit_comment_dir') || $this->user->data['user_id'] != $value['comment_user_id']))
174
+        {
168 175
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
169 176
         }
170 177
 
@@ -174,7 +181,8 @@  discard block
 block discarded – undo
174 181
         $submit = $this->request->is_set_post('update_comment') ? true : false;
175 182
 
176 183
         // If form is done
177
-        if ($submit) {
184
+        if ($submit)
185
+        {
178 186
             return $this->_data_processing($link_id, $comment_id, 'edit');
179 187
         }
180 188
 
@@ -194,7 +202,8 @@  discard block
 block discarded – undo
194 202
     {
195 203
         $this->_check_comments_enable($link_id);
196 204
 
197
-        if (!$this->auth->acl_get('u_comment_dir')) {
205
+        if (!$this->auth->acl_get('u_comment_dir'))
206
+        {
198 207
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
199 208
         }
200 209
 
@@ -202,9 +211,12 @@  discard block
 block discarded – undo
202 211
         $refresh = $this->request->is_set_post('refresh_vc') ? true : false;
203 212
 
204 213
         // If form is done
205
-        if ($submit || $refresh) {
214
+        if ($submit || $refresh)
215
+        {
206 216
             return $this->_data_processing($link_id);
207
-        } else {
217
+        }
218
+        else
219
+        {
208 220
             $redirect = $this->helper->route('ernadoo_phpbbdirectory_comment_view_controller', ['link_id' => (int) $link_id]);
209 221
             redirect($redirect);
210 222
         }
@@ -264,7 +276,8 @@  discard block
 block discarded – undo
264 276
 
265 277
         $have_result = false;
266 278
 
267
-        while ($comments = $this->db->sql_fetchrow($result)) {
279
+        while ($comments = $this->db->sql_fetchrow($result))
280
+        {
268 281
             $have_result = true;
269 282
 
270 283
             $edit_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_comment_dir') || (
@@ -322,13 +335,15 @@  discard block
 block discarded – undo
322 335
      */
323 336
     private function _data_processing($link_id, $comment_id = 0, $mode = 'new')
324 337
     {
325
-        if (!check_form_key('dir_form_comment')) {
338
+        if (!check_form_key('dir_form_comment'))
339
+        {
326 340
             return $this->helper->message('FORM_INVALID');
327 341
         }
328 342
 
329 343
         $this->s_comment = $this->request->variable('message', '', true);
330 344
 
331
-        if (!function_exists('validate_data')) {
345
+        if (!function_exists('validate_data'))
346
+        {
332 347
             include $this->root_path.'includes/functions_user.'.$this->php_ext;
333 348
         }
334 349
 
@@ -344,18 +359,22 @@  discard block
 block discarded – undo
344 359
 
345 360
         $error = array_map([$this->user, 'lang'], $error);
346 361
 
347
-        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) {
362
+        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'])
363
+        {
348 364
             $vc_response = $this->captcha->validate();
349
-            if ($vc_response !== false) {
365
+            if ($vc_response !== false)
366
+            {
350 367
                 $error[] = $vc_response;
351 368
             }
352 369
 
353
-            if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts']) {
370
+            if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts'])
371
+            {
354 372
                 $error[] = $this->user->lang['TOO_MANY_ADDS'];
355 373
             }
356 374
         }
357 375
 
358
-        if (!$error) {
376
+        if (!$error)
377
+        {
359 378
             $uid = $bitfield = $flags = '';
360 379
             generate_text_for_storage($this->s_comment, $uid, $bitfield, $flags, (bool) $this->config['dir_allow_bbcode'], (bool) $this->config['dir_allow_links'], (bool) $this->config['dir_allow_smilies']);
361 380
 
@@ -366,9 +385,12 @@  discard block
 block discarded – undo
366 385
                 'comment_bitfield'     => $bitfield,
367 386
             ];
368 387
 
369
-            if ($mode == 'edit') {
388
+            if ($mode == 'edit')
389
+            {
370 390
                 $this->comment->edit($data_edit, $comment_id);
371
-            } else {
391
+            }
392
+            else
393
+            {
372 394
                 $data_add = [
373 395
                     'comment_link_id'     => (int) $link_id,
374 396
                     'comment_date'        => time(),
@@ -387,7 +409,9 @@  discard block
 block discarded – undo
387 409
             $message = $message.'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_COMMENT', '<a href="'.$meta_info.'">', '</a>');
388 410
 
389 411
             return $this->helper->message($message);
390
-        } else {
412
+        }
413
+        else
414
+        {
391 415
             $this->template->assign_vars([
392 416
                 'ERROR'    => (count($error)) ? implode('<br />', $error) : '',
393 417
             ]);
@@ -414,13 +438,17 @@  discard block
 block discarded – undo
414 438
         $cat_id = (int) $this->db->sql_fetchfield('link_cat');
415 439
         $this->db->sql_freeresult($result);
416 440
 
417
-        if ($cat_id) {
441
+        if ($cat_id)
442
+        {
418 443
             $this->categorie->get($cat_id);
419 444
 
420
-            if (!$this->categorie->data['cat_allow_comments']) {
445
+            if (!$this->categorie->data['cat_allow_comments'])
446
+            {
421 447
                 throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
422 448
             }
423
-        } else {
449
+        }
450
+        else
451
+        {
424 452
             throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS');
425 453
         }
426 454
     }
@@ -435,7 +463,8 @@  discard block
 block discarded – undo
435 463
      */
436 464
     private function _populate_form($link_id, $mode)
437 465
     {
438
-        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode != 'edit') {
466
+        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode != 'edit')
467
+        {
439 468
             $this->s_hidden_fields = array_merge($this->s_hidden_fields, $this->captcha->get_hidden_fields());
440 469
 
441 470
             $this->template->assign_vars([
@@ -444,10 +473,12 @@  discard block
 block discarded – undo
444 473
             ]);
445 474
         }
446 475
 
447
-        if (!function_exists('generate_smilies')) {
476
+        if (!function_exists('generate_smilies'))
477
+        {
448 478
             include $this->root_path.'includes/functions_posting.'.$this->php_ext;
449 479
         }
450
-        if (!function_exists('display_custom_bbcodes')) {
480
+        if (!function_exists('display_custom_bbcodes'))
481
+        {
451 482
             include $this->root_path.'includes/functions_display.'.$this->php_ext;
452 483
         }
453 484
 
Please login to merge, or discard this patch.
controller/acp/cat.php 1 patch
Braces   +165 added lines, -76 removed lines patch added patch discarded remove patch
@@ -110,7 +110,8 @@  discard block
 block discarded – undo
110 110
         $parents_list = $this->categorie->make_cat_select($this->parent_id);
111 111
 
112 112
         // Fill categorie data with default values
113
-        if (!$this->update) {
113
+        if (!$this->update)
114
+        {
114 115
             $this->cat_data = [
115 116
                 'parent_id'                => $this->parent_id,
116 117
                 'cat_name'                 => $this->request->variable('cat_name', '', true),
@@ -142,7 +143,8 @@  discard block
 block discarded – undo
142 143
      */
143 144
     public function action_delete()
144 145
     {
145
-        if (!$this->cat_id) {
146
+        if (!$this->cat_id)
147
+        {
146 148
             trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&amp;parent_id='.$this->parent_id), E_USER_WARNING);
147 149
         }
148 150
 
@@ -151,7 +153,8 @@  discard block
 block discarded – undo
151 153
         $subcats_id = [];
152 154
         $subcats = $this->nestedset_category->get_subtree_data($this->cat_id);
153 155
 
154
-        foreach ($subcats as $row) {
156
+        foreach ($subcats as $row)
157
+        {
155 158
             $subcats_id[] = $row['cat_id'];
156 159
         }
157 160
 
@@ -162,7 +165,8 @@  discard block
 block discarded – undo
162 165
 			WHERE cat_id <> '.(int) $this->cat_id;
163 166
         $result = $this->db->sql_query_limit($sql, 1);
164 167
 
165
-        if ($this->db->sql_fetchrow($result)) {
168
+        if ($this->db->sql_fetchrow($result))
169
+        {
166 170
             $this->template->assign_vars([
167 171
                 'S_MOVE_DIR_CAT_OPTIONS'    => $this->categorie->make_cat_select((int) $this->cat_data['parent_id'], $subcats_id), ]
168 172
             );
@@ -193,16 +197,20 @@  discard block
 block discarded – undo
193 197
     {
194 198
         $row = $this->_get_cat_info($this->cat_id);
195 199
 
196
-        if (!$this->update) {
200
+        if (!$this->update)
201
+        {
197 202
             $this->cat_data = $row;
198
-        } else {
203
+        }
204
+        else
205
+        {
199 206
             $this->cat_data['left_id'] = $row['left_id'];
200 207
             $this->cat_data['right_id'] = $row['right_id'];
201 208
         }
202 209
 
203 210
         // Make sure no direct child categories are able to be selected as parents.
204 211
         $exclude_cats = [];
205
-        foreach ($this->nestedset_category->get_subtree_data($this->cat_id) as $row2) {
212
+        foreach ($this->nestedset_category->get_subtree_data($this->cat_id) as $row2)
213
+        {
206 214
             $exclude_cats[] = $row2['cat_id'];
207 215
         }
208 216
         $parents_list = $this->categorie->make_cat_select((int) $this->cat_data['parent_id'], $exclude_cats);
@@ -217,7 +225,8 @@  discard block
 block discarded – undo
217 225
      */
218 226
     public function action_move()
219 227
     {
220
-        if (!$this->cat_id) {
228
+        if (!$this->cat_id)
229
+        {
221 230
             trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&amp;parent_id='.$this->parent_id), E_USER_WARNING);
222 231
         }
223 232
 
@@ -228,22 +237,28 @@  discard block
 block discarded – undo
228 237
         $row = $this->db->sql_fetchrow($result);
229 238
         $this->db->sql_freeresult($result);
230 239
 
231
-        if (!$row) {
240
+        if (!$row)
241
+        {
232 242
             trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&amp;parent_id='.$this->parent_id), E_USER_WARNING);
233 243
         }
234 244
 
235
-        try {
245
+        try
246
+        {
236 247
             $move_cat_name = $this->nestedset_category->{$this->action}($this->cat_id);
237
-        } catch (\Exception $e) {
248
+        }
249
+        catch (\Exception $e)
250
+        {
238 251
             trigger_error($e->getMessage(), E_USER_WARNING);
239 252
         }
240 253
 
241
-        if ($move_cat_name !== false) {
254
+        if ($move_cat_name !== false)
255
+        {
242 256
             $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_'.strtoupper($this->action), time(), [$row['cat_name'], $move_cat_name]);
243 257
             $this->cache->destroy('sql', DIR_CAT_TABLE);
244 258
         }
245 259
 
246
-        if ($this->request->is_ajax()) {
260
+        if ($this->request->is_ajax())
261
+        {
247 262
             $json_response = new \phpbb\json_response();
248 263
             $json_response->send(['success' => ($move_cat_name !== false)]);
249 264
         }
@@ -280,7 +295,8 @@  discard block
 block discarded – undo
280 295
      */
281 296
     public function action_sync()
282 297
     {
283
-        if (!$this->cat_id) {
298
+        if (!$this->cat_id)
299
+        {
284 300
             trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&amp;parent_id='.$this->parent_id), E_USER_WARNING);
285 301
         }
286 302
 
@@ -293,7 +309,8 @@  discard block
 block discarded – undo
293 309
         $row = $this->db->sql_fetchrow($result);
294 310
         $this->db->sql_freeresult($result);
295 311
 
296
-        if (!$row) {
312
+        if (!$row)
313
+        {
297 314
             trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&amp;parent_id='.$this->parent_id), E_USER_WARNING);
298 315
         }
299 316
 
@@ -317,7 +334,8 @@  discard block
 block discarded – undo
317 334
         // Sync all links in batch mode...
318 335
         $this->_sync_dir_links($start, $end);
319 336
 
320
-        if ($end < $row2['max_link_id']) {
337
+        if ($end < $row2['max_link_id'])
338
+        {
321 339
             // We really need to find a way of showing statistics... no progress here
322 340
             $sql = 'SELECT COUNT(link_id) as num_links
323 341
 				FROM '.DIR_LINK_TABLE.'
@@ -369,7 +387,8 @@  discard block
 block discarded – undo
369 387
         $row = $this->db->sql_fetchrow($result);
370 388
         $this->db->sql_freeresult($result);
371 389
 
372
-        if (!$row) {
390
+        if (!$row)
391
+        {
373 392
             trigger_error($this->user->lang['DIR_NO_CAT'].adm_back_link($this->u_action.'&amp;parent_id='.$this->parent_id), E_USER_WARNING);
374 393
         }
375 394
 
@@ -389,17 +408,24 @@  discard block
 block discarded – undo
389 408
     public function display_cats()
390 409
     {
391 410
         // Default management page
392
-        if (!$this->parent_id) {
411
+        if (!$this->parent_id)
412
+        {
393 413
             $navigation = $this->user->lang['DIR_INDEX'];
394
-        } else {
414
+        }
415
+        else
416
+        {
395 417
             $navigation = '<a href="'.$this->u_action.'">'.$this->user->lang['DIR_INDEX'].'</a>';
396 418
 
397 419
             $cats_nav = $this->nestedset_category->get_path_data($this->parent_id);
398 420
 
399
-            foreach ($cats_nav as $row) {
400
-                if ($row['cat_id'] == $this->parent_id) {
421
+            foreach ($cats_nav as $row)
422
+            {
423
+                if ($row['cat_id'] == $this->parent_id)
424
+                {
401 425
                     $navigation .= ' -&gt; '.$row['cat_name'];
402
-                } else {
426
+                }
427
+                else
428
+                {
403 429
                     $navigation .= ' -&gt; <a href="'.$this->u_action.'&amp;parent_id='.$row['cat_id'].'">'.$row['cat_name'].'</a>';
404 430
                 }
405 431
             }
@@ -408,7 +434,8 @@  discard block
 block discarded – undo
408 434
         // Jumpbox
409 435
         $cat_box = $this->categorie->make_cat_select($this->parent_id);
410 436
 
411
-        if ($this->action == 'sync' || $this->action == 'sync_cat') {
437
+        if ($this->action == 'sync' || $this->action == 'sync_cat')
438
+        {
412 439
             $this->template->assign_var('S_RESYNCED', true);
413 440
         }
414 441
 
@@ -418,8 +445,10 @@  discard block
 block discarded – undo
418 445
 			ORDER BY left_id';
419 446
         $result = $this->db->sql_query($sql);
420 447
 
421
-        if ($row = $this->db->sql_fetchrow($result)) {
422
-            do {
448
+        if ($row = $this->db->sql_fetchrow($result))
449
+        {
450
+            do
451
+            {
423 452
                 $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '<img src="images/icon_subfolder.gif" alt="'.$this->user->lang['DIR_SUBCAT'].'" />' : '<img src="images/icon_folder.gif" alt="'.$this->user->lang['FOLDER'].'" />';
424 453
 
425 454
                 $url = $this->u_action."&amp;parent_id=$this->parent_id&amp;c={$row['cat_id']}";
@@ -439,7 +468,9 @@  discard block
 block discarded – undo
439 468
                     'U_SYNC'               => $url.'&amp;action=sync', ]
440 469
                 );
441 470
             } while ($row = $this->db->sql_fetchrow($result));
442
-        } elseif ($this->parent_id) {
471
+        }
472
+        elseif ($this->parent_id)
473
+        {
443 474
             $row = $this->_get_cat_info($this->parent_id);
444 475
 
445 476
             $url = $this->u_action.'&amp;parent_id='.$this->parent_id.'&amp;c='.$row['cat_id'];
@@ -485,25 +516,31 @@  discard block
 block discarded – undo
485 516
      */
486 517
     public function update()
487 518
     {
488
-        if (!check_form_key($this->form_key)) {
519
+        if (!check_form_key($this->form_key))
520
+        {
489 521
             $this->update = false;
490 522
             $this->errors[] = $this->user->lang['FORM_INVALID'];
491 523
         }
492 524
 
493
-        switch ($this->action) {
525
+        switch ($this->action)
526
+        {
494 527
             case 'delete':
495 528
                 $action_subcats = $this->request->variable('action_subcats', '');
496 529
                 $subcats_to_id = $this->request->variable('subcats_to_id', 0);
497 530
                 $action_links = $this->request->variable('action_links', '');
498 531
                 $links_to_id = $this->request->variable('links_to_id', 0);
499 532
 
500
-                try {
533
+                try
534
+                {
501 535
                     $this->errors = $this->_delete_cat($action_links, $action_subcats, $links_to_id, $subcats_to_id);
502
-                } catch (\Exception $e) {
536
+                }
537
+                catch (\Exception $e)
538
+                {
503 539
                     trigger_error($e->getMessage(), E_USER_WARNING);
504 540
                 }
505 541
 
506
-                if (count($this->errors)) {
542
+                if (count($this->errors))
543
+                {
507 544
                     break;
508 545
                 }
509 546
 
@@ -542,17 +579,22 @@  discard block
 block discarded – undo
542 579
                 ];
543 580
 
544 581
                 // Get data for cat description if specified
545
-                if ($this->cat_data['cat_desc']) {
582
+                if ($this->cat_data['cat_desc'])
583
+                {
546 584
                     generate_text_for_storage($this->cat_data['cat_desc'], $this->cat_data['cat_desc_uid'], $this->cat_data['cat_desc_bitfield'], $this->cat_data['cat_desc_options'], $this->request->variable('desc_parse_bbcode', false), $this->request->variable('desc_parse_urls', false), $this->request->variable('desc_parse_smilies', false));
547 585
                 }
548 586
 
549
-                try {
587
+                try
588
+                {
550 589
                     $this->errors = $this->_update_cat_data();
551
-                } catch (\Exception $e) {
590
+                }
591
+                catch (\Exception $e)
592
+                {
552 593
                     trigger_error($e->getMessage(), E_USER_WARNING);
553 594
                 }
554 595
 
555
-                if (!count($this->errors)) {
596
+                if (!count($this->errors))
597
+                {
556 598
                     $this->cache->destroy('sql', DIR_CAT_TABLE);
557 599
 
558 600
                     $message = ($this->action == 'add') ? $this->user->lang['DIR_CAT_CREATED'] : $this->user->lang['DIR_CAT_UPDATED'];
@@ -581,8 +623,10 @@  discard block
 block discarded – undo
581 623
         ];
582 624
 
583 625
         // Parse desciption if specified
584
-        if ($this->cat_data['cat_desc']) {
585
-            if (!isset($this->cat_data['cat_desc_uid'])) {
626
+        if ($this->cat_data['cat_desc'])
627
+        {
628
+            if (!isset($this->cat_data['cat_desc_uid']))
629
+            {
586 630
                 // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value...
587 631
                 $this->cat_data['cat_desc_uid'] = '';
588 632
                 $this->cat_data['cat_desc_bitfield'] = '';
@@ -651,7 +695,8 @@  discard block
 block discarded – undo
651 695
         $row = $this->db->sql_fetchrow($result);
652 696
         $this->db->sql_freeresult($result);
653 697
 
654
-        if (!$row) {
698
+        if (!$row)
699
+        {
655 700
             trigger_error('DIR_ERROR_NO_CATS', E_USER_ERROR);
656 701
         }
657 702
 
@@ -665,15 +710,18 @@  discard block
 block discarded – undo
665 710
      */
666 711
     private function _update_cat_data()
667 712
     {
668
-        if (!$this->cat_data['cat_name']) {
713
+        if (!$this->cat_data['cat_name'])
714
+        {
669 715
             $this->errors[] = $this->user->lang['DIR_CAT_NAME_EMPTY'];
670 716
         }
671 717
 
672
-        if (utf8_strlen($this->cat_data['cat_desc']) > 4000) {
718
+        if (utf8_strlen($this->cat_data['cat_desc']) > 4000)
719
+        {
673 720
             $this->errors[] = $this->user->lang['DIR_CAT_DESC_TOO_LONG'];
674 721
         }
675 722
 
676
-        if (($this->cat_data['cat_cron_enable'] && $this->cat_data['cat_cron_freq'] <= 0) || $this->cat_data['cat_cron_nb_check'] < 0) {
723
+        if (($this->cat_data['cat_cron_enable'] && $this->cat_data['cat_cron_freq'] <= 0) || $this->cat_data['cat_cron_nb_check'] < 0)
724
+        {
677 725
             $this->errors[] = $this->user->lang['DIR_CAT_DATA_NEGATIVE'];
678 726
         }
679 727
 
@@ -683,44 +731,55 @@  discard block
 block discarded – undo
683 731
         // What are we going to do tonight Brain? The same thing we do everynight,
684 732
         // try to take over the world ... or decide whether to continue update
685 733
         // and if so, whether it's a new cat/link or an existing one
686
-        if (count($this->errors)) {
734
+        if (count($this->errors))
735
+        {
687 736
             return $this->errors;
688 737
         }
689 738
 
690
-        if (!$cat_data_sql['cat_link_back']) {
739
+        if (!$cat_data_sql['cat_link_back'])
740
+        {
691 741
             $cat_data_sql['cat_cron_enable'] = 0;
692 742
             $cat_data_sql['cat_cron_next'] = 0;
693 743
         }
694 744
 
695
-        if (!$cat_data_sql['parent_id']) {
745
+        if (!$cat_data_sql['parent_id'])
746
+        {
696 747
             $cat_data_sql['display_subcat_list'] = 0;
697 748
         }
698 749
 
699 750
         // no cat_id means we're creating a new categorie
700
-        if (!isset($cat_data_sql['cat_id'])) {
701
-            if ($cat_data_sql['cat_cron_enable']) {
751
+        if (!isset($cat_data_sql['cat_id']))
752
+        {
753
+            if ($cat_data_sql['cat_cron_enable'])
754
+            {
702 755
                 $cat_data_sql['cat_cron_next'] = time() + $cat_data_sql['cat_cron_freq'] * 86400;
703 756
             }
704 757
 
705 758
             $this->cat_data = $this->nestedset_category->insert($cat_data_sql);
706 759
 
707
-            if ($cat_data_sql['parent_id']) {
760
+            if ($cat_data_sql['parent_id'])
761
+            {
708 762
                 $this->nestedset_category->change_parent($this->cat_data['cat_id'], $cat_data_sql['parent_id']);
709 763
             }
710 764
 
711 765
             $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_ADD', time(), [$this->cat_data['cat_name']]);
712
-        } else {
766
+        }
767
+        else
768
+        {
713 769
             $row = $this->_get_cat_info($cat_data_sql['cat_id']);
714 770
 
715
-            if ($row['parent_id'] != $cat_data_sql['parent_id']) {
771
+            if ($row['parent_id'] != $cat_data_sql['parent_id'])
772
+            {
716 773
                 $this->nestedset_category->change_parent($cat_data_sql['cat_id'], $cat_data_sql['parent_id']);
717 774
             }
718 775
 
719
-            if ($cat_data_sql['cat_cron_enable'] && ($row['cat_cron_freq'] != $cat_data_sql['cat_cron_freq'] || !$row['cat_cron_enable'])) {
776
+            if ($cat_data_sql['cat_cron_enable'] && ($row['cat_cron_freq'] != $cat_data_sql['cat_cron_freq'] || !$row['cat_cron_enable']))
777
+            {
720 778
                 $cat_data_sql['cat_cron_next'] = time() + $cat_data_sql['cat_cron_freq'] * 86400;
721 779
             }
722 780
 
723
-            if ($row['cat_name'] != $cat_data_sql['cat_name']) {
781
+            if ($row['cat_name'] != $cat_data_sql['cat_name'])
782
+            {
724 783
                 // the cat name has changed, clear the parents list of all categories (for safety)
725 784
                 $sql = 'UPDATE '.DIR_CAT_TABLE."
726 785
 					SET cat_parents = ''";
@@ -757,13 +816,19 @@  discard block
 block discarded – undo
757 816
 
758 817
         $log_action_links = $log_action_cats = $links_to_name = $subcats_to_name = '';
759 818
 
760
-        if ($action_links == 'delete') {
819
+        if ($action_links == 'delete')
820
+        {
761 821
             $log_action_links = 'LINKS';
762 822
             $this->errors = array_merge($this->errors, $this->_delete_cat_content());
763
-        } elseif ($action_links == 'move') {
764
-            if (!$links_to_id) {
823
+        }
824
+        elseif ($action_links == 'move')
825
+        {
826
+            if (!$links_to_id)
827
+            {
765 828
                 $this->errors[] = $this->user->lang['DIR_NO_DESTINATION_CAT'];
766
-            } else {
829
+            }
830
+            else
831
+            {
767 832
                 $log_action_links = 'MOVE_LINKS';
768 833
 
769 834
                 $sql = 'SELECT cat_name
@@ -773,25 +838,35 @@  discard block
 block discarded – undo
773 838
                 $row = $this->db->sql_fetchrow($result);
774 839
                 $this->db->sql_freeresult($result);
775 840
 
776
-                if (!$row) {
841
+                if (!$row)
842
+                {
777 843
                     throw new \OutOfBoundsException('DIR_NO_CAT');
778
-                } else {
844
+                }
845
+                else
846
+                {
779 847
                     $links_to_name = $row['cat_name'];
780 848
                     $this->_move_cat_content($this->cat_id, $links_to_id);
781 849
                 }
782 850
             }
783 851
         }
784 852
 
785
-        if (count($this->errors)) {
853
+        if (count($this->errors))
854
+        {
786 855
             return $this->errors;
787 856
         }
788 857
 
789
-        if ($action_subcats == 'delete') {
858
+        if ($action_subcats == 'delete')
859
+        {
790 860
             $log_action_cats = 'CATS';
791
-        } elseif ($action_subcats == 'move') {
792
-            if (!$subcats_to_id) {
861
+        }
862
+        elseif ($action_subcats == 'move')
863
+        {
864
+            if (!$subcats_to_id)
865
+            {
793 866
                 $this->errors[] = $this->user->lang['DIR_NO_DESTINATION_CAT'];
794
-            } else {
867
+            }
868
+            else
869
+            {
795 870
                 $log_action_cats = 'MOVE_CATS';
796 871
 
797 872
                 $subcats_to_name = $row['cat_name'];
@@ -799,7 +874,8 @@  discard block
 block discarded – undo
799 874
             }
800 875
         }
801 876
 
802
-        if (count($this->errors)) {
877
+        if (count($this->errors))
878
+        {
803 879
             return $this->errors;
804 880
         }
805 881
 
@@ -807,7 +883,8 @@  discard block
 block discarded – undo
807 883
 
808 884
         $log_action = implode('_', [$log_action_links, $log_action_cats]);
809 885
 
810
-        switch ($log_action) {
886
+        switch ($log_action)
887
+        {
811 888
             case 'MOVE_LINKS_MOVE_CATS':
812 889
                 $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DIR_CAT_DEL_MOVE_LINKS_MOVE_CATS', time(), [$links_to_name, $subcats_to_name, $this->cat_data['cat_name']]);
813 890
             break;
@@ -886,27 +963,32 @@  discard block
 block discarded – undo
886 963
         $result = $this->db->sql_query($sql);
887 964
 
888 965
         $link_ids = [];
889
-        while ($row = $this->db->sql_fetchrow($result)) {
966
+        while ($row = $this->db->sql_fetchrow($result))
967
+        {
890 968
             $link_ids[] = $row['link_id'];
891 969
 
892
-            if ($row['link_banner'] && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) {
970
+            if ($row['link_banner'] && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner']))
971
+            {
893 972
                 $banner_img = $this->dir_helper->get_banner_path(basename($row['link_banner']));
894 973
 
895
-                if (file_exists($banner_img)) {
974
+                if (file_exists($banner_img))
975
+                {
896 976
                     @unlink($banner_img);
897 977
                 }
898 978
             }
899 979
         }
900 980
         $this->db->sql_freeresult($result);
901 981
 
902
-        if (count($link_ids)) {
982
+        if (count($link_ids))
983
+        {
903 984
             // Delete links datas
904 985
             $link_datas_ary = [
905 986
                 DIR_COMMENT_TABLE     => 'comment_link_id',
906 987
                 DIR_VOTE_TABLE        => 'vote_link_id',
907 988
             ];
908 989
 
909
-            foreach ($link_datas_ary as $table => $field) {
990
+            foreach ($link_datas_ary as $table => $field)
991
+            {
910 992
                 $this->db->sql_query("DELETE FROM $table WHERE ".$this->db->sql_in_set($field, $link_ids));
911 993
             }
912 994
         }
@@ -917,7 +999,8 @@  discard block
 block discarded – undo
917 999
             DIR_WATCH_TABLE    => 'cat_id',
918 1000
         ];
919 1001
 
920
-        foreach ($cat_datas_ary as $table => $field) {
1002
+        foreach ($cat_datas_ary as $table => $field)
1003
+        {
921 1004
             $this->db->sql_query("DELETE FROM $table WHERE $field = ".(int) $this->cat_id);
922 1005
         }
923 1006
 
@@ -974,7 +1057,8 @@  discard block
 block discarded – undo
974 1057
 			WHERE vote_link_id BETWEEN '.(int) $start.' AND '.(int) $stop.'
975 1058
 			GROUP BY vote_link_id';
976 1059
         $result = $this->db->sql_query($sql);
977
-        while ($tmp = $this->db->sql_fetchrow($result)) {
1060
+        while ($tmp = $this->db->sql_fetchrow($result))
1061
+        {
978 1062
             $sql = 'UPDATE '.DIR_LINK_TABLE.'
979 1063
 				SET link_note = '.(int) $tmp['total'].', link_vote = '.(int) $tmp['nb_vote'].'
980 1064
 				WHERE link_id = '.(int) $tmp['vote_link_id'];
@@ -987,7 +1071,8 @@  discard block
 block discarded – undo
987 1071
 			WHERE comment_link_id BETWEEN '.(int) $start.' AND '.(int) $stop.'
988 1072
 			GROUP BY comment_link_id';
989 1073
         $result = $this->db->sql_query($sql);
990
-        while ($tmp = $this->db->sql_fetchrow($result)) {
1074
+        while ($tmp = $this->db->sql_fetchrow($result))
1075
+        {
991 1076
             $sql = 'UPDATE '.DIR_LINK_TABLE.'
992 1077
 				SET link_comment = '.(int) $tmp['nb_comment'].'
993 1078
 				WHERE link_id = '.(int) $tmp['comment_link_id'];
@@ -1009,18 +1094,22 @@  discard block
 block discarded – undo
1009 1094
         $imglist = filelist($icons_path, '');
1010 1095
         $filename_list = '<option value="">----------</option>';
1011 1096
 
1012
-        foreach ($imglist as $path => $img_ary) {
1097
+        foreach ($imglist as $path => $img_ary)
1098
+        {
1013 1099
             sort($img_ary);
1014 1100
 
1015
-            foreach ($img_ary as $img) {
1101
+            foreach ($img_ary as $img)
1102
+            {
1016 1103
                 $img = $path.$img;
1017 1104
                 $selected = '';
1018 1105
 
1019
-                if (strlen($img) > 255) {
1106
+                if (strlen($img) > 255)
1107
+                {
1020 1108
                     continue;
1021 1109
                 }
1022 1110
 
1023
-                if ($img == $img_selected) {
1111
+                if ($img == $img_selected)
1112
+                {
1024 1113
                     $selected = ' selected="selected"';
1025 1114
                 }
1026 1115
 
Please login to merge, or discard this patch.
controller/acp/main.php 1 patch
Braces   +45 added lines, -22 removed lines patch added patch discarded remove patch
@@ -54,7 +54,8 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function display_confirm($action)
56 56
     {
57
-        switch ($action) {
57
+        switch ($action)
58
+        {
58 59
             case 'votes':
59 60
                 $confirm = true;
60 61
                 $confirm_lang = 'DIR_RESET_VOTES_CONFIRM';
@@ -79,7 +80,8 @@  discard block
 block discarded – undo
79 80
                 $confirm = false;
80 81
         }
81 82
 
82
-        if ($confirm) {
83
+        if ($confirm)
84
+        {
83 85
             confirm_box(false, $this->user->lang[$confirm_lang], build_hidden_fields([
84 86
                 'action'    => $action,
85 87
             ]));
@@ -105,10 +107,12 @@  discard block
 block discarded – undo
105 107
 			FROM '.DIR_LINK_TABLE;
106 108
         $result = $this->db->sql_query($sql);
107 109
         $total_links = $waiting_links = 0;
108
-        while ($row = $this->db->sql_fetchrow($result)) {
110
+        while ($row = $this->db->sql_fetchrow($result))
111
+        {
109 112
             $total_links++;
110 113
 
111
-            if (!$row['link_active']) {
114
+            if (!$row['link_active'])
115
+            {
112 116
                 $waiting_links++;
113 117
             }
114 118
         }
@@ -139,16 +143,21 @@  discard block
 block discarded – undo
139 143
 
140 144
         $banners_path = $this->dir_helper->get_banner_path();
141 145
 
142
-        if ($banners_dir = @opendir($banners_path)) {
143
-            while (($file = readdir($banners_dir)) !== false) {
144
-                if ($file[0] != '.' && $file[0] != '..' && strpos($file, 'index.') === false && strpos($file, '.db') === false) {
146
+        if ($banners_dir = @opendir($banners_path))
147
+        {
148
+            while (($file = readdir($banners_dir)) !== false)
149
+            {
150
+                if ($file[0] != '.' && $file[0] != '..' && strpos($file, 'index.') === false && strpos($file, '.db') === false)
151
+                {
145 152
                     $banners_dir_size += filesize($banners_path.$file);
146 153
                 }
147 154
             }
148 155
             closedir($banners_dir);
149 156
 
150 157
             $banners_dir_size = get_formatted_filesize($banners_dir_size);
151
-        } else {
158
+        }
159
+        else
160
+        {
152 161
             // Couldn't open banners dir.
153 162
             $banners_dir_size = $this->user->lang['NOT_AVAILABLE'];
154 163
         }
@@ -178,9 +187,11 @@  discard block
 block discarded – undo
178 187
      */
179 188
     public function exec_action($action)
180 189
     {
181
-        switch ($action) {
190
+        switch ($action)
191
+        {
182 192
             case 'votes':
183
-                switch ($this->db->get_sql_layer()) {
193
+                switch ($this->db->get_sql_layer())
194
+                {
184 195
                     case 'sqlite':
185 196
                     case 'firebird':
186 197
                         $this->db->sql_query('DELETE FROM '.DIR_VOTE_TABLE);
@@ -195,13 +206,15 @@  discard block
 block discarded – undo
195 206
 					SET link_vote = 0, link_note = 0';
196 207
                 $this->db->sql_query($sql);
197 208
 
198
-                if ($this->request->is_ajax()) {
209
+                if ($this->request->is_ajax())
210
+                {
199 211
                     trigger_error('DIR_RESET_VOTES_SUCCESS');
200 212
                 }
201 213
             break;
202 214
 
203 215
             case 'comments':
204
-                switch ($this->db->get_sql_layer()) {
216
+                switch ($this->db->get_sql_layer())
217
+                {
205 218
                     case 'sqlite':
206 219
                     case 'firebird':
207 220
                         $this->db->sql_query('DELETE FROM '.DIR_COMMENT_TABLE);
@@ -216,7 +229,8 @@  discard block
 block discarded – undo
216 229
 					SET link_comment = 0';
217 230
                 $this->db->sql_query($sql);
218 231
 
219
-                if ($this->request->is_ajax()) {
232
+                if ($this->request->is_ajax())
233
+                {
220 234
                     trigger_error('DIR_RESET_COMMENTS_SUCCESS');
221 235
                 }
222 236
 
@@ -227,7 +241,8 @@  discard block
 block discarded – undo
227 241
 					SET link_view = 0';
228 242
                 $this->db->sql_query($sql);
229 243
 
230
-                if ($this->request->is_ajax()) {
244
+                if ($this->request->is_ajax())
245
+                {
231 246
                     trigger_error('DIR_RESET_CLICKS_SUCCESS');
232 247
                 }
233 248
             break;
@@ -235,7 +250,8 @@  discard block
 block discarded – undo
235 250
             case 'orphans':
236 251
                 $this->_orphan_files(true);
237 252
 
238
-                if ($this->request->is_ajax()) {
253
+                if ($this->request->is_ajax())
254
+                {
239 255
                     trigger_error('DIR_DELETE_ORPHANS_SUCCESS');
240 256
                 }
241 257
             break;
@@ -267,19 +283,23 @@  discard block
 block discarded – undo
267 283
         $imglist = filelist($banner_path);
268 284
         $physical_files = $logical_files = $orphan_files = [];
269 285
 
270
-        if (!empty($imglist[''])) {
286
+        if (!empty($imglist['']))
287
+        {
271 288
             $imglist = array_values($imglist);
272 289
             $imglist = $imglist[0];
273 290
 
274
-            foreach ($imglist as $img) {
291
+            foreach ($imglist as $img)
292
+            {
275 293
                 $physical_files[] = $img;
276 294
             }
277 295
             $sql = 'SELECT link_banner FROM '.DIR_LINK_TABLE.'
278 296
 				WHERE link_banner <> \'\'';
279 297
             $result = $this->db->sql_query($sql);
280 298
 
281
-            while ($row = $this->db->sql_fetchrow($result)) {
282
-                if (!preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) {
299
+            while ($row = $this->db->sql_fetchrow($result))
300
+            {
301
+                if (!preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner']))
302
+                {
283 303
                     $logical_files[] = basename($row['link_banner']);
284 304
                 }
285 305
             }
@@ -288,13 +308,16 @@  discard block
 block discarded – undo
288 308
             $orphan_files = array_diff($physical_files, $logical_files);
289 309
         }
290 310
 
291
-        if (!$delete) {
311
+        if (!$delete)
312
+        {
292 313
             return count($orphan_files);
293 314
         }
294 315
 
295 316
         $dh = @opendir($banner_path);
296
-        while (($file = readdir($dh)) !== false) {
297
-            if (in_array($file, $orphan_files)) {
317
+        while (($file = readdir($dh)) !== false)
318
+        {
319
+            if (in_array($file, $orphan_files))
320
+            {
298 321
                 @unlink($this->dir_helper->get_banner_path($file));
299 322
             }
300 323
         }
Please login to merge, or discard this patch.
controller/acp/settings.php 1 patch
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -61,12 +61,15 @@  discard block
 block discarded – undo
61 61
     public function display_config()
62 62
     {
63 63
         // Output relevant page
64
-        foreach ($this->display_vars['vars'] as $config_key => $vars) {
65
-            if (!is_array($vars) && strpos($config_key, 'legend') === false) {
64
+        foreach ($this->display_vars['vars'] as $config_key => $vars)
65
+        {
66
+            if (!is_array($vars) && strpos($config_key, 'legend') === false)
67
+            {
66 68
                 continue;
67 69
             }
68 70
 
69
-            if (strpos($config_key, 'legend') !== false) {
71
+            if (strpos($config_key, 'legend') !== false)
72
+            {
70 73
                 $this->template->assign_block_vars('options', [
71 74
                     'S_LEGEND'    => true,
72 75
                     'LEGEND'      => (isset($this->user->lang[$vars])) ? $this->user->lang[$vars] : $vars, ]
@@ -78,9 +81,12 @@  discard block
 block discarded – undo
78 81
             $type = explode(':', $vars['type']);
79 82
 
80 83
             $l_explain = '';
81
-            if ($vars['explain'] && isset($vars['lang_explain'])) {
84
+            if ($vars['explain'] && isset($vars['lang_explain']))
85
+            {
82 86
                 $l_explain = (isset($this->user->lang[$vars['lang_explain']])) ? $this->user->lang[$vars['lang_explain']] : $vars['lang_explain'];
83
-            } elseif ($vars['explain']) {
87
+            }
88
+            elseif ($vars['explain'])
89
+            {
84 90
                 $l_explain = (isset($this->user->lang[$vars['lang'].'_EXPLAIN'])) ? $this->user->lang[$vars['lang'].'_EXPLAIN'] : '';
85 91
             }
86 92
 
@@ -113,29 +119,35 @@  discard block
 block discarded – undo
113 119
         validate_config_vars($this->display_vars['vars'], $cfg_array, $error);
114 120
 
115 121
         // Do not write values if there is an error
116
-        if (count($error)) {
122
+        if (count($error))
123
+        {
117 124
             $submit = false;
118 125
         }
119 126
 
120 127
         // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
121
-        foreach ($this->display_vars['vars'] as $config_name => $null) {
122
-            if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
128
+        foreach ($this->display_vars['vars'] as $config_name => $null)
129
+        {
130
+            if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
131
+            {
123 132
                 continue;
124 133
             }
125 134
 
126 135
             $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
127 136
 
128
-            if ($config_name == 'dir_banner_filesize') {
137
+            if ($config_name == 'dir_banner_filesize')
138
+            {
129 139
                 $size_var = $this->request->variable($config_name, '');
130 140
                 $this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? round($config_value * 1024) : (($size_var == 'mb') ? round($config_value * 1048576) : $config_value);
131 141
             }
132 142
 
133
-            if ($submit) {
143
+            if ($submit)
144
+            {
134 145
                 $this->config->set($config_name, $config_value);
135 146
             }
136 147
         }
137 148
 
138
-        if ($submit) {
149
+        if ($submit)
150
+        {
139 151
             $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'DIR_CONFIG_SETTINGS');
140 152
 
141 153
             trigger_error($this->user->lang['CONFIG_UPDATED'].adm_back_link($this->u_action));
Please login to merge, or discard this patch.
controller/acp/validation.php 1 patch
Braces   +30 added lines, -14 removed lines patch added patch discarded remove patch
@@ -147,9 +147,12 @@  discard block
 block discarded – undo
147 147
         $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
148 148
         $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC');
149 149
 
150
-        if (is_array($sort_by_sql[$sort_key])) {
150
+        if (is_array($sort_by_sql[$sort_key]))
151
+        {
151 152
             $sql_sort_order = implode(' '.$direction.', ', $sort_by_sql[$sort_key]).' '.$direction;
152
-        } else {
153
+        }
154
+        else
155
+        {
153 156
             $sql_sort_order = $sort_by_sql[$sort_key].' '.$direction;
154 157
         }
155 158
 
@@ -184,7 +187,8 @@  discard block
 block discarded – undo
184 187
         $sql = $this->db->sql_build_query('SELECT', $sql_array);
185 188
         $result = $this->db->sql_query_limit($sql, $per_page, $start);
186 189
 
187
-        while ($row = $this->db->sql_fetchrow($result)) {
190
+        while ($row = $this->db->sql_fetchrow($result))
191
+        {
188 192
             $s_banner = $this->link->display_bann($row);
189 193
 
190 194
             $username = ($row['link_user_id'] == ANONYMOUS) ? $row['link_guest_email'] : $row['username'];
@@ -230,7 +234,8 @@  discard block
 block discarded – undo
230 234
     {
231 235
         $this->_get_infos_links($mark);
232 236
 
233
-        switch ($this->action) {
237
+        switch ($this->action)
238
+        {
234 239
             case 'approved':
235 240
                 $this->_action_approved();
236 241
                 break;
@@ -253,16 +258,19 @@  discard block
 block discarded – undo
253 258
      */
254 259
     public function notifiy_submiters()
255 260
     {
256
-        if (!class_exists('messenger')) {
261
+        if (!class_exists('messenger'))
262
+        {
257 263
             include $this->root_path.'includes/functions_messenger.'.$this->php_ext;
258 264
         }
259 265
         $messenger = new \messenger(false);
260 266
 
261
-        foreach ($this->links_data as $row) {
267
+        foreach ($this->links_data as $row)
268
+        {
262 269
             $this->notification->mark_notifications_read('ernadoo.phpbbdirectory.notification.type.directory_website_in_queue', (int) $row['link_id'], false);
263 270
 
264 271
             // New notification system can't send mail to an anonymous user with an email adress storage in another table than phpbb_users
265
-            if ($row['link_user_id'] == ANONYMOUS) {
272
+            if ($row['link_user_id'] == ANONYMOUS)
273
+            {
266 274
                 $username = $email = $row['link_guest_email'];
267 275
 
268 276
                 $messenger->template('@ernadoo_phpbbdirectory/directory_website_'.$this->action, $row['user_lang']);
@@ -274,7 +282,9 @@  discard block
 block discarded – undo
274 282
                 ]);
275 283
 
276 284
                 $messenger->send(NOTIFY_EMAIL);
277
-            } else {
285
+            }
286
+            else
287
+            {
278 288
                 $notification_data = [
279 289
                     'user_from'            => (int) $row['link_user_id'],
280 290
                     'link_id'              => (int) $row['link_id'],
@@ -307,7 +317,8 @@  discard block
 block discarded – undo
307 317
      */
308 318
     private function _action_approved()
309 319
     {
310
-        foreach ($this->links_data as $row) {
320
+        foreach ($this->links_data as $row)
321
+        {
311 322
             $this->_notify_suscribers($row);
312 323
 
313 324
             $sql_ary = [
@@ -322,7 +333,8 @@  discard block
 block discarded – undo
322 333
             $this->db->sql_query($sql);
323 334
         }
324 335
 
325
-        foreach ($this->cat_data as $cat_id => $count) {
336
+        foreach ($this->cat_data as $cat_id => $count)
337
+        {
326 338
             $sql = 'UPDATE '.DIR_CAT_TABLE.'
327 339
 							SET cat_links = cat_links + '.$count.'
328 340
 							WHERE cat_id = '.(int) $cat_id;
@@ -337,11 +349,14 @@  discard block
 block discarded – undo
337 349
      */
338 350
     private function _action_disapproved()
339 351
     {
340
-        foreach ($this->links_data as $row) {
341
-            if ($row['link_banner'] && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner'])) {
352
+        foreach ($this->links_data as $row)
353
+        {
354
+            if ($row['link_banner'] && !preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $row['link_banner']))
355
+            {
342 356
                 $banner_img = $this->dir_helper->get_banner_path(basename($row['link_banner']));
343 357
 
344
-                if (file_exists($banner_img)) {
358
+                if (file_exists($banner_img))
359
+                {
345 360
                     @unlink($banner_img);
346 361
                 }
347 362
             }
@@ -379,7 +394,8 @@  discard block
 block discarded – undo
379 394
         $sql = $this->db->sql_build_query('SELECT', $sql_array);
380 395
         $result = $this->db->sql_query($sql);
381 396
 
382
-        while ($row = $this->db->sql_fetchrow($result)) {
397
+        while ($row = $this->db->sql_fetchrow($result))
398
+        {
383 399
             $row['link_cat'] = $this->request->variable('c'.$row['link_id'], (int) $row['cat_id']);
384 400
 
385 401
             $this->links_data[] = $row;
Please login to merge, or discard this patch.
controller/search.php 1 patch
Braces   +48 added lines, -23 removed lines patch added patch discarded remove patch
@@ -91,7 +91,8 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function main($page)
93 93
     {
94
-        if (!$this->auth->acl_get('u_search_dir')) {
94
+        if (!$this->auth->acl_get('u_search_dir'))
95
+        {
95 96
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
96 97
         }
97 98
 
@@ -115,7 +116,8 @@  discard block
 block discarded – undo
115 116
         $sort_by_text = ['a' => $this->user->lang['AUTHOR'], 't' => $this->user->lang['POST_TIME'], 'r' => $this->user->lang['DIR_COMMENTS_ORDER'], 's' =>  $this->user->lang['DIR_NAME_ORDER'], 'v' => $this->user->lang['DIR_NB_CLICKS_ORDER']];
116 117
         $sort_by_sql = ['a' => 'u.username_clean', 't' => ['l.link_time', 'l.link_id'], 'r' => 'l.link_comment', 's' => 'LOWER(l.link_name)', 'v' => 'l.link_view'];
117 118
 
118
-        if ($this->config['dir_activ_pagerank']) {
119
+        if ($this->config['dir_activ_pagerank'])
120
+        {
119 121
             $sort_by_text['p'] = $this->user->lang['DIR_PR_ORDER'];
120 122
             $sort_by_sql['p'] = 'l.link_pagerank';
121 123
         }
@@ -128,12 +130,14 @@  discard block
 block discarded – undo
128 130
         /*
129 131
         ** search form submited
130 132
         */
131
-        if ($this->request->is_set_post('submit') || $keywords) {
133
+        if ($this->request->is_set_post('submit') || $keywords)
134
+        {
132 135
             // clear arrays
133 136
             $id_ary = $u_search = [];
134 137
             $keywords_ary = ($keywords) ? explode(' ', $keywords) : [];
135 138
 
136
-            if (!count($keywords_ary)) {
139
+            if (!count($keywords_ary))
140
+            {
137 141
                 return $this->helper->message('DIR_ERROR_KEYWORD');
138 142
             }
139 143
 
@@ -143,9 +147,12 @@  discard block
 block discarded – undo
143 147
 
144 148
             $l_search_matches = $this->user->lang('FOUND_SEARCH_MATCHES', (int) $total_match_count);
145 149
 
146
-            if (count($id_ary)) {
150
+            if (count($id_ary))
151
+            {
147 152
                 $sql_where = $this->db->sql_in_set('l.link_id', $id_ary);
148
-            } else {
153
+            }
154
+            else
155
+            {
149 156
                 return $this->helper->message('DIR_SEARCH_NO_RESULT');
150 157
             }
151 158
 
@@ -186,14 +193,16 @@  discard block
 block discarded – undo
186 193
                 'U_SEARCH_WORDS'          => $u_search,
187 194
             ]);
188 195
 
189
-            if ($cat_id) {
196
+            if ($cat_id)
197
+            {
190 198
                 $this->template->assign_vars([
191 199
                     'SEARCH_CATEGORY'      => $this->user->lang('RETURN_TO', \ernadoo\phpbbdirectory\core\categorie::getname((int) $cat_id)),
192 200
                     'U_SEARCH_CATEGORY'    => $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]),
193 201
                 ]);
194 202
             }
195 203
 
196
-            if ($sql_where) {
204
+            if ($sql_where)
205
+            {
197 206
                 $sql_array = [
198 207
                     'SELECT'      => 'l.link_name, l.link_description, l.link_url, l.link_uid, l.link_bitfield, l.link_flags, l.link_view, l.link_user_id, l.link_time, l.link_comment, l.link_flag, l.link_id, l.link_thumb, l.link_banner, c.cat_name, u.user_id, u.username, u.user_colour',
199 208
                     'FROM'        => [
@@ -215,11 +224,14 @@  discard block
 block discarded – undo
215 224
 
216 225
                 $rowset = $this->db->sql_fetchrowset($result);
217 226
 
218
-                if (count($rowset)) {
219
-                    if ($hilit) {
227
+                if (count($rowset))
228
+                {
229
+                    if ($hilit)
230
+                    {
220 231
                         // Remove bad highlights
221 232
                         $hilit_array = array_filter(explode('|', $hilit), 'strlen');
222
-                        foreach ($hilit_array as $key => $value) {
233
+                        foreach ($hilit_array as $key => $value)
234
+                        {
223 235
                             $hilit_array[$key] = phpbb_clean_search_string($value);
224 236
                             $hilit_array[$key] = str_replace('\*', '\w*?', preg_quote($hilit_array[$key], '#'));
225 237
                             $hilit_array[$key] = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $hilit_array[$key]);
@@ -227,14 +239,16 @@  discard block
 block discarded – undo
227 239
                         $hilit = implode('|', $hilit_array);
228 240
                     }
229 241
 
230
-                    foreach ($rowset as $data) {
242
+                    foreach ($rowset as $data)
243
+                    {
231 244
                         $s_banner = $this->link->display_bann($data);
232 245
                         $s_thumb = $this->link->display_thumb($data);
233 246
                         $s_flag = $this->link->display_flag($data);
234 247
 
235 248
                         $data['link_description'] = generate_text_for_display($data['link_description'], $data['link_uid'], $data['link_bitfield'], $data['link_flags']);
236 249
 
237
-                        if ($hilit) {
250
+                        if ($hilit)
251
+                        {
238 252
                             $data['link_name'] = preg_replace('#(?!<.*)(?<!\w)('.$hilit.')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $data['link_name']);
239 253
                             $data['link_description'] = preg_replace('#(?!<.*)(?<!\w)('.$hilit.')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $data['link_description']);
240 254
                         }
@@ -261,11 +275,13 @@  discard block
 block discarded – undo
261 275
                             'LINK_ID'          => $data['link_id'],
262 276
                         ]);
263 277
 
264
-                        if ($s_banner) {
278
+                        if ($s_banner)
279
+                        {
265 280
                             $this->template->assign_block_vars('results.banner', []);
266 281
                         }
267 282
 
268
-                        if ($this->config['dir_activ_flag']) {
283
+                        if ($this->config['dir_activ_flag'])
284
+                        {
269 285
                             $this->template->assign_block_vars('results.switch_dir_flag', []);
270 286
                         }
271 287
                     }
@@ -278,7 +294,8 @@  discard block
 block discarded – undo
278 294
 
279 295
         $s_catlist = $this->categorie->make_cat_select();
280 296
 
281
-        if (!$s_catlist) {
297
+        if (!$s_catlist)
298
+        {
282 299
             return $this->helper->message('NO_SEARCH');
283 300
         }
284 301
 
@@ -311,17 +328,24 @@  discard block
 block discarded – undo
311 328
         $reset_search_category = true;
312 329
         $ex_cid_ary = [];
313 330
 
314
-        while ($row = $this->db->sql_fetchrow($result)) {
315
-            if (count($search_category)) {
316
-                if ($search_child) {
317
-                    if (in_array($row['cat_id'], $search_category) && $row['right_id'] > $right_id) {
331
+        while ($row = $this->db->sql_fetchrow($result))
332
+        {
333
+            if (count($search_category))
334
+            {
335
+                if ($search_child)
336
+                {
337
+                    if (in_array($row['cat_id'], $search_category) && $row['right_id'] > $right_id)
338
+                    {
318 339
                         $right_id = (int) $row['right_id'];
319
-                    } elseif ($row['right_id'] < $right_id) {
340
+                    }
341
+                    elseif ($row['right_id'] < $right_id)
342
+                    {
320 343
                         continue;
321 344
                     }
322 345
                 }
323 346
 
324
-                if (!in_array($row['cat_id'], $search_category)) {
347
+                if (!in_array($row['cat_id'], $search_category))
348
+                {
325 349
                     $ex_cid_ary[] = (int) $row['cat_id'];
326 350
                     $reset_search_category = false;
327 351
                 }
@@ -329,7 +353,8 @@  discard block
 block discarded – undo
329 353
         }
330 354
         $this->db->sql_freeresult($result);
331 355
 
332
-        if ($reset_search_category) {
356
+        if ($reset_search_category)
357
+        {
333 358
             $search_category = [];
334 359
         }
335 360
 
Please login to merge, or discard this patch.
controller/links.php 1 patch
Braces   +77 added lines, -36 removed lines patch added patch discarded remove patch
@@ -115,7 +115,8 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function delete_link($cat_id, $link_id)
117 117
     {
118
-        if ($this->request->is_set_post('cancel')) {
118
+        if ($this->request->is_set_post('cancel'))
119
+        {
119 120
             $redirect = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]);
120 121
             redirect($redirect);
121 122
         }
@@ -126,17 +127,20 @@  discard block
 block discarded – undo
126 127
         $result = $this->db->sql_query($sql);
127 128
         $link_data = $this->db->sql_fetchrow($result);
128 129
 
129
-        if (empty($link_data)) {
130
+        if (empty($link_data))
131
+        {
130 132
             throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS');
131 133
         }
132 134
 
133 135
         $delete_allowed = $this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_dir') || ($this->user->data['user_id'] == $link_data['link_user_id'] && $this->auth->acl_get('u_delete_dir')));
134 136
 
135
-        if (!$delete_allowed) {
137
+        if (!$delete_allowed)
138
+        {
136 139
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
137 140
         }
138 141
 
139
-        if (confirm_box(true)) {
142
+        if (confirm_box(true))
143
+        {
140 144
             $this->link->del($cat_id, $link_id);
141 145
 
142 146
             $meta_info = $this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]);
@@ -144,7 +148,9 @@  discard block
 block discarded – undo
144 148
             $message = $this->user->lang['DIR_DELETE_OK'].'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_DIR', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_base_controller').'">', '</a>').'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]).'">', '</a>');
145 149
 
146 150
             return $this->helper->message($message);
147
-        } else {
151
+        }
152
+        else
153
+        {
148 154
             confirm_box(false, 'DIR_DELETE_SITE');
149 155
         }
150 156
     }
@@ -170,7 +176,8 @@  discard block
 block discarded – undo
170 176
 
171 177
         $edit_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_dir') || ($this->user->data['user_id'] == (int) $link_data['link_user_id'] && $this->auth->acl_get('u_edit_dir'))));
172 178
 
173
-        if (!$edit_allowed) {
179
+        if (!$edit_allowed)
180
+        {
174 181
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
175 182
         }
176 183
 
@@ -187,11 +194,15 @@  discard block
 block discarded – undo
187 194
         $this->categorie->get($cat_id);
188 195
 
189 196
         // If form is done
190
-        if ($submit || $refresh) {
191
-            if (false != ($result = $this->_data_processing($cat_id, $link_id, 'edit'))) {
197
+        if ($submit || $refresh)
198
+        {
199
+            if (false != ($result = $this->_data_processing($cat_id, $link_id, 'edit')))
200
+            {
192 201
                 return $result;
193 202
             }
194
-        } else {
203
+        }
204
+        else
205
+        {
195 206
             $sql = 'SELECT link_id, link_uid, link_flags, link_bitfield, link_cat, link_url, link_description, link_guest_email, link_name, link_rss, link_back, link_banner, link_flag, link_cat, link_time
196 207
 				FROM '.DIR_LINK_TABLE.'
197 208
 				WHERE link_id = '.(int) $link_id;
@@ -199,7 +210,8 @@  discard block
 block discarded – undo
199 210
 
200 211
             $site = $this->db->sql_fetchrow($result);
201 212
 
202
-            if (empty($site['link_id'])) {
213
+            if (empty($site['link_id']))
214
+            {
203 215
                 throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_LINKS');
204 216
             }
205 217
 
@@ -237,7 +249,8 @@  discard block
 block discarded – undo
237 249
      */
238 250
     public function new_link($cat_id)
239 251
     {
240
-        if (!$this->auth->acl_get('u_submit_dir')) {
252
+        if (!$this->auth->acl_get('u_submit_dir'))
253
+        {
241 254
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
242 255
         }
243 256
 
@@ -254,14 +267,17 @@  discard block
 block discarded – undo
254 267
         $this->categorie->get($cat_id);
255 268
 
256 269
         // The CAPTCHA kicks in here. We can't help that the information gets lost on language change.
257
-        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) {
270
+        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'])
271
+        {
258 272
             $this->captcha = $this->captcha_factory->get_instance($this->config['captcha_plugin']);
259 273
             $this->captcha->init(CONFIRM_POST);
260 274
         }
261 275
 
262 276
         // If form is done
263
-        if ($submit || $refresh) {
264
-            if (false != ($result = $this->_data_processing($cat_id))) {
277
+        if ($submit || $refresh)
278
+        {
279
+            if (false != ($result = $this->_data_processing($cat_id)))
280
+            {
265 281
                 return $result;
266 282
             }
267 283
         }
@@ -295,7 +311,8 @@  discard block
 block discarded – undo
295 311
     {
296 312
         $this->categorie->get($cat_id);
297 313
 
298
-        if (!$this->auth->acl_get('u_vote_dir') || !$this->categorie->data['cat_allow_votes']) {
314
+        if (!$this->auth->acl_get('u_vote_dir') || !$this->categorie->data['cat_allow_votes'])
315
+        {
299 316
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
300 317
         }
301 318
 
@@ -311,7 +328,8 @@  discard block
 block discarded – undo
311 328
         $result = $this->db->sql_query($sql);
312 329
         $data = $this->db->sql_fetchrow($result);
313 330
 
314
-        if (!empty($data['vote_link_id'])) {
331
+        if (!empty($data['vote_link_id']))
332
+        {
315 333
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_VOTE');
316 334
         }
317 335
 
@@ -337,11 +355,13 @@  discard block
 block discarded – undo
337 355
      */
338 356
     private function _data_processing($cat_id, $link_id = 0, $mode = 'new')
339 357
     {
340
-        if (($mode == 'edit' && !$this->auth->acl_get('m_edit_dir') && !$this->auth->acl_get('u_edit_dir')) || ($mode == 'new' && !$this->auth->acl_get('u_submit_dir'))) {
358
+        if (($mode == 'edit' && !$this->auth->acl_get('m_edit_dir') && !$this->auth->acl_get('u_edit_dir')) || ($mode == 'new' && !$this->auth->acl_get('u_submit_dir')))
359
+        {
341 360
             throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH');
342 361
         }
343 362
 
344
-        if (!check_form_key('dir_form')) {
363
+        if (!check_form_key('dir_form'))
364
+        {
345 365
             return $this->helper->message('FORM_INVALID');
346 366
         }
347 367
 
@@ -354,7 +374,8 @@  discard block
 block discarded – undo
354 374
         $this->back = $this->request->variable('back', '');
355 375
         $this->flag = $this->request->variable('flag', '');
356 376
 
357
-        if (!function_exists('validate_data')) {
377
+        if (!function_exists('validate_data'))
378
+        {
358 379
             include $this->root_path.'includes/functions_user.'.$this->php_ext;
359 380
         }
360 381
 
@@ -399,22 +420,27 @@  discard block
 block discarded – undo
399 420
         $error = array_map([$this->user, 'lang'], $error);
400 421
 
401 422
         // We check that url have good format
402
-        if (preg_match('/^(http|https):\/\//si', $this->url) && $this->config['dir_activ_checkurl'] && !$this->link->checkurl($this->url)) {
423
+        if (preg_match('/^(http|https):\/\//si', $this->url) && $this->config['dir_activ_checkurl'] && !$this->link->checkurl($this->url))
424
+        {
403 425
             $error[] = $this->user->lang['DIR_ERROR_CHECK_URL'];
404 426
         }
405 427
 
406
-        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm']) {
428
+        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'])
429
+        {
407 430
             $vc_response = $this->captcha->validate($data);
408
-            if ($vc_response !== false) {
431
+            if ($vc_response !== false)
432
+            {
409 433
                 $error[] = $vc_response;
410 434
             }
411 435
 
412
-            if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts']) {
436
+            if ($this->config['dir_visual_confirm_max_attempts'] && $this->captcha->get_attempt_count() > $this->config['dir_visual_confirm_max_attempts'])
437
+            {
413 438
                 $error[] = $this->user->lang['TOO_MANY_ADDS'];
414 439
             }
415 440
         }
416 441
 
417
-        if (!$error) {
442
+        if (!$error)
443
+        {
418 444
             /*
419 445
             * No errrors, we execute heavy tasks wich need a valid url
420 446
             */
@@ -430,7 +456,8 @@  discard block
 block discarded – undo
430 456
         }
431 457
 
432 458
         // Still no errors?? So let's go!
433
-        if (!$error) {
459
+        if (!$error)
460
+        {
434 461
             $this->banner = (!$this->banner && !$this->request->is_set_post('delete_banner')) ? $this->request->variable('old_banner', '') : $this->banner;
435 462
             $this->url = $this->link->clean_url($this->url);
436 463
 
@@ -452,16 +479,20 @@  discard block
 block discarded – undo
452 479
                 'link_thumb'           => $thumb,
453 480
             ];
454 481
 
455
-            if ($this->description) {
482
+            if ($this->description)
483
+            {
456 484
                 generate_text_for_storage($this->description, $data_edit['link_uid'], $data_edit['link_bitfield'], $data_edit['link_flags'], (bool) $this->config['allow_bbcode'], (bool) $this->config['allow_post_links'], (bool) $this->config['allow_smilies']);
457 485
             }
458 486
 
459 487
             $need_approval = ($this->categorie->need_approval() && !$this->auth->acl_get('a_') && !$this->auth->acl_get('m_')) ? true : false;
460 488
 
461
-            if ($mode == 'edit') {
489
+            if ($mode == 'edit')
490
+            {
462 491
                 $data_edit['link_cat_old'] = $this->request->variable('old_cat_id', 0);
463 492
                 $this->link->edit($data_edit, $link_id, $need_approval);
464
-            } else {
493
+            }
494
+            else
495
+            {
465 496
                 $data_add = [
466 497
                     'link_time'            => time(),
467 498
                     'link_view'            => 0,
@@ -480,8 +511,11 @@  discard block
 block discarded – undo
480 511
             $message = $message.'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_DIR', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_base_controller').'">', '</a>').'<br /><br />'.$this->user->lang('DIR_CLICK_RETURN_CAT', '<a href="'.$this->helper->route('ernadoo_phpbbdirectory_page_controller', ['cat_id' => (int) $cat_id]).'">', '</a>');
481 512
 
482 513
             return $this->helper->message($message);
483
-        } else {
484
-            if ($mode == 'edit') {
514
+        }
515
+        else
516
+        {
517
+            if ($mode == 'edit')
518
+            {
485 519
                 $this->s_hidden_fields = [
486 520
                     'old_cat_id'    => $this->request->variable('old_cat_id', 0),
487 521
                     'old_banner'    => $this->request->variable('old_banner', ''),
@@ -503,22 +537,27 @@  discard block
 block discarded – undo
503 537
      */
504 538
     public function return_banner($banner_img)
505 539
     {
506
-        if (!function_exists('file_gc')) {
540
+        if (!function_exists('file_gc'))
541
+        {
507 542
             include $this->root_path.'includes/functions_download.'.$this->php_ext;
508 543
         }
509 544
 
510 545
         $file_path = $this->dir_helper->get_banner_path($banner_img);
511 546
 
512
-        if ((@file_exists($file_path) && @is_readable($file_path))) {
547
+        if ((@file_exists($file_path) && @is_readable($file_path)))
548
+        {
513 549
             $response = new BinaryFileResponse($file_path);
514 550
             $response->setContentDisposition('inline', $banner_img);
515 551
 
516 552
             // Without fileinfo extension, Symfony is unable to guess the mime type
517
-            if (!extension_loaded('fileinfo')) {
553
+            if (!extension_loaded('fileinfo'))
554
+            {
518 555
                 $image_data = @getimagesize($file_path);
519 556
                 $response->headers->set('Content-Type', image_type_to_mime_type($image_data[2]));
520 557
             }
521
-        } else {
558
+        }
559
+        else
560
+        {
522 561
             $response = new Response();
523 562
             $response->setStatusCode(404);
524 563
         }
@@ -540,7 +579,8 @@  discard block
 block discarded – undo
540 579
     {
541 580
         global $phpbb_extension_manager;
542 581
 
543
-        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode == 'new') {
582
+        if (!$this->user->data['is_registered'] && $this->config['dir_visual_confirm'] && $mode == 'new')
583
+        {
544 584
             $this->s_hidden_fields = array_merge($this->s_hidden_fields, $this->captcha->get_hidden_fields());
545 585
 
546 586
             $this->user->add_lang('ucp');
@@ -552,7 +592,8 @@  discard block
 block discarded – undo
552 592
 
553 593
         $this->user->add_lang('posting');
554 594
 
555
-        if (!function_exists('display_custom_bbcodes')) {
595
+        if (!function_exists('display_custom_bbcodes'))
596
+        {
556 597
             include $this->root_path.'includes/functions_display.'.$this->php_ext;
557 598
         }
558 599
         display_custom_bbcodes();
Please login to merge, or discard this patch.
language/fr/directory.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,11 +9,13 @@
 block discarded – undo
9 9
 /**
10 10
  * DO NOT CHANGE.
11 11
  */
12
-if (!defined('IN_PHPBB')) {
12
+if (!defined('IN_PHPBB'))
13
+{
13 14
     exit;
14 15
 }
15 16
 
16
-if (empty($lang) || !is_array($lang)) {
17
+if (empty($lang) || !is_array($lang))
18
+{
17 19
     $lang = [];
18 20
 }
19 21
 
Please login to merge, or discard this patch.