<commit_before><?php

function getMMDVMHostVersion() {
   // returns creation-time or version of MMDVMHost as version-number
   $filename = MMDVMHOSTPATH."/MMDVMHost";
   exec($filename." -v 2>&1", $output);
   if (!startsWith(substr($output[0],18,8),"20")) {
      showLapTime("getMMDVMHostVersion");
      return getMMDVMHostFileVersion();
   } else {
      showLapTime("getMMDVMHostVersion");
      return substr($output[0],18,8)." (compiled ".getMMDVMHostFileVersion().")";
   }
}

function getMMDVMHostFileVersion() {
   // returns creation-time of MMDVMHost as version-number
   $filename = MMDVMHOSTPATH."/MMDVMHost";
   if (file_exists($filename)) {
      showLapTime("getMMDVMHostFileVersion");
      return date("d M Y", filectime($filename));
   }
}

function getFirmwareVersion() {
   $logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
   $logLines = explode("\n", `grep "MMDVM protocol version" $logPath`);
   $firmware = substr($logLines[count($logLines)-2], strpos($logLines[count($logLines)-2], "description")+13, strlen($logLines[count($logLines)-2])-strpos($logLines[count($logLines)-2], "description")+13);
   if (strlen($firmware) > 0) {
      $fp = fopen('/tmp/MMDVMFirmware.txt', 'w');
      fwrite($fp, $firmware);
      fclose($fp);
   } else {
      $fp = fopen('/tmp/MMDVMFirmware.txt', 'r');
      $contents = fread($fp, filesize("/tmp/MMDVMFirmware.txt"));
      $firmware = $contents;
   }
   echo $firmware;
}

function setDMRNetwork($network) {
   $fp = fopen('../config/DMRNetwork.txt', 'w');
   fwrite($fp, $network);
   fclose($fp);
}

function getDMRNetwork() {
   if (file_exists('config/DMRNetwork.txt')) {
      $fp = fopen('config/DMRNetwork.txt', 'r');
      $network = fread($fp, filesize("config/DMRNetwork.txt"));
      fclose($fp);
      return $network;	 
   } else {
   	  return "";
   }
   
}

function getDMRNetwork2() {
   $fp = fopen('../config/DMRNetwork.txt', 'r');
   $network = fread($fp, filesize("../config/DMRNetwork.txt"));
   fclose($fp);
   return $network;
}

function getDMRMasterState() {
   $logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
   $logLines = explode("\n", `egrep -h "(DMR, Logged into the master successfully)|(DMR, Closing DMR Network)" $logPath`);
   $state = -1;
   foreach($logLines as $logLine) {
      if (strpos($logLine, "successfully") > 0) {
         $state = 1;
      }
      if (strpos($logLine, "Closing") > 0) {
         $state = 0;
      }<commit_msg>also for getDMRNetwork2()<commit_after><?php

function getMMDVMHostVersion() {
   // returns creation-time or version of MMDVMHost as version-number
   $filename = MMDVMHOSTPATH."/MMDVMHost";
   exec($filename." -v 2>&1", $output);
   if (!startsWith(substr($output[0],18,8),"20")) {
      showLapTime("getMMDVMHostVersion");
      return getMMDVMHostFileVersion();
   } else {
      showLapTime("getMMDVMHostVersion");
      return substr($output[0],18,8)." (compiled ".getMMDVMHostFileVersion().")";
   }
}

function getMMDVMHostFileVersion() {
   // returns creation-time of MMDVMHost as version-number
   $filename = MMDVMHOSTPATH."/MMDVMHost";
   if (file_exists($filename)) {
      showLapTime("getMMDVMHostFileVersion");
      return date("d M Y", filectime($filename));
   }
}

function getFirmwareVersion() {
   $logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
   $logLines = explode("\n", `grep "MMDVM protocol version" $logPath`);
   $firmware = substr($logLines[count($logLines)-2], strpos($logLines[count($logLines)-2], "description")+13, strlen($logLines[count($logLines)-2])-strpos($logLines[count($logLines)-2], "description")+13);
   if (strlen($firmware) > 0) {
      $fp = fopen('/tmp/MMDVMFirmware.txt', 'w');
      fwrite($fp, $firmware);
      fclose($fp);
   } else {
      $fp = fopen('/tmp/MMDVMFirmware.txt', 'r');
      $contents = fread($fp, filesize("/tmp/MMDVMFirmware.txt"));
      $firmware = $contents;
   }
   echo $firmware;
}

function setDMRNetwork($network) {
   $fp = fopen('../config/DMRNetwork.txt', 'w');
   fwrite($fp, $network);
   fclose($fp);
}

function getDMRNetwork() {
   if (file_exists('config/DMRNetwork.txt')) {
      $fp = fopen('config/DMRNetwork.txt', 'r');
      $network = fread($fp, filesize("config/DMRNetwork.txt"));
      fclose($fp);
      return $network;	 
   } else {
   	  return "";
   }
   
}

function getDMRNetwork2() {
   if (file_exists('../config/DMRNetwork.txt')) {
   	  $fp = fopen('../config/DMRNetwork.txt', 'r');
      $network = fread($fp, filesize("../config/DMRNetwork.txt"));
      fclose($fp);
      return $network;	 
   } else {
   	  return "";
   }
}

function getDMRMasterState() {
   $logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
   $logLines = explode("\n", `egrep -h "(DMR, Logged into the master successfully)|(DMR, Closing DMR Network)" $logPath`);
   $state = -1;
   foreach($logLines as $logLine) {
      if (strpos($logLine, "successfully") > 0) {
         $state = 1;
      }
      if (strpos($logLine, "Closing") > 0) {
         $state = 0;
      }
{'fraction_non_alphanumeric': 0.19392983839180133, 'fraction_numerical': 0.01083957430035475, 'mean_word_length': 3.5556552962298027, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5142084', 'n_tokens_mistral': 1866, 'n_tokens_neox': 1847, 'n_words': 310}