filesite
7 months ago
5 changed files with 71 additions and 10 deletions
@ -0,0 +1,34 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* 常用的公用方法 |
||||||
|
*/ |
||||||
|
Class Common { |
||||||
|
public static function isCellphoneNumber($number) { |
||||||
|
return preg_match("/^1[3456789][0-9]{9}$/", $number); |
||||||
|
} |
||||||
|
|
||||||
|
//朋友手机号码的末 6 位 |
||||||
|
public static function isFriendsCode($number) { |
||||||
|
return preg_match("/^[0-9]{6}$/", $number); |
||||||
|
} |
||||||
|
|
||||||
|
//用户注册成功后,保存他的手机号码 6 位尾号作为邀请码 |
||||||
|
protected function saveFriendsCode($cellphone) { |
||||||
|
$logTime = date('Y-m-d H:i:s'); |
||||||
|
$logDir = __DIR__ . '/../runtime/friendscode/'; |
||||||
|
$logFilename = substr($cellphone, -6) . '.log'; |
||||||
|
$logOk = @error_log("{$logTime} created\n", 3, "{$logDir}{$logFilename}"); |
||||||
|
if (!$logOk) { //try to mkdir |
||||||
|
@mkdir($logDir, 0700, true); |
||||||
|
@error_log("{$logTime} created\n", 3, "{$logDir}{$logFilename}"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected function existFriendsCode($code) { |
||||||
|
if (self::isFriendsCode($code) == false) {return false;} |
||||||
|
$logDir = __DIR__ . '/../runtime/friendscode/'; |
||||||
|
$logFilename = "{$logDir}{$code}.log"; |
||||||
|
return file_exists($logFilename); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue