CryptomeBridge.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * RssBridgeCryptome
  4. * Retrieve lastest documents from Cryptome.
  5. * Returns the N most recent documents, sorting by date (most recent first).
  6. *
  7. * @name Cryptome
  8. * @description Returns the N most recent documents.
  9. * @use1(n="number")
  10. */
  11. class CryptomeBridge extends BridgeAbstract{
  12. public function collectData(array $param){
  13. $html = '';
  14. $num = 90;
  15. $link = 'http://cryptome.org/';
  16. // If you want HTTPS access instead, uncomment the following line:
  17. //$link = 'https://secure.netsolhost.com/cryptome.org/';
  18. $html = file_get_html($link) or $this->returnError('Could not request Cryptome.', 404);
  19. if (isset($param['n'])) { /* number of documents */
  20. $num = min(max(1, $param['n']+0), $num);
  21. }
  22. foreach($html->find('pre') as $element) {
  23. for ( $i = 0; $i < $num; ++$i ) {
  24. $item = new \Item();
  25. $item->uri = $link.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/#', $link, $element->find('b', $i)->innertext);
  28. $this->items[] = $item;
  29. }
  30. break;
  31. }
  32. }
  33. public function getName(){
  34. return 'Cryptome';
  35. }
  36. public function getURI(){
  37. return 'https://secure.netsolhost.com/cryptome.org/';
  38. }
  39. public function getCacheDuration(){
  40. return 21600; // 6 hours
  41. }
  42. }