Skip to content

Commit

Permalink
v.6.1
Browse files Browse the repository at this point in the history
Fixed elapsed time showing wrong string
  • Loading branch information
amirhp-com committed May 19, 2021
1 parent befb66e commit dc37335
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# @Date: 2020/11/15 02:49:02
# @Email: [email protected]
# @Last modified by: Amirhosseinhpv
# @Last modified time: 2021/05/19 12:30:19
# @Last modified time: 2021/05/19 12:40:35
# @License: GPLv2
# @Copyright: Copyright © 2020 Amirhosseinhpv, All rights reserved.
?>
Expand All @@ -25,7 +25,7 @@
ob_implicit_flush(true);
ob_start();
echo "<script>document.title = 'Uploading ...'; document.querySelector('h1').innerHTML += '<div style=\"font-size: 0;margin-top: 3rem;\"><small style=\"font-size: 1rem;font-family: initial;font-weight: initial;\">Transferring <u>{$url}</u> as <strong>{$name}</strong><br><span style=\"margin-top: 1rem;display: block;\">Please wait until process complete or Press ESC key to cancel</span></small></div><div id=\"progress\"></div>';</script>";
$time = strtotime('now');
$time = microtime(true);
$remote = fopen($url, 'r');
$local = fopen($name, 'w');
$headers = get_headers($url, true);
Expand Down Expand Up @@ -79,22 +79,12 @@ function human_filesize($bytes, $decimals = 2)
}
function human_timing($time)
{
$time = time() - $time; // to get the time since that moment
$time = ($time<1)? 1 : $time;
$tokens = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
}
$s = microtime(true) - $time;
$h = floor($s / 3600);
$s -= $h * 3600;
$m = floor($s / 60);
$s -= $m * 60;
return ($h > 0 ? "$h:" : "") .sprintf('%02d', $m).':'.sprintf('%02d', $s);
}
?>
<form style="margin-top: 1rem;" name='upload' method='post' action="<?php echo strtok($_SERVER['REQUEST_URI'], '?');?>">
Expand Down

0 comments on commit dc37335

Please sign in to comment.