2013-08-14 01:27:46 +02:00
|
|
|
<?php
|
|
|
|
class CryptomeBridge extends BridgeAbstract{
|
|
|
|
|
2016-08-27 21:03:26 +02:00
|
|
|
public $maintainer = "BoboTiG";
|
|
|
|
public $name = "Cryptome";
|
2016-08-28 13:28:50 +02:00
|
|
|
public $uri = "https://cryptome.org/";
|
2016-08-27 21:03:26 +02:00
|
|
|
public $description = "Returns the N most recent documents.";
|
2015-11-05 16:50:18 +01:00
|
|
|
|
2016-08-27 21:03:26 +02:00
|
|
|
public $parameters = array( array(
|
|
|
|
'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-28 13:28:50 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM($this->uri)
|
|
|
|
or $this->returnServerError('Could not request Cryptome.');
|
2016-08-28 01:25:33 +02:00
|
|
|
if (!empty($this->getInput('n'))) { /* number of documents */
|
2016-08-28 13:28:50 +02:00
|
|
|
$num = min($this->getInput('n'), 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-28 13:28:50 +02:00
|
|
|
$item['uri'] = $this->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-28 13:28:50 +02:00
|
|
|
$item['content'] = preg_replace('#http://cryptome.org/#', $this->uri, $element->find('b', $i)->innertext);
|
2013-08-14 01:27:46 +02:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 21600; // 6 hours
|
|
|
|
}
|
|
|
|
}
|