为emlog 5.x添加https支持-站长杂谈下载

为emlog 5.x添加https支持

来自版块: 站长杂谈发表于: 2015-8-17 12:27:37
32627
0
如本资源下载地址失效,请点击此处进行反馈
开通本站Svip会员,全站资源免费下
https 支持已集成到Emlog 6.0,以下内容仅适用于Emlog 5.x用户。. }( m! q* W9 ?: s! `% F& X- X7 {
        在进行修改之前,请先确定服务器已正确配置https。并且备份所有文件,防止遇到兼容性问题。
5 a1 M, `7 R+ Z1 {! X3 \% n
) t8 {4 ]! u- Z4 B        1. /include/lib/option.php
' [$ W: {: |5 A, ]) N        请将以下内容粘贴到 get function 的 default 判断分支之前 (在Emlog 5.3.1下是第43行)
  1. case 'blogurl':& K. p" S- g$ I* a8 d
  2.     return realUrl();
    ' P3 z( B$ }! s: s4 m. r# _
  3.     break;
    $ ]9 G  V+ q1 P  g' y
复制代码
        2. /include/lib/function.base.php7 f* u& H# p6 a. ~
        请将以下内容粘贴到文件的末尾
  1. /**$ `( O" M3 t, p' n% k
  2. * 获取当前访问的base url9 [% r$ m) C5 p* }+ [
  3. */
    6 y' Y* g. w5 a/ {( p* m( G
  4. function realUrl() {# `5 h) Z, S: C: c
  5.     $emlog_path = EMLOG_ROOT . DIRECTORY_SEPARATOR;
      a( _- @; n. E. U' ]; j% b* Y6 |
  6.     $script_path = pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME);; y1 I( ~2 k6 Y" L, U! l3 {/ |
  7.     $script_path = str_replace('\\', '/', $script_path);& |5 f1 u/ j  W' H
  8.     $path_element = explode('/', $script_path);6 F; Z+ I* s& i! F
  9.    
    / c) N6 _; F7 ]1 _# x2 @
  10.     $this_match = '';5 o+ Y: w" k9 V& A3 Q
  11.     $best_match = '';: ?% r" {$ M/ F6 B& }
  12.    8 k. G. A9 x2 A9 P
  13.     $current_deep = 0;3 i$ \/ n  V5 V% R6 w7 B: g( c4 c
  14.     $max_deep = count($path_element);  _) R/ H1 C! \
  15.    4 S. t# X4 |! i. e4 q. H
  16.     while($current_deep < $max_deep) {
    ( ?5 e# O2 a/ w: T# u, K
  17.         $this_match = $this_match . $path_element[$current_deep] . DIRECTORY_SEPARATOR;" w9 \; B& c3 _
  18.         0 Q" O6 n4 D" i+ Z, C  Y+ A
  19.         if (substr($emlog_path, strlen($this_match) * (-1)) === $this_match) {1 W4 u- d" X+ M2 ]' o
  20.             $best_match = $this_match;2 j0 }! x' b  b1 |9 W# w% ~! M# O7 b
  21.         }
    % k4 t9 l8 |$ c0 [
  22.         
    8 v0 r% g+ {4 J3 z  W* A, d2 t. m
  23.         $current_deep++;- S* f. w4 L6 f
  24.     }
    3 c5 K- E; {4 |% e# O
  25.    
    # a9 R4 f) P' r+ p6 X+ j0 o
  26.     $best_match = str_replace(DIRECTORY_SEPARATOR, '/', $best_match);4 ?! o* M& ]4 Z
  27.     $real_url  = $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
    . E+ y  d! x: ~
  28.     $real_url .= $_SERVER["SERVER_NAME"];
    7 s1 C6 V9 ]' C% }2 t
  29.     $real_url .= in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT'];
    4 e6 Y6 ]2 ]* G' x; O; W! q
  30.     $real_url .= $best_match;
    : ?" k8 |# A- |8 t
  31.    
    1 ?8 f, E; [- K  S1 t9 B
  32.     return $real_url;/ @# k6 W$ @3 A, z* x- z
  33. }
复制代码
4 x9 g, A0 c* W5 \% h
        3. /init.php9 v* O+ b9 p; u8 ~6 b; Q5 ]6 R/ d$ y
        请用以下代码覆盖同名的define (在Emlog 5.3.1下是第39行)
: y* F7 ~" q2 e+ G( p% F* m
  • define('DYNAMIC_BLOGURL', Option::get("blogurl"));
    & s: _/ }) J9 [

* l. V+ U" I8 z) v6 y) Y8 C6 C5 y3 m3 x! N

9 ]" {1 X( i+ g# f; D1 e/ A# x' U$ ]6 s- o6 t' g6 D

全部评论 0

您需要登录后才可以回帖 立即登录
登录
0
0
0
返回顶部