v.1.1 changes 16-04-2026:

- Minor changes to interface.
- Fixed different missing includes.
- Access now denied to api calls that are related to disabled modules.
- Fixed sorting of CPU and memory in server overview.
This commit is contained in:
2026-04-16 15:01:40 +02:00
parent 36b0ebd10c
commit eec1d13cf5
40 changed files with 26451 additions and 26428 deletions

View File

@@ -44,8 +44,11 @@ class API
public function __construct()
{
# Setup Database connection
require_once $_SERVER['DOCUMENT_ROOT'] . '/bin/php/db_connect.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/bin/php/Functions/globalFunctions.php';
# Setup Database connection
$this->conn = $GLOBALS['conn'];
if (!empty($_SESSION['user']['user_uuid'])) {
@@ -77,6 +80,9 @@ class API
}
}
# Get the enabled modules for the user
$GLOBALS['modules_enabled'] = getEnabledModules();
// Disable builder input for non-GET requests to prevent potential SQL injection vulnerabilities.
// Also disable the builder for users with the 'frontend' user type as an extra security measure.
// The builder should only be active for API users making GET requests.
@@ -98,7 +104,6 @@ class API
$this->user_type = 'frontend';
# Load the locale for the user, this is used for the return message in the frontend and other globalFunctions.
include_once $_SERVER['DOCUMENT_ROOT'] . '/bin/php/Functions/globalFunctions.php';
$locale = getPreferredLocale();
global $translations;
$translations = require $_SERVER['DOCUMENT_ROOT'] . "/bin/locales/{$locale}.php";

View File

@@ -1,20 +1,20 @@
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_companies extends API
{
public function updateCompanyState()
{
$query = "UPDATE companies SET company_state = ? WHERE company_uuid = ?";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('ss', $this->data['company_state'], $this->data['company_uuid']);
if ($this->executeStatement($stmt)) {
$this->apiOutput(200, ['success' => 'company state successfully updated']);
}
}
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_companies extends API
{
public function updateCompanyState()
{
$query = "UPDATE companies SET company_state = ? WHERE company_uuid = ?";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('ss', $this->data['company_state'], $this->data['company_uuid']);
if ($this->executeStatement($stmt)) {
$this->apiOutput(200, ['success' => 'company state successfully updated']);
}
}
}

View File

@@ -1,478 +1,478 @@
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_inserve extends API
{
private $inserve_url;
private $inserve_token;
public $inserve_source_uuid;
private $ch;
public $httpCode = false;
public $response = false;
private $cloudDistrubutor = 'digistate-servers';
public function setupConnection()
{
$query = "SELECT * FROM system_sources WHERE source_name = 'inserve'";
$result = $this->conn->query($query)->fetch_assoc();
$this->inserve_url = $result['source_url'];
$this->inserve_token = $result['source_auth_token'];
$this->inserve_source_uuid = $result['source_uuid'];
}
public function execCurl()
{
$this->response = curl_exec($this->ch);
$this->httpCode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
curl_close($this->ch);
}
public function returnResponse()
{
$this->apiOutput($this->httpCode, json_decode($this->response, true));
}
public function authMe()
{
$this->ch = curl_init($this->inserve_url . 'auth/me');
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json"
]
]);
$this->execCurl();
}
public function getLinkedCompanies()
{
$this->ch = curl_init($this->inserve_url . 'cloud-distributors/digistate-servers/companies');
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json"
]
]);
$this->execCurl();
}
public function companies($page)
{
// Build array the way the API expects
$params = [
'b' => [
['orderBy' => ['name', 'ASC']],
['orderBy' => ['id', 'DESC']],
['with' => ['operator', 'country']],
['paginate' => 300],
],
'page' => $page
];
$query = http_build_query($params);
$this->ch = curl_init($this->inserve_url . 'companies?' . $query);
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json"
]
]);
$this->execCurl();
return json_decode($this->response, true);
}
public function syncCompaniesFromSentri()
{
# First retrieve all the active companies to sync to the Inserver cloud distributor
$companies = [];
$sql = "SELECT company_source_id FROM companies WHERE company_state = 'active'";
$stmt = $this->conn->query($sql);
while ($row = $stmt->fetch_assoc()) {
$id = (int)$row['company_source_id'];
$companies[] = [
'cloud_distribution_id' => (string)$id,
'company_id' => $id
];
}
$url = $this->inserve_url . 'cloud-distributors/digistate-servers/companies';
$this->ch = curl_init($url);
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($companies),
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json",
"Content-Type: application/json"
],
]);
$this->execCurl();
}
public function getCloudSubscriptions()
{
$this->ch = curl_init($this->inserve_url . 'cloud-distribution-subscriptions/');
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json"
]
]);
$this->execCurl();
}
public function updateSubscription($subscriptionId = false, $payload = false)
{
$url = $this->inserve_url . 'cloud-distribution-subscriptions/' . $subscriptionId;
$this->ch = curl_init($url);
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json",
"Content-Type: application/json"
],
]);
$this->execCurl();
}
private function getAllTypes($type)
{
$allowedColumns = [
'server_licenses',
'server_backup'
];
if (!in_array($type, $allowedColumns, true)) {
throw new Exception('Invalid column name');
}
$query = "SELECT `$type` FROM servers";
$stmt = $this->prepareStatement($query);
$this->executeStatement($stmt);
$result = $stmt->get_result();
$servers = [];
while ($row = $result->fetch_assoc()) {
array_push($servers, $row);
}
$allTypes = [];
foreach ($servers as $server) {
if (!empty($server[$type])) {
$types = json_decode($server[$type], true);
if (is_array($types)) {
foreach ($types as $item) {
foreach ($item as $key => $value) {
$allTypes[$key . '.' . $value] = 0;
}
}
}
}
}
return $allTypes;
}
private function calculateTotalDiskUsage($diskJson)
{
$disks = json_decode($diskJson, true);
$server_disks_count = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$server_disks_count += $disk['disk_space'];
}
}
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$server_disks_count = array_sum($sizes);
}
return $server_disks_count;
}
private function buildCountObject(string $serverUuid, string $key): array
{
return [
'countSentri' => 0,
'countInserve' => 0,
'sentriCompanyId' => 0,
'SentriStatus' => 0,
'subscriptionInserveExists' => false,
'subscriptionInserveId' => false,
'subscriptionInserveCompanyId' => false,
'subscriptionInserveName' => false,
'subscriptionInserveStatus' => 0,
'md5' => md5($serverUuid . ':' . $key),
];
}
private function transformTypes(array $types, string $serverUuid): array
{
$result = [];
foreach ($types as $key => $value) {
$result[$key] = $this->buildCountObject($serverUuid, $key);
}
return $result;
}
private function buildCountArray($serverUuid)
{
$allBackupTypes = $this->getAllTypes('server_backup');
$allLicenseTypes = $this->getAllTypes('server_licenses');
$backupCounts = $this->transformTypes($allBackupTypes, $serverUuid);
$licenseCounts = $this->transformTypes($allLicenseTypes, $serverUuid);
return array_merge(
[
"server_CPU_count" => $this->buildCountObject($serverUuid, 'server_cpu_count'),
"server_Memory_count" => $this->buildCountObject($serverUuid, 'server_memory_count'),
"server_Disk_space_count" => $this->buildCountObject($serverUuid, 'server_disks_count'),
],
$licenseCounts,
$backupCounts
);
}
public function syncServerLicencesToInserve()
{
# Get all the linked companies
$this->getLinkedCompanies();
$allCompanies = json_decode($this->response, true);
$allCompaniesIds = array_column($allCompanies['matched'], 'id', 'company_id');
# first get the current subscriptions
$this->getCloudSubscriptions();
$allInserveSubscriptions = json_decode($this->response, true);
# Filter out all the none Sentri posted subscriptions based on the name for performance
$allInserveSubscriptions = array_filter($allInserveSubscriptions, function ($subscription) {
return isset($subscription['cloud_subscription_id']) && $subscription['cloud_subscription_id'] === 'sentri-servers';
});
# Build lookup of existing Inserve subscriptions by cloud_distribution_id
# this will be used later to lookup
$inserveLookup = [];
foreach ($allInserveSubscriptions as $subscription) {
if (!empty($subscription['cloud_distribution_id'])) {
$inserveLookup[$subscription['cloud_distribution_id']] = [
'id' => (int)$subscription['id'],
'quantity' => (int)$subscription['quantity'],
'status' => (int)$subscription['status'],
'cloud_distribution_company_id' => (int)$subscription['cloud_distribution_company_id'],
];
}
}
# get all the servers from Sentri
$sql = "SELECT * FROM servers INNER JOIN companies ON servers.company_uuid = companies.company_uuid WHERE company_state = 'active' AND server_state != 'new' AND server_state != 'disabled' ";
$stmt = $this->conn->query($sql);
while ($row = $stmt->fetch_assoc()) {
# Create a count of all the Subscriptions possible with every count on 0
$subscriptionCounts = $this->buildCountArray($row['server_uuid']);
$totalDiskSpace = $this->calculateTotalDiskUsage($row['server_disks']);
# Inserve status codes are:
# 0 = active, 1 = cancelled, 2 = pending, 3 = trial, 4 = on hold, 5 = removed
$statusMap = [
'active' => 0,
'trial' => 3,
'deleted' => 5,
];
// if no states matched there is something terrifying wrong, call the ambulance!
if (!isset($statusMap[$row['server_state']])) {
exit;
}
$sentriStatus = $statusMap[$row['server_state']];
# Set all the server resource counts from Sentri into the $subscriptionCounts
$subscriptionCounts['server_CPU_count']['countSentri'] = $row['server_cpu'];
$subscriptionCounts['server_Memory_count']['countSentri'] = (int)ceil($row['server_memory'] / 1024);
$subscriptionCounts['server_Disk_space_count']['countSentri'] = $totalDiskSpace;
$licenses = json_decode($row['server_licenses'], true);
foreach ($licenses as $license) {
foreach ($license as $key => $LicenseType) {
$subscriptionCounts[$key . '.' . $LicenseType]['countSentri']++;
}
}
$backups = json_decode($row['server_backup'], true);
foreach ($backups as $backup) {
foreach ($backup as $key => $BackupType) {
$subscriptionCounts[$key . '.' . $BackupType]['countSentri'] = $totalDiskSpace;
}
}
# Mark subscriptions that already exist in Inserve
foreach ($subscriptionCounts as $key => &$item) {
if (!is_array($item) || !isset($item['md5'])) {
continue;
}
$md5 = (string)$item['md5'];
if (isset($inserveLookup[$md5])) { # Subscription already exists in Inserve
$item['SentriStatus'] = $sentriStatus;
$item['sentriCompanyId'] = (int)$allCompaniesIds[$row['company_source_id']] ?? 0;
$item['subscriptionInserveExists'] = true;
$item['subscriptionInserveId'] = $inserveLookup[$item['md5']]['id'];
$item['countInserve'] = $inserveLookup[$item['md5']]['quantity'];
$item['subscriptionInserveCompanyId'] = $inserveLookup[$item['md5']]['cloud_distribution_company_id'];
$item['subscriptionInserveStatus'] = $inserveLookup[$item['md5']]['status'];
} else { # Subscription does not exists in Inserve
$item['sentriCompanyId'] = (int)$allCompaniesIds[$row['company_source_id']] ?? 0;
$item['subscriptionInserveExists'] = false;
$item['subscriptionInserveId'] = false;
$item['countInserve'] = 0;
$item['subscriptionInserveCompanyId'] = false;
}
}
unset($item);
// Make the subscriptions names look nice and dandy.
foreach ($subscriptionCounts as $key => &$item) {
// Set server name
$serverName = $row['server_hostname'] ?? $row['server_vm_host_name'] ?? 'Unknown';
// remove server_ prefix and _count suffix
$namePart = $key;
if (str_starts_with($key, 'server_') && str_ends_with($key, '_count')) {
$namePart = substr($key, 7, -6);
$namePart = ucfirst($namePart);
} // Handle keys with "."
elseif (strpos($key, '.') !== false) {
[$first, $second] = explode('.', $key, 2);
if ($first === $second || strtolower($second) === 'yes') {
$namePart = ucfirst($first);
} else {
$namePart = ucfirst($first) . ' - ' . $second;
}
} //Handle keys without . but with a space (expmale directadmin.Standard Discounted)
elseif (strpos($key, ' ') !== false) {
// explode on first .
$parts = explode('.', $key, 2);
if (count($parts) === 2) {
$namePart = ucfirst($parts[0]) . ' - ' . $parts[1];
} else {
// Cap first word before first space
$spacePos = strpos($key, ' ');
$first = ucfirst(substr($key, 0, $spacePos));
$rest = substr($key, $spacePos + 1);
$namePart = $first . ' - ' . $rest;
}
}
$item['subscriptionInserveName'] = $serverName . ' - ' . $namePart;
}
unset($item);
foreach ($subscriptionCounts as $key => $item) {
// if subscriptionInserveExists but the countInserve is null skip creation
if ($item['subscriptionInserveExists'] === false && (int)$item['countSentri'] === 0) {
continue;
}
// if subscriptionInserveExists is false create a new subscription
if ($item['subscriptionInserveExists'] === false) {
$payload = [
"cloud_distribution_id" => $item['md5'], #md5 hash based on the server_uuid from sentri and the subscription name (eg. server_cpu_count)
"cloud_subscription_id" => "sentri-servers", # Mark all the sentri-servers subscriptions so we can filter the subscriptions better
"name" => $item['subscriptionInserveName'],
"quantity" => $item['countSentri'],
"cloud_distribution_company_id" => $item['sentriCompanyId'], # this is generated by inserve (306 = digistate)
"status" => $item['SentriStatus'],
"period_type" => 0, # 0 = monthly, 1 = anual, 2 = one time cost
"start_date" => date('Y-m-d')
];
$this->createSubscription($payload);
continue;
}
// update the subscription if the countInserve and countSentri dont match
// Or when sentriCompanyId and subscriptionInserveCompanyId dont match
if ((
(int)$item['countInserve'] !== (int)$item['countSentri'] ||
(int)$item['sentriCompanyId'] !== (int)$item['subscriptionInserveCompanyId'] ||
(int)$item['SentriStatus'] !== (int)$item['subscriptionInserveStatus']
)
&& $item['subscriptionInserveExists'] !== false
) {
$payload = [
"quantity" => (int)$item['countSentri'],
"cloud_distribution_company_id" => (int)$item['sentriCompanyId'],
"name" => $item['subscriptionInserveName'],
"status" => $item['SentriStatus'],
"quantity" => $item['countSentri']
];
$this->updateSubscription($item['subscriptionInserveId'], $payload);
continue;
}
}
}
}
public function createSubscription($payload)
{
$url = $this->inserve_url . 'cloud-distribution-subscriptions';
$this->ch = curl_init($url);
# I need to make this pay load:
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json",
"Content-Type: application/json"
],
]);
$this->execCurl();
}
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_inserve extends API
{
private $inserve_url;
private $inserve_token;
public $inserve_source_uuid;
private $ch;
public $httpCode = false;
public $response = false;
private $cloudDistrubutor = 'digistate-servers';
public function setupConnection()
{
$query = "SELECT * FROM system_sources WHERE source_name = 'inserve'";
$result = $this->conn->query($query)->fetch_assoc();
$this->inserve_url = $result['source_url'];
$this->inserve_token = $result['source_auth_token'];
$this->inserve_source_uuid = $result['source_uuid'];
}
public function execCurl()
{
$this->response = curl_exec($this->ch);
$this->httpCode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
curl_close($this->ch);
}
public function returnResponse()
{
$this->apiOutput($this->httpCode, json_decode($this->response, true));
}
public function authMe()
{
$this->ch = curl_init($this->inserve_url . 'auth/me');
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json"
]
]);
$this->execCurl();
}
public function getLinkedCompanies()
{
$this->ch = curl_init($this->inserve_url . 'cloud-distributors/digistate-servers/companies');
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json"
]
]);
$this->execCurl();
}
public function companies($page)
{
// Build array the way the API expects
$params = [
'b' => [
['orderBy' => ['name', 'ASC']],
['orderBy' => ['id', 'DESC']],
['with' => ['operator', 'country']],
['paginate' => 300],
],
'page' => $page
];
$query = http_build_query($params);
$this->ch = curl_init($this->inserve_url . 'companies?' . $query);
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json"
]
]);
$this->execCurl();
return json_decode($this->response, true);
}
public function syncCompaniesFromSentri()
{
# First retrieve all the active companies to sync to the Inserver cloud distributor
$companies = [];
$sql = "SELECT company_source_id FROM companies WHERE company_state = 'active'";
$stmt = $this->conn->query($sql);
while ($row = $stmt->fetch_assoc()) {
$id = (int)$row['company_source_id'];
$companies[] = [
'cloud_distribution_id' => (string)$id,
'company_id' => $id
];
}
$url = $this->inserve_url . 'cloud-distributors/digistate-servers/companies';
$this->ch = curl_init($url);
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($companies),
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json",
"Content-Type: application/json"
],
]);
$this->execCurl();
}
public function getCloudSubscriptions()
{
$this->ch = curl_init($this->inserve_url . 'cloud-distribution-subscriptions/');
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json"
]
]);
$this->execCurl();
}
public function updateSubscription($subscriptionId = false, $payload = false)
{
$url = $this->inserve_url . 'cloud-distribution-subscriptions/' . $subscriptionId;
$this->ch = curl_init($url);
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json",
"Content-Type: application/json"
],
]);
$this->execCurl();
}
private function getAllTypes($type)
{
$allowedColumns = [
'server_licenses',
'server_backup'
];
if (!in_array($type, $allowedColumns, true)) {
throw new Exception('Invalid column name');
}
$query = "SELECT `$type` FROM servers";
$stmt = $this->prepareStatement($query);
$this->executeStatement($stmt);
$result = $stmt->get_result();
$servers = [];
while ($row = $result->fetch_assoc()) {
array_push($servers, $row);
}
$allTypes = [];
foreach ($servers as $server) {
if (!empty($server[$type])) {
$types = json_decode($server[$type], true);
if (is_array($types)) {
foreach ($types as $item) {
foreach ($item as $key => $value) {
$allTypes[$key . '.' . $value] = 0;
}
}
}
}
}
return $allTypes;
}
private function calculateTotalDiskUsage($diskJson)
{
$disks = json_decode($diskJson, true);
$server_disks_count = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$server_disks_count += $disk['disk_space'];
}
}
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$server_disks_count = array_sum($sizes);
}
return $server_disks_count;
}
private function buildCountObject(string $serverUuid, string $key): array
{
return [
'countSentri' => 0,
'countInserve' => 0,
'sentriCompanyId' => 0,
'SentriStatus' => 0,
'subscriptionInserveExists' => false,
'subscriptionInserveId' => false,
'subscriptionInserveCompanyId' => false,
'subscriptionInserveName' => false,
'subscriptionInserveStatus' => 0,
'md5' => md5($serverUuid . ':' . $key),
];
}
private function transformTypes(array $types, string $serverUuid): array
{
$result = [];
foreach ($types as $key => $value) {
$result[$key] = $this->buildCountObject($serverUuid, $key);
}
return $result;
}
private function buildCountArray($serverUuid)
{
$allBackupTypes = $this->getAllTypes('server_backup');
$allLicenseTypes = $this->getAllTypes('server_licenses');
$backupCounts = $this->transformTypes($allBackupTypes, $serverUuid);
$licenseCounts = $this->transformTypes($allLicenseTypes, $serverUuid);
return array_merge(
[
"server_CPU_count" => $this->buildCountObject($serverUuid, 'server_cpu_count'),
"server_Memory_count" => $this->buildCountObject($serverUuid, 'server_memory_count'),
"server_Disk_space_count" => $this->buildCountObject($serverUuid, 'server_disks_count'),
],
$licenseCounts,
$backupCounts
);
}
public function syncServerLicencesToInserve()
{
# Get all the linked companies
$this->getLinkedCompanies();
$allCompanies = json_decode($this->response, true);
$allCompaniesIds = array_column($allCompanies['matched'], 'id', 'company_id');
# first get the current subscriptions
$this->getCloudSubscriptions();
$allInserveSubscriptions = json_decode($this->response, true);
# Filter out all the none Sentri posted subscriptions based on the name for performance
$allInserveSubscriptions = array_filter($allInserveSubscriptions, function ($subscription) {
return isset($subscription['cloud_subscription_id']) && $subscription['cloud_subscription_id'] === 'sentri-servers';
});
# Build lookup of existing Inserve subscriptions by cloud_distribution_id
# this will be used later to lookup
$inserveLookup = [];
foreach ($allInserveSubscriptions as $subscription) {
if (!empty($subscription['cloud_distribution_id'])) {
$inserveLookup[$subscription['cloud_distribution_id']] = [
'id' => (int)$subscription['id'],
'quantity' => (int)$subscription['quantity'],
'status' => (int)$subscription['status'],
'cloud_distribution_company_id' => (int)$subscription['cloud_distribution_company_id'],
];
}
}
# get all the servers from Sentri
$sql = "SELECT * FROM servers INNER JOIN companies ON servers.company_uuid = companies.company_uuid WHERE company_state = 'active' AND server_state != 'new' AND server_state != 'disabled' ";
$stmt = $this->conn->query($sql);
while ($row = $stmt->fetch_assoc()) {
# Create a count of all the Subscriptions possible with every count on 0
$subscriptionCounts = $this->buildCountArray($row['server_uuid']);
$totalDiskSpace = $this->calculateTotalDiskUsage($row['server_disks']);
# Inserve status codes are:
# 0 = active, 1 = cancelled, 2 = pending, 3 = trial, 4 = on hold, 5 = removed
$statusMap = [
'active' => 0,
'trial' => 3,
'deleted' => 5,
];
// if no states matched there is something terrifying wrong, call the ambulance!
if (!isset($statusMap[$row['server_state']])) {
exit;
}
$sentriStatus = $statusMap[$row['server_state']];
# Set all the server resource counts from Sentri into the $subscriptionCounts
$subscriptionCounts['server_CPU_count']['countSentri'] = $row['server_cpu'];
$subscriptionCounts['server_Memory_count']['countSentri'] = (int)ceil($row['server_memory'] / 1024);
$subscriptionCounts['server_Disk_space_count']['countSentri'] = $totalDiskSpace;
$licenses = json_decode($row['server_licenses'], true);
foreach ($licenses as $license) {
foreach ($license as $key => $LicenseType) {
$subscriptionCounts[$key . '.' . $LicenseType]['countSentri']++;
}
}
$backups = json_decode($row['server_backup'], true);
foreach ($backups as $backup) {
foreach ($backup as $key => $BackupType) {
$subscriptionCounts[$key . '.' . $BackupType]['countSentri'] = $totalDiskSpace;
}
}
# Mark subscriptions that already exist in Inserve
foreach ($subscriptionCounts as $key => &$item) {
if (!is_array($item) || !isset($item['md5'])) {
continue;
}
$md5 = (string)$item['md5'];
if (isset($inserveLookup[$md5])) { # Subscription already exists in Inserve
$item['SentriStatus'] = $sentriStatus;
$item['sentriCompanyId'] = (int)$allCompaniesIds[$row['company_source_id']] ?? 0;
$item['subscriptionInserveExists'] = true;
$item['subscriptionInserveId'] = $inserveLookup[$item['md5']]['id'];
$item['countInserve'] = $inserveLookup[$item['md5']]['quantity'];
$item['subscriptionInserveCompanyId'] = $inserveLookup[$item['md5']]['cloud_distribution_company_id'];
$item['subscriptionInserveStatus'] = $inserveLookup[$item['md5']]['status'];
} else { # Subscription does not exists in Inserve
$item['sentriCompanyId'] = (int)$allCompaniesIds[$row['company_source_id']] ?? 0;
$item['subscriptionInserveExists'] = false;
$item['subscriptionInserveId'] = false;
$item['countInserve'] = 0;
$item['subscriptionInserveCompanyId'] = false;
}
}
unset($item);
// Make the subscriptions names look nice and dandy.
foreach ($subscriptionCounts as $key => &$item) {
// Set server name
$serverName = $row['server_hostname'] ?? $row['server_vm_host_name'] ?? 'Unknown';
// remove server_ prefix and _count suffix
$namePart = $key;
if (str_starts_with($key, 'server_') && str_ends_with($key, '_count')) {
$namePart = substr($key, 7, -6);
$namePart = ucfirst($namePart);
} // Handle keys with "."
elseif (strpos($key, '.') !== false) {
[$first, $second] = explode('.', $key, 2);
if ($first === $second || strtolower($second) === 'yes') {
$namePart = ucfirst($first);
} else {
$namePart = ucfirst($first) . ' - ' . $second;
}
} //Handle keys without . but with a space (expmale directadmin.Standard Discounted)
elseif (strpos($key, ' ') !== false) {
// explode on first .
$parts = explode('.', $key, 2);
if (count($parts) === 2) {
$namePart = ucfirst($parts[0]) . ' - ' . $parts[1];
} else {
// Cap first word before first space
$spacePos = strpos($key, ' ');
$first = ucfirst(substr($key, 0, $spacePos));
$rest = substr($key, $spacePos + 1);
$namePart = $first . ' - ' . $rest;
}
}
$item['subscriptionInserveName'] = $serverName . ' - ' . $namePart;
}
unset($item);
foreach ($subscriptionCounts as $key => $item) {
// if subscriptionInserveExists but the countInserve is null skip creation
if ($item['subscriptionInserveExists'] === false && (int)$item['countSentri'] === 0) {
continue;
}
// if subscriptionInserveExists is false create a new subscription
if ($item['subscriptionInserveExists'] === false) {
$payload = [
"cloud_distribution_id" => $item['md5'], #md5 hash based on the server_uuid from sentri and the subscription name (eg. server_cpu_count)
"cloud_subscription_id" => "sentri-servers", # Mark all the sentri-servers subscriptions so we can filter the subscriptions better
"name" => $item['subscriptionInserveName'],
"quantity" => $item['countSentri'],
"cloud_distribution_company_id" => $item['sentriCompanyId'], # this is generated by inserve (306 = digistate)
"status" => $item['SentriStatus'],
"period_type" => 0, # 0 = monthly, 1 = anual, 2 = one time cost
"start_date" => date('Y-m-d')
];
$this->createSubscription($payload);
continue;
}
// update the subscription if the countInserve and countSentri dont match
// Or when sentriCompanyId and subscriptionInserveCompanyId dont match
if ((
(int)$item['countInserve'] !== (int)$item['countSentri'] ||
(int)$item['sentriCompanyId'] !== (int)$item['subscriptionInserveCompanyId'] ||
(int)$item['SentriStatus'] !== (int)$item['subscriptionInserveStatus']
)
&& $item['subscriptionInserveExists'] !== false
) {
$payload = [
"quantity" => (int)$item['countSentri'],
"cloud_distribution_company_id" => (int)$item['sentriCompanyId'],
"name" => $item['subscriptionInserveName'],
"status" => $item['SentriStatus'],
"quantity" => $item['countSentri']
];
$this->updateSubscription($item['subscriptionInserveId'], $payload);
continue;
}
}
}
}
public function createSubscription($payload)
{
$url = $this->inserve_url . 'cloud-distribution-subscriptions';
$this->ch = curl_init($url);
# I need to make this pay load:
curl_setopt_array($this->ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
"X-Api-Key: $this->inserve_token",
"Accept: application/json",
"Content-Type: application/json"
],
]);
$this->execCurl();
}
}

View File

@@ -1,32 +1,32 @@
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_office_stompjes extends API
{
public function addStomp()
{
$query = "INSERT INTO office_stompjes (stomp_uuid, user_uuid, stomp_timestamp) VALUES (UUID(), ?, ?)";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('si', $this->data['user_uuid'], time());
$this->executeStatement($stmt);
$stmt->close();
$this->apiOutput(200, ['success' => 'Stomp added.']);
}
public function deleteStomp()
{
$query = "DELETE FROM office_stompjes WHERE stomp_uuid = ?";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('s', $this->data['stomp_uuid']);
$this->executeStatement($stmt);
$stmt->close();
$this->apiOutput(200, ['success' => 'Stomp removed.']);
}
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_office_stompjes extends API
{
public function addStomp()
{
$query = "INSERT INTO office_stompjes (stomp_uuid, user_uuid, stomp_timestamp) VALUES (UUID(), ?, ?)";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('si', $this->data['user_uuid'], time());
$this->executeStatement($stmt);
$stmt->close();
$this->apiOutput(200, ['success' => 'Stomp added.']);
}
public function deleteStomp()
{
$query = "DELETE FROM office_stompjes WHERE stomp_uuid = ?";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('s', $this->data['stomp_uuid']);
$this->executeStatement($stmt);
$stmt->close();
$this->apiOutput(200, ['success' => 'Stomp removed.']);
}
}

View File

@@ -1,277 +1,277 @@
<?php
namespace api\classes;
use api\classes\API;
use JsonException;
require_once 'API.php';
class API_servers extends API
{
public function getServers($returnBoolean = false)
{
list($query, $types, $params) = $this->buildDynamicQuery('servers');
$items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Server');
return $items;
}
public function validateDiskData($disks)
{
foreach ($disks as $index => $disk) {
// Ensure $disk is an array
if (!is_array($disk)) {
$this->apiOutput(400, ['error' => "Disk entry is not an array"]);
}
$requiredFields = ['disk_name', 'disk_space', 'disk_used', 'disk_location'];
foreach ($requiredFields as $field) {
if (!array_key_exists($field, $disk)) {
$this->apiOutput(400, ['error' => "Missing required field '$field' in disk information"]);
}
switch ($field) {
case 'disk_used':
case 'disk_space':
$disks[$index][$field] = $this->validateSingleData($disk[$field], ['type' => 'float']);
break;
case 'disk_location':
case 'disk_name':
$disks[$index][$field] = $this->validateSingleData($disk[$field], ['type' => 'string']);
break;
}
}
}
try {
return json_encode($disks, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
$this->apiOutput(400, ['error' => "Failed to encode disk data to JSON: " . $e->getMessage()]);
}
}
public function updateServer()
{
# if the server_state that is posted is 'deleted' check if the current server state is 'new' if so, delete it perm.
if ($this->data['server_state'] == 'deleted') {
$stmt = $GLOBALS['pdo']->prepare("SELECT server_state FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
$stmt->execute([$this->data['server_vm_id']]);
if ($stmt->fetch()) {
$deleteStmt = $GLOBALS['pdo']->prepare("DELETE FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
$deleteStmt->execute([$this->data['server_vm_id']]);
return;
}
}
if (isset($this->data['company_uuid'])) {
if (strlen($this->data['company_uuid']) == 0) {
$this->data['company_uuid'] = NULL;
}
}
$fields = [
'company_uuid',
'server_vm_id',
'server_vm_host_id',
'server_vm_host_name',
'server_power_state',
'server_state',
'server_hostname',
'server_os',
'server_cpu',
'server_memory',
'server_memory_demand',
'server_disks',
'server_ipv4',
'server_ipv6',
'server_vm_generation',
'server_vm_snapshot',
'server_licenses',
'server_backup',
'server_description'
];
$insertFields = ['server_uuid'];
$insertValues = ['UUID()'];
$bindParams = [];
foreach ($fields as $field) {
if (array_key_exists($field, $this->data)) {
$insertFields[] = $field;
$insertValues[] = ":$field";
$bindParams[":$field"] = $this->data[$field];
}
}
# Always include server_create_timestamp and server_modified_timestamp
$insertFields[] = 'server_create_timestamp';
$insertValues[] = ':server_create_timestamp';
$bindParams[':server_create_timestamp'] = time();
$insertFields[] = 'server_modified_timestamp';
$insertValues[] = ':server_modified_timestamp';
$bindParams[':server_modified_timestamp'] = time();
$query = "INSERT INTO servers (" . implode(',', $insertFields) . ")
VALUES (" . implode(',', $insertValues) . ")
ON DUPLICATE KEY UPDATE ";
# Build the ON DUPLICATE KEY UPDATE, only foor fields that exist
$updateParts = [];
foreach ($insertFields as $field) {
if (!in_array($field, ['server_create_timestamp', 'server_uuid'])) {
$updateParts[] = "$field = VALUES($field)";
}
}
$query .= implode(", ", $updateParts);
$stmt = $GLOBALS['pdo']->prepare($query);
if (!$stmt->execute($bindParams)) {
$this->apiOutput(400, ['error' => "Failed to insert server into database"]);
}
}
private function validateLicenseData($server_vm_id, $server_licenses)
{
$server_vm_id = $this->validateSingleData($server_vm_id, ['type' => 'string']);
$server_licenses_posted = $this->validateSingleData($server_licenses, ['type' => 'array']);
$query = "SELECT server_licenses FROM servers WHERE server_vm_id = ?";
$stmt = $this->prepareStatement($query);
$stmt->bind_param("s", $server_vm_id);
$this->executeStatement($stmt);
$result = $stmt->get_result();
$server_licenses_db = $result->fetch_assoc();
$server_licenses_db = $server_licenses_db['server_licenses'] ?? null;
$server_licenses_db_new = [];
if (!empty($server_licenses_db)) {
$decoded = json_decode($server_licenses_db, true);
if (is_array($decoded)) {
foreach ($decoded as $item) {
foreach ($item as $key => $value) {
$server_licenses_db_new[$key] = $value;
}
}
}
}
foreach ($server_licenses_posted as $item) {
foreach ($item as $rawKey => $value) {
$prefix = substr($rawKey, 0, 1);
$license = substr($rawKey, 1);
if ($prefix === '+') {
$server_licenses_db_new[$license] = $value;
}
if ($prefix === '-') {
unset($server_licenses_db_new[$license]);
}
}
}
$server_licenses_db_new_final = [];
foreach ($server_licenses_db_new as $key => $value) {
$server_licenses_db_new_final[] = [$key => $value];
}
return empty($server_licenses_db_new_final) ? '[]' : json_encode($server_licenses_db_new_final);
}
private function validateBackupData($server_vm_id, $server_backup)
{
$server_vm_id = $this->validateSingleData($server_vm_id, ['type' => 'string']);
$server_backup_posted = $this->validateSingleData($server_backup, ['type' => 'array']);
$query = "SELECT server_backup FROM servers WHERE server_vm_id = ?";
$stmt = $this->prepareStatement($query);
$stmt->bind_param("s", $server_vm_id);
$this->executeStatement($stmt);
$result = $stmt->get_result();
$server_backup_db = $result->fetch_assoc();
$server_backup_db = $server_backup_db['server_backup'] ?? null;
$server_backup_db_new = [];
if (!empty($server_backup_db)) {
$decoded = json_decode($server_backup_db, true);
if (is_array($decoded)) {
foreach ($decoded as $item) {
foreach ($item as $key => $value) {
$server_backup_db_new[$key] = $value;
}
}
}
}
foreach ($server_backup_posted as $item) {
foreach ($item as $rawKey => $value) {
$prefix = substr($rawKey, 0, 1);
$backup = substr($rawKey, 1);
if ($prefix === '+') {
$server_backup_db_new[$backup] = $value;
}
if ($prefix === '-') {
unset($server_backup_db_new[$backup]);
}
}
}
$server_backup_db_new_final = [];
foreach ($server_backup_db_new as $key => $value) {
$server_backup_db_new_final[] = [$key => $value];
}
return empty($server_backup_db_new_final) ? '[]' : json_encode($server_backup_db_new_final);
}
public function processServerData($server, $requiredFields, $optionalFields)
{
// since the disk data is sent as an array we need to check it seperatly from the other data validations
if (!empty($server['server_disks']) && is_array($server['server_disks'])) {
$server['server_disks'] = $this->validateDiskData($server['server_disks']);
} else {
unset($server['server_disks']);
}
if (!empty($server['server_licenses']) && is_array($server['server_licenses'])) {
$server['server_licenses'] = $this->validateLicenseData($server['server_vm_id'], $server['server_licenses']);
} else {
unset($server['server_licenses']);
}
if (!empty($server['server_backup']) && is_array($server['server_backup'])) {
$server['server_backup'] = $this->validateBackupData($server['server_vm_id'], $server['server_backup']);
} else {
unset($server['server_backup']);
}
foreach (['server_ipv4', 'server_ipv6'] as $key) {
if (!empty($server[$key]) && is_array($server[$key])) {
$server[$key] = json_encode($server[$key]);
} else {
unset($server[$key]);
}
}
$this->postedData = $server;
$this->validateData($requiredFields, $optionalFields);
$this->updateServer();
}
<?php
namespace api\classes;
use api\classes\API;
use JsonException;
require_once 'API.php';
class API_servers extends API
{
public function getServers($returnBoolean = false)
{
list($query, $types, $params) = $this->buildDynamicQuery('servers');
$items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Server');
return $items;
}
public function validateDiskData($disks)
{
foreach ($disks as $index => $disk) {
// Ensure $disk is an array
if (!is_array($disk)) {
$this->apiOutput(400, ['error' => "Disk entry is not an array"]);
}
$requiredFields = ['disk_name', 'disk_space', 'disk_used', 'disk_location'];
foreach ($requiredFields as $field) {
if (!array_key_exists($field, $disk)) {
$this->apiOutput(400, ['error' => "Missing required field '$field' in disk information"]);
}
switch ($field) {
case 'disk_used':
case 'disk_space':
$disks[$index][$field] = $this->validateSingleData($disk[$field], ['type' => 'float']);
break;
case 'disk_location':
case 'disk_name':
$disks[$index][$field] = $this->validateSingleData($disk[$field], ['type' => 'string']);
break;
}
}
}
try {
return json_encode($disks, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
$this->apiOutput(400, ['error' => "Failed to encode disk data to JSON: " . $e->getMessage()]);
}
}
public function updateServer()
{
# if the server_state that is posted is 'deleted' check if the current server state is 'new' if so, delete it perm.
if ($this->data['server_state'] == 'deleted') {
$stmt = $GLOBALS['pdo']->prepare("SELECT server_state FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
$stmt->execute([$this->data['server_vm_id']]);
if ($stmt->fetch()) {
$deleteStmt = $GLOBALS['pdo']->prepare("DELETE FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
$deleteStmt->execute([$this->data['server_vm_id']]);
return;
}
}
if (isset($this->data['company_uuid'])) {
if (strlen($this->data['company_uuid']) == 0) {
$this->data['company_uuid'] = NULL;
}
}
$fields = [
'company_uuid',
'server_vm_id',
'server_vm_host_id',
'server_vm_host_name',
'server_power_state',
'server_state',
'server_hostname',
'server_os',
'server_cpu',
'server_memory',
'server_memory_demand',
'server_disks',
'server_ipv4',
'server_ipv6',
'server_vm_generation',
'server_vm_snapshot',
'server_licenses',
'server_backup',
'server_description'
];
$insertFields = ['server_uuid'];
$insertValues = ['UUID()'];
$bindParams = [];
foreach ($fields as $field) {
if (array_key_exists($field, $this->data)) {
$insertFields[] = $field;
$insertValues[] = ":$field";
$bindParams[":$field"] = $this->data[$field];
}
}
# Always include server_create_timestamp and server_modified_timestamp
$insertFields[] = 'server_create_timestamp';
$insertValues[] = ':server_create_timestamp';
$bindParams[':server_create_timestamp'] = time();
$insertFields[] = 'server_modified_timestamp';
$insertValues[] = ':server_modified_timestamp';
$bindParams[':server_modified_timestamp'] = time();
$query = "INSERT INTO servers (" . implode(',', $insertFields) . ")
VALUES (" . implode(',', $insertValues) . ")
ON DUPLICATE KEY UPDATE ";
# Build the ON DUPLICATE KEY UPDATE, only foor fields that exist
$updateParts = [];
foreach ($insertFields as $field) {
if (!in_array($field, ['server_create_timestamp', 'server_uuid'])) {
$updateParts[] = "$field = VALUES($field)";
}
}
$query .= implode(", ", $updateParts);
$stmt = $GLOBALS['pdo']->prepare($query);
if (!$stmt->execute($bindParams)) {
$this->apiOutput(400, ['error' => "Failed to insert server into database"]);
}
}
private function validateLicenseData($server_vm_id, $server_licenses)
{
$server_vm_id = $this->validateSingleData($server_vm_id, ['type' => 'string']);
$server_licenses_posted = $this->validateSingleData($server_licenses, ['type' => 'array']);
$query = "SELECT server_licenses FROM servers WHERE server_vm_id = ?";
$stmt = $this->prepareStatement($query);
$stmt->bind_param("s", $server_vm_id);
$this->executeStatement($stmt);
$result = $stmt->get_result();
$server_licenses_db = $result->fetch_assoc();
$server_licenses_db = $server_licenses_db['server_licenses'] ?? null;
$server_licenses_db_new = [];
if (!empty($server_licenses_db)) {
$decoded = json_decode($server_licenses_db, true);
if (is_array($decoded)) {
foreach ($decoded as $item) {
foreach ($item as $key => $value) {
$server_licenses_db_new[$key] = $value;
}
}
}
}
foreach ($server_licenses_posted as $item) {
foreach ($item as $rawKey => $value) {
$prefix = substr($rawKey, 0, 1);
$license = substr($rawKey, 1);
if ($prefix === '+') {
$server_licenses_db_new[$license] = $value;
}
if ($prefix === '-') {
unset($server_licenses_db_new[$license]);
}
}
}
$server_licenses_db_new_final = [];
foreach ($server_licenses_db_new as $key => $value) {
$server_licenses_db_new_final[] = [$key => $value];
}
return empty($server_licenses_db_new_final) ? '[]' : json_encode($server_licenses_db_new_final);
}
private function validateBackupData($server_vm_id, $server_backup)
{
$server_vm_id = $this->validateSingleData($server_vm_id, ['type' => 'string']);
$server_backup_posted = $this->validateSingleData($server_backup, ['type' => 'array']);
$query = "SELECT server_backup FROM servers WHERE server_vm_id = ?";
$stmt = $this->prepareStatement($query);
$stmt->bind_param("s", $server_vm_id);
$this->executeStatement($stmt);
$result = $stmt->get_result();
$server_backup_db = $result->fetch_assoc();
$server_backup_db = $server_backup_db['server_backup'] ?? null;
$server_backup_db_new = [];
if (!empty($server_backup_db)) {
$decoded = json_decode($server_backup_db, true);
if (is_array($decoded)) {
foreach ($decoded as $item) {
foreach ($item as $key => $value) {
$server_backup_db_new[$key] = $value;
}
}
}
}
foreach ($server_backup_posted as $item) {
foreach ($item as $rawKey => $value) {
$prefix = substr($rawKey, 0, 1);
$backup = substr($rawKey, 1);
if ($prefix === '+') {
$server_backup_db_new[$backup] = $value;
}
if ($prefix === '-') {
unset($server_backup_db_new[$backup]);
}
}
}
$server_backup_db_new_final = [];
foreach ($server_backup_db_new as $key => $value) {
$server_backup_db_new_final[] = [$key => $value];
}
return empty($server_backup_db_new_final) ? '[]' : json_encode($server_backup_db_new_final);
}
public function processServerData($server, $requiredFields, $optionalFields)
{
// since the disk data is sent as an array we need to check it seperatly from the other data validations
if (!empty($server['server_disks']) && is_array($server['server_disks'])) {
$server['server_disks'] = $this->validateDiskData($server['server_disks']);
} else {
unset($server['server_disks']);
}
if (!empty($server['server_licenses']) && is_array($server['server_licenses'])) {
$server['server_licenses'] = $this->validateLicenseData($server['server_vm_id'], $server['server_licenses']);
} else {
unset($server['server_licenses']);
}
if (!empty($server['server_backup']) && is_array($server['server_backup'])) {
$server['server_backup'] = $this->validateBackupData($server['server_vm_id'], $server['server_backup']);
} else {
unset($server['server_backup']);
}
foreach (['server_ipv4', 'server_ipv6'] as $key) {
if (!empty($server[$key]) && is_array($server[$key])) {
$server[$key] = json_encode($server[$key]);
} else {
unset($server[$key]);
}
}
$this->postedData = $server;
$this->validateData($requiredFields, $optionalFields);
$this->updateServer();
}
}

View File

@@ -1,34 +1,34 @@
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_system_modules extends API
{
public function getModules($returnBoolean = false)
{
list($query, $types, $params) = $this->buildDynamicQuery('system_modules');
$items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Permission');
return $items;
}
public function enableModule()
{
$module_uuid_enabled = ($this->data['module_enabled']) ? 0 : 1;
# Module 'system cannot be disabled'
$query = "UPDATE system_modules SET module_enabled = ? WHERE module_uuid = ? AND module_slugify != 'system'";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('is', $module_uuid_enabled, $this->data['module_uuid']);
if ($this->executeStatement($stmt)) {
$this->apiOutput(200, ['success' => 'Module ' . ($module_uuid_enabled ? 'enabled' : 'disabled') . ' successfully.']);
}
}
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_system_modules extends API
{
public function getModules($returnBoolean = false)
{
list($query, $types, $params) = $this->buildDynamicQuery('system_modules');
$items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Permission');
return $items;
}
public function enableModule()
{
$module_uuid_enabled = ($this->data['module_enabled']) ? 0 : 1;
# Module 'system cannot be disabled'
$query = "UPDATE system_modules SET module_enabled = ? WHERE module_uuid = ? AND module_slugify != 'system'";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('is', $module_uuid_enabled, $this->data['module_uuid']);
if ($this->executeStatement($stmt)) {
$this->apiOutput(200, ['success' => 'Module ' . ($module_uuid_enabled ? 'enabled' : 'disabled') . ' successfully.']);
}
}
}

View File

@@ -1,26 +1,26 @@
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_system_sources extends API
{
public function inserveUpdate()
{
$query = "INSERT INTO system_sources (source_uuid, source_name, source_url, source_auth_username, source_auth_password, source_auth_token, source_create_timestamp, source_modified_timestamp)
VALUES (UUID(), ?, ?, '', '', ?, ?, NULL)
ON DUPLICATE KEY UPDATE
source_url = VALUES(source_url),
source_auth_token = VALUES(source_auth_token),
source_modified_timestamp = VALUES(source_create_timestamp)";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('sssi', $this->data['source_name'], $this->data['source_url'], $this->data['source_auth_token'], time());
$this->executeStatement($stmt);
$stmt->close();
$this->apiOutput(200, ['success' => 'Information modified'], 'Information updated successfully.');
}
<?php
namespace api\classes;
use api\classes\API;
require_once 'API.php';
class API_system_sources extends API
{
public function inserveUpdate()
{
$query = "INSERT INTO system_sources (source_uuid, source_name, source_url, source_auth_username, source_auth_password, source_auth_token, source_create_timestamp, source_modified_timestamp)
VALUES (UUID(), ?, ?, '', '', ?, ?, NULL)
ON DUPLICATE KEY UPDATE
source_url = VALUES(source_url),
source_auth_token = VALUES(source_auth_token),
source_modified_timestamp = VALUES(source_create_timestamp)";
$stmt = $this->prepareStatement($query);
$stmt->bind_param('sssi', $this->data['source_name'], $this->data['source_url'], $this->data['source_auth_token'], time());
$this->executeStatement($stmt);
$stmt->close();
$this->apiOutput(200, ['success' => 'Information modified'], 'Information updated successfully.');
}
}

View File

@@ -1,34 +1,33 @@
<?php
use api\classes\API_companies;
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_companies.php';
# Check permissions
$API_companies = new API_companies();
if ($API_companies->request_method === 'PUT') {
$API_companies->checkPermissions('customer-companies', 'RW');
# when called from the frontend will not be forwarding to a url since when its called from the frontend it doesnt need a redirection
$API_companies->return_url = false;
$requiredFields = [
'company_uuid' => ['type' => 'uuid'],
'company_state' => ['type' => 'enum', 'values' => ['active', 'imported', 'orphaned']]
];
$API_companies->validateData($requiredFields);
$API_companies->updateCompanyState();
<?php
use api\classes\API_companies;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_companies.php';
# Check permissions
$API_companies = new API_companies();
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
if ($API_companies->request_method === 'PUT') {
$API_companies->checkPermissions('customer-companies', 'RW');
# when called from the frontend will not be forwarding to a url since when its called from the frontend it doesnt need a redirection
$API_companies->return_url = false;
$requiredFields = [
'company_uuid' => ['type' => 'uuid'],
'company_state' => ['type' => 'enum', 'values' => ['active', 'imported', 'orphaned']]
];
$API_companies->validateData($requiredFields);
$API_companies->updateCompanyState();
}

View File

@@ -1,43 +1,43 @@
<?php
use api\classes\API_office_stompjes;
if (!$GLOBALS['modules_enabled']['office']) {
echo '405 Not Allowed';
exit;
}
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_office_stompjes.php';
$API_office_stompjes = new API_office_stompjes();
if ($API_office_stompjes->request_method === 'POST') {
$API_office_stompjes->checkPermissions('ofice-stompjes-canstomp', 'RW');
$API_office_stompjes->return_url = false;
$requiredFields = [
'user_uuid' => ['type' => 'uuid']
];
$API_office_stompjes->validateData($requiredFields);
$modules = $API_office_stompjes->addStomp();
$API_office_stompjes->apiOutput($code = 200, ['success' => 'stomp added successfully.']);
} elseif ($API_office_stompjes->request_method === 'DELETE') {
# Only superuser can delete permission due to fact that the backend needs programming when setting a permission
$API_office_stompjes->checkPermissions('ofice-stompjes', 'RW');
# when called from the frontend will not be forwarding to a url since when its called from the frontend it doesnt need a redirection
$API_office_stompjes->return_url = false;
$requiredFields = ['stomp_uuid' => ['type' => 'uuid']];
$API_office_stompjes->validateData($requiredFields);
# delete permission
$API_office_stompjes->deleteStomp();
<?php
use api\classes\API_office_stompjes;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_office_stompjes.php';
$API_office_stompjes = new API_office_stompjes();
if (!$GLOBALS['modules_enabled']['office']) {
echo '405 Not Allowed';
exit;
}
if ($API_office_stompjes->request_method === 'POST') {
$API_office_stompjes->checkPermissions('ofice-stompjes-canstomp', 'RW');
$API_office_stompjes->return_url = false;
$requiredFields = [
'user_uuid' => ['type' => 'uuid']
];
$API_office_stompjes->validateData($requiredFields);
$modules = $API_office_stompjes->addStomp();
$API_office_stompjes->apiOutput($code = 200, ['success' => 'stomp added successfully.']);
} elseif ($API_office_stompjes->request_method === 'DELETE') {
# Only superuser can delete permission due to fact that the backend needs programming when setting a permission
$API_office_stompjes->checkPermissions('ofice-stompjes', 'RW');
# when called from the frontend will not be forwarding to a url since when its called from the frontend it doesnt need a redirection
$API_office_stompjes->return_url = false;
$requiredFields = ['stomp_uuid' => ['type' => 'uuid']];
$API_office_stompjes->validateData($requiredFields);
# delete permission
$API_office_stompjes->deleteStomp();
}

View File

@@ -1,57 +1,57 @@
<?php
use api\classes\API_servers;
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
$API_servers = new API_servers();
if ($API_servers->request_method === 'POST') {
$API_servers->checkPermissions('servers', 'RW');
$requiredFields = [
'server_vm_id' => ['type' => 'string'],
];
$optionalFields = [
'server_vm_host_id' => ['type' => 'string'],
'server_vm_host_name' => ['type' => 'string'],
'company_uuid' => ['type' => 'string'],
'server_power_state' => ['type' => 'enum', 'values' => ['Running', 'Off']],
'server_state' => ['type' => 'enum', 'values' => ['new', 'active', 'deleted', 'trial', 'disabled']],
'server_hostname' => ['type' => 'string'],
'server_os' => ['type' => 'string'],
'server_cpu' => ['type' => 'int'],
'server_memory' => ['type' => 'int'],
'server_memory_demand' => ['type' => 'int'],
'server_disks' => ['type' => 'json'],
'server_ipv4' => ['type' => 'json'],
'server_ipv6' => ['type' => 'json'],
'server_vm_generation' => ['type' => 'int'],
'server_vm_snapshot' => ['type' => 'int'],
'server_licenses' => ['type' => 'json'],
'server_backup' => ['type' => 'json'],
'server_description' => ['type' => 'string'],
];
if (isset($API_servers->postedData['servers'])) {
// multiple servers are posted
$allServers = $API_servers->postedData['servers'];
foreach ($allServers as $server) {
$API_servers->processServerData($server, $requiredFields, $optionalFields);
}
} else {
// Single server update
$API_servers->processServerData($API_servers->postedData, $requiredFields, $optionalFields);
}
$API_servers->apiOutput(200, ['success' => "Server(s) modified or updated successfully."]);
<?php
use api\classes\API_servers;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
$API_servers = new API_servers();
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
if ($API_servers->request_method === 'POST') {
$API_servers->checkPermissions('servers', 'RW');
$requiredFields = [
'server_vm_id' => ['type' => 'string'],
];
$optionalFields = [
'server_vm_host_id' => ['type' => 'string'],
'server_vm_host_name' => ['type' => 'string'],
'company_uuid' => ['type' => 'string'],
'server_power_state' => ['type' => 'enum', 'values' => ['Running', 'Off']],
'server_state' => ['type' => 'enum', 'values' => ['new', 'active', 'deleted', 'trial', 'disabled']],
'server_hostname' => ['type' => 'string'],
'server_os' => ['type' => 'string'],
'server_cpu' => ['type' => 'int'],
'server_memory' => ['type' => 'int'],
'server_memory_demand' => ['type' => 'int'],
'server_disks' => ['type' => 'json'],
'server_ipv4' => ['type' => 'json'],
'server_ipv6' => ['type' => 'json'],
'server_vm_generation' => ['type' => 'int'],
'server_vm_snapshot' => ['type' => 'int'],
'server_licenses' => ['type' => 'json'],
'server_backup' => ['type' => 'json'],
'server_description' => ['type' => 'string'],
];
if (isset($API_servers->postedData['servers'])) {
// multiple servers are posted
$allServers = $API_servers->postedData['servers'];
foreach ($allServers as $server) {
$API_servers->processServerData($server, $requiredFields, $optionalFields);
}
} else {
// Single server update
$API_servers->processServerData($API_servers->postedData, $requiredFields, $optionalFields);
}
$API_servers->apiOutput(200, ['success' => "Server(s) modified or updated successfully."]);
}

View File

@@ -1,24 +1,24 @@
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
$API_inserve->setupConnection();
if ($API_inserve->request_method === 'GET') {
if ($_GET['action'] = 'auth/me') {
$API_inserve->checkPermissions('admin-sources', 'RO');
# This api call, when called from the frontend will not be forwarding to a url.
$API_inserve->return_url = false;
$auth = $API_inserve->authMe();
http_response_code($API_inserve->httpCode);
}
}
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
$API_inserve->setupConnection();
if ($API_inserve->request_method === 'GET') {
if ($_GET['action'] = 'auth/me') {
$API_inserve->checkPermissions('admin-sources', 'RO');
# This api call, when called from the frontend will not be forwarding to a url.
$API_inserve->return_url = false;
$auth = $API_inserve->authMe();
http_response_code($API_inserve->httpCode);
}
}

View File

@@ -1,22 +1,22 @@
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
if ($API_inserve->request_method === 'GET' || $API_inserve->request_method === 'POST') {
# This syncs the company id's from Sentri to the Inserve cloudDistributor
# These are the same id's but it Inserve requires it to be synced to the cloudDistributor
$API_inserve->checkPermissions('servers', 'RW');
$API_inserve->setupConnection();
$API_inserve->syncCompaniesFromSentri();
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
if ($API_inserve->request_method === 'GET' || $API_inserve->request_method === 'POST') {
# This syncs the company id's from Sentri to the Inserve cloudDistributor
# These are the same id's but it Inserve requires it to be synced to the cloudDistributor
$API_inserve->checkPermissions('servers', 'RW');
$API_inserve->setupConnection();
$API_inserve->syncCompaniesFromSentri();
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
}

View File

@@ -1,65 +1,65 @@
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
$API_inserve->setupConnection();
if ($API_inserve->request_method === 'POST' || $API_inserve->request_method === 'GET') {
# Code below will retrieve all the companies and create or update it in the database
$API_inserve->checkPermissions('customer-companies', 'RW');
$allCompanies = [];
$page = 1;
do {
$result = $API_inserve->companies($page);
if (!isset($result['data']) || empty($result['data'])) {
break;
}
foreach ($result['data'] as $item) {
$allCompanies[] = [
'id' => $item['id'],
'name' => $item['name'],
'debtor_code' => $item['debtor_code'],
'archived_at' => $item['archived_at']
];
}
$page++;
} while ($result['next_page_url'] !== null);
foreach ($allCompanies as $company) {
$source_uuid = $API_inserve->inserve_source_uuid;
$company_id = $company['id'];
$debtor_code = $company['debtor_code'];
$company_name = $company['name'];
$created_at = time();
# Add or modify the company if it is not archived
if ($company['archived_at'] == null) {
$query = "INSERT INTO companies (source_uuid, company_source_id, company_source_id2, company_name, company_create_timestamp)
VALUES (?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
company_name = VALUES(company_name),
company_source_id2 = VALUES(company_source_id2),
company_modified_timestamp = VALUES(company_create_timestamp)";
$stmt = $API_inserve->prepareStatement($query);
$stmt->bind_param('ssssi', $source_uuid, $company_id, $debtor_code, $company_name, $created_at);
$API_inserve->executeStatement($stmt);
$stmt->close();
}
}
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
}
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
$API_inserve->setupConnection();
if ($API_inserve->request_method === 'POST' || $API_inserve->request_method === 'GET') {
# Code below will retrieve all the companies and create or update it in the database
$API_inserve->checkPermissions('customer-companies', 'RW');
$allCompanies = [];
$page = 1;
do {
$result = $API_inserve->companies($page);
if (!isset($result['data']) || empty($result['data'])) {
break;
}
foreach ($result['data'] as $item) {
$allCompanies[] = [
'id' => $item['id'],
'name' => $item['name'],
'debtor_code' => $item['debtor_code'],
'archived_at' => $item['archived_at']
];
}
$page++;
} while ($result['next_page_url'] !== null);
foreach ($allCompanies as $company) {
$source_uuid = $API_inserve->inserve_source_uuid;
$company_id = $company['id'];
$debtor_code = $company['debtor_code'];
$company_name = $company['name'];
$created_at = time();
# Add or modify the company if it is not archived
if ($company['archived_at'] == null) {
$query = "INSERT INTO companies (source_uuid, company_source_id, company_source_id2, company_name, company_create_timestamp)
VALUES (?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
company_name = VALUES(company_name),
company_source_id2 = VALUES(company_source_id2),
company_modified_timestamp = VALUES(company_create_timestamp)";
$stmt = $API_inserve->prepareStatement($query);
$stmt->bind_param('ssssi', $source_uuid, $company_id, $debtor_code, $company_name, $created_at);
$API_inserve->executeStatement($stmt);
$stmt->close();
}
}
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
}

View File

@@ -1,20 +1,20 @@
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
if ($API_inserve->request_method === 'GET' || $API_inserve->request_method === 'POST') {
$API_inserve->checkPermissions('servers', 'RW');
$API_inserve->setupConnection();
$API_inserve->syncCompaniesFromSentri();
$API_inserve->syncServerLicencesToInserve();
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
if ($API_inserve->request_method === 'GET' || $API_inserve->request_method === 'POST') {
$API_inserve->checkPermissions('servers', 'RW');
$API_inserve->setupConnection();
$API_inserve->syncCompaniesFromSentri();
$API_inserve->syncServerLicencesToInserve();
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
}

View File

@@ -1,37 +1,37 @@
<?php
use api\classes\API_system_modules;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_modules.php';
$API_system_modules = new API_system_modules();
if ($API_system_modules->request_method === 'GET') {
# this part here is not tested (the whole GET part)
$API_system_modules->checkPermissions('admin-modules', 'RO');
$requiredFields = [];
$API_system_modules->validateData($requiredFields);
$modules = $API_system_modules->getModules();
$API_system_modules->apiOutput($code = 200, ['success' => $modules], '');
} elseif ($API_system_modules->request_method === 'PUT') {
# Enable or disable a module
$API_system_modules->checkPermissions('admin-modules', 'RW');
# This api call, when called from the frontend will not be forwarding to a url.
$API_system_modules->return_url = false;
$requiredFields = [
'module_uuid' => ['type' => 'uuid'],
'module_enabled' => ['type' => 'boolean'],
];
$API_system_modules->validateData($requiredFields);
$API_system_modules->enableModule();
}
<?php
use api\classes\API_system_modules;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_modules.php';
$API_system_modules = new API_system_modules();
if ($API_system_modules->request_method === 'GET') {
# this part here is not tested (the whole GET part)
$API_system_modules->checkPermissions('admin-modules', 'RO');
$requiredFields = [];
$API_system_modules->validateData($requiredFields);
$modules = $API_system_modules->getModules();
$API_system_modules->apiOutput($code = 200, ['success' => $modules], '');
} elseif ($API_system_modules->request_method === 'PUT') {
# Enable or disable a module
$API_system_modules->checkPermissions('admin-modules', 'RW');
# This api call, when called from the frontend will not be forwarding to a url.
$API_system_modules->return_url = false;
$requiredFields = [
'module_uuid' => ['type' => 'uuid'],
'module_enabled' => ['type' => 'boolean'],
];
$API_system_modules->validateData($requiredFields);
$API_system_modules->enableModule();
}

View File

@@ -1,30 +1,30 @@
<?php
use api\classes\API_system_sources;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_sources.php';
$API_system_sources = new API_system_sources();
if ($API_system_sources->request_method === 'POST') {
# Enable or disable a module
$API_system_sources->checkPermissions('admin-sources', 'RW');
if ($_POST['source_name'] == 'inserve') {
$requiredFields = [
'source_name' => ['type' => 'string'],
'source_url' => ['type' => 'string'],
'source_auth_token' => ['type' => 'string'],
];
} else {
$API_system_sources->apiOutput(400, ['error' => 'Error: no valid source_name posted']);
}
$API_system_sources->validateData($requiredFields);
if ($_POST['source_name'] == 'inserve') {
$API_system_sources->inserveUpdate();
}
}
<?php
use api\classes\API_system_sources;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_sources.php';
$API_system_sources = new API_system_sources();
if ($API_system_sources->request_method === 'POST') {
# Enable or disable a module
$API_system_sources->checkPermissions('admin-sources', 'RW');
if ($_POST['source_name'] == 'inserve') {
$requiredFields = [
'source_name' => ['type' => 'string'],
'source_url' => ['type' => 'string'],
'source_auth_token' => ['type' => 'string'],
];
} else {
$API_system_sources->apiOutput(400, ['error' => 'Error: no valid source_name posted']);
}
$API_system_sources->validateData($requiredFields);
if ($_POST['source_name'] == 'inserve') {
$API_system_sources->inserveUpdate();
}
}

View File

@@ -1,15 +1,15 @@
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
if (isset($_GET['view'])) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_company_view.php');
} else {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_view.php');
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
if (isset($_GET['view'])) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_company_view.php');
} else {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_view.php');
}

View File

@@ -1,125 +1,126 @@
<?php
use api\classes\API_servers;
use bin\php\Classes\serverOverviewBuilder;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
# Check permissions
$API_servers = new API_servers();
if (!$API_servers->checkPermissions('customer-companies', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['datepicker'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelectServers'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
$serverOverview = new serverOverviewBuilder();
# Retrieve Information for the page
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM companies WHERE company_uuid = ?");
$stmt->bind_param('s', $company_uuid);
$stmt->execute();
$result = $stmt->get_result();
$company_data = $result->fetch_assoc();
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('companies'), 'href' => '/companies/'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $company_data['company_name'], 'href' => ''));
# Retrieve Information for the page
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$_GET['company_uuid'] = $company_uuid;
$_GET['builder'] = [1 => ['where' => [0 => 'company_uuid', 1 => $company_uuid]]];
$requiredFields = ['company_uuid' => ['type' => 'uuid']];
$API_servers->postedData = $_GET;
$API_servers->validateData($requiredFields);
$servers_data = $API_servers->getServers(true);
if (count($servers_data) > 0) {
$serverOverview->servers = $servers_data;
$serverOverview->processServerData();
$serverOverview->showDelBtn = false;
$serverOverview->showCompanies = false;
}
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> <?php echo $company_data['company_name'] ?>
</h1>
</div>
<div class="col-md-6 col-lg-6">
<table>
<tr>
<td>company_uuid:</td>
<td><?php echo $company_data['company_uuid'] ?></td>
</tr>
<tr>
<td>source_uuid:</td>
<td><?php echo $company_data['source_uuid'] ?></td>
</tr>
<tr>
<td>company_source_id:</td>
<td><?php echo $company_data['company_source_id'] ?></td>
</tr>
<tr>
<td>company_source_id2:</td>
<td><?php echo $company_data['company_source_id2'] ?></td>
</tr>
<tr>
<td>company_name:</td>
<td><?php echo $company_data['company_name'] ?></td>
</tr>
<tr>
<td>company_state:</td>
<td><?php echo $company_data['company_state'] ?></td>
</tr>
<tr>
<td>company_create_timestamp:</td>
<td><?php echo $company_data['company_create_timestamp'] ?></td>
</tr>
<tr>
<td>company_modified_timestamp:</td>
<td><?php echo $company_data['company_modified_timestamp'] ?></td>
</tr>
</table>
</div>
</div>
</div>
<?php
if ($GLOBALS['modules_enabled']['servers'] && $API_servers->checkPermissions('servers', 'RO', true)) {
if (count($servers_data) > 0) {
$serverOverview->serverOverviewOutPut();
}
}
<?php
use api\classes\API_servers;
use bin\php\Classes\serverOverviewBuilder;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
# Check permissions
$API_servers = new API_servers();
if (!$API_servers->checkPermissions('customer-companies', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['datepicker'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelectServers'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
$serverOverview = new serverOverviewBuilder();
# Retrieve Information for the page
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM companies WHERE company_uuid = ?");
$stmt->bind_param('s', $company_uuid);
$stmt->execute();
$result = $stmt->get_result();
$company_data = $result->fetch_assoc();
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('companies'), 'href' => '/companies/'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $company_data['company_name'], 'href' => ''));
# Retrieve Information for the page
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$_GET['company_uuid'] = $company_uuid;
$_GET['builder'] = [1 => ['where' => [0 => 'company_uuid', 1 => $company_uuid]]];
$requiredFields = ['company_uuid' => ['type' => 'uuid']];
$API_servers->postedData = $_GET;
$API_servers->validateData($requiredFields);
$servers_data = $API_servers->getServers(true);
if (count($servers_data) > 0) {
$serverOverview->servers = $servers_data;
$serverOverview->processServerData();
$serverOverview->showDelBtn = false;
$serverOverview->showCompanies = false;
}
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> <?php echo $company_data['company_name'] ?>
</h1>
</div>
<div class="col-md-6 col-lg-6">
<table>
<tr>
<td>company_uuid:</td>
<td><?php echo $company_data['company_uuid'] ?></td>
</tr>
<tr>
<td>source_uuid:</td>
<td><?php echo $company_data['source_uuid'] ?></td>
</tr>
<tr>
<td>company_source_id:</td>
<td><?php echo $company_data['company_source_id'] ?></td>
</tr>
<tr>
<td>company_source_id2:</td>
<td><?php echo $company_data['company_source_id2'] ?></td>
</tr>
<tr>
<td>company_name:</td>
<td><?php echo $company_data['company_name'] ?></td>
</tr>
<tr>
<td>company_state:</td>
<td><?php echo $company_data['company_state'] ?></td>
</tr>
<tr>
<td>company_create_timestamp:</td>
<td><?php echo $company_data['company_create_timestamp'] ?></td>
</tr>
<tr>
<td>company_modified_timestamp:</td>
<td><?php echo $company_data['company_modified_timestamp'] ?></td>
</tr>
</table>
</div>
</div>
</div>
<?php
if ($GLOBALS['modules_enabled']['servers'] && $API_servers->checkPermissions('servers', 'RO', true)) {
if (count($servers_data) > 0) {
$serverOverview->serverOverviewOutPut();
}
}
?>

View File

@@ -1,137 +1,137 @@
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
use api\classes\API;
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
# Check permissions
$API = new API();
if (!$API->checkPermissions('customer-companies', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelect'] = true;
$jsScriptLoadData['datepicker'] = true;
$jsScriptLoadData['activateCompany'] = true;
# PageClasses Setup
# Retrieve Information for the page
if (!isset($_GET['all'])) {
$query = "SELECT companies.*, COUNT(servers.company_uuid) AS server_count FROM companies LEFT JOIN servers ON companies.company_uuid = servers.company_uuid WHERE company_state = 'active' GROUP BY companies.company_uuid ORDER BY companies.company_name ASC;";
} else {
$query = "SELECT companies.*, COUNT(servers.company_uuid) AS server_count FROM companies LEFT JOIN servers ON companies.company_uuid = servers.company_uuid GROUP BY companies.company_uuid ORDER BY companies.company_name ASC;";
}
$stmt = $GLOBALS['conn']->query($query);
$stompjes = array();
$companies = [];
while ($row = $stmt->fetch_assoc()) {
$companies[$row['company_uuid']] = $row;
}
# Start page output
?>
<div class="form-group form-show-validation row mb-3">
<div class="col-5">
<h2>
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> &nbsp; <?php echo __('companies') ?>
</h2>
</div>
<div class="col d-flex justify-content-end px-1">
<div class="col-lg-auto col-md-auto col-sm-auto">
<?php
if (!isset($_GET['all'])) { ?>
<a class="btn btn-secondary" href="?all">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_all') ?>
</a>
<?php } else { ?>
<a class="btn btn-secondary" href="?">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_active') ?>
</a>
<?php } ?>
</div> &nbsp;
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
<input type="hidden">
<div class="col-lg-auto col-md-auto col-sm-auto">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;<?php echo __('sync') ?>
</button>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,1,2,4" data-page-length="50">
<thead>
<tr>
<th><?php echo __('company_name') ?></th>
<th><?php echo __('company_id') ?></th>
<th><?php echo __('company_debtor') ?></th>
<th><?php echo __('company_state') ?></th>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<th><?php echo __('server_count') ?></th>
<?php } ?>
<th><?php echo __('actions') ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __('company_name') ?></th>
<th><?php echo __('company_id') ?></th>
<th><?php echo __('company_debtor') ?></th>
<th><?php echo __('company_state') ?></th>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<th><?php echo __('server_count') ?></th>
<?php } ?>
<th><?php echo __('actions') ?></th>
</tr>
</tfoot>
<tbody>
<?php foreach ($companies as $company) { ?>
<tr data-item-id="<?php echo $company['company_uuid'] ?>">
<td class="text-nowrap"><?php echo $company['company_name'] ?></td>
<td class="text-nowrap"><?php echo $company['company_source_id'] ?></td>
<td class="text-nowrap"><?php echo $company['company_source_id2'] ?></td>
<td class="text-nowrap"><?php echo $company['company_state'] ?></td>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<td class="text-nowrap"><?php echo $company['server_count'] ?></td>
<?php } ?>
<td>
<a href="/companies?view=<?php echo $company['company_uuid'] ?>" class="btn btn-info btn-sm btn-rounded" data-item-uuid="<?php echo $company['company_uuid'] ?>"><i class="fa-solid fa-eye"></i></a>
<?php if ($API->checkPermissions('customer-companies', 'RW', true) && $company['server_count'] == 0) { ?>
<a class="btn btn-<?php echo ($company['company_state'] != 'active') ? 'success' : 'danger' ?> btn-sm btn-rounded" data-item-company-state="" data-item-uuid="<?php echo $company['company_uuid'] ?>" data-item-state="<?php echo $company['company_state'] ?>"><i class="fa-solid <?php echo ($company['company_state'] != 'active') ? 'fa-plus' : 'fa-xmark' ?>"></i></a>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div>
</div>
</div>
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['customers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
use api\classes\API;
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
# Check permissions
$API = new API();
if (!$API->checkPermissions('customer-companies', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelect'] = true;
$jsScriptLoadData['datepicker'] = true;
$jsScriptLoadData['activateCompany'] = true;
# PageClasses Setup
# Retrieve Information for the page
if (!isset($_GET['all'])) {
$query = "SELECT companies.*, COUNT(servers.company_uuid) AS server_count FROM companies LEFT JOIN servers ON companies.company_uuid = servers.company_uuid WHERE company_state = 'active' GROUP BY companies.company_uuid ORDER BY companies.company_name ASC;";
} else {
$query = "SELECT companies.*, COUNT(servers.company_uuid) AS server_count FROM companies LEFT JOIN servers ON companies.company_uuid = servers.company_uuid GROUP BY companies.company_uuid ORDER BY companies.company_name ASC;";
}
$stmt = $GLOBALS['conn']->query($query);
$stompjes = array();
$companies = [];
while ($row = $stmt->fetch_assoc()) {
$companies[$row['company_uuid']] = $row;
}
# Start page output
?>
<div class="form-group form-show-validation row mb-3">
<div class="col-5">
<h2>
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> &nbsp; <?php echo __('companies') ?>
</h2>
</div>
<div class="col d-flex justify-content-end px-1">
<div class="col-lg-auto col-md-auto col-sm-auto">
<?php
if (!isset($_GET['all'])) { ?>
<a class="btn btn-secondary" href="?all">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_all') ?>
</a>
<?php } else { ?>
<a class="btn btn-secondary" href="?">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_active') ?>
</a>
<?php } ?>
</div> &nbsp;
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
<input type="hidden">
<div class="col-lg-auto col-md-auto col-sm-auto">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;<?php echo __('sync') ?>
</button>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,1,2,4" data-page-length="50">
<thead>
<tr>
<th><?php echo __('company_name') ?></th>
<th><?php echo __('company_id') ?></th>
<th><?php echo __('company_debtor') ?></th>
<th><?php echo __('company_state') ?></th>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<th><?php echo __('server_count') ?></th>
<?php } ?>
<th><?php echo __('actions') ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __('company_name') ?></th>
<th><?php echo __('company_id') ?></th>
<th><?php echo __('company_debtor') ?></th>
<th><?php echo __('company_state') ?></th>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<th><?php echo __('server_count') ?></th>
<?php } ?>
<th><?php echo __('actions') ?></th>
</tr>
</tfoot>
<tbody>
<?php foreach ($companies as $company) { ?>
<tr data-item-id="<?php echo $company['company_uuid'] ?>">
<td class="text-nowrap"><?php echo $company['company_name'] ?></td>
<td class="text-nowrap"><?php echo $company['company_source_id'] ?></td>
<td class="text-nowrap"><?php echo $company['company_source_id2'] ?></td>
<td class="text-nowrap"><?php echo $company['company_state'] ?></td>
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
<td class="text-nowrap"><?php echo $company['server_count'] ?></td>
<?php } ?>
<td>
<a href="/companies?view=<?php echo $company['company_uuid'] ?>" class="btn btn-info btn-sm btn-rounded" data-item-uuid="<?php echo $company['company_uuid'] ?>"><i class="fa-solid fa-eye"></i></a>
<?php if ($API->checkPermissions('customer-companies', 'RW', true) && $company['server_count'] == 0) { ?>
<a class="btn btn-<?php echo ($company['company_state'] != 'active') ? 'success' : 'danger' ?> btn-sm btn-rounded" data-item-company-state="" data-item-uuid="<?php echo $company['company_uuid'] ?>" data-item-state="<?php echo $company['company_state'] ?>"><i class="fa-solid <?php echo ($company['company_state'] != 'active') ? 'fa-plus' : 'fa-xmark' ?>"></i></a>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div>
</div>
</div>

View File

@@ -1,196 +1,196 @@
<?php
use api\classes\API;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['office']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
# Check permissions
$API = new API();
if (!$API->checkPermissions('ofice-stompjes', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['stompjes'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelect'] = true;
$jsScriptLoadData['datepicker'] = true;
# PageClasses Setup
# Retrieve Information for the page
$stmt = $GLOBALS['conn']->query("SELECT user_uuid, user_full_name, user_first_name, user_profile_picture_thumbnail, user_stompable, user_email FROM vc_users WHERE user_stompable = '1'");
$administrators = [];
while ($row = $stmt->fetch_assoc()) {
$administrators[$row['user_uuid']] = $row;
$administrators[$row['user_uuid']]['amount'] = 0;
}
if (!isset($_GET['fd'])) {
$SelectFromDate = strtotime(date('Y-m-01'));
} else {
$date = str_replace('/', '-', htmlspecialchars($_GET['fd'], ENT_QUOTES, 'UTF-8'));
$SelectFromDate = strtotime($date . ' 00:00:00');
}
if (!isset($_GET['td'])) {
$SelectTillDate = time();
} else {
$date = str_replace('/', '-', htmlspecialchars($_GET['td'], ENT_QUOTES, 'UTF-8'));
$SelectTillDate = strtotime($date . ' 23:59:59');
}
$stompjes = array();
$stmt = $GLOBALS['conn']->query("SELECT stomp_uuid, office_stompjes.user_uuid, user_full_name, user_first_name, stomp_timestamp FROM office_stompjes
INNER JOIN vc_users ON office_stompjes.user_uuid = vc_users.user_uuid
WHERE stomp_timestamp BETWEEN '$SelectFromDate' AND '$SelectTillDate'
AND user_stompable = '1'
ORDER BY stomp_timestamp DESC");
while ($row = $stmt->fetch_assoc()) {
array_push($stompjes, $row);
$administrators[$row['user_uuid']]['amount']++;
}
# Start page output
?>
<script>
const stompData = <?php echo json_encode($stompjes); ?>;
</script>
<div class="form-group form-show-validation row mb-3">
<div class="col-5">
<h2>
<i class="<?php echo $GLOBALS['pages']['office']['stompjeslist']['page_icon'] ?>"></i> &nbsp; <?php echo __('stompjeslist') ?>
</h2>
</div>
<div class="col d-flex justify-content-end px-1">
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-1">
<label>
<h5><?php echo __('from') ?>: </h5>
</label>
</div>
<div class="col-lg-auto col-md-auto col-sm-auto">
<div class="input-group">
<input type="text" id="fd" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectFromDate) ?>"/>
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
</div>
</div>
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-2">
<label>
<h5><?php echo __('to') ?>: </h5>
</label>
</div>
<div class="col-lg-auto col-md-auto col-sm-auto px-2">
<div class="input-group">
<input type="text" id="td" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectTillDate) ?>"/>
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
</div>
</div>
<div class="col-lg-auto col-md-auto col-sm-auto">
<a id="datePicker" class="btn btn-primary"><i class="fa-solid fa-arrow-rotate-right"></i></a>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<canvas id="stompjesChart" height="50"></canvas>
</div>
</div>
<div class="row align-content-center">
<?php foreach ($administrators as $administrator) {
if ($administrator['user_email'] != 'superuser') { ?>
<div class="col-sm-6 col-md-3 flex-shrink-0">
<div class="card card-stats card-round">
<div class="card-body">
<div class="row align-items-center">
<div class="col-icon">
<div class="avatar-l">
<img class="avatar-img rounded-circle" src="data:image/png;base64,<?php echo str_replace("'", '', $administrator['user_profile_picture_thumbnail']) ?>" height="50px" alt="">
</div>
</div>
<div class="col col-stats ms-3 ms-sm-0">
<div class="numbers">
<p class="card-category"><?php echo $administrator['user_first_name'] ?></p>
<h4 class="card-title" id="count-<?php echo $administrator['user_uuid'] ?>"><?php echo $administrator['amount'] ?></h4>
</div>
</div>
<div class="col col-stats ms-3 ms-sm-0">
<a href="#" class="btn btn-warning btn-lg btn-rounded stomp-btn w-100 <?php echo (!$API->checkPermissions('ofice-stompjes-canstomp', 'RW', true)) ? 'disabled' : '' ?>" data-item-uuid="<?php echo $administrator['user_uuid'] ?>" data-item-name="user_uuid" data-api-url="/api/v1/office/stompjes/"><i class="fa-solid fa-hand-fist"></i></a>
</div>
</div>
</div>
</div>
</div>
<?php }
} ?>
</div>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,2,3" data-page-length="50">
<thead>
<tr>
<th></th>
<th><?php echo __('first_name') ?></th>
<th><?php echo __('time') ?></th>
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
<th><?php echo __('actions') ?></th>
<?php } ?>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th><?php echo __('first_name') ?></th>
<th><?php echo __('time') ?></th>
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
<th><?php echo __('actions') ?></th>
<?php } ?>
</tr>
</tfoot>
<tbody>
<?php foreach ($stompjes as $stompje) {
if ($administrators[$stompje['user_uuid']]['user_email'] != 'superuser') { ?>
<tr data-item-id="<?php echo $stompje['stomp_uuid']; ?>" data-user-uuid=<?php echo $stompje['user_uuid']; ?>>
<td class="text-nowrap">
<div class="avatar-sm ">
<img class="avatar-img rounded-circle" src="data:image/png;base64,<?php echo str_replace("'", '', $administrators[$stompje['user_uuid']]['user_profile_picture_thumbnail']) ?>" height="50px" alt="">
</div>
</td>
<td class="text-nowrap"><?php echo $administrators[$stompje['user_uuid']]['user_first_name'] ?></td>
<td class="text-nowrap"><?php echo date('d-m-y H:i:s', $stompje['stomp_timestamp']) ?></td>
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
<td>
<a href="#" class="btn btn-danger btn-sm btn-rounded stomp-delete-btn" data-item-uuid="<?php echo $stompje['stomp_uuid'] ?>" data-api-url="/api/v1/office/stompjes/" data-item-name="stomp_uuid"><i class="fas fa-trash-alt"></i></a>
</td>
<?php } ?>
</tr>
<?php }
} ?>
</tbody>
</table>
<br>
</div>
</div>
</div>
<?php
use api\classes\API;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['office']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
# Check permissions
$API = new API();
if (!$API->checkPermissions('ofice-stompjes', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['stompjes'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelect'] = true;
$jsScriptLoadData['datepicker'] = true;
# PageClasses Setup
# Retrieve Information for the page
$stmt = $GLOBALS['conn']->query("SELECT user_uuid, user_full_name, user_first_name, user_profile_picture_thumbnail, user_stompable, user_email FROM vc_users WHERE user_stompable = '1'");
$administrators = [];
while ($row = $stmt->fetch_assoc()) {
$administrators[$row['user_uuid']] = $row;
$administrators[$row['user_uuid']]['amount'] = 0;
}
if (!isset($_GET['fd'])) {
$SelectFromDate = strtotime(date('Y-m-01'));
} else {
$date = str_replace('/', '-', htmlspecialchars($_GET['fd'], ENT_QUOTES, 'UTF-8'));
$SelectFromDate = strtotime($date . ' 00:00:00');
}
if (!isset($_GET['td'])) {
$SelectTillDate = time();
} else {
$date = str_replace('/', '-', htmlspecialchars($_GET['td'], ENT_QUOTES, 'UTF-8'));
$SelectTillDate = strtotime($date . ' 23:59:59');
}
$stompjes = array();
$stmt = $GLOBALS['conn']->query("SELECT stomp_uuid, office_stompjes.user_uuid, user_full_name, user_first_name, stomp_timestamp FROM office_stompjes
INNER JOIN vc_users ON office_stompjes.user_uuid = vc_users.user_uuid
WHERE stomp_timestamp BETWEEN '$SelectFromDate' AND '$SelectTillDate'
AND user_stompable = '1'
ORDER BY stomp_timestamp DESC");
while ($row = $stmt->fetch_assoc()) {
array_push($stompjes, $row);
$administrators[$row['user_uuid']]['amount']++;
}
# Start page output
?>
<script>
const stompData = <?php echo json_encode($stompjes); ?>;
</script>
<div class="form-group form-show-validation row mb-3">
<div class="col-5">
<h2>
<i class="<?php echo $GLOBALS['pages']['office']['stompjeslist']['page_icon'] ?>"></i> &nbsp; <?php echo __('stompjeslist') ?>
</h2>
</div>
<div class="col d-flex justify-content-end px-1">
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-1">
<label>
<h5><?php echo __('from') ?>: </h5>
</label>
</div>
<div class="col-lg-auto col-md-auto col-sm-auto">
<div class="input-group">
<input type="text" id="fd" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectFromDate) ?>"/>
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
</div>
</div>
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-2">
<label>
<h5><?php echo __('to') ?>: </h5>
</label>
</div>
<div class="col-lg-auto col-md-auto col-sm-auto px-2">
<div class="input-group">
<input type="text" id="td" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectTillDate) ?>"/>
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
</div>
</div>
<div class="col-lg-auto col-md-auto col-sm-auto">
<a id="datePicker" class="btn btn-primary"><i class="fa-solid fa-arrow-rotate-right"></i></a>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<canvas id="stompjesChart" height="50"></canvas>
</div>
</div>
<div class="row align-content-center">
<?php foreach ($administrators as $administrator) {
if ($administrator['user_email'] != 'superuser') { ?>
<div class="col-sm-6 col-md-3 flex-shrink-0">
<div class="card card-stats card-round">
<div class="card-body">
<div class="row align-items-center">
<div class="col-icon">
<div class="avatar-l">
<img class="avatar-img rounded-circle" src="data:image/png;base64,<?php echo str_replace("'", '', $administrator['user_profile_picture_thumbnail']) ?>" height="50px" alt="">
</div>
</div>
<div class="col col-stats ms-3 ms-sm-0">
<div class="numbers">
<p class="card-category"><?php echo $administrator['user_first_name'] ?></p>
<h4 class="card-title" id="count-<?php echo $administrator['user_uuid'] ?>"><?php echo $administrator['amount'] ?></h4>
</div>
</div>
<div class="col col-stats ms-3 ms-sm-0">
<a href="#" class="btn btn-warning btn-lg btn-rounded stomp-btn w-100 <?php echo (!$API->checkPermissions('ofice-stompjes-canstomp', 'RW', true)) ? 'disabled' : '' ?>" data-item-uuid="<?php echo $administrator['user_uuid'] ?>" data-item-name="user_uuid" data-api-url="/api/v1/office/stompjes/"><i class="fa-solid fa-hand-fist"></i></a>
</div>
</div>
</div>
</div>
</div>
<?php }
} ?>
</div>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,2,3" data-page-length="50">
<thead>
<tr>
<th></th>
<th><?php echo __('first_name') ?></th>
<th><?php echo __('time') ?></th>
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
<th><?php echo __('actions') ?></th>
<?php } ?>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th><?php echo __('first_name') ?></th>
<th><?php echo __('time') ?></th>
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
<th><?php echo __('actions') ?></th>
<?php } ?>
</tr>
</tfoot>
<tbody>
<?php foreach ($stompjes as $stompje) {
if ($administrators[$stompje['user_uuid']]['user_email'] != 'superuser') { ?>
<tr data-item-id="<?php echo $stompje['stomp_uuid']; ?>" data-user-uuid=<?php echo $stompje['user_uuid']; ?>>
<td class="text-nowrap">
<div class="avatar-sm ">
<img class="avatar-img rounded-circle" src="data:image/png;base64,<?php echo str_replace("'", '', $administrators[$stompje['user_uuid']]['user_profile_picture_thumbnail']) ?>" height="50px" alt="">
</div>
</td>
<td class="text-nowrap"><?php echo $administrators[$stompje['user_uuid']]['user_first_name'] ?></td>
<td class="text-nowrap"><?php echo date('d-m-y H:i:s', $stompje['stomp_timestamp']) ?></td>
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
<td>
<a href="#" class="btn btn-danger btn-sm btn-rounded stomp-delete-btn" data-item-uuid="<?php echo $stompje['stomp_uuid'] ?>" data-api-url="/api/v1/office/stompjes/" data-item-name="stomp_uuid"><i class="fas fa-trash-alt"></i></a>
</td>
<?php } ?>
</tr>
<?php }
} ?>
</tbody>
</table>
<br>
</div>
</div>
</div>

View File

@@ -1,2 +1,2 @@
<?php
<?php
echo '404 not found';

View File

@@ -1,15 +1,15 @@
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
if (isset($_GET['view'])) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_server_view.php');
} else {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_view.php');
<?php
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
if (isset($_GET['view'])) {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_server_view.php');
} else {
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_view.php');
}

View File

@@ -1,459 +1,460 @@
<?php
use api\classes\API;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
# Check permissions
$API = new API();
if (!$API->checkPermissions('servers', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['codeblocks'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$server_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM servers WHERE server_uuid = ?");
$stmt->bind_param('s', $server_uuid);
$stmt->execute();
$result = $stmt->get_result();
$server_data = $result->fetch_assoc();
if ($GLOBALS['modules_enabled']['customers']) {
$companies_data = $GLOBALS['conn']->query("SELECT company_uuid, company_name FROM companies WHERE company_state = 'active'");
$companies = array();
while ($company_data = $companies_data->fetch_assoc()) {
array_push($companies, $company_data);
}
}
# Retrieve Information for the page
$user_groups_data = $GLOBALS['conn']->query("SELECT * FROM vc_user_groups WHERE user_group_type = 'admin' ORDER BY user_group_weight DESC");
# memory
$mem = isset($server_data['server_memory']) ? (float)$server_data['server_memory'] : 0;
$demand = isset($server_data['server_memory_demand']) ? (float)$server_data['server_memory_demand'] : 0;
if ($mem > 0) {
$mem_percent = ($demand / $mem) * 100;
$mem_percent_numb = round($mem_percent, 1);
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
$mem_percent_sort = $mem_percent_numb;
if ($mem_percent_numb <= 89) {
$mem_demand_text_color = 'success';
}
if ($mem_percent_numb > 89) {
$mem_demand_text_color = 'secondary';
}
if ($mem_percent_numb > 99) {
$mem_demand_text_color = 'danger';
}
} else {
$mem_demand = "N/A";
$mem_percent_numb = 'N/A';
$mem_percent_sort = -1;
}
# disks
$disks = json_decode($server_data['server_disks'], true);
$totalDiskSpace = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$totalDiskSpace += $disk['disk_space'];
}
}
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$totalDiskSpace = array_sum($sizes);
}
$server_state_color = returnServerStateColor($server_data['server_state']);
# Licences
$licenses = json_decode($server_data['server_licenses'], true);
#
# OS Logo display
$baseos = strtolower(explode(' ', $server_data['server_os'])[0]);
$logos = [
'almalinux' => 'almalinux',
'centos' => 'centos',
];
$logo = $logos[$baseos] ?? 'server';
if ($API->checkPermissions('servers', 'RW', true)) {
$pageNavbar->AddHTMLButton(
'<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/servers?view=' . $server_data['server_uuid'] . '">
<input type="hidden" name="server_vm_id" value="' . $server_data['server_vm_id'] . '"/>' .
(
$server_data['server_state'] != 'deleted'
? '<input type="hidden" name="server_state" value="deleted">
<button class="btn btn-danger w-100">
<i class="fas fa-trash-alt"></i> Delete
</button>'
: '<input type="hidden" name="server_state" value="disabled">
<button class="btn btn-primary w-100">
<i class="fa-solid fa-clock-rotate-left"></i> Restore
</button>'
) .
'</form>'
);
};
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('server_overview'), 'href' => '/servers/'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $server_data['server_vm_host_name'], 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"> </i> <?php echo $server_data['server_vm_host_name'] ?>
<span class="badge bg-<?php echo $server_state_color ?> fs-4 align-middle"><?php echo ucfirst($server_data['server_state']) ?></span>
</h1>
</div>
<div class="row pb-5">
<div class="col-md-3 col-lg-3">
<h2><?php echo $server_data['server_os'] ?></h2>
<img class="img-fluid os-logo" src="/src/images/os/<?php echo $logo ?>.svg">
</div>
<div class="col-lg-auto col-md-auto">
<table class="table table-borderless">
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/servers?view=<?php echo $server_data['server_uuid'] ?>">
<input type="hidden" name="server_vm_id" value="<?php echo $server_data['server_vm_id'] ?>"/>
<tr>
<td>
<h4>
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
</h4>
</td>
<td>
<h4>
<?php echo (strlen($server_data['server_cpu']) > 0) ? $server_data['server_cpu'] . 'x' : ''; ?>
</h4>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
</h4>
</td>
<td>
<h4>
<?php echo (strlen($server_data['server_memory']) > 0) ? $server_data['server_memory'] . 'MB' : ''; ?>
</h4>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
</h4>
</td>
<td class="mx-3">
<h4>
<?php
if (is_array($disks) && count($disks) > 0) {
if (count($sizes) === 1) {
echo $sizes[0] . 'GB';
} else {
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
}
} ?>
</h4>
</td>
</tr>
<?php if ($GLOBALS['modules_enabled']['customers']) { ?>
<tr>
<td>
<h4>
<i class="fas fa-building"></i> <?php echo __('company') ?>
</h4>
</td>
<td>
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
<div class="input-group">
<select id="company_uuid" name="company_uuid" class="form-control">
<option></option>
<?php foreach ($companies as $company) { ?>
<option <?php echo ($server_data['company_uuid'] == $company['company_uuid']) ? 'selected' : '' ?> value="<?php echo $company['company_uuid'] ?>"><?php echo $company['company_name'] ?></option>
<?php } ?>
</select>
</div>
<?php } else { ?>
<h4>
<?php
$companyMap = array_column($companies, 'company_name', 'company_uuid');
echo $companyMap[$server_data['company_uuid']] ?? null;
?>
</h4>
<?php } ?>
</td>
</tr>
<?php } ?>
<tr>
<td>
<h4>
<i class="fa-solid fa-circle-dot"></i> <?php echo __('server_state') ?>
</h4>
</td>
<td>
<?php if ($API->checkPermissions('servers', 'RW', true)) {
if ($server_data['server_state'] != 'deleted') { ?>
<div class="input-group">
<select id="server_state" class="form-control" onchange="this.name = this.value ? 'server_state' : '';">
<option></option>
<option <?php echo ($server_data['server_state'] == 'active') ? 'selected' : '' ?> value="active">Active</option>
<option <?php echo ($server_data['server_state'] == 'trial') ? 'selected' : '' ?> value="trial">Trial</option>
<option <?php echo ($server_data['server_state'] == 'disabled') ? 'selected' : '' ?> value="disabled">Disabled</option>
</select>
</div>
<?php } else { ?>
<h4>
<?php echo ucfirst($server_data['server_state']) ?>
</h4>
<?php }
} else { ?>
<h4>
<?php echo ucfirst($server_data['server_state']) ?>
</h4>
<?php } ?>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-regular fa-clock"></i> <?php echo __('last_update') ?>
</h4>
</td>
<td>
<h4>
<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>
</h4>
</td>
</tr>
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
<tr>
<td></td>
<td>
<button class="btn btn-rounded btn-success w-100">
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
</button>
</td>
</tr>
<?php } ?>
</form>
</table>
</div>
</div>
<?php if (is_array($disks) && count($disks) > 0) { ?>
<h2 class="">
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo __('server_disks') ?>
</h2>
<div id="accordion">
<div class="card">
<?php foreach ($disks as $disk) { ?>
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $disk['disk_name'] ?>">
<div class="card-header py-1" id="heading<?php echo $disk['disk_name'] ?>">
<h4 class="mb-0">
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo $disk['disk_name'] ?>
</h4>
</div>
</a>
<div id="collapse<?php echo $disk['disk_name'] ?>" class="collapse" data-parent="#accordion">
<div class="card-body">
<table class="table table-borderless table-sm">
<tr>
<td><?php echo __('disk_space') ?>:</td>
<td><?php echo $disk['disk_space'] ?>GB</td>
</tr>
<tr>
<td><?php echo __('disk_file_used') ?>:</td>
<td><?php echo $disk['disk_used'] ?>GB</td>
</tr>
<tr>
<td><?php echo __('disk_location') ?>:</td>
<td><?php echo $disk['disk_location'] ?></td>
</tr>
</table>
</div>
</div>
<?php
} ?>
</div>
</div>
<?php }
if (is_array($licenses) && count($licenses) > 0) { ?>
<h2>
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo __('server_licenses') ?>
</h2>
<div id="accordion">
<div class="card">
<?php foreach ($licenses as $key => $licence) { ?>
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo array_key_first($licence) ?>">
<div class="card-header py-1" id="heading<?php echo array_key_first($licence) ?>">
<h4 class="mb-0">
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo ucfirst(array_key_first($licence)) ?>
</h4>
</div>
</a>
<div id="collapse<?php echo array_key_first($licence) ?>" class="collapse" data-parent="#accordion">
<div class="card-body">
<?php echo __('type') . ': ' . end($licence) ?>
</div>
</div>
<?php
} ?>
</div>
</div>
<?php } ?>
<h1 class="pt-5"><?php echo __('all_technical_information') ?></h1>
<div class="col-md-12 col-lg-12">
<table class="table table-borderless table-sm table-responsive">
<tr>
<td>server_uuid:</td>
<td class="w-100"><?php echo $server_data['server_uuid'] ?></td>
</tr>
<tr>
<td>company_uuid:</td>
<td><?php echo $server_data['company_uuid'] ?></td>
</tr>
<tr>
<td>server_vm_id:</td>
<td><?php echo $server_data['server_vm_id'] ?></td>
</tr>
<tr>
<td>server_vm_host_name:</td>
<td><?php echo $server_data['server_vm_host_name'] ?></td>
</tr>
<tr>
<td>server_vm_snapshot:</td>
<td><?php echo $server_data['server_vm_snapshot'] ?></td>
</tr>
<tr>
<td>server_vm_generation:</td>
<td><?php echo $server_data['server_vm_generation'] ?></td>
</tr>
<tr>
<td>server_power_state:</td>
<td><?php echo $server_data['server_power_state'] ?></td>
</tr>
<tr>
<td>server_state:</td>
<td><?php echo $server_data['server_state'] ?></td>
</tr>
<tr>
<td>server_hostname:</td>
<td><?php echo $server_data['server_hostname'] ?></td>
</tr>
<tr>
<td>server_os:</td>
<td><?php echo $server_data['server_os'] ?></td>
</tr>
<tr>
<td>server_cpu:</td>
<td><?php echo $server_data['server_cpu'] ?></td>
</tr>
<tr>
<td>server_memory:</td>
<td><?php echo $server_data['server_memory'] ?></td>
</tr>
<tr>
<td>server_memory_demand:</td>
<td><?php echo $server_data['server_memory_demand'] ?></td>
</tr>
<tr>
<td>server_disks:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_disks']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_ipv4:</td>
<td>
<pre class="bg-dark border rounded w-100 overflow-auto mb-0"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_ipv4']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_ipv6:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_ipv6']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_licenses:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_licenses']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_backup:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_backup']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_description:</td>
<td><?php echo $server_data['server_description'] ?></td>
</tr>
<tr>
<td>server_create_timestamp:</td>
<td><?php echo $server_data['server_create_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_create_timestamp']) ?>)</td>
</tr>
<tr>
<td>server_modified_timestamp:</td>
<td><?php echo $server_data['server_modified_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>)</td>
</tr>
</table>
</div>
</div>
</div>
<?php
use api\classes\API;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
# Check permissions
$API = new API();
if (!$API->checkPermissions('servers', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['codeblocks'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$server_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM servers WHERE server_uuid = ?");
$stmt->bind_param('s', $server_uuid);
$stmt->execute();
$result = $stmt->get_result();
$server_data = $result->fetch_assoc();
if ($GLOBALS['modules_enabled']['customers']) {
$companies_data = $GLOBALS['conn']->query("SELECT company_uuid, company_name FROM companies WHERE company_state = 'active'");
$companies = array();
while ($company_data = $companies_data->fetch_assoc()) {
array_push($companies, $company_data);
}
}
# Retrieve Information for the page
$user_groups_data = $GLOBALS['conn']->query("SELECT * FROM vc_user_groups WHERE user_group_type = 'admin' ORDER BY user_group_weight DESC");
# memory
$mem = isset($server_data['server_memory']) ? (float)$server_data['server_memory'] : 0;
$demand = isset($server_data['server_memory_demand']) ? (float)$server_data['server_memory_demand'] : 0;
if ($mem > 0) {
$mem_percent = ($demand / $mem) * 100;
$mem_percent_numb = round($mem_percent, 1);
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
$mem_percent_sort = $mem_percent_numb;
if ($mem_percent_numb <= 89) {
$mem_demand_text_color = 'success';
}
if ($mem_percent_numb > 89) {
$mem_demand_text_color = 'secondary';
}
if ($mem_percent_numb > 99) {
$mem_demand_text_color = 'danger';
}
} else {
$mem_demand = "N/A";
$mem_percent_numb = 'N/A';
$mem_percent_sort = -1;
}
# disks
$disks = json_decode($server_data['server_disks'], true);
$totalDiskSpace = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$totalDiskSpace += $disk['disk_space'];
}
}
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$totalDiskSpace = array_sum($sizes);
}
$server_state_color = returnServerStateColor($server_data['server_state']);
# Licences
$licenses = json_decode($server_data['server_licenses'], true);
#
# OS Logo display
$baseos = strtolower(explode(' ', $server_data['server_os'])[0]);
$logos = [
'almalinux' => 'almalinux',
'centos' => 'centos',
];
$logo = $logos[$baseos] ?? 'server';
if ($API->checkPermissions('servers', 'RW', true)) {
$pageNavbar->AddHTMLButton(
'<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/servers?view=' . $server_data['server_uuid'] . '">
<input type="hidden" name="server_vm_id" value="' . $server_data['server_vm_id'] . '"/>' .
(
$server_data['server_state'] != 'deleted'
? '<input type="hidden" name="server_state" value="deleted">
<button class="btn btn-danger w-100">
<i class="fas fa-trash-alt"></i> Delete
</button>'
: '<input type="hidden" name="server_state" value="disabled">
<button class="btn btn-primary w-100">
<i class="fa-solid fa-clock-rotate-left"></i> Restore
</button>'
) .
'</form>'
);
};
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('server_overview'), 'href' => '/servers/'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $server_data['server_vm_host_name'], 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"> </i> <?php echo $server_data['server_vm_host_name'] ?>
<span class="badge bg-<?php echo $server_state_color ?> fs-4 align-middle"><?php echo ucfirst($server_data['server_state']) ?></span>
</h1>
</div>
<div class="row pb-5">
<div class="col-md-3 col-lg-3">
<h2><?php echo $server_data['server_os'] ?></h2>
<img class="img-fluid os-logo" src="/src/images/os/<?php echo $logo ?>.svg">
</div>
<div class="col-lg-auto col-md-auto">
<table class="table table-borderless">
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/servers?view=<?php echo $server_data['server_uuid'] ?>">
<input type="hidden" name="server_vm_id" value="<?php echo $server_data['server_vm_id'] ?>"/>
<tr>
<td>
<h4>
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
</h4>
</td>
<td>
<h4>
<?php echo (strlen($server_data['server_cpu']) > 0) ? $server_data['server_cpu'] . 'x' : ''; ?>
</h4>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
</h4>
</td>
<td>
<h4>
<?php echo (strlen($server_data['server_memory']) > 0) ? $server_data['server_memory'] . 'MB' : ''; ?>
</h4>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
</h4>
</td>
<td class="mx-3">
<h4>
<?php
if (is_array($disks) && count($disks) > 0) {
if (count($sizes) === 1) {
echo $sizes[0] . 'GB';
} else {
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
}
} ?>
</h4>
</td>
</tr>
<?php if ($GLOBALS['modules_enabled']['customers']) { ?>
<tr>
<td>
<h4>
<i class="fas fa-building"></i> <?php echo __('company') ?>
</h4>
</td>
<td>
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
<div class="input-group">
<select id="company_uuid" name="company_uuid" class="form-control">
<option></option>
<?php foreach ($companies as $company) { ?>
<option <?php echo ($server_data['company_uuid'] == $company['company_uuid']) ? 'selected' : '' ?> value="<?php echo $company['company_uuid'] ?>"><?php echo $company['company_name'] ?></option>
<?php } ?>
</select>
</div>
<?php } else { ?>
<h4>
<?php
$companyMap = array_column($companies, 'company_name', 'company_uuid');
echo $companyMap[$server_data['company_uuid']] ?? null;
?>
</h4>
<?php } ?>
</td>
</tr>
<?php } ?>
<tr>
<td>
<h4>
<i class="fa-solid fa-circle-dot"></i> <?php echo __('server_state') ?>
</h4>
</td>
<td>
<?php if ($API->checkPermissions('servers', 'RW', true)) {
if ($server_data['server_state'] != 'deleted') { ?>
<div class="input-group">
<select id="server_state" class="form-control" onchange="this.name = this.value ? 'server_state' : '';">
<option></option>
<option <?php echo ($server_data['server_state'] == 'active') ? 'selected' : '' ?> value="active">Active</option>
<option <?php echo ($server_data['server_state'] == 'trial') ? 'selected' : '' ?> value="trial">Trial</option>
<option <?php echo ($server_data['server_state'] == 'disabled') ? 'selected' : '' ?> value="disabled">Disabled</option>
</select>
</div>
<?php } else { ?>
<h4>
<?php echo ucfirst($server_data['server_state']) ?>
</h4>
<?php }
} else { ?>
<h4>
<?php echo ucfirst($server_data['server_state']) ?>
</h4>
<?php } ?>
</td>
</tr>
<tr>
<td>
<h4>
<i class="fa-regular fa-clock"></i> <?php echo __('last_update') ?>
</h4>
</td>
<td>
<h4>
<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>
</h4>
</td>
</tr>
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
<tr>
<td></td>
<td>
<button class="btn btn-rounded btn-success w-100">
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
</button>
</td>
</tr>
<?php } ?>
</form>
</table>
</div>
</div>
<?php if (is_array($disks) && count($disks) > 0) { ?>
<h2 class="">
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo __('server_disks') ?>
</h2>
<div id="accordion">
<div class="card">
<?php foreach ($disks as $i => $disk) {
$collapseId = 'collapseDisk' . $i; ?>
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $collapseId ?>">
<div class="card-header py-1" id="heading<?php echo $collapseId ?>">
<h4 class="mb-0">
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo $disk['disk_name'] ?>
</h4>
</div>
</a>
<div id="collapse<?php echo $collapseId ?>" class="collapse" data-parent="#accordion">
<div class="card-body">
<table class="table table-borderless table-sm">
<tr>
<td><?php echo __('disk_space') ?>:</td>
<td><?php echo $disk['disk_space'] ?>GB</td>
</tr>
<tr>
<td><?php echo __('disk_file_used') ?>:</td>
<td><?php echo $disk['disk_used'] ?>GB</td>
</tr>
<tr>
<td><?php echo __('disk_location') ?>:</td>
<td><?php echo $disk['disk_location'] ?></td>
</tr>
</table>
</div>
</div>
<?php
} ?>
</div>
</div>
<?php }
if (is_array($licenses) && count($licenses) > 0) { ?>
<h2>
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo __('server_licenses') ?>
</h2>
<div id="accordion">
<div class="card">
<?php foreach ($licenses as $key => $licence) { ?>
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo array_key_first($licence) ?>">
<div class="card-header py-1" id="heading<?php echo array_key_first($licence) ?>">
<h4 class="mb-0">
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo ucfirst(array_key_first($licence)) ?>
</h4>
</div>
</a>
<div id="collapse<?php echo array_key_first($licence) ?>" class="collapse" data-parent="#accordion">
<div class="card-body">
<?php echo __('type') . ': ' . end($licence) ?>
</div>
</div>
<?php
} ?>
</div>
</div>
<?php } ?>
<h1 class="pt-5"><?php echo __('all_technical_information') ?></h1>
<div class="col-md-12 col-lg-12">
<table class="table table-borderless table-sm table-responsive">
<tr>
<td>server_uuid:</td>
<td class="w-100"><?php echo $server_data['server_uuid'] ?></td>
</tr>
<tr>
<td>company_uuid:</td>
<td><?php echo $server_data['company_uuid'] ?></td>
</tr>
<tr>
<td>server_vm_id:</td>
<td><?php echo $server_data['server_vm_id'] ?></td>
</tr>
<tr>
<td>server_vm_host_name:</td>
<td><?php echo $server_data['server_vm_host_name'] ?></td>
</tr>
<tr>
<td>server_vm_snapshot:</td>
<td><?php echo $server_data['server_vm_snapshot'] ?></td>
</tr>
<tr>
<td>server_vm_generation:</td>
<td><?php echo $server_data['server_vm_generation'] ?></td>
</tr>
<tr>
<td>server_power_state:</td>
<td><?php echo $server_data['server_power_state'] ?></td>
</tr>
<tr>
<td>server_state:</td>
<td><?php echo $server_data['server_state'] ?></td>
</tr>
<tr>
<td>server_hostname:</td>
<td><?php echo $server_data['server_hostname'] ?></td>
</tr>
<tr>
<td>server_os:</td>
<td><?php echo $server_data['server_os'] ?></td>
</tr>
<tr>
<td>server_cpu:</td>
<td><?php echo $server_data['server_cpu'] ?></td>
</tr>
<tr>
<td>server_memory:</td>
<td><?php echo $server_data['server_memory'] ?></td>
</tr>
<tr>
<td>server_memory_demand:</td>
<td><?php echo $server_data['server_memory_demand'] ?></td>
</tr>
<tr>
<td>server_disks:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_disks']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_ipv4:</td>
<td>
<pre class="bg-dark border rounded w-100 overflow-auto mb-0"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_ipv4']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_ipv6:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_ipv6']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_licenses:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_licenses']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_backup:</td>
<td>
<pre class="bg-dark border rounded"><code class="language-json"><?= htmlspecialchars(json_encode(json_decode($server_data['server_backup']), JSON_PRETTY_PRINT)) ?></code></pre>
</td>
</tr>
<tr>
<td>server_description:</td>
<td><?php echo $server_data['server_description'] ?></td>
</tr>
<tr>
<td>server_create_timestamp:</td>
<td><?php echo $server_data['server_create_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_create_timestamp']) ?>)</td>
</tr>
<tr>
<td>server_modified_timestamp:</td>
<td><?php echo $server_data['server_modified_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>)</td>
</tr>
</table>
</div>
</div>
</div>

View File

@@ -1,67 +1,67 @@
<?php
use api\classes\API_servers;
use bin\php\Classes\serverOverviewBuilder;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
# Check permissions
$API_servers = new API_servers();
if (!$API_servers->checkPermissions('servers', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelectServers'] = true;
# PageClasses Setup
$serverOverview = new serverOverviewBuilder();
# Retrieve Information for the page
if (!isset($_GET['del'])) {
if ($GLOBALS['modules_enabled']['customers']) {
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid WHERE servers.server_state != 'deleted'";
} else {
$API_servers->baseQuery = "SELECT * FROM servers WHERE servers.server_state != 'deleted'";
}
} else {
if ($GLOBALS['modules_enabled']['customers']) {
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid";
} else {
$API_servers->baseQuery = "SELECT * FROM servers";
}
}
$servers_data = $API_servers->getServers();
$serverOverview->servers = $servers_data;
$serverOverview->processServerData();
if (!$GLOBALS['modules_enabled']['customers']) {
$serverOverview->showCompanies = false;
}
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
array_push($GLOBALS['breadCrumbArray'], array('display' => __('view'), 'href' => ''));
# Start page output
$serverOverview->serverOverviewOutPut();
?>
<?php
use api\classes\API_servers;
use bin\php\Classes\serverOverviewBuilder;
if (!defined('APP_INIT')) {
exit;
}
if (!$GLOBALS['modules_enabled']['servers']) {
echo '405 Not Allowed';
exit;
}
# IDE Section
# Includes Section
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
# Check permissions
$API_servers = new API_servers();
if (!$API_servers->checkPermissions('servers', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['delete_confirmation'] = true;
$jsScriptLoadData['datatables'] = true;
$jsScriptLoadData['multiFilterSelectServers'] = true;
# PageClasses Setup
$serverOverview = new serverOverviewBuilder();
# Retrieve Information for the page
if (!isset($_GET['del'])) {
if ($GLOBALS['modules_enabled']['customers']) {
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid WHERE servers.server_state != 'deleted'";
} else {
$API_servers->baseQuery = "SELECT * FROM servers WHERE servers.server_state != 'deleted'";
}
} else {
if ($GLOBALS['modules_enabled']['customers']) {
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid";
} else {
$API_servers->baseQuery = "SELECT * FROM servers";
}
}
$servers_data = $API_servers->getServers();
$serverOverview->servers = $servers_data;
$serverOverview->processServerData();
if (!$GLOBALS['modules_enabled']['customers']) {
$serverOverview->showCompanies = false;
}
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
array_push($GLOBALS['breadCrumbArray'], array('display' => __('view'), 'href' => ''));
# Start page output
$serverOverview->serverOverviewOutPut();
?>

View File

@@ -1,173 +1,173 @@
<?php
use api\classes\API_usergroups;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usergroups.php');
# Check permissions
$API = new API_usergroups();
if (!$API->checkPermissions('admin-access-control-user-groups', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['updatePermissions'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$user_group_uuid = htmlspecialchars($_GET['user_group_view'], ENT_QUOTES, 'UTF-8');
$_GET['user_group_uuid'] = $user_group_uuid;
$API_usergroups = new API_usergroups();
$_GET['builder'] = [1 => ['where' => [0 => 'user_group_uuid', 1 => $user_group_uuid]]];
$requiredFields = ['user_group_uuid' => ['type' => 'uuid']];
$API_usergroups->validateData($requiredFields);
$user_group = $API_usergroups->getUsergroup()[0];
$query = "SELECT * FROM vc_user_group_permissions_portal
INNER JOIN vc_permissions ON vc_user_group_permissions_portal.permission_uuid = vc_permissions.permission_uuid
WHERE user_group_uuid = ?";
$stmt = $GLOBALS['pdo']->prepare($query);
$stmt->execute([$user_group_uuid]);
$group_permissions = $stmt->fetchAll(PDO::FETCH_ASSOC);
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('user_gr1oups'), 'href' => '/accesscontrol/#user-groups'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $user_group['user_group_name'], 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="fa-solid fa-user-group"></i> <?php echo __('user_group') . ': ' . $user_group['user_group_name'] ?>
</h1>
</div>
<div class="col-md-6 col-lg-6">
<table>
<tr>
<td>user_group_uuid:</td>
<td><?php echo $user_group['user_group_uuid'] ?></td>
</tr>
<tr>
<td>user_group_name:</td>
<td><?php echo $user_group['user_group_name'] ?></td>
</tr>
<tr>
<td>user_group_slugify:</td>
<td><?php echo $user_group['user_group_slugify'] ?></td>
</tr>
<tr>
<td>user_group_type:</td>
<td><?php echo $user_group['user_group_type'] ?></td>
</tr>
<tr>
<td>user_group_weight:</td>
<td><?php echo $user_group['user_group_weight'] ?></td>
</tr>
<tr>
<td>user_group_create_timestamp:</td>
<td><?php echo $user_group['user_group_create_timestamp'] ?></td>
</tr>
<tr>
<td>user_group_modified_timestamp:</td>
<td><?php echo $user_group['user_group_modified_timestamp'] ?></td>
</tr>
</table>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<h1>
<i class="fa-solid fa-lock"></i> <?php echo __('permission') ?>
</h1>
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,5">
<thead>
<tr>
<th><?php echo __('user_group') ?></th>
<th><?php echo __('NA') ?></th>
<th><?php echo __('RO') ?></th>
<th><?php echo __('RW') ?></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __('user_group') ?></th>
<th><?php echo __('NA') ?></th>
<th><?php echo __('RO') ?></th>
<th><?php echo __('RW') ?></th>
<th></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($group_permissions as $group_permissions_data) { ?>
<tr>
<td><?php echo $group_permissions_data['permission_name'] ?> </td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="NA" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'NA') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="RO" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'RO') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="RW" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'RW') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<a href="#" class="btn btn-info btn-sm btn-rounded" data-bs-toggle="modal" data-bs-target="#infoModal<?php echo $group_permissions_data['permission_uuid'] ?>"><i class="fa-solid fa-circle-info"></i></a>
</td>
<div class="modal fade" id="infoModal<?php echo $group_permissions_data['permission_uuid'] ?>" tabindex="-1" aria-labelledby="infoModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content bg-black2">
<div class="modal-header">
<h5 class="modal-title" id="infoModalLabel">
<i class="fas fa-info-circle"></i> <?php echo __('information') ?>
</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?php echo $group_permissions_data['permission_description'] ?>
</div>
</div>
</div>
</div>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<?php
use api\classes\API_usergroups;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usergroups.php');
# Check permissions
$API = new API_usergroups();
if (!$API->checkPermissions('admin-access-control-user-groups', 'RO', true)) {
echo 'error 401 unauthorized';
exit;
}
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['updatePermissions'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$user_group_uuid = htmlspecialchars($_GET['user_group_view'], ENT_QUOTES, 'UTF-8');
$_GET['user_group_uuid'] = $user_group_uuid;
$API_usergroups = new API_usergroups();
$_GET['builder'] = [1 => ['where' => [0 => 'user_group_uuid', 1 => $user_group_uuid]]];
$requiredFields = ['user_group_uuid' => ['type' => 'uuid']];
$API_usergroups->validateData($requiredFields);
$user_group = $API_usergroups->getUsergroup()[0];
$query = "SELECT * FROM vc_user_group_permissions_portal
INNER JOIN vc_permissions ON vc_user_group_permissions_portal.permission_uuid = vc_permissions.permission_uuid
WHERE user_group_uuid = ?";
$stmt = $GLOBALS['pdo']->prepare($query);
$stmt->execute([$user_group_uuid]);
$group_permissions = $stmt->fetchAll(PDO::FETCH_ASSOC);
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('user_groups'), 'href' => '/accesscontrol/#user-groups'));
array_push($GLOBALS['breadCrumbArray'], array('display' => $user_group['user_group_name'], 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="card">
<div class="card-body">
<div class="row">
<h1>
<i class="fa-solid fa-user-group"></i> <?php echo __('user_group') . ': ' . $user_group['user_group_name'] ?>
</h1>
</div>
<div class="col-md-6 col-lg-6">
<table>
<tr>
<td>user_group_uuid:</td>
<td><?php echo $user_group['user_group_uuid'] ?></td>
</tr>
<tr>
<td>user_group_name:</td>
<td><?php echo $user_group['user_group_name'] ?></td>
</tr>
<tr>
<td>user_group_slugify:</td>
<td><?php echo $user_group['user_group_slugify'] ?></td>
</tr>
<tr>
<td>user_group_type:</td>
<td><?php echo $user_group['user_group_type'] ?></td>
</tr>
<tr>
<td>user_group_weight:</td>
<td><?php echo $user_group['user_group_weight'] ?></td>
</tr>
<tr>
<td>user_group_create_timestamp:</td>
<td><?php echo $user_group['user_group_create_timestamp'] ?></td>
</tr>
<tr>
<td>user_group_modified_timestamp:</td>
<td><?php echo $user_group['user_group_modified_timestamp'] ?></td>
</tr>
</table>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<h1>
<i class="fa-solid fa-lock"></i> <?php echo __('permission') ?>
</h1>
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,5">
<thead>
<tr>
<th><?php echo __('user_group') ?></th>
<th><?php echo __('NA') ?></th>
<th><?php echo __('RO') ?></th>
<th><?php echo __('RW') ?></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __('user_group') ?></th>
<th><?php echo __('NA') ?></th>
<th><?php echo __('RO') ?></th>
<th><?php echo __('RW') ?></th>
<th></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($group_permissions as $group_permissions_data) { ?>
<tr>
<td><?php echo $group_permissions_data['permission_name'] ?> </td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="NA" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'NA') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="RO" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'RO') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<label class="switch">
<input type="checkbox" class="checkbox" data-permission-uuid="<?= $group_permissions_data['permission_uuid'] ?>" data-user-group-uuid="<?= $group_permissions_data['user_group_uuid'] ?>" data-value="RW" data-api-url="/api/v1/access-rights/" <?php echo(($group_permissions_data['permission_value'] == 'RW') ? 'checked' : '') ?>
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
<div class="slider"></div>
</label>
</td>
<td>
<a href="#" class="btn btn-info btn-sm btn-rounded" data-bs-toggle="modal" data-bs-target="#infoModal<?php echo $group_permissions_data['permission_uuid'] ?>"><i class="fa-solid fa-circle-info"></i></a>
</td>
<div class="modal fade" id="infoModal<?php echo $group_permissions_data['permission_uuid'] ?>" tabindex="-1" aria-labelledby="infoModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg">
<div class="modal-content bg-black2">
<div class="modal-header">
<h5 class="modal-title" id="infoModalLabel">
<i class="fas fa-info-circle"></i> <?php echo __('information') ?>
</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?php echo $group_permissions_data['permission_description'] ?>
</div>
</div>
</div>
</div>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>

View File

@@ -1,161 +1,167 @@
<?php
use api\classes\API;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
# Check permissions
$API = new API();
$API->checkPermissions('admin-sources', 'RO');
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['activeTabOnRefresh'] = true;
$jsScriptLoadData['copyInputValue'] = true;
$jsScriptLoadData['updateToggle'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['inserve_source'] = true;
$jsScriptLoadData['validateJson'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$inserve_settings = $GLOBALS['conn']->query("SELECT * FROM system_sources WHERE source_name = 'inserve'")->fetch_assoc();
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('portal_management'), 'href' => '/systemconfig'));
array_push($GLOBALS['breadCrumbArray'], array('display' => __('sources'), 'href' => '/systemconfig#sources'));
array_push($GLOBALS['breadCrumbArray'], array('display' => 'Inserve', 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="tab-content" id="v-pills-with-icon-tabContent">
<div class="card">
<div class="mx-2 pb-0 card-body">
<h1 class="">Inserve settings</h1>
<p>
Enter the necessary API details to set up and configure your connection to the Inserve API. This allows Sentri to communicate with Inserve and retrieve the data it needs. </p>
<hr>
</div>
<form id="FormValidation" method="post" action="/api/v1/system/sources/inserve/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/system/sources/inserve">
<input type="hidden" name="source_name" value="inserve">
<div class="card-body">
<div class="form-group form-show-validation row">
<label for="source_url" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('inserve_url') ?></label>
<div class="col-lg-9 col-md-12 col-sm-10">
<input type="text" class="form-control" id="source_url" name="source_url" value="<?php echo ($inserve_settings) ? $inserve_settings['source_url'] : '' ?>" placeholder="" required/>
</div>
</div>
<div class="form-group form-show-validation row">
<label for="source_auth_token" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('api_token') ?></label>
<div class="col-lg-9 col-md-12 col-sm-10">
<input type="text" class="form-control" id="source_auth_token" name="source_auth_token" value="" autocomplete="off" placeholder="<?php echo ($inserve_settings) ? substr($inserve_settings['source_auth_token'], 0, 6) . str_repeat('*', max(0, strlen($inserve_settings['source_auth_token']) - 6)) : ''; ?>" required/>
</div>
</div>
</div>
<div class="card-footer py-4">
<div class="row">
<div class="col d-flex justify-content-end">
<button class="btn btn-success mx-2 test-inserve-connection-btn">
<i class="fa-solid fa-spell-check"></i> <?php echo __('test_connection') ?>
</button>
<?php if ($API->checkPermissions('admin-sources', 'RW', true)) { ?>
<button type="submit" class="btn btn-primary">
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
</button>
<?php } ?>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="tab-content" id="v-pills-with-icon-tabContent">
<div class="card">
<div class="card-body">
<h1 class="">Inserve actions</h1>
<hr>
<div class="row row-cols-1 row-cols-md-3 g-2">
<?php if ($GLOBALS['modules_enabled']['customers'] && $API->checkPermissions('customer-companies', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync companies from Inserve to Sentri.</h5>
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call retrieves all companies from Inserve and creates or updates them in Sentri.</p>
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync.
</button>
</form>
</div>
</div>
</div>
<?php } ?>
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync cloud distributor companies</h5>
<form method="post" action="/api/v1/sources/inserve/sync-cloud-distributor/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call synchronizes active companies in Sentri with the corresponding cloud distributor companies in Inserve. These cloud distributor companies are required to associate Sentri server licenses with companies in Inserve.</p>
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync
</button>
</form>
</div>
</div>
</div>
<?php } ?>
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync servers licenses</h5>
<form method="post" action="/api/v1/sources/inserve/sync-server-licenses/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call first executes the sync-cloud-distributor action and then synchronizes all servers in an active, deleted, or trial state with Inserve licenses. It creates or updates server licenses in Inserve if they do not exist or if the license quantities differ from those in Sentri.</p>
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync
</button>
</form>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
<?php
use api\classes\API;
use bin\php\Classes\pageNavbar;
if (!defined('APP_INIT')) {
exit;
}
# IDE Section
# Includes Section
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
# Check permissions
$API = new API();
$API->checkPermissions('admin-sources', 'RO');
# Page functions
# JS Scripts to load for this page
$jsScriptLoadData['activeTabOnRefresh'] = true;
$jsScriptLoadData['copyInputValue'] = true;
$jsScriptLoadData['updateToggle'] = true;
$jsScriptLoadData['breadCrumbs'] = true;
$jsScriptLoadData['inserve_source'] = true;
$jsScriptLoadData['validateJson'] = true;
# PageClasses Setup
$pageNavbar = new pageNavbar(true);
# Retrieve Information for the page
$inserve_settings = $GLOBALS['conn']->query("SELECT * FROM system_sources WHERE source_name = 'inserve'")->fetch_assoc();
# Set breadcrumb data
array_push($GLOBALS['breadCrumbArray'], array('display' => __('portal_management'), 'href' => '/systemconfig'));
array_push($GLOBALS['breadCrumbArray'], array('display' => __('sources'), 'href' => '/systemconfig#sources'));
array_push($GLOBALS['breadCrumbArray'], array('display' => 'Inserve', 'href' => ''));
# Start page output
$pageNavbar->outPutNavbar();
?>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="tab-content" id="v-pills-with-icon-tabContent">
<div class="card">
<div class="mx-2 pb-0 card-body">
<h1 class="">Inserve settings</h1>
<p>
Enter the necessary API details to set up and configure your connection to the Inserve API. This allows Sentri to communicate with Inserve and retrieve the data it needs. </p>
<hr>
</div>
<form id="FormValidation" method="post" action="/api/v1/system/sources/inserve/">
<input type="hidden" name="_method" value="POST">
<input type="hidden" name="_return" value="/system/sources/inserve">
<input type="hidden" name="source_name" value="inserve">
<div class="card-body">
<div class="form-group form-show-validation row">
<label for="source_url" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('inserve_url') ?></label>
<div class="col-lg-9 col-md-12 col-sm-10">
<input type="text" class="form-control" id="source_url" name="source_url" value="<?php echo ($inserve_settings) ? $inserve_settings['source_url'] : '' ?>" placeholder="" required/>
</div>
</div>
<div class="form-group form-show-validation row">
<label for="source_auth_token" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('api_token') ?></label>
<div class="col-lg-9 col-md-12 col-sm-10">
<input type="text" class="form-control" id="source_auth_token" name="source_auth_token" value="" autocomplete="off" placeholder="<?php echo ($inserve_settings) ? substr($inserve_settings['source_auth_token'], 0, 6) . str_repeat('*', max(0, strlen($inserve_settings['source_auth_token']) - 6)) : ''; ?>" required/>
</div>
</div>
</div>
<div class="card-footer py-4">
<div class="row">
<div class="col d-flex justify-content-end">
<button class="btn btn-success mx-2 test-inserve-connection-btn">
<i class="fa-solid fa-spell-check"></i> <?php echo __('test_connection') ?>
</button>
<?php if ($API->checkPermissions('admin-sources', 'RW', true)) { ?>
<button type="submit" class="btn btn-primary">
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
</button>
<?php } ?>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="tab-content" id="v-pills-with-icon-tabContent">
<div class="card">
<div class="card-body">
<h1 class="">Inserve actions</h1>
<div class="row row-cols-1 row-cols-md-3 g-2">
<?php if ($GLOBALS['modules_enabled']['customers'] && $API->checkPermissions('customer-companies', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync companies from Inserve to Sentri.</h5>
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call retrieves all companies from Inserve and creates or updates them in Sentri.</p>
</form>
</div>
<div class="card-footer">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync.
</button>
</div>
</div>
</div>
<?php } ?>
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync cloud distributor companies</h5>
<form method="post" action="/api/v1/sources/inserve/sync-cloud-distributor/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call synchronizes active companies in Sentri with the corresponding cloud distributor companies in Inserve. These cloud distributor companies are required to associate Sentri server licenses with companies in Inserve.</p>
</form>
</div>
<div class="card-footer">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync
</button>
</div>
</div>
</div>
<?php } ?>
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
<div class="col">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">Sync servers licenses</h5>
<form method="post" action="/api/v1/sources/inserve/sync-server-licenses/">
<input type="hidden" name="_return" value="/system/sources/inserve">
<p class="card-text">This API call first executes the sync-cloud-distributor action and then synchronizes all servers in an active, deleted, or trial state with Inserve licenses. It creates or updates server licenses in Inserve if they do not exist or if the license quantities differ from those in Sentri.</p>
</form>
</div>
<div class="card-footer">
<button class="btn btn-primary">
<i class="fa-solid fa-arrow-rotate-right"></i> &nbsp;Sync
</button>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -1,475 +1,484 @@
<?php
namespace bin\php\Classes;
if (!defined('APP_INIT')) {
exit;
}
class serverOverviewBuilder
{
public array $servers = [];
public array $showColumns = array(
'server_hostname' => false,
'company_name' => false,
'server_power_state' => false,
'server_os' => false,
'server_cpu' => false,
'server_memory' => false,
'server_memory_demand' => false,
'server_disks' => false,
'server_ipv4' => false,
'server_ipv6' => false,
'server_vm_snapshot' => false,
'server_vm_generation' => false,
'server_licenses' => false,
'server_backup' => false,
'server_description' => false,
);
public array $allBackupTypes = [];
public array $allLicenseTypes = [];
public bool $showDelBtn = true;
public bool $showServerOverviewTitle = true;
public bool $showCompanies = true;
public function processServerData()
{
foreach ($this->servers as $server) {
if (!empty($server['server_backup'])) {
$backups = json_decode($server['server_backup'], true);
if (is_array($backups)) {
foreach ($backups as $item) {
foreach ($item as $key => $value) {
$this->allBackupTypes[$key] = true;
}
}
}
}
if (!empty($server['server_licenses'])) {
$licenses = json_decode($server['server_licenses'], true);
if (is_array($licenses)) {
foreach ($licenses as $item) {
foreach ($item as $key => $value) {
$this->allLicenseTypes[$key] = true;
}
}
}
}
}
$this->allBackupTypes = array_keys($this->allBackupTypes);
sort($this->allBackupTypes);
$this->allLicenseTypes = array_keys($this->allLicenseTypes);
sort($this->allLicenseTypes);
if (isset($_COOKIE['serverTableColumns'])) {
$CheckedColumns = json_decode(htmlspecialchars(($_COOKIE['serverTableColumns']), true));
foreach ($CheckedColumns as $CheckedColumn) {
$this->showColumns[$CheckedColumn] = true;
}
} else {
$this->showColumns['server_hostname'] = true;
$this->showColumns['company_name'] = true;
$this->showColumns['server_os'] = true;
$this->showColumns['server_cpu'] = true;
$this->showColumns['server_memory'] = true;
$this->showColumns['server_memory_demand'] = true;
$this->showColumns['server_disks'] = true;
$this->showColumns['server_state'] = true;
}
}
private function cleanNumber($num)
{
// If integer value, return without formatting
if (floor($num) == $num) {
return (string)$num;
}
// Otherwise return trimmed float
return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.');
}
public function serverOverviewOutPut()
{ ?>
<div class="form-group form-show-validation row mb-3">
<?php if ($this->showServerOverviewTitle) { ?>
<div class="col-auto">
<h2>
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"></i> &nbsp; <?php echo __('server_overview') ?>
</h2>
</div>
<?php } ?>
<div class="col d-flex justify-content-end px-1">
<div class="selectgroup selectgroup-pills">
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_state" class="selectgroup-input" <?php echo($this->showColumns['server_state'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_state') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_hostname" class="selectgroup-input" <?php echo($this->showColumns['server_hostname'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_hostname') ?></span>
</label>
<?php if ($this->showCompanies) { ?>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="company_name" class="selectgroup-input" <?php echo($this->showColumns['company_name'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('company') ?></span>
</label>
<?php } ?>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_os" class="selectgroup-input" <?php echo($this->showColumns['server_os'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_os') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_cpu" class="selectgroup-input" <?php echo($this->showColumns['server_cpu'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_cpu') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_memory" class="selectgroup-input" <?php echo($this->showColumns['server_memory'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_memory') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_memory_demand" class="selectgroup-input" <?php echo($this->showColumns['server_memory_demand'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_memory_demand') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_disks" class="selectgroup-input" <?php echo($this->showColumns['server_disks'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_disks') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_ipv4" class="selectgroup-input" <?php echo($this->showColumns['server_ipv4'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_ipv4') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_ipv6" class="selectgroup-input" <?php echo($this->showColumns['server_ipv6'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_ipv6') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_vm_snapshot" class="selectgroup-input" <?php echo($this->showColumns['server_vm_snapshot'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_vm_snapshot') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_vm_generation" class="selectgroup-input" <?php echo($this->showColumns['server_vm_generation'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_vm_generation') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_licenses" class="selectgroup-input" <?php echo($this->showColumns['server_licenses'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_licenses') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_backup" class="selectgroup-input" <?php echo($this->showColumns['server_backup'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_backup') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_power_state" class="selectgroup-input" <?php echo($this->showColumns['server_power_state'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_power_state') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_description" class="selectgroup-input" <?php echo($this->showColumns['server_description'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('description') ?></span>
</label>
</div>
</div>
<?php if ($this->showDelBtn) { ?>
<div class="col-lg-auto col-md-auto col-sm-auto">
<?php
if (!isset($_GET['del'])) { ?>
<a class="btn btn-danger btn-border" href="?del">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_del') ?>
</a>
<?php } else { ?>
<a class="btn btn-danger " href="/servers">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_del') ?>
</a>
<?php } ?>
</div>
<?php } ?>
</div>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="action" data-page-length="50">
<thead>
<tr>
<th data-column="server_state"><?php echo __('server_state') ?></th>
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
<?php if ($this->showCompanies) { ?>
<th data-column="company_name"><?php echo __('company') ?></th>
<?php } ?>
<th data-column="server_os"><?php echo __('server_os') ?></th>
<th data-column="server_cpu">
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
</th>
<th data-column="server_memory">
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
</th>
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
<th data-column="server_disks">
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
</th>
<th data-column="server_ipv4">
<?php echo __('server_ipv4') ?>
</th>
<th data-column="server_ipv6">
<?php echo __('server_ipv6') ?>
</th>
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></th>
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
<?php }
foreach ($this->allBackupTypes as $backupType) { ?>
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
<?php }
?>
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
<th data-column="server_description"><?php echo __('description') ?></th>
<th data-column="action">
<?php echo __('action') ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th data-column="server_state"><?php echo __('server_state') ?></th>
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
<?php if ($this->showCompanies) { ?>
<th data-column="company_name"><?php echo __('company') ?></th>
<?php } ?>
<th data-column="server_os"><?php echo __('server_os') ?></th>
<th data-column="server_cpu"><?php echo __('server_cpu') ?></th>
<th data-column="server_memory"><?php echo __('server_memory') ?></th>
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
<th data-column="server_disks"><?php echo __('server_disks') ?></th>
<th data-column="server_ipv4"><?php echo __('server_ipv4') ?></th>
<th data-column="server_ipv6"><?php echo __('server_ipv6') ?></th>
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></th>
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
<?php }
foreach ($this->allBackupTypes as $backupType) { ?>
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
<?php }
?>
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
<th data-column="server_description"><?php echo __('description') ?></th>
<th data-column="action"><?php echo __('action') ?></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($this->servers as $server) {
$disks = json_decode($server['server_disks'], true);
$totalDiskSpace = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$totalDiskSpace += $disk['disk_space'];
}
}
if (is_null($server['server_vm_host_name'])) {
$hostname = $server['server_hostname'];
} else {
$hostname = $server['server_vm_host_name'];
}
$mem = isset($server['server_memory']) ? (float)$server['server_memory'] : 0;
$demand = isset($server['server_memory_demand']) ? (float)$server['server_memory_demand'] : 0;
if ($mem == 0 && $demand == 0) {
$mem_assigned = 'N/A';
} else {
$mem_assigned = $this->cleanNumber($mem) . "M";
}
$mem_demand_text_color = '';
if ($mem > 0) {
$mem_percent = ($demand / $mem) * 100;
$mem_percent_numb = round($mem_percent, 1);
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
$mem_percent_sort = $mem_percent_numb;
if ($mem_percent_numb <= 89) {
$mem_demand_text_color = 'success';
}
if ($mem_percent_numb > 89) {
$mem_demand_text_color = 'secondary';
}
if ($mem_percent_numb > 99) {
$mem_demand_text_color = 'danger';
}
} else {
$mem_demand = "N/A";
$mem_percent_numb = 'N/A';
$mem_percent_sort = -1;
}
$ipv4_list = '';
if (!empty($server['server_ipv4'])) {
$ips = json_decode($server['server_ipv4'], true);
if (is_array($ips)) {
$ipv4_list = implode(', ', $ips);
}
}
$ipv6_list = '';
if (!empty($server['server_ipv6'])) {
$ips = json_decode($server['server_ipv6'], true);
if (is_array($ips)) {
$ipv6_list = implode(', ', $ips);
}
}
$thisServerLicenses = [];
foreach ($this->allLicenseTypes as $licenseType) {
$thisServerLicenses[$licenseType] = false;
}
if (!empty($server['server_licenses'])) {
$allLicenseTypesServer = json_decode($server['server_licenses'], true);
if (is_array($allLicenseTypesServer)) {
foreach ($allLicenseTypesServer as $licenseTypeServer) {
foreach ($licenseTypeServer as $licenseTypeServerKey => $licenseTypeServerValue) {
$thisServerLicenses[$licenseTypeServerKey] = true;
}
}
}
}
$thisServerBackup = [];
foreach ($this->allBackupTypes as $BackupType) {
$thisServerBackup[$BackupType] = false;
}
if (!empty($server['server_backup'])) {
$allBackupTypesServer = json_decode($server['server_backup'], true);
if (is_array($allBackupTypesServer)) {
foreach ($allBackupTypesServer as $BackupTypeServer) {
foreach ($BackupTypeServer as $BackupTypeServerKey => $BackupTypeServerValue) {
$thisServerBackup[$BackupTypeServerKey] = true;
}
}
}
}
if ($this->showCompanies) {
$company_name = '';
if (strlen($server['company_name']) > 0) {
$company_name = $server['company_name'];
}
}
$server_state_color = returnServerStateColor($server['server_state']);
?>
<tr data-item-id="<?php echo $server['server_uuid'] ?>">
<td data-column="server_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_state']); ?>">
<span class="badge rounded-pill bg-<?php echo $server_state_color ?>"><?php echo $server['server_state'] ?></span>
</td>
<td data-column="server_hostname" class="text-nowrap" data-filter="<?php echo htmlspecialchars($hostname); ?>" data-sort="<?php echo htmlspecialchars($hostname); ?>">
<i class="fa-solid fa-server"></i> <?php echo $hostname ?>
</td>
<?php if ($this->showCompanies) { ?>
<td data-column="company_name" class="text-nowrap" data-filter="<?php echo $company_name ?>" data-sort="<?php echo $company_name ?>">
<?php echo $company_name ?>
</td>
<?php } ?>
<td data-column="server_os" class="text-nowrap"><?php echo $server['server_os'] ?></td>
<td data-column="server_cpu" class="text-nowrap"><?php echo $server['server_cpu'] ?>
</td>
<td data-column="server_memory" class="text-nowrap" data-filter="<?php echo htmlspecialchars($mem); ?>" data-sort="<?php echo htmlspecialchars($mem); ?>">
<?php echo $mem_assigned ?>
</td>
<td data-column="server_memory_demand" class="text-nowrap <?php echo 'text-' . $mem_demand_text_color ?>" data-filter="<?php echo htmlspecialchars($mem_percent_numb); ?>" data-sort="<?php echo htmlspecialchars($mem_percent_sort); ?>">
<?php echo $mem_demand ?>
</td>
<td data-column="server_disks" class="text-nowrap"
<?php
$sortValue = '';
$filterValue = '';
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$totalDiskSpace = array_sum($sizes);
if ($totalDiskSpace > 0) {
$sortValue = $totalDiskSpace;
$filterValue = $totalDiskSpace;
}
}
?>
data-sort="<?php echo htmlspecialchars($sortValue); ?>" data-filter="<?php echo htmlspecialchars($filterValue); ?>">
<?php
if (!empty($sortValue)) {
if (count($sizes) === 1) {
echo $sizes[0] . 'GB';
} else {
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
}
}
?>
</td>
<td data-column="server_ipv4" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv4_list); ?>" data-filter="<?php echo htmlspecialchars($ipv4_list); ?>">
<?php echo $ipv4_list ?>
</td>
<td data-column="server_ipv6" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv6_list); ?>" data-filter="<?php echo htmlspecialchars($ipv6_list); ?>">
<?php echo $ipv6_list ?>
</td>
<td data-column="server_vm_snapshot" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_vm_snapshot']); ?>" data-filter="<?php echo htmlspecialchars($server['server_vm_snapshot']); ?>">
<?php echo $server['server_vm_snapshot']; ?>
</td>
<td data-column="server_vm_generation" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_vm_generation']); ?>" data-filter="<?php echo htmlspecialchars($server['server_vm_generation']); ?>">
<?php echo $server['server_vm_generation']; ?>
</td>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<td data-column="server_license_<?php echo $licenseType ?>" class="text-nowrap" data-sort="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>" data-filter="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>"><?php echo ($thisServerLicenses[$licenseType]) ? '<i class="fa-solid text-success fa-toggle-on"></i>' : '<i class="fa-solid text-danger fa-toggle-off"></i>' ?></td>
<?php }
foreach ($this->allBackupTypes as $BackupType) { ?>
<td data-column="server_backup_<?php echo $BackupType ?>" class="text-nowrap" data-sort="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>" data-filter="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>"><?php echo ($thisServerBackup[$BackupType]) ? '<i class="fa-solid text-success fa-toggle-on"></i>' : '<i class="fa-solid text-danger fa-toggle-off"></i>' ?></td>
<?php }
?>
<td data-column="server_power_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_power_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_power_state']); ?>">
<?php
if ($server['server_power_state'] == 'Off') {
echo '<i class="fa-solid text-danger fa-toggle-off"></i>';
} elseif ($server['server_power_state'] == 'Running') {
echo '<i class="fa-solid text-success fa-toggle-on"></i>';
} ?>
</td>
<td data-column="server_description" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_description']); ?>" data-filter="<?php echo $server['server_description']; ?>">
<?php echo $server['server_description']; ?>
</td>
<td>
<a href="/servers?view=<?php echo $server['server_uuid'] ?>" class="btn btn-info btn-sm btn-rounded"><i class="fa-solid fa-eye"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div>
</div>
</div>
<?php }
<?php
namespace bin\php\Classes;
if (!defined('APP_INIT')) {
exit;
}
class serverOverviewBuilder
{
public array $servers = [];
public array $showColumns = array(
'server_hostname' => false,
'company_name' => false,
'server_power_state' => false,
'server_os' => false,
'server_cpu' => false,
'server_memory' => false,
'server_memory_demand' => false,
'server_disks' => false,
'server_ipv4' => false,
'server_ipv6' => false,
'server_vm_snapshot' => false,
'server_vm_generation' => false,
'server_licenses' => false,
'server_backup' => false,
'server_description' => false,
);
public array $allBackupTypes = [];
public array $allLicenseTypes = [];
public bool $showDelBtn = true;
public bool $showServerOverviewTitle = true;
public bool $showCompanies = true;
public function processServerData()
{
foreach ($this->servers as $server) {
if (!empty($server['server_backup'])) {
$backups = json_decode($server['server_backup'], true);
if (is_array($backups)) {
foreach ($backups as $item) {
foreach ($item as $key => $value) {
$this->allBackupTypes[$key] = true;
}
}
}
}
if (!empty($server['server_licenses'])) {
$licenses = json_decode($server['server_licenses'], true);
if (is_array($licenses)) {
foreach ($licenses as $item) {
foreach ($item as $key => $value) {
$this->allLicenseTypes[$key] = true;
}
}
}
}
}
$this->allBackupTypes = array_keys($this->allBackupTypes);
sort($this->allBackupTypes);
$this->allLicenseTypes = array_keys($this->allLicenseTypes);
sort($this->allLicenseTypes);
if (isset($_COOKIE['serverTableColumns'])) {
$CheckedColumns = json_decode(htmlspecialchars(($_COOKIE['serverTableColumns']), true));
foreach ($CheckedColumns as $CheckedColumn) {
$this->showColumns[$CheckedColumn] = true;
}
} else {
$this->showColumns['server_hostname'] = true;
$this->showColumns['company_name'] = true;
$this->showColumns['server_os'] = true;
$this->showColumns['server_cpu'] = true;
$this->showColumns['server_memory'] = true;
$this->showColumns['server_memory_demand'] = true;
$this->showColumns['server_disks'] = true;
$this->showColumns['server_state'] = true;
}
}
private function cleanNumber($num)
{
// If integer value, return without formatting
if (floor($num) == $num) {
return (string)$num;
}
// Otherwise return trimmed float
return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.');
}
public function serverOverviewOutPut()
{ ?>
<div class="form-group form-show-validation row mb-3">
<?php if ($this->showServerOverviewTitle) { ?>
<div class="col-auto">
<h2>
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"></i> &nbsp; <?php echo __('server_overview') ?>
</h2>
</div>
<?php } ?>
<div class="col d-flex justify-content-end px-1">
<div class="selectgroup selectgroup-pills">
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_state" class="selectgroup-input" <?php echo($this->showColumns['server_state'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_state') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_hostname" class="selectgroup-input" <?php echo($this->showColumns['server_hostname'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_hostname') ?></span>
</label>
<?php if ($this->showCompanies) { ?>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="company_name" class="selectgroup-input" <?php echo($this->showColumns['company_name'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('company') ?></span>
</label>
<?php } ?>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_os" class="selectgroup-input" <?php echo($this->showColumns['server_os'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_os') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_cpu" class="selectgroup-input" <?php echo($this->showColumns['server_cpu'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_cpu') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_memory" class="selectgroup-input" <?php echo($this->showColumns['server_memory'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_memory') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_memory_demand" class="selectgroup-input" <?php echo($this->showColumns['server_memory_demand'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_memory_demand') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_disks" class="selectgroup-input" <?php echo($this->showColumns['server_disks'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_disks') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_ipv4" class="selectgroup-input" <?php echo($this->showColumns['server_ipv4'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_ipv4') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_ipv6" class="selectgroup-input" <?php echo($this->showColumns['server_ipv6'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_ipv6') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_vm_snapshot" class="selectgroup-input" <?php echo($this->showColumns['server_vm_snapshot'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_vm_snapshot') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_vm_generation" class="selectgroup-input" <?php echo($this->showColumns['server_vm_generation'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_vm_generation') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_licenses" class="selectgroup-input" <?php echo($this->showColumns['server_licenses'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_licenses') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_backup" class="selectgroup-input" <?php echo($this->showColumns['server_backup'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_backup') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_power_state" class="selectgroup-input" <?php echo($this->showColumns['server_power_state'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('server_power_state') ?></span>
</label>
<label class="selectgroup-item">
<input type="checkbox" name="value" value="server_description" class="selectgroup-input" <?php echo($this->showColumns['server_description'] ? 'checked=""' : '') ?>>
<span class="selectgroup-button"><?php echo __('description') ?></span>
</label>
</div>
</div>
<?php if ($this->showDelBtn) { ?>
<div class="col-lg-auto col-md-auto col-sm-auto">
<?php
if (!isset($_GET['del'])) { ?>
<a class="btn btn-danger btn-border" href="?del">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_del') ?>
</a>
<?php } else { ?>
<a class="btn btn-danger " href="/servers">
<i class="fa-solid fa-filter"></i> &nbsp; <?php echo __('show_del') ?>
</a>
<?php } ?>
</div>
<?php } ?>
</div>
<div class="card">
<div class="card-body">
<div class="table-responsive">
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="action" data-page-length="50">
<thead>
<tr>
<th data-column="server_state"><?php echo __('server_state') ?></th>
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
<?php if ($this->showCompanies) { ?>
<th data-column="company_name"><?php echo __('company') ?></th>
<?php } ?>
<th data-column="server_os"><?php echo __('server_os') ?></th>
<th data-column="server_cpu">
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
</th>
<th data-column="server_memory">
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
</th>
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
<th data-column="server_disks">
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
</th>
<th data-column="server_ipv4">
<?php echo __('server_ipv4') ?>
</th>
<th data-column="server_ipv6">
<?php echo __('server_ipv6') ?>
</th>
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></th>
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
<?php }
foreach ($this->allBackupTypes as $backupType) { ?>
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
<?php }
?>
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
<th data-column="server_description"><?php echo __('description') ?></th>
<th data-column="action">
<?php echo __('action') ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th data-column="server_state"><?php echo __('server_state') ?></th>
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
<?php if ($this->showCompanies) { ?>
<th data-column="company_name"><?php echo __('company') ?></th>
<?php } ?>
<th data-column="server_os"><?php echo __('server_os') ?></th>
<th data-column="server_cpu"><?php echo __('server_cpu') ?></th>
<th data-column="server_memory"><?php echo __('server_memory') ?></th>
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
<th data-column="server_disks"><?php echo __('server_disks') ?></th>
<th data-column="server_ipv4"><?php echo __('server_ipv4') ?></th>
<th data-column="server_ipv6"><?php echo __('server_ipv6') ?></th>
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></th>
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
<?php }
foreach ($this->allBackupTypes as $backupType) { ?>
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
<?php }
?>
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
<th data-column="server_description"><?php echo __('description') ?></th>
<th data-column="action"><?php echo __('action') ?></th>
</tr>
</tfoot>
<tbody>
<?php
foreach ($this->servers as $server) {
$disks = json_decode($server['server_disks'], true);
$totalDiskSpace = 0;
if (is_array($disks)) {
foreach ($disks as $disk) {
$totalDiskSpace += $disk['disk_space'];
}
}
if (is_null($server['server_vm_host_name'])) {
$hostname = $server['server_hostname'];
} else {
$hostname = $server['server_vm_host_name'];
}
$mem = isset($server['server_memory']) ? (float)$server['server_memory'] : 0;
$demand = isset($server['server_memory_demand']) ? (float)$server['server_memory_demand'] : 0;
if ($mem == 0 && $demand == 0) {
$mem_assigned = 'N/A';
$mem_assigned_sort = 0;
} else {
$mem_assigned = $this->cleanNumber($mem) . "M";
$mem_assigned_sort = $this->cleanNumber($mem);
}
$mem_demand_text_color = '';
if ($mem > 0) {
$mem_percent = ($demand / $mem) * 100;
$mem_percent_numb = round($mem_percent, 1);
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
$mem_percent_sort = $mem_percent_numb;
if ($mem_percent_numb <= 89) {
$mem_demand_text_color = 'success';
}
if ($mem_percent_numb > 89) {
$mem_demand_text_color = 'secondary';
}
if ($mem_percent_numb > 99) {
$mem_demand_text_color = 'danger';
}
} else {
$mem_demand = "N/A";
$mem_percent_numb = 'N/A';
$mem_percent_sort = 0;
}
if ($server['server_cpu']) {
$server_cpu = htmlspecialchars($server['server_cpu']);
$server_cpu_sort = (int)$server_cpu;
} else {
$server_cpu = "N/A";
$server_cpu_sort = 0;
}
$ipv4_list = '';
if (!empty($server['server_ipv4'])) {
$ips = json_decode($server['server_ipv4'], true);
if (is_array($ips)) {
$ipv4_list = implode(', ', $ips);
}
}
$ipv6_list = '';
if (!empty($server['server_ipv6'])) {
$ips = json_decode($server['server_ipv6'], true);
if (is_array($ips)) {
$ipv6_list = implode(', ', $ips);
}
}
$thisServerLicenses = [];
foreach ($this->allLicenseTypes as $licenseType) {
$thisServerLicenses[$licenseType] = false;
}
if (!empty($server['server_licenses'])) {
$allLicenseTypesServer = json_decode($server['server_licenses'], true);
if (is_array($allLicenseTypesServer)) {
foreach ($allLicenseTypesServer as $licenseTypeServer) {
foreach ($licenseTypeServer as $licenseTypeServerKey => $licenseTypeServerValue) {
$thisServerLicenses[$licenseTypeServerKey] = true;
}
}
}
}
$thisServerBackup = [];
foreach ($this->allBackupTypes as $BackupType) {
$thisServerBackup[$BackupType] = false;
}
if (!empty($server['server_backup'])) {
$allBackupTypesServer = json_decode($server['server_backup'], true);
if (is_array($allBackupTypesServer)) {
foreach ($allBackupTypesServer as $BackupTypeServer) {
foreach ($BackupTypeServer as $BackupTypeServerKey => $BackupTypeServerValue) {
$thisServerBackup[$BackupTypeServerKey] = true;
}
}
}
}
if ($this->showCompanies) {
$company_name = '';
if (strlen($server['company_name']) > 0) {
$company_name = $server['company_name'];
}
}
$server_state_color = returnServerStateColor($server['server_state']);
?>
<tr data-item-id="<?php echo $server['server_uuid'] ?>">
<td data-column="server_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_state']); ?>">
<span class="badge rounded-pill bg-<?php echo $server_state_color ?>"><?php echo $server['server_state'] ?></span>
</td>
<td data-column="server_hostname" class="text-nowrap" data-filter="<?php echo htmlspecialchars($hostname); ?>" data-sort="<?php echo htmlspecialchars($hostname); ?>">
<i class="fa-solid fa-server"></i> <?php echo $hostname ?>
</td>
<?php if ($this->showCompanies) { ?>
<td data-column="company_name" class="text-nowrap" data-filter="<?php echo $company_name ?>" data-sort="<?php echo $company_name ?>">
<?php echo $company_name ?>
</td>
<?php } ?>
<td data-column="server_os" class="text-nowrap"><?php echo $server['server_os'] ?></td>
<td data-column="server_cpu" class="text-nowrap" data-filter="<?php echo $server_cpu ?>" data-sort="<?php echo $server_cpu_sort ?>"><?php echo $server_cpu ?></td>
<td data-column="server_memory" class="text-nowrap" data-filter="<?php echo $mem_assigned; ?>" data-sort="<?php echo $mem_assigned_sort; ?>">
<?php echo $mem_assigned ?>
</td>
<td data-column="server_memory_demand" class="text-nowrap <?php echo 'text-' . $mem_demand_text_color ?>" data-filter="<?php echo htmlspecialchars($mem_percent_numb); ?>" data-sort="<?php echo htmlspecialchars($mem_percent_sort); ?>">
<?php echo $mem_demand ?>
</td>
<td data-column="server_disks" class="text-nowrap"
<?php
$sortValue = '';
$filterValue = '';
if (is_array($disks) && count($disks) > 0) {
$sizes = array_column($disks, 'disk_space');
$totalDiskSpace = array_sum($sizes);
if ($totalDiskSpace > 0) {
$sortValue = $totalDiskSpace;
$filterValue = $totalDiskSpace;
}
}
?>
data-sort="<?php echo htmlspecialchars($sortValue); ?>" data-filter="<?php echo htmlspecialchars($filterValue); ?>">
<?php
if (!empty($sortValue)) {
if (count($sizes) === 1) {
echo $sizes[0] . 'GB';
} else {
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
}
}
?>
</td>
<td data-column="server_ipv4" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv4_list); ?>" data-filter="<?php echo htmlspecialchars($ipv4_list); ?>">
<?php echo $ipv4_list ?>
</td>
<td data-column="server_ipv6" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv6_list); ?>" data-filter="<?php echo htmlspecialchars($ipv6_list); ?>">
<?php echo $ipv6_list ?>
</td>
<td data-column="server_vm_snapshot" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_vm_snapshot']); ?>" data-filter="<?php echo htmlspecialchars($server['server_vm_snapshot']); ?>">
<?php echo $server['server_vm_snapshot']; ?>
</td>
<td data-column="server_vm_generation" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_vm_generation']); ?>" data-filter="<?php echo htmlspecialchars($server['server_vm_generation']); ?>">
<?php echo $server['server_vm_generation']; ?>
</td>
<?php
foreach ($this->allLicenseTypes as $licenseType) { ?>
<td data-column="server_license_<?php echo $licenseType ?>" class="text-nowrap" data-sort="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>" data-filter="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>"><?php echo ($thisServerLicenses[$licenseType]) ? '<i class="fa-solid text-success fa-toggle-on"></i>' : '<i class="fa-solid text-danger fa-toggle-off"></i>' ?></td>
<?php }
foreach ($this->allBackupTypes as $BackupType) { ?>
<td data-column="server_backup_<?php echo $BackupType ?>" class="text-nowrap" data-sort="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>" data-filter="<?php echo ($thisServerLicenses[$licenseType]) ? 'yes' : 'no' ?>"><?php echo ($thisServerBackup[$BackupType]) ? '<i class="fa-solid text-success fa-toggle-on"></i>' : '<i class="fa-solid text-danger fa-toggle-off"></i>' ?></td>
<?php }
?>
<td data-column="server_power_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_power_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_power_state']); ?>">
<?php
if ($server['server_power_state'] == 'Off') {
echo '<i class="fa-solid text-danger fa-toggle-off"></i>';
} elseif ($server['server_power_state'] == 'Running') {
echo '<i class="fa-solid text-success fa-toggle-on"></i>';
} ?>
</td>
<td data-column="server_description" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_description']); ?>" data-filter="<?php echo $server['server_description']; ?>">
<?php echo $server['server_description']; ?>
</td>
<td>
<a href="/servers?view=<?php echo $server['server_uuid'] ?>" class="btn btn-info btn-sm btn-rounded"><i class="fa-solid fa-eye"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div>
</div>
</div>
<?php }
}

View File

@@ -1,24 +1,24 @@
<Dialing>
<Disable>
<Key Type="IME"/>
<Key Type="History"/>
<Key Type="Switch"/>
<Key Type="Line"/>
<Key Type="Favorite"/>
<Key Type="Empty"/>
<Key Type="DPickup"/>
<Key Type="Retrieve"/>
</Disable>
<Enable>
<Key Type="Send"/>
<Key Type="GPickup"/>
<Key Type="Delete"/>
<Key Type="End Call"/>
</Enable>
<Default>
<Key Type="Send"/>
<Key Type="Delete"/>
<Key Type="GPickup"/>
<Key Type="End Call"/>
</Default>
<Dialing>
<Disable>
<Key Type="IME"/>
<Key Type="History"/>
<Key Type="Switch"/>
<Key Type="Line"/>
<Key Type="Favorite"/>
<Key Type="Empty"/>
<Key Type="DPickup"/>
<Key Type="Retrieve"/>
</Disable>
<Enable>
<Key Type="Send"/>
<Key Type="GPickup"/>
<Key Type="Delete"/>
<Key Type="End Call"/>
</Enable>
<Default>
<Key Type="Send"/>
<Key Type="Delete"/>
<Key Type="GPickup"/>
<Key Type="End Call"/>
</Default>
</Dialing>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,141 +1,141 @@
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre-wrap;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #fbf1c7;
}
.token.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.constant,
.token.symbol,
.token.deleted {
color: #fe8019;
}
.token.number {
color: #fb4934;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #8ec07c;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #9a6e3a;
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #458588;
}
.token.function,
.token.class-name {
color: #d3869b;
}
.token.regex,
.token.important,
.token.variable {
color: #d79921;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
background: none;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre-wrap;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #fbf1c7;
}
.token.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.constant,
.token.symbol,
.token.deleted {
color: #fe8019;
}
.token.number {
color: #fb4934;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #8ec07c;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #9a6e3a;
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #458588;
}
.token.function,
.token.class-name {
color: #d3869b;
}
.token.regex,
.token.important,
.token.variable {
color: #d79921;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}

View File

@@ -1,16 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" x="0" y="0" version="1.1" xml:space="preserve" viewBox="0 0 61.028259 59.731277">
<defs/>
<style id="style2" type="text/css">
.st1{fill:#86da2f}.st2{fill:#24c2ff}.st3{fill:#ffcb12}.st4{fill:#0069da}.st5{fill:#ff4649}
</style>
<path id="path22" d="M56.11382 33.731278c2.6-.2 4.7 1.5 4.9 4.1.2 2.7-1.7 4.9-4.3 5.1-2.5.2-4.7-1.7-4.9-4.2-.2-2.7 1.6-4.7 4.3-5z" class="st1"/>
<path id="path24" d="M24.51382 55.031278c0-2.6 2-4.6 4.4-4.6 2.4 0 4.7 2.2 4.7 4.7 0 2.4-2 4.5-4.3 4.6-2.9 0-4.8-1.8-4.8-4.7z" class="st2"/>
<path id="path26" d="M31.61382 25.831278c-.4.2-.6-.1-.7-.4-3.7-6.9-2.6-15.6000004 3.9-20.8000004 1.7-1.4 4.9-1.7 6.3-.3.6.5.7 1.1.8 1.8.2 1.5.5 3 1.5 4.2000004 1.1 1.3 2.5 1.8 4.1 1.7 1.4 0 2.8-.2 3.7 1.4.5.9.3 4.4-.5 5.1-.4.3-.7.1-1 0-2.3-.9-4.7-.9-7.1-.5-.8.1-1.2-.1-1.2-1-.1-1.5-.4-2.9-1.2-4.2-1.5-2.7-4.3-2.8-6.1-.3-1.5 2-1.9 4.4-2.3 6.8-.4 2.1-.3 4.3-.2 6.5 0 0-.1 0 0 0z" class="st3"/>
<path id="path28" d="M34.11382 27.331278c-.2-.3-.1-.6.2-.8 5.7-5.2 14.2-6.2 20.8-1.1 1.7 1.4 2.8 4.3 1.9 6-.4.7-.9 1-1.5 1.2-1.4.6-2.7 1.2-3.6 2.5-.9 1.3-1.1 2.8-.7 4.4.3 1.3.8 2.7-.5 3.9-.7.7-4.1 1.3-5 .7-.4-.3-.3-.6-.2-1 .3-2.5-.3-4.8-1.2-7-.3-.8-.2-1.2.6-1.4 1.4-.4 2.7-1.1 3.7-2.1 2.2-2.1 1.7-4.8-1.2-6-2.3-1-4.7-.8-7-.6-2.2.1-4.3.7-6.3 1.3z" class="st1"/>
<path id="path30" d="M32.81382 29.931278c.3-.3.5-.2.8 0 6.6 4 10 11.9 7 19.6-.8 2-3.4 4-5.3 3.5-.8-.2-1.2-.6-1.6-1.1-.9-1.2-1.9-2.3-3.4-2.8-1.6-.5-3-.2-4.4.6-1.2.7-2.4 1.6-3.9.7-.9-.5-2.4-3.6-2.1-4.6.2-.4.6-.4 1-.4 2.5-.4 4.5-1.6 6.4-3.2.6-.5 1.1-.5 1.6.2.8 1.2 1.8 2.2 3.1 2.9 2.6 1.5 5.1.2 5.4-2.8.3-2.5-.6-4.7-1.4-6.9-.9-2-2-3.9-3.2-5.7z" class="st2"/>
<path id="path32" d="M29.61382 30.531278c-.4 2-1.3 3.9-2.5 5.6-3.6 5.4-8.8 7.6-15.2 7-2.2999997-.2-4.1999997-2.1-4.3999997-4-.1-.8.1-1.4.6-2 .7-.9 1.3-1.7 1.6-2.8.5999997-2.2-.2-4-1.8-5.6-2.2-2.2-1.9-4.2.7-5.8.3-.2.7-.4 1.1-.6.5999997-.3 1.0999997-.3 1.2999997.4.9 2.3 2.7 4 4.7 5.4.7.6.7 1 .1 1.7-1.2 1.3-1.9 2.9-2 4.7-.2 2.2 1.1 3.6 3.3 3.6 1.4 0 2.7-.5 3.9-1.1 3.1-1.6 5.5-3.9 7.8-6.3.3-.1.4-.3.8-.2z" class="st4"/>
<path id="path34" d="M13.21382 9.5312776c.2 0 .7.1 1.2.2 3.7.7000004 6-.6 7.2-4.1.8-2.3 2.5-3 4.7-1.8.1 0 .1.1.2.1 2.3 1.3 2.3 1.5.9 3.5-1.2 1.6-1.8 3.4000004-2.1 5.3000004-.2 1.1-.6 1.3-1.6.9-1.6-.6-3.3-.6-5 0-1.9.6-2.7 2.3-2.1 4.2.8 2.5 3 3.6 4.9 4.9 1.9 1.3 4.1 2 6.2 2.9.3.1.8.1.7.6-.1.3-.5.3-.9.3-4.5.2-8.8-.5-12.3-3.5-3.3-2.7-5.6999997-6-5.2999997-10.6.2999997-1.5 1.3999997-2.6000004 3.2999997-2.9000004z" class="st5"/>
<path id="path36" d="M5.0138203 37.631278c-2.4.3-4.80000003-1.7-5.00000003-4.2-.2-2.4 1.80000003-4.8 4.10000003-5 2.6-.3 5 1.5 5.2 3.9.1 2.3-1.4 5.1-4.3 5.3z" class="st4"/>
<path id="path38" d="M47.01382 2.0312776c2.5-.2 4.9 1.8 5.1 4.3.2 2.4-1.8 4.7000004-4.2 4.9000004-2.6.2-4.9-1.7000004-5.1-4.2000004-.2-2.5 1.6-4.8 4.2-5z" class="st3"/>
<path id="path40" d="M20.91382 3.9312776c.3 2.6-1.5 4.8-4.2 5.2-2.3.3-4.7-1.6-5-3.8-.3-2.9 1.3-4.99999996 4-5.29999996 2.5-.3 4.9 1.59999996 5.2 3.89999996z" class="st5"/>
<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" x="0" y="0" version="1.1" xml:space="preserve" viewBox="0 0 61.028259 59.731277">
<defs/>
<style id="style2" type="text/css">
.st1{fill:#86da2f}.st2{fill:#24c2ff}.st3{fill:#ffcb12}.st4{fill:#0069da}.st5{fill:#ff4649}
</style>
<path id="path22" d="M56.11382 33.731278c2.6-.2 4.7 1.5 4.9 4.1.2 2.7-1.7 4.9-4.3 5.1-2.5.2-4.7-1.7-4.9-4.2-.2-2.7 1.6-4.7 4.3-5z" class="st1"/>
<path id="path24" d="M24.51382 55.031278c0-2.6 2-4.6 4.4-4.6 2.4 0 4.7 2.2 4.7 4.7 0 2.4-2 4.5-4.3 4.6-2.9 0-4.8-1.8-4.8-4.7z" class="st2"/>
<path id="path26" d="M31.61382 25.831278c-.4.2-.6-.1-.7-.4-3.7-6.9-2.6-15.6000004 3.9-20.8000004 1.7-1.4 4.9-1.7 6.3-.3.6.5.7 1.1.8 1.8.2 1.5.5 3 1.5 4.2000004 1.1 1.3 2.5 1.8 4.1 1.7 1.4 0 2.8-.2 3.7 1.4.5.9.3 4.4-.5 5.1-.4.3-.7.1-1 0-2.3-.9-4.7-.9-7.1-.5-.8.1-1.2-.1-1.2-1-.1-1.5-.4-2.9-1.2-4.2-1.5-2.7-4.3-2.8-6.1-.3-1.5 2-1.9 4.4-2.3 6.8-.4 2.1-.3 4.3-.2 6.5 0 0-.1 0 0 0z" class="st3"/>
<path id="path28" d="M34.11382 27.331278c-.2-.3-.1-.6.2-.8 5.7-5.2 14.2-6.2 20.8-1.1 1.7 1.4 2.8 4.3 1.9 6-.4.7-.9 1-1.5 1.2-1.4.6-2.7 1.2-3.6 2.5-.9 1.3-1.1 2.8-.7 4.4.3 1.3.8 2.7-.5 3.9-.7.7-4.1 1.3-5 .7-.4-.3-.3-.6-.2-1 .3-2.5-.3-4.8-1.2-7-.3-.8-.2-1.2.6-1.4 1.4-.4 2.7-1.1 3.7-2.1 2.2-2.1 1.7-4.8-1.2-6-2.3-1-4.7-.8-7-.6-2.2.1-4.3.7-6.3 1.3z" class="st1"/>
<path id="path30" d="M32.81382 29.931278c.3-.3.5-.2.8 0 6.6 4 10 11.9 7 19.6-.8 2-3.4 4-5.3 3.5-.8-.2-1.2-.6-1.6-1.1-.9-1.2-1.9-2.3-3.4-2.8-1.6-.5-3-.2-4.4.6-1.2.7-2.4 1.6-3.9.7-.9-.5-2.4-3.6-2.1-4.6.2-.4.6-.4 1-.4 2.5-.4 4.5-1.6 6.4-3.2.6-.5 1.1-.5 1.6.2.8 1.2 1.8 2.2 3.1 2.9 2.6 1.5 5.1.2 5.4-2.8.3-2.5-.6-4.7-1.4-6.9-.9-2-2-3.9-3.2-5.7z" class="st2"/>
<path id="path32" d="M29.61382 30.531278c-.4 2-1.3 3.9-2.5 5.6-3.6 5.4-8.8 7.6-15.2 7-2.2999997-.2-4.1999997-2.1-4.3999997-4-.1-.8.1-1.4.6-2 .7-.9 1.3-1.7 1.6-2.8.5999997-2.2-.2-4-1.8-5.6-2.2-2.2-1.9-4.2.7-5.8.3-.2.7-.4 1.1-.6.5999997-.3 1.0999997-.3 1.2999997.4.9 2.3 2.7 4 4.7 5.4.7.6.7 1 .1 1.7-1.2 1.3-1.9 2.9-2 4.7-.2 2.2 1.1 3.6 3.3 3.6 1.4 0 2.7-.5 3.9-1.1 3.1-1.6 5.5-3.9 7.8-6.3.3-.1.4-.3.8-.2z" class="st4"/>
<path id="path34" d="M13.21382 9.5312776c.2 0 .7.1 1.2.2 3.7.7000004 6-.6 7.2-4.1.8-2.3 2.5-3 4.7-1.8.1 0 .1.1.2.1 2.3 1.3 2.3 1.5.9 3.5-1.2 1.6-1.8 3.4000004-2.1 5.3000004-.2 1.1-.6 1.3-1.6.9-1.6-.6-3.3-.6-5 0-1.9.6-2.7 2.3-2.1 4.2.8 2.5 3 3.6 4.9 4.9 1.9 1.3 4.1 2 6.2 2.9.3.1.8.1.7.6-.1.3-.5.3-.9.3-4.5.2-8.8-.5-12.3-3.5-3.3-2.7-5.6999997-6-5.2999997-10.6.2999997-1.5 1.3999997-2.6000004 3.2999997-2.9000004z" class="st5"/>
<path id="path36" d="M5.0138203 37.631278c-2.4.3-4.80000003-1.7-5.00000003-4.2-.2-2.4 1.80000003-4.8 4.10000003-5 2.6-.3 5 1.5 5.2 3.9.1 2.3-1.4 5.1-4.3 5.3z" class="st4"/>
<path id="path38" d="M47.01382 2.0312776c2.5-.2 4.9 1.8 5.1 4.3.2 2.4-1.8 4.7000004-4.2 4.9000004-2.6.2-4.9-1.7000004-5.1-4.2000004-.2-2.5 1.6-4.8 4.2-5z" class="st3"/>
<path id="path40" d="M20.91382 3.9312776c.3 2.6-1.5 4.8-4.2 5.2-2.3.3-4.7-1.6-5-3.8-.3-2.9 1.3-4.99999996 4-5.29999996 2.5-.3 4.9 1.59999996 5.2 3.89999996z" class="st5"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -1,39 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="800px" height="800px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
<g>
<g>
<g>
<path fill="#B4CCB9" d="M14,60c0,1.104,0.896,2,2,2h32c1.104,0,2-0.896,2-2V38H14V60z"/>
<rect x="14" y="26" fill="#B4CCB9" width="36" height="10"/>
<rect x="14" y="14" fill="#B4CCB9" width="36" height="10"/>
<path fill="#B4CCB9" d="M48,2H16c-1.104,0-2,0.896-2,2v8h36V4C50,2.896,49.104,2,48,2z"/>
</g>
<g opacity="0.15">
<rect x="14" y="26" width="36" height="10"/>
<rect x="14" y="14" width="36" height="10"/>
<path d="M48,2H16c-1.104,0-2,0.896-2,2v8h36V4C50,2.896,49.104,2,48,2z"/>
</g>
<g>
<path fill="#394240" d="M48,0H16c-2.211,0-4,1.789-4,4v56c0,2.211,1.789,4,4,4h32c2.211,0,4-1.789,4-4V4C52,1.789,50.211,0,48,0z
M50,60c0,1.104-0.896,2-2,2H16c-1.104,0-2-0.896-2-2V38h36V60z M50,36H14V26h36V36z M50,24H14V14h36V24z M50,12H14V4
c0-1.104,0.896-2,2-2h32c1.104,0,2,0.896,2,2V12z"/>
<path fill="#394240" d="M43,6H21c-0.553,0-1,0.447-1,1s0.447,1,1,1h22c0.553,0,1-0.447,1-1S43.553,6,43,6z"/>
<path fill="#394240" d="M21,20h22c0.553,0,1-0.447,1-1s-0.447-1-1-1H21c-0.553,0-1,0.447-1,1S20.447,20,21,20z"/>
<path fill="#394240" d="M21,32h22c0.553,0,1-0.447,1-1s-0.447-1-1-1H21c-0.553,0-1,0.447-1,1S20.447,32,21,32z"/>
<path fill="#394240" d="M32,58c1.657,0,3-1.344,3-3s-1.343-3-3-3s-3,1.344-3,3S30.343,58,32,58z M32,54c0.553,0,1,0.447,1,1
s-0.447,1-1,1s-1-0.447-1-1S31.447,54,32,54z"/>
<path fill="#394240" d="M40,58c1.657,0,3-1.344,3-3s-1.343-3-3-3s-3,1.344-3,3S38.343,58,40,58z M40,54c0.553,0,1,0.447,1,1
s-0.447,1-1,1s-1-0.447-1-1S39.447,54,40,54z"/>
<path fill="#394240" d="M24,58c1.657,0,3-1.344,3-3s-1.343-3-3-3s-3,1.344-3,3S22.343,58,24,58z M24,54c0.553,0,1,0.447,1,1
s-0.447,1-1,1s-1-0.447-1-1S23.447,54,24,54z"/>
</g>
</g>
<circle fill="#45AAB8" cx="24" cy="55" r="1"/>
<circle fill="#F76D57" cx="32" cy="55" r="1"/>
<circle fill="#F9EBB2" cx="40" cy="55" r="1"/>
</g>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="800px" height="800px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
<g>
<g>
<g>
<path fill="#B4CCB9" d="M14,60c0,1.104,0.896,2,2,2h32c1.104,0,2-0.896,2-2V38H14V60z"/>
<rect x="14" y="26" fill="#B4CCB9" width="36" height="10"/>
<rect x="14" y="14" fill="#B4CCB9" width="36" height="10"/>
<path fill="#B4CCB9" d="M48,2H16c-1.104,0-2,0.896-2,2v8h36V4C50,2.896,49.104,2,48,2z"/>
</g>
<g opacity="0.15">
<rect x="14" y="26" width="36" height="10"/>
<rect x="14" y="14" width="36" height="10"/>
<path d="M48,2H16c-1.104,0-2,0.896-2,2v8h36V4C50,2.896,49.104,2,48,2z"/>
</g>
<g>
<path fill="#394240" d="M48,0H16c-2.211,0-4,1.789-4,4v56c0,2.211,1.789,4,4,4h32c2.211,0,4-1.789,4-4V4C52,1.789,50.211,0,48,0z
M50,60c0,1.104-0.896,2-2,2H16c-1.104,0-2-0.896-2-2V38h36V60z M50,36H14V26h36V36z M50,24H14V14h36V24z M50,12H14V4
c0-1.104,0.896-2,2-2h32c1.104,0,2,0.896,2,2V12z"/>
<path fill="#394240" d="M43,6H21c-0.553,0-1,0.447-1,1s0.447,1,1,1h22c0.553,0,1-0.447,1-1S43.553,6,43,6z"/>
<path fill="#394240" d="M21,20h22c0.553,0,1-0.447,1-1s-0.447-1-1-1H21c-0.553,0-1,0.447-1,1S20.447,20,21,20z"/>
<path fill="#394240" d="M21,32h22c0.553,0,1-0.447,1-1s-0.447-1-1-1H21c-0.553,0-1,0.447-1,1S20.447,32,21,32z"/>
<path fill="#394240" d="M32,58c1.657,0,3-1.344,3-3s-1.343-3-3-3s-3,1.344-3,3S30.343,58,32,58z M32,54c0.553,0,1,0.447,1,1
s-0.447,1-1,1s-1-0.447-1-1S31.447,54,32,54z"/>
<path fill="#394240" d="M40,58c1.657,0,3-1.344,3-3s-1.343-3-3-3s-3,1.344-3,3S38.343,58,40,58z M40,54c0.553,0,1,0.447,1,1
s-0.447,1-1,1s-1-0.447-1-1S39.447,54,40,54z"/>
<path fill="#394240" d="M24,58c1.657,0,3-1.344,3-3s-1.343-3-3-3s-3,1.344-3,3S22.343,58,24,58z M24,54c0.553,0,1,0.447,1,1
s-0.447,1-1,1s-1-0.447-1-1S23.447,54,24,54z"/>
</g>
</g>
<circle fill="#45AAB8" cx="24" cy="55" r="1"/>
<circle fill="#F76D57" cx="32" cy="55" r="1"/>
<circle fill="#F9EBB2" cx="40" cy="55" r="1"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

File diff suppressed because it is too large Load Diff