php路径中有中文怎么解决方法,phpcms中文URL路径解决方法
php路径中有中⽂怎么解决⽅法,phpcms中⽂URL路径解决⽅
php教程cms怎样⽀持中⽂路径呢?phpcms中⽂URL要怎样设置呢?
待我下⾯叙来。。。
⾸先,在 phpcms的include⽬录下,有global.func.php ⽂件。
到 function createhtml($file) 这个函数。
说明下,这个函数是⽤来⽣成html静态⽂件的。
我们只需要修改下这个函数即可。
修改后如下:
view plaincopy to clipboardprint?
function createhtml($file)
{
//scofield 2010-3-16
//for create file as chinses name
$file = iconv('UTF-8', 'GBK', $file);
$data = ob_get_contents();
ob_clean();
dir_create(dirname($file));
$strlen = file_put_contents($file, $data);
@chmod($file,0777);
return $strlen;
}
function createhtml($file)
{
//scofield 2010-3-16
//for create file as chinses name
$file = iconv('UTF-8', 'GBK', $file);
$data = ob_get_contents();
ob_clean();
dir_create(dirname($file));
$strlen = file_put_contents($file, $data);
@chmod($file,0777);
}
$file = iconv(‘UTF-8′, ‘GBK’, $file); 主要增加了这⼀句。该句实现了 编码转换。这样⽣成的 html ⽂件或者路径 都可以带有中⽂。其次,在include⽬录下还有 include/url.class.php 这个⽂件。
打开后到 function show($contentid, $page = 0, $catid = 0, $time = 0, $prefix = ”) 这个函数。
添加 如下语句
view plaincopy to clipboardprint?
//scofield 2010-3-16
//get root category name
$catetemp = $this->db->get_one("SELECT * FROM `".DB_PRE."category` WHERE  catid = $catid  LIMIT 1");
$arrparentidarr = explode(',',$catetemp['arrparentid']);
$rootidtemp = $arrparentidarr[count($arrparentidarr)-1];
$rootcatetemp = $this->db->get_one("SELECT * FROM `".DB_PRE."category` WHERE  catid = $roo
tidtemp LIMIT 1"); $rootcatename = $rootcatetemp['catname'];
//for url roles add content title and category name
$showtitle = strip_tags($r['title']);
$catdirname = $C['catname'];
//scofield 2010-3-16
//get root category name
置换补贴
$catetemp = $this->db->get_one("SELECT * FROM `".DB_PRE."category` WHERE catid = $catid LIMIT 1");
$arrparentidarr = explode(',',$catetemp['arrparentid']);
$rootidtemp = $arrparentidarr[count($arrparentidarr)-1];
$rootcatetemp = $this->db->get_one("SELECT * FROM `".DB_PRE."category` WHERE catid = $rootidtemp LIMIT 1"); $rootcatename = $rootcatetemp['catname'];
//for url roles add content title and category name
$showtitle = strip_tags($r['title']);
$catdirname = $C['catname'];
完整的函数如下:
蓝眼泪 陈冠蒲view plaincopy to clipboardprint?
function show($contentid, $page = 0, $catid = 0, $time = 0, $prefix = '')
{
global $PHPCMS;
if($catid == 0 || $time == 0 || $prefix == '')
{
if($r['isupgrade'] && !emptyempty($r['url']))
{
if($page>1)
{
$base_name = basename($r['url']);
$fileext = fileext($base_name);
$url_a[0] = $url_a[1] = preg_replace('/.'.$fileext.'$/','_'.$page.'.'.$fileext,$r['url']);
return $url_a;
会变大变小的书包作文400字四年级}
else
{
$url_a[0] = $url_a[1] = $r['url'];
return $url_a;
}
}
$catid = $r['catid'];
$time = $r['inputtime'];
if(!$prefix) $prefix = $r['prefix'];
}
2010年新年祝福语if(!isset($this->CATEGORY[$catid])) return false;
$C = cache_read('category_'.$catid.'.php', '', 1);
$tag = 0;
if(preg_match('/:///',$C['url']))
{
$tag = 1;
$arr_url = preg_split('///', $C['url']);
$domain = ''.$arr_url[2];
$domain1 = ''.$arr_url[2].'/';
$info = $this->db->get_one("SELECT * FROM `".DB_PRE."category` WHERE `url` IN ('$domain', '$domain1') LIMIT 1"); $crootdir = $info['parentdir'].$info['catdir'].'/';
}
$categorydir = $C['parentdir'].$C['catdir'];
$catdir = $C['catdir'];
//for url roles add content title and category name
$showtitle = strip_tags($r['title']);
$catdirname = $C['catname'];
//scofield 2010-3-16
//get root category name
$catetemp = $this->db->get_one("SELECT * FROM `".DB_PRE."category` WHERE  catid = $catid  LIMIT 1"); $arrparentidarr = explode(',',$catetemp['arrparentid']);
$rootidtemp = $arrparentidarr[count($arrparentidarr)-1];
if($rootidtemp)
{
$rootcatetemp = $this->db->get_one("SELECT * FROM `".DB_PRE."category` WHERE  catid = $rootidtemp LIMIT 1"); $rootcatename = $rootcatetemp['catname'];
}else
{
$rootcatename = $catdirname ;
}
$fileext = $this->PHPCMS['fileext'];
$year = date('Y', $time);
$month = date('m', $time);
$day = date('d', $time);
$modelid = $C['modelid'];
$urlruleid = $this->MODEL[$modelid]['show_urlruleid'];
$urlrules = explode('|', $this->URLRULE[$urlruleid]);
$urlrule = $page
if($this->MODEL[$modelid]['ishtml'])
{
if($prefix)
{
$contentid = $prefix;
}
elseif($PHPCMS['enable_urlencode'])
{
$contentid = hash_string($contentid);
}
eval("$url = "$urlrule";");
if($tag)
{
if(!(strpos($url, $crootdir)===0))
{
$url = $crootdir.$url;
}
$url_a[0] = $url;
$url_a[1] = $domain1.str_replace($crootdir, '', $url);
}
else
{
$url_a[0] = $url_a[1] = $url;清明节手抄报文字
}
return $url_a;
}
function show($contentid, $page = 0, $catid = 0, $time = 0, $prefix = '')
{
global $PHPCMS;
if($catid == 0 || $time == 0 || $prefix == '')
{
$r = $this->db->get_one("SELECT * FROM `".DB_PRE."content` WHERE `contentid`='$contentid'"); if($r['isupgrade'] && !empty($r['url']))
{
if($page>1)
{
$base_name = basename($r['url']);
情人节红包祝福语$fileext = fileext($base_name);
$url_a[0] = $url_a[1] = preg_replace('/.'.$fileext.'$/','_'.$page.'.'.$fileext,$r['url']);
return $url_a;
}
else

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。