84 if (!function_exists(
'mysqli_connect')) {
85 throw new Exception(
'PHP not compiled with mysqli support.');
89 $this->mysqli =
new mysqli($host, $username,
$password);
91 throw new Exception(
'mysqli_connect() failed - check permissions and spelling.');
95 if (!$this->mysqli->select_db($database)) {
96 throw new Exception(
'Cannot use database '.$database);
107 $SQLquery =
'SELECT `value`';
108 $SQLquery .=
' FROM `'.$this->mysqli->real_escape_string($this->table).
'`';
109 $SQLquery .=
' WHERE (`filename` = \''.$this->mysqli->real_escape_string(
getID3::VERSION).
'\')
'; 110 $SQLquery .= ' AND (`filesize` = -1)
'; 111 $SQLquery .= ' AND (`filetime` = -1)
'; 112 $SQLquery .= ' AND (`analyzetime` = -1)
'; 113 if ($this->cursor = $this->mysqli->query($SQLquery)) { 114 list($version) = $this->cursor->fetch_array(); 116 if ($version != getID3::VERSION) { 117 $this->clear_cache(); 120 parent::__construct(); 124 // public: clear cache 125 public function clear_cache() { 126 $this->mysqli->query('DELETE FROM `
'.$this->mysqli->real_escape_string($this->table).'`
'); 127 $this->mysqli->query('INSERT INTO `
'.$this->mysqli->real_escape_string($this->table).'` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES (\
''.
getID3::VERSION.
'\', -1, -1, -1, \
''.
getID3::VERSION.
'\')
'); 131 // public: analyze file 132 public function analyze($filename, $filesize=null, $original_filename='') { 134 if (file_exists($filename)) { 137 $filetime = filemtime($filename); 138 $filesize = filesize($filename); 141 $SQLquery = 'SELECT `value`
'; 142 $SQLquery .= ' FROM `
'.$this->mysqli->real_escape_string($this->table).'`
'; 143 $SQLquery .= ' WHERE (`filename` = \
''.$this->mysqli->real_escape_string(
$filename).
'\')
'; 144 $SQLquery .= ' AND (`filesize` = \
''.$this->mysqli->real_escape_string($filesize).
'\')
'; 145 $SQLquery .= ' AND (`filetime` = \
''.$this->mysqli->real_escape_string($filetime).
'\')
'; 146 $this->cursor = $this->mysqli->query($SQLquery); 147 if ($this->cursor->num_rows > 0) { 149 list($result) = $this->cursor->fetch_array(); 150 return unserialize(base64_decode($result)); 155 $analysis = parent::analyze($filename, $filesize, $original_filename); 158 if (file_exists($filename)) { 159 $SQLquery = 'INSERT INTO `
'.$this->mysqli->real_escape_string($this->table).'` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES (
'; 160 $SQLquery .= '\
''.$this->mysqli->real_escape_string(
$filename).
'\'';
161 $SQLquery .=
', \''.$this->mysqli->real_escape_string($filesize).
'\'';
162 $SQLquery .=
', \''.$this->mysqli->real_escape_string($filetime).
'\'';
163 $SQLquery .=
', \''.$this->mysqli->real_escape_string(
time() ).
'\'';
164 $SQLquery .=
', \''.$this->mysqli->real_escape_string(base64_encode(serialize($analysis))).
'\')
'; 165 $this->cursor = $this->mysqli->query($SQLquery); 171 // private: (re)create mysqli table 172 private function create_table($drop=false) { 173 $SQLquery = 'CREATE TABLE IF NOT EXISTS `
'.$this->mysqli->real_escape_string($this->table).'` (
'; 174 $SQLquery .= '`filename` VARCHAR(990) NOT NULL DEFAULT \'\'';
175 $SQLquery .= ', `filesize` INT(11) NOT NULL DEFAULT \'0\'';
176 $SQLquery .= ', `filetime` INT(11) NOT NULL DEFAULT \'0\'';
177 $SQLquery .= ', `analyzetime` INT(11) NOT NULL DEFAULT \'0\'';
178 $SQLquery .= ', `value` LONGTEXT NOT NULL';
179 $SQLquery .= ', PRIMARY KEY (`filename`, `filesize`, `filetime`)) ENGINE=MyISAM CHARACTER SET=latin1 COLLATE=latin1_general_ci';
180 $this->cursor = $this->mysqli->query($SQLquery);
181 echo $this->mysqli->
error;
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