|
|
@ -23,7 +23,7 @@ Class Common { |
|
|
|
return str_replace($findChars, '', $str); |
|
|
|
return str_replace($findChars, '', $str); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function isCellphoneNumber($number) { |
|
|
|
public static function isCellphoneNumber($number) { |
|
|
|
return preg_match("/^1[3456789][0-9]{9}$/", $number); |
|
|
|
return preg_match("/^1[3456789][0-9]{9}$/", $number); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -48,7 +48,7 @@ Class Common { |
|
|
|
$logOk = @error_log("{$logTime} invite {$cellphone}\n", 3, "{$logDir}{$friendsLogfile}"); |
|
|
|
$logOk = @error_log("{$logTime} invite {$cellphone}\n", 3, "{$logDir}{$friendsLogfile}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//保存用户多收藏夹目录映射配置 |
|
|
|
//保存用户多收藏夹目录映射关系 |
|
|
|
public static function saveUserDirMap($cellphone, $username, $new_dir) { |
|
|
|
public static function saveUserDirMap($cellphone, $username, $new_dir) { |
|
|
|
$my_user_map = self::getMyDirs($cellphone, $username); |
|
|
|
$my_user_map = self::getMyDirs($cellphone, $username); |
|
|
|
array_push($my_user_map, $new_dir); |
|
|
|
array_push($my_user_map, $new_dir); |
|
|
@ -70,6 +70,80 @@ Class Common { |
|
|
|
return $saved === false ? false : true; |
|
|
|
return $saved === false ? false : true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取用户共享目录记录 |
|
|
|
|
|
|
|
public static function getMyShareDirs($cellphone, $username) { |
|
|
|
|
|
|
|
$my_id = self::getUserId($cellphone); |
|
|
|
|
|
|
|
$rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory']; |
|
|
|
|
|
|
|
$rootDir = str_replace("/{$username}", "/{$my_id}", $rootDir); //获取自己的目录 |
|
|
|
|
|
|
|
if (!is_dir($rootDir)) { |
|
|
|
|
|
|
|
$my_first_id = self::getMappedUsername($cellphone); |
|
|
|
|
|
|
|
$rootDir = str_replace("/{$my_id}", "/{$my_first_id}", $rootDir); //获取自己的目录 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map = array(); |
|
|
|
|
|
|
|
if (is_dir($rootDir)) { |
|
|
|
|
|
|
|
$cache_filename = "{$rootDir}/share_dirs.json"; |
|
|
|
|
|
|
|
if (file_exists($cache_filename)) { |
|
|
|
|
|
|
|
$json = file_get_contents($cache_filename); |
|
|
|
|
|
|
|
$map = json_decode($json, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $map; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//保存用户共享目录记录 |
|
|
|
|
|
|
|
public static function saveMyShareDirs($cellphone, $username, $friends_cellphone, $share_dir) { |
|
|
|
|
|
|
|
$shareDirs = self::getMyShareDirs($cellphone, $username); |
|
|
|
|
|
|
|
if (empty($shareDirs) || empty($shareDirs[$friends_cellphone])) { |
|
|
|
|
|
|
|
$shareDirs[$friends_cellphone] = array($share_dir); |
|
|
|
|
|
|
|
}else if(!in_array($share_dir, $shareDirs[$friends_cellphone])) { |
|
|
|
|
|
|
|
array_push($shareDirs[$friends_cellphone], $share_dir); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$my_id = self::getUserId($cellphone); |
|
|
|
|
|
|
|
$rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory']; |
|
|
|
|
|
|
|
$rootDir = str_replace("/{$username}", "/{$my_id}", $rootDir); //获取自己的目录 |
|
|
|
|
|
|
|
if (!is_dir($rootDir)) { |
|
|
|
|
|
|
|
$my_first_id = self::getMappedUsername($cellphone); |
|
|
|
|
|
|
|
$rootDir = str_replace("/{$my_id}", "/{$my_first_id}", $rootDir); //获取自己的目录 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$saved = false; |
|
|
|
|
|
|
|
if (is_dir($rootDir)) { |
|
|
|
|
|
|
|
$cache_filename = "{$rootDir}/share_dirs.json"; |
|
|
|
|
|
|
|
$saved = file_put_contents($cache_filename, json_encode($shareDirs, JSON_PRETTY_PRINT)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $saved === false ? false : true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//从用户共享目录记录里删除一个共享 |
|
|
|
|
|
|
|
public static function deleteFromMyShareDirs($cellphone, $username, $friends_cellphone, $share_dir) { |
|
|
|
|
|
|
|
$shareDirs = self::getMyShareDirs($cellphone, $username); |
|
|
|
|
|
|
|
if(!empty($shareDirs[$friends_cellphone]) && in_array($share_dir, $shareDirs[$friends_cellphone])) { |
|
|
|
|
|
|
|
$shareDirs[$friends_cellphone] = array_diff($shareDirs[$friends_cellphone], array($share_dir)); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$my_id = self::getUserId($cellphone); |
|
|
|
|
|
|
|
$rootDir = __DIR__ . '/../www/' . FSC::$app['config']['content_directory']; |
|
|
|
|
|
|
|
$rootDir = str_replace("/{$username}", "/{$my_id}", $rootDir); //获取自己的目录 |
|
|
|
|
|
|
|
if (!is_dir($rootDir)) { |
|
|
|
|
|
|
|
$my_first_id = self::getMappedUsername($cellphone); |
|
|
|
|
|
|
|
$rootDir = str_replace("/{$my_id}", "/{$my_first_id}", $rootDir); //获取自己的目录 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$saved = false; |
|
|
|
|
|
|
|
if (is_dir($rootDir)) { |
|
|
|
|
|
|
|
$cache_filename = "{$rootDir}/share_dirs.json"; |
|
|
|
|
|
|
|
$saved = file_put_contents($cache_filename, json_encode($shareDirs, JSON_PRETTY_PRINT)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $saved === false ? false : true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取新收藏夹目录名 |
|
|
|
//获取新收藏夹目录名 |
|
|
|
public static function getNewFavDir($cellphone) { |
|
|
|
public static function getNewFavDir($cellphone) { |
|
|
|
$new_dir = 2000; //默认从编号2000开始 |
|
|
|
$new_dir = 2000; //默认从编号2000开始 |
|
|
@ -403,4 +477,8 @@ Class Common { |
|
|
|
return $url; |
|
|
|
return $url; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function maskCellphone($cellphone) { |
|
|
|
|
|
|
|
return preg_replace("/^(.{3,})\d{4}(.{4})$/i", '$1****$2', $cellphone); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |