15621857753

phpcmsV9全站修改HTTS格式完美教程

来源:齐鲁建站 栏目:建站教程 阅读: 日期:2021-02-14

本文主要介绍了phpcmsV9全站修改HTTS格式完美教程,由于phpcmsV9默认版本不支持HTTPS格式,也就说如果强制使用HTTPS就会出现有些页面打不开的情况,特别是分页,本教程就来说说修改的方法。

打开 /phpcms/modules/admin/site.php 45行,128行

打开 /phpcms/modules/admin/templates/category_add.tpl.php

打开 /phpcms/modules/admin/templates/category_edit.tpl.php 11行

打开 /phpcms/modules/admin/templates/site_add.tpl.php 13行

打开 /phpcms/modules/admin/templates/site_edit.tpl.php 11行

打开 /phpsso_server/phpcms/modules/admin/templates/applications_add.tpl.php

打开 /phpsso_server/phpcms/modules/admin/templates/applications_edit.tpl.php 14行

找到下面代码:

http:\/\/(.+)\/$

http:\/\/(.+)\/$

改成

^(http(s)?:)?\/\/(.+)\/$

^(http(s)?:)?\/\/(.+)\/$

基本配置的

phpcms/modules/admin/templates/setting.tpl.php

http:\/\/(.+)[^/]$

http:\/\/(.+)[^/]$

改成

^(http(s)?:)?\/\/(.+)[^/]$

^(http(s)?:)?\/\/(.+)[^/]$

友链模块的

phpcms/modules/link/templates/link_add.tpl.php和link_edit.tpl.php找到

^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&]*([^<>])*$

^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&]*([^<>])*$

改成

^(http(s)?:)?\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&]*([^<>])*$

^(http(s)?:)?\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&]*([^<>])*$

扩展-来源的

phpcms/modules/admin/templates/copyfrom_add.tpl.php和copyfrom_edit.tpl.php找到

^http://

^http://

改成

^(http(s)?:)?\/\/(.+)\/$

^(http(s)?:)?\/\/(.+)\/$

扩展-关联链接的

phpcms/modules/admin/templates/keylink_add.tpl.php和keylink_edit.tpl.php找到

^http:

^http:

改成

^http(s)?:\/\/

^http(s)?:\/\/

以上为前端修改

通信及后台部分修改

后台内容列表,这部分很重要,牵扯到整个后台的分页,不仅限于内容分页

phpcms/modules/content/templates/content_list.tpl.php 97行找到

} elseif(strpos($r['url'],'http://')!==false) {

} elseif(strpos($r['url'],'http://')!==false) {

改成

} elseif(preg_match('/^(http(s)?:)?\/\//', $r['url'])) {

} elseif(preg_match('/^(http(s)?:)?\/\//', $r['url'])) {

后台分页,这部分很重要,牵扯到内容管理里的标题超链打开地址

phpcms/libs/functions/global.func.php

找到pageurl函数,没修改过的在784行,里面找到

$url = str_replace(array('http://','//','~'), array('~','/','http://'), $url);

$url = str_replace(array('http://','//','~'), array('~','/','http://'), $url);

改成

$url = preg_replace(array('/^((\w+):)?\/\//', '/\/{2,}/', '/~/'), array('$1~', '/', '//'), $url);

$url = preg_replace(array('/^((\w+):)?\/\//', '/\/{2,}/', '/~/'), array('$1~', '/', '//'), $url);

/phpsso_server/api/uc_client/client.php找到

$port = !empty($matches['port']) ? $matches['port'] : 80;

$port = !empty($matches['port']) ? $matches['port'] : 80;

改成

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme'] == 'https' ? 443 : 80);

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme'] == 'https' ? 443 : 80);

/phpsso_server/api/uc_client/model/misc.php找到

$port = !empty($matches['port']) ? $matches['port'] : 80;

$port = !empty($matches['port']) ? $matches['port'] : 80;

改成

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme'] == 'https' ? 443 : 80);

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme'] == 'https' ? 443 : 80);

/phpcms/libs/classes/http.class.php找到

$port = $matches['port'] ? $matches['port'] : 80;

$port = $matches['port'] ? $matches['port'] : 80;

改成

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme']=='https' ? 443 : 80);

$protocol = ('https' == $matches['scheme']) ? 'ssl://' : '';

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme']=='https' ? 443 : 80);

$protocol = ('https' == $matches['scheme']) ? 'ssl://' : '';

找到

$fp = @fsockopen($host, $port, $errno, $errstr, $timeout);

$fp = @fsockopen($host, $port, $errno, $errstr, $timeout);

改成

PHP

$fp = @fsockopen($protocol.$host, $port, $errno, $errstr, $timeout);

$fp = @fsockopen($protocol.$host, $port, $errno, $errstr, $timeout);

phpsso_server/phpcms/libs/classes/http.class.php找到

$port = $matches['port'] ? $matches['port'] : 80;

$port = $matches['port'] ? $matches['port'] : 80;

改成

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme']=='https' ? 443 : 80);

$protocol = ('https' == $matches['scheme']) ? 'ssl://' : '';

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme']=='https' ? 443 : 80);

$protocol = ('https' == $matches['scheme']) ? 'ssl://' : '';

phpcms/modules/member/classes/client.class.php里找到_ps_post函数,里面的

$port = !empty($matches['port']) ? $matches['port'] : 80;

$port = !empty($matches['port']) ? $matches['port'] : 80;

改成

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme']=='https' ? 443 : 80);

$port = !empty($matches['port']) ? $matches['port'] : ($matches['scheme']=='https' ? 443 : 80);

通过以上修改,基本解决了PHPCMCSV9兼容https的问题,至于为什么说基本,因为这里也有可能我尚未发现的地方,如果有可以在评论区告知一下,我更新上来

以上就是关于phpcms修改HTTS的所有内容,希望可以帮到大家,欢迎找小编一起交流~

响应式网站建设

展开