<?php
require('../e/class/connect.php');
require('../e/class/db_sql.php');
require("../e/data/dbcache/class.php");
$link=db_connect();
$empire=new mysqlquery;
$key=$_GET['key'];
$key=RepPostVar2($key);
$key=unescape($key);
if($key)
{
	$sql=$empire->query("select id,title,tpinyin,titleurl,classid,newspath,filename,type,typeset from {$dbtbpre}ecms_movie where title like '%".$key."%' or tpinyin like '%".$key."%'  order by onclick desc limit 10");
	while($r=$empire->fetch($sql))
	{
		$titleurl=sys_ReturnBqTitleLink($r);
		$type=$r[type];
		$html.=$r[id]."|".$r[typeset]."|".$r[title]."|".$type."|".$titleurl."|".$titleurl."||";
		 
	}
	If (strlen($html)>10) $html=substr($html,0,strlen($html)-1);
}
echo($html);
db_close();
$empire=NULL;

function unescape($str) {
  $str = rawurldecode($str);
  preg_match_all("/(?:%u.{4})|&#x.{4};|&#\d+;|.+/U",$str,$r);
  $ar = $r[0];

  foreach($ar as $k=>$v) {
    if(substr($v,0,2) == '%u'){
      $ar[$k] = iconv("UCS-2","gbk",pack("H4",substr($v,-4)));
	  if($ar[$k]=='')
	  {
		  $ar[$k]=substr($v,-6);
	  }
	}
    elseif(substr($v,0,3) == "&#x")
      $ar[$k] = iconv("UCS-2","gbk",pack("H4",substr($v,3,-1)));
    elseif(substr($v,0,2) == "&#") {
      $ar[$k] = iconv("UCS-2","gbk",pack("n",substr($v,2,-1)));
    }
  }
  return join("",$ar);
}
?>