Skip to content

Instantly share code, notes, and snippets.

@Egregius

Egregius/receivesmart.php Secret

Created Sep 5, 2020
Embed
What would you like to do?
<?php
if (isset($_REQUEST['token'])&&$_REQUEST['token']=='Apricot-4Contented-Carless-Spiritism-Clubs7-Trinity') {
$date=strftime('%F', time());
echo $date.PHP_EOL;
if ($_REQUEST['device']=='KINGSTON_SA400S37120G') {
$data=json_decode($_REQUEST['data'], true);
foreach ($data['ata_smart_attributes']['table'] as $d) {
if ($d['id']==9) $PowerOn=$d['raw']['value'];
elseif ($d['id']==12) $cycles=$d['raw']['value'];
elseif ($d['id']==241) $GB=$d['raw']['value'];
}
echo 'KINGSTON_SA400S37120G '.$GB.'GB '.$PowerOn.'u cycles:'.$cycles.PHP_EOL;
$db=new PDO("mysql:host=localhost;dbname=dbname;",'user','password');
$db->query("INSERT INTO KINGSTON_SA400S37120G (date, written, poweron, cycles) VALUES ('$date','$GB','$PowerOn','$cycles') ON DUPLICATE KEY UPDATE written='$GB', poweron='$PowerOn', cycles='$cycles';");
} elseif ($_REQUEST['device']=='SAMSUNG_970EVOPLUS') {
$data=json_decode($_REQUEST['data'], true);
$PowerOn=$data['nvme_smart_health_information_log']['power_on_hours'];
$cycles=$data['nvme_smart_health_information_log']['power_cycles'];
$GB=round(($data['nvme_smart_health_information_log']['data_units_written']*512)/1024/1024);
echo 'SAMSUNG_970EVOPLUS '.$GB.'GB '.$PowerOn.'u cycles:'.$cycles.PHP_EOL;
$db=new PDO("mysql:host=localhost;dbname=dbname;",'user','password');
$db->query("INSERT INTO SAMSUNG_970EVOPLUS (date, written, poweron, cycles) VALUES ('$date','$GB','$PowerOn','$cycles') ON DUPLICATE KEY UPDATE written='$GB', poweron='$PowerOn', cycles='$cycles';");
} elseif ($_REQUEST['device']=='SAMSUNG_840EVO250') {
$data=json_decode($_REQUEST['data'], true);
foreach ($data['ata_smart_attributes']['table'] as $d) {
if ($d['id']==9) $PowerOn=$d['raw']['value'];
elseif ($d['id']==12) $cycles=$d['raw']['value'];
elseif ($d['id']==241) $GB=round(($d['raw']['value']*512)/1024/1024/1024, 0);
}
echo 'SAMSUNG_840EVO250 '.$GB.'GB '.$PowerOn.'u cycles:'.$cycles.PHP_EOL;
$db=new PDO("mysql:host=localhost;dbname=dbname;",'user','password');
$query="INSERT INTO SAMSUNG_840EVO250 (date, written, poweron, cycles) VALUES ('$date','$GB','$PowerOn','$cycles') ON DUPLICATE KEY UPDATE written='$GB', poweron='$PowerOn', cycles='$cycles';";
echo $query.PHP_EOL;
$db->query($query);
} elseif ($_REQUEST['device']=='SAMSUNG_860PRO256') {
$data=json_decode($_REQUEST['data'], true);
foreach ($data['ata_smart_attributes']['table'] as $d) {
if ($d['id']==9) $PowerOn=$d['raw']['value'];
elseif ($d['id']==12) $cycles=$d['raw']['value'];
elseif ($d['id']==241) $GB=round(($d['raw']['value']*512)/1024/1024/1024, 0);
}
echo 'SAMSUNG_860PRO256 '.$GB.'GB '.$PowerOn.'u cycles:'.$cycles.PHP_EOL;
$db=new PDO("mysql:host=localhost;dbname=dbname;",'user','password');
$db->query("INSERT INTO SAMSUNG_860PRO256 (date, written, poweron, cycles) VALUES ('$date','$GB','$PowerOn','$cycles') ON DUPLICATE KEY UPDATE written='$GB', poweron='$PowerOn', cycles='$cycles';");
} elseif ($_REQUEST['device']=='SAMSUNG_860QVO1TB') {
$data=json_decode($_REQUEST['data'], true);
foreach ($data['ata_smart_attributes']['table'] as $d) {
if ($d['id']==9) $PowerOn=$d['raw']['value'];
elseif ($d['id']==12) $cycles=$d['raw']['value'];
elseif ($d['id']==241) {
print_r($d);
echo $d['raw']['value'].PHP_EOL;
$GB=round(($d['raw']['value']*512)/1024/1024/1024, 0);
}
}
echo 'SAMSUNG_860QVO1TB '.$GB.'GB '.$PowerOn.'u cycles:'.$cycles.PHP_EOL;
$db=new PDO("mysql:host=localhost;dbname=dbname;",'user','password');
$db->query("INSERT INTO SAMSUNG_860QVO1TB (date, written, poweron, cycles) VALUES ('$date','$GB','$PowerOn','$cycles') ON DUPLICATE KEY UPDATE written='$GB', poweron='$PowerOn', cycles='$cycles';");
} elseif ($_REQUEST['device']=='Apple_1TB_iMac2020') {
$data=json_decode($_REQUEST['data'], true);
foreach ($data['nvme_smart_health_information_log'] as $k=>$v) {
echo $k.' = '.$v.PHP_EOL;
if ($k=='power_on_hours') $PowerOn=$v;
elseif ($k=='power_cycles') $cycles=$v;
elseif ($k=='data_units_written') {
$GB=round(($v*512)/1024/1024, 0);
}
}
$msg= 'Apple_1TB_iMac2020 '.$GB.'GB '.$PowerOn.'u cycles:'.$cycles.PHP_EOL;
echo $msg;
$db=new PDO("mysql:host=localhost;dbname=dbname;",'user','password');
$db->query("INSERT INTO `Apple_1TB_iMac2020` (date, written, poweron, cycles) VALUES ('$date','$GB','$PowerOn','$cycles') ON DUPLICATE KEY UPDATE written='$GB', poweron='$PowerOn', cycles='$cycles';");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment