<?php
/**
 *      [XCECP] (C) COLNET Inc.
 *      This is NOT a freeware, use is subject to license terms
 */
if(!defined("IN_QKWEB")){exit("Access Denied");}
class LifeAction{
	public $msg;
	function index(){
		$sm = new SeoModel();
		$pageInfo = $sm->pageInfo(8);
		$pageInfo['title'] = $pageInfo['title']?$pageInfo['title']:$GLOBALS['siteConf']['siteName'];
		assign("pageInfo",$pageInfo);
		display();
	}

	function submit(){
		$mobile = getgpc('mobile','P');if(!preg_match("/^1[3|5|8][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/",$mobile)){Msg::show('手机号码不正确');}
		$amount = getgpc('amount','P');if(!is_numeric($amount) || !in_array($amount,array('1','10','20','30','50','100','200'))){Msg::show('充值金额不正确');return false;}
		$ret = array('success'=>false,'message'=>'Forbidden');
		if(!$this->submitHandler()){ $ret['message']=$this->msg;echo json_encode($ret);exit; }
	}

	function submitHandler(){
		$ret = array('success'=>false,'message'=>'Forbidden');
		$mobile = getgpc('mobile','P');if(!preg_match("/^1[3|5|8][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/",$mobile)){$this->msg='Mobile Number Error';}
		$amount = getgpc('amount','P');if(!is_numeric($amount) || !in_array($amount,array('1','10','20','30','50','100','200'))){$this->msg='Amount Error';return false;}
		$key = 'e2b708a0e1f93adce99801d706597daa';
		$param = array(
			'partner'=>'100029',
			'service'=>'cn.convenient.recharge.direct',
			'mobile'=>$mobile,
			'amount'=>$amount,	
			'timestamp'=>time(),
			'ip'=>getIp()
		);
		foreach($param as $key=>$val){ $str = '';$str.=$key.'='.$val.'&'; }
		$param['sign'] = md5($str.'key='.$key);
		$url = 'http://chong.ueidc.com/app/gate';
		echo Pay::html($url,$param,'POST',true,'正在转到收银台进行付款...');exit;
		return true;
	}
}
?>