<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[31]!=1)
  jump("jump.php?id=25&jump=main.php");
$phpcolor->table="flash";
$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=flash.php");
}
if(isset($_GET['action']) and $_GET['action'] == "adddo")
{
  if(empty($_POST['name']))
    jump("jump.php?id=2&jump=flash.php");
  $_POST['introduction']=autolink(nl2br($_POST['introduction']));
  $phpcolor->field="flashname,belong , flashurl, flashimg, introduction";
  $phpcolor->where="'".$_POST['name']."', '".$_POST['belong']."', '".$_POST['url']."', '".$_POST['img']."', '".$_POST['introduction']."'";
  $phpcolor->write();
  jump("jump.php?id=24&jump=flash.php");
}
if(isset($_GET['action']) and $_GET['action'] == "editdo" and isset($_GET['id']))
{
  if(empty($_POST['name']))
    jump("jump.php?id=2&jump=flash.php");
  $_POST['introduction']=autolink(nl2br($_POST['introduction']));
  $phpcolor->field="flashname='".$_POST['name']."',belong='".$_POST['belong']."',flashurl='".$_POST['url']."',flashimg='".$_POST['img']."',introduction='".$_POST['introduction']."'";
  $phpcolor->upgrade();
  jump("jump.php?id=24&jump=flash.php");
}
if(isset($_GET['action']) and $_GET['action'] == "add")
  $tpl -> display("flash_add.htm");
elseif(isset($_GET['action']) and $_GET['action'] == "edit" and isset($_GET['id']))
{
  $phpcolor->field="*";
  $flash=$phpcolor->exist(1);
  if($flash['belong']==1)
    $flash['classname']="FLASH游戏";
  elseif($flash['belong']==2)
    $flash['classname']="FLASH音乐";
  else
    $flash['classname']="FLASH动画";
  $tpl -> assign("flash", $flash);
  $tpl -> display("flash_edit.htm");
}
else
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  $phpcolor->field="id,flashname,belong,flashurl";
  $phpcolor->where="1=1 ";
  $count = $phpcolor->exist(2);
  $phpcolor->where="1=1 order by id desc limit ".($_GET['page']*20).",20";
  $flash=$phpcolor->assignment();
  $page=pages($count,'20',$_GET['page'],'flash','','','0');
  for($count=0;$count<count($flash);$count++)
  {
    if($flash[$count]['belong']==1)
      $flash[$count]['classname']="FLASH游戏";
	elseif($flash[$count]['belong']==2)
      $flash[$count]['classname']="FLASH音乐";
	else
      $flash[$count]['classname']="FLASH动画";
  }
  $tpl -> assign("flash", $flash);
  $tpl -> assign("page", $page);
  $tpl -> display("flash.htm");
}
?>