Guest User

Untitled

a guest
Sep 26th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.18 KB | None | 0 0
  1. <meta charset="utf-8">
  2.  
  3. @if( App::environment('local') )
  4. <title>local</title>
  5. @else
  6. <title>Bunlong Heng</title>
  7. @endif
  8.  
  9.  
  10. <meta charset="utf-8">
  11. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  12. <meta name="viewport" content="width=device-width, initial-scale=1">
  13. <meta name="author" content="Bunlong Heng">
  14. <meta name="csrf-token" value="{{ csrf_token() }}">
  15.  
  16.  
  17. <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
  18. <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
  19. <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
  20. <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
  21.  
  22.  
  23.  
  24.  
  25. <!-- HTML5 shiv and Respond.js IE8 support of HTML5 elements and media queries -->
  26.  
  27. <!--[if lt IE 9]>
  28. <script src="js/plugins/html5shiv.js"></script>
  29. <script src="js/plugins/respond.min.js"></script>
  30. <![endif]-->
  31.  
  32.  
  33. <?php
  34.  
  35. use AppVisitor, AppCURLexec;
  36.  
  37. if (!function_exists('getallheaders'))
  38. {
  39. function getallheaders()
  40. {
  41.  
  42. $headers = '';
  43. foreach ($_SERVER as $name => $value)
  44. {
  45. if (substr($name, 0, 5) == 'HTTP_')
  46. {
  47. $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
  48. }
  49. }
  50. return $headers;
  51. }
  52. }
  53.  
  54.  
  55. $ip = trim(shell_exec("dig +short myip.opendns.com @resolver1.opendns.com")); Debug::console($ip);
  56. $ip = $_SERVER['REMOTE_ADDR'];
  57. $info = shell_exec('curl ipinfo.io/'.$ip );
  58. $ip_info_array = json_decode($info,true);
  59.  
  60. $header_info = getallheaders();
  61. $loc = isset($ip_info_array['loc'])? $ip_info_array['loc'] : '';
  62. $url = 'https://maps.google.com/maps/api/geocode/json?latlng='. $loc .'&sensor=false';
  63. $geocode_array = CURLexec::get($url);
  64. $formatted_address = isset($geocode_array['results']['0']['formatted_address'])? $geocode_array['results']['0']['formatted_address'] : '';
  65. $place_id = isset($geocode_array['results']['0']['place_id'])? $geocode_array['results']['0']['place_id'] :'';
  66.  
  67. $formatted_address = isset($geocode_array['results']['0']['formatted_address'])? $geocode_array['results']['0']['formatted_address'] : '';
  68. $place_id = isset($geocode_array['results']['0']['place_id'])? $geocode_array['results']['0']['place_id'] : '';
  69. //Mac Address + Inet
  70. $env = Request::server ("HTTP_HOST"); //localhost:8888
  71.  
  72. if ($env == 'localhost:8888'){
  73. //Local
  74. $inet = trim(shell_exec("ifconfig en0 | grep 'netmask' | awk '{print $2}'"),"n");
  75. $grab_bssid_command = 'arp '.$inet.' | awk '{print $4}'';
  76. $bssid = trim(shell_exec($grab_bssid_command), "n");
  77.  
  78. }else{
  79.  
  80. //Other Machine/Server
  81. $inet = $ip;
  82. $grab_bssid_command = 'arp '.$inet.' | awk '{print $4}'';
  83. // dd($grab_bssid_command);
  84. $bssid = trim(shell_exec($grab_bssid_command), "n");
  85.  
  86. }
  87.  
  88.  
  89. // LatLong Map http://maps.google.com/?q=-27.0000,133.0000
  90. // Static Map = http://maps.google.com/maps/api/staticmap?center=40.7421,-74.0018&zoom=13&size=500x300
  91. $static_map_url = 'https://maps.google.com/maps/api/staticmap?center='. $loc.'&zoom=13&size=500x300&maptype=roadmap&scale=2
  92. &markers=size:mid|color:red|'. $loc .'|size:small';
  93.  
  94. $map_url = 'https://maps.google.com/?q='. $loc;
  95.  
  96.  
  97.  
  98. $ip = isset($ip_info_array['ip'])? $ip_info_array['ip'] : '';
  99. $host_name = isset($ip_info_array['hostname'])? $ip_info_array['hostname'] : '';
  100. $city = isset($ip_info_array['city'])? $ip_info_array['city'] : '';
  101. $region = isset($ip_info_array['region'])? $ip_info_array['region'] : '';
  102. $country = isset($ip_info_array['country'])? $ip_info_array['country'] : '';
  103. $org = isset($ip_info_array['org'])? $ip_info_array['org'] : '';
  104. $postal = isset($ip_info_array['postal'])? $ip_info_array['postal'] : '';
  105.  
  106. //User Agent
  107. $user_agent_info = isset($header_info['User-Agent'])? $header_info['User-Agent'] : '';
  108. $user_agent_array = ( explode(";",$user_agent_info));
  109.  
  110. //OS
  111. $os_array = explode(")",$user_agent_array[1]);
  112. $os = str_replace('_','.',$os_array[0]); //
  113. $os_version = preg_replace("/[^d.]/", '', $os); //10.10.5
  114.  
  115.  
  116. if(array_key_exists(1,$os_array)){
  117. if($os_array[1] !== ''){
  118. $webkit_array = explode(" ",$os_array[1]);
  119. }else{
  120. $webkit_array = '';
  121. }
  122.  
  123. }else{
  124. $webkit_array = '';
  125. }
  126.  
  127. if($webkit_array == ''){
  128. $web_kit = '';
  129. }else{
  130. $web_kit = $webkit_array[1];
  131. }
  132.  
  133.  
  134. /*================================
  135. = Browsers =
  136. ================================*/
  137. if(array_key_exists(2,$os_array)){
  138. if($os_array[2] !== ''){
  139. $browsers = explode(")",$os_array[2]);
  140. }else{
  141. $browsers = '';
  142. }
  143. }else{
  144. $browsers = '';
  145. }
  146.  
  147. if($browsers == ''){
  148. $browser_array = '';
  149. $chrome = '';
  150. $safari = '';
  151. }else{
  152. $browser_array = explode(" ",$browsers[0]);
  153. $chrome = $browser_array[1];
  154. if(array_key_exists(2,$browser_array)){
  155. $safari = $browser_array[2]; //bug
  156. }else{
  157. $safari = '';
  158. }
  159.  
  160. }
  161.  
  162.  
  163. //Agent
  164. $agent_os_array = explode("(",$user_agent_array[0]);
  165. $agent = $agent_os_array[0]; // Mozilla/5.0
  166. $device = $agent_os_array[1]; // Macintosh
  167.  
  168.  
  169.  
  170. // Check for existing
  171. $validator = Visitor::validator($ip);
  172.  
  173. if ($validator->fails()) {
  174.  
  175. $ip = Visitor::where('ip', '=', $ip)->firstOrFail();
  176. $id = $ip['attributes']['id'];
  177.  
  178. if($ip){
  179.  
  180. $visitor = Visitor::findOrFail($id);
  181. $visitor->visit_count = $visitor->visit_count + 1 ;
  182. $visitor->save();
  183.  
  184. }
  185.  
  186. } else {
  187.  
  188. $visitor = new Visitor;
  189.  
  190. $visitor->ip = $ip;
  191. $visitor->host_name = $host_name;
  192. $visitor->city = $city;
  193. $visitor->region = $region;
  194. $visitor->country = $country;
  195. $visitor->loc = $loc;
  196. $visitor->org = $org;
  197. $visitor->postal = $postal;
  198. $visitor->static_map_url = $static_map_url ;
  199. $visitor->map_url = $map_url ;
  200. $visitor->address = $formatted_address ;
  201. $visitor->details = $place_id;
  202. $visitor->user_agent = $agent;
  203. $visitor->visit_count = $visitor->visit_count + 1 ;
  204. $visitor->device = $device;
  205. $visitor->os = $os;
  206. $visitor->os_version = $os_version;
  207. $visitor->browser_type = $agent;
  208. $visitor->chrome = $chrome;
  209. $visitor->safari = $safari;
  210. $visitor->web_kit = $web_kit;
  211. $visitor->inet = $inet;
  212. $visitor->bssid = $bssid;
  213. $visitor->save();
  214.  
  215. }
  216.  
  217. //dd($visitor);
  218. Debug::console($loc);
  219.  
  220. if(
  221.  
  222. $visitor->country == 'US' AND
  223. $visitor->ip != '76.119.248.198'
  224.  
  225. // $visitor->ip != '72.22.171.98'
  226. // AND substr($visitor->host_name) != 'crawl-'
  227. // AND substr($visitor->host_name) != 'spider'
  228.  
  229. ){
  230.  
  231. //Send Email to me
  232. $mail = Mail::send('layouts.share.emails.site_visit',
  233.  
  234. array(
  235. 'ip_info_array' => $ip_info_array,
  236. 'header_info' => $header_info,
  237. 'formatted_address' => $formatted_address,
  238. 'static_map_url' => $static_map_url
  239. ) ,
  240.  
  241. function ($ip_info_array) {
  242.  
  243. $ip_info_array->from(env('MAIL_USERNAME') , 'bheng gmail');
  244. $ip_info_array->to(env('MAIL_TO') , 'Bunlong's Site ')
  245. ->subject( ' Visit Alert : ' . Request::server ("HTTP_HOST"));
  246. });
  247.  
  248.  
  249. //Send Text Message to me, use the forward from the mail client, so we don't put weigh on the application index
  250.  
  251. }
  252.  
  253.  
  254.  
  255. ?>
  256.  
  257. use AppVisitor;
  258. use AppCURLexec;
Add Comment
Please, Sign In to add comment