<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[37]!=1)
  jump("jump.php?id=25&jump=main.php");
$phpcolor->table="style";
$phpcolor->where="id = '".$_GET['id']."'";
if(isset($_GET['action']) and $_GET['action'] == "del" and isset($_GET['id']))
{
  $phpcolor->delete();
  jump("jump.php?id=24&jump=style.php");
}
if(isset($_GET['action']) and $_GET['action'] == "adddo")
{
  if($_POST['name']=="" || $_POST['link']=="" || $_POST['type']=="")
    jump("jump.php?id=2&jump=style.php?action=add");
  $phpcolor->field="name, link, phpfile, type";
  $phpcolor->where="'".$_POST['name']."', '".$_POST['link']."', '".$_POST['phpfile']."', '".$_POST['type']."'";
  $phpcolor->write();
  jump("jump.php?id=24&jump=style.php");
}
if(isset($_GET['action']) and $_GET['action'] == "editdo" and isset($_GET['id']))
{
  if($_POST['name']=="" || $_POST['link']=="" || $_POST['type']=="")
    jump("jump.php?id=2&jump=style.php?action=edit=and=id=".$_GET['id']);
  $phpcolor->field="name='".$_POST['name']."',link='".$_POST['link']."',phpfile='".$_POST['phpfile']."',type='".$_POST['type']."'";
  $phpcolor->upgrade();
  jump("jump.php?id=24&jump=style.php");
}
if(isset($_GET['action']) and $_GET['action'] == "add")
  $tpl -> display("style_add.htm");
elseif(isset($_GET['action']) and $_GET['action'] == "edit" and isset($_GET['id']))
{
  $phpcolor->field="*";
  $style=$phpcolor->exist(1);
  $tpl -> assign("style", $style);
  $tpl -> display("style_edit.htm");
}
else
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->field="*";
  $phpcolor->where="1=1";
  $count = $phpcolor->exist(2);
  $phpcolor->where="1=1 order by id limit ".($_GET['page']*20).",20";
  $style=$phpcolor->assignment();
  for($count=0;$count<count($style);$count++)
  {
    if($style[$count]['type']=="1")
	  $style[$count]['type']="全站模版";
	elseif($style[$count]['type']=="2")
	  $style[$count]['type']="单吧模版";
	else
	  $style[$count]['type']="专属模版";
  }
  $page=pages($count,20,$_GET['page'],'style','','','0');
  $tpl -> assign("style", $style);
  $tpl -> assign("page", $page);
  $tpl -> display("style.htm");
}
?>