标签 URL 下的文章

SeaCMS获取当前页面URL以使用Meta标签移动适配

编辑 /include/mkhtml.func.php 文件,找到:

function makePlayByData($vType,$vId,$playArr,$content,$sdate,$enname,$stringecho)
{
    if($GLOBALS['cfg_ismakeplay']==1){
        for($i=0;$i<$playArr[0];$i++)
        {
            $tmp =$content;
            $tmp = str_replace("{playpage:from}",$playArr[1][$i],$tmp);
            foreach ($playArr[2][$i] as $n=>$play){
                $tmp1 =$tmp;
                $playLink = str_replace($GLOBALS['cfg_cmspath'],"",getPlayLink2($vType,$vId,$sdate,$enname,$i,$n));
                $tmp1 = str_replace("{playpage:part}",$play,$tmp1);

在下方插入:

$tmp1 = str_replace("{currentpageurl}",'http://'.$_SERVER['HTTP_HOST'].$playLink,$tmp1);

找到:

if($TotalResult == 0||strpos($content,'{/seacms:channellist}')===false){
        $channelLink=str_replace($GLOBALS['cfg_cmspath'],"",getChannelPagesLink($currentTypeId,1));
        $tempStr = str_replace("{channelpage:page}",1,$tempStr);
        $content=$tempStr;
        $content=$mainClassObj->ParsePageList($content,$typeIds,1,$pCount,$TotalResult,"channel",$currentTypeId);
        $content=$mainClassObj->parseIf($content);

在下方插入:

$content=str_replace("{currentpageurl}",'http://'.$_SERVER['HTTP_HOST'].$channelLink,$content);

- 阅读剩余部分 -

PHP获取当前页面URL

在PHP众多预定义服务器变量中,$_SERVER["REQUEST_URI"] 算是经常用到的,但是这个变量只有apache才支持,因此,我们需要一个更加通用的方式来获取REQUEST_URI的值,本文就是结束这一问题的解决方案

// 说明:获取 _SERVER['REQUEST_URI'] 值的通用解决方案 
// 整理:www.2dan.cc 
<?php
function request_uri() 
{
    if (isset($_SERVER['REQUEST_URI'])) 
    {
        $uri = $_SERVER['REQUEST_URI']; 
    }
    else
    {
        if (isset($_SERVER['argv'])) 
        {
            $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0]; 
        }
        else
        {
            $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING']; 
        }
    }
    return $uri; 
}
?>