<?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

    $agentid = $_GET["agentid"];		
	$result  = 0;
	$msg0    = 1;	
	if($agentid != ""){		   
	  if($msg0 == 1){
	   $sql="select * from tgs_agent where agentid='$agentid' limit 1";
	   $res=mysql_query($sql);
	   if(mysql_num_rows($res)>0){
		   $arr = mysql_fetch_array($res);
		  $agentid  =  $arr["agentid"];
		  $product  =  $arr["product"];
		  $quyu     =  $arr["quyu"];
		  $shuyu    =  $arr["shuyu"];   
		  $qudao    =  $arr["qudao"];
		  $url      =  $arr["url"];
		  $about    =  $arr["about"];
		  $addtime  =  $arr["addtime"];
		  $jietime  =  $arr["jietime"];		   
		  $name     =  $arr["name"];
		  $tel      =  $arr["tel"];
		  $fax      =  $arr["fax"];
		  $phone    =  $arr["phone"];
		  $danwei   =  $arr["danwei"];		   
		  $email    =  $arr["email"];
		  $qq       =  $arr["qq"];
		  $weixin   =  $arr["weixin"];
		  $wangwang =  $arr["wangwang"];
		  $paipai   =  $arr["paipai"];
		  $zip      =  $arr["zip"];
		  $dizhi    =  $arr["dizhi"];
		  $beizhu   =  $arr["beizhu"];		   
		  $query_time  = $arr["query_time"];
		  $hits        = $arr['hits'];		   
		  $results     = "扫码查询 [真] 第一次查询";
		  $msg1        = str_replace("{{weixin}}",$weixin,unstrreplace($agent1));
          if($_SESSION['s_query_time']==""){
			 $_SESSION['s_query_time'] = $query_time;
		   }		   
		   if($hits>0){		
			   $results = "扫码查询 [真] 非第一次查询";
			 			   $msg1    = str_replace("{{weixin}}",$weixin,unstrreplace($agent2));
		   }
		    $msg1        = str_replace("{{agentid}}",$agentid,$msg1);
			$msg1        = str_replace("{{product}}",$product,$msg1);
			$msg1        = str_replace("{{quyu}}",$quyu,$msg1);
			$msg1        = str_replace("{{shuyu}}",$shuyu,$msg1);
			$msg1        = str_replace("{{qudao}}",$qudao,$msg1);
			$msg1        = str_replace("{{url}}",$url,$msg1);
			$msg1        = str_replace("{{about}}",$about,$msg1);
			$msg1        = str_replace("{{addtime}}",$addtime,$msg1);
			$msg1        = str_replace("{{jietime}}",$jietime,$msg1);
			$msg1        = str_replace("{{name}}",$name,$msg1);
			$msg1        = str_replace("{{tel}}",$tel,$msg1);
			$msg1        = str_replace("{{fax}}",$fax,$msg1);
			$msg1        = str_replace("{{bianhao}}",$bianhao,$msg1);
			$msg1        = str_replace("{{phone}}",$phone,$msg1);
			$msg1        = str_replace("{{danwei}}",$danwei,$msg1);
			$msg1        = str_replace("{{email}}",$email,$msg1);
			$msg1        = str_replace("{{qq}}",$qq,$msg1);
			$msg1        = str_replace("{{weixin}}",$weixin,$msg1);
			$msg1        = str_replace("{{wangwang}}",$wangwang,$msg1);
			$msg1        = str_replace("{{paipai}}",$paipai,$msg1);
			$msg1        = str_replace("{{zip}}",$zip,$msg1);
			$msg1        = str_replace("{{dizhi}}",$dizhi,$msg1);
			$msg1        = str_replace("{{beizhu}}",$beizhu,$msg1);
            $msg1        = str_replace("{{hits}}",$hits+1,$msg1);
			$msg1        = str_replace("{{query_time}}",$_SESSION['s_query_time'],$msg1);			    
		  mysql_query("update tgs_agent set hits=hits+1,query_time='".$GLOBALS['tgs']['cur_time']."' where agentid='".$agentid."' limit 1");		  
		  $msg0 = 1;
	   }
	   else
	   {
		 $results = "扫码查询 [假] 没有找到该代理信息";		 
		 $msg1   = str_replace("{{agentid}}",$agentid,unstrreplace($agent3));
	   }
		$sql = "insert into tgs_history set agentid='".$agentid."',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>