Example #1
0
 public static function createAnonymous()
 {
     global $table;
     $user = new self();
     $res = queryGetRow("select id, unix_timestamp(ban_date) as ban_date from {$table['ip_data']} where ip = ?", $user->ip);
     if (!$res) {
         $id = $user->createIpRecord();
         if (!$id) {
             throw new Exception('Cannot create anonymous user');
         }
         $ban_date = 0;
     } else {
         $id = $res['id'];
         $ban_date = $res['ban_date'];
     }
     $data['id'] = 0;
     $user->aid = $id;
     $data['name'] = 'Anonymous' . $id;
     $data['role'] = 'user';
     $data['user_id_ban_date'] = 0;
     $data['ip_ban_date'] = $ban_date;
     $user->setData($data);
     return $user;
 }