<?php
$vercode=''; //此处取值请自行修改
if(isset($_POST['vercode'])){
if ($_POST['vercode']!=$vercode){
 echo("[err]invalid vercode[/err]");
 exit();
}
}
error_reporting(E_ERROR | E_PARSE);
set_magic_quotes_runtime(0);
function_exists('date_default_timezone_set') && date_default_timezone_set('Etc/GMT+0');

define('R_P',getdirname(__FILE__));
define('D_P',R_P);
define('AREA_PATH',R_P.'html/channel/');
define('PORTAL_PATH',R_P.'html/portal/');
define('A_P', R_P.'apps/');
define('P_W','global');
defined('SCR') || define('SCR','other');

require_once(R_P.'require/common.php');

require_once(D_P.'data/sql_config.php');
if ($database == 'mysqli' && Pwloaddl('mysqli') === false) {
	$database = 'mysql';
}

	$m = 'cms';

	$db_mode = $m;
	define('M_P',R_P."mode/$m/");

	if (file_exists(M_P.'require/core.php')) {

		include_once(M_P.'require/core.php');
	}
	InitGP(array('action', 'type'));
	InitGP(array('page', 'cid', 'cms_subject', 'author', 'user'));
	if (!$cms_subject){
		echo('[err]cms_subject is null[/err]');
		exit;
	}
PwNewDB();

		$count = searchCount($cid, $cms_subject);
		if ($count>0){
			echo('[yes]');
		
		}else{
			echo('[no]');
		}
/**
 * 初始化数据库连接
 */
function PwNewDB() {
	if (!is_object($GLOBALS['db'])) {
		global $db, $database, $dbhost, $dbuser, $dbpw, $dbname, $PW, $charset, $pconnect;
		require_once Pcv(R_P . "require/db_$database.php");
		$db = new DB($dbhost, $dbuser, $dbpw, $dbname, $PW, $charset, $pconnect);
	}
}
		
function searchCount($cid, $title) {
	global $db;
	$_where = '';
	if ($cid) $_where .= ' AND column_id IN (' . $cid . ")";
	//if ($title) $_where .= ' AND subject LIKE ' . pwEscape('%' . $title . '%');
	if ($title) $_where .= ' AND subject = ' . pwEscape($title);
	$_where .= ' AND ifcheck <>2 ';
	$_sql = "SELECT COUNT(*) FROM pw_cms_article WHERE article_id " . $_where;
	return $db->get_value($_sql);
}
		
function managerRight($adminjob) {
	return If_manager && in_array($adminjob,array('rightset','manager','ystats','diyoption','optimize','modepage','sphinx','app','ajaxhandler'));
}
function adminRight($adminjob,$admintype){
	$temp = $admintype ? $admintype : $adminjob;
	return adminRightCheck($temp);
}
function getdirname($path=null){
	if (!empty($path)) {
		if (strpos($path,'\\')!==false) {
			return substr($path,0,strrpos($path,'\\')).'/';
		} elseif (strpos($path,'/')!==false) {
			return substr($path,0,strrpos($path,'/')).'/';
		}
	}
	return './';
}
?>