<?php
include("require.php");
if(!isset($_COOKIE['core_user_name']))
  jump("index.php");
if(!isset($_GET['action']))
  $_GET['action']="basic";
if($_GET['action']=="card")
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->table="shop_cards";
  $phpcolor->field="*";
  $phpcolor->where="uid='".$userv['id']."' and status!='1'";
  $count = $phpcolor->exist(2);
  $phpcolor->where="uid='".$userv['id']."' and status!='1' order by cardtime desc limit ".($_GET['page']*10).",10";
  $card=$phpcolor->assignment();
  $page=pages($count,10,$_GET['page'],'manage','&action=card','','0');
  $phpcolor->table="shop_card";
  $phpcolor->field="cardname,introduction";
  for ($count=0;$count<count($card);$count++)
  {
	$phpcolor->where="id='".$card[$count]['cardid']."'";
	$rs=$phpcolor->exist(1);
	$card[$count]['cardname']=$rs['cardname'];
	$card[$count]['introduction']=$rs['introduction'];
	if($card[$count]['status']=="0")
	  $card[$count]['statuss']='正常';
	else
	  $card[$count]['statuss']=$card[$count]['prices'].'点积分转让中';
  }
  $tpl -> assign("card", $card);
  $tpl -> assign("page", $page);
}
elseif($_GET['action']=="shop")
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->table="shop_cards";
  $phpcolor->field="*";
  $phpcolor->where="status='3'";
  $count = $phpcolor->exist(2);
  $phpcolor->where="status='3' order by selltime desc limit ".($_GET['page']*10).",10";
  $card=$phpcolor->assignment();
  $page=pages($count,10,$_GET['page'],'manage','&action=shop','','0');
  for ($count=0;$count<count($card);$count++)
  {
	$phpcolor->table="shop_card";
    $phpcolor->field="cardname,introduction";
	$phpcolor->where="id='".$card[$count]['cardid']."'";
	$rs=$phpcolor->exist(1);
	$card[$count]['cardname']=$rs['cardname'];
	$card[$count]['introduction']=$rs['introduction'];
	$phpcolor->table="user";
    $phpcolor->field="username";
    $phpcolor->where="id='".$card[$count]['uid']."'";
    $rs=$phpcolor->exist(1);
    $card[$count]['username']=$rs['username'];
  }
  $tpl -> assign("card", $card);
  $tpl -> assign("page", $page);
}
else
{
  $phpcolor->table="user";
  $phpcolor->field="*";
  $phpcolor->where="username = '".$_COOKIE['core_user_name']."'";
  $user=$phpcolor->exist(1);
  $rztime=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  $phpcolor->table="vip";
  $phpcolor->where="uid='".$user['id']."' and type='1' and etime>'".$rztime."'";
  $user['vip']=$phpcolor->exist(1);
  $phpcolor->where="uid='".$user['id']."' and type='2' and etime>'".$rztime."'";
  $user['dr']=$phpcolor->exist(1);
  $phpcolor->table="attest";
  $phpcolor->where="uid='".$user['id']."' and type='1'";
  $user['userv']="0";
  if($rs=$phpcolor->exist(1))
  {
    $user['userv']="1";
    $user['uservxx']=$rs['attest'];
  }
  $phpcolor->table="shop_cards";
  $phpcolor->field="*";
  $phpcolor->where="uid = '".$userv['id']."' and status='0'";
  $card=$phpcolor->exist(2);
  $phpcolor->where="uid = '".$userv['id']."' and status='3'";
  $cardz=$phpcolor->exist(2);
  $tpl -> assign("user", $user);
  $tpl -> assign("card", $card);
  $tpl -> assign("cardz", $cardz);
}
$tpl -> assign("core_header_title", $core_bartype."商城管理中心 - ");
$tpl -> assign("action", $_GET['action']);
$tpl -> display("$core_style/shop_manage.htm");
?>