1
0

CryptomeBridge.php 1.6 KB

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