Пример #1
0
            echo "<td><div class='usage-disk'><span style='margin:0;width:{$free}%' class='" . usage_color($free, true) . "'><span>" . my_scale($partition['avail'], $unit) . " {$unit}</span></span></div></td>";
        }
    } else {
        echo "<td>-</td><td>-</td>";
    }
}
switch ($_POST['action']) {
    case 'get_content':
        $disks = get_all_disks_info();
        echo "<table class='usb_disks'><thead><tr><td>Device</td><td>Identification</td><td></td><td>Temp</td><td>FS</td><td>Size</td><td>Used</td><td>Free</td><td>Open files</td><td>Auto mount</td><td>Script</td></tr></thead>";
        echo "<tbody>";
        if (count($disks)) {
            $odd = "odd";
            foreach ($disks as $disk) {
                echo "<tr class='{$odd}'>";
                printf("<td><img src='/webGui/images/%s'> %s</td>", is_disk_running($disk['device']) ? "green-on.png" : "green-blink.png", basename($disk['device']));
                $disk_mounted = false;
                foreach ($disk['partitions'] as $p) {
                    if (is_mounted($p['device'])) {
                        $disk_mounted = TRUE;
                    }
                }
                $m_button = "<td><span style='width:auto;text-align:right;'>" . ($disk_mounted ? "<button type='button' style='padding:2px 7px 2px 7px;' onclick=\"usb_mount('/usr/local/sbin/usb_umount {$disk[device]}');\"><i class='glyphicon glyphicon-export'></i> Unmount</button>" : "<button type='button' style='padding:2px 7px 2px 7px;' onclick=\"usb_mount('/usr/local/sbin/usb_mount {$disk[device]}');\"><i class='glyphicon glyphicon-import'></i>  Mount</button>") . "</span></td>";
                echo "<td><i class='glyphicon glyphicon-hdd hdd'></i>" . $disk['partitions'][0]['serial'] . $m_button . "</td>";
                $temp = my_temp($disk['temperature']);
                echo "<td >{$temp}</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td>";
                echo "<td><input type='checkbox' class='automount' serial='" . $disk['partitions'][0]['serial'] . "' " . ($disk['partitions'][0]['automount'] ? 'checked' : '') . "></td><td>-</td></tr>";
                foreach ($disk['partitions'] as $partition) {
                    $mounted = is_mounted($partition['device']);
                    echo "<tr class='{$odd}'><td></td><td><div>";
                    $fscheck = sprintf(get_fsck_commands($partition['fstype'])['ro'], $partition['device']);
 if ($mounted) {
     $mbutton .= "<button type='button' style='padding:2px 7px 2px 7px;' onclick=\"usb_mount('/usr/local/sbin/unassigned_umount {$disk[device]}');\"><i class='glyphicon glyphicon-export'></i> Unmount</button>";
 } else {
     $mbutton .= "<button type='button' style='padding:2px 7px 2px 7px;' onclick=\"usb_mount('/usr/local/sbin/unassigned_mount {$disk[device]}');\"><i class='glyphicon glyphicon-import'></i>  Mount</button>";
 }
 $preclear_link = !$mounted && file_exists("plugins/preclear.disk/icons/precleardisk.png") ? " <a title='Preclear' class='exec green' href='/Settings/Preclear'><img src='plugins/preclear.disk/icons/precleardisk.png'></a>" : "";
 if ($p === FALSE) {
     $hdd_serial = "<span class='exec toggle-hdd' hdd='{$disk_name}'><i class='glyphicon glyphicon-hdd hdd'></i><i class='glyphicon glyphicon-plus-sign glyphicon-append'></i>{$disk[serial]}</span>{$preclear_link}<div id='preclear_{$disk_name}'></div>";
 } else {
     $hdd_serial = "<span class='exec toggle-hdd' hdd='{$disk_name}'><i class='glyphicon glyphicon-hdd hdd'></i><span style='margin:4px;'></span>{$disk[serial]}</span>{$preclear_link}<div id='preclear_{$disk_name}'></div>";
 }
 if (is_file("/tmp/preclear_stat_{$disk_name}")) {
     $preclear .= "get_preclear('{$disk_name}');";
 }
 echo "<tr class='{$odd}'>";
 echo "<td><img src='/webGui/images/" . (is_disk_running($disk['device']) ? "green-on.png" : "green-blink.png") . "'> {$disk_name}</td>";
 echo "<td>{$hdd_serial}</td>";
 echo "<td>{$mbutton}</td>";
 echo "<td>{$temp}</td>";
 echo $p ? $p[5] : "<td>-</td>";
 echo "<td>" . my_scale($disk['size'], $unit) . " {$unit}</td>";
 echo $p ? $p[7] : "<td>-</td>";
 echo $p ? $p[8] : "<td>-</td><td>-</td>";
 echo "<td><input type='checkbox' class='automount' serial='" . $disk['partitions'][0]['serial'] . "' " . ($disk['partitions'][0]['automount'] ? 'checked' : '') . "></td>";
 echo $p ? $p[10] : "<td>-</td>";
 echo $p ? $p[11] : "<td>-</td>";
 echo "</tr>";
 if (!$p || $p) {
     foreach ($disk['partitions'] as $partition) {
         foreach (render_partition($disk, $partition) as $l) {
             echo str_replace("__SHOW__", count($disk['partitions']) > 1 ? "display:none;" : "display:none;", $l);
Пример #3
0
function get_temp($dev)
{
    $tc = $GLOBALS["paths"]["hdd_temp"];
    $temps = is_file($tc) ? json_decode(file_get_contents($tc), TRUE) : array();
    if (isset($temps[$dev]) && time() - $temps[$dev]['timestamp'] < 120) {
        return $temps[$dev]['temp'];
    } else {
        if (is_disk_running($dev)) {
            $temp = trim(shell_exec("/usr/sbin/smartctl -A -d sat,12 {$dev} 2>/dev/null| /bin/grep -m 1 -i Temperature_Celsius | /bin/awk '{print \$10}'"));
            if (!is_numeric($temp)) {
                $temp = trim(shell_exec("/usr/sbin/smartctl -A -d sat,12 {$dev} 2>/dev/null| /bin/grep -m 1 -i Airflow_Temperature | /bin/awk '{print \$10}'"));
            }
            $temp = is_numeric($temp) ? $temp : "*";
            $temps[$dev] = array('timestamp' => time(), 'temp' => $temp);
            file_put_contents($tc, json_encode($temps));
            return $temp;
        } else {
            return "*";
        }
    }
}
 }
 $temp = my_temp($disk['temperature']);
 $mbutton = make_mount_button($disk);
 $preclear_link = $disk['size'] !== 0 && !$flash && !$mounted && $Preclear && !$preclearing ? "&nbsp;&nbsp;" . $Preclear->Link($disk_name, "icon") : "";
 if ($p && !($is_precleared || $preclearing)) {
     $add_toggle = TRUE;
     $hdd_serial = "<span title='Click to view partitions/mount points.' class='exec toggle-hdd' hdd='{$disk_name}'>\n\t\t\t\t\t\t\t\t\t\t\t\t \t<i class='glyphicon glyphicon-hdd hdd'></i>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i class='glyphicon glyphicon-plus-sign glyphicon-append'></i>\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t\t{$disk[serial]}\n\t\t\t\t\t\t\t\t\t\t\t\t{$preclear_link}\n\t\t\t\t\t\t\t\t\t\t\t\t<div id='preclear_{$disk_name}'></div>";
 } else {
     $add_toggle = FALSE;
     $hdd_serial = "<span class='toggle-hdd' hdd='{$disk_name}'>\n\t\t\t\t\t\t\t\t\t\t\t\t \t<i class='glyphicon glyphicon-hdd hdd'></i>\n\t\t\t\t\t\t\t\t\t\t\t\t </span>\n\t\t\t\t\t\t\t\t\t\t\t\t <span style='margin:4px;'></span>\n\t\t\t\t\t\t\t\t\t\t\t\t {$disk[serial]}\n\t\t\t\t\t\t\t\t\t\t\t\t {$preclear_link}\n\t\t\t\t\t\t\t\t\t\t\t\t <div id='preclear_{$disk_name}'></div>";
 }
 echo "<tr class='{$odd} toggle-disk'>";
 if ($flash || !is_file($disk['partitions'][0]['command']) && !$mounted && !$preclearing) {
     echo "<td><img src='/webGui/images/green-blink.png'> {$disk_name}</td>";
 } else {
     echo "<td title='Disk Attributes on {$disk_name}.'><img src='/webGui/images/" . (is_disk_running($disk['device']) ? "green-on.png" : "green-blink.png") . "'>";
     echo "<a href='/Main/DeviceAttributes?name={$disk_name}&file=/tmp/screen_buffer'> {$disk_name}</a></td>";
 }
 echo "<td>{$hdd_serial}</td>";
 echo "<td class='mount'>{$mbutton}</td>";
 echo "<td>{$temp}</td>";
 echo $p ? $p[5] : "<td>-</td>";
 echo "<td>" . my_scale($disk['size'], $unit) . " {$unit}</td>";
 echo $p ? $p[7] : "<td>-</td>";
 echo $p ? $p[8] : "<td>-</td><td>-</td>";
 echo $p ? $p[9] : "<td>-</td>";
 echo $p ? $p[10] : "<td>-</td>";
 echo $p ? $p[11] : "<td>-</td>";
 echo $p ? $p[12] : "<td>-</td>";
 echo "</tr>";
 if ($add_toggle) {
Пример #5
0
function get_temp($dev) {
  if (is_disk_running($dev)) {
    $temp = trim(shell_exec("smartctl -A -d sat,12 $dev 2>/dev/null| grep -m 1 -i Temperature_Celsius | awk '{print $10}'"));
    return (is_numeric($temp)) ? $temp : "*";
  }
}