Changeset 873 for trunk/Modules/SpeedTest/download.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/SpeedTest/download.php
r738 r873 19 19 $disallow = $config->{'general'}->{'disallow'}; 20 20 $allow = $config->{'general'}->{'allow'}; 21 if ( $allow && (! preg_match("/$allow/",$remote_addr)) ) {21 if ( $allow && (! preg_match("/$allow/",$remote_addr)) ) { 22 22 include("unallowed.html"); 23 23 exit; 24 } elseif ( $disallow && preg_match("/$disallow/", $remote_addr) ) {24 } elseif ( $disallow && preg_match("/$disallow/", $remote_addr) ) { 25 25 include("unallowed.html"); 26 26 exit; … … 33 33 ## on initial results 34 34 $config_auto_size = $config->{'general'}->{'auto_size'}; 35 if ($config_auto_size) {35 if ($config_auto_size) { 36 36 ## We're using the auto_size functionality 37 if ( isset($_GET['auto_size']) && $_GET['auto_size']) {37 if ( isset($_GET['auto_size']) && $_GET['auto_size']) { 38 38 ## Intial test is done. Set down/upload sizes to the same as 39 39 ## our initial measured speeds. That way the test should take … … 55 55 56 56 ## Make sure sizes are below our configured limits 57 if ($down_kbytes > $config->{'download'}->{'max_kbytes'}) {57 if ($down_kbytes > $config->{'download'}->{'max_kbytes'}) { 58 58 $down_kbytes = $config->{'download'}->{'max_kbytes'}; 59 59 } 60 if ($up_kbytes > $config->{'upload'}->{'max_kbytes'}) {60 if ($up_kbytes > $config->{'upload'}->{'max_kbytes'}) { 61 61 $up_kbytes = $config->{'upload'}->{'max_kbytes'}; 62 62 } 63 63 64 if ($config->{'upload'}->{'skip_upload'}) {64 if ($config->{'upload'}->{'skip_upload'}) { 65 65 $up_kbytes = 0; 66 66 } … … 92 92 93 93 <?php 94 if (file_exists("header.html")) {94 if (file_exists("header.html")) { 95 95 ## Include "header.html" for a custom header, if the file exists 96 96 include("header.html"); … … 103 103 104 104 <?php 105 if ( ($config_auto_size) && (! isset($_GET['auto_size'])) ) {105 if ( ($config_auto_size) && (! isset($_GET['auto_size'])) ) { 106 106 ## auto_size is performing the initial, small test 107 107 print "<div>Calculating appropriate file sizes for testing</div>\n"; … … 137 137 </div> 138 138 139 <?php if (file_exists("footer.html")) { include("footer.html"); } ?>139 <?php if (file_exists("footer.html")) { include("footer.html"); } ?> 140 140 141 141 <?php /* Begin JavaScript functions that we'll need */ ?> … … 144 144 function StartUpload() { 145 145 uploadDiv = document.getElementById('upload_message'); 146 if (uploadDiv) {146 if (uploadDiv) { 147 147 uploadDiv.style.visibility='visible'; 148 148 uploadDiv.style.display='block'; 149 <?php if ($pretty_version) { ?>149 <?php if ($pretty_version) { ?> 150 150 setInterval("IncrementUploadBar()",200); 151 151 <?php } ?> … … 158 158 function IncrementDownloadBar() { 159 159 download_barElement = document.getElementById('download_bar'); 160 if (download_barElement) {160 if (download_barElement) { 161 161 download_bar_current_width += <?php echo $download_progress_bar_increment; ?>; 162 if (download_bar_current_width <= <?php echo $progress_bar_width; ?>) {162 if (download_bar_current_width <= <?php echo $progress_bar_width; ?>) { 163 163 download_barElement.style.width = download_bar_current_width +"px"; 164 164 } … … 176 176 function IncrementUploadBar() { 177 177 upload_barElement = document.getElementById('upload_bar'); 178 if (upload_barElement) {178 if (upload_barElement) { 179 179 upload_bar_current_width += <?php echo $upload_progress_bar_increment; ?>; 180 if (upload_bar_current_width < <?php echo $progress_bar_width; ?>) {180 if (upload_bar_current_width < <?php echo $progress_bar_width; ?>) { 181 181 upload_barElement.style.width = upload_bar_current_width +"px"; 182 182 } … … 186 186 function CompleteDownloadBar() { 187 187 download_barElement = document.getElementById('download_bar'); 188 if (download_barElement) {188 if (download_barElement) { 189 189 download_barElement.style.width = "100%"; 190 190 } … … 209 209 <?php 210 210 211 if ($pretty_version) {211 if ($pretty_version) { 212 212 print " 213 213 //--> … … 225 225 $extra_down_kbytes = $down_kbytes - $up_kbytes; 226 226 $total_kbytes = 0; 227 while ($total_kbytes <= $extra_down_kbytes) {228 if ($pretty_version) {227 while ($total_kbytes <= $extra_down_kbytes) { 228 if ($pretty_version) { 229 229 print " 230 230 <script language=\"javascript\"> … … 240 240 $total_kbytes += $each_chunk; 241 241 } 242 if (!$pretty_version) {242 if (!$pretty_version) { 243 243 print "dataElement.value=\"$data\";"; 244 244 print "CompleteDownloadBar();\n"; … … 254 254 ## Now, download the remaining bytes ($up_kbytes) and save it into a 255 255 ## form variable that we will post back to test the upload speed 256 while ($total_kbytes <= $down_kbytes) {257 if ($pretty_version) {256 while ($total_kbytes <= $down_kbytes) { 257 if ($pretty_version) { 258 258 print " 259 259 <script language=\"javascript\"> … … 270 270 } 271 271 272 if (!$pretty_version) {272 if (!$pretty_version) { 273 273 #print "\";"; 274 274 } else { … … 288 288 downloadtime = (endtime - starttime)/1000; 289 289 } 290 <?php if (! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?>290 <?php if (! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?> 291 291 292 292 down_size = <?php echo $total_kbytes; ?>; … … 297 297 298 298 <?php 299 if ($config_auto_size && (! isset($_GET['auto_size'])) ) {299 if ($config_auto_size && (! isset($_GET['auto_size'])) ) { 300 300 $params_auto_size = "&auto_size=1"; 301 301 } else { 302 302 $params_auto_size = ""; 303 303 } 304 if ($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) {304 if ($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) { 305 305 $next_url = $config->{'general'}->{'base_url'}."results.php"; 306 306 } else {
Note:
See TracChangeset
for help on using the changeset viewer.