86 if (!function_exists(
'mysql_pconnect')) {
87 throw new Exception(
'PHP not compiled with mysql support.');
91 $this->connection = mysql_pconnect($host, $username,
$password);
92 if (!$this->connection) {
93 throw new Exception(
'mysql_pconnect() failed - check permissions and spelling.');
97 if (!mysql_select_db($database, $this->connection)) {
98 throw new Exception(
'Cannot use database '.$database);
109 $SQLquery =
'SELECT `value`';
110 $SQLquery .=
' FROM `'.mysql_real_escape_string($this->table).
'`';
111 $SQLquery .=
' WHERE (`filename` = \''.mysql_real_escape_string(
getID3::VERSION).
'\')
'; 112 $SQLquery .= ' AND (`filesize` = -1)
'; 113 $SQLquery .= ' AND (`filetime` = -1)
'; 114 $SQLquery .= ' AND (`analyzetime` = -1)
'; 115 if ($this->cursor = mysql_query($SQLquery, $this->connection)) { 116 list($version) = mysql_fetch_array($this->cursor); 118 if ($version != getID3::VERSION) { 119 $this->clear_cache(); 122 parent::__construct(); 127 // public: clear cache 128 public function clear_cache() { 130 $this->cursor = mysql_query('DELETE FROM `
'.mysql_real_escape_string($this->table).'`
', $this->connection); 131 $this->cursor = mysql_query('INSERT INTO `
'.mysql_real_escape_string($this->table).'` VALUES (\
''.
getID3::VERSION.
'\', -1, -1, -1, \
''.
getID3::VERSION.
'\')
', $this->connection); 136 // public: analyze file 137 public function analyze($filename, $filesize=null, $original_filename='') { 139 if (file_exists($filename)) { 142 $filetime = filemtime($filename); 143 $filesize = filesize($filename); 146 $SQLquery = 'SELECT `value`
'; 147 $SQLquery .= ' FROM `
'.mysql_real_escape_string($this->table).'`
'; 148 $SQLquery .= ' WHERE (`filename` = \
''.mysql_real_escape_string(
$filename).
'\')
'; 149 $SQLquery .= ' AND (`filesize` = \
''.mysql_real_escape_string($filesize).
'\')
'; 150 $SQLquery .= ' AND (`filetime` = \
''.mysql_real_escape_string($filetime).
'\')
'; 151 $this->cursor = mysql_query($SQLquery, $this->connection); 152 if (mysql_num_rows($this->cursor) > 0) { 154 list($result) = mysql_fetch_array($this->cursor); 155 return unserialize(base64_decode($result)); 160 $analysis = parent::analyze($filename, $filesize, $original_filename); 163 if (file_exists($filename)) { 164 $SQLquery = 'INSERT INTO `
'.mysql_real_escape_string($this->table).'` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES (
'; 165 $SQLquery .= '\
''.mysql_real_escape_string(
$filename).
'\'';
166 $SQLquery .=
', \''.mysql_real_escape_string($filesize).
'\'';
167 $SQLquery .=
', \''.mysql_real_escape_string($filetime).
'\'';
168 $SQLquery .=
', \''.mysql_real_escape_string(
time() ).
'\'';
169 $SQLquery .=
', \''.mysql_real_escape_string(base64_encode(serialize($analysis))).
'\')
'; 170 $this->cursor = mysql_query($SQLquery, $this->connection); 177 // private: (re)create sql table 178 private function create_table($drop=false) { 180 $SQLquery = 'CREATE TABLE IF NOT EXISTS `
'.mysql_real_escape_string($this->table).'` (
'; 181 $SQLquery .= '`filename` VARCHAR(990) NOT NULL DEFAULT \'\'';
182 $SQLquery .= ', `filesize` INT(11) NOT NULL DEFAULT \'0\'';
183 $SQLquery .= ', `filetime` INT(11) NOT NULL DEFAULT \'0\'';
184 $SQLquery .= ', `analyzetime` INT(11) NOT NULL DEFAULT \'0\'';
185 $SQLquery .= ', `value` LONGTEXT NOT NULL';
186 $SQLquery .= ', PRIMARY KEY (`filename`, `filesize`, `filetime`)) ENGINE=MyISAM CHARACTER SET=latin1 COLLATE=latin1_general_ci';
187 $this->cursor = mysql_query($SQLquery, $this->connection);
188 echo mysql_error($this->connection);
getID3() by James Heinrich info@getid3.org //
__construct($host, $database, $username, $password, $table='getid3_cache')
create_table($drop=false)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(empty($password)) $table