Changeset 873 for trunk/Modules/SpeedTest
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- Location:
- trunk/Modules/SpeedTest
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/SpeedTest/SpeedTest.php
r738 r873 39 39 function Show() 40 40 { 41 if (count($this->System->PathItems) > 1)41 if (count($this->System->PathItems) > 1) 42 42 { 43 if ($this->System->PathItems[1] == 'download.php') return($this->ShowDownload());44 //else if ($this->System->PathItems[1] == 'rss') return($this->ShowRSS());45 else return (PAGE_NOT_FOUND);46 } else return ($this->ShowMain());43 if ($this->System->PathItems[1] == 'download.php') return ($this->ShowDownload()); 44 //else if ($this->System->PathItems[1] == 'rss') return ($this->ShowRSS()); 45 else return (PAGE_NOT_FOUND); 46 } else return ($this->ShowMain()); 47 47 } 48 48 … … 62 62 63 63 ## Redirect immediately to download.php if auto_start = 1 64 if ($config->{'general'}->{'auto_start'}) {64 if ($config->{'general'}->{'auto_start'}) { 65 65 Header("Location: ".$config['general']['base_url']."/download.php"); 66 66 exit; … … 77 77 <body>'; 78 78 79 if (file_exists("header.html")) {79 if (file_exists("header.html")) { 80 80 ## Include "header.html" for a custom header, if the file exists 81 81 include("header.html"); … … 86 86 $Output .= '<div id="speedtest_content">'; 87 87 88 if (file_exists("welcome.html")) {88 if (file_exists("welcome.html")) { 89 89 ## Include "welcome.html" for a custom welcome page, if the file exists 90 90 include("welcome.html"); … … 107 107 </div>'; 108 108 109 if (file_exists("footer.html")) {109 if (file_exists("footer.html")) { 110 110 ## Include "footer.html" for a custom footer, if the file exists 111 111 include("footer.html"); … … 114 114 print "</center>\n"; 115 115 } 116 return ($Output);116 return ($Output); 117 117 } 118 118 } -
trunk/Modules/SpeedTest/common.php
r560 r873 18 18 foreach ($lines as $line_num => $line) { 19 19 $line = rtrim(preg_replace("/#.*/","",$line)); 20 if (preg_match("/\[.*\]/", $line, $parts)) {20 if (preg_match("/\[.*\]/", $line, $parts)) { 21 21 $section = $parts[0]; 22 22 $section = preg_replace("/[\[\]]/","",$section); … … 34 34 function Debug($message) { 35 35 global $config; 36 if ($config->{'general'}->{'debug'}) {36 if ($config->{'general'}->{'debug'}) { 37 37 BCLog($message); 38 38 } … … 43 43 global $config; 44 44 $logfile = $config->{'general'}->{'logfile'}; 45 if (! $logfile) {45 if (! $logfile) { 46 46 return; 47 47 } -
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 { -
trunk/Modules/SpeedTest/results.php
r786 r873 16 16 17 17 ## Save the results of this speedtest to the database, if enabled 18 if ($config->{'database'}->{'enable'}) {18 if ($config->{'database'}->{'enable'}) { 19 19 $ip_matches = $config->{'database'}->{'ip_matches'}; 20 if ( (! $ip_matches) || ($ip_matches && preg_match("/$ip_matches/",$_SERVER['REMOTE_ADDR'])) ) {20 if ( (! $ip_matches) || ($ip_matches && preg_match("/$ip_matches/",$_SERVER['REMOTE_ADDR'])) ) { 21 21 Debug("Saving to database"); 22 22 $dbh = mysql_connect( … … 57 57 58 58 <?php 59 if (file_exists("header.html")) {59 if (file_exists("header.html")) { 60 60 ## Include "header.html" for a custom header, if the file exists 61 61 include("header.html"); … … 75 75 print "<h2>Download Speed: $clean_down</h2>\n"; 76 76 ## Find the biggest value 77 foreach ($config->{'comparisons-download'} as $key=>$value) {78 if ($value > $download_biggest) {77 foreach ($config->{'comparisons-download'} as $key=>$value) { 78 if ($value > $download_biggest) { 79 79 $download_biggest = $value; 80 80 } … … 82 82 ## Print a pretty table with a graph of the results 83 83 print "<center><table>\n"; 84 foreach ($config->{'comparisons-download'} as $key=>$value) {84 foreach ($config->{'comparisons-download'} as $key=>$value) { 85 85 $this_bar_width = $bar_width / $download_biggest * $value; 86 86 print "<tr><td>$key</td><td>".CleanSpeed($value)."</td><td width=\"400\">\n"; … … 97 97 98 98 ## Don't display the upload stuff if we didn't get a speed to compare with 99 if (isset($_GET['upspeed'])) {99 if (isset($_GET['upspeed'])) { 100 100 $clean_up = CleanSpeed($_GET['upspeed']); 101 101 $upload_biggest = $_GET['upspeed']; 102 102 print "<h2>Upload Speed: $clean_up</h2>\n"; 103 foreach ($config->{'comparisons-upload'} as $key=>$value) {104 if ($value > $upload_biggest) {103 foreach ($config->{'comparisons-upload'} as $key=>$value) { 104 if ($value > $upload_biggest) { 105 105 $upload_biggest = $value; 106 106 } 107 107 } 108 108 print "<table>\n"; 109 foreach ($config->{'comparisons-upload'} as $key=>$value) {109 foreach ($config->{'comparisons-upload'} as $key=>$value) { 110 110 $this_bar_width = $bar_width / $upload_biggest * $value; 111 111 print "<tr><td>$key</td><td>".CleanSpeed($value)."</td>\n"; … … 128 128 </div> 129 129 130 <?php if (file_exists("footer.html")) { include("footer.html"); } ?>130 <?php if (file_exists("footer.html")) { include("footer.html"); } ?> 131 131 132 132 </body> … … 136 136 ## Convert the raw speed value to a nicer value 137 137 function CleanSpeed($kbps) { 138 if ($kbps > 1024) {138 if ($kbps > 1024) { 139 139 $cleanspeed = round($kbps / 1024,2) . " Mbps"; 140 140 } else {
Note:
See TracChangeset
for help on using the changeset viewer.