<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[27]!=1)
  jump("jump.php?id=25&jump=main.php");
$phpcolor->table="indexpic";
$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=indexpic.php");
}
if(isset($_GET['action']) and $_GET['action'] == "adddo")
{
  if($_POST['theme']=="" || $_POST['link']=="" || $_POST['picture']=="")
    jump("jump.php?id=2&jump=indexpic.php?action=add");
  $phpcolor->field="theme, link, picture";
  $phpcolor->where="'".$_POST['theme']."', '".$_POST['link']."', '".$_POST['picture']."'";
  $phpcolor->write();
  jump("jump.php?id=24&jump=indexpic.php");
}
if(isset($_GET['action']) and $_GET['action'] == "editdo" and isset($_GET['id']))
{
  if($_POST['theme']=="" || $_POST['link']=="" || $_POST['picture']=="")
    jump("jump.php?id=2&jump=indexpic.php?action=edit=and=id=".$_GET['id']);
  $phpcolor->field="theme='".$_POST['theme']."',link='".$_POST['link']."',picture='".$_POST['picture']."'";
  $phpcolor->upgrade();
  jump("jump.php?id=24&jump=indexpic.php");
}
if(isset($_GET['action']) and $_GET['action'] == "add")
  $tpl -> display("indexpic_add.htm");
elseif(isset($_GET['action']) and $_GET['action'] == "edit" and isset($_GET['id']))
{
  $phpcolor->field="*";
  $indexpic=$phpcolor->exist(1);
  $tpl -> assign("indexpic", $indexpic);
  $tpl -> display("indexpic_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 desc limit ".($_GET['page']*20).",20";
  $indexpic=$phpcolor->assignment();
  $page=pages($count,20,$_GET['page'],'link','','','0');
  $tpl -> assign("indexpic", $indexpic);
  $tpl -> assign("page", $page);
  $tpl -> display("indexpic.htm");
}
?>