function AppCode(&$str) { if ($this->moduleLang == $this->sysLang) { return $str; } else { if ($this->sysLang == 'utf-8') { if ($this->moduleLang == 'gbk') { return gb2utf8($str); } if ($this->moduleLang == 'big5') { return gb2utf8(big52gb($str)); } } else { if ($this->sysLang == 'gbk') { if ($this->moduleLang == 'utf-8') { return utf82gb($str); } if ($this->moduleLang == 'big5') { return big52gb($str); } } else { if ($this->sysLang == 'big5') { if ($this->moduleLang == 'utf-8') { return gb2big5(utf82gb($str)); } if ($this->moduleLang == 'gbk') { return gb2big5($str); } } else { return $str; } } } } }
/** * 分析RSS里的链接 * * @access public * @param string $rssurl rss地址 * @return string */ function GetRssLinks($rssurl) { global $cfg_soft_lang; $dhd = new DedeHttpDown(); $dhd->OpenUrl($rssurl); $rsshtml = $dhd->GetHtml(); //分析编码 preg_match("/encoding=[\"']([^\"']*)[\"']/is", $rsshtml, $infos); if (isset($infos[1])) { $pcode = strtolower(trim($infos[1])); } else { $pcode = strtolower($cfg_soft_lang); } if ($cfg_soft_lang == 'gb2312') { if ($pcode == 'utf-8') { $rsshtml = utf82gb($rsshtml); } else { if ($pcode == 'big5') { $rsshtml = big52gb($rsshtml); } } } else { if ($cfg_soft_lang == 'utf-8') { if ($pcode == 'gbk' || $pcode == 'gb2312') { $rsshtml = gb2utf8($rsshtml); } else { if ($pcode == 'big5') { $rsshtml = gb2utf8(big52gb($rsshtml)); } } } } $rsarr = array(); preg_match_all("/<item(.*)<title>(.*)<\\/title>/isU", $rsshtml, $titles); preg_match_all("/<item(.*)<link>(.*)<\\/link>/isU", $rsshtml, $links); preg_match_all("/<item(.*)<description>(.*)<\\/description>/isU", $rsshtml, $descriptions); if (!isset($links[2])) { return ''; } foreach ($links[2] as $k => $v) { $rsarr[$k]['link'] = RpCdata($v); if (isset($titles[2][$k])) { $rsarr[$k]['title'] = RpCdata($titles[2][$k]); } else { $rsarr[$k]['title'] = preg_replace("/^(.*)\\//i", "", RpCdata($titles[2][$k])); } if (isset($descriptions[2][$k])) { $rsarr[$k]['image'] = GetddImgFromRss($descriptions[2][$k], $rssurl); } else { $rsarr[$k]['image'] = ''; } } return $rsarr; }
/** * 编码转换 * * @access public * @param string $str 字符串 * @return string */ function ChangeCode(&$str) { global $cfg_soft_lang; if ($cfg_soft_lang == 'utf-8') { if ($this->noteInfos["sourcelang"] == "gb2312") { $str = gb2utf8($str); } if ($this->noteInfos["sourcelang"] == "big5") { $str = gb2utf8(big52gb($str)); } } else { if ($this->noteInfos["sourcelang"] == "utf-8") { $str = utf82gb($str); } if ($this->noteInfos["sourcelang"] == "big5") { $str = big52gb($str); } } }
function TrimSymbol($str) { if(strtolower($this->CharSet)=="utf-8"){ $str = utf82gb($str); } else if(strtolower($this->CharSet)=="big5"){ $str = big52gb($str); } else if(!eregi("^gb",$this->CharSet)){ $this->NotEncodeText .= $str; return ""; } $str = trim($str); $slen = strlen($str); if($slen==0) return ""; $okstr = ""; for($i=0;$i<$slen;$i++){ if(ord($str[$i]) < 0x81){ //当字符为英文中的特殊符号 if(ereg("[^0-9a-zA-Z@.%#:/\\&-]",$str[$i])){ if($okstr!=""){ if( $okstr[strlen($okstr)-1]!=" " ) $okstr .= " "; } } //如果字符为非特殊符号 else{ if(strlen($okstr)>1){ if(ord($okstr[strlen($okstr)-2])>0x80) $okstr .= " ".$str[$i]; else $okstr .= $str[$i]; } else $okstr .= $str[$i]; } } else { //如果上一个字符为非中文和非空格,则加一个空格 if(strlen($okstr)>1){ if(ord($okstr[strlen($okstr)-2]) < 0x81 && $okstr[strlen($okstr)-1]!=" ") { $okstr .= " "; } } //如果中文字符 if( isset($str[$i+1]) ){ $c = $str[$i].$str[$i+1]; $n = hexdec(bin2hex($c)); if($n < 0xB0A1) { if($c=="《") { $okstr .= " 《"; } else if($c=="》") { $okstr .= "》 "; } else if($okstr[strlen($okstr)-1]!=" ") { $okstr .= " "; } } else{ //F7 - FE 是GB2312的终结编码 if($n < 0xF8FF) $okstr .= $c; } $i++; } else{ $okstr .= $str[$i]; } } }//结束循环 return $okstr; }
function ChangeCode(&$str) { if($GLOBALS['cfg_ver_lang']=='utf-8'){ if($this->Item["language"]=="gb2312") $str = gb2utf8($str); if($this->Item["language"]=="big5") $str = gb2utf8(big52gb($str)); }else{ if($this->Item["language"]=="utf-8") $str = utf82gb($str); if($this->Item["language"]=="big5") $str = big52gb($str); } }