Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
郭成尧
9 years ago
Commit
d6d5b487816fbe8af8d921506c6e953fb2a576fc
1 parent
0eed0de1
'解决品牌店铺报错'
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
library/WebPlugin/Helpers.php
library/WebPlugin/Helpers.php
View file @
d6d5b48
...
...
@@ -1090,4 +1090,58 @@ class Helpers
{
return
preg_match
(
"/[
\x7f
-
\xff
]/"
,
$str
);
}
/**
* 将首字符为//的url转换为http://
*
* @param string $url 需要转换的url
* @return mixed
*/
public
static
function
transHttpsUrl
(
$url
)
{
return
preg_replace
(
'/^\/\//'
,
'http://'
,
$url
);
}
/**
* http和https转换成//
* @param type $url 地址
* @return type string
*/
public
static
function
getUrlSafe
(
$url
)
{
if
(
self
::
isStrpos
(
array
(
'/special_'
,
'/special/'
),
$url
))
{
return
$url
;
}
return
strtr
(
$url
,
array
(
'http://'
=>
'//'
));
}
/**
* 查找数组是否包含字符串中
* @param type $array 要查找的数组
* @param type $str 要搜索的字符串
* @return boolean
*/
public
static
function
isStrpos
(
$array
=
array
(),
$str
=
''
)
{
foreach
(
$array
as
$val
)
{
if
(
strpos
(
$str
,
$val
)
!==
false
)
{
return
true
;
}
}
return
false
;
}
/**
* 获取当前页面是http还是https
* @return string
*/
public
static
function
getHttpOrHttps
()
{
if
((
isset
(
$_SERVER
[
'HTTPS'
])
&&
$_SERVER
[
'HTTPS'
]
!==
'off'
)
||
(
isset
(
$_SERVER
[
'SERVER_PORT'
])
&&
$_SERVER
[
'SERVER_PORT'
]
===
443
)
||
(
isset
(
$_SERVER
[
'HTTP_REFERER'
])
&&
substr
(
$_SERVER
[
'HTTP_REFERER'
],
0
,
5
)
===
'https'
))
{
return
'https:'
;
}
return
'http:'
;
}
}
...
...
Please
register
or
login
to post a comment