Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
/vendor/
composer.lock
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PHP Random User Agent Generator
Written in PHP, this script will generate real User Agent strings with optional capabilities to specify OS, Browser, Mobile, ect. simply by passing a parameter to the function called to generate the User Agent string. Created with the intentions of eliminating footprints while scraping the web for content using cURL because a truly solution to generate a truly random User Agent was not availble.
Written in PHP, this script will generate real User Agent strings with optional capabilities to specify OS, Browser, Mobile, etc. simply by passing a parameter to the function called to generate the User Agent string. Created with the intentions of eliminating footprints while scraping the web for content using cURL because an easy solution to generate a truly random User Agent was not availble.

__Other Randomly Generated Segments__
* Version of Android with Device / build number strings, and variations of known UA's for specific devices.
Expand All @@ -10,12 +10,16 @@ __Other Randomly Generated Segments__

It's also easy to customize with random syntax parsing and random number generating, see `Customizing User Agent` below
***
# Installation
For installation with composer run the following command:
```shell script
composer require chrisspaghetti/useragentgenerator:dev-master
```
***
# Usage Summary
1. Require `useragent.php` in the file where the User Agent string will be generated.
..*```php require_once __DIR__.'/userAgent.php';```
2. Initialize the `userAgent` class
1. Initialize the `userAgent` class
..*```php $agent = new userAgent;```
3. Call the `generate` function to generate a random User Agent string as many times as needed.
2. Call the `generate` function to generate a random User Agent string as many times as needed.
..*```php $UAString = $agent->generate();```

### Example Usage
Expand All @@ -30,7 +34,7 @@ $userAgent = (new userAgent) ->generate();
```

### Example Usage when specifying a single OS, Browser, or Mobile
You can specify either `firefox`, `chrome`, `mobile`, `windows`, `mac`, `iphone`, `ipad`, `ipod`, and `android`.
You can specify either `firefox`, `chrome`, `explorer`, `mobile`, `windows`, `mac`, `iphone`, `ipad`, `ipod`, and `android`.
```php
$agent = new userAgent();
$UAFireFox = $agent->generate('firefox'); // generates a firefox user agent on either windows or mac
Expand Down
43 changes: 26 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
{
"name": "phpfail/UserAgentGenerator",
"description": "Generate a random User Agent for based on OS, Browser, ect.",
"type": "library",
"version":"1.0.1",
"license":"GPL-3.0-only",
"authors": [
{
"name":"phpfail",
"email":"phpfail@gihub.com"
}
],
"autoload": {
"psr-4": {
"phpfail\\": "./"
}
"name": "chrisspaghetti/useragentgenerator",
"description": "Generate a random User Agent based on OS, platform, browser, etc.",
"keywords": [
"random",
"user agent",
"generator"
],
"type": "library",
"version": "1.0.2",
"license": "GPL-3.0-only",
"authors": [
{
"name": "phpfail",
"email": "phpfail@gihub.com"
},
"minimum-stability": "dev",
"require": {}
{
"name": "chrisspaghetti",
"email": "chrisspaghetti@chrispage.de",
"role": "Developer"
}
],
"require": {
"php": ">=7.0"
},
"autoload": {
"files": ["userAgent.php"]
}
}
17 changes: 17 additions & 0 deletions test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
require __DIR__ . '/vendor/autoload.php';
error_reporting(E_ALL);

echo 'RANDOM 100:'."\n";
for ($i = 1; $i<= 100; $i++) {
$agent = new userAgent();
echo $agent->generate()."\n";
}

echo "\n";
echo 'TESTING NESTED:'."\n";
for ($i = 1; $i<= 10; $i++) {
$example = 'Android [7.[1|0]|6.0|5.1]';
$agent = new userAgent();
echo $agent->generate($example)."\n";
}
Loading