<?php 
error_reporting (0); 
include("array.php");
require_once('config.php');


//评论
function ShowMsg($msg, $gourl, $onlymsg=0, $limittime=0)
{
    $htmlhead  = "<html>\r\n<head>\r\n<title>提示信息</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" />\r\n";
    $htmlhead .= "<base target='_self'/>\r\n<style>div{line-height:160%;}</style></head>\r\n<body leftmargin='0' topmargin='0' bgcolor='#FFFFFF'>\r\n<center>\r\n<script>\r\n";
    $htmlfoot  = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n";

    $litime = ($limittime==0 ? 1000 : $limittime);
    $func = '';

    if($gourl=='-1')
    {
        if($limittime==0) $litime = 5000;
        $gourl = "javascript:history.go(-1);";
    }
        $func .= "      var pgo=0;
      function JumpUrl(){
        if(pgo==0){ location='html.php?id=$gourl'; pgo=1; }
      }\r\n";
        $rmsg = $func;
        $rmsg .= "document.write(\"<br /><div style='width:450px;padding:0px;border:1px solid #c7ea6a;'>";
        $rmsg .= "<div style='padding:6px;font-size:12px;border-bottom:1px solid #c7ea6a;background:#f5fde6 ';'><b>提示信息！</b></div>\");\r\n";
        $rmsg .= "document.write(\"<div style='height:130px;font-size:10pt;background:#ffffff'><br />\");\r\n";
        $rmsg .= "document.write(\"".str_replace("\"","“",$msg)."\");\r\n";
        $rmsg .= "document.write(\"";
        $rmsg .= "<br /><a href='html.php?id={$gourl}'>如果你的浏览器没反应，请点击这里...</a>";
        $rmsg .= "<br/></div>\");\r\n";
        $rmsg .= "setTimeout('JumpUrl()',$litime);";
        $msg  = $htmlhead.$rmsg.$htmlfoot;
    
    echo $msg;
}
//增加关键词内链
function seo_rlink($str){
		if (!empty($str)){
		require('config_seo.php');
		$a=$seo_rlink;
		$c = explode(',',$a);
		foreach($c as $v)
		{
			if(preg_match("[|]",$v))
            {
    			list($r,$l) = explode('|',$v);
				//$str = str_replace($r, "<strong>".$r."</strong>",$str);
    			$str = preg_replace("/$r/", "<a href=\"$l\">$r</a>", $str ,1);
				}
		}
		return $str;
}else{
return $str;
}
}


//自动标签
function substring($str, $start, $len) {
	$tmpstr = "";
	$strlen = $start + $len;
	$i = 0;
	for(; $i < $strlen; $i ++) {
		if (160 < ord ( substr ( $str, $i, 1 ) )) {
			$tmpstr .= substr ( $str, $i, 2 );
			$i ++;
		} else {
			$tmpstr .= substr ( $str, $i, 1 );
		}
	}
	return $tmpstr;
}
function tags($str) {
	require_once ('./dededic.php');
	$sp = new SplitWord ();
	$str = $sp->SplitRMM ( $str );
	$sp->Clear ();
	$str = explode ( " ", $str );
	
	foreach ( $str as $key => $words ) {
		if (strlen ( $words ) < 4) {
			unset ( $str [$key] );
		}
	}
	
	$str = array_unique ( $str );
	
	foreach ( $str as $w ) {
		$str2 .= "<a href='../search.php?key={$w}'>" . $w . "</a> ";
	}
	
	return $str2;

}
//删除内容中的连接
function dellink($s){
		if (!empty($s)){
	$s = preg_replace("/<a[^>]+>(.+?)<\/a>/i","$1",$s);
	return $s;
}else{
return $s;
}
}
function wyc($text){    
  $swap_arr = array( );
  $content = file_get_contents("words.txt");
  $content = str_replace( "\r", "", $content );
  $content = preg_split( "/\\n/", $content, -1, PREG_SPLIT_NO_EMPTY );
  foreach ( $content as $k => $v )
  {
  if ( $k != 0 )
  {
    $str_data = explode( "=", $v );
    $swap_arr += array($str_data['0'] => $str_data['1']);
  }
  }
  $text = strtr($text,$swap_arr);
  return $text;   
} 
//关键词过滤
function s($s){
	require_once('config_sift.php');
	require_once('config.php');
	$siftw = explode ( '|', $sift );
	foreach($siftw as $key => $words){
	if (preg_match ("/".$siftw[$key]."/i", $s ) && !empty($siftw[$key])) {
	echo "<script>location.href='../index.php';</script>";
	exit;
	}else{
return $s;
}
}
}

function replace_keyword($string,$t=1){global $keyword; 
$keyword_key = array_keys($keyword); 
$keyword_value = array_values($keyword); 
if($t==1){$string = str_replace($keyword_key,$keyword_value,$string); 
}elseif($t==2){$string = str_replace($keyword_value,$keyword_key,$string); 
	}return $string; 
}


function check_out($msg){
	$msg = str_replace('&amp;','&',$msg);
	$msg = str_replace('&nbsp;',' ',$msg);
	$msg = str_replace('"','&quot;',$msg);
	$msg = str_replace("'",'&#39',$msg);
	$msg = str_replace("\t","   &nbsp;  &nbsp;",$msg);
	$msg = str_replace("<","&lt;",$msg);
	$msg = str_replace(">","&gt;",$msg);
	$msg = str_replace("\r","",$msg);
	$msg = str_replace("\n","<br />",$msg);
	$msg = str_replace("|","│",$msg);
	$msg = str_replace("   "," &nbsp; ",$msg);
	return $msg;
}
function write($f,$infoata,$method="w") {
	$filenum=@fopen($f,$method);
	@flock($filenum,LOCK_EX);
	$file_data=@fwrite($filenum,$infoata);
	@fclose($filenum);
	return $file_data;
}
function read($f) {
	$filenum=@fopen($f,"r");
	@flock($filenum,LOCK_SH);
	$file_data=@fread($filenum,filesize($f));
	@fclose($filenum);
	return $file_data;
}


?>
