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