function widgetHardDrives()
{
    global $drive;
    $warningthreshold = 90;
    if (!empty($drive)) {
        echo "<table border=\"0\" id=\"harddrives\">\n";
        echo "\t<col id=\"col-disk\" />\n";
        echo "\t<col id=\"col-capacity\" />\n";
        echo "\t<col id=\"col-remaining\" />\n";
        echo "\t<col id=\"col-progress\" />\n";
        echo "\t<tr>\n";
        echo "\t\t<th>Disk</th>\n";
        echo "\t\t<th>Size</th>\n";
        echo "\t\t<th>Free</th>\n";
        echo "\t\t<th>Usage</th>\n";
        echo "\t</tr>\n";
        foreach ($drive as $drivelabel => $drivepath) {
            echo "\t<tr>\n";
            echo "\t\t<td>" . $drivelabel . "</td>\n";
            echo "\t\t<td>" . ByteSize(disk_total_space($drivepath)) . "</td>\n";
            echo "\t\t<td>" . ByteSize(disk_free_space($drivepath)) . "</td>\n";
            echo "\t\t<td><div class=\"progressbar\"><div class=\"progress" . (disk_used_percentage($drivepath) > $warningthreshold ? " warning" : "") . "\" style=\"width:" . disk_used_percentage($drivepath) . "%\"></div><div class=\"progresslabel\">" . sprintf("%u", disk_used_percentage($drivepath)) . "%</div></div></td>\n";
            echo "\t</tr>\n";
        }
        echo "</table>\n";
    }
}
Example #2
0
File: _doc.php Project: voota/voota
      <?php 
    echo __('Documento');
    ?>
:
      <span id="fileName"> 
        <?php 
    if ($propuesta->getDoc()) {
        ?>
    	    <a class="document" href="<?php 
        echo S3Voota::getImagesUrl() . '/docs/' . $propuesta->getDoc();
        ?>
"><?php 
        echo $propuesta->getDoc();
        ?>
</a> (<?php 
        echo ByteSize($propuesta->getDocSize());
        ?>
)
        <?php 
    } else {
        ?>
    	    <?php 
        echo __('ninguno');
        ?>
        <?php 
    }
    ?>
      </span>
      <?php 
    if ($sf_user->isAuthenticated() && $propuesta->getSfGuardUserId() == $sf_user->getGuardUser()->getId()) {
        ?>
Example #3
0
function printTable($name, $cat, $size, $addToSab, $nzblink, $item_desc, $image = "", $weblink = "")
{
    if ($image != "") {
        $image = "<a href=" . $image . " class=\"highslide\" onclick=\"return hs.expand(this)\"><img id='search-thumb' src='" . $image . "' /></a>";
    }
    if ($weblink != "") {
        if (strpos($weblink, 'imdb') !== false) {
            $weblink = "<a href=" . $weblink . " target='_blank'><img id='imdb-badge' src='./media/imdb.png' /></a>";
        } else {
            $weblink = "";
        }
    }
    return "\t<tr class=\"row\">\n\t\t\t\t\t<td style='padding-top:5px;overflow:hidden;'><a href=\"#\";  onclick=\"sabAddUrl('" . htmlentities($addToSab) . "'); return false;\"><img class=\"table-icon\" src=\"./media/sab2_16.png\" alt=\"Download with SABnzdd+\"/></a></td>\n\t\t\t\t\t<td style='text-overflow:ellipsis;overflow:hidden; white-space: nowrap;'>" . $image . $weblink . "<a href='" . $nzblink . "' target='_blank'; onMouseOver=\"ShowPopupBox('" . $item_desc . "');\" onMouseOut=\"HidePopupBox();\"><div style='padding-top:4px;'>{$name}</div></a></td>\n\t\t\t\t\t<td style='padding-top:4px;' class='filesize'>" . ByteSize($size) . "</td>\n\t\t\t\t\t<td style='padding-top:4px;text-overflow:ellipsis;overflow:hidden; white-space: nowrap;'>{$cat}</td>\n\t\t\t\t</tr>";
}
wp_nonce_field("_wpr_truncate_queue");
?>
<input type="submit" name="submit" value="Empty The Queue" onClick="return window.confirm('WARNING: Are you sure you want to delete all the rows in the queue table? All sent and unsent e-mails will be deleted. This action CANNOT be undone.');" class="button-primary" style="background-color:#F00"/></form>
<form style="display:inline" action="<?php 
echo admin_url("admin.php?page=_wpr/queue_management&subact=delete_sent_emails");
?>
" method="post">
<?php 
wp_nonce_field("_wpr_delete_sent_mail");
?>
<input type="submit" name="submit" value="Delete Only Sent E-mails" onClick="return window.confirm('Are you sure you want to delete all the sent e-mail from the queue? This action CANNOT be undone.');" class="button-primary" />
</form>
<p></p><p></p>

<strong>Important: </strong> All sent emails in queue will be automatically deleted if queue size exceeds <?php 
echo ByteSize(WPR_MAX_QUEUE_TABLE_SIZE);
?>
 in size. 
</div>

<?php 
/*
<h2>Delivery Queue</h2>

<table class="widefat">
   <tr>
      <thead>
      <th> To </th>
      <th> Subject </th>
      <th></th>
    </thead>
Example #5
0
?>
      <?php 
if ($form['doc']->getValue()) {
    ?>
        <p><?php 
    echo __('Documento');
    ?>
: <a class="document"  href="<?php 
    echo S3Voota::getImagesUrl() . '/docs/' . $form['doc']->getValue();
    ?>
"><?php 
    echo $form['doc']->getValue();
    ?>
</a> (<?php 
    $s = new S3Voota();
    echo ByteSize($s->getSize('docs/' . $form['doc']->getValue()));
    ?>
)</p><?php 
    // TODO: Sustituir por enlace a fichero y tamaño de fichero correcto
    ?>
      <?php 
}
?>
    </div>
    
    <div id="sidebar">
      <div id="external-links">
      	<?php 
if ($form['enlace_n1']['url']->getValue() || $form['enlace_n2']['url']->getValue() || $form['enlace_n3']['url']->getValue() || $form['enlace_n4']['url']->getValue() || $form['enlace_n5']['url']->getValue()) {
    ?>
          <h3><?php 
 function get_filesize($filename)
 {
     $max_allowed_size = $this->max_allowed_size;
     if (file_exists($filename)) {
         $size = filesize($filename);
         if ($size > $max_allowed_size) {
             $readable_size = ByteSize($size);
             $readable_max_size = ByteSize($max_allowed_size);
             $this->Session->setFlash("Filesize exceeded! File: {$filename} has {$readable_size}, while maximum {$readable_max_size} is allowed.");
             return false;
         } else {
             return true;
         }
     } else {
         //elseif(file_exists($filename))
         $ch = curl_init($filename);
         curl_setopt($ch, CURLOPT_NOBODY, true);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_HEADER, true);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
         //not necessary unless the file redirects
         $data = curl_exec($ch);
         curl_close($ch);
         if ($data === false) {
             $this->Session->setFlash("Error in calculating remote file size: {$filename} - try again, please.");
             return false;
         }
         $contentLength = 'unknown';
         $status = 'unknown';
         if (preg_match('/^HTTP\\/1\\.[01] (\\d\\d\\d)/', $data, $matches)) {
             $status = (int) $matches[1];
         }
         if (preg_match('/Content-Length: (\\d+)/', $data, $matches)) {
             $contentLength = (int) $matches[1];
         }
         # echo 'HTTP Status: ' . $status . "\n";
         # echo 'Content-Length: ' . $contentLength;
         if ($contentLength > $max_allowed_size) {
             $this->Session->setFlash("File: {$filename}, size: {$contentLength} - maximum {$max_allowed_size} bytes allowed.");
             return false;
         } else {
             return true;
         }
     }
     //endif(file_exists($filename));
 }
            }
            // Cut off array at 5 each
            $torrentsDownloading = array_slice($torrentsDownloading, 0, 5);
            // List all pending downloads
            foreach ($torrentsDownloading as $torrentDone) {
                $name = $torrentDone[2];
                $sizeFull = $torrentDone[3];
                $sizeDone = $torrentDone[5];
                $percentage = $torrentDone[4] / 10;
                $speed = $torrentDone[9];
                echo "<div class='torrent'>";
                echo $name;
                echo "<progress value='" . $sizeDone . "' max='" . $sizeFull . "'></progress>";
                echo "<span class='stats'>";
                echo ByteSize($sizeDone) . " / " . ByteSize($sizeFull) . " (" . $percentage . "%)";
                echo " @ " . ByteSize($speed);
                echo "</span>";
                echo "</div>";
            }
        }
        ?>
				</div>
			</div>
		</section>
		<?php 
    }
    ?>

		<?php 
    if ($config['transmission']) {
        ?>
 function showForm($target, $ID)
 {
     global $DB, $CFG_GLPI, $LANG;
     $history = new PluginFusioninventorySnmphistory();
     if (!PluginFusioninventory::haveRight("snmp_networking", "r")) {
         return false;
     }
     if (PluginFusioninventory::haveRight("snmp_networking", "w")) {
         $canedit = true;
     } else {
         $canedit = false;
     }
     include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php";
     $this->ID = $ID;
     $nw = new Netwire();
     $CommonItem = new CommonItem();
     $plugin_fusioninventory_snmp = new PluginFusioninventorySNMP();
     echo "<script type='text/javascript' src='" . GLPI_ROOT . "/lib/extjs/adapter/prototype/prototype.js'></script>";
     echo "<script type='text/javascript' src='" . GLPI_ROOT . "/lib/extjs/adapter/prototype/effects.js'></script>";
     if (!($data = $this->find("`FK_networking`='" . $ID . "'", '', 1))) {
         // Add in database if not exist
         $input['FK_networking'] = $ID;
         $ID_tn = $this->add($input);
         $this->getFromDB($ID_tn);
     } else {
         foreach ($data as $ID_tn => $datas) {
             $this->fields = $data[$ID_tn];
         }
     }
     $PID = $this->fields['last_PID_update'];
     // Form networking informations
     echo "<div align='center'>\n            <form method='post' name='snmp_form' id='snmp_form' action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='3'>";
     echo $LANG['plugin_fusioninventory']["snmp"][11];
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["profile"][24] . "</td>";
     echo "<td align='center'>";
     $query_models = "SELECT * \n                       FROM `glpi_plugin_fusioninventory_model_infos`\n                       WHERE `device_type`!='2'\n                             AND `device_type`!='0';";
     $result_models = $DB->query($query_models);
     $exclude_models = array();
     while ($data_models = $DB->fetch_array($result_models)) {
         $exclude_models[] = $data_models['ID'];
     }
     Dropdown::show("PluginFusioninventoryModelInfos", array('name' => "model_infos", 'value' => $this->fields['FK_model_infos'], 'comments' => 0, 'used' => $exclude_models));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . $LANG['plugin_fusioninventory']["functionalities"][43] . "</td>";
     echo "<td align='center'>";
     PluginFusioninventorySNMP::auth_dropdown($this->fields['FK_snmp_connection']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>";
     echo " <input type='submit' name='GetRightModel'\n              value='" . $LANG['plugin_fusioninventory']["model_info"][13] . "' class='submit'/></td>";
     echo "<td>";
     echo "<input type='hidden' name='ID' value='" . $ID . "'>";
     echo "<input type='submit' name='update' value=\"" . $LANG["buttons"][7] . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table></form>";
     // Remote action of agent
     $pfit = new PluginFusioninventoryTask();
     $pfit->RemoteStateAgent($target, $ID, NETWORKING_TYPE, array('INVENTORY' => 1));
     // SNMP Informations
     //		echo "<div align='center'>
     echo "<form method='post' name='snmp_form' id='snmp_form'  action=\"" . $target . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='3'>";
     echo $LANG['plugin_fusioninventory']["title"][1];
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td colspan='2' height='30'>";
     echo $LANG['plugin_fusioninventory']["snmp"][52] . ": " . convDateTime($this->fields['last_fusioninventory_update']);
     echo "</td>";
     echo "</tr>";
     // Get link field to detect if cpu, memory and uptime are get onthis network device
     $Array_Object_TypeNameConstant = $plugin_fusioninventory_snmp->GetLinkOidToFields($ID, NETWORKING_TYPE);
     $mapping_name = array();
     foreach ($Array_Object_TypeNameConstant as $object => $mapping_type_name) {
         $mapping_name[$mapping_type_name] = "1";
     }
     if (isset($mapping_name['uptime']) and $mapping_name['uptime'] == "1") {
         echo "<tr class='tab_bg_1 center'>";
         echo "<td>" . $LANG['plugin_fusioninventory']["snmp"][12] . "</td>";
         echo "<td>";
         $sysUpTime = $this->fields['uptime'];
         if (strstr($sysUpTime, "days")) {
             list($day, $hour, $minute, $sec, $ticks) = sscanf($sysUpTime, "%d days, %d:%d:%d.%d");
         } else {
             if (strstr($sysUpTime, "hours")) {
                 $day = 0;
                 list($hour, $minute, $sec, $ticks) = sscanf($sysUpTime, "%d hours, %d:%d.%d");
             } else {
                 if (strstr($sysUpTime, "minutes")) {
                     $day = 0;
                     $hour = 0;
                     list($minute, $sec, $ticks) = sscanf($sysUpTime, "%d minutes, %d.%d");
                 } else {
                     if ($sysUpTime == "0") {
                         $day = 0;
                         $hour = 0;
                         $minute = 0;
                         $sec = 0;
                     } else {
                         list($hour, $minute, $sec, $ticks) = sscanf($sysUpTime, "%d:%d:%d.%d");
                         $day = 0;
                     }
                 }
             }
         }
         echo "<b>{$day}</b> " . $LANG["stats"][31] . " ";
         echo "<b>{$hour}</b> " . $LANG["job"][21] . " ";
         echo "<b>{$minute}</b> " . $LANG["job"][22] . " ";
         echo " " . strtolower($LANG["rulesengine"][42]) . " <b>{$sec}</b> " . $LANG["stats"][34] . " ";
         echo "</td>";
         echo "</tr>";
     }
     if (isset($mapping_name['cpu']) and $mapping_name['cpu'] == "1" or isset($mapping_name['cpuuser']) and $mapping_name['cpuuser'] == "1" and (isset($mapping_name['cpusystem']) and $mapping_name['cpusystem'] == "1")) {
         echo "<tr class='tab_bg_1 center'>";
         echo "<td>" . $LANG['plugin_fusioninventory']["snmp"][13] . "</td>";
         echo "<td>";
         PluginFusioninventoryDisplay::bar($this->fields['cpu'], '', 'inverse');
         echo "</td>";
         echo "</tr>";
     }
     if (isset($mapping_name['memory']) and $mapping_name['memory'] == "1") {
         echo "<tr class='tab_bg_1 center'>";
         echo "<td>" . $LANG['plugin_fusioninventory']["snmp"][14] . "</td>";
         echo "<td>";
         $query2 = "SELECT *\n                    FROM `glpi_networking`\n                    WHERE `ID`='" . $ID . "';";
         $result2 = $DB->query($query2);
         $data2 = $DB->fetch_assoc($result2);
         if (empty($data2["ram"])) {
             $ram_pourcentage = 0;
         } else {
             $ram_pourcentage = ceil(100 * ($data2["ram"] - $this->fields['memory']) / $data2["ram"]);
         }
         PluginFusioninventoryDisplay::bar($ram_pourcentage, " (" . ($data2["ram"] - $this->fields['memory']) . " Mo / " . $data2["ram"] . " Mo)", 'inverse');
         echo "</td>";
         echo "</tr>";
     }
     echo "</table></form>";
     // ********************************************************************************************** //
     // *********************************** METTRE TABLEAU DES PORTS ********************************* //
     // ********************************************************************************************** //
     function ByteSize($bytes, $sizeoct = 1024)
     {
         $size = $bytes / $sizeoct;
         if ($size < $sizeoct) {
             $size = number_format($size, 0);
             $size .= ' K';
         } else {
             if ($size / $sizeoct < $sizeoct) {
                 $size = number_format($size / $sizeoct, 0);
                 $size .= ' M';
             } else {
                 if ($size / $sizeoct / $sizeoct < $sizeoct) {
                     $size = number_format($size / $sizeoct / $sizeoct, 0);
                     $size .= ' G';
                 } else {
                     if ($size / $sizeoct / $sizeoct / $sizeoct < $sizeoct) {
                         $size = number_format($size / $sizeoct / $sizeoct / $sizeoct, 0);
                         $size .= ' T';
                     }
                 }
             }
         }
         return $size;
     }
     $query = "\n\t\tSELECT *,glpi_plugin_fusioninventory_networking_ports.ifmac as ifmacinternal\n\t\t\n\t\tFROM glpi_plugin_fusioninventory_networking_ports\n\n\t\tLEFT JOIN glpi_networking_ports\n\t\tON glpi_plugin_fusioninventory_networking_ports.FK_networking_ports = glpi_networking_ports.ID \n\t\tWHERE glpi_networking_ports.on_device='" . $ID . "'\n\t\tORDER BY logical_number ";
     echo "<script  type='text/javascript'>\nfunction close_array(id){\n\tdocument.getElementById('plusmoins'+id).innerHTML = '<img src=\\'" . GLPI_ROOT . "/pics/collapse.gif\\''+\n      'onClick=\\'Effect.Fade(\"viewfollowup'+id+'\");appear_array('+id+');\\' />';\n} \nfunction appear_array(id){\n\tdocument.getElementById('plusmoins'+id).innerHTML = '<img src=\\'" . GLPI_ROOT . "/pics/expand.gif\\''+\n      'onClick=\\'Effect.Appear(\"viewfollowup'+id+'\");close_array('+id+');\\' />';\n}\t\t\n\t\t\n\t\t</script>";
     echo "<table class='tab_cadre' cellpadding='5' width='1100'>";
     echo "<tr class='tab_bg_1'>";
     $query_array = "SELECT *\n                      FROM `glpi_display`\n                      WHERE `type`='" . PLUGIN_FUSIONINVENTORY_SNMP_NETWORKING_PORTS . "'\n                            AND `FK_users`='0'\n                      ORDER BY `rank`;";
     $result_array = $DB->query($query_array);
     echo "<th colspan='" . (mysql_num_rows($result_array) + 2) . "'>";
     echo $LANG['plugin_fusioninventory']["snmp"][40];
     $result = $DB->query($query);
     echo ' (' . $DB->numrows($result) . ')';
     if ($_SESSION["glpilanguage"] == "fr_FR") {
         $url_legend = "https://forge.indepnet.net/wiki/fusioninventory/Fr_VI_visualisationsdonnees_2_reseau";
     } else {
         $url_legend = "https://forge.indepnet.net/wiki/fusioninventory/En_VI_visualisationsdonnees_2_reseau";
     }
     echo " <a href='" . $url_legend . "'>[ " . $LANG['plugin_fusioninventory']["functionalities"][6] . " ]</a>";
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo '<th><img alt="Sélectionnez les éléments à afficher par défaut" 
                  title="Sélectionnez les éléments à afficher par défaut"
                  src="' . GLPI_ROOT . '/pics/options_search.png" class="pointer"
                  onclick="var w = window.open(\'' . GLPI_ROOT . '/front/popup.php?popup=search_config&type=5157\' ,\'glpipopup\',
                     \'height=400,
                  width=1000, top=100, left=100, scrollbars=yes\' ); w.focus();"></th>';
     echo "<th>" . $LANG["common"][16] . "</th>";
     $query_array = "SELECT * \n                      FROM `glpi_display`\n                      WHERE `type`='5157'\n                             AND `FK_users`='0'\n                      ORDER BY `rank`;";
     $result_array = $DB->query($query_array);
     while ($data_array = $DB->fetch_array($result_array)) {
         echo "<th>";
         switch ($data_array['num']) {
             case 2:
                 echo $LANG['plugin_fusioninventory']["snmp"][42];
                 break;
             case 3:
                 echo $LANG['plugin_fusioninventory']["snmp"][43];
                 break;
             case 4:
                 echo $LANG['plugin_fusioninventory']["snmp"][44];
                 break;
             case 5:
                 echo $LANG['plugin_fusioninventory']["snmp"][45];
                 break;
             case 6:
                 echo $LANG['plugin_fusioninventory']["snmp"][46];
                 break;
             case 7:
                 echo $LANG['plugin_fusioninventory']["snmp"][47];
                 break;
             case 8:
                 echo $LANG['plugin_fusioninventory']["snmp"][48];
                 break;
             case 9:
                 echo $LANG['plugin_fusioninventory']["snmp"][49];
                 break;
             case 10:
                 echo $LANG['plugin_fusioninventory']["snmp"][51];
                 break;
             case 11:
                 echo $LANG['plugin_fusioninventory']["mapping"][115];
                 break;
             case 12:
                 echo $LANG["networking"][17];
                 break;
             case 13:
                 echo $LANG['plugin_fusioninventory']["snmp"][50];
                 break;
             case 14:
                 echo $LANG["networking"][56];
                 break;
             case 15:
                 echo $LANG['plugin_fusioninventory']["snmp"][41];
                 break;
         }
         echo "</th>";
     }
     echo "</tr>";
     // Fin de l'entête du tableau
     if ($result) {
         while ($data = $DB->fetch_array($result)) {
             $background_img = "";
             if ($data["trunk"] == "1" and (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1"))) {
                 $background_img = " style='background-image: url(\"" . GLPI_ROOT . "/plugins/fusioninventory/pics/port_trunk.png\"); '";
             } else {
                 if ($data["trunk"] == "-1" and (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1"))) {
                     $background_img = " style='background-image: url(\"" . GLPI_ROOT . "/plugins/fusioninventory/pics/multiple_mac_addresses.png\"); '";
                 } else {
                     if (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1")) {
                         $background_img = " style='background-image: url(\"" . GLPI_ROOT . "/plugins/fusioninventory/pics/connected_trunk.png\"); '";
                     }
                 }
             }
             echo "<tr class='tab_bg_1 center' height='40'" . $background_img . ">";
             echo "<td id='plusmoins" . $data["ID"] . "'><img src='" . GLPI_ROOT . "/pics/expand.gif' onClick='Effect.Appear(\"viewfollowup" . $data["ID"] . "\");close_array(" . $data["ID"] . ");' /></td>";
             echo "<td><a href='networking.port.php?ID=" . $data["ID"] . "'>" . $data["name"] . "</a></td>";
             $query_array = "SELECT *\n                            FROM `glpi_display`\n                            WHERE `type`='5157'\n                                  AND `FK_users`='0'\n                            ORDER BY `rank`;";
             $result_array = $DB->query($query_array);
             while ($data_array = $DB->fetch_array($result_array)) {
                 switch ($data_array['num']) {
                     case 2:
                         echo "<td>" . $data["ifmtu"] . "</td>";
                         break;
                     case 3:
                         echo "<td>" . ByteSize($data["ifspeed"], 1000) . "bps</td>";
                         break;
                     case 4:
                         echo "<td>";
                         if (strstr($data["ifstatus"], "up") or strstr($data["ifinternalstatus"], "1")) {
                             echo "<img src='" . GLPI_ROOT . "/pics/greenbutton.png'/>";
                         } else {
                             if (strstr($data["ifstatus"], "down") or strstr($data["ifinternalstatus"], "2")) {
                                 echo "<img src='" . GLPI_ROOT . "/pics/redbutton.png'/>";
                             } else {
                                 if (strstr($data["ifstatus"], "testing") or strstr($data["ifinternalstatus"], "3")) {
                                     echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                                 }
                             }
                         }
                         echo "</td>";
                         break;
                     case 5:
                         echo "<td>" . $data["iflastchange"] . "</td>";
                         break;
                     case 6:
                         echo "<td>";
                         if ($data["ifinoctets"] == "0") {
                             echo "-";
                         } else {
                             echo ByteSize($data["ifinoctets"], 1000) . "o";
                         }
                         echo "</td>";
                         break;
                     case 7:
                         if ($data["ifinerrors"] == "0") {
                             echo "<td>-";
                         } else {
                             echo "<td background='#cf9b9b' class='tab_bg_1_2'>";
                             echo $data["ifinerrors"];
                         }
                         echo "</td>";
                         break;
                     case 8:
                         echo "<td>";
                         if ($data["ifinoctets"] == "0") {
                             echo "-";
                         } else {
                             echo ByteSize($data["ifoutoctets"], 1000) . "o";
                         }
                         echo "</td>";
                         break;
                     case 9:
                         if ($data["ifouterrors"] == "0") {
                             echo "<td>-";
                         } else {
                             echo "<td background='#cf9b9b' class='tab_bg_1_2'>";
                             echo $data["ifouterrors"];
                         }
                         echo "</td>";
                         break;
                     case 10:
                         echo "<td>" . $data["portduplex"] . "</td>";
                         break;
                     case 11:
                         // ** internal mac
                         echo "<td>" . $data["ifmac"] . "</td>";
                         break;
                     case 12:
                         // ** Mac address and link to device which are connected to this port
                         $opposite_port = $nw->getOppositeContact($data["FK_networking_ports"]);
                         if ($opposite_port != "") {
                             $query_device = "SELECT * \n                                         FROM `glpi_networking_ports`\n                                         WHERE `ID`='" . $opposite_port . "';";
                             $result_device = $DB->query($query_device);
                             $data_device = $DB->fetch_assoc($result_device);
                             $CommonItem->getFromDB($data_device["device_type"], $data_device["on_device"]);
                             $link1 = $CommonItem->getLink(1);
                             $link = str_replace($CommonItem->getName(0), $data_device["ifmac"], $CommonItem->getLink());
                             $link2 = str_replace($CommonItem->getName(0), $data_device["ifaddr"], $CommonItem->getLink());
                             if ($data_device["device_type"] == PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN) {
                                 if ($CommonItem->getField("accepted") == "1") {
                                     echo "<td style='background:#bfec75'\n                                        class='tab_bg_1_2'>" . $link1;
                                 } else {
                                     echo "<td background='#cf9b9b'\n                                        class='tab_bg_1_2'>" . $link1;
                                 }
                                 if (!empty($link)) {
                                     echo "<br/>" . $link;
                                 }
                                 if (!empty($link2)) {
                                     echo "<br/>" . $link2;
                                 }
                                 echo "</td>";
                             } else {
                                 echo "<td>" . $link1;
                                 if (!empty($link)) {
                                     echo "<br/>" . $link;
                                 }
                                 if (!empty($link2)) {
                                     echo "<br/>" . $link2;
                                 }
                                 echo "</td>";
                             }
                         } else {
                             echo "<td></td>";
                         }
                         break;
                     case 13:
                         // ** Connection status
                         echo "<td>";
                         if (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1")) {
                             echo "<img src='" . GLPI_ROOT . "/pics/greenbutton.png'/>";
                         } else {
                             if (strstr($data["ifstatus"], "down") or strstr($data["ifstatus"], "2")) {
                                 echo "<img src='" . GLPI_ROOT . "/pics/redbutton.png'/>";
                             } else {
                                 if (strstr($data["ifstatus"], "testing") or strstr($data["ifstatus"], "3")) {
                                     echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                                 } else {
                                     if (strstr($data["ifstatus"], "dormant") or strstr($data["ifstatus"], "5")) {
                                         echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/orangebutton.png'/>";
                                     }
                                 }
                             }
                         }
                         echo "</td>";
                         break;
                     case 14:
                         echo "<td>";
                         $canedit = haveRight("networking", "w");
                         $used = array();
                         $query_vlan = "SELECT * FROM glpi_networking_vlan WHERE FK_port='" . $data["ID"] . "'";
                         $result_vlan = $DB->query($query_vlan);
                         if ($DB->numrows($result_vlan) > 0) {
                             echo "<table cellpadding='0' cellspacing='0'>";
                             while ($line = $DB->fetch_array($result_vlan)) {
                                 $used[] = $line["FK_vlan"];
                                 $a_vlan = Dropdown::getDropdownName("glpi_dropdown_vlan", $line["FK_vlan"], 1);
                                 echo "<tr><td>" . $a_vlan['name'] . " [" . $a_vlan['comments'] . "]";
                                 echo "</td><td>";
                                 if ($canedit) {
                                     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?unassign_vlan=unassigned&amp;ID=" . $line["ID"] . "'>";
                                     echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/delete2.png\" alt='" . $LANG['buttons'][6] . "' title='" . $LANG['buttons'][6] . "'></a>";
                                 } else {
                                     echo "&nbsp;";
                                 }
                                 echo "</td></tr>";
                             }
                             echo "</table>";
                         } else {
                             echo "&nbsp;";
                         }
                         echo "</td>";
                         break;
                     case 15:
                         //Port description
                         echo "<td>" . $data["ifdescr"] . "</td>";
                         break;
                 }
             }
             echo "</tr>";
             // Historique
             echo "\n\t\t\t\t<tr style='display: none;' id='viewfollowup" . $data["ID"] . "'>\n\t\t\t\t\t<td colspan='" . (mysql_num_rows($result_array) + 2) . "'>" . PluginFusioninventorySnmphistory::showHistory($data["ID"]) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t";
         }
     }
     echo "</table>";
 }
Example #9
0
 function backup($name, $comment)
 {
     global $PATH;
     global $db;
     function ByteSize($bytes)
     {
         $size = $bytes / 1024;
         if ($size < 1024) {
             $size = number_format($size, 2);
             $size .= ' KB';
         } else {
             if ($size / 1024 < 1024) {
                 $size = number_format($size / 1024, 2);
                 $size .= ' MB';
             } else {
                 if ($size / 1024 / 1024 < 1024) {
                     $size = number_format($size / 1024 / 1024, 2);
                     $size .= ' GB';
                 }
             }
         }
         return $size;
     }
     $this->r->player->broadcastMessage("Map backup now starting");
     $this->r->player->broadcastMessage("Issuing save-all command");
     $this->r->server->runConsoleCommand("save-all");
     $this->r->player->broadcastMessage("Issuing save-off command");
     $this->r->server->runConsoleCommand("save-off");
     $date = date('Y-m-d-Hi');
     $output = $PATH['backups'] . $date . ".tgz";
     if (!file_exists($PATH['backups'])) {
         mkdir($PATH['backups'], 0777);
     }
     shell_exec("tar -czf " . $output . " " . $PATH['minecraft'] . "world");
     $size = ByteSize(filesize($output));
     $result = $db->insert("backups", array("id" => "", "name" => $name, "date" => date('Y-m-d'), "time" => date('Hi'), "size" => $size, "comment" => $comment, "filename" => $output));
     $this->r->player->broadcastMessage("Issuing save-on command");
     $this->r->server->runConsoleCommand("save-on");
     return $result;
 }