Skip to content

Commit

Permalink
Merge pull request #6 from kenjis/my_fix
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Simon Schick authored and Simon Schick committed Mar 9, 2012
2 parents f5435c4 + 73c7408 commit 904d489
Show file tree
Hide file tree
Showing 6 changed files with 582 additions and 791 deletions.
619 changes: 238 additions & 381 deletions docs/PHPSPEED_LICENSE.txt

Large diffs are not rendered by default.

619 changes: 238 additions & 381 deletions docs/PHPSYSINFO_LICENSE.txt

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions inc/functions.server.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
<?php
/**
* PHPspeed
*
* @author http://www.phpspeed.com
* @copyright 2006 http://www.phpspeed.com
* @license GPLv2 (or later)
*/

/**
* 2012/03/03 Modified by Kenji Suzuki <https://github.com/kenjis/>
*/

/***************************************************************************
*
* PHPspeed.com | PHP Benchmarking Script
* http://www.phpspeed.com
*
* Sat Mar 17, 2007 3:53 pm
* PHPspeed is now GPL licensed!!
* See http://www.phpspeed.com/phpspeed-forums-f1/phpspeed-is-now-gpl-licensed-t18.html
*
***************************************************************************/

/***************************************************************************
*
* PHPspeed.com | PHP Benchmarking Script
Expand Down Expand Up @@ -55,6 +78,13 @@

//THIS PROVIDES MEMORY INFO
$meminfo = file("/proc/meminfo");
$total_mem = 0;
$free_mem = 0;
$total_swap = 0;
$free_swap = 0;
$buffer_mem = 0;
$cache_mem = 0;
$shared_mem = 0;
for ($i = 0; $i < count($meminfo); $i++) {
list($item, $data) = explode(":", $meminfo[$i], 2);
$item = chop($item);
Expand Down
69 changes: 46 additions & 23 deletions inc/mysql.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
<?php
/**
* PHPspeed
*
* @author http://www.phpspeed.com
* @copyright 2006 http://www.phpspeed.com
* @license GPLv2 (or later)
*/

/**
* 2012/03/03 Modified by Kenji Suzuki <https://github.com/kenjis/>
*/

/***************************************************************************
*
* PHPspeed.com | PHP Benchmarking Script
* http://www.phpspeed.com
*
* Sat Mar 17, 2007 3:53 pm
* PHPspeed is now GPL licensed!!
* See http://www.phpspeed.com/phpspeed-forums-f1/phpspeed-is-now-gpl-licensed-t18.html
*
***************************************************************************/

/***************************************************************************
*
* PHPspeed.com | PHP Benchmarking Script
Expand Down Expand Up @@ -38,29 +61,29 @@ function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = tr

if($this->persistency)
{
$this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
$this->db_connect_id = mysql_pconnect($this->server, $this->user, $this->password);
}
else
{
$this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
$this->db_connect_id = mysql_connect($this->server, $this->user, $this->password);
}
if($this->db_connect_id)
{
if($database != "")
{
$this->dbname = $database;
$dbselect = @mysql_select_db($this->dbname);
$dbselect = mysql_select_db($this->dbname);
if(!$dbselect)
{
@mysql_close($this->db_connect_id);
mysql_close($this->db_connect_id);
$this->db_connect_id = $dbselect;
}
}
return $this->db_connect_id;
}
else
{
return false;
die('Could not connect to the Mysql server !!');
}
}

Expand All @@ -73,9 +96,9 @@ function sql_close()
{
if($this->query_result)
{
@mysql_free_result($this->query_result);
mysql_free_result($this->query_result);
}
$result = @mysql_close($this->db_connect_id);
$result = mysql_close($this->db_connect_id);
return $result;
}
else
Expand All @@ -94,7 +117,7 @@ function sql_query($query = "", $transaction = FALSE)
if($query != "")
{
$this->num_queries++;
$this->query_result = @mysql_query($query, $this->db_connect_id);
$this->query_result = mysql_query($query, $this->db_connect_id);
}
if($this->query_result)
{
Expand All @@ -104,7 +127,7 @@ function sql_query($query = "", $transaction = FALSE)
}
else
{
return ( $transaction == END_TRANSACTION ) ? true : false;
return false;
}
}

Expand All @@ -119,7 +142,7 @@ function sql_numrows($query_id = 0)
}
if($query_id)
{
$result = @mysql_num_rows($query_id);
$result = mysql_num_rows($query_id);
return $result;
}
else
Expand All @@ -131,7 +154,7 @@ function sql_affectedrows()
{
if($this->db_connect_id)
{
$result = @mysql_affected_rows($this->db_connect_id);
$result = mysql_affected_rows($this->db_connect_id);
return $result;
}
else
Expand All @@ -147,7 +170,7 @@ function sql_numfields($query_id = 0)
}
if($query_id)
{
$result = @mysql_num_fields($query_id);
$result = mysql_num_fields($query_id);
return $result;
}
else
Expand All @@ -163,7 +186,7 @@ function sql_fieldname($offset, $query_id = 0)
}
if($query_id)
{
$result = @mysql_field_name($query_id, $offset);
$result = mysql_field_name($query_id, $offset);
return $result;
}
else
Expand All @@ -179,7 +202,7 @@ function sql_fieldtype($offset, $query_id = 0)
}
if($query_id)
{
$result = @mysql_field_type($query_id, $offset);
$result = mysql_field_type($query_id, $offset);
return $result;
}
else
Expand All @@ -195,9 +218,9 @@ function sql_fetchrow($query_id = 0)
}
if($query_id)
{
//// $this->row[$query_id] = @mysql_fetch_array($query_id);
//// $this->row[$query_id] = mysql_fetch_array($query_id);
// return $this->row[$query_id];
return @mysql_fetch_array($query_id);
return mysql_fetch_array($query_id);
}
else
{
Expand All @@ -214,7 +237,7 @@ function sql_fetchrowset($query_id = 0)
{
unset($this->rowset[$query_id]);
unset($this->row[$query_id]);
while($this->rowset[$query_id] = @mysql_fetch_array($query_id))
while($this->rowset[$query_id] = mysql_fetch_array($query_id))
{
$result[] = $this->rowset[$query_id];
}
Expand All @@ -235,7 +258,7 @@ function sql_fetchfield($field, $rownum = -1, $query_id = 0)
{
if($rownum > -1)
{
$result = @mysql_result($query_id, $rownum, $field);
$result = mysql_result($query_id, $rownum, $field);
}
else
{
Expand Down Expand Up @@ -272,7 +295,7 @@ function sql_rowseek($rownum, $query_id = 0){
}
if($query_id)
{
$result = @mysql_data_seek($query_id, $rownum);
$result = mysql_data_seek($query_id, $rownum);
return $result;
}
else
Expand All @@ -283,7 +306,7 @@ function sql_rowseek($rownum, $query_id = 0){
function sql_nextid(){
if($this->db_connect_id)
{
$result = @mysql_insert_id($this->db_connect_id);
$result = mysql_insert_id($this->db_connect_id);
return $result;
}
else
Expand All @@ -302,7 +325,7 @@ function sql_freeresult($query_id = 0){
unset($this->row[$query_id]);
unset($this->rowset[$query_id]);

@mysql_free_result($query_id);
mysql_free_result($query_id);

return true;
}
Expand All @@ -313,8 +336,8 @@ function sql_freeresult($query_id = 0){
}
function sql_error($query_id = 0)
{
$result["message"] = @mysql_error($this->db_connect_id);
$result["code"] = @mysql_errno($this->db_connect_id);
$result["message"] = mysql_error($this->db_connect_id);
$result["code"] = mysql_errno($this->db_connect_id);

return $result;
}
Expand Down
7 changes: 4 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@

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

if ($ver == "")
if ($result === false)
{
header("Location:install/install.php");
die;
}

$ver = mysql_fetch_assoc($result);

session_start();

if (isset($_GET['action']) and $_GET['action'] == 'logout') {
Expand Down Expand Up @@ -232,7 +233,7 @@
<td class="row1">PHP ver: <b><?php echo phpversion(); ?></b></td>
<td class="row1">MySQL ver: <b><?php printf(mysql_get_server_info()); ?></b></td>
<td class="row1">Server: <b><?php echo $_SERVER['SERVER_SOFTWARE']; ?></b></td>
<td class="row1">Last Test: <?php echo date("m/d/y", $ver['last_test']) ?></td>
<td class="row1">Last Test: <?php echo date("m/d/y", (int) $ver['last_test']) ?></td>
</tr>
<tr>
<td class="row1"><a href="http://www.phpspeed.com/phpbenchmark.php"><img src="inc/phpspeed.php" border="0" alt="php benchmark"></a></td>
Expand Down
29 changes: 26 additions & 3 deletions mysql.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
<?php
/**
* PHPspeed
*
* @author http://www.phpspeed.com
* @copyright 2006 http://www.phpspeed.com
* @license GPLv2 (or later)
*/

/**
* 2012/03/03 Modified by Kenji Suzuki <https://github.com/kenjis/>
*/

/***************************************************************************
*
* PHPspeed.com | PHP Benchmarking Script
* http://www.phpspeed.com
*
* Sat Mar 17, 2007 3:53 pm
* PHPspeed is now GPL licensed!!
* See http://www.phpspeed.com/phpspeed-forums-f1/phpspeed-is-now-gpl-licensed-t18.html
*
***************************************************************************/

/***************************************************************************
*
* PHPspeed.com | PHP Benchmarking Script
Expand Down Expand Up @@ -105,8 +128,8 @@
}
else
{
if( $user == 'root' ) {
if( $password == '') {
if( $dbuname == 'root' ) {
if( $dbpass == '') {
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>";
}

Expand Down Expand Up @@ -160,7 +183,7 @@
if($p%2==0){
echo '</tr><tr>';
}
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>";
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>";
}
}

Expand Down

0 comments on commit 904d489

Please sign in to comment.