mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-21 23:20:22 +00:00
Initial commit
This commit is contained in:
parent
f7bdcb4e63
commit
a09ee1e86b
4 changed files with 147 additions and 0 deletions
65
includes/provider.php
Executable file
65
includes/provider.php
Executable file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
require_once 'includes/config.php';
|
||||
require_once 'includes/wifi_functions.php';
|
||||
|
||||
getWifiInterface();
|
||||
|
||||
/**
|
||||
* Manage VPN provider configuration
|
||||
*/
|
||||
function DisplayProviderConfig()
|
||||
{
|
||||
$status = new \RaspAP\Messages\StatusMessage;
|
||||
$providerName = getProviderValue($_SESSION["providerID"], "name");
|
||||
$binPath = getProviderValue($_SESSION["providerID"], "bin_path");
|
||||
|
||||
if (!RASPI_MONITOR_ENABLED) {
|
||||
if (isset($_POST['SaveProviderSettings'])) {
|
||||
if (isset($_POST['someVar'])) {
|
||||
$someVar = strip_tags(trim($_POST['someVar']));
|
||||
}
|
||||
$return = SaveProviderConfig($status, $someVar);
|
||||
} elseif (isset($_POST['StartProviderVPN'])) {
|
||||
$status->addMessage('Attempting to connect provider VPN', 'info');
|
||||
exec('sudo '.$binPath.' connect', $return);
|
||||
foreach ($return as $line) {
|
||||
$status->addMessage($line, 'info');
|
||||
}
|
||||
} elseif (isset($_POST['StopProviderVPN'])) {
|
||||
$status->addMessage('Attempting to disconnect provider VPN', 'info');
|
||||
exec('sudo '.$binPath.' disconnect', $return);
|
||||
foreach ($return as $line) {
|
||||
$status->addMessage($line, 'info');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exec("sudo $binPath status", $result);
|
||||
$serviceStatus = strtolower($output[1]) == 0 ? "disconnected" : "connected";
|
||||
$public_ip = get_public_ip();
|
||||
|
||||
exec("sudo $binPath status > /tmp/provider.log");
|
||||
$providerLog = file_get_contents('/tmp/provider.log');
|
||||
|
||||
echo renderTemplate(
|
||||
"provider", compact(
|
||||
"status",
|
||||
"serviceStatus",
|
||||
"providerName",
|
||||
"providerLog",
|
||||
"public_ip"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates VPN provider settings
|
||||
*
|
||||
* @param object $status
|
||||
* @return string $someVar
|
||||
*/
|
||||
function SaveProviderConfig($status, $someVar)
|
||||
{
|
||||
|
||||
}
|
53
templates/provider.php
Executable file
53
templates/provider.php
Executable file
|
@ -0,0 +1,53 @@
|
|||
<?php ob_start() ?>
|
||||
<?php if (!RASPI_MONITOR_ENABLED) : ?>
|
||||
<input type="submit" class="btn btn-outline btn-primary" name="SaveProviderConfig" value="Save settings" />
|
||||
<?php if ($openvpnstatus[0] == 0) {
|
||||
echo '<input type="submit" class="btn btn-success" name="StartProviderVPN" value="Connect '.$providerName.'" />' , PHP_EOL;
|
||||
} else {
|
||||
echo '<input type="submit" class="btn btn-warning" name="StopProviderVPN" value="Disconnect '.$providerName.'" />' , PHP_EOL;
|
||||
}
|
||||
?>
|
||||
<?php endif ?>
|
||||
<?php $buttons = ob_get_clean(); ob_end_clean() ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<i class="fas fa-shield-alt fa-fw mr-2"></i><?php echo _($providerName); ?>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-light btn-icon-split btn-sm service-status float-right">
|
||||
<span class="icon text-gray-600"><i class="fas fa-circle service-status-<?php echo $serviceStatus ?>"></i></span>
|
||||
<span class="text service-status"><?php echo strtolower($providerName); ?> <?php echo _($serviceStatus) ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</div><!-- /.row -->
|
||||
</div><!-- /.card-header -->
|
||||
<div class="card-body">
|
||||
<?php $status->showMessages(); ?>
|
||||
<form role="form" action="provider_conf" enctype="multipart/form-data" method="POST">
|
||||
<?php echo CSRFTokenFieldTag() ?>
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="nav-item"><a class="nav-link active" id="clienttab" href="#providerclient" data-toggle="tab"><?php echo _("Client settings"); ?></a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="loggingtab" href="#providerstatus" data-toggle="tab"><?php echo _("Status"); ?></a></li>
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<?php echo renderTemplate("provider/general", $__template_data) ?>
|
||||
<?php echo renderTemplate("provider/status", $__template_data) ?>
|
||||
</div><!-- /.tab-content -->
|
||||
|
||||
<?php echo $buttons ?>
|
||||
</form>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer"><?php echo _("Information provided by " .strtolower($providerName)); ?></div>
|
||||
</div><!-- /.card -->
|
||||
</div><!-- /.col-lg-12 -->
|
||||
</div><!-- /.row -->
|
||||
|
||||
|
17
templates/provider/general.php
Normal file
17
templates/provider/general.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<div class="tab-pane active" id="providerclient">
|
||||
<h4 class="mt-3"><?php echo _("Client settings"); ?></h4>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="row mb-2">
|
||||
<div class="col-lg-12 mt-2 mb-2">
|
||||
<div class="row ml-1">
|
||||
<div class="info-item col-xs-3"><?php echo _("IPv4 Address"); ?></div>
|
||||
<div class="info-value col-xs-3"><?php echo htmlspecialchars($public_ip, ENT_QUOTES); ?><a class="text-gray-500" href="https://ipapi.co/<?php echo($public_ip); ?>" target="_blank" rel="noopener noreferrer"><i class="fas fa-external-link-alt ml-2"></i></a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- col-8 -->
|
||||
<div class="col-sm-auto"></div>
|
||||
</div><!-- /.row -->
|
||||
</div><!-- /.tab-pane | general tab -->
|
||||
|
12
templates/provider/status.php
Normal file
12
templates/provider/status.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!-- logging tab -->
|
||||
<div class="tab-pane fade" id="providerstatus">
|
||||
<h4 class="mt-3 mb-3"><?php echo _("Status") ?></h4>
|
||||
<p><?php echo _("Current <code>".strtolower($providerName)."</code> connection status is displayed below.") ?></p>
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group col-md-8 mt-2">
|
||||
<textarea class="logoutput"><?php echo htmlspecialchars($providerLog, ENT_QUOTES); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.tab-pane -->
|
||||
|
Loading…
Reference in a new issue