function get_all_disks_info($bus = "all") { unassigned_log("Starting get_all_disks_info.", "DEBUG"); $d1 = time(); $ud_disks = get_unasigned_disks(); foreach ($ud_disks as $key => $disk) { if ($disk['type'] != $bus && $bus != "all") { continue; } $disk['temperature'] = "*"; $disk['size'] = intval(trim(shell_exec("/sbin/blockdev --getsize64 {$key} 2>/dev/null"))); $disk = array_merge($disk, get_disk_info($key)); foreach ($disk['partitions'] as $k => $p) { if ($p) { $disk['partitions'][$k] = get_partition_info($p); } } $ud_disks[$key] = $disk; } unassigned_log("Total time: " . (time() - $d1) . "s", "DEBUG"); usort($ud_disks, create_function('$a, $b', '$key="device";if ($a[$key] == $b[$key]) return 0; return ($a[$key] < $b[$key]) ? -1 : 1;')); return $ud_disks; }
<?php $plugin = "unassigned.devices"; require_once "plugins/{$plugin}/include/lib.php"; readfile('logging.htm'); function write_log($string) { if (empty($string)) { return; } $string = str_replace("\n", "<br>", $string); $string = str_replace('"', "\\\"", trim($string)); echo "<script>addLog(\"{$string}\");</script>"; @flush(); } if (isset($_GET['device']) && isset($_GET['owner'])) { $device = trim(urldecode($_GET['device'])); $info = get_partition_info($device, true); $owner = trim(urldecode($_GET['owner'])); $command = execute_script($info, 'ADD', TRUE); if ($command != "") { $command = $command . " 2>&1"; putenv("OWNER={$owner}"); write_log($command . "<br><br>"); $proc = popen($command, 'r'); while (!feof($proc)) { write_log(fgets($proc)); } } else { echo "No script file to execute!"; } }
function get_all_disks_info($bus="all") { // $d1 = time(); $disks = get_unasigned_disks(); foreach ($disks as $key => $disk) { if ($disk['type'] != $bus && $bus != "all") continue; $disk['temperature'] = get_temp($key); foreach ($disk['partitions'] as $k => $p) { $disk['partitions'][$k] = get_partition_info($p); } $disks[$key] = $disk; } // debug("get_all_disks_info: ".(time() - $d1)); return $disks; }