Example #1
0
 /**
  * Check activity if an IP and determine if it should get blocked
  */
 protected function protectFromBots()
 {
     $userIP = app()->request->getClientIp();
     $todayStart = (new Carbon('now'))->startOfDay();
     $todayEnd = (new Carbon('now'))->endOfDay();
     $activityCount = Activity::whereIp($userIP)->whereBetween('created_at', [$todayStart, $todayEnd])->count();
     if ($activityCount >= Darkshare::$maxPerIp) {
         $this->blockSubmission();
     }
 }
Example #2
0
 public function recordActivity($event)
 {
     Activity::create(['subject_id' => $this->id, 'subject_type' => get_class($this), 'name' => $this->getActivityName($this, $event), 'user_id' => \Auth::id(), 'ip' => app()->request->getClientIp()]);
 }