lennerd / vipxbotdetectbundle Goto Github PK
View Code? Open in Web Editor NEWThis bundle adds a detector service to Symfony for detecting different crawlers and spiders.
This bundle adds a detector service to Symfony for detecting different crawlers and spiders.
I need to whitelist curl from extended_bot but there is not way to do it.
Hi,
I must investigate but the command and detection in general doesn't seem to work anymore. Event with the basic example:
--------------------------
-- Vipx/BotDetectBundle --
--------------------------
> Testing user agent "AddThis" ...
> This agent is unknown, if you think it should be added, send a PR to lennerd/vipx-bot-detect on Github.
I will try to add a test to the command.
When user agent is empty '', the bot "Aboutus" is reported. When the user agent is 1 space " " , the bot is not detected, shouldn’t the user be trimmed before calling the detect method ?
$request->server->set('HTTP_USER_AGENT', '');
dump($this->get('vipx_bot_detect.detector')->detectFromRequest($request));
$request->server->set('HTTP_USER_AGENT', ' ');
dump($this->get('vipx_bot_detect.detector')->detectFromRequest($request)); die();
Outputs:
Controller.php on line 91:
Metadata {#436 ▼
-name: "AboutUs"
-agent: ""
-ip: null
-type: "bot"
-meta: array:1 [▶]
-agentMatch: "exact"
}
Controller.php on line 94:
null
I have created a little action that allows to test user agent manually just with a get method, like this:
http://dev.front.app.com/app_dev.php/testBotDetector?user-agent=ltx71%20-%20(http://ltx71.com/)
Outputs:
tested User agent: "ltx71 - (http://ltx71.com/)"
Name: ltx71
Type: bot
Metas:
email: [email protected]
website: http://ltx71.com/
Do you think it is worth including it in the bundle ?
How can I use custom bot list together with basic or extended bot list?
Hi there,
thanks for your great bundle! We would like to upgrade our application to Symfony 4, but we also need your bundle and it is hardwired to Sf3. Do you see any chance for an upgrade?
Regards
Nico
This is more like a question to you, @lennerd:
We're currently upgrading from a Symfony 3 application to Symfony 4 and we're using this bundle (is this still under development, because most recent commits are 2 years ago?)
So as we're upgrading, we want to use this bundle via correct dependency injection (not via the container ->get()), but that is not possible without a workaround, as there is no alias to the vipx_bot_detect.detector
service ID.
We want to use it via constructor injection (with autowire: true
in our service definition):
<?php
use Symfony\Component\HttpFoundation\RequestStack;
use Vipx\BotDetectBundle\BotDetector;
class BotManager
{
public function __construct(RequestStack $requestStack, BotDetector $botDetector)
{
$this->meta = $botDetector->detectFromRequest($requestStack->getCurrentRequest());
}
}
My workaround to this issue would be to add some
Vipx\BotDetectBundle\BotDetector:
alias: vipx_bot_detect.detector
public: true
to our services.yml but I don't think that this is a good idea.
I'm relatively new to Symfony and I don't know if this is really an issue with your bundle, but I just wanted to go the "quick way" via Github, I hope that's OK for you.
... by changing line 92 in BotDetector.php from
return $this->metadatas = require $cache;
to
return $this->metadatas = require $cache->getPath();
Hello,
Could you also include in branche 2.0, the correction made on class name definition in this commit:
8df5342
The v2's bundle also encounter some problems because of this incorrect class name definition.
Thanks
I'm getting such errors in the log:
[2016-02-11 21:45:53] user_agents.DEBUG: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:28.0) Gecko/20100101 Firefox/28.0 (FlipboardProxy/1.1; +http://flipboard.com/browserproxy)' [] []
[2016-02-11 21:45:53] user_agents.DEBUG: '52.21.123.187' [] []
[2016-02-11 21:45:53] scream.WARNING: preg_match(): Compilation failed: missing ) at offset 10 {"type":2,"file":"/home/sergii.smirnov/public_html/trim/vendor/vipx/bot-detect/Vipx/BotDetect/Metadata/Metadata.php","line":117,"scream":0} []
[2016-02-11 21:45:53] scream.WARNING: preg_match(): Compilation failed: nothing to repeat at offset 0 {"type":2,"file":"/home/sergii.smirnov/public_html/trim/vendor/vipx/bot-detect/Vipx/BotDetect/Metadata/Metadata.php","line":117,"scream":0} []
[2016-02-11 21:45:53] scream.WARNING: preg_match(): Compilation failed: missing ) at offset 24 {"type":2,"file":"/home/sergii.smirnov/public_html/trim/vendor/vipx/bot-detect/Vipx/BotDetect/Metadata/Metadata.php","line":117,"scream":0} []
[2016-02-11 21:45:53] scream.WARNING: preg_match(): Compilation failed: unmatched parentheses at offset 6 {"type":2,"file":"/home/sergii.smirnov/public_html/trim/vendor/vipx/bot-detect/Vipx/BotDetect/Metadata/Metadata.php","line":117,"scream":0} []
[2016-02-11 21:45:53] scream.WARNING: preg_match(): Compilation failed: nothing to repeat at offset 0 {"type":2,"file":"/home/sergii.smirnov/public_html/trim/vendor/vipx/bot-detect/Vipx/BotDetect/Metadata/Metadata.php","line":117,"scream":0} []
[2016-02-11 21:45:53] scream.WARNING: preg_match(): Compilation failed: nothing to repeat at offset 0 {"type":2,"file":"/home/sergii.smirnov/public_html/trim/vendor/vipx/bot-detect/Vipx/BotDetect/Metadata/Metadata.php","line":117,"scream":0} []
[2016-02-11 21:45:53] scream.WARNING: preg_match(): Compilation failed: missing ) at offset 17 {"type":2,"file":"/home/sergii.smirnov/public_html/trim/vendor/vipx/bot-detect/Vipx/BotDetect/Metadata/Metadata.php","line":117,"scream":0} []
Ip is defined as a string, but in extended_bot.yml for example, it's defined as an array:
Yigg:
agent: ''
ip: [188.138.56.55, 188.138.48.253]
type: bot
So when matching return $this->ip === $ip;
even if the ip is in the array, it won't match.
This PR make your bundle with all symfony version, can you update your tag with the last current version of your bundle ?
Because we have to use "dev-master" within composer.
Best regard
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.