Esempio n. 1
0
 public function fire()
 {
     $subscriptionCheck = new SubscriptionCheck(-1);
     Cache::forever('last_checked_subscription', $subscriptionCheck->setSubscription());
     if (!$subscriptionCheck->run()) {
         // $subscriptionCheck->errorMessage();
         return;
         // Todo: Log this
     }
     // send mail if email exists
     $subscriptionCheck->sendEmail(function ($email, $profiles) {
         Mail::send('emails.hacker', ['profiles' => $profiles], function ($message) use($email) {
             $message->to($email)->subject('Bans were found from your subscribed lists!');
         });
     });
     // just like sending email, send pushbullet if the subscribed user has it
     $subscriptionCheck->sendPushBullet(function ($email, $profiles) {
         $pushbullet = new PHPushbullet(env('PUSHBULLET_API'));
         $message = "";
         foreach ($profiles as $k => $profile) {
             if ($k + 1 != count($profiles)) {
                 $message .= $profile->display_name . ", ";
             } else {
                 $message .= (count($profiles) > 1 ? "and " : "") . $profile->display_name;
             }
         }
         $message .= (count($profiles) > 1 ? " were " : " was") . " Trade, Community, and/or VAC banned from your lists";
         $pushbullet->user($email)->note("Bans were found from your subscribed lists!", $message);
     });
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function track($id, $uniqid)
 {
     $email = Email::where('id', $id)->where('uniqid', $uniqid)->first();
     // If email is found
     if ($email) {
         // Get data
         $ip = $_SERVER['REMOTE_ADDR'];
         $host = gethostbyaddr($ip);
         $user_agent = $_SERVER['HTTP_USER_AGENT'];
         $country = @geoip_country_name_by_name($ip);
         if (!$country) {
             $country = null;
         }
         $validator = EmailTracking::validate(array('ip' => $ip, 'host' => $host, 'user_agent' => $user_agent, 'country' => $country));
         if ($validator->passes()) {
             $tracking = new EmailTracking();
             $tracking->ip = $ip;
             $tracking->host = $host;
             $tracking->user_agent = $user_agent;
             $tracking->country = $country;
             $tracking->save();
             $email->email_trackings()->save($tracking);
             // Attach tracking to email
             // Send pushbullet notification
             $user = $email->user;
             if ($user->pushbullet && $ip != env('IGNORE_IP', 'null')) {
                 $pushbullet = new PHPushbullet($user->pushbullet_api_key);
                 $message = 'Your email "' . $email->title . '" has been read by ' . $ip . ' (' . $host . ' - ' . $country . ').';
                 $pushbullet->device($user->pushbullet_device)->note($email->title, $message);
             }
             // Return pixel
             $response = Response::make(File::get(Config::get('mail_tracker.pixel_file')));
             $response->header('Content-Type', 'image/gif');
             return $response;
         }
         // Otherwise, log error
         abort(500, 'Something went wrong...');
     }
     // Otherwise, exit
     abort(404, 'Email not found!');
 }
 public function __construct($access_token = null)
 {
     parent::__construct($access_token, null, ['verify' => false]);
 }
 /**
  * Send a test notification
  *
  * @return Redirect
  */
 public function sendTestNotification()
 {
     $user = User::find(Auth::id());
     // If user found
     if ($user) {
         if ($user->pushbullet_api_key && $user->pushbullet_device) {
             // If api key and device are defined
             $pushbullet = new PHPushbullet($user->pushbullet_api_key);
             $message = 'This is a test notification from Mail Tracker';
             $pushbullet->device($user->pushbullet_device)->note('Mail Tracker', $message);
             Session::flash('pushbullet_info', 'Test notification sent to ' . $user->pushbullet_device . '!');
         } else {
             Session::flash('pushbullet_error', 'Please verify Pushbullet settings.');
         }
     }
     // Return to user profile
     return Redirect::action('Admin\\AdminUserController@edit');
 }
Esempio n. 5
0
 /**
  * pushes a report from the given account to the devices
  * @param $reportTitle
  * @param $reportBody
  * @param $account
  */
 public function pushReport($reportTitle, $reportBody, $account)
 {
     $pushKeys = $this->getPushBulletKeys();
     foreach ($pushKeys as $pushKey) {
         if ($pushKey['accounts'] == null || in_array($account, $pushKey['accounts'])) {
             $pushBullet = new PHPushbullet($pushKey['key']);
             if ($pushKey['devices'] == null) {
                 // pushes to all of the devices
                 foreach ($pushBullet->devices() as $device) {
                     $pushBullet->device($device->iden)->note($reportTitle, $reportBody);
                 }
             } else {
                 // pushes to selected devices
                 foreach ($pushKey['devices'] as $device) {
                     $pushBullet->device($device)->note($reportTitle, $reportBody);
                 }
             }
         }
     }
 }