CryptomeBridge.php 1.6 KB

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