public function testgetImageUrl() { $fc = new fourChan(); $url = $fc->getImageUrl(69696969, ".jpg"); echo $url; $this->assertEquals(!filter_var($url, FILTER_VALIDATE_URL) === false, true); }
} public function board_dump() { print_r($this->board_details); die; } public function get_image() { $page = file_get_contents($this->board_details[$this->board]) or die("http request failed\n"); $matches = array(); preg_match_all("^<a href=\".*\" target=\"_blank\">.*</a>-.*</span><br><a href=\"(.*)\" target=_blank><img src=.* border=0 align=left^", $page, $matches, PREG_SET_ORDER); if (count($matches) > 0) { switch ($this->seek_type) { case "random": default: srand(mktime()); $index = rand() % (count($matches) - 1); break; case "newest": $index = 0; break; } } else { return "could not find an image, something is wrong :/\n"; } return $matches[$index][1] . "\n"; } } $lol = new fourChan($argv); $lol->board_check(); echo $lol->get_image();