保留备查:
// 获取标题链接 function getsqlstr($str,$classid=1391){ global $dbtbpre,$empire; $where=' '; preg_match('/(.+?)《(.+?)》(.+)/',$str,$ms); if(!$ms)return ''; $where.="locate('$ms[1]',title)>0 and "; $where.="locate('$ms[2]',title)>0 "; preg_match('/((第[0-9]版))/',$ms[3],$mss); if($mss)$where.=" and locate('$mss[1]',title)>0 "; if(false!==strpos($ms[3],'真题')){$where.=" and locate('真题',title)>0 ";} if(false!==strpos($ms[3],'笔记')){$where.=" and locate('笔记',title)>0 ";} if(false!==strpos($ms[3],'习题')){$where.=" and locate('习题',title)>0 ";} if(!$where)$where=" 1=1"; $r=$empire->fetch1("select * from {$dbtbpre}ecms_article where classid=$classid and $where" ); if($r){ $titleurl=sys_ReturnBqTitleLink($r); return "<a target='_blank' href='$titleurl'>$str</a>"; }else{ return $str; } } //标题替换 function jhcChaLink($str){ return preg_replace_callback( '#<p>(.+?)</p>#', function ($ms){ if(false!==strpos($ms[1],'<a '))return $ms[0]; $tu=getsqlstr($ms[1]); if(!$tu)$tu=$ms[1]; return "<p>$tu</p>"; }, $str); }