image as $x) { $urlBase = $x->urlBase; $web_file = "http://www.bing.com{$urlBase}_1366x768.jpg"; // Web Resolution (without Logo) $bg_file = "http://www.bing.com{$urlBase}_1920x1200.jpg"; // Wallpaper Format $bg_cn_file = "http://www.bing.com{$urlBase}_ZH_1920x1200.jpg"; // Wallpaper Format for China if ($format == 0) { $out[] = $web_file; } elseif ($format == 1) { $out[] = $bg_file; } elseif ($format == 2) { $out[] = $bg_cn_file; } elseif ($format == 3) { $out[] = $web_file; $out[] = $bg_file; $out[] = $bg_cn_file; } elseif ($format == 4) { # TODO: find available resolutions in another way? $bla = file(__DIR__ . '/test_resolution/output'); foreach ($bla as &$bla_x) { $bla_x = trim($bla_x); if ($bla_x == '') continue; if ($bla_x[0] == '#') continue; $out[] = "http://www.bing.com{$urlBase}_{$bla_x}.jpg"; } } } // DEBUG echo "bing_get_pictures($market, $format) = \n"; print_r($out); return $out; } */ # --- function jpeg_is_ok($file) { $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if (($ext == 'jpg') || ($ext == 'jpeg')) { # Only check if EOI is there $x = file_get_contents($file); $eoi = substr($x, -2); return ($eoi == chr(0xff).chr(0xd9)); } else { // TODO: video files are not checked yet } } function curl_request($url, $fail = true) { $params = ''; $params .= "-s "; // silent $params .= "-S "; // but shows errors $params .= "-L "; // follow location $params .= "-k "; // allow all HTTPS connections, also untrusted ones $params .= "-A 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36' "; if ($fail) $params .= "-f "; $out = []; exec("curl $params ".escapeshellarg($url)." 2>/dev/null", $out, $code); if (trim(implode('',$out)) == 'OK') $code = 999; if ($code != 0) { // Bing seems to have blocked ViaThinkSoft Server! // lynx "https://www.bing.com/hpimagearchive.aspx?format=xml&idx=0&n=100&mbl=1&mkt=en-ww" // Outputs: "OK" instead of an XML file. But works for some TOR connections! //exec("vtor -- curl $params ".escapeshellarg($url)." 2>/dev/null", $out, $code); $url = 'http://marschall.my-router.de/proxy.php?url='.urlencode($url);; $out = []; exec("curl $params ".escapeshellarg($url)." 2>/dev/null", $out, $code); if (trim(implode('',$out)) == 'OK') $code = 999; } if (($fail) && ($code != 0)) return false; return implode("\n", $out); }