3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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); } }; PluginPortswitchPortswitch::loadConfig(); // ID der zu bearbeitenden Portkonfiguration übernehmen $sent = (isset($_POST['sent'])) ? $_POST['sent'] : ''; if ($sent!="") { if (isset($_POST['activate'])) { //Port aktivieren exec("../scripts/enable_port.sh ".PluginPortswitchPortswitch::$config_data[$sent]['ip']." ".PluginPortswitchPortswitch::$config_data[$sent]['port']." ".PluginPortswitchPortswitch::$config_data[$sent]['passwort']." ".PluginPortswitchPortswitch::$config_data[$sent]['stack']." ".PluginPortswitchPortswitch::$config_data[$sent]['hostname']); PluginPortswitchPortswitch::$config_data[$sent]['status'] = "Aktiviert"; } else if (isset($_POST['deactivate'])) { // Port deaktivieren exec("../scripts/disable_port.sh ".PluginPortswitchPortswitch::$config_data[$sent]['ip']." ".PluginPortswitchPortswitch::$config_data[$sent]['port']." ".PluginPortswitchPortswitch::$config_data[$sent]['passwort']." ".PluginPortswitchPortswitch::$config_data[$sent]['stack']." ".PluginPortswitchPortswitch::$config_data[$sent]['hostname']); PluginPortswitchPortswitch::$config_data[$sent]['status'] = "Deaktiviert"; } //ID des geänderten Ports in Session übernehmen, um die Verbindung auf der nächsten Seite zu aktualisieren $_SESSION['port_changed'] = $sent; PluginPortswitchPortswitch::$config_data[$sent]['kommentar'] = $_POST['kommentar']; PluginPortswitchPortswitch::saveConfig(); Html::back(); } else { die("Fehler: Es wurden keine Daten übermittelt."); } ?>
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: parse_ini_file(../../../files/_plugins/portswitch/config.ini): failed to open stream: No such file or directory in /in/900jQ on line 17 Fehler: Es wurden keine Daten übermittelt.
Output for hhvm-3.10.0 - 3.12.0
Warning: No such file or directory in /in/900jQ on line 17 Fehler: Es wurden keine Daten übermittelt.