예제 #1
0
function down_img($url, $savepath)
{
    $data = _Get($url);
    $f = fopen($savepath, 'w');
    if (!$f) {
        return "Error: File exists/not writable";
    }
    fwrite($f, $data);
    fclose($f);
    return true;
}
예제 #2
0
        $wotdRecords = json_decode(file_get_contents($filename), true);
    } else {
        $wotdRecords = array();
    }
} else {
    if ($useJSON === false) {
        DB::$host = $host;
        DB::$port = $port;
        DB::$user = $user;
        DB::$password = $password;
        DB::$dbName = $database;
        $wotdRecords = DB::query('SELECT * FROM wotd');
    }
}
$wrCount = (int) count($wotdRecords);
$html = _Get('https://growtopiagame.com');
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML($html, LIBXML_NOWARNING);
$XPath = new DOMXpath($doc);
$nameElem = $XPath->query('/html/body/div[17]/font[2]/font[1]');
$ownerElem = $XPath->query('/html/body/div[17]/font[2]/font[2]');
$wotdName = $nameElem->item(0)->nodeValue;
$wotdOwner = $ownerElem->item(0)->nodeValue;
if ($wotdRecords[$wrCount - 1]['wotdName'] == $wotdName) {
    $wotdCount = $wotdRecords[$wrCount - 1]['wotdCount'];
} else {
    $wotdCount = $wotdRecords[$wrCount - 1]['wotdCount'] + 1;
}
if ($wotdRecords[$wrCount - 1]['wotdDay'] === date('d')) {
    echo "Already Added";