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

主要参数
keyword		主题标题

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

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

*/



error_reporting(E_ERROR | E_PARSE);

set_magic_quotes_runtime(0);
$t_array = explode(' ',microtime());
$P_S_T	 = $t_array[0] + $t_array[1];

define('D_P','../../');

define('R_P',D_P);

$htmdir = 'htm_data';

function_exists('date_default_timezone_set') && date_default_timezone_set('Etc/GMT+0');

unset($_ENV,$HTTP_ENV_VARS,$_REQUEST,$HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_POST_FILES,$HTTP_COOKIE_VARS);
if(!get_magic_quotes_gpc()){
	Add_S($_POST);
	Add_S($_GET);
	Add_S($_COOKIE);
}
Add_S($_FILES);
if($_SERVER['HTTP_X_FORWARDED_FOR']){
	$onlineip = $_SERVER['HTTP_X_FORWARDED_FOR'];
	$c_agentip=1;
}elseif($_SERVER['HTTP_CLIENT_IP']){
	$onlineip = $_SERVER['HTTP_CLIENT_IP'];
	$c_agentip=1;
}else{
	$onlineip = $_SERVER['REMOTE_ADDR'];
	$c_agentip=0;
}
$onlineip = preg_match("/^[\d]([\d\.]){5,13}[\d]$/", $onlineip) ? $onlineip : 'unknown';
$timestamp= time();
require_once(R_P.'require/defend.php');

$db_cvtime != 0 && $timestamp += $db_cvtime*60;

if($db_debug){
	error_reporting(E_ALL ^ E_NOTICE);
}
$wind_version = "5.3";
$db_olsize	  = 96;

!$_SERVER['PHP_SELF'] && $_SERVER['PHP_SELF']=$_SERVER['SCRIPT_NAME'];
$REQUEST_URI  = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
if(strpos($_SERVER['PHP_SELF'],$db_dir)!==false){
	$tmp=substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],$db_dir));
}else{
	$tmp=$_SERVER['PHP_SELF'];
}
$db_bbsurl="http://$_SERVER[HTTP_HOST]".substr($tmp,0,strrpos($tmp,'/'));

$fid	  = (int)$fid;
$tid	  = (int)$tid;
$js_path  = '';
$db_obstart == 1 && function_exists('ob_gzhandler') ? ob_start('ob_gzhandler') : ob_start();

require_once(D_P.'data/sql_config.php');
$imgpath	= $db_http		!= 'N' ? $db_http	   : $picpath;
$attachpath = $db_attachurl != 'N' ? $db_attachurl : $attachname;
$imgdir		= R_P.$picpath;
$attachdir	= R_P.$attachname;
$pw_posts   = 'pw_posts';
$pw_tmsgs   = 'pw_tmsgs';

if(D_P != R_P && $db_http != 'N'){
	$R_url=substr($db_http,-1)=='/' ?  substr($db_http,0,-1) : $db_http;
	$R_url=substr($R_url,0,strrpos($R_url,'/'));
}else{
	$R_url=$db_bbsurl;
}



$H_url =& $db_wwwurl;
$B_url =& $db_bbsurl;




//require_once Pcv(R_P.'require/db_'.$database.'.php');
require_once (R_P.'require/db_'.$database.'.php');

$db = new DB($dbhost, $dbuser, $dbpw, $dbname, $pconnect);

unset($dbhost,$dbuser,$dbpw,$dbname,$pconnect,$manager_pwd);

function Add_S(&$array){
	foreach($array as $key=>$value){
		if(!is_array($value)){
			$array[$key]=addslashes($value);
		}else{
			Add_S($array[$key]);
		}
	}
}
function Char_cv($msg){
	$msg = str_replace('&amp;','&',$msg);
	$msg = str_replace('&nbsp;',' ',$msg);
	$msg = str_replace('"','&quot;',$msg);
	$msg = str_replace("'",'&#39;',$msg);
	$msg = str_replace("<","&lt;",$msg);
	$msg = str_replace(">","&gt;",$msg);
	$msg = str_replace("\t","&nbsp; &nbsp; ",$msg);
	$msg = str_replace("\r","",$msg);
	$msg = str_replace("  ","&nbsp; ",$msg);
	return $msg;
}

function readover($filename,$method="rb"){
	strpos($filename,'..')!==false && exit('Forbidden');
	if($handle=@fopen($filename,$method)){
		flock($handle,LOCK_SH);
		$filedata=@fread($handle,filesize($filename));
		fclose($handle);
	}
	return $filedata;
}


$keyword = Char_cv($keyword);

$query =$db->query("SELECT * FROM pw_threads WHERE subject='$keyword' LIMIT 1");
if ($db->num_rows($query)>0){
echo('1');
}
else
{
echo('0');
}


exit;

?>