CryptomeBridge.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. class CryptomeBridge extends BridgeAbstract{
  3. const MAINTAINER = "BoboTiG";
  4. const NAME = "Cryptome";
  5. const URI = "https://cryptome.org/";
  6. const DESCRIPTION = "Returns the N most recent documents.";
  7. const PARAMETERS = array( array(
  8. 'n'=>array(
  9. 'name'=>'number of elements',
  10. 'type'=>'number',
  11. 'defaultValue'=>20,
  12. 'exampleValue'=>10
  13. )
  14. ));
  15. public function collectData(){
  16. $html = getSimpleHTMLDOM(self::URI)
  17. or returnServerError('Could not request Cryptome.');
  18. $number=$this->getInput('n');
  19. if (!empty($number)) { /* number of documents */
  20. $num = min($number, 20);
  21. }
  22. foreach($html->find('pre') as $element) {
  23. for ( $i = 0; $i < $num; ++$i ) {
  24. $item = array();
  25. $item['uri'] = self::URI.substr($element->find('a', $i)->href, 20);
  26. $item['title'] = substr($element->find('b', $i)->plaintext, 22);
  27. $item['content'] = preg_replace('#http://cryptome.org/#', self::URI, $element->find('b', $i)->innertext);
  28. $this->items[] = $item;
  29. }
  30. break;
  31. }
  32. }
  33. public function getCacheDuration(){
  34. return 21600; // 6 hours
  35. }
  36. }