Source code of filesite.io.
https://filesite.io
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
7 months ago
|
<?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);
|
||
|
}
|
||
|
|
||
|
}
|