main
This commit is contained in:
@@ -1,29 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
* StarNet groups + active members partial.
|
||||
*
|
||||
* Sub-partial included by css_connections.php when at least one
|
||||
* `starNetCallsign1`..`5` is configured in /etc/ircddbgateway.
|
||||
*
|
||||
* Two tables:
|
||||
* 1. Configured groups — callsign, logoff callsign, info text,
|
||||
* user/group timeouts. Pulled directly from /etc/ircddbgateway.
|
||||
* 2. Active members — parsed from /var/log/pi-star/STARnet.log via
|
||||
* a preg_match_all that walks every "Adding/Removing <call> from
|
||||
* StarNet group <group>" line. We treat the log as the
|
||||
* authoritative state: an "Adding" entry inserts; a "Removing"
|
||||
* entry unsets. The final $groupsx map then holds current members.
|
||||
*
|
||||
* No security_headers call — it's a sub-sub-partial. Flagged for the
|
||||
* security pass.
|
||||
*/
|
||||
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/config/security_headers.php');
|
||||
setSecurityHeaders();
|
||||
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php';
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
<?php include_once $_SERVER['DOCUMENT_ROOT'].'/config/ircddblocal.php';
|
||||
include_once $_SERVER['DOCUMENT_ROOT'].'/config/language.php'; // Translation Code
|
||||
$configs = array();
|
||||
|
||||
if ($configfile = fopen($gatewayConfigPath,'r')) {
|
||||
@@ -53,95 +29,97 @@ $MYCALL=strtoupper($callsign);
|
||||
$i = 0;
|
||||
$stngrp = array();
|
||||
for($i = 1;$i < 6; $i++){
|
||||
$param="starNetCallsign" . $i;
|
||||
if(isset($configs[$param])) {
|
||||
$gname = $configs[$param];
|
||||
$stngrp[$gname] = $i;
|
||||
$ci++;
|
||||
if($ci > 1) { $ci = 0; }
|
||||
print "<tr>";
|
||||
print "<td align=\"center\">".str_replace(' ', ' ', substr($gname,0,8))."</td>";
|
||||
$param="starNetLogoff" . $i;
|
||||
if(isset($configs[$param])){ $output = str_replace(' ', ' ', substr($configs[$param],0,8)); print "<td align=\"center\">$output</td>";} else { print"<td> </td>";}
|
||||
$param="starNetInfo" . $i;
|
||||
if(isset($configs[$param])){ print "<td colspan=\"3\" align=\"left\">$configs[$param]</td>";} else { print"<td colspan=\"3\"> </td>";}
|
||||
$param="starNetUserTimeout" . $i;
|
||||
if(isset($configs[$param])){ print "<td align=\"center\">$configs[$param]</td>";} else { print"<td> </td>";}
|
||||
$param="starNetGroupTimeout" . $i;
|
||||
if(isset($configs[$param])){ print "<td align=\"center\">$configs[$param]</td>";} else { print"<td> </td>";}
|
||||
print "</tr>\n";
|
||||
}
|
||||
$param="starNetCallsign" . $i;
|
||||
if(isset($configs[$param])) {
|
||||
$gname = $configs[$param];
|
||||
$stngrp[$gname] = $i;
|
||||
$ci++;
|
||||
if($ci > 1) { $ci = 0; }
|
||||
print "<tr>";
|
||||
print "<td align=\"center\">".str_replace(' ', ' ', substr($gname,0,8))."</td>";
|
||||
$param="starNetLogoff" . $i;
|
||||
if(isset($configs[$param])){ $output = str_replace(' ', ' ', substr($configs[$param],0,8)); print "<td align=\"center\">$output</td>";} else { print"<td> </td>";}
|
||||
$param="starNetInfo" . $i;
|
||||
if(isset($configs[$param])){ print "<td colspan=\"3\" align=\"left\">$configs[$param]</td>";} else { print"<td colspan=\"3\"> </td>";}
|
||||
$param="starNetUserTimeout" . $i;
|
||||
if(isset($configs[$param])){ print "<td align=\"center\">$configs[$param]</td>";} else { print"<td> </td>";}
|
||||
$param="starNetGroupTimeout" . $i;
|
||||
if(isset($configs[$param])){ print "<td align=\"center\">$configs[$param]</td>";} else { print"<td> </td>";}
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table><br />
|
||||
|
||||
<?php
|
||||
$groupsx = array();
|
||||
if ($starLog = fopen($starLogPath,'r')) {
|
||||
while($logLine = fgets($starLog)) {
|
||||
preg_match_all('/^(.{19}).*(Adding|Removing) (.{8}).*StarNet group (.{8}).*$/',$logLine,$matches);
|
||||
$groupz = substr($matches[4][0],0,8);
|
||||
$member = substr($matches[3][0],0,8);
|
||||
$action = substr($matches[2][0],0,8);
|
||||
$date = $matches[1][0];
|
||||
$guid = $stngrp[$groupz];
|
||||
if ($action == 'Adding'){
|
||||
$groupsx[$guid][$groupz][$member] = $date;
|
||||
}
|
||||
elseif ($action == 'Removing'){
|
||||
unset($groupsx[$guid][$groupz][$member]);
|
||||
}
|
||||
}
|
||||
fclose($starLog);
|
||||
}
|
||||
$groupsx = array();
|
||||
if ($starLog = fopen($starLogPath,'r')) {
|
||||
while($logLine = fgets($starLog)) {
|
||||
preg_match_all('/^(.{19}).*(Adding|Removing) (.{8}).*StarNet group (.{8}).*$/',$logLine,$matches);
|
||||
$groupz = substr($matches[4][0],0,8);
|
||||
$member = substr($matches[3][0],0,8);
|
||||
$action = substr($matches[2][0],0,8);
|
||||
$date = $matches[1][0];
|
||||
$guid = $stngrp[$groupz];
|
||||
if ($action == 'Adding'){
|
||||
$groupsx[$guid][$groupz][$member] = $date;
|
||||
}
|
||||
elseif ($action == 'Removing'){
|
||||
unset($groupsx[$guid][$groupz][$member]);
|
||||
}
|
||||
}
|
||||
fclose($starLog);
|
||||
}
|
||||
|
||||
//Clean the empty arrays from the multidimensional array
|
||||
$groupsx = array_map('array_filter', $groupsx);
|
||||
//Clean the empty arrays from the multidimensional array
|
||||
$groupsx = array_map('array_filter', $groupsx);
|
||||
|
||||
$active = 0;
|
||||
for ($i = 1;$i < 6; $i++) {
|
||||
if (isset($groupsx[$i])) {
|
||||
$active = $active + count($groupsx[$i]);
|
||||
}
|
||||
}
|
||||
$active = 0;
|
||||
for ($i = 1;$i < 6; $i++) {
|
||||
if (isset($groupsx[$i])) {
|
||||
$active = $active + count($groupsx[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($active >= 1) {
|
||||
if ($active >= 1) {
|
||||
|
||||
echo "<b>".$lang['active_starnet_members']."</b>\n";
|
||||
echo "<table style=\"table-layout: fixed;\">\n";
|
||||
echo "<tr>\n";
|
||||
echo "<th><a class=tooltip href=\"#\">".$lang['time']." (".date('T').")<span><b>Time of Login</b></span></a></th>\n";
|
||||
echo "<th><a class=tooltip href=\"#\">".$lang['group']."<span><b>Starnet Callsign</b></span></a></th>\n";
|
||||
echo "<th><a class=tooltip href=\"#\">".$lang['callsign']."<span><b>Callsign</b></span></a></th>\n";
|
||||
echo "</tr>\n";
|
||||
echo "<b>".$lang['active_starnet_members']."</b>\n";
|
||||
echo "<table style=\"table-layout: fixed;\">\n";
|
||||
echo "<tr>\n";
|
||||
echo "<th><a class=tooltip href=\"#\">".$lang['time']." (".date('T').")<span><b>Time of Login</b></span></a></th>\n";
|
||||
echo "<th><a class=tooltip href=\"#\">".$lang['group']."<span><b>Starnet Callsign</b></span></a></th>\n";
|
||||
echo "<th><a class=tooltip href=\"#\">".$lang['callsign']."<span><b>Callsign</b></span></a></th>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
$ci = 0;
|
||||
$ulist = array();
|
||||
$glist = array();
|
||||
for($i = 1;$i < 6; $i++){
|
||||
if(isset($groupsx[$i])){
|
||||
$glist = $groupsx[$i];
|
||||
foreach ($glist as $gcall => $ulist){
|
||||
foreach ($ulist as $ucall => $ulogin){
|
||||
$ci++;
|
||||
if($ci > 1) { $ci = 0; }
|
||||
$ulogin = date("d-M-Y H:i:s", strtotime(substr($ulogin,0,19)));
|
||||
$utc_time = $ulogin;
|
||||
$ci = 0;
|
||||
$ulist = array();
|
||||
$glist = array();
|
||||
for($i = 1;$i < 6; $i++){
|
||||
if(isset($groupsx[$i])){
|
||||
$glist = $groupsx[$i];
|
||||
foreach ($glist as $gcall => $ulist){
|
||||
foreach ($ulist as $ucall => $ulogin){
|
||||
$ci++;
|
||||
if($ci > 1) { $ci = 0; }
|
||||
$ulogin = date("d-M-Y H:i:s", strtotime(substr($ulogin,0,19)));
|
||||
$utc_time = $ulogin;
|
||||
$utc_tz = new DateTimeZone('UTC');
|
||||
$local_tz = new DateTimeZone(date_default_timezone_get ());
|
||||
$dt = new DateTime($utc_time, $utc_tz);
|
||||
$dt->setTimeZone($local_tz);
|
||||
$local_time = $dt->format('H:i:s M jS');
|
||||
$groupz = str_replace(' ', ' ', substr($gcall,0,8));
|
||||
$ucall = str_replace(' ', '', substr($ucall,0,8));
|
||||
print "<tr>";
|
||||
print "<td align=\"left\">$local_time</td>";
|
||||
print "<td align=\"center\">$groupz</td>";
|
||||
print "<td align=\"center\"><a href=\"http://www.qrz.com/db/$ucall\" target=\"_new\" alt=\"Lookup Callsign\">$ucall</a></td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</table>\n<br />\n";
|
||||
}
|
||||
$groupz = str_replace(' ', ' ', substr($gcall,0,8));
|
||||
$ucall = str_replace(' ', '', substr($ucall,0,8));
|
||||
print "<tr>";
|
||||
print "<td align=\"left\">$local_time</td>";
|
||||
print "<td align=\"center\">$groupz</td>";
|
||||
print "<td align=\"center\"><a href=\"http://www.qrz.com/db/$ucall\" target=\"_new\" alt=\"Lookup Callsign\">$ucall</a></td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</table>\n<br />\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user