Skip to content

Commit 904d489

Browse files
Simon SchickSimon Schick
Simon Schick
authored and
Simon Schick
committed
Merge pull request #6 from kenjis/my_fix
* Fixed uninitialized variables in phpSysInfo package * Removed @-operator used for MySQL-functions * If mysql is not reachable the script will strictly die * Updated licenses to proper GNU-license (unmodified) * Fixed wrong variable names in mysql-file when checking the username and password * Partially removed transactions as it was not fully implemented * Updated error-handling while figuring out if package is installed
2 parents f5435c4 + 73c7408 commit 904d489

6 files changed

+582
-791
lines changed

docs/PHPSPEED_LICENSE.txt

+238-381
Large diffs are not rendered by default.

docs/PHPSYSINFO_LICENSE.txt

+238-381
Large diffs are not rendered by default.

inc/functions.server.php

+30
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
<?php
2+
/**
3+
* PHPspeed
4+
*
5+
* @author http://www.phpspeed.com
6+
* @copyright 2006 http://www.phpspeed.com
7+
* @license GPLv2 (or later)
8+
*/
9+
10+
/**
11+
* 2012/03/03 Modified by Kenji Suzuki <https://github.com/kenjis/>
12+
*/
13+
14+
/***************************************************************************
15+
*
16+
* PHPspeed.com | PHP Benchmarking Script
17+
* http://www.phpspeed.com
18+
*
19+
* Sat Mar 17, 2007 3:53 pm
20+
* PHPspeed is now GPL licensed!!
21+
* See http://www.phpspeed.com/phpspeed-forums-f1/phpspeed-is-now-gpl-licensed-t18.html
22+
*
23+
***************************************************************************/
24+
225
/***************************************************************************
326
*
427
* PHPspeed.com | PHP Benchmarking Script
@@ -55,6 +78,13 @@
5578

5679
//THIS PROVIDES MEMORY INFO
5780
$meminfo = file("/proc/meminfo");
81+
$total_mem = 0;
82+
$free_mem = 0;
83+
$total_swap = 0;
84+
$free_swap = 0;
85+
$buffer_mem = 0;
86+
$cache_mem = 0;
87+
$shared_mem = 0;
5888
for ($i = 0; $i < count($meminfo); $i++) {
5989
list($item, $data) = explode(":", $meminfo[$i], 2);
6090
$item = chop($item);

inc/mysql.php

+46-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
<?php
2+
/**
3+
* PHPspeed
4+
*
5+
* @author http://www.phpspeed.com
6+
* @copyright 2006 http://www.phpspeed.com
7+
* @license GPLv2 (or later)
8+
*/
9+
10+
/**
11+
* 2012/03/03 Modified by Kenji Suzuki <https://github.com/kenjis/>
12+
*/
13+
14+
/***************************************************************************
15+
*
16+
* PHPspeed.com | PHP Benchmarking Script
17+
* http://www.phpspeed.com
18+
*
19+
* Sat Mar 17, 2007 3:53 pm
20+
* PHPspeed is now GPL licensed!!
21+
* See http://www.phpspeed.com/phpspeed-forums-f1/phpspeed-is-now-gpl-licensed-t18.html
22+
*
23+
***************************************************************************/
24+
225
/***************************************************************************
326
*
427
* PHPspeed.com | PHP Benchmarking Script
@@ -38,29 +61,29 @@ function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = tr
3861

3962
if($this->persistency)
4063
{
41-
$this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
64+
$this->db_connect_id = mysql_pconnect($this->server, $this->user, $this->password);
4265
}
4366
else
4467
{
45-
$this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
68+
$this->db_connect_id = mysql_connect($this->server, $this->user, $this->password);
4669
}
4770
if($this->db_connect_id)
4871
{
4972
if($database != "")
5073
{
5174
$this->dbname = $database;
52-
$dbselect = @mysql_select_db($this->dbname);
75+
$dbselect = mysql_select_db($this->dbname);
5376
if(!$dbselect)
5477
{
55-
@mysql_close($this->db_connect_id);
78+
mysql_close($this->db_connect_id);
5679
$this->db_connect_id = $dbselect;
5780
}
5881
}
5982
return $this->db_connect_id;
6083
}
6184
else
6285
{
63-
return false;
86+
die('Could not connect to the Mysql server !!');
6487
}
6588
}
6689

@@ -73,9 +96,9 @@ function sql_close()
7396
{
7497
if($this->query_result)
7598
{
76-
@mysql_free_result($this->query_result);
99+
mysql_free_result($this->query_result);
77100
}
78-
$result = @mysql_close($this->db_connect_id);
101+
$result = mysql_close($this->db_connect_id);
79102
return $result;
80103
}
81104
else
@@ -94,7 +117,7 @@ function sql_query($query = "", $transaction = FALSE)
94117
if($query != "")
95118
{
96119
$this->num_queries++;
97-
$this->query_result = @mysql_query($query, $this->db_connect_id);
120+
$this->query_result = mysql_query($query, $this->db_connect_id);
98121
}
99122
if($this->query_result)
100123
{
@@ -104,7 +127,7 @@ function sql_query($query = "", $transaction = FALSE)
104127
}
105128
else
106129
{
107-
return ( $transaction == END_TRANSACTION ) ? true : false;
130+
return false;
108131
}
109132
}
110133

@@ -119,7 +142,7 @@ function sql_numrows($query_id = 0)
119142
}
120143
if($query_id)
121144
{
122-
$result = @mysql_num_rows($query_id);
145+
$result = mysql_num_rows($query_id);
123146
return $result;
124147
}
125148
else
@@ -131,7 +154,7 @@ function sql_affectedrows()
131154
{
132155
if($this->db_connect_id)
133156
{
134-
$result = @mysql_affected_rows($this->db_connect_id);
157+
$result = mysql_affected_rows($this->db_connect_id);
135158
return $result;
136159
}
137160
else
@@ -147,7 +170,7 @@ function sql_numfields($query_id = 0)
147170
}
148171
if($query_id)
149172
{
150-
$result = @mysql_num_fields($query_id);
173+
$result = mysql_num_fields($query_id);
151174
return $result;
152175
}
153176
else
@@ -163,7 +186,7 @@ function sql_fieldname($offset, $query_id = 0)
163186
}
164187
if($query_id)
165188
{
166-
$result = @mysql_field_name($query_id, $offset);
189+
$result = mysql_field_name($query_id, $offset);
167190
return $result;
168191
}
169192
else
@@ -179,7 +202,7 @@ function sql_fieldtype($offset, $query_id = 0)
179202
}
180203
if($query_id)
181204
{
182-
$result = @mysql_field_type($query_id, $offset);
205+
$result = mysql_field_type($query_id, $offset);
183206
return $result;
184207
}
185208
else
@@ -195,9 +218,9 @@ function sql_fetchrow($query_id = 0)
195218
}
196219
if($query_id)
197220
{
198-
//// $this->row[$query_id] = @mysql_fetch_array($query_id);
221+
//// $this->row[$query_id] = mysql_fetch_array($query_id);
199222
// return $this->row[$query_id];
200-
return @mysql_fetch_array($query_id);
223+
return mysql_fetch_array($query_id);
201224
}
202225
else
203226
{
@@ -214,7 +237,7 @@ function sql_fetchrowset($query_id = 0)
214237
{
215238
unset($this->rowset[$query_id]);
216239
unset($this->row[$query_id]);
217-
while($this->rowset[$query_id] = @mysql_fetch_array($query_id))
240+
while($this->rowset[$query_id] = mysql_fetch_array($query_id))
218241
{
219242
$result[] = $this->rowset[$query_id];
220243
}
@@ -235,7 +258,7 @@ function sql_fetchfield($field, $rownum = -1, $query_id = 0)
235258
{
236259
if($rownum > -1)
237260
{
238-
$result = @mysql_result($query_id, $rownum, $field);
261+
$result = mysql_result($query_id, $rownum, $field);
239262
}
240263
else
241264
{
@@ -272,7 +295,7 @@ function sql_rowseek($rownum, $query_id = 0){
272295
}
273296
if($query_id)
274297
{
275-
$result = @mysql_data_seek($query_id, $rownum);
298+
$result = mysql_data_seek($query_id, $rownum);
276299
return $result;
277300
}
278301
else
@@ -283,7 +306,7 @@ function sql_rowseek($rownum, $query_id = 0){
283306
function sql_nextid(){
284307
if($this->db_connect_id)
285308
{
286-
$result = @mysql_insert_id($this->db_connect_id);
309+
$result = mysql_insert_id($this->db_connect_id);
287310
return $result;
288311
}
289312
else
@@ -302,7 +325,7 @@ function sql_freeresult($query_id = 0){
302325
unset($this->row[$query_id]);
303326
unset($this->rowset[$query_id]);
304327

305-
@mysql_free_result($query_id);
328+
mysql_free_result($query_id);
306329

307330
return true;
308331
}
@@ -313,8 +336,8 @@ function sql_freeresult($query_id = 0){
313336
}
314337
function sql_error($query_id = 0)
315338
{
316-
$result["message"] = @mysql_error($this->db_connect_id);
317-
$result["code"] = @mysql_errno($this->db_connect_id);
339+
$result["message"] = mysql_error($this->db_connect_id);
340+
$result["code"] = mysql_errno($this->db_connect_id);
318341

319342
return $result;
320343
}

index.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121

2222
$sql = "SELECT * FROM phpspeed_config";
2323
$result = $db->sql_query($sql);
24-
$ver = mysql_fetch_assoc($result);
2524

26-
if ($ver == "")
25+
if ($result === false)
2726
{
2827
header("Location:install/install.php");
2928
die;
3029
}
3130

31+
$ver = mysql_fetch_assoc($result);
32+
3233
session_start();
3334

3435
if (isset($_GET['action']) and $_GET['action'] == 'logout') {
@@ -232,7 +233,7 @@
232233
<td class="row1">PHP ver: <b><?php echo phpversion(); ?></b></td>
233234
<td class="row1">MySQL ver: <b><?php printf(mysql_get_server_info()); ?></b></td>
234235
<td class="row1">Server: <b><?php echo $_SERVER['SERVER_SOFTWARE']; ?></b></td>
235-
<td class="row1">Last Test: <?php echo date("m/d/y", $ver['last_test']) ?></td>
236+
<td class="row1">Last Test: <?php echo date("m/d/y", (int) $ver['last_test']) ?></td>
236237
</tr>
237238
<tr>
238239
<td class="row1"><a href="http://www.phpspeed.com/phpbenchmark.php"><img src="inc/phpspeed.php" border="0" alt="php benchmark"></a></td>

mysql.php

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
<?php
2+
/**
3+
* PHPspeed
4+
*
5+
* @author http://www.phpspeed.com
6+
* @copyright 2006 http://www.phpspeed.com
7+
* @license GPLv2 (or later)
8+
*/
9+
10+
/**
11+
* 2012/03/03 Modified by Kenji Suzuki <https://github.com/kenjis/>
12+
*/
13+
14+
/***************************************************************************
15+
*
16+
* PHPspeed.com | PHP Benchmarking Script
17+
* http://www.phpspeed.com
18+
*
19+
* Sat Mar 17, 2007 3:53 pm
20+
* PHPspeed is now GPL licensed!!
21+
* See http://www.phpspeed.com/phpspeed-forums-f1/phpspeed-is-now-gpl-licensed-t18.html
22+
*
23+
***************************************************************************/
24+
225
/***************************************************************************
326
*
427
* PHPspeed.com | PHP Benchmarking Script
@@ -105,8 +128,8 @@
105128
}
106129
else
107130
{
108-
if( $user == 'root' ) {
109-
if( $password == '') {
131+
if( $dbuname == 'root' ) {
132+
if( $dbpass == '') {
110133
echo "<font color=red><b>Your user and password are the install default (user:root and password is blank), change it !!</b></font><br><br>";
111134
}
112135

@@ -160,7 +183,7 @@
160183
if($p%2==0){
161184
echo '</tr><tr>';
162185
}
163-
echo '<td class=row1><span class=gen>&nbsp;' . $row['Variable_name'] . '</span></td><td class=row1><span class=gen>&nbsp;' . number_format($row['Value']) . "</span></td>";
186+
echo '<td class=row1><span class=gen>&nbsp;' . $row['Variable_name'] . '</span></td><td class=row1><span class=gen>&nbsp;' . number_format((double) $row['Value']) . "</span></td>";
164187
}
165188
}
166189

0 commit comments

Comments
 (0)