EstCeQuonMetEnProdBridge.php 1.4 KB

123456789101112131415161718192021222324252627282930313233
  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 DESCRIPTION = 'Should we put a website in production today? (French)';
  7. public function collectData(){
  8. function ExtractFromDelimiters($string, $start, $end) {
  9. if (strpos($string, $start) !== false) {
  10. $section_retrieved = substr($string, strpos($string, $start) + strlen($start));
  11. $section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
  12. return $section_retrieved;
  13. } return false;
  14. }
  15. $html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request EstCeQuonMetEnProd: '.$this->getURI());
  16. $item = array();
  17. $item['uri'] = $this->getURI().'#'.date('Y-m-d');
  18. $item['title'] = $this->getName();
  19. $item['author'] = 'Nicolas Hoffmann';
  20. $item['timestamp'] = strtotime('today midnight');
  21. $item['content'] = str_replace('src="/', 'src="'.$this->getURI(), trim(ExtractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />')));
  22. $this->items[] = $item;
  23. }
  24. public function getCacheDuration() {
  25. return 21600; // 6 hours
  26. }
  27. }
  28. ?>