<?php
error_reporting(0);
define('IN_CRONLITE', true);
define('IN_OTHER', true);
define('CACHE_FILE', 0);
define('SYSTEM_ROOT', dirname(__FILE__).'/');
define('ROOT', dirname(SYSTEM_ROOT).'/');
date_default_timezone_set('Asia/Shanghai');
$date = date("Y-m-d H:i:s");

if (function_exists("set_time_limit"))
{
	@set_time_limit(0);
}
if (function_exists("ignore_user_abort"))
{
	@ignore_user_abort(true);
}

include_once(ROOT."includes/autoloader.php");
Autoloader::register();
require ROOT.'config.php';
//连接数据库
$DB = new \lib\PdoHelper($dbconfig);
$conf_ = $DB->getAll("SELECT * FROM pre_config");
foreach($conf_ as $k){$conf[$k['k']] = $k['v'];}

// 初始化VIP等级列表（用于折扣和提成计算）
$vip_list = [];
$rs = $DB->query("SELECT * FROM pre_user_vip ORDER BY vip ASC");
if($rs) {
    while($res = $rs->fetch()) {
        $vip_list[$res['vip']] = $res;
    }
}

include_once(ROOT."includes/functions.php");
$scriptpath=str_replace('\\','/',$_SERVER['SCRIPT_NAME']);
$sitepath = substr($scriptpath, 0, strrpos($scriptpath, '/'));
$siteurl = (is_https() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$sitepath.'/';
if(!isset($_SERVER['HTTP_USER_AGENT']) || !strpos($_SERVER['HTTP_USER_AGENT'],chr(46)))$_SERVER['HTTP_USER_AGENT']='Mozilla/5.0 (Windows NT 10.0) Safari/537.36';
$clientip = real_ip(0);
function showalert($msg,$status,$orderid=null,$tid=0){
	if($tid!=0){
		$link = '../user/index.php';
		$title = '购买成功';
		$icon = 'success';
		$button_text = '前往管理';
	}else{
		$link = '../user/recharge.php';
		$title = '充值成功';
		$icon = 'success';
		$button_text = '返回充值';
	}
	
	echo '<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>'.$title.'</title>
	<style>
		* {
			margin: 0;
			padding: 0;
			box-sizing: border-box;
		}
		body {
			font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
			background-color: #f5f5f5;
			display: flex;
			justify-content: center;
			align-items: center;
			height: 100vh;
			padding: 20px;
		}
		.success-container {
			background-color: white;
			border-radius: 16px;
			box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
			padding: 40px;
			text-align: center;
			max-width: 400px;
			width: 100%;
			animation: fadeInUp 0.5s ease-out;
		}
		@keyframes fadeInUp {
			from {
				opacity: 0;
				transform: translateY(30px);
			}
			to {
				opacity: 1;
				transform: translateY(0);
			}
		}
		.icon-container {
			width: 80px;
			height: 80px;
			background-color: #4CAF50;
			border-radius: 50%;
			display: flex;
			justify-content: center;
			align-items: center;
			margin: 0 auto 24px;
			box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
		}
		.icon-success {
			color: white;
			font-size: 40px;
		}
		h1 {
			font-size: 24px;
			font-weight: 600;
			color: #333;
			margin-bottom: 16px;
		}
		p {
			font-size: 16px;
			color: #666;
			margin-bottom: 32px;
			line-height: 1.5;
		}
		.button {
			display: inline-block;
			background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
			color: white;
			padding: 12px 32px;
			border-radius: 8px;
			text-decoration: none;
			font-size: 16px;
			font-weight: 500;
			transition: all 0.3s ease;
			box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
		}
		.button:hover {
			transform: translateY(-2px);
			box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
		}
		.button:active {
			transform: translateY(0);
		}
	</style>
</head>
<body>
	<div class="success-container">
		<div class="icon-container">
			<span class="icon-success">✓</span>
		</div>
		<h1>'.$title.'</h1>
		<p>'.$msg.'</p>
		<a href="'.$link.'" class="button">'.$button_text.'</a>
	</div>
	<script>
		// 3秒后自动跳转
		setTimeout(function() {
			window.location.href = "'.$link.'";
		}, 3000);
	</script>
</body>
</html>';
}
?>