<commit_before><?php
## T-map
$file = file_get_contents("json/farm.json");
$farm = json_decode($file,true);
$file = file_get_contents("json/status.json");
$status = json_decode($file,true);
$zones = $farm["zone"];
$zones2 = $status["zone"];
$farm_map = array();
$z = 0;
foreach($zones as $zone){
	$zone2 = $zones2[$z];
	$zone_map = array();
	$miner_per_table = $zone["layers"] * $zone["plot_split"];
	for($i = 0; $i < ceil( count($zone["miner"]) / $miner_per_table) ; $i ++) {
		$split_map = array();
		for($j = 0; $j < $zone["layers"]; $j ++) $split_map[] = array_fill(0, $zone["plot_split"], ' ');
		$zone_map[] = $split_map;
	}
	for($i=0; $i < count($zone["miner"]); $i ++){
		$miner = $zone["miner"][$i];
		$miner2 = $zone2["miner"][$i];
		$n = floor($i / $miner_per_table);
		$x = floor(($i % $miner_per_table) / $zone["layers"]);
		$y = ($i % $miner_per_table) % $zone["layers"];
		$ports = array();
		foreach($miner["cgminer"] as $cgminer) $ports[] = $cgminer["port"];
		if($miner2['alive'] == 'True')
		{
			$content = "<p class=\"tmap\">" . $miner2['modnum'];
			$content = $content . "<font color=\"white\">";
			switch($miner2['d_modnum'])
			{
			case 1:
				$content = $content . "&#x2B06&#x2B06";
				break;
			case -1:
				$content = $content . "&#x2B07&#x2B07";
				break;
			case 0:
				$content = $content . "  ";
				break;
			}
			$content = $content . "</font>";
			$content = $content . "</p><p class=\"tmap\">" . $miner2['hashrate'];
			$content = $content . "<font color=\"white\">";
			switch($miner2['d_hashrate'])
			{
			case 2:
				$content = $content . "&#x2B06&#x2B06";
				break;
			case -2:
				$content = $content . "&#x2B07&#x2B07";
				break;
			case 1:
				$content = $content . " &#x2B06";
				break;
			case -1:
				$content = $content . " &#x2B07";
				break;
			case 0:
				$content = $content . "  ";
				break;
			}
			$content = $content . "</font>";
			$content = $content . "</p><p class=\"tmap\">" . round($miner2['tempavg'],1) . "/" . $miner2['tempmax'] . "</p>";
		}
		else $content = "N/A";
		$zone_map[$n][$y][$x] = "<td class=\"tmap\" style=\"background:" . $miner2['color'] .
			"\" onclick=\"window.open('" . "cgminer.php?ip=" . $miner["ip"] . "&port=" . join(",",$ports) . "');\">" .
			$content 
			. "</td>";
	}	
	$farm_map[] = $zone_map;
	$z ++;
}
## Hashrate Graph
$timeshift = 8 * 3600;
$file = file_get_contents("bin/hashrate.log");
$lines = explode("\n",$file);
if (end($lines) == "") {
	    array_pop($lines);
}
$hashrates = array();
$series = array_fill(0, 4, array());
$now = time();
foreach($series as &$serie){
	$serie['pointStart'] = $now * 1000 - 3600 * 1000;
	$serie['pointInterval'] = 3600 * 1000;
	$serie['data'] = array();
}
$series[0]['color'] = "blue"; 
$series[1]['color'] = "cyan"; 
$series[2]['color'] = "green"; 
$series[3]['color'] = "red"; 
$series[0]['name'] = "Local Method 1"; 
$series[1]['name'] = "Local Method 2"; 
$series[2]['name'] = "Pool Worker"; 
$series[3]['name'] = "Pool Sum"; 
foreach($lines as $line) $hashrates[] = explode(";",$line);
foreach($hashrates as $hashrate){
	$unix = DateTime::createFromFormat('Y_m_d_H_i', $hashrate[0])->getTimestamp();
	$localtime = ($unix + $timeshift) * 1000;
	if($now - 24.5*3600 > $unix) continue;
	$series[0]['data'][] = array($localtime,$hashrate[1] * 1000000);
	$series[1]['data'][] = array($localtime,$hashrate[2] * 1000000);
	$series[2]['data'][] = array($localtime,$hashrate[3] * 1000000);
	$series[3]['data'][] = array($localtime,$hashrate[4] * 1000000);
}
?>

<html>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/comm.js"></script>
<script src="js/highcharts.js"></script>
<script>
function refresh(){
	$.ajax({
		type:"POST",
		url:"refresh.php",
		data:{},
		dataType:"json",
		success:function(data){
			alert(data.msg);
		}
	});
}
</script>
<script>
$(function () { 
	$('#hashrate').highcharts({
		plotOptions: {line:{lineWidth:1,marker:{radius:2,symbol:"circle"}}},
		title: {text:'Hash Rate Graph'},
		yAxis: {title:{text:'Hash/s'}},
		xAxis: {
			title:{text:'Time (UTC+8)'},<commit_msg>Add tooltip showing ip to T-map table<commit_after><?php
## T-map
$file = file_get_contents("json/farm.json");
$farm = json_decode($file,true);
$file = file_get_contents("json/status.json");
$status = json_decode($file,true);
$zones = $farm["zone"];
$zones2 = $status["zone"];
$farm_map = array();
$z = 0;
foreach($zones as $zone){
	$zone2 = $zones2[$z];
	$zone_map = array();
	$miner_per_table = $zone["layers"] * $zone["plot_split"];
	for($i = 0; $i < ceil( count($zone["miner"]) / $miner_per_table) ; $i ++) {
		$split_map = array();
		for($j = 0; $j < $zone["layers"]; $j ++) $split_map[] = array_fill(0, $zone["plot_split"], ' ');
		$zone_map[] = $split_map;
	}
	for($i=0; $i < count($zone["miner"]); $i ++){
		$miner = $zone["miner"][$i];
		$miner2 = $zone2["miner"][$i];
		$n = floor($i / $miner_per_table);
		$x = floor(($i % $miner_per_table) / $zone["layers"]);
		$y = ($i % $miner_per_table) % $zone["layers"];
		$ports = array();
		foreach($miner["cgminer"] as $cgminer) $ports[] = $cgminer["port"];
		if($miner2['alive'] == 'True')
		{
			$content = "<p class=\"tmap\">" . $miner2['modnum'];
			$content = $content . "<font color=\"white\">";
			switch($miner2['d_modnum'])
			{
			case 1:
				$content = $content . "&#x2B06&#x2B06";
				break;
			case -1:
				$content = $content . "&#x2B07&#x2B07";
				break;
			case 0:
				$content = $content . "  ";
				break;
			}
			$content = $content . "</font>";
			$content = $content . "</p><p class=\"tmap\">" . $miner2['hashrate'];
			$content = $content . "<font color=\"white\">";
			switch($miner2['d_hashrate'])
			{
			case 2:
				$content = $content . "&#x2B06&#x2B06";
				break;
			case -2:
				$content = $content . "&#x2B07&#x2B07";
				break;
			case 1:
				$content = $content . " &#x2B06";
				break;
			case -1:
				$content = $content . " &#x2B07";
				break;
			case 0:
				$content = $content . "  ";
				break;
			}
			$content = $content . "</font>";
			$content = $content . "</p><p class=\"tmap\">" . round($miner2['tempavg'],1) . "/" . $miner2['tempmax'] . "</p>";
		}
		else $content = "N/A";
		$zone_map[$n][$y][$x] = "<td title=\"" . $miner["ip"] . "\" class=\"tmap\" style=\"background:" . $miner2['color'] .
			"\" onclick=\"window.open('" . "cgminer.php?ip=" . $miner["ip"] . "&port=" . join(",",$ports) . "');\">" .
			$content 
			. "</td>";
	}	
	$farm_map[] = $zone_map;
	$z ++;
}
## Hashrate Graph
$timeshift = 8 * 3600;
$file = file_get_contents("bin/hashrate.log");
$lines = explode("\n",$file);
if (end($lines) == "") {
	    array_pop($lines);
}
$hashrates = array();
$series = array_fill(0, 4, array());
$now = time();
foreach($series as &$serie){
	$serie['pointStart'] = $now * 1000 - 3600 * 1000;
	$serie['pointInterval'] = 3600 * 1000;
	$serie['data'] = array();
}
$series[0]['color'] = "blue"; 
$series[1]['color'] = "cyan"; 
$series[2]['color'] = "green"; 
$series[3]['color'] = "red"; 
$series[0]['name'] = "Local Method 1"; 
$series[1]['name'] = "Local Method 2"; 
$series[2]['name'] = "Pool Worker"; 
$series[3]['name'] = "Pool Sum"; 
foreach($lines as $line) $hashrates[] = explode(";",$line);
foreach($hashrates as $hashrate){
	$unix = DateTime::createFromFormat('Y_m_d_H_i', $hashrate[0])->getTimestamp();
	$localtime = ($unix + $timeshift) * 1000;
	if($now - 24.5*3600 > $unix) continue;
	$series[0]['data'][] = array($localtime,$hashrate[1] * 1000000);
	$series[1]['data'][] = array($localtime,$hashrate[2] * 1000000);
	$series[2]['data'][] = array($localtime,$hashrate[3] * 1000000);
	$series[3]['data'][] = array($localtime,$hashrate[4] * 1000000);
}
?>

<html>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/comm.js"></script>
<script src="js/highcharts.js"></script>
<script>
function refresh(){
	$.ajax({
		type:"POST",
		url:"refresh.php",
		data:{},
		dataType:"json",
		success:function(data){
			alert(data.msg);
		}
	});
}
</script>
<script>
$(function () { 
	$('#hashrate').highcharts({
		credits: {enabled: false},
		plotOptions: {line:{lineWidth:1,marker:{radius:2,symbol:"circle"}}},
		title: {text:'Hash Rate Graph'},
		yAxis: {title:{text:'Hash/s'}},
		xAxis: {
			title:{text:'Time (UTC+8)'},
{'fraction_non_alphanumeric': 0.263892118112067, 'fraction_numerical': 0.033945594047895836, 'mean_word_length': 4.317058096415328, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 63, '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': '4131112', 'n_tokens_mistral': 3844, 'n_tokens_neox': 3428, 'n_words': 612}