2013-08-14 03:27:46 +04:00
|
|
|
<?php
|
|
|
|
class CryptomeBridge extends BridgeAbstract{
|
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const MAINTAINER = "BoboTiG";
|
|
|
|
const NAME = "Cryptome";
|
|
|
|
const URI = "https://cryptome.org/";
|
|
|
|
const DESCRIPTION = "Returns the N most recent documents.";
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 22:03:26 +03:00
|
|
|
'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-30 12:23:55 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM(self::URI)
|
2016-08-28 14:28:50 +03:00
|
|
|
or $this->returnServerError('Could not request Cryptome.');
|
2016-09-01 23:53:01 +03:00
|
|
|
$number=$this->getInput('n');
|
|
|
|
if (!empty($number)) { /* number of documents */
|
|
|
|
$num = min($number, 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-30 12:23:55 +03:00
|
|
|
$item['uri'] = self::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-30 12:23:55 +03:00
|
|
|
$item['content'] = preg_replace('#http://cryptome.org/#', self::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
|
|
|
|
}
|
|
|
|
}
|