<commit_before><?php
require_once(dirname(__FILE__).'/global.php');
require_once(dirname(__FILE__).'/users/users.php');
require_once(dirname(__FILE__).'/paginator.class.php');

$TITLE = 'URLs measured';
$SECTION = 'all';
require_once(dirname(__FILE__).'/header.php');
?>
<style>
.current {
	text-decoration: none;
	font-weight: bold;
	color: black;
}
</style>
<h1>URLs measured</h1>
<?php
$searchstring = null;
if (array_key_exists('search', $_GET)) {
	$searchstring = "urls.url LIKE '%".mysql_real_escape_string(trim($_GET['search']))."%'";
}

$current_group = array_key_exists('group', $_GET) ? $_GET['group'] : null;

$subset = null;

if (is_array($URLGroups) && count($URLGroups) > 0) {
?>
<ul>
<?php 
	if (is_null($current_group)) {
?>
<li><b>All URLs</b></li>
<?php
	} else {
?>
<li><a href="<?php echo $showslow_base.'all.php'.(is_null($searchstring) ? '' : '?search='.urlencode(trim($_GET['search'])))?>">All URLs</a></li>
<?php
	}

	foreach ($URLGroups as $id => $group) {
		if ($current_group == $id) {
			$subset = $group['urls'];
			?><li><b><?php echo $group['title']?></b></li><?php
		} else {
			?><li><a href="<?php echo $showslow_base.'all.php?'.(is_null($searchstring) ? '' : 'search='.urlencode(trim($_GET['search'])).'&').'group='.$id; ?>"><?php echo $group['title']?></a></li><?php
		}
	}
?></ul>
<hr size="1">
<?php
}
?>
<style>
.paginator {
	padding: 1em;
}

.paginator .paginate {
	padding: 2px 6px;
	border: 1px solid silver;
	text-decoration: none;
}

.paginator .current {
	padding: 2px 6px;
	border: 2px solid #7F6F26;
	background: #7F6F26;
	color: white;
}

.paginator .inactive {
	color: silver;
	padding: 2px 6px;
}
</style>
<div style="width: 100%; overflow: hidden">
<?php
$perPage = 50;
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
if ($page < 1) {
	$page = 1;
}
$offset = ($page - 1) * $perPage;

$subsetstring = null;
$first = true;
if (is_array($subset)) {
	foreach ($subset as $url) {
		if ($first) {
			$first = false;
		} else {
			$subsetstring .= ' OR ';
		}
		$subsetstring .= "urls.url LIKE '".mysql_real_escape_string($url)."%'";
	}
}

$query = "SELECT count(*)
	FROM urls
		LEFT JOIN yslow2 ON urls.yslow2_last_id = yslow2.id
		LEFT JOIN pagespeed ON urls.pagespeed_last_id = pagespeed.id
		LEFT JOIN dynatrace ON urls.dynatrace_last_id = dynatrace.id
	WHERE last_update IS NOT NULL";

if (!is_null($subsetstring)) {
	$query .= " AND ($subsetstring)";
}

if (!is_null($searchstring)) {
	$query .= " AND $searchstring";
}

$result = mysql_query($query);
$row = mysql_fetch_row($result);
$total = $row[0];

$pages = new Paginator();
$pages->items_total = $total;
$pages->mid_range = 7;
$pages->items_per_page = $perPage;

$query = 'SELECT url, last_update,
		yslow2.o as o,
		pagespeed.o as ps_o,
		dynatrace.rank as dt_o
	FROM urls
		LEFT JOIN yslow2 ON urls.yslow2_last_id = yslow2.id
		LEFT JOIN pagespeed ON urls.pagespeed_last_id = pagespeed.id
		LEFT JOIN dynatrace ON urls.dynatrace_last_id = dynatrace.id
	WHERE last_update IS NOT NULL';

if (!is_null($subsetstring)) {
	$query .= " AND ($subsetstring)";
}
if (!is_null($searchstring)) {
	$query .= " AND $searchstring";
}

$query .= sprintf(" ORDER BY url LIMIT %d OFFSET %d", $perPage, $offset);

$result = mysql_query($query);

if (!$result) {
	error_log(mysql_error());
}

$yslow = false;
$pagespeed = false;
$dynatrace = false;

$rows = array();
while ($row = mysql_fetch_assoc($result)) {
	$rows[] = $row;

	if (!$yslow && !is_null($row['o'])) {
		$yslow = true;
	}
	if (!$pagespeed && !is_null($row['ps_o'])) {
		$pagespeed = true;
	}
	if (!$dynatrace && !is_null($row['dt_o'])) {
		$dynatrace = true;
	}
}
?>
<form action="" method="GET">
Search URLs: <input type="text" size="80" name="search" value="<?php echo is_null($searchstring) ? '' : htmlentities(trim($_GET['search']))?>"/> <input type="submit" value="search"/> <?php if (!is_null($subset)) {?><input type="hidden" name="group" value="<?php echo htmlentities($_GET['group']) ?>"/><?php } ?>
</form>
<hr size="1">
<?php
if ($yslow || $pagespeed || $dynatrace) {
?>
<div class="paginator">
<?php
	$pages->paginate($showslow_base.'all.php');
	echo $pages->display_pages();
?>
</div>
<table>
<tr><th>Timestamp</th><commit_msg>Added clear search button. Added condition to search only on non-empty strings.<commit_after><?php
require_once(dirname(__FILE__).'/global.php');
require_once(dirname(__FILE__).'/users/users.php');
require_once(dirname(__FILE__).'/paginator.class.php');

$TITLE = 'URLs measured';
$SECTION = 'all';
require_once(dirname(__FILE__).'/header.php');
?>
<style>
.current {
	text-decoration: none;
	font-weight: bold;
	color: black;
}
</style>
<h1>URLs measured</h1>
<?php
$searchstring = null;
if (array_key_exists('search', $_GET) && trim($_GET['search']) != '') {
	$searchstring = "urls.url LIKE '%".mysql_real_escape_string(trim($_GET['search']))."%'";
}

$current_group = array_key_exists('group', $_GET) ? $_GET['group'] : null;

$subset = null;

if (is_array($URLGroups) && count($URLGroups) > 0) {
?>
<ul>
<?php 
	if (is_null($current_group)) {
?>
<li><b>All URLs</b></li>
<?php
	} else {
?>
<li><a href="<?php echo $showslow_base.'all.php'.(is_null($searchstring) ? '' : '?search='.urlencode(trim($_GET['search'])))?>">All URLs</a></li>
<?php
	}

	foreach ($URLGroups as $id => $group) {
		if ($current_group == $id) {
			$subset = $group['urls'];
			?><li><b><?php echo $group['title']?></b></li><?php
		} else {
			?><li><a href="<?php echo $showslow_base.'all.php?'.(is_null($searchstring) ? '' : 'search='.urlencode(trim($_GET['search'])).'&').'group='.$id; ?>"><?php echo $group['title']?></a></li><?php
		}
	}
?></ul>
<hr size="1">
<?php
}
?>
<style>
.paginator {
	padding: 1em;
}

.paginator .paginate {
	padding: 2px 6px;
	border: 1px solid silver;
	text-decoration: none;
}

.paginator .current {
	padding: 2px 6px;
	border: 2px solid #7F6F26;
	background: #7F6F26;
	color: white;
}

.paginator .inactive {
	color: silver;
	padding: 2px 6px;
}
</style>
<div style="width: 100%; overflow: hidden">
<?php
$perPage = 50;
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
if ($page < 1) {
	$page = 1;
}
$offset = ($page - 1) * $perPage;

$subsetstring = null;
$first = true;
if (is_array($subset)) {
	foreach ($subset as $url) {
		if ($first) {
			$first = false;
		} else {
			$subsetstring .= ' OR ';
		}
		$subsetstring .= "urls.url LIKE '".mysql_real_escape_string($url)."%'";
	}
}

$query = "SELECT count(*)
	FROM urls
		LEFT JOIN yslow2 ON urls.yslow2_last_id = yslow2.id
		LEFT JOIN pagespeed ON urls.pagespeed_last_id = pagespeed.id
		LEFT JOIN dynatrace ON urls.dynatrace_last_id = dynatrace.id
	WHERE last_update IS NOT NULL";

if (!is_null($subsetstring)) {
	$query .= " AND ($subsetstring)";
}

if (!is_null($searchstring)) {
	$query .= " AND $searchstring";
}

$result = mysql_query($query);
$row = mysql_fetch_row($result);
$total = $row[0];

$pages = new Paginator();
$pages->items_total = $total;
$pages->mid_range = 7;
$pages->items_per_page = $perPage;

$query = 'SELECT url, last_update,
		yslow2.o as o,
		pagespeed.o as ps_o,
		dynatrace.rank as dt_o
	FROM urls
		LEFT JOIN yslow2 ON urls.yslow2_last_id = yslow2.id
		LEFT JOIN pagespeed ON urls.pagespeed_last_id = pagespeed.id
		LEFT JOIN dynatrace ON urls.dynatrace_last_id = dynatrace.id
	WHERE last_update IS NOT NULL';

if (!is_null($subsetstring)) {
	$query .= " AND ($subsetstring)";
}
if (!is_null($searchstring)) {
	$query .= " AND $searchstring";
}

$query .= sprintf(" ORDER BY url LIMIT %d OFFSET %d", $perPage, $offset);

$result = mysql_query($query);

if (!$result) {
	error_log(mysql_error());
}

$yslow = false;
$pagespeed = false;
$dynatrace = false;

$rows = array();
while ($row = mysql_fetch_assoc($result)) {
	$rows[] = $row;

	if (!$yslow && !is_null($row['o'])) {
		$yslow = true;
	}
	if (!$pagespeed && !is_null($row['ps_o'])) {
		$pagespeed = true;
	}
	if (!$dynatrace && !is_null($row['dt_o'])) {
		$dynatrace = true;
	}
}
?>
<form name="searchform" action="" method="GET">
Search URLs:
<input type="text" id="search" size="80" name="search" value="<?php echo is_null($searchstring) ? '' : htmlentities(trim($_GET['search']))?>"/>
<input type="submit" value="search"/>
<input type="button" value="clear" onclick="document.getElementById('search').value=''; document.searchform.submit()">
<?php if (!is_null($subset)) {
	?><input type="hidden" name="group" value="<?php echo htmlentities($_GET['group']) ?>"/><?php
} ?>
</form>
<hr size="1">
<?php
if ($yslow || $pagespeed || $dynatrace) {
?>
<div class="paginator">
<?php
	$pages->paginate($showslow_base.'all.php');
	echo $pages->display_pages();
?>
</div>
<table>
<tr><th>Timestamp</th>
{'fraction_non_alphanumeric': 0.21856218215441517, 'fraction_numerical': 0.009708737864077669, 'mean_word_length': 5.093661971830986, 'pattern_counts': {'":': 0, '<': 120, '<?xml version=': 0, '>': 132, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2023161', 'n_tokens_mistral': 3485, 'n_tokens_neox': 3390, 'n_words': 716}