2013-08-14 01:27:46 +02:00
|
|
|
<?php
|
|
|
|
class CryptomeBridge extends BridgeAbstract{
|
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = "BoboTiG";
|
|
|
|
const NAME = "Cryptome";
|
|
|
|
const URI = "https://cryptome.org/";
|
2016-09-25 17:04:28 +02:00
|
|
|
const CACHE_TIMEOUT = 21600; //6h
|
2016-08-30 11:23:55 +02:00
|
|
|
const DESCRIPTION = "Returns the N most recent documents.";
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 21:03:26 +02:00
|
|
|
'n'=>array(
|
2016-08-22 01:25:56 +02:00
|
|
|
'name'=>'number of elements',
|
|
|
|
'type'=>'number',
|
2016-08-28 13:28:50 +02:00
|
|
|
'defaultValue'=>20,
|
2016-08-22 01:25:56 +02:00
|
|
|
'exampleValue'=>10
|
2016-08-27 21:03:26 +02:00
|
|
|
)
|
|
|
|
));
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData(){
|
2016-08-30 11:23:55 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM(self::URI)
|
2016-08-28 13:28:50 +02:00
|
|
|
or $this->returnServerError('Could not request Cryptome.');
|
2016-09-01 22:53:01 +02:00
|
|
|
$number=$this->getInput('n');
|
|
|
|
if (!empty($number)) { /* number of documents */
|
|
|
|
$num = min($number, 20);
|
2013-08-14 01:27:46 +02:00
|
|
|
}
|
|
|
|
|
2014-02-08 18:18:09 +01:00
|
|
|
|
2013-08-14 01:27:46 +02:00
|
|
|
foreach($html->find('pre') as $element) {
|
|
|
|
for ( $i = 0; $i < $num; ++$i ) {
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
2016-08-30 11:23:55 +02:00
|
|
|
$item['uri'] = self::URI.substr($element->find('a', $i)->href, 20);
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['title'] = substr($element->find('b', $i)->plaintext, 22);
|
2016-08-30 11:23:55 +02:00
|
|
|
$item['content'] = preg_replace('#http://cryptome.org/#', self::URI, $element->find('b', $i)->innertext);
|
2013-08-14 01:27:46 +02:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|