-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbenchhistory.php
242 lines (189 loc) · 8.33 KB
/
benchhistory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?php
define('IN_PHPSPEED', true);
include "config_db.php";
include "inc/mysql.php";
$self = $_SERVER['PHP_SELF'];
session_start();
if (isset($_GET['action']) and $_GET['action'] == 'logout') {
session_start();
session_destroy();
header("Location: $self");
}
if(isset($_SESSION['logged']) && $_SESSION['logged'] == 'yes') {
$login = "<a href=\"$self?action=logout\"><img align=\"middle\" src=\"inc/images/exit.gif\" border=\"0\" hspace=\"6\" alt=\"logout\"></a>";
} else {
$login = "<span class=\"gen\"><form name=\"login\" action=\"$self\" method=\"POST\" style=\"margin:0;\"><input type=\"hidden\" name=\"submit\">Name: <input type=\"text\" name=\"user\" size=\"10\" class=\"post\"> Pass: <input type=\"password\" name=\"pass\" size=\"10\" class=\"post\"> <input name=\"Submit\" type=\"submit\" class=\"button\" value=\"Login\"></form></span>";
}
$u = isset($_POST['user']) ? $_POST['user'] : ''; //username from form
$p = isset($_POST['pass']) ? $_POST['pass'] : ''; // password from form.
if ($u == "$admin" && $p == "$pass"){
$_SESSION['user'] = $u;
$_SESSION['logged'] = "yes";
header("Location: $self");
}
$db = new sql_db($dbhost, $dbuname, $dbpass, $dbname, false);
if(!$db->db_connect_id)
{
message_die(CRITICAL_ERROR, "Could not connect to the database");
}
$sql = "SELECT * FROM phpspeed_config";
$result = $db->sql_query($sql);
$ver = mysql_fetch_assoc($result);
$b = htmlentities(addslashes($_GET['bench']));
switch ($b){
case "1":
$r="1";
$t="Synthetic PHP BenchMark";
break;
case "2":
$r="2";
$t="Synthetic MySQL BenchMark";
break;
case "3":
$r="3";
$t="Synthetic Read/Write BenchMark";
break;
case "4":
$r="4";
$t="Real World PHP BenchMark";
break;
case "5":
$r="5";
$t="Real World PHP & MySQL BenchMark";
break;
case "6":
$r="6";
$t="Server Benchmark";
break;
default:
$r="1";
$t="Synthetic PHP BenchMark";
break;
}
$result = $db->sql_query("SELECT * FROM results$r ORDER BY testid DESC LIMIT 0,15");
$result2 = $db->sql_query("SELECT avg(score) FROM results$r");
$row2 = $db->sql_fetchrow($result2);
$avg = number_format($row2["avg(score)"]);
$result3 = $db->sql_query("SELECT timestamp, score FROM results$r ORDER BY score DESC");
$row3 = $db->sql_fetchrow($result3);
$max = number_format($row3["score"]);
$num = mysql_num_rows($result3);
if (isset($_GET['erase']) && ($_GET['erase'] == '1')) {
$del = "yes";
} else {
$del = "";
}
if (isset($_GET['conf']) && ($_GET['conf'] == '1')) {
$conf = "1";
} else {
$conf = "";
}
if (isset($_GET['csv']) && ($_GET['csv'] == '1')) {
$csv = "yes";
} else {
$csv = "";
}
if ($csv == 'yes') {
$csv_output = '"Test ID","Date","CPU","Uptime","Memory","PHPspeed","PHP","MySQL","Server","Test Results","Tests Run","Iterations","Total Time","Score","Site"';
$csv_output .= "\015\012";
$result = $db->sql_query("SELECT * FROM results$r ORDER BY testid DESC");
while(($row = mysql_fetch_array($result))) {
$csv_output .= '"'.$row['testid'].'","'. date("m/d/y",$row['timestamp']).'","'.$row['cpu'].'","'.$row['uptime'].'","'.$row['memory'].'","'.$row['phpspeed_version'].'","'.$row['php_version'].'","'.$row['mysql_version'].'","'.$row['server_software'].'","'. $row['test_results'].'","'.$row['tests_run'].'","'.$row['iterations'].'","'.$row['total_time'].'","'.$row['score'].'","'.$row['site'].'"';
$csv_output .= "\015\012";
}
//You cannot have the breaks in the same feed as the content.
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=\"PHPspeed_Benchmark".$r."_". date("dmy") . ".csv\"");
print $csv_output;
exit;
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PHPspeed | Test Results</title>
<meta http-equiv="content-language" content="en-us" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="start" title="Home" href="http://www.phpspeed.com/" />
<link rel="stylesheet" type="text/css" media="screen" href="inc/Style.css" />
</head>
<body>
<table width="97%" cellspacing="0" cellpadding="15" border="0" align="center">
<tr>
<td>
<span class="maintitle">PHPspeed <?php echo $ver['version']; ?></span><br />
<span class="mainmenu"><a href="index.php">Home</a> •
<a href="phpinfo.php">PHP Info</a> •
<a href="mysql.php">MySQL Info</a> •
<a href="info.php">System Info</a></span>
</td>
<td align="right">
<?php echo $login; ?>
</td>
</tr>
</table>
<?php
if (($del == 'yes') && ($conf != '1')) {
if(isset($_SESSION['logged']) && $_SESSION['logged'] == 'yes') {
?>
<H6> Are you sure?</h6>
<table width="94%" cellpadding="9" cellspacing="1" align="center" class="forumline">
<tr>
<td align="left" class="row2"><span style="color:yellow"> Are you sure you want to delete all results for Test # <?php echo $r; ?> <a href="benchhistory.php?conf=1&bench=<?php echo $r; ?>"><b>YES</b></a></span></td>
</tr>
</table><br />
<?php } else {
echo "<table width=\"95%\" align=\"center\">
<tr>
<td width=\"100%\">
<table class=\"forumline\" cellpadding=\"8\">
<tr>
<td class=\"row1\">You need to login to view this page...</td>
</tr>
</table>
</td>
</tr>
</table>";
}
} else if (($del != 'yes') && ($conf == '1')) {
if(isset($_SESSION['logged']) && $_SESSION['logged'] == 'yes') {
$result3 = $db->sql_query("TRUNCATE TABLE results$r");
}
?>
<H6> All data deleted...</h6>
<table width="94%" cellpadding="9" cellspacing="1" align="center" class="forumline">
<tr>
<td align="left" class="row2"><span style="color:yellow">SUCCESS! All data has been deleted.</span></td>
</tr>
</table><br />
<?php
} else {
?>
<H6> <?php echo $t; ?></h6>
<table width="94%" cellpadding="9" cellspacing="1" align="center" class="forumline">
<tr>
<th align="center">Tests Run: <?php echo $num; ?></th><th align="center">Best Score: <?php echo $max; ?></th><th align="center">Avg. Score: <?php echo $avg; ?></th>
</tr>
</table><br />
<h6> Last 15 Tests</h6>
<table width="94%" cellpadding="9" cellspacing="1" align="center" class="forumline">
<tr><th align="center">Date</th><th align="center">PHPspeed</th><th align="center">PHP</th><th align="center">MySQL</th><th align="center">Tests</th><th align="center">Iterations</th><th align="center">Time</th><th align="center">Score</th></tr>
<?php
while (($row = mysql_fetch_assoc($result))) {
echo "<tr><td class=\"row1\">" . date("m/d/y", $row["timestamp"]) . "</td><td class=\"row1\">" . $row["phpspeed_version"] . "</td><td class=\"row1\">" . $row["php_version"] . "</td><td class=\"row1\">" . $row["mysql_version"] . "</td><td class=\"row1\" align=\"center\">" . $row["tests_run"] . "</td><td class=\"row1\" align=\"center\">" . $row["iterations"] . "</td><td class=\"row1\" align=\"center\">" . $row["total_time"] . "</td><td class=\"row1\" align=\"center\">" . $row["score"] . "</td></tr>";
}
?>
</table>
<?php
echo "<table width=\"94%\" cellpadding=\"8\" cellspacing=\"1\" class=\"forumline\" align=\"center\">
<tr>
<td class=\"row2\" align=\"right\">
<a href=\"".$_SERVER['PHP_SELF']."?bench=$r&erase=1\"><img src=\"inc/images/delete.png\" align=\"middle\" border=\"0\"></a> <span class=\"gensmall\"><a href=\"".$_SERVER['PHP_SELF']."?bench=$r&erase=1\">Delete</a></span>
<a href=\"".$_SERVER['PHP_SELF']."?bench=$r&csv=1\"><img src=\"inc/images/csv.png\" border=\"0\"></a> <span class=\"gensmall\"> <a href=\"".$_SERVER['PHP_SELF']."?bench=$r&csv=1\">Save CSV</a></span>
</td>
</tr>
</table>";
}
?>
</body>
</html>