-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_hdd_temp.php
More file actions
executable file
·34 lines (29 loc) · 927 Bytes
/
get_hdd_temp.php
File metadata and controls
executable file
·34 lines (29 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php include_once("/var/www/html/site/secur.php"); ?>
<?php
function getTemp($disk){
$temp = shell_exec("sudo hddtemp $disk 2>&1");
return trim(explode(':', $temp)[2]);
}
function P($name, $type = "string"){
$pr = (isset($_POST[$name]) ? $_POST[$name] : (isset($_GET[$name]) ? $_GET[$name] : NULL));
if($type == "string")
return $pr;
elseif($type == "int" && $pr != NULL)
return intval($pr);
elseif($type == "float" && $pr != NULL)
return floatval($pr);
else return $pr;
}
function validateDevicePath($path) {
return preg_match('/^\/dev\/[a-zA-Z]+(\d+)?$/', $path) === 1;
}
$diskName = P("hdd");
$diskTmp = "";
$diskArray = explode(';', $diskName);
for($i = 0; $i < count($diskArray); $i++){
$diskOne = $diskArray[$i];
if($diskOne != "" && validateDevicePath($diskOne))
$diskTmp = $diskTmp . getTemp($diskOne) . ";";
}
echo $diskTmp;
?>