<?php
error_reporting(0);
session_start();
header('Content-type: text/html; charset=utf-8');
require("data/head.php");
?>
<!doctype html>
<html lang="zh-cn">
<head>

    <meta charset="utf-8">

    <meta http-equiv="Content-type" content="text/html; charset=utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">

    <meta name="apple-mobile-web-app-capable" content="yes" />

   <title><?=$cf['site_name']?></title>
      <meta name="keywords" content="<?=$cf['page_keywords']?>" />
      <meta name="description" content="<?=$cf['page_desc']?>" />
    <!--[if lt IE 9]>

    <script src="/Theme/js/html5.js"></script>

    <![endif]-->

<link href="themes/default/wapskin/css/base.css" rel="stylesheet" />
<link href="themes/default/wapskin/css/common.css" rel="stylesheet" />

</HEAD>
<body class="Security">
    <div class="content">
        <div class="catecom">

		 <?php

    $bianhao = $_GET["bianhao"];		
	$result  = 0;
	$msg0    = 1;	
	if($bianhao != ""){		   
	  if($msg0 == 1){
	   $sql="select * from tgs_code where bianhao='$bianhao' limit 1";
	   $res=mysql_query($sql);
	   if(mysql_num_rows($res)>0){
		   $arr = mysql_fetch_array($res);
		   $bianhao  =  $arr["bianhao"];
		   $riqi     =  $arr["riqi"];
		   $product  =  $arr["product"];
		   $zd1      =  $arr["zd1"];
		   $zd2      =  $arr["zd2"];
		   $query_time  = $arr["query_time"];
		   $hits        = $arr['hits'];		   
		   $results     = "扫码查询 [真] 第一次查询";
		   $msg1        = str_replace("{{product}}",$product,unstrreplace($notices1));
		   if($_SESSION['s_query_time']==""){
			 $_SESSION['s_query_time'] = $query_time;
		   }		   
		   if($hits>0){		
			   $results = "扫码查询 [真]  非第一次查询";
			   $msg1        = str_replace("{{product}}",$product,unstrreplace($notices2));
		   }
		    $msg1        = str_replace("{{bianhao}}",$bianhao,$msg1);
		    $msg1        = str_replace("{{riqi}}",$riqi,$msg1);
			$msg1        = str_replace("{{zd1}}",$zd1,$msg1);
			$msg1        = str_replace("{{zd2}}",$zd2,$msg1);
			$msg1        = str_replace("{{hits}}",$hits+1,$msg1);
			$msg1        = str_replace("{{query_time}}",$_SESSION['s_query_time'],$msg1);	   
		  mysql_query("update tgs_code set hits=hits+1,query_time='".$GLOBALS['tgs']['cur_time']."' where bianhao='".$bianhao."' limit 1");		  
		  $msg0 = 1;
	   }
	   else
	   {
		 $results = "扫码查询 [假] 没有找到该防伪码";		 
		 $msg1   = str_replace("{{bianhao}}",$bianhao,unstrreplace($notices3));
	   }
		$sql = "insert into tgs_history set bianhao='".$bianhao."',results='".$results."',addtime='".$GLOBALS['tgs']['cur_time']."',addip='".$GLOBALS['tgs']['cur_ip']."'";
		mysql_query($sql);
	 }	
	}else{
	    $msg1 = "请扫码！";
	}
//echo $msg0."|".$msg1;  
 echo $msg1;
?>
</div>
</div>
</BODY>
</HTML>