现在很多站都使用https加密链接,但有些站使用phpcms v9的朋友发现不能添加带https的友情链接,添加时会提示不合法。这是由于php中没有添加https造成的。以下小系列将分享完美的解决方案,并更改几个php文件。

1、打开 \phpcms\modules\link\index.php 文件,找到
if($_POST['url==""""""""" || !preg_match('/^http:\/\/(.*)/i', $_POST['url'])){
showmessage(L('siteurl_not_empty'),"?m=link&c=index&a=register&siteid=$siteid");
}
修改为:
if($_POST['url==""""""""" || !preg_match('/^(http:\/\/|httpss:\/\/)(.*)/i', $_POST['url'])){
showmessage(L('siteurl_not_empty'),"?m=link&c=index&a=register&siteid=$siteid");
}
找到
$logo = safe_replace(strip_tags($_POST['logo']));
if(!preg_match('/^http:\/\/(.*)/i', $logo)){
$logo = '';
}
修改为:
$logo = safe_replace(strip_tags($_POST['logo']));
if(!preg_match('/^(http:\/\/|httpss:\/\/)(.*)/i', $logo)){
$logo = '';
}
2、打开 \phpcms\modules\link\templates\link_add.tpl.php 文件,找到
$("#link_url").formValidator({onshow:"",onfocus:""}).inputValidator({min:1,onerror:""}).regexValidator({regexp:"^http:\/\/[A-Za-z0-9] \.[A-Za-z0-9] [/=\?%\-&]*([^]]*$,onerror:""})
修改为:
$("#link_url").formValidator({onshow:"",onfocus:""}).inputValidator({min:1,onerror:""}).regexValidator({regexp:"^(http:\/\/|httpss:\/\/)[A-Za-z0-9] \.[A-Za-z0-9] [\/=\,%\-[]*([^])*$",onerror:""})3、打开 \phpcms\modules\link\templates\link_edit.tpl.php 文件,以上\link_add.tpl.修改php的方法是一样的。
之后可以在后台更新缓存,添加https的网站友情链接。