user-agent

How to only allow one user agent on .htaccess?

青春壹個敷衍的年華 提交于 2019-12-04 22:11:09
问题 I have been searching all over google and I really need to know how to only allow one user agent on .htaccess? All I found is how to do it on a Dedicated or private server. 回答1: If the user-agent that you want to allow is: Lynx/2.8.8dev.12 Then you want these rules in the htaccess of the directory you want to restrict: RewriteEngine On RewriteCond %{HTTP_USER_AGENT} !Lynx/2\.8\.8dev\.12 [NC] RewriteRule ^ - [F,L] Every other user agent is forbidden with a 403. 来源: https://stackoverflow.com

Should I use custom headers or useragent header to send device informations to the server

夙愿已清 提交于 2019-12-04 21:20:22
问题 Every time I send a API request to my server I want send informations like device type and OS version (from my mobile app). My first thought is to use User Agent but I wonder if there's any benefits to use custom http header like "X-deviceType" or/and "X-osVersion" instead. 回答1: I am using the X-Device HTTP Header. Works well for the most part, however I have noticed that some requests from behind a proxy seem to be stripping the data from that header. 来源: https://stackoverflow.com/questions

Codeigniter user_agent

非 Y 不嫁゛ 提交于 2019-12-04 20:16:52
This is my first time developing a responsive website, and I attempted using the CodeIgniter user_agent class. I notice that there's is_mobile() and is_browser() However, the picture I have in mind is for the website on a tablet to look pretty similar to the browser, and only the mobile site to load a different view file altogether. However, is_mobile() includes both tablets and mobile phones, and it's not what I'm hoping for. Is there an alternative to this? Reason: I am using jQuery mobile, and I load a completely different layout for the mobile phone, and I don't want this view to appear on

How can I block some special User-agents Via IPTables

本秂侑毒 提交于 2019-12-04 19:40:20
I need to block packets from any source that includes some special User agents using IPTables. But I don’t want to manage it via .htaccess or Apache. Is there any way? user880414 You can do it like this: iptables -A INPUT -p tcp --dport 80 -m string --algo bm --string "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" -j DROP Short answer: No. Long answer: You could try something using the string match with iptables (see iptables -m string -h ). However, the clients would still be able to connect to your server, the only thing you could do is interrupt the connection in the middle of the

User Agent parsing with Regex

梦想与她 提交于 2019-12-04 15:45:12
I found a method online for separating out views when viewing a Ruby on Rails application on an iPhone and it parses the user agent to detect this. I'm specifically targeting iOS 4.2+ since previous versions don't support HTML5 Web Sockets which I need for my application. So far I am parsing /(iPhone.+OS.+4_2.+Safari)/ and it seems to work a treat but the problem I am having is that if you were using a beta or a future version of the OS the user agent might not include 4_2 but it may support Web Sockets. My question is.. how could I parse the string to have the following outcome: If there is a

Parallel requests in Mojolicious application

余生长醉 提交于 2019-12-04 14:18:05
I have perl application which, for example, parallel searching in google: use Mojo::UserAgent; use Mojo::IOLoop; my $ua = Mojo::UserAgent->new(); my $delay = Mojo::IOLoop->delay(sub { say 'DONE1 (should be before render)'; }); foreach my $i ( 1 .. 10 ) { $delay->begin(); $ua->get("http://www.google.ru/search?q=$i" => sub { say $i; $delay->end(); }); } $delay->wait() unless $delay->ioloop->is_running(); say 'DONE2 (should be before render)'; say 'Found! (render)'; And it's works fine: 6 1 7 10 3 9 2 5 8 4 DONE1 (should be before render) DONE2 (should be before render) Found! (render) When I use

New Safari 7 useragent string

折月煮酒 提交于 2019-12-04 13:00:34
I wouldn't really want to bother you here, but as I don't have a mac I cannot test this. I made a browser sniffing class (I know it's bad but it works well and is not the point). This all works fine, however my colleague said there was a bugg on a website I recently did. All I would like to know / see is if there is a link to any website that has the Safari 7 useragent string documented / raw or if someone could post the Safari 7 UA string here ( $_SERVER['HTTP_USER_AGENT'] in PHP). I checked for this on google and websites as useragentstring.com , but cant get the UA from there either. Thanks

How to block some of http user agent using php

强颜欢笑 提交于 2019-12-04 12:45:59
there have a way to block some of user agent via php script? Example on mod_security SecFilterSelective HTTP_USER_AGENT "Agent Name 1" SecFilterSelective HTTP_USER_AGENT "Agent Name 2" SecFilterSelective HTTP_USER_AGENT "Agent Name 3" Also we can block them using htaccess or robots.txt by example but I want in php. Any example code? I like @Nerdling's answer, but in case it's helpful, if you have a very long list of user agents that need to be blocked: $badAgents = array('fooAgent','blahAgent', 'etcAgent'); foreach($badAgents as $agent) { if(strpos($_SERVER['HTTP_USER_AGENT'],$agent) !== false

Switching stylesheet with Javascript based on browser

爱⌒轻易说出口 提交于 2019-12-04 10:44:01
I'm currently trying to edit a website for a client which uses Adobe Contribute so it uses a different stylesheet if the user is browsing from a mobile phone. The mobile phone stylesheet is much simpler and strips out background images and styles to reduce load time. I understand it would be better practice to have a completely seperate website for the mobile, but this is not practical for the client as he needs to be able to update his websites content using Contribute. This is working in some devices already such as the iPhone (last time I tested!) but on my Android phone I have a strange

What causes the “user agent stylesheet” to use “border-box” instead of “content-box” for box-sizing?

守給你的承諾、 提交于 2019-12-04 10:15:10
问题 I'm under the impression that the user agent stylesheet in browsers such as Safari, Chrome and Firefox is something that is internal to the browser and can't be directly modified (rather a style property needs to be overridden). I'm also under the impression due to various websites including Mozilla's that the default value of the box-sizing property for Webkit and Mozilla is "content-box." I tested this on a rather simple dummy page viewed in various browsers. My problem is that on two pages