<?php
require_once ("../inc/conn.php");
require_once ("qqconfig.php");
require_once ("qqconnect.php");

if (app_user == 0){ echo "会员系统关闭中";exit;}

$action = be("get","action");
$u_points=0;
$u_plays="";
$u_downs="";
$u_fav="";



switch($action)
{
	case "login" : login();foot();break;
	case "check" : checkLogin();break;
	case "logout" : logout();break;
	
	case "regcheck":regcheck();break;
	case "reg" : reg() ; foot();break;
	case "regsave" : regsave();break;
	
	case "findpass" : findpass(); foot();break;
	case "findpasssave" : findpasssave();break;
	
	case "info": chklogin(); userhead(); info(); foot();break;
	case "save": chklogin(); save();break;
	case "popedom" : chklogin();userhead(); popedom();foot();break;
	
	case "plays": chklogin(); userhead(); plays(); foot();break;
	case "playsdel" :  chklogin(); playsdel();break;
	
	case "downs": chklogin(); userhead(); downs(); foot();break;
	case "downsdel" :  chklogin(); downsdel();break;
	
	case "fav" : chklogin(); userhead(); fav(); foot();break;
	case "rfav" : chklogin(); userhead(); rfav(); foot();break;
	case "psw" : chklogin(); userhead(); psw(); foot();break;
	case "favdel" : chklogin(); favdel();break;
	case "tg" : tg();break;
	case "upgrade": chklogin(); userhead(); upgrade(); foot();break;
	case "upgradesave": chklogin(); upgradesave();break;
	case "upgradesave2": chklogin(); upgradesave2();break;
	
	case "pay": chklogin(); userhead(); pay();foot();break;
	case "pay2": chklogin(); userhead(); pay2();foot();break;
	case "pay3": chklogin(); userhead(); pay3();foot();break;
	case "paysave": chklogin(); paysave();break;
	case "paysave2": chklogin(); paysave2();break;
	case "wel": chklogin(); userhead(); wel(); foot();break;
	default :  chklogin(); userhead(); main(); foot();break;
}
dispseObj();

function chklogin()
{
	global $db,$u_plays,$u_downs,$u_fav,$u_points;
	$u_id = $_SESSION["userid"];
	
	if (!isN($u_id)){
		$row = $db->getRow("SELECT * FROM {pre}user where u_id=" . $u_id);
		$loginValidate = md5($row["u_random"] . $row["u_name"] . $row["u_id"]);
		
		if ($row && $_SESSION["usercheck"] != $loginValidate){
			$_SESSION["userid"] = "";
			$_SESSION["usergourp"] ="";
			$_SESSION["username"] = "";
			$_SESSION["usercheck"] ="";
	    	echo "<script>top.location.href='index.php?action=login';</script>";
	    	exit;
	    }
		$u_points=$row["u_points"];
		$u_plays=$row["u_plays"];
		$u_downs=$row["u_downs"];
		$u_fav=$row["u_fav"];
		unset($row);
	}
	else{
		echo "<script>top.location.href='index.php?action=login';</script>";
	}
}

function checkLogin()
{
	global $db;
	$u_name = be("post","u_name"); $u_name= chkSql($u_name,true);
	$u_password = md5(be("post","u_password"));
	$flag = be("all","flag"); $backurl = be("all","backurl");
	if (isN($flag)){ $flag = "iframe";}
	
	$row = $db->getRow("SELECT u_id, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_name='".$u_name."' and u_password = '".$u_password."' and u_status =1 or u_email='".$u_name."' and u_password = '".$u_password."' and u_status =1");
	
	if (!$row){
		if ($flag=="iframe"){
			alertUrl ("您输入的用户名和密码不正确或者您的账户已经被锁定!","login.php");
		}
		else{
			alertUrl ("您输入的用户名和密码不正确或者您的账户已经被锁定!","?action=login&url=".$backurl);
		}
	}
	else{
		$randnum = md5(rand(1,99999999));
		$u_flag = $row["u_flag"];
		
		if ($u_flag == 1){
			if ( time() > strtotime($row["u_end"]) ){
				$u_flag = 0;
				$u_start="";
				$u_end="";
			}
			else{
				$u_start=$row["u_start"];
				$u_end=$row["u_end"];
			}
		}
		else{
			$ugroup=$row["u_group"];
		}
		
		
		$_SESSION["userlastlogintime"] = $row["u_logintime"];
		$_SESSION["userid"] = $row["u_id"];
		$_SESSION["username"] = $row["u_name"];
		$_SESSION["usergroup"] = $row["u_group"];
		$_SESSION["ugpopvalue"] = $row["ug_popvalue"];
		$_SESSION["usercheck"] = md5($randnum . $row["u_name"] . $row["u_id"]);
		
		$db->Update ("{pre}user",array("u_logintime","u_ip","u_random","u_loginnum","u_flag","u_start","u_end"),array(date('Y-m-d H:i:s'),getIP(),$randnum,$row["u_loginnum"] + 1,$u_flag,$u_start,$u_end),"u_id=".$row["u_id"]);
		unset($row);
		
		if (isN($backurl)){
			if ($flag=="iframe"){
				echo "<script>window.location.href='login.php';</script>";
			}
			else{
				echo "<script>top.location.href='index.php';</script>";
			}
		}
		else{
			echo "<script>top.location.href='".$backurl ."';</script>";
		}
	}
}

function logout()
{
	$flag = be("all","flag");
	if (isN($flag)){ $flag = "iframe";}
	$_SESSION["userid"] = "";
	$_SESSION["usergroup"]="";
	$_SESSION["username"] = "";
	$_SESSION["usercheck"]="";
	$_SESSION["ugpopvalue"]="";
	$_SESSION["userlastlogintime"]="";
	if ($flag=="iframe"){
		echo "<script>window.location.href='login.php';</script>";
	}
	else{
		echo "<script>top.location.href='../index.php';</script>";
	}
}

function regcheck()
{
	global $db;
	$str=be("all","str"); $str=chkSql($str,true);
	$typea=be("all","typea"); $typea=chkSql($typea,true);
	$okstr = "{\"result\":true}";
	$errstr = "{\"result\":false}";
	switch($typea)
	{
		case "u_name": $where = "u_name='" .$str ."'";break;
		case "u_email": $where = "u_email='" . $str ."'";break;
		case "u_qq": $where = "u_qq='" . $str ."'";break;
		case "verifycode": 
			if ($_SESSION["code_userreg"] != $str){
				echo $errstr;exit;
			}
			else{
				echo $okstr;exit;
			}
		default : $where="";break;
	}
	
	$row = $db->getRow("SELECT * FROM {pre}user WHERE " . $where);
	if(!$row) { $str= $okstr;} else { $str= $errstr;}
	
	unset($row);
	echo $str;
}



function reg()
{
	global $db;
	if (app_reg == 0){ echo "系统已经关闭注册";exit;}
	
	$ref= be("all","ref");
	if ($ref=="qqlogin"){
		$qc = new QqConnect();
		$url = $qc->create_login_url();
	    echo '<script type="text/javascript">location.href="' .$url .'";</script>';
		unset($qc);
		exit;
	}
	else if ($ref=="qqlogged"){
		$qc = new QqConnect();
		
		if($qc->checkLogin()){
			$qc->callback();
			$qqid = $qc->get_openid();
			$userinfo = $qc->get_user_info();
			$nickname = $userinfo["nickname"]; $nickname=chkSql($nickname,true); $nickname=replaceStr($nickname,"'","");
			$tmpname = $nickname;
			
			$i=0;
			$rscount = $db->getOne("SELECT count(*) FROM {pre}user where u_qid='" . $qqid . "'");
			if ($rscount == 0){
				$rscount = $db->getOne("SELECT count(*) FROM {pre}user where u_name='" . $tmpname . "'");
				
				while ($rscount>0)
				{
					$tmpname = $nickname . $i;
					$rscount = $db->getOne("SELECT count(*) FROM {pre}user where u_name='" . $tmpname . "'");
					$i++;
				}
				$nickname = $tmpname;
				$db->Add( "{pre}user",array("u_name","u_qid", "u_password","u_qq","u_email","u_regtime","u_status","u_points","u_group","u_phone","u_question","u_answer"),array($nickname,$qqid,md5(""),"","",date('Y-m-d H:i:s'),app_regstate,app_regpoint,app_reggroup,"","",""));
			}
					    
			$row = $db->getRow("SELECT u_id, u_qid,u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_qid='".$qqid."' and u_status =1");
			
			if ($row){
				$randnum = md5(rand(1,99999999));
				if ($row["u_flag"] == 1){
					if ( time() > strtotime($row["u_end"]) ){
						$u_flag = app_reggroup;
						$u_start="";
						$u_end="";
					}
					else{ 
						$u_flag = $row["u_flag"];
						$u_start=$row["u_start"];
						$u_end=$row["u_end"];
					}
				}
				else{
					$ugroup=$row["u_group"];
				}
				$db->Update ("{pre}user",array("u_logintime","u_ip","u_random","u_loginnum","u_flag","u_start","u_end"),array(date('Y-m-d H:i:s'),getIP(),$randnum,$row["u_loginnum"] + 1,$u_flag,$u_start,$u_end),"u_id=".$row["u_id"]);
							
				$_SESSION["userid"] = $row["u_id"];
				$_SESSION["username"] = $row["u_name"];
				$_SESSION["usergroup"] = $row["u_group"];
				$_SESSION["ugpopvalue"] = $row["ug_popvalue"];
				$_SESSION["usercheck"] = md5($randnum . $row["u_name"] . $row["u_id"]);
			}
			unset($row);
			if ($randnum !=""){ echo '<script type="text/javascript">location.href="' .app_installdir .'";</script>';exit;  }
		}
		unset($qc);
	}
	else{
		
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>魅雅听听 - 新用户注册</title>
<meta name="keywords" content="{maccms:keywords}"/>
<meta name="description" content="{maccms:description}"/>
<link href="css/base.css" type="text/css" rel="stylesheet"/>
<link href="css/qirebox.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/jquery.validate.js"></script>
    <script type="text/javascript" src="../js/function.js"></script>
<script type="text/javascript">
function remote_check(typea, str){
  var url="?action=regcheck";
  var ret;
  $.ajax({'url':url,'async':false,'dataType':'json','data':{'typea':typea,'str':str},'success':function(data){ret=data;}});
  return ret.result;
}
var validator={
'u_name':[
  [/\S+/, '请输入用户名'],
  [/\S{4,}/, '用户名少于4位'],
  [function(u_name){return remote_check('u_name',u_name);}, '此用户名已被使用']
],
'u_password1':[
  [/^.+$/, '请输入密码'],
  [/^.{6,}$/, '密码少于6位']
],
'u_password2':[
  [/^.+$/, '请输入确认密码'],
  [function(s){return s==$('#item_u_password1 input').val();}, '两次密码输入不一致']
],
'u_email':[
  [/\S+/, '请输入电子邮件'],
  [/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i, '请输入格式正确的电子邮件'],
  [function(u_email){return remote_check('u_email',u_email)}, '此电子邮件已被使用']
],
'u_qq':[
  [/\S+/, '请输入QQ号码'],
  [/^[\d|\.|,]+$/, '请输入格式正确的QQ号码'],
  [function(u_qq){return remote_check('u_qq',u_qq)}, '此QQ号码已被使用']
],
'u_phone':[
  [/\S+/, '请输入电话号码'],
  [/^[\d|\.|,]+$/, '请输入格式正确的电话号码']
],
'verifycode':[
  [/\S+/,'请输入验证码'],
  [function(verifycode){return remote_check('verifycode',verifycode)}, '验证码不正确']
]
};

function validate(item) {
  var str=$("#item_"+item+" input").val();
  var m={
    'RegExp':function(r,s){
      return r.test(s);
    },
    'Function':function(f,s){
      return f(s);
    },
    'String':function(v,s){return v==s;}
  };
  for (var v in validator[item]) {
    var vi=validator[item][v];
    var c=Object.prototype.toString.apply(vi[0]).match(/(\w+)\]$/)[1];
    if (m[c] && !m[c](vi[0],str)) {
      fail(item,vi[1]);
      return false;
    }
  }
  succ(item);
  return true;
}

var result={};
for (var k in validator){
	result[k]=false;
}

function fail(item, msg){
	$("#item_"+item+" .ui-message").html(msg).removeClass('onCorrect').addClass('onError');
	result[item]=false;
	disable();
}
function succ(item) {
	$("#item_"+item+" .ui-message").html('填写正确').removeClass('onError').addClass('onCorrect');
	result[item]=true;
	check_all();
}
function check_all() {
	for (var k in result){
	  if (result[k]==false){
	    disable();
	    return true;
	  }
	}
	if (!$('#agree').attr('checked')) {
	  disable();
	  return true;
	}
	enable();
	return true;
}
function enable(){
	$('#submit_enabled').show();
	$('#submit_disabled').hide();
	return true;
}
function disable(){
	$('#submit_enabled').hide();
	$('#submit_disabled').show();
	return false;
}
function check_and_submit() {
	if (!check_all()) {
	return;
	}
	$('form')[0].submit();
}
$(function(){
	$('#regform input').blur(function(){ validate(this.name); }).change(check_all);
});
</script>
</head>
<body>
<div class="layout" id="sign-header">
	<div id="sign-logo">
		<a href="../"><img src="images/logo.png" alt=""/></a>
	</div>
</div>
<!-- // sign-header end -->
<div class="layout" id="sign-content">
	<div class="ui-box ui-qire sign-focus" id="reg-box">
		<div class="ui-title fn-clear">
			<span>已有帐号？请<a href="?action=login">直接登录</a></span>
			<h2>注册魅雅听听会员</h2>
		</div>
		<div class="ui-cnt fn-clear">
			<form id="regform" action="?action=regsave" method="post">
				<div class="ui-form" id="sign-primary">
					<div class="ui-form-item fn-clear" >
						<label class="ui-label w100">&nbsp;</label>
						<p class="qire-notice">
							友情提示：注册成功后，请用用户名登录即可！
						</p>
					</div>
					
					
					<div class="ui-form-item fn-clear" id="item_u_name">
						<label for="u_name" class="ui-label w100">用户名：</label><input type="text" id="u_name" name="u_name" class="ui-input w220" value=""/>
						<p class="ui-message onShow" >
							用户名使用4-16个字符
						</p>
					</div>
					<div class="ui-form-item fn-clear" id="item_u_password1">
						<label for="u_password1" class="ui-label w100">设置密码：</label><input type="password" id="u_password1" name="u_password1" maxlength="20" class="ui-input w220" value=""/>
						<p class="ui-message onShow" >
							6-16个字符
						</p>
					</div>
					<div class="ui-form-item fn-clear" id="item_u_password2">
						<label for="u_password2" class="ui-label w100">重复密码：</label><input type="password" id="u_password2" name="u_password2" maxlength="20" class="ui-input w220" value=""/>
						<p class="ui-message onShow" >
							请再一次输入密码
						</p>
					</div>					
					<div class="ui-form-item fn-clear" id="item_u_email">
						<label for="u_email" class="ui-label w100"><strong>Email</strong>地址：</label><input type="text" id="u_email" name="u_email" class="ui-input w220" value=""/>
						<div class="f3"><span></span></div>
						<p class="ui-message onShow" >
							请填写有效电子邮件，以获得注册验证信
						</p>
					</div>
					<div class="ui-form-item fn-clear" id="item_u_qq">
						<label for="u_email" class="ui-label w100"><strong>QQ</strong>号码：</label><input type="text" id="u_qq" name="u_qq" class="ui-input w220" value=""/>
						<div class="f3"><span></span></div>
						<p class="ui-message onShow" >
							请填写有效QQ号码，可以通过QQ号码登录
						</p>
					</div>
					<div class="ui-form-item fn-clear" id="item_u_phone">
						<label for="u_email" class="ui-label w100">电话号码：</label><input type="text" id="u_phone" name="u_phone" class="ui-input w220" value=""/>
						<div class="f3"><span></span></div>
						<p class="ui-message onShow" >
							请填写有效电话号码
						</p>
					</div>
					<div class="ui-form-item fn-clear" id="item_u_question">
						<label for="u_email" class="ui-label w100">找回问题：</label><input type="text" id="u_question" name="u_question" class="ui-input w220" value=""/>
						<div class="f3"><span></span></div>
						<p class="ui-message onShow" >
							请认真填写问题，以便日后找回密码
						</p>
					</div>
					<div class="ui-form-item fn-clear" id="item_u_answer">
						<label for="u_email" class="ui-label w100">找回答案：</label><input type="text" id="u_answer" name="u_answer" class="ui-input w220" value=""/>
						<div class="f3"><span></span></div>
						<p class="ui-message onShow" >
							请认真填写答案，以便日后找回密码
						</p>
					</div>
					<div class="ui-form-item fn-clear" id="item_verifycode">
						<label for="verifycode" class="ui-label w100">验证码：</label>
						<div class="ui-form-block w120">
							<input type="text" id="verifycode" name="verifycode" maxlength="10" class="ui-input w110" value=""/>				
						</div>
						<img src="../inc/code.php?a=userreg&s='Math.random()" title="看不清楚? 换一张！" style="cursor:hand;width: 88px;height: 35px;float: left; isplay: block;overflow: hidden;margin: 0 10px 0 0;vertical-align: top;cursor: pointer;" onClick="src='../inc/code.php?a=userreg&s='+Math.random()"/>			
						<p class="ui-message onShow" >
							输入上图运算的答案
						</p>
					</div>
					<div class="ui-form-item ui-form-checkbox fn-clear" id="item_agree">
						<label class="ui-label w100">&nbsp;</label>
						<div class="ui-form-block w220">
							<label for="agreement" class="ui-label-checkbox"><input type="checkbox" value="" name="agree" id="agree" checked="checked" value='1'/>我已阅读并接受《<a href="#">使用协议</a>》
							</label>
						</div>
					</div>
					<div class="ui-form-item fn-clear">
						<label class="ui-label w100">&nbsp;</label><input type="submit" id="register" class="ui-button w220" value="注册会员"/>
					</div>
				</div>
				<!-- // ui-form#sign-primary end -->
			</form>
			<div id="sign-app">
				<div class="sign-app-list">
					<h5>注册通行证可享会员服务</h5>
					<h5>可以收听任意有声小说</h5>
					<h5>可以任意有声小说</h5>
					<h5>让您看片、交友、互动，一个都不少。</h5>
					
					<h5>你还可以用以下方式直接登录：</h5>
					<a href="?action=reg&ref=qqlogin"><img src="images/qq_login.gif" alt=""/></a>
				</div>
			</div>
			<!-- // sign-app end -->
		</div>
	</div>
	<!-- // sign-box#regbox end -->
</div>
<!-- // sign-content end -->
<?php
}

function regsave()
{
	global $db;
	if (app_reg == 0){ echo "系统已经关闭注册";exit;}
	$verifycode = be("post","verifycode");
	if ($verifycode ==""){ alert ("请返回输入确认码。返回后请刷新登陆页面后重新输入正确的信息。");exit;}
	if (trim($verifycode) != $_SESSION["code_userreg"]) { alert ("确认码错误，请重新输入。返回后请刷新登陆页面后重新输入正确的信息。") ;exit;}
	
	$u_name = be("post","u_name"); $u_name=chkSql($u_name,true);
	$u_password1 = be("post","u_password1"); $u_password1=chkSql($u_password1,true);
	$u_password2 = be("post","u_password2"); $u_password2=chkSql($u_password2,true);
	$u_qq = be("post","u_qq"); $u_qq=chkSql($u_qq,true);
	$u_email = be("post","u_email"); $u_email=chkSql($u_email,true);
	$u_phone = be("post","u_phone"); $u_phone=chkSql($u_phone,true);
	$u_question = be("post","u_question"); $u_question=chkSql($u_question,true);
	$u_answer = be("post","u_answer"); $u_answer=chkSql($u_answer,true);
	
	
	if ($u_password1 != $u_password2){ alert ("两次密码不同");exit;}
	if (strlen($u_name) >32) { $u_name= substring($u_name,32);}
	if (strlen($u_password1) >32) { $u_password1=substring($u_password1,32);}
	if (strlen($u_email) > 32) { $u_email=substring($u_email,32);}
	if (strlen($u_qq) > 16) { $u_qq=substring($u_qq,16);}
	if (strlen($u_phone) >16) { $u_phone=substring($u_phone,16);}
	if (strlen($u_question) >255) { $u_question=substring($u_question,255);}
	if (strlen($u_answer) >255) { $u_answer=substring($u_answer,255);}
	if (!isNum($u_qq)){ alert ("QQ号码格式不正确"); exit;}
	if (!isNum($u_phone)){ alert ("电话号码格式不正确"); exit;}
	
	$u_password1 = md5($u_password1);
	$u_name = strip_tags($u_name);
	
	$row = $db->getRow("SELECT * FROM {pre}user WHERE u_name='".$u_name."'");
	if (!$row){
		 $db->Add  ("{pre}user",array("u_name", "u_password","u_qq","u_email","u_regtime","u_status","u_points","u_group","u_phone","u_question","u_answer"),array($u_name,$u_password1,$u_qq,$u_email,date('Y-m-d H:i:s'),app_regstate,app_regpoint,app_reggroup,$u_phone,$u_question,$u_answer));
		alertUrl ("注册成功,正在转向登录页面","index.php?action=login"); exit;
	}
	else{
		alert ("注册失败,该用户名已经被使用" );exit;
	}
	unset($row);
}

function findpass()
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>魅雅听听 - 找回密码 </title>
<meta name="keywords" content="{maccms:keywords}"/>
<meta name="description" content="{maccms:description}"/>
<link href="css/base.css" type="text/css" rel="stylesheet"/>
<link href="css/qirebox.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/jquery.validate.js"></script>
    <script type="text/javascript" src="../js/function.js"></script>
</head>
<body>
<div class="layout" id="sign-header">
	<div id="sign-logo">
		<a href="../"><img src="images/logo.png" alt=""/></a>
	</div>
</div>
<!-- // sign-header end -->
<div class="layout" id="sign-content">
	<div class="ui-box ui-qire sign-focus" id="login-box">
		<div class="ui-title fn-clear">
			<span>还没有会员帐号？请<a href="?action=reg">注册会员</a></span>
			<h2>找回密码</h2>
		</div>
		<div class="ui-cnt fn-clear">
			<form method="post" action="?action=findpasssave">
				<div class="ui-form" id="sign-primary">
					<div class="ui-form-item fn-clear">
						<label for="u_name" class="ui-label w100">您的帐号：</label><input type="text" id="u_name" name="u_name" class="ui-input w300" value=""/>			
					</div>
					<div class="ui-form-item fn-clear">
						<label for="u_name" class="ui-label w100">找回问题：</label><input type="text" id="u_question" name="u_question" class="ui-input w300" value=""/>			
					</div>
					<div class="ui-form-item fn-clear">
						<label for="u_name" class="ui-label w100">找回答案：</label><input type="text" id="u_answer" name="u_answer" class="ui-input w300" value=""/>			
					</div>
					<div class="ui-form-item fn-clear">
						<label for="u_password" class="ui-label w100">新密码：</label><input type="password" id="u_password" name="u_password" maxlength="20" class="ui-input w300" value=""/>		
					</div>

					<div class="ui-form-item fn-clear">
						<label class="ui-label w100">&nbsp;</label><input type="submit" value="提交" class="ui-button w100" />
						
					</div>
				</div>
				<!-- // ui-form#sign-primary end -->
			</form>
			<div id="sign-app">
				<div class="sign-app-list">
					<h5>注册通行证可享会员服务</h5>
					<h5>可以收听任意有声小说</h5>
					<h5>可以任意有声小说</h5>
					<h5>让您看片、交友、互动，一个都不少。</h5>
					
					<h5>你还可以用以下方式直接登录：</h5>
					<a href="?action=reg&ref=qqlogin"><img src="images/qq_login.gif" alt=""/></a>
				</div>
			</div>
			<!-- // sign-app end -->
		</div>
	</div>
	<!-- // sign-box#regbox end -->
</div>
<?php
}

function findpasssave()
{
	global $db;
	$u_name = be("post","u_name"); $u_name=chkSql($u_name,true);
	$u_password = be("post","u_password"); $u_password=chkSql($u_password,true);
	$u_email = be("post","u_email"); $u_email=chkSql($u_email,true);
	$u_question = be("post","u_question"); $u_question=chkSql($u_question,true);
	$u_answer = be("post","u_answer"); $u_answer=chkSql($u_answer,true);
	
	if (strlen($u_name) >32) { $u_name= substring($u_name,32);}
	if (strlen($u_password) >32) { $u_password=substring($u_password,32);}
	if (strlen($u_question) >255) { $u_question=substring($u_question,255);}
	if (strlen($u_answer) >255) { $u_answer=substring($u_answer,255);}
	$u_password = md5($u_password);
	if(isN($u_question) || isN($u_answer) || isN($u_password) || isN($u_name)){
		alert ("表单信息不完整,请重填!"); exit;
	}
	
	$row = $db->getRow("SELECT * FROM {pre}user WHERE u_name='".$u_name."'");
	if (!$row){
		alert ("重置密码失败"); exit;
	}
	else{
		if ($u_question != $row["u_question"] || $u_answer != $row["u_answer"]){ alert ("重置密码失败");exit;}
		$db->Update ("{pre}user",array("u_password"),array($u_password),"u_id = ". $row["u_id"]);
		alertUrl ("重置密码成功,正在转向登录页面","index.php?action=login"); exit;
	}
	unset($row);
}

function tg()
{
	global $db;
	$userid = be("get","uid"); $userid=chkSql($userid,true);
	
	if (!chkGlobalCache("tjlastdate")){	setGlobalCache ("tjlastdate", date('Y-m-d'),0); }
	if (isNum($userid)){
		$ip = getIP();
		$ly=  getReferer();
		$row = $db->getRow("select * from {pre}user where u_id=" . $userid .""); 
		if ($row){
			$sql="Select * From {pre}user_visit where uv_uid = " .$userid." and uv_ip ='".$ip."' and STR_TO_DATE(uv_time,'%Y-%m-%d')='".date("Y-m-d")."'";
			
			$row1 = $db->getRow($sql);
			if (!$row1){
				$db->Add ("{pre}user_visit",array("uv_uid","uv_ip","uv_ly","uv_time"), array($userid,$ip,$ly, date("Y-m-d H:i:s")));
				$db->query ("update {pre}user set u_tj=u_tj+1,u_points=u_points+" . app_popularize . " where u_id=". $userid);
				if ( strpos( ",". date('Y-m-d H:i:s',time()), getGlobalCache("tjlastdate") ) <=0 ) {
					 $sql="delete from {pre}user_visit whereSTR_TO_DATE(uv_time,'%Y-%m-%d')<'".date("Y-m-d")."'";
					 $db->query($sql);
					 setGlobalCache ("tjlastdate", date('Y-m-d') , 0);
				}
			}
			unset($row1);
		}
		unset($row);
	}
	redirect ("../");
}

function save()
{
	global $db;
	$oldpass = be("post","u_oldpass"); $oldpass=chkSql($oldpass,true);
	$password1 = be("post","u_password1"); $password1=chkSql($password1,true);
	$password2 = be("post","u_password2"); $password2=chkSql($password2,true);
	$u_qq= be("post","u_qq"); $u_qq=chkSql($u_qq,true);
	$u_email = be("post","u_email"); $u_email=chkSql($u_email,true);
	
	if (strlen($u_email)>32) { $u_email = substring($u_email,32);}
	if (strlen($u_qq)>16) { $u_qq = substring($u_qq,16);}
	if (strlen($password1)>32) { $password1 = substring($password1,32);}
	
	$row = $db->getRow("select * from {pre}user where u_id=" . $_SESSION["userid"]);
	if(!$row){
		alert ("非法访问"); exit;
	}
	else{
		if ($row["u_password"] != md5($oldpass)){
			alert ("对不起：您输入的密码有误。请重新输入"); exit;
		}
	}
	unset($row);
	if ($password1 != ""){
		if ($password1 != $password2){ alert ("两次密码不同");exit; }
		$password1 = md5($password1);
		$db->Update ("{pre}user",array("u_qq","u_email","u_password") ,array($u_qq,$u_email,$password1) ,"u_id = ". $_SESSION["userid"]);
	}
	else{
		$db->Update ("{pre}user",array("u_qq","u_email") ,array($u_qq,$u_email) ,"u_id = ". $_SESSION["userid"]);
	}
	alertUrl ("修改成功！","?action=wel");
}

function upgradesave()
{
	global $db,$u_points;
	$NewU_Group = be("post","u_group");
	$NewU_Group = chkSql($NewU_Group,true);
	$upgradearr = explode("_",$NewU_Group);
	
	if (intval($_SESSION["ugpopvalue"]) > intval($upgradearr[2])){ alert ("您现在的会员组比目标会员组权限高，不需要升级!");exit;}
	if ($_SESSION["usergroup"] == intval($upgradearr[0])){ alert ("您已经是该会员组成员无需升级!"); exit;}
	if ($u_points < intval($upgradearr[1])) { alert ("您的积分不够，无法升级到该会员组!"); exit;}
	$db->query( "UPDATE {pre}user set u_points=u_points-".$upgradearr[1] . ",u_group=".$upgradearr[0] . "  WHERE u_id =". $_SESSION["userid"]);
	$_SESSION["ugpopvalue"] = $upgradearr[2];
	alertUrl ("升级成功,请重新登陆！","?action=wel");
}

function upgradesave2()
{
	global $db,$u_points;
	$baoshi = be("post","baoshi");
	if(!isNum($baoshi)){ $baoshi=0; } else { $baoshi=intval($baoshi); }
	switch($baoshi)
	{
		case 1:
			$baoshi = app_weekpoint; $dn=7;
			break;
		case 2:
			$baoshi = app_monthpoint; $dn=30;
			break;
		case 3;
			$baoshi = app_yearpoint; $dn=365;
			break;
		default :
			alertUrl ("非法请求，请重试！",""); exit;
			break;
	}
	
	if ($u_points < $baoshi) { alert ("您的积分不够，无法包时长!"); exit;}
	$u_end = $db->getOne("select u_end from {pre}user where u_id=".$_SESSION["userid"]);
	//var_dump($u_end) ;exit;
	if(empty($u_end)){
		$u_end = date('Y-m-d H:i:s',time()+ 24*60*60*$dn );
	}
	else{
		$u_end = date('Y-m-d H:i:s',strtotime($u_end)+ 24*60*60*$dn );
	}
	$db->query( "UPDATE {pre}user set u_points=u_points-".$baoshi . ",u_flag=1,u_start='".date('Y-m-d H:i:s',time())."',u_end='". $u_end ."'  WHERE u_id =". $_SESSION["userid"]);
	alertUrl ("包时长成功,请重新登陆！","?action=wel");
}

function playsdel()
{
	global $db;
	$db->Update  ("{pre}user" ,array("u_plays"), array("") ,"u_id=". $_SESSION["userid"] );
	alerturl ("清空播放记录成功!","?action=plays");
}

function downsdel()
{
	global $db;
	$db->Update  ("{pre}user" ,array("u_downs"), array("") ,"u_id=". $_SESSION["userid"] );
	alerturl ("清空下载记录成功!","?action=downs");
}

function favdel()
{
	global $db,$u_fav;
	$d_id = be("arr","d_id"); $d_id=chkSql($d_id,true);
	
	if (!isN($d_id) ){
		$arr = explode(",",$d_id);
		for ($i=0;$i<count($arr);$i++){
			if (strpos(",".$u_fav,",".trim($arr[$i]).",") > 0){
				$u_fav = replaceStr($u_fav, trim($arr[$i]),"");
				$u_fav = replaceStr($u_fav,",,",",");
			}
		}
		$db->Update ( "{pre}user" , array("u_fav"), array($u_fav) ,"u_id=". $_SESSION["userid"] );
	}
	alerturl ("删除完毕!","?action=fav");
}

function userhead()
{
	global $db;
	$row = $db->getRow("SELECT u_id, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_id=". $_SESSION["userid"]);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html xmlns:wb=“http://open.weibo.com/wb”>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>基本资料 - 会员中心 -魅雅听听</title>
<meta name="keywords" content="{maccms:keywords}"/>
<meta name="description" content="{maccms:description}"/>
<link href="css/base.css" type="text/css" rel="stylesheet"/>
<link href="css/i.css?20120915" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/jquery.validate.js"></script>
    <script type="text/javascript" src="../js/function.js"></script>
<script src="js/formValidator-4.0.1.js" type="text/javascript"></script>
<script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="i-header">
	<div class="layout fn-clear">
		<div id="i-logo">
			<a href="../"><img width="157" height="42" src="images/ilogo.gif" alt=""/></a>
		</div>
		<ul id="i-nav">
			<li class="i-nav-item"><a class="nav-link" target="_blank" href="../">返回首页</a></li>			
			<li class="i-nav-item drop-down" id="ubox"><a class="nav-link"><?php echo $row["u_name"]?></a></li>
			<li class="i-nav-item" id="i-logout"><a class="nav-link logoutbt" href="?action=logout&flag=main" target="_self">退出</a></li>
		</ul>
	</div>
</div>
<!-- // i-header end -->
<?php
}

function foot()
{
?>
<!-- // sign-content end -->
<div class="footer">
	<div class="layout">
		<div class="foot-nav">
<a href="http://www.meiyatt.com/shtml/9.html" target="_blank" title="关于我们">关于我们</a>|
<a href="http://www.meiyatt.com/shtml/11.html" target="_blank" title="诚聘英才">诚聘英才</a>|
<a href="http://www.meiyatt.com/shtml/23.html" target="_blank" title="广告服务">广告服务</a>|
<a href="http://www.meiyatt.com/shtml/10.html" target="_blank" title="联系我们">联系我们</a>|
<a href="http://www.meiyatt.com/shtml/28.html" target="_blank" title="投稿指南">投稿指南</a>|
<a href="http://www.meiyatt.com/gbook.php" target="_blank" title="求书留言">求书留言</a>|
<a href="http://www.meiyatt.com/shtml/27.html" target="_blank" title="版权声明">版权声明</a>
		</div>
		<!-- // foot-nav End -->
		<div class="copyright">
			<p>
				北京魅雅听听文化传播有限公司 网络视听许可证 黔ICP备10002305号
			</p>
			<p>
				Copyright © 2008-2014 MeiYaTt.Com Theme designed
			</p>
		</div>
		<!-- // maxBox End -->
	</div>
</div>
<!-- // footer end --></body>
</html>
<?php
}

function main()
{
	global $db;
	$row = $db->getRow("SELECT u_id, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_id=". $_SESSION["userid"]);

?>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li class="current"><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
         <div class="i-box-cnt">
         <div id="i-usershow" class="fn-clear">
<div class="user-info"><a href="?action=wel"><img src="http://vip.img.meiyatt.com/150x150.jpg" alt="暂无图片" id="userlogo">
</a></div><!-- // user-info End -->
<div class="user-cnt"><div id="i-intro"><p class="user-author"><strong><?php echo $row["u_name"]?></strong><span>(<?php echo $row["ug_name"]?>)</span><a href="?action=info">编辑资料</a></p><ul class="user-sign fn-clear"><li class="regtime"><label>注册时间：<?php echo $row["u_regtime"]?></label></li>
<li class="lastlogin"><label>最后登录：</label><?php echo $row["u_logintime"]?></li></ul></div><!-- // i-intro end --><div id="i-message" class="fn-clear">
</div>
<!-- // i-message end -->
</div>
<!-- // user-cnt End -->
</div>


<!-- // i-usershow end -->
<div class="qire-notice" id="i-notice"><a class="close" href="javascript:void(0);" data="25">关闭</a>
<p><b>推荐在百度中搜索站名“<a target="_blank" href="http://www.baidu.com/s?ie=UTF-8&wd=%E9%AD%85%E9%9B%85%E5%90%AC%E5%90%AC"><span style="color:#009900;">魅雅听听</span></a>”进入本站;如果觉得魅雅还不错的话,请牢记域名
<a target="_blank" href="http://www.meiyatt.com/"><span style="color:#009900;">http://MeiYaTt.Com</span></a>和告诉你身边的朋友吧。</b>
</p></div>
<!-- // i-notice end -->

<p>
	<br />
</p>

<wb:topic column="n" border="n" width="815" height="925" tags="%E9%AD%85%E9%9B%85%E5%90%AC%E5%90%AC" color="333333%2Cffffff%2C0078b6%2Ccccccc%2C333333%2Cfafeff%2C0078b6%2Ccccccc%2Ccccccc%2Ce9f4fb" language="zh_cn" version="base" appkey="5J3O2c" footbar="y" url="%23" filter="n" ></wb:topic>

<!-- // i-indexcnt end --></div></div><!-- // i-box end --></div><!-- // content end -->
<script type="text/javascript">
	function toTop(obj){
		var top=0;
		while(obj){
			top +=obj.offsetTop;
			obj=obj.offsetParent        
		}
		return top;
    }
	$(".i-tab-nav a").click(function (e){
		$(this).parent().parent().children('li').removeClass('current');
		$(this).parent().addClass('current');
		$("#bbl").attr('data',$(this).attr('data'));
		$("#list").html('');
		showinfo();
	});		
</script>

		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<!-- // wrap End -->
<?php
}

function login()
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>魅雅听听 - 用户登录 </title>
<meta name="keywords" content="{maccms:keywords}"/>
<meta name="description" content="{maccms:description}"/>
<link href="css/base.css" type="text/css" rel="stylesheet"/>
<link href="css/qirebox.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/jquery.validate.js"></script>
    <script type="text/javascript" src="../js/function.js"></script>
<script src="js/formValidator-4.0.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){	
	$("body").bind('keyup',function(event) {
		if(event.keyCode==13){ $('#btnLogin').click(); }
	}); 
	$('#btnLogin').click(function() {
		if ($('#u_name').val()  == '') { alert('请输入用户！'); $("#u_name").focus(); return false; }
		if ($('#u_password').val()  == '') { alert('请输入密码！'); $("#u_password").focus(); return false; }
		$("#form1").submit();
	});
});
</script>
</head>
<body>
<div class="layout" id="sign-header">
	<div id="sign-logo">
		<a href="../"><img src="images/logo.png" alt=""/></a>
	</div>
</div>
<!-- // sign-header end -->
<div class="layout" id="sign-content">
	<div class="ui-box ui-qire sign-focus" id="login-box">
		<div class="ui-title fn-clear">
			<span>还没有会员帐号？请<a href="?action=reg">注册会员</a></span>
			<h2>魅雅听听会员登录</h2>
		</div>
		<div class="ui-cnt fn-clear">
			<form id="loginform_web" method="post" action="?action=check">
	      	<input id="flag" name="flag" type="hidden" value="center">
				<div class="ui-form" id="sign-primary">
					<div class="ui-form-item fn-clear">
						<label for="u_name" class="ui-label w100">帐号或邮箱：</label><input type="text" id="u_name" name="u_name" class="ui-input w220" value=""/>
						<p class="ui-message" id="u_nameTip">
							用户名或邮箱地址
						</p>
					</div>
					<div class="ui-form-item fn-clear">
						<label for="u_password" class="ui-label w100">密码：</label><input type="password" id="u_password" name="u_password" maxlength="20" class="ui-input w220" value=""/>
						<p class="ui-message" id="u_passwordTip">
							6-16个字符
						</p>
					</div>
					<div class="ui-form-item ui-form-checkbox fn-clear">
						<label class="ui-label w100">&nbsp;</label>
						<div class="ui-form-block w220">
							<label for="remember" class="ui-label-checkbox"><input type="checkbox" name="remember" id="remember" checked="checked" value="1"/>下次自动登录
							</label><a href="?action=findpass">忘记密码了？</a>
						</div>
					</div>
					<div class="ui-form-item fn-clear">
						<label class="ui-label w100">&nbsp;</label><input type="submit" id="btnLogin" class="ui-button w220" value="用户登录"/>
						
					</div>
				</div>
				<!-- // ui-form#sign-primary end -->
			</form>
			<div id="sign-app">
				<div class="sign-app-list">
					<h5>注册通行证可享会员服务</h5>
					<h5>可以收听任意有声小说</h5>
					<h5>可以任意有声小说</h5>
					<h5>让您看片、交友、互动，一个都不少。</h5>
					
					<h5>你还可以用以下方式直接登录：</h5>
					<a href="?action=reg&ref=qqlogin"><img src="images/qq_login.gif" alt=""/></a>
				</div>
			</div>
			<!-- // sign-app end -->
		</div>
	</div>
	<!-- // sign-box#regbox end -->
	<script type="text/javascript">
		$.formValidator.initConfig({
			formID:"loginform_web",
			debug:false,
			submitOnce:false,
			onSuccess:function(){
				//alert('dddddddddddddd');
				$("#loginform_web").qiresub({
					curobj:$("#loginform_web #loginbt"),
					txt:'数据提交中,请稍后...',
					onsucc:function(result){
						$.hidediv(result);
					}
				}).post({url:'/user-login-viluser'});
				return false;
			},
			onError:function(msg,obj,errorlist){
				$("#errorlist").empty();
				$.map(errorlist,function(msg){
					$("#errorlist").append("<li>" + msg + "</li>")
				});
				//alert(msg);
			},
			submitAfterAjaxPrompt : '有数据正在异步验证，请稍等...'
		});
		$("#loginform_web #u_name").formValidator({
			onShow:"用户名或邮箱地址",
			onFocus:"至少4个字符",
			onCorrect:"填写正确"
		})
		.inputValidator({
			min:4,
			onError:"你输入的用户名非法,请确认"
		});
		$("#loginform_web #u_password").formValidator({
			onShow:"请输入密码",
			onFocus:"至少6个长度",
			onCorrect:"密码合法"
		})
		.inputValidator({
			min:6,
			empty:{
				leftEmpty:false,
				rightEmpty:false,
				emptyError:"密码两边不能有空符号"
			},
			onError:"你输入的密码非法,请确认"
		});
	</script>
</div>
<!-- // sign-content end -->
<?php
}

function wel()
{
	global $db;
	$row = $db->getRow("SELECT u_id, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_id=". $_SESSION["userid"]);

?>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li class="current"><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
			<form id="form1" name="form1" method="post" action="" >
				<div id="i-profile">
					<div class="ui-title i-tab-nav-box">
						<ul class="i-tab-nav fn-clear">
							<li class="current"><a href="?action=wel" >基本资料</a></li>
							<li class="line"></li>
							<li><a href="?action=info" >修改信息</a></li>
							<li class="line"></li>
							<li><a href="?action=psw" >修改密码</a></li>
							<li class="line"></li>
							<li><a href="?action=popedom" >我的权限</a></li>
						</ul>
					</div>
					<div class="ui-form">
						<div class="ui-form-item fn-clear">
							<label class="ui-label w130">用户名：</label> <p class="ui-label-checkbox"><?php echo $row["u_name"]?></p>		
						</div>
						<div class="ui-form-item fn-clear">
							<label for="nickname" class="ui-label w130">所属会员组：</label> <p class="ui-label-checkbox"><?php echo $row["ug_name"]?></p>
						</div>
						
						<div class="ui-form-item fn-clear">
							<label for="nickname" class="ui-label w130">计费类型：</label> <p class="ui-label-checkbox"><?php echo getUserFlag($row["u_flag"])?></p>
						</div>
						<div class="ui-form-item fn-clear">	
							<label for="nickname" class="ui-label w130">其他限制：</label> <p class="ui-label-checkbox">从<?php echo $row["u_start"]?> 到 <?php echo $row["u_end"]?></p>
						</div>
						
						<div class="ui-form-item fn-clear">
							<label for="nickname" class="ui-label w130">QQ号码：</label> <p class="ui-label-checkbox"><?php echo $row["u_qq"]?></p>
						</div>
						<div class="ui-form-item fn-clear">	
							<label for="nickname" class="ui-label w130">Email地址：</label> <p class="ui-label-checkbox"> <?php echo $row["u_email"]?> </p>
						</div>

						<div class="ui-form-item fn-clear">
							<label for="nickname" class="ui-label w130">注册时间：</label> <p class="ui-label-checkbox"><?php echo $row["u_regtime"]?></p>
						</div>
						<div class="ui-form-item fn-clear">
							<label for="nickname" class="ui-label w130">登录IP：</label> <p class="ui-label-checkbox"><?php echo $row["u_ip"]?></p>
						</div>
						<div class="ui-form-item fn-clear">
							<label for="nickname" class="ui-label w130">登录时间：</label> <p class="ui-label-checkbox"><?php echo $row["u_logintime"]?> </p>
						</div>
						<div class="ui-form-item fn-clear">
							<label for="nickname" class="ui-label w130">账户积分：</label> <p class="ui-label-checkbox"><?php echo $row["u_points"]?></p>
						</div>
						<div class="ui-form-item fn-clear">
							<label for="nickname" class="ui-label w130">推广次数：</label><p> <?php echo $row["u_tj"]?></p><label class="ui-label w130">推广链接：</label><input id="url" class="ui-input w300 ui-input-hover" value="http://<?php echo app_siteurl?>/user/?action=tg&uid=<?php echo $_SESSION["userid"]?>" size="70" style="border: 1 solid #000000">
						</div>
					</div>
					<!-- // ui-form End -->
				</div>
				<!-- // ui-box End -->
			</form>
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<!-- // wrap End -->
<?php
	unset($row);
}

function info()
{
	global $db;
	$row = $db->getRow("SELECT u_id,u_qid, u_name, u_qq, u_email, u_phone, u_question, u_answer,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_id=". $_SESSION["userid"] . "");
?>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li class="current"><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
		
			<form id="form1" name="form1" method="post" action="?action=save" >
				<div id="i-profile">
					<div class="ui-title i-tab-nav-box">
						<ul class="i-tab-nav fn-clear">
							<li ><a href="?action=wel" >基本资料</a></li>
							<li class="line"></li>
							<li class="current"><a href="?action=info" >修改信息</a></li>
							<li class="line"></li>
							<li><a href="?action=psw" >修改密码</a></li>
							<li class="line"></li>
							<li><a href="?action=popedom" >我的权限</a></li>
						</ul>
					</div>
					<div class="ui-form">
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130">用户名：</label> <p class="ui-label-checkbox"><?php echo $row['u_name']?></p>
	</div>
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130">邮件地址：</label><input class="ui-input w250" id="u_email" size="40" value="<?php echo $row["u_email"]?>" name="u_email">
	</div>
	<div class="ui-form-item fn-clear">
		<label for="u_oldpass" class="ui-label w130">密码：</label><input type="u_oldpass" id="u_oldpass" name="u_oldpass" maxlength="20" class="ui-input w250" value="">
		<p class="onShow ui-message" id="u_oldpassTip" style="">请输入密码确定修改</p>
	</div>
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130">QQ号码：</label><input class="ui-input w250" id="u_qq" size="40" value="<?php echo $row["u_qq"]?>" name="u_qq">
	</div>
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130">联系电话：</label><input class="ui-input w250" id="u_phone" size="40" value="<?php echo $row["u_phone"]?>" name="u_phone">
	</div>
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130">找回密码问题：</label><input class="ui-input" width="430" id="u_question" size="40" value="<?php echo $row["u_question"]?>" name="u_question">
	</div>
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130">找回密码答案：</label><input class="ui-input" width="430"  width="430" id="u_answer" size="40" value="<?php echo $row["u_answer"]?>" name="u_answer">
	</div>	
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130"></label><input type="submit" id="btnSave" class="ui-button w150" value="保 存"> 
	</div>
</div>
					<!-- // ui-form End -->
				</div>
				<!-- // ui-box End -->
			</form>
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<!-- // wrap End -->
<script type="text/javascript">
			$.formValidator.initConfig({
				formID:"changepsw",
				debug:false,
				submitOnce:false,
				onSuccess:function(){
					//alert('dddddddddddddd');
					$("#changepsw").qiresub({
						curobj:$("#savebt"),
						txt:'数据提交中,请稍后...',
						onsucc:function(result){
							//$.showfloatdiv({offset:$("#register").offset(),txt:'成功注册'});
							$.hidediv(result);
							if(parseInt(result.rcode)>0)
							{
								$("#u_oldpass").val('');
								$("#u_password1").val('');
								$("#u_password2").val('');
							}
							//alert(result.msg);
						}
					}).post({url:'/user-Center-changepsw'});
					return false;
				},
				onError:function(msg,obj,errorlist){
					$("#errorlist").empty();
					$.map(errorlist,function(msg){
						$("#errorlist").append("<li>" + msg + "</li>")
					});
					//alert(msg);
				},
				submitAfterAjaxPrompt : '有数据正在异步验证，请稍等...'
			});
			
			$("#u_oldpass").formValidator({
				onShow:"请输入密码",
				onFocus:"至少6个长度",
				onCorrect:"密码输入正确",
				onError:'密码不能为空'
			})
			.inputValidator({
				min:6,
				empty:{
					leftEmpty:false,
					rightEmpty:false,
					emptyError:"密码两边不能有空符号"
				},onError:"密码在6-16位"
			});
			
			$("#u_password1").formValidator({
				onShow:"请输入密码",
				onFocus:"至少6个长度",
				onCorrect:"密码合法"
			})
			.inputValidator({
				min:6,
				empty:{
					leftEmpty:false,
					rightEmpty:false,
					emptyError:"密码不能为空"
				},
				onError:"密码在6-16位"
			});
			
			// Verifyu_oldpass
			$("#u_password2").formValidator({
				onShow:"输再次输入密码",
				onFocus:"至少6个长度",
				onCorrect:"密码一致"
			})
			.inputValidator({
				min:6,
				empty:{
					leftEmpty:false,
					rightEmpty:false,
					emptyError:"重复密码必须和新密码一致"
				},onError:"重复密码必须和新密码一致"
			})
			.compareValidator({
				desID:"u_password1",
				operateor:"=",
				onError:"2次密码不一致,请确认"
			});
		</script>
<?php
	unset($row);
}

function psw()
{
	global $db;
	$row = $db->getRow("SELECT u_id,u_qid, u_name, u_qq, u_email, u_phone, u_question, u_answer,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_id=". $_SESSION["userid"] . "");
?>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li class="current"><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
		
			<form id="form1" name="form1" method="post" action="?action=save" >
				<div id="i-profile">
					<div class="ui-title i-tab-nav-box">
						<ul class="i-tab-nav fn-clear">
							<li ><a href="?action=wel" >基本资料</a></li>
							<li class="line"></li>
							<li><a href="?action=info" >修改信息</a></li>
							<li class="line"></li>
							<li class="current"><a href="?action=psw" >修改密码</a></li>
							<li class="line"></li>
							<li><a href="?action=popedom" >我的权限</a></li>
						</ul>
					</div>
					<div class="ui-form">
	<div class="ui-form-item fn-clear">
		<label for="u_oldpass" class="ui-label w130">旧密码：</label><input type="u_oldpass" id="u_oldpass" name="u_oldpass" maxlength="20" class="ui-input w250" value="">
		<p class="onShow ui-message" id="u_oldpassTip" style="">请输入密码</p>
	</div>
	<div class="ui-form-item fn-clear">
		<label for="u_password1" class="ui-label w130">新密码：</label><input type="password" id="u_password1" name="u_password1" maxlength="20" class="ui-input w250" value="">
		<p class="onShow ui-message" id="u_password1Tip" style="">请输入密码</p>
	</div>
	<div class="ui-form-item fn-clear">
		<label for="u_password2" class="ui-label w130">重复密码：</label><input type="password" id="u_password2" name="u_password2" maxlength="20" class="ui-input w250" value="">
		<p class="onShow ui-message"  id="u_password2Tip" style="">输再次输入密码</p>
	</div>
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130"></label><input type="submit" id="btnSave" class="ui-button w150" value="保 存"> 
	</div>
</div>
					<!-- // ui-form End -->
				</div>
				<!-- // ui-box End -->
			</form>
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<!-- // wrap End -->
<script type="text/javascript">
			$.formValidator.initConfig({
				formID:"changepsw",
				debug:false,
				submitOnce:false,
				onSuccess:function(){
					//alert('dddddddddddddd');
					$("#changepsw").qiresub({
						curobj:$("#savebt"),
						txt:'数据提交中,请稍后...',
						onsucc:function(result){
							//$.showfloatdiv({offset:$("#register").offset(),txt:'成功注册'});
							$.hidediv(result);
							if(parseInt(result.rcode)>0)
							{
								$("#u_oldpass").val('');
								$("#u_password1").val('');
								$("#u_password2").val('');
							}
							//alert(result.msg);
						}
					}).post({url:'/user-Center-changepsw'});
					return false;
				},
				onError:function(msg,obj,errorlist){
					$("#errorlist").empty();
					$.map(errorlist,function(msg){
						$("#errorlist").append("<li>" + msg + "</li>")
					});
					//alert(msg);
				},
				submitAfterAjaxPrompt : '有数据正在异步验证，请稍等...'
			});
			
			$("#u_oldpass").formValidator({
				onShow:"请输入密码",
				onFocus:"至少6个长度",
				onCorrect:"密码输入正确",
				onError:'密码不能为空'
			})
			.inputValidator({
				min:6,
				empty:{
					leftEmpty:false,
					rightEmpty:false,
					emptyError:"密码两边不能有空符号"
				},onError:"密码在6-16位"
			});
			
			$("#u_password1").formValidator({
				onShow:"请输入密码",
				onFocus:"至少6个长度",
				onCorrect:"密码合法"
			})
			.inputValidator({
				min:6,
				empty:{
					leftEmpty:false,
					rightEmpty:false,
					emptyError:"密码不能为空"
				},
				onError:"密码在6-16位"
			});
			
			// Verifyu_oldpass
			$("#u_password2").formValidator({
				onShow:"输再次输入密码",
				onFocus:"至少6个长度",
				onCorrect:"密码一致"
			})
			.inputValidator({
				min:6,
				empty:{
					leftEmpty:false,
					rightEmpty:false,
					emptyError:"重复密码必须和新密码一致"
				},onError:"重复密码必须和新密码一致"
			})
			.compareValidator({
				desID:"u_password1",
				operateor:"=",
				onError:"2次密码不一致,请确认"
			});
		</script>
<?php
	unset($row);
}

function popedom()
{
	global $db;
?>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li class="current"><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
			<form id="form1" name="form1" method="post" action="" >
				<div id="i-profile">
					<div class="ui-title i-tab-nav-box">
						<ul class="i-tab-nav fn-clear">
							<li ><a href="?action=wel" >基本资料</a></li>
							<li class="line"></li>
							<li><a href="?action=info" >修改信息</a></li>
							<li class="line"></li>
							<li><a href="?action=psw" >修改密码</a></li>
							<li class="line"></li>
							<li class="current"><a href="?action=popedom" >我的权限</a></li>
						</ul>
					</div>
					<div class="ui-form">
						<div class="ui-form-item fn-clear">
	<table class="tbinfo pleft" >
	<!-- BEGIN row -->
<?php
	
	$i=0;
	$rs = $db->query( "select t_id,t_name from {pre}vod_type");
	while ($row = $db ->fetch_array($rs))
	{
		echo  "<tr><td width=\"150\" height=\"30\" align=\"right\"> ". $row["t_name"] . "</td>";
		echo "<td width=\"400\">";
		echo "浏览分类页 <img src='../images/icons/";
		if (getUserPopedom( $row["t_id"],"list")){ echo "ok.png";} else { echo "cancel.png"; }
		echo "' width=16 height=16 border=0 />      " ;
		      	  
		echo "浏览内容页 <img src='../images/icons/";
		if (getUserPopedom( $row["t_id"],"vod")){ echo "ok.png";} else { echo "cancel.png";}
		echo "' width=16 height=16 border=0 />      " ;
		      	  
		echo "浏览播放页 <img src='../images/icons/";
		if (getUserPopedom( $row["t_id"],"play")){ echo "ok.png";} else { echo "cancel.png";}
		echo "' width=16 height=16 border=0 />      " ;
		
		echo "浏览下载页 <img src='../images/icons/";
		if (getUserPopedom( $row["t_id"],"down")){ echo "ok.png";} else { echo "cancel.png";}
		echo "' width=16 height=16 border=0 />      " ;
		
		echo "</td></tr>";
		
		$i++;
	}
	unset($rs);
?>
	<!-- END row -->
	</table>	
						</div>						
					</div>
					<!-- // ui-form End -->
				</div>
				<!-- // ui-box End -->
			</form>
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<?php
}

function plays()
{
	global $db,$cache,$template,$u_plays;
?>
<script>
$(document).ready(function(){
	$("#btnDel").click(function(){
		if(confirm('确定要清空记录吗')){
			$("#form1").attr("action","index.php?action=playsdel");
			$("#form1").submit();
		}
		else{return false}
	});
});
function checkAll(val,objname){
	$("input[name='"+objname+"']").each(function() {
		this.checked = val;
	});
}
</script>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li class="current"><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
		
				<div id="i-history">
	<div class="ui-title i-tab-nav-box fn-clear">
		<ul class="i-tab-nav">
			<li class="current">播放记录</li>
		</ul>
	</div>
	<div class="ui-cnt">
		<ul class="user-txt-list his-list fn-clear" id="xlist">
<form id="form1" name="form1" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="link_lan" id="list"  align="center">
<tr>
<td width="5%" height="26" class="us_list_title">&nbsp;</td>
<td class="us_list_title" >小说名称</td>
<td width="15%" class="us_list_title">小说分类</td>
<td width="15%" class="us_list_title">小说地址</td>
<td width="15%" class="us_list_title">消费积分</td>
</tr>
	<?php
	if (isN($u_plays)){
	?>
	<tr><td align="center" colspan="5">没有任何播放记录!</td></tr>
	<?php
	}
	else{
		$u_plays= "0".$u_plays;
		if (substring($u_plays, 1, strlen($u_plays)-1 ) == ","){ $u_plays = substring($u_plays, strlen($u_plays)-1 , 0); }
		$pagenum = be("all","page");
		if (!isNum($pagenum)) { $pagenum = 1;} else { $pagenum = intval($pagenum);}
		if ($pagenum < 1) { $pagenum = 1;}
		
		$rc=false;
		$playarr = explode(",",$u_plays);
		$u_plays = "";
		for ($i=1;$i<count($playarr);$i++){
			$arr1 = explode("-",$playarr[$i]);
			if (count($arr1)==3){
				if ($rc) { $u_plays = $u_plays . ","; }
				$u_plays = $u_plays . $arr1[0];
				$rc=true;
			}
		}
		
		$sql = "SELECT d_id,d_name,d_enname,d_type,d_stint,d_addtime FROM {pre}vod  where d_id in (". $u_plays.") order by d_addtime desc ";
		$sql .= " limit ".(30 * ($pagenum-1)) .",30";
		$rs = $db->query($sql);
		while ($row = $db ->fetch_array($rs))
		{
			$tname= "未知";
			$tenname="";
		  	$typearr = getValueByArray($cache[0], "t_id" ,$row["d_type"] );
			if(is_array($typearr)){
				$t_name= $typearr["t_name"];
				$t_enname= $typearr["t_enname"];
			}
	?>
	<tr>
		<td> </td>
		<td><?php echo $row["d_name"]?></td>
		<td><?php echo $t_name?></td>
		<td><a target="_blank" href="<?php echo $template->getVodLink($row["d_id"],$row["d_name"],$row["d_enname"],$row["d_addtime"],$row["d_type"],$t_name,$t_enname)?>">浏览</a></td>
		<td><?php echo $row["d_stint"]?></td>
	</tr>
	<?php
		}
	}
	unset($rs);
	?>
	<tr>
	<td colspan="5">
    <input class="ui-edit ui-edit-short" type="button" id="btnDel" value="清空记录" class="input">
	</td>
	</tr>
	</table>
	</form>
		</div>
		<!-- // list-page End -->
	</div>
</div>
				<!-- // ui-box End -->
	
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<?php
}

function downs()
{
	global $db,$cache,$template,$u_downs;
?>
<script>
$(document).ready(function(){
	$("#btnDel").click(function(){
		if(confirm('确定要清空记录吗')){
			$("#form1").attr("action","index.php?action=downsdel");
			$("#form1").submit();
		}
		else{return false}
	});
});
function checkAll(val,objname){
	$("input[name='"+objname+"']").each(function() {
		this.checked = val;
	});
}
</script>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li class="current"><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
		
				<div id="i-history">
	<div class="ui-title i-tab-nav-box fn-clear">
		<ul class="i-tab-nav">
			<li class="current">下载记录</li>
		</ul>
	</div>
	<div class="ui-cnt">
		<ul class="user-txt-list his-list fn-clear" id="xlist">
<form id="form1" name="form1" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="link_lan" id="list"  align="center">
<tr>
<td width="5%" height="26" class="us_list_title">&nbsp;</td>
<td class="us_list_title" >小说名称</td>
<td width="15%" class="us_list_title">小说分类</td>
<td width="15%" class="us_list_title">小说地址</td>
<td width="15%" class="us_list_title">消费积分</td>
</tr>
	<?php
	if (isN($u_downs)){
	?>
	<tr><td align="center" colspan="5">没有任何下载记录!</td></tr>
	<?php
	}
	else{
		$u_downs= "0".$u_downs;
		if (substring($u_downs, 1, strlen($u_downs)-1 ) == ","){ $u_downs = substring($u_downs, strlen($u_downs)-1 , 0); }
		$pagenum = be("all","page");
		if (!isNum($pagenum)) { $pagenum = 1;} else { $pagenum = intval($pagenum);}
		if ($pagenum < 1) { $pagenum = 1;}
		$rc=false;
		$playarr = explode(",",$u_downs);
		$u_downs = "";
		for ($i=1;$i<count($playarr);$i++){
			$arr1 = explode("-",$playarr[$i]);
			if (count($arr1)==3){
				if ($rc) { $u_downs = $u_downs . ","; }
				$u_downs = $u_downs . $arr1[0];
				$rc=true;
			}
		}
		
		$sql = "SELECT d_id,d_name,d_enname,d_type,d_stintdown,d_addtime FROM {pre}vod  where d_id in (". $u_downs.") order by d_addtime desc ";
		$sql .= " limit ".(30 * ($pagenum-1)) .",30";
		$rs = $db->query($sql);
		while ($row = $db ->fetch_array($rs))
		{
			$tname= "未知";
			$tenname="";
		  	$typearr = getValueByArray($cache[0], "t_id" ,$row["d_type"] );
			if(is_array($typearr)){
				$t_name= $typearr["t_name"];
				$t_enname= $typearr["t_enname"];
			}
	?>
	<tr>
		<td> </td>
		<td><?php echo $row["d_name"]?></td>
		<td><?php echo $t_name?></td>
		<td><a target="_blank" href="<?php echo $template->getVodLink($row["d_id"],$row["d_name"],$row["d_enname"],$row["d_addtime"],$row["d_type"],$t_name,$t_enname)?>">浏览</a></td>
		<td><?php echo $row["d_stint"]?></td>
	</tr>
	<?php
		}
	}
	unset($rs);
	?>
	<tr>
	<td colspan="5">
    <input class="ui-edit ui-edit-short" type="button" id="btnDel" value="清空记录" class="input">
	</td>
	</tr>
	</table>
	</form>
		</div>
		<!-- // list-page End -->
	</div>
</div>
				<!-- // ui-box End -->
	
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<?php
}

function rfav()
{
				echo "<script>window.location.href='rfav.php';</script>";
?>
<?php
}

function fav()
{
	global $db,$template,$cache,$u_fav;
?>
<script>
$(document).ready(function(){
	$("#btnDel").click(function(){
		if(confirm('确定要删除吗')){
		$("#form1").attr("action","index.php?action=favdel");
		$("#form1").submit();
		}
		else{return false}
	});
});
function checkAll(val,objname){
	$("input[name='"+objname+"']").each(function() {
		this.checked = val;
	});
}
</script>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li class="current"><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
		
				<div id="i-history">
	<div class="ui-title i-tab-nav-box fn-clear">
		<ul class="i-tab-nav">
							<li class="current"><a href="?action=fav" >我的收藏</a></li>
							<li class="line"></li>
							<li><a href="rfav.php" >热门收藏</a></li>
		</ul>
	</div>
	<div class="ui-cnt">
		<ul class="user-txt-list his-list fn-clear" id="xlist">
	<form id="form1" name="form1" method="post">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="link_lan" id="list"  align="center">
	<tr>
	<td width="5%" height="26" class="us_list_title">&nbsp;</td>
	<td class="us_list_title" >小说名称</td>
	<td width="15%" class="us_list_title">小说分类</td>
	<td width="15%" class="us_list_title">小说地址</td>
	<td width="15%" class="us_list_title">消费积分</td>
	</tr>
	<?php
	if (isN($u_fav)){
	?>
	<tr><td align="center" colspan="5">没有任何播放记录!</td></tr>
	<?php
	}
	else{
		$u_fav= "0".$u_fav;
		if (substring($u_fav, 1, strlen($u_fav)-1 ) == ","){ $u_fav = substring($u_fav, strlen($u_fav)-1 , 0); }
		$pagenum = be("all","page");
		if (!isNum($pagenum)) { $pagenum = 1;} else { $pagenum = intval($pagenum);}
		if ($pagenum < 1) { $pagenum = 1;}
		
		
		$sql = "SELECT d_id,d_name,d_enname,d_type,d_stint,d_addtime FROM {pre}vod  where d_id in (". $u_fav.") order by d_addtime desc ";
		$sql .= " limit ".(30 * ($pagenum-1)) .",30";
		$rs = $db->query($sql);
		while ($row = $db ->fetch_array($rs))
		{
			$tname= "未知";
			$tenname="";
		  	$typearr = getValueByArray($cache[0], "t_id" ,$row["d_type"] );
			if(is_array($typearr)){
				$t_name= $typearr["t_name"];
				$t_enname= $typearr["t_enname"];
			}
	?>
	<tr>
		<td><input name="d_id[]" type="checkbox" value="<?php echo $row["d_id"]?>"></td>
		<td><?php echo $row["d_name"]?></td>
		<td><?php echo $t_name?></td>
		<td><a target="_blank" href="<?php echo $template->getVodLink($row["d_id"],$row["d_name"],$row["d_enname"],$row["d_addtime"],$row["d_type"],$t_name,$t_enname)?>">浏览</a></td>
		<td><?php echo $row["d_stint"]?></td>
	</tr>
	<?php
		}
	}
	unset($rs);
	?>
	<tr>
	<td colspan="5">
	全选<input class="ui-edit ui-edit-short" name="chkall" type="checkbox" id="chkall" value="1" onClick="checkAll(this.checked,'d_id[]');"/>&nbsp;
    <input class="ui-edit ui-edit-short" type="button" id="btnDel" value="删除" class="input">
	</td>
	</tr>
	</table>
	</form>
		</div>
		<!-- // list-page End -->
	</div>
</div>
				<!-- // ui-box End -->
		<!-- // list-page End -->
	</div>
</div>
				<!-- // ui-box End -->
	
	<?php
}

function upgrade()
{
	global $db;
	$row = $db->getRow("SELECT u_id, u_name, u_qq, u_email,u_regtime,u_status,u_points,u_tj, u_loginnum, u_logintime,u_ip,u_random,u_flag,u_start,u_end,ug_id,u_group,ug_name,ug_type,ug_popedom,ug_popvalue FROM ({pre}user LEFT OUTER JOIN {pre}user_group ON {pre}user.u_group = {pre}user_group.ug_id) where u_id=". $_SESSION["userid"] ."");
?>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li  class="current"><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
				<div id="i-profile">
					<div class="ui-title i-tab-nav-box">
						<ul class="i-tab-nav fn-clear">
							<li class="current">升级会员组</li>
						</ul>
					</div>
					<div class="ui-form">
					
					<div class="ui-form-item fn-clear">
	<form action="?action=upgradesave" method="post" name="form3" id="form3">
					<input type="hidden" name="flag" value="1"/>
					<div class="ui-form-item fn-clear">
						<div class="ui-form-item">
						<label for="nickname" class="ui-label w130">所属会员组：</label> <p class="ui-label-checkbox"><?php echo $row["ug_name"]?></p>
						<label for="nickname" class="ui-label w130">当前积分：</label> <p class="ui-label-checkbox"><?php echo $row["u_points"]?></p>
						</div>
		<tr>
						<label class="ui-label w130">请选择要升级会员组：</label>
						<div class="ui-select">
					     <select id="u_group" name="u_group">
						 <option value="">请选择会员组</option>
            <?php
			$rsug = $db->query("select ug_id,ug_name,ug_upgrade,ug_popvalue FROM {pre}user_group");
			while ($row1 = $db ->fetch_array($rsug))
	    	{
				echo   "<option value='".$row1["ug_id"] .  "_". $row1["ug_upgrade"] ."_". $row1["ug_popvalue"] ."'>&nbsp;|—". $row1["ug_name"] ."(". $row1["ug_upgrade"] ."积分)</option>";
			}
			unset($rsug);
            ?>
            </select>
						</div>
					 <label class="ui-label w130"><input class="ui-button" type="submit" value="升级" id="btnSave"></label>					 
					</div>
					</form>
	
					<div class="ui-form-item fn-clear">
					<div class="ui-form-item">
					<label for="nickname" class="ui-label w130">计费类型：</label> <p class="ui-label-checkbox"><?php echo getUserFlag( $row["u_flag"])?></p>
					</div>
	<form action="?action=upgradesave2" method="post" name="form3" id="form3">
					<input type="hidden" name="flag" value="2"/>
					<label class="ui-label w130">请选择要包时长：</label>
		<?php
			if ($row["u_flag"]==1){
				echo "&nbsp;&nbsp;时间从：&nbsp;&nbsp;从" . $row["u_start"] . "到" . $row["u_end"];
			}
		?>
					 <div class="ui-select">
				     <select id="baoshi" name="baoshi">
                     <option value="1">包周会员</option>
                     <option value="2">包月会员</option>
                     <option value="3">包年会员</option>
                     </select>
					 </div>
					 <label class="ui-label w130"><input class="ui-button" type="submit" value="升级" id="btnSave"></label>					 
					 </div>
					 </form>
						
					</div>
					<!-- // ui-form End -->
				</div>
				<!-- // ui-box End -->
			</form>
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div></div>
<?php
unset($rs);
}

function pay()
{
?>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li><a href="?action=wel"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="?action=fav"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="?action=plays"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="?action=downs"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li  class="current"><a href="?action=pay"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li><a href="?action=upgrade"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
			<form action="?action=paysave" method="post" name="form4" id="form4">
				<div id="i-profile">
					<div class="ui-title i-tab-nav-box">
						<ul class="i-tab-nav fn-clear">
							<li class="current"><a href="?action=pay">充值卡充值</a></li>
							<li class="line"></li>
							<li><a href="?action=pay2">支付宝充值</a></li>							
							<li class="line"></li>
							<li><a href="?action=pay3">银圣充值</a></li>							
						</ul>
					</div>
					<div class="ui-form">
							<div class="ui-form-item fn-clear">
		<label for="newpass" class="ui-label w130">充值卡号码：</label><input id="cardnum" name="cardnum" maxlength="40" class="ui-input w400" value="">
	</div>
			
				<div class="ui-form-item fn-clear">
		<label for="newpass" class="ui-label w130">充值卡密码：</label><input id="cardpwd" name="cardpwd" maxlength="40" class="ui-input w400" value="">
	</div>
			
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130"></label><input class="ui-button w150" type="submit" value="确认" id="btnSave">
	</div>					
					</div>
					<!-- // ui-form End -->
				</div>
				<!-- // ui-box End -->
			</form>
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<?php
}

function pay2()
{
	require_once ("buyconfig.php");
	require_once ("alipay/alipay.config.php");
	
	$url = "http://" .$_SERVER["HTTP_HOST"] . "/user/";
?>
<script language="javascript">
$(document).ready(function(){
	$("#form5").validate({
		rules:{
			OrdAmt:{
				required:true,
				number:true,
				min:<?php echo app_buymin?>
			}
		}
	});
});
</script>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li ><a href="index.php?m=user-index.html"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="index.php?m=user-fav.html"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="index.php?m=user-plays.html"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="index.php?m=user-downs.html"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li class="current"><a href="index.php?m=user-pay.html"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="index.php?m=user-upgrade.html"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
				<div id="i-profile">
					<div class="ui-title i-tab-nav-box">
						<ul class="i-tab-nav fn-clear">
							<li ><a href="?action=pay">充值卡充值</a></li>
							<li class="line"></li>
							<li class="current"><a href="?action=pay2">支付宝充值</a></li>							
							<li class="line"></li>
							<li><a href="?action=pay3">银圣充值</a></li>							
						</ul>
					</div>
					<div class="ui-form">
			<div class="ui-form-item fn-clear">
	<form action="alipay/alipayapi.php" method="post" name="form5" id="form5">
<label for="newpass" class="ui-label w130">支付宝充值金额：</label>
		<input type="text" name="WIDprice" value="<?php echo app_buymin?>" size="22" maxlength="12" class="ui-input w100">
		<label for="newpass" class="ui-label" style="width: 310px;">*（最小充值金额为<?php echo app_buymin?>元，1元可以兑换<?php echo app_buyexc?>个积分）</label>
	           </div>

			
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130"></label><input class="ui-button w150" type="submit" value="确认" id="btnSave">
	</div>					
					</div>
					<!-- // ui-form End -->
				</div>
				<!-- // ui-box End -->
		<input type="hidden" name="WIDseller_email" value="<?php echo app_alipay_id?>" >
		<input type="hidden" name="WIDout_trade_no" value="<?php echo date(Ymdhms)?>" >
		<input type="hidden" name="WIDsubject" value="在线充值" >
		<input type="hidden" name="RetUrl" value="<?php echo $url?>alipay/return_url.php" >
		<input type="hidden" name="BgRetUrl" value="<?php echo $url?>alipay/notify_url.php" >
		
	</form>
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<?php
}

function pay3()
{
	require_once ("buyconfig.php");
	require_once ("alipay/alipay.config.php");
	
	$url = "http://" .$_SERVER["HTTP_HOST"] . "/user/";
?>
<script language="javascript">
$(document).ready(function(){
	$("#form5").validate({
		rules:{
			OrdAmt:{
				required:true,
				number:true,
				min:<?php echo app_buymin?>
			}
		}
	});
});
</script>
<div id="content" class="layout">
	<div class="ui-box ui-qire fn-clear" id="i-box">
		<div id="i-bar">
			<h3>会员控制面板</h3>
			<div id="user-nav">
				<ul class="user-nav-list fn-clear">  					
		            <li><a href=""><span class="icon ct-icon">&nbsp;</span>我的首页</a></li>
		            <li ><a href="index.php?m=user-index.html"><span class="icon zl-icon">&nbsp;</span>我的资料</a></li>
					<li><a href="index.php?m=user-fav.html"><span class="icon sc-icon">&nbsp;</span>我的收藏</a></li>
					<!--<li><a href="#"><span class="icon dy-icon">&nbsp;</span>我的订阅</a></li>-->
					<li><a href="index.php?m=user-plays.html"><span class="icon pl-icon">&nbsp;</span>我的播放记录</a></li>
					<li><a href="index.php?m=user-downs.html"><span class="icon bf-icon">&nbsp;</span>我的下载记录</a></li>
					<li class="current"><a href="index.php?m=user-pay.html"><span class="icon dx-icon">&nbsp;</span>充值卡充值</a></li>
					<li ><a href="index.php?m=user-upgrade.html"><span class="icon gz-icon">&nbsp;</span>升级会员组</a></li>
					<!--<li><a href="#"><span class="icon fd-icon">&nbsp;</span>我的留言</li>--></a></li>
				</ul>
			</div>
			<!-- 
			<div class="user-visitors" id="user-visitors">
				<h3>最近访客</h3>
				<ul class="visitor-list">
				</ul>
			</div>
		     -->
		</div>
		<!-- // i-bar end -->
		<div class="i-box-cnt" id="i-cnt">
				<div id="i-profile">
					<div class="ui-title i-tab-nav-box">
						<ul class="i-tab-nav fn-clear">
							<li ><a href="?action=pay">充值卡充值</a></li>
							<li class="line"></li>
							<li><a href="?action=pay2">支付宝充值</a></li>							
							<li class="line"></li>
							<li class="current"><a href="?action=pay3">银圣充值</a></li>							
						</ul>
					</div>
					<div class="ui-form">
			<div class="ui-form-item fn-clear">
	<form action="http://pay.yinshengvip.com/pay/" method="post" name="form5" id="form5">
<label for="newpass" class="ui-label w130">银圣充值金额：</label>
		<input type="text" name="WIDprice" value="<?php echo app_buymin?>" size="22" maxlength="12" class="ui-input w100">
		<label for="newpass" class="ui-label" style="width: 310px;">*（最小充值金额为<?php echo app_buymin?>元，1元可以兑换<?php echo app_buyexc?>个积分）</label>
	           </div>

			
	<div class="ui-form-item fn-clear">
		<label class="ui-label w130"></label><input class="ui-button w150" type="submit" value="确认" id="btnSave">
	</div>					
					</div>
					<!-- // ui-form End -->
				</div>
				<!-- // ui-box End -->
		<input type="hidden" name="merchant_idcode" value="ksyitnnoudo6oght" >
		<input type="hidden" name="OrdId" value="<?php echo date(Ymdhms)?>" >
		<input type="hidden" name="Pid" value="10000" size="6" maxlength="10">
		<input type="hidden" name="RetUrl" value="<?php echo $url?>buy_return_url.php" >
		<input type="hidden" name="BgRetUrl" value="<?php echo $url?>buy_notify_url.php" >
		<input type="hidden" name="MerPriv" value="" size="60" maxlength="60">
		<input type="hidden" name="UsrMp" value="" size="15" maxlength="11">
		<input type="hidden" name="partnerID" value="<?php echo app_buyid?>" >
		<input type="hidden" name="keyID" value="<?php echo app_buykey?>" >
		
	</form>
		</div>
		<!-- // i-cnt End -->
	</div>
	<!-- // maxBox End -->
</div>
<?php
}

function paysave()
{
	global $db;
	$cardnum = be("post","cardnum"); $cardnum=chkSql($cardnum,true);
	$cardpwd = be("post","cardpwd"); $cardpwd=chkSql($cardpwd,true);
	if (isN($cardnum)){ alert ("卡号不能为空！" );exit;}
	if (isN($cardpwd)) { alert ("卡号密码不能为空" ); exit;}
	
	$sql = "SELECT * FROM {pre}user_card WHERE c_number='". $cardnum ."'and c_pass='". $cardpwd."'";
    $row = $db->getRow($sql);
	if (!$row){
		alert ("该充值卡不存在或者卡号密码错了");exit;
	}
	else{
		if ($row["c_used"]==1){
		   alert ("此卡已经充值，请不要重复使用此卡");exit;
		}
		$c_id = $row["c_id"];
		$c_point = $row["c_point"];
	}
	unset($rs);
	
	$sql = "SELECT * FROM {pre}user WHERE u_id=" . $_SESSION["userid"] . "";
	$row1 = $db->getRow($sql);
	if (!$row1){
		alert ("获取会员信息出错,充值失败"); exit ;
	}
	else{
		$db->query("update {pre}user set u_points=u_points+".$c_point." where u_id = ". $_SESSION["userid"]);
	}
	unset($row);
	unset($row1);
	$db->query("update {pre}user_card set c_used=1,c_user=". $_SESSION["userid"] .",c_sale=1,c_usetime='". date('Y-m-d H:i:s',time()) ."' where c_id = ". $c_id);
	alert ("充值成功");
}

function paysave2()
{
	$buynum = be("post","buynum"); $buynum=chkSql($buynum,true);
	if (!isNum($buynum)){ alert ("充值金额必须是数字！" );exit; } else { $buynum=intval($buynum); }
	if ($buynum < app_buymin) { alert ("最小充值金额是".app_buymin."元，请重填！" );exit; }
	
}
?>