{'general'}->{'disallow'}; $allow = $config->{'general'}->{'allow'}; if ( $allow && (! preg_match("/$allow/",$remote_addr)) ) { include("unallowed.html"); exit; } elseif ( $disallow && preg_match("/$disallow/", $remote_addr) ) { include("unallowed.html"); exit; } ## Figure out how many bytes to download/upload depending on if we are using ## auto_size or not. If using auto_size, then determine sizes based ## on initial results $config_auto_size = $config->{'general'}->{'auto_size'}; if ($config_auto_size) { ## We're using the auto_size functionality if ( isset($_GET['auto_size']) && $_GET['auto_size']) { ## Intial test is done. Set down/upload sizes to the same as ## our initial measured speeds. That way the test should take ## about 8 seconds for each test (up/down) making it about a ## 16 second test $down_kbytes = $_GET['downspeed']; $up_kbytes = $_GET['upspeed']; } else { ## Initial test using auto_size $down_kbytes = $config->{'download'}->{'initial_kbytes'}; $up_kbytes = $config->{'upload'}->{'initial_kbytes'}; } } else { ## auto_size is off. Just to the default sizes $down_kbytes = $config->{'download'}->{'default_kbytes'}; $up_kbytes = $config->{'upload'}->{'default_kbytes'}; } ## Make sure sizes are below our configured limits if ($down_kbytes > $config->{'download'}->{'max_kbytes'}) { $down_kbytes = $config->{'download'}->{'max_kbytes'}; } if ($up_kbytes > $config->{'upload'}->{'max_kbytes'}) { $up_kbytes = $config->{'upload'}->{'max_kbytes'}; } if ($config->{'upload'}->{'skip_upload'}) { $up_kbytes = 0; } ## Calculate number of loops for up/down, etc $each_chunk = 50; $progress_bar_width="400"; $reloads = $down_kbytes / $each_chunk; $increment = $progress_bar_width / $reloads; $download_progress_bar_increment = $increment; $reloads = $up_kbytes / $each_chunk; $increment = $progress_bar_width / $reloads; $upload_progress_bar_increment = $increment / 5; $pretty_version = $config->{'general'}->{'pretty_version'}; ?> <?php print $config->{'general'}->{'page_title'}; ?> - Fancy Speed Test


\n"; } ?>
Calculating appropriate file sizes for testing
\n"; ob_flush(); } else { ?>
Conducting Download Test ( kb)
Powered by Fancy Speed Test
"; } ## Read some stuff from our payload file $data_file = "payload.js"; $fd = fopen ($data_file, "r"); $data = fread ($fd, $each_chunk * 1024); ## Download $extra_down_kbytes first as junk $extra_down_kbytes = $down_kbytes - $up_kbytes; $total_kbytes = 0; while ($total_kbytes <= $extra_down_kbytes) { if ($pretty_version) { print " "; } else { print "dataElement.value=\"$data\";\n"; } $total_kbytes += $each_chunk; } if (!$pretty_version) { print "dataElement.value=\"$data\";"; print "CompleteDownloadBar();\n"; } else { print " "; } ## Now, download the remaining bytes ($up_kbytes) and save it into a ## form variable that we will post back to test the upload speed while ($total_kbytes <= $down_kbytes) { if ($pretty_version) { print " "; } else { print "dataElement.value = dataElement.value + \"$data\";\n"; } $total_kbytes += $each_chunk; } if (!$pretty_version) { #print "\";"; } else { print "