<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
error_reporting(1);
//error_reporting(E_ALL);
ini_set('html_errors',true);
ini_set('display_errors',true);
include("captcha.function.php");

session_start();

// Change this to your real email address:
$myemail = 'me@mysite.com';

// Initialising the $error variable. At the start it is 0. Each field in this form is processed, and if something is wrong (empty input, wrong email address, invalid captcha code, etc) $error is incremented. Form will stop processing if $error is > 0.
$error = 0;
$name_text = '请输入您的验证码';
$name = '';
$email_text = '请输入您的邮箱';
$email = '';
$captcha_text = 'Please tell me you\'re not a spambot';

// This piece of code decides whether to show the form or to process it
if (!isset($_POST['action']) || $_POST['action'] != 'submit') {
	show_form();
	die;
}

// Ok, let's process the form
else {
	// Checking name
	if (empty($_POST['code'])) {
		$error .= 1;
		Msgbox("请输入您的验证码");
	} else {
		$error  .= 0;
		// Please note, that in 'real life' you have to do something like this with user's data: mysql_real_escape_string(strip_tags(trim($_POST['name'])));
		$name = strip_tags($_POST['code']);
	}
	
	// Checking email
	if (empty($_POST['email'])) {
		$error .= 1;
		Msgbox("Please enter your email");
		$email_text = '<span>请输入您的邮箱</span>';
	} elseif (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_a-z{|}~]+\.'.'[-!#$%&\'*+\\.\/0-9=?A-Z^_a-z{|}~]+$/i', $_POST['email'])) {
		$error .= 1;
		Msgbox("请输入您的邮箱");
		$email = strip_tags($_POST['email']);
	} else {
		$error .= 0;
		$email = strip_tags($_POST['email']);
	}
	

	// Now let's check The CAPTCHA
	if (!captcha_verify_word()) {
//		$error .= 1;
//		Msgbox("Wrong image captcha code");
//		$captcha_text = '<span>Wrong image code</span>';
//	} else {
		$error .= 0;
	}
	
	// If $error is > 0, we'll show the form again
	if ($error > 0) {
		show_form();
		die;
	} else {
		// If everything is ok, we'll send an email
    $code = strip_tags(trim($_POST['code']));
    $email = strip_tags(trim($_POST['email']));
    $url = "http://ktweibo.applinzi.com/imapbox_2017_keygen.php?code=".$code."&email=".$email; 
///////
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_exec($ch);
    curl_close($ch);
/////////

//$timeout = array(
//'http'=> array(
//'timeout'=>60 //设置一个超时时间，单位为秒
//)
//);
//$ctx = stream_context_create($timeout);
//$URL = file_get_contents($url,0, $ctx);
    //file_get_contents($url); 
////    get_headers($url);
    //sleep(3);
		//判断contents值并跳转到显示序列号的页面。 //修改为直接去本地的数据库里查找，如果有值，表示入库成功完成。
		$link = mysql_connect("127.0.0.1","a1223214255","8877414");
		mysql_select_db("app_ktweibo", $link);
		$sql_check = "select * from serial where serial = '".$code."' and basemail = '".$email."' and imap_code is not null and is_valid = 0 LIMIT 1";
		$result = mysql_query($sql_check, $link);
		$v1 = mysql_fetch_array($result);
		$contents = $v1['IMAP_CODE'];
		 if($contents<>""){
			show_success($contents);
		}else{
			msgbox("您输入的激活码已使用或输入了错误的激活码。请加入官方QQ二群:480325372,寻求帮助。");
			show_form();
		}
		
//		if($contents == "0" || $contents == "" || strlen($contents) < 64){
//			msgbox("您输入的激活码已使用或输入了错误的激活码。请加入官方QQ群:21638001,寻求帮助。");
//			show_form();
//		}else{
//			show_success($contents);
//			}
		die();
	}
}

function MsgBox($str){     
	echo("<script language=javascript>") ;    
	echo ("alert('$str');");                
	echo("</script>");   
	}
// This function shows the form
function show_form() {
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="order.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.order_Div1 {width:230px; float:left; border:1px solid #999999; border-right:0px; height:330px; margin-top:40px; text-align:center; background:url(images/order-bg1.jpg) repeat-y #f7f7ef right top;}
.order_Div12 {width:230px; float:left; border:1px solid #009900; border-right:0px; height:330px; margin-top:40px; text-align:center; background:url(images/order-bg1.jpg) repeat-y #f7f7ef right top;}
.order_Div2 {width:300px; float:left; border:3px solid #CC9966; height:380px; text-align:center; background-color:#ffffff; font-family:Arial, Helvetica, sans-serif;}
.order_Div22 { width:300px; float:left; border:3px solid #009900; height:380px; text-align:center; background-color:#F4FFFF; font-family:Arial, Helvetica, sans-serif;}
.order_Div3 {width:230px; float:left; border:1px solid #999999; border-left:0px; height:330px; margin-top:40px; text-align:center; background:url(images/order-bg2.jpg) repeat-y #f7f7ef left top;}
.order_Div32 {width:230px; float:left; border:1px solid #009900; border-left:0px; height:330px; margin-top:40px; text-align:center; background:url(images/order-bg2.jpg) repeat-y #f7f7ef left top;}
.order_Div4 { border:1px solid #999999;width:414px; PADding:10px; text-align:center; background:url(images/serial.jpg) 10px 35px no-repeat; PADding-left:340px;}
.order_Div42 { border:1px solid #009900;width:414px; PADding:10px; text-align:center; background:url(images/serial.jpg) 10px 35px no-repeat; PADding-left:340px;}
#myform { padding: 1%; }
#myform div { margin-bottom: 0.5em; }
#myform span { color: #FF0000; font-weight: 700; }
#myform input { border: 1px solid #CCCCCC; padding: 0.2em; background-color: #F9FDFF; }
#myform textarea { border: 1px solid #CCCCCC; padding: 0.2em; background-color: #F9FDFF; }
#myform button { border: 1px solid; background-color: #3366CC; color: #FFFFEE; border-left-color: #6DBFFF; border-top-color: #6DBFFF; border-bottom-color: #0C3F67; border-right-color: #0C3F67; }
-->
</style>
</head>

<body>


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="generate">
	<input type="hidden" name="action" value="submit">
<div id="body-min">
  <div style="PADding:0px 30px 0px 20px;">
  	<div style="background:url(images/security.gif) no-repeat; width:760px; margin:0 auto; height:90px; text-align:center;">
	
  	  <h1 style="text-align:center; font-size:32px; line-height:40px; font-family:Arial, Helvetica, sans-serif; font-weight:bold; color:#333333; PADding-bottom:13px;">获取并激活您的 <font color=red>官方正版授权码</font></h1>
  	  <p style="text-align:center; font-size:18px; color:#999999;">ImapBox | ImageBox | ImovieBox | IbookBox | IurlBox</p>
  	</div>
    <div style="width:780px; margin:0 auto;">
      <div class="ClearAll"></div>
      <br />
      <div class="order_Div4" onmouseover="this.className='order_Div42'" onmouseout="this.className='order_Div4'">
        <p style="font-size:35px; font-weight:bold; PADding-top:15px; color:#333333;">ImapBox 系列授权 <span style="font-size:14px; font-weight:bold; color:#99CC00; ">在线激活. </span></p>
        <p style="font-size:18px; PADding-top:12px; color:#999999;" align="left"> &nbsp;&nbsp;您支付后会得到一串激活码:  <a style="color:blue;text-decoration:underline;font-size:12px;" href="http://www.imapbox.com/index.php/2013/09/26/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E5%B7%B2%E8%B4%AD%E4%B9%B0%E7%9A%84%E6%BF%80%E6%B4%BB%E7%A0%81/" target="_blank">如何激活?</a> <a style="color:blue;text-decoration:underline;font-size:12px;" href="http://www.imapbox.com/help.php" target="_blank">软件激活图示</a> <a style="color:blue;text-decoration:underline;font-size:12px;"  href="http://www.imapbox.com//wp-content/plugins/alipay/includes/tpl.cart.php?proid=100" target="_blank">购买</a></p>
         <p style="font-size:12px; PADding-top:12px; color:#999999;" align="left"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;激活码样例: 8e4BOK1JRAo1EFmlBkFhAlGAlr5xJvfu </p>
         <p style="font-size:30px; PADding-top:16px; PADding-bottom:10px; color:#FF6633; font-weight:bold;"><input style="height: 40px; text-indent: 10px; border: 3px solid #bbbbbb; background: #feffa0; line-height: 40px; width: 280px;" id="code" name="code" type="text" maxlength="40" value="输入您的32位激活码 (在您的邮箱中)" onclick="if (value =='输入您的32位激活码 (在您的邮箱中)'){value =''}" onblur="if (value ==''){value='输入您的32位激活码 (在您的邮箱中)'}"/></p>
         <p style="font-size:30px; PADding-top:16px; PADding-bottom:10px; color:#FF6633; font-weight:bold;"><input style="height: 40px; text-indent: 10px; border: 3px solid #bbbbbb; background: #feffa0; line-height: 40px; width: 280px;" id="email" name="email" type="text" maxlength="40" value="填写您的主邮箱帐号 ..." onclick="if (value =='填写您的主邮箱帐号 ...'){value =''}" onblur="if (value ==''){value='填写您的主邮箱帐号 ...'}"/></p>
        <br>
        <div><?php echo $GLOBALS['captcha_text']; ?><br>
<img src="captcha.image.php?nocache=<?php echo md5(time()); ?>" border="0"><br><br>
<input name="magicword" style="height: 20px; text-indent: 10px; border: 3px solid #bbbbbb; background: #feffa0; line-height: 20px; width: 280px;" type="text" tabindex="4">
</div>
<div>请输入您在上图中看到的验证码(<font color=red><b>注意要全部大写</b></font>)</div>
<p style="border-bottom:1px dashed #999999; PADding:5px;"></p>
        <p style="font-size:18px; PADding:6px; font-weight:bold; color:#FF6633;">确保您的邮箱帐号正确无误</p>
        <p style="font-size:12px; color:#999999;"> 激活成功的授权码会同时发到您的邮箱中  </p>
         <p style="font-size:12px; color:#999999; PADding-bottom:10px;"><font color="#FF6633"><b>点击下面的按钮开始激活!</b></font></p>
         <br> 
        <p><a href="#"><input type="image" src="images/generate.jpg" width="246" height="70" border="0" onmouseover="this.src='images/generate_hover.jpg'" onmouseout="this.src='images/generate.jpg'"/></p>
         
           <br>
        <p style="font-size:12px; color:#999999; PADding-top:10px;">当您点击 "Generate Serial Code" 按钮,您将在此页面看到您的正式激活的授权码. 同时,您的邮箱也会收到相同的授权码!</p>
        <br>
        <p style="font-size:12px; color:#ff0000;text-decoration:underline; PADding-bottom:10px;"><font color="blue"><b><a href="mailto:support@imapbox.com"><font color=red>不懂如何生成?或生成时出现了故障? <br>请加官方QQ群:21638001与官方客服联系,实时获得帮助!</font></a></b></font></p>
      </div>

      </div>
  
</div>
</form>
</body>
</html>
<?php
}
?>

<?php
function show_success($serial) {
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="order.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.order_Div1 {width:230px; float:left; border:1px solid #999999; border-right:0px; height:330px; margin-top:40px; text-align:center; background:url(images/order-bg1.jpg) repeat-y #f7f7ef right top;}
.order_Div12 {width:230px; float:left; border:1px solid #009900; border-right:0px; height:330px; margin-top:40px; text-align:center; background:url(images/order-bg1.jpg) repeat-y #f7f7ef right top;}
.order_Div2 {width:300px; float:left; border:3px solid #CC9966; height:380px; text-align:center; background-color:#ffffff; font-family:Arial, Helvetica, sans-serif;}
.order_Div22 { width:300px; float:left; border:3px solid #009900; height:380px; text-align:center; background-color:#F4FFFF; font-family:Arial, Helvetica, sans-serif;}
.order_Div3 {width:230px; float:left; border:1px solid #999999; border-left:0px; height:330px; margin-top:40px; text-align:center; background:url(images/order-bg2.jpg) repeat-y #f7f7ef left top;}
.order_Div32 {width:230px; float:left; border:1px solid #009900; border-left:0px; height:330px; margin-top:40px; text-align:center; background:url(images/order-bg2.jpg) repeat-y #f7f7ef left top;}
.order_Div4 { border:1px solid #999999;width:414px; PADding:10px; text-align:center; background:url(images/serial.jpg) 10px 35px no-repeat; PADding-left:340px;}
.order_Div42 { border:1px solid #009900;width:414px; PADding:10px; text-align:center; background:url(images/serial.jpg) 10px 35px no-repeat; PADding-left:340px;}
#myform { padding: 1%; }
#myform div { margin-bottom: 0.5em; }
#myform span { color: #FF0000; font-weight: 700; }
#myform input { border: 1px solid #CCCCCC; padding: 0.2em; background-color: #F9FDFF; }
#myform textarea { border: 1px solid #CCCCCC; padding: 0.2em; background-color: #F9FDFF; }
#myform button { border: 1px solid; background-color: #3366CC; color: #FFFFEE; border-left-color: #6DBFFF; border-top-color: #6DBFFF; border-bottom-color: #0C3F67; border-right-color: #0C3F67; }
-->
</style>
</head>

<body>



	
<div id="body-min">
  <div style="PADding:0px 30px 0px 20px;">
  	<div style="background:url(images/security.gif) no-repeat; width:760px; margin:0 auto; height:90px; text-align:center;">
	
  	  <h1 style="text-align:center; font-size:32px; line-height:40px; font-family:Arial, Helvetica, sans-serif; font-weight:bold; color:#333333; PADding-bottom:13px;">您的 iMapBox <font color=red>产品授权码</font> 成功生成!</h1>
  	  <p style="text-align:center; font-size:18px; color:#999999;">授权码成功显示! 恭喜您! 请复制到本地并妥善保存!</p>
  	</div>
    <div style="width:780px; margin:0 auto;">
      <div class="ClearAll"></div>
      <br />
      <div class="order_Div4" onmouseover="this.className='order_Div42'" onmouseout="this.className='order_Div4'">
        <p style="font-size:35px; font-weight:bold; PADding-top:15px; color:#333333;">成功显示 <span style="font-size:14px; font-weight:bold; color:#99CC00; "> 请复制您的授权码. </span></p>
        <p style="font-size:18px; PADding-top:12px; color:#999999;" align="left"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;将下列授权码复制到您的软件中!</p>
         <p style="font-size:12px; PADding-top:12px; color:#999999;" align="left"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>授权码面板:</font></p>
         <p style="font-size:30px; PADding-top:16px; PADding-bottom:10px; color:#FF6633; font-weight:bold;"><textarea style="height: 240px; text-indent: 10px; border: 3px solid #bbbbbb; background: #feffa0; line-height: 20px; width: 340px;overflow:hidden" id="serial" name="serial" type="text" maxlength="400"/><?php echo $serial;?></textarea></></p>
        
        <br>
<p style="border-bottom:1px dashed #999999; PADding:5px;"></p>
        <p style="font-size:18px; PADding:6px; font-weight:bold; color:#FF6633;">授权码同时也会发送到您的邮箱中!</p>
        <p style="font-size:12px; color:#999999;"> 你也可以在邮箱中收取您的授权码！ </p>
         <p style="font-size:12px; color:#999999; PADding-bottom:10px;"><font color="#FF6633"><b>如果没有找到建议在邮箱垃圾箱中找到.</b></font></p>
         <br> 
           <br>
        <p style="font-size:12px; color:#999999; PADding-top:10px;">激活方法：打开您的软件，找到下方的菜单，点击“帮助” -> "注册激活..", 复制上方的授权码粘帖到软件中的授权码框. 点击“激活”按钮，完成激活!</p>
        <br>
        <p style="font-size:12px; color:#ff0000;text-decoration:underline; PADding-bottom:10px;"><font color="blue"><b><a href="mailto:support@imapbox.com"><font color=red>有任何关于激活方面的问题，欢迎随时垂询 <br>给我们发送邮件,或加入官方QQ群：21638001，寻求帮助!</font></a></b></font></p>
      </div>

      </div>
    <div style="color: #666666; margin:0 auto; width:780px; margin-top:20px;">
			<p><strong>Note: </strong><br />
	  </p>
			<p>When you click &quot;<strong>Buy Now</strong>&quot;, you will be directed to Regnow who sells our products. After completing your payment you should click the &quot;<strong>Complete Secure Order</strong>&quot; to get your paid code.</p>
			<br />
			<p align="center"><span style="color: #666666"><a href="order.html#" target="_self"><img src="images/buy-now.gif" alt="payment methods" width="170" height="34" border="0"/></a></p>
			<br />
			<p align="center"><span style="color: #666666"><img src="images/cc.gif" alt="payment methods" width="419" height="28" /><br />
&nbsp; &nbsp;(We also accept Bravo, EuroCard, JCB, Novus, MasterDebit and VisaDebit)</span></p>
			<p style="border-bottom:1px dashed #CCCCCC; margin-top:20px; margin-bottom:20px;"></p>
			<p><img alt="encrypt" height="15" src="images/encrypt.gif" width="12" /> <strong>Your online order is 100% SAFE and SECURE!</strong><br />
			Regnow sells our products - they are a trusted online retailer specializing in digitally delivered products. All your information remains private and secure. We guarantee the safety and protection of your personal information.</p>
			<br />
			<p>
				<img alt="money back guarantee" height="15" src="images/guarantee.jpg" width="13" /><strong> Is my purchase guaranteed?</strong><br />
				A: Absolutely! All orders are backed by our unconditional 30-day money back guarantee.If you are unhappy with your purchase, for any reason, simply contact us via e-mail for a full refund.<br />
	  </p>
			<br />
			<p><strong>Order IMAPBOX now, completely Risk-Free!</strong></p>
			<br />
			<p>
				<img alt="privacy protected" height="44" src="images/privacy1.gif" width="154" />&nbsp;&nbsp; <img alt="secure order" height="31" src="images/secure.gif" width="88" /></p>
    </div>
    <br />
  </div>
</div>
</body>
</html>
<?php
}
?>