Processed with phpcs for PSR-2 coding standard

This commit is contained in:
billz 2019-04-10 08:37:35 +00:00
parent 89852cc633
commit c0570b616e
17 changed files with 1461 additions and 1416 deletions

5
includes/about.php Normal file → Executable file
View File

@ -1,8 +1,9 @@
<?php <?php
include_once( 'includes/status_messages.php' ); include_once('includes/status_messages.php');
function DisplayAbout() { function DisplayAbout()
{
/** /**
* *
* Displays info about the RaspAP project * Displays info about the RaspAP project

View File

@ -1,8 +1,9 @@
<?php <?php
include_once( 'includes/status_messages.php' ); include_once('includes/status_messages.php');
function DisplayAuthConfig($username, $password){ function DisplayAuthConfig($username, $password)
{
$status = new StatusMessages(); $status = new StatusMessages();
if (isset($_POST['UpdateAdminPassword'])) { if (isset($_POST['UpdateAdminPassword'])) {
if (CSRFValidate()) { if (CSRFValidate()) {
@ -10,7 +11,7 @@ function DisplayAuthConfig($username, $password){
$new_username=trim($_POST['username']); $new_username=trim($_POST['username']);
if ($_POST['newpass'] !== $_POST['newpassagain']) { if ($_POST['newpass'] !== $_POST['newpassagain']) {
$status->addMessage('New passwords do not match', 'danger'); $status->addMessage('New passwords do not match', 'danger');
} else if ($new_username == '') { } elseif ($new_username == '') {
$status->addMessage('Username must not be empty', 'danger'); $status->addMessage('Username must not be empty', 'danger');
} else { } else {
if (!file_exists(RASPI_ADMIN_DETAILS)) { if (!file_exists(RASPI_ADMIN_DETAILS)) {

View File

@ -15,4 +15,3 @@ if (!$validated) {
exit('Not authorized'.PHP_EOL); exit('Not authorized'.PHP_EOL);
} }

View File

@ -2,7 +2,7 @@
define('RASPI_VERSION', '1.4.1'); define('RASPI_VERSION', '1.4.1');
define('RASPI_CONFIG', '/etc/raspap'); define('RASPI_CONFIG', '/etc/raspap');
define('RASPI_CONFIG_NETWORKING',RASPI_CONFIG.'/networking'); define('RASPI_CONFIG_NETWORKING', RASPI_CONFIG.'/networking');
define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth'); define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth');
define('RASPI_WIFI_CLIENT_INTERFACE', 'wlan0'); define('RASPI_WIFI_CLIENT_INTERFACE', 'wlan0');
@ -20,17 +20,16 @@ define('RASPI_OPENVPN_SERVER_CONFIG', '/etc/openvpn/server.conf');
define('RASPI_TORPROXY_CONFIG', '/etc/tor/torrc'); define('RASPI_TORPROXY_CONFIG', '/etc/tor/torrc');
// Optional services, set to true to enable. // Optional services, set to true to enable.
define('RASPI_WIFICLIENT_ENABLED', true ); define('RASPI_WIFICLIENT_ENABLED', true);
define('RASPI_HOTSPOT_ENABLED', true ); define('RASPI_HOTSPOT_ENABLED', true);
define('RASPI_NETWORK_ENABLED', true ); define('RASPI_NETWORK_ENABLED', true);
define('RASPI_DHCP_ENABLED', true ); define('RASPI_DHCP_ENABLED', true);
define('RASPI_OPENVPN_ENABLED', false ); define('RASPI_OPENVPN_ENABLED', false);
define('RASPI_TORPROXY_ENABLED', false ); define('RASPI_TORPROXY_ENABLED', false);
define('RASPI_CONFAUTH_ENABLED', true ); define('RASPI_CONFAUTH_ENABLED', true);
define('RASPI_CHANGETHEME_ENABLED', true ); define('RASPI_CHANGETHEME_ENABLED', true);
define('RASPI_VNSTAT_ENABLED', true ); define('RASPI_VNSTAT_ENABLED', true);
// Locale settings // Locale settings
define('LOCALE_ROOT', 'locale'); define('LOCALE_ROOT', 'locale');
define('LOCALE_DOMAIN', 'messages'); define('LOCALE_DOMAIN', 'messages');

View File

@ -4,7 +4,8 @@
* *
* *
*/ */
function DisplayWPAConfig(){ function DisplayWPAConfig()
{
$status = new StatusMessages(); $status = new StatusMessages();
$networks = array(); $networks = array();
@ -14,7 +15,7 @@ function DisplayWPAConfig(){
$network = null; $network = null;
$ssid = null; $ssid = null;
foreach($known_return as $line) { foreach ($known_return as $line) {
if (preg_match('/network\s*=/', $line)) { if (preg_match('/network\s*=/', $line)) {
$network = array('visible' => false, 'configured' => true, 'connected' => false); $network = array('visible' => false, 'configured' => true, 'connected' => false);
} elseif ($network !== null) { } elseif ($network !== null) {
@ -23,7 +24,7 @@ function DisplayWPAConfig(){
$network = null; $network = null;
$ssid = null; $ssid = null;
} elseif ($lineArr = preg_split('/\s*=\s*/', trim($line))) { } elseif ($lineArr = preg_split('/\s*=\s*/', trim($line))) {
switch(strtolower($lineArr[0])) { switch (strtolower($lineArr[0])) {
case 'ssid': case 'ssid':
$ssid = trim($lineArr[1], '"'); $ssid = trim($lineArr[1], '"');
break; break;
@ -49,17 +50,16 @@ function DisplayWPAConfig(){
} }
} }
if ( isset($_POST['connect']) ) { if (isset($_POST['connect'])) {
$result = 0; $result = 0;
exec ( 'sudo wpa_cli -i ' . RASPI_WPA_CTRL_INTERFACE . ' select_network '.strval($_POST['connect'] )); exec('sudo wpa_cli -i ' . RASPI_WPA_CTRL_INTERFACE . ' select_network '.strval($_POST['connect']));
} } elseif (isset($_POST['client_settings']) && CSRFValidate()) {
else if ( isset($_POST['client_settings']) && CSRFValidate() ) {
$tmp_networks = $networks; $tmp_networks = $networks;
if ($wpa_file = fopen('/tmp/wifidata', 'w')) { if ($wpa_file = fopen('/tmp/wifidata', 'w')) {
fwrite($wpa_file, 'ctrl_interface=DIR=' . RASPI_WPA_CTRL_INTERFACE . ' GROUP=netdev' . PHP_EOL); fwrite($wpa_file, 'ctrl_interface=DIR=' . RASPI_WPA_CTRL_INTERFACE . ' GROUP=netdev' . PHP_EOL);
fwrite($wpa_file, 'update_config=1' . PHP_EOL); fwrite($wpa_file, 'update_config=1' . PHP_EOL);
foreach(array_keys($_POST) as $post) { foreach (array_keys($_POST) as $post) {
if (preg_match('/delete(\d+)/', $post, $post_match)) { if (preg_match('/delete(\d+)/', $post, $post_match)) {
unset($tmp_networks[$_POST['ssid' . $post_match[1]]]); unset($tmp_networks[$_POST['ssid' . $post_match[1]]]);
} elseif (preg_match('/update(\d+)/', $post, $post_match)) { } elseif (preg_match('/update(\d+)/', $post, $post_match)) {
@ -77,7 +77,7 @@ function DisplayWPAConfig(){
} }
$ok = true; $ok = true;
foreach($tmp_networks as $ssid => $network) { foreach ($tmp_networks as $ssid => $network) {
if ($network['protocol'] === 'Open') { if ($network['protocol'] === 'Open') {
fwrite($wpa_file, "network={".PHP_EOL); fwrite($wpa_file, "network={".PHP_EOL);
fwrite($wpa_file, "\tssid=\"".$ssid."\"".PHP_EOL); fwrite($wpa_file, "\tssid=\"".$ssid."\"".PHP_EOL);
@ -90,8 +90,8 @@ function DisplayWPAConfig(){
if (strlen($network['passphrase']) >=8 && strlen($network['passphrase']) <= 63) { if (strlen($network['passphrase']) >=8 && strlen($network['passphrase']) <= 63) {
unset($wpa_passphrase); unset($wpa_passphrase);
unset($line); unset($line);
exec( 'wpa_passphrase '.escapeshellarg($ssid). ' ' . escapeshellarg($network['passphrase']),$wpa_passphrase ); exec('wpa_passphrase '.escapeshellarg($ssid). ' ' . escapeshellarg($network['passphrase']), $wpa_passphrase);
foreach($wpa_passphrase as $line) { foreach ($wpa_passphrase as $line) {
if (preg_match('/^\s*}\s*$/', $line)) { if (preg_match('/^\s*}\s*$/', $line)) {
if (array_key_exists('priority', $network)) { if (array_key_exists('priority', $network)) {
fwrite($wpa_file, "\tpriority=".$network['priority'].PHP_EOL); fwrite($wpa_file, "\tpriority=".$network['priority'].PHP_EOL);
@ -109,9 +109,9 @@ function DisplayWPAConfig(){
} }
if ($ok) { if ($ok) {
system( 'sudo cp /tmp/wifidata ' . RASPI_WPA_SUPPLICANT_CONFIG, $returnval ); system('sudo cp /tmp/wifidata ' . RASPI_WPA_SUPPLICANT_CONFIG, $returnval);
if( $returnval == 0 ) { if ($returnval == 0) {
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' reconfigure', $reconfigure_out, $reconfigure_return ); exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' reconfigure', $reconfigure_out, $reconfigure_return);
if ($reconfigure_return == 0) { if ($reconfigure_return == 0) {
$status->addMessage('Wifi settings updated successfully', 'success'); $status->addMessage('Wifi settings updated successfully', 'success');
$networks = $tmp_networks; $networks = $tmp_networks;
@ -127,15 +127,15 @@ function DisplayWPAConfig(){
} }
} }
exec( 'sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan' ); exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan');
sleep(3); sleep(3);
exec( 'sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan_results',$scan_return ); exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan_results', $scan_return);
array_shift($scan_return); array_shift($scan_return);
// display output // display output
foreach( $scan_return as $network ) { foreach ($scan_return as $network) {
$arrNetwork = preg_split("/[\t]+/",$network); // split result into array $arrNetwork = preg_split("/[\t]+/", $network); // split result into array
// Save RSSI // Save RSSI
if (array_key_exists(4, $arrNetwork)) { if (array_key_exists(4, $arrNetwork)) {
@ -159,9 +159,9 @@ function DisplayWPAConfig(){
} }
} }
exec( 'iwconfig ' . RASPI_WIFI_CLIENT_INTERFACE, $iwconfig_return ); exec('iwconfig ' . RASPI_WIFI_CLIENT_INTERFACE, $iwconfig_return);
foreach ($iwconfig_return as $line) { foreach ($iwconfig_return as $line) {
if (preg_match( '/ESSID:\"([^"]+)\"/i',$line,$iwconfig_ssid )) { if (preg_match('/ESSID:\"([^"]+)\"/i', $line, $iwconfig_ssid)) {
$networks[$iwconfig_ssid[1]]['connected'] = true; $networks[$iwconfig_ssid[1]]['connected'] = true;
} }
} }
@ -231,9 +231,13 @@ function DisplayWPAConfig(){
<div class="col-xs-6 col-md-6"> <div class="col-xs-6 col-md-6">
<?php echo htmlspecialchars($network['RSSI'], ENT_QUOTES); <?php echo htmlspecialchars($network['RSSI'], ENT_QUOTES);
echo "dB ("; echo "dB (";
if($network['RSSI'] >= -50) { echo 100; } if ($network['RSSI'] >= -50) {
else if($network['RSSI'] <= -100) { echo 0;} echo 100;
else {echo 2*($network['RSSI'] + 100); } } elseif ($network['RSSI'] <= -100) {
echo 0;
} else {
echo 2*($network['RSSI'] + 100);
}
echo "%)"; echo "%)";
?> ?>
</div> </div>

View File

@ -3,7 +3,8 @@
/** /**
* Show dashboard page. * Show dashboard page.
*/ */
function DisplayDashboard(){ function DisplayDashboard()
{
$status = new StatusMessages(); $status = new StatusMessages();
// Need this check interface name for proper shell execution. // Need this check interface name for proper shell execution.
@ -23,7 +24,7 @@ function DisplayDashboard(){
$stdoutIpAllLinesGlued = implode(" ", $stdoutIp); $stdoutIpAllLinesGlued = implode(" ", $stdoutIp);
$stdoutIpWRepeatedSpaces = preg_replace('/\s\s+/', ' ', $stdoutIpAllLinesGlued); $stdoutIpWRepeatedSpaces = preg_replace('/\s\s+/', ' ', $stdoutIpAllLinesGlued);
preg_match('/link\/ether ([0-9a-f:]+)/i', $stdoutIpWRepeatedSpaces, $matchesMacAddr ) || $matchesMacAddr[1] = _('No MAC Address Found'); preg_match('/link\/ether ([0-9a-f:]+)/i', $stdoutIpWRepeatedSpaces, $matchesMacAddr) || $matchesMacAddr[1] = _('No MAC Address Found');
$macAddr = $matchesMacAddr[1]; $macAddr = $matchesMacAddr[1];
$ipv4Addrs = ''; $ipv4Addrs = '';
@ -57,7 +58,7 @@ function DisplayDashboard(){
} }
} }
preg_match('/state (UP|DOWN)/i', $stdoutIpWRepeatedSpaces, $matchesState ) || $matchesState[1] = 'unknown'; preg_match('/state (UP|DOWN)/i', $stdoutIpWRepeatedSpaces, $matchesState) || $matchesState[1] = 'unknown';
$interfaceState = $matchesState[1]; $interfaceState = $matchesState[1];
// Because of table layout used in the ip output we get the interface statistics directly from // Because of table layout used in the ip output we get the interface statistics directly from
@ -123,7 +124,7 @@ function DisplayDashboard(){
$stdoutIwInfoAllLinesGlued = implode(' ', $stdoutIwInfo); $stdoutIwInfoAllLinesGlued = implode(' ', $stdoutIwInfo);
$stdoutIpInfoWRepSpaces = preg_replace('/\s\s+/', ' ', $stdoutIwInfoAllLinesGlued); $stdoutIpInfoWRepSpaces = preg_replace('/\s\s+/', ' ', $stdoutIwInfoAllLinesGlued);
preg_match('/txpower ([0-9\.]+ dBm)/i', $stdoutIpInfoWRepSpaces, $matchesTxPower ) || $matchesTxPower[1] = ''; preg_match('/txpower ([0-9\.]+ dBm)/i', $stdoutIpInfoWRepSpaces, $matchesTxPower) || $matchesTxPower[1] = '';
$txPower = $matchesTxPower[1]; $txPower = $matchesTxPower[1];
// iw does not have the "Link Quality". This is a is an aggregate value, // iw does not have the "Link Quality". This is a is an aggregate value,
@ -150,7 +151,7 @@ function DisplayDashboard(){
// Pressed stop button // Pressed stop button
if ($interfaceState === 'UP') { if ($interfaceState === 'UP') {
$status->addMessage(sprintf(_('Interface is going %s.'), _('down')), 'warning'); $status->addMessage(sprintf(_('Interface is going %s.'), _('down')), 'warning');
exec( 'sudo ip link set '.RASPI_WIFI_CLIENT_INTERFACE.' down' ); exec('sudo ip link set '.RASPI_WIFI_CLIENT_INTERFACE.' down');
$wlan0up = false; $wlan0up = false;
$status->addMessage(sprintf(_('Interface is now %s.'), _('down')), 'success'); $status->addMessage(sprintf(_('Interface is now %s.'), _('down')), 'success');
} elseif ($interfaceState === 'unknown') { } elseif ($interfaceState === 'unknown') {
@ -158,7 +159,7 @@ function DisplayDashboard(){
} else { } else {
$status->addMessage(sprintf(_('Interface already %s.'), _('down')), 'warning'); $status->addMessage(sprintf(_('Interface already %s.'), _('down')), 'warning');
} }
} elseif( isset($_POST['ifup_wlan0']) ) { } elseif (isset($_POST['ifup_wlan0'])) {
// Pressed start button // Pressed start button
if ($interfaceState === 'DOWN') { if ($interfaceState === 'DOWN') {
$status->addMessage(sprintf(_('Interface is going %s.'), _('up')), 'warning'); $status->addMessage(sprintf(_('Interface is going %s.'), _('up')), 'warning');
@ -238,7 +239,7 @@ function DisplayDashboard(){
<tbody> <tbody>
<?php <?php
exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(arp -i '.RASPI_WIFI_CLIENT_INTERFACE.' | grep -oE "(([0-9]|[a-f]|[A-F]){2}:){5}([0-9]|[a-f]|[A-F]){2}" | tr "\n" "\|" | sed "s/.$//")', $clients); exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(arp -i '.RASPI_WIFI_CLIENT_INTERFACE.' | grep -oE "(([0-9]|[a-f]|[A-F]){2}:){5}([0-9]|[a-f]|[A-F]){2}" | tr "\n" "\|" | sed "s/.$//")', $clients);
foreach( $clients as $client ) { foreach ($clients as $client) {
$client_items = explode(' ', $client); $client_items = explode(' ', $client);
echo '<tr>'.PHP_EOL; echo '<tr>'.PHP_EOL;
echo '<td>'.htmlspecialchars($client_items[3], ENT_QUOTES).'</td>'.PHP_EOL; echo '<td>'.htmlspecialchars($client_items[3], ENT_QUOTES).'</td>'.PHP_EOL;
@ -258,11 +259,11 @@ foreach( $clients as $client ) {
<div class="col-lg-12"> <div class="col-lg-12">
<div class="row"> <div class="row">
<form action="?page=wlan0_info" method="POST"> <form action="?page=wlan0_info" method="POST">
<?php if ( !$wlan0up ) { <?php if (!$wlan0up) {
echo '<input type="submit" class="btn btn-success" value="'._("Start ").RASPI_WIFI_CLIENT_INTERFACE.'" name="ifup_wlan0" />'; echo '<input type="submit" class="btn btn-success" value="'._("Start ").RASPI_WIFI_CLIENT_INTERFACE.'" name="ifup_wlan0" />';
} else { } else {
echo '<input type="submit" class="btn btn-warning" value="'._("Stop ").RASPI_WIFI_CLIENT_INTERFACE.'" name="ifdown_wlan0" />'; echo '<input type="submit" class="btn btn-warning" value="'._("Stop ").RASPI_WIFI_CLIENT_INTERFACE.'" name="ifdown_wlan0" />';
} }
?> ?>
<input type="button" class="btn btn-outline btn-primary" value="<?php echo _("Refresh"); ?>" onclick="document.location.reload(true)" /> <input type="button" class="btn btn-outline btn-primary" value="<?php echo _("Refresh"); ?>" onclick="document.location.reload(true)" />
</form> </form>

View File

@ -5,7 +5,7 @@
*/ */
function DisplayDataUsage(&$extraFooterScripts) function DisplayDataUsage(&$extraFooterScripts)
{ {
exec("ip -o link show | awk -F ': ' '{print $2}' | grep -v lo ", $interfacesWlo); exec("ip -o link show | awk -F ': ' '{print $2}' | grep -v lo ", $interfacesWlo);
?> ?>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">

View File

@ -1,16 +1,17 @@
<?php <?php
include_once( 'includes/status_messages.php' ); include_once('includes/status_messages.php');
/** /**
* *
* Manage DHCP configuration * Manage DHCP configuration
* *
*/ */
function DisplayDHCPConfig() { function DisplayDHCPConfig()
{
$status = new StatusMessages(); $status = new StatusMessages();
if( isset( $_POST['savedhcpdsettings'] ) ) { if (isset($_POST['savedhcpdsettings'])) {
if (CSRFValidate()) { if (CSRFValidate()) {
$errors = ''; $errors = '';
define('IFNAMSIZ', 16); define('IFNAMSIZ', 16);
@ -63,10 +64,10 @@ function DisplayDHCPConfig() {
} }
} }
exec( 'pidof dnsmasq | wc -l',$dnsmasq ); exec('pidof dnsmasq | wc -l', $dnsmasq);
$dnsmasq_state = ($dnsmasq[0] > 0); $dnsmasq_state = ($dnsmasq[0] > 0);
if( isset( $_POST['startdhcpd'] ) ) { if (isset($_POST['startdhcpd'])) {
if (CSRFValidate()) { if (CSRFValidate()) {
if ($dnsmasq_state) { if ($dnsmasq_state) {
$status->addMessage('dnsmasq already running', 'info'); $status->addMessage('dnsmasq already running', 'info');
@ -82,7 +83,7 @@ function DisplayDHCPConfig() {
} else { } else {
error_log('CSRF violation'); error_log('CSRF violation');
} }
} elseif( isset($_POST['stopdhcpd'] ) ) { } elseif (isset($_POST['stopdhcpd'])) {
if (CSRFValidate()) { if (CSRFValidate()) {
if ($dnsmasq_state) { if ($dnsmasq_state) {
exec('sudo /etc/init.d/dnsmasq stop', $dnsmasq, $return); exec('sudo /etc/init.d/dnsmasq stop', $dnsmasq, $return);
@ -99,16 +100,16 @@ function DisplayDHCPConfig() {
error_log('CSRF violation'); error_log('CSRF violation');
} }
} else { } else {
if( $dnsmasq_state ) { if ($dnsmasq_state) {
$status->addMessage('Dnsmasq is running', 'success'); $status->addMessage('Dnsmasq is running', 'success');
} else { } else {
$status->addMessage('Dnsmasq is not running', 'warning'); $status->addMessage('Dnsmasq is not running', 'warning');
} }
} }
exec( 'cat '. RASPI_DNSMASQ_CONFIG, $return ); exec('cat '. RASPI_DNSMASQ_CONFIG, $return);
$conf = ParseConfig($return); $conf = ParseConfig($return);
$arrRange = explode( ",", $conf['dhcp-range'] ); $arrRange = explode(",", $conf['dhcp-range']);
$RangeStart = $arrRange[0]; $RangeStart = $arrRange[0];
$RangeEnd = $arrRange[1]; $RangeEnd = $arrRange[1];
$RangeMask = $arrRange[2]; $RangeMask = $arrRange[2];
@ -118,11 +119,11 @@ function DisplayDHCPConfig() {
$mselected = ''; $mselected = '';
$dselected = ''; $dselected = '';
$infiniteselected = ''; $infiniteselected = '';
preg_match( '/([0-9]*)([a-z])/i', $leaseTime, $arrRangeLeaseTime ); preg_match('/([0-9]*)([a-z])/i', $leaseTime, $arrRangeLeaseTime);
if ($leaseTime === 'infinite') { if ($leaseTime === 'infinite') {
$infiniteselected = ' selected="selected"'; $infiniteselected = ' selected="selected"';
} else { } else {
switch( $arrRangeLeaseTime[2] ) { switch ($arrRangeLeaseTime[2]) {
case 'h': case 'h':
$hselected = ' selected="selected"'; $hselected = ' selected="selected"';
break; break;
@ -163,15 +164,15 @@ function DisplayDHCPConfig() {
<?php <?php
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces); exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
foreach( $interfaces as $inet ) { foreach ($interfaces as $inet) {
$select = ''; $select = '';
if( $inet === $conf['interface'] ) { if ($inet === $conf['interface']) {
$select = ' selected="selected"'; $select = ' selected="selected"';
} }
echo ' <option value="'.htmlspecialchars($inet, ENT_QUOTES).'"'. echo ' <option value="'.htmlspecialchars($inet, ENT_QUOTES).'"'.
$select.'>'.htmlspecialchars($inet, ENT_QUOTES).'</option>' , PHP_EOL; $select.'>'.htmlspecialchars($inet, ENT_QUOTES).'</option>' , PHP_EOL;
} }
?> ?>
</select> </select>
</div> </div>
@ -209,12 +210,12 @@ function DisplayDHCPConfig() {
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" /> <input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
<?php <?php
if ( $dnsmasq_state ) { if ($dnsmasq_state) {
echo '<input type="submit" class="btn btn-warning" value="' . _("Stop dnsmasq") . '" name="stopdhcpd" />'; echo '<input type="submit" class="btn btn-warning" value="' . _("Stop dnsmasq") . '" name="stopdhcpd" />';
} else { } else {
echo'<input type="submit" class="btn btn-success" value="' . _("Start dnsmasq") . '" name="startdhcpd" />'; echo'<input type="submit" class="btn btn-success" value="' . _("Start dnsmasq") . '" name="startdhcpd" />';
} }
?> ?>
</form> </form>
</div><!-- /.tab-pane --> </div><!-- /.tab-pane -->
@ -238,11 +239,11 @@ function DisplayDHCPConfig() {
</thead> </thead>
<tbody> <tbody>
<?php <?php
exec( 'cat ' . RASPI_DNSMASQ_LEASES, $leases ); exec('cat ' . RASPI_DNSMASQ_LEASES, $leases);
foreach( $leases as $lease ) { foreach ($leases as $lease) {
echo ' <tr>'.PHP_EOL; echo ' <tr>'.PHP_EOL;
$lease_items = explode(' ', $lease); $lease_items = explode(' ', $lease);
foreach( $lease_items as $lease_item ) { foreach ($lease_items as $lease_item) {
echo ' <td>'.htmlspecialchars($lease_item, ENT_QUOTES).'</td>'.PHP_EOL; echo ' <td>'.htmlspecialchars($lease_item, ENT_QUOTES).'</td>'.PHP_EOL;
} }
echo ' </tr>'.PHP_EOL; echo ' </tr>'.PHP_EOL;

View File

@ -1,38 +1,46 @@
<?php <?php
/* Functions for Networking */ /* Functions for Networking */
function mask2cidr($mask){ function mask2cidr($mask)
{
$long = ip2long($mask); $long = ip2long($mask);
$base = ip2long('255.255.255.255'); $base = ip2long('255.255.255.255');
return 32-log(($long ^ $base)+1,2); return 32-log(($long ^ $base)+1, 2);
} }
/* Functions to write ini files */ /* Functions to write ini files */
function write_php_ini($array, $file) { function write_php_ini($array, $file)
{
$res = array(); $res = array();
foreach($array as $key => $val) { foreach ($array as $key => $val) {
if(is_array($val)) { if (is_array($val)) {
$res[] = "[$key]"; $res[] = "[$key]";
foreach($val as $skey => $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"'); foreach ($val as $skey => $sval) {
$res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"');
} }
else $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"'); } else {
$res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"');
} }
if(safefilerewrite($file, implode("\r\n", $res))) { }
if (safefilerewrite($file, implode("\r\n", $res))) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
function safefilerewrite($fileName, $dataToSave) { function safefilerewrite($fileName, $dataToSave)
{
if ($fp = fopen($fileName, 'w')) { if ($fp = fopen($fileName, 'w')) {
$startTime = microtime(TRUE); $startTime = microtime(true);
do { do {
$canWrite = flock($fp, LOCK_EX); $canWrite = flock($fp, LOCK_EX);
// If lock not obtained sleep for 0 - 100 milliseconds, to avoid collision and CPU load // If lock not obtained sleep for 0 - 100 milliseconds, to avoid collision and CPU load
if(!$canWrite) usleep(round(rand(0, 100)*1000)); if (!$canWrite) {
} while ((!$canWrite)and((microtime(TRUE)-$startTime) < 5)); usleep(round(rand(0, 100)*1000));
}
} while ((!$canWrite)and((microtime(true)-$startTime) < 5));
//file was locked so now we can store information //file was locked so now we can store information
if ($canWrite) { if ($canWrite) {
@ -46,16 +54,16 @@ function safefilerewrite($fileName, $dataToSave) {
} }
} }
/** /**
* *
* Add CSRF Token to form * Add CSRF Token to form
* *
*/ */
function CSRFToken() { function CSRFToken()
{
?> ?>
<input id="csrf_token" type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($_SESSION['csrf_token'], ENT_QUOTES);; ?>" /> <input id="csrf_token" type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($_SESSION['csrf_token'], ENT_QUOTES);
; ?>" />
<?php <?php
} }
@ -64,8 +72,9 @@ function CSRFToken() {
* Validate CSRF Token * Validate CSRF Token
* *
*/ */
function CSRFValidate() { function CSRFValidate()
if ( hash_equals($_POST['csrf_token'], $_SESSION['csrf_token']) ) { {
if (hash_equals($_POST['csrf_token'], $_SESSION['csrf_token'])) {
return true; return true;
} else { } else {
error_log('CSRF violation'); error_log('CSRF violation');
@ -76,7 +85,8 @@ function CSRFValidate() {
/** /**
* Test whether array is associative * Test whether array is associative
*/ */
function isAssoc($arr) { function isAssoc($arr)
{
return array_keys($arr) !== range(0, count($arr) - 1); return array_keys($arr) !== range(0, count($arr) - 1);
} }
@ -89,17 +99,18 @@ function isAssoc($arr) {
* If $options is an associative array this should be the key * If $options is an associative array this should be the key
* *
*/ */
function SelectorOptions($name, $options, $selected = null, $id = null) { function SelectorOptions($name, $options, $selected = null, $id = null)
{
echo '<select class="form-control" name="'.htmlspecialchars($name, ENT_QUOTES).'"'; echo '<select class="form-control" name="'.htmlspecialchars($name, ENT_QUOTES).'"';
if (isset($id)) { if (isset($id)) {
echo ' id="' . htmlspecialchars($id, ENT_QUOTES) .'"'; echo ' id="' . htmlspecialchars($id, ENT_QUOTES) .'"';
} }
echo '>' , PHP_EOL; echo '>' , PHP_EOL;
foreach ( $options as $opt => $label) { foreach ($options as $opt => $label) {
$select = ''; $select = '';
$key = isAssoc($options) ? $opt : $label; $key = isAssoc($options) ? $opt : $label;
if( $key == $selected ) { if ($key == $selected) {
$select = ' selected="selected"'; $select = ' selected="selected"';
} }
@ -118,8 +129,9 @@ function SelectorOptions($name, $options, $selected = null, $id = null) {
* @param string $separator * @param string $separator
* @return $string * @return $string
*/ */
function GetDistString( $input,$string,$offset,$separator ) { function GetDistString($input, $string, $offset, $separator)
$string = substr( $input,strpos( $input,$string )+$offset,strpos( substr( $input,strpos( $input,$string )+$offset ), $separator ) ); {
$string = substr($input, strpos($input, $string)+$offset, strpos(substr($input, strpos($input, $string)+$offset), $separator));
return $string; return $string;
} }
@ -128,12 +140,13 @@ function GetDistString( $input,$string,$offset,$separator ) {
* @param array $arrConfig * @param array $arrConfig
* @return $config * @return $config
*/ */
function ParseConfig( $arrConfig ) { function ParseConfig($arrConfig)
{
$config = array(); $config = array();
foreach( $arrConfig as $line ) { foreach ($arrConfig as $line) {
$line = trim($line); $line = trim($line);
if( $line != "" && $line[0] != "#" ) { if ($line != "" && $line[0] != "#") {
$arrLine = explode( "=",$line ); $arrLine = explode("=", $line);
$config[$arrLine[0]] = ( count($arrLine) > 1 ? $arrLine[1] : true ); $config[$arrLine[0]] = ( count($arrLine) > 1 ? $arrLine[1] : true );
} }
} }
@ -145,7 +158,8 @@ function ParseConfig( $arrConfig ) {
* @param string $freq * @param string $freq
* @return $channel * @return $channel
*/ */
function ConvertToChannel( $freq ) { function ConvertToChannel($freq)
{
if ($freq >= 2412 && $freq <= 2484) { if ($freq >= 2412 && $freq <= 2484) {
$channel = ($freq - 2407)/5; $channel = ($freq - 2407)/5;
} elseif ($freq >= 4915 && $freq <= 4980) { } elseif ($freq >= 4915 && $freq <= 4980) {
@ -167,10 +181,11 @@ function ConvertToChannel( $freq ) {
* @param string $security * @param string $security
* @return string * @return string
*/ */
function ConvertToSecurity( $security ) { function ConvertToSecurity($security)
{
$options = array(); $options = array();
preg_match_all('/\[([^\]]+)\]/s', $security, $matches); preg_match_all('/\[([^\]]+)\]/s', $security, $matches);
foreach($matches[1] as $match) { foreach ($matches[1] as $match) {
if (preg_match('/^(WPA\d?)/', $match, $protocol_match)) { if (preg_match('/^(WPA\d?)/', $match, $protocol_match)) {
$protocol = $protocol_match[1]; $protocol = $protocol_match[1];
$matchArr = explode('-', $match); $matchArr = explode('-', $match);
@ -196,13 +211,14 @@ function ConvertToSecurity( $security ) {
* *
* *
*/ */
function DisplayOpenVPNConfig() { function DisplayOpenVPNConfig()
{
exec( 'cat '. RASPI_OPENVPN_CLIENT_CONFIG, $returnClient ); exec('cat '. RASPI_OPENVPN_CLIENT_CONFIG, $returnClient);
exec( 'cat '. RASPI_OPENVPN_SERVER_CONFIG, $returnServer ); exec('cat '. RASPI_OPENVPN_SERVER_CONFIG, $returnServer);
exec( 'pidof openvpn | wc -l', $openvpnstatus); exec('pidof openvpn | wc -l', $openvpnstatus);
if( $openvpnstatus[0] == 0 ) { if ($openvpnstatus[0] == 0) {
$status = '<div class="alert alert-warning alert-dismissable">OpenVPN is not running $status = '<div class="alert alert-warning alert-dismissable">OpenVPN is not running
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'; <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>';
} else { } else {
@ -211,17 +227,17 @@ function DisplayOpenVPNConfig() {
} }
// parse client settings // parse client settings
foreach( $returnClient as $a ) { foreach ($returnClient as $a) {
if( $a[0] != "#" ) { if ($a[0] != "#") {
$arrLine = explode( " ",$a) ; $arrLine = explode(" ", $a) ;
$arrClientConfig[$arrLine[0]]=$arrLine[1]; $arrClientConfig[$arrLine[0]]=$arrLine[1];
} }
} }
// parse server settings // parse server settings
foreach( $returnServer as $a ) { foreach ($returnServer as $a) {
if( $a[0] != "#" ) { if ($a[0] != "#") {
$arrLine = explode( " ",$a) ; $arrLine = explode(" ", $a) ;
$arrServerConfig[$arrLine[0]]=$arrLine[1]; $arrServerConfig[$arrLine[0]]=$arrLine[1];
} }
} }
@ -305,7 +321,7 @@ function DisplayOpenVPNConfig() {
</div> </div>
<input type="submit" class="btn btn-outline btn-primary" name="SaveOpenVPNSettings" value="Save settings" /> <input type="submit" class="btn btn-outline btn-primary" name="SaveOpenVPNSettings" value="Save settings" />
<?php <?php
if($hostapdstatus[0] == 0) { if ($hostapdstatus[0] == 0) {
echo '<input type="submit" class="btn btn-success" name="StartOpenVPN" value="Start OpenVPN" />' , PHP_EOL; echo '<input type="submit" class="btn btn-success" name="StartOpenVPN" value="Start OpenVPN" />' , PHP_EOL;
} else { } else {
echo '<input type="submit" class="btn btn-warning" name="StopOpenVPN" value="Stop OpenVPN" />' , PHP_EOL; echo '<input type="submit" class="btn btn-warning" name="StopOpenVPN" value="Stop OpenVPN" />' , PHP_EOL;
@ -324,12 +340,13 @@ function DisplayOpenVPNConfig() {
* *
* *
*/ */
function DisplayTorProxyConfig(){ function DisplayTorProxyConfig()
{
exec( 'cat '. RASPI_TORPROXY_CONFIG, $return ); exec('cat '. RASPI_TORPROXY_CONFIG, $return);
exec( 'pidof tor | wc -l', $torproxystatus); exec('pidof tor | wc -l', $torproxystatus);
if( $torproxystatus[0] == 0 ) { if ($torproxystatus[0] == 0) {
$status = '<div class="alert alert-warning alert-dismissable">TOR is not running $status = '<div class="alert alert-warning alert-dismissable">TOR is not running
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'; <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>';
} else { } else {
@ -338,9 +355,9 @@ function DisplayTorProxyConfig(){
} }
$arrConfig = array(); $arrConfig = array();
foreach( $return as $a ) { foreach ($return as $a) {
if( $a[0] != "#" ) { if ($a[0] != "#") {
$arrLine = explode( " ",$a) ; $arrLine = explode(" ", $a) ;
$arrConfig[$arrLine[0]]=$arrLine[1]; $arrConfig[$arrLine[0]]=$arrLine[1];
} }
} }
@ -446,7 +463,7 @@ function DisplayTorProxyConfig(){
<input type="submit" class="btn btn-outline btn-primary" name="SaveTORProxySettings" value="Save settings" /> <input type="submit" class="btn btn-outline btn-primary" name="SaveTORProxySettings" value="Save settings" />
<?php <?php
if( $torproxystatus[0] == 0 ) { if ($torproxystatus[0] == 0) {
echo '<input type="submit" class="btn btn-success" name="StartTOR" value="Start TOR" />' , PHP_EOL; echo '<input type="submit" class="btn btn-success" name="StartTOR" value="Start TOR" />' , PHP_EOL;
} else { } else {
echo '<input type="submit" class="btn btn-warning" name="StopTOR" value="Stop TOR" />' , PHP_EOL; echo '<input type="submit" class="btn btn-warning" name="StopTOR" value="Stop TOR" />' , PHP_EOL;
@ -466,33 +483,34 @@ function DisplayTorProxyConfig(){
* *
* *
*/ */
function SaveTORAndVPNConfig(){ function SaveTORAndVPNConfig()
if( isset($_POST['SaveOpenVPNSettings']) ) { {
if (isset($_POST['SaveOpenVPNSettings'])) {
// TODO // TODO
} elseif( isset($_POST['SaveTORProxySettings']) ) { } elseif (isset($_POST['SaveTORProxySettings'])) {
// TODO // TODO
} elseif( isset($_POST['StartOpenVPN']) ) { } elseif (isset($_POST['StartOpenVPN'])) {
echo "Attempting to start openvpn"; echo "Attempting to start openvpn";
exec( 'sudo /etc/init.d/openvpn start', $return ); exec('sudo /etc/init.d/openvpn start', $return);
foreach( $return as $line ) { foreach ($return as $line) {
echo htmlspecialchars($line, ENT_QUOTES).'<br />' , PHP_EOL; echo htmlspecialchars($line, ENT_QUOTES).'<br />' , PHP_EOL;
} }
} elseif( isset($_POST['StopOpenVPN']) ) { } elseif (isset($_POST['StopOpenVPN'])) {
echo "Attempting to stop openvpn"; echo "Attempting to stop openvpn";
exec( 'sudo /etc/init.d/openvpn stop', $return ); exec('sudo /etc/init.d/openvpn stop', $return);
foreach( $return as $line ) { foreach ($return as $line) {
echo htmlspecialchars($line, ENT_QUOTES).'<br />' , PHP_EOL; echo htmlspecialchars($line, ENT_QUOTES).'<br />' , PHP_EOL;
} }
} elseif( isset($_POST['StartTOR']) ) { } elseif (isset($_POST['StartTOR'])) {
echo "Attempting to start TOR"; echo "Attempting to start TOR";
exec( 'sudo /etc/init.d/tor start', $return ); exec('sudo /etc/init.d/tor start', $return);
foreach( $return as $line ) { foreach ($return as $line) {
echo htmlspecialchars($line, ENT_QUOTES).'<br />' , PHP_EOL; echo htmlspecialchars($line, ENT_QUOTES).'<br />' , PHP_EOL;
} }
} elseif( isset($_POST['StopTOR']) ) { } elseif (isset($_POST['StopTOR'])) {
echo "Attempting to stop TOR"; echo "Attempting to stop TOR";
exec( 'sudo /etc/init.d/tor stop', $return ); exec('sudo /etc/init.d/tor stop', $return);
foreach( $return as $line ) { foreach ($return as $line) {
echo htmlspecialchars($line, ENT_QUOTES).'<br />' , PHP_EOL; echo htmlspecialchars($line, ENT_QUOTES).'<br />' , PHP_EOL;
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
include_once( 'includes/status_messages.php' ); include_once('includes/status_messages.php');
/** /**
* *
@ -9,40 +9,38 @@ include_once( 'includes/status_messages.php' );
function DisplayHostAPDConfig() function DisplayHostAPDConfig()
{ {
$status = new StatusMessages(); $status = new StatusMessages();
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini'); $arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
$arrConfig = array(); $arrConfig = array();
$arr80211Standard = array('a','b','g','n'); $arr80211Standard = array('a','b','g','n');
$arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None")); $arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP'); $arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces); exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
if( isset($_POST['SaveHostAPDSettings']) ) { if (isset($_POST['SaveHostAPDSettings'])) {
if (CSRFValidate()) { if (CSRFValidate()) {
SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status); SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
} else { } else {
error_log('CSRF violation'); error_log('CSRF violation');
} }
} elseif( isset($_POST['StartHotspot']) ) { } elseif (isset($_POST['StartHotspot'])) {
if (CSRFValidate()) { if (CSRFValidate()) {
$status->addMessage('Attempting to start hotspot', 'info'); $status->addMessage('Attempting to start hotspot', 'info');
if ($arrHostapdConf['WifiAPEnable'] == 1) { if ($arrHostapdConf['WifiAPEnable'] == 1) {
exec('sudo /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 5', $return ); exec('sudo /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 5', $return);
} else { } else {
exec( 'sudo /etc/raspap/hostapd/servicestart.sh --seconds 5', $return ); exec('sudo /etc/raspap/hostapd/servicestart.sh --seconds 5', $return);
} }
foreach( $return as $line ) { foreach ($return as $line) {
$status->addMessage($line, 'info'); $status->addMessage($line, 'info');
} }
} else { } else {
error_log('CSRF violation'); error_log('CSRF violation');
} }
} elseif( isset($_POST['StopHotspot']) ) { } elseif (isset($_POST['StopHotspot'])) {
if (CSRFValidate()) { if (CSRFValidate()) {
$status->addMessage('Attempting to stop hotspot', 'info'); $status->addMessage('Attempting to stop hotspot', 'info');
exec( 'sudo /etc/init.d/hostapd stop', $return ); exec('sudo /etc/init.d/hostapd stop', $return);
foreach( $return as $line ) { foreach ($return as $line) {
$status->addMessage($line, 'info'); $status->addMessage($line, 'info');
} }
} else { } else {
@ -50,21 +48,21 @@ function DisplayHostAPDConfig()
} }
} }
exec( 'cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig ); exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
exec( 'pidof hostapd | wc -l', $hostapdstatus); exec('pidof hostapd | wc -l', $hostapdstatus);
if( $hostapdstatus[0] == 0 ) { if ($hostapdstatus[0] == 0) {
$status->addMessage('HostAPD is not running', 'warning'); $status->addMessage('HostAPD is not running', 'warning');
} else { } else {
$status->addMessage('HostAPD is running', 'success'); $status->addMessage('HostAPD is running', 'success');
} }
foreach( $hostapdconfig as $hostapdconfigline ) { foreach ($hostapdconfig as $hostapdconfigline) {
if (strlen($hostapdconfigline) === 0) { if (strlen($hostapdconfigline) === 0) {
continue; continue;
} }
if ($hostapdconfigline[0] != "#" ) { if ($hostapdconfigline[0] != "#") {
$arrLine = explode("=", $hostapdconfigline) ; $arrLine = explode("=", $hostapdconfigline) ;
$arrConfig[$arrLine[0]]=$arrLine[1]; $arrConfig[$arrLine[0]]=$arrLine[1];
} }
@ -111,26 +109,26 @@ function DisplayHostAPDConfig()
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="cbxhwmode"><?php echo _("Wireless Mode") ;?></label> <label for="cbxhwmode"><?php echo _("Wireless Mode") ;?></label>
<?php <?php
$selectedHwMode = $arrConfig['hw_mode']; $selectedHwMode = $arrConfig['hw_mode'];
if (isset($arrConfig['ieee80211n'])) { if (isset($arrConfig['ieee80211n'])) {
if (strval($arrConfig['ieee80211n']) === '1') { if (strval($arrConfig['ieee80211n']) === '1') {
$selectedHwMode = 'n'; $selectedHwMode = 'n';
} }
} }
SelectorOptions('hw_mode', $arr80211Standard, $selectedHwMode, 'cbxhwmode'); ?> SelectorOptions('hw_mode', $arr80211Standard, $selectedHwMode, 'cbxhwmode'); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="cbxchannel"><?php echo _("Channel"); ?></label> <label for="cbxchannel"><?php echo _("Channel"); ?></label>
<?php <?php
$selectablechannels = range(1, 13); $selectablechannels = range(1, 13);
$countries_2_4Ghz_max11ch = array('AG', 'BS', 'BB', 'BZ', 'CR', 'CU', 'DM', 'DO', 'SV', 'GD', 'GT', $countries_2_4Ghz_max11ch = array('AG', 'BS', 'BB', 'BZ', 'CR', 'CU', 'DM', 'DO', 'SV', 'GD', 'GT',
'HT', 'HN', 'JM', 'MX', 'NI', 'PA', 'KN', 'LC', 'VC', 'TT', 'HT', 'HN', 'JM', 'MX', 'NI', 'PA', 'KN', 'LC', 'VC', 'TT',
'US', 'CA', 'UZ', 'CO'); 'US', 'CA', 'UZ', 'CO');
$countries_2_4Ghz_max14ch = array('JA'); $countries_2_4Ghz_max14ch = array('JA');
if (in_array($arrConfig['country_code'], $countries_max11channels)) { if (in_array($arrConfig['country_code'], $countries_max11channels)) {
// In North America till channel 11 is the maximum allowed wi-fi 2.4Ghz channel. // In North America till channel 11 is the maximum allowed wi-fi 2.4Ghz channel.
// Except for the US that allows channel 12 & 13 in low power mode with additional restrictions. // Except for the US that allows channel 12 & 13 in low power mode with additional restrictions.
// Canada that allows channel 12 in low power mode. Because it's unsure if low powered mode // Canada that allows channel 12 in low power mode. Because it's unsure if low powered mode
@ -138,11 +136,11 @@ if (in_array($arrConfig['country_code'], $countries_max11channels)) {
// source: https://en.wikipedia.org/wiki/List_of_WLAN_channels#Interference_concerns // source: https://en.wikipedia.org/wiki/List_of_WLAN_channels#Interference_concerns
// Also Uzbekistan and Colombia allow to select till channel 11 as maximum channel on the 2.4Ghz wi-fi band. // Also Uzbekistan and Colombia allow to select till channel 11 as maximum channel on the 2.4Ghz wi-fi band.
$selectablechannels = range(1, 11); $selectablechannels = range(1, 11);
} elseif (in_array($arrConfig['country_code'], $countries_2_4Ghz_max14ch)) { } elseif (in_array($arrConfig['country_code'], $countries_2_4Ghz_max14ch)) {
if ($arrConfig['hw_mode'] === 'b') { if ($arrConfig['hw_mode'] === 'b') {
$selectablechannels = range(1, 14); $selectablechannels = range(1, 14);
} }
} }
SelectorOptions('channel', $selectablechannels, intval($arrConfig['channel']), 'cbxchannel'); ?> SelectorOptions('channel', $selectablechannels, intval($arrConfig['channel']), 'cbxchannel'); ?>
</div> </div>
</div> </div>
@ -173,7 +171,7 @@ if (in_array($arrConfig['country_code'], $countries_max11channels)) {
<div class="row"> <div class="row">
<div class="form-group col-md-8"> <div class="form-group col-md-8">
<?php <?php
if($arrHostapdConf['LogEnable'] == 1) { if ($arrHostapdConf['LogEnable'] == 1) {
$log = file_get_contents('/tmp/hostapd.log'); $log = file_get_contents('/tmp/hostapd.log');
echo '<br /><textarea class="logoutput">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>'; echo '<br /><textarea class="logoutput">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
} else { } else {
@ -499,7 +497,7 @@ for (var i = 0; i < ops.length; ++i) {
</div><!-- /.panel-primary --> </div><!-- /.panel-primary -->
<input type="submit" class="btn btn-outline btn-primary" name="SaveHostAPDSettings" value="<?php echo _("Save settings"); ?>" /> <input type="submit" class="btn btn-outline btn-primary" name="SaveHostAPDSettings" value="<?php echo _("Save settings"); ?>" />
<?php <?php
if($hostapdstatus[0] == 0) { if ($hostapdstatus[0] == 0) {
echo '<input type="submit" class="btn btn-success" name="StartHotspot" value="' . _("Start hotspot") . '"/>' , PHP_EOL; echo '<input type="submit" class="btn btn-success" name="StartHotspot" value="' . _("Start hotspot") . '"/>' , PHP_EOL;
} else { } else {
echo '<input type="submit" class="btn btn-warning" name="StopHotspot" value="' . _("Stop hotspot") . '"/>' , PHP_EOL; echo '<input type="submit" class="btn btn-warning" name="StopHotspot" value="' . _("Stop hotspot") . '"/>' , PHP_EOL;
@ -513,7 +511,8 @@ for (var i = 0; i < ops.length; ++i) {
<?php <?php
} }
function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) { function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
{
// It should not be possible to send bad data for these fields so clearly // It should not be possible to send bad data for these fields so clearly
// someone is up to something if they fail. Fail silently. // someone is up to something if they fail. Fail silently.
if (!(array_key_exists($_POST['wpa'], $wpa_array) && if (!(array_key_exists($_POST['wpa'], $wpa_array) &&
@ -537,27 +536,27 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
// Check for WiFi client AP mode checkbox // Check for WiFi client AP mode checkbox
$wifiAPEnable = 0; $wifiAPEnable = 0;
if($arrHostapdConf['WifiAPEnable'] == 0) { if ($arrHostapdConf['WifiAPEnable'] == 0) {
if(isset($_POST['wifiAPEnable'])) { if (isset($_POST['wifiAPEnable'])) {
$wifiAPEnable = 1; $wifiAPEnable = 1;
} }
} else { } else {
if(isset($_POST['wifiAPEnable'])) { if (isset($_POST['wifiAPEnable'])) {
$wifiAPEnable = 1; $wifiAPEnable = 1;
} }
} }
// Check for Logfile output checkbox // Check for Logfile output checkbox
$logEnable = 0; $logEnable = 0;
if($arrHostapdConf['LogEnable'] == 0) { if ($arrHostapdConf['LogEnable'] == 0) {
if(isset($_POST['logEnable'])) { if (isset($_POST['logEnable'])) {
$logEnable = 1; $logEnable = 1;
exec('sudo /etc/raspap/hostapd/enablelog.sh'); exec('sudo /etc/raspap/hostapd/enablelog.sh');
} else { } else {
exec('sudo /etc/raspap/hostapd/disablelog.sh'); exec('sudo /etc/raspap/hostapd/disablelog.sh');
} }
} else { } else {
if(isset($_POST['logEnable'])) { if (isset($_POST['logEnable'])) {
$logEnable = 1; $logEnable = 1;
exec('sudo /etc/raspap/hostapd/enablelog.sh'); exec('sudo /etc/raspap/hostapd/enablelog.sh');
} else { } else {
@ -567,7 +566,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
$cfg = []; $cfg = [];
$cfg['LogEnable'] = $logEnable; $cfg['LogEnable'] = $logEnable;
$cfg['WifiAPEnable'] = $wifiAPEnable; $cfg['WifiAPEnable'] = $wifiAPEnable;
write_php_ini($cfg,'/etc/raspap/hostapd.ini'); write_php_ini($cfg, '/etc/raspap/hostapd.ini');
// Verify input // Verify input
if (empty($_POST['ssid']) || strlen($_POST['ssid']) > 32) { if (empty($_POST['ssid']) || strlen($_POST['ssid']) > 32) {
@ -639,7 +638,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
$config.= 'ignore_broadcast_ssid='.$ignore_broadcast_ssid.PHP_EOL; $config.= 'ignore_broadcast_ssid='.$ignore_broadcast_ssid.PHP_EOL;
exec('echo "'.$config.'" > /tmp/hostapddata', $temp); exec('echo "'.$config.'" > /tmp/hostapddata', $temp);
system( "sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return ); system("sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return);
if ($wifiAPEnable == 1) { if ($wifiAPEnable == 1) {
// Enable uap0 configuration in dnsmasq for Wifi client AP mode // Enable uap0 configuration in dnsmasq for Wifi client AP mode
@ -686,7 +685,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return); system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return);
if( $return == 0 ) { if ($return == 0) {
$status->addMessage('Wifi Hotspot settings saved', 'success'); $status->addMessage('Wifi Hotspot settings saved', 'success');
} else { } else {
$status->addMessage('Unable to save wifi hotspot settings', 'danger'); $status->addMessage('Unable to save wifi hotspot settings', 'danger');

View File

@ -1,11 +1,9 @@
<?php <?php
/** /**
* Sets locale information for i18n support * Sets locale information for i18n support
* *
*/ */
/** /**
* Rudimentary language detection via the browser. * Rudimentary language detection via the browser.
* Accept-Language returns a list of weighted values with a quality (or 'q') parameter. * Accept-Language returns a list of weighted values with a quality (or 'q') parameter.
@ -16,7 +14,7 @@
*/ */
if (empty($_SESSION['locale']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) { if (empty($_SESSION['locale']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){ switch ($lang) {
case "de": case "de":
$locale = "de_DE.UTF-8"; $locale = "de_DE.UTF-8";
break; break;
@ -72,4 +70,3 @@ bindtextdomain(LOCALE_DOMAIN, LOCALE_ROOT);
bind_textdomain_codeset(LOCALE_DOMAIN, 'UTF-8'); bind_textdomain_codeset(LOCALE_DOMAIN, 'UTF-8');
textdomain(LOCALE_DOMAIN); textdomain(LOCALE_DOMAIN);

View File

@ -1,19 +1,20 @@
<?php <?php
include_once( 'includes/status_messages.php' ); include_once('includes/status_messages.php');
/** /**
* *
* *
*/ */
function DisplayNetworkingConfig(){ function DisplayNetworkingConfig()
{
$status = new StatusMessages(); $status = new StatusMessages();
exec("ls /sys/class/net | grep -v lo", $interfaces); exec("ls /sys/class/net | grep -v lo", $interfaces);
foreach($interfaces as $interface) { foreach ($interfaces as $interface) {
exec("ip a show $interface",$$interface); exec("ip a show $interface", $$interface);
} }
CSRFToken(); CSRFToken();
@ -29,7 +30,7 @@ function DisplayNetworkingConfig(){
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li role="presentation" class="active"><a href="#summary" aria-controls="summary" role="tab" data-toggle="tab"><?php echo _("Summary"); ?></a></li> <li role="presentation" class="active"><a href="#summary" aria-controls="summary" role="tab" data-toggle="tab"><?php echo _("Summary"); ?></a></li>
<?php <?php
foreach($interfaces as $interface) { foreach ($interfaces as $interface) {
echo '<li role="presentation"><a href="#'.htmlspecialchars($interface, ENT_QUOTES).'" aria-controls="'.htmlspecialchars($interface, ENT_QUOTES).'" role="tab" data-toggle="tab">'.htmlspecialchars($interface, ENT_QUOTES).'</a></li>'; echo '<li role="presentation"><a href="#'.htmlspecialchars($interface, ENT_QUOTES).'" aria-controls="'.htmlspecialchars($interface, ENT_QUOTES).'" role="tab" data-toggle="tab">'.htmlspecialchars($interface, ENT_QUOTES).'</a></li>';
} }
?> ?>
@ -39,7 +40,7 @@ function DisplayNetworkingConfig(){
<h4><?php echo _("Current settings"); ?></h4> <h4><?php echo _("Current settings"); ?></h4>
<div class="row"> <div class="row">
<?php <?php
foreach($interfaces as $interface) { foreach ($interfaces as $interface) {
echo '<div class="col-md-6"> echo '<div class="col-md-6">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">'.htmlspecialchars($interface, ENT_QUOTES).'</div> <div class="panel-heading">'.htmlspecialchars($interface, ENT_QUOTES).'</div>
@ -56,7 +57,7 @@ function DisplayNetworkingConfig(){
</div><!-- /.col-lg-12 --> </div><!-- /.col-lg-12 -->
</div><!-- /.tab-pane --> </div><!-- /.tab-pane -->
<?php <?php
foreach($interfaces as $interface) { foreach ($interfaces as $interface) {
echo ' echo '
<div role="tabpanel" class="tab-pane fade in" id="'.htmlspecialchars($interface, ENT_QUOTES).'"> <div role="tabpanel" class="tab-pane fade in" id="'.htmlspecialchars($interface, ENT_QUOTES).'">
<div class="row"> <div class="row">
@ -110,7 +111,7 @@ function DisplayNetworkingConfig(){
</div> </div>
</div><!-- /.tab-panel --> </div><!-- /.tab-panel -->
</div>'; </div>';
} }
?> ?>
</div><!-- /.tab-content --> </div><!-- /.tab-content -->
</div><!-- /.panel-body --> </div><!-- /.panel-body -->

View File

@ -1,22 +1,30 @@
<?php <?php
class StatusMessages { class StatusMessages
{
public $messages = array(); public $messages = array();
public function addMessage($message, $level='success', $dismissable=true) { public function addMessage($message, $level = 'success', $dismissable = true)
{
$status = '<div class="alert alert-'.$level; $status = '<div class="alert alert-'.$level;
if ($dismissable) $status .= ' alert-dismissable'; if ($dismissable) {
$status .= ' alert-dismissable';
}
$status .= '">'. _($message); $status .= '">'. _($message);
if ($dismissable) $status .= '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button>'; if ($dismissable) {
$status .= '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button>';
}
$status .= '</div>'; $status .= '</div>';
array_push($this->messages, $status); array_push($this->messages, $status);
} }
public function showMessages($clear = true) { public function showMessages($clear = true)
foreach($this->messages as $message) { {
foreach ($this->messages as $message) {
echo $message; echo $message;
} }
if ( $clear ) $this->messages = array(); if ($clear) {
$this->messages = array();
}
} }
} }
?>

View File

@ -1,6 +1,6 @@
<?php <?php
include_once( 'includes/status_messages.php' ); include_once('includes/status_messages.php');
/** /**
* *
@ -9,7 +9,8 @@ include_once( 'includes/status_messages.php' );
* *
*/ */
function RPiVersion() { function RPiVersion()
{
// Lookup table from http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/ // Lookup table from http://www.raspberrypi-spy.co.uk/2012/09/checking-your-raspberry-pi-board-version/
$revisions = array( $revisions = array(
'0002' => 'Model B Revision 1.0', '0002' => 'Model B Revision 1.0',
@ -44,7 +45,7 @@ function RPiVersion() {
$cpuinfo_array = ''; $cpuinfo_array = '';
exec('cat /proc/cpuinfo', $cpuinfo_array); exec('cat /proc/cpuinfo', $cpuinfo_array);
$rev = trim(array_pop(explode(':',array_pop(preg_grep("/^Revision/", $cpuinfo_array))))); $rev = trim(array_pop(explode(':', array_pop(preg_grep("/^Revision/", $cpuinfo_array)))));
if (array_key_exists($rev, $revisions)) { if (array_key_exists($rev, $revisions)) {
return $revisions[$rev]; return $revisions[$rev];
} else { } else {
@ -56,13 +57,14 @@ function RPiVersion() {
* *
* *
*/ */
function DisplaySystem(){ function DisplaySystem()
{
$status = new StatusMessages(); $status = new StatusMessages();
if( isset($_POST['SaveLanguage']) ) { if (isset($_POST['SaveLanguage'])) {
if (CSRFValidate()) { if (CSRFValidate()) {
if(isset($_POST['locale'])) { if (isset($_POST['locale'])) {
$_SESSION['locale'] = $_POST['locale']; $_SESSION['locale'] = $_POST['locale'];
$status->addMessage('Language setting saved', 'success'); $status->addMessage('Language setting saved', 'success');
} }
@ -101,25 +103,39 @@ function DisplaySystem(){
$hours = floor($hours - ($days * 24)); $hours = floor($hours - ($days * 24));
$minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60)); $minutes = floor($minutes - ($days * 24 * 60) - ($hours * 60));
$uptime= ''; $uptime= '';
if ($days != 0) { $uptime .= $days . ' day' . (($days > 1)? 's ':' '); } if ($days != 0) {
if ($hours != 0) { $uptime .= $hours . ' hour' . (($hours > 1)? 's ':' '); } $uptime .= $days . ' day' . (($days > 1)? 's ':' ');
if ($minutes != 0) { $uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' '); } }
if ($hours != 0) {
$uptime .= $hours . ' hour' . (($hours > 1)? 's ':' ');
}
if ($minutes != 0) {
$uptime .= $minutes . ' minute' . (($minutes > 1)? 's ':' ');
}
// mem used // mem used
$memused_status = "primary"; $memused_status = "primary";
exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'", $memarray); exec("free -m | awk '/Mem:/ { total=$2 ; used=$3 } END { print used/total*100}'", $memarray);
$memused = floor($memarray[0]); $memused = floor($memarray[0]);
if ($memused > 90) { $memused_status = "danger"; } if ($memused > 90) {
elseif ($memused > 75) { $memused_status = "warning"; } $memused_status = "danger";
elseif ($memused > 0) { $memused_status = "success"; } } elseif ($memused > 75) {
$memused_status = "warning";
} elseif ($memused > 0) {
$memused_status = "success";
}
// cpu load // cpu load
$cores = exec("grep -c ^processor /proc/cpuinfo"); $cores = exec("grep -c ^processor /proc/cpuinfo");
$loadavg = exec("awk '{print $1}' /proc/loadavg"); $loadavg = exec("awk '{print $1}' /proc/loadavg");
$cpuload = floor(($loadavg * 100) / $cores); $cpuload = floor(($loadavg * 100) / $cores);
if ($cpuload > 90) { $cpuload_status = "danger"; } if ($cpuload > 90) {
elseif ($cpuload > 75) { $cpuload_status = "warning"; } $cpuload_status = "danger";
elseif ($cpuload > 0) { $cpuload_status = "success"; } } elseif ($cpuload > 75) {
$cpuload_status = "warning";
} elseif ($cpuload > 0) {
$cpuload_status = "success";
}
?> ?>
<div class="row"> <div class="row">
@ -129,14 +145,14 @@ function DisplaySystem(){
<div class="panel-body"> <div class="panel-body">
<?php <?php
if (isset($_POST['system_reboot'])) { if (isset($_POST['system_reboot'])) {
echo '<div class="alert alert-warning">' . _("System Rebooting Now!") . '</div>'; echo '<div class="alert alert-warning">' . _("System Rebooting Now!") . '</div>';
$result = shell_exec("sudo /sbin/reboot"); $result = shell_exec("sudo /sbin/reboot");
} }
if (isset($_POST['system_shutdown'])) { if (isset($_POST['system_shutdown'])) {
echo '<div class="alert alert-warning">' . _("System Shutting Down Now!") . '</div>'; echo '<div class="alert alert-warning">' . _("System Shutting Down Now!") . '</div>';
$result = shell_exec("sudo /sbin/shutdown -h now"); $result = shell_exec("sudo /sbin/shutdown -h now");
} }
?> ?>
<div class="row"> <div class="row">

View File

@ -3,13 +3,14 @@
* *
* *
*/ */
function DisplayThemeConfig(){ function DisplayThemeConfig()
{
$cselected = ''; $cselected = '';
$hselected = ''; $hselected = '';
$tselected = ''; $tselected = '';
switch( $_COOKIE['theme'] ) { switch ($_COOKIE['theme']) {
case "custom.css": case "custom.css":
$cselected = ' selected="selected"'; $cselected = ' selected="selected"';
break; break;
@ -21,7 +22,7 @@ function DisplayThemeConfig(){
break; break;
} }
?> ?>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<div class="panel panel-primary"> <div class="panel panel-primary">
@ -57,6 +58,6 @@ function DisplayThemeConfig(){
</div><!-- /.panel-primary --> </div><!-- /.panel-primary -->
</div><!-- /.col-lg-12 --> </div><!-- /.col-lg-12 -->
</div><!-- /.row --> </div><!-- /.row -->
<?php <?php
} }

View File

@ -20,21 +20,21 @@
session_start(); session_start();
include_once( 'includes/config.php' ); include_once('includes/config.php');
include_once( RASPI_CONFIG.'/raspap.php' ); include_once(RASPI_CONFIG.'/raspap.php');
include_once( 'includes/locale.php'); include_once('includes/locale.php');
include_once( 'includes/functions.php' ); include_once('includes/functions.php');
include_once( 'includes/dashboard.php' ); include_once('includes/dashboard.php');
include_once( 'includes/authenticate.php' ); include_once('includes/authenticate.php');
include_once( 'includes/admin.php' ); include_once('includes/admin.php');
include_once( 'includes/dhcp.php' ); include_once('includes/dhcp.php');
include_once( 'includes/hostapd.php' ); include_once('includes/hostapd.php');
include_once( 'includes/system.php' ); include_once('includes/system.php');
include_once( 'includes/configure_client.php' ); include_once('includes/configure_client.php');
include_once( 'includes/networking.php' ); include_once('includes/networking.php');
include_once( 'includes/themes.php' ); include_once('includes/themes.php');
include_once( 'includes/data_usage.php' ); include_once('includes/data_usage.php');
include_once( 'includes/about.php' ); include_once('includes/about.php');
$output = $return = 0; $output = $return = 0;
$page = $_GET['page']; $page = $_GET['page'];
@ -48,7 +48,7 @@ if (empty($_SESSION['csrf_token'])) {
} }
$csrf_token = $_SESSION['csrf_token']; $csrf_token = $_SESSION['csrf_token'];
if(!isset($_COOKIE['theme'])) { if (!isset($_COOKIE['theme'])) {
$theme = "custom.css"; $theme = "custom.css";
} else { } else {
$theme = $_COOKIE['theme']; $theme = $_COOKIE['theme'];
@ -122,47 +122,47 @@ $theme_url = 'dist/css/'.htmlspecialchars($theme, ENT_QUOTES);
<li> <li>
<a href="index.php?page=wlan0_info"><i class="fa fa-dashboard fa-fw"></i> <?php echo _("Dashboard"); ?></a> <a href="index.php?page=wlan0_info"><i class="fa fa-dashboard fa-fw"></i> <?php echo _("Dashboard"); ?></a>
</li> </li>
<?php if ( RASPI_WIFICLIENT_ENABLED ) : ?> <?php if (RASPI_WIFICLIENT_ENABLED) : ?>
<li> <li>
<a href="index.php?page=wpa_conf"><i class="fa fa-wifi fa-fw"></i> <?php echo _("Configure WiFi client"); ?></a> <a href="index.php?page=wpa_conf"><i class="fa fa-wifi fa-fw"></i> <?php echo _("Configure WiFi client"); ?></a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ( RASPI_HOTSPOT_ENABLED ) : ?> <?php if (RASPI_HOTSPOT_ENABLED) : ?>
<li> <li>
<a href="index.php?page=hostapd_conf"><i class="fa fa-dot-circle-o fa-fw"></i> <?php echo _("Configure hotspot"); ?></a> <a href="index.php?page=hostapd_conf"><i class="fa fa-dot-circle-o fa-fw"></i> <?php echo _("Configure hotspot"); ?></a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ( RASPI_NETWORK_ENABLED ) : ?> <?php if (RASPI_NETWORK_ENABLED) : ?>
<li> <li>
<a href="index.php?page=network_conf"><i class="fa fa-sitemap fa-fw"></i> <?php echo _("Configure networking"); ?></a> <a href="index.php?page=network_conf"><i class="fa fa-sitemap fa-fw"></i> <?php echo _("Configure networking"); ?></a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ( RASPI_DHCP_ENABLED ) : ?> <?php if (RASPI_DHCP_ENABLED) : ?>
<li> <li>
<a href="index.php?page=dhcpd_conf"><i class="fa fa-exchange fa-fw"></i> <?php echo _("Configure DHCP Server"); ?></a> <a href="index.php?page=dhcpd_conf"><i class="fa fa-exchange fa-fw"></i> <?php echo _("Configure DHCP Server"); ?></a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ( RASPI_OPENVPN_ENABLED ) : ?> <?php if (RASPI_OPENVPN_ENABLED) : ?>
<li> <li>
<a href="index.php?page=openvpn_conf"><i class="fa fa-lock fa-fw"></i> <?php echo _("Configure OpenVPN"); ?></a> <a href="index.php?page=openvpn_conf"><i class="fa fa-lock fa-fw"></i> <?php echo _("Configure OpenVPN"); ?></a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ( RASPI_TORPROXY_ENABLED ) : ?> <?php if (RASPI_TORPROXY_ENABLED) : ?>
<li> <li>
<a href="index.php?page=torproxy_conf"><i class="fa fa-eye-slash fa-fw"></i> <?php echo _("Configure TOR proxy"); ?></a> <a href="index.php?page=torproxy_conf"><i class="fa fa-eye-slash fa-fw"></i> <?php echo _("Configure TOR proxy"); ?></a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ( RASPI_CONFAUTH_ENABLED ) : ?> <?php if (RASPI_CONFAUTH_ENABLED) : ?>
<li> <li>
<a href="index.php?page=auth_conf"><i class="fa fa-lock fa-fw"></i> <?php echo _("Configure Auth"); ?></a> <a href="index.php?page=auth_conf"><i class="fa fa-lock fa-fw"></i> <?php echo _("Configure Auth"); ?></a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ( RASPI_CHANGETHEME_ENABLED ) : ?> <?php if (RASPI_CHANGETHEME_ENABLED) : ?>
<li> <li>
<a href="index.php?page=theme_conf"><i class="fa fa-wrench fa-fw"></i> <?php echo _("Change Theme"); ?></a> <a href="index.php?page=theme_conf"><i class="fa fa-wrench fa-fw"></i> <?php echo _("Change Theme"); ?></a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ( RASPI_VNSTAT_ENABLED ) : ?> <?php if (RASPI_VNSTAT_ENABLED) : ?>
<li> <li>
<a href="index.php?page=data_use"><i class="fa fa-bar-chart fa-fw"></i> <?php echo _("Data usage"); ?></a> <a href="index.php?page=data_use"><i class="fa fa-bar-chart fa-fw"></i> <?php echo _("Data usage"); ?></a>
</li> </li>
@ -190,9 +190,9 @@ $theme_url = 'dist/css/'.htmlspecialchars($theme, ENT_QUOTES);
</div><!-- /.row --> </div><!-- /.row -->
<?php <?php
$extraFooterScripts = array(); $extraFooterScripts = array();
// handle page actions // handle page actions
switch( $page ) { switch ($page) {
case "wlan0_info": case "wlan0_info":
DisplayDashboard(); DisplayDashboard();
break; break;

View File

@ -5,11 +5,10 @@ $config = array(
'admin_pass' => '$2y$10$YKIyWAmnQLtiJAy6QgHQ.eCpY4m.HCEbiHaTgN6.acNC6bDElzt.i' 'admin_pass' => '$2y$10$YKIyWAmnQLtiJAy6QgHQ.eCpY4m.HCEbiHaTgN6.acNC6bDElzt.i'
); );
if(file_exists(RASPI_CONFIG.'/raspap.auth')) { if (file_exists(RASPI_CONFIG.'/raspap.auth')) {
if ( $auth_details = fopen(RASPI_CONFIG.'/raspap.auth', 'r') ) { if ($auth_details = fopen(RASPI_CONFIG.'/raspap.auth', 'r')) {
$config['admin_user'] = trim(fgets($auth_details)); $config['admin_user'] = trim(fgets($auth_details));
$config['admin_pass'] = trim(fgets($auth_details)); $config['admin_pass'] = trim(fgets($auth_details));
fclose($auth_details); fclose($auth_details);
} }
} }
?>