Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ matrix:
- php: 5.6
- php: 5.3
- php: 5.6
- php: 7.0
- php: nightly
- php: hhvm
allow_failures:
Expand Down
32 changes: 16 additions & 16 deletions Extension/Cache/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ class Mysql extends GetId3
public function __construct($host, $database, $username, $password, $table = 'getid3_cache')
{
// Check for mysql support
if (!function_exists('mysql_pconnect')) {
throw new DefaultException('PHP not compiled with mysql support.');
if (!function_exists('mysqli_connect')) {
throw new DefaultException('PHP not compiled with mysqli support.');
}

// Connect to database
$this->connection = mysql_pconnect($host, $username, $password);
$this->connection = mysqli_connect('p:' . $host, $username, $password);
if (!$this->connection) {
throw new DefaultException('mysql_pconnect() failed - check permissions and spelling.');
throw new DefaultException('mysqli_connect() failed - check permissions and spelling.');
}

// Select database
if (!mysql_select_db($database, $this->connection)) {
if (!mysqli_select_db($this->connection, $database)) {
throw new DefaultException('Cannot use database '.$database);
}

Expand All @@ -131,8 +131,8 @@ public function __construct($host, $database, $username, $password, $table = 'ge

// Check version number and clear cache if changed
$version = '';
if ($this->cursor = mysql_query('SELECT `value` FROM `'.mysql_real_escape_string($this->table)."` WHERE (`filename` = '".mysql_real_escape_string(GetId3Core::VERSION)."') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection)) {
list($version) = mysql_fetch_array($this->cursor);
if ($this->cursor = mysqli_query($this->connection, 'SELECT `value` FROM `'.mysqli_real_escape_string($this->connection, $this->table)."` WHERE (`filename` = '".mysqli_real_escape_string($this->connection, GetId3Core::VERSION)."') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')")) {
list($version) = mysqli_fetch_array($this->cursor);
}
if ($version != GetId3Core::VERSION) {
$this->clear_cache();
Expand All @@ -146,8 +146,8 @@ public function __construct($host, $database, $username, $password, $table = 'ge
*/
public function clear_cache()
{
$this->cursor = mysql_query('DELETE FROM `'.mysql_real_escape_string($this->table).'`', $this->connection);
$this->cursor = mysql_query('INSERT INTO `'.mysql_real_escape_string($this->table)."` VALUES ('".GetId3Core::VERSION."', -1, -1, -1, '".GetId3Core::VERSION."')", $this->connection);
$this->cursor = mysqli_query($this->connection, 'DELETE FROM `'.mysqli_real_escape_string($this->connection, $this->table).'`');
$this->cursor = mysqli_query($this->connection, 'INSERT INTO `'.mysqli_real_escape_string($this->connection, $this->table)."` VALUES ('".GetId3Core::VERSION."', -1, -1, -1, '".GetId3Core::VERSION."')");
}

/**
Expand All @@ -166,10 +166,10 @@ public function analyze($filename)
$filesize = filesize($filename);

// Lookup file
$this->cursor = mysql_query('SELECT `value` FROM `'.mysql_real_escape_string($this->table)."` WHERE (`filename` = '".mysql_real_escape_string($filename)."') AND (`filesize` = '".mysql_real_escape_string($filesize)."') AND (`filetime` = '".mysql_real_escape_string($filetime)."')", $this->connection);
if (mysql_num_rows($this->cursor) > 0) {
$this->cursor = mysqli_query($this->connection, 'SELECT `value` FROM `'.mysqli_real_escape_string($this->connection, $this->table)."` WHERE (`filename` = '".mysqli_real_escape_string($this->connection, $filename)."') AND (`filesize` = '".mysqli_real_escape_string($this->connection, $filesize)."') AND (`filetime` = '".mysqli_real_escape_string($this->connection, $filetime)."')");
if (mysqli_num_rows($this->cursor) > 0) {
// Hit
list($result) = mysql_fetch_array($this->cursor);
list($result) = mysqli_fetch_array($this->cursor);

return unserialize(base64_decode($result));
}
Expand All @@ -180,7 +180,7 @@ public function analyze($filename)

// Save result
if (file_exists($filename)) {
$this->cursor = mysql_query('INSERT INTO `'.mysql_real_escape_string($this->table)."` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('".mysql_real_escape_string($filename)."', '".mysql_real_escape_string($filesize)."', '".mysql_real_escape_string($filetime)."', '".mysql_real_escape_string(time())."', '".mysql_real_escape_string(base64_encode(serialize($analysis)))."')", $this->connection);
$this->cursor = mysqli_query($this->connection, 'INSERT INTO `'.mysqli_real_escape_string($this->connection, $this->table)."` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('".mysqli_real_escape_string($this->connection, $filename)."', '".mysqli_real_escape_string($this->connection, $filesize)."', '".mysqli_real_escape_string($connection, $filetime)."', '".mysqli_real_escape_string($this->connection, time())."', '".mysqli_real_escape_string($this->connection, base64_encode(serialize($analysis)))."')");
}

return $analysis;
Expand All @@ -193,13 +193,13 @@ public function analyze($filename)
*/
private function create_table($drop = false)
{
$this->cursor = mysql_query('CREATE TABLE IF NOT EXISTS `'.mysql_real_escape_string($this->table)."` (
$this->cursor = mysqli_query($this->connection, 'CREATE TABLE IF NOT EXISTS `'.mysqli_real_escape_string($this->connection, $this->table)."` (
`filename` VARCHAR(255) NOT NULL DEFAULT '',
`filesize` INT(11) NOT NULL DEFAULT '0',
`filetime` INT(11) NOT NULL DEFAULT '0',
`analyzetime` INT(11) NOT NULL DEFAULT '0',
`value` TEXT NOT NULL,
PRIMARY KEY (`filename`,`filesize`,`filetime`)) ENGINE=MyISAM", $this->connection);
echo mysql_error($this->connection);
PRIMARY KEY (`filename`,`filesize`,`filetime`)) ENGINE=MyISAM");
echo mysqli_error($this->connection);
}
}
4 changes: 2 additions & 2 deletions Resources/demos/demo.audioinfo.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// | $au = new AudioInfo(); |
// | print_r($au->Info('file.flac'); |
// +----------------------------------------------------------------------+
// | Authors: Allan Hansen <ah�artemis*dk> |
// | Authors: Allan Hansen <ah�artemis*dk> |
// +----------------------------------------------------------------------+
//

Expand All @@ -47,7 +47,7 @@ class AudioInfo
/**
* Constructor
*/
public function AudioInfo()
public function __construct()
{
// Initialize getID3 engine
$this->getID3 = new getID3();
Expand Down
4 changes: 2 additions & 2 deletions Resources/demos/demo.browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,15 @@
echo '<td><b>Average:</b></td>';
echo '<td align="right">'.number_format($TotalScannedFilesize / max($TotalScannedKnownFiles, 1)).'</td>';
echo '<td>&nbsp;</td>';
echo '<td align="right">'.getid3_lib::PlaytimeString($TotalScannedPlaytime / max($TotalScannedPlaytimeFiles, 1)).'</td>';
echo '<td align="right">'.\GetId3\Lib\Helper::PlaytimeString($TotalScannedPlaytime / max($TotalScannedPlaytimeFiles, 1)).'</td>';
echo '<td align="right">'.BitrateText(round(($TotalScannedBitrate / 1000) / max($TotalScannedBitrateFiles, 1))).'</td>';
echo '<td rowspan="2" colspan="'.($columnsintable - 5).'"><table class="table" border="0" cellspacing="0" cellpadding="2"><tr><th align="right">Identified Files:</th><td align="right">'.number_format($TotalScannedKnownFiles).'</td><td>&nbsp;&nbsp;&nbsp;</td><th align="right">Errors:</th><td align="right">'.number_format($FilesWithErrors).'</td></tr><tr><th align="right">Unknown Files:</th><td align="right">'.number_format($TotalScannedUnknownFiles).'</td><td>&nbsp;&nbsp;&nbsp;</td><th align="right">Warnings:</th><td align="right">'.number_format($FilesWithWarnings).'</td></tr></table>';
echo '</tr>';
echo '<tr bgcolor="#'.$getID3checkColor_Head.'">';
echo '<td><b>Total:</b></td>';
echo '<td align="right">'.number_format($TotalScannedFilesize).'</td>';
echo '<td>&nbsp;</td>';
echo '<td align="right">'.getid3_lib::PlaytimeString($TotalScannedPlaytime).'</td>';
echo '<td align="right">'.\GetId3\Lib\Helper::PlaytimeString($TotalScannedPlaytime).'</td>';
echo '<td>&nbsp;</td>';
echo '</tr>';
}
Expand Down
Loading