Repository: JayBizzle/Laravel-Crawler-Detect Branch: master Commit: a0339574b6df Files: 12 Total size: 9.2 KB Directory structure: gitextract_9rujszq2/ ├── .coveralls.yml ├── .gitignore ├── .styleci.yml ├── .travis.yml ├── LICENSE ├── README.md ├── composer.json ├── phpunit.xml ├── src/ │ ├── Facades/ │ │ └── LaravelCrawlerDetect.php │ └── LaravelCrawlerDetectServiceProvider.php └── tests/ ├── UATests.php └── bootstrap.php ================================================ FILE CONTENTS ================================================ ================================================ FILE: .coveralls.yml ================================================ service_name: travis-ci ================================================ FILE: .gitignore ================================================ /vendor composer.phar composer.lock .DS_Store ================================================ FILE: .styleci.yml ================================================ preset: none enabled: - array_element_white_space_after_comma - blankline_after_open_tag - braces - concat_without_spaces - double_arrow_multiline_whitespaces - duplicate_semicolon - elseif - empty_return - encoding - eof_ending - function_call_space - function_declaration - include - indentation - join_function - line_after_namespace - linefeed - list_commas - logical_not_operators_with_successor_space - short_array_syntax - lowercase_constants - lowercase_keywords - method_argument_space - multiline_array_trailing_comma - multiline_spaces_before_semicolon - multiple_use - namespace_no_leading_whitespace - no_blank_lines_after_class_opening - no_empty_lines_after_phpdocs - no_extra_consecutive_blank_lines - object_operator - operators_spaces - ordered_use - parenthesis - phpdoc_indent - phpdoc_inline_tag - phpdoc_no_access - phpdoc_no_package - phpdoc_scalar - phpdoc_short_description - phpdoc_to_comment - phpdoc_trim - phpdoc_type_to_var - phpdoc_var_without_name - remove_leading_slash_use - return - self_accessor - short_echo_tag - short_tag - single_array_no_trailing_comma - single_blank_line_before_namespace - single_line_after_imports - single_quote - spaces_before_semicolon - spaces_cast - standardize_not_equal - ternary_spaces - trailing_spaces - trim_array_spaces - unalign_equals - unary_operators_spaces - visibility - whitespacy_lines ================================================ FILE: .travis.yml ================================================ language: php matrix: include: - php: 5.5 - php: 5.6 - php: 7.0 - php: 7.1 - php: 7.2 - php: 7.3 - php: 7.4 - php: nightly allow_failures: - php: nightly fast_finish: true before_script: - travis_retry composer self-update - travis_retry composer install --prefer-source --no-interaction --dev script: vendor/bin/phpunit ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2017 Mark Beech Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ Laravel Crawler Detect ======= [![Build Status](https://img.shields.io/travis/JayBizzle/Laravel-Crawler-Detect/master.svg?style=flat-square)](https://travis-ci.org/JayBizzle/Laravel-Crawler-Detect) [![Total Downloads](https://img.shields.io/packagist/dt/JayBizzle/Laravel-Crawler-Detect.svg?style=flat-square)](https://packagist.org/packages/jaybizzle/laravel-crawler-detect) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/JayBizzle/Laravel-Crawler-Detect.svg?style=flat-square)](https://scrutinizer-ci.com/g/JayBizzle/Laravel-Crawler-Detect/?branch=master) [![StyleCI](https://styleci.io/repos/32484055/shield)](https://styleci.io/repos/32484055) A Laravel wrapper for [CrawlerDetect](https://github.com/JayBizzle/Crawler-Detect) - the web crawler detection library Installation ============ Run `composer require jaybizzle/laravel-crawler-detect 1.*` or add `"jaybizzle/laravel-crawler-detect": "1.*"` to your `composer.json` file. The last version compatible with Laravel 4 was [v1.0.2](https://github.com/JayBizzle/Laravel-Crawler-Detect/tree/v1.0.2) so if you need that, you will have to fix your `composer.json` to that specific version. Add the following to the `providers` array in your `config/app.php` file.. ```PHP Jaybizzle\LaravelCrawlerDetect\LaravelCrawlerDetectServiceProvider::class, ``` ...and the following to your `aliases` array... ```PHP 'Crawler' => Jaybizzle\LaravelCrawlerDetect\Facades\LaravelCrawlerDetect::class, ``` Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider. Usage ================== ```PHP use Crawler; // Check current 'visitors' user agent if(Crawler::isCrawler()) { // true if crawler user agent detected } // Pass a user agent as a string if(Crawler::isCrawler('Mozilla/5.0 (compatible; aiHitBot/2.9; +https://www.aihitdata.com/about)')) { // true if crawler user agent detected } ================================================ FILE: composer.json ================================================ { "name": "jaybizzle/laravel-crawler-detect", "description": "A Laravel package to detect web crawlers via the user agent", "keywords": ["laravel", "spider", "bot", "detect", "user-agent", "crawler", "crawler detect", "crawler detector", "crawlerdetect", "php crawler detect"], "homepage": "http://github.com/JayBizzle/Laravel-Crawler-Detect", "license": "MIT", "authors": [ { "name": "Mark Beech", "email": "mbeech@mark-beech.co.uk" } ], "require": { "php": ">=5.4.0", "jaybizzle/crawler-detect": "1.*" }, "require-dev": { "orchestra/testbench": "^3.2|^3.4", "phpunit/phpunit": "^4.8|^5.5|^6.5" }, "autoload": { "psr-4": { "Jaybizzle\\LaravelCrawlerDetect\\": "src/" } }, "extra": { "laravel": { "providers": [ "Jaybizzle\\LaravelCrawlerDetect\\LaravelCrawlerDetectServiceProvider" ], "aliases": { "Crawler": "Jaybizzle\\LaravelCrawlerDetect\\Facades\\LaravelCrawlerDetect" } } }, "minimum-stability": "stable" } ================================================ FILE: phpunit.xml ================================================ ./tests/ ================================================ FILE: src/Facades/LaravelCrawlerDetect.php ================================================ package('Jaybizzle/LaravelCrawlerDetect'); } /** * Register the service provider. * * @return void */ public function register() { $this->app->singleton('LaravelCrawlerDetect', function () { return new \Jaybizzle\CrawlerDetect\CrawlerDetect(request()->server()); }); } /** * Get the services provided by the provider. * * @return array */ public function provides() { return []; } } ================================================ FILE: tests/UATests.php ================================================ 'Jaybizzle\LaravelCrawlerDetect\Facades\LaravelCrawlerDetect', ]; } public function setUp() { parent::setUp(); $this->LaravelCrawlerDetect = new CrawlerDetect(); } protected function getEnvironmentSetUp($app) { // reset base path to point to our package's src directory $app['path.base'] = __DIR__.'/../src'; } public function testBots() { $lines = file('https://raw.githubusercontent.com/JayBizzle/Crawler-Detect/master/tests/crawlers.txt'); foreach ($lines as $line) { $test = Crawler::isCrawler($line); $this->assertTrue($test, $line); } } public function testDevices() { $lines = file('https://raw.githubusercontent.com/JayBizzle/Crawler-Detect/master/tests/devices.txt'); foreach ($lines as $line) { $test = Crawler::isCrawler($line); $this->assertFalse($test, $line); } } } ================================================ FILE: tests/bootstrap.php ================================================