<?php
if (! defined ( 'APP_PATH' ) || ! defined ( 'I_PATH' )) {
	exit ( 'Access Denied' );
}
/**
 * 模拟用户登陆
 * Enter description here ...
 * @param unknown_type $userid
 */
function login_user($userid) {
	if (isset ( $userid )) {
		$r = syDB ( 'member' )->find ( 'id=' . $userid );
		if (! $r) {
			message ("程序出现问题请与管理员联系:错误代码100100100");
		} else {
			$_SESSION ['member'] = array ('user' => $r ['user'], 'id' => $r ['id'], 'gid' => $r ['gid'], 'another_name' => '', 'type' => '0' );
			if (! empty ( $_SESSION ['shopingcar'] )) {
				$orderidArr = explode ( ',', substr ( $_SESSION ['shopingcar'], 1 ) );
				$oidlen = 4 - strlen ( $r ['id'] );
				$oidstr = '';
				if (intval ( $oidlen ) > 0) {
					for($i = 1; $i <= intval ( $oidlen ); $i ++) {
						$oidstr .= '0';
					}
				}
				$oidstr .= $r ['id'];
				foreach ( $orderidArr as $v ) {
					$updateArr = array ('user_id' => $r ['id'] );
					syDB ( 'consumer_records' )->update ( array ('orderid' => $v ), $updateArr );
					$rs = syDB ( 'order' )->find ( array ('id' => $v ) );
					$oid = preg_replace ( '/[0-9]{4}$/', $oidstr, $rs ['oid'] );
					$updateArr1 = array ('mid' => $r ['id'], 'oid' => $oid );
					syDB ( 'order' )->update ( array ('id' => $v ), $updateArr1 );
				}
				unset ( $_SESSION ['shopingcar'] );
				unset ( $_SESSION ['shopingrecode'] );
				echo "<html><head><meta http-equiv='refresh' content=';url=index.php?c=member&a=listorder'></head><body></body></html>";
				exit;
			}
		}
	}
}

class member extends controllerBase {
	function __construct() {
		parent::__construct ();
		syClass ( 'symember' );
		$this->cu = syClass ( 'ldi_member' );
		$this->dbl = func_get_iglobal ( array ('db', 'prefix' ) );
		$this->db = $this->dbl . 'member';
		$this->sy_class_type = syClass ( 'syclasstype' );
		$this->molds_message = syDB ( 'molds' )->find ( array ('molds' => 'message' ) );
		$this->fun_comment = syDB ( 'funs' )->find ( array ('funs' => 'comment' ) );
		
		$this->SysIconfig = parent::geticonfig ();
		
		if (! empty ( $_SESSION ['member'] )) {
			$this->member_g = syDB ( 'member_group' )->find ( array ('gid' => $_SESSION ['member'] ['gid'] ) );
			if ($this->member_g ['submit'] == 1) {
				$this->typemenu = syDB ( 'classtype' )->findAll ( ' msubmit>0 and msubmit<=' . $this->member_g ['weight'] . ' ', ' orders desc,tid ', 'tid,molds,classname,orders,msubmit' );
			}
		}
	}
	function index() {
		$this->display ( "member/index.html" );
	}
	
	function login() {
		if ($this->sysParams ( "go" ) == 1) {
			//第三方登录START
			if (1 == $this->sysParams ( "authlogin" )) //QQ登录
{
				if (! $this->sysParams ( 'openid', 1 ) || ! $this->sysParams ( 'token', 1 )) {
					message ( "缺少传值", "?c=member&a=login" );
				}
				$openid = urldecode ( $this->sysParams ( "openid", 1 ) );
				$token = urldecode ( $this->sysParams ( "token", 1 ) );
				//$mylogin = array('qq_openid' => $openid,'qq_token'=>$token);
				$mylogin = array ('qq_openid' => $openid );
				$rr = syDB ( 'member' )->find ( $mylogin );
				
				if (! $rr) {
					message ( "参数错误", "?c=member&a=login" );
					exit ();
				}
				
				$weight = syDB ( 'member_group' )->find ( array ('gid' => $rr ['gid'] ) );
				$_SESSION ['member'] = array ('user' => $rr ['user'], 'id' => $rr ['id'], 'gid' => $rr ['gid'], 'another_name' => $rr ['another_name'], 'type' => '0' );
				$this->jump ( "?c=member" );
				exit ();
			} elseif (2 == $this->sysParams ( "authlogin" )) { //微博登录
				

				if (! $this->sysParams ( 'openid', 1 ) || ! $this->sysParams ( 'token', 1 )) {
					message ( "缺少传值", "?c=member&a=login" );
				}
				
				$openid = urldecode ( $this->sysParams ( "openid", 1 ) );
				$token = urldecode ( $this->sysParams ( "token", 1 ) );
				
				$mylogin = array ('sina_id' => $openid, 'sina_token' => $token );
				$rr = syDB ( 'member' )->find ( $mylogin );
				if (! $rr) {
					message ( "参数错误", "?c=member&a=login" );
					exit ();
				}
				
				$weight = syDB ( 'member_group' )->find ( array ('gid' => $rr ['gid'] ) );
				$_SESSION ['member'] = array ('user' => $rr ['user'], 'id' => $rr ['id'], 'gid' => $rr ['gid'], 'another_name' => $rr ['another_name'], 'type' => '0' );
				$this->jump ( "?c=member" );
				exit ();
			}
			///第三放登录END
			

			if ($this->sysParams ( "user", 1 ) && $this->sysParams ( "pass", 1 )) {
				if (func_get_iglobal ( array ('vercode' ) ) == 1) {
					if (! $this->sysParams ( "vercode", 1 ) || md5 ( strtolower ( $this->sysParams ( "vercode", 1 ) ) ) != $_SESSION ['i_verify'])
						message ( "验证码错误" );
				}
				$conditions = array ('user' => $this->sysParams ( "user", 1 ), 'pass' => md5 ( md5 ( $this->sysParams ( "pass", 1 ) ) . $this->sysParams ( "user", 1 ) ) );
				$r = syDB ( 'member' )->find ( $conditions );
				if (! $r) {
					message ( "用户名或密码错误" );
				} else {
					$weight = syDB ( 'member_group' )->find ( array ('gid' => $r ['gid'] ) );
					$_SESSION ['member'] = array ('user' => $r ['user'], 'id' => $r ['id'], 'gid' => $r ['gid'], 'another_name' => '', 'type' => '0' );
					
					////////////////////////////逻辑修改10  购物车
					if (! empty ( $_SESSION ['shopingcar'] )) {
						$orderidArr = explode ( ',', substr ( $_SESSION ['shopingcar'], 1 ) );
						$oidlen = 4 - strlen ( $r ['id'] );
						$oidstr = '';
						if (intval ( $oidlen ) > 0) {
							for($i = 1; $i <= intval ( $oidlen ); $i ++) {
								$oidstr .= '0';
							}
						}
						
						$oidstr .= $r ['id'];
						
						foreach ( $orderidArr as $v ) {
							$updateArr = array ('user_id' => $r ['id'] );
							syDB ( 'consumer_records' )->update ( array ('orderid' => $v ), $updateArr );
							$rs = syDB ( 'order' )->find ( array ('id' => $v ) );
							$oid = preg_replace ( '/[0-9]{4}$/', $oidstr, $rs ['oid'] );
							$updateArr1 = array ('mid' => $r ['id'], 'oid' => $oid );
							syDB ( 'order' )->update ( array ('id' => $v ), $updateArr1 );
						}
						unset ( $_SESSION ['shopingcar'] );
						unset ( $_SESSION ['shopingrecode'] );
						$this->jump ( "index.php?c=member&a=listorder" );
					}
					
					$this->jump ( "?c=member" );
				}
			} else {
				message ( "请输入用户名和密码" );
			}
		}
		$url = $_SERVER ['HTTP_HOST'] ? $_SERVER ['HTTP_HOST'] : $_SERVER ['SERVER_NAME'];
		$url = 'http://' . $url . str_replace ( 'index.php', '', $_SERVER ['SCRIPT_NAME'] );
		$url = $url . 'auth/sinalogin/index.php';
		
		$rtjson = file_get_contents ( $url );
		$rtArr = json_decode ( $rtjson, 1 );
		$this->sinalogin_url = $rtArr ['error'];
		
		$this->display ( "member/login.html" );
	
	}
	function out() {
		$_SESSION ['member'] = array ();
		if (isset ( $_COOKIE [session_name ()] )) {
			setcookie ( session_name (), '', time () - 42000, '/' );
		}
		session_destroy ();
		$this->jump ( $GLOBALS ['WWW'] );
	}
	function rules() {
		if ($this->sysParams ( "r" ) == 1) {
			if (syDB ( 'member' )->find ( array ('user' => $this->sysParams ( 'user', 1 ) ) )) {
				echo 'false';
			} else {
				echo 'true';
			}
		}
		if ($this->sysParams ( "r" ) == 2) {
			if (md5 ( strtolower ( $this->sysParams ( "vercode", 1 ) ) ) != $_SESSION ['i_verify']) {
				echo 'false';
			} else {
				echo 'true';
			}
		}
	}
	
	function reg() {
		$this->fields = $this->fields_info ( 'member', 0, array (), 1 );
		$source_type = $_REQUEST ['source']; //他的来源 。。。。 1、qq:qq登陆后需要补充信息 2、weibo:微博登陆后需要同步的信息
		if (empty ( $source_type )) {
			$source_type = $_REQUEST ['source_type'];
		}
		if (! empty ( $source_type )) {
			$qqtoken = $_COOKIE ['QQToken'];
		}
		if ($this->sysParams ( "go" ) == 1) {
			if (! $this->sysParams ( 'user', 1 ))
				message ( "请输入用户名" );
			if (! isset ( $source_type )) {
				if (syDB ( 'member' )->find ( array ('user' => $this->sysParams ( 'user', 1 ) ) ))
					message ( "用户名已被注册，请更换" );
			}
			if (! $this->sysParams ( 'pass1', 1 ))
				message ( "请输入密码" );
			if (! $this->sysParams ( 'pass2', 1 ))
				message ( "请输入确认密码" );
			if (! $this->sysParams ( 'email', 1 ))
				message ( "请输入Email" );
			if ($this->sysParams ( 'pass1', 1 ) != $this->sysParams ( 'pass2', 1 ))
				message ( "两次密码输入不一致" );
			if (func_get_iglobal ( array ('vercode' ) ) == 1) {
				if (md5 ( strtolower ( $this->sysParams ( "vercode", 1 ) ) ) != $_SESSION ['i_verify']) {
					message ( "验证码错误" );
				}
			}
			$newrow1 = array ('user' => $this->sysParams ( 'user', 1 ), 'pass' => md5 ( md5 ( $this->sysParams ( "pass1", 1 ) ) . $this->sysParams ( "user", 1 ) ), 'email' => $this->sysParams ( 'email', 1 ), 'gid' => 1, 'money' => 0, 'regtime' => time () );
			
			$newrow2 = array ();
			$newrow2 = array_merge ( $newrow2, $this->fields_args ( 'member', 0, 1 ) );
			//print_r($newrow1);
			$newVerifier = $this->cu->syVerifier ( $newrow1 );
			if (false == $newVerifier) {
				//同步数据
				if ($source_type == "qq") {
					require_once I_PATH . "/class/ldi_qqlogin.php";
					$login = new ldi_qqlogin ();
					$qqlogin = $login->findBy ( 'openid', $qqtoken );
					$this->cu->update ( 'id=' . $qqlogin ['userid'], $newrow1 );
					$addnewrow = $qqlogin ['userid'];
					$row = array ();
					$row ['is_sycn'] = 1;
					$row ['qq'] = $_REQUEST ['qq'];
					$login->update ( "openid='$qqtoken'", $row );
				} else {
					$addnewrow = $this->cu->create ( $newrow1 );
					if ($addnewrow == FALSE) {
						message ( "注册失败，请重新注册" );
					}
				}
				$arrays = array ('aid' => $addnewrow );
				$newrow2 = array_merge ( $newrow2, $arrays );
				//syDB ( 'member_field' )->create ( $newrow2 );
				
				$_SESSION ['member'] = array ('user' => $newrow1 ['user'], 'id' => $addnewrow, 'gid' => 1 );
				////////////////////////////逻辑修改10
				if (! empty ( $_SESSION ['shopingcar'] )) {
					$orderidArr = explode ( ',', substr ( $_SESSION ['shopingcar'], 1 ) );
					$oidlen = 4 - strlen ( $_SESSION ['member'] ['id'] );
					$oidstr = '';
					if (intval ( $oidlen ) > 0) {
						for($i = 1; $i <= intval ( $oidlen ); $i ++) {
							$oidstr .= '0';
						}
					}
					
					$oidstr .= $_SESSION ['member'] ['id'];
					
					foreach ( $orderidArr as $v ) {
						$updateArr = array ('user_id' => $_SESSION ['member'] ['id'] );
						syDB ( 'consumer_records' )->update ( array ('orderid' => $v ), $updateArr );
						$rs = syDB ( 'order' )->find ( array ('id' => $v ) );
						$oid = preg_replace ( '/[0-9]{4}$/', $oidstr, $rs ['oid'] );
						$updateArr1 = array ('mid' => $_SESSION ['member'] ['id'], 'oid' => $oid );
						syDB ( 'order' )->update ( array ('id' => $v ), $updateArr1 );
					}
					unset ( $_SESSION ['shopingcar'] );
					unset ( $_SESSION ['shopingrecode'] );
					message ( "恭喜您，注册成功", "?c=member&a=listorder" );
				}
				/////////////////////////
				

				message ( "恭喜您，注册成功", "?c=member" );
			} else {
				
				message_err ( $newVerifier );
			}
		}
		
		////////////////hd个人修改/////////////////////
		

		$this->auth = isset ( $_GET ['auth'] ) ? preg_match ( '/^[0-9]{1}$/', $_GET ['auth'] ) ? $_GET ['auth'] : 0 : 0;
		
		if ($this->auth > 0) {
			if (! isset ( $_GET ['another_name'] ) || ! isset ( $_GET ['openid'] ) || ! isset ( $_GET ['token'] )) {
				message ( "参数不合法", "index.php" );
			}
			
			$this->another_name = urldecode ( $_GET ['another_name'] );
			$this->openid = urldecode ( $_GET ['openid'] );
			$this->token = urldecode ( $_GET ['token'] );
		
		}
		
		/////////////////////////////////////////////////////////////////
		$url = $_SERVER ['HTTP_HOST'] ? $_SERVER ['HTTP_HOST'] : $_SERVER ['SERVER_NAME'];
		$url = 'http://' . $url . str_replace ( 'index.php', '', $_SERVER ['SCRIPT_NAME'] );
		$url = $url . 'auth/sinalogin/index.php';
		
		$rtjson = file_get_contents ( $url );
		$rtArr = json_decode ( $rtjson, 1 );
		$this->sinalogin_url = $rtArr ['error'];
		if (! empty ( $source_type )) // 用户同步问题
{
			//模拟登陆进去
			//取UserID
			if ($source_type == "qq") {
				require_once I_PATH . "/class/ldi_qqlogin.php";
				$login = new ldi_qqlogin ();
				$qqlogin = $login->findBy ( 'openid', $qqtoken );
				$userid = $qqlogin ['userid'];
				$this->another_name = $qqlogin ['qq_username'];
			}
		}
		$this->source_type = $source_type;
		$this->display ( "member/reg.html" );
	}
	
	function myinfo() {
		if ($this->sysParams ( "go" ) == 1) {
			if (! $this->sysParams ( 'email', 1 ))
				message ( "请输入Email" );
			$newrow1 = array ('email' => $this->sysParams ( 'email', 1 ) );
			if ($this->sysParams ( 'pass', 1 ) || $this->sysParams ( 'pass1', 1 ) || $this->sysParams ( 'pass2', 1 )) {
				if (! $this->sysParams ( 'pass', 1 ))
					message ( "请输入原密码" );
				if (! syDB ( 'member' )->find ( array ('user' => $_SESSION ['member'] ['user'], 'pass' => md5 ( md5 ( $this->sysParams ( "pass", 1 ) ) . $_SESSION ['member'] ['user'] ) ) ))
					message ( "原密码错误" );
				if (! $this->sysParams ( 'pass1', 1 ))
					message ( "请输入新密码" );
				if (! $this->sysParams ( 'pass2', 1 ))
					message ( "请输入确认新密码" );
				if ($this->sysParams ( 'pass1', 1 ) != $this->sysParams ( 'pass2', 1 ))
					message ( "两次密码输入不一致" );
				$newrow1 = array_merge ( $newrow1, array ('pass' => md5 ( md5 ( $this->sysParams ( "pass1", 1 ) ) . $_SESSION ['member'] ['user'] ) ) );
			}
			$newrow2 = array ();
			$newrow2 = array_merge ( $newrow2, $this->fields_args ( 'member' ) );
			syDB ( 'member' )->update ( array ('id' => $_SESSION ['member'] ['id'] ), $newrow1 );
			//syDB ( 'member_field' )->update ( array ('aid' => $_SESSION ['member'] ['id'] ), $newrow2 );
			message ( "资料修改成功" );
		}
		$user = syDB ( 'member' )->findSql ( 'select * from ' . $this->db . ' a left join ' . $this->db . '_field b on (a.id=b.aid) where id=' . $_SESSION ['member'] ['id'] );
		$this->my = $user [0];
		$this->fields = $this->fields_info ( 'member', 0, $this->my, 1 );
		$this->display ( "member/myinfo.html" );
	}
	function mylist() {
		if (! $this->sysParams ( 'tid' ))
			message ( "请指定内容tid", "?c=member" );
		$tid = $this->sysParams ( 'tid' );
		$this->type = syDB ( 'classtype' )->find ( array ('tid' => $tid ), null, 'tid,molds,classname,msubmit' );
		$c = syClass ( 'ldi_' . $this->type ['molds'] );
		if ($this->member_g ['submit'] == 0 || membergroup ( $this->type ['msubmit'], 'weight' ) > $this->member_g ['submit'])
			message ( "本栏目无权投稿", "?c=member" );
		$tid_leafid = $this->sy_class_type->leafid ( $tid );
		$this->lists = $c->syPager ( $this->sysParams ( 'page', 0, 1 ), 20 )->findAll ( " tid in(" . $tid_leafid . ") and user='" . $_SESSION ['member'] ['user'] . "' and usertype=1 ", 'orders desc,id desc' );
		$pages = $c->syPager ()->getPager ();
		$this->pages = pagetxt ( $pages, func_get_iglobal ( array ('url', 'url_path_base' ) ) . '?c=member&a=mylist&tid=' . $tid );
		$this->display ( "member/mylist.html" );
	}
	function mymessage() {
		$this->lists = syDB ( 'message' )->findAll ( " user='" . $_SESSION ['member'] ['user'] . "' ", 'addtime desc,id desc' );
		$c = syClass ( 'ldi_message' );
		$this->lists = $c->syPager ( $this->sysParams ( 'page', 0, 1 ), 10 )->findAll ( array ('user' => $_SESSION ['member'] ['user'] ), ' addtime desc ' );
		$c_page = $c->syPager ()->getPager ();
		$this->pages = pagetxt ( $c_page, func_get_iglobal ( array ('url', 'url_path_base' ) ) . '?c=member&a=mymessage' );
		$this->display ( "member/mymessage.html" );
	}
	function mycomment() {
		$c = syClass ( 'ldi_comment' );
		$this->lists = $c->syPager ( $this->sysParams ( 'page', 0, 1 ), 10 )->findAll ( array ('user' => $_SESSION ['member'] ['user'] ), ' addtime desc ' );
		$c_page = $c->syPager ()->getPager ();
		$this->pages = pagetxt ( $c_page, func_get_iglobal ( array ('url', 'url_path_base' ) ) . '?c=member&a=mycomment' );
		$this->display ( "member/mycomment.html" );
	}
	function mydel() {
		$molds = $this->sysParams ( 'molds', 1 );
		$id = $this->sysParams ( 'id' );
		switch ($molds) {
			case 'comment' :
				if (! syDB ( 'comment' )->delete ( array ('cid' => $id ) )) {
					message ( "删除失败,请重新提交" );
				}
				break;
			default :
				$c = syDB ( $molds )->find ( array ('id' => $id ), null, 'id,isshow' );
				if ($c ['isshow'] == 1)
					message ( "此内容已经审核，不能删除。" );
				if (! syDB ( $molds )->delete ( array ('id' => $id ) ) && ! syDB ( $molds . '_field' )->delete ( array ('aid' => $id ) )) {
					message ( "删除失败,请重新提交" );
				}
				break;
		}
		message ( "删除成功" );
	}
	function release() {
		if (! $this->sysParams ( 'tid' ))
			message ( "请选择栏目", "?c=member" );
		$this->id = $this->sysParams ( 'id' );
		$tid = $this->sysParams ( 'tid' );
		$this->type = syDB ( 'classtype' )->find ( array ('tid' => $tid ), null, 'tid,molds,classname,msubmit' );
		if ($this->type ['msubmit'] != - 1) {
			if ($this->member_g ['submit'] == 0 || $this->type ['msubmit'] == 0 || membergroup ( $this->type ['msubmit'], 'weight' ) > $this->member_g ['weight'])
				message ( "无权发布", "?c=member" );
		}
		if ($this->sysParams ( "go" ) == 1) {
			if (func_get_iglobal ( array ('vercode' ) ) == 1) {
				if (! $this->sysParams ( "vercode", 1 ) || md5 ( strtolower ( $this->sysParams ( "vercode", 1 ) ) ) != $_SESSION ['i_verify'])
					message ( "验证码错误" );
			}
			$isshow = ($this->member_g ['audit'] == 1) ? 1 : 0;
			//按频道投稿入库
			$row1 = array ('tid' => $tid, 'sid' => 0, 'title' => $this->sysParams ( 'title', 1 ), 'style' => '', 'trait' => '', 'gourl' => '', 'htmlfile' => '', 'htmlurl' => '', 'addtime' => time (), 'hits' => 0, 'litpic' => '', 'orders' => 0, 'mrank' => 0, 'mgold' => 0, 'isshow' => $isshow, 'keywords' => '', 'description' => '', 'user' => $_SESSION ['member'] ['user'], 'usertype' => 1 );
			if ($this->type ['molds'] == 'product')
				$row1 = array_merge ( array ('price' => $this->sysParams ( 'price', 3 ) ), $row1 );
			$row2 = array_merge ( array ('body' => $this->sysParams ( 'body', 1 ) ), $this->fields_args ( $this->type ['molds'], $tid ) );
			$add = syClass ( 'ldi_' . $this->type ['molds'] );
			$newv = $add->syVerifier ( $row1 );
			if (false == $newv) {
				if ($this->id) {
					if (syDB ( $this->type ['molds'] )->find ( array ('tid' => $tid, 'id' => $this->id, 'user' => $_SESSION ['member'] ['user'], 'usertype' => 1 ) )) {
						syDB ( $this->type ['molds'] )->update ( array ('id' => $this->id ), $row1 );
						syDB ( $this->type ['molds'] . '_field' )->update ( array ('aid' => $this->id ), $row2 );
					} else {
						message ( '无权操作' );
					}
				} else {
					$a = $add->create ( $row1 );
					$row2 = array_merge ( $row2, array ('aid' => $a ) );
					syDB ( $this->type ['molds'] . '_field' )->create ( $row2 );
				}
				syDB ( 'member_file' )->update ( array ('hand' => $this->sysParams ( 'hand' ), 'uid' => $_SESSION ['member'] ['id'] ), array ('hand' => 0, 'aid' => $a, 'molds' => $this->type ['molds'] ) );
				message ( '内容更新成功', '?c=member&a=mylist&tid=' . $tid );
			} else {
				message_err ( $newv );
			}
		
		//--------------
		}
		$this->hand = date ( 'His' ) . mt_rand ( 100, 999 );
		if ($this->id) {
			$c = syDB ( $this->type ['molds'] )->findSql ( 'select * from ' . $this->dbl . $this->type ['molds'] . ' a left join ' . $this->dbl . $this->type ['molds'] . '_field b on (a.id=b.aid) where user="' . $_SESSION ['member'] ['user'] . '" and usertype=1 and id=' . $this->id );
			$c = $c [0];
		}
		
		$this->fields = array ();
		//按频道显示投稿字段
		switch ($this->type ['molds']) {
			case 'article' :
				$a = array (array ('name' => '标题', 'input' => '<input name="title" type="text" class="inp" value="' . $c ['title'] . '" style="width:300px;" />', 'fields' => 'title' ), array ('name' => '内容', 'input' => '<textarea name="body" id="body1" class="inp" style="width:550px;height:200px;">' . $c ['body'] . '</textarea>', 'fields' => 'body' ) );
				$this->fields = array_merge ( $this->fields, $a );
				break;
			case 'product' :
				$a = array (array ('name' => '标题', 'input' => '<input name="title" type="text" class="inp" value="' . $c ['title'] . '" style="width:300px;" />', 'fields' => 'title' ), array ('name' => '价格', 'input' => '<input name="price" type="text" class="inp" value="' . $c ['price'] . '" style="width:300px;" />', 'fields' => 'price' ), array ('name' => '内容', 'input' => '<textarea name="body" id="body1" class="inp" style="width:550px;height:200px;">' . $c ['body'] . '</textarea>', 'fields' => 'body' ) );
				$this->fields = array_merge ( $this->fields, $a );
				break;
		}
		//--------------
		if ($c) {
			$this->fields = array_merge ( $this->fields, $this->fields_info ( $this->type ['molds'], $tid, $c, 0, $this->hand ) );
		} else {
			$this->fields = array_merge ( $this->fields, $this->fields_info ( $this->type ['molds'], $tid, array (), 0, $this->hand ) );
		}
		$this->display ( "member/release.html" );
	}
	function m_upload() {
		$ufm = syDB ( 'member_file' )->findSql ( 'SELECT sum(size) FROM ' . $this->db . '_file where uid=' . $_SESSION ['member'] ['id'] );
		if ($ufm [0] ['sum(size)'] > $this->member_g ['fileallsize'] * 1024) {
			echo '您的上传空间已满';
			exit ();
		}
		$fileClass = syClass ( 'syupload', array ($this->member_g ['filetype'], $this->member_g ['filesize'] * 1024 ) );
		if (! empty ( $_FILES )) {
			$fileinfos = $fileClass->upload_file ( $_FILES [$this->sysParams ( 'isfiles', 1 )] );
			if (is_array ( $fileinfos )) {
				$finfo = array ('uid' => $_SESSION ['member'] ['id'], 'url' => $fileinfos ['fn'], 'size' => $fileinfos ['si'], 'fields' => $this->sysParams ( 'inputid', 1 ), 'hand' => $this->sysParams ( 'hand' ) );
				$w = ' (hand=' . $this->sysParams ( 'hand' ) . ' and uid=' . $_SESSION ['member'] ['id'] . ' and fields="' . $this->sysParams ( 'inputid', 1 ) . '") or (hand!=' . $this->sysParams ( 'hand' ) . ' and hand!=0 and uid=' . $_SESSION ['member'] ['id'] . ') ';
				foreach ( syDB ( 'member_file' )->findAll ( $w, null, 'hand,fields,uid,url' ) as $v ) {
					@unlink ( $v ['url'] );
				}
				syDB ( 'member_file' )->delete ( $w );
				syDB ( 'member_file' )->create ( $finfo );
				echo '0';
				$f = explode ( '.', $fileinfos ['fn'] );
				echo ',' . $fileinfos ['fn'];
				echo ',' . preg_replace ( '/.*\/.*\//si', '', $f [0] );
				if (stripos ( $fileinfos ['fn'], 'jpg' ) || stripos ( $fileinfos ['fn'], 'gif' ) || stripos ( $fileinfos ['fn'], 'png' ) || stripos ( $fileinfos ['fn'], 'jpeg' )) {
					echo ',1';
				} else {
					echo ',' . $f [1];
				}
			} else {
				echo $fileClass->errmsg;
			}
		}
	}
	function m_upload_load() {
		$this->hand = $this->sysParams ( 'hand' );
		$this->inputid = $this->sysParams ( 'inputid', 1 );
		if (! $this->hand || $this->inputid == '')
			message ( "no hand or inputid" );
		$this->multi = $this->sysParams ( 'multi' ) ? 'true' : 'false';
		if ($this->sysParams ( 'fileExt', 1 )) {
			$this->fileExt = $this->sysParams ( 'fileExt', 1 );
		} else {
			foreach ( explode ( ',', $this->member_g ['filetype'] ) as $v ) {
				$fileExt .= ';*.' . $v;
			}
			$this->fileExt = substr ( $fileExt, 1 );
		}
		$this->sizeLimit = $this->sysParams ( 'sizeLimit' ) ? $this->sysParams ( 'sizeLimit' ) : $this->member_g ['filesize'] * 1024;
		$this->fileover = $this->sysParams ( 'fileover' ) ? $this->sysParams ( 'fileover' ) : 1;
		$this->display ( "member/uploads.html" );
	}
	
	private function fields_args($molds, $tid = 0, $lists = 0) {
		$fa = array ();
		$fieldswhere = " fieldshow=1 and issubmit=1 and molds='" . $molds . "'";
		if ($tid) {
			$fieldswhere .= " and types like '%|" . $tid . "|%' ";
		}
		if ($lists) {
			$fieldswhere .= " and lists=1 ";
		}
		$v = syDB ( 'fields' )->findAll ( $fieldswhere, ' fieldorder DESC,fid ' );
		foreach ( $v as $f ) {
			if ($f ['fieldstype'] == 'varchar' || $f ['fieldstype'] == 'files' || $f ['fieldstype'] == 'select' || $f ['fieldstype'] == 'text') {
				$ns = $this->sysParams ( $f ['fields'], 1 );
			}
			if ($f ['fieldstype'] == 'int') {
				$ns = $this->sysParams ( $f ['fields'] );
			}
			if ($f ['fieldstype'] == 'decimal') {
				$ns = $this->sysParams ( $f ['fields'], 3 );
			}
			if ($f ['fieldstype'] == 'time') {
				$ns = strtotime ( $this->sysParams ( $f ['fields'], 1 ) );
			}
			if ($f ['fieldstype'] == 'fileall') {
				$fieldsall = $this->sysParams ( $f ['fields'] . 'file', 2 );
				if ($fieldsall) {
					$txt = $this->sysParams ( $f ['fields'] . 'txt', 2 );
					$ns = '';
					foreach ( $fieldsall as $k => $v ) {
						$ns .= '|-|' . $v . '|,|' . $txt [$k];
					}
					$ns = substr ( $ns, 3 );
				}
			}
			if ($f ['fieldstype'] == 'checkbox') {
				if ($this->sysParams ( $f ['fields'], 2 )) {
					$ns = '|' . implode ( '|', $this->sysParams ( $f ['fields'], 2 ) ) . '|';
				} else {
					$ns = '';
				}
			}
			if ($molds == 'member' && $lists == 1) {
				if ($ns == '')
					message ( "请输入" . $f ['fieldsname'] );
			}
			$n = array ($f ['fields'] => $ns );
			$fa = array_merge ( $fa, $n );
		}
		return $fa;
	}
	private function fields_info($molds, $tid = 0, $c = array(), $lists = 0, $hand = 0) {
		$allfields = array ();
		$fieldswhere = " fieldshow=1 and issubmit=1 and molds='" . $molds . "'";
		if ($tid) {
			$fieldswhere .= " and types like '%|" . $tid . "|%' ";
		}
		if ($lists) {
			$fieldswhere .= " and lists=1 ";
		}
		$v = syDB ( 'fields' )->findAll ( $fieldswhere, ' fieldorder DESC,fid ' );
		foreach ( $v as $f ) {
			$m = '';
			switch ($f ['fieldstype']) {
				case 'varchar' :
					if ($f ['fieldslong'] > 255) {
						$t = '<textarea name="' . $f ['fields'] . '" style="width:300px; height:50px;" class="inp">' . $c [$f ['fields']] . '</textarea>';
					} else {
						$t = '<input name="' . $f ['fields'] . '" type="text" class="inp" value="' . $c [$f ['fields']] . '" />';
					}
					$m = '最多' . $f ['fieldslong'] . '个字';
					break;
				case 'text' :
					$t .= '<textarea name="' . $f ['fields'] . '" id="' . $f ['fields'] . '" style="width:550px;height:200px;" class="inp">' . $c [$f ['fields']] . '</textarea>';
					break;
				case 'int' :
					$t = '<input name="' . $f ['fields'] . '" type="text" class="inp" value="' . $c [$f ['fields']] . '" />';
					$m = '请输入整数格式，可为负数';
					break;
				case 'decimal' :
					$t = '<input name="' . $f ['fields'] . '" type="text" class="inp" value="' . $c [$f ['fields']] . '" />';
					$m = '请输入货币格式，如2.03';
					break;
				case 'time' :
					if ($c [$f ['fields']] != '') {
						$time = date ( 'Y-m-d H:i', $c [$f ['fields']] );
					} else {
						$time = date ( 'Y-m-d H:i' );
					}
					$t = '<input name="' . $f ['fields'] . '" type="text" class="inp" value="' . $time . '" onClick="WdatePicker({dateFmt:';
					$t .= "'yyyy-MM-dd HH:mm'";
					$t .= '})" />';
					break;
				case 'files' :
					$t = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><input name="' . $f ['fields'] . '" id="' . $f ['fields'] . '" type="text" class="inp" value="' . $c [$f ['fields']] . '" /></td><td width="5"></td><td><iframe frameborder="0" width="300" height="26" scrolling="No" id="flitpic" name="flitpic" src="?c=member&a=m_upload_load&inputid=' . $f ['fields'] . '&hand=' . $hand . '" style="float:left;"></iframe></td></tr></table>';
					break;
				case 'fileall' :
					$t = '<table border="0" cellspacing="0" cellpadding="0"><tr><td><input name="' . $f ['fields'] . '" id="' . $f ['fields'] . '" type="text" class="inp" value="' . $c [$f ['fields']] . '" /></td><td width="5"></td><td><iframe frameborder="0" width="300" height="26" scrolling="No" id="flitpic" name="flitpic" src="?c=member&a=m_upload_load&inputid=' . $f ['fields'] . '&hand=' . $hand . '" style="float:left;"></iframe></td></tr></table>';
					break;
				case 'select' :
					$t = '<select name="' . $f ['fields'] . '">';
					foreach ( explode ( ',', $f ['selects'] ) as $v ) {
						$s = explode ( '=', $v );
						$t .= '<option value="' . $s [1] . '" ';
						if ($c [$f ['fields']] == $s [1])
							$t .= 'selected="selected"';
						$t .= '>' . $s [0] . '</option>';
					}
					$t .= '</select>';
					break;
				case 'checkbox' :
					$t = '';
					foreach ( explode ( ',', $f ['selects'] ) as $v ) {
						$s = explode ( '=', $v );
						$t .= '<input type="checkbox" name="' . $f ['fields'] . '[]" value="' . $s [1] . '" ';
						if (stristr ( $c [$f ['fields']], '|' . $s [1] . '|' ) != FALSE)
							$t .= 'checked="checked"';
						$t .= '>' . $s [0];
					}
					break;
			}
			$allfields = array_merge ( $allfields, array (array ('name' => $f ['fieldsname'], 'input' => $t, 'fields' => $f ['fields'], 'm' => $m ) ) );
		}
		return $allfields;
	}
	///获取用户IP地址
	function hdsys_getip() {
		$ip = false;
		if (! empty ( $_SERVER ["HTTP_CLIENT_IP"] )) {
			$ip = $_SERVER ["HTTP_CLIENT_IP"];
		}
		if (! empty ( $_SERVER ['HTTP_X_FORWARDED_FOR'] )) {
			$ips = explode ( ", ", $_SERVER ['HTTP_X_FORWARDED_FOR'] );
			if ($ip) {
				array_unshift ( $ips, $ip );
				$ip = FALSE;
			}
			for($i = 0; $i < count ( $ips ); $i ++) {
				if (! eregi ( "^(10|172\.16|192\.168)\.", $ips [$i] )) {
					$ip = $ips [$i];
					break;
				}
			}
		}
		return ($ip ? $ip : $_SERVER ['REMOTE_ADDR']);
	}
	//购物车
	function shopingcar() {
		//if(empty($_SESSION['member'])){message("请先登录查看购物车","?c=member&a=login");}
		
		
		if ($this->sysParams ( "go" ) == 1) //添加产品
			{
			if (! isset ( $_POST ['productid'] ) || ! isset ( $_POST ['num'] ) || ! preg_match ( '/^[1-9]\d*$/', $_POST ['productid'] ) || ! preg_match ( '/^[1-9]\d*$/', $_POST ['num'] )) {
				$Arr = array ('erro' => 1, 'error' => '参数不完整' );
				echo json_encode ( $Arr );
				exit ();
			}			
			$conditions = array ('id' => $_POST ['productid'], 'isshow' => '1' );
			$rs = syDB ( 'product' )->find ( $conditions );
			if (! $rs) {
				$Arr = array ('erro' => 1, 'error' => '该产品不存在，或已经下架' );
			}
			
			$serialNum = date ( 'md' ); //流水号
			$num1 = 4 - strlen ( $rs ['id'] );
			if (intval ( $num1 ) > 0) {
				for($i = 1; $i <= $num1; $i ++) {
					$serialNum .= '0';
				}
			}
			
			$serialNum .= $rs ['id'];
			
			//逻辑修改1
			if (! empty ( $_SESSION ['member'] )) {
				$num2 = 4 - strlen ( $_SESSION ['member'] ['id'] );
				if (intval ( $num2 ) > 0) {
					for($s = 1; $s <= intval ( $num2 ); $s ++) {
						$serialNum .= '0';
					}
				}
				
				$serialNum .= $_SESSION ['member'] ['id'];
			} else {
				$serialNum .= '0000';
			}
			
			//添加
			$total = $rs ['price'] * $_POST ['num'];
			$addArr = array ('oid' => $serialNum, 'aid' => $rs ['id'], 'status' => '0', 'ip' => $this->hdsys_getip (), 'telphone' => '', 'pnum' => $_POST ['num'], 'pname' => $rs ['title'], 'price' => $rs ['price'], 'subtotal' => $total );
			
			//逻辑修改2
			if (! empty ( $_SESSION ['member'] )) {
				$addArr ['mid'] = $_SESSION ['member'] ['id'];
			} else {
				$addArr ['mid'] = '0';
			}
			
			$add = syClass ( 'ldi_order' );
			$a = $add->create ( $addArr );
			
			//逻辑修改3
			$_SESSION ['shopingcar'] .= ',' . $a;
			
			$Arr = array ('erro' => 0, 'error' => '商品已成功添加到购物车' );
			echo json_encode ( $Arr );
			exit ();
		
		} elseif ($this->sysParams ( "go" ) == 2) { //删除产品
			

			if (! $this->sysParams ( 'id' )) {
				$Arr = array ('erro' => 1, 'error' => '参数不完整' );
				echo json_encode ( $Arr );
				exit ();
			}
			
			//逻辑修改4
			if (! empty ( $_SESSION ['shopingcar'] )) {
				$arr = explode ( ',', substr ( $_SESSION ['shopingcar'], 1 ) );
				$str = '';
				foreach ( $arr as $v ) {
					if ($v != $this->sysParams ( 'id' )) {
						$str .= ',' . $v;
					}
				}
				$_SESSION ['shopingcar'] = $str;
			}
			
			$aa = syDB ( 'order' )->delete ( array ('id' => $this->sysParams ( 'id' ), 'mid' => $_SESSION ['member'] ['id'] ) );
			$dellArr = array ('erro' => 0, 'error' => '删除成功' );
			echo json_encode ( $dellArr );
			exit ();
		} elseif ($this->sysParams ( "go" ) == 3) { //提交订单
			//{phone:phone,address:address,yzcode:yzcode,more:more}
			

			if (! $this->sysParams ( 'phone', 1 ))
				message ( "请输入手机号码" );
			if (! $this->sysParams ( 'address', 1 ))
				message ( "联系地址" );
			if (! $this->sysParams ( 'yzcode', 1 ))
				message ( "邮政编码" );
			if (! $this->sysParams ( 'more', 1 ))
				message ( "订单备注" );
			
			if (! isset ( $_POST ['idliststr'] ) || ! preg_match ( '/[0-9\-\,]+/', $_POST ['idliststr'] )) {
				$aa = array ('erro' => 1, 'error' => '参数不合法' );
				exit ( json_encode ( $aa ) );
			}
			
			$updatenumArr = explode ( ',', substr ( $_POST ['idliststr'], 0, - 1 ) );
			
			foreach ( $updatenumArr as $v ) {
				$myarr = explode ( '-', $v );
				$updrs = syDB ( 'order' )->find ( array ('id' => $myarr [0] ), null, 'pnum,price' );
				if ($updrs ['pnum'] != $myarr [1]) {
					$updsum = $myarr [1] * $updrs ['price'];
					$updnumArr = array ('pnum' => $myarr [1], 'subtotal' => $updsum );
					syDB ( 'order' )->update ( array ('id' => $myarr [0] ), $updnumArr );
				}
			}
			
			$updateArr = array ('status' => '1', 'adddate' => time (), 'telphone' => $this->sysParams ( 'phone', 1 ), 'address' => $this->sysParams ( 'address', 1 ), 'postcode' => $this->sysParams ( 'yzcode', 1 ) );
			
			if ($this->sysParams ( 'more', 1 ) != '') {
				$updateArr ['more'] = $this->sysParams ( 'more', 1 );
			}
			
			//插入消费记录	
			////////////////////////////////////////////////////////////////////////////////
			

			//逻辑修改6
			if (! empty ( $_SESSION ['member'] )) {
				$selectArr = array ('mid' => $_SESSION ['member'] ['id'], 'status' => '0' );
				$getRecodeArr = syDB ( 'order' )->findall ( $selectArr );
			} else {
				if (! empty ( $_SESSION ['shopingcar'] )) {
					$myorderidArr = explode ( ',', substr ( $_SESSION ['shopingcar'], 1 ) );
					$getRecodeArr = array ();
					foreach ( $myorderidArr as $vvv ) {
						$mms = syDB ( 'order' )->find ( array ('id' => $vvv ) );
						if (! empty ( $mms )) {
							$getRecodeArr [] = $mms;
						}
					}
				
				} else {
					
					$rtArr = array ('erro' => 1, 'error' => '非法操作' );
					echo json_encode ( $rtArr );
					exit ();
				}
			}
			//未登录消费记录字符串
			$recodestr = '';
			foreach ( $getRecodeArr as $v ) {
				$totalfee = $v ['pnum'] * $v ['price'];
				$info = '购买' . $v ['pname'] . '共计' . $totalfee . '元';
				$recodeArr = array ('orderid' => $v ['id'], 'createtime' => time (), 'spendtype' => '2', 'spand_money' => $totalfee, 'actually_money' => $totalfee, 'isvalid' => '0', 'remark' => $info, 'iscomplated' => '0' );
				
				//逻辑修改7  #如果未登录用户则ID为0
				if (! empty ( $_SESSION ['member'] )) {
					$recodeArr ['user_id'] = $_SESSION ['member'] ['id'];
				} else {
					$recodeArr ['user_id'] = '0';
				}
				
				$rr = syClass ( 'ldi_consumer_records' )->create ( $recodeArr );
				$recodestr .= ',' . $rr;
			}
			//////////////////////////////////////////////////////////////////////////////////////
			//未登录用户添加消费记录SESSION
			if (empty ( $_SESSION ['member'] ) && ! empty ( $_SESSION ['shopingcar'] )) {
				if (! empty ( $_SESSION ['shopingrecode'] )) {
					$_SESSION ['shopingrecode'] .= $recodestr;
				} else {
					$_SESSION ['shopingrecode'] = $recodestr;
				}
			}
			
			//修改订单状态
			if (! empty ( $_SESSION ['member'] )) {
				syDB ( 'order' )->update ( array ('mid' => $_SESSION ['member'] ['id'], 'status' => '0' ), $updateArr );
			} else {
				if (! empty ( $_SESSION ['shopingcar'] )) {
					foreach ( $myorderidArr as $vvvv ) {
						syDB ( 'order' )->update ( array ('id' => $vvvv ), $updateArr );
					}
				}
			}
			
			$rtArr = array ('erro' => 0, 'error' => '订单提交成功' );
			echo json_encode ( $rtArr );
			exit ();
		
		} elseif ($this->sysParams ( "go" ) == 4) { //修改产品数量
			//orderid:id,num:nn
			//检查传值
			if (! isset ( $_POST ['orderid'] ) || ! isset ( $_POST ['num'] ) || ! preg_match ( '/^[1-9]\d*$/', $_POST ['orderid'] ) || ! preg_match ( '/^[1-9]\d*$/', $_POST ['num'] )) {
				$aa = array ('erro' => '1', 'error' => '参数不合法' );
				exit ( json_encode ( $aa ) );
			}
			//检测是否登录
			if (! empty ( $_SESSION ['member'] )) {
				$conditions = array ('mid' => $_SESSION ['member'] ['id'], 'id' => $_POST ['orderid'], 'status' => '0' );
				$rs = syDB ( 'order' )->find ( $conditions );
				$getAll = array ('mid' => $_SESSION ['member'] ['id'], 'status' => '0' );
				$logintype = 1;
			} else {
				if (! empty ( $_SESSION ['shopingcar'] )) {
					$showArr = explode ( ',', substr ( $_SESSION ['shopingcar'], 1 ) );
					if (! in_array ( $_POST ['orderid'], $showArr )) {
						$aa = array ('erro' => '1', 'error' => '非法操作' );
						exit ( json_encode ( $aa ) );
					}
					$getAll = $showArr;
					$logintype = 0;
					$conditions = array ('id' => $_POST ['orderid'], 'status' => '0' );
					$rs = syDB ( 'order' )->find ( $conditions );
				
				} else {
					$aa = array ('erro' => '1', 'error' => '商品信息错误' );
					exit ( json_encode ( $aa ) );
				}
			}
			
			if (empty ( $rs )) {
				$aa = array ('erro' => '1', 'error' => '商品信息错误' );
				exit ( json_encode ( $aa ) );
			}
			//原单一商品总价
			

			//新单一商品总价
			$sumoneprice = $rs ['price'] * $_POST ['num'];
			
			$updateArr = array ('pnum' => $_POST ['num'], 'subtotal' => $sumoneprice );
			syDB ( 'order' )->update ( array ('id' => $_POST ['orderid'], 'status' => '0' ), $updateArr );
			
			$newsumprice = 0;
			if ($logintype == 1) {
				$sumArr = syDB ( 'order' )->findall ( $getAll, null, 'subtotal' );
				foreach ( $showArr as $v ) {
					$newsumprice += $v ['subtotal'];
				}
			} else {
				
				foreach ( $getAll as $v ) {
					$sumArr = syDB ( 'order' )->find ( array ('id' => $v ) );
					$newsumprice += $sumArr ['subtotal'];
				
				}
			}
			
			$aa = array ('erro' => '0', 'sumprice' => $sumoneprice, 'total' => $newsumprice );
			exit ( json_encode ( $aa ) );
		
		}
		
		//检出商品#逻辑修改5
		if (! empty ( $_SESSION ['member'] )) {
			$conditions = array ('mid' => $_SESSION ['member'] ['id'], 'status' => '0' );
			$this->order = syDB ( 'order' )->findall ( $conditions );
		} else {
			if (! empty ( $_SESSION ['shopingcar'] )) {
				$allorder = array ();
				$showArr = explode ( ',', substr ( $_SESSION ['shopingcar'], 1 ) );
				$where = "";
				foreach ( $showArr as $v ) {
					$checkshow = syDB ( 'order' )->find ( "id=" . $v . " and status=0" );
					if (! empty ( $checkshow )) {
						$allorder [] = $checkshow;
					}
				}
				$this->order = $allorder;
			}
		}
		
		$arr = array ();
		
		//总价格
		$this->totalmoney = 0;
		
		foreach ( $this->order as $v ) {
			$arr [] = $v ['aid'];
			$this->totalmoney += $v ['price'] * $v ['pnum'];
		}
		
		$arrs = array_unique ( $arr );
		$Arrimg = array ();
		
		foreach ( $arrs as $vv ) {
			$proimg = array ('id' => $vv );
			$rm = syDB ( 'product' )->find ( $proimg );
			$Arrimg [$vv] = $rm ['litpic'];
		
		}
		//图片集
		$this->productImg = $Arrimg;
		
		$this->display ( "member/shopingcart.html" );
	}
	//订单列表
	function listorder() {
		//if(empty($_SESSION['member'])){message("请先登录后查看","?c=member&a=login");}
		

		//检出商品
		if (! empty ( $_SESSION ['member'] )) {
			$this->listorder = syDB ( 'order' )->findall ( 'mid = ' . $_SESSION ['member'] ['id'] . ' AND status > 0', ' id desc ' );
		} else {
			if (! empty ( $_SESSION ['shopingcar'] )) {
				$recodeArr = explode ( ',', substr ( $_SESSION ['shopingcar'], 1 ) );
				$myarr = array ();
				foreach ( $recodeArr as $v ) {
					$aa = syDB ( 'order' )->find ( 'id = ' . $v . ' AND status > 0' );
					if (! empty ( $aa )) {
						$myarr [] = $aa;
					}
				
				}
				$this->listorder = $myarr;
			
			} else {
				$this->listorder = array ();
			}
		}
		
		$this->display ( "member/listorder.html" );
	}
	
	//订单详细页面
	function ordershow() {
		//if(empty($_SESSION['member'])){message("请先登录后查看","?c=member&a=login");}
		if (! $this->sysParams ( 'orderid', 1 ))
			message ( "请按正确的流程操作", "?c=member&a=listorder" );
		
		if (! empty ( $_SESSION ['member'] ['id'] )) {
			$conditions = array ('mid' => $_SESSION ['member'] ['id'], 'id' => $this->sysParams ( 'orderid', 1 ) );
			$this->ordershow = syDB ( 'order' )->find ( $conditions );
		} else {
			
			$conditions = array ('mid' => '0', 'id' => $this->sysParams ( 'orderid', 1 ) );
			$this->ordershow = syDB ( 'order' )->find ( $conditions );
		}
		
		$proimg = array ('id' => $this->ordershow ['aid'] );
		$rm = syDB ( 'product' )->find ( $proimg );
		$this->productImg = $rm ['litpic'];
		$this->orderStatus = array ('1' => '已下单', '2' => '已付款', '4' => '系统已确认', '8' => '已发货' );
		
		//支付信息
		if ($this->ordershow ['status'] < 2) {
			$recodeArr = syDB ( 'consumer_records' )->find ( array ('orderid' => $this->ordershow ['id'] ) );
			
			$this->aplipayOrderId = $this->ordershow ['id']; //订单ID
			$this->aplipayPorductName = $this->ordershow ['pname']; //商品名
			$this->aplipayTotalFee = $this->ordershow ['pnum'] * $this->ordershow ['price']; //商品总价
			$this->aplipayUid = $_SESSION ['member'] ['id']; //用户ID
			$this->aplipayInfo = $this->ordershow ['more'];
			$this->aplipayMid = $_SESSION ['member'] ['id'] . "|" . $this->ordershow ['id'] . "|" . $recodeArr ['id'];
			if ($this->ordershow ['more'] == '') {
				$this->Info = '购买' . $this->ordershow ['pname'] . '共计' . $this->aplipayTotalFee . '元';
			}
		
		}
		
		$this->display ( "member/ordershow.html" );
	
	}
}
