44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* Test page - will work when accessed from within GLPI session
|
||
|
|
*/
|
||
|
|
$AJAX_INCLUDE = 1;
|
||
|
|
|
||
|
|
define('GLPI_ROOT', dirname(__DIR__, 4));
|
||
|
|
require_once GLPI_ROOT . '/inc/includes.php';
|
||
|
|
|
||
|
|
header('Content-Type: text/html; charset=UTF-8');
|
||
|
|
Html::header_nocache();
|
||
|
|
|
||
|
|
Session::checkLoginUser();
|
||
|
|
|
||
|
|
// Check rights
|
||
|
|
if (!Session::haveRight('plugin_urbackup', READ)) {
|
||
|
|
echo "<p style='color:red'>No READ permission on plugin_urbackup</p>";
|
||
|
|
Html::footer();
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "<p style='color:green'>READ permission OK</p>";
|
||
|
|
|
||
|
|
// Get server ID
|
||
|
|
$server_id = (int) ($_GET['id'] ?? 0);
|
||
|
|
|
||
|
|
if ($server_id > 0) {
|
||
|
|
$server = new GlpiPlugin\Urbackup\Server();
|
||
|
|
if ($server->getFromDB($server_id)) {
|
||
|
|
echo "<p>Server: " . $server->fields['name'] . "</p>";
|
||
|
|
|
||
|
|
$client = new GlpiPlugin\Urbackup\UrbackupApiClient($server);
|
||
|
|
$result = $client->testConnection();
|
||
|
|
|
||
|
|
echo "<pre>" . print_r($result, true) . "</pre>";
|
||
|
|
} else {
|
||
|
|
echo "<p>Server not found</p>";
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
echo "<p>No server ID provided</p>";
|
||
|
|
}
|
||
|
|
|
||
|
|
Html::footer();
|