EstCeQuonMetEnProdBridge.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class EstCeQuonMetEnProdBridge extends BridgeAbstract {
  3. public function loadMetadatas() {
  4. $this->maintainer = 'ORelio';
  5. $this->name = 'Est-ce qu\'on met en prod aujourd\'hui ?';
  6. $this->uri = 'https://www.estcequonmetenprodaujourdhui.info/';
  7. $this->description = 'Should we put a website in production today? (French)';
  8. }
  9. public function collectData(array $param) {
  10. function ExtractFromDelimiters($string, $start, $end) {
  11. if (strpos($string, $start) !== false) {
  12. $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
  13. $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
  14. return $section_retrieved;
  15. } return false;
  16. }
  17. $html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request EstCeQuonMetEnProd: '.$this->getURI());
  18. $item = array();
  19. $item['uri'] = $this->getURI().'#'.date('Y-m-d');
  20. $item['title'] = $this->getName();
  21. $item['author'] = 'Nicolas Hoffmann';
  22. $item['timestamp'] = strtotime('today midnight');
  23. $item['content'] = str_replace('src="/', 'src="'.$this->getURI(), trim(ExtractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />')));
  24. $this->items[] = $item;
  25. }
  26. public function getCacheDuration() {
  27. return 21600; // 6 hours
  28. }
  29. }
  30. ?>