Code Duplication    Length = 22-25 lines in 5 locations

Sources/ManageBans.php 1 location

@@ 294-318 (lines=25) @@
291
 * @param string $sort A string telling ORDER BY how to sort the results
292
 * @return array An array of information about the bans for the list
293
 */
294
function list_getBans($start, $items_per_page, $sort)
295
{
296
	global $smcFunc;
297
298
	$request = $smcFunc['db_query']('', '
299
		SELECT bg.id_ban_group, bg.name, bg.ban_time, bg.expire_time, bg.reason, bg.notes, COUNT(bi.id_ban) AS num_triggers
300
		FROM {db_prefix}ban_groups AS bg
301
			LEFT JOIN {db_prefix}ban_items AS bi ON (bi.id_ban_group = bg.id_ban_group)
302
		GROUP BY bg.id_ban_group, bg.name, bg.ban_time, bg.expire_time, bg.reason, bg.notes
303
		ORDER BY {raw:sort}
304
		LIMIT {int:offset}, {int:limit}',
305
		array(
306
			'sort' => $sort,
307
			'offset' => $start,
308
			'limit' => $items_per_page,
309
		)
310
	);
311
	$bans = array();
312
	while ($row = $smcFunc['db_fetch_assoc']($request))
313
		$bans[] = $row;
314
315
	$smcFunc['db_free_result']($request);
316
317
	return $bans;
318
}
319
320
/**
321
 * Get the total number of ban from the ban group table

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

@@ 1561-1582 (lines=22) @@
1558
 * @param string $sort A string indicating how to sort the results
1559
 * @return array An array of holidays, each of which is an array containing the id, year, month, day and title of the holiday
1560
 */
1561
function list_getHolidays($start, $items_per_page, $sort)
1562
{
1563
	global $smcFunc;
1564
1565
	$request = $smcFunc['db_query']('', '
1566
		SELECT id_holiday, YEAR(event_date) AS year, MONTH(event_date) AS month, DAYOFMONTH(event_date) AS day, title
1567
		FROM {db_prefix}calendar_holidays
1568
		ORDER BY {raw:sort}
1569
		LIMIT {int:start}, {int:max}',
1570
		array(
1571
			'sort' => $sort,
1572
			'start' => $start,
1573
			'max' => $items_per_page,
1574
		)
1575
	);
1576
	$holidays = array();
1577
	while ($row = $smcFunc['db_fetch_assoc']($request))
1578
		$holidays[] = $row;
1579
	$smcFunc['db_free_result']($request);
1580
1581
	return $holidays;
1582
}
1583
1584
/**
1585
 * Helper function to get the total number of holidays