107 lines
2.8 KiB
PHP
107 lines
2.8 KiB
PHP
<?php
|
|
|
|
if (!defined('GLPI_ROOT')) {
|
|
die("Sorry. You can't access directly to this file");
|
|
}
|
|
|
|
|
|
|
|
class PluginRemotesupportRemotesupport extends CommonDBTM {
|
|
static function showInfo($item) {
|
|
|
|
$fi_path = Plugin::getWebDir('fusioninventory');
|
|
|
|
// Manage locks pictures
|
|
PluginFusioninventoryLock::showLockIcon('Computer');
|
|
|
|
$pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer();
|
|
$a_computerextend = $pfInventoryComputerComputer->hasAutomaticInventory($item->getID());
|
|
if (empty($a_computerextend)) {
|
|
return true;
|
|
}
|
|
|
|
echo '<table class="tab_glpi" width="100%">';
|
|
echo '<tr>';
|
|
echo '<th>'.__('Remote Support').'</th>';
|
|
echo '</tr>';
|
|
echo '<tr class="tab_bg_1">';
|
|
echo '<td>';
|
|
|
|
$url = "<a target=\"_blank\" href=\"https://" . $_SERVER['SERVER_ADDR']. "/vnc.html?path=vnc%2F". $a_computerextend['remote_addr'] ."&autoconnect=true&resize=scale&reconnect=true&show_dot=true\"><li class=\"document\"><i class=\"fa fa-laptop-medical\"></i>" . $a_computerextend['remote_addr'] . "</li></a>";
|
|
|
|
if ($url != ""){
|
|
echo "<div><ul class=\"timeline_choices\"><h2>VNC connect : </h2>";
|
|
echo $url;
|
|
echo "</ul></div>";
|
|
}
|
|
echo '</td>';
|
|
echo '</tr>';
|
|
echo '</table>';
|
|
|
|
}
|
|
|
|
static function getStatesIds() {
|
|
global $DB;
|
|
|
|
$states_ids = [];
|
|
|
|
$req = $DB->request('glpi_states', ['FIELDS' => ['glpi_states' => ['id', 'name']]], [ 'OR' => [ 'name' => 'Online', 'name' => 'Offline']]);
|
|
|
|
$ret = $req->next();
|
|
$states_ids[$ret['name']] = $ret['id'];
|
|
$ret = $req->next();
|
|
$states_ids[$ret['name']] = $ret['id'];
|
|
|
|
return $states_ids;
|
|
}
|
|
|
|
static function cronRemotesupport($task) {
|
|
global $DB;
|
|
|
|
Toolbox::logInFile("remotsupport","Starting search of agents\n");
|
|
|
|
$agents = [];
|
|
$data_set = [];
|
|
|
|
$stids = self::getStatesIds();
|
|
|
|
|
|
foreach (getAllDataFromTable(PluginFusioninventoryAgent::getTable()) as $a) {
|
|
|
|
$data_set[] = $a["id"];
|
|
$agents[$a["id"]] = $a;
|
|
}
|
|
|
|
|
|
foreach ($data_set as $id) {
|
|
$agent = new PluginFusioninventoryAgent;
|
|
$agent->getFromDB((int)$id);
|
|
$st = $agent->getStatus();
|
|
|
|
if ($st["message"] != "noanswer")
|
|
Toolbox::logInFile("remotsupport",print_r($agents[$id],true));
|
|
|
|
$comp = new Computer();
|
|
$comp->getFromDB($agents[$id]["computers_id"]);
|
|
if ($st["message"] == "noanswer")
|
|
$comp->fields["states_id"] = $stids["Offline"];
|
|
else
|
|
$comp->fields["states_id"] = $stids["Online"];
|
|
$DB->update("glpi_computers", [
|
|
'states_id' => $comp->fields["states_id"] ],
|
|
[ 'id' => $agents[$id]["computers_id"] ]
|
|
);
|
|
$comp->fields["contact"]."\n";
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
static function cronInfo($name) {
|
|
return [
|
|
'description' => "Agent search remotesupport"];
|
|
}
|
|
}
|