<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[36]!=1)
  jump("jump.php?id=25&jump=main.php");
$phpcolor->table="vip";
$phpcolor->where="id = '".$_GET['id']."'";
if(isset($_GET['action']) and $_GET['action'] == "del" and isset($_GET['id']))
{
  $phpcolor->field="*";
  $phpcolor->delete();
  jump("jump.php?id=24&jump=vip.php");
}
if(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "edit")
{
  $phpcolor->field="*";
  $vip = $phpcolor->exist(1);
  $phpcolor->table="user";
  $phpcolor->field="username";
  $phpcolor->where="id = '".$vip['uid']."'";
  $rs=$phpcolor->exist(1);
  $vip['username']=$rs['username'];
  $tpl -> assign("vip", $vip);
  $tpl -> display("vip_edit.htm");
}
elseif(isset($_GET['action']) and isset($_GET['id']) and $_GET['action'] == "editdo")
{
  if($_POST['etime']=="" or strlen($_POST['etime'])>200)
    jump("jump.php?id=8&jump=vip.php?action=edit=and=id=".$_GET['id']);
  $phpcolor->field="etime='".$_POST['etime']."'";
  $phpcolor->upgrade();
  jump("jump.php?id=24&jump=vip.php");
}
elseif(isset($_GET['action']) and $_GET['action'] == "add")
  $tpl -> display("vip_add.htm");
elseif(isset($_GET['action']) and $_GET['action'] == "adddo")
{
 if($_POST['etime']=="" or strlen($_POST['etime'])>200)
    jump("jump.php?id=8&jump=vip.php");
  $phpcolor->table="user";
  $phpcolor->field="id";
  $phpcolor->where="username = '".$_POST['username']."'";
  if(!$rs=$phpcolor->exist(1))
    jump("jump.php?id=1&jump=vip.php");
  $phpcolor->table="vip";
  $phpcolor->field="*";
  $phpcolor->where="uid = '".$rs['id']."' and type = '".$_POST['type']."'";
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  if($phpcolor->exist(2))
    jump("jump.php?id=4&jump=vip.php");
  $phpcolor->field="uid, stime, etime, type";
  $phpcolor->where="'".$rs['id']."','".$time."','".$_POST['etime']."','".$_POST['type']."'";
  $phpcolor->write();
  jump("vip.php");
}
else
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->field="*";
  if(isset($_GET['theme']))
  {
	$phpcolor->table="user";
	$phpcolor->field="id";
    $phpcolor->where="username = '".$_GET['theme']."'";
    $rs=$phpcolor->exist(1);
	$phpcolor->table="attest";
    $phpcolor->where="uid = '".$rs['id']."'";
    $count = $phpcolor->exist(2);
    $phpcolor->where="uid = '".$rs['id']." order by stime desc' limit ".($_GET['page']*20).",20";
	$phpcolor->field="*";
    $page=pages($count,20,$_GET['page'],'attest','&theme=',$_GET['theme'],'0');
  }
  else
  {
    if(isset($_GET['type']) and $_GET['type']=="vip")
    {
	  $phpcolor->where="type = '1'";
      $count = $phpcolor->exist(2);
	  $phpcolor->where="type = '1' order by stime desc limit ".($_GET['page']*20).",20";
	  $page=pages($count,20,$_GET['page'],'attest','&type=','yes','0');
	}
    elseif(isset($_GET['type']) and $_GET['type']=="daren")
    {
      $phpcolor->where="type = '2'";
      $count = $phpcolor->exist(2);
      $phpcolor->where="type = '2' order by stime desc limit ".($_GET['page']*20).",20";
	  $page=pages($count,20,$_GET['page'],'attest','&type=','dsh','0');
	}
	else
	{
	  $phpcolor->where="1=1";
      $count = $phpcolor->exist(2);
      $phpcolor->where="1=1 order by stime desc limit ".($_GET['page']*20).",20";
	  $page=pages($count,20,$_GET['page'],'attest','','','0');
	}
  }
  $vip=$phpcolor->assignment();
  $phpcolor->table="user";
  for($count=0;$count<count($vip);$count++)
  {
    $phpcolor->field="username";
    $phpcolor->where="id = '".$vip[$count]['uid']."'";
    $rs=$phpcolor->exist(1);
    $vip[$count]['username']=$rs['username'];
  }
  $tpl -> assign("vip", $vip);
  $tpl -> assign("page", $page);
  $tpl -> display("vip.htm");
}
?>