Initial commit (source: raspap-insiders)

This commit is contained in:
billz
2025-07-14 02:22:42 -07:00
parent 51d528fd42
commit 5c979424f3
4 changed files with 374 additions and 0 deletions

78
app/lib/signprint.php Normal file
View File

@@ -0,0 +1,78 @@
<?php
require_once '../../includes/config.php';
require_once '../../includes/defaults.php';
// prevent direct file access
if (!isset($_SERVER['HTTP_REFERER'])) {
header('HTTP/1.0 403 Forbidden');
exit;
}
$hostapd = parse_ini_file(RASPI_HOSTAPD_CONFIG, false, INI_SCANNER_RAW);
$ssid = $hostapd['ssid'];
$password = isset($hostapd['wpa_psk']) ? $hostapd['wpa_psk'] : $hostapd['wpa_passphrase'];
?>
<html>
<head>
<title><?php echo _("Printable Wi-Fi sign"); ?></title>
<!-- Bootstrap Core CSS -->
<link href="../../dist/bootstrap/css/bootstrap.css" rel="stylesheet">
<!-- SB-Admin-2 CSS -->
<link href="../../dist/sb-admin-2/css/sb-admin-2.min.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="../../dist/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
</head>
<body id="page-top">
<div id="wrapper">
<div id="content-wrapper" class="d-flex flex-column">
<div id="container">
<div class="row text-center">
<div class="col">
<div class="mt-5 mb-5">
<h2><i class="fas fa-wifi"></i> <?php echo _("Wi-Fi Connect"); ?></h2>
</div>
</div>
</div><!-- /row -->
<div class="row">
<div class="col"></div>
<div class="col-5">
<img src="../img/wifi-qr-code.php" class="figure-img img-fluid" alt="RaspAP Wifi QR code" style="width:100%;">
</div>
<div class="col"></div>
</div><!-- /row -->
<div class="row text-center">
<div class="col"></div>
<div class="col-8">
<div class="mt-4">
<div><?php echo _("To connect with your phone or tablet, scan the QR code above with your camera app."); ?></div>
<div><?php echo _("For other devices, use the login credentials below."); ?></div>
</div>
</div>
<div class="col"></div>
</div><!-- /row -->
<div class="row text-center">
<div class="col"></div>
<div class="col-8">
<div class="mt-4">
<?php echo _("Network"); ?>
<h3 class="mb-3"><?php echo $ssid ?></h3>
<?php echo _("Password"); ?>
<h3 class="mb-5"><?php echo $password ?></h3>
</div>
</div>
<div class="col"></div>
</div><!-- /row -->
</div><!-- /content -->
</div><!-- /content-wrapper -->
</div><!-- /page wrapper -->
</body>
</html>

View File

@@ -0,0 +1,109 @@
<?php
/**
* DeviceScanner class
*
* @description A class for enumerating available devices and their details
* @author Bill Zimmerman <billzimmerman@gmail.com>
* @license https://github.com/raspap/raspap-webgui/blob/master/LICENSE
*/
namespace RaspAP\Networking;
class DeviceScanner
{
public function listDevices(): array
{
$devices = [];
foreach (glob('/sys/class/net/*') as $ifacePath) {
$iface = basename($ifacePath);
if ($iface === 'lo') {
continue; // skip loopback
}
$device = [
'name' => $iface,
'mac' => $this->readFile("$ifacePath/address"),
'ipaddress' => $this->getIPAddress($iface),
'vendor' => '',
'model' => '',
'vid' => '',
'pid' => '',
'driver' => '',
'type' => $this->getInterfaceType($iface),
'isAP' => false,
'connected' => 'y', // placeholder
'signal' => '0 dB (100%)' // placeholder
];
$udev = $this->getUdevAttributes($iface);
$device['vendor'] = $this->getVendorName($udev);
$device['model'] = $udev['ID_MODEL_FROM_DATABASE'] ?? $udev['ID_MODEL'] ?? '';
$device['vid'] = $udev['ID_VENDOR_ID'] ?? '';
$device['pid'] = $udev['ID_MODEL_ID'] ?? '';
$device['driver'] = $udev['ID_NET_DRIVER'] ?? '';
$devices[] = $device;
}
return $devices;
}
private function readFile(string $path): string
{
return is_readable($path) ? trim(file_get_contents($path)) : '';
}
private function getIPAddress(string $iface): string
{
$cmd = "ip -4 -o addr show dev " . escapeshellarg($iface) . " | awk '{print $4}' | cut -d/ -f1";
$result = [];
exec($cmd, $result);
return $result[0] ?? '';
}
private function getInterfaceType(string $iface): string
{
$wirelessPath = "/sys/class/net/{$iface}/wireless";
if (is_dir($wirelessPath)) {
return 'wlan';
}
$typeFile = "/sys/class/net/{$iface}/type";
$type = $this->readFile($typeFile);
return match ($type) {
'1' => 'eth', // ARPHRD_ETHER
'772' => 'loopback',
'512' => 'ppp',
default => 'unknown'
};
}
private function getUdevAttributes(string $iface): array
{
$attributes = [];
$output = [];
$path = escapeshellarg("/sys/class/net/{$iface}");
exec("udevadm info {$path}", $output);
foreach ($output as $line) {
if (preg_match('/E: (\w+)=([^\n]+)/', $line, $matches)) {
$attributes[$matches[1]] = $matches[2];
}
}
return $attributes;
}
private function getVendorName(array $udev): ?string
{
return $udev['ID_VENDOR_FROM_DATABASE']
?? $udev['ID_VENDOR']
?? $udev['ID_OUI_FROM_DATABASE']
?? null;
}
}

View File

@@ -0,0 +1,95 @@
<div role="tabpanel" class="tab-pane" id="diagnostic">
<h4 class="mt-3"><?php echo _("Speedtest") ?></h4>
<div class="row">
<div class="col-md-8">
<div id="loading" class="visible">
<p id="message"><span class="loadCircle"></span><?php echo _("Selecting a server"); ?>...</p>
</div>
<div id="testWrapper" class="hidden">
<button id="startStopBtn" type="button" class="btn btn-outline btn-primary" onclick="startStop()"></button>
<a class="privacy" href="#" onclick="I('privacyPolicy').style.display=''"><?php echo _("Privacy"); ?></a>
<div class="col-sm-4 centered">
<div id="serverArea">
<?php echo _("Server"); ?>: <select id="server" class="form-select" onchange="s.setSelectedServer(SPEEDTEST_SERVERS[this.value]);"></select>
</div>
</div>
<div id="test">
<div class="testGroup">
<div class="testArea2">
<div class="testName"><?php echo _("Ping"); ?></div>
<div id="pingText" class="meterText" style="color:#AA6060"></div>
<div class="unit"><?php echo _("ms"); ?></div>
</div>
<div class="testArea2">
<div class="testName"><?php echo _("Jitter"); ?></div>
<div id="jitText" class="meterText" style="color:#AA6060"></div>
<div class="unit"><?php echo _("ms"); ?></div>
</div>
</div>
<div class="testGroup">
<div class="testArea">
<div class="testName"><?php echo _("Download"); ?></div>
<canvas id="dlMeter" class="meter"></canvas>
<div id="dlText" class="meterText"></div>
<div class="unit"><?php echo _("Mbps"); ?></div>
</div>
<div class="testArea">
<div class="testName"><?php echo _("Upload"); ?></div>
<canvas id="ulMeter" class="meter"></canvas>
<div id="ulText" class="meterText"></div>
<div class="unit"><?php echo _("Mbps"); ?></div>
</div>
</div>
<div id="ipArea">
<span id="ip"></span>
</div>
</div>
</div><!-- /.testWrapper -->
<div id="privacyPolicy" style="display:none">
<h4>Speedtest Privacy Policy</h4>
<p>RaspAP's <a href="https://speedtest.raspap.com/">Speedtest server</a> is configured with telemetry enabled.</p>
<h5>Data we collect</h5>
<p>
At the end of the test, the following data is collected and stored:
<ul>
<li>Test ID</li>
<li>Time of testing</li>
<li>Test results (download and upload speed, ping and jitter)</li>
<li>IP address</li>
<li>ISP information</li>
<li>Approximate location (inferred from IP address, not GPS)</li>
<li>User agent and browser locale</li>
</ul>
</p>
<h5>How we use the data</h5>
<p>
Data collected through this service is used to:
<ul>
<li>Allow sharing of test results (sharable image for forums, etc.)</li>
<li>To improve the service offered to you (for instance, to detect problems on our side)</li>
</ul>
No personal information is disclosed to third parties.
</p>
<h5>Your consent</h5>
<p>
By starting the test, you consent to the terms of this privacy policy.
</p>
<h5>Data removal</h5>
<p>
If you wish to have your information deleted, simply provide us with your IP address. Without this information we won't be able to comply with your request. Contact <a href="mailto:&#115;&#117;&#112;&#112;&#111;&#114;&#116;&#64;&#114;&#97;&#115;&#112;&#97;&#112;&#46;&#99;&#111;&#109;">&#115;&#117;&#112;&#112;&#111;&#114;&#116;&#64;&#114;&#97;&#115;&#112;&#97;&#112;&#46;&#99;&#111;&#109;</a> for all deletion requests.
</p>
<br/>
<div class="closePrivacyPolicy">
<a class="privacy" href="#" onclick="I('privacyPolicy').style.display='none'">Close</a>
</div>
<br/>
</div><!-- /.privacyPolicy -->
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.tabpanel -->

View File

@@ -0,0 +1,92 @@
<div role="tabpanel" class="tab-pane active" id="summary">
<h4 class="mt-3"><?php echo _("Internet connection"); ?></h4>
<div class="row">
<div class="col-sm-12">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th><?php echo _("Interface"); ?></th>
<th><?php echo _("IP Address"); ?></th>
<th><?php echo _("Gateway"); ?></th>
<th colspan="2"><?php echo _("Internet Access"); ?></th>
</tr>
</thead>
<tbody>
<?php if (isset($routeInfo["error"]) || empty($routeInfo)): ?>
<tr><td colspan=5>No route to the internet found</td></tr>
<?php else: ?>
<?php foreach($routeInfo as $route): ?>
<tr>
<td><?php echo $route['interface'] ?></td>
<td><?php echo $route['ip-address'] ?></td>
<td><?php echo $route['gateway'] ?><br><?php $route['gw-name'] ?></td>
<?php if ($route['isAP']): ?>
<td>
<p class="m-0">Access point</p>
</td>
<?php else: ?>
<td>
<p class="m-0" data-bs-toggle="tooltip" data-bs-placement="left" title="<?php echo "ping ".RASPI_ACCESS_CHECK_IP ?>">
<i class="fas <?php echo $route["access-ip"] ? "fa-check" : "fa-times"; ?>" ></i> <?php echo "IP" ?>
</p>
<p class="m-0" data-bs-toggle="tooltip" data-bs-placement="left" title="<?php echo "ping ".RASPI_ACCESS_CHECK_DNS ?>">
<i class="fas <?php echo $route["access-dns"] ? "fa-check" : "fa-times"; ?>" ></i> <?php echo "DNS" ?>
</p>
<p class="m-0" data-bs-toggle="tooltip" data-bs-placement="left" title="<?php echo RASPI_ACCESS_CHECK_URL ?>">
<i class="fas <?php echo $route["access-url"] ? "fa-check" : "fa-times"; ?>" ></i> <?php echo "HTTP" ?>
</p>
</td>
<?php endif ?>
</tr>
<?php endforeach ?>
<?php endif ?>
</tbody>
</table>
</div>
</div>
</div>
<h4 class="mt-3"><?php echo _("Routing table"); ?></h4>
<div class="card h-100 w-100">
<div class="card-header"><?php echo _("raw output") ?></div>
<div class="card-body">
<div class="row">
<div class="col-sm-12">
<div class="table-responsive">
<table class="table">
<tbody>
<?php foreach($routeInfoRaw as $route): ?>
<tr>
<pre class="unstyled"><?php echo $route; ?></pre>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<h4 class="mt-3"><?php echo _("Current settings") ?></h4>
<div class="row">
<?php if (!$bridgedEnabled) : // No interface details when bridged ?>
<?php foreach ($interfaces as $interface): ?>
<?php $if_quoted = htmlspecialchars($interface, ENT_QUOTES) ?>
<div class="col-md mb-3">
<div class="card h-100 w-100">
<div class="card-header"><?php echo $if_quoted ?></div>
<div class="card-body">
<pre class="unstyled" id="<?php echo $if_quoted ?>-summary"></pre>
</div>
</div>
</div>
<?php endforeach ?>
<?php endif ?>
</div><!-- /.row -->
<button type="button" onClick="window.location.reload();" class="btn btn-outline btn-primary"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh") ?></a>
</div><!-- /.tabpanel -->