CryptomeBridge.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. * @maintainer BoboTiG
  10. * @use1(n="number")
  11. */
  12. class CryptomeBridge extends BridgeAbstract{
  13. public function collectData(array $param){
  14. $html = '';
  15. $num = 20;
  16. $link = 'http://cryptome.org/';
  17. // If you want HTTPS access instead, uncomment the following line:
  18. //$link = 'https://secure.netsolhost.com/cryptome.org/';
  19. $html = file_get_html($link) or $this->returnError('Could not request Cryptome.', 404);
  20. if (!empty($param['n'])) { /* number of documents */
  21. $num = min(max(1, $param['n']+0), $num);
  22. }
  23. foreach($html->find('pre') as $element) {
  24. for ( $i = 0; $i < $num; ++$i ) {
  25. $item = new \Item();
  26. $item->uri = $link.substr($element->find('a', $i)->href, 20);
  27. $item->title = substr($element->find('b', $i)->plaintext, 22);
  28. $item->content = preg_replace('#http://cryptome.org/#', $link, $element->find('b', $i)->innertext);
  29. $this->items[] = $item;
  30. }
  31. break;
  32. }
  33. }
  34. public function getName(){
  35. return 'Cryptome';
  36. }
  37. public function getURI(){
  38. return 'https://secure.netsolhost.com/cryptome.org/';
  39. }
  40. public function getCacheDuration(){
  41. return 21600; // 6 hours
  42. }
  43. }