public function detectDevice() { // @ https://github.com/jenssegers/agent $agent = new Agent(); if ($agent->isMobile() || $agent->isTablet()) { if ($agent->is('android')) { return 'android'; } if ($agent->is('iOS')) { return 'ios'; } return $agent->platform(); } if ($agent->isDesktop()) { if ($agent->is('Windows')) { return 'windows'; } if ($agent->is('OS X')) { return 'OSX'; } return 'desktop'; } }
public function postAdd(Request $request, Agent $agent) { $data = $request->all(); $validation = Validator::make($data, Poster::getValidationRules()); if ($validation->fails()) { return view('message', ['OKs' => [], 'errors' => $validation->errors()->all()]); } $original_image_dir = 'images/original/'; $small_image_dir = 'images/small/'; $original_image_name = $original_image_dir . "no_image.jpg"; $small_image_name = $small_image_dir . "no_image_sml.jpg"; if ($request->hasFile('image')) { $time = time(); $original_image_name = $original_image_dir . $time . '.jpg'; $small_image_name = $small_image_dir . $time . '.jpg'; Image::make(Input::file('image'))->save($original_image_name)->resize(200, null, function ($constraint) { $constraint->aspectRatio(); })->save($small_image_name); } else { } $data['image'] = $original_image_name; $data['image_sml'] = $small_image_name; $data['author_ip'] = $request->getClientIp(); $data['author_browser'] = $agent->browser(); $data['author_country'] = "Ukraine"; Poster::create($data); return view('message', array('OKs' => ['Poster created'], 'errors' => [''])); }
/** * @param null $userAgent * @return null|string */ public function setAgentToDetector($userAgent = null) { if (is_null($userAgent)) { $this->agentDetector->setUserAgent($this->getUseragent()); } return $this->agentDetector->setUserAgent($userAgent); }
public function submit() { if (Input::get('rating') == 'one') { $rating = 1; } if (Input::get('rating') == 'two') { $rating = 2; } if (Input::get('rating') == 'three') { $rating = 3; } if (Input::get('rating') == 'four') { $rating = 4; } if (Input::get('rating') == 'five') { $rating = 5; } DB::table('restaurants_reviews')->insert(['restaurants_id' => Input::get('rid'), 'user_id' => 0, 'text' => 'qwe', 'review_text' => Input::get('text'), 'rating' => $rating, 'source' => 'RL', 'source_link' => 'RL', 'updated_at' => '', 'user_name' => 'Guest', 'user_location' => Session::get('geoip-location.city') . ', ' . Session::get('geoip-location.state'), 'spin_status' => 1]); echo '<script>alert("Thank You for your valuable review");</script>'; $data['restaurant'] = \App\Restaurants::where('permalink', '=', Input::get('rlink'))->take(1)->get(); $agent = new Agent(); if ($agent->isMobile()) { return \View::make('mobile_restaurant')->with('data', $data); } else { return \View::make('restaurant')->with('data', $data); } }
/** * Show the application welcome screen to the user. * * @return Response */ public function index() { DB::connection()->enableQueryLog(); $data['location'] = GeoIP::getLocation(); $l_city = $data['location']['city']; $l_state = $data['location']['state']; $agent = new Agent(); $get_city = \App\City::where('city', '=', $l_city)->take(1)->get(); if (count($get_city) != 0) { foreach ($get_city as $c) { $city = $c->id; } } else { $city = 894; $data['location']['city'] = 'Phoenix'; $data['location']['state'] = 'AZ'; } $data['recent_restaurants'] = \App\Restaurants::where('having_menu', '=', '1')->where('city_id', '=', $city)->orderBy(DB::raw('RAND()'))->take(4)->get(); $data['recent_reviews'] = \App\Restaurant_Reviews::orderBy(DB::raw('RAND()'))->leftJoin('restaurants', 'restaurants_reviews.restaurants_id', '=', 'restaurants.id')->leftJoin('city', 'restaurants.city_id', '=', 'city.id')->leftJoin('state', 'restaurants.state_id', '=', 'state.id')->take(6)->get(); //$data['nearest_zip'] = \App\Zip::where('zip', '>', (int)session('geoip-locations.postal_code')-10)->where('zip', '<', (int)session('geoip-locations.postal_code')+10) // ->take(5)->get(); //dd(DB::getQueryLog()); //dd($data['recent_reviews']); if ($agent->isMobile()) { return view('mobile_home')->with($data); } else { return view('home')->with($data); } }
/** * @param string $property * @return string|false */ public function getVersion($property) { $property = (string) $property; $cache = CM_Cache_Local::getInstance(); return $cache->get($cache->key(__METHOD__, $this->_headerList, $property), function () use($property) { return $this->_parser->version($property); }); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $agent = new Agent(); $set = Set::with('media', 'squares.purchase.media', 'content', 'rewards')->where('id', 1)->first(); if ($agent->isMobile() || $agent->isTablet()) { return view('public.mobile.index', ['set' => $set]); } return view('public.index', ['set' => $set]); }
public function index() { $agent = new Agent(); if ($agent->isMobile()) { return View::render($this->createView('DemoApp:frontend/index_mobile.html.twig'), array()); } else { return View::render($this->createView('DemoApp:frontend/index.html.twig'), array()); } }
public function access_channel() { $agent = new Agent(); if ($agent->isMobile()) { return "Mobile"; } elseif ($agent->isTablet()) { return "Tablet"; } else { return "Web"; } }
public function edit() { $agent = new Agent(); if ($agent->isMobile() or $agent->isTablet()) { $messages = 'This feature is disabled for Mobile and Tablet devices. If you want to change profile information, do it later from allowed devices.'; return redirect('/system/notification')->with('messages', $messages); } else { $name = \Auth::user()->name; $results = \DB::select('select * from users_data where name = ?', [$name]); return view('profile.edit')->with('results', $results); } }
public function testDevices() { $agent = new Agent(); foreach ($this->devices as $device => $ua) { $agent->setUserAgent($ua); $this->assertTrue($agent->isMobile()); $this->assertEquals($device, $agent->device()); if (!strpos($device, ' ')) { $method = "is{$device}"; $this->assertTrue($agent->{$method}()); } } }
public function create() { $agent = new Agent(); if ($agent->isMobile() or $agent->isTablet()) { $messages = 'This feature is disabled for Mobile and Tablet devices. If you want to make a publication do it later from allowed devices.'; return redirect('/system/notification')->with('messages', $messages); } else { if (\Auth::user()->suspend == true) { $messages = 'You are now suspended. Suspended users cannot publish contents.'; return redirect('/system/notification')->with('messages', $messages); } else { return view('publication.create'); } } }
public function index() { $agent = new Agent(); if (Auth::check()) { if (Auth::user()->email === NULL) { return view('base.referral'); } if ($agent->isMobile() or $agent->isTablet()) { return view('base.nomobile'); } $users = User::orderBy('id', 'desc')->take(50)->get(); return view('base.home', compact('users')); } return view('welcome'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $agent = new Agent(); // Определяем устройство и устанавливаем пути к js контроллерам и видам if ($agent->isMobile()) { \Config::set('js-controllers.path_controllers', 'dist/main/ng'); \Config::set('js-controllers.path_js_files', 'dist/main/js'); \View::addLocation(realpath(base_path('resources/views/mobile'))); } else { \Config::set('js-controllers.path_controllers', 'dist/main/ng'); \Config::set('js-controllers.path_js_files', 'dist/main/js'); \View::addLocation(realpath(base_path('resources/views/desktop'))); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $response = ['status' => 'ERROR', 'message' => '', 'data' => []]; $ua_hashed = md5('ua_' . $request->server('HTTP_USER_AGENT')); if (!Cache::has($ua_hashed)) { $agent = new Agent(); $is_bot = $agent->isRobot(); Cache::forever($ua_hashed, $is_bot); } else { $is_bot = Cache::get($ua_hashed); } if ($is_bot) { $response['message'] = 'Bot request is not allowed.'; return response()->json($response, 403); } return $next($request); }
/** * Display the home page. * * @return Response */ public function index(Guard $auth) { // $agent = new Agent(); $desk = $device = $agent->isMobile(); if ($desk == 1) { $desk = "mobile"; } else { $desk = "desk"; } Session::put('device', $desk); if ($auth->check()) { $user = $auth->user(); // $view = view('RegistroOperadores.registroStep1'); // revisar debe redirecccionar a otro lado return redirect('/myProfileOp')->with('user', $user->id); } else { $view = view('auth.completeRegister'); } return $view; }
public static function cc($request, $action, $option = []) { $agent = new Agent(); $platform = $agent->platform(); $platform_v = $agent->version($platform); $browser = $agent->browser(); $browser_v = $agent->version($browser); $device = $agent->device(); $charge_fee = 0; $charge_diamond = 0; $charge_datas = ''; $charge_explanation = ''; switch ($action) { case 'charge': $charge_fee = $option['fee']; $charge_diamond = $charge_fee * 1; $charge_explanation = '您于' . date('Y-m-d H:i:s') . '充值了 ¥' . $charge_fee . ' 获得了 ' . $charge_diamond . '颗勤云石'; break; case 'consume:vip': $charge_diamond = -60; $charge_datas = $option['datas']; $charge_explanation = '您于' . date('Y-m-d H:i:s') . '消费了 ' . $charge_diamond . '颗勤云石,购买了VIP会员' . $charge_datas . '个月'; break; case 'bequeath:signup': $charge_diamond = 18; $charge_explanation = '感谢您与' . date('Y-m-d H:i:s') . '注册本网站,系统自动赠送您' . $charge_diamond . '颗宝石'; break; case 'bequeath:invited': $charge_diamond = 18; $charge_explanation = '感谢您分享了本网站的注册链接给好友,好友已经注册本网站,系统自动赠送您' . $charge_diamond . '颗宝石'; break; } return self::create(['charge_cuid' => isset($option['userCreated']) ? $option['userCreated']->user_id : 0, 'charge_ruid' => $option['userRelated']->user_id, 'charge_action' => $action, 'charge_datas' => $charge_datas, 'charge_diamond' => $charge_diamond, 'charge_fee' => $charge_fee, 'charge_explanation' => $charge_explanation, 'charge_ip' => ip2long($request->ip()), 'charge_device' => $device, 'charge_system' => $platform, 'charge_system_v' => $platform_v, 'charge_browser' => $browser, 'charge_browser_v' => $browser_v]); }
public static function cc($request, $user, $action) { $agent = new Agent(); $platform = $agent->platform(); $platform_v = $agent->version($platform); $browser = $agent->browser(); $browser_v = $agent->version($browser); $device = $agent->device(); switch ($action) { case 'login': $mylog_content = $user->user_email . '于' . date('Y-m-d H:i:s') . '进行登录操作'; break; case 'logout': $mylog_content = $user->user_email . '于' . date('Y-m-d H:i:s') . '进行登出操作'; break; case 'signup': $mylog_content = $user->user_email . '于' . date('Y-m-d H:i:s') . '注册本网站'; break; case 'user:confirm': $mylog_content = $user->user_email . '于' . date('Y-m-d H:i:s') . '进行用户验证'; break; case 'user:password_update': $mylog_content = date('Y-m-d H:i:s') . ' 修改了账号密码'; break; default: $mylog_content = ''; break; } return self::create(['mylog_cuid' => $user->user_id, 'mylog_action' => $action, 'mylog_content' => $mylog_content, 'mylog_ip' => ip2long($request->ip()), 'mylog_device' => $device, 'mylog_system' => $platform, 'mylog_system_v' => $platform_v, 'mylog_browser' => $browser, 'mylog_browser_v' => $browser_v]); }
/** * @medium * @dataProvider userAgentData */ public function testUserAgents($userAgent, $isMobile, $isTablet, $version, $model, $vendor) { //make sure we're passed valid data if (!is_string($userAgent) || !is_bool($isMobile) || !is_bool($isTablet)) { $this->markTestIncomplete("The User-Agent {$userAgent} does not have sufficient information for testing."); return; } //setup $md = new Agent(); $md->setUserAgent($userAgent); //is mobile? $this->assertEquals($md->isMobile(), $isMobile); //is tablet? $this->assertEquals($md->isTablet(), $isTablet); if (isset($version)) { foreach ($version as $condition => $assertion) { $this->assertEquals($assertion, $md->version($condition), 'FAILED UA (version("' . $condition . '")): ' . $userAgent); } } //version property tests if (isset($version)) { foreach ($version as $property => $stringVersion) { $v = $md->version($property); $this->assertSame($stringVersion, $v); } } //@todo: model test, not sure how exactly yet //@todo: vendor test. The below is theoretical, but fails 50% of the tests... /*if (isset($vendor)) { $method = "is$vendor"; $this->assertTrue($md->{$method}(), "Expected Mobile_Detect::{$method}() to be true."); }*/ }
public function downloadfileAction($fileid) { $agent = new Agent(); if ($agent->isMobile() || $agent->isTablet()) { $params = app('\\Aimeos\\Shop\\Base\\Page')->getSections('no-mobile-page'); return \View::make('shop::page.nomobile', $params); } $user = Auth::user(); $context = \App::make('\\Aimeos\\Shop\\Base\\Context')->get(); $dlManager = \MShop_Factory::createManager($context, 'download'); $search = $dlManager->createSearch(true); $expr = array($search->compare('==', 'download.fileid', $fileid), $search->compare('==', 'download.userid', $user->id), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); $dlList = $dlManager->searchItems($search); $download = reset($dlList); $relPath = $download->getUrl(); $disk = Storage::disk(config('shop.distros.drivename')); $filename = substr(strrchr($relPath, "/"), 1); $filesize = $disk->size($relPath); $expDate = Carbon::parse($download->getTimeCreated())->addDays(config('shop.distros.max-time')); $expiration = $expDate->toFormattedDateString(); $today = Carbon::now(); $downloadtotal = config('shop.distros.max-downloads'); $downloadcount = $download->getDownloads(); $params = app('\\Aimeos\\Shop\\Base\\Page')->getSections('download-page'); $params['fileid'] = $fileid; $params['filename'] = $filename; $params['filesize'] = $filesize; $params['downloadtotal'] = $downloadtotal; $params['downloadcount'] = $downloadcount; if ($today->gt($expDate) || $downloadcount >= $downloadtotal) { $params['expiration'] = 'Expired'; } else { $params['expiration'] = $expiration; } return \View::make('shop::page.download', $params); }
/** * Register any application authentication / authorization services. * * @param \Illuminate\Contracts\Auth\Access\Gate $gate * @return void */ public function boot(GateContract $gate) { $this->registerPolicies($gate); $gate->define('crud-users', function () { return \Auth::user()->isAdmin(); }); $gate->define('auth', function () { return \Auth::check(); }); $gate->define('home', function () { return Request::path() === '/' || Request::path() == 'home' || Request::path() == '' ? true : false; }); $gate->define('admin/users', function () { return strpos(Request::path(), 'admin/users') === false ? true : false; }); $gate->define('ismobile', function () { $agent = new Agent(); return $agent->isMobile(); }); $gate->define('isphone', function () { $agent = new Agent(); return $agent->isPhone(); }); }
public function testVersions() { $agent = new Agent(); foreach ($this->browserVersions as $version => $ua) { $agent->setUserAgent($ua); $browser = $agent->browser(); $this->assertEquals($version, $agent->version($browser)); } foreach ($this->operatingSystemVersions as $version => $ua) { $agent->setUserAgent($ua); $platform = $agent->platform(); $this->assertEquals($version, $agent->version($platform)); } }
public function insertUserInformation($ipAddress, $userAgentString, $sapiName, GeocoderResult $geocoderResult = null) { $userAgent = new UserAgent(); $userAgent->setUserAgent($userAgentString); $browser = $userAgent->browser(); $platform = $userAgent->platform(); $data = ['ip_address' => $ipAddress, 'sapi_name' => substr($sapiName, 0, 32), 'user_agent' => substr($userAgentString, 0, 255), 'user_agent_browser' => substr($browser, 0, 32), 'user_agent_device' => substr($userAgent->device(), 0, 32), 'user_agent_browser_version' => substr($userAgent->version($browser), 0, 32), 'user_agent_platform_version' => substr($userAgent->version($platform), 0, 32), 'user_agent_platform' => substr($platform, 0, 32), 'user_agent_robot' => substr($userAgent->robot(), 0, 32)]; if ($geocoderResult) { $region = $geocoderResult->getAdminLevels()->first(); $data['geo_city'] = substr($geocoderResult->getLocality(), 0, 32); $data['geo_region'] = $region ? substr($region->getCode(), 0, 32) : null; $data['geo_country'] = substr($geocoderResult->getCountry(), 0, 32); $data['geo_country_code'] = substr($geocoderResult->getCountryCode(), 0, 6); $data['geo_latitude'] = substr($geocoderResult->getLatitude(), 0, 32); $data['geo_longitude'] = substr($geocoderResult->getLongitude(), 0, 32); } $this->getAdapter()->insert('dewdrop_activity_log_user_information', $data); return $this->getAdapter()->lastInsertId(); }
public function store($inputs) { $contact = new $this->model(); $contact->name = $inputs['name']; $contact->email = $inputs['email']; $contact->text = $inputs['message']; $contact->ip = \Request::ip(); $agent = new Agent(); $lang = $agent->languages(); $lang = implode(",", $lang); $platform = $agent->platform(); $version_p = $agent->version($platform); $device = $agent->device(); $browser = $agent->browser(); $version_b = $agent->version($browser); $contact->agent = $platform . $version_p . "|" . $device . "|" . $browser . $version_b . "|" . $lang; $contact->save(); }
public function postFSave(FSavePRequest $request, $user_email, $form_url) { $user = User::where('user_email', base64_decode($user_email))->where('user_active', '1')->firstOrFail(); $form = $user->Form()->where('form_url', $form_url)->where('form_active', 1)->firstOrFail(); if (!$form->canWrite()) { return redirect()->back()->with('msgError', '表单已经超过填写人数的最大限制了'); } $agent = new Agent(); $platform = $agent->platform(); $platform_v = $agent->version($platform); $browser = $agent->browser(); $browser_v = $agent->version($browser); $device = $agent->device(); $result = Result::create(['result_ruid' => Auth::check() ? Auth::id() : 0, 'result_form_id' => $form->form_id, 'result_ip' => ip2long($request->ip()), 'result_device' => $device, 'result_system' => $platform, 'result_system_v' => $platform_v, 'result_browser' => $browser, 'result_browser_v' => $browser_v]); if ($result) { //插入数据 $fields = $form->Field()->orderBy('field_sort', 'ASC')->get(); $splitStr = ':$split$:'; $user_id = Auth::check() ? Auth::id() : 0; foreach ($fields as $field) { $inputs = $request->input($field->field_attr_name); if (is_array($inputs)) { if ($field->field_type == 'group:shop-thumbnail') { $rows = []; foreach ($inputs as $input) { $rows[] = $input['goods_name'] . '(' . $input['goods_preice'] . '):' . $input['goods_num']; } $resultrow_attr_value = implode($splitStr, $rows); } else { $resultrow_attr_value = implode($splitStr, $inputs); } } else { $resultrow_attr_value = $inputs; } ResultRow::create(['resultrow_ruid' => $user_id, 'resultrow_result_id' => $result->result_id, 'resultrow_sort' => $field->field_sort, 'resultrow_type' => $field->field_type, 'resultrow_title' => $field->field_title, 'resultrow_tips' => $field->field_tips, 'resultrow_attr_name' => $field->field_attr_name, 'resultrow_attr_value' => $resultrow_attr_value]); } // 发送邮件提示 if ($form->form_tips_email) { $email = Email::create(['email_cuid' => 0, 'email_ruid' => $user->user_id, 'email_block' => 'form_reply_tips', 'email_target' => $user->user_email, 'email_title' => '[ ' . WEBSITE_NAME . ' ]提示您:您的表单有了新的回复', 'email_datas' => $form->form_code, 'email_is_sent' => 0]); $this->dispatch(new SendReminderEmail($email)); } $res = redirect('/u/' . $user_email . '/f-success')->with('msgSuccess', '您的表单已经成功提交,感谢您的参与。'); } else { $res = redirect()->back()->with('msgError', MSG_FA); } return $res; }
/** * Redirect to long url * @return rediect to long url */ public function redirect(Request $request, $shortUrl) { $agent = new Agent(); $agent->setUserAgent($request->headers); $urls = Url::where('short_url', '=', $shortUrl)->get(); if (!$urls->first()) { echo "Not Found"; return; } $url = $urls[0]; $longUrl = $url['long_url']; $url->clicks = $url['clicks'] + 1; $url->save(); $url->hits()->create(['client_ip' => $_SERVER['REMOTE_ADDR'], 'language' => $agent->languages()[0], 'device' => $agent->device(), 'platform' => $agent->platform(), 'browser' => $agent->browser()]); //$agent->languages()[0],$agent->device(), $agent->platform(),$agent->browser(),$agent->robot();;;; return redirect($url['long_url']); }
public function getPlatform() { if ($this->agent->isPhone()) { return 'phone'; } if ($this->agent->isTablet()) { return 'tablet'; } if ($this->agent->isMobile()) { return 'mobile'; } if ($this->agent->isDesktop()) { return 'desktop'; } if ($this->agent->isRobot()) { return 'robot'; } return null; }
public static function saveSession() { $session_id = uniqid(); Session::put('session_id', $session_id); $agent = new Agent(); $browser = $agent->browser(); $version = $agent->version($browser); $platform = $agent->platform(); $versionpla = $agent->version($platform); $device = $agent->device(); $session = new SaveSession(); $session->browser = $browser; $session->version = $version; $session->platform = $browser; $session->versionpla = $versionpla; $session->device = $device; //$session->ip = $request->ip; $session->cookie = $session_id; $session->save(); }
function is_mobile() { $agent = new Agent(); return $agent->isMobile(); }
public function setUserAgentAttribute($value) { $agent = new Agent(); $agent->setUserAgent($value); if ($agent->isDesktop()) { $platform = 'Desktop'; } elseif ($agent->isMobile()) { if ($agent->isTablet()) { $platform = 'Tablet'; } else { $platform = 'Mobile'; } } $this->attributes['remote_platform'] = $platform; $this->attributes['user_agent'] = $value; }