https://github.com/dflydev/dflydev-snort
Sniff content to determine things about it.
https://github.com/dflydev/dflydev-snort
Last synced: 2 months ago
JSON representation
Sniff content to determine things about it.
- Host: GitHub
- URL: https://github.com/dflydev/dflydev-snort
- Owner: dflydev
- License: mit
- Created: 2013-01-12T07:14:56.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-01-13T17:17:18.000Z (over 13 years ago)
- Last Synced: 2025-10-09T10:11:36.606Z (8 months ago)
- Language: PHP
- Size: 145 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Snort
=====
Sniff content to determine things about it.
Partial implementation of [Content-Type Processing Model draft][1] as inspired
by [Apache Tika][4].
Requirements
------------
* PHP 5.3+
Installation
------------
Through [Composer][2] as [dflydev/snort][3].
Usage
-----
```php
addData($bytes, 0, strlen($bytes));
$sniffer = new Dflydev\Snort\TextOrBinary\TextOrBinarySniffer;
if ($sniffer->isLikelyText($buffer)) {
print "Well, probably text? (as best as we can guess in 512 bytes...)\n";
}
if ($sniffer->isLikelyBinary($buffer)) {
print "Well, probably binary? (as best as we can guess in 512 bytes...)\n";
}
if ($sniffer->isMostlyAscii($buffer)) {
print "Yup, Mostly ASCII!\n";
}
if ($sniffer->looksLikeUtf8($buffer)) {
print "Yup, UTF-8!\n";
}
```
License
-------
MIT, see LICENSE.
Community
---------
If you have questions or want to help out, join us in the **#dflydev** channel
on **irc.freenode.net** or mention [@dflydev][5] on Twitter.
Not Invented Here
-----------------
This work was heavily influenced by [Apache Tika][4] and the information
available from the [Content-Type Processing Model draft][1].
[1]: http://tools.ietf.org/html/draft-abarth-mime-sniff-01
[2]: http://getcomposer.org
[3]: https://packagist.org/packages/dflydev/snort
[4]: http://tika.apache.org
[5]: https://twitter.com/dflydev