<?php
include(dirname(__FILE__)."/require.php");
if($ppurview[27]!=1)
  jump("jump.php?id=25&jump=main.php");
$phpcolor->table="index";
$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=indexusertj.php");
}
if(isset($_GET['action']) and $_GET['action'] == "editdo" and isset($_GET['id']))
{
  if($_POST['yid']=="")
    jump("jump.php?id=2&jump=indexusertj.php?action=edit=and=id=".$_GET['id']);
  $phpcolor->table="topic";
  $phpcolor->field="theme";
  $phpcolor->where="id = '".$_POST['yid']."'";
  $rss=$phpcolor->exist(1);
  if($_POST['theme']=="")
    $_POST['theme']=$rss['theme'];
  $phpcolor->table="index";
  $phpcolor->where="id = '".$_GET['id']."'";
  $phpcolor->field="type='3',yid='".$_POST['yid']."',theme='".$_POST['theme']."'";
  $phpcolor->upgrade();
  jump("jump.php?id=24&jump=indexusertj.php");
}
if(isset($_GET['action']) and $_GET['action'] == "ok" and isset($_GET['id']))
{
  $phpcolor->field="belong='2'";
  $phpcolor->upgrade();
  $phpcolor->field="*";
  $indexusertj=$phpcolor->exist(1);
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  if($email_mopen==1)
  {
    $email_tzhfc=str_replace("{theme}",$indexusertj['theme'],$email_tzhfc);
	$email_tzhfc=str_replace("{tid}",$indexusertj['yid'],$email_tzhfc);
	$email_tzhfc=str_replace("{wz}","首页吧友推荐",$email_tzhfc);
	$phpcolor->message($email_tzhfc,$email_addresser,$indexusertj['barname'],$time,2);
  }
  $phpcolor->upintegral($indexusertj['barname'],$indexusertj['yid'],$int_utjzy,6,$time);
  jump("jump.php?id=24&jump=indexusertj.php");
}
if(isset($_GET['action']) and $_GET['action'] == "headlines" and isset($_GET['id']))
{
  $phpcolor->field="*";
  $indexusertj=$phpcolor->exist(1);
  $phpcolor->delete();
  $phpcolor->table="topic";
  $phpcolor->field="recommend='2'";
  $phpcolor->where="id = '".$indexusertj['yid']."'";
  $phpcolor->upgrade();
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  if($email_mopen==1)
  {
    $email_tzhfc=str_replace("{theme}",$indexusertj['theme'],$email_tzhfc);
	$email_tzhfc=str_replace("{tid}",$indexusertj['yid'],$email_tzhfc);
	$email_tzhfc=str_replace("{wz}","首页头条推荐",$email_tzhfc);
	$phpcolor->message($email_tzhfc,$email_addresser,$indexusertj['barname'],$time,2);
  }
  $phpcolor->upintegral($indexusertj['barname'],$indexusertj['yid'],$int_utjzy,6,$time);
  jump("jump.php?id=24&jump=indexusertj.php");
}
if(isset($_GET['action']) and $_GET['action'] == "post" and isset($_GET['id']))
{
  $phpcolor->field="*";
  $indexusertj=$phpcolor->exist(1);
  $phpcolor->delete();
  $phpcolor->table="topic";
  $phpcolor->field="recommend='1'";
  $phpcolor->where="id = '".$indexusertj['yid']."'";
  $phpcolor->upgrade();
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  if($email_mopen==1)
  {
    $email_tzhfc=str_replace("{theme}",$indexusertj['theme'],$email_tzhfc);
	$email_tzhfc=str_replace("{tid}",$indexusertj['yid'],$email_tzhfc);
	$email_tzhfc=str_replace("{wz}","首页热点关注",$email_tzhfc);
	$phpcolor->message($email_tzhfc,$email_addresser,$indexusertj['barname'],$time,2);
  }
  $phpcolor->upintegral($indexusertj['barname'],$indexusertj['yid'],$int_utjzy,6,$time);
  jump("jump.php?id=24&jump=indexusertj.php");
}
if(isset($_GET['action']) and $_GET['action'] == "classpost" and isset($_GET['id']))
{
  $phpcolor->field="*";
  $indexusertj=$phpcolor->exist(1);
  $phpcolor->table="topic";
  $phpcolor->field="belong";
  $phpcolor->where="id = '".$indexusertj['yid']."'";
  $barid=$phpcolor->exist(1);
  $phpcolor->table="bar";
  $phpcolor->field="barname";
  $phpcolor->where="id = '".$barid['belong']."'";
  $barname=$phpcolor->exist(1);
  $phpcolor->table="index";
  $phpcolor->field="type='1',belong='".$_POST['belong']."',barname='".$barname['barname']."'";
  $phpcolor->where="id = '".$_GET['id']."'";
  $phpcolor->upgrade();
  $phpcolor->where="type = '1' and belong='".$_POST['belong']."'";
  if($phpcolor->exist(2)>5)
  {
    $phpcolor->where="type = '1' and belong='".$_POST['belong']."' order by id limit 1";
    $phpcolor->delete();
  }
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  if($email_mopen==1)
  {
    $phpcolor->table="class";
	$phpcolor->field="classname";
    $phpcolor->where="id = '".$_POST['belong']."'";
    $class=$phpcolor->exist(1);
    $email_tzhfc=str_replace("{theme}",$indexusertj['theme'],$email_tzhfc);
	$email_tzhfc=str_replace("{tid}",$indexusertj['yid'],$email_tzhfc);
	$email_tzhfc=str_replace("{wz}","首页".$class['classname']."分类推荐",$email_tzhfc);
	$phpcolor->message($email_tzhfc,$email_addresser,$indexusertj['barname'],$time,2);
  }
  $phpcolor->upintegral($indexusertj['barname'],$indexusertj['yid'],$int_utjzy,6,$time);
  jump("jump.php?id=24&jump=indexusertj.php");
}
if(isset($_GET['action']) and $_GET['action'] == "edit" and isset($_GET['id']))
{
  $phpcolor->field="*";
  $indexusertj=$phpcolor->exist(1);
  if($indexusertj['belong']=="1")
    $indexusertj['belong']="<span style='color:#0000FF'>未审核</span>";
  else
    $indexusertj['belong']="<span style='color:#00FF00'>已审核</span>";
  $phpcolor->table="class";
  $phpcolor->field="id,classname";
  $phpcolor->where="base = 0 and indexs = 1 order by belong";
  $sort=$phpcolor->assignment();
  $tpl -> assign("sort", $sort);
  $tpl -> assign("indexusertj", $indexusertj);
  $tpl -> display("indexusertj_edit.htm");
}
else
{
  if(!isset($_GET['page']))
    $_GET['page']=0;
  if(isset($_GET['so']))
  {
    $phpcolor->field="*";
    $phpcolor->where="type=3 and theme like '%".$_GET['so']."%'";
    $count = $phpcolor->exist(2);
    $phpcolor->where="type=3 and theme like '%".$_GET['so']."%' order by id desc limit ".($_GET['page']*20).",20";
    $indexusertj=$phpcolor->assignment();
	$page=pages($count,20,$_GET['page'],'indexusertj','&so=',$_GET['so'],'0');
  }
  else
  {
    $phpcolor->field="*";
    $phpcolor->where="type=3";
    $count = $phpcolor->exist(2);
    $phpcolor->where="type=3 order by id desc limit ".($_GET['page']*20).",20";
    $indexusertj=$phpcolor->assignment();
	$page=pages($count,20,$_GET['page'],'indexusertj','','','0');
  }
  for($count=0;$count<count($indexusertj);$count++)
  {
    if($indexusertj[$count]['belong']=="1")
	  $indexusertj[$count]['belong']="<span style='color:#0000FF'>未审核</span>";
	else
	  $indexusertj[$count]['belong']="<span style='color:#00FF00'>已审核</span>";
  }
  $tpl -> assign("indexusertj", $indexusertj);
  $tpl -> assign("page", $page);
  $tpl -> display("indexusertj.htm");
}
?>