<commit_before><?php
/**
 * 事件相关函数
 * @package Z-BlogPHP
 * @subpackage System\Event 操作事件
 * @copyright (C) RainbowSoft Studio
 */


################################################################################################################
/**
 * 验证登录
 * @return bool
 */
function VerifyLogin() {
	global $zbp;

	if (isset($zbp->membersbyname[GetVars('username', 'POST')])) {
		if ($zbp->Verify_MD5(GetVars('username', 'POST'), GetVars('password', 'POST'))) {
			$un = GetVars('username', 'POST');
			$ps = md5($zbp->user->Password . $zbp->guid);
			$sd = (int)GetVars('savedate');
			if ( $sd == 0) {
				setcookie("username", $un, 0, $zbp->cookiespath);
				setcookie("password", $ps, 0, $zbp->cookiespath);
				setcookie("dishtml5", GetVars('dishtml5', 'POST'), 0, $zbp->cookiespath);
			} else {
				setcookie("username", $un, time() + 3600 * 24 * $sd, $zbp->cookiespath);
				setcookie("password", $ps, time() + 3600 * 24 * $sd, $zbp->cookiespath);
				setcookie("dishtml5", GetVars('dishtml5', 'POST'), time() + 3600 * 24 * $sd, $zbp->cookiespath);
			}

			return true;
		} else {
			$zbp->ShowError(8, __FILE__, __LINE__);
		}
	} else {
		$zbp->ShowError(8, __FILE__, __LINE__);
	}
}

/**
 * 注销登录
 */
function Logout() {
	global $zbp;

	setcookie('username', '', time() - 3600, $zbp->cookiespath);
	setcookie('password', '', time() - 3600, $zbp->cookiespath);
	setcookie("dishtml5", '', time() - 3600, $zbp->cookiespath);

}

################################################################################################################
/**
 * 获取文章
 * @param mixed $idorname 文章id 或 名称、别名
 * @param array $option|null
 * @return Post
 */
function GetPost($idorname, $option = null) {
	global $zbp;

	if (!is_array($option)) {
		$option = array();
	}

	if (!isset($option['only_article']))
		$option['only_article'] = false;
	if (!isset($option['only_page']))
		$option['only_page'] = false;

	if(is_string($idorname)){
		$w[] = array('array', array(array('log_Alias', $idorname), array('log_Title', $idorname)));
		if($option['only_article']==true){
			$w[]=array('=','log_Type','0');
		}
		elseif($option['only_page']==true){
			$w[]=array('=','log_Type','1');
		}
		$articles = $zbp->GetPostList('*', $w, null, 1, null);
		if (count($articles) == 0) {
			return new Post;
		}
		return $articles[0];
	}
	if(is_integer($idorname)){
		return $zbp->GetPostByID($idorname);
	}
}

/**
 * 获取文章列表
 * @param int $count 数量
 * @param null $cate 分类ID
 * @param null $auth 用户ID
 * @param null $date 日期
 * @param null $tags 标签
 * @param null $search 搜索关键词
 * @param null $option
 * @return array|mixed
 */
function GetList($count = 10, $cate = null, $auth = null, $date = null, $tags = null, $search = null, $option = null) {
	global $zbp;

	if (!is_array($option)) {
		$option = array();
	}

	if (!isset($option['only_ontop']))
		$option['only_ontop'] = false;
	if (!isset($option['only_not_ontop']))
		$option['only_not_ontop'] = false;
	if (!isset($option['has_subcate']))
		$option['has_subcate'] = false;
	if (!isset($option['is_related']))
		$option['is_related'] = false;

	if ($option['is_related']) {
		$at = $zbp->GetPostByID($option['is_related']);
		$tags = $at->Tags;
		if (!$tags)
			return array();
		$count = $count + 1;
	}

	if ($option['only_ontop'] == true) {
		$w[] = array('=', 'log_IsTop', 0);
	} elseif ($option['only_not_ontop'] == true) {
		$w[] = array('=', 'log_IsTop', 1);
	}

	$w = array();
	$w[] = array('=', 'log_Status', 0);

	$articles = array();
<commit_msg>GetList小改；<commit_after><?php
/**
 * 事件相关函数
 * @package Z-BlogPHP
 * @subpackage System\Event 操作事件
 * @copyright (C) RainbowSoft Studio
 */


################################################################################################################
/**
 * 验证登录
 * @return bool
 */
function VerifyLogin() {
	global $zbp;

	if (isset($zbp->membersbyname[GetVars('username', 'POST')])) {
		if ($zbp->Verify_MD5(GetVars('username', 'POST'), GetVars('password', 'POST'))) {
			$un = GetVars('username', 'POST');
			$ps = md5($zbp->user->Password . $zbp->guid);
			$sd = (int)GetVars('savedate');
			if ( $sd == 0) {
				setcookie("username", $un, 0, $zbp->cookiespath);
				setcookie("password", $ps, 0, $zbp->cookiespath);
				setcookie("dishtml5", GetVars('dishtml5', 'POST'), 0, $zbp->cookiespath);
			} else {
				setcookie("username", $un, time() + 3600 * 24 * $sd, $zbp->cookiespath);
				setcookie("password", $ps, time() + 3600 * 24 * $sd, $zbp->cookiespath);
				setcookie("dishtml5", GetVars('dishtml5', 'POST'), time() + 3600 * 24 * $sd, $zbp->cookiespath);
			}

			return true;
		} else {
			$zbp->ShowError(8, __FILE__, __LINE__);
		}
	} else {
		$zbp->ShowError(8, __FILE__, __LINE__);
	}
}

/**
 * 注销登录
 */
function Logout() {
	global $zbp;

	setcookie('username', '', time() - 3600, $zbp->cookiespath);
	setcookie('password', '', time() - 3600, $zbp->cookiespath);
	setcookie("dishtml5", '', time() - 3600, $zbp->cookiespath);

}

################################################################################################################
/**
 * 获取文章
 * @param mixed $idorname 文章id 或 名称、别名
 * @param array $option|null
 * @return Post
 */
function GetPost($idorname, $option = null) {
	global $zbp;

	if (!is_array($option)) {
		$option = array();
	}

	if (!isset($option['only_article']))
		$option['only_article'] = false;
	if (!isset($option['only_page']))
		$option['only_page'] = false;

	if(is_string($idorname)){
		$w[] = array('array', array(array('log_Alias', $idorname), array('log_Title', $idorname)));
		if($option['only_article']==true){
			$w[]=array('=','log_Type','0');
		}
		elseif($option['only_page']==true){
			$w[]=array('=','log_Type','1');
		}
		$articles = $zbp->GetPostList('*', $w, null, 1, null);
		if (count($articles) == 0) {
			return new Post;
		}
		return $articles[0];
	}
	if(is_integer($idorname)){
		return $zbp->GetPostByID($idorname);
	}
}

/**
 * 获取文章列表
 * @param int $count 数量
 * @param null $cate 分类ID
 * @param null $auth 用户ID
 * @param null $date 日期
 * @param null $tags 标签
 * @param null $search 搜索关键词
 * @param null $option
 * @return array|mixed
 */
function GetList($count = 10, $cate = null, $auth = null, $date = null, $tags = null, $search = null, $option = null) {
	global $zbp;

	if (!is_array($option)) {
		$option = array();
	}

	if (!isset($option['only_ontop']))
		$option['only_ontop'] = false;
	if (!isset($option['only_not_ontop']))
		$option['only_not_ontop'] = false;
	if (!isset($option['has_subcate']))
		$option['has_subcate'] = false;
	if (!isset($option['is_related']))
		$option['is_related'] = false;

	if ($option['is_related']) {
		$at = $zbp->GetPostByID($option['is_related']);
		$tags = $at->Tags;
		if (!$tags)
			return array();
		$count = $count + 1;
	}

	$w = array();

	if ($option['only_ontop'] == true) {
		$w[] = array('=', 'log_IsTop', 0);
	} elseif ($option['only_not_ontop'] == true) {
		$w[] = array('=', 'log_IsTop', 1);
	}

	$w[] = array('=', 'log_Status', 0);

	$articles = array();

{'fraction_non_alphanumeric': 0.2803377218088151, 'fraction_numerical': 0.015455065827132226, 'mean_word_length': 4.766501650165017, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3208729', 'n_tokens_mistral': 2880, 'n_tokens_neox': 2695, 'n_words': 520}