php生产txt_PHP生成TXT文件

//Judge the equipment is 1200 or not

if(substr($serial,0,3)=="014"){

global $db;

$mac = $_POST['mac']?$_POST['mac']:$_GET['mac'];

//Get OUI & judge the oui is or not

$customer_oui=substr($mac,0,6);

$data = $db->fetchNextObject($db->query("SELECT customer_id,code FROM `customer_table` WHERE

customer_id='{$customer_id}' and code='{$customer_oui}'" ));

if (empty($data))

{

$data = $db->fetchNextObject($db->query("SELECT customer_id,code FROM `customer_table` WHERE

customer_name='{$customer_id}' and code='{$customer_oui}'"));

if (empty($data))

{

echo $msg = "OUI is not exist";

return;

}

$cust_id=$data->customer_id;

}else{

$cust_id=$data->customer_id;

}

//Judge the oui is or not

if ($passwd != "itibia-lic-pass")

{

echo "password error";

return;

}

//create the 1200license file and make the user can download

if($download==1){

$mac=strtoupper($mac);

$md5_mac1=md5($mac);

$md5_mac2=md5($md5_mac1);

$md5_mac2_0=$md5_mac2."a19-=km,bEcd3235!#$deddk";

$md5_mac3=md5($md5_mac2_0);

$license_1200=substr($md5_mac3,strlen($md5_mac3)-13,strlen($md5_mac3));

//make the info insert into the license_1200_log_table

$sql = "INSERT INTO `license_1200_log_table` (`id`, `costomer_id`, `serpack`, `serial`, `mac`, `hd`,

`create_time`) VALUES (NULL, '".$cust_id."', '".$serpack_id."', '".$serial."', '".$mac."', '".$hd."',

NOW())";

$result = $db->query($sql);

$filename='1200license.lrc';

$encoded_filename = urlencode($filename);

$encoded_filename = str_replace("+", "%20", $encoded_filename);

// application/octet-stream为TXT类型文件 make it for many kind browser

header("Content-Type: application/octet-stream");

if (preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT']) ) {

header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');

} elseif (preg_match("/Firefox/", $_SERVER['HTTP_USER_AGENT'])) {

header('Content-Disposition: attachment; filename*="' . $filename . '"');

} else {

header('Content-Disposition: attachment; filename="' . $filename . '"');

}

echo $license_1200;

}

exit;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值