当前位置:首页 > 技术手札 > 正文内容

emlog修改为Https

秋风渡红尘7年前 (2018-10-25)技术手札1731

模板里面有写死的http,需要改成https

header.php

footer.php


include/lib/function.base.php第73行


return 'http://' . $_SERVER['HTTP_HOST'] . $matches[0]; 


修改为

return '//' . $_SERVER['HTTP_HOST'] . $matches[0];

以上测试成功。附其他处理办法:

include/lib/option.php

1、请将以下内容粘贴到get function的default判断分支之前 (在Emlog 5.3.1下是第43行)

case 'blogurl':
    return realUrl();
    break;
2、include/lib/function.base.php

请将以下内容粘贴到文件的末尾

/**
 * 获取当前访问的base url
 */
function realUrl() {
    static $real_url = NULL;
    
    if ($real_url !== NULL) {
        return $real_url;
    }
 
    $emlog_path = EMLOG_ROOT . DIRECTORY_SEPARATOR;
    $script_path = pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME);
    $script_path = str_replace('\\', '/', $script_path);
    $path_element = explode('/', $script_path);
    
    $this_match = '';
    $best_match = '';
    
    $current_deep = 0;
    $max_deep = count($path_element);
    
    while($current_deep < $max_deep) {
        $this_match = $this_match . $path_element[$current_deep] . DIRECTORY_SEPARATOR;
        
        if (substr($emlog_path, strlen($this_match) * (-1)) === $this_match) {
            $best_match = $this_match;
        }
        
        $current_deep++;
    }
    
    $best_match = str_replace(DIRECTORY_SEPARATOR, '/', $best_match);
    $real_url  = $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
    $real_url .= $_SERVER["SERVER_NAME"];
    $real_url .= in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT'];
    $real_url .= $best_match;
    
    return $real_url;
}
3、/init.php

请用以下代码覆盖同名的define (在Emlog 5.3.1下是第39行)

define('DYNAMIC_BLOGURL', Option::get("blogurl"));

扫描二维码推送至手机访问。

版权声明:本文由咿呀贝发布,如需转载请注明出处。

本文链接:https://www.yiyabei.cn/?id=32

标签: 网络EMLOG
分享给朋友:

相关文章

ubuntu安装问题之分区不可用

ubuntu安装问题之分区不可用

        ubuntu是linux一个比较出色的发行版之一,无论国内国外都有不少的拥趸,而且国内安装ubuntu系统的人也越来越多,大有大步向前的姿...

carlibre抓取网页内容生成电子书

carlibre抓取网页内容生成电子书

#!/usr/bin/python # encoding: utf-8 from calibre.web.feeds.recipes import BasicNewsRecipe class Pro_Git_Chinese(Basic...

QT编译的程序中文乱码

QT编译的程序中文乱码

在主程序加入 QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));...

caddy的文件目录

caddy的文件目录

通过查看 /usr/local/caddy vim /usr/local/caddy/Caddyfile 得知文件目录是在 /etc/v2ray/pages...

ubuntu把iso镜像文件添加为更新源

ubuntu把iso镜像文件添加为更新源

环境:vmware12 + win7物理机 + ubuntu16.04虚拟机 iso是用vm直接挂载到ubuntu的,其实是想用iso来升级系统,结果不知道怎么执行升级,反而是一大堆问题。 正确添加源的方法是:...

cocos creator逐个输出字体实现方式

cocos creator逐个输出字体实现方式

方法一: for str += string 特点是每次循环前面的字符都要重新输出一次,容易造成闪烁。 方法二: for location[i].t...