Beispiel #1
0
 public function get_click($id)
 {
     //Are we even working with a number?
     if (!is_numeric($id)) {
         //Yikes let's get the hell out of here
         App::abort(404, 'Invalid click link');
     }
     //Now to pull our VA record or fail
     $va = User::find($id);
     if (empty($va)) {
         return Redirect::to('/')->with('topmessage', 'Sorry, that VA URL could not be located. Please try again and open a ticket if you continue experiencing the same issue.');
     }
     //Great a VA exists, let's make sure to add one to their clicks if this IP hasn't added a click within the last minute.
     $existingClick = Click::where('ip', '=', Request::getClientIp())->orderBy('created_at', 'DESC')->first();
     if (!empty($existingClick)) {
         $lastClickByIp = strtotime($existingClick->created_at);
         if (time() - $lastClickByIp > 60) {
             //No click found by the same IP in the last 60 seconds thus we should add this one
             $click = new Click();
             $click->vid = $id;
             $click->ip = Request::getClientIp();
             $click->save();
         }
     } else {
         //No click found by that same IP at all. Let's insert into the DB
         $click = new Click();
         $click->vid = $id;
         $click->ip = Request::getClientIp();
         $click->save();
     }
     //Finally redirect the user to the VA URL
     return Redirect::to($va->url);
 }
 public function index()
 {
     $vin = Input::get('vin', '');
     $vehicle = Vehicle::where('vin', '=', $vin)->first();
     $dealer = Dealer::where('id', '=', $vehicle->dealer)->first();
     $click = new Click();
     $click->vin = $vehicle->vin;
     $click->dealer = $dealer->dealer;
     $click->state = $vehicle->state;
     $click->datetime = date("Y-m-d H:i:s");
     $click->ip = $_SERVER['REMOTE_ADDR'];
     $click->paid = $vehicle->paid;
     $click->save();
     $dealer->current_clicks = $dealer->current_clicks + 1;
     if ($vehicle->paid > 0) {
         $dealer->paid_clicks = $dealer->paid_clicks + 1;
     }
     if ($dealer->active == 1 && $dealer->monthly_clicks <= $dealer->paid_clicks) {
         $dealer->active = 0;
         DB::table('vehicle')->where('dealer', $dealer->id)->update(array('paid' => 0, 'modified' => 1));
     }
     $dealer->save();
     return Redirect::to($vehicle->url);
 }
 public function clicked()
 {
     try {
         $inputs = [];
         foreach (Input::all() as $key => $value) {
             $inputs[strtolower($key)] = Input::get($key);
         }
         $apicall_id = explode('@', $inputs['message-id'])[0];
         if ($inputs['tag'] != 'Password Recovery') {
             $analytic = Analytic::whereRecipient($inputs['recipient'])->whereApicallId($apicall_id)->first();
             $click = Click::whereEmailId($analytic->email_id)->whereSubscriberId($analytic->subscriber_id)->whereUrl($inputs['url'])->count();
             if (!$click) {
                 $click = new Click();
                 $click->email_id = $analytic->email_id;
                 $click->subscriber_id = $analytic->subscriber_id;
                 $click->url = $inputs['url'];
                 $click->save();
                 if ($analytic->client_name == NULL) {
                     $analytic->ip = $inputs['ip'];
                     $analytic->country = $inputs['country'];
                     $analytic->city = $inputs['city'];
                     $analytic->client_name = $inputs['client-name'];
                     $analytic->client_type = $inputs['client-type'];
                     $analytic->client_os = $inputs['client-os'];
                     $analytic->device_type = $inputs['device-type'];
                     $analytic->reason = "disabled images";
                     $analytic->save();
                 }
             }
         }
         return Response::json(['success'], 200);
     } catch (Exception $e) {
         Log::error($e);
         return Response::json(['error'], 406);
     }
 }