<commit_before>#!/usr/bin/php
<?php
	ini_set('display_errors','On');
	error_reporting(E_ALL);

	chdir(dirname(__FILE__));

	include('config.inc.php');
	include('sql.inc.php');
	include('aprs.inc.php');

	echo "connecting to aprs...\n";
	$aprs_socket = aprs_connect();
	if ($aprs_socket === false)
		return 1;

	$sql = sql_connect();
	if ($sql === false)
		return 1;

	$repeater_ids = sql_get_repeater_ids_for_network($sql);
	$sql->close();

	if ($repeater_ids) {
		foreach ($repeater_ids as $repeater_id) {
			echo "getting info for repeater id $repeater_id...\n";
			$ctx = stream_context_create(array(
				'http' => array(
					'timeout' => 5
				)
			));
			$result = file_get_contents("https://api.brandmeister.network/v1.0/repeater/?action=GET&q=$repeater_id", 0, $ctx);
			$result = json_decode($result);
			if (!isset($result->callsign)) {
				echo "  no callsign, ignoring\n";
				continue;
			}
			if ($result->lat == 0 || $result->lng == 0) {
				echo "  invalid coordinates, ignoring\n";
				continue;
			}

			if ($result->priorityDescription != '')
				$description = $result->priorityDescription;
			else {
				$description = explode('-', $result->hardware);
				$description = $description[0];
				$description = explode(' ', $description);
				$description = $description[0];
				$description = str_replace('_', ' ', $description);
				if ($description == '')
					$description = APRS_DEFAULT_TEXT;
			}

			aprs_send_location($result->callsign, ($result->tx == $result->rx), $result->lat,
				$result->lng, $result->pep, $result->agl, $result->gain, $description . ' ' .
				$result->tx . '/' . $result->rx . ' CC' . $result->colorcode);
		}
	}


	socket_close($aprs_socket);
?>
<commit_msg>Add last update handling<commit_after>#!/usr/bin/php
<?php
	ini_set('display_errors','On');
	error_reporting(E_ALL);

	chdir(dirname(__FILE__));

	include('config.inc.php');
	include('sql.inc.php');
	include('aprs.inc.php');

	echo "connecting to aprs...\n";
	$aprs_socket = aprs_connect();
	if ($aprs_socket === false)
		return 1;

	$sql = sql_connect();
	if ($sql === false)
		return 1;

	$repeater_ids = sql_get_repeater_ids_for_network($sql);
	$sql->close();

	if ($repeater_ids) {
		foreach ($repeater_ids as $repeater_id) {
			echo "getting info for repeater id $repeater_id...\n";
			$ctx = stream_context_create(array(
				'http' => array(
					'timeout' => 5
				)
			));
			$result = file_get_contents("https://api.brandmeister.network/v1.0/repeater/?action=GET&q=$repeater_id", 0, $ctx);
			$result = json_decode($result);
			if (!isset($result->callsign)) {
				echo "  no callsign, ignoring\n";
				continue;
			}
			if ($result->lat == 0 || $result->lng == 0) {
				echo "  invalid coordinates, ignoring\n";
				continue;
			}
			if (time()-strtotime($result->last_updated) > 600) {
				echo "  last update was too long ago, ignoring\n";
				continue;
			}

			if ($result->priorityDescription != '')
				$description = $result->priorityDescription;
			else {
				$description = explode('-', $result->hardware);
				$description = $description[0];
				$description = explode(' ', $description);
				$description = $description[0];
				$description = str_replace('_', ' ', $description);
				if ($description == '')
					$description = APRS_DEFAULT_TEXT;
			}

			aprs_send_location($result->callsign, ($result->tx == $result->rx), $result->lat,
				$result->lng, $result->pep, $result->agl, $result->gain, $description . ' ' .
				$result->tx . '/' . $result->rx . ' CC' . $result->colorcode);
		}
	}


	socket_close($aprs_socket);
?>

{'fraction_non_alphanumeric': 0.19257801518133258, 'fraction_numerical': 0.006466123137475401, 'mean_word_length': 3.7188328912466844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 2, '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': '569053', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1249, 'n_words': 229}