Code Duplication    Length = 22-25 lines in 5 locations

Sources/ManageSearchEngines.php 3 locations

@@ 333-354 (lines=22) @@
330
 * @param string $sort A string indicating how to sort the results
331
 * @return array An array of information about known spiders
332
 */
333
function list_getSpiders($start, $items_per_page, $sort)
334
{
335
	global $smcFunc;
336
337
	$request = $smcFunc['db_query']('', '
338
		SELECT id_spider, spider_name, user_agent, ip_info
339
		FROM {db_prefix}spiders
340
		ORDER BY {raw:sort}
341
		LIMIT {int:start}, {int:items}',
342
		array(
343
			'sort' => $sort,
344
			'start' => $start,
345
			'items' => $items_per_page,
346
		)
347
	);
348
	$spiders = array();
349
	while ($row = $smcFunc['db_fetch_assoc']($request))
350
		$spiders[$row['id_spider']] = $row;
351
	$smcFunc['db_free_result']($request);
352
353
	return $spiders;
354
}
355
356
/**
357
 * Callback function for createList()
@@ 822-844 (lines=23) @@
819
 * @param string $sort A string indicating how to sort the results
820
 * @return array An array of spider log data
821
 */
822
function list_getSpiderLogs($start, $items_per_page, $sort)
823
{
824
	global $smcFunc;
825
826
	$request = $smcFunc['db_query']('', '
827
		SELECT sl.id_spider, sl.url, sl.log_time, s.spider_name
828
		FROM {db_prefix}log_spider_hits AS sl
829
			INNER JOIN {db_prefix}spiders AS s ON (s.id_spider = sl.id_spider)
830
		ORDER BY {raw:sort}
831
		LIMIT {int:start}, {int:items}',
832
		array(
833
			'sort' => $sort,
834
			'start' => $start,
835
			'items' => $items_per_page,
836
		)
837
	);
838
	$spider_logs = array();
839
	while ($row = $smcFunc['db_fetch_assoc']($request))
840
		$spider_logs[] = $row;
841
	$smcFunc['db_free_result']($request);
842
843
	return $spider_logs;
844
}
845
846
/**
847
 * Callback function for createList()
@@ 1049-1071 (lines=23) @@
1046
 * @param string $sort A string indicating how to sort the results
1047
 * @return array An array of spider statistics info
1048
 */
1049
function list_getSpiderStats($start, $items_per_page, $sort)
1050
{
1051
	global $smcFunc;
1052
1053
	$request = $smcFunc['db_query']('', '
1054
		SELECT ss.id_spider, ss.stat_date, ss.page_hits, s.spider_name
1055
		FROM {db_prefix}log_spider_stats AS ss
1056
			INNER JOIN {db_prefix}spiders AS s ON (s.id_spider = ss.id_spider)
1057
		ORDER BY {raw:sort}
1058
		LIMIT {int:start}, {int:items}',
1059
		array(
1060
			'sort' => $sort,
1061
			'start' => $start,
1062
			'items' => $items_per_page,
1063
		)
1064
	);
1065
	$spider_stats = array();
1066
	while ($row = $smcFunc['db_fetch_assoc']($request))
1067
		$spider_stats[] = $row;
1068
	$smcFunc['db_free_result']($request);
1069
1070
	return $spider_stats;
1071
}
1072
1073
/**
1074
 * Callback function for createList()

Sources/Subs-Calendar.php 1 location

@@ 1689-1710 (lines=22) @@
1686
 * @param string $sort A string indicating how to sort the results
1687
 * @return array An array of holidays, each of which is an array containing the id, year, month, day and title of the holiday
1688
 */
1689
function list_getHolidays($start, $items_per_page, $sort)
1690
{
1691
	global $smcFunc;
1692
1693
	$request = $smcFunc['db_query']('', '
1694
		SELECT id_holiday, YEAR(event_date) AS year, MONTH(event_date) AS month, DAYOFMONTH(event_date) AS day, title
1695
		FROM {db_prefix}calendar_holidays
1696
		ORDER BY {raw:sort}
1697
		LIMIT {int:start}, {int:max}',
1698
		array(
1699
			'sort' => $sort,
1700
			'start' => $start,
1701
			'max' => $items_per_page,
1702
		)
1703
	);
1704
	$holidays = array();
1705
	while ($row = $smcFunc['db_fetch_assoc']($request))
1706
		$holidays[] = $row;
1707
	$smcFunc['db_free_result']($request);
1708
1709
	return $holidays;
1710
}
1711
1712
/**
1713
 * Helper function to get the total number of holidays

Sources/ManageBans.php 1 location

@@ 309-333 (lines=25) @@
306
 * @param string $sort A string telling ORDER BY how to sort the results
307
 * @return array An array of information about the bans for the list
308
 */
309
function list_getBans($start, $items_per_page, $sort)
310
{
311
	global $smcFunc;
312
313
	$request = $smcFunc['db_query']('', '
314
		SELECT bg.id_ban_group, bg.name, bg.ban_time, bg.expire_time, bg.reason, bg.notes, COUNT(bi.id_ban) AS num_triggers
315
		FROM {db_prefix}ban_groups AS bg
316
			LEFT JOIN {db_prefix}ban_items AS bi ON (bi.id_ban_group = bg.id_ban_group)
317
		GROUP BY bg.id_ban_group, bg.name, bg.ban_time, bg.expire_time, bg.reason, bg.notes
318
		ORDER BY {raw:sort}
319
		LIMIT {int:offset}, {int:limit}',
320
		array(
321
			'sort' => $sort,
322
			'offset' => $start,
323
			'limit' => $items_per_page,
324
		)
325
	);
326
	$bans = array();
327
	while ($row = $smcFunc['db_fetch_assoc']($request))
328
		$bans[] = $row;
329
330
	$smcFunc['db_free_result']($request);
331
332
	return $bans;
333
}
334
335
/**
336
 * Get the total number of ban from the ban group table