<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[27]!=1)
{
  Header("Location: jump.php?id=25&jump=main.php");
  exit();
}
$phpcolor->table=$core_mysql_prefix."indexpic";
$phpcolor->where="id = '".$_GET['id']."'";
if(isset($_GET['action']) and $_GET['action'] == "del" and isset($_GET['id']))
{
  $phpcolor->delete();
  Header("Location: jump.php?id=24&jump=indexpic.php");
}
elseif(isset($_GET['action']) and $_GET['action'] == "adddo")
{
  if($_POST['theme']=="" || $_POST['link']=="" || $_POST['picture']=="")
    Header("Location: jump.php?id=2&jump=indexpic.php?action=add");
  else
  {
    $phpcolor->field="theme, link, picture";
    $phpcolor->where="'".$_POST['theme']."', '".$_POST['link']."', '".$_POST['picture']."'";
    $phpcolor->write();
    Header("Location: jump.php?id=24&jump=indexpic.php");
  }
}
elseif(isset($_GET['action']) and $_GET['action'] == "editdo" and isset($_GET['id']))
{
  if($_POST['theme']=="" || $_POST['link']=="" || $_POST['picture']=="")
    Header("Location: jump.php?id=2&jump=indexpic.php?action=edit=and=id=".$_GET['id']);
  else
  {
    $phpcolor->field="theme='".$_POST['theme']."',link='".$_POST['link']."',picture='".$_POST['picture']."'";
    $phpcolor->upgrade();
    Header("Location: jump.php?id=24&jump=indexpic.php");
  }
}
elseif(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 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");
}
?>