<?php
require ('../e/class/connect.php');
require ('../e/class/db_sql.php');
DoEmpireCMSFireC();
$link=db_connect();
$empire=new mysqlquery;
$query="select id,tpinyin,title  from {$dbtbpre}ecms_movie order by id asc limit 99999";
$query=$empire->query($query);

while($r=$empire->fetch($query)){
		$id=$r[id];
		$title=$r[title];
		$tpinyin=ReturnPinyinFun($title);
		$tpinyin=getstrstr($tpinyin);
		$tpinyin=$tpinyin==''?$r[id]:$tpinyin;
		$filename=$tpinyin.'/index';
		$q=$empire->query("update {$dbtbpre}ecms_movie set tpinyin='$tpinyin',filename='$filename' where id='$id' ");
       if($q) echo '<font color=green>'.$id.'-'.$tpinyin.'更新成功</font><br />';
	   else echo '<font color=red>'.$id.'-'.$tpinyin.'更新失败</font><br />';
}


db_close();
$empire=NULL;

function isNums($ch = null)
{  
 if($ch >= "0" && $ch <= "9")
 {   
  return true;
 }else
 {
  return false ;
 }
}

/**
 * 判断字母
 */
function isChars($ch = null)
{
 if(($ch >= "a" && $ch <= "z") || ($ch >= "A" && $ch <= "Z"))
 {
  return true;
 }else
 {
  return false ;
 }
}
/**
 * 过滤数字和字符
 */
function getstrstr($gbk=NULL)
{  
 $temp = '';
 $gbk = strval($gbk);
 if($gbk == "\0")
 {
  return null;
 } 
 $gbr=str_split($gbk);
 for($i=0;$i<count($gbr);$i++)
 {
  if(isNums($gbr[$i])||isChars($gbr[$i]))
  {
   $temp.=$gbr[$i];
  } 
 }
 return $temp;
}





?>