
<?php
error_reporting(0);
//error_reporting(E_ALL^E_NOTICE);
//header("Content-type: text/html; charset=utf-8");
$privateKey = "smkldospdosldaaa";
$iv = "0392039203920300";
$MachineName = trim($_POST['MachineName']);
$MachineCPU = trim($_POST['MachineCPU']);
$MachineMAC = trim($_POST['MachineMAC']);
$MachineIP = trim($_POST['MachineIP']);
$HardWareNumber = trim($_POST['HardWareNumber']);
$MainBoardNumber = trim($_POST['MainBoardNumber']);
$OSVersion = trim($_POST['OSVersion']);
$NETVersion = trim($_POST['NETVersion']);
/*
file_put_contents("debug.txt",PHP_EOL."---------------".PHP_EOL."接收到的值".PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MachineName]=".PHP_EOL.$MachineName.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MachineCPU]=".PHP_EOL.$MachineCPU.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MachineMAC]=".PHP_EOL.$MachineMAC.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MachineIP]=".PHP_EOL.$MachineIP.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[HardWareNumber]=".PHP_EOL.$HardWareNumber.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MainBoardNumber]=".PHP_EOL.$MainBoardNumber.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[OSVersion]=".PHP_EOL.$OSVersion.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[NETVersion]=".PHP_EOL.$NETVersion.PHP_EOL,FILE_APPEND);
*/
/*
此加密方法中先对内容解密。再对解密的内容使用padding pkcs7去除特殊字符 搜索PKCS7
*/
function remove($str=""){
$block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$pad = ord($str[($len = strlen($str)) - 1]);
$str = substr($str, 0, strlen($str) - $pad);
return $str;
}
//去掉网络编码
$MachineName = base64_decode($MachineName);
$MachineCPU = base64_decode($MachineCPU);
$MachineMAC = base64_decode($MachineMAC);
$MachineIP = base64_decode($MachineIP);
$HardWareNumber = base64_decode($HardWareNumber);
$MainBoardNumber = base64_decode($MainBoardNumber);
$OSVersion = base64_decode($OSVersion);
$NETVersion = base64_decode($NETVersion);
/*
file_put_contents("debug.txt",PHP_EOL."---------------".PHP_EOL."用base64_decode去掉网络编码后".PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MachineName]=".PHP_EOL.$MachineName.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MachineCPU]=".PHP_EOL.$MachineCPU.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MachineMAC]=".PHP_EOL.$MachineMAC.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MachineIP]=".PHP_EOL.$MachineIP.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[HardWareNumber]=".PHP_EOL.$HardWareNumber.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[MainBoardNumber]=".PHP_EOL.$MainBoardNumber.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[OSVersion]=".PHP_EOL.$OSVersion.PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."_POST[NETVersion]=".PHP_EOL.$NETVersion.PHP_EOL,FILE_APPEND);
*/
//解密
$MachineName = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $MachineName, MCRYPT_MODE_CBC, $iv);
$MachineCPU = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $MachineCPU, MCRYPT_MODE_CBC, $iv);
$MachineMAC = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $MachineMAC, MCRYPT_MODE_CBC, $iv);
$MachineIP = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $MachineIP, MCRYPT_MODE_CBC, $iv);
$HardWareNumber = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $HardWareNumber, MCRYPT_MODE_CBC, $iv);
$MainBoardNumber = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $MainBoardNumber, MCRYPT_MODE_CBC, $iv);
$OSVersion = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $OSVersion, MCRYPT_MODE_CBC, $iv);
$NETVersion = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $NETVersion, MCRYPT_MODE_CBC, $iv);
$MachineName = remove($MachineName);
$MachineCPU = remove($MachineCPU);
$MachineMAC = remove($MachineMAC);
$MachineIP = remove($MachineIP);
$HardWareNumber = remove($HardWareNumber);
$MainBoardNumber = remove($MainBoardNumber);
$OSVersion = remove($OSVersion);
$NETVersion = remove($NETVersion);
//写TXT
file_put_contents("debug.txt",PHP_EOL."----------------------------jie mi------------------------------".PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."MachineName".PHP_EOL.$MachineName."-长度:".strlen($MachineName).PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."MachineCPU".PHP_EOL.$MachineCPU."-长度:".strlen($MachineCPU).PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."MachineMAC".PHP_EOL.$MachineMAC."-长度:".strlen($MachineMAC).PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."MachineIP".PHP_EOL.$MachineIP."-长度:".strlen($MachineIP).PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."HardWareNumber".PHP_EOL.$HardWareNumber."-长度:".strlen($HardWareNumber).PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."MainBoardNumber".PHP_EOL.$MainBoardNumber."-长度:".strlen($MainBoardNumber).PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."OSVersion".PHP_EOL.$OSVersion."-长度:".strlen($OSVersion).PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."NETVersion".PHP_EOL.$NETVersion."-长度:".strlen($NETVersion).PHP_EOL,FILE_APPEND);
file_put_contents("debug.txt",PHP_EOL."------------------------------------------------------------".PHP_EOL,FILE_APPEND);
//写入数据库
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}else{
echo "<br>数据库连接成功<br>";
}
mysql_select_db("test", $con);
mysql_query("SET NAMES 'utf8'");
$result = mysql_query("SELECT * FROM test");
//var_dump($result);
//echo time();
//循环输出
/*while($row = mysql_fetch_array($result))
{
echo $row[0] . " " . $row[1] . " " . $row[2] . " " . date('y-m-d h:i:s',$row[3]);
echo "<br />";
}*/
//插入记录
mysql_query("INSERT INTO test (title,content,createtime) VALUES ('HardWareNumber','$HardWareNumber',".time().")");
mysql_query("INSERT INTO test (title,content,createtime) VALUES ('MachineCPU','$MachineCPU',".time().")");
mysql_query("INSERT INTO test (title,content,createtime) VALUES ('MachineMAC','$MachineMAC',".time().")");
mysql_query("INSERT INTO test (title,content,createtime) VALUES ('MachineIP','$MachineIP',".time().")");
mysql_query("INSERT INTO test (title,content,createtime) VALUES ('HardWareNumber','$HardWareNumber',".time().")");
mysql_query("INSERT INTO test (title,content,createtime) VALUES ('MainBoardNumber','$MainBoardNumber',".time().")");
mysql_query("INSERT INTO test (title,content,createtime) VALUES ('OSVersion','$OSVersion',".time().")");
mysql_query("INSERT INTO test (title,content,createtime) VALUES ('NETVersion','$NETVersion',".time().")");
mysql_query("INSERT INTO test (title,content,createtime) VALUES ('---','---',".time().")");
mysql_close($con);
?>