2017 © Pedro Peláez
 

library pinger

Tiny PHP library used to ping desired URLs

image

raitocz/pinger

Tiny PHP library used to ping desired URLs

  • Friday, October 13, 2017
  • by RaitoCZ
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Pinger

Travis branch Packagist Pre Release license, (*1)

Installation

composer require raitocz/pinger, (*2)

Introduction

This project is under development, it is recommended to wait with usage for stable release (soon)., (*3)

Tiny PHP library used to ping desired URLs. You can use proxy list to ping as from different computer making this tool handy when you wan to test the server load from different IPs. Use at your own risk, you can DDoS yourself or get blacklisted for attacking another server., (*4)

The user agent is generated from random numbers so the server is tricked to be believing that each request came from different computer (although from same IP if no proxy list specified)., (*5)

This script is working well for example with unprotected polls for adding votes (ones where links are not generated for each page reload) as this was the reason why it was created & later transformed to this library., (*6)

Warnings

This script can also clog your computer fast as it is making each request as separate PHP process, so too fast settings can flood your RAM. That's why the Wait time is in Seconds. Although you can set it for example to 0.000001 I highly don't recommend that. Setting it to 0.1 will flood free 16GB RAM in few seconds, for example., (*7)

Please also note the limitations of Windows systems for usleep() which is used: http://php.net/manual/en/function.usleep.php, (*8)

Basic usage

Simplest request to one url 100x each second:, (*9)

// As object:
$pinger = new Pinger();
$pinger->setUrls(array('http://localhost/'))
    ->setRepeat(100)
    ->setWait(1)
    ->start();

// As static method:
Pinger::run(array('http://localhost/'), 100, 1);

Here are examples of diferent modes (used only static method for shorter code):, (*10)

Random mode (default)

$urls = array(
    'http://localhost/1',
    'http://localhost/02',
    'http://localhost/003',
    'http://localhost/0004',    
);

Pinger::run($urls, 2, 1, Pinger::MODE_RANDOM);

result:, (*11)

ping: http://localhost/003
ping: http://localhost/0004
ping: http://localhost/003
ping: http://localhost/1
ping: http://localhost/0004
ping: http://localhost/1
ping: http://localhost/02
ping: http://localhost/02

Random mode No repeat

$urls = array(
    'http://localhost/1',
    'http://localhost/02',
    'http://localhost/003',
    'http://localhost/0004',    
);

Pinger::run($urls, 2, 1, Pinger::MODE_RANDOM_NOREPEAT);

result:, (*12)

ping: http://localhost/1
ping: http://localhost/003
ping: http://localhost/0004
ping: http://localhost/02
ping: http://localhost/003
ping: http://localhost/0004
ping: http://localhost/1
ping: http://localhost/02

Batch URL

$urls = array(
    'http://localhost/1',
    'http://localhost/02',
    'http://localhost/003',
    'http://localhost/0004',    
);

Pinger::run($urls, 2, 1, Pinger::MODE_BATCH_URL);

result:, (*13)

ping: http://localhost/1
ping: http://localhost/1
ping: http://localhost/02
ping: http://localhost/02
ping: http://localhost/003
ping: http://localhost/003
ping: http://localhost/0004
ping: http://localhost/0004

Batch Array

$urls = array(
    'http://localhost/1',
    'http://localhost/02',
    'http://localhost/003',
    'http://localhost/0004',    
);

Pinger::run($urls, 2, 1, Pinger::MODE_BATCH_ARRAY);

result:, (*14)

ping: http://localhost/1
ping: http://localhost/02
ping: http://localhost/003
ping: http://localhost/0004
ping: http://localhost/1
ping: http://localhost/02
ping: http://localhost/003
ping: http://localhost/0004

The Versions

13/10 2017

dev-master

9999999-dev

Tiny PHP library used to ping desired URLs

  Sources   Download

MIT

The Development Requires

by Raito Akehanareru

13/10 2017

v1.0.1

1.0.1.0

Tiny PHP library used to ping desired URLs

  Sources   Download

MIT

The Development Requires

by Raito Akehanareru

13/10 2017

v1.0.0

1.0.0.0

Tiny PHP library used to ping desired URLs

  Sources   Download

MIT

The Development Requires

by Raito Akehanareru