'; header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($url)); header("Content-Length: " . $filesize); header('Content-Transfer-Encoding: chunked'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); $stream = fopen('php://output', 'w'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_READFUNCTION, function ($ch, $fd, $length) use ($stream) { return fwrite($stream, fread($fd, $length)); }); curl_exec($ch); curl_close($ch); } else { echo '404'; } } } else { # must redirect $page = "https://lg-roms.com/official-firmware/" . $clean_name . '-' . $clean_model . '/' . $clean_Revision . '/'. $clean_country; $exist_post3 = mysql_fetch_assoc(mysql_query("select * from `ref` where `ref`='$ref' AND `page`='$page' limit 1")); if($exist_post3){ mysql_query("update `ref` set `times`=times+1 where `ref`='$ref' AND `page`='$page' limit 1"); }else{ $q = "insert into `ref` (`ref`,`times`,`page`) values ('$ref','1','$page')"; mysql_query($q); } header("Location: ".$page); } } else { # without refferer $page = "https://lg-roms.com/official-firmware/" . $clean_name . '-' . $clean_model . '/' . $clean_Revision . '/'. $clean_country; header("Location: ".$page); } function human_filesize($bytes, $dec = 2) { $size = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $factor = floor((strlen($bytes) - 1) / 3); return sprintf("%.{$dec}f", $bytes / pow(1024, $factor)) . @$size[$factor]; }