Some fixes

This commit is contained in:
Geoffrey Frogeye 2016-12-10 20:16:23 +01:00
parent 931a6ae2b3
commit f308830095

View file

@ -1,9 +1,8 @@
<?php <?php
require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';
use OTPHP\TOTP;
include_once('config.inc.php'); require_once('config.inc.php');
$route = explode('/', trim(substr(explode('?', $_SERVER['REDIRECT_URL'])[0], strrpos($_SERVER['SCRIPT_NAME'], '/')), '/')); $route = explode('/', trim(substr(explode('?', $_SERVER['REDIRECT_URL'])[0], strrpos($_SERVER['SCRIPT_NAME'], '/')), '/'));
$meth = $_SERVER['REQUEST_METHOD']; $meth = $_SERVER['REQUEST_METHOD'];
@ -190,12 +189,22 @@ function getKeys($network) {
global $SSH_KEY_REGEX; global $SSH_KEY_REGEX;
global $DOMAIN; global $DOMAIN;
$machines = load('machine'); $machines = load('machine');
$networks = load('networks'); $networks = load('network');
$t = ''; $t = '';
foreach ($machines as $machineName => $machine) { foreach ($machines as $machineName => $machine) {
if ( if (
(isset($machine['network']) && isset($networks[$machine['network']]) && $networks[$machine['network']]['secure'] == 'true') (
|| ($network && in_array($machine['network'], $network['allowed'])) isset($machine['network'])
&& isset($networks[$machine['network']])
) && (
(
$networks[$machine['network']]['secure'] == 'true'
) || (
$network
&& isset($network['allowed'])
&& in_array($machine['network'], $network['allowed'])
)
)
) { ) {
if (isset($machine['userkey']) && preg_match($SSH_KEY_REGEX, $machine['userkey'], $matches)) { if (isset($machine['userkey']) && preg_match($SSH_KEY_REGEX, $machine['userkey'], $matches)) {
$t .= $matches[0].' '.$machineName.'@'.($machine['network'] ? $machine['network'].'.' : '').$DOMAIN."\n"; $t .= $matches[0].' '.$machineName.'@'.($machine['network'] ? $machine['network'].'.' : '').$DOMAIN."\n";