<?php
require_once(PHP168_PATH."inc/artic_function.php");
header('Content-Type: text/html; charset=big5'); 
if(!$lfjid)
{
	die("<A HREF='$webdb[www_url]/do/login.php' onclick=\"clickEdit.cancel('clickEdit_$TagId')\">請先登錄</A>");
}
if($act=="do"){
	if(!$lfjuid){
		$power=0;
	}elseif($web_admin){
		$power=2;
		$rs=$db->get_one("SELECT S.admin,S.fid,A.* FROM {$pre}article$erp A LEFT JOIN {$pre}sort S ON A.fid=S.fid WHERE A.aid='$id'");
	}else{
		$rs=$db->get_one("SELECT S.admin,S.fid,A.* FROM {$pre}article$erp A LEFT JOIN {$pre}sort S ON A.fid=S.fid WHERE A.aid='$id'");
		$detail=@explode(",",$rs[admin]);
		if($rs[uid]==$lfjuid){
			$power=1;
		}elseif($lfjid&&@in_array($lfjid,$detail)){
			$power=2;
		}else{
			$power=0;
		}
	}
	if($power==0){
		die("你無權操作");
	}
	if($step==2){
		if($action=="delete")
		{
			do_work($id,$action);

			//靜態頁處理
			make_article_html("list.php?fid=$rs[fid]",'del',$rs);
			refreshto("list.php?fid=$rs[fid]","刪除succeed",1);
		}
		elseif($power==2)
		{
			do_work($id,$action);

			//靜態頁處理
			if($action!="com"&&$action!="uncom")
			{
				make_article_html("list.php?fid=$rs[fid]",'',$rs);
			}
			refreshto("$FROMURL","操作succeed",1);
		}
	}
	else
	{
		$rs=$db->get_one("SELECT * FROM {$pre}article$erp WHERE aid='$id'");
		echo "<A HREF=\"$webdb[www_url]/member/post.php?job=postnew&fid=$fid\">新發表</A><br><A HREF=\"$webdb[www_url]/member/index.php?main=post.php?job=manage&aid=$id\">修改</A><br><A HREF=\"$webdb[www_url]/do/job.php?job=$job&act=$act&step=2&action=delete&id=$id\" onclick=\"return confirm('你確認要刪除嗎?');\">刪除</A><br>";
		if($rs[levels]&&$power==2){
			echo "(已推薦)<A HREF=\"$webdb[www_url]/do/job.php?job=$job&act=$act&step=2&action=uncom&levels=0&id=$id\">取消推薦</A><br>";
		}elseif($power==2){
			echo "(未推薦)<A HREF=\"$webdb[www_url]/do/job.php?job=$job&act=$act&step=2&action=com&levels=1&id=$id\">推薦</A><br>";
		}
		if($rs[yz]&&$power==2){
			echo "(已審核)<A HREF=\"$webdb[www_url]/do/job.php?job=$job&act=$act&step=2&action=unyz&yz=0&id=$id\">取消審核</A><br>";
		}elseif($power==2){
			echo "(未審核)<A HREF=\"$webdb[www_url]/do/job.php?job=$job&act=$act&step=2&action=yz&yz=1&id=$id\">審核</A><br>";
		}
		if($rs['list']>$timestamp&&$power==2){
			echo "(已置頂)<A HREF=\"\"><A HREF=\"$webdb[www_url]/do/job.php?job=$job&act=$act&step=2&action=untop&top=$timestamp&id=$id\">取消置頂</A></A><br>";
		}elseif($power==2){
			$times=3600*24*30;
			echo "(未置頂)<A HREF=\"$webdb[www_url]/do/job.php?job=$job&act=$act&step=2&action=top&toptime=$times&id=$id\">置頂</A><br>";
		}
	}
}
?>