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

emlog修改为Https

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

模板里面有写死的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"));

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

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

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

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

相关文章

工作站T7810重装系统注意事项

工作站T7810重装系统注意事项

        dell的工作站T7810(Dell Precision Tower 7810)由于使用了磁盘阵列技术,在重装系统时发现会找不到任何驱动设备。...

如何禁用Firefox火狐浏览器的“不安全密码警告”

如何禁用Firefox火狐浏览器的“不安全密码警告”

Step1: 打开firefox,在地址栏敲:about:config 此时会跳出:“这可能是质量保证失效”的页面,点击“我了解此风险” Step2: 在配置页面的顶部搜索栏里敲:...

win7升级ie8至ie11后无法打开

win7升级ie8至ie11后无法打开

win7升级ie8至ie11后无法打开,表现为 1、双击无反应,进程中没有ie进程。 2、卸载ie11后,连ie8也无法使用路。 3、检查windows功能,ie是启用的。 4、想起来用...

AUTO CAD2018启动出现Unhandled……

AUTO CAD2018启动出现Unhandled……

AUTO CAD2018启动出现Unhandled…… 回想起之前正常启动之后动过电脑的情况,一是安装了第二个显示器并更新了驱动。二是安装skecthup2017时为了安装netframework4.5.2不得已卸载了4....

局域网和外网多重网络同时使用

局域网和外网多重网络同时使用

要点: 1、ip、子网掩码都使用内网; 2、网关保证空白; 3、设置静态路由。 具体操作: 1、保证完成了上述1、2两条操作; 2、设置静态路由...

QT编译的程序中文乱码

QT编译的程序中文乱码

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