Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge

This commit is contained in:
zotlabs 2017-11-20 15:04:08 -08:00
commit babe14410c
28 changed files with 5662 additions and 67 deletions

View file

@ -0,0 +1,62 @@
<?php /** @file */
namespace Zotlabs\Daemon;
class Thumbnail {
static public function run($argc,$argv) {
if(! $argc == 2)
return;
$c = q("select * from attach where hash = '%s' ",
dbesc($argv[1])
);
if(! $c)
return;
$preview_style = intval(get_config('system','thumbnail_security',0));
$attach = $c[0];
$isize = 300;
if(strpos($attach['filetype'],'text/') !== false) {
$stream = @fopen($attach['content'],'rb');
if($stream) {
$content = trim(stream_get_contents($stream,4096));
$content = str_replace("\r",'',$content);
$content_a = explode("\n",$content);
}
if($content_a) {
$fsize = 4;
$lsize = 8;
$image = imagecreate($isize,$isize);
imagecolorallocate($image,255,255,255);
$colour = imagecolorallocate($image,0,0,0);
$border = imagecolorallocate($image,64,64,64);
$x1 = 0;
$y1 = 0;
$x2 = ImageSX($image) - 1;
$y2 = ImageSY($image) - 1;
for($i = 0; $i < 2; $i++) {
ImageRectangle($image, $x1++, $y1++, $x2--, $y2--, $border);
}
foreach($content_a as $l => $t) {
$l = $l + 1;
$x = 3;
$y = ($l * $lsize) + 3 - $fsize;
imagestring($image,1,$x,$y,$t,$colour);
if(($l * $lsize) >= $isize) {
break;
}
}
imagejpeg($image,$attach['content'] . '.thumb');
}
}
}
}

View file

@ -48,7 +48,7 @@ class Hq extends \Zotlabs\Web\Controller {
WHERE uid = %d
AND mid = parent_mid
$item_normal
ORDER BY id DESC
ORDER BY created DESC
limit 1",
local_channel()
);

View file

@ -492,10 +492,11 @@ class Ping extends \Zotlabs\Web\Controller {
$t3 = dba_timer();
if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
$r = q("SELECT id, item_wall FROM item
WHERE item_unseen = 1 and uid = %d
$item_normal
AND author_xchan != '%s'",
AND author_xchan != '%s' $sql_extra ",
intval(local_channel()),
dbesc($ob_hash)
);

View file

@ -208,6 +208,16 @@ class Browser extends DAV\Browser\Plugin {
$photo_icon = '';
$preview_style = intval(get_config('system','thumbnail_security',0));
$r = q("select content from attach where hash = '%s' and uid = %d limit 1",
dbesc($attachHash),
intval($owner)
);
if($r && file_exists(dbunescbin($r[0]['content']) . '.thumb')) {
$photo_icon = 'data:image/jpeg;base64,' . base64_encode(file_get_contents(dbunescbin($r[0]['content']) . '.thumb'));
// logger('found thumb: ' . $photo_icon);
}
if(strpos($type,'image/') === 0 && $attachHash) {
$r = q("select resource_id, imgscale from photo where resource_id = '%s' and imgscale in ( %d, %d ) order by imgscale asc limit 1",
dbesc($attachHash),
@ -220,12 +230,11 @@ class Browser extends DAV\Browser\Plugin {
if($type === 'image/svg+xml' && $preview_style > 0) {
$photo_icon = $fullPath;
}
}
$g = [ 'resource_id' => $attachHash, 'thumbnail' => $photo_icon, 'security' => $preview_style ];
call_hooks('file_thumbnail', $g);
$photo_icon = $g['photo_icon'];
$photo_icon = $g['thumbnail'];
$attachIcon = ""; // "<a href=\"attach/".$attachHash."\" title=\"".$displayName."\"><i class=\"fa fa-arrow-circle-o-down\"></i></a>";

View file

@ -362,6 +362,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$args = array( 'resource_id' => $hash, 'album' => $album, 'os_syspath' => $f, 'os_path' => $xpath['os_path'], 'display_path' => $xpath['path'], 'filename' => $name, 'getimagesize' => $gis, 'directory' => $direct);
$p = photo_upload($c[0], \App::get_observer(), $args);
}
\Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $this->folder_hash ]);
$sync = attach_export_data($c[0], $hash);

View file

@ -244,6 +244,9 @@ class File extends DAV\Node implements DAV\IFile {
}
}
\Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $this->data['hash'] ]);
$sync = attach_export_data($c[0],$this->data['hash']);
if($sync)

View file

@ -35,7 +35,8 @@
"simplepie/simplepie": "~1.5",
"league/html-to-markdown": "^4.4",
"pear/text_languagedetect": "^1.0",
"commerceguys/intl": "~0.7"
"commerceguys/intl": "~0.7",
"lukasreschke/id3parser": "^0.0.1"
},
"require-dev" : {
"php" : ">=7.0",

37
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "cc603d3dc499e43f840f9551039fa93c",
"content-hash": "9c45792f04ea3e30f312f5eef0bdad86",
"packages": [
{
"name": "bshaffer/oauth2-server-php",
@ -217,6 +217,41 @@
],
"time": "2017-03-16T00:45:59+00:00"
},
{
"name": "lukasreschke/id3parser",
"version": "v0.0.1",
"source": {
"type": "git",
"url": "https://github.com/LukasReschke/ID3Parser.git",
"reference": "cd3ba6e8918cc30883f01a3c24281cfe23b8877a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/LukasReschke/ID3Parser/zipball/cd3ba6e8918cc30883f01a3c24281cfe23b8877a",
"reference": "cd3ba6e8918cc30883f01a3c24281cfe23b8877a",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"ID3Parser\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL"
],
"homepage": "https://github.com/LukasReschke/ID3Parser/",
"keywords": [
"codecs",
"php",
"tags"
],
"time": "2016-04-04T09:34:50+00:00"
},
{
"name": "michelf/php-markdown",
"version": "1.7.0",

View file

@ -951,6 +951,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
call_hooks('photo_upload_end', $ret);
}
\Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $hash ]);
if($dosync) {
$sync = attach_export_data($channel,$hash);

View file

@ -241,69 +241,84 @@ abstract class photo_driver {
}
/**
* @brief reads exif data from filename
*/
public function exif($filename) {
public function orient($filename) {
if((! function_exists('exif_read_data'))
|| (! in_array($this->getType(), [ 'image/jpeg' , 'image/tiff'] ))) {
return false;
}
/**
* This function is a bit unusual, because it is operating on a file, but you must
* first create an image from that file to initialise the type and check validity
* of the image.
/*
* PHP 7.2 allows you to use a stream resource, which should reduce/avoid
* memory exhaustion on large images.
*/
if(! $this->is_valid())
return false;
if((! function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg'))
return false;
$exif = @exif_read_data($filename,null,true);
if($exif) {
$ort = $exif['IFD0']['Orientation'];
switch($ort)
{
case 1: // nothing
break;
case 2: // horizontal flip
$this->flip();
break;
case 3: // 180 rotate left
$this->rotate(180);
break;
case 4: // vertical flip
$this->flip(false, true);
break;
case 5: // vertical flip + 90 rotate right
$this->flip(false, true);
$this->rotate(-90);
break;
case 6: // 90 rotate right
$this->rotate(-90);
break;
case 7: // horizontal flip + 90 rotate right
$this->flip();
$this->rotate(-90);
break;
case 8: // 90 rotate left
$this->rotate(90);
break;
}
return $exif;
if(version_compare(PHP_VERSION,'7.2.0') >= 0) {
$f = @fopen($filename,'rb');
}
else {
$f = $filename;
}
return false;
if($f) {
return @exif_read_data($f);
}
return false;
}
/**
* @brief orients current image based on exif orientation information
*/
public function orient($exif) {
if(! ($this->is_valid() && $exif)) {
return false;
}
$ort = $exif['IFD0']['Orientation'];
if(! $ort) {
return false;
}
switch($ort) {
case 1: // nothing
break;
case 2: // horizontal flip
$this->flip();
break;
case 3: // 180 rotate left
$this->rotate(180);
break;
case 4: // vertical flip
$this->flip(false, true);
break;
case 5: // vertical flip + 90 rotate right
$this->flip(false, true);
$this->rotate(-90);
break;
case 6: // 90 rotate right
$this->rotate(-90);
break;
case 7: // horizontal flip + 90 rotate right
$this->flip();
$this->rotate(-90);
break;
case 8: // 90 rotate left
$this->rotate(90);
break;
default:
break;
}
return true;
}

View file

@ -203,7 +203,13 @@ function photo_upload($channel, $observer, $args) {
return $ret;
}
$exif = $ph->orient(($args['os_syspath']) ? $args['os_syspath'] : $src);
// obtain exif data from the source file if present
$exif = $ph->exif(($args['os_syspath']) ? $args['os_syspath'] : $src);
if($exif) {
$ph->orient($exif);
}
@unlink($src);

View file

@ -2704,8 +2704,8 @@ function linkify_tags($a, &$body, $uid, $diaspora = false) {
function getIconFromType($type) {
$iconMap = array(
//Folder
t('Collection') => 'fa-folder',
'multipart/mixed' => 'fa-folder', //dirs in attach use this mime type
t('Collection') => 'fa-folder-o',
'multipart/mixed' => 'fa-folder-o', //dirs in attach use this mime type
//Common file
'application/octet-stream' => 'fa-file-o',
//Text

View file

@ -271,6 +271,13 @@ return array(
'HTMLPurifier_VarParser_Native' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Native.php',
'HTMLPurifier_Zipper' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php',
'Hubzilla\\Import\\Import' => $baseDir . '/include/Import/Importer.php',
'ID3Parser\\ID3Parser' => $vendorDir . '/lukasreschke/id3parser/src/ID3Parser.php',
'ID3Parser\\getID3\\Tags\\getid3_id3v1' => $vendorDir . '/lukasreschke/id3parser/src/getID3/Tags/getid3_id3v1.php',
'ID3Parser\\getID3\\Tags\\getid3_id3v2' => $vendorDir . '/lukasreschke/id3parser/src/getID3/Tags/getid3_id3v2.php',
'ID3Parser\\getID3\\getID3' => $vendorDir . '/lukasreschke/id3parser/src/getID3/getid3.php',
'ID3Parser\\getID3\\getid3_exception' => $vendorDir . '/lukasreschke/id3parser/src/getID3/getid3_exception.php',
'ID3Parser\\getID3\\getid3_handler' => $vendorDir . '/lukasreschke/id3parser/src/getID3/getid3_handler.php',
'ID3Parser\\getID3\\getid3_lib' => $vendorDir . '/lukasreschke/id3parser/src/getID3/getid3_lib.php',
'League\\HTMLToMarkdown\\Configuration' => $vendorDir . '/league/html-to-markdown/src/Configuration.php',
'League\\HTMLToMarkdown\\ConfigurationAwareInterface' => $vendorDir . '/league/html-to-markdown/src/ConfigurationAwareInterface.php',
'League\\HTMLToMarkdown\\Converter\\BlockquoteConverter' => $vendorDir . '/league/html-to-markdown/src/Converter/BlockquoteConverter.php',
@ -780,6 +787,7 @@ return array(
'Zotlabs\\Daemon\\Poller' => $baseDir . '/Zotlabs/Daemon/Poller.php',
'Zotlabs\\Daemon\\Queue' => $baseDir . '/Zotlabs/Daemon/Queue.php',
'Zotlabs\\Daemon\\Ratenotif' => $baseDir . '/Zotlabs/Daemon/Ratenotif.php',
'Zotlabs\\Daemon\\Thumbnail' => $baseDir . '/Zotlabs/Daemon/Thumbnail.php',
'Zotlabs\\Extend\\Hook' => $baseDir . '/Zotlabs/Extend/Hook.php',
'Zotlabs\\Identity\\BasicId\\BasicId' => $baseDir . '/Zotlabs/Identity/BasicId.php',
'Zotlabs\\Identity\\ProfilePhoto\\ProfilePhoto' => $baseDir . '/Zotlabs/Identity/ProfilePhoto.php',
@ -848,6 +856,7 @@ return array(
'Zotlabs\\Module\\Chat' => $baseDir . '/Zotlabs/Module/Chat.php',
'Zotlabs\\Module\\Chatsvc' => $baseDir . '/Zotlabs/Module/Chatsvc.php',
'Zotlabs\\Module\\Cloud' => $baseDir . '/Zotlabs/Module/Cloud.php',
'Zotlabs\\Module\\Cloud_tiles' => $baseDir . '/Zotlabs/Module/Cloud_tiles.php',
'Zotlabs\\Module\\Common' => $baseDir . '/Zotlabs/Module/Common.php',
'Zotlabs\\Module\\Connect' => $baseDir . '/Zotlabs/Module/Connect.php',
'Zotlabs\\Module\\Connections' => $baseDir . '/Zotlabs/Module/Connections.php',
@ -855,6 +864,7 @@ return array(
'Zotlabs\\Module\\Contactgroup' => $baseDir . '/Zotlabs/Module/Contactgroup.php',
'Zotlabs\\Module\\Cover_photo' => $baseDir . '/Zotlabs/Module/Cover_photo.php',
'Zotlabs\\Module\\Dav' => $baseDir . '/Zotlabs/Module/Dav.php',
'Zotlabs\\Module\\Defperms' => $baseDir . '/Zotlabs/Module/Defperms.php',
'Zotlabs\\Module\\Directory' => $baseDir . '/Zotlabs/Module/Directory.php',
'Zotlabs\\Module\\Dirsearch' => $baseDir . '/Zotlabs/Module/Dirsearch.php',
'Zotlabs\\Module\\Display' => $baseDir . '/Zotlabs/Module/Display.php',
@ -879,6 +889,7 @@ return array(
'Zotlabs\\Module\\Help' => $baseDir . '/Zotlabs/Module/Help.php',
'Zotlabs\\Module\\Home' => $baseDir . '/Zotlabs/Module/Home.php',
'Zotlabs\\Module\\Hostxrd' => $baseDir . '/Zotlabs/Module/Hostxrd.php',
'Zotlabs\\Module\\Hq' => $baseDir . '/Zotlabs/Module/Hq.php',
'Zotlabs\\Module\\Impel' => $baseDir . '/Zotlabs/Module/Impel.php',
'Zotlabs\\Module\\Import' => $baseDir . '/Zotlabs/Module/Import.php',
'Zotlabs\\Module\\Import_items' => $baseDir . '/Zotlabs/Module/Import_items.php',

View file

@ -18,6 +18,7 @@ return array(
'Sabre\\CalDAV\\' => array($vendorDir . '/sabre/dav/lib/CalDAV'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'League\\HTMLToMarkdown\\' => array($vendorDir . '/league/html-to-markdown/src'),
'ID3Parser\\' => array($vendorDir . '/lukasreschke/id3parser/src'),
'Hubzilla\\' => array($baseDir . '/include'),
'CommerceGuys\\Intl\\' => array($vendorDir . '/commerceguys/intl/src'),
);

View file

@ -42,6 +42,10 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
array (
'League\\HTMLToMarkdown\\' => 22,
),
'I' =>
array (
'ID3Parser\\' => 10,
),
'H' =>
array (
'Hubzilla\\' => 9,
@ -101,6 +105,10 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
array (
0 => __DIR__ . '/..' . '/league/html-to-markdown/src',
),
'ID3Parser\\' =>
array (
0 => __DIR__ . '/..' . '/lukasreschke/id3parser/src',
),
'Hubzilla\\' =>
array (
0 => __DIR__ . '/../..' . '/include',
@ -415,6 +423,13 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'HTMLPurifier_VarParser_Native' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier/VarParser/Native.php',
'HTMLPurifier_Zipper' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier/Zipper.php',
'Hubzilla\\Import\\Import' => __DIR__ . '/../..' . '/include/Import/Importer.php',
'ID3Parser\\ID3Parser' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/ID3Parser.php',
'ID3Parser\\getID3\\Tags\\getid3_id3v1' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/getID3/Tags/getid3_id3v1.php',
'ID3Parser\\getID3\\Tags\\getid3_id3v2' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/getID3/Tags/getid3_id3v2.php',
'ID3Parser\\getID3\\getID3' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/getID3/getid3.php',
'ID3Parser\\getID3\\getid3_exception' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/getID3/getid3_exception.php',
'ID3Parser\\getID3\\getid3_handler' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/getID3/getid3_handler.php',
'ID3Parser\\getID3\\getid3_lib' => __DIR__ . '/..' . '/lukasreschke/id3parser/src/getID3/getid3_lib.php',
'League\\HTMLToMarkdown\\Configuration' => __DIR__ . '/..' . '/league/html-to-markdown/src/Configuration.php',
'League\\HTMLToMarkdown\\ConfigurationAwareInterface' => __DIR__ . '/..' . '/league/html-to-markdown/src/ConfigurationAwareInterface.php',
'League\\HTMLToMarkdown\\Converter\\BlockquoteConverter' => __DIR__ . '/..' . '/league/html-to-markdown/src/Converter/BlockquoteConverter.php',
@ -924,6 +939,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Daemon\\Poller' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Poller.php',
'Zotlabs\\Daemon\\Queue' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Queue.php',
'Zotlabs\\Daemon\\Ratenotif' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Ratenotif.php',
'Zotlabs\\Daemon\\Thumbnail' => __DIR__ . '/../..' . '/Zotlabs/Daemon/Thumbnail.php',
'Zotlabs\\Extend\\Hook' => __DIR__ . '/../..' . '/Zotlabs/Extend/Hook.php',
'Zotlabs\\Identity\\BasicId\\BasicId' => __DIR__ . '/../..' . '/Zotlabs/Identity/BasicId.php',
'Zotlabs\\Identity\\ProfilePhoto\\ProfilePhoto' => __DIR__ . '/../..' . '/Zotlabs/Identity/ProfilePhoto.php',
@ -992,6 +1008,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Chat' => __DIR__ . '/../..' . '/Zotlabs/Module/Chat.php',
'Zotlabs\\Module\\Chatsvc' => __DIR__ . '/../..' . '/Zotlabs/Module/Chatsvc.php',
'Zotlabs\\Module\\Cloud' => __DIR__ . '/../..' . '/Zotlabs/Module/Cloud.php',
'Zotlabs\\Module\\Cloud_tiles' => __DIR__ . '/../..' . '/Zotlabs/Module/Cloud_tiles.php',
'Zotlabs\\Module\\Common' => __DIR__ . '/../..' . '/Zotlabs/Module/Common.php',
'Zotlabs\\Module\\Connect' => __DIR__ . '/../..' . '/Zotlabs/Module/Connect.php',
'Zotlabs\\Module\\Connections' => __DIR__ . '/../..' . '/Zotlabs/Module/Connections.php',
@ -999,6 +1016,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Contactgroup' => __DIR__ . '/../..' . '/Zotlabs/Module/Contactgroup.php',
'Zotlabs\\Module\\Cover_photo' => __DIR__ . '/../..' . '/Zotlabs/Module/Cover_photo.php',
'Zotlabs\\Module\\Dav' => __DIR__ . '/../..' . '/Zotlabs/Module/Dav.php',
'Zotlabs\\Module\\Defperms' => __DIR__ . '/../..' . '/Zotlabs/Module/Defperms.php',
'Zotlabs\\Module\\Directory' => __DIR__ . '/../..' . '/Zotlabs/Module/Directory.php',
'Zotlabs\\Module\\Dirsearch' => __DIR__ . '/../..' . '/Zotlabs/Module/Dirsearch.php',
'Zotlabs\\Module\\Display' => __DIR__ . '/../..' . '/Zotlabs/Module/Display.php',
@ -1023,6 +1041,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
'Zotlabs\\Module\\Help' => __DIR__ . '/../..' . '/Zotlabs/Module/Help.php',
'Zotlabs\\Module\\Home' => __DIR__ . '/../..' . '/Zotlabs/Module/Home.php',
'Zotlabs\\Module\\Hostxrd' => __DIR__ . '/../..' . '/Zotlabs/Module/Hostxrd.php',
'Zotlabs\\Module\\Hq' => __DIR__ . '/../..' . '/Zotlabs/Module/Hq.php',
'Zotlabs\\Module\\Impel' => __DIR__ . '/../..' . '/Zotlabs/Module/Impel.php',
'Zotlabs\\Module\\Import' => __DIR__ . '/../..' . '/Zotlabs/Module/Import.php',
'Zotlabs\\Module\\Import_items' => __DIR__ . '/../..' . '/Zotlabs/Module/Import_items.php',

View file

@ -849,5 +849,42 @@
}
],
"description": "Internationalization library powered by CLDR data."
},
{
"name": "lukasreschke/id3parser",
"version": "v0.0.1",
"version_normalized": "0.0.1.0",
"source": {
"type": "git",
"url": "https://github.com/LukasReschke/ID3Parser.git",
"reference": "cd3ba6e8918cc30883f01a3c24281cfe23b8877a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/LukasReschke/ID3Parser/zipball/cd3ba6e8918cc30883f01a3c24281cfe23b8877a",
"reference": "cd3ba6e8918cc30883f01a3c24281cfe23b8877a",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"time": "2016-04-04T09:34:50+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"ID3Parser\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL"
],
"homepage": "https://github.com/LukasReschke/ID3Parser/",
"keywords": [
"codecs",
"php",
"tags"
]
}
]

View file

@ -0,0 +1 @@
.idea/

29
vendor/lukasreschke/id3parser/README.md vendored Normal file
View file

@ -0,0 +1,29 @@
# ID3 Parser
This is a pure ID3 parser based upon [getID3](https://github.com/JamesHeinrich/getID3). It supports the following ID3
versions inside MP3 files:
- ID3v1 (v1.0 & v1.1)
- ID3v2 (v2.2, v2.3 & v2.4)
## Usage
```php
<?php
require_once __DIR__ . '/vendor/autoload.php';
$analyzer = new \ID3Parser\ID3Parser();
$tags = $analyzer->analyze('/tmp/myfile.mp3'));
```
## Why should I use this package over getID3 directly?
getID3 has evolved to a state where it is having a lot of other features such as parsing a ton of other file formats and
for some of it, it is even invoking external programs on the server. For example it is nowadays even supporting SVG files.
Such a big parsing library can easily be haunted by security related bugs as for example [CVE-2014-2053](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-2053)
and some other vulnerabilities have proven. This library takes the ID3 parsing code from getID3 and strips all other
functions.
In cases where reading the ID3v2 tags is sufficient this library is likely to be a more secure approach, if you need any
of the advanced features of getID3 however you're likely to be unhappy with this library.

View file

@ -0,0 +1,14 @@
{
"name": "lukasreschke/id3parser",
"homepage" : "https://github.com/LukasReschke/ID3Parser/",
"require" : {
"php" : ">=5.4.0"
},
"license": "GPL",
"keywords": ["php","tags","codecs"],
"autoload" : {
"psr-4" : {
"ID3Parser\\" : "src/"
}
}
}

View file

@ -0,0 +1,22 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
namespace ID3Parser;
use ID3Parser\getID3\getID3;
class ID3Parser {
/**
* @param string $fileName
* @return array
*/
public function analyze($fileName) {
$getID3 = new getID3();
return $getID3->analyze($fileName);
}
}

View file

@ -0,0 +1,356 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
namespace ID3Parser\getID3\Tags;
use ID3Parser\getID3\getid3_handler;
use ID3Parser\getID3\getid3_lib;
class getid3_id3v1 extends getid3_handler
{
public function Analyze() {
$info = &$this->getid3->info;
if (!getid3_lib::intValueSupported($info['filesize'])) {
$info['warning'][] = 'Unable to check for ID3v1 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
return false;
}
$this->fseek(-256, SEEK_END);
$preid3v1 = $this->fread(128);
$id3v1tag = $this->fread(128);
if (substr($id3v1tag, 0, 3) == 'TAG') {
$info['avdataend'] = $info['filesize'] - 128;
$ParsedID3v1['title'] = $this->cutfield(substr($id3v1tag, 3, 30));
$ParsedID3v1['artist'] = $this->cutfield(substr($id3v1tag, 33, 30));
$ParsedID3v1['album'] = $this->cutfield(substr($id3v1tag, 63, 30));
$ParsedID3v1['year'] = $this->cutfield(substr($id3v1tag, 93, 4));
$ParsedID3v1['comment'] = substr($id3v1tag, 97, 30); // can't remove nulls yet, track detection depends on them
$ParsedID3v1['genreid'] = ord(substr($id3v1tag, 127, 1));
// If second-last byte of comment field is null and last byte of comment field is non-null
// then this is ID3v1.1 and the comment field is 28 bytes long and the 30th byte is the track number
if (($id3v1tag{125} === "\x00") && ($id3v1tag{126} !== "\x00")) {
$ParsedID3v1['track'] = ord(substr($ParsedID3v1['comment'], 29, 1));
$ParsedID3v1['comment'] = substr($ParsedID3v1['comment'], 0, 28);
}
$ParsedID3v1['comment'] = $this->cutfield($ParsedID3v1['comment']);
$ParsedID3v1['genre'] = $this->LookupGenreName($ParsedID3v1['genreid']);
if (!empty($ParsedID3v1['genre'])) {
unset($ParsedID3v1['genreid']);
}
if (isset($ParsedID3v1['genre']) && (empty($ParsedID3v1['genre']) || ($ParsedID3v1['genre'] == 'Unknown'))) {
unset($ParsedID3v1['genre']);
}
foreach ($ParsedID3v1 as $key => $value) {
$ParsedID3v1['comments'][$key][0] = $value;
}
// ID3v1 data is supposed to be padded with NULL characters, but some taggers pad with spaces
$GoodFormatID3v1tag = $this->GenerateID3v1Tag(
$ParsedID3v1['title'],
$ParsedID3v1['artist'],
$ParsedID3v1['album'],
$ParsedID3v1['year'],
(isset($ParsedID3v1['genre']) ? $this->LookupGenreID($ParsedID3v1['genre']) : false),
$ParsedID3v1['comment'],
(!empty($ParsedID3v1['track']) ? $ParsedID3v1['track'] : ''));
$ParsedID3v1['padding_valid'] = true;
if ($id3v1tag !== $GoodFormatID3v1tag) {
$ParsedID3v1['padding_valid'] = false;
$info['warning'][] = 'Some ID3v1 fields do not use NULL characters for padding';
}
$ParsedID3v1['tag_offset_end'] = $info['filesize'];
$ParsedID3v1['tag_offset_start'] = $ParsedID3v1['tag_offset_end'] - 128;
$info['id3v1'] = $ParsedID3v1;
}
if (substr($preid3v1, 0, 3) == 'TAG') {
// The way iTunes handles tags is, well, brain-damaged.
// It completely ignores v1 if ID3v2 is present.
// This goes as far as adding a new v1 tag *even if there already is one*
// A suspected double-ID3v1 tag has been detected, but it could be that
// the "TAG" identifier is a legitimate part of an APE or Lyrics3 tag
if (substr($preid3v1, 96, 8) == 'APETAGEX') {
// an APE tag footer was found before the last ID3v1, assume false "TAG" synch
} elseif (substr($preid3v1, 119, 6) == 'LYRICS') {
// a Lyrics3 tag footer was found before the last ID3v1, assume false "TAG" synch
} else {
// APE and Lyrics3 footers not found - assume double ID3v1
$info['warning'][] = 'Duplicate ID3v1 tag detected - this has been known to happen with iTunes';
$info['avdataend'] -= 128;
}
}
return true;
}
public static function cutfield($str) {
return trim(substr($str, 0, strcspn($str, "\x00")));
}
public static function ArrayOfGenres($allowSCMPXextended=false) {
static $GenreLookup = array(
0 => 'Blues',
1 => 'Classic Rock',
2 => 'Country',
3 => 'Dance',
4 => 'Disco',
5 => 'Funk',
6 => 'Grunge',
7 => 'Hip-Hop',
8 => 'Jazz',
9 => 'Metal',
10 => 'New Age',
11 => 'Oldies',
12 => 'Other',
13 => 'Pop',
14 => 'R&B',
15 => 'Rap',
16 => 'Reggae',
17 => 'Rock',
18 => 'Techno',
19 => 'Industrial',
20 => 'Alternative',
21 => 'Ska',
22 => 'Death Metal',
23 => 'Pranks',
24 => 'Soundtrack',
25 => 'Euro-Techno',
26 => 'Ambient',
27 => 'Trip-Hop',
28 => 'Vocal',
29 => 'Jazz+Funk',
30 => 'Fusion',
31 => 'Trance',
32 => 'Classical',
33 => 'Instrumental',
34 => 'Acid',
35 => 'House',
36 => 'Game',
37 => 'Sound Clip',
38 => 'Gospel',
39 => 'Noise',
40 => 'Alt. Rock',
41 => 'Bass',
42 => 'Soul',
43 => 'Punk',
44 => 'Space',
45 => 'Meditative',
46 => 'Instrumental Pop',
47 => 'Instrumental Rock',
48 => 'Ethnic',
49 => 'Gothic',
50 => 'Darkwave',
51 => 'Techno-Industrial',
52 => 'Electronic',
53 => 'Pop-Folk',
54 => 'Eurodance',
55 => 'Dream',
56 => 'Southern Rock',
57 => 'Comedy',
58 => 'Cult',
59 => 'Gangsta Rap',
60 => 'Top 40',
61 => 'Christian Rap',
62 => 'Pop/Funk',
63 => 'Jungle',
64 => 'Native American',
65 => 'Cabaret',
66 => 'New Wave',
67 => 'Psychedelic',
68 => 'Rave',
69 => 'Showtunes',
70 => 'Trailer',
71 => 'Lo-Fi',
72 => 'Tribal',
73 => 'Acid Punk',
74 => 'Acid Jazz',
75 => 'Polka',
76 => 'Retro',
77 => 'Musical',
78 => 'Rock & Roll',
79 => 'Hard Rock',
80 => 'Folk',
81 => 'Folk/Rock',
82 => 'National Folk',
83 => 'Swing',
84 => 'Fast-Fusion',
85 => 'Bebob',
86 => 'Latin',
87 => 'Revival',
88 => 'Celtic',
89 => 'Bluegrass',
90 => 'Avantgarde',
91 => 'Gothic Rock',
92 => 'Progressive Rock',
93 => 'Psychedelic Rock',
94 => 'Symphonic Rock',
95 => 'Slow Rock',
96 => 'Big Band',
97 => 'Chorus',
98 => 'Easy Listening',
99 => 'Acoustic',
100 => 'Humour',
101 => 'Speech',
102 => 'Chanson',
103 => 'Opera',
104 => 'Chamber Music',
105 => 'Sonata',
106 => 'Symphony',
107 => 'Booty Bass',
108 => 'Primus',
109 => 'Porn Groove',
110 => 'Satire',
111 => 'Slow Jam',
112 => 'Club',
113 => 'Tango',
114 => 'Samba',
115 => 'Folklore',
116 => 'Ballad',
117 => 'Power Ballad',
118 => 'Rhythmic Soul',
119 => 'Freestyle',
120 => 'Duet',
121 => 'Punk Rock',
122 => 'Drum Solo',
123 => 'A Cappella',
124 => 'Euro-House',
125 => 'Dance Hall',
126 => 'Goa',
127 => 'Drum & Bass',
128 => 'Club-House',
129 => 'Hardcore',
130 => 'Terror',
131 => 'Indie',
132 => 'BritPop',
133 => 'Negerpunk',
134 => 'Polsk Punk',
135 => 'Beat',
136 => 'Christian Gangsta Rap',
137 => 'Heavy Metal',
138 => 'Black Metal',
139 => 'Crossover',
140 => 'Contemporary Christian',
141 => 'Christian Rock',
142 => 'Merengue',
143 => 'Salsa',
144 => 'Thrash Metal',
145 => 'Anime',
146 => 'JPop',
147 => 'Synthpop',
255 => 'Unknown',
'CR' => 'Cover',
'RX' => 'Remix'
);
static $GenreLookupSCMPX = array();
if ($allowSCMPXextended && empty($GenreLookupSCMPX)) {
$GenreLookupSCMPX = $GenreLookup;
// http://www.geocities.co.jp/SiliconValley-Oakland/3664/alittle.html#GenreExtended
// Extended ID3v1 genres invented by SCMPX
// Note that 255 "Japanese Anime" conflicts with standard "Unknown"
$GenreLookupSCMPX[240] = 'Sacred';
$GenreLookupSCMPX[241] = 'Northern Europe';
$GenreLookupSCMPX[242] = 'Irish & Scottish';
$GenreLookupSCMPX[243] = 'Scotland';
$GenreLookupSCMPX[244] = 'Ethnic Europe';
$GenreLookupSCMPX[245] = 'Enka';
$GenreLookupSCMPX[246] = 'Children\'s Song';
$GenreLookupSCMPX[247] = 'Japanese Sky';
$GenreLookupSCMPX[248] = 'Japanese Heavy Rock';
$GenreLookupSCMPX[249] = 'Japanese Doom Rock';
$GenreLookupSCMPX[250] = 'Japanese J-POP';
$GenreLookupSCMPX[251] = 'Japanese Seiyu';
$GenreLookupSCMPX[252] = 'Japanese Ambient Techno';
$GenreLookupSCMPX[253] = 'Japanese Moemoe';
$GenreLookupSCMPX[254] = 'Japanese Tokusatsu';
//$GenreLookupSCMPX[255] = 'Japanese Anime';
}
return ($allowSCMPXextended ? $GenreLookupSCMPX : $GenreLookup);
}
public static function LookupGenreName($genreid, $allowSCMPXextended=true) {
switch ($genreid) {
case 'RX':
case 'CR':
break;
default:
if (!is_numeric($genreid)) {
return false;
}
$genreid = intval($genreid); // to handle 3 or '3' or '03'
break;
}
$GenreLookup = self::ArrayOfGenres($allowSCMPXextended);
return (isset($GenreLookup[$genreid]) ? $GenreLookup[$genreid] : false);
}
public static function LookupGenreID($genre, $allowSCMPXextended=false) {
$GenreLookup = self::ArrayOfGenres($allowSCMPXextended);
$LowerCaseNoSpaceSearchTerm = strtolower(str_replace(' ', '', $genre));
foreach ($GenreLookup as $key => $value) {
if (strtolower(str_replace(' ', '', $value)) == $LowerCaseNoSpaceSearchTerm) {
return $key;
}
}
return false;
}
public static function StandardiseID3v1GenreName($OriginalGenre) {
if (($GenreID = self::LookupGenreID($OriginalGenre)) !== false) {
return self::LookupGenreName($GenreID);
}
return $OriginalGenre;
}
public static function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track='') {
$ID3v1Tag = 'TAG';
$ID3v1Tag .= str_pad(trim(substr($title, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
$ID3v1Tag .= str_pad(trim(substr($artist, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
$ID3v1Tag .= str_pad(trim(substr($album, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
$ID3v1Tag .= str_pad(trim(substr($year, 0, 4)), 4, "\x00", STR_PAD_LEFT);
if (!empty($track) && ($track > 0) && ($track <= 255)) {
$ID3v1Tag .= str_pad(trim(substr($comment, 0, 28)), 28, "\x00", STR_PAD_RIGHT);
$ID3v1Tag .= "\x00";
if (gettype($track) == 'string') {
$track = (int) $track;
}
$ID3v1Tag .= chr($track);
} else {
$ID3v1Tag .= str_pad(trim(substr($comment, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
}
if (($genreid < 0) || ($genreid > 147)) {
$genreid = 255; // 'unknown' genre
}
switch (gettype($genreid)) {
case 'string':
case 'integer':
$ID3v1Tag .= chr(intval($genreid));
break;
default:
$ID3v1Tag .= chr(255); // 'unknown' genre
break;
}
return $ID3v1Tag;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,252 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
namespace ID3Parser\getID3;
class getID3 {
// public: Settings
private $encoding = 'UTF-8'; // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
// public: Read buffer size in bytes
private $option_fread_buffer_size = 32768;
// Public variables
public $filename; // Filename of file being analysed.
public $fp; // Filepointer to file being analysed.
public $info; // Result array.
public $memory_limit = 0;
// Protected variables
protected $startup_error = '';
protected $startup_warning = '';
const FREAD_BUFFER_SIZE = 32768;
// public: constructor
public function __construct() {
// Check for PHP version
$required_php_version = '5.3.0';
if (version_compare(PHP_VERSION, $required_php_version, '<')) {
$this->startup_error .= 'getID3() requires PHP v'.$required_php_version.' or higher - you are running v'.PHP_VERSION;
return false;
}
// Check memory
$this->memory_limit = ini_get('memory_limit');
if (preg_match('#([0-9]+)M#i', $this->memory_limit, $matches)) {
// could be stored as "16M" rather than 16777216 for example
$this->memory_limit = $matches[1] * 1048576;
} elseif (preg_match('#([0-9]+)G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
// could be stored as "2G" rather than 2147483648 for example
$this->memory_limit = $matches[1] * 1073741824;
}
if ($this->memory_limit <= 0) {
// memory limits probably disabled
} elseif ($this->memory_limit <= 4194304) {
$this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini';
} elseif ($this->memory_limit <= 12582912) {
$this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
}
return true;
}
public function fread_buffer_size() {
return $this->option_fread_buffer_size;
}
// public: setOption
public function setOption($optArray) {
if (!is_array($optArray) || empty($optArray)) {
return false;
}
foreach ($optArray as $opt => $val) {
if (isset($this->$opt) === false) {
continue;
}
$this->$opt = $val;
}
return true;
}
public function openfile($filename) {
try {
if (!empty($this->startup_error)) {
throw new getid3_exception($this->startup_error);
}
if (!empty($this->startup_warning)) {
$this->warning($this->startup_warning);
}
// init result array and set parameters
$this->filename = $filename;
$this->info = array();
// remote files not supported
if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
throw new getid3_exception('Remote files are not supported - please copy the file locally first');
}
$filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
$filename = preg_replace('#(.+)'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#U', '\1'.DIRECTORY_SEPARATOR, $filename);
// open local file
//if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { // see http://www.getid3.org/phpBB3/viewtopic.php?t=1720
if ((is_readable($filename) || file_exists($filename)) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {
// great
} else {
$errormessagelist = array();
if (!is_readable($filename)) {
$errormessagelist[] = '!is_readable';
}
if (!is_file($filename)) {
$errormessagelist[] = '!is_file';
}
if (!file_exists($filename)) {
$errormessagelist[] = '!file_exists';
}
if (empty($errormessagelist)) {
$errormessagelist[] = 'fopen failed';
}
throw new getid3_exception('Could not open "'.$filename.'" ('.implode('; ', $errormessagelist).')');
}
$this->info['filesize'] = filesize($filename);
// set redundant parameters - might be needed in some include file
// filenames / filepaths in getID3 are always expressed with forward slashes (unix-style) for both Windows and other to try and minimize confusion
$filename = str_replace('\\', '/', $filename);
$this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
$this->info['filename'] = getid3_lib::mb_basename($filename);
$this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
// set more parameters
$this->info['avdataoffset'] = 0;
$this->info['avdataend'] = $this->info['filesize'];
$this->info['fileformat'] = ''; // filled in later
$this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
$this->info['video']['dataformat'] = ''; // filled in later, unset if not used
$this->info['tags'] = array(); // filled in later, unset if not used
$this->info['error'] = array(); // filled in later, unset if not used
$this->info['warning'] = array(); // filled in later, unset if not used
$this->info['comments'] = array(); // filled in later, unset if not used
$this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
return true;
} catch (\Exception $e) {
$this->error($e->getMessage());
}
return false;
}
// public: analyze file
public function analyze($filename) {
try {
if (!$this->openfile($filename)) {
return $this->info;
}
// Handle tags
foreach (array('id3v2'=>'id3v2', 'id3v1'=>'id3v1') as $tag_name => $tag_key) {
$option_tag = 'option_tag_'.$tag_name;
if ($option_tag) {
try {
$tag_class = '\ID3Parser\getID3\Tags\getid3_'.$tag_name;
/** @var Tags\getid3_id3v2|Tags\getid3_id3v2 $tag */
$tag = new $tag_class($this);
$tag->Analyze();
}
catch (getid3_exception $e) {
throw $e;
}
}
}
if (isset($this->info['id3v2']['tag_offset_start'])) {
$this->info['avdataoffset'] = max($this->info['avdataoffset'], $this->info['id3v2']['tag_offset_end']);
}
foreach (array('id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
if (isset($this->info[$tag_key]['tag_offset_start'])) {
$this->info['avdataend'] = min($this->info['avdataend'], $this->info[$tag_key]['tag_offset_start']);
}
}
} catch (\Exception $e) {
$this->error('Caught exception: '.$e->getMessage());
}
// return info array
return $this->info;
}
// private: error handling
public function error($message) {
$this->CleanUp();
if (!isset($this->info['error'])) {
$this->info['error'] = array();
}
$this->info['error'][] = $message;
return $this->info;
}
// private: warning handling
public function warning($message) {
$this->info['warning'][] = $message;
return true;
}
// private: CleanUp
private function CleanUp() {
// remove possible empty keys
$AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
foreach ($AVpossibleEmptyKeys as $dummy => $key) {
if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
unset($this->info['audio'][$key]);
}
if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) {
unset($this->info['video'][$key]);
}
}
// remove empty root keys
if (!empty($this->info)) {
foreach ($this->info as $key => $value) {
if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
unset($this->info[$key]);
}
}
}
// remove meaningless entries from unknown-format files
if (empty($this->info['fileformat'])) {
if (isset($this->info['avdataoffset'])) {
unset($this->info['avdataoffset']);
}
if (isset($this->info['avdataend'])) {
unset($this->info['avdataend']);
}
}
// remove possible duplicated identical entries
if (!empty($this->info['error'])) {
$this->info['error'] = array_values(array_unique($this->info['error']));
}
if (!empty($this->info['warning'])) {
$this->info['warning'] = array_values(array_unique($this->info['warning']));
}
// remove "global variable" type keys
unset($this->info['php_memory_limit']);
return true;
}
}

View file

@ -0,0 +1,13 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
namespace ID3Parser\getID3;
class getid3_exception extends \Exception {
public $message;
}

View file

@ -0,0 +1,145 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
namespace ID3Parser\getID3;
abstract class getid3_handler {
/**
* @var getID3
*/
protected $getid3; // pointer
protected $data_string_flag = false; // analyzing filepointer or string
protected $data_string = ''; // string to analyze
protected $data_string_position = 0; // seek position in string
protected $data_string_length = 0; // string length
private $dependency_to = null;
public function __construct(getID3 $getid3, $call_module=null) {
$this->getid3 = $getid3;
if ($call_module) {
$this->dependency_to = str_replace('getid3_', '', $call_module);
}
}
// Analyze from file pointer
abstract public function Analyze();
// Analyze from string instead
public function AnalyzeString($string) {
// Enter string mode
$this->setStringMode($string);
// Save info
$saved_avdataoffset = $this->getid3->info['avdataoffset'];
$saved_avdataend = $this->getid3->info['avdataend'];
$saved_filesize = (isset($this->getid3->info['filesize']) ? $this->getid3->info['filesize'] : null); // may be not set if called as dependency without openfile() call
// Reset some info
$this->getid3->info['avdataoffset'] = 0;
$this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = $this->data_string_length;
// Analyze
$this->Analyze();
// Restore some info
$this->getid3->info['avdataoffset'] = $saved_avdataoffset;
$this->getid3->info['avdataend'] = $saved_avdataend;
$this->getid3->info['filesize'] = $saved_filesize;
// Exit string mode
$this->data_string_flag = false;
}
public function setStringMode($string) {
$this->data_string_flag = true;
$this->data_string = $string;
$this->data_string_length = strlen($string);
}
protected function ftell() {
if ($this->data_string_flag) {
return $this->data_string_position;
}
return ftell($this->getid3->fp);
}
protected function fread($bytes) {
if ($this->data_string_flag) {
$this->data_string_position += $bytes;
return substr($this->data_string, $this->data_string_position - $bytes, $bytes);
}
$pos = $this->ftell() + $bytes;
if (!getid3_lib::intValueSupported($pos)) {
throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
}
return fread($this->getid3->fp, $bytes);
}
protected function fseek($bytes, $whence=SEEK_SET) {
if ($this->data_string_flag) {
switch ($whence) {
case SEEK_SET:
$this->data_string_position = $bytes;
break;
case SEEK_CUR:
$this->data_string_position += $bytes;
break;
case SEEK_END:
$this->data_string_position = $this->data_string_length + $bytes;
break;
}
return 0;
} else {
$pos = $bytes;
if ($whence == SEEK_CUR) {
$pos = $this->ftell() + $bytes;
} elseif ($whence == SEEK_END) {
$pos = $this->getid3->info['filesize'] + $bytes;
}
if (!getid3_lib::intValueSupported($pos)) {
throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
}
}
return fseek($this->getid3->fp, $bytes, $whence);
}
protected function feof() {
if ($this->data_string_flag) {
return $this->data_string_position >= $this->data_string_length;
}
return feof($this->getid3->fp);
}
final protected function isDependencyFor($module) {
return $this->dependency_to == $module;
}
protected function error($text) {
$this->getid3->info['error'][] = $text;
return false;
}
protected function warning($text) {
return $this->getid3->warning($text);
}
protected function notice($text) {
// does nothing for now
}
}

File diff suppressed because it is too large Load diff

View file

@ -105,6 +105,10 @@ a,
color: $link_colour;
}
.cloud-icon.tiles i {
color: #aaa;
}
a:hover,
a:focus,
.fakelink:hover,

View file

@ -3,7 +3,7 @@
{{if $parentpath}}
<div class="cloud-container" >
<div class="cloud-icon"><a href="{{$parentpath.path}}">
<div class="cloud-icon tiles"><a href="{{$parentpath.path}}">
<i class="fa fa-fw fa-level-up" ></i>
</a>
</div>
@ -14,7 +14,7 @@
{{foreach $entries as $item}}
<div class="cloud-container">
<div class="cloud-icon"><a href="{{$item.fullPath}}">
<div class="cloud-icon tiles"><a href="{{$item.fullPath}}">
{{if $item.photo_icon}}
<img src="{{$item.photo_icon}}" title="{{$item.type}}" >
{{else}}