Exemple #1
0
    }
    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();