Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
677d3c66
Commit
677d3c66
authored
Nov 27, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
7bb0366d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
40 deletions
+26
-40
common.php
application/common.php
+26
-40
No files found.
application/common.php
View file @
677d3c66
...
...
@@ -96,46 +96,44 @@ function down_file($url, $dir, $filename=''){
return
$filename
;
}
/**
* 隐藏客户手机号中间几位
* zhuwei 2017年12月22日15:33:48
* @param $phone
* @return mixed|string
* 朱伟 2017年12月22日15:33:48
*/
function
hide_customer_phone
(
$phone
)
{
//首先去除前后'|'
$phone
=
trim
(
$phone
,
"|"
);
$phone
=
trim
(
$phone
,
"|"
);
//然后判断里面是否有'|'
if
(
strpos
(
$phone
,
"|"
)
!==
false
)
{
if
(
strpos
(
$phone
,
"|"
)
!==
false
)
{
$explode_phone
=
explode
(
"|"
,
$phone
);
foreach
(
$explode_phone
as
$k
=>
$v
)
{
if
(
checkMobileValidity
(
$v
))
{
$explode_phone
[
$k
]
=
substr_replace
(
$v
,
'****'
,
3
,
4
);
if
(
checkMobileValidity
(
$v
))
{
$explode_phone
[
$k
]
=
substr_replace
(
$v
,
'****'
,
3
,
4
);
}
}
return
implode
(
"|"
,
$explode_phone
);
}
else
{
if
(
checkMobileValidity
(
$phone
))
{
$phone
=
substr_replace
(
$phone
,
'****'
,
3
,
4
);
}
else
{
if
(
checkMobileValidity
(
$phone
))
{
$phone
=
substr_replace
(
$phone
,
'****'
,
3
,
4
);
}
return
$phone
;
}
}
////打印
//function prt($arr){
// echo "<pre/>";
// print_r($arr);
//}
/**^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$
* 验证手机号是否正确
* zhuwei 2017-10-18 17:28:01
/**
*验证手机号是否正确
* @param $phone
* @return bool
* 朱伟 2017-10-18 17:28:01
*/
function
checkMobileValidity
(
$phone
)
{
$mobilephone
=
trim
(
$phone
);
// $exp = "/^13[0-9]{1}[0-9]{8}$|15[012356789]{1}[0-9]{8}$|18[012356789]{1}[0-9]{8}$|14[57]{1}[0-9]$/";
$exp
=
"/^(1[0-9])\d
{
9
}
$/"
;
if
(
preg_match
(
$exp
,
$mobilephone
))
{
return
true
;
...
...
@@ -144,35 +142,23 @@ function checkMobileValidity($phone)
}
}
/**
* 时间轴 '刚刚' '昨天' '前天'
* @param $time_inpute
* @return false|string
* 朱伟 2017-10-23 09:56:05
*/
function
tranTime
(
$time_inpute
)
{
$time2
=
strtotime
(
$time_inpute
);
function
tranTime
(
$time_inpute
)
{
$time2
=
strtotime
(
$time_inpute
);
$time
=
time
()
-
$time2
;
$rtime
=
date
(
"H点i分s秒"
,
$time2
);
if
(
$time
<
60
)
{
$str
=
'刚刚'
;
}
elseif
(
$time
<
60
*
60
)
{
$min
=
floor
(
$time
/
60
);
$str
=
$min
.
'分钟前'
;
}
// elseif ($time < 60 * 60 * 24) {
// $h = floor($time/(60*60));
// $str = $h.'小时前 ';
// }
// elseif ($time < 60 * 60 * 24 * 3) {
// $d = floor($time/(60*60*24));
// if($d==1)
// $str = '昨天 '.$rtime;
// else
// $str = '前天 '.$rtime;
// }
else
{
$str
=
date
(
"Y-m-d"
,
$time2
);
}
elseif
(
$time
<
60
*
60
)
{
$min
=
floor
(
$time
/
60
);
$str
=
$min
.
'分钟前'
;
}
else
{
$str
=
date
(
"Y-m-d"
,
$time2
);
}
return
$str
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment