|
@@ -104,9 +104,18 @@ class User extends Model{
|
|
|
*/
|
|
|
public function randOtherCode($id){
|
|
|
$info = $this->db()->field('short')->where("id", "<>", $id)->select();
|
|
|
+ return $this->getUserJsonFile($info);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function getUserJsonFile($info){
|
|
|
$r = rand(0, count($info)-1);
|
|
|
-
|
|
|
- return $info[$r]['short'];
|
|
|
+ $short = $info[$r]['short'];
|
|
|
+ $path = "load/$short.txt";
|
|
|
+ if(!file_exists($path)){
|
|
|
+ unset($info[$r]);
|
|
|
+ $short = $this->getUserJsonFile(array_values($info));
|
|
|
+ }
|
|
|
+ return $short;
|
|
|
}
|
|
|
|
|
|
/**
|