EstCeQuonMetEnProdBridge.php 1.2 KB

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