<?php
/*
EditorTools文章采集发布助手 v0.1版
----------------------------------
文件名
ETCHK.php
php168 v4.0文章检查文件，请复制在admin目录使用，为保密，请自行修改文件名

主要参数
keyword		标题

如果需要进行用户名、密码校验，请自行填加相关代码。

ET发布配置-文章检查网址处，可以如下填写
http://您的网址/admin/ETchk.php?keyword=<%title%>

*/



require("../global.php");

//$keyword=str_replace("%","\%",$keyword);
$keyword=trim($keyword);
$rows=20;
$leng=80;

//if($keyword&&!$type)
//{
	$type='title';
//}

if($type&&!$keyword)
{
	echo("[err]关键字不能为空[/err]");
	exit;
}

elseif($type&&$keyword)
{
//	if($_COOKIE[searchTime])
//	{
//		//showerr("5秒钟内,请不要重复提交查询");
//	}
	//setcookie("searchTime",$timestamp+5);

	$SQL='';
	$searchTable='article';
	if($searchTable=='article')
	{
	$SQL="BINARY title='$keyword'";
	
/*		if($type=='title')
		{
			$SQL="BINARY title LIKE '%$keyword%'";
		}
		elseif($type=='id')
		{
			$SQL="aid = '$keyword'";
		}
		elseif($type=='content')
		{
			if($groupdb['allowsearch']!=2&&!$web_admin)
			{
				showerr("你所在用户组,不能搜索文章内容");
			}
			//未完善好
			$SQL="BINARY title LIKE '%$keyword%'";
		}
		elseif($type=='username')
		{
			$SQL="BINARY username LIKE '%$keyword%'";
		}
		else
		{
			showerr("请选择要搜索的类型");
		}
*/
//		if($page<1)
//		{
			$page=1;
//		}
		$min=($page-1)*$rows;

		$which='aid,title,smalltitle,fid,fname,uid,username,hits,comments,posttime,titlecolor,fonttype,target';

		$listdb=list_article("WHERE $SQL ORDER BY aid DESC LIMIT $min,$rows",$which,$leng);
		
		if(!$listdb)
		{
			echo("0");
		}
		else{
		echo("1");
		}
		exit;
		//$showpage=getpage("{$pre}article","WHERE $SQL","search.php?searchTable=$searchTable&type=$type&keyword=".urlencode($keyword)."",$rows);
	}
	elseif($searchTable=='log'||$searchTable=='down'||$searchTable=='photo'||$searchTable=='mv'||$searchTable=='shop'||$searchTable=='music'||$searchTable=='flash')
	{
		include(PHP168_PATH."inc/{$searchTable}_function.php");

		switch($searchTable){
			case "log":
				$sTabel="log_article";
				break;
			case "down":
				$sTabel="down_software";
				break;
			case "photo":
				$sTabel="photo_pic";
				break;
			case "mv":
				$sTabel="mv_video";
				break;
			case "shop":
				$sTabel="shop_product";
				break;
			case "music":
				$sTabel="music_song";
				break;
			case "flash":
				$sTabel="flash_swf";
				break;
		}

		$PATH=$webdb["{$searchTable}_url"];

		if($type=='title')
		{
			$SQL="BINARY title LIKE '%$keyword%'";
		}
		elseif($type=='id')
		{
			$SQL="id = '$keyword'";
		}
		elseif($type=='content')
		{
			$SQL="BINARY content LIKE '%$keyword%'";
		}
		elseif($type=='username')
		{
			$SQL="BINARY username LIKE '%$keyword%'";
		}
		else
		{
			showerr("请选择要搜索的类型");
		}

		if($page<1){
			$page=1;
		}

		$min=($page-1)*$rows;

		$which='id,title,fid,fname,uid,username,hits,comments,posttime';

		$listdb=list_content("WHERE $SQL ORDER BY id DESC LIMIT $min,$rows",$which,$leng);

		if(!$listdb)
		{
			showerr("很抱歉,没有找到你要查询的内容");
		}

		$showpage=getpage("{$pre}$sTabel","WHERE $SQL","search.php?searchTable=$searchTable&type=$type&keyword=".urlencode($keyword)."",$rows);
	}
}

//require(PHP168_PATH."inc/head.php");
//require(html("search"));
//require(PHP168_PATH."inc/foot.php");

?>