Answer the question
In order to leave comments, you need to log in
How to count id3 tags of files on ftp?
Hello!
$iFSize = $iFSize = ftp_size($this->connectionId, $sFilepath);
/* !!! */ $vFD = fopen($sFilepath,'r'); $sSrc = fread($vFD,$iFSize); fclose($vFD);
public function listFile2($directory){
// $valid_ext = array("mp3", "wav", "m3u");
$list = ftp_mlsd($this->connectionId, $directory);
if(!empty($list)){
foreach ($list as $file) {
switch ($file['type']) {
case 'file': var_dump($this->getTagsInfo($directory.'/'.$file['name'])); break;
case 'dir': $this->listFile2($directory.'/'.$file['name']); break;
}
}
}
return $this->fileList;
}
public function getTagsInfo($sFilepath) {
$iFSize = filesize($sFilepath); $vFD = fopen($sFilepath,'r'); $sSrc = fread($vFD,$iFSize); fclose($vFD);
if (substr($sSrc,0,3) == 'ID3') {
$aInfo['FileName'] = $sFilepath;
$aInfo['Version'] = hexdec(bin2hex(substr($sSrc,3,1))).'.'.hexdec(bin2hex(substr($sSrc,4,1)));
}
if ($aInfo['Version'] == '4.0' || $aInfo['Version'] == '3.0') {
for ($i = 0; $i < count($this->aTV23); $i++) {
if (strpos($sSrc, $this->aTV23[$i].chr(0)) != FALSE) {
$s = '';
$iPos = strpos($sSrc, $this->aTV23[$i].chr(0));
$iLen = hexdec(bin2hex(substr($sSrc,($iPos + 5),3)));
$data = substr($sSrc, $iPos, 9 + $iLen);
for ($a = 0; $a < strlen($data); $a++) {
$char = substr($data, $a, 1);
if ($char >= ' ' && $char <= '~')
$s .= $char;
}
if (substr($s, 0, 4) == $this->aTV23[$i]) {
$iSL = 4;
if ($this->aTV23[$i] == 'USLT') {
$iSL = 7;
} elseif ($this->aTV23[$i] == 'TALB') {
$iSL = 5;
} elseif ($this->aTV23[$i] == 'TENC') {
$iSL = 6;
}
$aInfo[$this->aTV23t[$i]] = substr($s, $iSL);
}
}
}
}
if($aInfo['Version'] == '2.0') {
for ($i = 0; $i < count($this->aTV22); $i++) {
if (strpos($sSrc, $this->aTV22[$i].chr(0)) != FALSE) {
$s = '';
$iPos = strpos($sSrc, $this->aTV22[$i].chr(0));
$iLen = hexdec(bin2hex(substr($sSrc,($iPos + 3),3)));
$data = substr($sSrc, $iPos, 6 + $iLen);
for ($a = 0; $a < strlen($data); $a++) {
$char = substr($data, $a, 1);
if ($char >= ' ' && $char <= '~')
$s .= $char;
}
if (substr($s, 0, 3) == $this->aTV22[$i]) {
$iSL = 3;
if ($this->aTV22[$i] == 'ULT') {
$iSL = 6;
}
$aInfo[$this->aTV22t[$i]] = substr($s, $iSL);
}
}
}
}
return $aInfo;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question