<?php
include("require.php");
if(!isset($_COOKIE['core_user_name']) or !isset($_GET['action']))
  jump("../index.php");
if(isset($_GET['action']) and $_GET['action'] == "sellno" and isset($_GET['id']))
{
  $phpcolor->table="shop_cards";
  $phpcolor->field="*";
  $phpcolor->where="id = '".$_GET['id']."' and status='3'";
  $card = $phpcolor->exist(1);
  if($userv['id']!=$card['uid'])
    jump("error.php?id=2");
  $phpcolor->field="status='0'";
  $phpcolor->upgrade();
  jump("shop_manage.php?action=card");
}
if(isset($_GET['action']) and $_GET['action'] == "sellyes" and isset($_GET['id']))
{
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  $phpcolor->table="shop_cards";
  $phpcolor->field="*";
  $phpcolor->where="id = '".$_GET['id']."' and status='0'";
  $card = $phpcolor->exist(1);
  if($userv['id']!=$card['uid'])
    jump("error.php?id=2");
  if(!eregi("^[0-9]+$",$_POST['prices']))
    jump("error.php?id=1&last=shop_manage.php?action=card");
  $phpcolor->field="status='3',prices='".$_POST['prices']."',selltime='".$time."'";
  $phpcolor->upgrade();
  jump("shop_manage.php?action=card");
}
if(isset($_GET['action']) and $_GET['action'] == "shopzr")
{
  $phpcolor->table="shop_cards";
  $phpcolor->field="*";
  $phpcolor->where="id='".$_POST['id']."'";
  $card = $phpcolor->exist(1);
  $phpcolor->table="shop_card";
  $phpcolor->field="cardname,introduction";
  $phpcolor->where="id='".$card['cardid']."'";
  $cards = $phpcolor->exist(1);
  $txt="<form action='shop_action.php?action=sellyes&id=".$card['id']."' method='post'><div style='line-height:150%'>您准备转让道具《".$cards['cardname']."》<br>道具作用：".$cards['introduction']."<br>该道具是您于".$card['cardtime']."使用".$card['price']."点积分购买<br>请输入转让价<input name='prices' type='text' class='box1' size='5' />点<br><input type='submit' value='转让' /></from>";
  die($txt);
}
if(isset($_GET['action']) and $_GET['action'] == "cardsysd")
{
  $phpcolor->table="shop_cards";
  $phpcolor->field="*";
  $phpcolor->where="id='".$_POST['id']."'";
  $card = $phpcolor->exist(1);
  if($userv['id']!=$card['uid'])
    die("0");
  if($_POST['mbids']=="")
    die("1");
  if($card['cardid']<=3)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
    $txt="您确认要对《<a href='read.php?id=".$post['id']."'>".$post['theme']."</a>》使用该道具吗？";
  }
  elseif($card['cardid']==4)
  {
    $phpcolor->table="repost";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and state = '1'";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
    $txt="您确认要删除 <a href='read.php?id=".$post['belong']."'>".$post['author']."发布在".($post['floor']+1)."楼的内容</a> 吗？";
  }
  elseif($card['cardid']==5)
  {
    $phpcolor->table="repost";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and state = '1'";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	$phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$post['belong']."' and (state = '1' or state = '2')";
	$topic = $phpcolor->exist(1);
	if($topic['author'] != $_COOKIE['core_user_name'])
	  die("3");
    $txt="您确认要删除 <a href='read.php?id=".$post['belong']."'>".$post['author']."发布在".($post['floor']+1)."楼的内容</a> 吗？";
  }
  elseif($card['cardid']==6)
  {
    $phpcolor->table="bar";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."'";
    if(!$bar = $phpcolor->exist(1))
	  die("4");
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$phpcolor->table="block";
    $phpcolor->field="*";
    $phpcolor->where="username='".$_COOKIE['core_user_name']."'  and (removetime>'".$time."' or removetime='0000-00-00 00:00:00') and barid ='".$bar['id']."'";
	if(!$block = $phpcolor->exist(1))
	  die("5");
    $txt="您确认要解除您在 ".$bar['barname']."吧 的封锁状态吗？";
  }
  elseif($card['cardid']==7)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
	$vip=$phpcolor->isvord($userv['id'],1);
	if(!$vip)
	  die("3");
	$post['content'] = str_replace("<br />","",$post['content']);
	$txt='主题：<input value="'.$post['theme'].'" id="theme" type="text" style="width:260px; height:20px;" /><br>内容：<textarea id="content" style="width:260px; height:45px;">'.$post['content'].'</textarea>';
  }
  elseif($card['cardid']==8)
  {
    $phpcolor->table="repost";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and state = '1'";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
	$vip=$phpcolor->isvord($userv['id'],1);
	if(!$vip)
	  die("3");
	$post['content'] = str_replace("<br />","",$post['content']);
	$txt='内容：<textarea id="content" style="width:260px; height:65px;">'.$post['content'].'</textarea>';
  }
  elseif($card['cardid']>=9)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	$vip=$phpcolor->isvord($userv['id'],1);
	if(!$vip)
	  die("3");
	$txt="您确认要对《<a href='read.php?id=".$post['id']."'>".$post['theme']."</a>》使用该道具吗？";
  }
  die($txt);
}
if(isset($_GET['action']) and $_GET['action'] == "cardsysy")
{
  $phpcolor->table="shop_cards";
  $phpcolor->field="*";
  $phpcolor->where="id='".$_POST['id']."'";
  $card = $phpcolor->exist(1);
  if($userv['id']!=$card['uid'])
    die("0");
  if($_POST['mbids']=="")
    die("1");
  if($card['cardid']==1)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
    $phpcolor->field="pxtime='0000-00-00 00:00:00'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="通过道具，执行沉贴，主题ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==2)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
    $phpcolor->field="locks='1'";
    $phpcolor->upgrade();
    $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="通过道具，执行锁贴，主题ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==3)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
    $phpcolor->field="state='0'";
    $phpcolor->upgrade();
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$phpcolor->table="recover";
    $phpcolor->field="tid, operate, operatetime, ip, type";
    $phpcolor->where="'".$_POST['mbids']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '1'";
    $phpcolor->write();
	$phpcolor->table="repost";
	$phpcolor->field="state='4'";
	$phpcolor->where="belong = '".$_POST['mbids']."' and state!='0'";
    $phpcolor->upgrade();
	$neirong="通过道具，执行删除主题，主题ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==4)
  {
    $phpcolor->table="repost";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and state = '1'";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
    $phpcolor->field="state='0'";
    $phpcolor->upgrade();
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$phpcolor->table="recover";
    $phpcolor->field="tid, operate, operatetime, ip, type";
    $phpcolor->where="'".$_POST['mbids']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
    $phpcolor->write();
	$neirong="通过道具，执行删除回贴，回贴ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==5)
  {
    $phpcolor->table="repost";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and state = '1'";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	$phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$post['belong']."' and (state = '1' or state = '2')";
	$topic = $phpcolor->exist(1);
	if($topic['author'] != $_COOKIE['core_user_name'])
	  die("3");
	$phpcolor->table="repost";
    $phpcolor->field="state='0'";
    $phpcolor->where="id='".$_POST['mbids']."' and state = '1'";
    $phpcolor->upgrade();
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$phpcolor->table="recover";
    $phpcolor->field="tid, operate, operatetime, ip, type";
    $phpcolor->where="'".$_POST['mbids']."', '".$_COOKIE["core_user_name"]."','".$time."','".$_SERVER['REMOTE_ADDR']."' , '2'";
    $phpcolor->write();
	$neirong="通过道具，执行删除回贴，回贴ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==6)
  {
    $phpcolor->table="bar";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."'";
    if(!$bar = $phpcolor->exist(1))
	  die("5");
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$phpcolor->table="block";
    $phpcolor->field="*";
    $phpcolor->where="username='".$_COOKIE['core_user_name']."'  and (removetime>'".$time."' or removetime='0000-00-00 00:00:00') and barid ='".$bar['id']."'";
	if(!$block = $phpcolor->exist(1))
	  die("5");
    $phpcolor->delete();
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="通过道具，解除由".$block['operate']."封锁的".$block['username']."，吧名：".$bar['barname'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==7)
  {
	$_POST['theme']=mb_convert_encoding($_POST['theme'], "gbk", "UTF-8");
	$_POST['content']=mb_convert_encoding($_POST['content'], "gbk", "UTF-8");
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
	$vip=$phpcolor->isvord($userv['id'],1);
	if(!$vip)
	  die("3");
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
    $_POST['content']=nl2br(autolink($_POST['content']));
	if($_POST['theme']=="" || $_POST['content']=="")
	  die("6");
	$_POST['content']=$_POST['content']."
<br />作者与".$time."对本贴进行编辑";
    $phpcolor->field="theme='".$_POST['theme']."', content='".$_POST['content']."'";
    $phpcolor->upgrade();
	$neirong="通过道具，执行编辑主题，主题ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==8)
  {
	$_POST['content']=mb_convert_encoding($_POST['content'], "gbk", "UTF-8");
    $phpcolor->table="repost";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and state = '1'";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	if($post['author'] != $_COOKIE['core_user_name'])
	  die("3");
	$vip=$phpcolor->isvord($userv['id'],1);
	if(!$vip)
	  die("3");
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
    $_POST['content']=nl2br(autolink($_POST['content']));
	if($_POST['content']=="")
	  die("6");
	$_POST['content']=$_POST['content']."<br />作者与".$time."对本贴进行编辑";
    $phpcolor->field="content='".$_POST['content']."'";
    $phpcolor->upgrade();
	$neirong="通过道具，执行编辑回贴，回贴ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==9)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	$vip=$phpcolor->isvord($userv['id'],1);
	if(!$vip)
	  die("3");
    $phpcolor->field="boutique='1'";
    $phpcolor->upgrade();
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="通过道具，执行加精主题，主题ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==10)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	$vip=$phpcolor->isvord($userv['id'],1);
	if(!$vip)
	  die("3");
    $phpcolor->field="pxtime='2036-12-31 23:59:59',top='1'";
    $phpcolor->upgrade();
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="通过道具，执行置顶主题，主题ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==11)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	$vip=$phpcolor->isvord($userv['id'],1);
	if(!$vip)
	  die("3");
    $phpcolor->field="locks='1'";
    $phpcolor->upgrade();
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="通过道具，执行锁定主题，主题ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  if($card['cardid']==12)
  {
    $phpcolor->table="topic";
    $phpcolor->field="*";
    $phpcolor->where="id='".$_POST['mbids']."' and (state = '1' or state = '2')";
    if(!$post = $phpcolor->exist(1))
	  die("2");
	$vip=$phpcolor->isvord($userv['id'],1);
	if(!$vip)
	  die("3");
    $phpcolor->field="pxtime='0000-00-00 00:00:00'";
    $phpcolor->upgrade();
	$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
	$neirong="通过道具，执行沉贴，主题ID：".$_POST['mbids'];
    $phpcolor->logwrite($neirong,$_COOKIE["core_user_name"],$time,2);
	$phpcolor->table="shop_cards";
    $phpcolor->field="status='1'";
    $phpcolor->where="id='".$_POST['id']."'";
	$phpcolor->upgrade();
  }
  die("4");
}
if(isset($_GET['action']) and $_GET['action'] == "cardsy")
{
  $phpcolor->table="shop_cards";
  $phpcolor->field="*";
  $phpcolor->where="id='".$_POST['id']."'";
  $card = $phpcolor->exist(1);
  $phpcolor->table="shop_card";
  $phpcolor->field="cardname,introduction";
  $phpcolor->where="id='".$card['cardid']."'";
  $cards = $phpcolor->exist(1);
  $txt="<div style='line-height:200%'>您准备使用道具《".$cards['cardname']."》<br>请输入目标Sid：<input id='mbids' name='mbids' type='text' class='box1' size='5' /><br><input id='djsd' type='submit' onclick='cardsysd(".$card['id'].")' value='锁定' />&nbsp;<input id='djsy' disabled='false' type='submit' onclick='cardsysy(".$card['id'].")' value='使用' /><div style='line-height:200%' id='tishi'></div>";
  die($txt);
}
if(isset($_GET['action']) and $_GET['action']=="buydiv")
{
  submitfilter($_POST['id']);
  if($_POST['classid']==1)
  {
    if($_POST['id']==1 and $shop_dropen!=1)
	  $txt="对不起，".$core_bartype."达人服务目前不允许自助开通";
	elseif($_POST['id']==2 and $shop_vipopen!=1)
	  $txt="对不起，".$core_bartype."VIP服务目前不允许自助开通";
    else
	{
      $phpcolor->table="user";
      $phpcolor->field="money";
      $phpcolor->where="username='".$_COOKIE['core_user_name']."'";
      $user=$phpcolor->exist(1);
      $servename=$core_bartype."VIP服务";
	  $pricem=$shop_vipmm;
	  $pricey=$shop_vipmy;
      if($_POST['id']==1)
	  {
	    $servename=$core_bartype."达人服务";
        $pricem=$shop_drmm;
	    $pricey=$shop_drmy;
	  }
	  $txt="<div style='line-height:200%'>您准备开通：".$servename."<br>开通价格：<input name='selltime' id='selltime' type='radio' value='1'/>".$pricem."元/月&nbsp;<input name='selltime' id='selltime' type='radio' value='2'/>".$pricey."元/年。<br>您现有余额：".$user['money']."元&nbsp;<a href='pay.php?action=pay'>充值</a><br><a href='JavaScript:' onclick='buy(1,".$_POST['id'].");'><img src='images/shop/btn01.jpg' border='0'></a></div><div style='line-height:200%' id='tishi'></div>";
	}
  }
  if($_POST['classid']==2)
  {
	$phpcolor->table="user";
    $phpcolor->field="integral";
    $phpcolor->where="username='".$_COOKIE['core_user_name']."'";
    $user=$phpcolor->exist(1);
    $phpcolor->table="shop_card";
    $phpcolor->field="*";
    $phpcolor->where="id=".$_POST['id'];
	$txt="对不起，该道具不存在";
    if($card=$phpcolor->exist(1))
	{
      $stock="<span style='color:#F00; font-weight:bold'>缺货</span>，我们将尽快补货。";
	  if($card['stock']>0)
	    $stock="<span style='color:#0F0; font-weight:bold'>".$card['stock']."张</span>，请尽快下手哦o(∩_∩)o";
      $price="市场价：<span style='color:#00F'>".$card['price']."点</span>";
	  $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='".$userv['id']."' and type='2' and etime>'".$rztime."'";
	  if($phpcolor->exist(2))
        $price="达人价：<span style='color:#C60'>".$card['dprice']."点</span>";
      $phpcolor->where="uid='".$userv['id']."' and type='1' and etime>'".$rztime."'";
      if($phpcolor->exist(2))
        $price="会员价<span style='color:#F00'>".$card['vprice']."点</span>";
	  $txt="<div style='line-height:150%'>您准备购买的道具为《".$card['cardname']."》<br>作用：".$card['introduction']."<br>当前库存还有".$stock."<br>您的价格为".$price."积分。（现有积分：".$user['integral']."点）<br><a href='JavaScript:' onclick='buy(2,".$_POST['id'].");'><img src='images/shop/btn01.jpg' border='0'></a></div><div style='line-height:150%' id='tishi'></div>";
	}
  }
  die($txt);
}
if(isset($_GET['action']) and $_GET['action']=="buy")
{
  submitfilter($_POST['id']);
  if($_POST['classid']==1)
  {
	$phpcolor->table="user";
    $phpcolor->field="money";
    $phpcolor->where="username='".$_COOKIE['core_user_name']."'";
    $user=$phpcolor->exist(1);
    if(($_POST['id']==1 and $shop_dropen!=1) or ($_POST['id']==2 and $shop_vipopen!=1))
	  die("5");
	else
	{
      if($_POST['selltime']==1 and $_POST['id']==1)
	    $price=$shop_drmm;
	  elseif($_POST['selltime']==1 and $_POST['id']==2)
	    $price=$shop_vipmm;
      elseif($_POST['selltime']==2 and $_POST['id']==1)
	    $price=$shop_drmy;
	  elseif($_POST['selltime']==2 and $_POST['id']==2)
	    $price=$shop_vipmy;
      else
	    die("6");
      if($user['money']<$price)
	    die("4");
	  $type="1";
      if($_POST['id']==1)
	    $type="2";
      $selltime=365;
	  if($_POST['selltime']==1)
	    $selltime=31;
      $rs=$type+2;
      if($isyn=$phpcolor->isvord($userv['id'],$rs))
	  {
		$etime=date('Y-m-d H:i:s',strtotime($isyn['etime'])+$selltime*86400);
		$phpcolor->table="vip";
        $phpcolor->field="etime='".$etime."'";
		$phpcolor->where="uid = '".$userv['id']."' and type='".$type."'";
        $phpcolor->upgrade();
	  }
	  else
	  {
		$time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
		$etime=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600+$selltime*86400);
		$phpcolor->table="vip";
        $phpcolor->field="*";
		$phpcolor->where="uid = '".$userv['id']."' and type='".$type."'";
        $phpcolor->delete();
		$phpcolor->field="uid, stime, etime, type";
        $phpcolor->where="'".$userv['id']."','".$time."','".$etime."','".$type."'";
        $phpcolor->write();
	  }
	  $phpcolor->table="pay";
      $tradeno=(strtotime(date('Y-m-d H:i:s'))+$core_time*3600).rand(1000,9999);
      $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
      $phpcolor->field="sid ,username, money, status, type, operatetime, ip";
      $phpcolor->where="'".$tradeno."','".$_COOKIE['core_user_name']."','".$price."','0','".($type+5)."','".$time."','系统操作'";
      $phpcolor->write();
	  $phpcolor->table="user";
      $phpcolor->field="money=money-".$price;
      $phpcolor->where="username = '".$_COOKIE['core_user_name']."'";
      $phpcolor->upgrade();
	  die("3");
	}
  }
  if($_POST['classid']==2)
  {
	$phpcolor->table="user";
    $phpcolor->field="integral";
    $phpcolor->where="username='".$_COOKIE['core_user_name']."'";
    $user=$phpcolor->exist(1);
    $phpcolor->table="shop_card";
    $phpcolor->field="*";
    $phpcolor->where="id=".$_POST['id'];
    if($card=$phpcolor->exist(1))
	{
      if($card['stock']<1)
	    die("2");
      if($card['type']==2 and !$phpcolor->isvord($userv['id'],1))
	    die("7");
      $price=$card['price'];
      $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='".$userv['id']."' and type='2' and etime>'".$rztime."'";
	  if($phpcolor->exist(2))
        $price=$card['dprice'];
      $phpcolor->where="uid='".$userv['id']."' and type='1' and etime>'".$rztime."'";
      if($phpcolor->exist(2))
        $price=$card['vprice'];
      if($user['integral']<$price)
	    die("1");
      $phpcolor->table="shop_cards";
      $phpcolor->field="uid ,cardid, price, status, prices, cardtime";
      $phpcolor->where="'".$userv['id']."','".$_POST['id']."','".$price."','0','0','".$rztime."'";
      $phpcolor->write();
	  $phpcolor->table="shop_card";
      $phpcolor->field="stock=stock-1";
      $phpcolor->where="id='".$_POST['id']."'";
      $phpcolor->upgrade();
	  $phpcolor->upintegral($_COOKIE['core_user_name'],$_POST['id'],$price,3,$rztime);
	  die("3");
	}
  }
}
?>