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:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,4 +2,5 @@ pub/data/devices/*/documents/*
|
|||||||
pub/data/devices/*/firmware/*
|
pub/data/devices/*/firmware/*
|
||||||
.idea/*
|
.idea/*
|
||||||
composer.*
|
composer.*
|
||||||
pub/config.php
|
CAcert.crt
|
||||||
|
pub/config.php
|
||||||
|
|||||||
402
LICENSE
402
LICENSE
@@ -1,202 +1,202 @@
|
|||||||
|
|
||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
http://www.apache.org/licenses/
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
1. Definitions.
|
1. Definitions.
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
the copyright owner that is granting the License.
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
other entities that control, are controlled by, or are under common
|
other entities that control, are controlled by, or are under common
|
||||||
control with that entity. For the purposes of this definition,
|
control with that entity. For the purposes of this definition,
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
direction or management of such entity, whether by contract or
|
direction or management of such entity, whether by contract or
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
exercising permissions granted by this License.
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
including but not limited to software source code, documentation
|
including but not limited to software source code, documentation
|
||||||
source, and configuration files.
|
source, and configuration files.
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
"Object" form shall mean any form resulting from mechanical
|
||||||
transformation or translation of a Source form, including but
|
transformation or translation of a Source form, including but
|
||||||
not limited to compiled object code, generated documentation,
|
not limited to compiled object code, generated documentation,
|
||||||
and conversions to other media types.
|
and conversions to other media types.
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
Object form, made available under the License, as indicated by a
|
Object form, made available under the License, as indicated by a
|
||||||
copyright notice that is included in or attached to the work
|
copyright notice that is included in or attached to the work
|
||||||
(an example is provided in the Appendix below).
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
form, that is based on (or derived from) the Work and for which the
|
form, that is based on (or derived from) the Work and for which the
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
of this License, Derivative Works shall not include works that remain
|
of this License, Derivative Works shall not include works that remain
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
the Work and Derivative Works thereof.
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
"Contribution" shall mean any work of authorship, including
|
||||||
the original version of the Work and any modifications or additions
|
the original version of the Work and any modifications or additions
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
means any form of electronic, verbal, or written communication sent
|
means any form of electronic, verbal, or written communication sent
|
||||||
to the Licensor or its representatives, including but not limited to
|
to the Licensor or its representatives, including but not limited to
|
||||||
communication on electronic mailing lists, source code control systems,
|
communication on electronic mailing lists, source code control systems,
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
excluding communication that is conspicuously marked or otherwise
|
excluding communication that is conspicuously marked or otherwise
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
subsequently incorporated within the Work.
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
Work and such Derivative Works in Source or Object form.
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
(except as stated in this section) patent license to make, have made,
|
(except as stated in this section) patent license to make, have made,
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
where such license applies only to those patent claims licensable
|
where such license applies only to those patent claims licensable
|
||||||
by such Contributor that are necessarily infringed by their
|
by such Contributor that are necessarily infringed by their
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
institute patent litigation against any entity (including a
|
institute patent litigation against any entity (including a
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
or contributory patent infringement, then any patent licenses
|
or contributory patent infringement, then any patent licenses
|
||||||
granted to You under this License for that Work shall terminate
|
granted to You under this License for that Work shall terminate
|
||||||
as of the date such litigation is filed.
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
modifications, and in Source or Object form, provided that You
|
modifications, and in Source or Object form, provided that You
|
||||||
meet the following conditions:
|
meet the following conditions:
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
(a) You must give any other recipients of the Work or
|
||||||
Derivative Works a copy of this License; and
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
(b) You must cause any modified files to carry prominent notices
|
||||||
stating that You changed the files; and
|
stating that You changed the files; and
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
that You distribute, all copyright, patent, trademark, and
|
that You distribute, all copyright, patent, trademark, and
|
||||||
attribution notices from the Source form of the Work,
|
attribution notices from the Source form of the Work,
|
||||||
excluding those notices that do not pertain to any part of
|
excluding those notices that do not pertain to any part of
|
||||||
the Derivative Works; and
|
the Derivative Works; and
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
distribution, then any Derivative Works that You distribute must
|
distribution, then any Derivative Works that You distribute must
|
||||||
include a readable copy of the attribution notices contained
|
include a readable copy of the attribution notices contained
|
||||||
within such NOTICE file, excluding those notices that do not
|
within such NOTICE file, excluding those notices that do not
|
||||||
pertain to any part of the Derivative Works, in at least one
|
pertain to any part of the Derivative Works, in at least one
|
||||||
of the following places: within a NOTICE text file distributed
|
of the following places: within a NOTICE text file distributed
|
||||||
as part of the Derivative Works; within the Source form or
|
as part of the Derivative Works; within the Source form or
|
||||||
documentation, if provided along with the Derivative Works; or,
|
documentation, if provided along with the Derivative Works; or,
|
||||||
within a display generated by the Derivative Works, if and
|
within a display generated by the Derivative Works, if and
|
||||||
wherever such third-party notices normally appear. The contents
|
wherever such third-party notices normally appear. The contents
|
||||||
of the NOTICE file are for informational purposes only and
|
of the NOTICE file are for informational purposes only and
|
||||||
do not modify the License. You may add Your own attribution
|
do not modify the License. You may add Your own attribution
|
||||||
notices within Derivative Works that You distribute, alongside
|
notices within Derivative Works that You distribute, alongside
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
that such additional attribution notices cannot be construed
|
that such additional attribution notices cannot be construed
|
||||||
as modifying the License.
|
as modifying the License.
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
You may add Your own copyright statement to Your modifications and
|
||||||
may provide additional or different license terms and conditions
|
may provide additional or different license terms and conditions
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
the conditions stated in this License.
|
the conditions stated in this License.
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
this License, without any additional terms or conditions.
|
this License, without any additional terms or conditions.
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
the terms of any separate license agreement you may have executed
|
the terms of any separate license agreement you may have executed
|
||||||
with Licensor regarding such Contributions.
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
except as required for reasonable and customary use in describing the
|
except as required for reasonable and customary use in describing the
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
implied, including, without limitation, any warranties or conditions
|
implied, including, without limitation, any warranties or conditions
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
appropriateness of using or redistributing the Work and assume any
|
appropriateness of using or redistributing the Work and assume any
|
||||||
risks associated with Your exercise of permissions under this License.
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
unless required by applicable law (such as deliberate and grossly
|
unless required by applicable law (such as deliberate and grossly
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
liable to You for damages, including any direct, indirect, special,
|
liable to You for damages, including any direct, indirect, special,
|
||||||
incidental, or consequential damages of any character arising as a
|
incidental, or consequential damages of any character arising as a
|
||||||
result of this License or out of the use or inability to use the
|
result of this License or out of the use or inability to use the
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
other commercial damages or losses), even if such Contributor
|
other commercial damages or losses), even if such Contributor
|
||||||
has been advised of the possibility of such damages.
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
or other liability obligations and/or rights consistent with this
|
or other liability obligations and/or rights consistent with this
|
||||||
License. However, in accepting such obligations, You may act only
|
License. However, in accepting such obligations, You may act only
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
defend, and hold each Contributor harmless for any liability
|
defend, and hold each Contributor harmless for any liability
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
of your accepting any such warranty or additional liability.
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
To apply the Apache License to your work, attach the following
|
||||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
replaced with your own identifying information. (Don't include
|
replaced with your own identifying information. (Don't include
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
comment syntax for the file format. We also recommend that a
|
comment syntax for the file format. We also recommend that a
|
||||||
file or class name and description of purpose be included on the
|
file or class name and description of purpose be included on the
|
||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright 2025 Marco Mooij
|
Copyright 2025 Marco Mooij
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
@@ -44,8 +44,11 @@ class API
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
# Setup Database connection
|
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/bin/php/db_connect.php';
|
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'];
|
$this->conn = $GLOBALS['conn'];
|
||||||
|
|
||||||
if (!empty($_SESSION['user']['user_uuid'])) {
|
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.
|
// 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.
|
// 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.
|
// The builder should only be active for API users making GET requests.
|
||||||
@@ -98,7 +104,6 @@ class API
|
|||||||
$this->user_type = 'frontend';
|
$this->user_type = 'frontend';
|
||||||
|
|
||||||
# Load the locale for the user, this is used for the return message in the frontend and other globalFunctions.
|
# 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();
|
$locale = getPreferredLocale();
|
||||||
global $translations;
|
global $translations;
|
||||||
$translations = require $_SERVER['DOCUMENT_ROOT'] . "/bin/locales/{$locale}.php";
|
$translations = require $_SERVER['DOCUMENT_ROOT'] . "/bin/locales/{$locale}.php";
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\classes;
|
namespace api\classes;
|
||||||
|
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
|
|
||||||
require_once 'API.php';
|
require_once 'API.php';
|
||||||
|
|
||||||
class API_companies extends API
|
class API_companies extends API
|
||||||
{
|
{
|
||||||
public function updateCompanyState()
|
public function updateCompanyState()
|
||||||
{
|
{
|
||||||
$query = "UPDATE companies SET company_state = ? WHERE company_uuid = ?";
|
$query = "UPDATE companies SET company_state = ? WHERE company_uuid = ?";
|
||||||
$stmt = $this->prepareStatement($query);
|
$stmt = $this->prepareStatement($query);
|
||||||
$stmt->bind_param('ss', $this->data['company_state'], $this->data['company_uuid']);
|
$stmt->bind_param('ss', $this->data['company_state'], $this->data['company_uuid']);
|
||||||
if ($this->executeStatement($stmt)) {
|
if ($this->executeStatement($stmt)) {
|
||||||
$this->apiOutput(200, ['success' => 'company state successfully updated']);
|
$this->apiOutput(200, ['success' => 'company state successfully updated']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,478 +1,478 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\classes;
|
namespace api\classes;
|
||||||
|
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
|
|
||||||
require_once 'API.php';
|
require_once 'API.php';
|
||||||
|
|
||||||
class API_inserve extends API
|
class API_inserve extends API
|
||||||
{
|
{
|
||||||
|
|
||||||
private $inserve_url;
|
private $inserve_url;
|
||||||
|
|
||||||
private $inserve_token;
|
private $inserve_token;
|
||||||
|
|
||||||
public $inserve_source_uuid;
|
public $inserve_source_uuid;
|
||||||
|
|
||||||
private $ch;
|
private $ch;
|
||||||
public $httpCode = false;
|
public $httpCode = false;
|
||||||
|
|
||||||
public $response = false;
|
public $response = false;
|
||||||
|
|
||||||
private $cloudDistrubutor = 'digistate-servers';
|
private $cloudDistrubutor = 'digistate-servers';
|
||||||
|
|
||||||
public function setupConnection()
|
public function setupConnection()
|
||||||
{
|
{
|
||||||
$query = "SELECT * FROM system_sources WHERE source_name = 'inserve'";
|
$query = "SELECT * FROM system_sources WHERE source_name = 'inserve'";
|
||||||
$result = $this->conn->query($query)->fetch_assoc();
|
$result = $this->conn->query($query)->fetch_assoc();
|
||||||
|
|
||||||
$this->inserve_url = $result['source_url'];
|
$this->inserve_url = $result['source_url'];
|
||||||
$this->inserve_token = $result['source_auth_token'];
|
$this->inserve_token = $result['source_auth_token'];
|
||||||
$this->inserve_source_uuid = $result['source_uuid'];
|
$this->inserve_source_uuid = $result['source_uuid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execCurl()
|
public function execCurl()
|
||||||
{
|
{
|
||||||
$this->response = curl_exec($this->ch);
|
$this->response = curl_exec($this->ch);
|
||||||
$this->httpCode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
|
$this->httpCode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
|
||||||
|
|
||||||
curl_close($this->ch);
|
curl_close($this->ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function returnResponse()
|
public function returnResponse()
|
||||||
{
|
{
|
||||||
$this->apiOutput($this->httpCode, json_decode($this->response, true));
|
$this->apiOutput($this->httpCode, json_decode($this->response, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authMe()
|
public function authMe()
|
||||||
{
|
{
|
||||||
$this->ch = curl_init($this->inserve_url . 'auth/me');
|
$this->ch = curl_init($this->inserve_url . 'auth/me');
|
||||||
curl_setopt_array($this->ch, [
|
curl_setopt_array($this->ch, [
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_HTTPHEADER => [
|
CURLOPT_HTTPHEADER => [
|
||||||
"X-Api-Key: $this->inserve_token",
|
"X-Api-Key: $this->inserve_token",
|
||||||
"Accept: application/json"
|
"Accept: application/json"
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$this->execCurl();
|
$this->execCurl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLinkedCompanies()
|
public function getLinkedCompanies()
|
||||||
{
|
{
|
||||||
$this->ch = curl_init($this->inserve_url . 'cloud-distributors/digistate-servers/companies');
|
$this->ch = curl_init($this->inserve_url . 'cloud-distributors/digistate-servers/companies');
|
||||||
curl_setopt_array($this->ch, [
|
curl_setopt_array($this->ch, [
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_HTTPHEADER => [
|
CURLOPT_HTTPHEADER => [
|
||||||
"X-Api-Key: $this->inserve_token",
|
"X-Api-Key: $this->inserve_token",
|
||||||
"Accept: application/json"
|
"Accept: application/json"
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
$this->execCurl();
|
$this->execCurl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function companies($page)
|
public function companies($page)
|
||||||
{
|
{
|
||||||
// Build array the way the API expects
|
// Build array the way the API expects
|
||||||
$params = [
|
$params = [
|
||||||
'b' => [
|
'b' => [
|
||||||
['orderBy' => ['name', 'ASC']],
|
['orderBy' => ['name', 'ASC']],
|
||||||
['orderBy' => ['id', 'DESC']],
|
['orderBy' => ['id', 'DESC']],
|
||||||
['with' => ['operator', 'country']],
|
['with' => ['operator', 'country']],
|
||||||
['paginate' => 300],
|
['paginate' => 300],
|
||||||
],
|
],
|
||||||
'page' => $page
|
'page' => $page
|
||||||
];
|
];
|
||||||
|
|
||||||
$query = http_build_query($params);
|
$query = http_build_query($params);
|
||||||
|
|
||||||
$this->ch = curl_init($this->inserve_url . 'companies?' . $query);
|
$this->ch = curl_init($this->inserve_url . 'companies?' . $query);
|
||||||
|
|
||||||
curl_setopt_array($this->ch, [
|
curl_setopt_array($this->ch, [
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_HTTPHEADER => [
|
CURLOPT_HTTPHEADER => [
|
||||||
"X-Api-Key: $this->inserve_token",
|
"X-Api-Key: $this->inserve_token",
|
||||||
"Accept: application/json"
|
"Accept: application/json"
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->execCurl();
|
$this->execCurl();
|
||||||
|
|
||||||
return json_decode($this->response, true);
|
return json_decode($this->response, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function syncCompaniesFromSentri()
|
public function syncCompaniesFromSentri()
|
||||||
{
|
{
|
||||||
# First retrieve all the active companies to sync to the Inserver cloud distributor
|
# First retrieve all the active companies to sync to the Inserver cloud distributor
|
||||||
$companies = [];
|
$companies = [];
|
||||||
|
|
||||||
$sql = "SELECT company_source_id FROM companies WHERE company_state = 'active'";
|
$sql = "SELECT company_source_id FROM companies WHERE company_state = 'active'";
|
||||||
$stmt = $this->conn->query($sql);
|
$stmt = $this->conn->query($sql);
|
||||||
while ($row = $stmt->fetch_assoc()) {
|
while ($row = $stmt->fetch_assoc()) {
|
||||||
$id = (int)$row['company_source_id'];
|
$id = (int)$row['company_source_id'];
|
||||||
$companies[] = [
|
$companies[] = [
|
||||||
'cloud_distribution_id' => (string)$id,
|
'cloud_distribution_id' => (string)$id,
|
||||||
'company_id' => $id
|
'company_id' => $id
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = $this->inserve_url . 'cloud-distributors/digistate-servers/companies';
|
$url = $this->inserve_url . 'cloud-distributors/digistate-servers/companies';
|
||||||
|
|
||||||
$this->ch = curl_init($url);
|
$this->ch = curl_init($url);
|
||||||
|
|
||||||
curl_setopt_array($this->ch, [
|
curl_setopt_array($this->ch, [
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_POST => true,
|
CURLOPT_POST => true,
|
||||||
CURLOPT_POSTFIELDS => json_encode($companies),
|
CURLOPT_POSTFIELDS => json_encode($companies),
|
||||||
CURLOPT_HTTPHEADER => [
|
CURLOPT_HTTPHEADER => [
|
||||||
"X-Api-Key: $this->inserve_token",
|
"X-Api-Key: $this->inserve_token",
|
||||||
"Accept: application/json",
|
"Accept: application/json",
|
||||||
"Content-Type: application/json"
|
"Content-Type: application/json"
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->execCurl();
|
$this->execCurl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCloudSubscriptions()
|
public function getCloudSubscriptions()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->ch = curl_init($this->inserve_url . 'cloud-distribution-subscriptions/');
|
$this->ch = curl_init($this->inserve_url . 'cloud-distribution-subscriptions/');
|
||||||
|
|
||||||
curl_setopt_array($this->ch, [
|
curl_setopt_array($this->ch, [
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_HTTPHEADER => [
|
CURLOPT_HTTPHEADER => [
|
||||||
"X-Api-Key: $this->inserve_token",
|
"X-Api-Key: $this->inserve_token",
|
||||||
"Accept: application/json"
|
"Accept: application/json"
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->execCurl();
|
$this->execCurl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateSubscription($subscriptionId = false, $payload = false)
|
public function updateSubscription($subscriptionId = false, $payload = false)
|
||||||
{
|
{
|
||||||
$url = $this->inserve_url . 'cloud-distribution-subscriptions/' . $subscriptionId;
|
$url = $this->inserve_url . 'cloud-distribution-subscriptions/' . $subscriptionId;
|
||||||
|
|
||||||
$this->ch = curl_init($url);
|
$this->ch = curl_init($url);
|
||||||
|
|
||||||
curl_setopt_array($this->ch, [
|
curl_setopt_array($this->ch, [
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_CUSTOMREQUEST => 'PUT',
|
CURLOPT_CUSTOMREQUEST => 'PUT',
|
||||||
CURLOPT_POSTFIELDS => json_encode($payload),
|
CURLOPT_POSTFIELDS => json_encode($payload),
|
||||||
CURLOPT_HTTPHEADER => [
|
CURLOPT_HTTPHEADER => [
|
||||||
"X-Api-Key: $this->inserve_token",
|
"X-Api-Key: $this->inserve_token",
|
||||||
"Accept: application/json",
|
"Accept: application/json",
|
||||||
"Content-Type: application/json"
|
"Content-Type: application/json"
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->execCurl();
|
$this->execCurl();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAllTypes($type)
|
private function getAllTypes($type)
|
||||||
{
|
{
|
||||||
$allowedColumns = [
|
$allowedColumns = [
|
||||||
'server_licenses',
|
'server_licenses',
|
||||||
'server_backup'
|
'server_backup'
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!in_array($type, $allowedColumns, true)) {
|
if (!in_array($type, $allowedColumns, true)) {
|
||||||
throw new Exception('Invalid column name');
|
throw new Exception('Invalid column name');
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = "SELECT `$type` FROM servers";
|
$query = "SELECT `$type` FROM servers";
|
||||||
$stmt = $this->prepareStatement($query);
|
$stmt = $this->prepareStatement($query);
|
||||||
$this->executeStatement($stmt);
|
$this->executeStatement($stmt);
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
$servers = [];
|
$servers = [];
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
array_push($servers, $row);
|
array_push($servers, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
$allTypes = [];
|
$allTypes = [];
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
if (!empty($server[$type])) {
|
if (!empty($server[$type])) {
|
||||||
$types = json_decode($server[$type], true);
|
$types = json_decode($server[$type], true);
|
||||||
if (is_array($types)) {
|
if (is_array($types)) {
|
||||||
foreach ($types as $item) {
|
foreach ($types as $item) {
|
||||||
foreach ($item as $key => $value) {
|
foreach ($item as $key => $value) {
|
||||||
$allTypes[$key . '.' . $value] = 0;
|
$allTypes[$key . '.' . $value] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $allTypes;
|
return $allTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calculateTotalDiskUsage($diskJson)
|
private function calculateTotalDiskUsage($diskJson)
|
||||||
{
|
{
|
||||||
$disks = json_decode($diskJson, true);
|
$disks = json_decode($diskJson, true);
|
||||||
$server_disks_count = 0;
|
$server_disks_count = 0;
|
||||||
if (is_array($disks)) {
|
if (is_array($disks)) {
|
||||||
foreach ($disks as $disk) {
|
foreach ($disks as $disk) {
|
||||||
$server_disks_count += $disk['disk_space'];
|
$server_disks_count += $disk['disk_space'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_array($disks) && count($disks) > 0) {
|
if (is_array($disks) && count($disks) > 0) {
|
||||||
$sizes = array_column($disks, 'disk_space');
|
$sizes = array_column($disks, 'disk_space');
|
||||||
$server_disks_count = array_sum($sizes);
|
$server_disks_count = array_sum($sizes);
|
||||||
}
|
}
|
||||||
return $server_disks_count;
|
return $server_disks_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildCountObject(string $serverUuid, string $key): array
|
private function buildCountObject(string $serverUuid, string $key): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'countSentri' => 0,
|
'countSentri' => 0,
|
||||||
'countInserve' => 0,
|
'countInserve' => 0,
|
||||||
'sentriCompanyId' => 0,
|
'sentriCompanyId' => 0,
|
||||||
'SentriStatus' => 0,
|
'SentriStatus' => 0,
|
||||||
'subscriptionInserveExists' => false,
|
'subscriptionInserveExists' => false,
|
||||||
'subscriptionInserveId' => false,
|
'subscriptionInserveId' => false,
|
||||||
'subscriptionInserveCompanyId' => false,
|
'subscriptionInserveCompanyId' => false,
|
||||||
'subscriptionInserveName' => false,
|
'subscriptionInserveName' => false,
|
||||||
'subscriptionInserveStatus' => 0,
|
'subscriptionInserveStatus' => 0,
|
||||||
'md5' => md5($serverUuid . ':' . $key),
|
'md5' => md5($serverUuid . ':' . $key),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function transformTypes(array $types, string $serverUuid): array
|
private function transformTypes(array $types, string $serverUuid): array
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($types as $key => $value) {
|
foreach ($types as $key => $value) {
|
||||||
$result[$key] = $this->buildCountObject($serverUuid, $key);
|
$result[$key] = $this->buildCountObject($serverUuid, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildCountArray($serverUuid)
|
private function buildCountArray($serverUuid)
|
||||||
{
|
{
|
||||||
$allBackupTypes = $this->getAllTypes('server_backup');
|
$allBackupTypes = $this->getAllTypes('server_backup');
|
||||||
$allLicenseTypes = $this->getAllTypes('server_licenses');
|
$allLicenseTypes = $this->getAllTypes('server_licenses');
|
||||||
|
|
||||||
$backupCounts = $this->transformTypes($allBackupTypes, $serverUuid);
|
$backupCounts = $this->transformTypes($allBackupTypes, $serverUuid);
|
||||||
$licenseCounts = $this->transformTypes($allLicenseTypes, $serverUuid);
|
$licenseCounts = $this->transformTypes($allLicenseTypes, $serverUuid);
|
||||||
|
|
||||||
return array_merge(
|
return array_merge(
|
||||||
[
|
[
|
||||||
"server_CPU_count" => $this->buildCountObject($serverUuid, 'server_cpu_count'),
|
"server_CPU_count" => $this->buildCountObject($serverUuid, 'server_cpu_count'),
|
||||||
"server_Memory_count" => $this->buildCountObject($serverUuid, 'server_memory_count'),
|
"server_Memory_count" => $this->buildCountObject($serverUuid, 'server_memory_count'),
|
||||||
"server_Disk_space_count" => $this->buildCountObject($serverUuid, 'server_disks_count'),
|
"server_Disk_space_count" => $this->buildCountObject($serverUuid, 'server_disks_count'),
|
||||||
],
|
],
|
||||||
$licenseCounts,
|
$licenseCounts,
|
||||||
$backupCounts
|
$backupCounts
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function syncServerLicencesToInserve()
|
public function syncServerLicencesToInserve()
|
||||||
{
|
{
|
||||||
# Get all the linked companies
|
# Get all the linked companies
|
||||||
$this->getLinkedCompanies();
|
$this->getLinkedCompanies();
|
||||||
$allCompanies = json_decode($this->response, true);
|
$allCompanies = json_decode($this->response, true);
|
||||||
$allCompaniesIds = array_column($allCompanies['matched'], 'id', 'company_id');
|
$allCompaniesIds = array_column($allCompanies['matched'], 'id', 'company_id');
|
||||||
|
|
||||||
# first get the current subscriptions
|
# first get the current subscriptions
|
||||||
$this->getCloudSubscriptions();
|
$this->getCloudSubscriptions();
|
||||||
$allInserveSubscriptions = json_decode($this->response, true);
|
$allInserveSubscriptions = json_decode($this->response, true);
|
||||||
|
|
||||||
# Filter out all the none Sentri posted subscriptions based on the name for performance
|
# Filter out all the none Sentri posted subscriptions based on the name for performance
|
||||||
$allInserveSubscriptions = array_filter($allInserveSubscriptions, function ($subscription) {
|
$allInserveSubscriptions = array_filter($allInserveSubscriptions, function ($subscription) {
|
||||||
return isset($subscription['cloud_subscription_id']) && $subscription['cloud_subscription_id'] === 'sentri-servers';
|
return isset($subscription['cloud_subscription_id']) && $subscription['cloud_subscription_id'] === 'sentri-servers';
|
||||||
});
|
});
|
||||||
|
|
||||||
# Build lookup of existing Inserve subscriptions by cloud_distribution_id
|
# Build lookup of existing Inserve subscriptions by cloud_distribution_id
|
||||||
# this will be used later to lookup
|
# this will be used later to lookup
|
||||||
$inserveLookup = [];
|
$inserveLookup = [];
|
||||||
foreach ($allInserveSubscriptions as $subscription) {
|
foreach ($allInserveSubscriptions as $subscription) {
|
||||||
if (!empty($subscription['cloud_distribution_id'])) {
|
if (!empty($subscription['cloud_distribution_id'])) {
|
||||||
$inserveLookup[$subscription['cloud_distribution_id']] = [
|
$inserveLookup[$subscription['cloud_distribution_id']] = [
|
||||||
'id' => (int)$subscription['id'],
|
'id' => (int)$subscription['id'],
|
||||||
'quantity' => (int)$subscription['quantity'],
|
'quantity' => (int)$subscription['quantity'],
|
||||||
'status' => (int)$subscription['status'],
|
'status' => (int)$subscription['status'],
|
||||||
'cloud_distribution_company_id' => (int)$subscription['cloud_distribution_company_id'],
|
'cloud_distribution_company_id' => (int)$subscription['cloud_distribution_company_id'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# get all the servers from Sentri
|
# 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' ";
|
$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);
|
$stmt = $this->conn->query($sql);
|
||||||
|
|
||||||
while ($row = $stmt->fetch_assoc()) {
|
while ($row = $stmt->fetch_assoc()) {
|
||||||
# Create a count of all the Subscriptions possible with every count on 0
|
# Create a count of all the Subscriptions possible with every count on 0
|
||||||
$subscriptionCounts = $this->buildCountArray($row['server_uuid']);
|
$subscriptionCounts = $this->buildCountArray($row['server_uuid']);
|
||||||
$totalDiskSpace = $this->calculateTotalDiskUsage($row['server_disks']);
|
$totalDiskSpace = $this->calculateTotalDiskUsage($row['server_disks']);
|
||||||
|
|
||||||
# Inserve status codes are:
|
# Inserve status codes are:
|
||||||
# 0 = active, 1 = cancelled, 2 = pending, 3 = trial, 4 = on hold, 5 = removed
|
# 0 = active, 1 = cancelled, 2 = pending, 3 = trial, 4 = on hold, 5 = removed
|
||||||
$statusMap = [
|
$statusMap = [
|
||||||
'active' => 0,
|
'active' => 0,
|
||||||
'trial' => 3,
|
'trial' => 3,
|
||||||
'deleted' => 5,
|
'deleted' => 5,
|
||||||
];
|
];
|
||||||
|
|
||||||
// if no states matched there is something terrifying wrong, call the ambulance!
|
// if no states matched there is something terrifying wrong, call the ambulance!
|
||||||
if (!isset($statusMap[$row['server_state']])) {
|
if (!isset($statusMap[$row['server_state']])) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$sentriStatus = $statusMap[$row['server_state']];
|
$sentriStatus = $statusMap[$row['server_state']];
|
||||||
|
|
||||||
# Set all the server resource counts from Sentri into the $subscriptionCounts
|
# Set all the server resource counts from Sentri into the $subscriptionCounts
|
||||||
$subscriptionCounts['server_CPU_count']['countSentri'] = $row['server_cpu'];
|
$subscriptionCounts['server_CPU_count']['countSentri'] = $row['server_cpu'];
|
||||||
$subscriptionCounts['server_Memory_count']['countSentri'] = (int)ceil($row['server_memory'] / 1024);
|
$subscriptionCounts['server_Memory_count']['countSentri'] = (int)ceil($row['server_memory'] / 1024);
|
||||||
$subscriptionCounts['server_Disk_space_count']['countSentri'] = $totalDiskSpace;
|
$subscriptionCounts['server_Disk_space_count']['countSentri'] = $totalDiskSpace;
|
||||||
|
|
||||||
$licenses = json_decode($row['server_licenses'], true);
|
$licenses = json_decode($row['server_licenses'], true);
|
||||||
foreach ($licenses as $license) {
|
foreach ($licenses as $license) {
|
||||||
foreach ($license as $key => $LicenseType) {
|
foreach ($license as $key => $LicenseType) {
|
||||||
$subscriptionCounts[$key . '.' . $LicenseType]['countSentri']++;
|
$subscriptionCounts[$key . '.' . $LicenseType]['countSentri']++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$backups = json_decode($row['server_backup'], true);
|
$backups = json_decode($row['server_backup'], true);
|
||||||
foreach ($backups as $backup) {
|
foreach ($backups as $backup) {
|
||||||
foreach ($backup as $key => $BackupType) {
|
foreach ($backup as $key => $BackupType) {
|
||||||
$subscriptionCounts[$key . '.' . $BackupType]['countSentri'] = $totalDiskSpace;
|
$subscriptionCounts[$key . '.' . $BackupType]['countSentri'] = $totalDiskSpace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mark subscriptions that already exist in Inserve
|
# Mark subscriptions that already exist in Inserve
|
||||||
foreach ($subscriptionCounts as $key => &$item) {
|
foreach ($subscriptionCounts as $key => &$item) {
|
||||||
if (!is_array($item) || !isset($item['md5'])) {
|
if (!is_array($item) || !isset($item['md5'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$md5 = (string)$item['md5'];
|
$md5 = (string)$item['md5'];
|
||||||
|
|
||||||
if (isset($inserveLookup[$md5])) { # Subscription already exists in Inserve
|
if (isset($inserveLookup[$md5])) { # Subscription already exists in Inserve
|
||||||
$item['SentriStatus'] = $sentriStatus;
|
$item['SentriStatus'] = $sentriStatus;
|
||||||
$item['sentriCompanyId'] = (int)$allCompaniesIds[$row['company_source_id']] ?? 0;
|
$item['sentriCompanyId'] = (int)$allCompaniesIds[$row['company_source_id']] ?? 0;
|
||||||
$item['subscriptionInserveExists'] = true;
|
$item['subscriptionInserveExists'] = true;
|
||||||
$item['subscriptionInserveId'] = $inserveLookup[$item['md5']]['id'];
|
$item['subscriptionInserveId'] = $inserveLookup[$item['md5']]['id'];
|
||||||
$item['countInserve'] = $inserveLookup[$item['md5']]['quantity'];
|
$item['countInserve'] = $inserveLookup[$item['md5']]['quantity'];
|
||||||
$item['subscriptionInserveCompanyId'] = $inserveLookup[$item['md5']]['cloud_distribution_company_id'];
|
$item['subscriptionInserveCompanyId'] = $inserveLookup[$item['md5']]['cloud_distribution_company_id'];
|
||||||
$item['subscriptionInserveStatus'] = $inserveLookup[$item['md5']]['status'];
|
$item['subscriptionInserveStatus'] = $inserveLookup[$item['md5']]['status'];
|
||||||
} else { # Subscription does not exists in Inserve
|
} else { # Subscription does not exists in Inserve
|
||||||
$item['sentriCompanyId'] = (int)$allCompaniesIds[$row['company_source_id']] ?? 0;
|
$item['sentriCompanyId'] = (int)$allCompaniesIds[$row['company_source_id']] ?? 0;
|
||||||
$item['subscriptionInserveExists'] = false;
|
$item['subscriptionInserveExists'] = false;
|
||||||
$item['subscriptionInserveId'] = false;
|
$item['subscriptionInserveId'] = false;
|
||||||
$item['countInserve'] = 0;
|
$item['countInserve'] = 0;
|
||||||
$item['subscriptionInserveCompanyId'] = false;
|
$item['subscriptionInserveCompanyId'] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($item);
|
unset($item);
|
||||||
|
|
||||||
// Make the subscriptions names look nice and dandy.
|
// Make the subscriptions names look nice and dandy.
|
||||||
foreach ($subscriptionCounts as $key => &$item) {
|
foreach ($subscriptionCounts as $key => &$item) {
|
||||||
// Set server name
|
// Set server name
|
||||||
$serverName = $row['server_hostname'] ?? $row['server_vm_host_name'] ?? 'Unknown';
|
$serverName = $row['server_hostname'] ?? $row['server_vm_host_name'] ?? 'Unknown';
|
||||||
|
|
||||||
// remove server_ prefix and _count suffix
|
// remove server_ prefix and _count suffix
|
||||||
$namePart = $key;
|
$namePart = $key;
|
||||||
if (str_starts_with($key, 'server_') && str_ends_with($key, '_count')) {
|
if (str_starts_with($key, 'server_') && str_ends_with($key, '_count')) {
|
||||||
$namePart = substr($key, 7, -6);
|
$namePart = substr($key, 7, -6);
|
||||||
$namePart = ucfirst($namePart);
|
$namePart = ucfirst($namePart);
|
||||||
} // Handle keys with "."
|
} // Handle keys with "."
|
||||||
elseif (strpos($key, '.') !== false) {
|
elseif (strpos($key, '.') !== false) {
|
||||||
[$first, $second] = explode('.', $key, 2);
|
[$first, $second] = explode('.', $key, 2);
|
||||||
if ($first === $second || strtolower($second) === 'yes') {
|
if ($first === $second || strtolower($second) === 'yes') {
|
||||||
$namePart = ucfirst($first);
|
$namePart = ucfirst($first);
|
||||||
} else {
|
} else {
|
||||||
$namePart = ucfirst($first) . ' - ' . $second;
|
$namePart = ucfirst($first) . ' - ' . $second;
|
||||||
}
|
}
|
||||||
} //Handle keys without . but with a space (expmale directadmin.Standard Discounted)
|
} //Handle keys without . but with a space (expmale directadmin.Standard Discounted)
|
||||||
elseif (strpos($key, ' ') !== false) {
|
elseif (strpos($key, ' ') !== false) {
|
||||||
// explode on first .
|
// explode on first .
|
||||||
$parts = explode('.', $key, 2);
|
$parts = explode('.', $key, 2);
|
||||||
if (count($parts) === 2) {
|
if (count($parts) === 2) {
|
||||||
$namePart = ucfirst($parts[0]) . ' - ' . $parts[1];
|
$namePart = ucfirst($parts[0]) . ' - ' . $parts[1];
|
||||||
} else {
|
} else {
|
||||||
// Cap first word before first space
|
// Cap first word before first space
|
||||||
$spacePos = strpos($key, ' ');
|
$spacePos = strpos($key, ' ');
|
||||||
$first = ucfirst(substr($key, 0, $spacePos));
|
$first = ucfirst(substr($key, 0, $spacePos));
|
||||||
$rest = substr($key, $spacePos + 1);
|
$rest = substr($key, $spacePos + 1);
|
||||||
$namePart = $first . ' - ' . $rest;
|
$namePart = $first . ' - ' . $rest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['subscriptionInserveName'] = $serverName . ' - ' . $namePart;
|
$item['subscriptionInserveName'] = $serverName . ' - ' . $namePart;
|
||||||
}
|
}
|
||||||
unset($item);
|
unset($item);
|
||||||
|
|
||||||
foreach ($subscriptionCounts as $key => $item) {
|
foreach ($subscriptionCounts as $key => $item) {
|
||||||
// if subscriptionInserveExists but the countInserve is null skip creation
|
// if subscriptionInserveExists but the countInserve is null skip creation
|
||||||
if ($item['subscriptionInserveExists'] === false && (int)$item['countSentri'] === 0) {
|
if ($item['subscriptionInserveExists'] === false && (int)$item['countSentri'] === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if subscriptionInserveExists is false create a new subscription
|
// if subscriptionInserveExists is false create a new subscription
|
||||||
if ($item['subscriptionInserveExists'] === false) {
|
if ($item['subscriptionInserveExists'] === false) {
|
||||||
$payload = [
|
$payload = [
|
||||||
"cloud_distribution_id" => $item['md5'], #md5 hash based on the server_uuid from sentri and the subscription name (eg. server_cpu_count)
|
"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
|
"cloud_subscription_id" => "sentri-servers", # Mark all the sentri-servers subscriptions so we can filter the subscriptions better
|
||||||
"name" => $item['subscriptionInserveName'],
|
"name" => $item['subscriptionInserveName'],
|
||||||
"quantity" => $item['countSentri'],
|
"quantity" => $item['countSentri'],
|
||||||
"cloud_distribution_company_id" => $item['sentriCompanyId'], # this is generated by inserve (306 = digistate)
|
"cloud_distribution_company_id" => $item['sentriCompanyId'], # this is generated by inserve (306 = digistate)
|
||||||
"status" => $item['SentriStatus'],
|
"status" => $item['SentriStatus'],
|
||||||
"period_type" => 0, # 0 = monthly, 1 = anual, 2 = one time cost
|
"period_type" => 0, # 0 = monthly, 1 = anual, 2 = one time cost
|
||||||
"start_date" => date('Y-m-d')
|
"start_date" => date('Y-m-d')
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->createSubscription($payload);
|
$this->createSubscription($payload);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the subscription if the countInserve and countSentri dont match
|
// update the subscription if the countInserve and countSentri dont match
|
||||||
// Or when sentriCompanyId and subscriptionInserveCompanyId dont match
|
// Or when sentriCompanyId and subscriptionInserveCompanyId dont match
|
||||||
if ((
|
if ((
|
||||||
(int)$item['countInserve'] !== (int)$item['countSentri'] ||
|
(int)$item['countInserve'] !== (int)$item['countSentri'] ||
|
||||||
(int)$item['sentriCompanyId'] !== (int)$item['subscriptionInserveCompanyId'] ||
|
(int)$item['sentriCompanyId'] !== (int)$item['subscriptionInserveCompanyId'] ||
|
||||||
(int)$item['SentriStatus'] !== (int)$item['subscriptionInserveStatus']
|
(int)$item['SentriStatus'] !== (int)$item['subscriptionInserveStatus']
|
||||||
)
|
)
|
||||||
&& $item['subscriptionInserveExists'] !== false
|
&& $item['subscriptionInserveExists'] !== false
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
$payload = [
|
$payload = [
|
||||||
"quantity" => (int)$item['countSentri'],
|
"quantity" => (int)$item['countSentri'],
|
||||||
"cloud_distribution_company_id" => (int)$item['sentriCompanyId'],
|
"cloud_distribution_company_id" => (int)$item['sentriCompanyId'],
|
||||||
"name" => $item['subscriptionInserveName'],
|
"name" => $item['subscriptionInserveName'],
|
||||||
"status" => $item['SentriStatus'],
|
"status" => $item['SentriStatus'],
|
||||||
"quantity" => $item['countSentri']
|
"quantity" => $item['countSentri']
|
||||||
];
|
];
|
||||||
$this->updateSubscription($item['subscriptionInserveId'], $payload);
|
$this->updateSubscription($item['subscriptionInserveId'], $payload);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createSubscription($payload)
|
public function createSubscription($payload)
|
||||||
{
|
{
|
||||||
$url = $this->inserve_url . 'cloud-distribution-subscriptions';
|
$url = $this->inserve_url . 'cloud-distribution-subscriptions';
|
||||||
$this->ch = curl_init($url);
|
$this->ch = curl_init($url);
|
||||||
|
|
||||||
# I need to make this pay load:
|
# I need to make this pay load:
|
||||||
curl_setopt_array($this->ch, [
|
curl_setopt_array($this->ch, [
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_POST => true,
|
CURLOPT_POST => true,
|
||||||
CURLOPT_POSTFIELDS => json_encode($payload),
|
CURLOPT_POSTFIELDS => json_encode($payload),
|
||||||
CURLOPT_HTTPHEADER => [
|
CURLOPT_HTTPHEADER => [
|
||||||
"X-Api-Key: $this->inserve_token",
|
"X-Api-Key: $this->inserve_token",
|
||||||
"Accept: application/json",
|
"Accept: application/json",
|
||||||
"Content-Type: application/json"
|
"Content-Type: application/json"
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->execCurl();
|
$this->execCurl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,32 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\classes;
|
namespace api\classes;
|
||||||
|
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
|
|
||||||
require_once 'API.php';
|
require_once 'API.php';
|
||||||
|
|
||||||
class API_office_stompjes extends API
|
class API_office_stompjes extends API
|
||||||
{
|
{
|
||||||
public function addStomp()
|
public function addStomp()
|
||||||
{
|
{
|
||||||
$query = "INSERT INTO office_stompjes (stomp_uuid, user_uuid, stomp_timestamp) VALUES (UUID(), ?, ?)";
|
$query = "INSERT INTO office_stompjes (stomp_uuid, user_uuid, stomp_timestamp) VALUES (UUID(), ?, ?)";
|
||||||
$stmt = $this->prepareStatement($query);
|
$stmt = $this->prepareStatement($query);
|
||||||
$stmt->bind_param('si', $this->data['user_uuid'], time());
|
$stmt->bind_param('si', $this->data['user_uuid'], time());
|
||||||
$this->executeStatement($stmt);
|
$this->executeStatement($stmt);
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
|
|
||||||
$this->apiOutput(200, ['success' => 'Stomp added.']);
|
$this->apiOutput(200, ['success' => 'Stomp added.']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteStomp()
|
public function deleteStomp()
|
||||||
{
|
{
|
||||||
$query = "DELETE FROM office_stompjes WHERE stomp_uuid = ?";
|
$query = "DELETE FROM office_stompjes WHERE stomp_uuid = ?";
|
||||||
$stmt = $this->prepareStatement($query);
|
$stmt = $this->prepareStatement($query);
|
||||||
$stmt->bind_param('s', $this->data['stomp_uuid']);
|
$stmt->bind_param('s', $this->data['stomp_uuid']);
|
||||||
$this->executeStatement($stmt);
|
$this->executeStatement($stmt);
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
|
|
||||||
$this->apiOutput(200, ['success' => 'Stomp removed.']);
|
$this->apiOutput(200, ['success' => 'Stomp removed.']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,277 +1,277 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\classes;
|
namespace api\classes;
|
||||||
|
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
|
|
||||||
require_once 'API.php';
|
require_once 'API.php';
|
||||||
|
|
||||||
class API_servers extends API
|
class API_servers extends API
|
||||||
{
|
{
|
||||||
public function getServers($returnBoolean = false)
|
public function getServers($returnBoolean = false)
|
||||||
{
|
{
|
||||||
list($query, $types, $params) = $this->buildDynamicQuery('servers');
|
list($query, $types, $params) = $this->buildDynamicQuery('servers');
|
||||||
|
|
||||||
$items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Server');
|
$items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Server');
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateDiskData($disks)
|
public function validateDiskData($disks)
|
||||||
{
|
{
|
||||||
foreach ($disks as $index => $disk) {
|
foreach ($disks as $index => $disk) {
|
||||||
|
|
||||||
// Ensure $disk is an array
|
// Ensure $disk is an array
|
||||||
if (!is_array($disk)) {
|
if (!is_array($disk)) {
|
||||||
$this->apiOutput(400, ['error' => "Disk entry is not an array"]);
|
$this->apiOutput(400, ['error' => "Disk entry is not an array"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$requiredFields = ['disk_name', 'disk_space', 'disk_used', 'disk_location'];
|
$requiredFields = ['disk_name', 'disk_space', 'disk_used', 'disk_location'];
|
||||||
|
|
||||||
foreach ($requiredFields as $field) {
|
foreach ($requiredFields as $field) {
|
||||||
if (!array_key_exists($field, $disk)) {
|
if (!array_key_exists($field, $disk)) {
|
||||||
$this->apiOutput(400, ['error' => "Missing required field '$field' in disk information"]);
|
$this->apiOutput(400, ['error' => "Missing required field '$field' in disk information"]);
|
||||||
}
|
}
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'disk_used':
|
case 'disk_used':
|
||||||
case 'disk_space':
|
case 'disk_space':
|
||||||
$disks[$index][$field] = $this->validateSingleData($disk[$field], ['type' => 'float']);
|
$disks[$index][$field] = $this->validateSingleData($disk[$field], ['type' => 'float']);
|
||||||
break;
|
break;
|
||||||
case 'disk_location':
|
case 'disk_location':
|
||||||
case 'disk_name':
|
case 'disk_name':
|
||||||
$disks[$index][$field] = $this->validateSingleData($disk[$field], ['type' => 'string']);
|
$disks[$index][$field] = $this->validateSingleData($disk[$field], ['type' => 'string']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return json_encode($disks, JSON_THROW_ON_ERROR);
|
return json_encode($disks, JSON_THROW_ON_ERROR);
|
||||||
} catch (JsonException $e) {
|
} catch (JsonException $e) {
|
||||||
$this->apiOutput(400, ['error' => "Failed to encode disk data to JSON: " . $e->getMessage()]);
|
$this->apiOutput(400, ['error' => "Failed to encode disk data to JSON: " . $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function updateServer()
|
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 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') {
|
if ($this->data['server_state'] == 'deleted') {
|
||||||
$stmt = $GLOBALS['pdo']->prepare("SELECT server_state FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
$stmt = $GLOBALS['pdo']->prepare("SELECT server_state FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
||||||
$stmt->execute([$this->data['server_vm_id']]);
|
$stmt->execute([$this->data['server_vm_id']]);
|
||||||
|
|
||||||
if ($stmt->fetch()) {
|
if ($stmt->fetch()) {
|
||||||
$deleteStmt = $GLOBALS['pdo']->prepare("DELETE FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
$deleteStmt = $GLOBALS['pdo']->prepare("DELETE FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
||||||
$deleteStmt->execute([$this->data['server_vm_id']]);
|
$deleteStmt->execute([$this->data['server_vm_id']]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->data['company_uuid'])) {
|
if (isset($this->data['company_uuid'])) {
|
||||||
if (strlen($this->data['company_uuid']) == 0) {
|
if (strlen($this->data['company_uuid']) == 0) {
|
||||||
$this->data['company_uuid'] = NULL;
|
$this->data['company_uuid'] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
'company_uuid',
|
'company_uuid',
|
||||||
'server_vm_id',
|
'server_vm_id',
|
||||||
'server_vm_host_id',
|
'server_vm_host_id',
|
||||||
'server_vm_host_name',
|
'server_vm_host_name',
|
||||||
'server_power_state',
|
'server_power_state',
|
||||||
'server_state',
|
'server_state',
|
||||||
'server_hostname',
|
'server_hostname',
|
||||||
'server_os',
|
'server_os',
|
||||||
'server_cpu',
|
'server_cpu',
|
||||||
'server_memory',
|
'server_memory',
|
||||||
'server_memory_demand',
|
'server_memory_demand',
|
||||||
'server_disks',
|
'server_disks',
|
||||||
'server_ipv4',
|
'server_ipv4',
|
||||||
'server_ipv6',
|
'server_ipv6',
|
||||||
'server_vm_generation',
|
'server_vm_generation',
|
||||||
'server_vm_snapshot',
|
'server_vm_snapshot',
|
||||||
'server_licenses',
|
'server_licenses',
|
||||||
'server_backup',
|
'server_backup',
|
||||||
'server_description'
|
'server_description'
|
||||||
];
|
];
|
||||||
|
|
||||||
$insertFields = ['server_uuid'];
|
$insertFields = ['server_uuid'];
|
||||||
$insertValues = ['UUID()'];
|
$insertValues = ['UUID()'];
|
||||||
$bindParams = [];
|
$bindParams = [];
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if (array_key_exists($field, $this->data)) {
|
if (array_key_exists($field, $this->data)) {
|
||||||
$insertFields[] = $field;
|
$insertFields[] = $field;
|
||||||
$insertValues[] = ":$field";
|
$insertValues[] = ":$field";
|
||||||
$bindParams[":$field"] = $this->data[$field];
|
$bindParams[":$field"] = $this->data[$field];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Always include server_create_timestamp and server_modified_timestamp
|
# Always include server_create_timestamp and server_modified_timestamp
|
||||||
$insertFields[] = 'server_create_timestamp';
|
$insertFields[] = 'server_create_timestamp';
|
||||||
$insertValues[] = ':server_create_timestamp';
|
$insertValues[] = ':server_create_timestamp';
|
||||||
$bindParams[':server_create_timestamp'] = time();
|
$bindParams[':server_create_timestamp'] = time();
|
||||||
|
|
||||||
$insertFields[] = 'server_modified_timestamp';
|
$insertFields[] = 'server_modified_timestamp';
|
||||||
$insertValues[] = ':server_modified_timestamp';
|
$insertValues[] = ':server_modified_timestamp';
|
||||||
$bindParams[':server_modified_timestamp'] = time();
|
$bindParams[':server_modified_timestamp'] = time();
|
||||||
|
|
||||||
$query = "INSERT INTO servers (" . implode(',', $insertFields) . ")
|
$query = "INSERT INTO servers (" . implode(',', $insertFields) . ")
|
||||||
VALUES (" . implode(',', $insertValues) . ")
|
VALUES (" . implode(',', $insertValues) . ")
|
||||||
ON DUPLICATE KEY UPDATE ";
|
ON DUPLICATE KEY UPDATE ";
|
||||||
|
|
||||||
# Build the ON DUPLICATE KEY UPDATE, only foor fields that exist
|
# Build the ON DUPLICATE KEY UPDATE, only foor fields that exist
|
||||||
$updateParts = [];
|
$updateParts = [];
|
||||||
foreach ($insertFields as $field) {
|
foreach ($insertFields as $field) {
|
||||||
if (!in_array($field, ['server_create_timestamp', 'server_uuid'])) {
|
if (!in_array($field, ['server_create_timestamp', 'server_uuid'])) {
|
||||||
$updateParts[] = "$field = VALUES($field)";
|
$updateParts[] = "$field = VALUES($field)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query .= implode(", ", $updateParts);
|
$query .= implode(", ", $updateParts);
|
||||||
|
|
||||||
$stmt = $GLOBALS['pdo']->prepare($query);
|
$stmt = $GLOBALS['pdo']->prepare($query);
|
||||||
|
|
||||||
if (!$stmt->execute($bindParams)) {
|
if (!$stmt->execute($bindParams)) {
|
||||||
$this->apiOutput(400, ['error' => "Failed to insert server into database"]);
|
$this->apiOutput(400, ['error' => "Failed to insert server into database"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validateLicenseData($server_vm_id, $server_licenses)
|
private function validateLicenseData($server_vm_id, $server_licenses)
|
||||||
{
|
{
|
||||||
$server_vm_id = $this->validateSingleData($server_vm_id, ['type' => 'string']);
|
$server_vm_id = $this->validateSingleData($server_vm_id, ['type' => 'string']);
|
||||||
$server_licenses_posted = $this->validateSingleData($server_licenses, ['type' => 'array']);
|
$server_licenses_posted = $this->validateSingleData($server_licenses, ['type' => 'array']);
|
||||||
|
|
||||||
$query = "SELECT server_licenses FROM servers WHERE server_vm_id = ?";
|
$query = "SELECT server_licenses FROM servers WHERE server_vm_id = ?";
|
||||||
$stmt = $this->prepareStatement($query);
|
$stmt = $this->prepareStatement($query);
|
||||||
$stmt->bind_param("s", $server_vm_id);
|
$stmt->bind_param("s", $server_vm_id);
|
||||||
$this->executeStatement($stmt);
|
$this->executeStatement($stmt);
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
$server_licenses_db = $result->fetch_assoc();
|
$server_licenses_db = $result->fetch_assoc();
|
||||||
|
|
||||||
$server_licenses_db = $server_licenses_db['server_licenses'] ?? null;
|
$server_licenses_db = $server_licenses_db['server_licenses'] ?? null;
|
||||||
$server_licenses_db_new = [];
|
$server_licenses_db_new = [];
|
||||||
if (!empty($server_licenses_db)) {
|
if (!empty($server_licenses_db)) {
|
||||||
$decoded = json_decode($server_licenses_db, true);
|
$decoded = json_decode($server_licenses_db, true);
|
||||||
if (is_array($decoded)) {
|
if (is_array($decoded)) {
|
||||||
foreach ($decoded as $item) {
|
foreach ($decoded as $item) {
|
||||||
foreach ($item as $key => $value) {
|
foreach ($item as $key => $value) {
|
||||||
$server_licenses_db_new[$key] = $value;
|
$server_licenses_db_new[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($server_licenses_posted as $item) {
|
foreach ($server_licenses_posted as $item) {
|
||||||
foreach ($item as $rawKey => $value) {
|
foreach ($item as $rawKey => $value) {
|
||||||
|
|
||||||
$prefix = substr($rawKey, 0, 1);
|
$prefix = substr($rawKey, 0, 1);
|
||||||
$license = substr($rawKey, 1);
|
$license = substr($rawKey, 1);
|
||||||
|
|
||||||
if ($prefix === '+') {
|
if ($prefix === '+') {
|
||||||
$server_licenses_db_new[$license] = $value;
|
$server_licenses_db_new[$license] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($prefix === '-') {
|
if ($prefix === '-') {
|
||||||
unset($server_licenses_db_new[$license]);
|
unset($server_licenses_db_new[$license]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$server_licenses_db_new_final = [];
|
$server_licenses_db_new_final = [];
|
||||||
foreach ($server_licenses_db_new as $key => $value) {
|
foreach ($server_licenses_db_new as $key => $value) {
|
||||||
$server_licenses_db_new_final[] = [$key => $value];
|
$server_licenses_db_new_final[] = [$key => $value];
|
||||||
}
|
}
|
||||||
|
|
||||||
return empty($server_licenses_db_new_final) ? '[]' : json_encode($server_licenses_db_new_final);
|
return empty($server_licenses_db_new_final) ? '[]' : json_encode($server_licenses_db_new_final);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validateBackupData($server_vm_id, $server_backup)
|
private function validateBackupData($server_vm_id, $server_backup)
|
||||||
{
|
{
|
||||||
$server_vm_id = $this->validateSingleData($server_vm_id, ['type' => 'string']);
|
$server_vm_id = $this->validateSingleData($server_vm_id, ['type' => 'string']);
|
||||||
$server_backup_posted = $this->validateSingleData($server_backup, ['type' => 'array']);
|
$server_backup_posted = $this->validateSingleData($server_backup, ['type' => 'array']);
|
||||||
|
|
||||||
$query = "SELECT server_backup FROM servers WHERE server_vm_id = ?";
|
$query = "SELECT server_backup FROM servers WHERE server_vm_id = ?";
|
||||||
$stmt = $this->prepareStatement($query);
|
$stmt = $this->prepareStatement($query);
|
||||||
$stmt->bind_param("s", $server_vm_id);
|
$stmt->bind_param("s", $server_vm_id);
|
||||||
$this->executeStatement($stmt);
|
$this->executeStatement($stmt);
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
$server_backup_db = $result->fetch_assoc();
|
$server_backup_db = $result->fetch_assoc();
|
||||||
|
|
||||||
$server_backup_db = $server_backup_db['server_backup'] ?? null;
|
$server_backup_db = $server_backup_db['server_backup'] ?? null;
|
||||||
$server_backup_db_new = [];
|
$server_backup_db_new = [];
|
||||||
if (!empty($server_backup_db)) {
|
if (!empty($server_backup_db)) {
|
||||||
$decoded = json_decode($server_backup_db, true);
|
$decoded = json_decode($server_backup_db, true);
|
||||||
if (is_array($decoded)) {
|
if (is_array($decoded)) {
|
||||||
foreach ($decoded as $item) {
|
foreach ($decoded as $item) {
|
||||||
foreach ($item as $key => $value) {
|
foreach ($item as $key => $value) {
|
||||||
$server_backup_db_new[$key] = $value;
|
$server_backup_db_new[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($server_backup_posted as $item) {
|
foreach ($server_backup_posted as $item) {
|
||||||
foreach ($item as $rawKey => $value) {
|
foreach ($item as $rawKey => $value) {
|
||||||
|
|
||||||
$prefix = substr($rawKey, 0, 1);
|
$prefix = substr($rawKey, 0, 1);
|
||||||
$backup = substr($rawKey, 1);
|
$backup = substr($rawKey, 1);
|
||||||
|
|
||||||
if ($prefix === '+') {
|
if ($prefix === '+') {
|
||||||
$server_backup_db_new[$backup] = $value;
|
$server_backup_db_new[$backup] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($prefix === '-') {
|
if ($prefix === '-') {
|
||||||
unset($server_backup_db_new[$backup]);
|
unset($server_backup_db_new[$backup]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$server_backup_db_new_final = [];
|
$server_backup_db_new_final = [];
|
||||||
foreach ($server_backup_db_new as $key => $value) {
|
foreach ($server_backup_db_new as $key => $value) {
|
||||||
$server_backup_db_new_final[] = [$key => $value];
|
$server_backup_db_new_final[] = [$key => $value];
|
||||||
}
|
}
|
||||||
|
|
||||||
return empty($server_backup_db_new_final) ? '[]' : json_encode($server_backup_db_new_final);
|
return empty($server_backup_db_new_final) ? '[]' : json_encode($server_backup_db_new_final);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processServerData($server, $requiredFields, $optionalFields)
|
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
|
// 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'])) {
|
if (!empty($server['server_disks']) && is_array($server['server_disks'])) {
|
||||||
$server['server_disks'] = $this->validateDiskData($server['server_disks']);
|
$server['server_disks'] = $this->validateDiskData($server['server_disks']);
|
||||||
} else {
|
} else {
|
||||||
unset($server['server_disks']);
|
unset($server['server_disks']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($server['server_licenses']) && is_array($server['server_licenses'])) {
|
if (!empty($server['server_licenses']) && is_array($server['server_licenses'])) {
|
||||||
$server['server_licenses'] = $this->validateLicenseData($server['server_vm_id'], $server['server_licenses']);
|
$server['server_licenses'] = $this->validateLicenseData($server['server_vm_id'], $server['server_licenses']);
|
||||||
} else {
|
} else {
|
||||||
unset($server['server_licenses']);
|
unset($server['server_licenses']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($server['server_backup']) && is_array($server['server_backup'])) {
|
if (!empty($server['server_backup']) && is_array($server['server_backup'])) {
|
||||||
$server['server_backup'] = $this->validateBackupData($server['server_vm_id'], $server['server_backup']);
|
$server['server_backup'] = $this->validateBackupData($server['server_vm_id'], $server['server_backup']);
|
||||||
} else {
|
} else {
|
||||||
unset($server['server_backup']);
|
unset($server['server_backup']);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (['server_ipv4', 'server_ipv6'] as $key) {
|
foreach (['server_ipv4', 'server_ipv6'] as $key) {
|
||||||
if (!empty($server[$key]) && is_array($server[$key])) {
|
if (!empty($server[$key]) && is_array($server[$key])) {
|
||||||
$server[$key] = json_encode($server[$key]);
|
$server[$key] = json_encode($server[$key]);
|
||||||
} else {
|
} else {
|
||||||
unset($server[$key]);
|
unset($server[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->postedData = $server;
|
$this->postedData = $server;
|
||||||
|
|
||||||
$this->validateData($requiredFields, $optionalFields);
|
$this->validateData($requiredFields, $optionalFields);
|
||||||
|
|
||||||
$this->updateServer();
|
$this->updateServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,34 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\classes;
|
namespace api\classes;
|
||||||
|
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
|
|
||||||
require_once 'API.php';
|
require_once 'API.php';
|
||||||
|
|
||||||
class API_system_modules extends API
|
class API_system_modules extends API
|
||||||
{
|
{
|
||||||
public function getModules($returnBoolean = false)
|
public function getModules($returnBoolean = false)
|
||||||
{
|
{
|
||||||
list($query, $types, $params) = $this->buildDynamicQuery('system_modules');
|
list($query, $types, $params) = $this->buildDynamicQuery('system_modules');
|
||||||
|
|
||||||
$items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Permission');
|
$items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Permission');
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function enableModule()
|
public function enableModule()
|
||||||
{
|
{
|
||||||
|
|
||||||
$module_uuid_enabled = ($this->data['module_enabled']) ? 0 : 1;
|
$module_uuid_enabled = ($this->data['module_enabled']) ? 0 : 1;
|
||||||
|
|
||||||
# Module 'system cannot be disabled'
|
# Module 'system cannot be disabled'
|
||||||
$query = "UPDATE system_modules SET module_enabled = ? WHERE module_uuid = ? AND module_slugify != 'system'";
|
$query = "UPDATE system_modules SET module_enabled = ? WHERE module_uuid = ? AND module_slugify != 'system'";
|
||||||
$stmt = $this->prepareStatement($query);
|
$stmt = $this->prepareStatement($query);
|
||||||
$stmt->bind_param('is', $module_uuid_enabled, $this->data['module_uuid']);
|
$stmt->bind_param('is', $module_uuid_enabled, $this->data['module_uuid']);
|
||||||
|
|
||||||
if ($this->executeStatement($stmt)) {
|
if ($this->executeStatement($stmt)) {
|
||||||
$this->apiOutput(200, ['success' => 'Module ' . ($module_uuid_enabled ? 'enabled' : 'disabled') . ' successfully.']);
|
$this->apiOutput(200, ['success' => 'Module ' . ($module_uuid_enabled ? 'enabled' : 'disabled') . ' successfully.']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,26 +1,26 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace api\classes;
|
namespace api\classes;
|
||||||
|
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
|
|
||||||
require_once 'API.php';
|
require_once 'API.php';
|
||||||
|
|
||||||
class API_system_sources extends API
|
class API_system_sources extends API
|
||||||
{
|
{
|
||||||
public function inserveUpdate()
|
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)
|
$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)
|
VALUES (UUID(), ?, ?, '', '', ?, ?, NULL)
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
source_url = VALUES(source_url),
|
source_url = VALUES(source_url),
|
||||||
source_auth_token = VALUES(source_auth_token),
|
source_auth_token = VALUES(source_auth_token),
|
||||||
source_modified_timestamp = VALUES(source_create_timestamp)";
|
source_modified_timestamp = VALUES(source_create_timestamp)";
|
||||||
$stmt = $this->prepareStatement($query);
|
$stmt = $this->prepareStatement($query);
|
||||||
$stmt->bind_param('sssi', $this->data['source_name'], $this->data['source_url'], $this->data['source_auth_token'], time());
|
$stmt->bind_param('sssi', $this->data['source_name'], $this->data['source_url'], $this->data['source_auth_token'], time());
|
||||||
$this->executeStatement($stmt);
|
$this->executeStatement($stmt);
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
|
|
||||||
$this->apiOutput(200, ['success' => 'Information modified'], 'Information updated successfully.');
|
$this->apiOutput(200, ['success' => 'Information modified'], 'Information updated successfully.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,34 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_companies;
|
use api\classes\API_companies;
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['customers']) {
|
session_start();
|
||||||
echo '405 Not Allowed';
|
|
||||||
exit;
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_companies.php';
|
||||||
}
|
|
||||||
|
|
||||||
session_start();
|
# Check permissions
|
||||||
|
$API_companies = new API_companies();
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_companies.php';
|
|
||||||
|
if (!$GLOBALS['modules_enabled']['customers']) {
|
||||||
|
echo '405 Not Allowed';
|
||||||
# Check permissions
|
exit;
|
||||||
$API_companies = new API_companies();
|
}
|
||||||
|
|
||||||
|
if ($API_companies->request_method === 'PUT') {
|
||||||
if ($API_companies->request_method === 'PUT') {
|
$API_companies->checkPermissions('customer-companies', 'RW');
|
||||||
$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
|
||||||
# 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;
|
||||||
$API_companies->return_url = false;
|
|
||||||
|
$requiredFields = [
|
||||||
$requiredFields = [
|
'company_uuid' => ['type' => 'uuid'],
|
||||||
'company_uuid' => ['type' => 'uuid'],
|
'company_state' => ['type' => 'enum', 'values' => ['active', 'imported', 'orphaned']]
|
||||||
'company_state' => ['type' => 'enum', 'values' => ['active', 'imported', 'orphaned']]
|
];
|
||||||
];
|
|
||||||
|
$API_companies->validateData($requiredFields);
|
||||||
$API_companies->validateData($requiredFields);
|
|
||||||
|
$API_companies->updateCompanyState();
|
||||||
$API_companies->updateCompanyState();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,43 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_office_stompjes;
|
use api\classes\API_office_stompjes;
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['office']) {
|
session_start();
|
||||||
echo '405 Not Allowed';
|
|
||||||
exit;
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_office_stompjes.php';
|
||||||
}
|
|
||||||
|
$API_office_stompjes = new API_office_stompjes();
|
||||||
session_start();
|
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_office_stompjes.php';
|
if (!$GLOBALS['modules_enabled']['office']) {
|
||||||
|
echo '405 Not Allowed';
|
||||||
$API_office_stompjes = new API_office_stompjes();
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ($API_office_stompjes->request_method === 'POST') {
|
if ($API_office_stompjes->request_method === 'POST') {
|
||||||
$API_office_stompjes->checkPermissions('ofice-stompjes-canstomp', 'RW');
|
$API_office_stompjes->checkPermissions('ofice-stompjes-canstomp', 'RW');
|
||||||
|
|
||||||
$API_office_stompjes->return_url = false;
|
$API_office_stompjes->return_url = false;
|
||||||
|
|
||||||
$requiredFields = [
|
$requiredFields = [
|
||||||
'user_uuid' => ['type' => 'uuid']
|
'user_uuid' => ['type' => 'uuid']
|
||||||
];
|
];
|
||||||
|
|
||||||
$API_office_stompjes->validateData($requiredFields);
|
$API_office_stompjes->validateData($requiredFields);
|
||||||
|
|
||||||
$modules = $API_office_stompjes->addStomp();
|
$modules = $API_office_stompjes->addStomp();
|
||||||
|
|
||||||
$API_office_stompjes->apiOutput($code = 200, ['success' => 'stomp added successfully.']);
|
$API_office_stompjes->apiOutput($code = 200, ['success' => 'stomp added successfully.']);
|
||||||
} elseif ($API_office_stompjes->request_method === 'DELETE') {
|
} elseif ($API_office_stompjes->request_method === 'DELETE') {
|
||||||
|
|
||||||
# Only superuser can delete permission due to fact that the backend needs programming when setting a permission
|
# Only superuser can delete permission due to fact that the backend needs programming when setting a permission
|
||||||
$API_office_stompjes->checkPermissions('ofice-stompjes', 'RW');
|
$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
|
# 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;
|
$API_office_stompjes->return_url = false;
|
||||||
|
|
||||||
$requiredFields = ['stomp_uuid' => ['type' => 'uuid']];
|
$requiredFields = ['stomp_uuid' => ['type' => 'uuid']];
|
||||||
$API_office_stompjes->validateData($requiredFields);
|
$API_office_stompjes->validateData($requiredFields);
|
||||||
|
|
||||||
# delete permission
|
# delete permission
|
||||||
$API_office_stompjes->deleteStomp();
|
$API_office_stompjes->deleteStomp();
|
||||||
}
|
}
|
||||||
@@ -1,57 +1,57 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_servers;
|
use api\classes\API_servers;
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['servers']) {
|
session_start();
|
||||||
echo '405 Not Allowed';
|
|
||||||
exit;
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
|
||||||
}
|
|
||||||
|
$API_servers = new API_servers();
|
||||||
session_start();
|
|
||||||
|
if (!$GLOBALS['modules_enabled']['servers']) {
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
|
echo '405 Not Allowed';
|
||||||
|
exit;
|
||||||
$API_servers = new API_servers();
|
}
|
||||||
|
|
||||||
if ($API_servers->request_method === 'POST') {
|
if ($API_servers->request_method === 'POST') {
|
||||||
$API_servers->checkPermissions('servers', 'RW');
|
$API_servers->checkPermissions('servers', 'RW');
|
||||||
|
|
||||||
$requiredFields = [
|
$requiredFields = [
|
||||||
'server_vm_id' => ['type' => 'string'],
|
'server_vm_id' => ['type' => 'string'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$optionalFields = [
|
$optionalFields = [
|
||||||
'server_vm_host_id' => ['type' => 'string'],
|
'server_vm_host_id' => ['type' => 'string'],
|
||||||
'server_vm_host_name' => ['type' => 'string'],
|
'server_vm_host_name' => ['type' => 'string'],
|
||||||
'company_uuid' => ['type' => 'string'],
|
'company_uuid' => ['type' => 'string'],
|
||||||
'server_power_state' => ['type' => 'enum', 'values' => ['Running', 'Off']],
|
'server_power_state' => ['type' => 'enum', 'values' => ['Running', 'Off']],
|
||||||
'server_state' => ['type' => 'enum', 'values' => ['new', 'active', 'deleted', 'trial', 'disabled']],
|
'server_state' => ['type' => 'enum', 'values' => ['new', 'active', 'deleted', 'trial', 'disabled']],
|
||||||
'server_hostname' => ['type' => 'string'],
|
'server_hostname' => ['type' => 'string'],
|
||||||
'server_os' => ['type' => 'string'],
|
'server_os' => ['type' => 'string'],
|
||||||
'server_cpu' => ['type' => 'int'],
|
'server_cpu' => ['type' => 'int'],
|
||||||
'server_memory' => ['type' => 'int'],
|
'server_memory' => ['type' => 'int'],
|
||||||
'server_memory_demand' => ['type' => 'int'],
|
'server_memory_demand' => ['type' => 'int'],
|
||||||
'server_disks' => ['type' => 'json'],
|
'server_disks' => ['type' => 'json'],
|
||||||
'server_ipv4' => ['type' => 'json'],
|
'server_ipv4' => ['type' => 'json'],
|
||||||
'server_ipv6' => ['type' => 'json'],
|
'server_ipv6' => ['type' => 'json'],
|
||||||
'server_vm_generation' => ['type' => 'int'],
|
'server_vm_generation' => ['type' => 'int'],
|
||||||
'server_vm_snapshot' => ['type' => 'int'],
|
'server_vm_snapshot' => ['type' => 'int'],
|
||||||
'server_licenses' => ['type' => 'json'],
|
'server_licenses' => ['type' => 'json'],
|
||||||
'server_backup' => ['type' => 'json'],
|
'server_backup' => ['type' => 'json'],
|
||||||
'server_description' => ['type' => 'string'],
|
'server_description' => ['type' => 'string'],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($API_servers->postedData['servers'])) {
|
if (isset($API_servers->postedData['servers'])) {
|
||||||
// multiple servers are posted
|
// multiple servers are posted
|
||||||
$allServers = $API_servers->postedData['servers'];
|
$allServers = $API_servers->postedData['servers'];
|
||||||
|
|
||||||
foreach ($allServers as $server) {
|
foreach ($allServers as $server) {
|
||||||
$API_servers->processServerData($server, $requiredFields, $optionalFields);
|
$API_servers->processServerData($server, $requiredFields, $optionalFields);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Single server update
|
// Single server update
|
||||||
$API_servers->processServerData($API_servers->postedData, $requiredFields, $optionalFields);
|
$API_servers->processServerData($API_servers->postedData, $requiredFields, $optionalFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
$API_servers->apiOutput(200, ['success' => "Server(s) modified or updated successfully."]);
|
$API_servers->apiOutput(200, ['success' => "Server(s) modified or updated successfully."]);
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_inserve;
|
use api\classes\API_inserve;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
|
||||||
|
|
||||||
$API_inserve = new API_inserve();
|
$API_inserve = new API_inserve();
|
||||||
$API_inserve->setupConnection();
|
$API_inserve->setupConnection();
|
||||||
|
|
||||||
|
|
||||||
if ($API_inserve->request_method === 'GET') {
|
if ($API_inserve->request_method === 'GET') {
|
||||||
|
|
||||||
if ($_GET['action'] = 'auth/me') {
|
if ($_GET['action'] = 'auth/me') {
|
||||||
$API_inserve->checkPermissions('admin-sources', 'RO');
|
$API_inserve->checkPermissions('admin-sources', 'RO');
|
||||||
|
|
||||||
# This api call, when called from the frontend will not be forwarding to a url.
|
# This api call, when called from the frontend will not be forwarding to a url.
|
||||||
$API_inserve->return_url = false;
|
$API_inserve->return_url = false;
|
||||||
$auth = $API_inserve->authMe();
|
$auth = $API_inserve->authMe();
|
||||||
|
|
||||||
http_response_code($API_inserve->httpCode);
|
http_response_code($API_inserve->httpCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_inserve;
|
use api\classes\API_inserve;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
|
||||||
|
|
||||||
|
|
||||||
$API_inserve = new API_inserve();
|
$API_inserve = new API_inserve();
|
||||||
|
|
||||||
if ($API_inserve->request_method === 'GET' || $API_inserve->request_method === 'POST') {
|
if ($API_inserve->request_method === 'GET' || $API_inserve->request_method === 'POST') {
|
||||||
# This syncs the company id's from Sentri to the Inserve cloudDistributor
|
# 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
|
# These are the same id's but it Inserve requires it to be synced to the cloudDistributor
|
||||||
$API_inserve->checkPermissions('servers', 'RW');
|
$API_inserve->checkPermissions('servers', 'RW');
|
||||||
$API_inserve->setupConnection();
|
$API_inserve->setupConnection();
|
||||||
|
|
||||||
$API_inserve->syncCompaniesFromSentri();
|
$API_inserve->syncCompaniesFromSentri();
|
||||||
|
|
||||||
|
|
||||||
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
|
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
|
||||||
}
|
}
|
||||||
@@ -1,65 +1,65 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_inserve;
|
use api\classes\API_inserve;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
|
||||||
|
|
||||||
$API_inserve = new API_inserve();
|
$API_inserve = new API_inserve();
|
||||||
$API_inserve->setupConnection();
|
$API_inserve->setupConnection();
|
||||||
|
|
||||||
if ($API_inserve->request_method === 'POST' || $API_inserve->request_method === 'GET') {
|
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
|
# Code below will retrieve all the companies and create or update it in the database
|
||||||
|
|
||||||
$API_inserve->checkPermissions('customer-companies', 'RW');
|
$API_inserve->checkPermissions('customer-companies', 'RW');
|
||||||
|
|
||||||
$allCompanies = [];
|
$allCompanies = [];
|
||||||
$page = 1;
|
$page = 1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$result = $API_inserve->companies($page);
|
$result = $API_inserve->companies($page);
|
||||||
|
|
||||||
if (!isset($result['data']) || empty($result['data'])) {
|
if (!isset($result['data']) || empty($result['data'])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($result['data'] as $item) {
|
foreach ($result['data'] as $item) {
|
||||||
$allCompanies[] = [
|
$allCompanies[] = [
|
||||||
'id' => $item['id'],
|
'id' => $item['id'],
|
||||||
'name' => $item['name'],
|
'name' => $item['name'],
|
||||||
'debtor_code' => $item['debtor_code'],
|
'debtor_code' => $item['debtor_code'],
|
||||||
'archived_at' => $item['archived_at']
|
'archived_at' => $item['archived_at']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$page++;
|
$page++;
|
||||||
|
|
||||||
} while ($result['next_page_url'] !== null);
|
} while ($result['next_page_url'] !== null);
|
||||||
|
|
||||||
foreach ($allCompanies as $company) {
|
foreach ($allCompanies as $company) {
|
||||||
$source_uuid = $API_inserve->inserve_source_uuid;
|
$source_uuid = $API_inserve->inserve_source_uuid;
|
||||||
$company_id = $company['id'];
|
$company_id = $company['id'];
|
||||||
$debtor_code = $company['debtor_code'];
|
$debtor_code = $company['debtor_code'];
|
||||||
$company_name = $company['name'];
|
$company_name = $company['name'];
|
||||||
$created_at = time();
|
$created_at = time();
|
||||||
|
|
||||||
# Add or modify the company if it is not archived
|
# Add or modify the company if it is not archived
|
||||||
if ($company['archived_at'] == null) {
|
if ($company['archived_at'] == null) {
|
||||||
$query = "INSERT INTO companies (source_uuid, company_source_id, company_source_id2, company_name, company_create_timestamp)
|
$query = "INSERT INTO companies (source_uuid, company_source_id, company_source_id2, company_name, company_create_timestamp)
|
||||||
VALUES (?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?)
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
company_name = VALUES(company_name),
|
company_name = VALUES(company_name),
|
||||||
company_source_id2 = VALUES(company_source_id2),
|
company_source_id2 = VALUES(company_source_id2),
|
||||||
company_modified_timestamp = VALUES(company_create_timestamp)";
|
company_modified_timestamp = VALUES(company_create_timestamp)";
|
||||||
$stmt = $API_inserve->prepareStatement($query);
|
$stmt = $API_inserve->prepareStatement($query);
|
||||||
$stmt->bind_param('ssssi', $source_uuid, $company_id, $debtor_code, $company_name, $created_at);
|
$stmt->bind_param('ssssi', $source_uuid, $company_id, $debtor_code, $company_name, $created_at);
|
||||||
$API_inserve->executeStatement($stmt);
|
$API_inserve->executeStatement($stmt);
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
|
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_inserve;
|
use api\classes\API_inserve;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
|
||||||
|
|
||||||
|
|
||||||
$API_inserve = new API_inserve();
|
$API_inserve = new API_inserve();
|
||||||
|
|
||||||
if ($API_inserve->request_method === 'GET' || $API_inserve->request_method === 'POST') {
|
if ($API_inserve->request_method === 'GET' || $API_inserve->request_method === 'POST') {
|
||||||
$API_inserve->checkPermissions('servers', 'RW');
|
$API_inserve->checkPermissions('servers', 'RW');
|
||||||
$API_inserve->setupConnection();
|
$API_inserve->setupConnection();
|
||||||
|
|
||||||
$API_inserve->syncCompaniesFromSentri();
|
$API_inserve->syncCompaniesFromSentri();
|
||||||
$API_inserve->syncServerLicencesToInserve();
|
$API_inserve->syncServerLicencesToInserve();
|
||||||
|
|
||||||
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
|
$API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']);
|
||||||
}
|
}
|
||||||
@@ -1,37 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_system_modules;
|
use api\classes\API_system_modules;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_modules.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_modules.php';
|
||||||
|
|
||||||
$API_system_modules = new API_system_modules();
|
$API_system_modules = new API_system_modules();
|
||||||
|
|
||||||
if ($API_system_modules->request_method === 'GET') {
|
if ($API_system_modules->request_method === 'GET') {
|
||||||
# this part here is not tested (the whole GET part)
|
# this part here is not tested (the whole GET part)
|
||||||
$API_system_modules->checkPermissions('admin-modules', 'RO');
|
$API_system_modules->checkPermissions('admin-modules', 'RO');
|
||||||
|
|
||||||
$requiredFields = [];
|
$requiredFields = [];
|
||||||
$API_system_modules->validateData($requiredFields);
|
$API_system_modules->validateData($requiredFields);
|
||||||
|
|
||||||
$modules = $API_system_modules->getModules();
|
$modules = $API_system_modules->getModules();
|
||||||
|
|
||||||
$API_system_modules->apiOutput($code = 200, ['success' => $modules], '');
|
$API_system_modules->apiOutput($code = 200, ['success' => $modules], '');
|
||||||
|
|
||||||
} elseif ($API_system_modules->request_method === 'PUT') {
|
} elseif ($API_system_modules->request_method === 'PUT') {
|
||||||
# Enable or disable a module
|
# Enable or disable a module
|
||||||
$API_system_modules->checkPermissions('admin-modules', 'RW');
|
$API_system_modules->checkPermissions('admin-modules', 'RW');
|
||||||
|
|
||||||
# This api call, when called from the frontend will not be forwarding to a url.
|
# This api call, when called from the frontend will not be forwarding to a url.
|
||||||
$API_system_modules->return_url = false;
|
$API_system_modules->return_url = false;
|
||||||
|
|
||||||
$requiredFields = [
|
$requiredFields = [
|
||||||
'module_uuid' => ['type' => 'uuid'],
|
'module_uuid' => ['type' => 'uuid'],
|
||||||
'module_enabled' => ['type' => 'boolean'],
|
'module_enabled' => ['type' => 'boolean'],
|
||||||
];
|
];
|
||||||
$API_system_modules->validateData($requiredFields);
|
$API_system_modules->validateData($requiredFields);
|
||||||
|
|
||||||
$API_system_modules->enableModule();
|
$API_system_modules->enableModule();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_system_sources;
|
use api\classes\API_system_sources;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_sources.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_system_sources.php';
|
||||||
|
|
||||||
$API_system_sources = new API_system_sources();
|
$API_system_sources = new API_system_sources();
|
||||||
|
|
||||||
if ($API_system_sources->request_method === 'POST') {
|
if ($API_system_sources->request_method === 'POST') {
|
||||||
# Enable or disable a module
|
# Enable or disable a module
|
||||||
$API_system_sources->checkPermissions('admin-sources', 'RW');
|
$API_system_sources->checkPermissions('admin-sources', 'RW');
|
||||||
|
|
||||||
if ($_POST['source_name'] == 'inserve') {
|
if ($_POST['source_name'] == 'inserve') {
|
||||||
$requiredFields = [
|
$requiredFields = [
|
||||||
'source_name' => ['type' => 'string'],
|
'source_name' => ['type' => 'string'],
|
||||||
'source_url' => ['type' => 'string'],
|
'source_url' => ['type' => 'string'],
|
||||||
'source_auth_token' => ['type' => 'string'],
|
'source_auth_token' => ['type' => 'string'],
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$API_system_sources->apiOutput(400, ['error' => 'Error: no valid source_name posted']);
|
$API_system_sources->apiOutput(400, ['error' => 'Error: no valid source_name posted']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$API_system_sources->validateData($requiredFields);
|
$API_system_sources->validateData($requiredFields);
|
||||||
|
|
||||||
if ($_POST['source_name'] == 'inserve') {
|
if ($_POST['source_name'] == 'inserve') {
|
||||||
$API_system_sources->inserveUpdate();
|
$API_system_sources->inserveUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['customers']) {
|
if (!$GLOBALS['modules_enabled']['customers']) {
|
||||||
echo '405 Not Allowed';
|
echo '405 Not Allowed';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['view'])) {
|
if (isset($_GET['view'])) {
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_company_view.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_company_view.php');
|
||||||
} else {
|
} else {
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_view.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/customers/pageCompanies_view.php');
|
||||||
}
|
}
|
||||||
@@ -1,125 +1,126 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_servers;
|
use api\classes\API_servers;
|
||||||
use bin\php\Classes\serverOverviewBuilder;
|
use bin\php\Classes\serverOverviewBuilder;
|
||||||
use bin\php\Classes\pageNavbar;
|
use bin\php\Classes\pageNavbar;
|
||||||
|
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['customers']) {
|
if (!$GLOBALS['modules_enabled']['customers']) {
|
||||||
echo '405 Not Allowed';
|
echo '405 Not Allowed';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
# IDE Section
|
# IDE Section
|
||||||
|
|
||||||
# Includes Section
|
# Includes Section
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
|
||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
$API_servers = new API_servers();
|
$API_servers = new API_servers();
|
||||||
if (!$API_servers->checkPermissions('customer-companies', 'RO', true)) {
|
if (!$API_servers->checkPermissions('customer-companies', 'RO', true)) {
|
||||||
echo 'error 401 unauthorized';
|
echo 'error 401 unauthorized';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Page functions
|
# Page functions
|
||||||
|
|
||||||
# JS Scripts to load for this page
|
# JS Scripts to load for this page
|
||||||
$jsScriptLoadData['datepicker'] = true;
|
$jsScriptLoadData['datepicker'] = true;
|
||||||
$jsScriptLoadData['breadCrumbs'] = true;
|
$jsScriptLoadData['breadCrumbs'] = true;
|
||||||
$jsScriptLoadData['datatables'] = true;
|
$jsScriptLoadData['delete_confirmation'] = true;
|
||||||
$jsScriptLoadData['multiFilterSelectServers'] = true;
|
$jsScriptLoadData['datatables'] = true;
|
||||||
|
$jsScriptLoadData['multiFilterSelectServers'] = true;
|
||||||
# PageClasses Setup
|
|
||||||
$pageNavbar = new pageNavbar(true);
|
# PageClasses Setup
|
||||||
$serverOverview = new serverOverviewBuilder();
|
$pageNavbar = new pageNavbar(true);
|
||||||
|
$serverOverview = new serverOverviewBuilder();
|
||||||
# Retrieve Information for the page
|
|
||||||
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
|
# Retrieve Information for the page
|
||||||
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM companies WHERE company_uuid = ?");
|
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
|
||||||
$stmt->bind_param('s', $company_uuid);
|
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM companies WHERE company_uuid = ?");
|
||||||
$stmt->execute();
|
$stmt->bind_param('s', $company_uuid);
|
||||||
|
$stmt->execute();
|
||||||
$result = $stmt->get_result();
|
|
||||||
$company_data = $result->fetch_assoc();
|
$result = $stmt->get_result();
|
||||||
|
$company_data = $result->fetch_assoc();
|
||||||
# Set breadcrumb data
|
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('companies'), 'href' => '/companies/'));
|
# Set breadcrumb data
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => $company_data['company_name'], 'href' => ''));
|
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');
|
# Retrieve Information for the page
|
||||||
$_GET['company_uuid'] = $company_uuid;
|
$company_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
|
||||||
$_GET['builder'] = [1 => ['where' => [0 => 'company_uuid', 1 => $company_uuid]]];
|
$_GET['company_uuid'] = $company_uuid;
|
||||||
$requiredFields = ['company_uuid' => ['type' => 'uuid']];
|
$_GET['builder'] = [1 => ['where' => [0 => 'company_uuid', 1 => $company_uuid]]];
|
||||||
$API_servers->postedData = $_GET;
|
$requiredFields = ['company_uuid' => ['type' => 'uuid']];
|
||||||
$API_servers->validateData($requiredFields);
|
$API_servers->postedData = $_GET;
|
||||||
$servers_data = $API_servers->getServers(true);
|
$API_servers->validateData($requiredFields);
|
||||||
|
$servers_data = $API_servers->getServers(true);
|
||||||
if (count($servers_data) > 0) {
|
|
||||||
$serverOverview->servers = $servers_data;
|
if (count($servers_data) > 0) {
|
||||||
$serverOverview->processServerData();
|
$serverOverview->servers = $servers_data;
|
||||||
$serverOverview->showDelBtn = false;
|
$serverOverview->processServerData();
|
||||||
$serverOverview->showCompanies = false;
|
$serverOverview->showDelBtn = false;
|
||||||
}
|
$serverOverview->showCompanies = false;
|
||||||
|
}
|
||||||
# Start page output
|
|
||||||
$pageNavbar->outPutNavbar();
|
# Start page output
|
||||||
?>
|
$pageNavbar->outPutNavbar();
|
||||||
<div class="card">
|
?>
|
||||||
<div class="card-body">
|
<div class="card">
|
||||||
<div class="row">
|
<div class="card-body">
|
||||||
<h1>
|
<div class="row">
|
||||||
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> <?php echo $company_data['company_name'] ?>
|
<h1>
|
||||||
</h1>
|
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> <?php echo $company_data['company_name'] ?>
|
||||||
</div>
|
</h1>
|
||||||
<div class="col-md-6 col-lg-6">
|
</div>
|
||||||
<table>
|
<div class="col-md-6 col-lg-6">
|
||||||
<tr>
|
<table>
|
||||||
<td>company_uuid:</td>
|
<tr>
|
||||||
<td><?php echo $company_data['company_uuid'] ?></td>
|
<td>company_uuid:</td>
|
||||||
</tr>
|
<td><?php echo $company_data['company_uuid'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>source_uuid:</td>
|
<tr>
|
||||||
<td><?php echo $company_data['source_uuid'] ?></td>
|
<td>source_uuid:</td>
|
||||||
</tr>
|
<td><?php echo $company_data['source_uuid'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>company_source_id:</td>
|
<tr>
|
||||||
<td><?php echo $company_data['company_source_id'] ?></td>
|
<td>company_source_id:</td>
|
||||||
</tr>
|
<td><?php echo $company_data['company_source_id'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>company_source_id2:</td>
|
<tr>
|
||||||
<td><?php echo $company_data['company_source_id2'] ?></td>
|
<td>company_source_id2:</td>
|
||||||
</tr>
|
<td><?php echo $company_data['company_source_id2'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>company_name:</td>
|
<tr>
|
||||||
<td><?php echo $company_data['company_name'] ?></td>
|
<td>company_name:</td>
|
||||||
</tr>
|
<td><?php echo $company_data['company_name'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>company_state:</td>
|
<tr>
|
||||||
<td><?php echo $company_data['company_state'] ?></td>
|
<td>company_state:</td>
|
||||||
</tr>
|
<td><?php echo $company_data['company_state'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>company_create_timestamp:</td>
|
<tr>
|
||||||
<td><?php echo $company_data['company_create_timestamp'] ?></td>
|
<td>company_create_timestamp:</td>
|
||||||
</tr>
|
<td><?php echo $company_data['company_create_timestamp'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>company_modified_timestamp:</td>
|
<tr>
|
||||||
<td><?php echo $company_data['company_modified_timestamp'] ?></td>
|
<td>company_modified_timestamp:</td>
|
||||||
</tr>
|
<td><?php echo $company_data['company_modified_timestamp'] ?></td>
|
||||||
</table>
|
</tr>
|
||||||
</div>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<?php
|
|
||||||
if ($GLOBALS['modules_enabled']['servers'] && $API_servers->checkPermissions('servers', 'RO', true)) {
|
<?php
|
||||||
if (count($servers_data) > 0) {
|
if ($GLOBALS['modules_enabled']['servers'] && $API_servers->checkPermissions('servers', 'RO', true)) {
|
||||||
$serverOverview->serverOverviewOutPut();
|
if (count($servers_data) > 0) {
|
||||||
}
|
$serverOverview->serverOverviewOutPut();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,137 +1,137 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['customers']) {
|
if (!$GLOBALS['modules_enabled']['customers']) {
|
||||||
echo '405 Not Allowed';
|
echo '405 Not Allowed';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
# IDE Section
|
# IDE Section
|
||||||
|
|
||||||
# Includes Section
|
# Includes Section
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
|
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
$API = new API();
|
$API = new API();
|
||||||
if (!$API->checkPermissions('customer-companies', 'RO', true)) {
|
if (!$API->checkPermissions('customer-companies', 'RO', true)) {
|
||||||
echo 'error 401 unauthorized';
|
echo 'error 401 unauthorized';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Page functions
|
# Page functions
|
||||||
|
|
||||||
# JS Scripts to load for this page
|
# JS Scripts to load for this page
|
||||||
$jsScriptLoadData['delete_confirmation'] = true;
|
$jsScriptLoadData['delete_confirmation'] = true;
|
||||||
$jsScriptLoadData['datatables'] = true;
|
$jsScriptLoadData['datatables'] = true;
|
||||||
$jsScriptLoadData['multiFilterSelect'] = true;
|
$jsScriptLoadData['multiFilterSelect'] = true;
|
||||||
$jsScriptLoadData['datepicker'] = true;
|
$jsScriptLoadData['datepicker'] = true;
|
||||||
$jsScriptLoadData['activateCompany'] = true;
|
$jsScriptLoadData['activateCompany'] = true;
|
||||||
|
|
||||||
# PageClasses Setup
|
# PageClasses Setup
|
||||||
|
|
||||||
# Retrieve Information for the page
|
# Retrieve Information for the page
|
||||||
if (!isset($_GET['all'])) {
|
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;";
|
$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 {
|
} 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;";
|
$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);
|
$stmt = $GLOBALS['conn']->query($query);
|
||||||
$stompjes = array();
|
$stompjes = array();
|
||||||
|
|
||||||
$companies = [];
|
$companies = [];
|
||||||
while ($row = $stmt->fetch_assoc()) {
|
while ($row = $stmt->fetch_assoc()) {
|
||||||
$companies[$row['company_uuid']] = $row;
|
$companies[$row['company_uuid']] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Start page output
|
# Start page output
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group form-show-validation row mb-3">
|
<div class="form-group form-show-validation row mb-3">
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<h2>
|
<h2>
|
||||||
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> <?php echo __('companies') ?>
|
<i class="<?php echo $GLOBALS['pages']['customers']['companies']['page_icon'] ?>"></i> <?php echo __('companies') ?>
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="col d-flex justify-content-end px-1">
|
<div class="col d-flex justify-content-end px-1">
|
||||||
<div class="col-lg-auto col-md-auto col-sm-auto">
|
<div class="col-lg-auto col-md-auto col-sm-auto">
|
||||||
<?php
|
<?php
|
||||||
if (!isset($_GET['all'])) { ?>
|
if (!isset($_GET['all'])) { ?>
|
||||||
<a class="btn btn-secondary" href="?all">
|
<a class="btn btn-secondary" href="?all">
|
||||||
<i class="fa-solid fa-filter"></i> <?php echo __('show_all') ?>
|
<i class="fa-solid fa-filter"></i> <?php echo __('show_all') ?>
|
||||||
</a>
|
</a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<a class="btn btn-secondary" href="?">
|
<a class="btn btn-secondary" href="?">
|
||||||
<i class="fa-solid fa-filter"></i> <?php echo __('show_active') ?>
|
<i class="fa-solid fa-filter"></i> <?php echo __('show_active') ?>
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
|
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
|
||||||
<input type="hidden">
|
<input type="hidden">
|
||||||
<div class="col-lg-auto col-md-auto col-sm-auto">
|
<div class="col-lg-auto col-md-auto col-sm-auto">
|
||||||
<button class="btn btn-primary">
|
<button class="btn btn-primary">
|
||||||
<i class="fa-solid fa-arrow-rotate-right"></i> <?php echo __('sync') ?>
|
<i class="fa-solid fa-arrow-rotate-right"></i> <?php echo __('sync') ?>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="table-responsive">
|
<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">
|
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,1,2,4" data-page-length="50">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo __('company_name') ?></th>
|
<th><?php echo __('company_name') ?></th>
|
||||||
<th><?php echo __('company_id') ?></th>
|
<th><?php echo __('company_id') ?></th>
|
||||||
<th><?php echo __('company_debtor') ?></th>
|
<th><?php echo __('company_debtor') ?></th>
|
||||||
<th><?php echo __('company_state') ?></th>
|
<th><?php echo __('company_state') ?></th>
|
||||||
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
|
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
|
||||||
<th><?php echo __('server_count') ?></th>
|
<th><?php echo __('server_count') ?></th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<th><?php echo __('actions') ?></th>
|
<th><?php echo __('actions') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo __('company_name') ?></th>
|
<th><?php echo __('company_name') ?></th>
|
||||||
<th><?php echo __('company_id') ?></th>
|
<th><?php echo __('company_id') ?></th>
|
||||||
<th><?php echo __('company_debtor') ?></th>
|
<th><?php echo __('company_debtor') ?></th>
|
||||||
<th><?php echo __('company_state') ?></th>
|
<th><?php echo __('company_state') ?></th>
|
||||||
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
|
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
|
||||||
<th><?php echo __('server_count') ?></th>
|
<th><?php echo __('server_count') ?></th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<th><?php echo __('actions') ?></th>
|
<th><?php echo __('actions') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<?php foreach ($companies as $company) { ?>
|
<?php foreach ($companies as $company) { ?>
|
||||||
<tr data-item-id="<?php echo $company['company_uuid'] ?>">
|
<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_name'] ?></td>
|
||||||
<td class="text-nowrap"><?php echo $company['company_source_id'] ?></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_source_id2'] ?></td>
|
||||||
<td class="text-nowrap"><?php echo $company['company_state'] ?></td>
|
<td class="text-nowrap"><?php echo $company['company_state'] ?></td>
|
||||||
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
|
<?php if ($GLOBALS['modules_enabled']['servers']) { ?>
|
||||||
<td class="text-nowrap"><?php echo $company['server_count'] ?></td>
|
<td class="text-nowrap"><?php echo $company['server_count'] ?></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<td>
|
<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>
|
<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) { ?>
|
<?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>
|
<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 } ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,196 +1,196 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
|
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['office']) {
|
if (!$GLOBALS['modules_enabled']['office']) {
|
||||||
echo '405 Not Allowed';
|
echo '405 Not Allowed';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# IDE Section
|
# IDE Section
|
||||||
|
|
||||||
# Includes Section
|
# Includes Section
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_permissions.php');
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
$API = new API();
|
$API = new API();
|
||||||
if (!$API->checkPermissions('ofice-stompjes', 'RO', true)) {
|
if (!$API->checkPermissions('ofice-stompjes', 'RO', true)) {
|
||||||
echo 'error 401 unauthorized';
|
echo 'error 401 unauthorized';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Page functions
|
# Page functions
|
||||||
|
|
||||||
# JS Scripts to load for this page
|
# JS Scripts to load for this page
|
||||||
$jsScriptLoadData['delete_confirmation'] = true;
|
$jsScriptLoadData['delete_confirmation'] = true;
|
||||||
$jsScriptLoadData['stompjes'] = true;
|
$jsScriptLoadData['stompjes'] = true;
|
||||||
$jsScriptLoadData['datatables'] = true;
|
$jsScriptLoadData['datatables'] = true;
|
||||||
$jsScriptLoadData['multiFilterSelect'] = true;
|
$jsScriptLoadData['multiFilterSelect'] = true;
|
||||||
$jsScriptLoadData['datepicker'] = true;
|
$jsScriptLoadData['datepicker'] = true;
|
||||||
|
|
||||||
# PageClasses Setup
|
# PageClasses Setup
|
||||||
|
|
||||||
|
|
||||||
# Retrieve Information for the page
|
# 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'");
|
$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 = [];
|
$administrators = [];
|
||||||
while ($row = $stmt->fetch_assoc()) {
|
while ($row = $stmt->fetch_assoc()) {
|
||||||
$administrators[$row['user_uuid']] = $row;
|
$administrators[$row['user_uuid']] = $row;
|
||||||
$administrators[$row['user_uuid']]['amount'] = 0;
|
$administrators[$row['user_uuid']]['amount'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_GET['fd'])) {
|
if (!isset($_GET['fd'])) {
|
||||||
$SelectFromDate = strtotime(date('Y-m-01'));
|
$SelectFromDate = strtotime(date('Y-m-01'));
|
||||||
} else {
|
} else {
|
||||||
$date = str_replace('/', '-', htmlspecialchars($_GET['fd'], ENT_QUOTES, 'UTF-8'));
|
$date = str_replace('/', '-', htmlspecialchars($_GET['fd'], ENT_QUOTES, 'UTF-8'));
|
||||||
$SelectFromDate = strtotime($date . ' 00:00:00');
|
$SelectFromDate = strtotime($date . ' 00:00:00');
|
||||||
}
|
}
|
||||||
if (!isset($_GET['td'])) {
|
if (!isset($_GET['td'])) {
|
||||||
$SelectTillDate = time();
|
$SelectTillDate = time();
|
||||||
} else {
|
} else {
|
||||||
$date = str_replace('/', '-', htmlspecialchars($_GET['td'], ENT_QUOTES, 'UTF-8'));
|
$date = str_replace('/', '-', htmlspecialchars($_GET['td'], ENT_QUOTES, 'UTF-8'));
|
||||||
$SelectTillDate = strtotime($date . ' 23:59:59');
|
$SelectTillDate = strtotime($date . ' 23:59:59');
|
||||||
}
|
}
|
||||||
|
|
||||||
$stompjes = array();
|
$stompjes = array();
|
||||||
$stmt = $GLOBALS['conn']->query("SELECT stomp_uuid, office_stompjes.user_uuid, user_full_name, user_first_name, stomp_timestamp FROM office_stompjes
|
$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
|
INNER JOIN vc_users ON office_stompjes.user_uuid = vc_users.user_uuid
|
||||||
WHERE stomp_timestamp BETWEEN '$SelectFromDate' AND '$SelectTillDate'
|
WHERE stomp_timestamp BETWEEN '$SelectFromDate' AND '$SelectTillDate'
|
||||||
AND user_stompable = '1'
|
AND user_stompable = '1'
|
||||||
ORDER BY stomp_timestamp DESC");
|
ORDER BY stomp_timestamp DESC");
|
||||||
while ($row = $stmt->fetch_assoc()) {
|
while ($row = $stmt->fetch_assoc()) {
|
||||||
array_push($stompjes, $row);
|
array_push($stompjes, $row);
|
||||||
$administrators[$row['user_uuid']]['amount']++;
|
$administrators[$row['user_uuid']]['amount']++;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Start page output
|
# Start page output
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
const stompData = <?php echo json_encode($stompjes); ?>;
|
const stompData = <?php echo json_encode($stompjes); ?>;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="form-group form-show-validation row mb-3">
|
<div class="form-group form-show-validation row mb-3">
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<h2>
|
<h2>
|
||||||
<i class="<?php echo $GLOBALS['pages']['office']['stompjeslist']['page_icon'] ?>"></i> <?php echo __('stompjeslist') ?>
|
<i class="<?php echo $GLOBALS['pages']['office']['stompjeslist']['page_icon'] ?>"></i> <?php echo __('stompjeslist') ?>
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="col d-flex justify-content-end px-1">
|
<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">
|
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-1">
|
||||||
<label>
|
<label>
|
||||||
<h5><?php echo __('from') ?>: </h5>
|
<h5><?php echo __('from') ?>: </h5>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-auto col-md-auto col-sm-auto">
|
<div class="col-lg-auto col-md-auto col-sm-auto">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" id="fd" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectFromDate) ?>"/>
|
<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>
|
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-2">
|
<div class="col-lg-auto col-md-auto col-sm-auto mt-sm-1 px-2">
|
||||||
<label>
|
<label>
|
||||||
<h5><?php echo __('to') ?>: </h5>
|
<h5><?php echo __('to') ?>: </h5>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-auto col-md-auto col-sm-auto px-2">
|
<div class="col-lg-auto col-md-auto col-sm-auto px-2">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" id="td" class="form-control" data-datepicker="true" value="<?php echo date('d/m/Y', $SelectTillDate) ?>"/>
|
<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>
|
<span class="input-group-text"><i class="fa fa-calendar-check"></i></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-auto col-md-auto col-sm-auto">
|
<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>
|
<a id="datePicker" class="btn btn-primary"><i class="fa-solid fa-arrow-rotate-right"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<canvas id="stompjesChart" height="50"></canvas>
|
<canvas id="stompjesChart" height="50"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row align-content-center">
|
<div class="row align-content-center">
|
||||||
<?php foreach ($administrators as $administrator) {
|
<?php foreach ($administrators as $administrator) {
|
||||||
if ($administrator['user_email'] != 'superuser') { ?>
|
if ($administrator['user_email'] != 'superuser') { ?>
|
||||||
<div class="col-sm-6 col-md-3 flex-shrink-0">
|
<div class="col-sm-6 col-md-3 flex-shrink-0">
|
||||||
<div class="card card-stats card-round">
|
<div class="card card-stats card-round">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
<div class="col-icon">
|
<div class="col-icon">
|
||||||
<div class="avatar-l">
|
<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="">
|
<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>
|
</div>
|
||||||
<div class="col col-stats ms-3 ms-sm-0">
|
<div class="col col-stats ms-3 ms-sm-0">
|
||||||
<div class="numbers">
|
<div class="numbers">
|
||||||
<p class="card-category"><?php echo $administrator['user_first_name'] ?></p>
|
<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>
|
<h4 class="card-title" id="count-<?php echo $administrator['user_uuid'] ?>"><?php echo $administrator['amount'] ?></h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-stats ms-3 ms-sm-0">
|
<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>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php }
|
<?php }
|
||||||
} ?>
|
} ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="table-responsive">
|
<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">
|
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,2,3" data-page-length="50">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th><?php echo __('first_name') ?></th>
|
<th><?php echo __('first_name') ?></th>
|
||||||
<th><?php echo __('time') ?></th>
|
<th><?php echo __('time') ?></th>
|
||||||
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
||||||
<th><?php echo __('actions') ?></th>
|
<th><?php echo __('actions') ?></th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th><?php echo __('first_name') ?></th>
|
<th><?php echo __('first_name') ?></th>
|
||||||
<th><?php echo __('time') ?></th>
|
<th><?php echo __('time') ?></th>
|
||||||
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
||||||
<th><?php echo __('actions') ?></th>
|
<th><?php echo __('actions') ?></th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($stompjes as $stompje) {
|
<?php foreach ($stompjes as $stompje) {
|
||||||
if ($administrators[$stompje['user_uuid']]['user_email'] != 'superuser') { ?>
|
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']; ?>>
|
<tr data-item-id="<?php echo $stompje['stomp_uuid']; ?>" data-user-uuid=<?php echo $stompje['user_uuid']; ?>>
|
||||||
<td class="text-nowrap">
|
<td class="text-nowrap">
|
||||||
<div class="avatar-sm ">
|
<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="">
|
<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>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-nowrap"><?php echo $administrators[$stompje['user_uuid']]['user_first_name'] ?></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>
|
<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)) { ?>
|
<?php if ($API->checkPermissions('ofice-stompjes', 'RW', true)) { ?>
|
||||||
<td>
|
<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>
|
<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>
|
</td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php }
|
<?php }
|
||||||
} ?>
|
} ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
<?php
|
<?php
|
||||||
echo '404 not found';
|
echo '404 not found';
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['servers']) {
|
if (!$GLOBALS['modules_enabled']['servers']) {
|
||||||
echo '405 Not Allowed';
|
echo '405 Not Allowed';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['view'])) {
|
if (isset($_GET['view'])) {
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_server_view.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_server_view.php');
|
||||||
} else {
|
} else {
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_view.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/pages/servers/pageServerOverview_view.php');
|
||||||
}
|
}
|
||||||
@@ -1,459 +1,460 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
use bin\php\Classes\pageNavbar;
|
use bin\php\Classes\pageNavbar;
|
||||||
|
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['servers']) {
|
if (!$GLOBALS['modules_enabled']['servers']) {
|
||||||
echo '405 Not Allowed';
|
echo '405 Not Allowed';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
# IDE Section
|
# IDE Section
|
||||||
|
|
||||||
# Includes Section
|
# Includes Section
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php';
|
||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
$API = new API();
|
$API = new API();
|
||||||
if (!$API->checkPermissions('servers', 'RO', true)) {
|
if (!$API->checkPermissions('servers', 'RO', true)) {
|
||||||
echo 'error 401 unauthorized';
|
echo 'error 401 unauthorized';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Page functions
|
# Page functions
|
||||||
|
|
||||||
# JS Scripts to load for this page
|
# JS Scripts to load for this page
|
||||||
$jsScriptLoadData['delete_confirmation'] = true;
|
$jsScriptLoadData['delete_confirmation'] = true;
|
||||||
$jsScriptLoadData['breadCrumbs'] = true;
|
$jsScriptLoadData['breadCrumbs'] = true;
|
||||||
$jsScriptLoadData['codeblocks'] = true;
|
$jsScriptLoadData['codeblocks'] = true;
|
||||||
|
|
||||||
# PageClasses Setup
|
# PageClasses Setup
|
||||||
$pageNavbar = new pageNavbar(true);
|
$pageNavbar = new pageNavbar(true);
|
||||||
|
|
||||||
# Retrieve Information for the page
|
# Retrieve Information for the page
|
||||||
$server_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
|
$server_uuid = htmlspecialchars($_GET['view'], ENT_QUOTES, 'UTF-8');
|
||||||
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM servers WHERE server_uuid = ?");
|
$stmt = $GLOBALS['conn']->prepare("SELECT * FROM servers WHERE server_uuid = ?");
|
||||||
$stmt->bind_param('s', $server_uuid);
|
$stmt->bind_param('s', $server_uuid);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
$server_data = $result->fetch_assoc();
|
$server_data = $result->fetch_assoc();
|
||||||
|
|
||||||
if ($GLOBALS['modules_enabled']['customers']) {
|
if ($GLOBALS['modules_enabled']['customers']) {
|
||||||
$companies_data = $GLOBALS['conn']->query("SELECT company_uuid, company_name FROM companies WHERE company_state = 'active'");
|
$companies_data = $GLOBALS['conn']->query("SELECT company_uuid, company_name FROM companies WHERE company_state = 'active'");
|
||||||
$companies = array();
|
$companies = array();
|
||||||
while ($company_data = $companies_data->fetch_assoc()) {
|
while ($company_data = $companies_data->fetch_assoc()) {
|
||||||
array_push($companies, $company_data);
|
array_push($companies, $company_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve Information for the page
|
# 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");
|
$user_groups_data = $GLOBALS['conn']->query("SELECT * FROM vc_user_groups WHERE user_group_type = 'admin' ORDER BY user_group_weight DESC");
|
||||||
|
|
||||||
|
|
||||||
# memory
|
# memory
|
||||||
$mem = isset($server_data['server_memory']) ? (float)$server_data['server_memory'] : 0;
|
$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;
|
$demand = isset($server_data['server_memory_demand']) ? (float)$server_data['server_memory_demand'] : 0;
|
||||||
if ($mem > 0) {
|
if ($mem > 0) {
|
||||||
$mem_percent = ($demand / $mem) * 100;
|
$mem_percent = ($demand / $mem) * 100;
|
||||||
$mem_percent_numb = round($mem_percent, 1);
|
$mem_percent_numb = round($mem_percent, 1);
|
||||||
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
|
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
|
||||||
$mem_percent_sort = $mem_percent_numb;
|
$mem_percent_sort = $mem_percent_numb;
|
||||||
|
|
||||||
if ($mem_percent_numb <= 89) {
|
if ($mem_percent_numb <= 89) {
|
||||||
$mem_demand_text_color = 'success';
|
$mem_demand_text_color = 'success';
|
||||||
}
|
}
|
||||||
if ($mem_percent_numb > 89) {
|
if ($mem_percent_numb > 89) {
|
||||||
$mem_demand_text_color = 'secondary';
|
$mem_demand_text_color = 'secondary';
|
||||||
}
|
}
|
||||||
if ($mem_percent_numb > 99) {
|
if ($mem_percent_numb > 99) {
|
||||||
$mem_demand_text_color = 'danger';
|
$mem_demand_text_color = 'danger';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$mem_demand = "N/A";
|
$mem_demand = "N/A";
|
||||||
$mem_percent_numb = 'N/A';
|
$mem_percent_numb = 'N/A';
|
||||||
$mem_percent_sort = -1;
|
$mem_percent_sort = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# disks
|
# disks
|
||||||
$disks = json_decode($server_data['server_disks'], true);
|
$disks = json_decode($server_data['server_disks'], true);
|
||||||
$totalDiskSpace = 0;
|
$totalDiskSpace = 0;
|
||||||
if (is_array($disks)) {
|
if (is_array($disks)) {
|
||||||
foreach ($disks as $disk) {
|
foreach ($disks as $disk) {
|
||||||
$totalDiskSpace += $disk['disk_space'];
|
$totalDiskSpace += $disk['disk_space'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($disks) && count($disks) > 0) {
|
if (is_array($disks) && count($disks) > 0) {
|
||||||
$sizes = array_column($disks, 'disk_space');
|
$sizes = array_column($disks, 'disk_space');
|
||||||
$totalDiskSpace = array_sum($sizes);
|
$totalDiskSpace = array_sum($sizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
$server_state_color = returnServerStateColor($server_data['server_state']);
|
$server_state_color = returnServerStateColor($server_data['server_state']);
|
||||||
|
|
||||||
# Licences
|
# Licences
|
||||||
$licenses = json_decode($server_data['server_licenses'], true);
|
$licenses = json_decode($server_data['server_licenses'], true);
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
# OS Logo display
|
# OS Logo display
|
||||||
$baseos = strtolower(explode(' ', $server_data['server_os'])[0]);
|
$baseos = strtolower(explode(' ', $server_data['server_os'])[0]);
|
||||||
$logos = [
|
$logos = [
|
||||||
'almalinux' => 'almalinux',
|
'almalinux' => 'almalinux',
|
||||||
'centos' => 'centos',
|
'centos' => 'centos',
|
||||||
];
|
];
|
||||||
$logo = $logos[$baseos] ?? 'server';
|
$logo = $logos[$baseos] ?? 'server';
|
||||||
|
|
||||||
if ($API->checkPermissions('servers', 'RW', true)) {
|
if ($API->checkPermissions('servers', 'RW', true)) {
|
||||||
$pageNavbar->AddHTMLButton(
|
$pageNavbar->AddHTMLButton(
|
||||||
'<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
|
'<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
|
||||||
<input type="hidden" name="_method" value="POST">
|
<input type="hidden" name="_method" value="POST">
|
||||||
<input type="hidden" name="_return" value="/servers?view=' . $server_data['server_uuid'] . '">
|
<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'] . '"/>' .
|
<input type="hidden" name="server_vm_id" value="' . $server_data['server_vm_id'] . '"/>' .
|
||||||
(
|
(
|
||||||
$server_data['server_state'] != 'deleted'
|
$server_data['server_state'] != 'deleted'
|
||||||
? '<input type="hidden" name="server_state" value="deleted">
|
? '<input type="hidden" name="server_state" value="deleted">
|
||||||
<button class="btn btn-danger w-100">
|
<button class="btn btn-danger w-100">
|
||||||
<i class="fas fa-trash-alt"></i> Delete
|
<i class="fas fa-trash-alt"></i> Delete
|
||||||
</button>'
|
</button>'
|
||||||
: '<input type="hidden" name="server_state" value="disabled">
|
: '<input type="hidden" name="server_state" value="disabled">
|
||||||
<button class="btn btn-primary w-100">
|
<button class="btn btn-primary w-100">
|
||||||
<i class="fa-solid fa-clock-rotate-left"></i> Restore
|
<i class="fa-solid fa-clock-rotate-left"></i> Restore
|
||||||
</button>'
|
</button>'
|
||||||
) .
|
) .
|
||||||
'</form>'
|
'</form>'
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
# Set breadcrumb data
|
# Set breadcrumb data
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('server_overview'), 'href' => '/servers/'));
|
array_push($GLOBALS['breadCrumbArray'], array('display' => __('server_overview'), 'href' => '/servers/'));
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => $server_data['server_vm_host_name'], 'href' => ''));
|
array_push($GLOBALS['breadCrumbArray'], array('display' => $server_data['server_vm_host_name'], 'href' => ''));
|
||||||
|
|
||||||
# Start page output
|
# Start page output
|
||||||
$pageNavbar->outPutNavbar();
|
$pageNavbar->outPutNavbar();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1>
|
<h1>
|
||||||
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"> </i> <?php echo $server_data['server_vm_host_name'] ?>
|
<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>
|
<span class="badge bg-<?php echo $server_state_color ?> fs-4 align-middle"><?php echo ucfirst($server_data['server_state']) ?></span>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row pb-5">
|
<div class="row pb-5">
|
||||||
<div class="col-md-3 col-lg-3">
|
<div class="col-md-3 col-lg-3">
|
||||||
<h2><?php echo $server_data['server_os'] ?></h2>
|
<h2><?php echo $server_data['server_os'] ?></h2>
|
||||||
<img class="img-fluid os-logo" src="/src/images/os/<?php echo $logo ?>.svg">
|
<img class="img-fluid os-logo" src="/src/images/os/<?php echo $logo ?>.svg">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-auto col-md-auto">
|
<div class="col-lg-auto col-md-auto">
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
|
<form id="FormValidation" enctype="multipart/form-data" method="post" action="/api/v1/servers/">
|
||||||
<input type="hidden" name="_method" value="POST">
|
<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="_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'] ?>"/>
|
<input type="hidden" name="server_vm_id" value="<?php echo $server_data['server_vm_id'] ?>"/>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
|
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<?php echo (strlen($server_data['server_cpu']) > 0) ? $server_data['server_cpu'] . 'x' : ''; ?>
|
<?php echo (strlen($server_data['server_cpu']) > 0) ? $server_data['server_cpu'] . 'x' : ''; ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
|
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<?php echo (strlen($server_data['server_memory']) > 0) ? $server_data['server_memory'] . 'MB' : ''; ?>
|
<?php echo (strlen($server_data['server_memory']) > 0) ? $server_data['server_memory'] . 'MB' : ''; ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
|
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
<td class="mx-3">
|
<td class="mx-3">
|
||||||
<h4>
|
<h4>
|
||||||
<?php
|
<?php
|
||||||
if (is_array($disks) && count($disks) > 0) {
|
if (is_array($disks) && count($disks) > 0) {
|
||||||
if (count($sizes) === 1) {
|
if (count($sizes) === 1) {
|
||||||
echo $sizes[0] . 'GB';
|
echo $sizes[0] . 'GB';
|
||||||
} else {
|
} else {
|
||||||
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
|
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
|
||||||
}
|
}
|
||||||
} ?>
|
} ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($GLOBALS['modules_enabled']['customers']) { ?>
|
<?php if ($GLOBALS['modules_enabled']['customers']) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<i class="fas fa-building"></i> <?php echo __('company') ?>
|
<i class="fas fa-building"></i> <?php echo __('company') ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
|
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
|
||||||
|
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<select id="company_uuid" name="company_uuid" class="form-control">
|
<select id="company_uuid" name="company_uuid" class="form-control">
|
||||||
<option></option>
|
<option></option>
|
||||||
<?php foreach ($companies as $company) { ?>
|
<?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>
|
<option <?php echo ($server_data['company_uuid'] == $company['company_uuid']) ? 'selected' : '' ?> value="<?php echo $company['company_uuid'] ?>"><?php echo $company['company_name'] ?></option>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<h4>
|
<h4>
|
||||||
<?php
|
<?php
|
||||||
$companyMap = array_column($companies, 'company_name', 'company_uuid');
|
$companyMap = array_column($companies, 'company_name', 'company_uuid');
|
||||||
echo $companyMap[$server_data['company_uuid']] ?? null;
|
echo $companyMap[$server_data['company_uuid']] ?? null;
|
||||||
?>
|
?>
|
||||||
</h4>
|
</h4>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<i class="fa-solid fa-circle-dot"></i> <?php echo __('server_state') ?>
|
<i class="fa-solid fa-circle-dot"></i> <?php echo __('server_state') ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php if ($API->checkPermissions('servers', 'RW', true)) {
|
<?php if ($API->checkPermissions('servers', 'RW', true)) {
|
||||||
if ($server_data['server_state'] != 'deleted') { ?>
|
if ($server_data['server_state'] != 'deleted') { ?>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<select id="server_state" class="form-control" onchange="this.name = this.value ? 'server_state' : '';">
|
<select id="server_state" class="form-control" onchange="this.name = this.value ? 'server_state' : '';">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option <?php echo ($server_data['server_state'] == 'active') ? 'selected' : '' ?> value="active">Active</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'] == 'trial') ? 'selected' : '' ?> value="trial">Trial</option>
|
||||||
<option <?php echo ($server_data['server_state'] == 'disabled') ? 'selected' : '' ?> value="disabled">Disabled</option>
|
<option <?php echo ($server_data['server_state'] == 'disabled') ? 'selected' : '' ?> value="disabled">Disabled</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<h4>
|
<h4>
|
||||||
<?php echo ucfirst($server_data['server_state']) ?>
|
<?php echo ucfirst($server_data['server_state']) ?>
|
||||||
</h4>
|
</h4>
|
||||||
<?php }
|
<?php }
|
||||||
} else { ?>
|
} else { ?>
|
||||||
<h4>
|
<h4>
|
||||||
<?php echo ucfirst($server_data['server_state']) ?>
|
<?php echo ucfirst($server_data['server_state']) ?>
|
||||||
</h4>
|
</h4>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<i class="fa-regular fa-clock"></i> <?php echo __('last_update') ?>
|
<i class="fa-regular fa-clock"></i> <?php echo __('last_update') ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<h4>
|
<h4>
|
||||||
<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>
|
<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>
|
||||||
</h4>
|
</h4>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
|
<?php if ($API->checkPermissions('servers', 'RW', true)) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-rounded btn-success w-100">
|
<button class="btn btn-rounded btn-success w-100">
|
||||||
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
|
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</form>
|
</form>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (is_array($disks) && count($disks) > 0) { ?>
|
<?php if (is_array($disks) && count($disks) > 0) { ?>
|
||||||
<h2 class="">
|
<h2 class="">
|
||||||
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo __('server_disks') ?>
|
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo __('server_disks') ?>
|
||||||
</h2>
|
</h2>
|
||||||
<div id="accordion">
|
<div id="accordion">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<?php foreach ($disks as $disk) { ?>
|
<?php foreach ($disks as $i => $disk) {
|
||||||
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $disk['disk_name'] ?>">
|
$collapseId = 'collapseDisk' . $i; ?>
|
||||||
<div class="card-header py-1" id="heading<?php echo $disk['disk_name'] ?>">
|
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo $collapseId ?>">
|
||||||
<h4 class="mb-0">
|
<div class="card-header py-1" id="heading<?php echo $collapseId ?>">
|
||||||
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo $disk['disk_name'] ?>
|
<h4 class="mb-0">
|
||||||
</h4>
|
<i class="fa-solid fa-hard-drive text-secondary"></i> <?php echo $disk['disk_name'] ?>
|
||||||
</div>
|
</h4>
|
||||||
</a>
|
</div>
|
||||||
|
</a>
|
||||||
<div id="collapse<?php echo $disk['disk_name'] ?>" class="collapse" data-parent="#accordion">
|
|
||||||
<div class="card-body">
|
<div id="collapse<?php echo $collapseId ?>" class="collapse" data-parent="#accordion">
|
||||||
<table class="table table-borderless table-sm">
|
<div class="card-body">
|
||||||
<tr>
|
<table class="table table-borderless table-sm">
|
||||||
<td><?php echo __('disk_space') ?>:</td>
|
<tr>
|
||||||
<td><?php echo $disk['disk_space'] ?>GB</td>
|
<td><?php echo __('disk_space') ?>:</td>
|
||||||
</tr>
|
<td><?php echo $disk['disk_space'] ?>GB</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td><?php echo __('disk_file_used') ?>:</td>
|
<tr>
|
||||||
<td><?php echo $disk['disk_used'] ?>GB</td>
|
<td><?php echo __('disk_file_used') ?>:</td>
|
||||||
</tr>
|
<td><?php echo $disk['disk_used'] ?>GB</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td><?php echo __('disk_location') ?>:</td>
|
<tr>
|
||||||
<td><?php echo $disk['disk_location'] ?></td>
|
<td><?php echo __('disk_location') ?>:</td>
|
||||||
</tr>
|
<td><?php echo $disk['disk_location'] ?></td>
|
||||||
</table>
|
</tr>
|
||||||
</div>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
</div>
|
||||||
} ?>
|
<?php
|
||||||
</div>
|
} ?>
|
||||||
</div>
|
</div>
|
||||||
<?php }
|
</div>
|
||||||
|
<?php }
|
||||||
|
|
||||||
if (is_array($licenses) && count($licenses) > 0) { ?>
|
|
||||||
<h2>
|
if (is_array($licenses) && count($licenses) > 0) { ?>
|
||||||
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo __('server_licenses') ?>
|
<h2>
|
||||||
</h2>
|
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo __('server_licenses') ?>
|
||||||
<div id="accordion">
|
</h2>
|
||||||
<div class="card">
|
<div id="accordion">
|
||||||
<?php foreach ($licenses as $key => $licence) { ?>
|
<div class="card">
|
||||||
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo array_key_first($licence) ?>">
|
<?php foreach ($licenses as $key => $licence) { ?>
|
||||||
<div class="card-header py-1" id="heading<?php echo array_key_first($licence) ?>">
|
<a data-bs-toggle="collapse" data-bs-target="#collapse<?php echo array_key_first($licence) ?>">
|
||||||
<h4 class="mb-0">
|
<div class="card-header py-1" id="heading<?php echo array_key_first($licence) ?>">
|
||||||
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo ucfirst(array_key_first($licence)) ?>
|
<h4 class="mb-0">
|
||||||
</h4>
|
<i class="fa-solid fa-file-invoice-dollar text-success"></i> <?php echo ucfirst(array_key_first($licence)) ?>
|
||||||
</div>
|
</h4>
|
||||||
</a>
|
</div>
|
||||||
|
</a>
|
||||||
<div id="collapse<?php echo array_key_first($licence) ?>" class="collapse" data-parent="#accordion">
|
|
||||||
<div class="card-body">
|
<div id="collapse<?php echo array_key_first($licence) ?>" class="collapse" data-parent="#accordion">
|
||||||
<?php echo __('type') . ': ' . end($licence) ?>
|
<div class="card-body">
|
||||||
</div>
|
<?php echo __('type') . ': ' . end($licence) ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
</div>
|
||||||
} ?>
|
<?php
|
||||||
</div>
|
} ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<h1 class="pt-5"><?php echo __('all_technical_information') ?></h1>
|
|
||||||
<div class="col-md-12 col-lg-12">
|
<h1 class="pt-5"><?php echo __('all_technical_information') ?></h1>
|
||||||
<table class="table table-borderless table-sm table-responsive">
|
<div class="col-md-12 col-lg-12">
|
||||||
<tr>
|
<table class="table table-borderless table-sm table-responsive">
|
||||||
<td>server_uuid:</td>
|
<tr>
|
||||||
<td class="w-100"><?php echo $server_data['server_uuid'] ?></td>
|
<td>server_uuid:</td>
|
||||||
</tr>
|
<td class="w-100"><?php echo $server_data['server_uuid'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>company_uuid:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['company_uuid'] ?></td>
|
<td>company_uuid:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['company_uuid'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_vm_id:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_vm_id'] ?></td>
|
<td>server_vm_id:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_vm_id'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_vm_host_name:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_vm_host_name'] ?></td>
|
<td>server_vm_host_name:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_vm_host_name'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_vm_snapshot:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_vm_snapshot'] ?></td>
|
<td>server_vm_snapshot:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_vm_snapshot'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_vm_generation:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_vm_generation'] ?></td>
|
<td>server_vm_generation:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_vm_generation'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_power_state:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_power_state'] ?></td>
|
<td>server_power_state:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_power_state'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_state:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_state'] ?></td>
|
<td>server_state:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_state'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_hostname:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_hostname'] ?></td>
|
<td>server_hostname:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_hostname'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_os:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_os'] ?></td>
|
<td>server_os:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_os'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_cpu:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_cpu'] ?></td>
|
<td>server_cpu:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_cpu'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_memory:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_memory'] ?></td>
|
<td>server_memory:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_memory'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_memory_demand:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_memory_demand'] ?></td>
|
<td>server_memory_demand:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_memory_demand'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_disks:</td>
|
<tr>
|
||||||
<td>
|
<td>server_disks:</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>
|
||||||
</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>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_ipv4:</td>
|
<tr>
|
||||||
<td>
|
<td>server_ipv4:</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>
|
||||||
</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>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_ipv6:</td>
|
<tr>
|
||||||
<td>
|
<td>server_ipv6:</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>
|
||||||
</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>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_licenses:</td>
|
<tr>
|
||||||
<td>
|
<td>server_licenses:</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>
|
||||||
</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>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_backup:</td>
|
<tr>
|
||||||
<td>
|
<td>server_backup:</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>
|
||||||
</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>
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_description:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_description'] ?></td>
|
<td>server_description:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_description'] ?></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>server_create_timestamp:</td>
|
<tr>
|
||||||
<td><?php echo $server_data['server_create_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_create_timestamp']) ?>)</td>
|
<td>server_create_timestamp:</td>
|
||||||
</tr>
|
<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>
|
<tr>
|
||||||
<td><?php echo $server_data['server_modified_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>)</td>
|
<td>server_modified_timestamp:</td>
|
||||||
</tr>
|
<td><?php echo $server_data['server_modified_timestamp'] ?> (<?php echo date('Y-m-d H:i:s', $server_data['server_modified_timestamp']) ?>)</td>
|
||||||
</table>
|
</tr>
|
||||||
</div>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -1,67 +1,67 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_servers;
|
use api\classes\API_servers;
|
||||||
use bin\php\Classes\serverOverviewBuilder;
|
use bin\php\Classes\serverOverviewBuilder;
|
||||||
|
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$GLOBALS['modules_enabled']['servers']) {
|
if (!$GLOBALS['modules_enabled']['servers']) {
|
||||||
echo '405 Not Allowed';
|
echo '405 Not Allowed';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
# IDE Section
|
# IDE Section
|
||||||
|
|
||||||
# Includes Section
|
# Includes Section
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_servers.php';
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/serverOverviewBuilder.php');
|
||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
$API_servers = new API_servers();
|
$API_servers = new API_servers();
|
||||||
if (!$API_servers->checkPermissions('servers', 'RO', true)) {
|
if (!$API_servers->checkPermissions('servers', 'RO', true)) {
|
||||||
echo 'error 401 unauthorized';
|
echo 'error 401 unauthorized';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Page functions
|
# Page functions
|
||||||
|
|
||||||
# JS Scripts to load for this page
|
# JS Scripts to load for this page
|
||||||
$jsScriptLoadData['delete_confirmation'] = true;
|
$jsScriptLoadData['delete_confirmation'] = true;
|
||||||
$jsScriptLoadData['datatables'] = true;
|
$jsScriptLoadData['datatables'] = true;
|
||||||
$jsScriptLoadData['multiFilterSelectServers'] = true;
|
$jsScriptLoadData['multiFilterSelectServers'] = true;
|
||||||
|
|
||||||
# PageClasses Setup
|
# PageClasses Setup
|
||||||
$serverOverview = new serverOverviewBuilder();
|
$serverOverview = new serverOverviewBuilder();
|
||||||
|
|
||||||
# Retrieve Information for the page
|
# Retrieve Information for the page
|
||||||
if (!isset($_GET['del'])) {
|
if (!isset($_GET['del'])) {
|
||||||
if ($GLOBALS['modules_enabled']['customers']) {
|
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'";
|
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid WHERE servers.server_state != 'deleted'";
|
||||||
} else {
|
} else {
|
||||||
$API_servers->baseQuery = "SELECT * FROM servers WHERE servers.server_state != 'deleted'";
|
$API_servers->baseQuery = "SELECT * FROM servers WHERE servers.server_state != 'deleted'";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ($GLOBALS['modules_enabled']['customers']) {
|
if ($GLOBALS['modules_enabled']['customers']) {
|
||||||
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid";
|
$API_servers->baseQuery = "SELECT * FROM servers LEFT JOIN companies ON companies.company_uuid = servers.company_uuid";
|
||||||
} else {
|
} else {
|
||||||
$API_servers->baseQuery = "SELECT * FROM servers";
|
$API_servers->baseQuery = "SELECT * FROM servers";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$servers_data = $API_servers->getServers();
|
$servers_data = $API_servers->getServers();
|
||||||
$serverOverview->servers = $servers_data;
|
$serverOverview->servers = $servers_data;
|
||||||
$serverOverview->processServerData();
|
$serverOverview->processServerData();
|
||||||
if (!$GLOBALS['modules_enabled']['customers']) {
|
if (!$GLOBALS['modules_enabled']['customers']) {
|
||||||
$serverOverview->showCompanies = false;
|
$serverOverview->showCompanies = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set breadcrumb data
|
# Set breadcrumb data
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
|
array_push($GLOBALS['breadCrumbArray'], array('display' => __('permission'), 'href' => '/accesscontrol/#permissions'));
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('view'), 'href' => ''));
|
array_push($GLOBALS['breadCrumbArray'], array('display' => __('view'), 'href' => ''));
|
||||||
|
|
||||||
# Start page output
|
# Start page output
|
||||||
$serverOverview->serverOverviewOutPut();
|
$serverOverview->serverOverviewOutPut();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
@@ -1,173 +1,173 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API_usergroups;
|
use api\classes\API_usergroups;
|
||||||
use bin\php\Classes\pageNavbar;
|
use bin\php\Classes\pageNavbar;
|
||||||
|
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
# IDE Section
|
# IDE Section
|
||||||
|
|
||||||
# Includes Section
|
# Includes Section
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usergroups.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_usergroups.php');
|
||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
$API = new API_usergroups();
|
$API = new API_usergroups();
|
||||||
if (!$API->checkPermissions('admin-access-control-user-groups', 'RO', true)) {
|
if (!$API->checkPermissions('admin-access-control-user-groups', 'RO', true)) {
|
||||||
echo 'error 401 unauthorized';
|
echo 'error 401 unauthorized';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Page functions
|
# Page functions
|
||||||
|
|
||||||
# JS Scripts to load for this page
|
# JS Scripts to load for this page
|
||||||
$jsScriptLoadData['breadCrumbs'] = true;
|
$jsScriptLoadData['breadCrumbs'] = true;
|
||||||
$jsScriptLoadData['updatePermissions'] = true;
|
$jsScriptLoadData['updatePermissions'] = true;
|
||||||
|
|
||||||
# PageClasses Setup
|
# PageClasses Setup
|
||||||
$pageNavbar = new pageNavbar(true);
|
$pageNavbar = new pageNavbar(true);
|
||||||
|
|
||||||
# Retrieve Information for the page
|
# Retrieve Information for the page
|
||||||
|
|
||||||
$user_group_uuid = htmlspecialchars($_GET['user_group_view'], ENT_QUOTES, 'UTF-8');
|
$user_group_uuid = htmlspecialchars($_GET['user_group_view'], ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
$_GET['user_group_uuid'] = $user_group_uuid;
|
$_GET['user_group_uuid'] = $user_group_uuid;
|
||||||
$API_usergroups = new API_usergroups();
|
$API_usergroups = new API_usergroups();
|
||||||
$_GET['builder'] = [1 => ['where' => [0 => 'user_group_uuid', 1 => $user_group_uuid]]];
|
$_GET['builder'] = [1 => ['where' => [0 => 'user_group_uuid', 1 => $user_group_uuid]]];
|
||||||
$requiredFields = ['user_group_uuid' => ['type' => 'uuid']];
|
$requiredFields = ['user_group_uuid' => ['type' => 'uuid']];
|
||||||
$API_usergroups->validateData($requiredFields);
|
$API_usergroups->validateData($requiredFields);
|
||||||
$user_group = $API_usergroups->getUsergroup()[0];
|
$user_group = $API_usergroups->getUsergroup()[0];
|
||||||
|
|
||||||
$query = "SELECT * FROM vc_user_group_permissions_portal
|
$query = "SELECT * FROM vc_user_group_permissions_portal
|
||||||
INNER JOIN vc_permissions ON vc_user_group_permissions_portal.permission_uuid = vc_permissions.permission_uuid
|
INNER JOIN vc_permissions ON vc_user_group_permissions_portal.permission_uuid = vc_permissions.permission_uuid
|
||||||
WHERE user_group_uuid = ?";
|
WHERE user_group_uuid = ?";
|
||||||
$stmt = $GLOBALS['pdo']->prepare($query);
|
$stmt = $GLOBALS['pdo']->prepare($query);
|
||||||
$stmt->execute([$user_group_uuid]);
|
$stmt->execute([$user_group_uuid]);
|
||||||
$group_permissions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$group_permissions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
# Set breadcrumb data
|
# Set breadcrumb data
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('user_gr1oups'), 'href' => '/accesscontrol/#user-groups'));
|
array_push($GLOBALS['breadCrumbArray'], array('display' => __('user_groups'), 'href' => '/accesscontrol/#user-groups'));
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => $user_group['user_group_name'], 'href' => ''));
|
array_push($GLOBALS['breadCrumbArray'], array('display' => $user_group['user_group_name'], 'href' => ''));
|
||||||
|
|
||||||
# Start page output
|
# Start page output
|
||||||
$pageNavbar->outPutNavbar();
|
$pageNavbar->outPutNavbar();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1>
|
<h1>
|
||||||
<i class="fa-solid fa-user-group"></i> <?php echo __('user_group') . ': ' . $user_group['user_group_name'] ?>
|
<i class="fa-solid fa-user-group"></i> <?php echo __('user_group') . ': ' . $user_group['user_group_name'] ?>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 col-lg-6">
|
<div class="col-md-6 col-lg-6">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>user_group_uuid:</td>
|
<td>user_group_uuid:</td>
|
||||||
<td><?php echo $user_group['user_group_uuid'] ?></td>
|
<td><?php echo $user_group['user_group_uuid'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>user_group_name:</td>
|
<td>user_group_name:</td>
|
||||||
<td><?php echo $user_group['user_group_name'] ?></td>
|
<td><?php echo $user_group['user_group_name'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>user_group_slugify:</td>
|
<td>user_group_slugify:</td>
|
||||||
<td><?php echo $user_group['user_group_slugify'] ?></td>
|
<td><?php echo $user_group['user_group_slugify'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>user_group_type:</td>
|
<td>user_group_type:</td>
|
||||||
<td><?php echo $user_group['user_group_type'] ?></td>
|
<td><?php echo $user_group['user_group_type'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>user_group_weight:</td>
|
<td>user_group_weight:</td>
|
||||||
<td><?php echo $user_group['user_group_weight'] ?></td>
|
<td><?php echo $user_group['user_group_weight'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>user_group_create_timestamp:</td>
|
<td>user_group_create_timestamp:</td>
|
||||||
<td><?php echo $user_group['user_group_create_timestamp'] ?></td>
|
<td><?php echo $user_group['user_group_create_timestamp'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>user_group_modified_timestamp:</td>
|
<td>user_group_modified_timestamp:</td>
|
||||||
<td><?php echo $user_group['user_group_modified_timestamp'] ?></td>
|
<td><?php echo $user_group['user_group_modified_timestamp'] ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h1>
|
<h1>
|
||||||
<i class="fa-solid fa-lock"></i> <?php echo __('permission') ?>
|
<i class="fa-solid fa-lock"></i> <?php echo __('permission') ?>
|
||||||
</h1>
|
</h1>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,5">
|
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="0,5">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo __('user_group') ?></th>
|
<th><?php echo __('user_group') ?></th>
|
||||||
<th><?php echo __('NA') ?></th>
|
<th><?php echo __('NA') ?></th>
|
||||||
<th><?php echo __('RO') ?></th>
|
<th><?php echo __('RO') ?></th>
|
||||||
<th><?php echo __('RW') ?></th>
|
<th><?php echo __('RW') ?></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo __('user_group') ?></th>
|
<th><?php echo __('user_group') ?></th>
|
||||||
<th><?php echo __('NA') ?></th>
|
<th><?php echo __('NA') ?></th>
|
||||||
<th><?php echo __('RO') ?></th>
|
<th><?php echo __('RO') ?></th>
|
||||||
<th><?php echo __('RW') ?></th>
|
<th><?php echo __('RW') ?></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach ($group_permissions as $group_permissions_data) { ?>
|
foreach ($group_permissions as $group_permissions_data) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $group_permissions_data['permission_name'] ?> </td>
|
<td><?php echo $group_permissions_data['permission_name'] ?> </td>
|
||||||
<td>
|
<td>
|
||||||
<label class="switch">
|
<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' : '') ?>
|
<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' ?>>
|
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
|
||||||
<div class="slider"></div>
|
<div class="slider"></div>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label class="switch">
|
<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' : '') ?>
|
<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' ?>>
|
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
|
||||||
<div class="slider"></div>
|
<div class="slider"></div>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label class="switch">
|
<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' : '') ?>
|
<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' ?>>
|
<?php echo ($API->checkPermissions('admin-access-control-permissions', 'RW', true)) ? '' : 'disabled' ?>>
|
||||||
<div class="slider"></div>
|
<div class="slider"></div>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
<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>
|
<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>
|
</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 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-dialog modal-dialog-centered modal-lg">
|
||||||
<div class="modal-content bg-black2">
|
<div class="modal-content bg-black2">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title" id="infoModalLabel">
|
<h5 class="modal-title" id="infoModalLabel">
|
||||||
<i class="fas fa-info-circle"></i> <?php echo __('information') ?>
|
<i class="fas fa-info-circle"></i> <?php echo __('information') ?>
|
||||||
</h5>
|
</h5>
|
||||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<?php echo $group_permissions_data['permission_description'] ?>
|
<?php echo $group_permissions_data['permission_description'] ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,161 +1,167 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use api\classes\API;
|
use api\classes\API;
|
||||||
use bin\php\Classes\pageNavbar;
|
use bin\php\Classes\pageNavbar;
|
||||||
|
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
# IDE Section
|
# IDE Section
|
||||||
|
|
||||||
|
|
||||||
# Includes Section
|
# Includes Section
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/pageNavbar.php');
|
||||||
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
include_once($_SERVER['DOCUMENT_ROOT'] . '/api/classes/API.php');
|
||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
$API = new API();
|
$API = new API();
|
||||||
$API->checkPermissions('admin-sources', 'RO');
|
$API->checkPermissions('admin-sources', 'RO');
|
||||||
|
|
||||||
# Page functions
|
# Page functions
|
||||||
|
|
||||||
|
|
||||||
# JS Scripts to load for this page
|
# JS Scripts to load for this page
|
||||||
$jsScriptLoadData['activeTabOnRefresh'] = true;
|
$jsScriptLoadData['activeTabOnRefresh'] = true;
|
||||||
$jsScriptLoadData['copyInputValue'] = true;
|
$jsScriptLoadData['copyInputValue'] = true;
|
||||||
$jsScriptLoadData['updateToggle'] = true;
|
$jsScriptLoadData['updateToggle'] = true;
|
||||||
$jsScriptLoadData['breadCrumbs'] = true;
|
$jsScriptLoadData['breadCrumbs'] = true;
|
||||||
$jsScriptLoadData['inserve_source'] = true;
|
$jsScriptLoadData['inserve_source'] = true;
|
||||||
$jsScriptLoadData['validateJson'] = true;
|
$jsScriptLoadData['validateJson'] = true;
|
||||||
|
|
||||||
# PageClasses Setup
|
# PageClasses Setup
|
||||||
$pageNavbar = new pageNavbar(true);
|
$pageNavbar = new pageNavbar(true);
|
||||||
|
|
||||||
# Retrieve Information for the page
|
# Retrieve Information for the page
|
||||||
$inserve_settings = $GLOBALS['conn']->query("SELECT * FROM system_sources WHERE source_name = 'inserve'")->fetch_assoc();
|
$inserve_settings = $GLOBALS['conn']->query("SELECT * FROM system_sources WHERE source_name = 'inserve'")->fetch_assoc();
|
||||||
|
|
||||||
# Set breadcrumb data
|
# Set breadcrumb data
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => __('portal_management'), 'href' => '/systemconfig'));
|
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' => __('sources'), 'href' => '/systemconfig#sources'));
|
||||||
array_push($GLOBALS['breadCrumbArray'], array('display' => 'Inserve', 'href' => ''));
|
array_push($GLOBALS['breadCrumbArray'], array('display' => 'Inserve', 'href' => ''));
|
||||||
|
|
||||||
|
|
||||||
# Start page output
|
# Start page output
|
||||||
$pageNavbar->outPutNavbar();
|
$pageNavbar->outPutNavbar();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-lg-12">
|
<div class="col-md-12 col-lg-12">
|
||||||
<div class="tab-content" id="v-pills-with-icon-tabContent">
|
<div class="tab-content" id="v-pills-with-icon-tabContent">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="mx-2 pb-0 card-body">
|
<div class="mx-2 pb-0 card-body">
|
||||||
<h1 class="">Inserve settings</h1>
|
<h1 class="">Inserve settings</h1>
|
||||||
<p>
|
<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>
|
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>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="FormValidation" method="post" action="/api/v1/system/sources/inserve/">
|
<form id="FormValidation" method="post" action="/api/v1/system/sources/inserve/">
|
||||||
<input type="hidden" name="_method" value="POST">
|
<input type="hidden" name="_method" value="POST">
|
||||||
<input type="hidden" name="_return" value="/system/sources/inserve">
|
<input type="hidden" name="_return" value="/system/sources/inserve">
|
||||||
<input type="hidden" name="source_name" value="inserve">
|
<input type="hidden" name="source_name" value="inserve">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<div class="form-group form-show-validation row">
|
<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>
|
<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">
|
<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/>
|
<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>
|
</div>
|
||||||
|
|
||||||
<div class="form-group form-show-validation row">
|
<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>
|
<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">
|
<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/>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer py-4">
|
<div class="card-footer py-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col d-flex justify-content-end">
|
<div class="col d-flex justify-content-end">
|
||||||
<button class="btn btn-success mx-2 test-inserve-connection-btn">
|
<button class="btn btn-success mx-2 test-inserve-connection-btn">
|
||||||
<i class="fa-solid fa-spell-check"></i> <?php echo __('test_connection') ?>
|
<i class="fa-solid fa-spell-check"></i> <?php echo __('test_connection') ?>
|
||||||
</button>
|
</button>
|
||||||
<?php if ($API->checkPermissions('admin-sources', 'RW', true)) { ?>
|
<?php if ($API->checkPermissions('admin-sources', 'RW', true)) { ?>
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
|
<i class="fa-solid fa-floppy-disk"></i> <?php echo __('save') ?>
|
||||||
</button>
|
</button>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 col-lg-12">
|
<div class="col-md-12 col-lg-12">
|
||||||
<div class="tab-content" id="v-pills-with-icon-tabContent">
|
<div class="tab-content" id="v-pills-with-icon-tabContent">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h1 class="">Inserve actions</h1>
|
<h1 class="">Inserve actions</h1>
|
||||||
<hr>
|
<div class="row row-cols-1 row-cols-md-3 g-2">
|
||||||
<div class="row row-cols-1 row-cols-md-3 g-2">
|
<?php if ($GLOBALS['modules_enabled']['customers'] && $API->checkPermissions('customer-companies', 'RW', true)) { ?>
|
||||||
<?php if ($GLOBALS['modules_enabled']['customers'] && $API->checkPermissions('customer-companies', 'RW', true)) { ?>
|
<div class="col">
|
||||||
<div class="col">
|
<div class="card h-100">
|
||||||
<div class="card h-100">
|
<div class="card-body">
|
||||||
<div class="card-body">
|
<h5 class="card-title">Sync companies from Inserve to Sentri.</h5>
|
||||||
<h5 class="card-title">Sync companies from Inserve to Sentri.</h5>
|
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
|
||||||
<form method="post" action="/api/v1/sources/inserve/sync-companies/">
|
<input type="hidden" name="_return" value="/system/sources/inserve">
|
||||||
<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>
|
||||||
<p class="card-text">This API call retrieves all companies from Inserve and creates or updates them in Sentri.</p>
|
</form>
|
||||||
<button class="btn btn-primary">
|
</div>
|
||||||
<i class="fa-solid fa-arrow-rotate-right"></i> Sync.
|
<div class="card-footer">
|
||||||
</button>
|
<button class="btn btn-primary">
|
||||||
</form>
|
<i class="fa-solid fa-arrow-rotate-right"></i> Sync.
|
||||||
</div>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
|
|
||||||
<div class="col">
|
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
|
||||||
<div class="card h-100">
|
<div class="col">
|
||||||
<div class="card-body">
|
<div class="card h-100">
|
||||||
<h5 class="card-title">Sync cloud distributor companies</h5>
|
<div class="card-body">
|
||||||
<form method="post" action="/api/v1/sources/inserve/sync-cloud-distributor/">
|
<h5 class="card-title">Sync cloud distributor companies</h5>
|
||||||
<input type="hidden" name="_return" value="/system/sources/inserve">
|
<form method="post" action="/api/v1/sources/inserve/sync-cloud-distributor/">
|
||||||
<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>
|
<input type="hidden" name="_return" value="/system/sources/inserve">
|
||||||
<button class="btn btn-primary">
|
<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>
|
||||||
<i class="fa-solid fa-arrow-rotate-right"></i> Sync
|
</form>
|
||||||
</button>
|
</div>
|
||||||
</form>
|
<div class="card-footer">
|
||||||
</div>
|
<button class="btn btn-primary">
|
||||||
</div>
|
<i class="fa-solid fa-arrow-rotate-right"></i> Sync
|
||||||
</div>
|
</button>
|
||||||
<?php } ?>
|
</div>
|
||||||
|
</div>
|
||||||
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
|
</div>
|
||||||
<div class="col">
|
<?php } ?>
|
||||||
<div class="card h-100">
|
|
||||||
<div class="card-body">
|
<?php if ($GLOBALS['modules_enabled']['servers'] && $API->checkPermissions('servers', 'RW', true)) { ?>
|
||||||
<h5 class="card-title">Sync servers licenses</h5>
|
<div class="col">
|
||||||
<form method="post" action="/api/v1/sources/inserve/sync-server-licenses/">
|
<div class="card h-100">
|
||||||
<input type="hidden" name="_return" value="/system/sources/inserve">
|
<div class="card-body">
|
||||||
<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>
|
<h5 class="card-title">Sync servers licenses</h5>
|
||||||
<button class="btn btn-primary">
|
<form method="post" action="/api/v1/sources/inserve/sync-server-licenses/">
|
||||||
<i class="fa-solid fa-arrow-rotate-right"></i> Sync
|
<input type="hidden" name="_return" value="/system/sources/inserve">
|
||||||
</button>
|
<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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="card-footer">
|
||||||
</div>
|
<button class="btn btn-primary">
|
||||||
<?php } ?>
|
<i class="fa-solid fa-arrow-rotate-right"></i> Sync
|
||||||
</div>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,475 +1,484 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace bin\php\Classes;
|
namespace bin\php\Classes;
|
||||||
|
|
||||||
if (!defined('APP_INIT')) {
|
if (!defined('APP_INIT')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
class serverOverviewBuilder
|
class serverOverviewBuilder
|
||||||
{
|
{
|
||||||
public array $servers = [];
|
public array $servers = [];
|
||||||
|
|
||||||
public array $showColumns = array(
|
public array $showColumns = array(
|
||||||
'server_hostname' => false,
|
'server_hostname' => false,
|
||||||
'company_name' => false,
|
'company_name' => false,
|
||||||
'server_power_state' => false,
|
'server_power_state' => false,
|
||||||
'server_os' => false,
|
'server_os' => false,
|
||||||
'server_cpu' => false,
|
'server_cpu' => false,
|
||||||
'server_memory' => false,
|
'server_memory' => false,
|
||||||
'server_memory_demand' => false,
|
'server_memory_demand' => false,
|
||||||
'server_disks' => false,
|
'server_disks' => false,
|
||||||
'server_ipv4' => false,
|
'server_ipv4' => false,
|
||||||
'server_ipv6' => false,
|
'server_ipv6' => false,
|
||||||
'server_vm_snapshot' => false,
|
'server_vm_snapshot' => false,
|
||||||
'server_vm_generation' => false,
|
'server_vm_generation' => false,
|
||||||
'server_licenses' => false,
|
'server_licenses' => false,
|
||||||
'server_backup' => false,
|
'server_backup' => false,
|
||||||
'server_description' => false,
|
'server_description' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public array $allBackupTypes = [];
|
public array $allBackupTypes = [];
|
||||||
public array $allLicenseTypes = [];
|
public array $allLicenseTypes = [];
|
||||||
|
|
||||||
public bool $showDelBtn = true;
|
public bool $showDelBtn = true;
|
||||||
public bool $showServerOverviewTitle = true;
|
public bool $showServerOverviewTitle = true;
|
||||||
|
|
||||||
public bool $showCompanies = true;
|
public bool $showCompanies = true;
|
||||||
|
|
||||||
public function processServerData()
|
public function processServerData()
|
||||||
{
|
{
|
||||||
foreach ($this->servers as $server) {
|
foreach ($this->servers as $server) {
|
||||||
if (!empty($server['server_backup'])) {
|
if (!empty($server['server_backup'])) {
|
||||||
$backups = json_decode($server['server_backup'], true);
|
$backups = json_decode($server['server_backup'], true);
|
||||||
if (is_array($backups)) {
|
if (is_array($backups)) {
|
||||||
foreach ($backups as $item) {
|
foreach ($backups as $item) {
|
||||||
foreach ($item as $key => $value) {
|
foreach ($item as $key => $value) {
|
||||||
$this->allBackupTypes[$key] = true;
|
$this->allBackupTypes[$key] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($server['server_licenses'])) {
|
if (!empty($server['server_licenses'])) {
|
||||||
$licenses = json_decode($server['server_licenses'], true);
|
$licenses = json_decode($server['server_licenses'], true);
|
||||||
if (is_array($licenses)) {
|
if (is_array($licenses)) {
|
||||||
foreach ($licenses as $item) {
|
foreach ($licenses as $item) {
|
||||||
foreach ($item as $key => $value) {
|
foreach ($item as $key => $value) {
|
||||||
$this->allLicenseTypes[$key] = true;
|
$this->allLicenseTypes[$key] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->allBackupTypes = array_keys($this->allBackupTypes);
|
$this->allBackupTypes = array_keys($this->allBackupTypes);
|
||||||
sort($this->allBackupTypes);
|
sort($this->allBackupTypes);
|
||||||
|
|
||||||
$this->allLicenseTypes = array_keys($this->allLicenseTypes);
|
$this->allLicenseTypes = array_keys($this->allLicenseTypes);
|
||||||
sort($this->allLicenseTypes);
|
sort($this->allLicenseTypes);
|
||||||
|
|
||||||
|
|
||||||
if (isset($_COOKIE['serverTableColumns'])) {
|
if (isset($_COOKIE['serverTableColumns'])) {
|
||||||
$CheckedColumns = json_decode(htmlspecialchars(($_COOKIE['serverTableColumns']), true));
|
$CheckedColumns = json_decode(htmlspecialchars(($_COOKIE['serverTableColumns']), true));
|
||||||
foreach ($CheckedColumns as $CheckedColumn) {
|
foreach ($CheckedColumns as $CheckedColumn) {
|
||||||
$this->showColumns[$CheckedColumn] = true;
|
$this->showColumns[$CheckedColumn] = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->showColumns['server_hostname'] = true;
|
$this->showColumns['server_hostname'] = true;
|
||||||
$this->showColumns['company_name'] = true;
|
$this->showColumns['company_name'] = true;
|
||||||
$this->showColumns['server_os'] = true;
|
$this->showColumns['server_os'] = true;
|
||||||
$this->showColumns['server_cpu'] = true;
|
$this->showColumns['server_cpu'] = true;
|
||||||
$this->showColumns['server_memory'] = true;
|
$this->showColumns['server_memory'] = true;
|
||||||
$this->showColumns['server_memory_demand'] = true;
|
$this->showColumns['server_memory_demand'] = true;
|
||||||
$this->showColumns['server_disks'] = true;
|
$this->showColumns['server_disks'] = true;
|
||||||
$this->showColumns['server_state'] = true;
|
$this->showColumns['server_state'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cleanNumber($num)
|
private function cleanNumber($num)
|
||||||
{
|
{
|
||||||
// If integer value, return without formatting
|
// If integer value, return without formatting
|
||||||
if (floor($num) == $num) {
|
if (floor($num) == $num) {
|
||||||
return (string)$num;
|
return (string)$num;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise return trimmed float
|
// Otherwise return trimmed float
|
||||||
return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.');
|
return rtrim(rtrim(number_format($num, 10, '.', ''), '0'), '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serverOverviewOutPut()
|
public function serverOverviewOutPut()
|
||||||
{ ?>
|
{ ?>
|
||||||
<div class="form-group form-show-validation row mb-3">
|
<div class="form-group form-show-validation row mb-3">
|
||||||
<?php if ($this->showServerOverviewTitle) { ?>
|
<?php if ($this->showServerOverviewTitle) { ?>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<h2>
|
<h2>
|
||||||
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"></i> <?php echo __('server_overview') ?>
|
<i class="<?php echo $GLOBALS['pages']['servers']['server_overview']['page_icon'] ?>"></i> <?php echo __('server_overview') ?>
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<div class="col d-flex justify-content-end px-1">
|
<div class="col d-flex justify-content-end px-1">
|
||||||
<div class="selectgroup selectgroup-pills">
|
<div class="selectgroup selectgroup-pills">
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_state" class="selectgroup-input" <?php echo($this->showColumns['server_state'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_state') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_hostname" class="selectgroup-input" <?php echo($this->showColumns['server_hostname'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_hostname') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<?php if ($this->showCompanies) { ?>
|
<?php if ($this->showCompanies) { ?>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="company_name" class="selectgroup-input" <?php echo($this->showColumns['company_name'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('company') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_os" class="selectgroup-input" <?php echo($this->showColumns['server_os'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_os') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_cpu" class="selectgroup-input" <?php echo($this->showColumns['server_cpu'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_cpu') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_memory" class="selectgroup-input" <?php echo($this->showColumns['server_memory'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_memory') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_memory_demand" class="selectgroup-input" <?php echo($this->showColumns['server_memory_demand'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_memory_demand') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_disks" class="selectgroup-input" <?php echo($this->showColumns['server_disks'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_disks') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_ipv4" class="selectgroup-input" <?php echo($this->showColumns['server_ipv4'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_ipv4') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_ipv6" class="selectgroup-input" <?php echo($this->showColumns['server_ipv6'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_ipv6') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_vm_snapshot" class="selectgroup-input" <?php echo($this->showColumns['server_vm_snapshot'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_vm_snapshot') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_vm_generation" class="selectgroup-input" <?php echo($this->showColumns['server_vm_generation'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_vm_generation') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_licenses" class="selectgroup-input" <?php echo($this->showColumns['server_licenses'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_licenses') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_backup" class="selectgroup-input" <?php echo($this->showColumns['server_backup'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_backup') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_power_state" class="selectgroup-input" <?php echo($this->showColumns['server_power_state'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('server_power_state') ?></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="selectgroup-item">
|
<label class="selectgroup-item">
|
||||||
<input type="checkbox" name="value" value="server_description" class="selectgroup-input" <?php echo($this->showColumns['server_description'] ? 'checked=""' : '') ?>>
|
<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>
|
<span class="selectgroup-button"><?php echo __('description') ?></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php if ($this->showDelBtn) { ?>
|
<?php if ($this->showDelBtn) { ?>
|
||||||
<div class="col-lg-auto col-md-auto col-sm-auto">
|
<div class="col-lg-auto col-md-auto col-sm-auto">
|
||||||
<?php
|
<?php
|
||||||
if (!isset($_GET['del'])) { ?>
|
if (!isset($_GET['del'])) { ?>
|
||||||
<a class="btn btn-danger btn-border" href="?del">
|
<a class="btn btn-danger btn-border" href="?del">
|
||||||
<i class="fa-solid fa-filter"></i> <?php echo __('show_del') ?>
|
<i class="fa-solid fa-filter"></i> <?php echo __('show_del') ?>
|
||||||
</a>
|
</a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<a class="btn btn-danger " href="/servers">
|
<a class="btn btn-danger " href="/servers">
|
||||||
<i class="fa-solid fa-filter"></i> <?php echo __('show_del') ?>
|
<i class="fa-solid fa-filter"></i> <?php echo __('show_del') ?>
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="action" data-page-length="50">
|
<table class="multi-filter-select display table table-striped table-hover" data-skip-columns="action" data-page-length="50">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-column="server_state"><?php echo __('server_state') ?></th>
|
<th data-column="server_state"><?php echo __('server_state') ?></th>
|
||||||
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
|
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
|
||||||
<?php if ($this->showCompanies) { ?>
|
<?php if ($this->showCompanies) { ?>
|
||||||
<th data-column="company_name"><?php echo __('company') ?></th>
|
<th data-column="company_name"><?php echo __('company') ?></th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<th data-column="server_os"><?php echo __('server_os') ?></th>
|
<th data-column="server_os"><?php echo __('server_os') ?></th>
|
||||||
<th data-column="server_cpu">
|
<th data-column="server_cpu">
|
||||||
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
|
<i class="fa-solid fa-microchip"></i> <?php echo __('server_cpu') ?>
|
||||||
</th>
|
</th>
|
||||||
<th data-column="server_memory">
|
<th data-column="server_memory">
|
||||||
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
|
<i class="fa-solid fa-memory"></i> <?php echo __('server_memory') ?>
|
||||||
</th>
|
</th>
|
||||||
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
|
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></th>
|
||||||
<th data-column="server_disks">
|
<th data-column="server_disks">
|
||||||
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
|
<i class="fa-solid fa-hard-drive"></i> <?php echo __('server_disks') ?>
|
||||||
</th>
|
</th>
|
||||||
<th data-column="server_ipv4">
|
<th data-column="server_ipv4">
|
||||||
<?php echo __('server_ipv4') ?>
|
<?php echo __('server_ipv4') ?>
|
||||||
</th>
|
</th>
|
||||||
<th data-column="server_ipv6">
|
<th data-column="server_ipv6">
|
||||||
<?php echo __('server_ipv6') ?>
|
<?php echo __('server_ipv6') ?>
|
||||||
</th>
|
</th>
|
||||||
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></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>
|
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
|
||||||
<?php
|
<?php
|
||||||
foreach ($this->allLicenseTypes as $licenseType) { ?>
|
foreach ($this->allLicenseTypes as $licenseType) { ?>
|
||||||
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
|
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
|
||||||
<?php }
|
<?php }
|
||||||
foreach ($this->allBackupTypes as $backupType) { ?>
|
foreach ($this->allBackupTypes as $backupType) { ?>
|
||||||
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
|
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
|
||||||
<?php }
|
<?php }
|
||||||
?>
|
?>
|
||||||
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
|
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
|
||||||
<th data-column="server_description"><?php echo __('description') ?></th>
|
<th data-column="server_description"><?php echo __('description') ?></th>
|
||||||
<th data-column="action">
|
<th data-column="action">
|
||||||
<?php echo __('action') ?>
|
<?php echo __('action') ?>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-column="server_state"><?php echo __('server_state') ?></th>
|
<th data-column="server_state"><?php echo __('server_state') ?></th>
|
||||||
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
|
<th data-column="server_hostname"><?php echo __('server_hostname') ?></th>
|
||||||
<?php if ($this->showCompanies) { ?>
|
<?php if ($this->showCompanies) { ?>
|
||||||
<th data-column="company_name"><?php echo __('company') ?></th>
|
<th data-column="company_name"><?php echo __('company') ?></th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<th data-column="server_os"><?php echo __('server_os') ?></th>
|
<th data-column="server_os"><?php echo __('server_os') ?></th>
|
||||||
<th data-column="server_cpu"><?php echo __('server_cpu') ?></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"><?php echo __('server_memory') ?></th>
|
||||||
<th data-column="server_memory_demand"><?php echo __('server_memory_demand') ?></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_disks"><?php echo __('server_disks') ?></th>
|
||||||
<th data-column="server_ipv4"><?php echo __('server_ipv4') ?></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_ipv6"><?php echo __('server_ipv6') ?></th>
|
||||||
<th data-column="server_vm_snapshot"><?php echo __('server_vm_snapshot') ?></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>
|
<th data-column="server_vm_generation"><?php echo __('server_vm_generation') ?></th>
|
||||||
<?php
|
<?php
|
||||||
foreach ($this->allLicenseTypes as $licenseType) { ?>
|
foreach ($this->allLicenseTypes as $licenseType) { ?>
|
||||||
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
|
<th data-column="server_licenses_<?php echo $licenseType ?>"><?php echo $licenseType ?></th>
|
||||||
<?php }
|
<?php }
|
||||||
foreach ($this->allBackupTypes as $backupType) { ?>
|
foreach ($this->allBackupTypes as $backupType) { ?>
|
||||||
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
|
<th data-column="server_backup_<?php echo $backupType ?>"><?php echo $backupType ?></th>
|
||||||
<?php }
|
<?php }
|
||||||
?>
|
?>
|
||||||
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
|
<th data-column="server_power_state"><?php echo __('server_power_state') ?></th>
|
||||||
<th data-column="server_description"><?php echo __('description') ?></th>
|
<th data-column="server_description"><?php echo __('description') ?></th>
|
||||||
<th data-column="action"><?php echo __('action') ?></th>
|
<th data-column="action"><?php echo __('action') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ($this->servers as $server) {
|
foreach ($this->servers as $server) {
|
||||||
$disks = json_decode($server['server_disks'], true);
|
$disks = json_decode($server['server_disks'], true);
|
||||||
$totalDiskSpace = 0;
|
$totalDiskSpace = 0;
|
||||||
if (is_array($disks)) {
|
if (is_array($disks)) {
|
||||||
foreach ($disks as $disk) {
|
foreach ($disks as $disk) {
|
||||||
$totalDiskSpace += $disk['disk_space'];
|
$totalDiskSpace += $disk['disk_space'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($server['server_vm_host_name'])) {
|
if (is_null($server['server_vm_host_name'])) {
|
||||||
$hostname = $server['server_hostname'];
|
$hostname = $server['server_hostname'];
|
||||||
} else {
|
} else {
|
||||||
$hostname = $server['server_vm_host_name'];
|
$hostname = $server['server_vm_host_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$mem = isset($server['server_memory']) ? (float)$server['server_memory'] : 0;
|
$mem = isset($server['server_memory']) ? (float)$server['server_memory'] : 0;
|
||||||
$demand = isset($server['server_memory_demand']) ? (float)$server['server_memory_demand'] : 0;
|
$demand = isset($server['server_memory_demand']) ? (float)$server['server_memory_demand'] : 0;
|
||||||
|
|
||||||
if ($mem == 0 && $demand == 0) {
|
if ($mem == 0 && $demand == 0) {
|
||||||
$mem_assigned = 'N/A';
|
$mem_assigned = 'N/A';
|
||||||
} else {
|
$mem_assigned_sort = 0;
|
||||||
$mem_assigned = $this->cleanNumber($mem) . "M";
|
} 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_demand_text_color = '';
|
||||||
$mem_percent_numb = round($mem_percent, 1);
|
if ($mem > 0) {
|
||||||
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
|
$mem_percent = ($demand / $mem) * 100;
|
||||||
$mem_percent_sort = $mem_percent_numb;
|
$mem_percent_numb = round($mem_percent, 1);
|
||||||
|
$mem_demand = round($mem_percent, 1) . "%"; // round to 1 decimal place
|
||||||
if ($mem_percent_numb <= 89) {
|
$mem_percent_sort = $mem_percent_numb;
|
||||||
$mem_demand_text_color = 'success';
|
|
||||||
}
|
if ($mem_percent_numb <= 89) {
|
||||||
if ($mem_percent_numb > 89) {
|
$mem_demand_text_color = 'success';
|
||||||
$mem_demand_text_color = 'secondary';
|
}
|
||||||
}
|
if ($mem_percent_numb > 89) {
|
||||||
if ($mem_percent_numb > 99) {
|
$mem_demand_text_color = 'secondary';
|
||||||
$mem_demand_text_color = 'danger';
|
}
|
||||||
}
|
if ($mem_percent_numb > 99) {
|
||||||
|
$mem_demand_text_color = 'danger';
|
||||||
} else {
|
}
|
||||||
$mem_demand = "N/A";
|
|
||||||
$mem_percent_numb = 'N/A';
|
} else {
|
||||||
$mem_percent_sort = -1;
|
$mem_demand = "N/A";
|
||||||
}
|
$mem_percent_numb = 'N/A';
|
||||||
|
$mem_percent_sort = 0;
|
||||||
$ipv4_list = '';
|
}
|
||||||
if (!empty($server['server_ipv4'])) {
|
|
||||||
$ips = json_decode($server['server_ipv4'], true);
|
if ($server['server_cpu']) {
|
||||||
if (is_array($ips)) {
|
$server_cpu = htmlspecialchars($server['server_cpu']);
|
||||||
$ipv4_list = implode(', ', $ips);
|
$server_cpu_sort = (int)$server_cpu;
|
||||||
}
|
} else {
|
||||||
}
|
$server_cpu = "N/A";
|
||||||
|
$server_cpu_sort = 0;
|
||||||
$ipv6_list = '';
|
}
|
||||||
if (!empty($server['server_ipv6'])) {
|
|
||||||
$ips = json_decode($server['server_ipv6'], true);
|
$ipv4_list = '';
|
||||||
if (is_array($ips)) {
|
if (!empty($server['server_ipv4'])) {
|
||||||
$ipv6_list = implode(', ', $ips);
|
$ips = json_decode($server['server_ipv4'], true);
|
||||||
}
|
if (is_array($ips)) {
|
||||||
}
|
$ipv4_list = implode(', ', $ips);
|
||||||
|
}
|
||||||
$thisServerLicenses = [];
|
}
|
||||||
foreach ($this->allLicenseTypes as $licenseType) {
|
|
||||||
$thisServerLicenses[$licenseType] = false;
|
$ipv6_list = '';
|
||||||
}
|
if (!empty($server['server_ipv6'])) {
|
||||||
|
$ips = json_decode($server['server_ipv6'], true);
|
||||||
if (!empty($server['server_licenses'])) {
|
if (is_array($ips)) {
|
||||||
$allLicenseTypesServer = json_decode($server['server_licenses'], true);
|
$ipv6_list = implode(', ', $ips);
|
||||||
if (is_array($allLicenseTypesServer)) {
|
}
|
||||||
foreach ($allLicenseTypesServer as $licenseTypeServer) {
|
}
|
||||||
foreach ($licenseTypeServer as $licenseTypeServerKey => $licenseTypeServerValue) {
|
|
||||||
$thisServerLicenses[$licenseTypeServerKey] = true;
|
$thisServerLicenses = [];
|
||||||
}
|
foreach ($this->allLicenseTypes as $licenseType) {
|
||||||
}
|
$thisServerLicenses[$licenseType] = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (!empty($server['server_licenses'])) {
|
||||||
$thisServerBackup = [];
|
$allLicenseTypesServer = json_decode($server['server_licenses'], true);
|
||||||
foreach ($this->allBackupTypes as $BackupType) {
|
if (is_array($allLicenseTypesServer)) {
|
||||||
$thisServerBackup[$BackupType] = false;
|
foreach ($allLicenseTypesServer as $licenseTypeServer) {
|
||||||
}
|
foreach ($licenseTypeServer as $licenseTypeServerKey => $licenseTypeServerValue) {
|
||||||
|
$thisServerLicenses[$licenseTypeServerKey] = true;
|
||||||
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;
|
$thisServerBackup = [];
|
||||||
}
|
foreach ($this->allBackupTypes as $BackupType) {
|
||||||
}
|
$thisServerBackup[$BackupType] = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (!empty($server['server_backup'])) {
|
||||||
if ($this->showCompanies) {
|
$allBackupTypesServer = json_decode($server['server_backup'], true);
|
||||||
$company_name = '';
|
if (is_array($allBackupTypesServer)) {
|
||||||
if (strlen($server['company_name']) > 0) {
|
foreach ($allBackupTypesServer as $BackupTypeServer) {
|
||||||
$company_name = $server['company_name'];
|
foreach ($BackupTypeServer as $BackupTypeServerKey => $BackupTypeServerValue) {
|
||||||
}
|
$thisServerBackup[$BackupTypeServerKey] = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$server_state_color = returnServerStateColor($server['server_state']);
|
}
|
||||||
|
}
|
||||||
?>
|
|
||||||
|
if ($this->showCompanies) {
|
||||||
<tr data-item-id="<?php echo $server['server_uuid'] ?>">
|
$company_name = '';
|
||||||
<td data-column="server_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_state']); ?>">
|
if (strlen($server['company_name']) > 0) {
|
||||||
<span class="badge rounded-pill bg-<?php echo $server_state_color ?>"><?php echo $server['server_state'] ?></span>
|
$company_name = $server['company_name'];
|
||||||
</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>
|
$server_state_color = returnServerStateColor($server['server_state']);
|
||||||
<?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>
|
<tr data-item-id="<?php echo $server['server_uuid'] ?>">
|
||||||
<?php } ?>
|
<td data-column="server_state" class="text-nowrap" data-filter="<?php echo htmlspecialchars($server['server_state']); ?>" data-sort="<?php echo htmlspecialchars($server['server_state']); ?>">
|
||||||
<td data-column="server_os" class="text-nowrap"><?php echo $server['server_os'] ?></td>
|
<span class="badge rounded-pill bg-<?php echo $server_state_color ?>"><?php echo $server['server_state'] ?></span>
|
||||||
<td data-column="server_cpu" class="text-nowrap"><?php echo $server['server_cpu'] ?>
|
</td>
|
||||||
</td>
|
<td data-column="server_hostname" class="text-nowrap" data-filter="<?php echo htmlspecialchars($hostname); ?>" data-sort="<?php echo htmlspecialchars($hostname); ?>">
|
||||||
<td data-column="server_memory" class="text-nowrap" data-filter="<?php echo htmlspecialchars($mem); ?>" data-sort="<?php echo htmlspecialchars($mem); ?>">
|
<i class="fa-solid fa-server"></i> <?php echo $hostname ?>
|
||||||
<?php echo $mem_assigned ?>
|
</td>
|
||||||
</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 ?>">
|
||||||
<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 $company_name ?>
|
||||||
<?php echo $mem_demand ?>
|
</td>
|
||||||
</td>
|
<?php } ?>
|
||||||
|
<td data-column="server_os" class="text-nowrap"><?php echo $server['server_os'] ?></td>
|
||||||
<td data-column="server_disks" class="text-nowrap"
|
<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>
|
||||||
<?php
|
<td data-column="server_memory" class="text-nowrap" data-filter="<?php echo $mem_assigned; ?>" data-sort="<?php echo $mem_assigned_sort; ?>">
|
||||||
$sortValue = '';
|
<?php echo $mem_assigned ?>
|
||||||
$filterValue = '';
|
</td>
|
||||||
|
|
||||||
if (is_array($disks) && count($disks) > 0) {
|
<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); ?>">
|
||||||
$sizes = array_column($disks, 'disk_space');
|
<?php echo $mem_demand ?>
|
||||||
$totalDiskSpace = array_sum($sizes);
|
</td>
|
||||||
|
|
||||||
if ($totalDiskSpace > 0) {
|
<td data-column="server_disks" class="text-nowrap"
|
||||||
$sortValue = $totalDiskSpace;
|
<?php
|
||||||
$filterValue = $totalDiskSpace;
|
$sortValue = '';
|
||||||
}
|
$filterValue = '';
|
||||||
}
|
|
||||||
?>
|
if (is_array($disks) && count($disks) > 0) {
|
||||||
data-sort="<?php echo htmlspecialchars($sortValue); ?>" data-filter="<?php echo htmlspecialchars($filterValue); ?>">
|
$sizes = array_column($disks, 'disk_space');
|
||||||
<?php
|
$totalDiskSpace = array_sum($sizes);
|
||||||
if (!empty($sortValue)) {
|
|
||||||
if (count($sizes) === 1) {
|
if ($totalDiskSpace > 0) {
|
||||||
echo $sizes[0] . 'GB';
|
$sortValue = $totalDiskSpace;
|
||||||
} else {
|
$filterValue = $totalDiskSpace;
|
||||||
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
|
}
|
||||||
}
|
}
|
||||||
}
|
?>
|
||||||
?>
|
data-sort="<?php echo htmlspecialchars($sortValue); ?>" data-filter="<?php echo htmlspecialchars($filterValue); ?>">
|
||||||
</td>
|
<?php
|
||||||
<td data-column="server_ipv4" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv4_list); ?>" data-filter="<?php echo htmlspecialchars($ipv4_list); ?>">
|
if (!empty($sortValue)) {
|
||||||
<?php echo $ipv4_list ?>
|
if (count($sizes) === 1) {
|
||||||
</td>
|
echo $sizes[0] . 'GB';
|
||||||
<td data-column="server_ipv6" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv6_list); ?>" data-filter="<?php echo htmlspecialchars($ipv6_list); ?>">
|
} else {
|
||||||
<?php echo $ipv6_list ?>
|
echo $totalDiskSpace . 'GB (' . implode('GB, ', $sizes) . 'GB)';
|
||||||
</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>
|
||||||
<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']); ?>">
|
<td data-column="server_ipv4" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv4_list); ?>" data-filter="<?php echo htmlspecialchars($ipv4_list); ?>">
|
||||||
<?php echo $server['server_vm_generation']; ?>
|
<?php echo $ipv4_list ?>
|
||||||
</td>
|
</td>
|
||||||
|
<td data-column="server_ipv6" class="text-nowrap" data-sort="<?php echo htmlspecialchars($ipv6_list); ?>" data-filter="<?php echo htmlspecialchars($ipv6_list); ?>">
|
||||||
<?php
|
<?php echo $ipv6_list ?>
|
||||||
|
</td>
|
||||||
foreach ($this->allLicenseTypes as $licenseType) { ?>
|
<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']); ?>">
|
||||||
<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 echo $server['server_vm_snapshot']; ?>
|
||||||
<?php }
|
</td>
|
||||||
foreach ($this->allBackupTypes as $BackupType) { ?>
|
<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']); ?>">
|
||||||
<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 echo $server['server_vm_generation']; ?>
|
||||||
<?php }
|
</td>
|
||||||
?>
|
|
||||||
<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
|
||||||
<?php
|
|
||||||
if ($server['server_power_state'] == 'Off') {
|
foreach ($this->allLicenseTypes as $licenseType) { ?>
|
||||||
echo '<i class="fa-solid text-danger fa-toggle-off"></i>';
|
<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>
|
||||||
} elseif ($server['server_power_state'] == 'Running') {
|
<?php }
|
||||||
echo '<i class="fa-solid text-success fa-toggle-on"></i>';
|
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>
|
||||||
</td>
|
<?php }
|
||||||
<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 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']); ?>">
|
||||||
</td>
|
<?php
|
||||||
<td>
|
if ($server['server_power_state'] == 'Off') {
|
||||||
<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>
|
echo '<i class="fa-solid text-danger fa-toggle-off"></i>';
|
||||||
</td>
|
} elseif ($server['server_power_state'] == 'Running') {
|
||||||
</tr>
|
echo '<i class="fa-solid text-success fa-toggle-on"></i>';
|
||||||
<?php } ?>
|
} ?>
|
||||||
</tbody>
|
</td>
|
||||||
</table>
|
<td data-column="server_description" class="text-nowrap" data-sort="<?php echo htmlspecialchars($server['server_description']); ?>" data-filter="<?php echo $server['server_description']; ?>">
|
||||||
<br>
|
<?php echo $server['server_description']; ?>
|
||||||
</div>
|
</td>
|
||||||
</div>
|
<td>
|
||||||
</div>
|
<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>
|
||||||
<?php }
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php }
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,24 @@
|
|||||||
<Dialing>
|
<Dialing>
|
||||||
<Disable>
|
<Disable>
|
||||||
<Key Type="IME"/>
|
<Key Type="IME"/>
|
||||||
<Key Type="History"/>
|
<Key Type="History"/>
|
||||||
<Key Type="Switch"/>
|
<Key Type="Switch"/>
|
||||||
<Key Type="Line"/>
|
<Key Type="Line"/>
|
||||||
<Key Type="Favorite"/>
|
<Key Type="Favorite"/>
|
||||||
<Key Type="Empty"/>
|
<Key Type="Empty"/>
|
||||||
<Key Type="DPickup"/>
|
<Key Type="DPickup"/>
|
||||||
<Key Type="Retrieve"/>
|
<Key Type="Retrieve"/>
|
||||||
</Disable>
|
</Disable>
|
||||||
<Enable>
|
<Enable>
|
||||||
<Key Type="Send"/>
|
<Key Type="Send"/>
|
||||||
<Key Type="GPickup"/>
|
<Key Type="GPickup"/>
|
||||||
<Key Type="Delete"/>
|
<Key Type="Delete"/>
|
||||||
<Key Type="End Call"/>
|
<Key Type="End Call"/>
|
||||||
</Enable>
|
</Enable>
|
||||||
<Default>
|
<Default>
|
||||||
<Key Type="Send"/>
|
<Key Type="Send"/>
|
||||||
<Key Type="Delete"/>
|
<Key Type="Delete"/>
|
||||||
<Key Type="GPickup"/>
|
<Key Type="GPickup"/>
|
||||||
<Key Type="End Call"/>
|
<Key Type="End Call"/>
|
||||||
</Default>
|
</Default>
|
||||||
</Dialing>
|
</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
@@ -1,141 +1,141 @@
|
|||||||
/**
|
/**
|
||||||
* prism.js default theme for JavaScript, CSS and HTML
|
* prism.js default theme for JavaScript, CSS and HTML
|
||||||
* Based on dabblet (http://dabblet.com)
|
* Based on dabblet (http://dabblet.com)
|
||||||
* @author Lea Verou
|
* @author Lea Verou
|
||||||
*/
|
*/
|
||||||
|
|
||||||
code[class*="language-"],
|
code[class*="language-"],
|
||||||
pre[class*="language-"] {
|
pre[class*="language-"] {
|
||||||
color: black;
|
color: black;
|
||||||
background: none;
|
background: none;
|
||||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-spacing: normal;
|
word-spacing: normal;
|
||||||
word-break: normal;
|
word-break: normal;
|
||||||
word-wrap: normal;
|
word-wrap: normal;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
|
|
||||||
-moz-tab-size: 4;
|
-moz-tab-size: 4;
|
||||||
-o-tab-size: 4;
|
-o-tab-size: 4;
|
||||||
tab-size: 4;
|
tab-size: 4;
|
||||||
|
|
||||||
-webkit-hyphens: none;
|
-webkit-hyphens: none;
|
||||||
-moz-hyphens: none;
|
-moz-hyphens: none;
|
||||||
-ms-hyphens: none;
|
-ms-hyphens: none;
|
||||||
hyphens: none;
|
hyphens: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
|
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
|
||||||
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
|
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
background: #b3d4fc;
|
background: #b3d4fc;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
|
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
|
||||||
code[class*="language-"]::selection, code[class*="language-"] ::selection {
|
code[class*="language-"]::selection, code[class*="language-"] ::selection {
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
background: #b3d4fc;
|
background: #b3d4fc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
code[class*="language-"],
|
code[class*="language-"],
|
||||||
pre[class*="language-"] {
|
pre[class*="language-"] {
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Code blocks */
|
/* Code blocks */
|
||||||
pre[class*="language-"] {
|
pre[class*="language-"] {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
margin: .5em 0;
|
margin: .5em 0;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
:not(pre) > code[class*="language-"],
|
:not(pre) > code[class*="language-"],
|
||||||
pre[class*="language-"] {
|
pre[class*="language-"] {
|
||||||
background: #f5f2f0;
|
background: #f5f2f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inline code */
|
/* Inline code */
|
||||||
:not(pre) > code[class*="language-"] {
|
:not(pre) > code[class*="language-"] {
|
||||||
padding: .1em;
|
padding: .1em;
|
||||||
border-radius: .3em;
|
border-radius: .3em;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.comment,
|
.token.comment,
|
||||||
.token.prolog,
|
.token.prolog,
|
||||||
.token.doctype,
|
.token.doctype,
|
||||||
.token.cdata {
|
.token.cdata {
|
||||||
color: slategray;
|
color: slategray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.punctuation {
|
.token.punctuation {
|
||||||
color: #fbf1c7;
|
color: #fbf1c7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.namespace {
|
.token.namespace {
|
||||||
opacity: .7;
|
opacity: .7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.property,
|
.token.property,
|
||||||
.token.tag,
|
.token.tag,
|
||||||
.token.boolean,
|
.token.boolean,
|
||||||
.token.constant,
|
.token.constant,
|
||||||
.token.symbol,
|
.token.symbol,
|
||||||
.token.deleted {
|
.token.deleted {
|
||||||
color: #fe8019;
|
color: #fe8019;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.number {
|
.token.number {
|
||||||
color: #fb4934;
|
color: #fb4934;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.selector,
|
.token.selector,
|
||||||
.token.attr-name,
|
.token.attr-name,
|
||||||
.token.string,
|
.token.string,
|
||||||
.token.char,
|
.token.char,
|
||||||
.token.builtin,
|
.token.builtin,
|
||||||
.token.inserted {
|
.token.inserted {
|
||||||
color: #8ec07c;
|
color: #8ec07c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.operator,
|
.token.operator,
|
||||||
.token.entity,
|
.token.entity,
|
||||||
.token.url,
|
.token.url,
|
||||||
.language-css .token.string,
|
.language-css .token.string,
|
||||||
.style .token.string {
|
.style .token.string {
|
||||||
color: #9a6e3a;
|
color: #9a6e3a;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.atrule,
|
.token.atrule,
|
||||||
.token.attr-value,
|
.token.attr-value,
|
||||||
.token.keyword {
|
.token.keyword {
|
||||||
color: #458588;
|
color: #458588;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.function,
|
.token.function,
|
||||||
.token.class-name {
|
.token.class-name {
|
||||||
color: #d3869b;
|
color: #d3869b;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.regex,
|
.token.regex,
|
||||||
.token.important,
|
.token.important,
|
||||||
.token.variable {
|
.token.variable {
|
||||||
color: #d79921;
|
color: #d79921;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.important,
|
.token.important,
|
||||||
.token.bold {
|
.token.bold {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.italic {
|
.token.italic {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.entity {
|
.token.entity {
|
||||||
cursor: help;
|
cursor: help;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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">
|
<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/>
|
<defs/>
|
||||||
<style id="style2" type="text/css">
|
<style id="style2" type="text/css">
|
||||||
.st1{fill:#86da2f}.st2{fill:#24c2ff}.st3{fill:#ffcb12}.st4{fill:#0069da}.st5{fill:#ff4649}
|
.st1{fill:#86da2f}.st2{fill:#24c2ff}.st3{fill:#ffcb12}.st4{fill:#0069da}.st5{fill:#ff4649}
|
||||||
</style>
|
</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="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="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="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="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="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="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="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="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="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"/>
|
<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>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
@@ -1,39 +1,39 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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">
|
<!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 -->
|
<!-- 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"
|
<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">
|
width="800px" height="800px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
|
||||||
<g>
|
<g>
|
||||||
<g>
|
<g>
|
||||||
<g>
|
<g>
|
||||||
<path fill="#B4CCB9" d="M14,60c0,1.104,0.896,2,2,2h32c1.104,0,2-0.896,2-2V38H14V60z"/>
|
<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="26" fill="#B4CCB9" width="36" height="10"/>
|
||||||
<rect x="14" y="14" 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"/>
|
<path fill="#B4CCB9" d="M48,2H16c-1.104,0-2,0.896-2,2v8h36V4C50,2.896,49.104,2,48,2z"/>
|
||||||
</g>
|
</g>
|
||||||
<g opacity="0.15">
|
<g opacity="0.15">
|
||||||
<rect x="14" y="26" width="36" height="10"/>
|
<rect x="14" y="26" width="36" height="10"/>
|
||||||
<rect x="14" y="14" 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"/>
|
<path d="M48,2H16c-1.104,0-2,0.896-2,2v8h36V4C50,2.896,49.104,2,48,2z"/>
|
||||||
</g>
|
</g>
|
||||||
<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
|
<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
|
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"/>
|
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="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,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="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
|
<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"/>
|
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
|
<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"/>
|
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
|
<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"/>
|
s-0.447,1-1,1s-1-0.447-1-1S23.447,54,24,54z"/>
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
<circle fill="#45AAB8" cx="24" cy="55" r="1"/>
|
<circle fill="#45AAB8" cx="24" cy="55" r="1"/>
|
||||||
<circle fill="#F76D57" cx="32" cy="55" r="1"/>
|
<circle fill="#F76D57" cx="32" cy="55" r="1"/>
|
||||||
<circle fill="#F9EBB2" cx="40" cy="55" r="1"/>
|
<circle fill="#F9EBB2" cx="40" cy="55" r="1"/>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</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
260
vendor/endroid/qr-code/README.md
vendored
260
vendor/endroid/qr-code/README.md
vendored
@@ -1,130 +1,130 @@
|
|||||||
# QR Code
|
# QR Code
|
||||||
|
|
||||||
*By [endroid](https://endroid.nl/)*
|
*By [endroid](https://endroid.nl/)*
|
||||||
|
|
||||||
[](https://packagist.org/packages/endroid/qr-code)
|
[](https://packagist.org/packages/endroid/qr-code)
|
||||||
[](https://github.com/endroid/qr-code/actions)
|
[](https://github.com/endroid/qr-code/actions)
|
||||||
[](https://packagist.org/packages/endroid/qr-code)
|
[](https://packagist.org/packages/endroid/qr-code)
|
||||||
[](https://packagist.org/packages/endroid/qr-code)
|
[](https://packagist.org/packages/endroid/qr-code)
|
||||||
[](https://packagist.org/packages/endroid/qr-code)
|
[](https://packagist.org/packages/endroid/qr-code)
|
||||||
|
|
||||||
This library helps you generate QR codes in a jiffy. Makes use of [bacon/bacon-qr-code](https://github.com/Bacon/BaconQrCode)
|
This library helps you generate QR codes in a jiffy. Makes use of [bacon/bacon-qr-code](https://github.com/Bacon/BaconQrCode)
|
||||||
to generate the matrix and [khanamiryan/qrcode-detector-decoder](https://github.com/khanamiryan/php-qrcode-detector-decoder)
|
to generate the matrix and [khanamiryan/qrcode-detector-decoder](https://github.com/khanamiryan/php-qrcode-detector-decoder)
|
||||||
for validating generated QR codes. Further extended with Twig extensions, generation routes, a factory and a
|
for validating generated QR codes. Further extended with Twig extensions, generation routes, a factory and a
|
||||||
Symfony bundle for easy installation and configuration.
|
Symfony bundle for easy installation and configuration.
|
||||||
|
|
||||||
Different writers are provided to generate the QR code as PNG, SVG, EPS, PDF or in binary format.
|
Different writers are provided to generate the QR code as PNG, SVG, EPS, PDF or in binary format.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Use [Composer](https://getcomposer.org/) to install the library.
|
Use [Composer](https://getcomposer.org/) to install the library.
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
$ composer require endroid/qr-code
|
$ composer require endroid/qr-code
|
||||||
```
|
```
|
||||||
|
|
||||||
## Basic usage
|
## Basic usage
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use Endroid\QrCode\QrCode;
|
use Endroid\QrCode\QrCode;
|
||||||
|
|
||||||
$qrCode = new QrCode('Life is too short to be generating QR codes');
|
$qrCode = new QrCode('Life is too short to be generating QR codes');
|
||||||
|
|
||||||
header('Content-Type: '.$qrCode->getContentType());
|
header('Content-Type: '.$qrCode->getContentType());
|
||||||
echo $qrCode->writeString();
|
echo $qrCode->writeString();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Advanced usage
|
## Advanced usage
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use Endroid\QrCode\ErrorCorrectionLevel;
|
use Endroid\QrCode\ErrorCorrectionLevel;
|
||||||
use Endroid\QrCode\LabelAlignment;
|
use Endroid\QrCode\LabelAlignment;
|
||||||
use Endroid\QrCode\QrCode;
|
use Endroid\QrCode\QrCode;
|
||||||
use Endroid\QrCode\Response\QrCodeResponse;
|
use Endroid\QrCode\Response\QrCodeResponse;
|
||||||
|
|
||||||
// Create a basic QR code
|
// Create a basic QR code
|
||||||
$qrCode = new QrCode('Life is too short to be generating QR codes');
|
$qrCode = new QrCode('Life is too short to be generating QR codes');
|
||||||
$qrCode->setSize(300);
|
$qrCode->setSize(300);
|
||||||
$qrCode->setMargin(10);
|
$qrCode->setMargin(10);
|
||||||
|
|
||||||
// Set advanced options
|
// Set advanced options
|
||||||
$qrCode->setWriterByName('png');
|
$qrCode->setWriterByName('png');
|
||||||
$qrCode->setEncoding('UTF-8');
|
$qrCode->setEncoding('UTF-8');
|
||||||
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH());
|
$qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH());
|
||||||
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
|
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
|
||||||
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
|
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
|
||||||
$qrCode->setLabel('Scan the code', 16, __DIR__.'/../assets/fonts/noto_sans.otf', LabelAlignment::CENTER());
|
$qrCode->setLabel('Scan the code', 16, __DIR__.'/../assets/fonts/noto_sans.otf', LabelAlignment::CENTER());
|
||||||
$qrCode->setLogoPath(__DIR__.'/../assets/images/symfony.png');
|
$qrCode->setLogoPath(__DIR__.'/../assets/images/symfony.png');
|
||||||
$qrCode->setLogoSize(150, 200);
|
$qrCode->setLogoSize(150, 200);
|
||||||
$qrCode->setValidateResult(false);
|
$qrCode->setValidateResult(false);
|
||||||
|
|
||||||
// Round block sizes to improve readability and make the blocks sharper in pixel based outputs (like png).
|
// Round block sizes to improve readability and make the blocks sharper in pixel based outputs (like png).
|
||||||
// There are three approaches:
|
// There are three approaches:
|
||||||
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN); // The size of the qr code is shrinked, if necessary, but the size of the final image remains unchanged due to additional margin being added (default)
|
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN); // The size of the qr code is shrinked, if necessary, but the size of the final image remains unchanged due to additional margin being added (default)
|
||||||
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_ENLARGE); // The size of the qr code and the final image is enlarged, if necessary
|
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_ENLARGE); // The size of the qr code and the final image is enlarged, if necessary
|
||||||
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_SHRINK); // The size of the qr code and the final image is shrinked, if necessary
|
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_SHRINK); // The size of the qr code and the final image is shrinked, if necessary
|
||||||
|
|
||||||
// Set additional writer options (SvgWriter example)
|
// Set additional writer options (SvgWriter example)
|
||||||
$qrCode->setWriterOptions(['exclude_xml_declaration' => true]);
|
$qrCode->setWriterOptions(['exclude_xml_declaration' => true]);
|
||||||
|
|
||||||
// Directly output the QR code
|
// Directly output the QR code
|
||||||
header('Content-Type: '.$qrCode->getContentType());
|
header('Content-Type: '.$qrCode->getContentType());
|
||||||
echo $qrCode->writeString();
|
echo $qrCode->writeString();
|
||||||
|
|
||||||
// Save it to a file
|
// Save it to a file
|
||||||
$qrCode->writeFile(__DIR__.'/qrcode.png');
|
$qrCode->writeFile(__DIR__.'/qrcode.png');
|
||||||
|
|
||||||
// Generate a data URI to include image data inline (i.e. inside an <img> tag)
|
// Generate a data URI to include image data inline (i.e. inside an <img> tag)
|
||||||
$dataUri = $qrCode->writeDataUri();
|
$dataUri = $qrCode->writeDataUri();
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Encoding
|
### Encoding
|
||||||
You can pick one of these values for encoding:
|
You can pick one of these values for encoding:
|
||||||
|
|
||||||
`ISO-8859-1`, `ISO-8859-2`, `ISO-8859-3`, `ISO-8859-4`, `ISO-8859-5`, `ISO-8859-6`, `ISO-8859-7`, `ISO-8859-8`, `ISO-8859-9`, `ISO-8859-10`, `ISO-8859-11`, `ISO-8859-12`, `ISO-8859-13`, `ISO-8859-14`, `ISO-8859-15`, `ISO-8859-16`, `Shift_JIS`, `windows-1250`, `windows-1251`, `windows-1252`, `windows-1256`, `UTF-16BE`, `UTF-8`, `US-ASCII`, `GBK` `EUC-KR`
|
`ISO-8859-1`, `ISO-8859-2`, `ISO-8859-3`, `ISO-8859-4`, `ISO-8859-5`, `ISO-8859-6`, `ISO-8859-7`, `ISO-8859-8`, `ISO-8859-9`, `ISO-8859-10`, `ISO-8859-11`, `ISO-8859-12`, `ISO-8859-13`, `ISO-8859-14`, `ISO-8859-15`, `ISO-8859-16`, `Shift_JIS`, `windows-1250`, `windows-1251`, `windows-1252`, `windows-1256`, `UTF-16BE`, `UTF-8`, `US-ASCII`, `GBK` `EUC-KR`
|
||||||
|
|
||||||
If you use a barcode scanner you can have some troubles while reading the generated QR codes. Depending on the encoding you chose you will have an extra amount of data corresponding to the ECI block. Some barcode scanner are not programmed to interpret this block of information. For exemple the ECI block for `UTF-8` is `000026` so the above exemple will produce : `\000026Life is too short to be generating QR codes`. To ensure a maximum compatibility you can use the `ISO-8859-1` encoding that is the default encoding used by barcode scanners.
|
If you use a barcode scanner you can have some troubles while reading the generated QR codes. Depending on the encoding you chose you will have an extra amount of data corresponding to the ECI block. Some barcode scanner are not programmed to interpret this block of information. For exemple the ECI block for `UTF-8` is `000026` so the above exemple will produce : `\000026Life is too short to be generating QR codes`. To ensure a maximum compatibility you can use the `ISO-8859-1` encoding that is the default encoding used by barcode scanners.
|
||||||
|
|
||||||
## Readability
|
## Readability
|
||||||
|
|
||||||
The readability of a QR code is primarily determined by the size, the input
|
The readability of a QR code is primarily determined by the size, the input
|
||||||
length, the error correction level and any possible logo over the image so you
|
length, the error correction level and any possible logo over the image so you
|
||||||
can tweak these parameters if you are looking for optimal results. You can also
|
can tweak these parameters if you are looking for optimal results. You can also
|
||||||
check $qrCode->getRoundBlockSize() value to see if block dimensions are rounded
|
check $qrCode->getRoundBlockSize() value to see if block dimensions are rounded
|
||||||
so that the image is more sharp and readable. Please note that rounding block
|
so that the image is more sharp and readable. Please note that rounding block
|
||||||
size can result in additional padding to compensate for the rounding difference.
|
size can result in additional padding to compensate for the rounding difference.
|
||||||
|
|
||||||
## Built-in validation reader
|
## Built-in validation reader
|
||||||
|
|
||||||
You can enable the built-in validation reader (disabled by default) by calling
|
You can enable the built-in validation reader (disabled by default) by calling
|
||||||
setValidateResult(true). This validation reader does not guarantee that the QR
|
setValidateResult(true). This validation reader does not guarantee that the QR
|
||||||
code will be readable by all readers but it helps you provide a minimum level
|
code will be readable by all readers but it helps you provide a minimum level
|
||||||
of quality.
|
of quality.
|
||||||
|
|
||||||
Take note that the validator can consume quite amount of additional resources.
|
Take note that the validator can consume quite amount of additional resources.
|
||||||
|
|
||||||
## Symfony integration
|
## Symfony integration
|
||||||
|
|
||||||
The [endroid/qr-code-bundle](https://github.com/endroid/qr-code-bundle)
|
The [endroid/qr-code-bundle](https://github.com/endroid/qr-code-bundle)
|
||||||
integrates the QR code library in Symfony for an even better experience.
|
integrates the QR code library in Symfony for an even better experience.
|
||||||
|
|
||||||
* Configure your defaults (like image size, default writer etc.)
|
* Configure your defaults (like image size, default writer etc.)
|
||||||
* Generate QR codes quickly from anywhere via the factory service
|
* Generate QR codes quickly from anywhere via the factory service
|
||||||
* Generate QR codes directly by typing an URL like /qr-code/\<text>.png?size=300
|
* Generate QR codes directly by typing an URL like /qr-code/\<text>.png?size=300
|
||||||
* Generate QR codes or URLs directly from Twig using dedicated functions
|
* Generate QR codes or URLs directly from Twig using dedicated functions
|
||||||
|
|
||||||
Read the [bundle documentation](https://github.com/endroid/qr-code-bundle)
|
Read the [bundle documentation](https://github.com/endroid/qr-code-bundle)
|
||||||
for more information.
|
for more information.
|
||||||
|
|
||||||
## Versioning
|
## Versioning
|
||||||
|
|
||||||
Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility
|
Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility
|
||||||
breaking changes will be kept to a minimum but be aware that these can occur.
|
breaking changes will be kept to a minimum but be aware that these can occur.
|
||||||
Lock your dependencies for production and test your code when upgrading.
|
Lock your dependencies for production and test your code when upgrading.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This bundle is under the MIT license. For the full copyright and license
|
This bundle is under the MIT license. For the full copyright and license
|
||||||
information please view the LICENSE file that was distributed with this source code.
|
information please view the LICENSE file that was distributed with this source code.
|
||||||
|
|||||||
Reference in New Issue
Block a user