<?php
	function getform($forminput)
	{
		$form_input=trim(strip_tags($forminput));
		return $form_input;
	}
	
	//转换Unix时间戳为 2007-02-28 13:01:11的格式
	function GetDateTime($mktime){
		if($mktime==""||ereg("[^0-9]",$mktime)) return "";
		return strftime("%Y-%m-%d %H:%M:%S",$mktime);
	}

	function GetDateTimes($mktime){
		if($mktime==""||ereg("[^0-9]",$mktime)) return "";
		return strftime("%Y-%m-%d %H:%M",$mktime);
	}

	//转换Unix时间戳为 2007-02-28 13:01:11的格式
	function Getsj($mktime){
		if($mktime==""||ereg("[^0-9]",$mktime)) return "";
		return strftime("%m-%d %H:%M",$mktime);
	}

	//转换Unix时间戳为 2007-02-28 13:01:11的格式
	function Getrqsj($mktime){
		if($mktime==""||ereg("[^0-9]",$mktime)) return "";
		return strftime("%Y-%m-%d %H:%M",$mktime);
	}

	//转换unix时间戳为日期 07-02-28格式
	function GetDates($mktime){
		if($mktime==""||ereg("[^0-9]",$mktime)) return "";
		return strftime("%Y-%m-%d",$mktime);
	}
	
	
	//转换unix时间戳为日期 2007-02-28格式
	function Getriqi($mktime){
		if($mktime==""||ereg("[^0-9]",$mktime)) return "";
		return strftime("%Y%m%d",$mktime);
	}

	//转换unix时间戳为日期 2007-02-28格式
	function Geturl($mktime){
		if($mktime==""||ereg("[^0-9]",$mktime)) return "";
		return strftime("%Y/%m/%d",$mktime);
	}


	function arcurl($str,$id){
		$url='http://www.zaoan.cc/system/'.Getriqi($str).'/'.$id.'.shtml';
		return $url;
	}

	
	function SpGetPinyin($str, $ishead=0, $isclose=1)
	{
		global $pinyins;
		$restr = '';
		$str = trim($str);
		$slen = strlen($str);
		if($slen < 2)
		{
			return $str;
		}
		if(count($pinyins) == 0)
		{
			$fp = fopen(DEDEINC.'/data/pinyin.dat', 'r');
			while(!feof($fp))
			{
				$line = trim(fgets($fp));
				$pinyins[$line[0].$line[1]] = substr($line, 3, strlen($line)-3);
			}
			fclose($fp);
		}
		for($i=0; $i<$slen; $i++)
		{
			if(ord($str[$i])>0x80)
			{
				$c = $str[$i].$str[$i+1];
				$i++;
				if(isset($pinyins[$c]))
				{
					if($ishead==0)
					{
						$restr .= $pinyins[$c];
					}
					else
					{
						$restr .= $pinyins[$c][0];
					}
				}else
				{
					$restr .= "_";
				}
			}else if( preg_match("/[a-z0-9]/i", $str[$i]) )
			{
				$restr .= $str[$i];
			}
			else
			{
				$restr .= "_";
			}
		}
		if($isclose==0)
		{
			unset($pinyins);
		}
		return $restr;
	}


	function fenci($keyword){
		
		if(strlen($keyword)>7){
			$sp = new SplitWord('UTF-8','UTF-8');
			$sp->SetSource($keyword,'UTF-8','UTF-8');
			$sp->SetResultType(2);
			$sp->StartAnalysis(TRUE);
			$spwords = $sp->GetFinallyResult();
			$spwords = str_replace(' ',',',$spwords);
			$spwords = ltrim($spwords,',');
		}else{
			$spwords = $keyword;
		}
	
		return $spwords;
	}

?>