Browse Source

implement access helper

yggdrasil-0.4.7
ghost 1 year ago
parent
commit
8701199a33
  1. 9
      src/library/access.php
  2. 7
      src/public/peer.php

9
src/library/access.php

@ -0,0 +1,9 @@
<?php
class Access
{
public static function address(array $list)
{
return isset($_SERVER['REMOTE_ADDR']) && in_array($_SERVER['REMOTE_ADDR'], $list);
}
}

7
src/public/peer.php

@ -2,6 +2,7 @@
// Load dependencies // Load dependencies
require_once (__DIR__ . '/../config/app.php'); require_once (__DIR__ . '/../config/app.php');
require_once (__DIR__ . '/../library/access.php');
require_once (__DIR__ . '/../library/mysql.php'); require_once (__DIR__ . '/../library/mysql.php');
require_once (__DIR__ . '/../../vendor/autoload.php'); require_once (__DIR__ . '/../../vendor/autoload.php');
@ -226,7 +227,7 @@ $peerPortStatuses = $db->findLastPeerPortStatusesByPeerId($requestPeerId);
<div class="padding-4"> <div class="padding-4">
<h1> <h1>
<?php echo sprintf(_('Peer %s'), $peerInfo->address) ?> <?php echo sprintf(_('Peer %s'), $peerInfo->address) ?>
<?php if (!empty($_SERVER['REMOTE_ADDR']) && $peerInfo->address == $_SERVER['REMOTE_ADDR']) { ?> <?php if (Access::address([$peerInfo->address])) { ?>
<span class="label label-green font-size-12 font-width-normal cursor-default" title="<?php echo _('you have connected from this peer') ?>"> <span class="label label-green font-size-12 font-width-normal cursor-default" title="<?php echo _('you have connected from this peer') ?>">
<?php echo _('this connection') ?> <?php echo _('this connection') ?>
</span> </span>
@ -248,7 +249,7 @@ $peerPortStatuses = $db->findLastPeerPortStatusesByPeerId($requestPeerId);
<?php echo _('Time') ?> <?php echo _('Time') ?>
</a> </a>
</th> </th>
<?php if (!empty($_SERVER['REMOTE_ADDR']) && $peerInfo->address == $_SERVER['REMOTE_ADDR']) { ?> <?php if (Access::address([$peerInfo->address])) { ?>
<th class="text-left"> <th class="text-left">
<?php echo _('Remote') ?> <?php echo _('Remote') ?>
<sub title="<?php echo _('Feature visible for this connection only') ?>"> <sub title="<?php echo _('Feature visible for this connection only') ?>">
@ -276,7 +277,7 @@ $peerPortStatuses = $db->findLastPeerPortStatusesByPeerId($requestPeerId);
<?php foreach ($peerRemoteConnections as $i => $peerRemoteConnection) { ?> <?php foreach ($peerRemoteConnections as $i => $peerRemoteConnection) { ?>
<tr> <tr>
<td class="text-left no-wrap"><?php echo date('Y-m-d H:s:i', $peerRemoteConnection->timeAdded) ?></td> <td class="text-left no-wrap"><?php echo date('Y-m-d H:s:i', $peerRemoteConnection->timeAdded) ?></td>
<?php if (!empty($_SERVER['REMOTE_ADDR']) && $peerInfo->address == $_SERVER['REMOTE_ADDR']) { ?> <?php if (Access::address([$peerInfo->address])) { ?>
<td class="text-left"> <td class="text-left">
<?php echo $peerRemoteConnection->remote ?> <?php echo $peerRemoteConnection->remote ?>
</td> </td>

Loading…
Cancel
Save