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

function updateUrlAggregates($url_id, $measurement_id)
{
	# updating latest values for the URL
	$query = sprintf("UPDATE urls set pagespeed_last_id = %d, last_update = now() WHERE id = %d",
		mysql_real_escape_string($measurement_id),
		mysql_real_escape_string($url_id)
	);
	$result = mysql_query($query);

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

if (array_key_exists('v', $_GET) && array_key_exists('u', $_GET)
	&& array_key_exists('w', $_GET) && filter_var($_GET['w'], FILTER_VALIDATE_INT) !== false
	&& array_key_exists('o', $_GET) && filter_var($_GET['o'], FILTER_VALIDATE_FLOAT) !== false
	&& array_key_exists('l', $_GET) && filter_var($_GET['l'], FILTER_VALIDATE_INT) !== false
	&& array_key_exists('r', $_GET) && filter_var($_GET['r'], FILTER_VALIDATE_INT) !== false
	&& array_key_exists('t', $_GET) && filter_var($_GET['t'], FILTER_VALIDATE_INT) !== false
	)
{
	$url_id = getUrlId($_GET['u']);

	if ($_GET['v'] >= 1.6) {
		$scaleimgs = $_GET['pSpecifyImageDimensions'];
		$imgdims = $_GET['pSpecifyImageDimensions'];
	} else {
		$scaleimgs = $_GET['pScaleImgs'];
		$imgdims = $_GET['pImgDims'];
	}

	# adding new entry
	$query = sprintf("INSERT INTO pagespeed (
		`ip` , `user_agent` , `url_id` ,
		`w` , `o` , `l`, `r` , `t`, `v` ,
		pMinifyJS,
		pOptImgs,
		pImgDims,
		pCombineJS,
		pCombineCSS,
		pBrowserCache,
		pProxyCache,
		pNoCookie,<commit_msg>Using PHP's own version_compare - hope it'll do better job at comparing versions even if it's not perfrect itself.<commit_after><?php 
require_once(dirname(dirname(dirname(__FILE__))).'/global.php');

function updateUrlAggregates($url_id, $measurement_id)
{
	# updating latest values for the URL
	$query = sprintf("UPDATE urls set pagespeed_last_id = %d, last_update = now() WHERE id = %d",
		mysql_real_escape_string($measurement_id),
		mysql_real_escape_string($url_id)
	);
	$result = mysql_query($query);

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

if (array_key_exists('v', $_GET) && array_key_exists('u', $_GET)
	&& array_key_exists('w', $_GET) && filter_var($_GET['w'], FILTER_VALIDATE_INT) !== false
	&& array_key_exists('o', $_GET) && filter_var($_GET['o'], FILTER_VALIDATE_FLOAT) !== false
	&& array_key_exists('l', $_GET) && filter_var($_GET['l'], FILTER_VALIDATE_INT) !== false
	&& array_key_exists('r', $_GET) && filter_var($_GET['r'], FILTER_VALIDATE_INT) !== false
	&& array_key_exists('t', $_GET) && filter_var($_GET['t'], FILTER_VALIDATE_INT) !== false
	)
{
	$url_id = getUrlId($_GET['u']);

	if (version_compare($_GET['v'], '1.6', '>=')) {
		$scaleimgs = $_GET['pSpecifyImageDimensions'];
		$imgdims = $_GET['pSpecifyImageDimensions'];
	} else {
		$scaleimgs = $_GET['pScaleImgs'];
		$imgdims = $_GET['pImgDims'];
	}

	# adding new entry
	$query = sprintf("INSERT INTO pagespeed (
		`ip` , `user_agent` , `url_id` ,
		`w` , `o` , `l`, `r` , `t`, `v` ,
		pMinifyJS,
		pOptImgs,
		pImgDims,
		pCombineJS,
		pCombineCSS,
		pBrowserCache,
		pProxyCache,
		pNoCookie,
{'fraction_non_alphanumeric': 0.19155206286836934, 'fraction_numerical': 0.0013097576948264572, 'mean_word_length': 6.022988505747127, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1521684', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1181, 'n_words': 210}