source: trunk/Modules/SpeedTest/SpeedTest.php

Last change on this file was 912, checked in by chronos, 3 years ago
  • Modified: Updated Common package.
File size: 3.6 KB
Line 
1<?php
2
3###############################################################################
4## Fancy Speed Test - Easily measure your upload and download speeds
5## Home Page: http://www.brandonchecketts.com/speedtest/
6## Author: Brandon Checketts
7## File: index.php
8## Version: 1.1
9## Date: 2006-02-06
10## Purpose: Display a welcome page, or redirect straight to the
11## download test if auto_start is enabled
12###############################################################################
13
14class ModuleSpeedTest extends Module
15{
16 function __construct(System $System)
17 {
18 parent::__construct($System);
19 $this->Name = 'SpeedTest';
20 $this->Version = '1.0';
21 $this->Creator = 'Chronos';
22 $this->License = 'GNU/GPLv3';
23 $this->Description = 'Testing of download and upload bandwidth';
24 }
25
26 function DoStart(): void
27 {
28 $this->System->Pages['speedtest'] = 'PageSpeedTest';
29 }
30}
31
32class PageSpeedTest extends Page
33{
34 function __construct(System $System)
35 {
36 parent::__construct($System);
37 $this->Title = 'Test rychlosti';
38 $this->Description = 'Test rychlosti připojení';
39 $this->ParentClass = 'PagePortal';
40 }
41
42 function Show(): string
43 {
44 if (count($this->System->PathItems) > 1)
45 {
46 if ($this->System->PathItems[1] == 'download.php') return $this->ShowDownload();
47 //else if ($this->System->PathItems[1] == 'rss') return $this->ShowRSS();
48 else return PAGE_NOT_FOUND;
49 } else return $this->ShowMain();
50 }
51
52 function ShowDownload(): void
53 {
54 global $config;
55 require_once(dirname(__FILE__)."/download.php");
56
57 }
58
59 function ShowMain(): string
60 {
61 global $config;
62
63 require_once(dirname(__FILE__)."/common.php");
64 ReadConfig(dirname(__FILE__)."/speedtest.cfg");
65
66## Redirect immediately to download.php if auto_start = 1
67if ($config->{'general'}->{'auto_start'}) {
68 Header("Location: ".$config['general']['base_url']."/download.php");
69 exit;
70}
71
72$Output = '<html>
73<head>
74<title>'.$config->{'general'}->{'page_title'}.' - Fancy Speed Test</title>
75<meta http-equiv="Expires" CONTENT="Fri, Jan 1 1980 00:00:00 GMT" />
76<meta http-equiv="Pragma" CONTENT="no-cache" />
77<meta http-equiv="Cache-Control" CONTENT="no-cache" />
78<link rel="stylesheet" href="style.css" />
79</head>
80<body>';
81
82if (file_exists("header.html")) {
83 ## Include "header.html" for a custom header, if the file exists
84 include("header.html");
85} else {
86 ## Else just print a plain header
87 print "<center>\n";
88}
89$Output .= '<div id="speedtest_content">';
90
91if (file_exists("welcome.html")) {
92 ## Include "welcome.html" for a custom welcome page, if the file exists
93 include("welcome.html");
94} else {
95 ## Else print a standard welcome message
96
97$Output .= '<center>
98<div style="width: 400px;">
99Welcome to our speedtest. This test will measure your connection speed to and
100from our server by downloading some data from our server, and then uploading it
101back to the server. The test should take approximately 30 seconds to complete.
102</div>
103</center>';
104}
105
106$Output .= '<center><h2><a class="start_test" title="Begin Speed Test" href="'.$config->{'general'}->{'base_url'}.'/download.php">Start Test</a></h2></center>
107<div id="speedtest_credits">
108 Powered by <a title="Brandon Checketts Fancy Source Speedtest" href="http://www.brandonchecketts.com/speedtest/" target="_new">Fancy Speed Test</a>
109</div>
110</div>';
111
112if (file_exists("footer.html")) {
113 ## Include "footer.html" for a custom footer, if the file exists
114 include("footer.html");
115} else {
116 ## Else just print a plain footer
117 print "</center>\n";
118}
119 return $Output;
120 }
121}
122
Note: See TracBrowser for help on using the repository browser.