Issues (322)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

root/directory.php (51 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 19.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
*
4
* @author Erwan NADER (ErnadoO) [email protected]
5
* @package phpBB3
6
* @version $Id$
7
* @copyright (c) 2009 http://www.phpbb-services.com
8
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
9
*
10
*/
11
12
/**
13
*/
14
15
/**
16
* @ignore
17
*/
18
define('IN_PHPBB', true);
19
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
20
$phpEx = substr(strrchr(__FILE__, '.'), 1);
21
include($phpbb_root_path . 'common.' . $phpEx);
22
include($phpbb_root_path . 'includes/mods/directory/functions.' . $phpEx);
23
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
24
$directory_root_path = $config['dir_root_path'];
25
26
// Start session management
27
$user->session_begin();
28
$auth->acl($user->data);
29
$user->setup('mods/directory');
30
31
$mode 			= request_var('mode', '');
32
$id				= request_var('id', 0);
33
$u				= request_var('u', 0);
34
$start			= request_var('start', 0);
35
$submit			= (isset($_POST['submit'])) ? true : false;
36
$refresh		= (isset($_POST['refresh_vc'])) ? true : false;
37
$timestamp		= request_var('timestamp', 0);
38
39
if($timestamp)
40
{
41
	echo $user->format_date((int)$timestamp);
42
43
	garbage_collection();
44
	exit_handler();
45
}
46
47
$categorie	= new categorie($id);
48
$title		= $user->lang['DIRECTORY'];
49
$s_hidden_fields = array();
50
51
$template->assign_block_vars('navlinks', array(
52
	'FORUM_NAME'	=> $title,
53
	'U_VIEW_FORUM'	=> append_sid("{$directory_root_path}directory.$phpEx"))
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
54
);
55
56
if($submit || $refresh || $mode == 'new')
57
{
58
	// The CAPTCHA kicks in here. We can't help that the information gets lost on language change.
59 View Code Duplication
	if(!$user->data['is_registered'] && $config['dir_visual_confirm'])
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
	{
61
		include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
62
		$captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']);
63
		$captcha->init(CONFIRM_POST);
64
	}
65
}
66
67
// If we delete a link
68
if ($mode == 'delete')
69
{
70
	if (isset($_POST['cancel']))
71
	{
72
		$redirect = append_sid("{$phpbb_root_path}directory.$phpEx", "mode=cat&amp;id=$id");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpbb_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
73
		redirect($redirect);
74
	}
75
76
	$sql = 'SELECT link_user_id FROM ' . DIR_LINK_TABLE . ' WHERE link_id = ' . (int)$u;
77
	$result = $db->sql_query($sql);
78
	$link_data = $db->sql_fetchrow($result);
79
80
	if(empty($link_data))
81
	{
82
		trigger_error('DIR_ERROR_NO_LINKS');
83
	}
84
85
	$delete_allowed = $user->data['is_registered'] && ($auth->acl_get('m_delete_dir') || ($user->data['user_id'] == $link_data['link_user_id'] && $auth->acl_get('u_delete_dir')));
86
87
	if(!$delete_allowed)
88
	{
89
		trigger_error('DIR_ERROR_NOT_AUTH');
90
	}
91
92
	$link->del($u, $id);
93
}
94
95
if (isset($_POST['submit_vote']) )
96
{
97
	if (!$auth->acl_get('u_vote_dir') || !$categorie->data['cat_allow_votes'])
98
	{
99
		trigger_error('DIR_ERROR_NOT_AUTH');
100
	}
101
	$link->add_vote($u);
102
}
103
104
// If form is done
105
if ($submit || $refresh)
106
{
107
	if (($mode == 'edit' && !$auth->acl_get('m_edit_dir') && !$auth->acl_get('u_edit_dir')) || ($mode == 'new' && !$auth->acl_get('u_submit_dir')))
108
	{
109
		trigger_error('DIR_ERROR_NOT_AUTH');
110
	}
111
112
	if (!check_form_key('dir_form'))
113
	{
114
		trigger_error('FORM_INVALID');
115
	}
116
117
	$url			= request_var('url', '');
118
	$site_name		= utf8_normalize_nfc(request_var('site_name', '', true));
119
	$description	= utf8_normalize_nfc(request_var('description', '', true));
120
	$guest_email	= request_var('guest_email', '');
121
	$rss			= request_var('rss', '');
122
	$banner 		= request_var('banner', '');
123
	$back			= request_var('back', '');
124
	$flag 			= request_var('flag', '');
125
126
	include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
127
128
	// We define variables to check
129
	$data = array(
130
		'email'			=> $guest_email,
131
		'site_name'		=> $site_name,
132
		'website'		=> $url,
133
		'description'	=> $description,
134
		'rss'			=> $rss,
135
		'banner'		=> $banner,
136
		'back'			=> $back,
137
		'cat'			=> $id,
138
	);
139
140
	// We define verification type for each variable
141
	$data2 = array(
142
		'email'			=>		array(
143
			array('string', $user->data['is_registered'], 6, 60),
144
			array('email', '')),
145
		'site_name' =>			array(
146
			array('string', false, 1, 100)),
147
		'website'		=>		array(
148
			array('string',	false, 12, 255),
149
			array('match',	true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
150
		'description'	=>		array(
151
			array('string', !$categorie->data['cat_must_describe'], 1, $config['dir_length_describe'])),
152
		'rss'			=>		array(
153
			array('string', true, 12, 255),
154
			array('match',	empty($rss), '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
155
		'banner'		=>		array(
156
			array('string', true, 5, 255)),
157
		'back'			=>		array(
158
			array('string',	!$categorie->data['cat_link_back'], 12, 255),
159
			array('link_back', true)),
160
		'cat'			=>		array(
161
			array('num', '', 1)));
162
163
	$user->add_lang('ucp');
164
	$error = validate_data($data, $data2);
165
	$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
166
167
	// We check that url have good format
168
	if(preg_match('/^(http|https):\/\//si', $url) && $config['dir_activ_checkurl'] && !$link->checkurl($url))
169
	{
170
		$error[] = $user->lang['DIR_ERROR_CHECK_URL'];
171
	}
172
173
	$wrong_confirm = false;
174 View Code Duplication
	if (!$user->data['is_registered'] && $config['dir_visual_confirm'])
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
175
	{
176
		$vc_response = $captcha->validate($data);
177
		if ($vc_response !== false)
178
		{
179
			$error[] = $vc_response;
180
		}
181
182
		if ($config['dir_visual_confirm_max_attempts'] && $captcha->get_attempt_count() > $config['dir_visual_confirm_max_attempts'])
183
		{
184
			$error[] = $user->lang['TOO_MANY_ADDS'];
185
		}
186
	}
187
188
	if(!$error)
189
	{
190
		/**
191
		* No errrors, we execute heavy tasks wich need a valid url
192
		*/
193
194
		// Banner
195
		$link->banner_process($banner, $error);
196
197
		// PageRank
198
		$pagerank = $link->pagerank_process($url);
199
200
		// Thumb ;)
201
		$thumb = $link->thumb_process($url);
202
	}
203
204
	// Still no errors?? So let's go baby!
205
	if (!$error)
206
	{
207
		$poll			= $uid			= $bitfield			= $options	= '';
208
		$allow_bbcode	= $allow_urls	= $allow_smilies	= true;
209
		generate_text_for_storage($description, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
210
211
		$banner	= (!$banner && !isset($_POST['delete_banner'])) ? request_var('old_banner', '') : $banner;
212
		$url	= $link->clean_url($url);
213
214
		$data_edit = array(
215
			'link_guest_email'	=> $guest_email,
216
			'link_name'			=> $site_name,
217
			'link_url'			=> $url,
218
			'link_description'	=> $description,
219
			'link_cat'			=> (int)$id,
220
			'link_rss'			=> $rss,
221
			'link_banner'		=> $banner,
222
			'link_back'			=> $back,
223
			'link_uid'			=> $uid,
224
			'link_flags'		=> $options,
225
			'link_flag'			=> $flag,
226
			'link_bitfield'		=> $bitfield,
227
			'link_pagerank'		=> (int)$pagerank,
228
			'link_thumb'		=> $thumb,
229
		);
230
231
		$need_approval = (categorie::need_approval($id) && !$auth->acl_get('a_') && !$auth->acl_get('m_')) ? true : false;
232
233
		if ($mode == 'edit')
234
		{
235
			$data_edit['link_cat_old'] = request_var('old_cat_id', 0);
236
			$link->edit($data_edit, $u, $need_approval);
237
		}
238
		else
239
		{
240
			$data_add = array(
241
				'link_time'			=> time(),
242
				'link_view'			=> 0,
243
				'link_active'		=> $need_approval ? false : true,
244
				'link_user_id'		=> (int)$user->data['user_id'],
245
			);
246
247
			$data_add = array_merge($data_edit, $data_add);
248
249
			$link->add($data_add, $u);
250
251
			// We check notification for this categorie
252
			if ($config['email_enable'] && !$need_approval)
253
			{
254
				$data_add['cat_name'] = $categorie->data['cat_name'];
255
				$link->notify_member($data_add);
256
			}
257
		}
258
259
		$meta_info = append_sid("{$directory_root_path}directory.$phpEx", "mode=cat&amp;id=$id");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
260
		meta_refresh(3, $meta_info);
261
		$message	= ($need_approval) ? $user->lang['DIR_'.strtoupper($mode).'_SITE_ACTIVE'] : $user->lang['DIR_'.strtoupper($mode).'_SITE_OK'];
262
		$message	= $message . "<br /><br />" . sprintf($user->lang['DIR_CLICK_RETURN_DIR'], '<a href="' . append_sid("{$directory_root_path}directory.$phpEx") . '">', '</a>') . '<br /><br />' . sprintf($user->lang['DIR_CLICK_RETURN_CAT'], '<a href="' . append_sid("{$directory_root_path}directory.$phpEx", "mode=cat&amp;id=$id") . '">', '</a>');
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal <br /><br /> does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
263
		trigger_error($message);
264
265
	}
266
	else
267
	{
268
		if($mode == 'edit')
269
		{
270
			$s_hidden_fields = array(
271
				'old_cat_id'	=> request_var('old_cat_id', 0),
272
				'old_banner'	=> request_var('old_banner', '')
273
			);
274
		}
275
276
		$template->assign_vars( array(
277
			'ERROR'	=> (isset($error)) ? implode('<br />', $error) : ''
278
		));
279
	}
280
}
281
282
// We subscribe or unsubscribe
283
if ($mode == 'notification')
284
{
285
	if ($user->data['is_registered'])
286
	{
287
		if (request_var('notif', 0))
288
		{
289
			$data = array(
290
				'n_user_id' => (int)$user->data['user_id'],
291
				'n_cat_id' 	=> (int)$id,
292
			);
293
294
			$sql = 'INSERT INTO ' . DIR_NOTIFICATION_TABLE . ' ' . $db->sql_build_array('INSERT', $data);
295
			$db->sql_query($sql);
296
		}
297
		else
298
		{
299
			$sql = 'DELETE FROM ' . DIR_NOTIFICATION_TABLE . '
300
						WHERE n_user_id = ' . (int)$user->data['user_id'] . '
301
							AND n_cat_id = ' . (int)$id;
302
			$db->sql_query($sql);
303
		}
304
	}
305
	redirect(append_sid("{$directory_root_path}directory.$phpEx", "mode=cat&id=$id"));
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
306
}
307
else if (($mode == 'new' || $mode == 'edit'))
308
{
309
	if ($mode == 'new' && !$auth->acl_get('u_submit_dir'))
310
	{
311
		trigger_error('DIR_ERROR_NOT_AUTH');
312
	}
313
314
	if ($mode == 'edit')
315
	{
316
		$sql = 'SELECT link_user_id FROM ' . DIR_LINK_TABLE . ' WHERE link_id = ' . (int)$u;
317
		$result = $db->sql_query($sql);
318
		$link_data = $db->sql_fetchrow($result);
319
320
		$edit_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_edit_dir') || ($user->data['user_id'] == $link_data['link_user_id'] && $auth->acl_get('u_edit_dir'))));
321
322
		if (!$edit_allowed)
323
		{
324
			trigger_error('DIR_ERROR_NOT_AUTH');
325
		}
326
	}
327
328
	$title = ($mode == 'edit') ? $user->lang['DIR_EDIT_SITE'] : $user->lang['DIR_NEW_SITE'];
329
	add_form_key('dir_form');
330
331
	$template->assign_block_vars('navlinks', array(
332
		'FORUM_NAME'	=> $title,
333
		'U_VIEW_FORUM'	=> append_sid("{$directory_root_path}directory.$phpEx"))
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
334
	);
335
336
	if (!$submit && ($mode == 'edit'))
337
	{
338
		$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 FROM ' . DIR_LINK_TABLE . '
339
				WHERE link_id = ' . (int)$u;
340
		$result = $db->sql_query($sql);
341
342
		$site = $db->sql_fetchrow($result);
343
344
		if (empty($site['link_id']))
345
		{
346
			trigger_error('DIR_ERROR_NO_LINKS');
347
		}
348
349
		$s_hidden_fields = array(
350
			'old_cat_id'	=> $site['link_cat'],
351
			'old_banner'	=> $site['link_banner'],
352
		);
353
354
		$description = generate_text_for_edit($site['link_description'], $site['link_uid'], $site['link_flags']);
355
		$site['link_banner'] = (preg_match('/^(http:\/\/|https:\/\/|ftp:\/\/|ftps:\/\/|www\.).+/si', $site['link_banner'])) ? $site['link_banner'] : '';
356
357
		$url			= $site['link_url'];
358
		$site_name		= $site['link_name'];
359
		$description	= $description['text'];
360
		$guest_email	= $site['link_guest_email'];
361
		$rss			= $site['link_rss'];
362
		$banner 		= $site['link_banner'];
363
		$back			= $site['link_back'];
364
		$flag 			= $site['link_flag'];
365
		$id				= $site['link_cat'];
366
	}
367
368
	if (!$user->data['is_registered'] && $config['dir_visual_confirm'] && $mode == 'new')
369
	{
370
		$s_hidden_fields = array_merge($s_hidden_fields, $captcha->get_hidden_fields());
371
372
		$user->add_lang('ucp');
373
374
		$template->assign_vars(array(
375
			'CAPTCHA_TEMPLATE'		=> $captcha->get_template(),
376
		));
377
	}
378
379
	// We get config for display options
380
	$bbcode_status	= ($config['dir_allow_bbcode'] || $auth->acl_get('a_')) ? true : false;
381
	$smilies_status	= ($bbcode_status && $config['dir_allow_smilies'] || $auth->acl_get('a_')) ? true : false;
382
	$img_status		= ($bbcode_status || $auth->acl_get('a_')) ? true : false;
383
	$url_status		= ($config['dir_allow_links']) ? true : false;
384
385
	$s_guest	= (!$user->data['is_registered'] || !empty($guest_email));
386
	$s_rss		= $config['dir_activ_rss'];
387
	$s_banner	= $config['dir_activ_banner'];
388
	$s_back		= $categorie->data['cat_link_back'];
389
	$s_flag		= $config['dir_activ_flag'];
390
391
	$template->set_filenames(array('body' => 'mods/directory/add_site.html'));
392
	$user->add_lang('posting');
393
	display_custom_bbcodes();
394
395
	$flag_path	= $phpbb_root_path.'images/directory/flags/';
396
	$flag		= isset($flag) ? $flag : '';
397
398
	$template->assign_vars( array(
399
		'BBCODE_STATUS'			=> ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid($phpbb_root_path."faq.$phpEx", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid($phpbb_root_path."faq.$phpEx", 'mode=bbcode') . '">', '</a>'),
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
400
		'IMG_STATUS'			=> ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
401
		'SMILIES_STATUS'		=> ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
402
		'URL_STATUS'			=> ($bbcode_status && $url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'],
403
404
		'L_TITLE'				=> $title,
405
		'L_DIR_DESCRIPTION_EXP'	=> sprintf($user->lang['DIR_DESCRIPTION_EXP'], $config['dir_length_describe']),
406
		'L_DIR_SUBMIT_TYPE'		=> dir_submit_type($categorie->data['cat_validate']),
407
		'L_DIR_SITE_BANN_EXP'	=> sprintf($user->lang['DIR_SITE_BANN_EXP'], $config['dir_banner_width'], $config['dir_banner_height']),
408
409
		'S_GUEST'				=> $s_guest ? true : false,
410
		'S_RSS'					=> $s_rss ? true : false,
411
		'S_BANNER'				=> $s_banner ? true : false,
412
		'S_BACK'				=> $s_back ? true : false,
413
		'S_FLAG'				=> $s_flag ? true : false,
414
		'S_BBCODE_ALLOWED' 		=> (bool)$bbcode_status,
415
416
		'DIR_FLAG_PATH'			=> $flag_path,
417
		'DIR_FLAG_IMAGE'		=> $flag ? $flag_path . $flag : $phpbb_root_path . 'images/spacer.gif',
418
419
		'EDIT_MODE'				=> ($mode == 'edit') ? true : false,
420
421
		'SITE_NAME'				=> isset($site_name) ? $site_name : '',
422
		'SITE_URL'				=> isset($url) ? $url : '',
423
		'DESCRIPTION'			=> isset($description) ? $description : '',
424
		'GUEST_EMAIL'			=> isset($guest_email) ? $guest_email : '',
425
		'RSS'					=> isset($rss) ? $rss : '',
426
		'BANNER'				=> isset($banner) ? $banner : '',
427
		'BACK'					=> isset($back) ? $back : '',
428
		'S_POST_ACTION'			=> build_url(),
429
		'S_CATLIST'				=> $categorie->make_cat_select($id),
430
		'S_LIST_FLAG'			=> get_dir_flag_list($flag),
431
		'S_DESC_STAR'			=> (@$categorie->data['cat_must_describe']) ? '*' : '',
432
		'S_ROOT'				=> $id,
433
		'S_HIDDEN_FIELDS'		=> build_hidden_fields($s_hidden_fields),
434
435
		'U_SOMMAIRE'			=> append_sid("{$directory_root_path}directory.$phpEx"),
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
436
	));
437
}
438
else if ($mode == 'cat')
439
{
440
	if (!$id)
441
	{
442
		send_status_line(404, 'Not Found');
443
444
		redirect('directory.'.$phpEx);
445
	}
446
447
	$link_list = array();
448
	$sort_days	= request_var('st', 0);
449
	$sort_key	= request_var('sk', (string)substr($config['dir_default_order'], 0, 1));
450
	$sort_dir	= request_var('sd', (string)substr($config['dir_default_order'], 2));
451
452
	// We gete notification status
453
454
	$data = array(
455
		'n_user_id' 	=> (int)$user->data['user_id'],
456
		'n_cat_id' 	=> (int)$id,
457
	);
458
459
	$sql = 'SELECT n_user_id FROM ' . DIR_NOTIFICATION_TABLE . ' WHERE ' . $db->sql_build_array('SELECT', $data);
460
	$result = $db->sql_query($sql);
461
	$cat = $db->sql_fetchrow($result);
462
463
	// Categorie ordering options
464
	$limit_days		= array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
465
	$sort_by_text	= array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['DIR_COMMENTS_ORDER'], 's' =>  $user->lang['DIR_NAME_ORDER'], 'v' => $user->lang['DIR_NB_CLICS_ORDER'], 'p' => $user->lang['DIR_PR_ORDER']);
466
	$sort_by_sql	= array('a' => 'u.username', 't' => 'l.link_time', 'r' => 'l.link_comment', 's' => 'l.link_name', 'v' => 'l.link_view', 'p' => 'l.link_pagerank');
467
468
	$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
469
	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);
470
471
	$u_sort_param = ($sort_days === 0 && $sort_key == (string)substr($config['dir_default_order'], 0, 1) && $sort_dir == (string)substr($config['dir_default_order'], 2)) ? '' : '&amp;'.$u_sort_param;
472
473
	// A deadline has been selected
474
	if ($sort_days)
475
	{
476
		$min_post_time = time() - ($sort_days * 86400);
477
478
		$sql = 'SELECT COUNT(link_id) AS nb_links
479
			FROM ' . DIR_LINK_TABLE . '
480
			WHERE link_cat = ' . (int)$id . '
481
				AND link_time >= ' . $min_post_time;
482
		$result = $db->sql_query($sql);
483
		$nb_links = (int) $db->sql_fetchfield('nb_links');
484
		$db->sql_freeresult($result);
485
486
		if (isset($_POST['sort']))
487
		{
488
			$start = 0;
489
		}
490
		$sql_limit_time = " AND l.link_time >= $min_post_time";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $min_post_time instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
491
	}
492
	else
493
	{
494
		$sql_limit_time = '';
495
		$nb_links		= $categorie->data['cat_links'];
496
	}
497
498
	// Make sure $start is set to the last page if it exceeds the amount
499 View Code Duplication
	if ($start < 0 || $start > $nb_links)
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
500
	{
501
		$start = ($start < 0) ? 0 : floor(($nb_links - 1) / $config['dir_show']) * $config['dir_show'];
502
	}
503
504
	$categorie->display();
505
506
	$title .= ' - ' . $categorie->data['cat_name'];
507
508
	// Build navigation links
509
	generate_dir_nav($categorie->data);
510
511
	$template->assign_vars(array(
512
		'L_DIR_CAT_NAME'		=> $user->lang['DIR_CAT_NAME'] . ': ' . $categorie->data['cat_name'],
513
		'L_DIR_NOTIFICATION'	=> (($cat['n_user_id']) ? $user->lang['DIR_BE_NOT_NOTIFIED'] : $user->lang['DIR_BE_NOTIFIED']),
514
515
		'U_PAGE'				=> append_sid("{$directory_root_path}directory.$phpEx", "mode=cat&amp;id=$id{$u_sort_param}", true),
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $u_sort_param instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
516
		'U_ORDER'				=> append_sid("{$directory_root_path}directory.$phpEx", array('mode' => 'cat', 'id' => $id, 'cat' => $cat), true),
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
517
		'U_NOTIFICATION'		=> append_sid("{$directory_root_path}directory.$phpEx", array('mode' => 'notification', 'id' => $id, 'notif' => ($cat['n_user_id']) ? 0 : 1), true),
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
518
519
		'S_ACTION'				=> append_sid("{$directory_root_path}directory.$phpEx", "mode=cat&amp;id=$id&amp;start=$start", true),
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $start instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
520
		'S_SELECT_SORT_DIR'		=> $s_sort_dir,
521
		'S_SELECT_SORT_KEY'		=> $s_sort_key,
522
		'S_SELECT_SORT_DAYS'	=> $s_limit_days,
523
		'S_CATLIST'				=> $categorie->make_cat_select($id),
524
		'S_JUMPBOX_ACTION'		=> append_sid("{$directory_root_path}directory.$phpEx"),
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
525
526
		'S_CAT_ID'				=> $id,
527
		'S_NOTIFICATION'		=> ($config['email_enable'] && $user->data['is_registered']) ? true : false,
528
529
		'PAGE_NUMBER'			=> on_page($nb_links, $config['dir_show'], $start),
530
		'PAGINATION'			=> generate_pagination(append_sid("{$directory_root_path}directory.$phpEx", "mode=cat&amp;id=$id{$u_sort_param}", true), $nb_links, $config['dir_show'], $start),
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $u_sort_param instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
531
		'TOTAL_LINKS'			=> (($nb_links > 1) ? sprintf($user->lang['DIR_NB_LINKS'], $nb_links) : sprintf($user->lang['DIR_NB_LINK'], $nb_links)),
532
	));
533
534
	// If the user is trying to reach late pages, start searching from the end
535
	$store_reverse = false;
536
	$sql_limit = $config['dir_show'];
537
	if ($start > $nb_links / 2)
538
	{
539
		$store_reverse = true;
540
541
		if ($start + $config['dir_show'] > $nb_links)
542
		{
543
			$sql_limit = min($config['dir_show'], max(1, $nb_links - $start));
544
		}
545
546
		// Select the sort order
547
		$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');
548
		$sql_start		= max(0, $nb_links - $sql_limit - $start);
549
	}
550
	else
551
	{
552
		// Select the sort order
553
		$sql_sort_order	= $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
554
		$sql_start		= $start;
555
	}
556
557
	// Grab just the sorted link ids
558
	$sql_array = array(
559
		'SELECT'	=> 'l.link_id',
560
		'FROM'		=> array(
561
				DIR_LINK_TABLE	=> 'l'),
562
		'LEFT_JOIN'	=> array(
563
				array(
564
					'FROM'	=> array(USERS_TABLE	=> 'u'),
565
					'ON'	=> 'l.link_user_id = u.user_id'
566
				),
567
		),
568
		'WHERE'		=> "l.link_cat = $id
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $sql_limit_time instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
569
			AND l.link_active = 1
570
				$sql_limit_time",
571
		'ORDER_BY'	=> $sql_sort_order);
572
573
	$sql = $db->sql_build_query('SELECT', $sql_array);
574
	$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
575
576
	while ($row = $db->sql_fetchrow($result))
577
	{
578
		$link_list[] = (int) $row['link_id'];
579
	}
580
	$db->sql_freeresult($result);
581
582
	if (sizeof($link_list))
583
	{
584
		/*
585
		** We get links, informations about poster, votes and number of comments
586
		*/
587
		$sql_array = array(
588
			'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',
589
			'FROM'		=> array(
590
					DIR_LINK_TABLE	=> 'l'),
591
			'LEFT_JOIN'	=> array(
592
					array(
593
						'FROM'	=> array(USERS_TABLE	=> 'u'),
594
						'ON'	=> 'l.link_user_id = u.user_id'
595
					),
596
					array(
597
						'FROM'	=> array(DIR_VOTE_TABLE => 'v'),
598
						'ON'	=> 'l.link_id = v.vote_link_id AND v.vote_user_id = ' . $user->data['user_id']
599
					)
600
			),
601
			'WHERE'		=> $db->sql_in_set('l.link_id', $link_list). $sql_limit_time);
602
603
		$sql = $db->sql_build_query('SELECT', $sql_array);
604
		$result = $db->sql_query($sql);
605
606
		while ($site = $db->sql_fetchrow($result))
607
		{
608
			$rowset[$site['link_id']] = $site;
609
		}
610
		$db->sql_freeresult($result);
611
612
		$link_list = ($store_reverse) ? array_reverse($link_list) : $link_list;
613
614
		$votes_status 		= ((int)$categorie->data['cat_allow_votes']) ? true : false;
615
		$comments_status 	= ((int)$categorie->data['cat_allow_comments']) ? true : false;
616
617
		foreach ($link_list as $link_id)
618
		{
619
			$site = &$rowset[$link_id];
620
621
			$s_flag		= $link->display_flag($site);
622
			$s_note		= $link->display_note($site['link_note'], $site['link_vote'], $votes_status);
623
			$s_thumb	= $link->display_thumb($site);
624
			$s_vote		= $link->display_vote($site, $votes_status);
625
			$s_comment	= $link->display_comm($site['link_id'], $site['link_comment'], $comments_status);
626
			$s_banner	= $link->display_bann($site);
627
			$s_pr		= $link->display_pagerank($site);
628
			$s_rss		= $site['link_rss'];
629
630
			$edit_allowed 	= ($user->data['is_registered'] && ($auth->acl_get('m_edit_dir') || ($user->data['user_id'] == $site['link_user_id'] && $auth->acl_get('u_edit_dir'))));
631
			$delete_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_delete_dir') || ($user->data['user_id'] == $site['link_user_id'] && $auth->acl_get('u_delete_dir'))));
632
633
			$template->assign_block_vars('site', array(
634
				'LINK_ID'		=> $site['link_id'],
635
				'USER'			=> get_username_string('full', $site['link_user_id'], $site['username'], $site['user_colour']),
636
				'DESCRIPTION' 	=> generate_text_for_display($site['link_description'], $site['link_uid'], $site['link_bitfield'], $site['link_flags']),
637
				'THUMB'			=> '<img src="'.$s_thumb.'" alt="'.$user->lang['DIR_THUMB'].'" title="'.$site['link_name'].'"/>',
638
				'NOTE'			=> $s_note,
639
				'NB_VOTE'		=> ($site['link_vote'] > 1) ? $user->lang('DIR_NB_VOTES', $site['link_vote'])  : sprintf($user->lang['DIR_NB_VOTE'], $site['link_vote']),
640
				'VOTE'			=> $s_vote,
641
				'PAGERANK'		=> $s_pr,
642
				'COMMENT'		=> $s_comment,
643
				'BANNER'		=> $s_banner,
644
				'RSS'			=> $s_rss,
645
				'COUNT'			=> ($site['link_view'] > 1) ? sprintf($user->lang['DIR_NB_CLICS'], $site['link_view']) : sprintf($user->lang['DIR_NB_CLIC'], $site['link_view']),
646
				'TIME'			=> ($site['link_time']) ? $user->format_date($site['link_time']) : '',
647
				'NAME'			=> $site['link_name'],
648
649
				'S_NEW_LINK'	=> (((time() - $site['link_time']) / 86400) <= $config['dir_new_time']) ? true : false,
650
				'S_HAVE_FLAG'	=> $config['dir_activ_flag'] ? true : false,
651
652
				'IMG_FLAG'		=> $s_flag,
653
				'ON_CLICK' 		=> "onclick=\"window.open('".append_sid($directory_root_path.'directory.'.$phpEx, array('mode' => 'view_url', 'u' => $site['link_id']))."');return false;\"",
654
655
				'U_LINK'	=> $site['link_url'],
656
				'U_EDIT'	=> ($edit_allowed) ? append_sid("{$directory_root_path}directory.$phpEx", "mode=edit&amp;id=$id&amp;u=" . $site['link_id'], true) : '',
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
657
				'U_DELETE'	=> ($delete_allowed) ? append_sid("{$directory_root_path}directory.$phpEx", "mode=delete&amp;id=$id&amp;u=" . $site['link_id'], true) : '',
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $directory_root_path instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $phpEx instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
658
			));
659
		}
660
661
		// Links back verification is on, we do a checkup
662
		if ($categorie->data['cat_cron_enable'] && $categorie->data['cat_cron_next'] < time())
663
		{
664
			$template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=prune_directory&amp;cat=' . $id) . '" alt="cron" width="1" height="1" />');
665
		}
666
	}
667
	else
668
	{
669
		$template->assign_block_vars('no_draw_link', array());
670
	}
671
}
672
else if ($mode == 'view_url')
673
{
674
	$link->view($u);
675
}
676
else
677
{
678
	$categorie->display();
679
	recent_links();
680
}
681
682
page_header($title, false);
683
684
$template->assign_var('DIRECTORY_TRANSLATION_INFO', (!empty($user->lang['DIRECTORY_TRANSLATION_INFO'])) ? $user->lang['DIRECTORY_TRANSLATION_INFO'] : '');
685
686
page_footer(false);
687
688
?>