dom = new Dom; $this->period = strtotime("1 week ago"); $this->output = ''; } /** * Function to start the section. * @param whether to return or print the text */ protected function startSection($return = false) { if (FORMAT === 'MARKDOWN') { $text = "\n#### ".$this->title."\n"; } if (FORMAT === 'HTML') { $text = "\n

".$this->title."

\n
\n"; } $this->output .= $text; } abstract protected function parse(); public function print() { $this->startSection(); try { $this->parse(); } catch (\Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; echo $e->getTraceAsString(); return; } $this->endSection(); if ($this->output === $this->startSection(true)) // nothing to print return; echo $this->output; } protected function get_text($url) { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, CURLOPT_CONNECTTIMEOUT => 30, )); $resp = curl_exec($curl); curl_close($curl); return $resp; } public function check() { try { $this->print(); } catch (Exception $e) { echo $e->getMessage(); echo $e->getTraceAsString(); } } }