Ejemplo n.º 1
0
 public function post_ban()
 {
     if (Request::ajax()) {
         $error = '';
         $get = Input::all();
         $banUsername = $get['bUsername'];
         $banReason = $get['bReason'];
         $user = User::where('username', '=', $banUsername)->first();
         // belki kullanıcı zaten banlı olabilir.admin değğilse tekrar banlayamasın
         if ($user->username == Sentry::user()->username) {
             $error = 'Lütfen kendinizi banlamayınız.';
             die("ban");
         }
         $ban = $user->bans()->first();
         // Kullanıcı Zaten Banlıysa,bitiş tarihini geri döndür.
         if ($ban) {
             die($ban->ban_end);
         }
         // Güvenlik Koaaaaaaaaaaaaaaaaaaaaaaaaantrolü
         $date = date('Y-m-d H:i:s');
         $bandate = date('Y-m-d H:i:s', strtotime('+1 day', strtotime($date)));
         $banData = Ban::create(array('user_id' => $user->id, 'ban_ip' => $user->ip_address, 'ban_email' => $user->user_email, 'ban_start' => $date, 'ban_end' => $bandate, 'ban_reason' => $banReason, 'ban_moderatorid' => Sentry::user()->id));
         die("OK");
     }
 }
Ejemplo n.º 2
0
 public function block()
 {
     $this->user = User::find($this->params()->id);
     if ($this->request()->isPost()) {
         if ($this->user->is_mod_or_higher()) {
             $this->notice("You can not ban other moderators or administrators");
             $this->redirectTo(['#block', 'id' => $this->params()->id]);
             return;
         }
         !is_array($this->params()->ban) && ($this->params()->ban = []);
         $attrs = array_merge($this->params()->ban, ['banned_by' => current_user()->id, 'user_id' => $this->params()->id]);
         Ban::create($attrs);
         $this->redirectTo('#show_blocked_users');
     } else {
         $this->ban = new Ban(['user_id' => $this->user->id, 'duration' => "1"]);
     }
 }