<commit_before><?php

$db = new SQLite3('port_data.sqlite');

$result = $db->query('SELECT minport, maxport, description FROM portmap');

$sum_ports = array();
$sum_ports_byname = array();
while($data = $result->fetchArray()) {
	$ports = range($data['minport'], $data['maxport']);
	foreach($ports as $port) {
		$sum_ports_byname[$port][] = $data['description'];
	}

	$sum_ports = array_merge($sum_ports, $ports);
}

if(isset($argv[1])) {
	if( isset($sum_ports_byname[$argv[1]]) ){
		foreach($sum_ports_byname[$argv[1]] as $item) {
			echo " - " . $item . "\n";
		}
	}else{
		echo "Not Found\n";
	}
}else{
	do {
		$random = rand(0, 65535);
	}while( in_array($random, $sum_ports) );

	echo "random port:" . $random . "\n";
}<commit_msg>Fixed up formatting, display protocol<commit_after><?php

$db = new SQLite3('port_data.sqlite');

$result = $db->query('SELECT minport, maxport, protocol, description FROM portmap');

$sum_ports = array();
$sum_ports_byname = array();
while($data = $result->fetchArray()) {
	$ports = range($data['minport'], $data['maxport']);
	foreach($ports as $port) {
		$sum_ports_byname[$port][] = $data;
	}
}

$sum_ports = array_keys($sum_ports_byname);

$protocol = array( 1 => "TCP", "UDP", "UDP/TCP" );

if(isset($argv[1])) {
	if( isset($sum_ports_byname[$argv[1]]) ){
		foreach($sum_ports_byname[$argv[1]] as $item) {
			echo " - {$protocol[$item['protocol']]}: {$item['description']}\n";
		}
	}else{
		echo "No Matches Found\n";
	}
}else{
	do {
		$random = rand(0, 65535);
	}while( in_array($random, $sum_ports) );

	echo "random port: {$random}\n";
}
{'fraction_non_alphanumeric': 0.22355921469284357, 'fraction_numerical': 0.013299556681443952, 'mean_word_length': 5.370967741935484, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '4252375', 'n_tokens_mistral': 635, 'n_tokens_neox': 621, 'n_words': 118}