Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
Location:
trunk/Modules/SpeedTest
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/SpeedTest/SpeedTest.php

    r738 r873  
    3939  function Show()
    4040  {
    41     if(count($this->System->PathItems) > 1)
     41    if (count($this->System->PathItems) > 1)
    4242    {
    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());
    4747  }
    4848
     
    6262
    6363## Redirect immediately to download.php if auto_start = 1
    64 if($config->{'general'}->{'auto_start'}) {
     64if ($config->{'general'}->{'auto_start'}) {
    6565    Header("Location: ".$config['general']['base_url']."/download.php");
    6666    exit;
     
    7777<body>';
    7878
    79 if(file_exists("header.html")) {
     79if (file_exists("header.html")) {
    8080    ## Include "header.html" for a custom header, if the file exists
    8181    include("header.html");
     
    8686$Output .= '<div id="speedtest_content">';
    8787
    88 if(file_exists("welcome.html")) {
     88if (file_exists("welcome.html")) {
    8989    ## Include "welcome.html" for a custom welcome page, if the file exists
    9090    include("welcome.html");
     
    107107</div>';
    108108
    109 if(file_exists("footer.html")) {
     109if (file_exists("footer.html")) {
    110110    ## Include "footer.html" for a custom footer, if the file exists
    111111    include("footer.html");
     
    114114    print "</center>\n";
    115115}
    116     return($Output);
     116    return ($Output);
    117117  }
    118118}
  • trunk/Modules/SpeedTest/common.php

    r560 r873  
    1818    foreach ($lines as $line_num => $line) {
    1919        $line = rtrim(preg_replace("/#.*/","",$line));
    20         if(preg_match("/\[.*\]/", $line, $parts)) {
     20        if (preg_match("/\[.*\]/", $line, $parts)) {
    2121            $section = $parts[0];
    2222            $section = preg_replace("/[\[\]]/","",$section);
     
    3434function Debug($message) {
    3535    global $config;
    36     if($config->{'general'}->{'debug'}) {
     36    if ($config->{'general'}->{'debug'}) {
    3737        BCLog($message);
    3838    }
     
    4343    global $config;
    4444    $logfile = $config->{'general'}->{'logfile'};
    45     if(! $logfile) {
     45    if (! $logfile) {
    4646        return;
    4747    }
  • trunk/Modules/SpeedTest/download.php

    r738 r873  
    1919$disallow = $config->{'general'}->{'disallow'};
    2020$allow = $config->{'general'}->{'allow'};
    21 if( $allow && (! preg_match("/$allow/",$remote_addr)) ) {
     21if ( $allow && (! preg_match("/$allow/",$remote_addr)) ) {
    2222    include("unallowed.html");
    2323    exit;
    24 } elseif( $disallow && preg_match("/$disallow/", $remote_addr) ) {
     24} elseif ( $disallow && preg_match("/$disallow/", $remote_addr) ) {
    2525    include("unallowed.html");
    2626    exit;
     
    3333## on initial results
    3434$config_auto_size = $config->{'general'}->{'auto_size'};
    35 if($config_auto_size) {
     35if ($config_auto_size) {
    3636    ## 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']) {
    3838        ## Intial test is done.  Set down/upload sizes to the same as
    3939        ## our initial measured speeds.   That way the test should take
     
    5555
    5656## Make sure sizes are below our configured limits
    57 if($down_kbytes > $config->{'download'}->{'max_kbytes'}) {
     57if ($down_kbytes > $config->{'download'}->{'max_kbytes'}) {
    5858    $down_kbytes = $config->{'download'}->{'max_kbytes'};
    5959}
    60 if($up_kbytes > $config->{'upload'}->{'max_kbytes'}) {
     60if ($up_kbytes > $config->{'upload'}->{'max_kbytes'}) {
    6161    $up_kbytes = $config->{'upload'}->{'max_kbytes'};
    6262}
    6363
    64 if($config->{'upload'}->{'skip_upload'}) {
     64if ($config->{'upload'}->{'skip_upload'}) {
    6565    $up_kbytes = 0;
    6666}
     
    9292
    9393<?php
    94 if(file_exists("header.html")) {
     94if (file_exists("header.html")) {
    9595    ## Include "header.html" for a custom header, if the file exists
    9696    include("header.html");
     
    103103
    104104<?php
    105 if( ($config_auto_size) && (! isset($_GET['auto_size'])) ) {
     105if ( ($config_auto_size) && (! isset($_GET['auto_size'])) ) {
    106106    ## auto_size is performing the initial, small test
    107107    print "<div>Calculating appropriate file sizes for testing</div>\n";
     
    137137</div>
    138138
    139 <?php if(file_exists("footer.html")) { include("footer.html"); } ?>
     139<?php if (file_exists("footer.html")) { include("footer.html"); } ?>
    140140
    141141<?php /* Begin JavaScript functions that we'll need */ ?>
     
    144144function StartUpload() {
    145145    uploadDiv = document.getElementById('upload_message');
    146     if(uploadDiv) {
     146    if (uploadDiv) {
    147147        uploadDiv.style.visibility='visible';
    148148        uploadDiv.style.display='block';
    149         <?php if($pretty_version) { ?>
     149        <?php if ($pretty_version) { ?>
    150150        setInterval("IncrementUploadBar()",200);
    151151        <?php } ?>
     
    158158function IncrementDownloadBar() {
    159159    download_barElement = document.getElementById('download_bar');
    160     if(download_barElement) {
     160    if (download_barElement) {
    161161        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; ?>) {
    163163            download_barElement.style.width = download_bar_current_width +"px";
    164164        }
     
    176176function IncrementUploadBar() {
    177177    upload_barElement = document.getElementById('upload_bar');
    178     if(upload_barElement) {
     178    if (upload_barElement) {
    179179        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; ?>) {
    181181            upload_barElement.style.width = upload_bar_current_width +"px";
    182182        }
     
    186186function CompleteDownloadBar() {
    187187    download_barElement = document.getElementById('download_bar');
    188     if(download_barElement) {
     188    if (download_barElement) {
    189189        download_barElement.style.width = "100%";
    190190    }
     
    209209<?php
    210210
    211 if($pretty_version) {
     211if ($pretty_version) {
    212212print "
    213213//-->
     
    225225    $extra_down_kbytes = $down_kbytes - $up_kbytes;
    226226    $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) {
    229229        print "
    230230<script language=\"javascript\">
     
    240240        $total_kbytes += $each_chunk;
    241241    }
    242     if(!$pretty_version) {
     242    if (!$pretty_version) {
    243243        print "dataElement.value=\"$data\";";
    244244        print "CompleteDownloadBar();\n";
     
    254254    ## Now, download the remaining bytes ($up_kbytes)  and save it into a
    255255    ## 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) {
    258258        print "
    259259<script language=\"javascript\">
     
    270270    }
    271271
    272     if(!$pretty_version) {
     272    if (!$pretty_version) {
    273273        #print "\";";
    274274    } else {
     
    288288      downloadtime = (endtime - starttime)/1000;
    289289  }
    290     <?php if(! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?>
     290    <?php if (! $config->{'upload'}->{'skip_upload'}){ ?> StartUpload(); <?php } ?>
    291291
    292292  down_size = <?php echo $total_kbytes; ?>;
     
    297297
    298298<?php
    299 if($config_auto_size && (! isset($_GET['auto_size'])) ) {
     299if ($config_auto_size && (! isset($_GET['auto_size'])) ) {
    300300    $params_auto_size = "&auto_size=1";
    301301} else {
    302302    $params_auto_size = "";
    303303}
    304 if($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) {
     304if ($config->{'upload'}->{'skip_upload'} && (! $params_auto_size)) {
    305305    $next_url = $config->{'general'}->{'base_url'}."results.php";
    306306} else {
  • trunk/Modules/SpeedTest/results.php

    r786 r873  
    1616
    1717## Save the results of this speedtest to the database, if enabled
    18 if($config->{'database'}->{'enable'}) {
     18if ($config->{'database'}->{'enable'}) {
    1919    $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'])) ) {
    2121        Debug("Saving to database");
    2222        $dbh = mysql_connect(
     
    5757
    5858<?php
    59 if(file_exists("header.html")) {
     59if (file_exists("header.html")) {
    6060    ## Include "header.html" for a custom header, if the file exists
    6161    include("header.html");
     
    7575    print "<h2>Download Speed: $clean_down</h2>\n";
    7676    ## 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) {
    7979            $download_biggest = $value;
    8080        }
     
    8282    ## Print a pretty table with a graph of the results
    8383    print "<center><table>\n";
    84     foreach($config->{'comparisons-download'} as $key=>$value) {
     84    foreach ($config->{'comparisons-download'} as $key=>$value) {
    8585        $this_bar_width = $bar_width / $download_biggest * $value;
    8686        print "<tr><td>$key</td><td>".CleanSpeed($value)."</td><td width=\"400\">\n";
     
    9797
    9898    ## 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'])) {
    100100        $clean_up = CleanSpeed($_GET['upspeed']);
    101101        $upload_biggest = $_GET['upspeed'];
    102102        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) {
    105105                $upload_biggest = $value;
    106106            }
    107107        }
    108108        print "<table>\n";
    109         foreach($config->{'comparisons-upload'} as $key=>$value) {
     109        foreach ($config->{'comparisons-upload'} as $key=>$value) {
    110110            $this_bar_width = $bar_width / $upload_biggest * $value;
    111111            print "<tr><td>$key</td><td>".CleanSpeed($value)."</td>\n";
     
    128128</div>
    129129
    130 <?php if(file_exists("footer.html")) { include("footer.html"); } ?>
     130<?php if (file_exists("footer.html")) { include("footer.html"); } ?>
    131131
    132132</body>
     
    136136## Convert the raw speed value to a nicer value
    137137function CleanSpeed($kbps) {
    138     if($kbps > 1024)   {
     138    if ($kbps > 1024)   {
    139139        $cleanspeed = round($kbps / 1024,2) . " Mbps";
    140140    } else {
Note: See TracChangeset for help on using the changeset viewer.