<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
if(isset($LabelArray['内容']) && !isset($LabelArray['Html']))
{
$str_arr=explode("。",$LabelArray['内容']);
shuffle($str_arr);
$body=implode("。", $str_arr);
$LabelArray['标题']=CutStr(get_title($str_arr),30);
$LabelArray['内容']="企聚网--".$body;
}
function get_title($arr)
{
if(isset($arr[0]))
{
$title_str_arr=explode(",",
$arr[0]);
$len=count($title_str_arr);
if($len>=2)
{
return DelCode($title_str_arr[0]."_".$title_str_arr[1]);
}
else
{
return DelCode($title_str_arr[0]);
}
}
else{
return "";
}
}
function DelCode($str)
{
$search = array("'<script[^>]*?>.*?</script>'si",
// strip out javascript
"'<[\/\!]*?[^<>]*?>'si",
// strip out html tags
"'([\r\n])[\s]+'",
// strip out white space
"'&(quot|#34|#034|#x22);'i",
// replace html entities
"'&(amp|#38|#038|#x26);'i",
// added hexadecimal values
"'&(lt|#60|#060|#x3c);'i",
"'&(gt|#62|#062|#x3e);'i",
"'&(nbsp|#160|#xa0);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&(reg|#174);'i",
"'&(deg|#176);'i",
"'&(#39|#039|#x27);'",
"'&(euro|#8364);'i",
// europe
"'&a(uml|UML);'",
// german
"'&o(uml|UML);'",
"'&u(uml|UML);'",
"'&A(uml|UML);'",
"'&O(uml|UML);'",
"'&U(uml|UML);'",
"'ß'i",
);
$replace = array("",
"",
"\\1",
"\"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
chr(174),
chr(176),
chr(39),
chr(128),
"?",
"?",
"?",
"?",
"?",
"?",
"?",
);
$str = preg_replace($search,$replace,$str);
return trim($str);
}
function mktitle($string, $replacement = '_')
{
$map = array(
'/à|á|å|â|ä/' => 'a',
'/è|é|ê|ẽ|ë/' => 'e',
'/ì|í|î/' => 'i',
'/ò|ó|ô|ø/' => 'o',
'/ù|ú|ů|û/' => 'u',
'/ç|č/' => 'c',
'/ñ|ň/' => 'n',
'/ľ/' => 'l',
'/ý/' => 'y',
'/ť/' => 't',
'/ž/' => 'z',
'/š/' => 's',
'/æ/' => 'ae',
'/ö/' => 'oe',
'/ü/' => 'ue',
'/Ä/' => 'Ae',
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/ß/' => 'ss',
'/ /'=>' ',
'/ /'=>'',
'/\.|~|·|!|@|#|¥|%|…|&|×|(|)|-|\+|=|『|【|』|】|、|:|;|“|”|\'|《|,|》|。|?|\/|—|_|:|√|<|°|丶|>|-|★|||│|‖|ˇ/'=>' ',
'/[^\w\s^.\x80-\xff]/' => ' ',
'/\\s+/' => $replacement
);
$string = trim($string);
$string = preg_replace(array_keys($map), array_values($map), $string);
$string = preg_replace('/\\s+/',$replacement, strtolower($string));
$string = trim($string,$replacement);
return $string;
}
function CutStr($sourcestr,$cutlength)
{
$returnstr='';
$i=0;
$n=0;
$str_length=strlen($sourcestr);//字符串的字节数
while (($n<$cutlength) and ($i<=$str_length))
{
$temp_str=substr($sourcestr,$i,1);
$ascnum=Ord($temp_str);//得到字符串中第$i位字符的ascii码
if ($ascnum>=224) //如果ASCII位高与224,
{
$returnstr=$returnstr.substr($sourcestr,$i,3); //根据UTF-8编码规范,将3个连续的字符计为单个字符
$i=$i+3; //实际Byte计为3
$n++; //字串长度计1
}
elseif ($ascnum>=192) //如果ASCII位高与192,
{
$returnstr=$returnstr.substr($sourcestr,$i,2); //根据UTF-8编码规范,将2个连续的字符计为单个字符
$i=$i+2; //实际Byte计为2
$n++; //字串长度计1
}
elseif ($ascnum>=65 && $ascnum<=90) //如果是大写字母,
{
$returnstr=$returnstr.substr($sourcestr,$i,1);
$i=$i+1; //实际的Byte数仍计1个
$n++; //但考虑整体美观,大写字母计成一个高位字符
}
else //其他情况下,包括小写字母和半角标点符号,
{
$returnstr=$returnstr.substr($sourcestr,$i,1);
$i=$i+1; //实际的Byte数计1个
$n=$n+0.5; //小写字母和半角标点等与半个高位字符宽...
}
}
if ($str_length>$i){
$returnstr = $returnstr ;//超过长度时在尾处加上省略号
}
return htmlspecialchars($returnstr);
}
echo serialize($LabelArray);
?>