Skip to content

Latest commit

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Website Info

Build Status

PHP library to retrieve server information like installed cms, webserver, dns lookup, etc... from any webpage

Requirements:

Install the library

The preferred way to install this library is to use Composer.

$ php composer.phar require zeichen32/website-info ~1.0

Usage

// Create a new WebsiteInfo instance with all default parser$ws = \WebsiteInfo\Factory::createWithDefaultParser();
// OR$ws = \WebsiteInfo\Factory::create(array(
new \WebsiteInfo\Parser\Webserver\Apache(),
new \WebsiteInfo\Parser\Webserver\Nginx(),
new \WebsiteInfo\Parser\Webserver\IIS(),
// ...
));
// Retrieve informations about wordpress.com$result = $ws->get('http://wordpress.com');
print_r($result);
Array
(
[headers] => Array
(
[request] => Array
(
[Host] => Array
(
[0] => wordpress.org
)
[user-agent] => Array
(
[0] => WebsiteInfo
)
)
[response] => Array
(
[Server] => Array
(
[0] => nginx
)
[Content-Type] => Array
(
[0] => text/html; charset=utf-8
)
)
)
[webserver] => Array
(
[name] => Nginx
[version] => unknown
[score] => 1
[raw] => nginx
)
[embed] => Array
(
[title] => WordPress Blog Tool, Publishing Platform, and CMS
[description] =>
[url] => https://wordpress.org/
[type] => link
[embed_code] =>
[images] => Array
(
[collection] => Array
(
[0] => http://wpdotorg.files.wordpress.com/2012/10/red-negative-w-crop.jpg
)
[base] => Array
(
[image] => http://wpdotorg.files.wordpress.com/2012/10/red-negative-w-crop.jpg
[width] => 264
[height] => 354
[aspect_ration] =>
)
)
[author] => Array
(
[name] =>
[url] =>
)
[provider] => Array
(
[name] => wordpress
[url] => https://wordpress.org
[icon] => https://s.w.org/favicon.ico?2
[icons] => Array
(
[0] => https://wordpress.org/favicon.ico
[1] => https://wordpress.org/favicon.png
)
)
)
[lookup] => Array
(
[ip] => Array
(
[0] => 66.155.40.249
[1] => 66.155.40.250
)
[hostname] => wordpress.org
[dns] => Array
(
...
)
)
)

Available parser

ParserClassDescription
ApacheWebsiteInfo\Parser\Webserver\ApacheTry to find information about apache webserver
NginxWebsiteInfo\Parser\Webserver\NginxTry to find information about nginx webserver
IISWebsiteInfo\Parser\Webserver\IISTry to find information about Microsoft IIS webserver
DrupalWebsiteInfo\Parser\CMS\DrupalTry to find information about installed Drupal CMS
JoomlaWebsiteInfo\Parser\CMS\JoomlaTry to find information about installed Joomla! CMS
MagentoWebsiteInfo\Parser\CMS\MagentoTry to find information about installed Magento system
phpBBWebsiteInfo\Parser\CMS\PHPBBTry to find information about installed phpBB system
ShopwareWebsiteInfo\Parser\CMS\ShopwareTry to find information about installed Shopware system
Typo3WebsiteInfo\Parser\CMS\Typo3Try to find information about installed Typo3 CMS
vBulletinWebsiteInfo\Parser\CMS\VBulletinTry to find information about installed vBulletin system
WordpressWebsiteInfo\Parser\CMS\WordpressTry to find information about installed Wordpress CMS
GoogleWebsiteInfo\Parser\Analytics\GoogleTry to find information about used google ads and analytics
PiwikWebsiteInfo\Parser\Analytics\PiwikTry to find information about used piwik analytics
EmbedWebsiteInfo\Parser\Embed\EmbedTry to find embed information
LookupWebsiteInfo\Parser\LookupTry to find lookup informations like dns, ip etc.

Create your own parser

  1. Create a new parser that do something with the response
namespaceAcme\Parser;
useWebsiteInfo\Event\ParseResponseEvent;
useWebsiteInfo\Parser\AbstractParser;
class MyParser extends AbstractParser {
publicfunctiononParseResponse(ParseResponseEvent$event)
{
// Get response object$response = $event->getResponse();
// Do something with the response$something = $this->doSomething( (string) $response->getBody() );
// Add a new section to the output container$event->getData()->addSection('my_new_section', array(
'foo' => 'bar',
'version' => '1.0',
'score' => 1,
'raw' => $something
));
}
}
  1. Use your parser
// Create a new WebsiteInfo instance$ws = \WebsiteInfo\Factory::createWithDefaultParser();
// Register your parser$ws->addParser(new \Acme\Parser\MyParser());
// Retrieve informations about wordpress.com$result = $ws->get('http://wordpress.com');

Using the result container cache

  1. Using the ArrayCache (Memory Cache)
// Create a new WebsiteInfo instance$ws = \WebsiteInfo\Factory::createWithDefaultParser();
// Using the array cache$ws->setCache(new \TwoDevs\Cache\ArrayCache());
// Retrieve informations about wordpress.com$result = $ws->get('http://wordpress.com');
  1. If doctrine cache is installed, it can be used to cache the result container using the doctrine cache adapter.
// Create a new WebsiteInfo instance$ws = \WebsiteInfo\Factory::createWithDefaultParser();
// Create a new DoctrineCache instance$doctrineCache = new \Doctrine\Common\Cache\FilesystemCache('var/cache');
// Create a new DoctrineCache adapter$cacheAdapter = new \TwoDevs\Cache\DoctrineCache($doctrineCache);
// Using the cache$ws->setCache($cacheAdapter);
// Retrieve informations about wordpress.com$result = $ws->get('http://wordpress.com');
  1. If zend cache is installed, it can be used to cache the result container using the zend cache adapter.
// Create a new WebsiteInfo instance$ws = \WebsiteInfo\Factory::createWithDefaultParser();
// Create a new ZendStorage instance$zendCache = new \Zend\Cache\Storage\Adapter\Memory();
// Create a new ZendCache adapter$cacheAdapter = new \TwoDevs\Cache\ZendCache($zendCache);
// Using the cache$ws->setCache($cacheAdapter);
// Retrieve informations about wordpress.com$result = $ws->get('http://wordpress.com');

How to use a different HttpClient

This library use the Saxulum HttpClientInterface which allows you to simple change the used HttpClient.

For example you want to use Buzz as HttpClient:

  1. Add the Buzz adapter to your composer.json:
$ php composer.phar require saxulum-http-client-adapter-buzz ~1.0
  1. Create a new BuzzClient
// Create a new Buzz Client $buzz = new \Buzz\Browser();
// Create the client adapter$client = new \Saxulum\HttpClient\Buzz\HttpClient($guzzle);
// Create a new WebsiteInfo instance with all default parser and custom client$ws = \WebsiteInfo\Factory::createWithDefaultParser($client);
// Retrieve informations about wordpress.com$result = $ws->get('http://wordpress.com');
print_r($result);

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages