@ 2014-06-23T09:16:42Z <?php
define('GLPI_ROOT', '../../..');
if(!defined('GLPI_ROOT'))
{
die("Sorry. You can't access directly to this file");
}
// plugin_portswitch -> PluginPortswitchPortswitch
// + extends CommonDBTM
class PluginPortswitchPortswitch
{
public static $config_data;
public static function loadConfig()
{
self::$config_data = parse_ini_file(GLPI_ROOT."/files/_plugins/portswitch/config.ini", true);
}
public static function drawInfoBox()
{
include_once(GLPI_ROOT."/inc/includes.php");
if(Session::haveRight("user", "w"))
{
echo "<tr><td class='top' width='450px'>";
echo "<br><table class='tab_cadrehov'><tr><th colspan=\"4\"><a href=\"/glpi/plugins/portswitch/\">Portswitch</a></th></tr>";
echo "<tr><th>Bezeichnung</th><th>Status</th></tr>";
self::loadConfig();
for($i = 0; $i < sizeof(self::$config_data); $i++)
{
echo "<tr><center>";
if(self::$config_data[$i]['status'] == "Aktiviert")
{
echo "<td>".self::$config_data[$i]['name']."</td><td>".self::getHtmlStatus($i)." ( ";
$kommentar_array = explode(",", self::$config_data[$i]['kommentar']);
for($j = 0; $j < sizeof($kommentar_array); $j++)
echo "<a href=\"/glpi/front/ticket.form.php?id=".$kommentar_array[$j]."\"> #".$kommentar_array[$j]."</a>";
echo " ) </td>";
}
else
{
echo "<td>".self::$config_data[$i]['name']."</td><td>".self::getHtmlStatus($i)."</td>";
}
echo "</tr></center>";
}
echo "</table>";
echo "</td></tr>";
}
}
public static function getHtmlStatus($id)
{
if(self::$config_data[$id]['status'] == "Aktiviert")
return "<font color=\"#00FF00\">Aktiv</font>";
else if(self::$config_data[$id]['status'] == "Deaktiviert")
return "<font color=\"#FF0000\">Inaktiv</font>";
else
return "<font color=\"#0000FF\">Unbekannt</font>";
}
public static function saveConfig()
{
$config_file = fopen(GLPI_ROOT."/files/_plugins/portswitch/config.ini", 'w');
if($config_file == false)
die("Konnte ".GLPI_ROOT."/files/_plugins/portswitch/config.ini nicht schreiben.");
for($i = 0; $i < sizeof(self::$config_data); $i++)
{
fwrite($config_file, "[$i]\n");
fwrite($config_file, "name = \"".self::$config_data[$i]['name']."\"\n");
fwrite($config_file, "ip = \"".self::$config_data[$i]['ip']."\"\n");
fwrite($config_file, "port = \"".self::$config_data[$i]['port']."\"\n");
fwrite($config_file, "kommentar = \"".self::$config_data[$i]['kommentar']."\"\n");
fwrite($config_file, "status = \"".self::$config_data[$i]['status']."\"\n");
fwrite($config_file, "passwort = \"".self::$config_data[$i]['passwort']."\"\n");
fwrite($config_file, "stack = \"".self::$config_data[$i]['stack']."\"\n");
fwrite($config_file, "hostname = \"".self::$config_data[$i]['hostname']."\"\n");
fwrite($config_file, "link = \"".self::$config_data[$i]['link']."\"\n\n");
}
fclose($config_file);
}
};
// Status aktualisieren
if (isset($_SESSION['port_changed'])) {
$changed = $_SESSION['port_changed'];
unset($_SESSION['port_changed']);
if(PluginPortswitchPortswitch::$config_data[$changed]['link'] != '0.0.0.0') {
PluginPortswitchPortswitch::$config_data[$changed]['link'] = exec('../scripts/checkport.sh '.PluginPortswitchPortswitch::$config_data[$changed]['ip'].' '.PluginPortswitchPortswitch::$config_data[$changed]['port'].' '.PluginPortswitchPortswitch::$config_data[$changed]['passwort'].' '.PluginPortswitchPortswitch::$config_data[$changed]['stack'].' '.PluginPortswitchPortswitch::$config_data[$changed]['hostname']);
} else {
PluginPortswitchPortswitch::$config_data[$changed]['link'] = 'Konnte nicht abgefragt werden. (Konfiguration prüfen!)';
}
PluginPortswitchPortswitch::saveConfig();
}
for($i = 0; $i < sizeof(PluginPortswitchPortswitch::$config_data); $i++)
{
?>
<h1><?php echo PluginPortswitchPortswitch::$config_data[$i]['name']; ?> auf Switch <?php echo PluginPortswitchPortswitch::$config_data[$i]['hostname']; ?>:<?php echo PluginPortswitchPortswitch::$config_data[$i]['port']; ?> Kontrolle</h1>
<form method="POST" action="<?php echo GLPI_ROOT; ?>/plugins/portswitch/front/portswitch.form.php">
<p>
Ticketnummern (mit Komma trennen, z.B. <i>"1024,2048,..."</i>: <input type="text" name="kommentar" value="<?php echo PluginPortswitchPortswitch::$config_data[$i]['kommentar']; ?>"><br>
<input type="submit" name="Aktualisieren" value="Aktualisieren">
</p>
<p>
<input type="hidden" name="sent" value="<?php echo $i; ?>">
<input type="submit" name="deactivate" value="Deaktivieren">
<input type="submit" name="activate" value="Aktivieren">
</p>
<p> </p>
<p>
<?php
switch(PluginPortswitchPortswitch::$config_data[$i]['link']) {
case 'Down':
$color = '#FF0000';
break;
case 'Up':
$color = '#00FF00';
break;
default:
$color = '#0000FF';
}
?>
Port Link-Status: <span style="color:<?php echo $color; ?>"><?php echo PluginPortswitchPortswitch::$config_data[$i]['link']; ?></span><br>
Port Status: <?php echo PluginPortswitchPortswitch::getHtmlStatus($i); ?><br><br>
<input type="submit" name="link" value="Update Link Status">
</p>
<?php
Html::closeForm();
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.10 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Fatal error: Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, null given in /in/R1g5K:105
Stack trace:
#0 {main}
thrown in /in/R1g5K on line 105
Process exited with code 255 . Output for 8.0.0 - 8.0.9 Fatal error: Uncaught TypeError: sizeof(): Argument #1 ($var) must be of type Countable|array, null given in /in/R1g5K:105
Stack trace:
#0 {main}
thrown in /in/R1g5K on line 105
Process exited with code 255 . Output for 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 Warning: sizeof(): Parameter must be an array or an object that implements Countable in /in/R1g5K on line 105
Output for 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.25 preferences:dark mode live preview
207.74 ms | 402 KiB | 317 Q