Added new module for import/export

This commit is contained in:
Dennis Eichhorn 2018-05-20 09:58:42 +02:00
commit 3714872918
20 changed files with 677 additions and 0 deletions

View File

@ -0,0 +1,78 @@
[
{
"id": 1007001001,
"pid": "/backend",
"type": 2,
"subtype": 1,
"name": "Exchange",
"uri": "/{/lang}/backend/admin/exchange/dashboard?{?}",
"target": "self",
"icon": null,
"order": 50,
"from": "Exchange",
"permission": { "type": null, "element": null },
"parent": 1000101001,
"children": [
{
"id": 1007002001,
"pid": "/backend/admin/exchange",
"type": 3,
"subtype": 1,
"name": "Dashboard",
"uri": "/{/lang}/backend/admin/exchange/dashboard?{?}",
"target": "self",
"icon": null,
"order": 1,
"from": "Exchange",
"permission": { "type": null, "element": null },
"parent": 1007001001,
"children": []
},
{
"id": 1007002002,
"pid": "/backend/admin/exchange",
"type": 3,
"subtype": 1,
"name": "Import",
"uri": "/{/lang}/backend/admin/exchange/import?{?}",
"target": "self",
"icon": null,
"order": 5,
"from": "Exchange",
"permission": { "type": null, "element": null },
"parent": 1007001001,
"children": []
},
{
"id": 1007002003,
"pid": "/backend/admin/exchange",
"type": 3,
"subtype": 1,
"name": "Export",
"uri": "/{/lang}/backend/admin/exchange/export?{?}",
"target": "self",
"icon": null,
"order": 10,
"from": "Exchange",
"permission": { "type": null, "element": null },
"parent": 1007001001,
"children": []
},
{
"id": 1007002004,
"pid": "/backend/admin/exchange",
"type": 3,
"subtype": 1,
"name": "Setup",
"uri": "/{/lang}/backend/admin/exchange/setup?{?}",
"target": "self",
"icon": null,
"order": 15,
"from": "Exchange",
"permission": { "type": null, "element": null },
"parent": 1007001001,
"children": []
}
]
}
]

View File

@ -0,0 +1,47 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Exchange\Admin\Install;
use phpOMS\DataStorage\Database\DatabasePool;
/**
* Navigation class.
*
* @package Modules
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class Navigation
{
/**
* Install navigation providing
*
* @param string $path Path to some file
* @param DatabasePool $dbPool Database pool for database interaction
*
* @return void
*
* @since 1.0.0
*/
public static function install(string $path = null, DatabasePool $dbPool = null) : void
{
$navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true);
$class = '\\Modules\\Navigation\\Admin\\Installer';
/** @var $class \Modules\Navigation\Admin\Installer */
$class::installExternal($dbPool, $navData);
}
}

33
Admin/Installer.php Normal file
View File

@ -0,0 +1,33 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Exchange\Admin;
use phpOMS\DataStorage\Database\DatabaseType;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\InstallerAbstract;
use phpOMS\Module\InfoManager;
/**
* Exchange install class.
*
* @package Modules
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class Installer extends InstallerAbstract
{
}

View File

@ -0,0 +1,30 @@
<?php
use phpOMS\Router\RouteVerb;
return [
'^.*/backend/admin/exchange/import.*$' => [
[
'dest' => '\Modules\Exchange\Controller:viewExchangeImport',
'verb' => RouteVerb::GET,
],
],
'^.*/backend/admin/exchange/export.*$' => [
[
'dest' => '\Modules\Exchange\Controller:viewExchangeExport',
'verb' => RouteVerb::GET,
],
],
'^.*/backend/admin/exchange/dashboard.*$' => [
[
'dest' => '\Modules\Exchange\Controller:viewExchangeDashboard',
'verb' => RouteVerb::GET,
],
],
'^.*/backend/admin/exchange/setup.*$' => [
[
'dest' => '\Modules\Exchange\Controller:viewExchangeSetup',
'verb' => RouteVerb::GET,
],
],
];

3
Admin/Routes/console.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$moduleRoutes = [];

3
Admin/Routes/socket.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$moduleRoutes = [];

32
Admin/Status.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Exchange\Admin;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\StatusAbstract;
use phpOMS\Module\InfoManager;
/**
* Navigation class.
*
* @package Modules
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class Status extends StatusAbstract
{
}

32
Admin/Uninstaller.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Exchange\Admin;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\UninstallerAbstract;
use phpOMS\Module\InfoManager;
/**
* Navigation class.
*
* @package Modules
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class Uninstaller extends UninstallerAbstract
{
}

33
Admin/Updater.php Normal file
View File

@ -0,0 +1,33 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Exchange\Admin;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\UpdaterAbstract;
use phpOMS\System\File\Directory;
use phpOMS\Module\InfoManager;
/**
* Updater class.
*
* @package Modules
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
class Updater extends UpdaterAbstract
{
}

85
Controller.php Normal file
View File

@ -0,0 +1,85 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
declare(strict_types=1);
namespace Modules\Exchange;
use Modules\Navigation\Models\Navigation;
use Modules\Navigation\Views\NavigationView;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
use phpOMS\Views\View;
/**
* Exchange controller class.
*
* @package Modules
* @license OMS License 1.0
* @link http://website.orange-management.de
* @since 1.0.0
*/
final class Controller extends ModuleAbstract implements WebInterface
{
/**
* Module path.
*
* @var string
* @since 1.0.0
*/
public const MODULE_PATH = __DIR__;
/**
* Module version.
*
* @var string
* @since 1.0.0
*/
public const MODULE_VERSION = '1.0.0';
/**
* Module name.
*
* @var string
* @since 1.0.0
*/
public const MODULE_NAME = 'Exchange';
/**
* Module id.
*
* @var int
* @since 1.0.0
*/
public const MODULE_ID = 1007000000;
/**
* Providing.
*
* @var string[]
* @since 1.0.0
*/
protected static $providing = [];
/**
* Dependencies.
*
* @var string[]
* @since 1.0.0
*/
protected static $dependencies = [
];
}

0
Docs/introduction.md Normal file
View File

0
README.md Normal file
View File

View File

@ -0,0 +1,16 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
return ['Navigation' => [
'List' => 'List',
'Exchange' => 'Exchange',
]];

View File

@ -0,0 +1,15 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
$MODLANG[1] = [
'i:ModuleInstalled' => 'Installation of the module {$1} was successful.',
];

View File

@ -0,0 +1,15 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
return ['Exchange' => [
'Exchange' => 'Exchange',
]];

View File

@ -0,0 +1,70 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
$logs = $this->app->logger->countLogs();
$penetrators = $this->app->logger->getHighestPerpetrator();
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12 col-md-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('System'); ?></h1></header>
<div class="inner">
<table class="list wf-100">
<tbody>
<tr><td><?= $this->getHtml('OS'); ?><td><?= $this->printHtml(php_uname('s')); ?>
<tr><td><?= $this->getHtml('Version'); ?><td><?= $this->printHtml(php_uname('v')); ?>
<tr><td><?= $this->getHtml('Release'); ?><td><?= $this->printHtml(php_uname('r')); ?>
<tr><td><?= $this->getHtml('RAMUsage'); ?><td><?= $this->printHtml(memory_get_usage(true)/(1024*1024)); ?> MB
<tr><td><?= $this->getHtml('MemoryLimit'); ?><td><?= $this->printHtml(ini_get('memory_limit')); ?>
<tr><td><?= $this->getHtml('SystemRAM'); ?><td><?= $this->printHtml(\phpOMS\System\SystemUtils::getRAM()/(1024)); ?> MB
<tr><td><?= $this->getHtml('CPUUsage'); ?><td><?= $this->printHtml(\phpOMS\System\SystemUtils::getCpuUsage()); ?>%
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-md-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Logs'); ?></h1></header>
<div class="inner">
<table class="list wf-100">
<tbody>
<tr><td><?= $this->getHtml('Emergencies'); ?><td><?= $this->printHtml($logs['emergency'] ?? 0); ?>
<tr><td><?= $this->getHtml('Criticals'); ?><td><?= $this->printHtml($logs['critical'] ?? 0); ?>
<tr><td><?= $this->getHtml('Errors'); ?><td><?= $this->printHtml($logs['error'] ?? 0); ?>
<tr><td><?= $this->getHtml('Warnings'); ?><td><?= $this->printHtml($logs['warning'] ?? 0); ?>
<tr><td><?= $this->getHtml('Alerts'); ?><td><?= $this->printHtml($logs['alert'] ?? 0); ?>
<tr><td><?= $this->getHtml('Notices'); ?><td><?= $this->printHtml($logs['notice'] ?? 0); ?>
<tr><td><?= $this->getHtml('Info'); ?><td><?= $this->printHtml($logs['info'] ?? 0); ?>
<tr><td><?= $this->getHtml('Debug'); ?><td><?= $this->printHtml($logs['debug'] ?? 0); ?>
<tr><td><?= $this->getHtml('Total'); ?><td><?= $this->printHtml(array_sum($logs)); ?>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-md-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Penetrators'); ?></h1></header>
<div class="inner">
<table class="list wf-100">
<tbody>
<?php foreach ($penetrators as $ip => $count) : ?>
<tr><td><?= $this->printHtml($ip); ?><td><?= $this->printHtml($count); ?>
<?php endforeach; ?>
</table>
</div>
</section>
</div>
</div>

View File

@ -0,0 +1,92 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
/**
* @var \phpOMS\Views\View $this
*/
$log = $this->app->logger->getByLine((int) $this->request->getData('id') ?? 1);
$temp = trim($log['backtrace']);
$log['backtrace'] = json_decode($temp, true);
$details = '* Uri: `' . trim($log['path']) . "`\n"
. '* Level: `' . trim($log['level']) . "`\n"
. '* Message: `' . trim($log['message']) . "`\n"
. '* File: `' . trim($log['file']) . "`\n"
. '* Line: `' . trim($log['line']) . "`\n"
. '* Version: `' . trim($log['version']) . "`\n"
. '* OS: `' . trim($log['os']) . "`\n\n"
. "Backtrace: \n\n```\n" . json_encode($log['backtrace'], JSON_PRETTY_PRINT);
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12 col-md-6">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Logs') ?></h1></header>
<div class="inner">
<table class="list w-100">
<tr>
<td><?= $this->getHtml('ID', 0, 0); ?>
<td><i class="fa fa-anchor"></i>
<td class="wf-100"><?= $this->printHtml((int) $this->request->getData('id') ?? 0); ?>
<tr>
<td><?= $this->getHtml('Time') ?>
<td><i class="fa fa-clock-o"></i>
<td><?= $this->printHtml($log['datetime']); ?>
<tr>
<td><?= $this->getHtml('Uri') ?>
<td><i class="fa fa-globe"></i>
<td><?= $this->printHtml($log['path']); ?>
<tr>
<td><?= $this->getHtml('Source') ?>
<td><i class="fa fa-wifi"></i>
<td><?= $this->printHtml($log['ip']); ?>
<tr>
<td><?= $this->getHtml('Level') ?>
<td>
<i class="fa fa-<?= $this->printHtml(in_array($log['level'], ['notice', 'info', 'debug']) ? 'info-circle' : 'warning'); ?>"></i>
<td><?= $this->printHtml($log['level']); ?>
<tr>
<td><?= $this->getHtml('Message') ?>
<td><i class="fa fa-commenting"></i>
<td><?= $this->printHtml($log['message']); ?>
<tr>
<td><?= $this->getHtml('File') ?>
<td><i class="fa fa-file"></i>
<td><?= $this->printHtml($log['file']); ?>
<tr>
<td><?= $this->getHtml('Line') ?>
<td><i class="fa fa-commenting"></i>
<td><?= $this->printHtml($log['line']); ?>
<tr>
<td><?= $this->getHtml('Version') ?>
<td><i class="fa fa-pencil"></i>
<td><?= $this->printHtml($log['version']); ?>
<tr>
<td><?= $this->getHtml('OS') ?>
<td><i class="fa fa-laptop"></i>
<td><?= $this->printHtml($log['os']); ?>
<tr>
<td colspan="3"><?= $this->getHtml('Backtrace') ?>
<tr>
<td colspan="3">
<pre><?= $this->printHtml(json_encode($log['backtrace'], JSON_PRETTY_PRINT)); ?></pre>
<tr>
<td colspan="3" style="padding-top: 10px"><a class="button" target="_blank"
href="https://gitreports.com/issue/Orange-Management/Orange-Management/?name=Guest&issue_title=<?= $this->printHtml(urlencode($log['message'])); ?>&details=<?= $this->printHtml(urlencode($details)); ?>"><?= $this->getHtml('Report') ?></a>
</table>
</div>
</section>
</div>
</div>

View File

@ -0,0 +1,48 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
/**
* @var \phpOMS\Views\View $this
*/
$logs = array_reverse($this->app->logger->get(25), true);
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="box col-xs-12 wf-100">
<table class="table red">
<caption><?= $this->getHtml('Logs') ?></caption>
<thead>
<tr>
<td><?= $this->getHtml('Timestamp') ?>
<td><?= $this->getHtml('Level') ?>
<td><?= $this->getHtml('Source') ?>
<td class="wf-100"><?= $this->getHtml('Message') ?>
<tfoot>
<tr>
<td colspan="5">
<tbody>
<?php foreach ($logs as $key => $value) :
$url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/admin/monitoring/logs/single?{?}&id=' . $key);?>
<tr>
<td><a href=<?= $this->printHtml($url); ?>><i class="fa fa-clock-o"></i> <?= $this->printHtml($value[0] ?? ''); ?></a>
<td><a href=<?= $this->printHtml($url); ?>><i class="fa fa-<?= $this->printHtml(in_array($value[1], ['notice', 'info', 'debug']) ? 'info-circle' : 'warning'); ?>"></i> <?= $this->printHtml($value[1] ?? ''); ?></a>
<td><a href=<?= $this->printHtml($url); ?>><i class="fa fa-wifi"></i> <?= $this->printHtml($value[2] ?? ''); ?></a>
<td><a href=<?= $this->printHtml($url); ?>><i class="fa fa-commenting"></i> <?= $this->printHtml($value[7] ?? ''); ?></a>
<?php endforeach;
if (!isset($key)) : ?>
<tr>
<td colspan="4">
<?php endif; ?>
</table>
</div>
</div>

BIN
img/module_teaser_small.png Normal file

Binary file not shown.

45
info.json Normal file
View File

@ -0,0 +1,45 @@
{
"name": {
"id": 1007000000,
"internal": "Exchange",
"external": "Exchange"
},
"category": "Admin",
"version": "1.0.0",
"requirements": {
"phpOMS": "1.0.0",
"phpOMS-db": "1.0.0"
},
"creator": {
"name": "Orange Management",
"website": "www.spl1nes.com"
},
"description": "The administration module.",
"directory": "Exchange",
"dependencies": {
"Admin": "1.0.0"
},
"providing": {
"Navigation": "*"
},
"load": [
{
"pid": [
"/backend"
],
"type": 5,
"from": "Exchange",
"for": "Navigation",
"file": "Navigation"
},
{
"pid": [
"/backend/admin/exchange"
],
"type": 4,
"for": "Content",
"file": "Exchange",
"from": "Exchange"
}
]
}