"; } else { echo "File type: ".$hdrs['Content-Type']."
"; } } if(isset($hdrs['Content-Length'])) { global $len; if(is_array($hdrs['Content-Length'])) { $len = end($hdrs['Content-Length']); $adi = $len; if($adi > 1024) { $adi /= 1024; $t = "KB"; } if($adi > 1024) { $adi /= 1024; $t = "MB"; } $adi = round($adi, 2); echo "File size: $adi $t
"; global $bytmax; $bytmax = $len; } else { $adi = $hdrs['Content-Length']; $t = "Bytes"; if($adi > 1024) { $adi /= 1024; $t = "KB"; } if($adi > 1024) { $adi /= 1024; $t = "MB"; } $adi = round($adi, 2); echo "File size: $adi $t
"; global $bytmax; $bytmax = $hdrs['Content-Length']; } } if(isset($hdrs["location"])) { if(is_array($hdrs['location'])) { $lctn = end($hdrs['location']); echo "Redirection: $lctn
"; $_POST["url"] = $lctn; } else { echo "Redirection: ".$hdrs['location']."
"; $_POST["url"] = $hdrs['location']; } } } function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) { switch($notification_code) { case STREAM_NOTIFY_RESOLVE: case STREAM_NOTIFY_AUTH_REQUIRED: case STREAM_NOTIFY_COMPLETED: case STREAM_NOTIFY_FAILURE: case STREAM_NOTIFY_AUTH_RESULT: var_dump($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max); break; case STREAM_NOTIFY_CONNECT: echo ""; break; case STREAM_NOTIFY_PROGRESS: if($bytes_max) { global $pr; global $bm; $bm = ""; $bm = $bytes_max; $adi = $bytes_transferred; $t = "Bytes"; if($adi > 1024) { $adi /= 1024; $t = "KB"; } if($adi > 1024) { $adi /= 1024; $t = "MB"; } $adi2 = ""; $adi2 = $bytes_max; $t2 = "Bytes"; if($adi2 > 1024) { $adi2 /= 1024; $t2 = "KB"; } if($adi2 > 1024) { $adi2 /= 1024; $t2 = "MB"; } $adi = round($adi, 2); $adi2 = round($adi2, 2); $pr = $bytes_transferred * 100; $pr = $pr / $bytes_max; $pr = intval($pr); } else { $pr = "unknown"; $adi = 0; $t = "Unknown"; $t2 = "Unknown"; $adi2 = 0; } echo " "; break; } } echo "\n"; $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); $name = DownloadFolder."/".$_POST["name"]; echo "name: ".$name."
"; echo '
0% Complete
'; $put = copy($_POST["url"], $name, $ctx); if($put) { $put = filesize($name); $t2 = "Bytes"; if($put > 1024) { $put /= 1024; $t2 = "KB"; } if($put > 1024) { $put /= 1024; $t2 = "MB"; } $t = "Bytes"; if(!isset($bm)) { $bm = 0; } if($bm > 1024) { $bm /= 1024; $t = "KB"; } if($bm > 1024) { $bm /= 1024; $t = "MB"; } $put = round($put, 2); $bm = round($bm, 2); echo " "; } } ?>