diff --git a/.env.example b/.env.example
new file mode 100644
index 00000000..214b4621
--- /dev/null
+++ b/.env.example
@@ -0,0 +1,19 @@
+APP_ENV=local
+APP_DEBUG=true
+APP_KEY=SomeRandomString
+
+DB_HOST=localhost
+DB_DATABASE=homestead
+DB_USERNAME=homestead
+DB_PASSWORD=secret
+
+CACHE_DRIVER=file
+SESSION_DRIVER=file
+QUEUE_DRIVER=sync
+
+MAIL_DRIVER=smtp
+MAIL_HOST=mailtrap.io
+MAIL_PORT=2525
+MAIL_USERNAME=null
+MAIL_PASSWORD=null
+MAIL_ENCRYPTION=null
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
index 21256661..95883dea 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,3 @@
-* text=auto
\ No newline at end of file
+* text=auto
+*.css linguist-vendored
+*.less linguist-vendored
diff --git a/.gitignore b/.gitignore
index 3bfe13d1..e038e3d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,50 +1,5 @@
-.vagrant
-
-# Numerous always-ignore extensions
-*.diff
-*.err
-*.orig
-*.log
-*.rej
-*.swo
-*.swp
-*.vi
-*~
-*.sass-cache
-
-# OS or Editor folders
-.DS_Store
-Thumbs.db
-.cache
-.project
-.settings
-.tmproj
-*.esproj
-nbproject
-*.iml
-
-# Dreamweaver added files
-_notes
-dwsync.xml
-
-# Komodo
-*.komodoproject
-.komodotools
-
-# Folders to ignore
-.hg
-.svn
-.CVS
-intermediate
-publish
-.idea
-
-node_modules
-/public/build/
-/bootstrap/compiled.php
/vendor
-/app/config/production
-composer.phar
-composer.lock
-atlassian-ide-plugin.xml
-_ide_helper.php
+/node_modules
+Homestead.yaml
+.env
+.vagrant
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 015febc4..00000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Contribution Guidelines
-
-Please submit all issues and pull requests to the [laravel/framework](http://github.com/laravel/framework) repository!
\ No newline at end of file
diff --git a/app/Console/Commands/Inspire.php b/app/Console/Commands/Inspire.php
new file mode 100644
index 00000000..db9ab854
--- /dev/null
+++ b/app/Console/Commands/Inspire.php
@@ -0,0 +1,33 @@
+comment(PHP_EOL.Inspiring::quote().PHP_EOL);
+ }
+}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
new file mode 100644
index 00000000..0aad2598
--- /dev/null
+++ b/app/Console/Kernel.php
@@ -0,0 +1,30 @@
+command('inspire')
+ ->hourly();
+ }
+}
diff --git a/app/Events/Event.php b/app/Events/Event.php
new file mode 100644
index 00000000..ba2f8883
--- /dev/null
+++ b/app/Events/Event.php
@@ -0,0 +1,8 @@
+middleware('guest', ['except' => 'getLogout']);
+ }
+
+ /**
+ * Get a validator for an incoming registration request.
+ *
+ * @param array $data
+ * @return \Illuminate\Contracts\Validation\Validator
+ */
+ protected function validator(array $data)
+ {
+ return Validator::make($data, [
+ 'name' => 'required|max:255',
+ 'email' => 'required|email|max:255|unique:users',
+ 'password' => 'required|confirmed|min:6',
+ ]);
+ }
+
+ /**
+ * Create a new user instance after a valid registration.
+ *
+ * @param array $data
+ * @return User
+ */
+ protected function create(array $data)
+ {
+ return User::create([
+ 'name' => $data['name'],
+ 'email' => $data['email'],
+ 'password' => bcrypt($data['password']),
+ ]);
+ }
+}
diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php
new file mode 100644
index 00000000..1ceed97b
--- /dev/null
+++ b/app/Http/Controllers/Auth/PasswordController.php
@@ -0,0 +1,32 @@
+middleware('guest');
+ }
+}
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
new file mode 100644
index 00000000..9be752a1
--- /dev/null
+++ b/app/Http/Controllers/Controller.php
@@ -0,0 +1,12 @@
+ \App\Http\Middleware\Authenticate::class,
+ 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
+ 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
+ ];
+}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
new file mode 100644
index 00000000..4fbafecf
--- /dev/null
+++ b/app/Http/Middleware/Authenticate.php
@@ -0,0 +1,47 @@
+auth = $auth;
+ }
+
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @return mixed
+ */
+ public function handle($request, Closure $next)
+ {
+ if ($this->auth->guest()) {
+ if ($request->ajax()) {
+ return response('Unauthorized.', 401);
+ } else {
+ return redirect()->guest('auth/login');
+ }
+ }
+
+ return $next($request);
+ }
+}
diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php
new file mode 100644
index 00000000..3aa15f8d
--- /dev/null
+++ b/app/Http/Middleware/EncryptCookies.php
@@ -0,0 +1,17 @@
+auth = $auth;
+ }
+
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @return mixed
+ */
+ public function handle($request, Closure $next)
+ {
+ if ($this->auth->check()) {
+ return redirect('/home');
+ }
+
+ return $next($request);
+ }
+}
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
new file mode 100644
index 00000000..a2c35414
--- /dev/null
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -0,0 +1,17 @@
+ [
+ 'App\Listeners\EventListener',
+ ],
+ ];
+
+ /**
+ * Register any other events for your application.
+ *
+ * @param \Illuminate\Contracts\Events\Dispatcher $events
+ * @return void
+ */
+ public function boot(DispatcherContract $events)
+ {
+ parent::boot($events);
+
+ //
+ }
+}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
new file mode 100644
index 00000000..d50b1c0f
--- /dev/null
+++ b/app/Providers/RouteServiceProvider.php
@@ -0,0 +1,44 @@
+group(['namespace' => $this->namespace], function ($router) {
+ require app_path('Http/routes.php');
+ });
+ }
+}
diff --git a/app/User.php b/app/User.php
new file mode 100644
index 00000000..86eabed1
--- /dev/null
+++ b/app/User.php
@@ -0,0 +1,35 @@
+disableQueryLog();
-
- $oldDb = DB::connection('old');
-
- $this->call('migrate:refresh');
-
- $oldUsers = $oldDb->table('users')->get();
- $this->info('Syncing Users');
- foreach ($oldUsers as $user) {
- $displayName = $user->display_name;
- if (!$displayName)
- $displayName = $user->username;
-
- if (!$displayName)
- $displayName = $user->mlpforums_name;
-
- if (!$displayName)
- continue;
-
- DB::table('users')->insert([
- 'id' => $user->id,
- 'display_name' => $displayName,
- 'email' => $user->email,
- 'created_at' => $user->created_at,
- 'updated_at' => $user->updated_at,
- 'slug' => $user->slug,
- 'bio' => $user->bio,
- 'sync_names' => $user->sync_names,
- 'can_see_explicit_content' => $user->can_see_explicit_content,
- 'mlpforums_name' => $user->mlpforums_name,
- 'uses_gravatar' => $user->uses_gravatar,
- 'gravatar' => $user->gravatar,
- 'avatar_id' => null
- ]);
-
- $coverId = null;
- if (!$user->uses_gravatar) {
- try {
- $coverFile = $this->getIdDirectory('users', $user->id) . '/' . $user->id . '_.png';
- $coverId = \Entities\Image::upload(new Symfony\Component\HttpFoundation\File\UploadedFile($coverFile, $user->id . '_.png'), $user->id)->id;
- DB::table('users')->where('id', $user->id)->update(['avatar_id' => $coverId]);
- } catch (\Exception $e) {
- $this->error('Could copy user avatar ' . $user->id . ' because ' . $e->getMessage());
- DB::table('users')->where('id', $user->id)->update(['uses_gravatar' => true]);
- }
- }
- }
-
- $this->info('Syncing Genres');
- $oldGenres = $oldDb->table('genres')->get();
- foreach ($oldGenres as $genre) {
- DB::table('genres')->insert([
- 'id' => $genre->id,
- 'name' => $genre->title,
- 'slug' => $genre->slug
- ]);
- }
-
- $this->info('Syncing Albums');
- $oldAlbums = $oldDb->table('albums')->get();
- foreach ($oldAlbums as $playlist) {
- $logViews = $oldDb->table('album_log_views')->whereAlbumId($playlist->id)->get();
- $logDownload = $oldDb->table('album_log_downloads')->whereAlbumId($playlist->id)->get();
-
- DB::table('albums')->insert([
- 'title' => $playlist->title,
- 'description' => $playlist->description,
- 'created_at' => $playlist->created_at,
- 'updated_at' => $playlist->updated_at,
- 'deleted_at' => $playlist->deleted_at,
- 'slug' => $playlist->slug,
- 'id' => $playlist->id,
- 'user_id' => $playlist->user_id,
- 'view_count' => 0,
- 'download_count' => 0
- ]);
-
- foreach ($logViews as $logItem) {
- try {
- DB::table('resource_log_items')->insert([
- 'user_id' => $logItem->user_id,
- 'log_type' => \Entities\ResourceLogItem::VIEW,
- 'album_id' => $logItem->album_id,
- 'created_at' => $logItem->created_at,
- 'ip_address' => $logItem->ip_address,
- ]);
- } catch (\Exception $e) {
- $this->error('Could insert log item for album ' . $playlist->id . ' because ' . $e->getMessage());
- }
- }
-
- foreach ($logDownload as $logItem) {
- try {
- DB::table('resource_log_items')->insert([
- 'user_id' => $logItem->user_id,
- 'log_type' => \Entities\ResourceLogItem::DOWNLOAD,
- 'album_id' => $logItem->album_id,
- 'created_at' => $logItem->created_at,
- 'ip_address' => $logItem->ip_address,
- 'track_format_id' => $logItem->track_file_format_id - 1
- ]);
- } catch (\Exception $e) {
- $this->error('Could insert log item for album ' . $playlist->id . ' because ' . $e->getMessage());
- }
- }
- }
-
- $this->info('Syncing Tracks');
- $oldTracks = $oldDb->table('tracks')->get();
- foreach ($oldTracks as $track) {
- $coverId = null;
- if ($track->cover) {
- try {
- $coverFile = $this->getIdDirectory('tracks', $track->id) . '/' . $track->id . '_' . $track->cover . '.png';
- $coverId = \Entities\Image::upload(new Symfony\Component\HttpFoundation\File\UploadedFile($coverFile, $track->id . '_' . $track->cover . '.png'), $track->user_id)->id;
- } catch (\Exception $e) {
- $this->error('Could copy track cover ' . $track->id . ' because ' . $e->getMessage());
- }
- }
-
- $trackLogViews = $oldDb->table('track_log_views')->whereTrackId($track->id)->get();
- $trackLogPlays = $oldDb->table('track_log_plays')->whereTrackId($track->id)->get();
- $trackLogDownload = $oldDb->table('track_log_downloads')->whereTrackId($track->id)->get();
-
- DB::table('tracks')->insert([
- 'id' => $track->id,
- 'title' => $track->title,
- 'slug' => $track->slug,
- 'description' => $track->description,
- 'lyrics' => $track->lyrics,
- 'created_at' => $track->created_at,
- 'deleted_at' => $track->deleted_at,
- 'updated_at' => $track->updated_at,
- 'released_at' => $track->released_at,
- 'published_at' => $track->published_at,
- 'genre_id' => $track->genre_id,
- 'is_explicit' => $track->explicit,
- 'is_downloadable' => $track->downloadable,
- 'is_vocal' => $track->is_vocal,
- 'track_type_id' => $track->track_type_id,
- 'track_number' => $track->track_number,
- 'user_id' => $track->user_id,
- 'album_id' => $track->album_id,
- 'cover_id' => $coverId,
- 'license_id' => $track->license_id,
- 'duration' => $track->duration,
- 'view_count' => 0,
- 'play_count' => 0,
- 'download_count' => 0
- ]);
-
- foreach ($trackLogViews as $logItem) {
- try {
- DB::table('resource_log_items')->insert([
- 'user_id' => $logItem->user_id,
- 'log_type' => \Entities\ResourceLogItem::VIEW,
- 'track_id' => $logItem->track_id,
- 'created_at' => $logItem->created_at,
- 'ip_address' => $logItem->ip_address
- ]);
- } catch (\Exception $e) {
- $this->error('Could insert log item for track ' . $track->id . ' because ' . $e->getMessage());
- }
- }
-
- foreach ($trackLogPlays as $logItem) {
- try {
- DB::table('resource_log_items')->insert([
- 'user_id' => $logItem->user_id,
- 'log_type' => \Entities\ResourceLogItem::PLAY,
- 'track_id' => $logItem->track_id,
- 'created_at' => $logItem->created_at,
- 'ip_address' => $logItem->ip_address
- ]);
- } catch (\Exception $e) {
- $this->error('Could insert log item for track ' . $track->id . ' because ' . $e->getMessage());
- }
- }
-
- foreach ($trackLogDownload as $logItem) {
- try {
- DB::table('resource_log_items')->insert([
- 'user_id' => $logItem->user_id,
- 'log_type' => \Entities\ResourceLogItem::DOWNLOAD,
- 'track_id' => $logItem->track_id,
- 'created_at' => $logItem->created_at,
- 'ip_address' => $logItem->ip_address,
- 'track_format_id' => $logItem->track_file_format_id - 1
- ]);
- } catch (\Exception $e) {
- $this->error('Could insert log item for track ' . $track->id . ' because ' . $e->getMessage());
- }
- }
- }
-
- $oldShowSongs = $oldDb->table('song_track')->get();
- foreach ($oldShowSongs as $song) {
- try {
- DB::table('show_song_track')->insert([
- 'id' => $song->id,
- 'show_song_id' => $song->song_id,
- 'track_id' => $song->track_id
- ]);
- } catch (\Exception $e) {
- $this->error('Could insert show track item for ' . $song->track_id . ' because ' . $e->getMessage());
- }
- }
-
- $this->info('Syncing Playlists');
- $oldPlaylists = $oldDb->table('playlists')->get();
- foreach ($oldPlaylists as $playlist) {
- $logViews = $oldDb->table('playlist_log_views')->wherePlaylistId($playlist->id)->get();
- $logDownload = $oldDb->table('playlist_log_downloads')->wherePlaylistId($playlist->id)->get();
-
- DB::table('playlists')->insert([
- 'title' => $playlist->title,
- 'description' => $playlist->description,
- 'created_at' => $playlist->created_at,
- 'updated_at' => $playlist->updated_at,
- 'deleted_at' => $playlist->deleted_at,
- 'slug' => $playlist->slug,
- 'id' => $playlist->id,
- 'user_id' => $playlist->user_id,
- 'is_public' => true,
- 'view_count' => 0,
- 'download_count' => 0,
- ]);
-
- foreach ($logViews as $logItem) {
- try {
- DB::table('resource_log_items')->insert([
- 'user_id' => $logItem->user_id,
- 'log_type' => \Entities\ResourceLogItem::VIEW,
- 'playlist_id' => $logItem->playlist_id,
- 'created_at' => $logItem->created_at,
- 'ip_address' => $logItem->ip_address,
- ]);
- } catch (\Exception $e) {
- $this->error('Could insert log item for playlist ' . $playlist->id . ' because ' . $e->getMessage());
- }
- }
-
- foreach ($logDownload as $logItem) {
- try {
- DB::table('resource_log_items')->insert([
- 'user_id' => $logItem->user_id,
- 'log_type' => \Entities\ResourceLogItem::DOWNLOAD,
- 'playlist_id' => $logItem->playlist_id,
- 'created_at' => $logItem->created_at,
- 'ip_address' => $logItem->ip_address,
- 'track_format_id' => $logItem->track_file_format_id - 1
- ]);
- } catch (\Exception $e) {
- $this->error('Could insert log item for playlist ' . $playlist->id . ' because ' . $e->getMessage());
- }
- }
- }
-
- $this->info('Syncing Playlist Tracks');
- $oldPlaylistTracks = $oldDb->table('playlist_track')->get();
- foreach ($oldPlaylistTracks as $playlistTrack) {
- DB::table('playlist_track')->insert([
- 'id' => $playlistTrack->id,
- 'created_at' => $playlistTrack->created_at,
- 'updated_at' => $playlistTrack->updated_at,
- 'position' => $playlistTrack->position,
- 'playlist_id' => $playlistTrack->playlist_id,
- 'track_id' => $playlistTrack->track_id
- ]);
- }
-
- $this->info('Syncing Comments');
- $oldComments = $oldDb->table('comments')->get();
- foreach ($oldComments as $comment) {
- try {
- DB::table('comments')->insert([
- 'id' => $comment->id,
- 'user_id' => $comment->user_id,
- 'created_at' => $comment->created_at,
- 'deleted_at' => $comment->deleted_at,
- 'updated_at' => $comment->updated_at,
- 'content' => $comment->content,
- 'track_id' => $comment->track_id,
- 'album_id' => $comment->album_id,
- 'playlist_id' => $comment->playlist_id,
- 'profile_id' => $comment->profile_id
- ]);
- } catch (Exception $e) {
- $this->error('Could not sync comment ' . $comment->id . ' because ' . $e->getMessage());
- }
- }
-
- $this->info('Syncing Favourites');
- $oldFavs = $oldDb->table('favourites')->get();
- foreach ($oldFavs as $fav) {
- try {
- DB::table('favourites')->insert([
- 'id' => $fav->id,
- 'user_id' => $fav->user_id,
- 'created_at' => $fav->created_at,
- 'track_id' => $fav->track_id,
- 'album_id' => $fav->album_id,
- 'playlist_id' => $fav->playlist_id,
- ]);
- } catch (Exception $e) {
- $this->error('Could not sync favourite ' . $fav->id . ' because ' . $e->getMessage());
- }
- }
-
- $this->info('Syncing Followers');
- $oldFollowers = $oldDb->table('user_follower')->get();
- foreach ($oldFollowers as $follower) {
- try {
- DB::table('followers')->insert([
- 'id' => $follower->id,
- 'user_id' => $follower->follower_id,
- 'artist_id' => $follower->user_id,
- 'created_at' => $follower->created_at,
- ]);
- } catch (Exception $e) {
- $this->error('Could not sync follower ' . $follower->id . ' because ' . $e->getMessage());
- }
- }
- }
-
- private function getIdDirectory($type, $id) {
- $dir = (string) ( floor( $id / 100 ) * 100 );
- return \Config::get('app.files_directory') . '/' . $type . '/' . $dir;
- }
-
- protected function getArguments() {
- return [];
- }
-
- protected function getOptions() {
- return [];
- }
- }
\ No newline at end of file
diff --git a/app/commands/RefreshCache.php b/app/commands/RefreshCache.php
deleted file mode 100644
index 34a48f5d..00000000
--- a/app/commands/RefreshCache.php
+++ /dev/null
@@ -1,202 +0,0 @@
-disableQueryLog();
-
- DB::table('tracks')->update(['comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.track_id = tracks.id AND deleted_at IS NULL)')]);
-
- DB::table('albums')->update([
- 'comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.album_id = albums.id AND deleted_at IS NULL)'),
- 'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE album_id = albums.id)')
- ]);
-
- DB::table('playlists')->update([
- 'comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.playlist_id = playlists.id AND deleted_at IS NULL)'),
- 'track_count' => DB::raw('(SELECT COUNT(id) FROM playlist_track WHERE playlist_id = playlists.id)')
- ]);
-
- DB::table('users')->update([
- 'comment_count' => DB::raw('(SELECT COUNT(id) FROM comments WHERE comments.profile_id = users.id AND deleted_at IS NULL)'),
- 'track_count' => DB::raw('(SELECT COUNT(id) FROM tracks WHERE deleted_at IS NULL AND published_at IS NOT NULL AND user_id = users.id)')
- ]);
-
- $users = DB::table('users')->get();
- $cacheItems = [];
- $resources = [
- 'album' => [],
- 'playlist' => [],
- 'track' => []
- ];
-
- foreach ($users as $user) {
- $cacheItems[$user->id] = [
- 'album' => [],
- 'playlist' => [],
- 'track' => [],
- ];
- }
-
- $logItems = DB::table('resource_log_items')->get();
- foreach ($logItems as $item) {
- $type = '';
- $id = 0;
-
- if ($item->album_id) {
- $type = 'album';
- $id = $item->album_id;
- }
- else if ($item->playlist_id) {
- $type = 'playlist';
- $id = $item->playlist_id;
- }
- else if ($item->track_id) {
- $type = 'track';
- $id = $item->track_id;
- }
-
- $resource = $this->getCacheItem($resources, $type, $id);
-
- if ($item->user_id != null) {
- $userResource = $this->getUserCacheItem($cacheItems, $item->user_id, $type, $id);
-
- if ($item->log_type == \Entities\ResourceLogItem::DOWNLOAD) {
- $userResource['download_count']++;
- }
- else if ($item->log_type == \Entities\ResourceLogItem::VIEW) {
- $userResource['view_count']++;
- }
- else if ($item->log_type == \Entities\ResourceLogItem::PLAY) {
- $userResource['play_count']++;
- }
-
- $cacheItems[$item->user_id][$type][$id] = $userResource;
- }
-
- if ($item->log_type == \Entities\ResourceLogItem::DOWNLOAD) {
- $resource['download_count']++;
- }
- else if ($item->log_type == \Entities\ResourceLogItem::VIEW) {
- $resource['view_count']++;
- }
- else if ($item->log_type == \Entities\ResourceLogItem::PLAY) {
- $resource['play_count']++;
- }
-
- $resources[$type][$id] = $resource;
- }
-
- $pins = DB::table('pinned_playlists')->get();
- foreach ($pins as $pin) {
- $userResource = $this->getUserCacheItem($cacheItems, $pin->user_id, 'playlist', $pin->playlist_id);
- $userResource['is_pinned'] = true;
- $cacheItems[$pin->user_id]['playlist'][$pin->playlist_id] = $userResource;
- }
-
- $favs = DB::table('favourites')->get();
- foreach ($favs as $fav) {
- $type = '';
- $id = 0;
-
- if ($fav->album_id) {
- $type = 'album';
- $id = $fav->album_id;
- }
- else if ($fav->playlist_id) {
- $type = 'playlist';
- $id = $fav->playlist_id;
- }
- else if ($fav->track_id) {
- $type = 'track';
- $id = $fav->track_id;
- }
-
- $userResource = $this->getUserCacheItem($cacheItems, $fav->user_id, $type, $id);
- $userResource['is_favourited'] = true;
- $cacheItems[$fav->user_id][$type][$id] = $userResource;
-
- $resource = $this->getCacheItem($resources, $type, $id);
- $resource['favourite_count']++;
- $resources[$type][$id] = $resource;
- }
-
- foreach (DB::table('followers')->get() as $follower) {
- $userResource = $this->getUserCacheItem($cacheItems, $follower->user_id, 'artist', $follower->artist_id);
- $userResource['is_followed'] = true;
- $cacheItems[$follower->user_id]['artist'][$follower->artist_id] = $userResource;
- }
-
- foreach ($resources as $name => $resourceArray) {
- foreach ($resourceArray as $id => $resource) {
- DB::table($name . 's')->whereId($id)->update($resource);
- }
- }
-
- DB::table('resource_users')->delete();
- foreach ($cacheItems as $cacheItem) {
- foreach ($cacheItem as $resources) {
- foreach ($resources as $resource) {
- DB::table('resource_users')->insert($resource);
- }
- }
- }
- }
-
- private function getCacheItem(&$resources, $type, $id) {
- if (!isset($resources[$type][$id])) {
- $item = [
- 'view_count' => 0,
- 'download_count' => 0,
- 'favourite_count' => 0,
- ];
-
- if ($type == 'track')
- $item['play_count'] = 0;
-
- $resources[$type][$id] = $item;
- return $item;
- }
-
- return $resources[$type][$id];
- }
-
- private function getUserCacheItem(&$items, $userId, $type, $id) {
- if (!isset($items[$userId][$type][$id])) {
- $item = [
- 'is_followed' => false,
- 'is_favourited' => false,
- 'is_pinned' => false,
- 'view_count' => 0,
- 'play_count' => 0,
- 'download_count' => 0,
- 'user_id' => $userId
- ];
-
- $item[$type . '_id'] = $id;
-
- $items[$userId][$type][$id] = $item;
- return $item;
- }
-
- return $items[$userId][$type][$id];
- }
-
- protected function getArguments() {
- return [];
- }
-
- protected function getOptions() {
- return [];
- }
-}
\ No newline at end of file
diff --git a/app/config/app.php b/app/config/app.php
deleted file mode 100644
index a68e4624..00000000
--- a/app/config/app.php
+++ /dev/null
@@ -1,190 +0,0 @@
- false,
-
- /*
- |--------------------------------------------------------------------------
- | Application Debug Mode
- |--------------------------------------------------------------------------
- |
- | When your application is in debug mode, detailed error messages with
- | stack traces will be shown on every error that occurs within your
- | application. If disabled, a simple generic error page is shown.
- |
- */
-
- 'debug' => false,
-
- /*
- |--------------------------------------------------------------------------
- | Application URL
- |--------------------------------------------------------------------------
- |
- | This URL is used by the console to properly generate URLs when using
- | the Artisan command line tool. You should set this to the root of
- | your application so that it is used when running Artisan tasks.
- |
- */
-
- 'url' => 'http://pony.fm',
-
- /*
- |--------------------------------------------------------------------------
- | Application Timezone
- |--------------------------------------------------------------------------
- |
- | Here you may specify the default timezone for your application, which
- | will be used by the PHP date and date-time functions. We have gone
- | ahead and set this to a sensible default for you out of the box.
- |
- */
-
- 'timezone' => 'UTC',
-
- /*
- |--------------------------------------------------------------------------
- | Application Locale Configuration
- |--------------------------------------------------------------------------
- |
- | The application locale determines the default locale that will be used
- | by the translation service provider. You are free to set this value
- | to any of the locales which will be supported by the application.
- |
- */
-
- 'locale' => 'en',
-
- /*
- |--------------------------------------------------------------------------
- | Encryption Key
- |--------------------------------------------------------------------------
- |
- | This key is used by the Illuminate encrypter service and should be set
- | to a random, long string, otherwise these encrypted values will not
- | be safe. Make sure to change it before deploying any application!
- |
- */
-
- 'key' => 'AQUSDTDK5xA04yb9eO9iwlm72NpC8e90',
-
- /*
- |--------------------------------------------------------------------------
- | Autoloaded Service Providers
- |--------------------------------------------------------------------------
- |
- | The service providers listed here will be automatically loaded on the
- | request to your application. Feel free to add your own services to
- | this array to grant expanded functionality to your applications.
- |
- */
-
- 'providers' => array(
-
- 'Illuminate\Foundation\Providers\ArtisanServiceProvider',
- 'Illuminate\Auth\AuthServiceProvider',
- 'Illuminate\Cache\CacheServiceProvider',
- 'Illuminate\Foundation\Providers\CommandCreatorServiceProvider',
- 'Illuminate\Session\CommandsServiceProvider',
- 'Illuminate\Foundation\Providers\ComposerServiceProvider',
- 'Illuminate\Routing\ControllerServiceProvider',
- 'Illuminate\Cookie\CookieServiceProvider',
- 'Illuminate\Database\DatabaseServiceProvider',
- 'Illuminate\Encryption\EncryptionServiceProvider',
- 'Illuminate\Filesystem\FilesystemServiceProvider',
- 'Illuminate\Hashing\HashServiceProvider',
- 'Illuminate\Html\HtmlServiceProvider',
- 'Illuminate\Foundation\Providers\KeyGeneratorServiceProvider',
- 'Illuminate\Log\LogServiceProvider',
- 'Illuminate\Mail\MailServiceProvider',
- 'Illuminate\Foundation\Providers\MaintenanceServiceProvider',
- 'Illuminate\Database\MigrationServiceProvider',
- 'Illuminate\Foundation\Providers\OptimizeServiceProvider',
- 'Illuminate\Pagination\PaginationServiceProvider',
- 'Illuminate\Foundation\Providers\PublisherServiceProvider',
- 'Illuminate\Queue\QueueServiceProvider',
- 'Illuminate\Redis\RedisServiceProvider',
- 'Illuminate\Auth\Reminders\ReminderServiceProvider',
- 'Illuminate\Foundation\Providers\RouteListServiceProvider',
- 'Illuminate\Database\SeedServiceProvider',
- 'Illuminate\Foundation\Providers\ServerServiceProvider',
- 'Illuminate\Session\SessionServiceProvider',
- 'Illuminate\Foundation\Providers\TinkerServiceProvider',
- 'Illuminate\Translation\TranslationServiceProvider',
- 'Illuminate\Validation\ValidationServiceProvider',
- 'Illuminate\View\ViewServiceProvider',
- 'Illuminate\Workbench\WorkbenchServiceProvider',
-
- 'Intouch\LaravelNewrelic\LaravelNewrelicServiceProvider',
-
- ),
-
- /*
- |--------------------------------------------------------------------------
- | Service Provider Manifest
- |--------------------------------------------------------------------------
- |
- | The service provider manifest is used by Laravel to lazy load service
- | providers which are not needed for each request, as well to keep a
- | list of all of the services. Here, you may set its storage spot.
- |
- */
-
- 'manifest' => storage_path().'/meta',
-
- /*
- |--------------------------------------------------------------------------
- | Class Aliases
- |--------------------------------------------------------------------------
- |
- | This array of class aliases will be registered when this application
- | is started. However, feel free to register as many as you wish as
- | the aliases are "lazy" loaded so they don't hinder performance.
- |
- */
-
- 'aliases' => array(
-
- 'App' => 'Illuminate\Support\Facades\App',
- 'Artisan' => 'Illuminate\Support\Facades\Artisan',
- 'Auth' => 'Illuminate\Support\Facades\Auth',
- 'Blade' => 'Illuminate\Support\Facades\Blade',
- 'Cache' => 'Illuminate\Support\Facades\Cache',
- 'ClassLoader' => 'Illuminate\Support\ClassLoader',
- 'Config' => 'Illuminate\Support\Facades\Config',
- 'Controller' => 'Illuminate\Routing\Controllers\Controller',
- 'Cookie' => 'Illuminate\Support\Facades\Cookie',
- 'Crypt' => 'Illuminate\Support\Facades\Crypt',
- 'DB' => 'Illuminate\Support\Facades\DB',
- 'Eloquent' => 'Illuminate\Database\Eloquent\Model',
- 'Event' => 'Illuminate\Support\Facades\Event',
-// 'File' => 'Illuminate\Support\Facades\File',
- 'Form' => 'Illuminate\Support\Facades\Form',
- 'Hash' => 'Illuminate\Support\Facades\Hash',
- 'HTML' => 'Illuminate\Support\Facades\HTML',
- 'Input' => 'Illuminate\Support\Facades\Input',
- 'Lang' => 'Illuminate\Support\Facades\Lang',
- 'Log' => 'Illuminate\Support\Facades\Log',
- 'Mail' => 'Illuminate\Support\Facades\Mail',
- 'Paginator' => 'Illuminate\Support\Facades\Paginator',
- 'Password' => 'Illuminate\Support\Facades\Password',
- 'Queue' => 'Illuminate\Support\Facades\Queue',
- 'Redirect' => 'Illuminate\Support\Facades\Redirect',
- 'Redis' => 'Illuminate\Support\Facades\Redis',
- 'Request' => 'Illuminate\Support\Facades\Request',
- 'Response' => 'Illuminate\Support\Facades\Response',
- 'Route' => 'Illuminate\Support\Facades\Route',
- 'Schema' => 'Illuminate\Support\Facades\Schema',
- 'Seeder' => 'Illuminate\Database\Seeder',
- 'Session' => 'Illuminate\Support\Facades\Session',
- 'Str' => 'Illuminate\Support\Str',
- 'URL' => 'Illuminate\Support\Facades\URL',
- 'Validator' => 'Illuminate\Support\Facades\Validator',
- 'View' => 'Illuminate\Support\Facades\View',
-
- 'Newrelic' => 'Intouch\LaravelNewrelic\Facades\Newrelic',
-
- ),
-
-);
diff --git a/app/config/auth.php b/app/config/auth.php
deleted file mode 100644
index 79c15f02..00000000
--- a/app/config/auth.php
+++ /dev/null
@@ -1,63 +0,0 @@
- 'pfm',
-
- /*
- |--------------------------------------------------------------------------
- | Authentication Model
- |--------------------------------------------------------------------------
- |
- | When using the "Eloquent" authentication driver, we need to know which
- | Eloquent model should be used to retrieve your users. Of course, it
- | is often just the "User" model but you may use whatever you like.
- |
- */
-
- 'model' => 'User',
-
- /*
- |--------------------------------------------------------------------------
- | Authentication Table
- |--------------------------------------------------------------------------
- |
- | When using the "Database" authentication driver, we need to know which
- | table should be used to retrieve your users. We have chosen a basic
- | default value but you may easily change it to any table you like.
- |
- */
-
- 'table' => 'users',
-
- /*
- |--------------------------------------------------------------------------
- | Password Reminder Settings
- |--------------------------------------------------------------------------
- |
- | Here you may set the settings for password reminders, including a view
- | that should be used as your password reminder e-mail. You will also
- | be able to set the name of the table that holds the reset tokens.
- |
- */
-
- 'reminder' => array(
-
- 'email' => 'emails.auth.reminder', 'table' => 'password_reminders',
-
- ),
-
-);
\ No newline at end of file
diff --git a/app/config/cache.php b/app/config/cache.php
deleted file mode 100644
index ce898423..00000000
--- a/app/config/cache.php
+++ /dev/null
@@ -1,89 +0,0 @@
- 'file',
-
- /*
- |--------------------------------------------------------------------------
- | File Cache Location
- |--------------------------------------------------------------------------
- |
- | When using the "file" cache driver, we need a location where the cache
- | files may be stored. A sensible default has been specified, but you
- | are free to change it to any other place on disk that you desire.
- |
- */
-
- 'path' => storage_path().'/cache',
-
- /*
- |--------------------------------------------------------------------------
- | Database Cache Connection
- |--------------------------------------------------------------------------
- |
- | When using the "database" cache driver you may specify the connection
- | that should be used to store the cached items. When this option is
- | null the default database connection will be utilized for cache.
- |
- */
-
- 'connection' => null,
-
- /*
- |--------------------------------------------------------------------------
- | Database Cache Table
- |--------------------------------------------------------------------------
- |
- | When using the "database" cache driver we need to know the table that
- | should be used to store the cached items. A default table name has
- | been provided but you're free to change it however you deem fit.
- |
- */
-
- 'table' => 'cache',
-
- /*
- |--------------------------------------------------------------------------
- | Memcached Servers
- |--------------------------------------------------------------------------
- |
- | Now you may specify an array of your Memcached servers that should be
- | used when utilizing the Memcached cache driver. All of the servers
- | should contain a value for "host", "port", and "weight" options.
- |
- */
-
- 'memcached' => array(
-
- array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
-
- ),
-
- /*
- |--------------------------------------------------------------------------
- | Cache Key Prefix
- |--------------------------------------------------------------------------
- |
- | When utilizing a RAM based store such as APC or Memcached, there might
- | be other applications utilizing the same cache. So, we'll specify a
- | value to get prefixed to all our keys so we can avoid collisions.
- |
- */
-
- 'prefix' => 'laravel',
-
-);
diff --git a/app/config/compile.php b/app/config/compile.php
deleted file mode 100644
index 54d7185b..00000000
--- a/app/config/compile.php
+++ /dev/null
@@ -1,18 +0,0 @@
- PDO::FETCH_CLASS,
-
- /*
- |--------------------------------------------------------------------------
- | Default Database Connection Name
- |--------------------------------------------------------------------------
- |
- | Here you may specify which of the database connections below you wish
- | to use as your default connection for all database work. Of course
- | you may use many connections at once using the Database library.
- |
- */
-
- 'default' => 'mysql',
-
- /*
- |--------------------------------------------------------------------------
- | Database Connections
- |--------------------------------------------------------------------------
- |
- | Here are each of the database connections setup for your application.
- | Of course, examples of configuring each database platform that is
- | supported by Laravel is shown below to make development simple.
- |
- |
- | All database work in Laravel is done through the PHP PDO facilities
- | so make sure you have the driver for your particular database of
- | choice installed on your machine before you begin development.
- |
- */
-
- 'connections' => array(
-
- 'sqlite' => array(
- 'driver' => 'sqlite',
- 'database' => __DIR__.'/../database/production.sqlite',
- 'prefix' => '',
- ),
-
- 'mysql' => array(
- 'driver' => 'mysql',
- 'host' => 'localhost',
- 'database' => 'database',
- 'username' => 'root',
- 'password' => '',
- 'charset' => 'utf8',
- 'collation' => 'utf8_unicode_ci',
- 'prefix' => '',
- ),
-
- 'pgsql' => array(
- 'driver' => 'pgsql',
- 'host' => 'localhost',
- 'database' => 'database',
- 'username' => 'root',
- 'password' => '',
- 'charset' => 'utf8',
- 'prefix' => '',
- 'schema' => 'public',
- ),
-
- 'sqlsrv' => array(
- 'driver' => 'sqlsrv',
- 'host' => 'localhost',
- 'database' => 'database',
- 'username' => 'root',
- 'password' => '',
- 'prefix' => '',
- ),
-
- ),
-
- /*
- |--------------------------------------------------------------------------
- | Migration Repository Table
- |--------------------------------------------------------------------------
- |
- | This table keeps track of all the migrations that have already run for
- | your application. Using this information, we can determine which of
- | the migrations on disk have not actually be run in the databases.
- |
- */
-
- 'migrations' => 'migrations',
-
- /*
- |--------------------------------------------------------------------------
- | Redis Databases
- |--------------------------------------------------------------------------
- |
- | Redis is an open source, fast, and advanced key-value store that also
- | provides a richer set of commands than a typical key-value systems
- | such as APC or Memcached. Laravel makes it easy to dig right in.
- |
- */
-
- 'redis' => array(
-
- 'cluster' => true,
-
- 'default' => array(
- 'host' => '127.0.0.1',
- 'port' => 6379,
- 'database' => 0,
- ),
-
- ),
-
-);
diff --git a/app/config/mail.php b/app/config/mail.php
deleted file mode 100644
index eb9e6406..00000000
--- a/app/config/mail.php
+++ /dev/null
@@ -1,111 +0,0 @@
- 'smtp',
-
- /*
- |--------------------------------------------------------------------------
- | SMTP Host Address
- |--------------------------------------------------------------------------
- |
- | Here you may provide the host address of the SMTP server used by your
- | applications. A default option is provided that is compatible with
- | the Postmark mail service, which will provide reliable delivery.
- |
- */
-
- 'host' => 'smtp.mailgun.org',
-
- /*
- |--------------------------------------------------------------------------
- | SMTP Host Port
- |--------------------------------------------------------------------------
- |
- | This is the SMTP port used by your application to delivery e-mails to
- | users of your application. Like the host we have set this value to
- | stay compatible with the Postmark e-mail application by default.
- |
- */
-
- 'port' => 587,
-
- /*
- |--------------------------------------------------------------------------
- | Global "From" Address
- |--------------------------------------------------------------------------
- |
- | You may wish for all e-mails sent by your application to be sent from
- | the same address. Here, you may specify a name and address that is
- | used globally for all e-mails that are sent by your application.
- |
- */
-
- 'from' => array('address' => null, 'name' => null),
-
- /*
- |--------------------------------------------------------------------------
- | E-Mail Encryption Protocol
- |--------------------------------------------------------------------------
- |
- | Here you may specify the encryption protocol that should be used when
- | the application send e-mail messages. A sensible default using the
- | transport layer security protocol should provide great security.
- |
- */
-
- 'encryption' => 'tls',
-
- /*
- |--------------------------------------------------------------------------
- | SMTP Server Username
- |--------------------------------------------------------------------------
- |
- | If your SMTP server requires a username for authentication, you should
- | set it here. This will get used to authenticate with your server on
- | connection. You may also set the "password" value below this one.
- |
- */
-
- 'username' => null,
-
- /*
- |--------------------------------------------------------------------------
- | SMTP Server Password
- |--------------------------------------------------------------------------
- |
- | Here you may set the password required by your SMTP server to send out
- | messages from your application. This will be given to the server on
- | connection so that the application will be able to send messages.
- |
- */
-
- 'password' => null,
-
- /*
- |--------------------------------------------------------------------------
- | Sendmail System Path
- |--------------------------------------------------------------------------
- |
- | When using the "sendmail" driver to send e-mails, we will need to know
- | the path to where Sendmail lives on this server. A default path has
- | been provided here, which will work well on most of your systems.
- |
- */
-
- 'sendmail' => '/usr/sbin/sendmail -bs',
-
-);
diff --git a/app/config/poniverse.php b/app/config/poniverse.php
deleted file mode 100644
index 09a5b33a..00000000
--- a/app/config/poniverse.php
+++ /dev/null
@@ -1,11 +0,0 @@
- 1,
- 'urls' => [
- 'api' => '',
- 'auth' => '',
- 'token' => ''
- ],
- 'client_id' => 0,
- 'secret' => ''
- ];
\ No newline at end of file
diff --git a/app/config/queue.php b/app/config/queue.php
deleted file mode 100644
index 220998cb..00000000
--- a/app/config/queue.php
+++ /dev/null
@@ -1,60 +0,0 @@
- 'sync',
-
- /*
- |--------------------------------------------------------------------------
- | Queue Connections
- |--------------------------------------------------------------------------
- |
- | Here you may configure the connection information for each server that
- | is used by your application. A default configuration has been added
- | for each back-end shipped with Laravel. You are free to add more.
- |
- */
-
- 'connections' => array(
-
- 'sync' => array(
- 'driver' => 'sync',
- ),
-
- 'beanstalkd' => array(
- 'driver' => 'beanstalkd',
- 'host' => 'localhost',
- 'queue' => 'default',
- ),
-
- 'sqs' => array(
- 'driver' => 'sqs',
- 'key' => 'your-public-key',
- 'secret' => 'your-secret-key',
- 'queue' => 'your-queue-url',
- 'region' => 'us-east-1',
- ),
-
- 'iron' => array(
- 'driver' => 'iron',
- 'project' => 'your-project-id',
- 'token' => 'your-token',
- 'queue' => 'your-queue-name',
- ),
-
- ),
-
-);
diff --git a/app/config/session.php b/app/config/session.php
deleted file mode 100644
index e11e98cd..00000000
--- a/app/config/session.php
+++ /dev/null
@@ -1,125 +0,0 @@
- 'native',
-
- /*
- |--------------------------------------------------------------------------
- | Session Lifetime
- |--------------------------------------------------------------------------
- |
- | Here you may specify the number of minutes that you wish the session
- | to be allowed to remain idle for it is expired. If you want them
- | to immediately expire when the browser closes, set it to zero.
- |
- */
-
- 'lifetime' => 120,
-
- /*
- |--------------------------------------------------------------------------
- | Session File Location
- |--------------------------------------------------------------------------
- |
- | When using the native session driver, we need a location where session
- | files may be stored. A default has been set for you but a different
- | location may be specified. This is only needed for file sessions.
- |
- */
-
- 'files' => storage_path().'/sessions',
-
- /*
- |--------------------------------------------------------------------------
- | Session Database Connection
- |--------------------------------------------------------------------------
- |
- | When using the "database" session driver, you may specify the database
- | connection that should be used to manage your sessions. This should
- | correspond to a connection in your "database" configuration file.
- |
- */
-
- 'connection' => null,
-
- /*
- |--------------------------------------------------------------------------
- | Session Database Table
- |--------------------------------------------------------------------------
- |
- | When using the "database" session driver, you may specify the table we
- | should use to manage the sessions. Of course, a sensible default is
- | provided for you; however, you are free to change this as needed.
- |
- */
-
- 'table' => 'sessions',
-
- /*
- |--------------------------------------------------------------------------
- | Session Sweeping Lottery
- |--------------------------------------------------------------------------
- |
- | Some session drivers must manually sweep their storage location to get
- | rid of old sessions from storage. Here are the chances that it will
- | happen on a given request. By default, the odds are 2 out of 100.
- |
- */
-
- 'lottery' => array(2, 100),
-
- /*
- |--------------------------------------------------------------------------
- | Session Cookie Name
- |--------------------------------------------------------------------------
- |
- | Here you may change the name of the cookie used to identify a session
- | instance by ID. The name specified here will get used every time a
- | new session cookie is created by the framework for every driver.
- |
- */
-
- 'cookie' => 'laravel_session',
-
- /*
- |--------------------------------------------------------------------------
- | Session Cookie Path
- |--------------------------------------------------------------------------
- |
- | The session cookie path determines the path for which the cookie will
- | be regarded as available. Typically, this will be the root path of
- | your application but you are free to change this when necessary.
- |
- */
-
- 'path' => '/',
-
- /*
- |--------------------------------------------------------------------------
- | Session Cookie Domain
- |--------------------------------------------------------------------------
- |
- | Here you may change the domain of the cookie used to identify a session
- | in your application. This will determine which domains the cookie is
- | available to in your application. A sensible default has been set.
- |
- */
-
- 'domain' => null,
-
-);
diff --git a/app/config/testing/cache.php b/app/config/testing/cache.php
deleted file mode 100644
index 16d3ae2f..00000000
--- a/app/config/testing/cache.php
+++ /dev/null
@@ -1,20 +0,0 @@
- 'array',
-
-);
\ No newline at end of file
diff --git a/app/config/testing/session.php b/app/config/testing/session.php
deleted file mode 100644
index a18c1b9f..00000000
--- a/app/config/testing/session.php
+++ /dev/null
@@ -1,21 +0,0 @@
- 'array',
-
-);
\ No newline at end of file
diff --git a/app/config/view.php b/app/config/view.php
deleted file mode 100644
index eba10a4c..00000000
--- a/app/config/view.php
+++ /dev/null
@@ -1,31 +0,0 @@
- array(__DIR__.'/../views'),
-
- /*
- |--------------------------------------------------------------------------
- | Pagination View
- |--------------------------------------------------------------------------
- |
- | This view will be used to render the pagination link output, and can
- | be easily customized here to show any view you like. A clean view
- | compatible with Twitter's Bootstrap is given to you by default.
- |
- */
-
- 'pagination' => 'pagination::slider',
-
-);
diff --git a/app/config/workbench.php b/app/config/workbench.php
deleted file mode 100644
index 56bee526..00000000
--- a/app/config/workbench.php
+++ /dev/null
@@ -1,31 +0,0 @@
- '',
-
- /*
- |--------------------------------------------------------------------------
- | Workbench Author E-Mail Address
- |--------------------------------------------------------------------------
- |
- | Like the option above, your e-mail address is used when generating new
- | workbench packages. The e-mail is placed in your composer.json file
- | automatically after the package is created by the workbench tool.
- |
- */
-
- 'email' => '',
-
-);
\ No newline at end of file
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
deleted file mode 100644
index 5a085c0e..00000000
--- a/app/controllers/AccountController.php
+++ /dev/null
@@ -1,14 +0,0 @@
-slug != $slug)
- return Redirect::action('AlbumsController@getAlbum', [$id, $album->slug]);
-
- return View::make('albums.show');
- }
-
- public function getShortlink($id) {
- $album = Album::find($id);
- if (!$album)
- App::abort(404);
-
- return Redirect::action('AlbumsController@getTrack', [$id, $album->slug]);
- }
-
- public function getDownload($id, $extension) {
- $album = Album::with('tracks', 'user')->find($id);
- if (!$album)
- App::abort(404);
-
- $format = null;
- $formatName = null;
-
- foreach (Track::$Formats as $name => $item) {
- if ($item['extension'] == $extension) {
- $format = $item;
- $formatName = $name;
- break;
- }
- }
-
- if ($format == null)
- App::abort(404);
-
- ResourceLogItem::logItem('album', $id, ResourceLogItem::DOWNLOAD, $format['index']);
- $downloader = new AlbumDownloader($album, $formatName);
- $downloader->download();
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Mobile/TracksController.php b/app/controllers/Api/Mobile/TracksController.php
deleted file mode 100644
index d6933a84..00000000
--- a/app/controllers/Api/Mobile/TracksController.php
+++ /dev/null
@@ -1,40 +0,0 @@
-userDetails()
- ->listed()
- ->explicitFilter()
- ->published()
- ->with('user', 'genre', 'cover', 'album', 'album.user')->take(10);
-
- $json = [
- 'total_tracks' => $tracks->count(),
- 'tracks' => $tracks->toArray()
- ];
-
- return Response::json($json, 200);
- }
-
- public function popular()
- {
- $tracks = Track::popular(10)
- ->userDetails()
- ->listed()
- ->explicitFilter()
- ->published()
- ->with('user', 'genre', 'cover', 'album', 'album.user')->take(10);
-
- $json = [
- 'total_tracks' => $tracks->count(),
- 'tracks' => $tracks->toArray()
- ];
-
- return Response::json($json, 200);
- }
-}
\ No newline at end of file
diff --git a/app/controllers/Api/V1/TracksController.php b/app/controllers/Api/V1/TracksController.php
deleted file mode 100644
index 5461656d..00000000
--- a/app/controllers/Api/V1/TracksController.php
+++ /dev/null
@@ -1,94 +0,0 @@
-published()
- ->whereHash($hash)->first();
-
- if (!$track)
- return Response::json(['message' => 'Track not found.'], 403);
-
- $comments = [];
- foreach ($track->comments as $comment) {
- $comments[] = [
- 'id' => $comment->id,
- 'created_at' => $comment->created_at,
- 'content' => $comment->content,
- 'user' => [
- 'name' => $comment->user->display_name,
- 'id' => $comment->user->id,
- 'url' => $comment->user->url,
- 'avatars' => [
- 'normal' => $comment->user->getAvatarUrl(Image::NORMAL),
- 'thumbnail' => $comment->user->getAvatarUrl(Image::THUMBNAIL),
- 'small' => $comment->user->getAvatarUrl(Image::SMALL),
- ]
- ]
- ];
- }
-
- return Response::json([
- 'id' => $track->id,
- 'title' => $track->title,
- 'description' => $track->description,
- 'lyrics' => $track->lyrics,
- 'user' => [
- 'id' => $track->user->id,
- 'name' => $track->user->display_name,
- 'url' => $track->user->url,
- 'avatars' => [
- 'thumbnail' => $track->user->getAvatarUrl(Image::THUMBNAIL),
- 'small' => $track->user->getAvatarUrl(Image::SMALL),
- 'normal' => $track->user->getAvatarUrl(Image::NORMAL)
- ]
- ],
- 'stats' => [
- 'views' => $track->view_count,
- 'plays' => $track->play_count,
- 'downloads' => $track->download_count,
- 'comments' => $track->comment_count,
- 'favourites' => $track->favourite_count
- ],
- 'url' => $track->url,
- 'is_vocal' => !!$track->is_vocal,
- 'is_explicit' => !!$track->is_explicit,
- 'is_downloadable' => !!$track->is_downloadable,
- 'published_at' => $track->published_at,
- 'duration' => $track->duration,
- 'genre' => $track->genre != null
- ?
- [
- 'id' => $track->genre->id,
- 'name' => $track->genre->name
- ] : null,
- 'type' => [
- 'id' => $track->track_type->id,
- 'name' => $track->track_type->title
- ],
- 'covers' => [
- 'thumbnail' => $track->getCoverUrl(Image::THUMBNAIL),
- 'small' => $track->getCoverUrl(Image::SMALL),
- 'normal' => $track->getCoverUrl(Image::NORMAL)
- ],
- 'comments' => $comments
- ], 200);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/AccountController.php b/app/controllers/Api/Web/AccountController.php
deleted file mode 100644
index a933d856..00000000
--- a/app/controllers/Api/Web/AccountController.php
+++ /dev/null
@@ -1,38 +0,0 @@
- $user->bio,
- 'can_see_explicit_content' => $user->can_see_explicit_content == 1,
- 'display_name' => $user->display_name,
- 'sync_names' => $user->sync_names == 1,
- 'mlpforums_name' => $user->mlpforums_name,
- 'gravatar' => $user->gravatar ? $user->gravatar : $user->email,
- 'avatar_url' => !$user->uses_gravatar ? $user->getAvatarUrl() : null,
- 'uses_gravatar' => $user->uses_gravatar == 1
- ], 200);
- }
-
- public function postSave() {
- return $this->execute(new SaveAccountSettingsCommand(Input::all()));
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/AlbumsController.php b/app/controllers/Api/Web/AlbumsController.php
deleted file mode 100644
index ff8de5a2..00000000
--- a/app/controllers/Api/Web/AlbumsController.php
+++ /dev/null
@@ -1,131 +0,0 @@
-execute(new CreateAlbumCommand(Input::all()));
- }
-
- public function postEdit($id) {
- return $this->execute(new EditAlbumCommand($id, Input::all()));
- }
-
- public function postDelete($id) {
- return $this->execute(new DeleteAlbumCommand($id));
- }
-
- public function getShow($id) {
- $album = Album::with([
- 'tracks' => function($query) { $query->userDetails(); },
- 'tracks.cover',
- 'tracks.genre',
- 'tracks.user',
- 'user',
- 'comments',
- 'comments.user'])
- ->userDetails()
- ->find($id);
-
- if (!$album)
- App::abort(404);
-
- if (Input::get('log')) {
- ResourceLogItem::logItem('album', $id, ResourceLogItem::VIEW);
- $album->view_count++;
- }
-
- $returned_album = Album::mapPublicAlbumShow($album);
- if($returned_album['is_downloadable'] == 0) {
- unset($returned_album['formats']);
- }
-
- return Response::json([
- 'album' => $returned_album
- ], 200);
- }
-
- public function getIndex() {
- $page = 1;
- if (Input::has('page'))
- $page = Input::get('page');
-
- $query = Album::summary()
- ->with('user', 'user.avatar', 'cover')
- ->userDetails()
- ->orderBy('created_at', 'desc')
- ->where('track_count', '>', 0);
-
- $count = $query->count();
- $perPage = 40;
-
- $query->skip(($page - 1) * $perPage)->take($perPage);
- $albums = [];
-
- foreach ($query->get() as $album) {
- $albums[] = Album::mapPublicAlbumSummary($album);
- }
-
- return Response::json(["albums" => $albums, "current_page" => $page, "total_pages" => ceil($count / $perPage)], 200);
- }
-
- public function getOwned() {
- $query = Album::summary()->where('user_id', \Auth::user()->id)->orderBy('created_at', 'desc')->get();
- $albums = [];
- foreach ($query as $album) {
- $albums[] = [
- 'id' => $album->id,
- 'title' => $album->title,
- 'slug' => $album->slug,
- 'created_at' => $album->created_at,
- 'covers' => [
- 'small' => $album->getCoverUrl(Image::SMALL),
- 'normal' => $album->getCoverUrl(Image::NORMAL)
- ]
- ];
- }
- return Response::json($albums, 200);
- }
-
- public function getEdit($id) {
- $album = Album::with('tracks')->find($id);
- if (!$album)
- return $this->notFound('Album ' . $id . ' not found!');
-
- if ($album->user_id != Auth::user()->id)
- return $this->notAuthorized();
-
- $tracks = [];
- foreach ($album->tracks as $track) {
- $tracks[] = [
- 'id' => $track->id,
- 'title' => $track->title
- ];
- }
-
- return Response::json([
- 'id' => $album->id,
- 'title' => $album->title,
- 'user_id' => $album->user_id,
- 'slug' => $album->slug,
- 'created_at' => $album->created_at,
- 'published_at' => $album->published_at,
- 'description' => $album->description,
- 'cover_url' => $album->hasCover() ? $album->getCoverUrl(Image::NORMAL) : null,
- 'real_cover_url' => $album->getCoverUrl(Image::NORMAL),
- 'tracks' => $tracks
- ], 200);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/ArtistsController.php b/app/controllers/Api/Web/ArtistsController.php
deleted file mode 100644
index 63beb16b..00000000
--- a/app/controllers/Api/Web/ArtistsController.php
+++ /dev/null
@@ -1,180 +0,0 @@
-first();
- if (!$user)
- App::abort(404);
-
- $favs = Favourite::whereUserId($user->id)->with([
- 'track.genre',
- 'track.cover',
- 'track.user',
- 'album.cover',
- 'album.user',
- 'track' => function($query) { $query->userDetails(); },
- 'album' => function($query) { $query->userDetails(); }])->get();
-
- $tracks = [];
- $albums = [];
-
- foreach ($favs as $fav) {
- if ($fav->type == 'Entities\Track') {
- $tracks[] = Track::mapPublicTrackSummary($fav->track);
- }
- else if ($fav->type == 'Entities\Album') {
- $albums[] = Album::mapPublicAlbumSummary($fav->album);
- }
- }
-
- return Response::json([
- 'tracks' => $tracks,
- 'albums' => $albums
- ], 200);
- }
-
- public function getContent($slug) {
- $user = User::whereSlug($slug)->first();
- if (!$user)
- App::abort(404);
-
- $query = Track::summary()->published()->listed()->explicitFilter()->with('genre', 'cover', 'user')->userDetails()->whereUserId($user->id)->whereNotNull('published_at');
- $tracks = [];
- $singles = [];
-
- foreach ($query->get() as $track) {
- if ($track->album_id != null)
- $tracks[] = Track::mapPublicTrackSummary($track);
- else
- $singles[] = Track::mapPublicTrackSummary($track);
- }
-
- $query = Album::summary()
- ->with('user')
- ->orderBy('created_at', 'desc')
- ->where('track_count', '>', 0)
- ->whereUserId($user->id);
-
- $albums = [];
-
- foreach ($query->get() as $album) {
- $albums[] = Album::mapPublicAlbumSummary($album);
- }
-
- return Response::json(['singles' => $singles, 'albumTracks' => $tracks, 'albums' => $albums], 200);
- }
-
- public function getShow($slug) {
- $user = User::whereSlug($slug)
- ->userDetails()
- ->with(['comments' => function ($query) { $query->with('user'); }])
- ->first();
- if (!$user)
- App::abort(404);
-
- $trackQuery = Track::summary()
- ->published()
- ->explicitFilter()
- ->listed()
- ->with('genre', 'cover', 'user')
- ->userDetails()
- ->whereUserId($user->id)
- ->whereNotNull('published_at')
- ->orderBy('created_at', 'desc')
- ->take(20);
-
- $latestTracks = [];
- foreach ($trackQuery->get() as $track) {
- $latestTracks[] = Track::mapPublicTrackSummary($track);
- }
-
- $comments = [];
- foreach ($user->comments as $comment) {
- $comments[] = Comment::mapPublic($comment);
- }
-
- $userData = [
- 'is_following' => false
- ];
-
- if ($user->users->count()) {
- $userRow = $user->users[0];
- $userData = [
- 'is_following' => $userRow->is_followed
- ];
- }
-
- return Response::json([
- 'artist' => [
- 'id' => $user->id,
- 'name' => $user->display_name,
- 'slug' => $user->slug,
- 'is_archived' => $user->is_archived,
- 'avatars' => [
- 'small' => $user->getAvatarUrl(Image::SMALL),
- 'normal' => $user->getAvatarUrl(Image::NORMAL)
- ],
- 'created_at' => $user->created_at,
- 'followers' => [],
- 'following' => [],
- 'latest_tracks' => $latestTracks,
- 'comments' => $comments,
- 'bio' => $user->bio,
- 'mlpforums_username' => $user->mlpforums_name,
- 'message_url' => $user->message_url,
- 'user_data' => $userData
- ]
- ], 200);
- }
-
- public function getIndex() {
- $page = 1;
- if (Input::has('page'))
- $page = Input::get('page');
-
- $query = User::orderBy('created_at', 'desc')
- ->where('track_count', '>', 0);
-
- $count = $query->count();
- $perPage = 40;
-
- $query->skip(($page - 1) * $perPage)->take($perPage);
- $users = [];
-
- foreach ($query->get() as $user) {
- $users[] = [
- 'id' => $user->id,
- 'name' => $user->display_name,
- 'slug' => $user->slug,
- 'url' => $user->url,
- 'is_archived' => $user->is_archived,
- 'avatars' => [
- 'small' => $user->getAvatarUrl(Image::SMALL),
- 'normal' => $user->getAvatarUrl(Image::NORMAL)
- ],
- 'created_at' => $user->created_at
- ];
- }
-
- return Response::json(["artists" => $users, "current_page" => $page, "total_pages" => ceil($count / $perPage)], 200);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/AuthController.php b/app/controllers/Api/Web/AuthController.php
deleted file mode 100644
index 80d2de07..00000000
--- a/app/controllers/Api/Web/AuthController.php
+++ /dev/null
@@ -1,11 +0,0 @@
-execute(new CreateCommentCommand($type, $id, Input::all()));
- }
-
- public function getIndex($type, $id) {
- $column = '';
-
- if ($type == 'track')
- $column = 'track_id';
- else if ($type == 'user')
- $column = 'profile_id';
- else if ($type == 'album')
- $column = 'album_id';
- else if ($type == 'playlist')
- $column = 'playlist_id';
- else
- App::abort(500);
-
- $query = Comment::where($column, '=', $id)->orderBy('created_at', 'desc')->with('user');
- $comments = [];
-
- foreach ($query->get() as $comment) {
- $comments[] = Comment::mapPublic($comment);
- }
-
- return Response::json(['list' => $comments, 'count' => count($comments)]);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/DashboardController.php b/app/controllers/Api/Web/DashboardController.php
deleted file mode 100644
index e664dccb..00000000
--- a/app/controllers/Api/Web/DashboardController.php
+++ /dev/null
@@ -1,45 +0,0 @@
-with(['genre', 'user', 'cover', 'user.avatar'])
- ->whereIsLatest(true)
- ->listed()
- ->userDetails()
- ->explicitFilter()
- ->published()
- ->orderBy('published_at', 'desc')
- ->take(30);
-
- $recentTracks = [];
-
- foreach ($recentQuery->get() as $track) {
- $recentTracks[] = Track::mapPublicTrackSummary($track);
- }
-
- return Response::json([
- 'recent_tracks' => $recentTracks,
- 'popular_tracks' => Track::popular(30, Auth::check() && Auth::user()->can_see_explicit_content),
- 'news' => News::getNews(0, 10)], 200);
- }
-
- public function postReadNews() {
- News::markPostAsRead(Input::get('url'));
- return Response::json([
- ]);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/FavouritesController.php b/app/controllers/Api/Web/FavouritesController.php
deleted file mode 100644
index fa435cf8..00000000
--- a/app/controllers/Api/Web/FavouritesController.php
+++ /dev/null
@@ -1,98 +0,0 @@
-execute(new ToggleFavouriteCommand(Input::get('type'), Input::get('id')));
- }
-
- public function getTracks() {
- $query = Favourite
- ::whereUserId(Auth::user()->id)
- ->whereNotNull('track_id')
- ->with([
- 'track' => function($query) {
- $query
- ->userDetails()
- ->published();
- },
- 'track.user',
- 'track.genre',
- 'track.cover',
- 'track.album',
- 'track.album.user'
- ]);
-
- $tracks = [];
-
- foreach ($query->get() as $fav) {
- if ($fav->track == null) // deleted track
- continue;
-
- $tracks[] = Track::mapPublicTrackSummary($fav->track);
- }
-
- return Response::json(["tracks" => $tracks], 200);
- }
-
- public function getAlbums() {
- $query = Favourite
- ::whereUserId(Auth::user()->id)
- ->whereNotNull('album_id')
- ->with([
- 'album' => function($query) {
- $query->userDetails();
- },
- 'album.user',
- 'album.user.avatar',
- 'album.cover'
- ]);
-
- $albums = [];
-
- foreach ($query->get() as $fav) {
- if ($fav->album == null) // deleted album
- continue;
-
- $albums[] = Album::mapPublicAlbumSummary($fav->album);
- }
-
- return Response::json(["albums" => $albums], 200);
- }
-
- public function getPlaylists() {
- $query = Favourite
- ::whereUserId(Auth::user()->id)
- ->whereNotNull('playlist_id')
- ->with([
- 'playlist' => function($query) {
- $query->userDetails();
- },
- 'playlist.user',
- 'playlist.user.avatar',
- 'playlist.tracks',
- 'playlist.tracks.cover'
- ]);
-
- $playlists = [];
-
- foreach ($query->get() as $fav) {
- if ($fav->playlist == null) // deleted playlist
- continue;
-
- $playlists[] = Playlist::mapPublicPlaylistSummary($fav->playlist);
- }
-
- return Response::json(["playlists" => $playlists], 200);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/FollowController.php b/app/controllers/Api/Web/FollowController.php
deleted file mode 100644
index 3f859f72..00000000
--- a/app/controllers/Api/Web/FollowController.php
+++ /dev/null
@@ -1,13 +0,0 @@
-execute(new ToggleFollowingCommand(Input::get('type'), Input::get('id')));
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/ImagesController.php b/app/controllers/Api/Web/ImagesController.php
deleted file mode 100644
index 6a0048fe..00000000
--- a/app/controllers/Api/Web/ImagesController.php
+++ /dev/null
@@ -1,34 +0,0 @@
-id);
- $images = [];
- foreach ($query->get() as $image) {
- $images[] = [
- 'id' => $image->id,
- 'urls' => [
- 'small' => $image->getUrl(Image::SMALL),
- 'normal' => $image->getUrl(Image::NORMAL),
- 'thumbnail' => $image->getUrl(Image::THUMBNAIL),
- 'original' => $image->getUrl(Image::ORIGINAL)
- ],
- 'filename' => $image->filename
- ];
- }
-
- return Response::json($images, 200);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/PlaylistsController.php b/app/controllers/Api/Web/PlaylistsController.php
deleted file mode 100644
index 5134cac6..00000000
--- a/app/controllers/Api/Web/PlaylistsController.php
+++ /dev/null
@@ -1,118 +0,0 @@
-execute(new CreatePlaylistCommand(Input::all()));
- }
-
- public function postEdit($id) {
- return $this->execute(new EditPlaylistCommand($id, Input::all()));
- }
-
- public function postDelete($id) {
- return $this->execute(new DeletePlaylistCommand($id, Input::all()));
- }
-
- public function postAddTrack($id) {
- return $this->execute(new AddTrackToPlaylistCommand($id, Input::get('track_id')));
- }
-
- public function getIndex() {
- $page = 1;
- if (Input::has('page'))
- $page = Input::get('page');
-
- $query = Playlist::summary()
- ->with('user', 'user.avatar', 'tracks', 'tracks.cover', 'tracks.user', 'tracks.album', 'tracks.album.user')
- ->userDetails()
- ->orderBy('created_at', 'desc')
- ->where('track_count', '>', 0)
- ->whereIsPublic(true);
-
- $count = $query->count();
- $perPage = 40;
-
- $query->skip(($page - 1) * $perPage)->take($perPage);
- $playlists = [];
-
- foreach ($query->get() as $playlist) {
- $playlists[] = Playlist::mapPublicPlaylistSummary($playlist);
- }
-
- return Response::json(["playlists" => $playlists, "current_page" => $page, "total_pages" => ceil($count / $perPage)], 200);
- }
-
- public function getShow($id) {
- $playlist = Playlist::with(['tracks.user', 'tracks.genre', 'tracks.cover', 'tracks.album', 'tracks' => function($query) { $query->userDetails(); }, 'comments', 'comments.user'])->userDetails()->find($id);
- if (!$playlist || !$playlist->canView(Auth::user()))
- App::abort('404');
-
- if (Input::get('log')) {
- ResourceLogItem::logItem('playlist', $id, ResourceLogItem::VIEW);
- $playlist->view_count++;
- }
-
- return Response::json(Playlist::mapPublicPlaylistShow($playlist), 200);
- }
-
- public function getPinned() {
- $query = Playlist
- ::userDetails()
- ->with('tracks', 'tracks.cover', 'tracks.user', 'user')
- ->join('pinned_playlists', function($join) {
- $join->on('playlist_id', '=', 'playlists.id');
- })
- ->where('pinned_playlists.user_id', '=', Auth::user()->id)
- ->orderBy('title', 'asc')
- ->select('playlists.*')
- ->get();
-
- $playlists = [];
- foreach ($query as $playlist) {
- $mapped = Playlist::mapPublicPlaylistSummary($playlist);
- $mapped['description'] = $playlist->description;
- $mapped['is_pinned'] = true;
- $playlists[] = $mapped;
- }
-
- return Response::json($playlists, 200);
- }
-
- public function getOwned() {
- $query = Playlist::summary()->with('pins', 'tracks', 'tracks.cover')->where('user_id', \Auth::user()->id)->orderBy('title', 'asc')->get();
- $playlists = [];
- foreach ($query as $playlist) {
- $playlists[] = [
- 'id' => $playlist->id,
- 'title' => $playlist->title,
- 'slug' => $playlist->slug,
- 'created_at' => $playlist->created_at,
- 'description' => $playlist->description,
- 'url' => $playlist->url,
- 'covers' => [
- 'small' => $playlist->getCoverUrl(Image::SMALL),
- 'normal' => $playlist->getCoverUrl(Image::NORMAL)
- ],
- 'is_pinned' => $playlist->hasPinFor(Auth::user()->id),
- 'is_public' => $playlist->is_public == 1
- ];
- }
- return Response::json($playlists, 200);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/ProfilerController.php b/app/controllers/Api/Web/ProfilerController.php
deleted file mode 100644
index f1443252..00000000
--- a/app/controllers/Api/Web/ProfilerController.php
+++ /dev/null
@@ -1,24 +0,0 @@
- ProfileRequest::load($request)->toArray()], 200);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/TaxonomiesController.php b/app/controllers/Api/Web/TaxonomiesController.php
deleted file mode 100644
index d8c53b16..00000000
--- a/app/controllers/Api/Web/TaxonomiesController.php
+++ /dev/null
@@ -1,20 +0,0 @@
- License::all()->toArray(),
- 'genres' => Genre::select('genres.*', DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.genre_id = genres.id AND tracks.published_at IS NOT NULL) AS track_count'))->orderBy('name')->get()->toArray(),
- 'track_types' => TrackType::select('track_types.*', DB::raw('(SELECT COUNT(id) FROM tracks WHERE tracks.track_type_id = track_types.id AND tracks.published_at IS NOT NULL) AS track_count'))->get()->toArray(),
- 'show_songs' => ShowSong::select('title', 'id', 'slug', DB::raw('(SELECT COUNT(tracks.id) FROM show_song_track INNER JOIN tracks ON tracks.id = show_song_track.track_id WHERE show_song_track.show_song_id = show_songs.id AND tracks.published_at IS NOT NULL) AS track_count'))->get()->toArray()
- ], 200);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/Api/Web/TracksController.php b/app/controllers/Api/Web/TracksController.php
deleted file mode 100644
index 85752d6d..00000000
--- a/app/controllers/Api/Web/TracksController.php
+++ /dev/null
@@ -1,139 +0,0 @@
-execute(new UploadTrackCommand());
- }
-
- public function postDelete($id) {
- return $this->execute(new DeleteTrackCommand($id));
- }
-
- public function postEdit($id) {
- return $this->execute(new EditTrackCommand($id, Input::all()));
- }
-
- public function getShow($id) {
- $track = Track::userDetails()->withComments()->find($id);
- if (!$track || !$track->canView(Auth::user()))
- return $this->notFound('Track not found!');
-
- if (Input::get('log')) {
- ResourceLogItem::logItem('track', $id, ResourceLogItem::VIEW);
- $track->view_count++;
- }
-
- $returned_track = Track::mapPublicTrackShow($track);
- if ($returned_track['is_downloadable'] != 1) {
- unset($returned_track['formats']);
- }
-
- return Response::json(['track' => $returned_track], 200);
- }
-
- public function getIndex() {
- $page = 1;
- $perPage = 45;
-
- if (Input::has('page'))
- $page = Input::get('page');
-
- $query = Track::summary()
- ->userDetails()
- ->listed()
- ->explicitFilter()
- ->published()
- ->with('user', 'genre', 'cover', 'album', 'album.user');
-
- $this->applyFilters($query);
-
- $totalCount = $query->count();
- $query->take($perPage)->skip($perPage * ($page - 1));
-
- $tracks = [];
- $ids = [];
-
- foreach ($query->get(['tracks.*']) as $track) {
- $tracks[] = Track::mapPublicTrackSummary($track);
- $ids[] = $track->id;
- }
-
- return Response::json(["tracks" => $tracks, "current_page" => $page, "total_pages" => ceil($totalCount / $perPage)], 200);
- }
-
- public function getOwned() {
- $query = Track::summary()->where('user_id', \Auth::user()->id)->orderBy('created_at', 'desc');
-
- $tracks = [];
- foreach ($query->get() as $track)
- $tracks[] = Track::mapPrivateTrackSummary($track);
-
- return Response::json($tracks, 200);
- }
-
- public function getEdit($id) {
- $track = Track::with('showSongs')->find($id);
- if (!$track)
- return $this->notFound('Track ' . $id . ' not found!');
-
- if ($track->user_id != Auth::user()->id)
- return $this->notAuthorized();
-
- return Response::json(Track::mapPrivateTrackShow($track), 200);
- }
-
- private function applyFilters($query) {
- if (Input::has('order')) {
- $order = \Input::get('order');
- $parts = explode(',', $order);
- $query->orderBy($parts[0], $parts[1]);
- }
-
- if (Input::has('is_vocal')) {
- $isVocal = \Input::get('is_vocal');
- if ($isVocal == 'true')
- $query->whereIsVocal(true);
- else
- $query->whereIsVocal(false);
- }
-
- if (Input::has('in_album')) {
- if (Input::get('in_album') == 'true')
- $query->whereNotNull('album_id');
- else
- $query->whereNull('album_id');
- }
-
- if (Input::has('genres'))
- $query->whereIn('genre_id', Input::get('genres'));
-
- if (Input::has('types'))
- $query->whereIn('track_type_id', Input::get('types'));
-
- if (Input::has('songs')) {
- $query->join('show_song_track', function($join) {
- $join->on('tracks.id', '=', 'show_song_track.track_id');
- });
- $query->whereIn('show_song_track.show_song_id', Input::get('songs'));
- }
-
- return $query;
- }
- }
\ No newline at end of file
diff --git a/app/controllers/ApiControllerBase.php b/app/controllers/ApiControllerBase.php
deleted file mode 100644
index 0553f885..00000000
--- a/app/controllers/ApiControllerBase.php
+++ /dev/null
@@ -1,23 +0,0 @@
-authorize())
- return $this->notAuthorized();
-
- $result = $command->execute();
- if ($result->didFail()) {
- return Response::json(['message' => 'Validation failed', 'errors' => $result->getValidator()->messages()->getMessages()], 400);
- }
-
- return Response::json($result->getResponse(), 200);
- }
-
- public function notAuthorized() {
- return Response::json(['message' => 'You may not do this!'], 403);
- }
-
- public function notFound($message) {
- return Response::json(['message' => $message], 403);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/ArtistsController.php b/app/controllers/ArtistsController.php
deleted file mode 100644
index c5e1dde8..00000000
--- a/app/controllers/ArtistsController.php
+++ /dev/null
@@ -1,25 +0,0 @@
-first();
- if (!$user)
- App::abort('404');
-
- return View::make('artists.profile');
- }
-
- public function getShortlink($id) {
- $user = User::find($id);
- if (!$user)
- App::abort('404');
-
- return Redirect::action('ArtistsController@getProfile', [$id]);
- }
- }
\ No newline at end of file
diff --git a/app/controllers/AuthController.php b/app/controllers/AuthController.php
deleted file mode 100644
index bef05124..00000000
--- a/app/controllers/AuthController.php
+++ /dev/null
@@ -1,94 +0,0 @@
-poniverse = new Poniverse(Config::get('poniverse.client_id'), Config::get('poniverse.secret'));
- $this->poniverse->setRedirectUri(URL::to('/auth/oauth'));
- }
-
- public function getLogin() {
- if (Auth::guest())
- return Redirect::to($this->poniverse->getAuthenticationUrl('login'));
-
- return Redirect::to('/');
- }
-
- public function postLogout() {
- Auth::logout();
- return Redirect::to('/');
- }
-
- public function getOAuth() {
- $code = $this->poniverse->getClient()->getAccessToken(
- Config::get('poniverse.urls')['token'],
- 'authorization_code',
- [
- 'code' => Input::query('code'),
- 'redirect_uri' => URL::to('/auth/oauth')
- ]);
-
- if($code['code'] != 200) {
- if($code['code'] == 400 && $code['result']['error_description'] == 'The authorization code has expired' && !isset($this->request['login_attempt'])) {
- return Redirect::to($this->poniverse->getAuthenticationUrl('login_attempt'));
- }
-
- return Redirect::to('/')->with('message', 'Unfortunately we are having problems attempting to log you in at the moment. Please try again at a later time.' );
- }
-
- $this->poniverse->setAccessToken($code['result']['access_token']);
- $poniverseUser = $this->poniverse->getUser();
- $token = DB::table('oauth2_tokens')->where('external_user_id', '=', $poniverseUser['id'])->where('service', '=', 'poniverse')->first();
-
- $setData = [
- 'access_token' => $code['result']['access_token'],
- 'expires' => date( 'Y-m-d H:i:s', strtotime("+".$code['result']['expires_in']." Seconds", time())),
- 'type' => $code['result']['token_type'],
- ];
-
- if(isset($code['result']['refresh_token']) && !empty($code['result']['refresh_token'])) {
- $setData['refresh_token'] = $code['result']['refresh_token'];
- }
-
- if($token) {
- //User already exists, update access token and refresh token if provided.
- DB::table('oauth2_tokens')->where('id', '=', $token->id)->update($setData);
- return $this->loginRedirect(User::find($token->user_id));
- }
-
- //Check by email to see if they already have an account
- $localMember = User::where('email', '=', $poniverseUser['email'])->first();
-
- if ($localMember) {
- return $this->loginRedirect($localMember);
- }
-
- $user = new User;
-
- $user->mlpforums_name = $poniverseUser['username'];
- $user->display_name = $poniverseUser['display_name'];
- $user->email = $poniverseUser['email'];
- $user->created_at = gmdate("Y-m-d H:i:s", time());
- $user->uses_gravatar = 1;
-
- $user->save();
-
- //We need to insert a new token row :O
-
- $setData['user_id'] = $user->id;
- $setData['external_user_id'] = $poniverseUser['id'];
- $setData['service'] = 'poniverse';
-
- DB::table('oauth2_tokens')->insert($setData);
-
- return $this->loginRedirect($user);
- }
-
- protected function loginRedirect($user, $rememberMe = true) {
- Auth::login($user, $rememberMe);
- return Redirect::to('/');
- }
- }
\ No newline at end of file
diff --git a/app/controllers/ContentController.php b/app/controllers/ContentController.php
deleted file mode 100644
index 55b5fe56..00000000
--- a/app/controllers/ContentController.php
+++ /dev/null
@@ -1,15 +0,0 @@
-getFile($coverType['id']);
-
- if (!is_file($filename)) {
- $redirect = URL::to('/images/icons/profile_' . Image::$ImageTypes[$coverType['id']]['name'] . '.png');
- return Redirect::to($redirect);
- }
-
- if (Config::get('app.sendfile')) {
- $response->header('X-Sendfile', $filename);
- } else {
- $response->header('X-Accel-Redirect', $filename);
- }
-
- $response->header('Content-Disposition', 'filename="' . $filename . '"');
- $response->header('Content-Type', 'image/png');
-
- $lastModified = filemtime($filename);
-
- $response->header('Last-Modified', $lastModified);
- $response->header('Cache-Control', 'max-age=' . (60 * 60 * 24 * 7));
-
- return $response;
- }
- }
\ No newline at end of file
diff --git a/app/controllers/PlaylistsController.php b/app/controllers/PlaylistsController.php
deleted file mode 100644
index acfea0ab..00000000
--- a/app/controllers/PlaylistsController.php
+++ /dev/null
@@ -1,55 +0,0 @@
-canView(Auth::user()))
- App::abort(404);
-
- if ($playlist->slug != $slug)
- return Redirect::action('PlaylistsController@getPlaylist', [$id, $playlist->slug]);
-
- return View::make('playlists.show');
- }
-
- public function getShortlink($id) {
- $playlist = Playlist::find($id);
- if (!$playlist || !$playlist->canView(Auth::user()))
- App::abort(404);
-
- return Redirect::action('PlaylistsController@getPlaylist', [$id, $playlist->slug]);
- }
-
- public function getDownload($id, $extension) {
- $playlist = Playlist::with('tracks', 'user', 'tracks.album')->find($id);
- if (!$playlist || !$playlist->is_public)
- App::abort(404);
-
- $format = null;
- $formatName = null;
-
- foreach (Track::$Formats as $name => $item) {
- if ($item['extension'] == $extension) {
- $format = $item;
- $formatName = $name;
- break;
- }
- }
-
- if ($format == null)
- App::abort(404);
-
- ResourceLogItem::logItem('playlist', $id, ResourceLogItem::DOWNLOAD, $format['index']);
- $downloader = new PlaylistDownloader($playlist, $formatName);
- $downloader->download();
- }
- }
\ No newline at end of file
diff --git a/app/controllers/TracksController.php b/app/controllers/TracksController.php
deleted file mode 100644
index a9ccd910..00000000
--- a/app/controllers/TracksController.php
+++ /dev/null
@@ -1,131 +0,0 @@
-published()
- ->userDetails()
- ->with(
- 'user',
- 'user.avatar',
- 'genre'
- )->first();
-
- if (!$track || !$track->canView(Auth::user()))
- App::abort(404);
-
- $userData = [
- 'stats' => [
- 'views' => 0,
- 'plays' => 0,
- 'downloads' => 0
- ],
- 'is_favourited' => false
- ];
-
- if ($track->users->count()) {
- $userRow = $track->users[0];
- $userData = [
- 'stats' => [
- 'views' => $userRow->view_count,
- 'plays' => $userRow->play_count,
- 'downloads' => $userRow->download_count,
- ],
- 'is_favourited' => $userRow->is_favourited
- ];
- }
-
- return View::make('tracks.embed', ['track' => $track, 'user' => $userData]);
- }
-
- public function getTrack($id, $slug) {
- $track = Track::find($id);
- if (!$track || !$track->canView(Auth::user()))
- App::abort(404);
-
- if ($track->slug != $slug)
- return Redirect::action('TracksController@getTrack', [$id, $track->slug]);
-
- return View::make('tracks.show');
- }
-
- public function getShortlink($id) {
- $track = Track::find($id);
- if (!$track || !$track->canView(Auth::user()))
- App::abort(404);
-
- return Redirect::action('TracksController@getTrack', [$id, $track->slug]);
- }
-
- public function getStream($id, $extension) {
- $track = Track::find($id);
- if (!$track || !$track->canView(Auth::user()))
- App::abort(404);
-
- $trackFile = TrackFile::findOrFailByExtension($track->id, $extension);
- ResourceLogItem::logItem('track', $id, ResourceLogItem::PLAY, $trackFile->getFormat()['index']);
-
- $response = Response::make('', 200);
- $filename = $trackFile->getFile();
-
- if (Config::get('app.sendfile')) {
- $response->header('X-Sendfile', $filename);
- } else {
- $response->header('X-Accel-Redirect', $filename);
- }
-
- $time = gmdate(filemtime($filename));
-
- if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $time == $_SERVER['HTTP_IF_MODIFIED_SINCE']) {
- header('HTTP/1.0 304 Not Modified');
- exit();
- }
-
- $response->header('Last-Modified', $time);
- $response->header('Content-Type', $trackFile->getFormat()['mime_type']);
-
- return $response;
- }
-
- public function getDownload($id, $extension) {
- $track = Track::find($id);
- if (!$track || !$track->canView(Auth::user()))
- App::abort(404);
-
- $trackFile = TrackFile::findOrFailByExtension($track->id, $extension);
- ResourceLogItem::logItem('track', $id, ResourceLogItem::DOWNLOAD, $trackFile->getFormat()['index']);
-
- $response = Response::make('', 200);
- $filename = $trackFile->getFile();
-
- if (Config::get('app.sendfile')) {
- $response->header('X-Sendfile', $filename);
- $response->header('Content-Disposition', 'attachment; filename="' . $trackFile->getDownloadFilename() . '"');
- } else {
- $response->header('X-Accel-Redirect', $filename);
- $response->header('Content-Disposition', 'attachment; filename="' . $trackFile->getDownloadFilename() . '"');
- }
-
- $time = gmdate(filemtime($filename));
-
- if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $time == $_SERVER['HTTP_IF_MODIFIED_SINCE']) {
- header('HTTP/1.0 304 Not Modified');
- exit();
- }
-
- $response->header('Last-Modified', $time);
- $response->header('Content-Type', $trackFile->getFormat()['mime_type']);
-
- return $response;
- }
- }
\ No newline at end of file
diff --git a/app/controllers/UploaderController.php b/app/controllers/UploaderController.php
deleted file mode 100644
index c748fb3a..00000000
--- a/app/controllers/UploaderController.php
+++ /dev/null
@@ -1,7 +0,0 @@
-getAvatarFile($coverType['id']), 'image/png', 'cover.png');
- }
- }
\ No newline at end of file
diff --git a/app/database/migrations/2013_06_07_003952_create_users_table.php b/app/database/migrations/2013_06_07_003952_create_users_table.php
deleted file mode 100644
index b0dd0bae..00000000
--- a/app/database/migrations/2013_06_07_003952_create_users_table.php
+++ /dev/null
@@ -1,57 +0,0 @@
-increments('id');
- $table->string('display_name', 255);
- $table->string('mlpforums_name')->nullable();
- $table->boolean('sync_names')->default(true);
- $table->string('email', 150)->indexed();
- $table->string('gravatar')->nullable();
- $table->string('slug');
- $table->boolean('uses_gravatar')->default(true);
- $table->boolean('can_see_explicit_content');
- $table->text('bio');
- $table->integer('track_count')->unsigned();
- $table->integer('comment_count')->unsigned();
- $table->timestamps();
- });
-
- Schema::create('roles', function($table){
- $table->increments('id');
- $table->string('name');
- });
-
- Schema::create('role_user', function($table){
- $table->increments('id');
- $table->integer('user_id')->unsigned()->index();
- $table->integer('role_id')->unsigned()->index();
- $table->timestamps();
-
- $table->foreign('user_id')->references('id')->on('users');
- $table->foreign('role_id')->references('id')->on('roles');
- });
-
- Schema::create('cache', function($table){
- $table->string('key')->index();
- $table->text('value');
- $table->integer('expiration')->unsigned()->index();
- });
-
- DB::table('roles')->insert(['name' => 'super_admin']);
- DB::table('roles')->insert(['name' => 'admin']);
- DB::table('roles')->insert(['name' => 'moderator']);
- DB::table('roles')->insert(['name' => 'user']);
- }
-
- public function down() {
- Schema::drop('cache');
- Schema::drop('role_user');
- Schema::drop('roles');
- Schema::drop('users');
- }
-}
diff --git a/app/database/migrations/2013_06_27_015259_create_tracks_table.php b/app/database/migrations/2013_06_27_015259_create_tracks_table.php
deleted file mode 100644
index ad97ac73..00000000
--- a/app/database/migrations/2013_06_27_015259_create_tracks_table.php
+++ /dev/null
@@ -1,128 +0,0 @@
-increments('id');
- $table->string('title', 100);
- $table->text('description');
- $table->boolean('affiliate_distribution');
- $table->boolean('open_distribution');
- $table->boolean('remix');
- });
-
- Schema::create('genres', function($table){
- $table->increments('id');
- $table->string('name')->unique();
- $table->string('slug', 200)->index();
- });
-
- Schema::create('track_types', function($table){
- $table->increments('id');
- $table->string('title');
- $table->string('editor_title');
- });
-
- Schema::create('tracks', function($table){
- $table->increments('id');
-
- $table->integer('user_id')->unsigned();
- $table->integer('license_id')->unsigned()->nullable()->default(NULL);
- $table->integer('genre_id')->unsigned()->nullable()->index()->default(NULL);
- $table->integer('track_type_id')->unsigned()->nullable()->default(NULL);
-
- $table->string('title', 100)->index();
- $table->string('slug', 200)->index();
- $table->text('description')->nullable();
- $table->text('lyrics')->nullable();
- $table->boolean('is_vocal');
- $table->boolean('is_explicit');
- $table->integer('cover_id')->unsigned()->nullable();
- $table->boolean('is_downloadable');
- $table->float('duration')->unsigned();
-
- $table->integer('play_count')->unsigned();
- $table->integer('view_count')->unsigned();
- $table->integer('download_count')->unsigned();
- $table->integer('favourite_count')->unsigned();
- $table->integer('comment_count')->unsigned();
-
- $table->timestamps();
- $table->timestamp('deleted_at')->nullable()->index();
- $table->timestamp('published_at')->nullable()->index();
- $table->timestamp('released_at')->nullable();
-
- $table->foreign('user_id')->references('id')->on('users');
- $table->foreign('license_id')->references('id')->on('licenses');
- $table->foreign('genre_id')->references('id')->on('genres')->on_update('cascade');
- $table->foreign('track_type_id')->references('id')->on('track_types')->on_update('cascade');
- });
-
-
- DB::table('licenses')->insert([
- 'title' => 'Personal',
- 'description' => 'Only you and Pony.fm are allowed to distribute and broadcast the track.',
- 'affiliate_distribution' => 0,
- 'open_distribution' => 0,
- 'remix' => 0
- ]);
-
- DB::table('licenses')->insert([
- 'title' => 'Broadcast',
- 'description' => 'You, Pony.fm, and its affiliates may distribute and broadcast the track.',
- 'affiliate_distribution' => 1,
- 'open_distribution' => 0,
- 'remix' => 0
- ]);
-
- DB::table('licenses')->insert([
- 'title' => 'Open',
- 'description' => 'Anyone is permitted to broadcast and distribute the song in its original form, with attribution to you.',
- 'affiliate_distribution' => 1,
- 'open_distribution' => 1,
- 'remix' => 0
- ]);
-
- DB::table('licenses')->insert([
- 'title' => 'Remix',
- 'description' => 'Anyone is permitted to broadcast and distribute the song in any form, or create derivative works based on it for any purpose, with attribution to you.',
- 'affiliate_distribution' => 1,
- 'open_distribution' => 1,
- 'remix' => 1
- ]);
-
- DB::table('track_types')->insert([
- 'title' => 'Original Song',
- 'editor_title' => 'an original song'
- ]);
-
- DB::table('track_types')->insert([
- 'title' => 'Official Song Remix',
- 'editor_title' => 'a remix of an official song'
- ]);
-
- DB::table('track_types')->insert([
- 'title' => 'Fan Song Remix',
- 'editor_title' => 'a remix of a fan song'
- ]);
-
- DB::table('track_types')->insert([
- 'title' => 'Ponified Song',
- 'editor_title' => 'a non-pony song, turned pony'
- ]);
-
- DB::table('track_types')->insert([
- 'title' => 'Official Show Audio Remix',
- 'editor_title' => 'a remix of official show audio'
- ]);
- }
-
- public function down() {
- Schema::drop('tracks');
- Schema::drop('licenses');
- Schema::drop('track_types');
- Schema::drop('genres');
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_07_26_230827_create_images_table.php b/app/database/migrations/2013_07_26_230827_create_images_table.php
deleted file mode 100644
index bf1f9e0b..00000000
--- a/app/database/migrations/2013_07_26_230827_create_images_table.php
+++ /dev/null
@@ -1,44 +0,0 @@
-increments('id');
- $table->string('filename', 256);
- $table->string('mime', 100);
- $table->string('extension', 32);
- $table->integer('size');
- $table->string('hash', 32);
- $table->integer('uploaded_by')->unsigned();
- $table->timestamps();
-
- $table->foreign('uploaded_by')->references('id')->on('users');
- });
-
- Schema::table('users', function($table) {
- $table->integer('avatar_id')->unsigned()->nullable();
- $table->foreign('avatar_id')->references('id')->on('images');
- });
-
- DB::table('tracks')->update(['cover_id' => null]);
-
- Schema::table('tracks', function($table) {
- $table->foreign('cover_id')->references('id')->on('images');
- });
- }
-
- public function down() {
- Schema::table('tracks', function($table) {
- $table->dropForeign('tracks_cover_id_foreign');
- });
-
- Schema::table('users', function($table) {
- $table->dropForeign('users_avatar_id_foreign');
- $table->dropColumn('avatar_id');
- });
-
- Schema::drop('images');
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_07_28_034328_create_songs_table.php b/app/database/migrations/2013_07_28_034328_create_songs_table.php
deleted file mode 100644
index 9b7e24f2..00000000
--- a/app/database/migrations/2013_07_28_034328_create_songs_table.php
+++ /dev/null
@@ -1,2050 +0,0 @@
-increments('id');
- $table->string('title', 100);
- $table->text('lyrics');
- $table->string('slug', 200)->indexed();
- });
-
- Schema::create('show_song_track', function($table) {
- $table->increments('id');
- $table->integer('track_id')->unsigned();
- $table->integer('show_song_id')->unsigned();
-
- $table->foreign('track_id')->references('id')->on('tracks')->on_update('cascade');
- $table->foreign('show_song_id')->references('id')->on('show_songs')->on_update('cascade');
- });
-
- DB::table('show_songs')->insert([
- 'id' => 1,
- 'title' => "Equestria Girls",
- 'lyrics' => "[Pinkie Pie]
-Ooh! This is my jam!
-
-There is a place
-Where the grass is what's for dinner
-Applejack: Soup's on, everypony!
-[Pinkie Pie]
-Charmed, fun, and wild
-Applejack: Yeehaw!
-[Pinkie Pie]
-There must be something in the water
-Spike: What?
-[Pinkie Pie]
-Sippin' rainbow juice
-Talking Elements of Harmony
-Rarity, Twilight, Applejack: Yeah!
-[Pinkie Pie]
-Our Bronies
-
-Braeburn: Hey there!
-
-[Pinkie Pie]
-Hang out too
-
-Ponies: (laughing)
-Spike: Come on, Bronies!
-
-[Pinkie Pie]
-'Cause they know we're awesome fillies
-Spike: Come on, everypony!
-
-[Pinkie Pie]
-You could travel the world (You could travel the world)
-But no one can groove like the girls with the hooves
-Once you party with ponies
-
-Spike: Party with the ponies
-
-[Pinkie Pie]
-You'll be seeing Rainbooms!
-O-oh o-oh o-ooh!
-
-(Chorus)
-[Pinkie Pie]
-Equestria girls, we're kinda magical
-Spike: Equestria!
-
-[Pinkie Pie]
-Boots on hooves, bikinis on top
-Furry coats, so cute
-We'll blow your mind
-Aoaoah oh, aoaoaoh!
-Equestria girls, we're pony-fabulous
-
-Spike: Equestria!
-
-[Pinkie Pie]
-Fast, fine, fierce, we trot till we drop (Rarity: Oh!)
-Cutie marks represent
-
-Spike: Cutie marks!
-
-[Pinkie Pie]
-Now put your hooves up
-
-Spike: Put yo' hooves in the air
-
-[Pinkie Pie]
-Aoaoah oh, aoaoaoh!
-
-[Male Backup/Spike]
-Break it down, DJ Pon-3
-These are the ponies I love the most
-I wish you could all be Equestria girls",
- 'slug' => "equestria-girls",
- ]);
- DB::table('show_songs')->insert([
- 'id' => 2,
- 'title' => "My Little Pony Theme Song",
- 'lyrics' => "[Backup singer]
-My Little Pony, My Little Pony
-Ahh, ahh, ahh, ahhh…..
-
-[Twilight Sparkle]
-(My Little Pony)
-I used to wonder what friendship could be
-(My Little Pony)
-Until you all shared its magic with me
-
-[Rainbow Dash]
-Big adventure
-
-[Pinkie Pie]
-Tons of fun
-
-[Rarity]
-A beautiful heart
-
-[Applejack]
-Faithful and strong
-
-[Fluttershy]
-Sharing kindness
-
-[Twilight Sparkle]
-It's an easy feat
-And magic makes it all complete
-You have my little ponies
-Do you know you're all my very best friends?",
- 'slug' => "my-little-pony-theme-song",
- ]);
- DB::table('show_songs')->insert([
- 'id' => 3,
- 'title' => "Laughter Song",
- 'lyrics' => "[Pinkie Pie]
-When I was a little filly and the sun was going down...
-
-Twilight Sparkle: Tell me she's not...
-
-[Pinkie Pie]
-The darkness and the shadows, they would always make me frown
-
-Rarity: She is.
-
-[Pinkie Pie]
-I'd hide under my pillow
-From what I thought I saw
-But Granny Pie said that wasn't the way
-To deal with fears at all
-
-Rainbow Dash: Then what is?
-
-[Pinkie Pie]
-She said: \"Pinkie, you gotta stand up tall
-Learn to face your fears
-You'll see that they can't hurt you
-Just laugh to make them disappear.\"
-
-Ha! Ha! Ha!
-
-Ponies: [gasp]
-
-[Pinkie Pie]
-So, giggle at the ghostly
-Guffaw at the grossly
-Crack up at the creepy
-Whoop it up with the weepy
-Chortle at the kooky
-Snortle at the spooky
-
-And tell that big dumb scary face to take a hike and leave you alone and if he thinks he can scare you then he's got another thing coming and the very idea of such a thing just makes you wanna... hahahaha... heh...
-
-Laaaaaaauuugh!",
- 'slug' => "laughter-song",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 4,
- 'title' => "Pinkie's Gala Fantasy Song",
- 'lyrics' => "[Pinkie Pie]
-Oh the Grand Galloping Gala is the best place for me
-Oh the Grand Galloping Gala is the best place for me
-Hip hip
-Hooray
-It's the best place for me
-For Pinkie...
-
-Pinkie Pie: With decorations like streamers and fairy-lights and pinwheels and piñatas and pin-cushions. With goodies like sugar cubes and sugar canes and sundaes and sun-beams and sarsaparilla. And I get to play my favorite-est of favorite fantabulous games like Pin the Tail on the Pony!
-
-[Pinkie Pie]
-Oh the Grand Galloping Gala is the best place for me
-Oh the Grand Galloping Gala is the best place for me
-'Cause it's the most galarrific superly-terrific gala ever
-In the whole galaxy
-Wheee!",
- 'slug' => "pinkies-gala-fantasy-song",
-]);
-DB::table('show_songs')->insert([
- 'id' => 5,
- 'title' => "The Ticket Song",
- 'lyrics' => "[Pinkie Pie]
-Twilight is my bestest friend
-Whoopie, whoopie!
-
-Twilight Sparkle: Pinkie...
-
-[Pinkie Pie]
-She's the cutest, smartest, all around best pony, pony!
-
-Twilight Sparkle: Pinkie.
-
-[Pinkie Pie]
-I bet if I throw a super-duper fun party, party!
-
-Twilight Sparkle: Pinkie!
-
-[Pinkie Pie]
-She'll give her extra ticket to the gala to me!
-
-Twilight Sparkle: PIIINKIIIE!!",
- 'slug' => "the-ticket-song",
-]);
-DB::table('show_songs')->insert([
- 'id' => 6,
- 'title' => "Junior Speedsters Chant",
- 'lyrics' => "[Rainbow Dash/Gilda]
-Junior Speedsters are our lives,
-Sky-bound soars and daring dives
-Junior Speedsters, it's our quest,
-To some day be the very best!",
- 'slug' => "junior-speedsters-chant",
-]);
-DB::table('show_songs')->insert([
- 'id' => 7,
- 'title' => "Hop Skip and Jump song",
- 'lyrics' => "[Pinkie Pie]
-It's not very far
-Just move your little rump
-You can make it if you try with a hop, skip and jump
-
-Twilight Sparkle: We don't have time for this.
-
-[Pinkie Pie]
-A hop, skip and jump,
-Just move your little rump,
-A hop, skip and jump,
-A hop, skip and jump,
-A hop, skip and jump,
-A hop skip and jump,
-A hop skip and jump!",
- 'slug' => "hop-skip-and-jump-song",
-]);
-DB::table('show_songs')->insert([
- 'id' => 8,
- 'title' => "Evil Enchantress song",
- 'lyrics' => "[Pinkie Pie/Flutterguy]
-She's an evil enchantress
-She does evil dances
-And if you look deep in her eyes
-She'll put you in trances
-Then what will she do?
-She'll mix up an evil brew
-Then she'll gobble you up
-In a big tasty stew
-Soooo.... Watch out!",
- 'slug' => "evil-enchantress-song",
-]);
-DB::table('show_songs')->insert([
- 'id' => 9,
- 'title' => "Winter Wrap Up",
- 'lyrics' => "[Rainbow Dash]
-Three months of winter coolness
-And awesome holidays
-
-[Pinkie Pie]
-We've kept our hoovsies warm at home
-Time off from work to play
-
-[Applejack]
-But the food we've stored is runnin' out
-And we can't grow in this cold
-
-[Rarity]
-And even though I love my boots
-This fashion's getting old
-
-[Twilight Sparkle]
-The time has come to welcome spring
-And all things warm and green
-But it's also time to say goodbye
-It's winter we must clean
-How can I help? I'm new, you see
-What does everypony do?
-How do I fit in without magic?
-I haven't got a clue!
-
-[Choir]
-Winter Wrap Up! Winter Wrap Up!
-Let's finish our holiday cheer
-Winter Wrap Up! Winter Wrap Up!
-
-[Applejack]
-'Cause tomorrow spring–
-
-[Rainbow Dash]
-–is here!
-
-[Choir]
-'Cause tomorrow spring is here!
-
-[Rainbow Dash]
-Bringing home the southern birds
-A Pegasus' job begins
-And clearing all the gloomy skies
-To let the sunshine in
-We move the clouds
-And we melt the white snow
-
-[Rainbow Dash and Pinkie Pie]
-When the sun comes up
-Its warmth and beauty will glow!
-
-[Choir]
-Winter Wrap Up! Winter Wrap Up!
-Let's finish our holiday cheer
-Winter Wrap Up! Winter Wrap Up!
-'Cause tomorrow spring is here
-Winter Wrap Up! Winter Wrap Up!
-'Cause tomorrow spring is here
-'Cause tomorrow spring is here!
-
-[Rarity]
-Little critters hibernate
-Under the snow and ice
-
-[Fluttershy]
-We wake up all their sleepy heads
-So quietly and nice
-
-[Rarity]
-We help them gather up their food
-Fix their homes below
-
-[Fluttershy]
-We welcome back the southern birds
-
-[Fluttershy and Rarity]
-So their families can grow!
-
-[Choir]
-Winter Wrap Up! Winter Wrap Up! ([Rarity] Winter, winter)
-Let's finish our holiday cheer
-Winter Wrap Up! Winter Wrap Up! ([Rarity] Winter, winter)
-'Cause tomorrow spring is here
-Winter Wrap Up! Winter Wrap Up! ([Rarity] Winter, winter)
-'Cause tomorrow spring is here
-'Cause tomorrow spring is here!
-
-[Applejack]
-No easy task to clear the ground
-Plant our tiny seeds
-With proper care and sunshine
-Everyone it feeds
-Apples, carrots, celery stalks
-Colorful flowers too
-We must work so very hard
-
-[Applejack, Cherry Berry, and Golden Harvest]
-It's just so much to do!
-
-[Choir]
-Winter Wrap Up! Winter Wrap Up!
-Let's finish our holiday cheer
-Winter Wrap Up! Winter Wrap Up!
-'Cause tomorrow spring is here
-Winter Wrap Up! Winter Wrap Up!
-
-[Pinkie Pie]
-'Cause tomorrow spring is here
-
-[Choir]
-'Cause tomorrow spring is here!
-
-[Twilight Sparkle]
-Now that I know what they all do
-I have to find my place
-And help with all of my heart
-Tough task ahead I face
-How will I do without my magic
-Help the Earth pony way
-I wanna belong so I must
-Do my best today,
-Do my best today!
-
-[Choir]
-Winter Wrap Up! Winter Wrap Up!
-Let's finish our holiday cheer
-Winter Wrap Up! Winter Wrap Up!
-'Cause tomorrow spring is here
-Winter Wrap Up! Winter Wrap Up!
-
-[Twilight Sparkle]
-'Cause tomorrow spring is here
-'Cause tomorrow spring is here
-'Cause tomorrow spring is here!",
- 'slug' => "winter-wrap-up",
-]);
-DB::table('show_songs')->insert([
- 'id' => 10,
- 'title' => "Cupcake Song",
- 'lyrics' => "[Pinkie Pie]
-All you have to do is take a cup of flour!
-Add it to the mix!
-Now just take a little something sweet, not sour!
-A bit of salt, just a pinch!
-
-Baking these treats is such a cinch!
-Add a teaspoon of vanilla!
-Add a little more, and you count to four,
-And you never get your fill of...
-
-Cupcakes! So sweet and tasty!
-Cupcakes! Don't be too hasty!
-Cupcakes! Cupcakes, cupcakes, CUPCAKES!",
- 'slug' => "cupcake-song",
-]);
-DB::table('show_songs')->insert([
- 'id' => 11,
- 'title' => "Art of the Dress",
- 'lyrics' => "[Rarity]
-Thread by thread, stitching it together
-Twilight's dress, cutting out the pattern snip by snip
-Making sure the fabric folds nicely
-It's the perfect color and so hip
-Always gotta keep in mind my pacing
-Making sure the clothes' correctly facing
-I'm stitching Twilight's dress
-
-Yard by yard, fussing on the details
-Jewel neckline, don't you know a stitch in time saves nine?
-Make her something perfect to inspire
-Even though she hates formal attire
-Gotta mind those intimate details
-Even though she's more concerned with sales
-It's Applejack's new dress
-
-Dressmaking's easy, for Pinkie Pie something pink
-Fluttershy something breezy
-Blend color and form,
-
-[To Opalescence] Do you think it looks cheesy?
-
-Something brash, perhaps quite fetching
-Hook and eye, couldn't you just simply die?
-Making sure it fits forelock and crest
-Don't forget some magic in the dress
-Even though it rides high on the flank
-Rainbow won't look like a tank
-I'm stitching Rainbow's dress
-
-Piece by piece, snip by snip
-Croup, dock, haunch, shoulders, hip
-Thread by thread, primmed and pressed
-Yard by yard, never stressed
-And that's the art of the dress!",
- 'slug' => "art-of-the-dress",
-]);
-DB::table('show_songs')->insert([
- 'id' => 12,
- 'title' => "Hush Now Lullaby",
- 'lyrics' => "[Fluttershy]
-Hush now, quiet now
-It's time to lay your sleepy head
-Hush now, quiet now
-It's time to go to bed
-Hush Now Lullaby (Sweetie Belle)
-
-[Sweetie Belle]
-Hush now! Quiet now!
-It's time to lay your sleepy head!
-Said hush now! Quiet now!
-It's time to go to bed!
-
-Fluttershy: Okay Sweetie, that was...
-
-[Sweetie Belle]
-Driftin' (driftin') off to sleep!
-The exciting day behind you!
-Driftin' (driftin') off to sleep!
-Let the joy of dream land find you!
-
-Fluttershy: Thank you Sweetie, um...
-
-[Sweetie Belle]
-Hush now! Quiet now!
-Lay your sleepy head!
-Said hush now! Quiet now!
-It's time to go to BED!
-
-OW!",
- 'slug' => "hush-now-lullaby",
-]);
-DB::table('show_songs')->insert([
- 'id' => 13,
- 'title' => "Cutie Mark Crusaders Song",
- 'lyrics' => "[Scootaloo]
-Look, here, are three little ponies
-Ready to sing for this crowd
-Listen up, 'cause here's our story
-I'm gonna sing it
-
-[Sweetie Belle, Apple Bloom, and Scootaloo]
-Very loud!
-
-[Scootaloo]
-When you're a younger pony
-And your flank is very bare
-Feels like the sun will never come
-When your cutie mark's not there
-
-So the three of us will fight the fight
-There is nothing that we fear
-We'll have to figure out what we'll do next
-
-[Sweetie Belle, Apple Bloom, and Scootaloo]
-Till our cutie marks are here!
-
-We are the Cutie Mark Crusaders
-On a quest to find out who we are
-And we will never stop the journey
-Not until we have our cutie marks
-
-[Scootaloo]
-They all say that you'll get your mark
-When the time is really right
-And you know just what you're supposed to do
-And your talent comes to light
-
-But it's not as easy as it sounds
-And that waiting's hard to do
-So we test our talents everywhere
-
-[Sweetie Belle, Apple Bloom, and Scootaloo]
-Until our face is blue
-
-We are the Cutie Mark Crusaders
-On a quest to find out who we are
-And we will never stop the journey
-Not until we have our cutie marks
-
-We are the Cutie Mark Crusaders
-On a quest to find out who we are
-And we will never stop the journey
-Not until we have our cutie marks!",
- 'slug' => "cutie-mark-crusaders-song",
-]);
-DB::table('show_songs')->insert([
- 'id' => 14,
- 'title' => "You Got to Share, You Got to Care",
- 'lyrics' => "[Pinkie Pie]
-We may be divided
-But of you all, I beg
-To remember we're all hoofed
-At the end of each leg
-
-No matter what the issue
-Come from wherever you please
-All this fighting gets you nothing
-But hoof and mouth disease
-
-Arguing's not the way
-Hey, come out and play!
-It's a shiny, new day
-So, what do you say?
-
-You gotta share
-You gotta care
-It's the right thing to do
-You gotta share
-You gotta care
-And there'll always be a way through
-
-Both our diets, I should mention
-Are completely vegetarian
-We all eat hay and oats
-Why be at each other's throat?
-
-You gotta share
-You gotta care
-It's the right thing to do
-And there'll always be a way
-Thro-o-o-o-ugh!",
- 'slug' => "you-got-to-share-you-got-to-care",
-]);
-DB::table('show_songs')->insert([
- 'id' => 15,
- 'title' => "So Many Wonders",
- 'lyrics' => "[Fluttershy]
-What is this place
-filled with so many wonders?
-Casting its spell
-That I am now under
-
-Squirrels in the trees
-and the cute little bunnies
-Birds flying free
-and bees with their honey
-
-Hooneeeeey!
-
-Oooh, what a magical place
-and I owe it all to the Pegasus race
-If I knew the ground had so much up its sleeve
-I'd have come here sooner, and never leave
-
-Yes, I love everythiiiiiiiiiiiing!",
- 'slug' => "so-many-wonders",
-]);
-DB::table('show_songs')->insert([
- 'id' => 16,
- 'title' => "Pinkie Pie's Singing Telegram",
- 'lyrics' => "[Pinkie Pie]
-This is your singing telegram
-I hope it finds you well
-You're invited to a party
-'Cause we think you're really swell
-
-Gummy's turning one year old
-So help us celebrate
-The cake will be delicious
-The festivities first-rate
-
-There will be games and dancing
-Bob for apples, cut a rug
-And when the party's over
-We'll gather 'round for a group hug
-
-No need to bring a gift
-Being there will be enough
-Birthdays mean having fun with friends
-Not getting lots of stuff
-
-It won't be the same without you
-So we hope that you say yes
-So, please, oh please R.S.V.P
-And come, and be our guest!",
- 'slug' => "pinkie-pies-singing-telegram",
-]);
-DB::table('show_songs')->insert([
- 'id' => 17,
- 'title' => "At the Gala",
- 'lyrics' => "Twilight Sparkle: I can't believe we're finally here. With all that we've imagined, the reality of this night is sure to make this... The Best Night Ever!
-
-At the Gala
-
-[Choir]
-At the Gala
-
-[Fluttershy]
-At the Gala, in the garden
-I'm going to see them all!
-All the creatures, I'll befriend them at the Gala! (at the Gala!)
-All the birdies, and the critters
-They will love me big and small!
-We'll become good friends forever
-Right here at the Gala!
-
-[Choir]
-All our dreams will come true right here at the Gala, at the Gala!
-
-[Applejack]
-At the Gala (it's amazing!), I will sell them (better hurry!)
-All my appletastic treats! (yummy, yummy!)
-Hungry ponies (they'll be snacking!), they will buy them (bring your money!)
-Caramel apples, apple sweets! (gimme some!)
-And I'll earn a lot of money for the Apple family!
-
-[Choir]
-All our dreams and our hopes from now until hereafter
-All that we've been wishing for will happen at the Gala, at the Gala!
-
-[Rarity]
-At the Gala, all the royals
-They will meet fair Rarity
-They will see I'm just as regal at the Gala! (at the Gala)
-I will find him, my Prince Charming,
-And how gallant he will be,
-He will treat me like a lady, tonight at the Gala!
-
-[Choir]
-This is what we've waited for, to have the best night ever!
-Each of us will live our dreams, tonight at the Gala, at the Gala!
-[Rainbow Dash]
-Been dreaming, I've been waiting
-To fly with those brave ponies
-The Wonderbolts, their daring tricks
-Spinning 'round and having kicks
-Perform for crowds of thousands
-They'll shower us with diamonds
-The Wonderbolts will see me right here at the Gala!
-
-[Choir]
-All we've longed for, all we've dreamed, our happy ever after!
-Finally will all come true, right here at the Grand Gala, at the Gala!
-
-[Pinkie Pie]
-I am here at the Grand Gala, for it is the best party
-But the one thing it was missing was a pony named Pinkie
-For I am the best at parties, all the ponies will agree
-Ponies playing, ponies dancing, with me at the Grand Gala!
-
-[Choir]
-Happiness and laughter at the Gala, at the Gala!
-
-[Twilight Sparkle]
-At the Gala (at the Gala), with the Princess (with the Princess)
-Is where I'm going to be (she will be)
-We will talk all about magic and what I've learned and seen (she will see)
-It is going to be so special as she takes time just for me!
-
-[Choir]
-This will be the best night ever!
-Into the Gala we must go, we're ready now, we're all aglow
-Into the Gala, let's go in and have the best night ever
-Into the Gala, now's the time, we're ready and we look divine
-
-[Choir + Fluttershy]
-Into the Gala
-
-[Fluttershy]
-Meet new friends
-
-[Choir + Applejack]
-Into the Gala
-
-[Applejack]
-Sell some apples
-
-[Choir + Rarity]
-Into the Gala
-
-[Rarity]
-Find my prince
-
-[Choir + Rainbow Dash]
-Prove I'm great
-
-[Rainbow Dash]
-As a Wonderbolt is
-
-Fluttershy: To meet!
-Applejack: To sell!
-Rarity: To find!
-Rainbow Dash: To prove!
-Pinkie Pie: To whoo!
-Twilight Sparkle: To talk!
-
-[All]
-Into the Gala, into the Gala!
-And we'll have the best night ever!
-At the Gala!",
- 'slug' => "at-the-gala",
-]);
-DB::table('show_songs')->insert([
- 'id' => 18,
- 'title' => "I'm at the Grand Galloping Gala",
- 'lyrics' => "[Pinkie Pie]
-I'm at the Grand Galloping Gala,
-I'm at the Grand Galloping Gala,
-I'm at the Grand Galloping Gala,
-It's all I ever dreamed.
-
-It's all I ever dreamed, woo hoo!
-It's all I ever dreamed, yippee!
-I'm at the Grand Galloping GalaaaaaaaaaaAAAAAAAAAAAA!
-[pause]
-
-It's all I ever... dreamed?",
- 'slug' => "im-at-the-grand-galloping-gala",
-]);
-DB::table('show_songs')->insert([
- 'id' => 19,
- 'title' => "Pony Pokey",
- 'lyrics' => "[Pinkie]
-You reach your right hoof in
-You reach your right hoof out
-You reach your right hoof in
-And you shake it all about
-You do the Pony Pokey meeting lots of folks with clout
-That's what I'm talking about
-
-You step your left hoof in
-You pull it right back out
-You step your left hoof in
-But you better help him out
-You do the Pony Pokey but should find a different route
-That's what it's all about
-
-You kick your back left in
-You pull your back left out
-You reach your back left in
-Just be brave and have no doubt
-You do the Pony Pokey feeling like you're gonna pout
-That's what I'm singing about
-
-You tilt your head in
-You tilt your head out
-You tilt your head in
-Then you shake it all about
-You do the Pony Pokey even though your date's a lout
-You're better off without
-
-You stomp your whole self in
-You stomp your whole self out
-You stomp your whole self in
-And you stomp yourself about
-You do the Pony Pokey and you give a little shout-
-
-Fluttershy: COME OUT!
-
-[Pinkie Pie]
-That's what I'm talking about
-You do the Pony Pokey
-You do the Pony Pokey
-You do the Pony Pokey
-And that's what it's all about
-
-Yeah!",
- 'slug' => "pony-pokey",
-]);
-DB::table('show_songs')->insert([
- 'id' => 20,
- 'title' => "Find A Pet Song",
- 'lyrics' => "[Fluttershy]
-Now, Rainbow, my dear, I cannot express my delight
-It's abundantly clear
-That somewhere out here
-Is the pet that will suit you just right
-
-[Rainbow Dash]
-I can't wait to get started, but first let me set a few rules
-It's of utmost importance
-The pet that I get
-Is something that's awesome and cool
-
-Fluttershy: Awesome, cool, got it!
-I have so many wonderful choices, just wait, you will see
-
-[Rainbow Dash]
-I need something real fast like a bullet to keep up with me
-
-[Fluttershy]
-Sure! How 'bout a bunny?
-They're cutesy and wootsie and quick as can be
-
-[Rainbow Dash]
-Cutesy, wootsie? Have you even met me?
-
-[Fluttershy]
-Rainbow, have faith
-You see, I will bet you
-Somewhere in here is the pet that will get you
-
-Fluttershy: Come on, the sky's the limit!
-Rainbow Dash: Sky is good. I'd like it to fly.
-Fluttershy: Really? Because I think this widdle puddy tat has your name written all over it. Yes, he does. Aww, look, he likes you!
-Rainbow Dash: Pass.
-
-[Fluttershy]
-I have so many wonderful choices for you to decide
-There are otters and seals
-With massive appeal
-
-Rainbow Dash: Otters and seals do not fly.
-Fluttershy: Maybe not, but I've seen this particular seal catch ten feet of air when he breaches the water!
-Rainbow Dash: That's it. I'm outta here.
-
-[Fluttershy]
-Wait! There must be a pet here
-That will fit the ticket
-How 'bout a ladybug, or a cute cricket?
-
-Rainbow Dash: Bigger. And cooler.
-Fluttershy: Bigger, cooler. Right.
-
-[Fluttershy]
-I've got just the thing in that tree, Dash
-Meet your new fabulous pet, Squirrely
-
-Rainbow Dash: It's just a squirrel.
-Fluttershy: Not just any squirrel. A flying squirrel!
-Rainbow Dash: ...Yeah. So, like I was saying...
-
-[Rainbow Dash]
-Fluttershy, pal, this won't cut it
-I need a pet to keep up with me
-Something awesome, something flying
-With coolness that defies gravity!
-
-Fluttershy: I'm sensing you want an animal that can fly.
-Rainbow Dash: Ya think?
-
-[Fluttershy]
-I have plenty of wonderful creatures who soar in the sky
-Like a sweet hummingbird or a giant monarch butterfly
-
-Rainbow Dash: Better, but cooler.
-
-[Fluttershy]
-I see. How 'bout an owl, or a wasp, or a toucan?
-There's so many wonderful creatures the likes of that
-There are falcons and eagles
-They are both quite regal
-Or perhaps what you need is a dark and mysterious bat?
-
-Rainbow Dash: Now you're talking. But instead of just one standout, now that's too many.
-
-[Rainbow Dash]
-So many choices, and such riches aplenty
-
-Fluttershy: Not a bad problem to have, if you ask me.
-
-[Rainbow Dash]
-The bat would be awesome, but the wasp I'm digging too
-Do you have something in a yellow striped bat?
-
-Fluttershy: No.
-
-[Fluttershy]
-I've got a hot pink flamingo, just dying to meet you
-
-[Rainbow Dash]
-What to do, what to do? [gasp]
-A prize! That's it! There's really just one way
-To find out which animal's best
-Hold a contest of speed, agility, and guts
-That will put each pet to the test
-
-[Fluttershy]
-Don't forget style, that should be considered
-
-[Rainbow Dash]
-Then we'll know for sure who's best of the litter
-
-[Fluttershy]
-The one who is awesome as cool
-
-[Rainbow Dash]
-Just like me
-Can't settle for less, 'cause I'm the best
-
-[Fluttershy and Rainbow Dash]
-So a contest we will see
-
-[Rainbow Dash]
-Who's the number one, greatest, perfectest pet
-
-[Fluttershy and Rainbow Dash]
-In the world for me
-
-[Fluttershy]
-May the games
-
-[Fluttershy and Rainbow Dash]
-Begin
-
-Rainbow Dash: And may the best pet win!",
- 'slug' => "find-a-pet-song",
-]);
-DB::table('show_songs')->insert([
- 'id' => 21,
- 'title' => "Becoming Popular (The Pony Everypony Should Know)",
- 'lyrics' => "[Rarity]
-I'll be the toast of the town, the girl on the go
-I'm the type of pony everypony, everypony should know
-
-I'll be the one to watch, the girl in the flow
-I'm the type of pony everypony, everypony should know
-Becoming as popular as popular can be
-Making my mark, making my mark in high society
-I'm the belle of the ball, the star of the show, yeah
-I'm the type of pony everypony, everypony should know
-
-See how they hang on every word that I speak
-My approving glance is what they all seek
-I'm the crème de la crème, not just another Jane Doe
-I'm the type of pony everypony should know
-
-At home, at the opera, on a fancy yacht
-Becoming the talk, the talk of all of Canterlot
-I'm the crème de la crème, not just another Jane Doe, yeah
-I'm the type of pony everypony, everypony should know
-
-Because I'm the type of pony
-Yes, I'm the type of pony
-Yes, I'm the type of pony everypony should know",
- 'slug' => "becoming-popular-the-pony-everypony-should-know",
-]);
-DB::table('show_songs')->insert([
- 'id' => 22,
- 'title' => "The Heart Carol",
- 'lyrics' => "[Choir]
-The fire of friendship lives in our hearts
-As long as it burns we cannot drift apart
-Though quarrels arise, their numbers are few
-Laughter and singing will see us through (will see us through)
-We are a circle of pony friends
-A circle of friends we'll be to the very end",
- 'slug' => "the-heart-carol",
-]);
-DB::table('show_songs')->insert([
- 'id' => 23,
- 'title' => "Happy Monthiversary",
- 'lyrics' => "[Pinkie Pie]
-Happy monthiversary to you and you today
-[very quickly] I can't believe you're already a month old time sure flies doesn't it well it seems like only yesterday you were born.
-But now you're a month old today, hey!",
- 'slug' => "happy-monthiversary",
-]);
-DB::table('show_songs')->insert([
- 'id' => 24,
- 'title' => "Piggy Dance",
- 'lyrics' => "[Pinkie Pie]
-First you jiggle your tail! Oink oink oink!
-Then you wriggle your snout! Oink oink oink!
-Then you wiggle your rump! Oink oink oink!
-Then shout it out! Oink oink oink!
-[repeat verse two more times]",
- 'slug' => "piggy-dance",
-]);
-DB::table('show_songs')->insert([
- 'id' => 25,
- 'title' => "The Flim Flam Brothers",
- 'lyrics' => "[Flim]
-Well, lookie what we got here, brother of mine, it's the same in every town
-Ponies with thirsty throats, dry tongues, and not a drop of cider to be found
-Maybe they're not aware that there's really no need for this teary despair
-
-[Flam]
-That the key that they need to solve this sad cider shortage you and I will share
-
-Ponies: [excited chattering]
-
-[Flim and Flam]
-Well you've got opportunity
-In this very community
-
-[Flam]
-He's Flim
-
-[Flim]
-He's Flam
-
-[Flim and Flam]
-We're the world famous Flim Flam brothers
-Traveling salesponies nonpareil
-
-Pinkie Pie: Non-pa what?
-
-[Flim]
-Nonpareil, and that's exactly the reason why, you see
-No pony else in this whole place will give you such a chance to be where you need to be
-And that's a new world, with tons of cider
-Fresh squeezed and ready for drinking
-
-[Flam]
-More cider than you can drink in all your days of thinking.
-
-Rainbow Dash: I doubt that.
-
-[Flim and Flam]
-So take this opportunity
-
-[Flim, Flam, and Crowd]
-In this very community
-
-[Flam]
-He's Flim
-
-[Flim]
-He's Flam
-
-[Flim and Flam]
-
-We're the world famous Flim Flam brothers
-Traveling salesponies nonpareil
-
-[Flim]
-I suppose by now you're wondering 'bout our peculiar mode of transport
-
-[Flam]
-I say, our mode of locomotion
-
-[Flim]
-And I suppose by now you're wondering, where is this promised cider?
-
-[Flam]
-Any horse can make a claim and any pony can do the same
-
-[Flim]
-But my brother and I have something most unique and superb
-Unseen at any time in this big new world
-
-[Flim and Flam]
-And that's opportunity
-
-[Flim]
-Folks, it's the one and only, the biggest and the best
-
-[Flam]
-The unbelievable
-
-[Flim]
-Unimpeachable
-
-[Flam]
-Indispensable
-
-[Flim]
-I can't believe-able
-
-[Flim and Flam]
-Flim Flam brothers' Super Speedy Cider Squeezy 6000
-
-Flam: What d'you say, sister?
-
-[Crowd]
-Oh, we got opportunity
-In this very community
-Please Flim, please Flam, help us out of this jam
-With your Flim Flam brothers' Super Speedy Cider Squeezy 6000
-
-Flim: Young filly, I would be ever so honored if you might see fit to let my brother and I borrow some of your delicious, and might I add spell-bindingly fragrant apples for our little demonstration here?
-
-Applejack: Uh, sure, I guess.
-
-[Crowd]
-Opportunity, in our community
-
-[Flam]
-Ready Flim?
-
-[Flim]
-Ready Flam?
-
-[Flim and Flam]
-Let's bing-bang zam!
-
-Flim: And show these thirsty ponies a world of delectable cider!
-
-[Crowd]
-Cider, cider, cider, cider... [continues until Granny Smith interrupts]
-
-Flim: Watch closely my friends!
-Flam: The fun begins!
-Flim: Now, here's where the magic happens, right here in this heaving roiling cider press boiling guts of the very machine, those apples plucked fresh are right now as we speak being turned into grade-A top-notch five-star blow-your-horseshoes-off one-of-a-kind cider!
-Flam: Feel free to take a sneak peek!
-
-[Granny Smith]
-Now wait, you fellers, hold it!
-You went and over-sold it!
-I guarantee that what you have there won't compare
-For the very most important ingredient
-Can't be added or done expedient
-And it's quality, friends, Apple Acre's quality and care!
-
-[Flim]
-Well Granny, I'm glad you brought that up, my dear, I say I'm glad you brought that up
-You see that we are very picky when it comes to cider if you'll kindly try a cup
-
-[Flam]
-Yes, sir, yes ma'am this great machine lets just the very best
-So whaddaya say then, Apples
-Care to step into the modern world
-And put the Super Speedy Cider Squeezy 6000 to the test?
-
-[Crowd]
-Cider, cider, cider, cider... [continues until Flim and Flam begin singing]
-
-Flim: What do you think, folks? Do you see what the Apples can't? I see it clear as day! I know she does! So does he! C'mon Ponyville, you know what I'm talking about!
-
-[Flim and Flam]
-We're saying you've got
-
-[Flim, Flam, and Crowd]
-Opportunity
-In this very community
-He's Flim, he's Flam
-We're the world famous Flim Flam brothers
-Traveling salesponies nonpareil
-
-[Flim and Flam]
-Yeah!",
- 'slug' => "the-flim-flam-brothers",
-]);
-DB::table('show_songs')->insert([
- 'id' => 26,
- 'title' => "The Perfect Stallion",
- 'lyrics' => "[Sweetie Belle]
-Cheerilee is sweet and kind.
-She's the best teacher we could hope for.
-The perfect stallion you and I must find.
-One to really make her heart soar.
-
-But...
-This one's too young.
-This one's too old.
-He clearly has a terrible cold.
-
-Hay Fever: Achoo!
-
-[Apple Bloom]
-This guy's too silly.
-He's way too uptight.
-
-Persnickety: I say!
-
-[Sweetie Belle]
-Well nothing's wrong with this one.
-He seems alright.
-
-Scootaloo: His girlfriend sure thinks so.
-
-[Sweetie Belle]
-How 'bout this one?
-
-[Apple Bloom]
-He's much too flashy.
-
-[Scootaloo]
-He might do,
-
-[Apple Bloom and Sweetie Belle]
-If he weren't so splashy.
-
-[Apple Bloom]
-Too short.
-
-[Sweetie Belle]
-Too tall.
-
-[Apple Bloom]
-Too clean.
-
-[Scootaloo]
-Too smelly.
-
-[Sweetie Belle]
-Too strangely obsessed with tubs of jelly.
-
-Apple Bloom, Scootaloo, and Sweetie Belle: [sigh]
-
-[Apple Bloom]
-I don't think that we're mistaken.
-It seems all the good ones are taken.
-
-[Sweetie Belle]
-I really feel that at this rate,
-We'll never find the perfect date.
-
-[Apple Bloom, Scootaloo, and Sweetie Belle]
-Don't wanna quit and give up hope.
-
-Scootaloo: Doing anything special for Hearts and Hooves Day?
-
-[Sweetie Belle]
-Oh please, oh please oh please say-
-
-Big McIntosh: Nope.
-Apple Bloom, Scootaloo, and Sweetie Belle: [gasp]
-
-[Sweetie Belle]
-We did it girls. We've found the one.
-Who will send our teacher's heart aflutter.
-
-Apple Bloom: Wait a minute. Let me get this straight. Are you talking about my brother?",
- 'slug' => "the-perfect-stallion",
-]);
-DB::table('show_songs')->insert([
- 'id' => 27,
- 'title' => "Smile Song",
- 'lyrics' => "[Pinkie Pie]
-My name is Pinkie Pie (Hello!)
-And I am here to say (How ya doin'?)
-I'm gonna make you smile, and I will brighten up your day-aaay!
-It doesn't matter now (What's up?)
-If you are sad or blue (Howdy!)
-'Cause cheering up my friends is just what Pinkie's here to do
-
-'Cause I love to make you smile, smile, smile
-Yes I do
-It fills my heart with sunshine all the while
-Yes it does
-'Cause all I really need's a smile, smile, smile
-From these happy friends of mine
-
-I like to see you grin (Awesome!)
-I would love to see you beam (Rock on!)
-The corners of your mouth turned up
-Is always Pinkie's dream (Hoof-bump!)
-But if you're kind of worried
-And your face has made a frown
-I'll work real hard and do my best
-To turn that sad frown upside down
-
-'Cause I love to make you grin, grin, grin
-Yes I do
-Bust it out from ear to ear, let it begin
-Just give me a joyful grin, grin, grin
-And you fill me with good cheer
-
-It's true, some days are dark and lonely
-And maybe you feel sad
-But Pinkie will be there to show you that it isn't that bad
-There's one thing that makes me happy
-And makes my whole life worthwhile
-And that's when I talk to my friends and get them to smile
-
-I really am so happy
-Your smile fills me with glee
-I give a smile, I get a smile
-And that's so special to me
-
-'Cause I love to see you beam, beam, beam
-Yes I do
-Tell me, what more can I say to make you see
-That I do
-It makes me happy when you beam, beam, beam
-Yes, it always makes my day!
-
-Come on everypony smile, smile, smile
-Fill my heart up with sunshine, sunshine
-All I really need's a smile, smile, smile
-From these happy friends of mine!
-
-[Choir and Pinkie Pie]
-Come on everypony smile, smile, smile
-Fill my heart up with sunshine, sunshine
-All I really need's a smile, smile, smile
-From these happy friends of mine!
-
-[Pinkie Pie]
-Yes a perfect gift for me ([Choir] Come on everypony smile, smile, smile)
-Is a smile as wide as a mile (Fill my heart up with sunshine, sunshine)
-To make me happy as can be (All I really need's a smile, smile, smile; from these happy friends of...)
-
-[Choir and Pinkie Pie]
-Smile, smile, smile, smile, smile!
-
-[Pinkie Pie]
-Come on and smile
-Come on and smile!",
- 'slug' => "smile-song",
-]);
-DB::table('show_songs')->insert([
- 'id' => 28,
- 'title' => "Cranky Doodle Donkey",
- 'lyrics' => "[Pinkie Pie]
-You're a Cranky Doodle Donkey guy.
-A Cranky Doodle Donkey.
-I never met you but you're my new friend and I'm your best friend Pinkie Pie!",
- 'slug' => "cranky-doodle-donkey",
-]);
-DB::table('show_songs')->insert([
- 'id' => 29,
- 'title' => "Welcome Song",
- 'lyrics' => "[Pinkie Pie]
-Welcome welcome welcome
-A fine welcome to you
-Welcome welcome welcome
-I say how do you do?
-Welcome welcome welcome
-I say hip hip hurray
-Welcome welcome welcome
-To Ponyville today
-
-Pinkie Pie: Wait for it!",
- 'slug' => "welcome-song",
-]);
-DB::table('show_songs')->insert([
- 'id' => 30,
- 'title' => "Cranky Doodle Joy",
- 'lyrics' => "[Pinkie Pie]
-He had a Cranky Doodle sweetheart
-She's his cranky doodle joy
-I helped the Cranky Doodle boy, yeah!
-I helped the Cranky Doodle boy!
-
-Cranky Doodle Donkey and Matilda: Pinkie!
-Pinkie Pie: Whoops, privacy. Sorry.",
- 'slug' => "cranky-doodle-joy",
-]);
-DB::table('show_songs')->insert([
- 'id' => 31,
- 'title' => "Big Brother Best Friend Forever (B.B.B.F.F.)",
- 'lyrics' => "[Twilight Sparkle]
-When I was just a filly, I found it rather silly
-To see how many other ponies I could meet
-I had my books to read, didn't know that I would ever need
-Other ponies to make my life complete
-
-But there was one colt that I cared for
-I knew he would be there for me
-
-My big brother, best friend forever!
-Like two peas in a pod, we did everything together
-He taught me how to fly a kite (Best friend forever!)
-We never had a single fight (We did everything together!)
-We shared our hopes, we shared our dreams
-I miss him more than I realized
-It seems...
-
-[Rest of main six]
-Your big brother, best friend forever
-Like two peas in a pod, you did everything together
-
-[Twilight Sparkle]
-And though he's, oh, so far away
-I hoped that he would stay
-My big brother best friend
-Forever...
-Forever...",
- 'slug' => "big-brother-best-friend-forever-bbbff",
-]);
-DB::table('show_songs')->insert([
- 'id' => 32,
- 'title' => "This Day Aria",
- 'lyrics' => "[Queen Chrysalis]
-This day is going to be perfect
-The kind of day of which I've dreamed since I was small
-Everypony will gather 'round
-Say I look lovely in my gown
-What they don't know is that I have fooled them all!
-
-[Princess Cadance]
-This day was going to be perfect
-The kind of day of which I've dreamed since I was small
-But instead of having cake
-With all my friends to celebrate
-My wedding bells, they may not ring for me at all
-
-[Queen Chrysalis]
-I could care less about the dress
-I won't partake in any cake
-Vows, well I'll be lying when I say
-That through any kind of weather
-I'll want us to be together
-The truth is I don't care for him at all
-No I do not love the groom
-In my heart there is no room
-But I still want him to be all mine
-
-[Princess Cadance]
-Must escape before it's too late
-Find a way to save the day
-Hope, I'll be lying if I say
-\"I don't fear that I may lose him
-To one who wants to use him
-Not care for, love and cherish him each day\"
-For I oh-so love the groom
-All my thoughts he does consume
-Oh Shining Armor, I'll be there very soon
-
-[Queen Chrysalis]
-Finally the moment has arrived
-For me to be one lucky bride
-
-[Princess Cadance]
-Oh, the wedding we won't make
-He'll end up marrying a fake
-Shining Armor will be
-
-[Queen Chrysalis]: ...mine, all mine. [evil laugh]",
- 'slug' => "this-day-aria",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 33,
- 'title' => "Love Is In Bloom",
- 'lyrics' => "[Twilight Sparkle]
-Love is in bloom
-A beautiful bride, a handsome groom,
-Two hearts becoming one
-A bond that cannot be undone because
-
-Love is in bloom
-A beautiful bride, a handsome groom
-I said love is in bloom
-You're starting a life and making room
-For us (For us, For us...)
-
-Your special day
-We celebrate now, the pony way
-Your friends are all right here
-Won't let these moments disappear because
-
-Love is in bloom
-A beautiful bride, a handsome groom
-I said love is in bloom
-You're starting a life and making room
-For us, (For us... For us...Aah...)",
- 'slug' => "love-is-in-bloom",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 34,
- 'title' => "The Failure Song",
- 'lyrics' => "[Twilight Sparkle]
-I was prepared to do my best
-Thought I could handle any test
-For I can do so many tricks
-But I wasn't prepared for this
-
- Levitation would have been a breeze
-Facts and figures I recite with ease
-
-Twilight Sparkle: The square root of five hundred and forty-six is twenty-three point three six six six four two eight nine one zero nine.
- Teacher: She is correct!
-
- [Twilight Sparkle]
-I could ace a quiz on friendship's bliss
-But I wasn't prepared for this
- Will I fail, or will I pass?
- I can't be sure...
-
-[Spike]
-She can't be sure...
-
-[Twilight Sparkle]
-My mind is sharp, my skills intact
-My heart is pure...
-
-[Spike]
-Her heart is pure...
-
-[Twilight Sparkle]
-Oh, I've taken my share of licks
-I've made it through the thin and thick
-But no I wasn't
-
-[Spike]
-Oh no, she wasn't
-
-[Twilight Sparkle]
-Oh no, I wasn't
-
-[Spike]
-Oh no, she wasn't
-
-[Twilight Sparkle]
-No I wasn't
-
-[Twilight Sparkle and Spike]
-Prepared... for this!",
- 'slug' => "the-failure-song",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 35,
- 'title' => "The Ballad of the Crystal Empire",
- 'lyrics' => "[Twilight Sparkle]
-Princess Cadence needs our help
-Her magic will not last forever
-I think we can do it
-But we need to work together
-We have to get this right
-Yes we have to make them see
-We can save the Crystal Ponies with their history
-
-[Rainbow Dash]
-It says that they liked jousting
-
-[Rarity]
-They flew a flag of many hues
-
-[Applejack]
-Made sweets of crystal berries
-
-[Fluttershy]
-They had a petting zoo with tiny ewes
-
-[Twilight Sparkle, Rainbow Dash, Pinkie Pie, Applejack, Rarity, Fluttershy and Spike]
-Oh, we have to get this right
-Yes we have to make them see
-We can save the Crystal Ponies with their history
-
-[Pinkie Pie]
-There was a crystal flugelhorn
-That everypony liked to play
-
-[Twilight Sparkle]
-And the Crystal Kingdom anthem
-Can you learn it in a day?
-
-[Twilight Sparkle, Rainbow Dash, Pinkie Pie, Applejack, Rarity, Fluttershy and Spike]
-Oh, we have to get this right
-Yes we have to make them see
-We can save the Crystal Ponies... with their history!",
- 'slug' => "the-ballad-of-the-crystal-empire",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 36,
- 'title' => "The Success Song",
- 'lyrics' => "[Rarity]
-You were prepared to do your best
-Had what it takes to pass the test
-All those doubts you can dismiss
-Turns out you were
-
-[Applejack, Rainbow Dash, Rarity, Pinkie Pie, Fluttershy, and Spike]
-Prepared for this!
-
-[Applejack]
-You clearly have just what it takes
-
-[Pinkie Pie]
-To pass a test with such high stakes
-
-[Fluttershy]
-We knew for sure you would prevail
-
-[Rainbow Dash]
-Since when does Twilight Sparkle ever fail?
-
-[Applejack, Rainbow Dash, Rarity, Pinkie Pie, Fluttershy, and Spike]
-All those doubts that you can dismiss
-Trust yourself and you cannot miss
-
-[Applejack, Rarity, and Pinkie Pie]
-Turns out you were
-
-[Twilight Sparkle]
-Turns out I was
-
-[Rainbow Dash, Fluttershy,and Spike]
-Turns out you were
-
-[Twilight Sparkle]
-Turns out I was
-
-[Rarity]
-Turns out you were
-
-[Spike, Applejack, Rainbow Dash, Rarity, Pinkie Pie, Fluttershy, and Twilight Sparkle]
-Prepared... for this!",
- 'slug' => "the-success-song",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 37,
- 'title' => "Babs Seed",
- 'lyrics' => "[Cutie Mark Crusaders]
-Yeah, yeah, yeah
-Yeah, yeah, yeah
-Yeah, yeah, yeah, yeah, yeah
-
-[Apple Bloom]
-First, we thought that Babs was so really, really sweet
-A new friend to have and it seemed like such a treat
-
-[Scootaloo]
-But then, we found the truth; she's just a bully from the east
-She went from Babs, yeah, to a bully and a beast
-
-[Apple Bloom]
-Everywhere we turn, she's just a step ahead
-
-[Cutie Mark Crusaders]
-Babs Seed, Babs Seed, what we gonna do?
-Got a bully on our tail
-Gotta hide, we gotta bail
-Babs Seed, Babs Seed, if she's after you
-Gotta run, we gotta flee
-Gotta hurry, don't you see?
-Babs Seed, Babs Seed, she's just a bad, bad seed
-
-Yeah, yeah, yeah
-Yeah, yeah, yeah
-Yeah, yeah, yeah, yeah, yeah
-
-[Apple Bloom]
-Hiding from a bully, we know it isn't right
-But the Cutie Mark Crusaders, we aren't lookin' for a fight
-
-[Scootaloo]
-Oh, she'll go home soon, and then we'll have some peace again
-But for now, we're staying out of her way 'til then
-
-[Apple Bloom]
-Everywhere we turn, she's just a step ahead
-
-[Cutie Mark Crusaders]
-Babs Seed, Babs Seed, what we gonna do?
-Got a bully on our tail
-Gotta hide, we gotta bail
-Babs Seed, Babs Seed, if she's after you
-Gotta run, we gotta flee
-Gotta hurry, don't you see?
-
- Why so mean? Why so crude?
-
- Why so angry? Why so rude?
- Can't you be nice? Can't we be friends?
- Isn't it sad? Is this how it all ends?
-Babs Seed, Babs Seed, she's just a bad, bad-
- Babs Seed, Babs Seed, she's just a bad, bad-
-Babs Seed, Babs Seed-
-
-[Scootaloo]
-She's just a bad, bad seed",
- 'slug' => "babs-seed",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 38,
- 'title' => "Raise This Barn",
- 'lyrics' => "[Applejack]
-Yee-hoo!
-
- Raise this barn, raise this barn
-One, two, three, four
-Together, we can raise this barn
-One, two, three, four
-
-Up, up, up, go the beams
-Hammer those joints, work in teams
-Turn 'em round quick by the right elbow
-Grab a new partner, here we go
-
-Apple family: Yeah!
-Applejack: Come on, Apple family! Let's get to it! Wee-hoo!
-
- [Applejack]
-Raise this barn, raise this barn
-One, two, three, four
-Together, we can raise this barn
-One, two, three, four
-
-Finish the frame, recycling wood
-Working hard, you're doing good
-Turn 'em round quick by the right elbow
-Grab your partner, here we go
-
-Apple family: Yeah!
- Applejack: Whoo-whee!
-
- [Applejack]
-Raise this barn, raise this barn
-One, two, three, four
-Together, we can raise this barn
-One, two, three, four
-
-Slats of wood come off the ground
-Hold 'em up and nail 'em down
-Turn 'em round quick by the left elbow
-Grab a new partner, here we go
-
-Apple family: Yeah!
-Applejack: Come on, Apples! Get 'er done!
-
- [Apple Bloom]
-Look at us, we're family
-
-[Applejack]
-Working together thankfully
-
-[Apple Bloom]
-We Apples, we are proud to say
-
-[Applejack and Apple Bloom]
-Stick together the pony way
-
-[Applejack]
-Bow to your partner, circle right
-Get down if you're scared of heights
-Forward back and twirl around
-The barn's gonna be the best in town
-
-Apple family: Yeah!
-Applejack: Yee-haw! Attagirl!
-Apple Bloom: Alright, let's get to it!
-
- [Apple family]
-Raise this barn, raise this barn
-One, two, three, four
-Together, we can raise this barn
-One, two, three, four
-
-[Applejack]
-Take your brushes, young and old
-Together, paint it, bright and bold
-Turn 'em round quick by the left elbow
-Grab a new partner, here we go
-
-[Apple family]
-We raised this barn, we raised this barn
-Yes, we did
-Together we sure raised this barn
-Yes, we did
-
-Being together counts the most
-We all came here from coast to coast
-All we need to strive to be
-Is part of the Apple family
-
-Apple Bloom: Yeah!",
- 'slug' => "raise-this-barn",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 39,
- 'title' => "Morning in Ponyville",
- 'lyrics' => "[Twilight Sparkle]
-Morning in Ponyville shimmers
-Morning in Ponyville shines
-And I know for absolute certain
-That everything is certainly fine
-
-There's the Mayor en route to her office
-There's the sofa clerk selling some quills
-
-Store owner: Morning, kid!
-
-[Twilight Sparkle]
-My Ponyville is so gentle and still
-Can things ever go wrong?
-I don't think that they will
-
-Morning in Ponyville shimmers
-Morning in Ponyville shines
- And I know for absolute certain
- That everything is certainly...",
- 'slug' => "morning-in-ponyville",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 40,
- 'title' => "What My Cutie Mark Is Telling Me",
- 'lyrics' => "[Rainbow Dash]
-These animals don't listen, no, not one little bit
-They run around out of control and throw their hissy fits
-It's up to me to stop them, 'cause plainly you can see
-It's got to be my destiny, and it's what my cutie mark is telling me
-
-[Fluttershy]
-I try to keep them laughing, put a smile upon their face
-But no matter what I try, it seems a bit of a disgrace
-I have to entertain them, it's there for all to see
- It's got to be my destiny, and it's what my cutie mark is telling me
-
-[Pinkie Pie]
-I don't care much for pickin' fruit and plowin' fields ain't such a hoot
-No matter what I try, I cannot fix this busted water chute!
- I've got so many chores to do, it's no fun being me
-But it has to be my destiny, 'cause it's what my cutie mark is telling me
-
-[Applejack]
-Lookie here at what I made, I think that it's a dress
-I know it doesn't look like much, I'm under some distress
-Could y'all give me a hand here and help me fix this mess?
- My destiny is not pretty, but it's what my cutie mark is tellin' me
-
-[Rarity]
-I'm in love with weather patterns but the others have concerns
-For I just gave them frostbite over-top of their sunburns
-I have to keep on trying for everyone can see
-It's got to be
-
-[Fluttershy]
-It's got to be
-
-[Pinkie Pie]
-My destiny
-
-[Applejack]
-My destiny
-
-[Rarity, Rainbow Dash, and Fluttershy]
-And it's what my cutie mark
-
-[Pinkie Pie and Applejack]
-It's what my cutie mark
-
-[All]
-Yes, it's what my cutie mark is telling me!",
- 'slug' => "what-my-cutie-mark-is-telling-me",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 41,
- 'title' => "I've Got to Find a Way",
- 'lyrics' => "[Twilight Sparkle]
-I have to find a way
-To make this all okay
-I can't believe this small mistake
-Could've caused so much heartache
-
-Oh why, oh why
-
-Losing promise
-I don't know what to do
- Seeking answers
-I fear I won't get through to you
-
-Oh why, oh why",
- 'slug' => "ive-got-to-find-a-way",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 42,
- 'title' => "A True, True Friend",
- 'lyrics' => "[Twilight Sparkle]
-A true, true friend helps a friend in need
-
-A friend will be there to help them see
-[Twilight and Fluttershy]
-A true, true friend helps a friend in need
-To see the light that shines from a true, true friend
-
-Rainbow Dash: Um, hello! Friend trapped inside, remember?
-
-[Twilight Sparkle]
-Rarity needs your help
-She's trying hard doing what she can
-
-[Fluttershy]
-Would you try, just give it a chance
-You might find that you'll start to understand
-
-[Twilight and Fluttershy]
-A true, true friend helps a friend in need
-A friend will be there to help you see
-A true, true friend helps a friend in need
-To see the light that shines from a true, true friend
-
-Rainbow Dash: Uh, what just happened?
-Twilight Sparkle: There's no time to explain, but we need your help. Applejack's trying to make dresses!
-Rainbow Dash: Say no more!
-
-[Rainbow Dash]
-Applejack needs your help
-She's trying hard doing what she can
-Would you try, just give it a chance
-You might find that you'll start to understand
-
-[Twilight, Fluttershy, and Rainbow Dash]
-A true, true friend helps a friend in need
-A friend will be there to help them see
-A true, true friend helps a friend in need
-To see the light that shines from a true, true friend
-
-Rarity: [gasps] Oh my, what a terrible dream I had. Or, maybe I'm still having it.
- Twilight Sparkle: Rarity, Pinkie Pie is about to lose the apple farm. We need Applejack's help!
-Rarity: Lose the apple farm? Well we can't let that happen, now can we?
-
- [Rarity]
- Pinkie Pie is in trouble
-We need to get there by her side
-We can try to do what we can now
-For together we can be her guide
-
-[Twilight, Fluttershy, Rainbow Dash, and Rarity]
-A true, true friend helps a friend in need
-A friend will be there to help them see
-A true, true friend helps a friend in need
-To see the light that shines from a true, true friend
-
-[key up]
-
-Applejack: Yee-haw! Now that's more like it, what's next?
- Twilight Sparkle: The townspeople are furious, we need the old Pinkie Pie back.
- Applejack: I'm on it, I know just the thing.
-
-[Applejack]
-The townspeople need you, they've been sad for a while
- They march around, faces frown and never seem to smile
- And if you feel like helping, we'd appreciate a loooooot
-If you get up there and spread some cheer from here to Canterlooooooot!
-
-Pinkie Pie: Come on ponies, I wanna see you smile!
-Crowd: Pinkie!
-
-[All and chorus]
-A true, true friend helps a friend in need
-A friend will be there to help them see
-A true, true friend helps a friend in need
-To see the light (to see the light)
-That shines (that shines)
-From a true, true friend!",
- 'slug' => "a-true-true-friend",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 43,
- 'title' => "Celestia's Ballad",
- 'lyrics' => "[Princess Celestia]
-You've come such a long, long way
-And I've watched you from that very first day
-To see how you might grow
-To see what you might do
- To see what you've been through
-And all the ways you've made me proud of you
-
-It's time now for a new change to come
-You've grown up and your new life has begun
-To go where you will go
-To see what you will see
-To find what you will be
-For it's time for you to fulfill your destiny",
- 'slug' => "celestias-ballad",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 44,
- 'title' => "Behold, Princess Twilight Sparkle",
- 'lyrics' => "[Choir]
-Thou Princess Twilight cometh
-Behold, behold
-A Princess here before us
-Behold, behold, behold
-
-Behold, behold (behold, behold)
-The Princess Twilight cometh
-Behold, behold (behold, behold)
-The Princess is
-The Princess is here",
- 'slug' => "behold-princess-twilight-sparkle",
- ]);
-DB::table('show_songs')->insert([
- 'id' => 45,
- 'title' => "Life in Equestria",
- 'lyrics' => "[Twilight Sparkle]
-Life in Equestria shimmers
-Life in Equestria shines
-And I know for absolute certain
-
-[Main Cast]
-That everything (everything)
-Yes, everything
-Yes, everything is certainly fine
-It’s fine
-
-Twilight Sparkle: Yes! Everything’s going to be just fine!",
- 'slug' => "life-in-equestria",
- ]);
- }
-
- public function down() {
- Schema::table('show_song_track', function($table){
- $table->dropForeign('show_song_track_track_id_foreign');
- $table->dropForeign('show_song_track_show_song_id_foreign');
- });
-
- Schema::drop('show_song_track');
- Schema::drop('show_songs');
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_07_28_060804_create_albums.php b/app/database/migrations/2013_07_28_060804_create_albums.php
deleted file mode 100644
index d2aa6456..00000000
--- a/app/database/migrations/2013_07_28_060804_create_albums.php
+++ /dev/null
@@ -1,45 +0,0 @@
-increments('id');
- $table->integer('user_id')->unsigned();
- $table->string('title')->index();
- $table->string('slug')->index();
- $table->text('description');
- $table->integer('cover_id')->unsigned()->nullable();
-
- $table->integer('track_count')->unsigned();
- $table->integer('view_count')->unsigned();
- $table->integer('download_count')->unsigned();
- $table->integer('favourite_count')->unsigned();
- $table->integer('comment_count')->unsigned();
-
- $table->timestamps();
- $table->timestamp('deleted_at')->nullable()->index();
-
- $table->foreign('cover_id')->references('id')->on('images');
- $table->foreign('user_id')->references('id')->on('users');
- });
-
- Schema::table('tracks', function($table) {
- $table->integer('album_id')->unsigned()->nullable();
- $table->integer('track_number')->unsigned()->nullable();
-
- $table->foreign('album_id')->references('id')->on('albums');
- });
- }
-
- public function down() {
- Schema::table('tracks', function($table) {
- $table->dropForeign('tracks_album_id_foreign');
- $table->dropColumn('album_id');
- $table->dropColumn('track_number');
- });
-
- Schema::drop('albums');
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_07_28_135136_create_playlists.php b/app/database/migrations/2013_07_28_135136_create_playlists.php
deleted file mode 100644
index 9c61a5a5..00000000
--- a/app/database/migrations/2013_07_28_135136_create_playlists.php
+++ /dev/null
@@ -1,67 +0,0 @@
-increments('id');
- $table->integer('user_id')->unsigned()->index();
- $table->string('title');
- $table->string('slug');
- $table->text('description');
- $table->boolean('is_public');
-
- $table->integer('track_count')->unsigned();
- $table->integer('view_count')->unsigned();
- $table->integer('download_count')->unsigned();
- $table->integer('favourite_count')->unsigned();
- $table->integer('follow_count')->unsigned();
- $table->integer('comment_count')->unsigned();
-
- $table->timestamps();
- $table->date('deleted_at')->nullable()->index();
-
- $table->foreign('user_id')->references('id')->on('users')->on_update('cascade');
- });
-
- Schema::create('playlist_track', function($table){
- $table->increments('id');
- $table->timestamps();
- $table->integer('playlist_id')->unsigned()->index();
- $table->integer('track_id')->unsigned()->index();
- $table->integer('position')->unsigned();
-
- $table->foreign('playlist_id')->references('id')->on('playlists')->on_update('cascade')->on_delete('cascade');
- $table->foreign('track_id')->references('id')->on('tracks')->on_update('cascade');
- });
-
- Schema::create('pinned_playlists', function($table) {
- $table->increments('id');
- $table->integer('user_id')->unsigned()->index();
- $table->integer('playlist_id')->unsigned()->index();
- $table->timestamps();
-
- $table->foreign('user_id')->references('id')->on('users')->on_update('cascade');
- $table->foreign('playlist_id')->references('id')->on('playlists')->on_update('cascade');
- });
- }
-
- public function down() {
- Schema::table('playlist_track', function($table){
- $table->dropForeign('playlist_track_playlist_id_foreign');
- $table->dropForeign('playlist_track_track_id_foreign');
- });
-
- Schema::drop('playlist_track');
-
- Schema::drop('pinned_playlists');
-
- Schema::table('playlists', function($table){
- $table->dropForeign('playlists_user_id_foreign');
- });
-
- Schema::drop('playlists');
- }
-
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_08_01_051337_create_comments.php b/app/database/migrations/2013_08_01_051337_create_comments.php
deleted file mode 100644
index d70491cb..00000000
--- a/app/database/migrations/2013_08_01_051337_create_comments.php
+++ /dev/null
@@ -1,38 +0,0 @@
-increments('id');
- $table->integer('user_id')->unsigned();
- $table->string('ip_address', 46);
- $table->text('content');
-
- $table->timestamps();
- $table->timestamp('deleted_at')->nullable()->index();
-
- $table->integer('profile_id')->unsigned()->nullable()->index();
- $table->integer('track_id')->unsigned()->nullable()->index();
- $table->integer('album_id')->unsigned()->nullable()->index();
- $table->integer('playlist_id')->unsigned()->nullable()->index();
-
- $table->foreign('profile_id')->references('id')->on('users');
- $table->foreign('user_id')->references('id')->on('users');
- $table->foreign('track_id')->references('id')->on('tracks');
- $table->foreign('album_id')->references('id')->on('albums');
- $table->foreign('playlist_id')->references('id')->on('playlists');
- });
- }
-
- public function down() {
- Schema::table('comments', function($table){
- $table->dropForeign('comments_user_id_foreign');
- $table->dropForeign('comments_track_id_foreign');
- $table->dropForeign('comments_album_id_foreign');
- $table->dropForeign('comments_playlist_id_foreign');
- });
- Schema::drop('comments');
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_08_18_041928_create_user_tables.php b/app/database/migrations/2013_08_18_041928_create_user_tables.php
deleted file mode 100644
index ac526370..00000000
--- a/app/database/migrations/2013_08_18_041928_create_user_tables.php
+++ /dev/null
@@ -1,57 +0,0 @@
-increments('id');
- $table->integer('user_id')->unsigned()->index();
-
- $table->integer('track_id')->unsigned()->nullable()->index();
- $table->integer('album_id')->unsigned()->nullable()->index();
- $table->integer('playlist_id')->unsigned()->nullable()->index();
- $table->integer('artist_id')->unsigned()->nullable()->index();
-
- $table->boolean('is_followed');
- $table->boolean('is_favourited');
- $table->boolean('is_pinned');
-
- $table->integer('view_count');
- $table->integer('play_count');
- $table->integer('download_count');
-
- $table->foreign('artist_id')->references('id')->on('users')->on_delete('cascade');
- $table->foreign('user_id')->references('id')->on('users')->on_delete('cascade');
- $table->foreign('track_id')->references('id')->on('tracks')->on_delete('cascade');;
- $table->foreign('album_id')->references('id')->on('albums')->on_delete('cascade');;
- $table->foreign('playlist_id')->references('id')->on('playlists')->on_delete('cascade');;
-
- $table->unique(['user_id', 'track_id', 'album_id', 'playlist_id', 'artist_id'], 'resource_unique');
- });
-
- Schema::create('resource_log_items', function($table){
- $table->increments('id');
- $table->integer('user_id')->unsigned()->nullable()->index();
- $table->integer('log_type')->unsigned();
- $table->string('ip_address', 46)->index();
- $table->integer('track_format_id')->unsigned()->nullable();
-
- $table->integer('track_id')->unsigned()->nullable()->index();
- $table->integer('album_id')->unsigned()->nullable()->index();
- $table->integer('playlist_id')->unsigned()->nullable()->index();
-
- $table->timestamp('created_at');
-
- $table->foreign('user_id')->references('id')->on('users')->on_delete('cascade');
- $table->foreign('track_id')->references('id')->on('tracks');
- $table->foreign('album_id')->references('id')->on('albums');
- $table->foreign('playlist_id')->references('id')->on('playlists');
- });
- }
-
- public function down() {
- Schema::drop('resource_users');
- Schema::drop('resource_log_items');
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_08_18_045248_create_favourites.php b/app/database/migrations/2013_08_18_045248_create_favourites.php
deleted file mode 100644
index 8901d451..00000000
--- a/app/database/migrations/2013_08_18_045248_create_favourites.php
+++ /dev/null
@@ -1,34 +0,0 @@
-increments('id');
- $table->integer('user_id')->unsigned()->index();
-
- $table->integer('track_id')->unsigned()->nullable()->index();
- $table->integer('album_id')->unsigned()->nullable()->index();
- $table->integer('playlist_id')->unsigned()->nullable()->index();
-
- $table->timestamp('created_at');
-
- $table->foreign('user_id')->references('id')->on('users')->on_delete('cascade');
- $table->foreign('track_id')->references('id')->on('tracks');
- $table->foreign('album_id')->references('id')->on('albums');
- $table->foreign('playlist_id')->references('id')->on('playlists');
- });
- }
-
- public function down() {
- Schema::table('favourites', function($table){
- $table->dropForeign('favourites_user_id_foreign');
- $table->dropForeign('favourites_track_id_foreign');
- $table->dropForeign('favourites_album_id_foreign');
- $table->dropForeign('favourites_playlist_id_foreign');
- });
-
- Schema::drop('favourites');
- }
- }
\ No newline at end of file
diff --git a/app/database/migrations/2013_08_29_025516_create_followers.php b/app/database/migrations/2013_08_29_025516_create_followers.php
deleted file mode 100644
index d9604534..00000000
--- a/app/database/migrations/2013_08_29_025516_create_followers.php
+++ /dev/null
@@ -1,25 +0,0 @@
-increments('id');
- $table->integer('user_id')->unsigned()->index();
-
- $table->integer('artist_id')->unsigned()->nullable()->index();
- $table->integer('playlist_id')->unsigned()->nullable()->index();
-
- $table->timestamp('created_at');
-
- $table->foreign('user_id')->references('id')->on('users')->on_delete('cascade');
- $table->foreign('artist_id')->references('id')->on('users')->on_delete('cascade');
- $table->foreign('playlist_id')->references('id')->on('playlists');
- });
- }
-
- public function down() {
- Schema::drop('followers');
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_09_01_025031_oauth.php b/app/database/migrations/2013_09_01_025031_oauth.php
deleted file mode 100644
index 0606d77c..00000000
--- a/app/database/migrations/2013_09_01_025031_oauth.php
+++ /dev/null
@@ -1,22 +0,0 @@
-increments('id');
- $table->integer('user_id');
- $table->integer('external_user_id');
- $table->text('access_token');
- $table->timestamp('expires');
- $table->text('refresh_token');
- $table->string('type');
- $table->string('service');
- });
- }
-
- public function down() {
- Schema::drop('oauth2_tokens');
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_09_01_232520_create_news_table.php b/app/database/migrations/2013_09_01_232520_create_news_table.php
deleted file mode 100644
index d6e9aa73..00000000
--- a/app/database/migrations/2013_09_01_232520_create_news_table.php
+++ /dev/null
@@ -1,21 +0,0 @@
-increments('id');
- $table->integer('user_id')->unsigned()->index();
- $table->string('post_hash', 32)->index();
- $table->timestamps();
-
- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
- });
- }
-
- public function down() {
- Schema::drop('news');
- }
-
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_09_10_014644_create_latest_column.php b/app/database/migrations/2013_09_10_014644_create_latest_column.php
deleted file mode 100644
index 38b8e6c7..00000000
--- a/app/database/migrations/2013_09_10_014644_create_latest_column.php
+++ /dev/null
@@ -1,37 +0,0 @@
-boolean('is_latest')->notNullable()->indexed();
- });
-
- DB::update('
- UPDATE
- tracks
- SET
- is_latest = true
- WHERE
- (
- SELECT
- t2.id
- FROM
- (SELECT id, user_id FROM tracks WHERE published_at IS NOT NULL AND deleted_at IS NULL) AS t2
- WHERE
- t2.user_id = tracks.user_id
- ORDER BY
- created_at DESC
- LIMIT 1
- ) = tracks.id
- AND
- published_at IS NOT NULL');
- }
-
- public function down() {
- Schema::table('tracks', function($table) {
- $table->dropColumn('is_latest');
- });
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_09_23_031316_create_track_hashes.php b/app/database/migrations/2013_09_23_031316_create_track_hashes.php
deleted file mode 100644
index 88da6afa..00000000
--- a/app/database/migrations/2013_09_23_031316_create_track_hashes.php
+++ /dev/null
@@ -1,23 +0,0 @@
-string('hash', 32)->notNullable()->indexed();
- });
-
- foreach (Track::with('user')->get() as $track) {
- $track->updateHash();
- $track->save();
- }
- }
-
- public function down() {
- Schema::table('tracks', function($table) {
- $table->dropColumn('hash');
- });
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2013_09_24_055911_track_is_listed.php b/app/database/migrations/2013_09_24_055911_track_is_listed.php
deleted file mode 100644
index 184e8b8d..00000000
--- a/app/database/migrations/2013_09_24_055911_track_is_listed.php
+++ /dev/null
@@ -1,23 +0,0 @@
-boolean('is_listed')->notNullable()->indexed();
- });
-
- DB::update('
- UPDATE
- tracks
- SET
- is_listed = true');
- }
-
- public function down() {
- Schema::table('tracks', function($table) {
- $table->dropColumn('is_listed');
- });
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2014_05_28_071738_update_track_hash.php b/app/database/migrations/2014_05_28_071738_update_track_hash.php
deleted file mode 100644
index cbb72f79..00000000
--- a/app/database/migrations/2014_05_28_071738_update_track_hash.php
+++ /dev/null
@@ -1,16 +0,0 @@
-get() as $track) {
- $track->updateHash();
- $track->save();
- }
- }
-
- public function down() {
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2015_04_30_064436_add_remember_me_field.php b/app/database/migrations/2015_04_30_064436_add_remember_me_field.php
deleted file mode 100644
index 1e400d3b..00000000
--- a/app/database/migrations/2015_04_30_064436_add_remember_me_field.php
+++ /dev/null
@@ -1,17 +0,0 @@
-string('remember_token', 100)->nullable()->indexed();
- });
- }
-
- public function down() {
- Schema::table('users', function($table) {
- $table->dropColumn('remember_token');
- });
- }
-}
\ No newline at end of file
diff --git a/app/database/migrations/2015_05_20_155236_add_archived_profile_field.php b/app/database/migrations/2015_05_20_155236_add_archived_profile_field.php
deleted file mode 100644
index 6dfa4b13..00000000
--- a/app/database/migrations/2015_05_20_155236_add_archived_profile_field.php
+++ /dev/null
@@ -1,31 +0,0 @@
-boolean( 'is_archived' )->default(false);
- } );
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::table( 'users', function ( $table ) {
- $table->dropColumn( 'is_archived' );
- } );
- }
-
-}
\ No newline at end of file
diff --git a/app/database/migrations/2015_05_25_011121_create_track_files_table.php b/app/database/migrations/2015_05_25_011121_create_track_files_table.php
deleted file mode 100644
index 0984c119..00000000
--- a/app/database/migrations/2015_05_25_011121_create_track_files_table.php
+++ /dev/null
@@ -1,54 +0,0 @@
-increments('id');
- $table->integer('track_id')->unsigned()->indexed();
- $table->boolean('is_master')->default(false)->indexed();
- $table->string('format')->indexed();
-
- $table->foreign('track_id')->references('id')->on('tracks');
- $table->timestamps();
- });
-
- foreach (Track::all() as $track){
- foreach (Track::$Formats as $name => $item) {
- DB::table('track_files')->insert(
- [
- 'track_id' => $track->id,
- 'is_master' => $name === 'FLAC' ? true : false,
- 'format' => $name,
- 'created_at'=> $track->created_at,
- 'updated_at'=> Carbon\Carbon::now()
- ]
- );
- }
- }
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::drop('track_files');
- }
-
-}
\ No newline at end of file
diff --git a/app/database/production.sqlite b/app/database/production.sqlite
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/database/seeds/DatabaseSeeder.php b/app/database/seeds/DatabaseSeeder.php
deleted file mode 100644
index 6a8c204c..00000000
--- a/app/database/seeds/DatabaseSeeder.php
+++ /dev/null
@@ -1,17 +0,0 @@
-call('UserTableSeeder');
- }
-
-}
\ No newline at end of file
diff --git a/app/filters.php b/app/filters.php
deleted file mode 100644
index 9c739444..00000000
--- a/app/filters.php
+++ /dev/null
@@ -1,106 +0,0 @@
-after($request, $response);
-
- Cache::put('profiler-request-' . $profiler->getId(), $profiler->toString(), 2);
- header('X-Request-Id: ' . $profiler->getId());
- }
-
- App::error(function($exception) use ($profiler) {
- $profiler->log('error', $exception->__toString(), []);
- processResponse($profiler, null, null);
- });
-
- App::after(function($request, $response) use ($profiler) {
- if ($response->headers->get('content-type') != 'application/json')
- return;
-
- processResponse($profiler, $request, $response);
- });
-
- Log::listen(function($level, $message, $context) use ($profiler) {
- $profiler->log($level, $message, $context);
- });
-
- App::error(function($exception) {
- // return Response::view('errors.500', array(), 404);
- });
- }
-
- App::missing(function($exception) {
- return Response::view('errors.404', array(), 404);
- });
-
-
- /*
- |--------------------------------------------------------------------------
- | Authentication Filters
- |--------------------------------------------------------------------------
- |
- | The following filters are used to verify that the user of the current
- | session is logged into this application. The "basic" filter easily
- | integrates HTTP Basic authentication for quick, simple checking.
- |
- */
-
- Route::filter('auth', function()
- {
- if (Auth::guest()) return Redirect::guest('login');
- });
-
-
- Route::filter('auth.basic', function()
- {
- return Auth::basic();
- });
-
- /*
- |--------------------------------------------------------------------------
- | Guest Filter
- |--------------------------------------------------------------------------
- |
- | The "guest" filter is the counterpart of the authentication filters as
- | it simply checks that the current user is not logged in. A redirect
- | response will be issued if they are, which you may freely change.
- |
- */
-
- Route::filter('guest', function()
- {
- if (Auth::check()) return Redirect::to('/');
- });
-
- /*
- |--------------------------------------------------------------------------
- | CSRF Protection Filter
- |--------------------------------------------------------------------------
- |
- | The CSRF filter is responsible for protecting your application against
- | cross-site request forgery attacks. If this special token in a user
- | session does not match the one given in this request, we'll bail.
- |
- */
-
- Route::filter('csrf', function()
- {
- if (Session::token() != Input::get('_token') && Session::token() != Request::header('X-Token')) {
- throw new Illuminate\Session\TokenMismatchException;
- }
- });
\ No newline at end of file
diff --git a/app/lang/en/pagination.php b/app/lang/en/pagination.php
deleted file mode 100644
index eb9be3ba..00000000
--- a/app/lang/en/pagination.php
+++ /dev/null
@@ -1,20 +0,0 @@
- '« Previous',
-
- 'next' => 'Next »',
-
-);
\ No newline at end of file
diff --git a/app/lang/en/reminders.php b/app/lang/en/reminders.php
deleted file mode 100644
index 4a9f1766..00000000
--- a/app/lang/en/reminders.php
+++ /dev/null
@@ -1,22 +0,0 @@
- "Passwords must be six characters and match the confirmation.",
-
- "user" => "We can't find a user with that e-mail address.",
-
- "token" => "This password reset token is invalid.",
-
-);
\ No newline at end of file
diff --git a/app/lang/en/validation.php b/app/lang/en/validation.php
deleted file mode 100644
index 40d4d727..00000000
--- a/app/lang/en/validation.php
+++ /dev/null
@@ -1,104 +0,0 @@
- "The :attribute must be accepted.",
- "active_url" => "The :attribute is not a valid URL.",
- "after" => "The :attribute must be a date after :date.",
- "alpha" => "The :attribute may only contain letters.",
- "alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.",
- "alpha_num" => "The :attribute may only contain letters and numbers.",
- "before" => "The :attribute must be a date before :date.",
- "between" => array(
- "numeric" => "The :attribute must be between :min - :max.",
- "file" => "The :attribute must be between :min - :max kilobytes.",
- "string" => "The :attribute must be between :min - :max characters.",
- ),
- "confirmed" => "The :attribute confirmation does not match.",
- "date" => "The :attribute is not a valid date.",
- "date_format" => "The :attribute does not match the format :format.",
- "different" => "The :attribute and :other must be different.",
- "digits" => "The :attribute must be :digits digits.",
- "digits_between" => "The :attribute must be between :min and :max digits.",
- "email" => "The :attribute format is invalid.",
- "exists" => "The selected :attribute is invalid.",
- "image" => "The :attribute must be an image.",
- "in" => "The selected :attribute is invalid.",
- "integer" => "The :attribute must be an integer.",
- "ip" => "The :attribute must be a valid IP address.",
- "max" => array(
- "numeric" => "The :attribute may not be greater than :max.",
- "file" => "The :attribute may not be greater than :max kilobytes.",
- "string" => "The :attribute may not be greater than :max characters.",
- ),
- "mimes" => "The :attribute must be a file of type: :values.",
- "min" => array(
- "numeric" => "The :attribute must be at least :min.",
- "file" => "The :attribute must be at least :min kilobytes.",
- "string" => "The :attribute must be at least :min characters.",
- ),
- "not_in" => "The selected :attribute is invalid.",
- "numeric" => "The :attribute must be a number.",
- "regex" => "The :attribute format is invalid.",
- "required" => "The :attribute field is required.",
- "required_if" => "The :attribute field is required when :other is :value.",
- "required_with" => "The :attribute field is required when :values is present.",
- "required_without" => "The :attribute field is required when :values is not present.",
- "same" => "The :attribute and :other must match.",
- "size" => array(
- "numeric" => "The :attribute must be :size.",
- "file" => "The :attribute must be :size kilobytes.",
- "string" => "The :attribute must be :size characters.",
- ),
- "unique" => "The :attribute has already been taken.",
- "url" => "The :attribute format is invalid.",
-
- /*
- |--------------------------------------------------------------------------
- | Custom Validation Language Lines
- |--------------------------------------------------------------------------
- |
- | Here you may specify custom validation messages for attributes using the
- | convention "attribute.rule" to name the lines. This makes it quick to
- | specify a specific custom language line for a given attribute rule.
- |
- */
-
- 'custom' => array(),
-
- //=== CUSTOM VALIDATION MESSAGES ===//
-
- "audio" => "The :attribute must be an audio file.",
- "audio_channels" => "The :attribute contains an invalid number of channels.",
- "audio_format" => "The :attribute does not contain audio in a valid format.",
- "required_when" => "The :attribute field cannot be left blank.",
- "sample_rate" => "The :attribute has an invalid sample rate.",
- "min_width" => "The :attribute is not wide enough.",
- "min_height" => "The :attribute is not tall enough.",
- "textarea_length" => "The :attribute must be less than 250 characters long.", // @TODO: Figure out how to retrieve the parameter from the validation rule
-
- /*
- |--------------------------------------------------------------------------
- | Custom Validation Attributes
- |--------------------------------------------------------------------------
- |
- | The following language lines are used to swap attribute place-holders
- | with something more reader friendly such as E-Mail Address instead
- | of "email". This simply helps us make messages a little cleaner.
- |
- */
-
- 'attributes' => array(),
-
-);
diff --git a/app/library/Assets.php b/app/library/Assets.php
deleted file mode 100644
index be3c779b..00000000
--- a/app/library/Assets.php
+++ /dev/null
@@ -1,107 +0,0 @@
-';
-
- $scripts = self::mergeGlobs(self::getScriptsForArea($area));
- $retVal = "";
-
- foreach ($scripts as $script) {
- $filename = self::replaceExtensionWith($script, ".coffee", ".js");
- $retVal .= "";
- }
-
- return $retVal;
- }
-
- public static function styleIncludes($area = 'app') {
- if (!Config::get("app.debug"))
- return '';
-
- $styles = self::mergeGlobs(self::getStylesForArea($area));
- $retVal = "";
-
- foreach ($styles as $style) {
- $filename = self::replaceExtensionWith($style, ".less", ".css");
- $retVal .= "";
- }
-
- return $retVal;
- }
-
- private static function replaceExtensionWith($filename, $fromExtension, $toExtension) {
- $fromLength = strlen($fromExtension);
- return substr($filename, -$fromLength) == $fromExtension
- ? substr($filename, 0, strlen($filename) - $fromLength) . $toExtension
- : $filename;
- }
-
- /** Merges an array of paths that are passed into "glob" into a list of unique filenames.
- * Note that this method assumes the globs should be relative to the "app" folder of this project */
- private static function mergeGlobs($globs) {
- $files = [];
- $filesFound = [];
- foreach ($globs as $glob) {
- foreach (glob("../app/" . $glob, GLOB_BRACE) as $file) {
- if (isset($filesFound[$file]))
- continue;
-
- $filesFound[$file] = true;
- $files[] = substr($file, 7); // chop off ../app/
- }
- }
-
- return $files;
- }
-
- private static function getScriptsForArea($area) {
- if ($area == 'app') {
- return [
- "scripts/base/jquery-2.0.2.js",
- "scripts/base/angular.js",
- "scripts/base/*.{coffee,js}",
- "scripts/shared/*.{coffee,js}",
- "scripts/app/*.{coffee,js}",
- "scripts/app/services/*.{coffee,js}",
- "scripts/app/filters/*.{coffee,js}",
- "scripts/app/directives/*.{coffee,js}",
- "scripts/app/controllers/*.{coffee,js}",
- "scripts/**/*.{coffee,js}"
- ];
- } else if ($area == 'embed') {
- return [
- "scripts/base/jquery-2.0.2.js",
- "scripts/base/jquery.viewport.js",
- "scripts/base/underscore.js",
- "scripts/base/moment.js",
- "scripts/base/jquery.timeago.js",
- "scripts/base/soundmanager2-nodebug.js",
- "scripts/embed/*.coffee"];
- }
-
- throw new Exception();
- }
-
- private static function getStylesForArea($area) {
- if ($area == 'app') {
- return [
- "styles/base/jquery-ui.css",
- "styles/base/colorbox.css",
- "styles/app.less",
- "styles/profiler.less"
- ];
- } else if ($area == 'embed') {
- return [
- "styles/embed.less"
- ];
- }
-
- throw new Exception();
- }
- }
\ No newline at end of file
diff --git a/app/library/AudioCache.php b/app/library/AudioCache.php
deleted file mode 100644
index 48866988..00000000
--- a/app/library/AudioCache.php
+++ /dev/null
@@ -1,16 +0,0 @@
-_lastModified = $lastModified;
- parent::__construct([], '', '', []);
- }
-
- public function load(FilterInterface $additionalFilter = null) {
- }
-
- public function getLastModified() {
- return $this->_lastModified;
- }
- }
diff --git a/app/library/External.php b/app/library/External.php
deleted file mode 100644
index e2a7dbe8..00000000
--- a/app/library/External.php
+++ /dev/null
@@ -1,14 +0,0 @@
-
- */
- class File extends \Illuminate\Support\Facades\File
- {
-
- public static function inline($path, $mime, $name = null)
- {
- if (is_null($name))
- {
- $name = basename($path);
- }
-
- $response = Response::make(static::get($path));
-
- $response->header('Content-Type', $mime);
- $response->header('Content-Disposition', 'inline; filename="'.$name.'"');
- $response->header('Content-Transfer-Encoding', 'binary');
- $response->header('Expires', 0);
- $response->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
- $response->header('Pragma', 'public');
- $response->header('Content-Length', filesize($path));
-
- return $response;
- }
-
- }
diff --git a/app/library/Gravatar.php b/app/library/Gravatar.php
deleted file mode 100644
index 1bb3e071..00000000
--- a/app/library/Gravatar.php
+++ /dev/null
@@ -1,26 +0,0 @@
-format('c');
- }
-
- $title = date('c', strtotime($timestamp));
- $content = date('F d, o \@ g:i:s a', strtotime($timestamp));
- return ''.$content.'';
- }
- }
\ No newline at end of file
diff --git a/app/library/IpsHasher.php b/app/library/IpsHasher.php
deleted file mode 100644
index aefe0c2f..00000000
--- a/app/library/IpsHasher.php
+++ /dev/null
@@ -1,29 +0,0 @@
- $options['salt']]) === $hashedValue;
- }
-
- public function needsRehash($hashedValue, array $options = array()) {
- return false;
- }
-
- static public function ips_sanitize( $value ) {
- $value = str_replace('&', '&', $value);
- $value = str_replace('\\', '\', $value);
- $value = str_replace('!', '!', $value);
- $value = str_replace('$', '$', $value);
- $value = str_replace('"', '"', $value);
- $value = str_replace('<', '<', $value);
- $value = str_replace('>', '>', $value);
- $value = str_replace('\'', ''', $value);
- return $value;
- }
- }
\ No newline at end of file
diff --git a/app/library/PFMAuth.php b/app/library/PFMAuth.php
deleted file mode 100644
index 3e68067e..00000000
--- a/app/library/PFMAuth.php
+++ /dev/null
@@ -1,21 +0,0 @@
-getPathname());
- return in_array($file->getAudioCodec(), $parameters);
- }
-
-
- /**
- * Validate the sample rate of the audio file.
- *
- * @param string $attribute
- * @param array $value
- * @param array $parameters
- * @return bool
- */
- public function validateSampleRate($attribute, $value, $parameters)
- {
- // attribute is the file field
- // value is the file array itself
- // parameters is a list of sample rates the file can be, verified via ffmpeg
- $file = AudioCache::get($value->getPathname());
- return in_array($file->getAudioSampleRate(), $parameters);
- }
-
-
- /**
- * Validate the number of channels in the audio file.
- *
- * @param string $attribute
- * @param array $value
- * @param array $parameters
- * @return bool
- */
- public function validateAudioChannels($attribute, $value, $parameters)
- {
- // attribute is the file field
- // value is the file array itself
- // parameters is a list of sample rates the file can be, verified via ffmpeg
- $file = AudioCache::get($value->getPathname());
- return in_array($file->getAudioChannels(), $parameters);
- }
-
-
- /**
- * Validate the bit rate of the audio file.
- *
- * @param string $attribute
- * @param array $value
- * @param array $parameters
- * @return bool
- */
- public function validateAudioBitrate($attribute, $value, $parameters)
- {
- // attribute is the file field
- // value is the file array itself
- // parameters is a list of sample rates the file can be, verified via ffmpeg
- $file = AudioCache::get($value->getPathname());
- return in_array($file->getAudioBitRate(), $parameters);
- }
-
-
- /**
- * Validate the duration of the audio file, in seconds.
- *
- * @param string $attribute
- * @param array $value
- * @param array $parameters
- * @return bool
- */
- public function validateMinDuration($attribute, $value, $parameters)
- {
- // attribute is the file field
- // value is the file array itself
- // parameters is an array containing one value: the minimum duration
- $file = AudioCache::get($value->getPathname());
- return $file->getDuration() >= (float) $parameters[0];
- }
-
-
- /**
- * Require a field when the value of another field matches a certain value.
- *
- * @param string $attribute
- * @param array $value
- * @param array $parameters
- * @return bool
- */
- /** OLD CODE
- public function validate_required_when($attribute, $value, $parameters)
- {
- if ( Input::get($parameters[0]) === $parameters[1] && static::required($attribute, $value) ){
- return true;
-
- } else {
- return false;
- }
- }
- **/
-
- // custom required_when validator
- public function validateRequiredWhen($attribute, $value, $parameters){
- if ( Input::get($parameters[0]) == $parameters[1] ) {
- return $this->validate_required($attribute, $value);
- }
-
- return true;
- }
-
-
- // custom image width validator
- public function validateMinWidth($attribute, $value, $parameters){
- return getimagesize($value->getPathname())[0] >= $parameters[0];
- }
-
- // custom image height validator
- public function validateMinHeight($attribute, $value, $parameters){
- return getimagesize($value->getPathname())[1] >= $parameters[0];
- }
-
- public function validateTextareaLength($attribute, $value, $parameters) {
- return strlen(str_replace("\r\n", "\n", $value)) <= $parameters[0];
- }
- }
\ No newline at end of file
diff --git a/app/library/Poniverse/Poniverse.php b/app/library/Poniverse/Poniverse.php
deleted file mode 100644
index 3ad250cf..00000000
--- a/app/library/Poniverse/Poniverse.php
+++ /dev/null
@@ -1,95 +0,0 @@
-urls = Config::get('poniverse.urls');
-
- $this->clientId = $clientId;
- $this->clientSecret = $clientSecret;
- $this->accessToken = $accessToken;
-
- //Setup Dependencies
- $this->setupOAuth2();
- $this->setupHttpful();
- }
-
- protected function setupOAuth2()
- {
- require_once('oauth2/Client.php');
- require_once('oauth2/GrantType/IGrantType.php');
- require_once('oauth2/GrantType/AuthorizationCode.php');
-
- $this->client = new \OAuth2\Client($this->clientId, $this->clientSecret);
- }
-
- protected function setupHttpful()
- {
- require_once('autoloader.php');
- $autoloader = new SplClassLoader('Httpful', __DIR__."/httpful/src/");
- $autoloader->register();
- }
-
- public function setAccessToken($accessToken)
- {
- $this->accessToken = $accessToken;
- }
-
- public function getAuthenticationUrl($state)
- {
- return $this->client->getAuthenticationUrl($this->urls['auth'], $this->redirectUri, ['state' => $state]);
- }
-
- public function setRedirectUri($redirectUri)
- {
- $this->redirectUri = $redirectUri;
- }
-
- /**
- * Gets the OAuth2 Client
- *
- * @return \OAuth2\Client
- */
- public function getClient()
- {
- return $this->client;
- }
-
- /**
- * Gets data about the currently logged in user
- *
- * @return array
- */
- public function getUser()
- {
- $data = \Httpful\Request::get($this->urls['api'] . "users?access_token=" . $this->accessToken );
-
- $result = $data->addHeader('Accept', 'application/json')->send();
-
- return json_decode($result, true);
- }
-}
\ No newline at end of file
diff --git a/app/library/Poniverse/autoloader.php b/app/library/Poniverse/autoloader.php
deleted file mode 100644
index 54a20935..00000000
--- a/app/library/Poniverse/autoloader.php
+++ /dev/null
@@ -1,137 +0,0 @@
-register();
- *
- * @author Jonathan H. Wage
- * @author Roman S. Borschel
- * @author Matthew Weier O'Phinney
- * @author Kris Wallsmith
- * @author Fabien Potencier
- */
-class SplClassLoader
-{
- private $_fileExtension = '.php';
- private $_namespace;
- private $_includePath;
- private $_namespaceSeparator = '\\';
-
- /**
- * Creates a new SplClassLoader that loads classes of the
- * specified namespace.
- *
- * @param string $ns The namespace to use.
- * @param string $includePath
- */
- public function __construct($ns = null, $includePath = null)
- {
- $this->_namespace = $ns;
- $this->_includePath = $includePath;
- }
-
- /**
- * Sets the namespace separator used by classes in the namespace of this class loader.
- *
- * @param string $sep The separator to use.
- */
- public function setNamespaceSeparator($sep)
- {
- $this->_namespaceSeparator = $sep;
- }
-
- /**
- * Gets the namespace seperator used by classes in the namespace of this class loader.
- *
- * @return string
- */
- public function getNamespaceSeparator()
- {
- return $this->_namespaceSeparator;
- }
-
- /**
- * Sets the base include path for all class files in the namespace of this class loader.
- *
- * @param string $includePath
- */
- public function setIncludePath($includePath)
- {
- $this->_includePath = $includePath;
- }
-
- /**
- * Gets the base include path for all class files in the namespace of this class loader.
- *
- * @return string $includePath
- */
- public function getIncludePath()
- {
- return $this->_includePath;
- }
-
- /**
- * Sets the file extension of class files in the namespace of this class loader.
- *
- * @param string $fileExtension
- */
- public function setFileExtension($fileExtension)
- {
- $this->_fileExtension = $fileExtension;
- }
-
- /**
- * Gets the file extension of class files in the namespace of this class loader.
- *
- * @return string $fileExtension
- */
- public function getFileExtension()
- {
- return $this->_fileExtension;
- }
-
- /**
- * Installs this class loader on the SPL autoload stack.
- */
- public function register()
- {
- spl_autoload_register(array($this, 'loadClass'));
- }
-
- /**
- * Uninstalls this class loader from the SPL autoloader stack.
- */
- public function unregister()
- {
- spl_autoload_unregister(array($this, 'loadClass'));
- }
-
- /**
- * Loads the given class or interface.
- *
- * @param string $className The name of the class to load.
- * @return void
- */
- public function loadClass($className)
- {
- if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
- $fileName = '';
- $namespace = '';
- if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
- $namespace = substr($className, 0, $lastNsPos);
- $className = substr($className, $lastNsPos + 1);
- $fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
- }
- $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
-
- require ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
- }
- }
-}
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/.gitignore b/app/library/Poniverse/httpful/.gitignore
deleted file mode 100644
index d1584ef4..00000000
--- a/app/library/Poniverse/httpful/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-.DS_Store
-composer.lock
-vendor
-downloads
diff --git a/app/library/Poniverse/httpful/.travis.yml b/app/library/Poniverse/httpful/.travis.yml
deleted file mode 100644
index ba03761e..00000000
--- a/app/library/Poniverse/httpful/.travis.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-language: php
-before_script: cd tests
-php:
- - 5.3
- - 5.4
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/LICENSE.txt b/app/library/Poniverse/httpful/LICENSE.txt
deleted file mode 100644
index 90892706..00000000
--- a/app/library/Poniverse/httpful/LICENSE.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Copyright (c) 2012 Nate Good
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/README.md b/app/library/Poniverse/httpful/README.md
deleted file mode 100644
index f816015a..00000000
--- a/app/library/Poniverse/httpful/README.md
+++ /dev/null
@@ -1,150 +0,0 @@
-# Httpful
-
-[![Build Status](https://secure.travis-ci.org/nategood/httpful.png?branch=master)](http://travis-ci.org/nategood/httpful)
-
-[Httpful](http://phphttpclient.com) is a simple Http Client library for PHP 5.3+. There is an emphasis of readability, simplicity, and flexibility – basically provide the features and flexibility to get the job done and make those features really easy to use.
-
-Features
-
- - Readable HTTP Method Support (GET, PUT, POST, DELETE, HEAD, PATCH and OPTIONS)
- - Custom Headers
- - Automatic "Smart" Parsing
- - Automatic Payload Serialization
- - Basic Auth
- - Client Side Certificate Auth
- - Request "Templates"
-
-# Sneak Peak
-
-Here's something to whet your appetite. Search the twitter API for tweets containing "#PHP". Include a trivial header for the heck of it. Notice that the library automatically interprets the response as JSON (can override this if desired) and parses it as an array of objects.
-
- $url = "http://search.twitter.com/search.json?q=" . urlencode('#PHP');
- $response = Request::get($url)
- ->withXTrivialHeader('Just as a demo')
- ->send();
-
- foreach ($response->body->results as $tweet) {
- echo "@{$tweet->from_user} tweets \"{$tweet->text}\"\n";
- }
-
-# Installation
-
-## Phar
-
-A [PHP Archive](http://php.net/manual/en/book.phar.php) (or .phar) file is available for [downloading](http://phphttpclient.com/httpful.phar). Simply [download](http://phphttpclient.com/httpful.phar) the .phar, drop it into your project, and include it like you would any other php file. _This method is ideal smaller projects, one off scripts, and quick API hacking_.
-
- sendIt();
- ...
-
-## Composer
-
-Httpful is PSR-0 compliant and can be installed using [composer](http://getcomposer.org/). Simply add `nategood/httpful` to your composer.json file. _Composer is the sane alternative to PEAR. It is excellent for managing dependancies in larger projects_.
-
- {
- "require": {
- "nategood/httpful": "*"
- }
- }
-
-## Install from Source
-
-Because Httpful is PSR-0 compliant, you can also just clone the Httpful repository and use a PSR-0 compatible autoloader to load the library, like [Symfony's](http://symfony.com/doc/current/components/class_loader.html). Alternatively you can use the PSR-0 compliant autoloader included with the Httpful (simply `require("bootstrap.php")`).
-
-# Show Me More!
-
-You can checkout the [Httpful Landing Page](http://phphttpclient.com) for more info including many examples and [documentation](http:://phphttpclient.com/docs).
-
-# Contributing
-
-Httpful highly encourages sending in pull requests. When submitting a pull request please:
-
- - All pull requests should target the `dev` branch (not `master`)
- - Make sure your code follows the [coding conventions](http://pear.php.net/manual/en/standards.php)
- - Please use soft tabs (four spaces) instead of hard tabs
- - Make sure you add appropriate test coverage for your changes
- - Run all unit tests in the test directory via `phpunit ./tests`
- - Include commenting where appropriate and add a descriptive pull request message
-
-# Changelog
-
-## 0.2.6
-
- - FIX [I #85](https://github.com/nategood/httpful/issues/85) Empty Content Length issue resolved
-
-## 0.2.5
-
- - FEATURE [I #80](https://github.com/nategood/httpful/issues/80) [I #81](https://github.com/nategood/httpful/issues/81) Proxy support added with `useProxy` method.
-
-## 0.2.4
-
- - FEATURE [I #77](https://github.com/nategood/httpful/issues/77) Convenience method for setting a timeout (seconds) `$req->timeoutIn(10);`
- - FIX [I #75](https://github.com/nategood/httpful/issues/75) [I #78](https://github.com/nategood/httpful/issues/78) Bug with checking if digest auth is being used.
-
-## 0.2.3
-
- - FIX Overriding default Mime Handlers
- - FIX [PR #73](https://github.com/nategood/httpful/pull/73) Parsing http status codes
-
-## 0.2.2
-
- - FEATURE Add support for parsing JSON responses as associative arrays instead of objects
- - FEATURE Better support for setting constructor arguments on Mime Handlers
-
-## 0.2.1
-
- - FEATURE [PR #72](https://github.com/nategood/httpful/pull/72) Allow support for custom Accept header
-
-## 0.2.0
-
- - REFACTOR [PR #49](https://github.com/nategood/httpful/pull/49) Broke headers out into their own class
- - REFACTOR [PR #54](https://github.com/nategood/httpful/pull/54) Added more specific Exceptions
- - FIX [PR #58](https://github.com/nategood/httpful/pull/58) Fixes throwing an error on an empty xml response
- - FEATURE [PR #57](https://github.com/nategood/httpful/pull/57) Adds support for digest authentication
-
-## 0.1.6
-
- - Ability to set the number of max redirects via overloading `followRedirects(int max_redirects)`
- - Standards Compliant fix to `Accepts` header
- - Bug fix for bootstrap process when installed via Composer
-
-## 0.1.5
-
- - Use `DIRECTORY_SEPARATOR` constant [PR #33](https://github.com/nategood/httpful/pull/32)
- - [PR #35](https://github.com/nategood/httpful/pull/35)
- - Added the raw\_headers property reference to response.
- - Compose request header and added raw\_header to Request object.
- - Fixed response has errors and added more comments for clarity.
- - Fixed header parsing to allow the minimum (status line only) and also cater for the actual CRLF ended headers as per RFC2616.
- - Added the perfect test Accept: header for all Acceptable scenarios see @b78e9e82cd9614fbe137c01bde9439c4e16ca323 for details.
- - Added default User-Agent header
- - `User-Agent: Httpful/0.1.5` + curl version + server software + PHP version
- - To bypass this "default" operation simply add a User-Agent to the request headers even a blank User-Agent is sufficient and more than simple enough to produce me thinks.
- - Completed test units for additions.
- - Added phpunit coverage reporting and helped phpunit auto locate the tests a bit easier.
-
-## 0.1.4
-
- - Add support for CSV Handling [PR #32](https://github.com/nategood/httpful/pull/32)
-
-## 0.1.3
-
- - Handle empty responses in JsonParser and XmlParser
-
-## 0.1.2
-
- - Added support for setting XMLHandler configuration options
- - Added examples for overriding XmlHandler and registering a custom parser
- - Removed the httpful.php download (deprecated in favor of httpful.phar)
-
-## 0.1.1
-
- - Bug fix serialization default case and phpunit tests
-
-## 0.1.0
-
- - Added Support for Registering Mime Handlers
- - Created AbstractMimeHandler type that all Mime Handlers must extend
- - Pulled out the parsing/serializing logic from the Request/Response classes into their own MimeHandler classes
- - Added ability to register new mime handlers for mime types
diff --git a/app/library/Poniverse/httpful/bootstrap.php b/app/library/Poniverse/httpful/bootstrap.php
deleted file mode 100644
index 10f2a7cf..00000000
--- a/app/library/Poniverse/httpful/bootstrap.php
+++ /dev/null
@@ -1,4 +0,0 @@
-setStub($stub);
-} catch(Exception $e) {
- $phar = false;
-}
-exit_unless($phar, "Unable to create a phar. Make certain you have phar.readonly=0 set in your ini file.");
-$phar->buildFromDirectory(dirname($source_dir));
-echo "[ OK ]\n";
-
-
-
-// Add it to git!
-echo "Adding httpful.phar to the repo... ";
-$return_code = 0;
-passthru("git add $phar_path", $return_code);
-exit_unless($return_code === 0, "Unable to add download files to git.");
-echo "[ OK ]\n";
-echo "\nBuild completed successfully.\n\n";
diff --git a/app/library/Poniverse/httpful/composer.json b/app/library/Poniverse/httpful/composer.json
deleted file mode 100644
index 6d61e6e7..00000000
--- a/app/library/Poniverse/httpful/composer.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name": "nategood/httpful",
- "description": "A Readable, Chainable, REST friendly, PHP HTTP Client",
- "homepage": "http://github.com/nategood/httpful",
- "license": "MIT",
- "keywords": ["http", "curl", "rest", "restful", "api", "requests"],
- "version": "0.2.6",
- "authors": [
- {
- "name": "Nate Good",
- "email": "me@nategood.com",
- "homepage": "http://nategood.com"
- }
- ],
- "require": {
- "php": ">=5.3",
- "ext-curl": "*"
- },
- "autoload": {
- "psr-0": {
- "Httpful": "src/"
- }
- },
- "require-dev": {
- "phpunit/phpunit": "*"
- }
-}
diff --git a/app/library/Poniverse/httpful/examples/freebase.php b/app/library/Poniverse/httpful/examples/freebase.php
deleted file mode 100644
index bb3b528f..00000000
--- a/app/library/Poniverse/httpful/examples/freebase.php
+++ /dev/null
@@ -1,12 +0,0 @@
-expectsJson()
- ->sendIt();
-
-echo 'The Dead Weather has ' . count($response->body->result->album) . " albums.\n";
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/examples/github.php b/app/library/Poniverse/httpful/examples/github.php
deleted file mode 100644
index 8eb3f3ba..00000000
--- a/app/library/Poniverse/httpful/examples/github.php
+++ /dev/null
@@ -1,9 +0,0 @@
-send();
-
-echo "{$request->body->name} joined GitHub on " . date('M jS', strtotime($request->body->{'created-at'})) ."\n";
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/examples/override.php b/app/library/Poniverse/httpful/examples/override.php
deleted file mode 100644
index 2c3bdd5c..00000000
--- a/app/library/Poniverse/httpful/examples/override.php
+++ /dev/null
@@ -1,44 +0,0 @@
- 'http://example.com');
-\Httpful\Httpful::register(\Httpful\Mime::XML, new \Httpful\Handlers\XmlHandler($conf));
-
-// We can also add the parsers with our own...
-class SimpleCsvHandler extends \Httpful\Handlers\MimeHandlerAdapter
-{
- /**
- * Takes a response body, and turns it into
- * a two dimensional array.
- *
- * @param string $body
- * @return mixed
- */
- public function parse($body)
- {
- return str_getcsv($body);
- }
-
- /**
- * Takes a two dimensional array and turns it
- * into a serialized string to include as the
- * body of a request
- *
- * @param mixed $payload
- * @return string
- */
- public function serialize($payload)
- {
- $serialized = '';
- foreach ($payload as $line) {
- $serialized .= '"' . implode('","', $line) . '"' . "\n";
- }
- return $serialized;
- }
-}
-
-\Httpful\Httpful::register('text/csv', new SimpleCsvHandler());
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/examples/showclix.php b/app/library/Poniverse/httpful/examples/showclix.php
deleted file mode 100644
index 9c50bf5f..00000000
--- a/app/library/Poniverse/httpful/examples/showclix.php
+++ /dev/null
@@ -1,24 +0,0 @@
-expectsType('json')
- ->sendIt();
-
-// Print out the event details
-echo "The event {$response->body->event} will take place on {$response->body->event_start}\n";
-
-// Example overriding the default JSON handler with one that encodes the response as an array
-\Httpful\Httpful::register(\Httpful\Mime::JSON, new \Httpful\Handlers\JsonHandler(array('decode_as_array' => true)));
-
-$response = Request::get($uri)
- ->expectsType('json')
- ->sendIt();
-
-// Print out the event details
-echo "The event {$response->body['event']} will take place on {$response->body['event_start']}\n";
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/src/Httpful/Bootstrap.php b/app/library/Poniverse/httpful/src/Httpful/Bootstrap.php
deleted file mode 100644
index 3bf62ae6..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Bootstrap.php
+++ /dev/null
@@ -1,97 +0,0 @@
-
- */
-class Bootstrap
-{
-
- const DIR_GLUE = DIRECTORY_SEPARATOR;
- const NS_GLUE = '\\';
-
- public static $registered = false;
-
- /**
- * Register the autoloader and any other setup needed
- */
- public static function init()
- {
- spl_autoload_register(array('\Httpful\Bootstrap', 'autoload'));
- self::registerHandlers();
- }
-
- /**
- * The autoload magic (PSR-0 style)
- *
- * @param string $classname
- */
- public static function autoload($classname)
- {
- self::_autoload(dirname(dirname(__FILE__)), $classname);
- }
-
- /**
- * Register the autoloader and any other setup needed
- */
- public static function pharInit()
- {
- spl_autoload_register(array('\Httpful\Bootstrap', 'pharAutoload'));
- self::registerHandlers();
- }
-
- /**
- * Phar specific autoloader
- *
- * @param string $classname
- */
- public static function pharAutoload($classname)
- {
- self::_autoload('phar://httpful.phar', $classname);
- }
-
- /**
- * @param string base
- * @param string classname
- */
- private static function _autoload($base, $classname)
- {
- $parts = explode(self::NS_GLUE, $classname);
- $path = $base . self::DIR_GLUE . implode(self::DIR_GLUE, $parts) . '.php';
-
- if (file_exists($path)) {
- require_once($path);
- }
- }
- /**
- * Register default mime handlers. Is idempotent.
- */
- public static function registerHandlers()
- {
- if (self::$registered === true) {
- return;
- }
-
- // @todo check a conf file to load from that instead of
- // hardcoding into the library?
- $handlers = array(
- \Httpful\Mime::JSON => new \Httpful\Handlers\JsonHandler(),
- \Httpful\Mime::XML => new \Httpful\Handlers\XmlHandler(),
- \Httpful\Mime::FORM => new \Httpful\Handlers\FormHandler(),
- \Httpful\Mime::CSV => new \Httpful\Handlers\CsvHandler(),
- );
-
- foreach ($handlers as $mime => $handler) {
- // Don't overwrite if the handler has already been registered
- if (Httpful::hasParserRegistered($mime))
- continue;
- Httpful::register($mime, $handler);
- }
-
- self::$registered = true;
- }
-}
diff --git a/app/library/Poniverse/httpful/src/Httpful/Exception/ConnectionErrorException.php b/app/library/Poniverse/httpful/src/Httpful/Exception/ConnectionErrorException.php
deleted file mode 100644
index bba73a69..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Exception/ConnectionErrorException.php
+++ /dev/null
@@ -1,7 +0,0 @@
-
- */
-
-namespace Httpful\Handlers;
-
-class CsvHandler extends MimeHandlerAdapter
-{
- /**
- * @param string $body
- * @return mixed
- */
- public function parse($body)
- {
- if (empty($body))
- return null;
-
- $parsed = array();
- $fp = fopen('data://text/plain;base64,' . base64_encode($body), 'r');
- while (($r = fgetcsv($fp)) !== FALSE) {
- $parsed[] = $r;
- }
-
- if (empty($parsed))
- throw new \Exception("Unable to parse response as CSV");
- return $parsed;
- }
-
- /**
- * @param mixed $payload
- * @return string
- */
- public function serialize($payload)
- {
- $fp = fopen('php://temp/maxmemory:'. (6*1024*1024), 'r+');
- $i = 0;
- foreach ($payload as $fields) {
- if($i++ == 0) {
- fputcsv($fp, array_keys($fields));
- }
- fputcsv($fp, $fields);
- }
- rewind($fp);
- $data = stream_get_contents($fp);
- fclose($fp);
- return $data;
- }
-}
diff --git a/app/library/Poniverse/httpful/src/Httpful/Handlers/FormHandler.php b/app/library/Poniverse/httpful/src/Httpful/Handlers/FormHandler.php
deleted file mode 100644
index fea1c37c..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Handlers/FormHandler.php
+++ /dev/null
@@ -1,30 +0,0 @@
-
- */
-
-namespace Httpful\Handlers;
-
-class FormHandler extends MimeHandlerAdapter
-{
- /**
- * @param string $body
- * @return mixed
- */
- public function parse($body)
- {
- $parsed = array();
- parse_str($body, $parsed);
- return $parsed;
- }
-
- /**
- * @param mixed $payload
- * @return string
- */
- public function serialize($payload)
- {
- return http_build_query($payload, null, '&');
- }
-}
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/src/Httpful/Handlers/JsonHandler.php b/app/library/Poniverse/httpful/src/Httpful/Handlers/JsonHandler.php
deleted file mode 100644
index 6520d933..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Handlers/JsonHandler.php
+++ /dev/null
@@ -1,40 +0,0 @@
-
- */
-
-namespace Httpful\Handlers;
-
-class JsonHandler extends MimeHandlerAdapter
-{
- private $decode_as_array = false;
-
- public function init(array $args)
- {
- $this->decode_as_array = !!(array_key_exists('decode_as_array', $args) ? $args['decode_as_array'] : false);
- }
-
- /**
- * @param string $body
- * @return mixed
- */
- public function parse($body)
- {
- if (empty($body))
- return null;
- $parsed = json_decode($body, $this->decode_as_array);
- if (is_null($parsed))
- throw new \Exception("Unable to parse response as JSON");
- return $parsed;
- }
-
- /**
- * @param mixed $payload
- * @return string
- */
- public function serialize($payload)
- {
- return json_encode($payload);
- }
-}
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/src/Httpful/Handlers/MimeHandlerAdapter.php b/app/library/Poniverse/httpful/src/Httpful/Handlers/MimeHandlerAdapter.php
deleted file mode 100644
index dd15c04c..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Handlers/MimeHandlerAdapter.php
+++ /dev/null
@@ -1,43 +0,0 @@
-init($args);
- }
-
- /**
- * Initial setup of
- * @param array $args
- */
- public function init(array $args)
- {
- }
-
- /**
- * @param string $body
- * @return mixed
- */
- public function parse($body)
- {
- return $body;
- }
-
- /**
- * @param mixed $payload
- * @return string
- */
- function serialize($payload)
- {
- return (string) $payload;
- }
-}
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/src/Httpful/Handlers/README.md b/app/library/Poniverse/httpful/src/Httpful/Handlers/README.md
deleted file mode 100644
index 5542d406..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Handlers/README.md
+++ /dev/null
@@ -1,44 +0,0 @@
-# Handlers
-
-Handlers are simple classes that are used to parse response bodies and serialize request payloads. All Handlers must extend the `MimeHandlerAdapter` class and implement two methods: `serialize($payload)` and `parse($response)`. Let's build a very basic Handler to register for the `text/csv` mime type.
-
-
- */
-
-namespace Httpful\Handlers;
-
-class XHtmlHandler extends MimeHandlerAdapter
-{
- // @todo add html specific parsing
- // see DomDocument::load http://docs.php.net/manual/en/domdocument.loadhtml.php
-}
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/src/Httpful/Handlers/XmlHandler.php b/app/library/Poniverse/httpful/src/Httpful/Handlers/XmlHandler.php
deleted file mode 100644
index 4b11659b..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Handlers/XmlHandler.php
+++ /dev/null
@@ -1,120 +0,0 @@
-
- * @author Nathan Good
- */
-
-namespace Httpful\Handlers;
-
-class XmlHandler extends MimeHandlerAdapter
-{
- /**
- * @var string $namespace xml namespace to use with simple_load_string
- */
- private $namespace;
-
- /**
- * @var int $libxml_opts see http://www.php.net/manual/en/libxml.constants.php
- */
- private $libxml_opts;
-
- /**
- * @param array $conf sets configuration options
- */
- public function __construct(array $conf = array())
- {
- $this->namespace = isset($conf['namespace']) ? $conf['namespace'] : '';
- $this->libxml_opts = isset($conf['libxml_opts']) ? $conf['libxml_opts'] : 0;
- }
-
- /**
- * @param string $body
- * @return mixed
- * @throws Exception if unable to parse
- */
- public function parse($body)
- {
- if (empty($body))
- return null;
- $parsed = simplexml_load_string($body, null, $this->libxml_opts, $this->namespace);
- if ($parsed === false)
- throw new \Exception("Unable to parse response as XML");
- return $parsed;
- }
-
- /**
- * @param mixed $payload
- * @return string
- * @throws Exception if unable to serialize
- */
- public function serialize($payload)
- {
- list($_, $dom) = $this->_future_serializeAsXml($payload);
- return $dom->saveXml();
- }
-
- /**
- * @author Zack Douglas
- */
- private function _future_serializeAsXml($value, $node = null, $dom = null)
- {
- if (!$dom) {
- $dom = new \DOMDocument;
- }
- if (!$node) {
- if (!is_object($value)) {
- $node = $dom->createElement('response');
- $dom->appendChild($node);
- } else {
- $node = $dom;
- }
- }
- if (is_object($value)) {
- $objNode = $dom->createElement(get_class($value));
- $node->appendChild($objNode);
- $this->_future_serializeObjectAsXml($value, $objNode, $dom);
- } else if (is_array($value)) {
- $arrNode = $dom->createElement('array');
- $node->appendChild($arrNode);
- $this->_future_serializeArrayAsXml($value, $arrNode, $dom);
- } else if (is_bool($value)) {
- $node->appendChild($dom->createTextNode($value?'TRUE':'FALSE'));
- } else {
- $node->appendChild($dom->createTextNode($value));
- }
- return array($node, $dom);
- }
- /**
- * @author Zack Douglas
- */
- private function _future_serializeArrayAsXml($value, &$parent, &$dom)
- {
- foreach ($value as $k => &$v) {
- $n = $k;
- if (is_numeric($k)) {
- $n = "child-{$n}";
- }
- $el = $dom->createElement($n);
- $parent->appendChild($el);
- $this->_future_serializeAsXml($v, $el, $dom);
- }
- return array($parent, $dom);
- }
- /**
- * @author Zack Douglas
- */
- private function _future_serializeObjectAsXml($value, &$parent, &$dom)
- {
- $refl = new \ReflectionObject($value);
- foreach ($refl->getProperties() as $pr) {
- if (!$pr->isPrivate()) {
- $el = $dom->createElement($pr->getName());
- $parent->appendChild($el);
- $this->_future_serializeAsXml($pr->getValue($value), $el, $dom);
- }
- }
- return array($parent, $dom);
- }
-}
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/src/Httpful/Http.php b/app/library/Poniverse/httpful/src/Httpful/Http.php
deleted file mode 100644
index 59374e93..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Http.php
+++ /dev/null
@@ -1,86 +0,0 @@
-
- */
-class Http
-{
- const HEAD = 'HEAD';
- const GET = 'GET';
- const POST = 'POST';
- const PUT = 'PUT';
- const DELETE = 'DELETE';
- const PATCH = 'PATCH';
- const OPTIONS = 'OPTIONS';
- const TRACE = 'TRACE';
-
- /**
- * @return array of HTTP method strings
- */
- public static function safeMethods()
- {
- return array(self::HEAD, self::GET, self::OPTIONS, self::TRACE);
- }
-
- /**
- * @return bool
- * @param string HTTP method
- */
- public static function isSafeMethod($method)
- {
- return in_array($method, self::safeMethods());
- }
-
- /**
- * @return bool
- * @param string HTTP method
- */
- public static function isUnsafeMethod($method)
- {
- return !in_array($method, self::safeMethods());
- }
-
- /**
- * @return array list of (always) idempotent HTTP methods
- */
- public static function idempotentMethods()
- {
- // Though it is possible to be idempotent, POST
- // is not guarunteed to be, and more often than
- // not, it is not.
- return array(self::HEAD, self::GET, self::PUT, self::DELETE, self::OPTIONS, self::TRACE, self::PATCH);
- }
-
- /**
- * @return bool
- * @param string HTTP method
- */
- public static function isIdempotent($method)
- {
- return in_array($method, self::safeidempotentMethodsMethods());
- }
-
- /**
- * @return bool
- * @param string HTTP method
- */
- public static function isNotIdempotent($method)
- {
- return !in_array($method, self::idempotentMethods());
- }
-
- /**
- * @deprecated Technically anything *can* have a body,
- * they just don't have semantic meaning. So say's Roy
- * http://tech.groups.yahoo.com/group/rest-discuss/message/9962
- *
- * @return array of HTTP method strings
- */
- public static function canHaveBody()
- {
- return array(self::POST, self::PUT, self::PATCH, self::OPTIONS);
- }
-
-}
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/src/Httpful/Httpful.php b/app/library/Poniverse/httpful/src/Httpful/Httpful.php
deleted file mode 100644
index 98cd75a9..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Httpful.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
- */
-class Mime
-{
- const JSON = 'application/json';
- const XML = 'application/xml';
- const XHTML = 'application/html+xml';
- const FORM = 'application/x-www-form-urlencoded';
- const PLAIN = 'text/plain';
- const JS = 'text/javascript';
- const HTML = 'text/html';
- const YAML = 'application/x-yaml';
- const CSV = 'text/csv';
-
- /**
- * Map short name for a mime type
- * to a full proper mime type
- */
- public static $mimes = array(
- 'json' => self::JSON,
- 'xml' => self::XML,
- 'form' => self::FORM,
- 'plain' => self::PLAIN,
- 'text' => self::PLAIN,
- 'html' => self::HTML,
- 'xhtml' => self::XHTML,
- 'js' => self::JS,
- 'javascript'=> self::JS,
- 'yaml' => self::YAML,
- 'csv' => self::CSV,
- );
-
- /**
- * Get the full Mime Type name from a "short name".
- * Returns the short if no mapping was found.
- * @return string full mime type (e.g. application/json)
- * @param string common name for mime type (e.g. json)
- */
- public static function getFullMime($short_name)
- {
- return array_key_exists($short_name, self::$mimes) ? self::$mimes[$short_name] : $short_name;
- }
-
- /**
- * @return bool
- * @param string $short_name
- */
- public static function supportsMimeType($short_name)
- {
- return array_key_exists($short_name, self::$mimes);
- }
-}
diff --git a/app/library/Poniverse/httpful/src/Httpful/Request.php b/app/library/Poniverse/httpful/src/Httpful/Request.php
deleted file mode 100644
index 63b92ecb..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Request.php
+++ /dev/null
@@ -1,1023 +0,0 @@
-
- */
-class Request
-{
-
- // Option constants
- const SERIALIZE_PAYLOAD_NEVER = 0;
- const SERIALIZE_PAYLOAD_ALWAYS = 1;
- const SERIALIZE_PAYLOAD_SMART = 2;
-
- const MAX_REDIRECTS_DEFAULT = 25;
-
- public $uri,
- $method = Http::GET,
- $headers = array(),
- $raw_headers = '',
- $strict_ssl = false,
- $content_type,
- $expected_type,
- $additional_curl_opts = array(),
- $auto_parse = true,
- $serialize_payload_method = self::SERIALIZE_PAYLOAD_SMART,
- $username,
- $password,
- $serialized_payload,
- $payload,
- $parse_callback,
- $error_callback,
- $follow_redirects = false,
- $max_redirects = self::MAX_REDIRECTS_DEFAULT,
- $payload_serializers = array();
-
- // Options
- // private $_options = array(
- // 'serialize_payload_method' => self::SERIALIZE_PAYLOAD_SMART
- // 'auto_parse' => true
- // );
-
- // Curl Handle
- public $_ch,
- $_debug;
-
- // Template Request object
- private static $_template;
-
- /**
- * We made the constructor private to force the factory style. This was
- * done to keep the syntax cleaner and better the support the idea of
- * "default templates". Very basic and flexible as it is only intended
- * for internal use.
- * @param array $attrs hash of initial attribute values
- */
- private function __construct($attrs = null)
- {
- if (!is_array($attrs)) return;
- foreach ($attrs as $attr => $value) {
- $this->$attr = $value;
- }
- }
-
- // Defaults Management
-
- /**
- * Let's you configure default settings for this
- * class from a template Request object. Simply construct a
- * Request object as much as you want to and then pass it to
- * this method. It will then lock in those settings from
- * that template object.
- * The most common of which may be default mime
- * settings or strict ssl settings.
- * Again some slight memory overhead incurred here but in the grand
- * scheme of things as it typically only occurs once
- * @param Request $template
- */
- public static function ini(Request $template)
- {
- self::$_template = clone $template;
- }
-
- /**
- * Reset the default template back to the
- * library defaults.
- */
- public static function resetIni()
- {
- self::_initializeDefaults();
- }
-
- /**
- * Get default for a value based on the template object
- * @return mixed default value
- * @param string|null $attr Name of attribute (e.g. mime, headers)
- * if null just return the whole template object;
- */
- public static function d($attr)
- {
- return isset($attr) ? self::$_template->$attr : self::$_template;
- }
-
- // Accessors
-
- /**
- * @return bool does the request have a timeout?
- */
- public function hasTimeout()
- {
- return isset($this->timeout);
- }
-
- /**
- * @return bool has the internal curl request been initialized?
- */
- public function hasBeenInitialized()
- {
- return isset($this->_ch);
- }
-
- /**
- * @return bool Is this request setup for basic auth?
- */
- public function hasBasicAuth()
- {
- return isset($this->password) && isset($this->username);
- }
-
- /**
- * @return bool Is this request setup for digest auth?
- */
- public function hasDigestAuth()
- {
- return isset($this->password) && isset($this->username) && $this->additional_curl_opts[CURLOPT_HTTPAUTH] == CURLAUTH_DIGEST;
- }
-
- /**
- * Specify a HTTP timeout
- * @return Request $this
- * @param |int $timeout seconds to timeout the HTTP call
- */
- public function timeout($timeout)
- {
- $this->timeout = $timeout;
- return $this;
- }
-
- // alias timeout
- public function timeoutIn($seconds)
- {
- return $this->timeout($seconds);
- }
-
- /**
- * If the response is a 301 or 302 redirect, automatically
- * send off another request to that location
- * @return Request $this
- * @param bool|int $follow follow or not to follow or maximal number of redirects
- */
- public function followRedirects($follow = true)
- {
- $this->max_redirects = $follow === true ? self::MAX_REDIRECTS_DEFAULT : max(0, $follow);
- $this->follow_redirects = (bool) $follow;
- return $this;
- }
-
- /**
- * @return Request $this
- * @see Request::followRedirects()
- */
- public function doNotFollowRedirects()
- {
- return $this->followRedirects(false);
- }
-
- /**
- * Actually send off the request, and parse the response
- * @return string|associative array of parsed results
- * @throws ConnectionErrorException when unable to parse or communicate w server
- */
- public function send()
- {
- if (!$this->hasBeenInitialized())
- $this->_curlPrep();
-
- $result = curl_exec($this->_ch);
-
- if ($result === false) {
- $this->_error(curl_error($this->_ch));
- throw new ConnectionErrorException('Unable to connect.');
- }
-
- $info = curl_getinfo($this->_ch);
- $response = explode("\r\n\r\n", $result, 2 + $info['redirect_count']);
-
- $body = array_pop($response);
- $headers = array_pop($response);
-
- return new Response($body, $headers, $this);
- }
- public function sendIt()
- {
- return $this->send();
- }
-
- // Setters
-
- /**
- * @return Request this
- * @param string $uri
- */
- public function uri($uri)
- {
- $this->uri = $uri;
- return $this;
- }
-
- /**
- * User Basic Auth.
- * Only use when over SSL/TSL/HTTPS.
- * @return Request this
- * @param string $username
- * @param string $password
- */
- public function basicAuth($username, $password)
- {
- $this->username = $username;
- $this->password = $password;
- return $this;
- }
- // @alias of basicAuth
- public function authenticateWith($username, $password)
- {
- return $this->basicAuth($username, $password);
- }
- // @alias of basicAuth
- public function authenticateWithBasic($username, $password)
- {
- return $this->basicAuth($username, $password);
- }
-
- /**
- * User Digest Auth.
- * @return Request this
- * @param string $username
- * @param string $password
- */
- public function digestAuth($username, $password)
- {
- $this->addOnCurlOption(CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
- return $this->basicAuth($username, $password);
- }
-
- // @alias of digestAuth
- public function authenticateWithDigest($username, $password)
- {
- return $this->digestAuth($username, $password);
- }
-
- /**
- * @return is this request setup for client side cert?
- */
- public function hasClientSideCert() {
- return isset($this->client_cert) && isset($this->client_key);
- }
-
- /**
- * Use Client Side Cert Authentication
- * @return Request $this
- * @param string $key file path to client key
- * @param string $cert file path to client cert
- * @param string $passphrase for client key
- * @param string $encoding default PEM
- */
- public function clientSideCert($cert, $key, $passphrase = null, $encoding = 'PEM')
- {
- $this->client_cert = $cert;
- $this->client_key = $key;
- $this->client_passphrase = $passphrase;
- $this->client_encoding = $encoding;
-
- return $this;
- }
- // @alias of basicAuth
- public function authenticateWithCert($cert, $key, $passphrase = null, $encoding = 'PEM')
- {
- return $this->clientSideCert($cert, $key, $passphrase, $encoding);
- }
-
- /**
- * Set the body of the request
- * @return Request this
- * @param mixed $payload
- * @param string $mimeType
- */
- public function body($payload, $mimeType = null)
- {
- $this->mime($mimeType);
- $this->payload = $payload;
- // Iserntentially don't call _serializePayload yet. Wait until
- // we actually send off the request to convert payload to string.
- // At that time, the `serialized_payload` is set accordingly.
- return $this;
- }
-
- /**
- * Helper function to set the Content type and Expected as same in
- * one swoop
- * @return Request this
- * @param string $mime mime type to use for content type and expected return type
- */
- public function mime($mime)
- {
- if (empty($mime)) return $this;
- $this->content_type = $this->expected_type = Mime::getFullMime($mime);
- return $this;
- }
- // @alias of mime
- public function sendsAndExpectsType($mime)
- {
- return $this->mime($mime);
- }
- // @alias of mime
- public function sendsAndExpects($mime)
- {
- return $this->mime($mime);
- }
-
- /**
- * Set the method. Shouldn't be called often as the preferred syntax
- * for instantiation is the method specific factory methods.
- * @return Request this
- * @param string $method
- */
- public function method($method)
- {
- if (empty($method)) return $this;
- $this->method = $method;
- return $this;
- }
-
- /**
- * @return Request this
- * @param string $mime
- */
- public function expects($mime)
- {
- if (empty($mime)) return $this;
- $this->expected_type = Mime::getFullMime($mime);
- return $this;
- }
- // @alias of expects
- public function expectsType($mime)
- {
- return $this->expects($mime);
- }
-
- /**
- * @return Request this
- * @param string $mime
- */
- public function contentType($mime)
- {
- if (empty($mime)) return $this;
- $this->content_type = Mime::getFullMime($mime);
- return $this;
- }
- // @alias of contentType
- public function sends($mime)
- {
- return $this->contentType($mime);
- }
- // @alias of contentType
- public function sendsType($mime)
- {
- return $this->contentType($mime);
- }
-
- /**
- * Do we strictly enforce SSL verification?
- * @return Request this
- * @param bool $strict
- */
- public function strictSSL($strict)
- {
- $this->strict_ssl = $strict;
- return $this;
- }
- public function withoutStrictSSL()
- {
- return $this->strictSSL(false);
- }
- public function withStrictSSL()
- {
- return $this->strictSSL(true);
- }
-
- /**
- * Use proxy configuration
- * @return Request this
- * @param string $proxy_host Hostname or address of the proxy
- * @param number $proxy_port Port of the proxy. Default 80
- * @param string $auth_type Authentication type or null. Accepted values are CURLAUTH_BASIC, CURLAUTH_NTLM. Default null, no authentication
- * @param string $auth_username Authentication username. Default null
- * @param string $auth_password Authentication password. Default null
- */
- public function useProxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null){
- $this->addOnCurlOption(CURLOPT_PROXY, "{$proxy_host}:{$proxy_port}");
- if(in_array($auth_type, array(CURLAUTH_BASIC,CURLAUTH_NTLM)) ){
- $this->addOnCurlOption(CURLOPT_PROXYAUTH, $auth_type)
- ->addOnCurlOption(CURLOPT_PROXYUSERPWD, "{$auth_username}:{$auth_password}");
- }
- return $this;
- }
-
- /**
- * @return is this request setup for using proxy?
- */
- public function hasProxy(){
- return is_string($this->additional_curl_opts[CURLOPT_PROXY]);
- }
-
- /**
- * Determine how/if we use the built in serialization by
- * setting the serialize_payload_method
- * The default (SERIALIZE_PAYLOAD_SMART) is...
- * - if payload is not a scalar (object/array)
- * use the appropriate serialize method according to
- * the Content-Type of this request.
- * - if the payload IS a scalar (int, float, string, bool)
- * than just return it as is.
- * When this option is set SERIALIZE_PAYLOAD_ALWAYS,
- * it will always use the appropriate
- * serialize option regardless of whether payload is scalar or not
- * When this option is set SERIALIZE_PAYLOAD_NEVER,
- * it will never use any of the serialization methods.
- * Really the only use for this is if you want the serialize methods
- * to handle strings or not (e.g. Blah is not valid JSON, but "Blah"
- * is). Forcing the serialization helps prevent that kind of error from
- * happening.
- * @return Request $this
- * @param int $mode
- */
- public function serializePayload($mode)
- {
- $this->serialize_payload_method = $mode;
- return $this;
- }
-
- /**
- * @see Request::serializePayload()
- * @return Request
- */
- public function neverSerializePayload()
- {
- return $this->serializePayload(self::SERIALIZE_PAYLOAD_NEVER);
- }
-
- /**
- * This method is the default behavior
- * @see Request::serializePayload()
- * @return Request
- */
- public function smartSerializePayload()
- {
- return $this->serializePayload(self::SERIALIZE_PAYLOAD_SMART);
- }
-
- /**
- * @see Request::serializePayload()
- * @return Request
- */
- public function alwaysSerializePayload()
- {
- return $this->serializePayload(self::SERIALIZE_PAYLOAD_ALWAYS);
- }
-
- /**
- * Add an additional header to the request
- * Can also use the cleaner syntax of
- * $Request->withMyHeaderName($my_value);
- * @see Request::__call()
- *
- * @return Request this
- * @param string $header_name
- * @param string $value
- */
- public function addHeader($header_name, $value)
- {
- $this->headers[$header_name] = $value;
- return $this;
- }
-
- /**
- * Add group of headers all at once. Note: This is
- * here just as a convenience in very specific cases.
- * The preferred "readable" way would be to leverage
- * the support for custom header methods.
- * @return Response $this
- * @param array $headers
- */
- public function addHeaders(array $headers)
- {
- foreach ($headers as $header => $value) {
- $this->addHeader($header, $value);
- }
- return $this;
- }
-
- /**
- * @return Request
- * @param bool $auto_parse perform automatic "smart"
- * parsing based on Content-Type or "expectedType"
- * If not auto parsing, Response->body returns the body
- * as a string.
- */
- public function autoParse($auto_parse = true)
- {
- $this->auto_parse = $auto_parse;
- return $this;
- }
-
- /**
- * @see Request::autoParse()
- * @return Request
- */
- public function withoutAutoParsing()
- {
- return $this->autoParse(false);
- }
-
- /**
- * @see Request::autoParse()
- * @return Request
- */
- public function withAutoParsing()
- {
- return $this->autoParse(true);
- }
-
- /**
- * Use a custom function to parse the response.
- * @return Request this
- * @param \Closure $callback Takes the raw body of
- * the http response and returns a mixed
- */
- public function parseWith(\Closure $callback)
- {
- $this->parse_callback = $callback;
- return $this;
- }
-
- /**
- * @see Request::parseResponsesWith()
- * @return Request $this
- * @param \Closure $callback
- */
- public function parseResponsesWith(\Closure $callback)
- {
- return $this->parseWith($callback);
- }
-
- /**
- * Register a callback that will be used to serialize the payload
- * for a particular mime type. When using "*" for the mime
- * type, it will use that parser for all responses regardless of the mime
- * type. If a custom '*' and 'application/json' exist, the custom
- * 'application/json' would take precedence over the '*' callback.
- *
- * @return Request $this
- * @param string $mime mime type we're registering
- * @param Closure $callback takes one argument, $payload,
- * which is the payload that we'll be
- */
- public function registerPayloadSerializer($mime, \Closure $callback)
- {
- $this->payload_serializers[Mime::getFullMime($mime)] = $callback;
- return $this;
- }
-
- /**
- * @see Request::registerPayloadSerializer()
- * @return Request $this
- * @param Closure $callback
- */
- public function serializePayloadWith(\Closure $callback)
- {
- return $this->regregisterPayloadSerializer('*', $callback);
- }
-
- /**
- * Magic method allows for neatly setting other headers in a
- * similar syntax as the other setters. This method also allows
- * for the sends* syntax.
- * @return Request this
- * @param string $method "missing" method name called
- * the method name called should be the name of the header that you
- * are trying to set in camel case without dashes e.g. to set a
- * header for Content-Type you would use contentType() or more commonly
- * to add a custom header like X-My-Header, you would use xMyHeader().
- * To promote readability, you can optionally prefix these methods with
- * "with" (e.g. withXMyHeader("blah") instead of xMyHeader("blah")).
- * @param array $args in this case, there should only ever be 1 argument provided
- * and that argument should be a string value of the header we're setting
- */
- public function __call($method, $args)
- {
- // This method supports the sends* methods
- // like sendsJSON, sendsForm
- //!method_exists($this, $method) &&
- if (substr($method, 0, 5) === 'sends') {
- $mime = strtolower(substr($method, 5));
- if (Mime::supportsMimeType($mime)) {
- $this->sends(Mime::getFullMime($mime));
- return $this;
- }
- // else {
- // throw new \Exception("Unsupported Content-Type $mime");
- // }
- }
- if (substr($method, 0, 7) === 'expects') {
- $mime = strtolower(substr($method, 7));
- if (Mime::supportsMimeType($mime)) {
- $this->expects(Mime::getFullMime($mime));
- return $this;
- }
- // else {
- // throw new \Exception("Unsupported Content-Type $mime");
- // }
- }
-
- // This method also adds the custom header support as described in the
- // method comments
- if (count($args) === 0)
- return;
-
- // Strip the sugar. If it leads with "with", strip.
- // This is okay because: No defined HTTP headers begin with with,
- // and if you are defining a custom header, the standard is to prefix it
- // with an "X-", so that should take care of any collisions.
- if (substr($method, 0, 4) === 'with')
- $method = substr($method, 4);
-
- // Precede upper case letters with dashes, uppercase the first letter of method
- $header = ucwords(implode('-', preg_split('/([A-Z][^A-Z]*)/', $method, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY)));
- $this->addHeader($header, $args[0]);
- return $this;
- }
-
- // Internal Functions
-
- /**
- * This is the default template to use if no
- * template has been provided. The template
- * tells the class which default values to use.
- * While there is a slight overhead for object
- * creation once per execution (not once per
- * Request instantiation), it promotes readability
- * and flexibility within the class.
- */
- private static function _initializeDefaults()
- {
- // This is the only place you will
- // see this constructor syntax. It
- // is only done here to prevent infinite
- // recusion. Do not use this syntax elsewhere.
- // It goes against the whole readability
- // and transparency idea.
- self::$_template = new Request(array('method' => Http::GET));
-
- // This is more like it...
- self::$_template
- ->withoutStrictSSL();
- }
-
- /**
- * Set the defaults on a newly instantiated object
- * Doesn't copy variables prefixed with _
- * @return Request this
- */
- private function _setDefaults()
- {
- if (!isset(self::$_template))
- self::_initializeDefaults();
- foreach (self::$_template as $k=>$v) {
- if ($k[0] != '_')
- $this->$k = $v;
- }
- return $this;
- }
-
- private function _error($error)
- {
- // Default actions write to error log
- // TODO add in support for various Loggers
- error_log($error);
- }
-
- /**
- * Factory style constructor works nicer for chaining. This
- * should also really only be used internally. The Request::get,
- * Request::post syntax is preferred as it is more readable.
- * @return Request
- * @param string $method Http Method
- * @param string $mime Mime Type to Use
- */
- public static function init($method = null, $mime = null)
- {
- // Setup our handlers, can call it here as it's idempotent
- Bootstrap::init();
-
- // Setup the default template if need be
- if (!isset(self::$_template))
- self::_initializeDefaults();
-
- $request = new Request();
- return $request
- ->_setDefaults()
- ->method($method)
- ->sendsType($mime)
- ->expectsType($mime);
- }
-
- /**
- * Does the heavy lifting. Uses de facto HTTP
- * library cURL to set up the HTTP request.
- * Note: It does NOT actually send the request
- * @return Request $this;
- */
- public function _curlPrep()
- {
- // Check for required stuff
- if (!isset($this->uri))
- throw new \Exception('Attempting to send a request before defining a URI endpoint.');
-
- $ch = curl_init($this->uri);
-
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->method);
-
- if ($this->hasBasicAuth()) {
- curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password);
- }
-
- if ($this->hasClientSideCert()) {
-
- if (!file_exists($this->client_key))
- throw new \Exception('Could not read Client Key');
-
- if (!file_exists($this->client_cert))
- throw new \Exception('Could not read Client Certificate');
-
- curl_setopt($ch, CURLOPT_SSLCERTTYPE, $this->client_encoding);
- curl_setopt($ch, CURLOPT_SSLKEYTYPE, $this->client_encoding);
- curl_setopt($ch, CURLOPT_SSLCERT, $this->client_cert);
- curl_setopt($ch, CURLOPT_SSLKEY, $this->client_key);
- curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $this->client_passphrase);
- // curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $this->client_cert_passphrase);
- }
-
- if ($this->hasTimeout()) {
- curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
- }
-
- if ($this->follow_redirects) {
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_MAXREDIRS, $this->max_redirects);
- }
-
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->strict_ssl);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
- // https://github.com/nategood/httpful/issues/84
- // set Content-Length to the size of the payload if present
- if (isset($this->payload)) {
- $this->serialized_payload = $this->_serializePayload($this->payload);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $this->serialized_payload);
- $this->headers['Content-Length'] = strlen($this->serialized_payload);
- }
-
- $headers = array();
- // https://github.com/nategood/httpful/issues/37
- // Except header removes any HTTP 1.1 Continue from response headers
- $headers[] = 'Expect:';
-
- if (!isset($this->headers['User-Agent'])) {
- $headers[] = $this->buildUserAgent();
- }
-
- $headers[] = "Content-Type: {$this->content_type}";
-
- // allow custom Accept header if set
- if (!isset($this->headers['Accept'])) {
- // http://pretty-rfc.herokuapp.com/RFC2616#header.accept
- $accept = 'Accept: */*; q=0.5, text/plain; q=0.8, text/html;level=3;';
-
- if (!empty($this->expected_type)) {
- $accept .= "q=0.9, {$this->expected_type}";
- }
-
- $headers[] = $accept;
- }
-
- // Solve a bug on squid proxy, NONE/411 when miss content length
- if (!isset($this->headers['Content-Length'])) {
- $this->headers['Content-Length'] = 0;
- }
-
- foreach ($this->headers as $header => $value) {
- $headers[] = "$header: $value";
- }
-
- $url = \parse_url($this->uri);
- $path = (isset($url['path']) ? $url['path'] : '/').(isset($url['query']) ? '?'.$url['query'] : '');
- $this->raw_headers = "{$this->method} $path HTTP/1.1\r\n";
- $host = (isset($url['host']) ? $url['host'] : 'localhost').(isset($url['port']) ? ':'.$url['port'] : '');
- $this->raw_headers .= "Host: $host\r\n";
- $this->raw_headers .= \implode("\r\n", $headers);
- $this->raw_headers .= "\r\n";
-
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
-
- if ($this->_debug) {
- curl_setopt($ch, CURLOPT_VERBOSE, true);
- }
-
- curl_setopt($ch, CURLOPT_HEADER, 1);
-
- // If there are some additional curl opts that the user wants
- // to set, we can tack them in here
- foreach ($this->additional_curl_opts as $curlopt => $curlval) {
- curl_setopt($ch, $curlopt, $curlval);
- }
-
- $this->_ch = $ch;
-
- return $this;
- }
-
- public function buildUserAgent() {
- $user_agent = 'User-Agent: Httpful/' . Httpful::VERSION . ' (cURL/';
- $curl = \curl_version();
-
- if (isset($curl['version'])) {
- $user_agent .= $curl['version'];
- } else {
- $user_agent .= '?.?.?';
- }
-
- $user_agent .= ' PHP/'. PHP_VERSION . ' (' . PHP_OS . ')';
-
- if (isset($_SERVER['SERVER_SOFTWARE'])) {
- $user_agent .= ' ' . \preg_replace('~PHP/[\d\.]+~U', '',
- $_SERVER['SERVER_SOFTWARE']);
- } else {
- if (isset($_SERVER['TERM_PROGRAM'])) {
- $user_agent .= " {$_SERVER['TERM_PROGRAM']}";
- }
-
- if (isset($_SERVER['TERM_PROGRAM_VERSION'])) {
- $user_agent .= "/{$_SERVER['TERM_PROGRAM_VERSION']}";
- }
- }
-
- if (isset($_SERVER['HTTP_USER_AGENT'])) {
- $user_agent .= " {$_SERVER['HTTP_USER_AGENT']}";
- }
-
- $user_agent .= ')';
-
- return $user_agent;
- }
-
- /**
- * Semi-reluctantly added this as a way to add in curl opts
- * that are not otherwise accessible from the rest of the API.
- * @return Request $this
- * @param string $curlopt
- * @param mixed $curloptval
- */
- public function addOnCurlOption($curlopt, $curloptval)
- {
- $this->additional_curl_opts[$curlopt] = $curloptval;
- return $this;
- }
-
- /**
- * Turn payload from structured data into
- * a string based on the current Mime type.
- * This uses the auto_serialize option to determine
- * it's course of action. See serialize method for more.
- * Renamed from _detectPayload to _serializePayload as of
- * 2012-02-15.
- *
- * Added in support for custom payload serializers.
- * The serialize_payload_method stuff still holds true though.
- * @see Request::registerPayloadSerializer()
- *
- * @return string
- * @param mixed $payload
- */
- private function _serializePayload($payload)
- {
- if (empty($payload) || $this->serialize_payload_method === self::SERIALIZE_PAYLOAD_NEVER)
- return $payload;
-
- // When we are in "smart" mode, don't serialize strings/scalars, assume they are already serialized
- if ($this->serialize_payload_method === self::SERIALIZE_PAYLOAD_SMART && is_scalar($payload))
- return $payload;
-
- // Use a custom serializer if one is registered for this mime type
- if (isset($this->payload_serializers['*']) || isset($this->payload_serializers[$this->content_type])) {
- $key = isset($this->payload_serializers[$this->content_type]) ? $this->content_type : '*';
- return call_user_func($this->payload_serializers[$key], $payload);
- }
-
- return Httpful::get($this->content_type)->serialize($payload);
- }
-
- /**
- * HTTP Method Get
- * @return Request
- * @param string $uri optional uri to use
- * @param string $mime expected
- */
- public static function get($uri, $mime = null)
- {
- return self::init(Http::GET)->uri($uri)->mime($mime);
- }
-
-
- /**
- * Like Request:::get, except that it sends off the request as well
- * returning a response
- * @return Response
- * @param string $uri optional uri to use
- * @param string $mime expected
- */
- public static function getQuick($uri, $mime = null)
- {
- return self::get($uri, $mime)->send();
- }
-
- /**
- * HTTP Method Post
- * @return Request
- * @param string $uri optional uri to use
- * @param string $payload data to send in body of request
- * @param string $mime MIME to use for Content-Type
- */
- public static function post($uri, $payload = null, $mime = null)
- {
- return self::init(Http::POST)->uri($uri)->body($payload, $mime);
- }
-
- /**
- * HTTP Method Put
- * @return Request
- * @param string $uri optional uri to use
- * @param string $payload data to send in body of request
- * @param string $mime MIME to use for Content-Type
- */
- public static function put($uri, $payload = null, $mime = null)
- {
- return self::init(Http::PUT)->uri($uri)->body($payload, $mime);
- }
-
- /**
- * HTTP Method Patch
- * @return Request
- * @param string $uri optional uri to use
- * @param string $payload data to send in body of request
- * @param string $mime MIME to use for Content-Type
- */
- public static function patch($uri, $payload = null, $mime = null)
- {
- return self::init(Http::PATCH)->uri($uri)->body($payload, $mime);
- }
-
- /**
- * HTTP Method Delete
- * @return Request
- * @param string $uri optional uri to use
- */
- public static function delete($uri, $mime = null)
- {
- return self::init(Http::DELETE)->uri($uri)->mime($mime);
- }
-
- /**
- * HTTP Method Head
- * @return Request
- * @param string $uri optional uri to use
- */
- public static function head($uri)
- {
- return self::init(Http::HEAD)->uri($uri);
- }
-
- /**
- * HTTP Method Options
- * @return Request
- * @param string $uri optional uri to use
- */
- public static function options($uri)
- {
- return self::init(Http::OPTIONS)->uri($uri);
- }
-}
diff --git a/app/library/Poniverse/httpful/src/Httpful/Response.php b/app/library/Poniverse/httpful/src/Httpful/Response.php
deleted file mode 100644
index c5199d3e..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Response.php
+++ /dev/null
@@ -1,189 +0,0 @@
-
- */
-class Response
-{
-
- public $body,
- $raw_body,
- $headers,
- $raw_headers,
- $request,
- $code = 0,
- $content_type,
- $parent_type,
- $charset,
- $is_mime_vendor_specific = false,
- $is_mime_personal = false;
-
- private $parsers;
- /**
- * @param string $body
- * @param string $headers
- * @param Request $request
- */
- public function __construct($body, $headers, Request $request)
- {
- $this->request = $request;
- $this->raw_headers = $headers;
- $this->raw_body = $body;
-
- $this->code = $this->_parseCode($headers);
- $this->headers = Response\Headers::fromString($headers);
-
- $this->_interpretHeaders();
-
- $this->body = $this->_parse($body);
- }
-
- /**
- * Status Code Definitions
- *
- * Informational 1xx
- * Successful 2xx
- * Redirection 3xx
- * Client Error 4xx
- * Server Error 5xx
- *
- * http://pretty-rfc.herokuapp.com/RFC2616#status.codes
- *
- * @return bool Did we receive a 4xx or 5xx?
- */
- public function hasErrors()
- {
- return $this->code >= 400;
- }
-
- /**
- * @return return bool
- */
- public function hasBody()
- {
- return !empty($this->body);
- }
-
- /**
- * Parse the response into a clean data structure
- * (most often an associative array) based on the expected
- * Mime type.
- * @return array|string|object the response parse accordingly
- * @param string Http response body
- */
- public function _parse($body)
- {
- // If the user decided to forgo the automatic
- // smart parsing, short circuit.
- if (!$this->request->auto_parse) {
- return $body;
- }
-
- // If provided, use custom parsing callback
- if (isset($this->request->parse_callback)) {
- return call_user_func($this->request->parse_callback, $body);
- }
-
- // Decide how to parse the body of the response in the following order
- // 1. If provided, use the mime type specifically set as part of the `Request`
- // 2. If a MimeHandler is registered for the content type, use it
- // 3. If provided, use the "parent type" of the mime type from the response
- // 4. Default to the content-type provided in the response
- $parse_with = $this->request->expected_type;
- if (empty($this->request->expected_type)) {
- $parse_with = Httpful::hasParserRegistered($this->content_type)
- ? $this->content_type
- : $this->parent_type;
- }
-
- return Httpful::get($parse_with)->parse($body);
- }
-
- /**
- * Parse text headers from response into
- * array of key value pairs
- * @return array parse headers
- * @param string $headers raw headers
- */
- public function _parseHeaders($headers)
- {
- $headers = preg_split("/(\r|\n)+/", $headers, -1, \PREG_SPLIT_NO_EMPTY);
- $parse_headers = array();
- for ($i = 1; $i < count($headers); $i++) {
- list($key, $raw_value) = explode(':', $headers[$i], 2);
- $key = trim($key);
- $value = trim($raw_value);
- if (array_key_exists($key, $parse_headers)) {
- // See HTTP RFC Sec 4.2 Paragraph 5
- // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
- // If a header appears more than once, it must also be able to
- // be represented as a single header with a comma-separated
- // list of values. We transform accordingly.
- $parse_headers[$key] .= ',' . $value;
- } else {
- $parse_headers[$key] = $value;
- }
- }
- return $parse_headers;
- }
-
- public function _parseCode($headers)
- {
- $parts = explode(' ', substr($headers, 0, strpos($headers, "\r\n")));
- if (count($parts) < 2 || !is_numeric($parts[1])) {
- throw new \Exception("Unable to parse response code from HTTP response due to malformed response");
- }
- return intval($parts[1]);
- }
-
- /**
- * After we've parse the headers, let's clean things
- * up a bit and treat some headers specially
- */
- public function _interpretHeaders()
- {
- // Parse the Content-Type and charset
- $content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : '';
- $content_type = explode(';', $content_type);
-
- $this->content_type = $content_type[0];
- if (count($content_type) == 2 && strpos($content_type[1], '=') !== false) {
- list($nill, $this->charset) = explode('=', $content_type[1]);
- }
-
- // RFC 2616 states "text/*" Content-Types should have a default
- // charset of ISO-8859-1. "application/*" and other Content-Types
- // are assumed to have UTF-8 unless otherwise specified.
- // http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1
- // http://www.w3.org/International/O-HTTP-charset.en.php
- if (!isset($this->charset)) {
- $this->charset = substr($this->content_type, 5) === 'text/' ? 'iso-8859-1' : 'utf-8';
- }
-
- // Is vendor type? Is personal type?
- if (strpos($this->content_type, '/') !== false) {
- list($type, $sub_type) = explode('/', $this->content_type);
- $this->is_mime_vendor_specific = substr($sub_type, 0, 4) === 'vnd.';
- $this->is_mime_personal = substr($sub_type, 0, 4) === 'prs.';
- }
-
- // Parent type (e.g. xml for application/vnd.github.message+xml)
- $this->parent_type = $this->content_type;
- if (strpos($this->content_type, '+') !== false) {
- list($vendor, $this->parent_type) = explode('+', $this->content_type, 2);
- $this->parent_type = Mime::getFullMime($this->parent_type);
- }
- }
-
- /**
- * @return string
- */
- public function __toString()
- {
- return $this->raw_body;
- }
-}
diff --git a/app/library/Poniverse/httpful/src/Httpful/Response/Headers.php b/app/library/Poniverse/httpful/src/Httpful/Response/Headers.php
deleted file mode 100644
index 7abc57dd..00000000
--- a/app/library/Poniverse/httpful/src/Httpful/Response/Headers.php
+++ /dev/null
@@ -1,58 +0,0 @@
-headers = $headers;
- }
-
- public static function fromString($string)
- {
- $lines = preg_split("/(\r|\n)+/", $string, -1, PREG_SPLIT_NO_EMPTY);
- array_shift($lines); // HTTP HEADER
- $headers = array();
- foreach ($lines as $line) {
- list($name, $value) = explode(':', $line, 2);
- $headers[strtolower(trim($name))] = trim($value);
- }
- return new self($headers);
- }
-
- public function offsetExists($offset)
- {
- return isset($this->headers[strtolower($offset)]);
- }
-
- public function offsetGet($offset)
- {
- if (isset($this->headers[$name = strtolower($offset)])) {
- return $this->headers[$name];
- }
- }
-
- public function offsetSet($offset, $value)
- {
- throw new \Exception("Headers are read-only.");
- }
-
- public function offsetUnset($offset)
- {
- throw new \Exception("Headers are read-only.");
- }
-
- public function count()
- {
- return count($this->headers);
- }
-
- public function toArray()
- {
- return $this->headers;
- }
-
-}
\ No newline at end of file
diff --git a/app/library/Poniverse/httpful/tests/Httpful/HttpfulTest.php b/app/library/Poniverse/httpful/tests/Httpful/HttpfulTest.php
deleted file mode 100644
index ac2ab546..00000000
--- a/app/library/Poniverse/httpful/tests/Httpful/HttpfulTest.php
+++ /dev/null
@@ -1,458 +0,0 @@
-
- */
-namespace Httpful\Test;
-
-require(dirname(dirname(dirname(__FILE__))) . '/bootstrap.php');
-\Httpful\Bootstrap::init();
-
-use Httpful\Httpful;
-use Httpful\Request;
-use Httpful\Mime;
-use Httpful\Http;
-use Httpful\Response;
-
-class HttpfulTest extends \PHPUnit_Framework_TestCase
-{
- const TEST_SERVER = '127.0.0.1:8008';
- const TEST_URL = 'http://127.0.0.1:8008';
- const TEST_URL_400 = 'http://127.0.0.1:8008/400';
-
- const SAMPLE_JSON_HEADER =
-"HTTP/1.1 200 OK
-Content-Type: application/json
-Connection: keep-alive
-Transfer-Encoding: chunked\r\n";
- const SAMPLE_JSON_RESPONSE = '{"key":"value","object":{"key":"value"},"array":[1,2,3,4]}';
- const SAMPLE_CSV_HEADER =
-"HTTP/1.1 200 OK
-Content-Type: text/csv
-Connection: keep-alive
-Transfer-Encoding: chunked\r\n";
- const SAMPLE_CSV_RESPONSE =
-"Key1,Key2
-Value1,Value2
-\"40.0\",\"Forty\"";
- const SAMPLE_XML_RESPONSE = '2a stringTRUE';
- const SAMPLE_XML_HEADER =
-"HTTP/1.1 200 OK
-Content-Type: application/xml
-Connection: keep-alive
-Transfer-Encoding: chunked\r\n";
- const SAMPLE_VENDOR_HEADER =
-"HTTP/1.1 200 OK
-Content-Type: application/vnd.nategood.message+xml
-Connection: keep-alive
-Transfer-Encoding: chunked\r\n";
- const SAMPLE_VENDOR_TYPE = "application/vnd.nategood.message+xml";
- const SAMPLE_MULTI_HEADER =
-"HTTP/1.1 200 OK
-Content-Type: application/json
-Connection: keep-alive
-Transfer-Encoding: chunked
-X-My-Header:Value1
-X-My-Header:Value2\r\n";
- function testInit()
- {
- $r = Request::init();
- // Did we get a 'Request' object?
- $this->assertEquals('Httpful\Request', get_class($r));
- }
-
- function testMethods()
- {
- $valid_methods = array('get', 'post', 'delete', 'put', 'options', 'head');
- $url = 'http://example.com/';
- foreach ($valid_methods as $method) {
- $r = call_user_func(array('Httpful\Request', $method), $url);
- $this->assertEquals('Httpful\Request', get_class($r));
- $this->assertEquals(strtoupper($method), $r->method);
- }
- }
-
- function testDefaults()
- {
- // Our current defaults are as follows
- $r = Request::init();
- $this->assertEquals(Http::GET, $r->method);
- $this->assertFalse($r->strict_ssl);
- }
-
- function testShortMime()
- {
- // Valid short ones
- $this->assertEquals(Mime::JSON, Mime::getFullMime('json'));
- $this->assertEquals(Mime::XML, Mime::getFullMime('xml'));
- $this->assertEquals(Mime::HTML, Mime::getFullMime('html'));
- $this->assertEquals(Mime::CSV, Mime::getFullMime('csv'));
-
- // Valid long ones
- $this->assertEquals(Mime::JSON, Mime::getFullMime(Mime::JSON));
- $this->assertEquals(Mime::XML, Mime::getFullMime(Mime::XML));
- $this->assertEquals(Mime::HTML, Mime::getFullMime(Mime::HTML));
- $this->assertEquals(Mime::CSV, Mime::getFullMime(Mime::CSV));
-
- // No false positives
- $this->assertNotEquals(Mime::XML, Mime::getFullMime(Mime::HTML));
- $this->assertNotEquals(Mime::JSON, Mime::getFullMime(Mime::XML));
- $this->assertNotEquals(Mime::HTML, Mime::getFullMime(Mime::JSON));
- $this->assertNotEquals(Mime::XML, Mime::getFullMime(Mime::CSV));
- }
-
- function testSettingStrictSsl()
- {
- $r = Request::init()
- ->withStrictSsl();
-
- $this->assertTrue($r->strict_ssl);
-
- $r = Request::init()
- ->withoutStrictSsl();
-
- $this->assertFalse($r->strict_ssl);
- }
-
- function testSendsAndExpectsType()
- {
- $r = Request::init()
- ->sendsAndExpectsType(Mime::JSON);
- $this->assertEquals(Mime::JSON, $r->expected_type);
- $this->assertEquals(Mime::JSON, $r->content_type);
-
- $r = Request::init()
- ->sendsAndExpectsType('html');
- $this->assertEquals(Mime::HTML, $r->expected_type);
- $this->assertEquals(Mime::HTML, $r->content_type);
-
- $r = Request::init()
- ->sendsAndExpectsType('form');
- $this->assertEquals(Mime::FORM, $r->expected_type);
- $this->assertEquals(Mime::FORM, $r->content_type);
-
- $r = Request::init()
- ->sendsAndExpectsType('application/x-www-form-urlencoded');
- $this->assertEquals(Mime::FORM, $r->expected_type);
- $this->assertEquals(Mime::FORM, $r->content_type);
-
- $r = Request::init()
- ->sendsAndExpectsType(Mime::CSV);
- $this->assertEquals(Mime::CSV, $r->expected_type);
- $this->assertEquals(Mime::CSV, $r->content_type);
- }
-
- function testIni()
- {
- // Test setting defaults/templates
-
- // Create the template
- $template = Request::init()
- ->method(Http::POST)
- ->withStrictSsl()
- ->expectsType(Mime::HTML)
- ->sendsType(Mime::FORM);
-
- Request::ini($template);
-
- $r = Request::init();
-
- $this->assertTrue($r->strict_ssl);
- $this->assertEquals(Http::POST, $r->method);
- $this->assertEquals(Mime::HTML, $r->expected_type);
- $this->assertEquals(Mime::FORM, $r->content_type);
-
- // Test the default accessor as well
- $this->assertTrue(Request::d('strict_ssl'));
- $this->assertEquals(Http::POST, Request::d('method'));
- $this->assertEquals(Mime::HTML, Request::d('expected_type'));
- $this->assertEquals(Mime::FORM, Request::d('content_type'));
-
- Request::resetIni();
- }
-
- function testAccept()
- {
- $r = Request::get('http://example.com/')
- ->expectsType(Mime::JSON);
-
- $this->assertEquals(Mime::JSON, $r->expected_type);
- $r->_curlPrep();
- $this->assertContains('application/json', $r->raw_headers);
- }
-
- function testCustomAccept()
- {
- $accept = 'application/api-1.0+json';
- $r = Request::get('http://example.com/')
- ->addHeader('Accept', $accept);
-
- $r->_curlPrep();
- $this->assertContains($accept, $r->raw_headers);
- $this->assertEquals($accept, $r->headers['Accept']);
- }
-
- function testUserAgent()
- {
- $r = Request::get('http://example.com/')
- ->withUserAgent('ACME/1.2.3');
-
- $this->assertArrayHasKey('User-Agent', $r->headers);
- $r->_curlPrep();
- $this->assertContains('User-Agent: ACME/1.2.3', $r->raw_headers);
- $this->assertNotContains('User-Agent: HttpFul/1.0', $r->raw_headers);
-
- $r = Request::get('http://example.com/')
- ->withUserAgent('');
-
- $this->assertArrayHasKey('User-Agent', $r->headers);
- $r->_curlPrep();
- $this->assertContains('User-Agent:', $r->raw_headers);
- $this->assertNotContains('User-Agent: HttpFul/1.0', $r->raw_headers);
- }
-
- function testAuthSetup()
- {
- $username = 'nathan';
- $password = 'opensesame';
-
- $r = Request::get('http://example.com/')
- ->authenticateWith($username, $password);
-
- $this->assertEquals($username, $r->username);
- $this->assertEquals($password, $r->password);
- $this->assertTrue($r->hasBasicAuth());
- }
-
- function testDigestAuthSetup()
- {
- $username = 'nathan';
- $password = 'opensesame';
-
- $r = Request::get('http://example.com/')
- ->authenticateWithDigest($username, $password);
-
- $this->assertEquals($username, $r->username);
- $this->assertEquals($password, $r->password);
- $this->assertTrue($r->hasDigestAuth());
- }
-
- function testJsonResponseParse()
- {
- $req = Request::init()->sendsAndExpects(Mime::JSON);
- $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
-
- $this->assertEquals("value", $response->body->key);
- $this->assertEquals("value", $response->body->object->key);
- $this->assertInternalType('array', $response->body->array);
- $this->assertEquals(1, $response->body->array[0]);
- }
-
- function testXMLResponseParse()
- {
- $req = Request::init()->sendsAndExpects(Mime::XML);
- $response = new Response(self::SAMPLE_XML_RESPONSE, self::SAMPLE_XML_HEADER, $req);
- $sxe = $response->body;
- $this->assertEquals("object", gettype($sxe));
- $this->assertEquals("SimpleXMLElement", get_class($sxe));
- $bools = $sxe->xpath('/stdClass/boolProp');
- list( , $bool ) = each($bools);
- $this->assertEquals("TRUE", (string) $bool);
- $ints = $sxe->xpath('/stdClass/arrayProp/array/k1/myClass/intProp');
- list( , $int ) = each($ints);
- $this->assertEquals("2", (string) $int);
- $strings = $sxe->xpath('/stdClass/stringProp');
- list( , $string ) = each($strings);
- $this->assertEquals("a string", (string) $string);
- }
-
- function testCsvResponseParse()
- {
- $req = Request::init()->sendsAndExpects(Mime::CSV);
- $response = new Response(self::SAMPLE_CSV_RESPONSE, self::SAMPLE_CSV_HEADER, $req);
-
- $this->assertEquals("Key1", $response->body[0][0]);
- $this->assertEquals("Value1", $response->body[1][0]);
- $this->assertInternalType('string', $response->body[2][0]);
- $this->assertEquals("40.0", $response->body[2][0]);
- }
-
- function testParsingContentTypeCharset()
- {
- $req = Request::init()->sendsAndExpects(Mime::JSON);
- // $response = new Response(SAMPLE_JSON_RESPONSE, "", $req);
- // // Check default content type of iso-8859-1
- $response = new Response(self::SAMPLE_JSON_RESPONSE, "HTTP/1.1 200 OK
-Content-Type: text/plain; charset=utf-8\r\n", $req);
- $this->assertInstanceOf('Httpful\Response\Headers', $response->headers);
- $this->assertEquals($response->headers['Content-Type'], 'text/plain; charset=utf-8');
- $this->assertEquals($response->content_type, 'text/plain');
- $this->assertEquals($response->charset, 'utf-8');
- }
-
- function testEmptyResponseParse()
- {
- $req = Request::init()->sendsAndExpects(Mime::JSON);
- $response = new Response("", self::SAMPLE_JSON_HEADER, $req);
- $this->assertEquals(null, $response->body);
-
- $reqXml = Request::init()->sendsAndExpects(Mime::XML);
- $responseXml = new Response("", self::SAMPLE_XML_HEADER, $reqXml);
- $this->assertEquals(null, $responseXml->body);
- }
-
- function testNoAutoParse()
- {
- $req = Request::init()->sendsAndExpects(Mime::JSON)->withoutAutoParsing();
- $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $this->assertInternalType('string', $response->body);
- $req = Request::init()->sendsAndExpects(Mime::JSON)->withAutoParsing();
- $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $this->assertInternalType('object', $response->body);
- }
-
- function testParseHeaders()
- {
- $req = Request::init()->sendsAndExpects(Mime::JSON);
- $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $this->assertEquals('application/json', $response->headers['Content-Type']);
- }
-
- function testRawHeaders()
- {
- $req = Request::init()->sendsAndExpects(Mime::JSON);
- $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $this->assertContains('Content-Type: application/json', $response->raw_headers);
- }
-
- function testHasErrors()
- {
- $req = Request::init()->sendsAndExpects(Mime::JSON);
- $response = new Response('', "HTTP/1.1 100 Continue\r\n", $req);
- $this->assertFalse($response->hasErrors());
- $response = new Response('', "HTTP/1.1 200 OK\r\n", $req);
- $this->assertFalse($response->hasErrors());
- $response = new Response('', "HTTP/1.1 300 Multiple Choices\r\n", $req);
- $this->assertFalse($response->hasErrors());
- $response = new Response('', "HTTP/1.1 400 Bad Request\r\n", $req);
- $this->assertTrue($response->hasErrors());
- $response = new Response('', "HTTP/1.1 500 Internal Server Error\r\n", $req);
- $this->assertTrue($response->hasErrors());
- }
-
- function test_parseCode()
- {
- $req = Request::init()->sendsAndExpects(Mime::JSON);
- $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $code = $response->_parseCode("HTTP/1.1 406 Not Acceptable\r\n");
- $this->assertEquals(406, $code);
- }
-
- function testToString()
- {
- $req = Request::init()->sendsAndExpects(Mime::JSON);
- $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $this->assertEquals(self::SAMPLE_JSON_RESPONSE, (string)$response);
- }
-
- function test_parseHeaders()
- {
- $parse_headers = Response\Headers::fromString(self::SAMPLE_JSON_HEADER);
- $this->assertCount(3, $parse_headers);
- $this->assertEquals('application/json', $parse_headers['Content-Type']);
- $this->assertTrue(isset($parse_headers['Connection']));
- }
-
- function testMultiHeaders()
- {
- $req = Request::init();
- $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_MULTI_HEADER, $req);
- $parse_headers = $response->_parseHeaders(self::SAMPLE_MULTI_HEADER);
- $this->assertEquals('Value1,Value2', $parse_headers['X-My-Header']);
- }
-
- function testDetectContentType()
- {
- $req = Request::init();
- $response = new Response(self::SAMPLE_JSON_RESPONSE, self::SAMPLE_JSON_HEADER, $req);
- $this->assertEquals('application/json', $response->headers['Content-Type']);
- }
-
- function testMissingBodyContentType()
- {
- $body = 'A string';
- $request = Request::post(HttpfulTest::TEST_URL, $body)->_curlPrep();
- $this->assertEquals($body, $request->serialized_payload);
- }
-
- function testParentType()
- {
- // Parent type
- $request = Request::init()->sendsAndExpects(Mime::XML);
- $response = new Response('Nathan', self::SAMPLE_VENDOR_HEADER, $request);
-
- $this->assertEquals("application/xml", $response->parent_type);
- $this->assertEquals(self::SAMPLE_VENDOR_TYPE, $response->content_type);
- $this->assertTrue($response->is_mime_vendor_specific);
-
- // Make sure we still parsed as if it were plain old XML
- $this->assertEquals("Nathan", $response->body->name->__toString());
- }
-
- function testMissingContentType()
- {
- // Parent type
- $request = Request::init()->sendsAndExpects(Mime::XML);
- $response = new Response('Nathan',
-"HTTP/1.1 200 OK
-Connection: keep-alive
-Transfer-Encoding: chunked\r\n", $request);
-
- $this->assertEquals("", $response->content_type);
- }
-
- function testCustomMimeRegistering()
- {
- // Register new mime type handler for "application/vnd.nategood.message+xml"
- Httpful::register(self::SAMPLE_VENDOR_TYPE, new DemoMimeHandler());
-
- $this->assertTrue(Httpful::hasParserRegistered(self::SAMPLE_VENDOR_TYPE));
-
- $request = Request::init();
- $response = new Response('Nathan', self::SAMPLE_VENDOR_HEADER, $request);
-
- $this->assertEquals(self::SAMPLE_VENDOR_TYPE, $response->content_type);
- $this->assertEquals('custom parse', $response->body);
- }
-
- public function testShorthandMimeDefinition()
- {
- $r = Request::init()->expects('json');
- $this->assertEquals(Mime::JSON, $r->expected_type);
-
- $r = Request::init()->expectsJson();
- $this->assertEquals(Mime::JSON, $r->expected_type);
- }
-
- public function testOverrideXmlHandler()
- {
- // Lazy test...
- $prev = \Httpful\Httpful::get(\Httpful\Mime::XML);
- $this->assertEquals($prev, new \Httpful\Handlers\XmlHandler());
- $conf = array('namespace' => 'http://example.com');
- \Httpful\Httpful::register(\Httpful\Mime::XML, new \Httpful\Handlers\XmlHandler($conf));
- $new = \Httpful\Httpful::get(\Httpful\Mime::XML);
- $this->assertNotEquals($prev, $new);
- }
-}
-
-class DemoMimeHandler extends \Httpful\Handlers\MimeHandlerAdapter {
- public function parse($body) {
- return 'custom parse';
- }
-}
-
diff --git a/app/library/Poniverse/httpful/tests/phpunit.xml b/app/library/Poniverse/httpful/tests/phpunit.xml
deleted file mode 100644
index 8f62e80a..00000000
--- a/app/library/Poniverse/httpful/tests/phpunit.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- .
-
-
-
-
-
-
diff --git a/app/library/Poniverse/oauth2/Client.php b/app/library/Poniverse/oauth2/Client.php
deleted file mode 100644
index 698739fc..00000000
--- a/app/library/Poniverse/oauth2/Client.php
+++ /dev/null
@@ -1,515 +0,0 @@
-
- * @author Anis Berejeb
- * @version 1.2-dev
- */
-namespace OAuth2;
-
-class Client
-{
- /**
- * Different AUTH method
- */
- const AUTH_TYPE_URI = 0;
- const AUTH_TYPE_AUTHORIZATION_BASIC = 1;
- const AUTH_TYPE_FORM = 2;
-
- /**
- * Different Access token type
- */
- const ACCESS_TOKEN_URI = 0;
- const ACCESS_TOKEN_BEARER = 1;
- const ACCESS_TOKEN_OAUTH = 2;
- const ACCESS_TOKEN_MAC = 3;
-
- /**
- * Different Grant types
- */
- const GRANT_TYPE_AUTH_CODE = 'authorization_code';
- const GRANT_TYPE_PASSWORD = 'password';
- const GRANT_TYPE_CLIENT_CREDENTIALS = 'client_credentials';
- const GRANT_TYPE_REFRESH_TOKEN = 'refresh_token';
-
- /**
- * HTTP Methods
- */
- const HTTP_METHOD_GET = 'GET';
- const HTTP_METHOD_POST = 'POST';
- const HTTP_METHOD_PUT = 'PUT';
- const HTTP_METHOD_DELETE = 'DELETE';
- const HTTP_METHOD_HEAD = 'HEAD';
- const HTTP_METHOD_PATCH = 'PATCH';
-
- /**
- * HTTP Form content types
- */
- const HTTP_FORM_CONTENT_TYPE_APPLICATION = 0;
- const HTTP_FORM_CONTENT_TYPE_MULTIPART = 1;
-
- /**
- * Client ID
- *
- * @var string
- */
- protected $client_id = null;
-
- /**
- * Client Secret
- *
- * @var string
- */
- protected $client_secret = null;
-
- /**
- * Client Authentication method
- *
- * @var int
- */
- protected $client_auth = self::AUTH_TYPE_URI;
-
- /**
- * Access Token
- *
- * @var string
- */
- protected $access_token = null;
-
- /**
- * Access Token Type
- *
- * @var int
- */
- protected $access_token_type = self::ACCESS_TOKEN_URI;
-
- /**
- * Access Token Secret
- *
- * @var string
- */
- protected $access_token_secret = null;
-
- /**
- * Access Token crypt algorithm
- *
- * @var string
- */
- protected $access_token_algorithm = null;
-
- /**
- * Access Token Parameter name
- *
- * @var string
- */
- protected $access_token_param_name = 'access_token';
-
- /**
- * The path to the certificate file to use for https connections
- *
- * @var string Defaults to .
- */
- protected $certificate_file = null;
-
- /**
- * cURL options
- *
- * @var array
- */
- protected $curl_options = array();
-
- /**
- * Construct
- *
- * @param string $client_id Client ID
- * @param string $client_secret Client Secret
- * @param int $client_auth (AUTH_TYPE_URI, AUTH_TYPE_AUTHORIZATION_BASIC, AUTH_TYPE_FORM)
- * @param string $certificate_file Indicates if we want to use a certificate file to trust the server. Optional, defaults to null.
- * @return void
- */
- public function __construct($client_id, $client_secret, $client_auth = self::AUTH_TYPE_URI, $certificate_file = null)
- {
- if (!extension_loaded('curl')) {
- throw new Exception('The PHP exention curl must be installed to use this library.', Exception::CURL_NOT_FOUND);
- }
-
- $this->client_id = $client_id;
- $this->client_secret = $client_secret;
- $this->client_auth = $client_auth;
- $this->certificate_file = $certificate_file;
- if (!empty($this->certificate_file) && !is_file($this->certificate_file)) {
- throw new InvalidArgumentException('The certificate file was not found', InvalidArgumentException::CERTIFICATE_NOT_FOUND);
- }
- }
-
- /**
- * Get the client Id
- *
- * @return string Client ID
- */
- public function getClientId()
- {
- return $this->client_id;
- }
-
- /**
- * Get the client Secret
- *
- * @return string Client Secret
- */
- public function getClientSecret()
- {
- return $this->client_secret;
- }
-
- /**
- * getAuthenticationUrl
- *
- * @param string $auth_endpoint Url of the authentication endpoint
- * @param string $redirect_uri Redirection URI
- * @param array $extra_parameters Array of extra parameters like scope or state (Ex: array('scope' => null, 'state' => ''))
- * @return string URL used for authentication
- */
- public function getAuthenticationUrl($auth_endpoint, $redirect_uri, array $extra_parameters = array())
- {
- $parameters = array_merge(array(
- 'response_type' => 'code',
- 'client_id' => $this->client_id,
- 'redirect_uri' => $redirect_uri
- ), $extra_parameters);
- return $auth_endpoint . '?' . http_build_query($parameters, null, '&');
- }
-
- /**
- * getAccessToken
- *
- * @param string $token_endpoint Url of the token endpoint
- * @param int $grant_type Grant Type ('authorization_code', 'password', 'client_credentials', 'refresh_token', or a custom code (@see GrantType Classes)
- * @param array $parameters Array sent to the server (depend on which grant type you're using)
- * @return array Array of parameters required by the grant_type (CF SPEC)
- */
- public function getAccessToken($token_endpoint, $grant_type, array $parameters)
- {
- if (!$grant_type) {
- throw new InvalidArgumentException('The grant_type is mandatory.', InvalidArgumentException::INVALID_GRANT_TYPE);
- }
- $grantTypeClassName = $this->convertToCamelCase($grant_type);
- $grantTypeClass = __NAMESPACE__ . '\\GrantType\\' . $grantTypeClassName;
- if (!class_exists($grantTypeClass)) {
- throw new InvalidArgumentException('Unknown grant type \'' . $grant_type . '\'', InvalidArgumentException::INVALID_GRANT_TYPE);
- }
- $grantTypeObject = new $grantTypeClass();
- $grantTypeObject->validateParameters($parameters);
- if (!defined($grantTypeClass . '::GRANT_TYPE')) {
- throw new Exception('Unknown constant GRANT_TYPE for class ' . $grantTypeClassName, Exception::GRANT_TYPE_ERROR);
- }
- $parameters['grant_type'] = $grantTypeClass::GRANT_TYPE;
- $http_headers = array();
- switch ($this->client_auth) {
- case self::AUTH_TYPE_URI:
- case self::AUTH_TYPE_FORM:
- $parameters['client_id'] = $this->client_id;
- $parameters['client_secret'] = $this->client_secret;
- break;
- case self::AUTH_TYPE_AUTHORIZATION_BASIC:
- $parameters['client_id'] = $this->client_id;
- $http_headers['Authorization'] = 'Basic ' . base64_encode($this->client_id . ':' . $this->client_secret);
- break;
- default:
- throw new Exception('Unknown client auth type.', Exception::INVALID_CLIENT_AUTHENTICATION_TYPE);
- break;
- }
-
- return $this->executeRequest($token_endpoint, $parameters, self::HTTP_METHOD_POST, $http_headers, self::HTTP_FORM_CONTENT_TYPE_APPLICATION);
- }
-
- /**
- * setToken
- *
- * @param string $token Set the access token
- * @return void
- */
- public function setAccessToken($token)
- {
- $this->access_token = $token;
- }
-
- /**
- * Set the client authentication type
- *
- * @param string $client_auth (AUTH_TYPE_URI, AUTH_TYPE_AUTHORIZATION_BASIC, AUTH_TYPE_FORM)
- * @return void
- */
- public function setClientAuthType($client_auth)
- {
- $this->client_auth = $client_auth;
- }
-
- /**
- * Set an option for the curl transfer
- *
- * @param int $option The CURLOPT_XXX option to set
- * @param mixed $value The value to be set on option
- * @return void
- */
- public function setCurlOption($option, $value)
- {
- $this->curl_options[$option] = $value;
- }
-
- /**
- * Set multiple options for a cURL transfer
- *
- * @param array $options An array specifying which options to set and their values
- * @return void
- */
- public function setCurlOptions($options)
- {
- $this->curl_options = array_merge($this->curl_options, $options);
- }
-
- /**
- * Set the access token type
- *
- * @param int $type Access token type (ACCESS_TOKEN_BEARER, ACCESS_TOKEN_MAC, ACCESS_TOKEN_URI)
- * @param string $secret The secret key used to encrypt the MAC header
- * @param string $algorithm Algorithm used to encrypt the signature
- * @return void
- */
- public function setAccessTokenType($type, $secret = null, $algorithm = null)
- {
- $this->access_token_type = $type;
- $this->access_token_secret = $secret;
- $this->access_token_algorithm = $algorithm;
- }
-
- /**
- * Fetch a protected ressource
- *
- * @param string $protected_ressource_url Protected resource URL
- * @param array $parameters Array of parameters
- * @param string $http_method HTTP Method to use (POST, PUT, GET, HEAD, DELETE)
- * @param array $http_headers HTTP headers
- * @param int $form_content_type HTTP form content type to use
- * @return array
- */
- public function fetch($protected_resource_url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, array $http_headers = array(), $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
- {
- if ($this->access_token) {
- switch ($this->access_token_type) {
- case self::ACCESS_TOKEN_URI:
- if (is_array($parameters)) {
- $parameters[$this->access_token_param_name] = $this->access_token;
- } else {
- throw new InvalidArgumentException(
- 'You need to give parameters as array if you want to give the token within the URI.',
- InvalidArgumentException::REQUIRE_PARAMS_AS_ARRAY
- );
- }
- break;
- case self::ACCESS_TOKEN_BEARER:
- $http_headers['Authorization'] = 'Bearer ' . $this->access_token;
- break;
- case self::ACCESS_TOKEN_OAUTH:
- $http_headers['Authorization'] = 'OAuth ' . $this->access_token;
- break;
- case self::ACCESS_TOKEN_MAC:
- $http_headers['Authorization'] = 'MAC ' . $this->generateMACSignature($protected_resource_url, $parameters, $http_method);
- break;
- default:
- throw new Exception('Unknown access token type.', Exception::INVALID_ACCESS_TOKEN_TYPE);
- break;
- }
- }
- return $this->executeRequest($protected_resource_url, $parameters, $http_method, $http_headers, $form_content_type);
- }
-
- /**
- * Generate the MAC signature
- *
- * @param string $url Called URL
- * @param array $parameters Parameters
- * @param string $http_method Http Method
- * @return string
- */
- private function generateMACSignature($url, $parameters, $http_method)
- {
- $timestamp = time();
- $nonce = uniqid();
- $parsed_url = parse_url($url);
- if (!isset($parsed_url['port']))
- {
- $parsed_url['port'] = ($parsed_url['scheme'] == 'https') ? 443 : 80;
- }
- if ($http_method == self::HTTP_METHOD_GET) {
- if (is_array($parameters)) {
- $parsed_url['path'] .= '?' . http_build_query($parameters, null, '&');
- } elseif ($parameters) {
- $parsed_url['path'] .= '?' . $parameters;
- }
- }
-
- $signature = base64_encode(hash_hmac($this->access_token_algorithm,
- $timestamp . "\n"
- . $nonce . "\n"
- . $http_method . "\n"
- . $parsed_url['path'] . "\n"
- . $parsed_url['host'] . "\n"
- . $parsed_url['port'] . "\n\n"
- , $this->access_token_secret, true));
-
- return 'id="' . $this->access_token . '", ts="' . $timestamp . '", nonce="' . $nonce . '", mac="' . $signature . '"';
- }
-
- /**
- * Execute a request (with curl)
- *
- * @param string $url URL
- * @param mixed $parameters Array of parameters
- * @param string $http_method HTTP Method
- * @param array $http_headers HTTP Headers
- * @param int $form_content_type HTTP form content type to use
- * @return array
- */
- private function executeRequest($url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, array $http_headers = null, $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
- {
- $curl_options = array(
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_SSL_VERIFYPEER => true,
- CURLOPT_CUSTOMREQUEST => $http_method
- );
-
- switch($http_method) {
- case self::HTTP_METHOD_POST:
- $curl_options[CURLOPT_POST] = true;
- /* No break */
- case self::HTTP_METHOD_PUT:
- case self::HTTP_METHOD_PATCH:
-
- /**
- * Passing an array to CURLOPT_POSTFIELDS will encode the data as multipart/form-data,
- * while passing a URL-encoded string will encode the data as application/x-www-form-urlencoded.
- * http://php.net/manual/en/function.curl-setopt.php
- */
- if(is_array($parameters) && self::HTTP_FORM_CONTENT_TYPE_APPLICATION === $form_content_type) {
- $parameters = http_build_query($parameters, null, '&');
- }
- $curl_options[CURLOPT_POSTFIELDS] = $parameters;
- break;
- case self::HTTP_METHOD_HEAD:
- $curl_options[CURLOPT_NOBODY] = true;
- /* No break */
- case self::HTTP_METHOD_DELETE:
- case self::HTTP_METHOD_GET:
- if (is_array($parameters)) {
- $url .= '?' . http_build_query($parameters, null, '&');
- } elseif ($parameters) {
- $url .= '?' . $parameters;
- }
- break;
- default:
- break;
- }
-
- $curl_options[CURLOPT_URL] = $url;
-
- if (is_array($http_headers)) {
- $header = array();
- foreach($http_headers as $key => $parsed_urlvalue) {
- $header[] = "$key: $parsed_urlvalue";
- }
- $curl_options[CURLOPT_HTTPHEADER] = $header;
- }
-
- $ch = curl_init();
- curl_setopt_array($ch, $curl_options);
- // https handling
- if (!empty($this->certificate_file)) {
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
- curl_setopt($ch, CURLOPT_CAINFO, $this->certificate_file);
- } else {
- // bypass ssl verification
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- }
- if (!empty($this->curl_options)) {
- curl_setopt_array($ch, $this->curl_options);
- }
- $result = curl_exec($ch);
- $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
- if ($curl_error = curl_error($ch)) {
- throw new Exception($curl_error, Exception::CURL_ERROR);
- } else {
- $json_decode = json_decode($result, true);
- }
- curl_close($ch);
-
- return array(
- 'result' => (null === $json_decode) ? $result : $json_decode,
- 'code' => $http_code,
- 'content_type' => $content_type
- );
- }
-
- /**
- * Set the name of the parameter that carry the access token
- *
- * @param string $name Token parameter name
- * @return void
- */
- public function setAccessTokenParamName($name)
- {
- $this->access_token_param_name = $name;
- }
-
- /**
- * Converts the class name to camel case
- *
- * @param mixed $grant_type the grant type
- * @return string
- */
- private function convertToCamelCase($grant_type)
- {
- $parts = explode('_', $grant_type);
- array_walk($parts, function(&$item) { $item = ucfirst($item);});
- return implode('', $parts);
- }
-}
-
-class Exception extends \Exception
-{
- const CURL_NOT_FOUND = 0x01;
- const CURL_ERROR = 0x02;
- const GRANT_TYPE_ERROR = 0x03;
- const INVALID_CLIENT_AUTHENTICATION_TYPE = 0x04;
- const INVALID_ACCESS_TOKEN_TYPE = 0x05;
-}
-
-class InvalidArgumentException extends \InvalidArgumentException
-{
- const INVALID_GRANT_TYPE = 0x01;
- const CERTIFICATE_NOT_FOUND = 0x02;
- const REQUIRE_PARAMS_AS_ARRAY = 0x03;
- const MISSING_PARAMETER = 0x04;
-}
diff --git a/app/library/Poniverse/oauth2/GrantType/AuthorizationCode.php b/app/library/Poniverse/oauth2/GrantType/AuthorizationCode.php
deleted file mode 100644
index f3436e4c..00000000
--- a/app/library/Poniverse/oauth2/GrantType/AuthorizationCode.php
+++ /dev/null
@@ -1,41 +0,0 @@
-getAuthenticationUrl(AUTHORIZATION_ENDPOINT, REDIRECT_URI);
- header('Location: ' . $auth_url);
- die('Redirect');
-}
-else
-{
- $params = array('code' => $_GET['code'], 'redirect_uri' => REDIRECT_URI);
- $response = $client->getAccessToken(TOKEN_ENDPOINT, 'authorization_code', $params);
- parse_str($response['result'], $info);
- $client->setAccessToken($info['access_token']);
- $response = $client->fetch('https://graph.facebook.com/me');
- var_dump($response, $response['result']);
-}
-
-How can I add a new Grant Type ?
-================================
-Simply write a new class in the namespace OAuth2\GrantType. You can place the class file under GrantType.
-Here is an example :
-
-namespace OAuth2\GrantType;
-
-/**
- * MyCustomGrantType Grant Type
- */
-class MyCustomGrantType implements IGrantType
-{
- /**
- * Defines the Grant Type
- *
- * @var string Defaults to 'my_custom_grant_type'.
- */
- const GRANT_TYPE = 'my_custom_grant_type';
-
- /**
- * Adds a specific Handling of the parameters
- *
- * @return array of Specific parameters to be sent.
- * @param mixed $parameters the parameters array (passed by reference)
- */
- public function validateParameters(&$parameters)
- {
- if (!isset($parameters['first_mandatory_parameter']))
- {
- throw new \Exception('The \'first_mandatory_parameter\' parameter must be defined for the Password grant type');
- }
- elseif (!isset($parameters['second_mandatory_parameter']))
- {
- throw new \Exception('The \'seconde_mandatory_parameter\' parameter must be defined for the Password grant type');
- }
- }
-}
-
-call the OAuth client getAccessToken with the grantType you defined in the GRANT_TYPE constant, As following :
-$response = $client->getAccessToken(TOKEN_ENDPOINT, 'my_custom_grant_type', $params);
-
diff --git a/app/library/Poniverse/oauth2/composer.json b/app/library/Poniverse/oauth2/composer.json
deleted file mode 100644
index 2e052a52..00000000
--- a/app/library/Poniverse/oauth2/composer.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "adoy/oauth2",
- "description": "Light PHP wrapper for the OAuth 2.0 protocol (based on OAuth 2.0 Authorization Protocol draft-ietf-oauth-v2-15)",
- "authors": [
- {
- "name": "Charron Pierrick",
- "email": "pierrick@webstart.fr"
- },
- {
- "name": "Berejeb Anis",
- "email": "anis.berejeb@gmail.com"
- }
- ],
- "autoload": {
- "classmap": [
- "../"
- ]
- }
-}
diff --git a/app/library/ZipStream.php b/app/library/ZipStream.php
deleted file mode 100644
index e627efb8..00000000
--- a/app/library/ZipStream.php
+++ /dev/null
@@ -1,573 +0,0 @@
-
- * @copyright 2009-2013 A. Grandt
- * @license GNU LGPL, Attribution required for commercial implementations, requested for everything else.
- * @link http://www.phpclasses.org/package/6116
- * @link https://github.com/Grandt/PHPZip
- * @version 1.37
- */
-class ZipStream {
- const VERSION = 1.37;
-
- const ZIP_LOCAL_FILE_HEADER = "\x50\x4b\x03\x04"; // Local file header signature
- const ZIP_CENTRAL_FILE_HEADER = "\x50\x4b\x01\x02"; // Central file header signature
- const ZIP_END_OF_CENTRAL_DIRECTORY = "\x50\x4b\x05\x06\x00\x00\x00\x00"; //end of Central directory record
-
- const EXT_FILE_ATTR_DIR = "\x10\x00\xFF\x41";
- const EXT_FILE_ATTR_FILE = "\x00\x00\xFF\x81";
-
- const ATTR_VERSION_TO_EXTRACT = "\x14\x00"; // Version needed to extract
- const ATTR_MADE_BY_VERSION = "\x1E\x03"; // Made By Version
-
- private $zipMemoryThreshold = 1048576; // Autocreate tempfile if the zip data exceeds 1048576 bytes (1 MB)
-
- private $zipComment = null;
- private $cdRec = array(); // central directory
- private $offset = 0;
- private $isFinalized = FALSE;
- private $addExtraField = TRUE;
-
- private $streamChunkSize = 16384; // 65536;
- private $streamFilePath = null;
- private $streamTimeStamp = null;
- private $streamComment = null;
- private $streamFile = null;
- private $streamData = null;
- private $streamFileLength = 0;
-
- /**
- * Constructor.
- *
- * @param String $archiveName Name to send to the HTTP client.
- * @param String $contentType Content mime type. Optional, defaults to "application/zip".
- */
- function __construct($archiveName = "", $contentType = "application/zip") {
- if (!function_exists('sys_get_temp_dir')) {
- die ("ERROR: ZipStream " . self::VERSION . " requires PHP version 5.2.1 or above.");
- }
-
- $headerFile = null;
- $headerLine = null;
- if (!headers_sent($headerFile, $headerLine) or die("
Error: Unable to send file $archiveName. HTML Headers have already been sent from $headerFile in line $headerLine
")) {
- if ((ob_get_contents() === FALSE || ob_get_contents() == '') or die("\n
Error: Unable to send file $archiveName.epub. Output buffer contains the following text (typically warnings or errors): " . ob_get_contents() . "
")) {
- if (ini_get('zlib.output_compression')) {
- ini_set('zlib.output_compression', 'Off');
- }
-
- header('Pragma: public');
- header("Last-Modified: " . gmdate("D, d M Y H:i:s T"));
- header("Expires: 0");
- header("Accept-Ranges: bytes");
- //header("Connection: Keep-Alive");
- header("Content-Type: " . $contentType);
- header('Content-Disposition: attachment; filename="' . $archiveName . '";');
- header("Content-Transfer-Encoding: binary");
- flush();
- }
- }
- }
-
- function __destruct() {
- $this->isFinalized = TRUE;
- $this->cdRec = null;
- exit;
- }
-
- /**
- * Extra fields on the Zip directory records are Unix time codes needed for compatibility on the default Mac zip archive tool.
- * These are enabled as default, as they do no harm elsewhere and only add 26 bytes per file added.
- *
- * @param bool $setExtraField TRUE (default) will enable adding of extra fields, anything else will disable it.
- */
- function setExtraField($setExtraField = TRUE) {
- $this->addExtraField = ($setExtraField === TRUE);
- }
-
- /**
- * Set Zip archive comment.
- *
- * @param string $newComment New comment. null to clear.
- * @return bool $success
- */
- public function setComment($newComment = null) {
- if ($this->isFinalized) {
- return FALSE;
- }
- $this->zipComment = $newComment;
-
- return TRUE;
- }
-
- /**
- * Add an empty directory entry to the zip archive.
- * Basically this is only used if an empty directory is added.
- *
- * @param string $directoryPath Directory Path and name to be added to the archive.
- * @param int $timestamp (Optional) Timestamp for the added directory, if omitted or set to 0, the current time will be used.
- * @param string $fileComment (Optional) Comment to be added to the archive for this directory. To use fileComment, timestamp must be given.
- * @return bool $success
- */
- public function addDirectory($directoryPath, $timestamp = 0, $fileComment = null) {
- if ($this->isFinalized) {
- return FALSE;
- }
-
- $directoryPath = str_replace("\\", "/", $directoryPath);
- $directoryPath = rtrim($directoryPath, "/");
-
- if (strlen($directoryPath) > 0) {
- $this->buildZipEntry($directoryPath.'/', $fileComment, "\x00\x00", "\x00\x00", $timestamp, "\x00\x00\x00\x00", 0, 0, self::EXT_FILE_ATTR_DIR);
- return TRUE;
- }
- return FALSE;
- }
-
- /**
- * Add a file to the archive at the specified location and file name.
- *
- * @param string $data File data.
- * @param string $filePath Filepath and name to be used in the archive.
- * @param int $timestamp (Optional) Timestamp for the added file, if omitted or set to 0, the current time will be used.
- * @param string $fileComment (Optional) Comment to be added to the archive for this file. To use fileComment, timestamp must be given.
- * @return bool $success
- */
- public function addFile($data, $filePath, $timestamp = 0, $fileComment = null) {
- if ($this->isFinalized) {
- return FALSE;
- }
-
- if (is_resource($data) && get_resource_type($data) == "stream") {
- $this->addLargeFile($data, $filePath, $timestamp, $fileComment);
- return FALSE;
- }
-
- $gzType = "\x08\x00"; // Compression type 8 = deflate
- $gpFlags = "\x00\x00"; // General Purpose bit flags for compression type 8 it is: 0=Normal, 1=Maximum, 2=Fast, 3=super fast compression.
- $dataLength = strlen($data);
- $fileCRC32 = pack("V", crc32($data));
-
- $gzData = gzcompress($data);
- $gzData = substr(substr($gzData, 0, strlen($gzData) - 4), 2); // gzcompress adds a 2 byte header and 4 byte CRC we can't use.
- // The 2 byte header does contain useful data, though in this case the 2 parameters we'd be interrested in will always be 8 for compression type, and 2 for General purpose flag.
- $gzLength = strlen($gzData);
-
- if ($gzLength >= $dataLength) {
- $gzLength = $dataLength;
- $gzData = $data;
- $gzType = "\x00\x00"; // Compression type 0 = stored
- $gpFlags = "\x00\x00"; // Compression type 0 = stored
- }
-
- $this->buildZipEntry($filePath, $fileComment, $gpFlags, $gzType, $timestamp, $fileCRC32, $gzLength, $dataLength, self::EXT_FILE_ATTR_FILE);
-
- print ($gzData);
-
- return TRUE;
- }
-
- /**
- * Add the content to a directory.
- *
- * @author Adam Schmalhofer
- * @author A. Grandt
- *
- * @param String $realPath Path on the file system.
- * @param String $zipPath Filepath and name to be used in the archive.
- * @param bool $recursive Add content recursively, default is TRUE.
- * @param bool $followSymlinks Follow and add symbolic links, if they are accessible, default is TRUE.
- * @param array &$addedFiles Reference to the added files, this is used to prevent duplicates, efault is an empty array.
- * If you start the function by parsing an array, the array will be populated with the realPath
- * and zipPath kay/value pairs added to the archive by the function.
- */
- public function addDirectoryContent($realPath, $zipPath, $recursive = TRUE, $followSymlinks = TRUE, &$addedFiles = array()) {
- if (file_exists($realPath) && !isset($addedFiles[realpath($realPath)])) {
- if (is_dir($realPath)) {
- $this->addDirectory($zipPath);
- }
-
- $addedFiles[realpath($realPath)] = $zipPath;
-
- $iter = new DirectoryIterator($realPath);
- foreach ($iter as $file) {
- if ($file->isDot()) {
- continue;
- }
- $newRealPath = $file->getPathname();
- $newZipPath = self::pathJoin($zipPath, $file->getFilename());
-
- if (file_exists($newRealPath) && ($followSymlinks === TRUE || !is_link($newRealPath))) {
- if ($file->isFile()) {
- $addedFiles[realpath($newRealPath)] = $newZipPath;
- $this->addLargeFile($newRealPath, $newZipPath);
- } else if ($recursive === TRUE) {
- $this->addDirectoryContent($newRealPath, $newZipPath, $recursive);
- } else {
- $this->addDirectory($zipPath);
- }
- }
- }
- }
- }
-
- /**
- * Add a file to the archive at the specified location and file name.
- *
- * @param string $dataFile File name/path.
- * @param string $filePath Filepath and name to be used in the archive.
- * @param int $timestamp (Optional) Timestamp for the added file, if omitted or set to 0, the current time will be used.
- * @param string $fileComment (Optional) Comment to be added to the archive for this file. To use fileComment, timestamp must be given.
- * @return bool $success
- */
- public function addLargeFile($dataFile, $filePath, $timestamp = 0, $fileComment = null) {
- if ($this->isFinalized) {
- return FALSE;
- }
-
- if (is_string($dataFile) && is_file($dataFile)) {
- $this->processFile($dataFile, $filePath, $timestamp, $fileComment);
- } else if (is_resource($dataFile) && get_resource_type($dataFile) == "stream") {
- $fh = $dataFile;
- $this->openStream($filePath, $timestamp, $fileComment);
-
- while (!feof($fh)) {
- $this->addStreamData(fread($fh, $this->streamChunkSize));
- }
- $this->closeStream($this->addExtraField);
- }
- return TRUE;
- }
-
- /**
- * Create a stream to be used for large entries.
- *
- * @param string $filePath Filepath and name to be used in the archive.
- * @param int $timestamp (Optional) Timestamp for the added file, if omitted or set to 0, the current time will be used.
- * @param string $fileComment (Optional) Comment to be added to the archive for this file. To use fileComment, timestamp must be given.
- * @return bool $success
- */
- public function openStream($filePath, $timestamp = 0, $fileComment = null) {
- if (!function_exists('sys_get_temp_dir')) {
- die ("ERROR: Zip " . self::VERSION . " requires PHP version 5.2.1 or above if large files are used.");
- }
-
- if ($this->isFinalized) {
- return FALSE;
- }
-
- if (strlen($this->streamFilePath) > 0) {
- closeStream();
- }
-
- $this->streamFile = tempnam(sys_get_temp_dir(), 'ZipStream');
- $this->streamData = fopen($this->streamFile, "wb");
- $this->streamFilePath = $filePath;
- $this->streamTimestamp = $timestamp;
- $this->streamFileComment = $fileComment;
- $this->streamFileLength = 0;
-
- return TRUE;
- }
-
- /**
- * Add data to the open stream.
- *
- * @param String $data
- * @return $length bytes added or FALSE if the archive is finalized or there are no open stream.
- */
- public function addStreamData($data) {
- if ($this->isFinalized || strlen($this->streamFilePath) == 0) {
- return FALSE;
- }
-
- $length = fwrite($this->streamData, $data, strlen($data));
- if ($length != strlen($data)) {
- die ("
Length mismatch
\n");
- }
- $this->streamFileLength += $length;
-
- return $length;
- }
-
- /**
- * Close the current stream.
- *
- * @return bool $success
- */
- public function closeStream() {
- if ($this->isFinalized || strlen($this->streamFilePath) == 0) {
- return FALSE;
- }
-
- fflush($this->streamData);
- fclose($this->streamData);
-
- $this->processFile($this->streamFile, $this->streamFilePath, $this->streamTimestamp, $this->streamFileComment);
-
- $this->streamData = null;
- $this->streamFilePath = null;
- $this->streamTimestamp = null;
- $this->streamFileComment = null;
- $this->streamFileLength = 0;
-
- // Windows is a little slow at times, so a millisecond later, we can unlink this.
- unlink($this->streamFile);
-
- $this->streamFile = null;
-
- return TRUE;
- }
-
- private function processFile($dataFile, $filePath, $timestamp = 0, $fileComment = null) {
- if ($this->isFinalized) {
- return FALSE;
- }
-
- $tempzip = tempnam(sys_get_temp_dir(), 'ZipStream');
-
- $zip = new ZipArchive;
- if ($zip->open($tempzip) === TRUE) {
- $zip->addFile($dataFile, 'file');
- $zip->close();
- }
-
- $file_handle = fopen($tempzip, "rb");
- $stats = fstat($file_handle);
- $eof = $stats['size']-72;
-
- fseek($file_handle, 6);
-
- $gpFlags = fread($file_handle, 2);
- $gzType = fread($file_handle, 2);
- fread($file_handle, 4);
- $fileCRC32 = fread($file_handle, 4);
- $v = unpack("Vval", fread($file_handle, 4));
- $gzLength = $v['val'];
- $v = unpack("Vval", fread($file_handle, 4));
- $dataLength = $v['val'];
-
- $this->buildZipEntry($filePath, $fileComment, $gpFlags, $gzType, $timestamp, $fileCRC32, $gzLength, $dataLength, self::EXT_FILE_ATTR_FILE);
-
- fseek($file_handle, 34);
- $pos = 34;
-
- while (!feof($file_handle) && $pos < $eof) {
- $datalen = $this->streamChunkSize;
- if ($pos + $this->streamChunkSize > $eof) {
- $datalen = $eof-$pos;
- }
- echo fread($file_handle, $datalen);
- $pos += $datalen;
- flush();
- }
-
- fclose($file_handle);
- unlink($tempzip);
- }
-
- /**
- * Close the archive.
- * A closed archive can no longer have new files added to it.
- * @return bool $success
- */
- public function finalize() {
- if (!$this->isFinalized) {
- if (strlen($this->streamFilePath) > 0) {
- $this->closeStream();
- }
-
- $cdRecSize = pack("v", sizeof($this->cdRec));
-
- $cd = implode("", $this->cdRec);
- print($cd);
- print(self::ZIP_END_OF_CENTRAL_DIRECTORY);
- print($cdRecSize.$cdRecSize);
- print(pack("VV", strlen($cd), $this->offset));
- if (!empty($this->zipComment)) {
- print(pack("v", strlen($this->zipComment)));
- print($this->zipComment);
- } else {
- print("\x00\x00");
- }
-
- flush();
-
- $this->isFinalized = TRUE;
- $cd = null;
- $this->cdRec = null;
-
- return TRUE;
- }
- return FALSE;
- }
-
- /**
- * Calculate the 2 byte dostime used in the zip entries.
- *
- * @param int $timestamp
- * @return 2-byte encoded DOS Date
- */
- private function getDosTime($timestamp = 0) {
- $timestamp = (int)$timestamp;
- $oldTZ = @date_default_timezone_get();
- date_default_timezone_set('UTC');
- $date = ($timestamp == 0 ? getdate() : getdate($timestamp));
- date_default_timezone_set($oldTZ);
- if ($date["year"] >= 1980) {
- return pack("V", (($date["mday"] + ($date["mon"] << 5) + (($date["year"]-1980) << 9)) << 16) |
- (($date["seconds"] >> 1) + ($date["minutes"] << 5) + ($date["hours"] << 11)));
- }
- return "\x00\x00\x00\x00";
- }
-
- /**
- * Build the Zip file structures
- *
- * @param String $filePath
- * @param String $fileComment
- * @param String $gpFlags
- * @param String $gzType
- * @param int $timestamp
- * @param string $fileCRC32
- * @param int $gzLength
- * @param int $dataLength
- * @param integer $extFileAttr Use self::EXT_FILE_ATTR_FILE for files, self::EXT_FILE_ATTR_DIR for Directories.
- */
- private function buildZipEntry($filePath, $fileComment, $gpFlags, $gzType, $timestamp, $fileCRC32, $gzLength, $dataLength, $extFileAttr) {
- $filePath = str_replace("\\", "/", $filePath);
- $fileCommentLength = (empty($fileComment) ? 0 : strlen($fileComment));
- $timestamp = (int)$timestamp;
- $timestamp = ($timestamp == 0 ? time() : $timestamp);
-
- $dosTime = $this->getDosTime($timestamp);
- $tsPack = pack("V", $timestamp);
-
- $ux = "\x75\x78\x0B\x00\x01\x04\xE8\x03\x00\x00\x04\x00\x00\x00\x00";
-
- if (!isset($gpFlags) || strlen($gpFlags) != 2) {
- $gpFlags = "\x00\x00";
- }
-
- $isFileUTF8 = mb_check_encoding($filePath, "UTF-8") && !mb_check_encoding($filePath, "ASCII");
- $isCommentUTF8 = !empty($fileComment) && mb_check_encoding($fileComment, "UTF-8") && !mb_check_encoding($fileComment, "ASCII");
- if ($isFileUTF8 || $isCommentUTF8) {
- $flag = 0;
- $gpFlagsV = unpack("vflags", $gpFlags);
- if (isset($gpFlagsV['flags'])) {
- $flag = $gpFlagsV['flags'];
- }
- $gpFlags = pack("v", $flag | (1 << 11));
- }
-
- $header = $gpFlags . $gzType . $dosTime. $fileCRC32
- . pack("VVv", $gzLength, $dataLength, strlen($filePath)); // File name length
-
- $zipEntry = self::ZIP_LOCAL_FILE_HEADER;
- $zipEntry .= self::ATTR_VERSION_TO_EXTRACT;
- $zipEntry .= $header;
- $zipEntry .= $this->addExtraField ? "\x1C\x00" : "\x00\x00"; // Extra field length
- $zipEntry .= $filePath; // FileName
- // Extra fields
- if ($this->addExtraField) {
- $zipEntry .= "\x55\x54\x09\x00\x03" . $tsPack . $tsPack . $ux;
- }
-
- print($zipEntry);
-
- $cdEntry = self::ZIP_CENTRAL_FILE_HEADER;
- $cdEntry .= self::ATTR_MADE_BY_VERSION;
- $cdEntry .= ($dataLength === 0 ? "\x0A\x00" : self::ATTR_VERSION_TO_EXTRACT);
- $cdEntry .= $header;
- $cdEntry .= $this->addExtraField ? "\x18\x00" : "\x00\x00"; // Extra field length
- $cdEntry .= pack("v", $fileCommentLength); // File comment length
- $cdEntry .= "\x00\x00"; // Disk number start
- $cdEntry .= "\x00\x00"; // internal file attributes
- $cdEntry .= $extFileAttr; // External file attributes
- $cdEntry .= pack("V", $this->offset); // Relative offset of local header
- $cdEntry .= $filePath; // FileName
- // Extra fields
- if ($this->addExtraField) {
- $cdEntry .= "\x55\x54\x05\x00\x03" . $tsPack . $ux;
- }
-
- if (!empty($fileComment)) {
- $cdEntry .= $fileComment; // Comment
- }
-
- $this->cdRec[] = $cdEntry;
- $this->offset += strlen($zipEntry) + $gzLength;
- }
-
- /**
- * Join $file to $dir path, and clean up any excess slashes.
- *
- * @param String $dir
- * @param String $file
- */
- public static function pathJoin($dir, $file) {
- if (empty($dir) || empty($file)) {
- return self::getRelativePath($dir . $file);
- }
- return self::getRelativePath($dir . '/' . $file);
- }
-
- /**
- * Clean up a path, removing any unnecessary elements such as /./, // or redundant ../ segments.
- * If the path starts with a "/", it is deemed an absolute path and any /../ in the beginning is stripped off.
- * The returned path will not end in a "/".
- *
- * @param String $path The path to clean up
- * @return String the clean path
- */
- public static function getRelativePath($path) {
- $path = preg_replace("#/+\.?/+#", "/", str_replace("\\", "/", $path));
- $dirs = explode("/", rtrim(preg_replace('#^(?:\./)+#', '', $path), '/'));
-
- $offset = 0;
- $sub = 0;
- $subOffset = 0;
- $root = "";
-
- if (empty($dirs[0])) {
- $root = "/";
- $dirs = array_splice($dirs, 1);
- } else if (preg_match("#[A-Za-z]:#", $dirs[0])) {
- $root = strtoupper($dirs[0]) . "/";
- $dirs = array_splice($dirs, 1);
- }
-
- $newDirs = array();
- foreach ($dirs as $dir) {
- if ($dir !== "..") {
- $subOffset--;
- $newDirs[++$offset] = $dir;
- } else {
- $subOffset++;
- if (--$offset < 0) {
- $offset = 0;
- if ($subOffset > $sub) {
- $sub++;
- }
- }
- }
- }
-
- if (empty($root)) {
- $root = str_repeat("../", $sub);
- }
- return $root . implode("/", array_slice($newDirs, 0, $offset));
- }
-}
-?>
\ No newline at end of file
diff --git a/app/library/getid3/extension.cache.dbm.php b/app/library/getid3/extension.cache.dbm.php
deleted file mode 100644
index 9a88c22b..00000000
--- a/app/library/getid3/extension.cache.dbm.php
+++ /dev/null
@@ -1,211 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// extension.cache.dbm.php - part of getID3() //
-// Please see readme.txt for more information //
-// ///
-/////////////////////////////////////////////////////////////////
-// //
-// This extension written by Allan Hansen //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-/**
-* This is a caching extension for getID3(). It works the exact same
-* way as the getID3 class, but return cached information very fast
-*
-* Example:
-*
-* Normal getID3 usage (example):
-*
-* require_once 'getid3/getid3.php';
-* $getID3 = new getID3;
-* $getID3->encoding = 'UTF-8';
-* $info1 = $getID3->analyze('file1.flac');
-* $info2 = $getID3->analyze('file2.wv');
-*
-* getID3_cached usage:
-*
-* require_once 'getid3/getid3.php';
-* require_once 'getid3/getid3/extension.cache.dbm.php';
-* $getID3 = new getID3_cached('db3', '/tmp/getid3_cache.dbm',
-* '/tmp/getid3_cache.lock');
-* $getID3->encoding = 'UTF-8';
-* $info1 = $getID3->analyze('file1.flac');
-* $info2 = $getID3->analyze('file2.wv');
-*
-*
-* Supported Cache Types
-*
-* SQL Databases: (use extension.cache.mysql)
-*
-* cache_type cache_options
-* -------------------------------------------------------------------
-* mysql host, database, username, password
-*
-*
-* DBM-Style Databases: (this extension)
-*
-* cache_type cache_options
-* -------------------------------------------------------------------
-* gdbm dbm_filename, lock_filename
-* ndbm dbm_filename, lock_filename
-* db2 dbm_filename, lock_filename
-* db3 dbm_filename, lock_filename
-* db4 dbm_filename, lock_filename (PHP5 required)
-*
-* PHP must have write access to both dbm_filename and lock_filename.
-*
-*
-* Recommended Cache Types
-*
-* Infrequent updates, many reads any DBM
-* Frequent updates mysql
-*/
-
-
-class getID3_cached_dbm extends getID3
-{
-
- // public: constructor - see top of this file for cache type and cache_options
- function getID3_cached_dbm($cache_type, $dbm_filename, $lock_filename) {
-
- // Check for dba extension
- if (!extension_loaded('dba')) {
- throw new Exception('PHP is not compiled with dba support, required to use DBM style cache.');
- }
-
- // Check for specific dba driver
- if (!function_exists('dba_handlers') || !in_array($cache_type, dba_handlers())) {
- throw new Exception('PHP is not compiled --with '.$cache_type.' support, required to use DBM style cache.');
- }
-
- // Create lock file if needed
- if (!file_exists($lock_filename)) {
- if (!touch($lock_filename)) {
- throw new Exception('failed to create lock file: '.$lock_filename);
- }
- }
-
- // Open lock file for writing
- if (!is_writeable($lock_filename)) {
- throw new Exception('lock file: '.$lock_filename.' is not writable');
- }
- $this->lock = fopen($lock_filename, 'w');
-
- // Acquire exclusive write lock to lock file
- flock($this->lock, LOCK_EX);
-
- // Create dbm-file if needed
- if (!file_exists($dbm_filename)) {
- if (!touch($dbm_filename)) {
- throw new Exception('failed to create dbm file: '.$dbm_filename);
- }
- }
-
- // Try to open dbm file for writing
- $this->dba = dba_open($dbm_filename, 'w', $cache_type);
- if (!$this->dba) {
-
- // Failed - create new dbm file
- $this->dba = dba_open($dbm_filename, 'n', $cache_type);
-
- if (!$this->dba) {
- throw new Exception('failed to create dbm file: '.$dbm_filename);
- }
-
- // Insert getID3 version number
- dba_insert(getID3::VERSION, getID3::VERSION, $this->dba);
- }
-
- // Init misc values
- $this->cache_type = $cache_type;
- $this->dbm_filename = $dbm_filename;
-
- // Register destructor
- register_shutdown_function(array($this, '__destruct'));
-
- // Check version number and clear cache if changed
- if (dba_fetch(getID3::VERSION, $this->dba) != getID3::VERSION) {
- $this->clear_cache();
- }
-
- parent::getID3();
- }
-
-
-
- // public: destuctor
- function __destruct() {
-
- // Close dbm file
- dba_close($this->dba);
-
- // Release exclusive lock
- flock($this->lock, LOCK_UN);
-
- // Close lock file
- fclose($this->lock);
- }
-
-
-
- // public: clear cache
- function clear_cache() {
-
- // Close dbm file
- dba_close($this->dba);
-
- // Create new dbm file
- $this->dba = dba_open($this->dbm_filename, 'n', $this->cache_type);
-
- if (!$this->dba) {
- throw new Exception('failed to clear cache/recreate dbm file: '.$this->dbm_filename);
- }
-
- // Insert getID3 version number
- dba_insert(getID3::VERSION, getID3::VERSION, $this->dba);
-
- // Re-register shutdown function
- register_shutdown_function(array($this, '__destruct'));
- }
-
-
-
- // public: analyze file
- function analyze($filename) {
-
- if (file_exists($filename)) {
-
- // Calc key filename::mod_time::size - should be unique
- $key = $filename.'::'.filemtime($filename).'::'.filesize($filename);
-
- // Loopup key
- $result = dba_fetch($key, $this->dba);
-
- // Hit
- if ($result !== false) {
- return unserialize($result);
- }
- }
-
- // Miss
- $result = parent::analyze($filename);
-
- // Save result
- if (file_exists($filename)) {
- dba_insert($key, serialize($result), $this->dba);
- }
-
- return $result;
- }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/extension.cache.mysql.php b/app/library/getid3/extension.cache.mysql.php
deleted file mode 100644
index 1e1f91fa..00000000
--- a/app/library/getid3/extension.cache.mysql.php
+++ /dev/null
@@ -1,173 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// extension.cache.mysql.php - part of getID3() //
-// Please see readme.txt for more information //
-// ///
-/////////////////////////////////////////////////////////////////
-// //
-// This extension written by Allan Hansen //
-// Table name mod by Carlo Capocasa //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-/**
-* This is a caching extension for getID3(). It works the exact same
-* way as the getID3 class, but return cached information very fast
-*
-* Example: (see also demo.cache.mysql.php in /demo/)
-*
-* Normal getID3 usage (example):
-*
-* require_once 'getid3/getid3.php';
-* $getID3 = new getID3;
-* $getID3->encoding = 'UTF-8';
-* $info1 = $getID3->analyze('file1.flac');
-* $info2 = $getID3->analyze('file2.wv');
-*
-* getID3_cached usage:
-*
-* require_once 'getid3/getid3.php';
-* require_once 'getid3/getid3/extension.cache.mysql.php';
-* // 5th parameter (tablename) is optional, default is 'getid3_cache'
-* $getID3 = new getID3_cached_mysql('localhost', 'database', 'username', 'password', 'tablename');
-* $getID3->encoding = 'UTF-8';
-* $info1 = $getID3->analyze('file1.flac');
-* $info2 = $getID3->analyze('file2.wv');
-*
-*
-* Supported Cache Types (this extension)
-*
-* SQL Databases:
-*
-* cache_type cache_options
-* -------------------------------------------------------------------
-* mysql host, database, username, password
-*
-*
-* DBM-Style Databases: (use extension.cache.dbm)
-*
-* cache_type cache_options
-* -------------------------------------------------------------------
-* gdbm dbm_filename, lock_filename
-* ndbm dbm_filename, lock_filename
-* db2 dbm_filename, lock_filename
-* db3 dbm_filename, lock_filename
-* db4 dbm_filename, lock_filename (PHP5 required)
-*
-* PHP must have write access to both dbm_filename and lock_filename.
-*
-*
-* Recommended Cache Types
-*
-* Infrequent updates, many reads any DBM
-* Frequent updates mysql
-*/
-
-
-class getID3_cached_mysql extends getID3
-{
-
- // private vars
- var $cursor;
- var $connection;
-
-
- // public: constructor - see top of this file for cache type and cache_options
- function getID3_cached_mysql($host, $database, $username, $password, $table='getid3_cache') {
-
- // Check for mysql support
- if (!function_exists('mysql_pconnect')) {
- throw new Exception('PHP not compiled with mysql support.');
- }
-
- // Connect to database
- $this->connection = mysql_pconnect($host, $username, $password);
- if (!$this->connection) {
- throw new Exception('mysql_pconnect() failed - check permissions and spelling.');
- }
-
- // Select database
- if (!mysql_select_db($database, $this->connection)) {
- throw new Exception('Cannot use database '.$database);
- }
-
- // Set table
- $this->table = $table;
-
- // Create cache table if not exists
- $this->create_table();
-
- // 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(getID3::VERSION)."') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection)) {
- list($version) = mysql_fetch_array($this->cursor);
- }
- if ($version != getID3::VERSION) {
- $this->clear_cache();
- }
-
- parent::getID3();
- }
-
-
-
- // public: clear cache
- 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 ('".getID3::VERSION."', -1, -1, -1, '".getID3::VERSION."')", $this->connection);
- }
-
-
-
- // public: analyze file
- function analyze($filename) {
-
- if (file_exists($filename)) {
-
- // Short-hands
- $filetime = filemtime($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) {
- // Hit
- list($result) = mysql_fetch_array($this->cursor);
- return unserialize(base64_decode($result));
- }
- }
-
- // Miss
- $analysis = parent::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);
- }
- return $analysis;
- }
-
-
-
- // private: (re)create sql table
- function create_table($drop=false) {
-
- $this->cursor = mysql_query("CREATE TABLE IF NOT EXISTS `".mysql_real_escape_string($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`)) TYPE=MyISAM", $this->connection);
- echo mysql_error($this->connection);
- }
-}
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/getid3.lib.php b/app/library/getid3/getid3.lib.php
deleted file mode 100644
index e736688e..00000000
--- a/app/library/getid3/getid3.lib.php
+++ /dev/null
@@ -1,1316 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// getid3.lib.php - part of getID3() //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_lib
-{
-
- static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
- $returnstring = '';
- for ($i = 0; $i < strlen($string); $i++) {
- if ($hex) {
- $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
- } else {
- $returnstring .= ' '.(preg_match("#[\x20-\x7E]#", $string{$i}) ? $string{$i} : '�');
- }
- if ($spaces) {
- $returnstring .= ' ';
- }
- }
- if (!empty($htmlencoding)) {
- if ($htmlencoding === true) {
- $htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean
- }
- $returnstring = htmlentities($returnstring, ENT_QUOTES, $htmlencoding);
- }
- return $returnstring;
- }
-
- static function trunc($floatnumber) {
- // truncates a floating-point number at the decimal point
- // returns int (if possible, otherwise float)
- if ($floatnumber >= 1) {
- $truncatednumber = floor($floatnumber);
- } elseif ($floatnumber <= -1) {
- $truncatednumber = ceil($floatnumber);
- } else {
- $truncatednumber = 0;
- }
- if (getid3_lib::intValueSupported($truncatednumber)) {
- $truncatednumber = (int) $truncatednumber;
- }
- return $truncatednumber;
- }
-
-
- static function safe_inc(&$variable, $increment=1) {
- if (isset($variable)) {
- $variable += $increment;
- } else {
- $variable = $increment;
- }
- return true;
- }
-
- static function CastAsInt($floatnum) {
- // convert to float if not already
- $floatnum = (float) $floatnum;
-
- // convert a float to type int, only if possible
- if (getid3_lib::trunc($floatnum) == $floatnum) {
- // it's not floating point
- if (getid3_lib::intValueSupported($floatnum)) {
- // it's within int range
- $floatnum = (int) $floatnum;
- }
- }
- return $floatnum;
- }
-
- public static function intValueSupported($num) {
- // check if integers are 64-bit
- static $hasINT64 = null;
- if ($hasINT64 === null) { // 10x faster than is_null()
- $hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1
- if (!$hasINT64 && !defined('PHP_INT_MIN')) {
- define('PHP_INT_MIN', ~PHP_INT_MAX);
- }
- }
- // if integers are 64-bit - no other check required
- if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) {
- return true;
- }
- return false;
- }
-
- static function DecimalizeFraction($fraction) {
- list($numerator, $denominator) = explode('/', $fraction);
- return $numerator / ($denominator ? $denominator : 1);
- }
-
-
- static function DecimalBinary2Float($binarynumerator) {
- $numerator = getid3_lib::Bin2Dec($binarynumerator);
- $denominator = getid3_lib::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
- return ($numerator / $denominator);
- }
-
-
- static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
- if (strpos($binarypointnumber, '.') === false) {
- $binarypointnumber = '0.'.$binarypointnumber;
- } elseif ($binarypointnumber{0} == '.') {
- $binarypointnumber = '0'.$binarypointnumber;
- }
- $exponent = 0;
- while (($binarypointnumber{0} != '1') || (substr($binarypointnumber, 1, 1) != '.')) {
- if (substr($binarypointnumber, 1, 1) == '.') {
- $exponent--;
- $binarypointnumber = substr($binarypointnumber, 2, 1).'.'.substr($binarypointnumber, 3);
- } else {
- $pointpos = strpos($binarypointnumber, '.');
- $exponent += ($pointpos - 1);
- $binarypointnumber = str_replace('.', '', $binarypointnumber);
- $binarypointnumber = $binarypointnumber{0}.'.'.substr($binarypointnumber, 1);
- }
- }
- $binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2), $maxbits + 2, '0', STR_PAD_RIGHT);
- return array('normalized'=>$binarypointnumber, 'exponent'=>(int) $exponent);
- }
-
-
- static function Float2BinaryDecimal($floatvalue) {
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
- $maxbits = 128; // to how many bits of precision should the calculations be taken?
- $intpart = getid3_lib::trunc($floatvalue);
- $floatpart = abs($floatvalue - $intpart);
- $pointbitstring = '';
- while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
- $floatpart *= 2;
- $pointbitstring .= (string) getid3_lib::trunc($floatpart);
- $floatpart -= getid3_lib::trunc($floatpart);
- }
- $binarypointnumber = decbin($intpart).'.'.$pointbitstring;
- return $binarypointnumber;
- }
-
-
- static function Float2String($floatvalue, $bits) {
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
- switch ($bits) {
- case 32:
- $exponentbits = 8;
- $fractionbits = 23;
- break;
-
- case 64:
- $exponentbits = 11;
- $fractionbits = 52;
- break;
-
- default:
- return false;
- break;
- }
- if ($floatvalue >= 0) {
- $signbit = '0';
- } else {
- $signbit = '1';
- }
- $normalizedbinary = getid3_lib::NormalizeBinaryPoint(getid3_lib::Float2BinaryDecimal($floatvalue), $fractionbits);
- $biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent
- $exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
- $fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
-
- return getid3_lib::BigEndian2String(getid3_lib::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
- }
-
-
- static function LittleEndian2Float($byteword) {
- return getid3_lib::BigEndian2Float(strrev($byteword));
- }
-
-
- static function BigEndian2Float($byteword) {
- // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
- // http://www.psc.edu/general/software/packages/ieee/ieee.html
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
-
- $bitword = getid3_lib::BigEndian2Bin($byteword);
- if (!$bitword) {
- return 0;
- }
- $signbit = $bitword{0};
-
- switch (strlen($byteword) * 8) {
- case 32:
- $exponentbits = 8;
- $fractionbits = 23;
- break;
-
- case 64:
- $exponentbits = 11;
- $fractionbits = 52;
- break;
-
- case 80:
- // 80-bit Apple SANE format
- // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
- $exponentstring = substr($bitword, 1, 15);
- $isnormalized = intval($bitword{16});
- $fractionstring = substr($bitword, 17, 63);
- $exponent = pow(2, getid3_lib::Bin2Dec($exponentstring) - 16383);
- $fraction = $isnormalized + getid3_lib::DecimalBinary2Float($fractionstring);
- $floatvalue = $exponent * $fraction;
- if ($signbit == '1') {
- $floatvalue *= -1;
- }
- return $floatvalue;
- break;
-
- default:
- return false;
- break;
- }
- $exponentstring = substr($bitword, 1, $exponentbits);
- $fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
- $exponent = getid3_lib::Bin2Dec($exponentstring);
- $fraction = getid3_lib::Bin2Dec($fractionstring);
-
- if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
- // Not a Number
- $floatvalue = false;
- } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
- if ($signbit == '1') {
- $floatvalue = '-infinity';
- } else {
- $floatvalue = '+infinity';
- }
- } elseif (($exponent == 0) && ($fraction == 0)) {
- if ($signbit == '1') {
- $floatvalue = -0;
- } else {
- $floatvalue = 0;
- }
- $floatvalue = ($signbit ? 0 : -0);
- } elseif (($exponent == 0) && ($fraction != 0)) {
- // These are 'unnormalized' values
- $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fractionstring);
- if ($signbit == '1') {
- $floatvalue *= -1;
- }
- } elseif ($exponent != 0) {
- $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fractionstring));
- if ($signbit == '1') {
- $floatvalue *= -1;
- }
- }
- return (float) $floatvalue;
- }
-
-
- static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
- $intvalue = 0;
- $bytewordlen = strlen($byteword);
- if ($bytewordlen == 0) {
- return false;
- }
- for ($i = 0; $i < $bytewordlen; $i++) {
- if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
- //$intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7); // faster, but runs into problems past 2^31 on 32-bit systems
- $intvalue += (ord($byteword{$i}) & 0x7F) * pow(2, ($bytewordlen - 1 - $i) * 7);
- } else {
- $intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
- }
- }
- if ($signed && !$synchsafe) {
- // synchsafe ints are not allowed to be signed
- if ($bytewordlen <= PHP_INT_SIZE) {
- $signMaskBit = 0x80 << (8 * ($bytewordlen - 1));
- if ($intvalue & $signMaskBit) {
- $intvalue = 0 - ($intvalue & ($signMaskBit - 1));
- }
- } else {
- throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in getid3_lib::BigEndian2Int()');
- }
- }
- return getid3_lib::CastAsInt($intvalue);
- }
-
-
- static function LittleEndian2Int($byteword, $signed=false) {
- return getid3_lib::BigEndian2Int(strrev($byteword), false, $signed);
- }
-
-
- static function BigEndian2Bin($byteword) {
- $binvalue = '';
- $bytewordlen = strlen($byteword);
- for ($i = 0; $i < $bytewordlen; $i++) {
- $binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
- }
- return $binvalue;
- }
-
-
- static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
- if ($number < 0) {
- throw new Exception('ERROR: getid3_lib::BigEndian2String() does not support negative numbers');
- }
- $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
- $intstring = '';
- if ($signed) {
- if ($minbytes > PHP_INT_SIZE) {
- throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in getid3_lib::BigEndian2String()');
- }
- $number = $number & (0x80 << (8 * ($minbytes - 1)));
- }
- while ($number != 0) {
- $quotient = ($number / ($maskbyte + 1));
- $intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
- $number = floor($quotient);
- }
- return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT);
- }
-
-
- static function Dec2Bin($number) {
- while ($number >= 256) {
- $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
- $number = floor($number / 256);
- }
- $bytes[] = $number;
- $binstring = '';
- for ($i = 0; $i < count($bytes); $i++) {
- $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
- }
- return $binstring;
- }
-
-
- static function Bin2Dec($binstring, $signed=false) {
- $signmult = 1;
- if ($signed) {
- if ($binstring{0} == '1') {
- $signmult = -1;
- }
- $binstring = substr($binstring, 1);
- }
- $decvalue = 0;
- for ($i = 0; $i < strlen($binstring); $i++) {
- $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
- }
- return getid3_lib::CastAsInt($decvalue * $signmult);
- }
-
-
- static function Bin2String($binstring) {
- // return 'hi' for input of '0110100001101001'
- $string = '';
- $binstringreversed = strrev($binstring);
- for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
- $string = chr(getid3_lib::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
- }
- return $string;
- }
-
-
- static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
- $intstring = '';
- while ($number > 0) {
- if ($synchsafe) {
- $intstring = $intstring.chr($number & 127);
- $number >>= 7;
- } else {
- $intstring = $intstring.chr($number & 255);
- $number >>= 8;
- }
- }
- return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
- }
-
-
- static function array_merge_clobber($array1, $array2) {
- // written by kc�hireability*com
- // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
- if (!is_array($array1) || !is_array($array2)) {
- return false;
- }
- $newarray = $array1;
- foreach ($array2 as $key => $val) {
- if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
- $newarray[$key] = getid3_lib::array_merge_clobber($newarray[$key], $val);
- } else {
- $newarray[$key] = $val;
- }
- }
- return $newarray;
- }
-
-
- static function array_merge_noclobber($array1, $array2) {
- if (!is_array($array1) || !is_array($array2)) {
- return false;
- }
- $newarray = $array1;
- foreach ($array2 as $key => $val) {
- if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
- $newarray[$key] = getid3_lib::array_merge_noclobber($newarray[$key], $val);
- } elseif (!isset($newarray[$key])) {
- $newarray[$key] = $val;
- }
- }
- return $newarray;
- }
-
-
- static function ksort_recursive(&$theArray) {
- ksort($theArray);
- foreach ($theArray as $key => $value) {
- if (is_array($value)) {
- self::ksort_recursive($theArray[$key]);
- }
- }
- return true;
- }
-
- static function fileextension($filename, $numextensions=1) {
- if (strstr($filename, '.')) {
- $reversedfilename = strrev($filename);
- $offset = 0;
- for ($i = 0; $i < $numextensions; $i++) {
- $offset = strpos($reversedfilename, '.', $offset + 1);
- if ($offset === false) {
- return '';
- }
- }
- return strrev(substr($reversedfilename, 0, $offset));
- }
- return '';
- }
-
-
- static function PlaytimeString($seconds) {
- $sign = (($seconds < 0) ? '-' : '');
- $seconds = abs($seconds);
- $H = floor( $seconds / 3600);
- $M = floor(($seconds - (3600 * $H) ) / 60);
- $S = round( $seconds - (3600 * $H) - (60 * $M) );
- return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT);
- }
-
-
- static function DateMac2Unix($macdate) {
- // Macintosh timestamp: seconds since 00:00h January 1, 1904
- // UNIX timestamp: seconds since 00:00h January 1, 1970
- return getid3_lib::CastAsInt($macdate - 2082844800);
- }
-
-
- static function FixedPoint8_8($rawdata) {
- return getid3_lib::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
- }
-
-
- static function FixedPoint16_16($rawdata) {
- return getid3_lib::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
- }
-
-
- static function FixedPoint2_30($rawdata) {
- $binarystring = getid3_lib::BigEndian2Bin($rawdata);
- return getid3_lib::Bin2Dec(substr($binarystring, 0, 2)) + (float) (getid3_lib::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
- }
-
-
- static function CreateDeepArray($ArrayPath, $Separator, $Value) {
- // assigns $Value to a nested array path:
- // $foo = getid3_lib::CreateDeepArray('/path/to/my', '/', 'file.txt')
- // is the same as:
- // $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
- // or
- // $foo['path']['to']['my'] = 'file.txt';
- while ($ArrayPath && ($ArrayPath{0} == $Separator)) {
- $ArrayPath = substr($ArrayPath, 1);
- }
- if (($pos = strpos($ArrayPath, $Separator)) !== false) {
- $ReturnedArray[substr($ArrayPath, 0, $pos)] = getid3_lib::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
- } else {
- $ReturnedArray[$ArrayPath] = $Value;
- }
- return $ReturnedArray;
- }
-
- static function array_max($arraydata, $returnkey=false) {
- $maxvalue = false;
- $maxkey = false;
- foreach ($arraydata as $key => $value) {
- if (!is_array($value)) {
- if ($value > $maxvalue) {
- $maxvalue = $value;
- $maxkey = $key;
- }
- }
- }
- return ($returnkey ? $maxkey : $maxvalue);
- }
-
- static function array_min($arraydata, $returnkey=false) {
- $minvalue = false;
- $minkey = false;
- foreach ($arraydata as $key => $value) {
- if (!is_array($value)) {
- if ($value > $minvalue) {
- $minvalue = $value;
- $minkey = $key;
- }
- }
- }
- return ($returnkey ? $minkey : $minvalue);
- }
-
- static function XML2array($XMLstring) {
- if (function_exists('simplexml_load_string')) {
- if (function_exists('get_object_vars')) {
- $XMLobject = simplexml_load_string($XMLstring);
- return self::SimpleXMLelement2array($XMLobject);
- }
- }
- return false;
- }
-
- static function SimpleXMLelement2array($XMLobject) {
- if (!is_object($XMLobject) && !is_array($XMLobject)) {
- return $XMLobject;
- }
- $XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject);
- foreach ($XMLarray as $key => $value) {
- $XMLarray[$key] = self::SimpleXMLelement2array($value);
- }
- return $XMLarray;
- }
-
-
- // Allan Hansen
- // getid3_lib::md5_data() - returns md5sum for a file from startuing position to absolute end position
- static function hash_data($file, $offset, $end, $algorithm) {
- static $tempdir = '';
- if (!getid3_lib::intValueSupported($end)) {
- return false;
- }
- switch ($algorithm) {
- case 'md5':
- $hash_function = 'md5_file';
- $unix_call = 'md5sum';
- $windows_call = 'md5sum.exe';
- $hash_length = 32;
- break;
-
- case 'sha1':
- $hash_function = 'sha1_file';
- $unix_call = 'sha1sum';
- $windows_call = 'sha1sum.exe';
- $hash_length = 40;
- break;
-
- default:
- throw new Exception('Invalid algorithm ('.$algorithm.') in getid3_lib::hash_data()');
- break;
- }
- $size = $end - $offset;
- while (true) {
- if (GETID3_OS_ISWINDOWS) {
-
- // It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
- // Fall back to create-temp-file method:
- if ($algorithm == 'sha1') {
- break;
- }
-
- $RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
- foreach ($RequiredFiles as $required_file) {
- if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
- // helper apps not available - fall back to old method
- break;
- }
- }
- $commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' "'.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).'" | ';
- $commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
- $commandline .= GETID3_HELPERAPPSDIR.$windows_call;
-
- } else {
-
- $commandline = 'head -c'.$end.' '.escapeshellarg($file).' | ';
- $commandline .= 'tail -c'.$size.' | ';
- $commandline .= $unix_call;
-
- }
- if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
- //throw new Exception('PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm');
- break;
- }
- return substr(`$commandline`, 0, $hash_length);
- }
-
- if (empty($tempdir)) {
- // yes this is ugly, feel free to suggest a better way
- require_once(dirname(__FILE__).'/getid3.php');
- $getid3_temp = new getID3();
- $tempdir = $getid3_temp->tempdir;
- unset($getid3_temp);
- }
- // try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
- if (($data_filename = tempnam($tempdir, 'gI3')) === false) {
- // can't find anywhere to create a temp file, just fail
- return false;
- }
-
- // Init
- $result = false;
-
- // copy parts of file
- try {
- getid3_lib::CopyFileParts($file, $data_filename, $offset, $end - $offset);
- $result = $hash_function($data_filename);
- } catch (Exception $e) {
- throw new Exception('getid3_lib::CopyFileParts() failed in getid_lib::hash_data(): '.$e->getMessage());
- }
- unlink($data_filename);
- return $result;
- }
-
- static function CopyFileParts($filename_source, $filename_dest, $offset, $length) {
- if (!getid3_lib::intValueSupported($offset + $length)) {
- throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
- }
- if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
- if (($fp_dest = fopen($filename_dest, 'wb'))) {
- if (fseek($fp_src, $offset, SEEK_SET) == 0) {
- $byteslefttowrite = $length;
- while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) {
- $byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite);
- $byteslefttowrite -= $byteswritten;
- }
- return true;
- } else {
- throw new Exception('failed to seek to offset '.$offset.' in '.$filename_source);
- }
- fclose($fp_dest);
- } else {
- throw new Exception('failed to create file for writing '.$filename_dest);
- }
- fclose($fp_src);
- } else {
- throw new Exception('failed to open file for reading '.$filename_source);
- }
- return false;
- }
-
- static function iconv_fallback_int_utf8($charval) {
- if ($charval < 128) {
- // 0bbbbbbb
- $newcharstring = chr($charval);
- } elseif ($charval < 2048) {
- // 110bbbbb 10bbbbbb
- $newcharstring = chr(($charval >> 6) | 0xC0);
- $newcharstring .= chr(($charval & 0x3F) | 0x80);
- } elseif ($charval < 65536) {
- // 1110bbbb 10bbbbbb 10bbbbbb
- $newcharstring = chr(($charval >> 12) | 0xE0);
- $newcharstring .= chr(($charval >> 6) | 0xC0);
- $newcharstring .= chr(($charval & 0x3F) | 0x80);
- } else {
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
- $newcharstring = chr(($charval >> 18) | 0xF0);
- $newcharstring .= chr(($charval >> 12) | 0xC0);
- $newcharstring .= chr(($charval >> 6) | 0xC0);
- $newcharstring .= chr(($charval & 0x3F) | 0x80);
- }
- return $newcharstring;
- }
-
- // ISO-8859-1 => UTF-8
- static function iconv_fallback_iso88591_utf8($string, $bom=false) {
- if (function_exists('utf8_encode')) {
- return utf8_encode($string);
- }
- // utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
- $newcharstring = '';
- if ($bom) {
- $newcharstring .= "\xEF\xBB\xBF";
- }
- for ($i = 0; $i < strlen($string); $i++) {
- $charval = ord($string{$i});
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
- }
- return $newcharstring;
- }
-
- // ISO-8859-1 => UTF-16BE
- static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
- $newcharstring = '';
- if ($bom) {
- $newcharstring .= "\xFE\xFF";
- }
- for ($i = 0; $i < strlen($string); $i++) {
- $newcharstring .= "\x00".$string{$i};
- }
- return $newcharstring;
- }
-
- // ISO-8859-1 => UTF-16LE
- static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
- $newcharstring = '';
- if ($bom) {
- $newcharstring .= "\xFF\xFE";
- }
- for ($i = 0; $i < strlen($string); $i++) {
- $newcharstring .= $string{$i}."\x00";
- }
- return $newcharstring;
- }
-
- // ISO-8859-1 => UTF-16LE (BOM)
- static function iconv_fallback_iso88591_utf16($string) {
- return getid3_lib::iconv_fallback_iso88591_utf16le($string, true);
- }
-
- // UTF-8 => ISO-8859-1
- static function iconv_fallback_utf8_iso88591($string) {
- if (function_exists('utf8_decode')) {
- return utf8_decode($string);
- }
- // utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
- $newcharstring = '';
- $offset = 0;
- $stringlength = strlen($string);
- while ($offset < $stringlength) {
- if ((ord($string{$offset}) | 0x07) == 0xF7) {
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
- $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
- (ord($string{($offset + 3)}) & 0x3F);
- $offset += 4;
- } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
- // 1110bbbb 10bbbbbb 10bbbbbb
- $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
- (ord($string{($offset + 2)}) & 0x3F);
- $offset += 3;
- } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
- // 110bbbbb 10bbbbbb
- $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
- (ord($string{($offset + 1)}) & 0x3F);
- $offset += 2;
- } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
- // 0bbbbbbb
- $charval = ord($string{$offset});
- $offset += 1;
- } else {
- // error? throw some kind of warning here?
- $charval = false;
- $offset += 1;
- }
- if ($charval !== false) {
- $newcharstring .= (($charval < 256) ? chr($charval) : '?');
- }
- }
- return $newcharstring;
- }
-
- // UTF-8 => UTF-16BE
- static function iconv_fallback_utf8_utf16be($string, $bom=false) {
- $newcharstring = '';
- if ($bom) {
- $newcharstring .= "\xFE\xFF";
- }
- $offset = 0;
- $stringlength = strlen($string);
- while ($offset < $stringlength) {
- if ((ord($string{$offset}) | 0x07) == 0xF7) {
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
- $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
- (ord($string{($offset + 3)}) & 0x3F);
- $offset += 4;
- } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
- // 1110bbbb 10bbbbbb 10bbbbbb
- $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
- (ord($string{($offset + 2)}) & 0x3F);
- $offset += 3;
- } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
- // 110bbbbb 10bbbbbb
- $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
- (ord($string{($offset + 1)}) & 0x3F);
- $offset += 2;
- } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
- // 0bbbbbbb
- $charval = ord($string{$offset});
- $offset += 1;
- } else {
- // error? throw some kind of warning here?
- $charval = false;
- $offset += 1;
- }
- if ($charval !== false) {
- $newcharstring .= (($charval < 65536) ? getid3_lib::BigEndian2String($charval, 2) : "\x00".'?');
- }
- }
- return $newcharstring;
- }
-
- // UTF-8 => UTF-16LE
- static function iconv_fallback_utf8_utf16le($string, $bom=false) {
- $newcharstring = '';
- if ($bom) {
- $newcharstring .= "\xFF\xFE";
- }
- $offset = 0;
- $stringlength = strlen($string);
- while ($offset < $stringlength) {
- if ((ord($string{$offset}) | 0x07) == 0xF7) {
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
- $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
- (ord($string{($offset + 3)}) & 0x3F);
- $offset += 4;
- } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
- // 1110bbbb 10bbbbbb 10bbbbbb
- $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
- (ord($string{($offset + 2)}) & 0x3F);
- $offset += 3;
- } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
- // 110bbbbb 10bbbbbb
- $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
- (ord($string{($offset + 1)}) & 0x3F);
- $offset += 2;
- } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
- // 0bbbbbbb
- $charval = ord($string{$offset});
- $offset += 1;
- } else {
- // error? maybe throw some warning here?
- $charval = false;
- $offset += 1;
- }
- if ($charval !== false) {
- $newcharstring .= (($charval < 65536) ? getid3_lib::LittleEndian2String($charval, 2) : '?'."\x00");
- }
- }
- return $newcharstring;
- }
-
- // UTF-8 => UTF-16LE (BOM)
- static function iconv_fallback_utf8_utf16($string) {
- return getid3_lib::iconv_fallback_utf8_utf16le($string, true);
- }
-
- // UTF-16BE => UTF-8
- static function iconv_fallback_utf16be_utf8($string) {
- if (substr($string, 0, 2) == "\xFE\xFF") {
- // strip BOM
- $string = substr($string, 2);
- }
- $newcharstring = '';
- for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
- }
- return $newcharstring;
- }
-
- // UTF-16LE => UTF-8
- static function iconv_fallback_utf16le_utf8($string) {
- if (substr($string, 0, 2) == "\xFF\xFE") {
- // strip BOM
- $string = substr($string, 2);
- }
- $newcharstring = '';
- for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
- }
- return $newcharstring;
- }
-
- // UTF-16BE => ISO-8859-1
- static function iconv_fallback_utf16be_iso88591($string) {
- if (substr($string, 0, 2) == "\xFE\xFF") {
- // strip BOM
- $string = substr($string, 2);
- }
- $newcharstring = '';
- for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
- $newcharstring .= (($charval < 256) ? chr($charval) : '?');
- }
- return $newcharstring;
- }
-
- // UTF-16LE => ISO-8859-1
- static function iconv_fallback_utf16le_iso88591($string) {
- if (substr($string, 0, 2) == "\xFF\xFE") {
- // strip BOM
- $string = substr($string, 2);
- }
- $newcharstring = '';
- for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
- $newcharstring .= (($charval < 256) ? chr($charval) : '?');
- }
- return $newcharstring;
- }
-
- // UTF-16 (BOM) => ISO-8859-1
- static function iconv_fallback_utf16_iso88591($string) {
- $bom = substr($string, 0, 2);
- if ($bom == "\xFE\xFF") {
- return getid3_lib::iconv_fallback_utf16be_iso88591(substr($string, 2));
- } elseif ($bom == "\xFF\xFE") {
- return getid3_lib::iconv_fallback_utf16le_iso88591(substr($string, 2));
- }
- return $string;
- }
-
- // UTF-16 (BOM) => UTF-8
- static function iconv_fallback_utf16_utf8($string) {
- $bom = substr($string, 0, 2);
- if ($bom == "\xFE\xFF") {
- return getid3_lib::iconv_fallback_utf16be_utf8(substr($string, 2));
- } elseif ($bom == "\xFF\xFE") {
- return getid3_lib::iconv_fallback_utf16le_utf8(substr($string, 2));
- }
- return $string;
- }
-
- static function iconv_fallback($in_charset, $out_charset, $string) {
-
- if ($in_charset == $out_charset) {
- return $string;
- }
-
- // iconv() availble
- if (function_exists('iconv')) {
- if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
- switch ($out_charset) {
- case 'ISO-8859-1':
- $converted_string = rtrim($converted_string, "\x00");
- break;
- }
- return $converted_string;
- }
-
- // iconv() may sometimes fail with "illegal character in input string" error message
- // and return an empty string, but returning the unconverted string is more useful
- return $string;
- }
-
-
- // iconv() not available
- static $ConversionFunctionList = array();
- if (empty($ConversionFunctionList)) {
- $ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8';
- $ConversionFunctionList['ISO-8859-1']['UTF-16'] = 'iconv_fallback_iso88591_utf16';
- $ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
- $ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
- $ConversionFunctionList['UTF-8']['ISO-8859-1'] = 'iconv_fallback_utf8_iso88591';
- $ConversionFunctionList['UTF-8']['UTF-16'] = 'iconv_fallback_utf8_utf16';
- $ConversionFunctionList['UTF-8']['UTF-16BE'] = 'iconv_fallback_utf8_utf16be';
- $ConversionFunctionList['UTF-8']['UTF-16LE'] = 'iconv_fallback_utf8_utf16le';
- $ConversionFunctionList['UTF-16']['ISO-8859-1'] = 'iconv_fallback_utf16_iso88591';
- $ConversionFunctionList['UTF-16']['UTF-8'] = 'iconv_fallback_utf16_utf8';
- $ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
- $ConversionFunctionList['UTF-16LE']['UTF-8'] = 'iconv_fallback_utf16le_utf8';
- $ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
- $ConversionFunctionList['UTF-16BE']['UTF-8'] = 'iconv_fallback_utf16be_utf8';
- }
- if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
- $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
- return getid3_lib::$ConversionFunction($string);
- }
- throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
- }
-
-
- static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
- $string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
- $HTMLstring = '';
-
- switch ($charset) {
- case '1251':
- case '1252':
- case '866':
- case '932':
- case '936':
- case '950':
- case 'BIG5':
- case 'BIG5-HKSCS':
- case 'cp1251':
- case 'cp1252':
- case 'cp866':
- case 'EUC-JP':
- case 'EUCJP':
- case 'GB2312':
- case 'ibm866':
- case 'ISO-8859-1':
- case 'ISO-8859-15':
- case 'ISO8859-1':
- case 'ISO8859-15':
- case 'KOI8-R':
- case 'koi8-ru':
- case 'koi8r':
- case 'Shift_JIS':
- case 'SJIS':
- case 'win-1251':
- case 'Windows-1251':
- case 'Windows-1252':
- $HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
- break;
-
- case 'UTF-8':
- $strlen = strlen($string);
- for ($i = 0; $i < $strlen; $i++) {
- $char_ord_val = ord($string{$i});
- $charval = 0;
- if ($char_ord_val < 0x80) {
- $charval = $char_ord_val;
- } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i+3 < $strlen) {
- $charval = (($char_ord_val & 0x07) << 18);
- $charval += ((ord($string{++$i}) & 0x3F) << 12);
- $charval += ((ord($string{++$i}) & 0x3F) << 6);
- $charval += (ord($string{++$i}) & 0x3F);
- } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i+2 < $strlen) {
- $charval = (($char_ord_val & 0x0F) << 12);
- $charval += ((ord($string{++$i}) & 0x3F) << 6);
- $charval += (ord($string{++$i}) & 0x3F);
- } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i+1 < $strlen) {
- $charval = (($char_ord_val & 0x1F) << 6);
- $charval += (ord($string{++$i}) & 0x3F);
- }
- if (($charval >= 32) && ($charval <= 127)) {
- $HTMLstring .= htmlentities(chr($charval));
- } else {
- $HTMLstring .= ''.$charval.';';
- }
- }
- break;
-
- case 'UTF-16LE':
- for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
- if (($charval >= 32) && ($charval <= 127)) {
- $HTMLstring .= chr($charval);
- } else {
- $HTMLstring .= ''.$charval.';';
- }
- }
- break;
-
- case 'UTF-16BE':
- for ($i = 0; $i < strlen($string); $i += 2) {
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
- if (($charval >= 32) && ($charval <= 127)) {
- $HTMLstring .= chr($charval);
- } else {
- $HTMLstring .= ''.$charval.';';
- }
- }
- break;
-
- default:
- $HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()';
- break;
- }
- return $HTMLstring;
- }
-
-
-
- static function RGADnameLookup($namecode) {
- static $RGADname = array();
- if (empty($RGADname)) {
- $RGADname[0] = 'not set';
- $RGADname[1] = 'Track Gain Adjustment';
- $RGADname[2] = 'Album Gain Adjustment';
- }
-
- return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
- }
-
-
- static function RGADoriginatorLookup($originatorcode) {
- static $RGADoriginator = array();
- if (empty($RGADoriginator)) {
- $RGADoriginator[0] = 'unspecified';
- $RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
- $RGADoriginator[2] = 'set by user';
- $RGADoriginator[3] = 'determined automatically';
- }
-
- return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
- }
-
-
- static function RGADadjustmentLookup($rawadjustment, $signbit) {
- $adjustment = $rawadjustment / 10;
- if ($signbit == 1) {
- $adjustment *= -1;
- }
- return (float) $adjustment;
- }
-
-
- static function RGADgainString($namecode, $originatorcode, $replaygain) {
- if ($replaygain < 0) {
- $signbit = '1';
- } else {
- $signbit = '0';
- }
- $storedreplaygain = intval(round($replaygain * 10));
- $gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
- $gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
- $gainstring .= $signbit;
- $gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
-
- return $gainstring;
- }
-
- static function RGADamplitude2dB($amplitude) {
- return 20 * log10($amplitude);
- }
-
-
- static function GetDataImageSize($imgData, &$imageinfo) {
- static $tempdir = '';
- if (empty($tempdir)) {
- // yes this is ugly, feel free to suggest a better way
- require_once(dirname(__FILE__).'/getid3.php');
- $getid3_temp = new getID3();
- $tempdir = $getid3_temp->tempdir;
- unset($getid3_temp);
- }
- $GetDataImageSize = false;
- if ($tempfilename = tempnam($tempdir, 'gI3')) {
- if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) {
- fwrite($tmp, $imgData);
- fclose($tmp);
- $GetDataImageSize = @GetImageSize($tempfilename, $imageinfo);
- }
- unlink($tempfilename);
- }
- return $GetDataImageSize;
- }
-
- static function ImageTypesLookup($imagetypeid) {
- static $ImageTypesLookup = array();
- if (empty($ImageTypesLookup)) {
- $ImageTypesLookup[1] = 'gif';
- $ImageTypesLookup[2] = 'jpeg';
- $ImageTypesLookup[3] = 'png';
- $ImageTypesLookup[4] = 'swf';
- $ImageTypesLookup[5] = 'psd';
- $ImageTypesLookup[6] = 'bmp';
- $ImageTypesLookup[7] = 'tiff (little-endian)';
- $ImageTypesLookup[8] = 'tiff (big-endian)';
- $ImageTypesLookup[9] = 'jpc';
- $ImageTypesLookup[10] = 'jp2';
- $ImageTypesLookup[11] = 'jpx';
- $ImageTypesLookup[12] = 'jb2';
- $ImageTypesLookup[13] = 'swc';
- $ImageTypesLookup[14] = 'iff';
- }
- return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
- }
-
- static function CopyTagsToComments(&$ThisFileInfo) {
-
- // Copy all entries from ['tags'] into common ['comments']
- if (!empty($ThisFileInfo['tags'])) {
- foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
- foreach ($tagarray as $tagname => $tagdata) {
- foreach ($tagdata as $key => $value) {
- if (!empty($value)) {
- if (empty($ThisFileInfo['comments'][$tagname])) {
-
- // fall through and append value
-
- } elseif ($tagtype == 'id3v1') {
-
- $newvaluelength = strlen(trim($value));
- foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
- $oldvaluelength = strlen(trim($existingvalue));
- if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) {
- // new value is identical but shorter-than (or equal-length to) one already in comments - skip
- break 2;
- }
- }
-
- } elseif (!is_array($value)) {
-
- $newvaluelength = strlen(trim($value));
- foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
- $oldvaluelength = strlen(trim($existingvalue));
- if (($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
- $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
- break 2;
- }
- }
-
- }
- if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
- $value = (is_string($value) ? trim($value) : $value);
- $ThisFileInfo['comments'][$tagname][] = $value;
- }
- }
- }
- }
- }
-
- // Copy to ['comments_html']
- foreach ($ThisFileInfo['comments'] as $field => $values) {
- if ($field == 'picture') {
- // pictures can take up a lot of space, and we don't need multiple copies of them
- // let there be a single copy in [comments][picture], and not elsewhere
- continue;
- }
- foreach ($values as $index => $value) {
- if (is_array($value)) {
- $ThisFileInfo['comments_html'][$field][$index] = $value;
- } else {
- $ThisFileInfo['comments_html'][$field][$index] = str_replace('', '', getid3_lib::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
- }
- }
- }
- }
- return true;
- }
-
-
- static function EmbeddedLookup($key, $begin, $end, $file, $name) {
-
- // Cached
- static $cache;
- if (isset($cache[$file][$name])) {
- return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
- }
-
- // Init
- $keylength = strlen($key);
- $line_count = $end - $begin - 7;
-
- // Open php file
- $fp = fopen($file, 'r');
-
- // Discard $begin lines
- for ($i = 0; $i < ($begin + 3); $i++) {
- fgets($fp, 1024);
- }
-
- // Loop thru line
- while (0 < $line_count--) {
-
- // Read line
- $line = ltrim(fgets($fp, 1024), "\t ");
-
- // METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
- //$keycheck = substr($line, 0, $keylength);
- //if ($key == $keycheck) {
- // $cache[$file][$name][$keycheck] = substr($line, $keylength + 1);
- // break;
- //}
-
- // METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
- //$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
- $explodedLine = explode("\t", $line, 2);
- $ThisKey = (isset($explodedLine[0]) ? $explodedLine[0] : '');
- $ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : '');
- $cache[$file][$name][$ThisKey] = trim($ThisValue);
- }
-
- // Close and return
- fclose($fp);
- return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
- }
-
- static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
- global $GETID3_ERRORARRAY;
-
- if (file_exists($filename)) {
- if (include_once($filename)) {
- return true;
- } else {
- $diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
- }
- } else {
- $diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
- }
- if ($DieOnFailure) {
- throw new Exception($diemessage);
- } else {
- $GETID3_ERRORARRAY[] = $diemessage;
- }
- return false;
- }
-
- public static function trimNullByte($string) {
- return trim($string, "\x00");
- }
-
-}
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/getid3.php b/app/library/getid3/getid3.php
deleted file mode 100644
index e8a3f7e2..00000000
--- a/app/library/getid3/getid3.php
+++ /dev/null
@@ -1,1744 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// Please see readme.txt for more information //
-// ///
-/////////////////////////////////////////////////////////////////
-
-// attempt to define temp dir as something flexible but reliable
-$temp_dir = ini_get('upload_tmp_dir');
-if ($temp_dir && (!is_dir($temp_dir) || !is_readable($temp_dir))) {
- $temp_dir = '';
-}
-if (!$temp_dir && function_exists('sys_get_temp_dir')) {
- // PHP v5.2.1+
- // sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts
- $temp_dir = sys_get_temp_dir();
-}
-$temp_dir = realpath($temp_dir);
-$open_basedir = ini_get('open_basedir');
-if ($open_basedir) {
- // e.g. "/var/www/vhosts/getid3.org/httpdocs/:/tmp/"
- $temp_dir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $temp_dir);
- $open_basedir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $open_basedir);
- if (substr($temp_dir, -1, 1) != DIRECTORY_SEPARATOR) {
- $temp_dir .= DIRECTORY_SEPARATOR;
- }
- $found_valid_tempdir = false;
- $open_basedirs = explode(':', $open_basedir);
- foreach ($open_basedirs as $basedir) {
- if (substr($basedir, -1, 1) != DIRECTORY_SEPARATOR) {
- $basedir .= DIRECTORY_SEPARATOR;
- }
- if (preg_match('#^'.preg_quote($basedir).'#', $temp_dir)) {
- $found_valid_tempdir = true;
- break;
- }
- }
- if (!$found_valid_tempdir) {
- $temp_dir = '';
- }
- unset($open_basedirs, $found_valid_tempdir, $basedir);
-}
-if (!$temp_dir) {
- $temp_dir = '*'; // invalid directory name should force tempnam() to use system default temp dir
-}
-// $temp_dir = '/something/else/'; // feel free to override temp dir here if it works better for your system
-define('GETID3_TEMP_DIR', $temp_dir);
-unset($open_basedir, $temp_dir);
-
-
-// define a constant rather than looking up every time it is needed
-if (!defined('GETID3_OS_ISWINDOWS')) {
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
- define('GETID3_OS_ISWINDOWS', true);
- } else {
- define('GETID3_OS_ISWINDOWS', false);
- }
-}
-
-// Get base path of getID3() - ONCE
-if (!defined('GETID3_INCLUDEPATH')) {
- foreach (get_included_files() as $key => $val) {
- if (basename($val) == 'getid3.php') {
- define('GETID3_INCLUDEPATH', dirname($val).DIRECTORY_SEPARATOR);
- break;
- }
- }
-}
-
-// End: Defines
-
-
-class getID3
-{
- // public: Settings
- public $encoding = 'UTF-8'; // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
- public $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252'
-
- // public: Optional tag checks - disable for speed.
- public $option_tag_id3v1 = true; // Read and process ID3v1 tags
- public $option_tag_id3v2 = true; // Read and process ID3v2 tags
- public $option_tag_lyrics3 = true; // Read and process Lyrics3 tags
- public $option_tag_apetag = true; // Read and process APE tags
- public $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding
- public $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
-
- // public: Optional tag/comment calucations
- public $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc
-
- // public: Optional handling of embedded attachments (e.g. images)
- public $option_save_attachments = true; // defaults to true (ATTACHMENTS_INLINE) for backward compatibility
-
- // public: Optional calculations
- public $option_md5_data = false; // Get MD5 sum of data part - slow
- public $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
- public $option_sha1_data = false; // Get SHA1 sum of data part - slow
- public $option_max_2gb_check = null; // Check whether file is larger than 2GB and thus not supported by 32-bit PHP (null: auto-detect based on PHP_INT_MAX)
-
- // public: Read buffer size in bytes
- public $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.
-
- // Protected variables
- protected $startup_error = '';
- protected $startup_warning = '';
- protected $memory_limit = 0;
-
- const VERSION = '1.9.3-20111213';
- const FREAD_BUFFER_SIZE = 32768;
- var $tempdir = GETID3_TEMP_DIR;
-
- const ATTACHMENTS_NONE = false;
- const ATTACHMENTS_INLINE = true;
-
- // public: constructor
- public function __construct() {
-
- // Check for PHP version
- $required_php_version = '5.0.5';
- 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';
- }
-
- // Check safe_mode off
- if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
- $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
- }
-
- if (intval(ini_get('mbstring.func_overload')) > 0) {
- $this->warning('WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", this may break things.');
- }
-
- // Check for magic_quotes_runtime
- if (function_exists('get_magic_quotes_runtime')) {
- if (get_magic_quotes_runtime()) {
- return $this->startup_error('magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).');
- }
- }
-
- // Check for magic_quotes_gpc
- if (function_exists('magic_quotes_gpc')) {
- if (get_magic_quotes_gpc()) {
- return $this->startup_error('magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).');
- }
- }
-
- // Load support library
- if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
- $this->startup_error .= 'getid3.lib.php is missing or corrupt';
- }
-
- if ($this->option_max_2gb_check === null) {
- $this->option_max_2gb_check = (PHP_INT_MAX <= 2147483647);
- }
-
-
- // Needed for Windows only:
- // Define locations of helper applications for Shorten, VorbisComment, MetaFLAC
- // as well as other helper functions such as head, tail, md5sum, etc
- // This path cannot contain spaces, but the below code will attempt to get the
- // 8.3-equivalent path automatically
- // IMPORTANT: This path must include the trailing slash
- if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
-
- $helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
-
- if (!is_dir($helperappsdir)) {
- $this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
- } elseif (strpos(realpath($helperappsdir), ' ') !== false) {
- $DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
- $path_so_far = array();
- foreach ($DirPieces as $key => $value) {
- if (strpos($value, ' ') !== false) {
- if (!empty($path_so_far)) {
- $commandline = 'dir /x '.escapeshellarg(implode(DIRECTORY_SEPARATOR, $path_so_far));
- $dir_listing = `$commandline`;
- $lines = explode("\n", $dir_listing);
- foreach ($lines as $line) {
- $line = trim($line);
- if (preg_match('#^([0-9/]{10}) +([0-9:]{4,5}( [AP]M)?) +(|[0-9,]+) +([^ ]{0,11}) +(.+)$#', $line, $matches)) {
- list($dummy, $date, $time, $ampm, $filesize, $shortname, $filename) = $matches;
- if ((strtoupper($filesize) == '') && (strtolower($filename) == strtolower($value))) {
- $value = $shortname;
- }
- }
- }
- } else {
- $this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.';
- }
- }
- $path_so_far[] = $value;
- }
- $helperappsdir = implode(DIRECTORY_SEPARATOR, $path_so_far);
- }
- define('GETID3_HELPERAPPSDIR', $helperappsdir.DIRECTORY_SEPARATOR);
- }
-
- return true;
- }
-
- public function version() {
- return self::VERSION;
- }
-
- public function fread_buffer_size() {
- return $this->option_fread_buffer_size;
- }
-
-
- // public: setOption
- 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();
- $this->info['GETID3_VERSION'] = $this->version();
- $this->info['php_memory_limit'] = $this->memory_limit;
-
- // 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'))) {
- // great
- } else {
- throw new getid3_exception('Could not open "'.$filename.'" (does not exist, or is not a file)');
- }
-
- $this->info['filesize'] = filesize($filename);
- // set redundant parameters - might be needed in some include file
- $this->info['filename'] = basename($filename);
- $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
- $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
-
-
- // option_max_2gb_check
- if ($this->option_max_2gb_check) {
- // PHP (32-bit all, and 64-bit Windows) doesn't support integers larger than 2^31 (~2GB)
- // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
- // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
- $fseek = fseek($this->fp, 0, SEEK_END);
- if (($fseek < 0) || (($this->info['filesize'] != 0) && (ftell($this->fp) == 0)) ||
- ($this->info['filesize'] < 0) ||
- (ftell($this->fp) < 0)) {
- $real_filesize = false;
- if (GETID3_OS_ISWINDOWS) {
- $commandline = 'dir /-C "'.str_replace('/', DIRECTORY_SEPARATOR, $filename).'"';
- $dir_output = `$commandline`;
- if (preg_match('#1 File\(s\)[ ]+([0-9]+) bytes#i', $dir_output, $matches)) {
- $real_filesize = (float) $matches[1];
- }
- } else {
- $commandline = 'ls -o -g -G --time-style=long-iso '.escapeshellarg($filename);
- $dir_output = `$commandline`;
- if (preg_match('#([0-9]+) ([0-9]{4}-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}) '.str_replace('#', '\\#', preg_quote($filename)).'$#', $dir_output, $matches)) {
- $real_filesize = (float) $matches[1];
- }
- }
- if ($real_filesize === false) {
- unset($this->info['filesize']);
- fclose($this->fp);
- throw new getid3_exception('Unable to determine actual filesize. File is most likely larger than '.round(PHP_INT_MAX / 1073741824).'GB and is not supported by PHP.');
- } elseif (getid3_lib::intValueSupported($real_filesize)) {
- unset($this->info['filesize']);
- fclose($this->fp);
- throw new getid3_exception('PHP seems to think the file is larger than '.round(PHP_INT_MAX / 1073741824).'GB, but filesystem reports it as '.number_format($real_filesize, 3).'GB, please report to info@getid3.org');
- }
- $this->info['filesize'] = $real_filesize;
- $this->error('File is larger than '.round(PHP_INT_MAX / 1073741824).'GB (filesystem reports it as '.number_format($real_filesize, 3).'GB) and is not properly supported by PHP.');
- }
- }
-
- // 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
- function analyze($filename) {
- try {
- if (!$this->openfile($filename)) {
- return $this->info;
- }
-
- // Handle tags
- foreach (array('id3v2'=>'id3v2', 'id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
- $option_tag = 'option_tag_'.$tag_name;
- if ($this->$option_tag) {
- $this->include_module('tag.'.$tag_name);
- try {
- $tag_class = 'getid3_'.$tag_name;
- $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']);
- }
- }
-
- // ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier
- if (!$this->option_tag_id3v2) {
- fseek($this->fp, 0, SEEK_SET);
- $header = fread($this->fp, 10);
- if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) {
- $this->info['id3v2']['header'] = true;
- $this->info['id3v2']['majorversion'] = ord($header{3});
- $this->info['id3v2']['minorversion'] = ord($header{4});
- $this->info['avdataoffset'] += getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
- }
- }
-
- // read 32 kb file data
- fseek($this->fp, $this->info['avdataoffset'], SEEK_SET);
- $formattest = fread($this->fp, 32774);
-
- // determine format
- $determined_format = $this->GetFileFormat($formattest, $filename);
-
- // unable to determine file format
- if (!$determined_format) {
- fclose($this->fp);
- return $this->error('unable to determine file format');
- }
-
- // check for illegal ID3 tags
- if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
- if ($determined_format['fail_id3'] === 'ERROR') {
- fclose($this->fp);
- return $this->error('ID3 tags not allowed on this file type.');
- } elseif ($determined_format['fail_id3'] === 'WARNING') {
- $this->warning('ID3 tags not allowed on this file type.');
- }
- }
-
- // check for illegal APE tags
- if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
- if ($determined_format['fail_ape'] === 'ERROR') {
- fclose($this->fp);
- return $this->error('APE tags not allowed on this file type.');
- } elseif ($determined_format['fail_ape'] === 'WARNING') {
- $this->warning('APE tags not allowed on this file type.');
- }
- }
-
- // set mime type
- $this->info['mime_type'] = $determined_format['mime_type'];
-
- // supported format signature pattern detected, but module deleted
- if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
- fclose($this->fp);
- return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
- }
-
- // module requires iconv support
- // Check encoding/iconv support
- if (!empty($determined_format['iconv_req']) && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
- $errormessage = 'iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
- if (GETID3_OS_ISWINDOWS) {
- $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
- } else {
- $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
- }
- return $this->error($errormessage);
- }
-
- // include module
- include_once(GETID3_INCLUDEPATH.$determined_format['include']);
-
- // instantiate module class
- $class_name = 'getid3_'.$determined_format['module'];
- if (!class_exists($class_name)) {
- return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
- }
- //if (isset($determined_format['option'])) {
- // //$class = new $class_name($this->fp, $this->info, $determined_format['option']);
- //} else {
- //$class = new $class_name($this->fp, $this->info);
- $class = new $class_name($this);
- //}
-
- if (!empty($determined_format['set_inline_attachments'])) {
- $class->inline_attachments = $this->option_save_attachments;
- }
- $class->Analyze();
-
- unset($class);
-
- // close file
- fclose($this->fp);
-
- // process all tags - copy to 'tags' and convert charsets
- if ($this->option_tags_process) {
- $this->HandleAllTags();
- }
-
- // perform more calculations
- if ($this->option_extra_info) {
- $this->ChannelsBitratePlaytimeCalculations();
- $this->CalculateCompressionRatioVideo();
- $this->CalculateCompressionRatioAudio();
- $this->CalculateReplayGain();
- $this->ProcessAudioStreams();
- }
-
- // get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
- if ($this->option_md5_data) {
- // do not cald md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
- if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
- $this->getHashdata('md5');
- }
- }
-
- // get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
- if ($this->option_sha1_data) {
- $this->getHashdata('sha1');
- }
-
- // remove undesired keys
- $this->CleanUp();
-
- } catch (Exception $e) {
- $this->error('Caught exception: '.$e->getMessage());
- }
-
- // return info array
- return $this->info;
- }
-
-
- // private: error handling
- function error($message) {
- $this->CleanUp();
- if (!isset($this->info['error'])) {
- $this->info['error'] = array();
- }
- $this->info['error'][] = $message;
- return $this->info;
- }
-
-
- // private: warning handling
- function warning($message) {
- $this->info['warning'][] = $message;
- return true;
- }
-
-
- // private: CleanUp
- 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;
- }
-
-
- // return array containing information about all supported formats
- function GetFileFormatArray() {
- static $format_info = array();
- if (empty($format_info)) {
- $format_info = array(
-
- // Audio formats
-
- // AC-3 - audio - Dolby AC-3 / Dolby Digital
- 'ac3' => array(
- 'pattern' => '^\x0B\x77',
- 'group' => 'audio',
- 'module' => 'ac3',
- 'mime_type' => 'audio/ac3',
- ),
-
- // AAC - audio - Advanced Audio Coding (AAC) - ADIF format
- 'adif' => array(
- 'pattern' => '^ADIF',
- 'group' => 'audio',
- 'module' => 'aac',
- 'mime_type' => 'application/octet-stream',
- 'fail_ape' => 'WARNING',
- ),
-
-
- // AA - audio - Audible Audiobook
- 'adts' => array(
- 'pattern' => '^.{4}\x57\x90\x75\x36',
- 'group' => 'audio',
- 'module' => 'aa',
- 'mime_type' => 'audio/audible ',
- ),
-
- // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
- 'adts' => array(
- 'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
- 'group' => 'audio',
- 'module' => 'aac',
- 'mime_type' => 'application/octet-stream',
- 'fail_ape' => 'WARNING',
- ),
-
-
- // AU - audio - NeXT/Sun AUdio (AU)
- 'au' => array(
- 'pattern' => '^\.snd',
- 'group' => 'audio',
- 'module' => 'au',
- 'mime_type' => 'audio/basic',
- ),
-
- // AVR - audio - Audio Visual Research
- 'avr' => array(
- 'pattern' => '^2BIT',
- 'group' => 'audio',
- 'module' => 'avr',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // BONK - audio - Bonk v0.9+
- 'bonk' => array(
- 'pattern' => '^\x00(BONK|INFO|META| ID3)',
- 'group' => 'audio',
- 'module' => 'bonk',
- 'mime_type' => 'audio/xmms-bonk',
- ),
-
- // DSS - audio - Digital Speech Standard
- 'dss' => array(
- 'pattern' => '^[\x02-\x03]dss',
- 'group' => 'audio',
- 'module' => 'dss',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // DTS - audio - Dolby Theatre System
- 'dts' => array(
- 'pattern' => '^\x7F\xFE\x80\x01',
- 'group' => 'audio',
- 'module' => 'dts',
- 'mime_type' => 'audio/dts',
- ),
-
- // FLAC - audio - Free Lossless Audio Codec
- 'flac' => array(
- 'pattern' => '^fLaC',
- 'group' => 'audio',
- 'module' => 'flac',
- 'mime_type' => 'audio/x-flac',
- 'set_inline_attachments' => true,
- ),
-
- // LA - audio - Lossless Audio (LA)
- 'la' => array(
- 'pattern' => '^LA0[2-4]',
- 'group' => 'audio',
- 'module' => 'la',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // LPAC - audio - Lossless Predictive Audio Compression (LPAC)
- 'lpac' => array(
- 'pattern' => '^LPAC',
- 'group' => 'audio',
- 'module' => 'lpac',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // MIDI - audio - MIDI (Musical Instrument Digital Interface)
- 'midi' => array(
- 'pattern' => '^MThd',
- 'group' => 'audio',
- 'module' => 'midi',
- 'mime_type' => 'audio/midi',
- ),
-
- // MAC - audio - Monkey's Audio Compressor
- 'mac' => array(
- 'pattern' => '^MAC ',
- 'group' => 'audio',
- 'module' => 'monkey',
- 'mime_type' => 'application/octet-stream',
- ),
-
-// has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available
-// // MOD - audio - MODule (assorted sub-formats)
-// 'mod' => array(
-// 'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)',
-// 'group' => 'audio',
-// 'module' => 'mod',
-// 'option' => 'mod',
-// 'mime_type' => 'audio/mod',
-// ),
-
- // MOD - audio - MODule (Impulse Tracker)
- 'it' => array(
- 'pattern' => '^IMPM',
- 'group' => 'audio',
- 'module' => 'mod',
- //'option' => 'it',
- 'mime_type' => 'audio/it',
- ),
-
- // MOD - audio - MODule (eXtended Module, various sub-formats)
- 'xm' => array(
- 'pattern' => '^Extended Module',
- 'group' => 'audio',
- 'module' => 'mod',
- //'option' => 'xm',
- 'mime_type' => 'audio/xm',
- ),
-
- // MOD - audio - MODule (ScreamTracker)
- 's3m' => array(
- 'pattern' => '^.{44}SCRM',
- 'group' => 'audio',
- 'module' => 'mod',
- //'option' => 's3m',
- 'mime_type' => 'audio/s3m',
- ),
-
- // MPC - audio - Musepack / MPEGplus
- 'mpc' => array(
- 'pattern' => '^(MPCK|MP\+|[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
- 'group' => 'audio',
- 'module' => 'mpc',
- 'mime_type' => 'audio/x-musepack',
- ),
-
- // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS)
- 'mp3' => array(
- 'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\x0B\x10-\x1B\x20-\x2B\x30-\x3B\x40-\x4B\x50-\x5B\x60-\x6B\x70-\x7B\x80-\x8B\x90-\x9B\xA0-\xAB\xB0-\xBB\xC0-\xCB\xD0-\xDB\xE0-\xEB\xF0-\xFB]',
- 'group' => 'audio',
- 'module' => 'mp3',
- 'mime_type' => 'audio/mpeg',
- ),
-
- // OFR - audio - OptimFROG
- 'ofr' => array(
- 'pattern' => '^(\*RIFF|OFR)',
- 'group' => 'audio',
- 'module' => 'optimfrog',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // RKAU - audio - RKive AUdio compressor
- 'rkau' => array(
- 'pattern' => '^RKA',
- 'group' => 'audio',
- 'module' => 'rkau',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // SHN - audio - Shorten
- 'shn' => array(
- 'pattern' => '^ajkg',
- 'group' => 'audio',
- 'module' => 'shorten',
- 'mime_type' => 'audio/xmms-shn',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org)
- 'tta' => array(
- 'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
- 'group' => 'audio',
- 'module' => 'tta',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // VOC - audio - Creative Voice (VOC)
- 'voc' => array(
- 'pattern' => '^Creative Voice File',
- 'group' => 'audio',
- 'module' => 'voc',
- 'mime_type' => 'audio/voc',
- ),
-
- // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF)
- 'vqf' => array(
- 'pattern' => '^TWIN',
- 'group' => 'audio',
- 'module' => 'vqf',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // WV - audio - WavPack (v4.0+)
- 'wv' => array(
- 'pattern' => '^wvpk',
- 'group' => 'audio',
- 'module' => 'wavpack',
- 'mime_type' => 'application/octet-stream',
- ),
-
-
- // Audio-Video formats
-
- // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
- 'asf' => array(
- 'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
- 'group' => 'audio-video',
- 'module' => 'asf',
- 'mime_type' => 'video/x-ms-asf',
- 'iconv_req' => false,
- ),
-
- // BINK - audio/video - Bink / Smacker
- 'bink' => array(
- 'pattern' => '^(BIK|SMK)',
- 'group' => 'audio-video',
- 'module' => 'bink',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // FLV - audio/video - FLash Video
- 'flv' => array(
- 'pattern' => '^FLV\x01',
- 'group' => 'audio-video',
- 'module' => 'flv',
- 'mime_type' => 'video/x-flv',
- ),
-
- // MKAV - audio/video - Mastroka
- 'matroska' => array(
- 'pattern' => '^\x1A\x45\xDF\xA3',
- 'group' => 'audio-video',
- 'module' => 'matroska',
- 'mime_type' => 'video/x-matroska', // may also be audio/x-matroska
- 'set_inline_attachments' => true,
- ),
-
- // MPEG - audio/video - MPEG (Moving Pictures Experts Group)
- 'mpeg' => array(
- 'pattern' => '^\x00\x00\x01(\xBA|\xB3)',
- 'group' => 'audio-video',
- 'module' => 'mpeg',
- 'mime_type' => 'video/mpeg',
- ),
-
- // NSV - audio/video - Nullsoft Streaming Video (NSV)
- 'nsv' => array(
- 'pattern' => '^NSV[sf]',
- 'group' => 'audio-video',
- 'module' => 'nsv',
- 'mime_type' => 'application/octet-stream',
- ),
-
- // Ogg - audio/video - Ogg (Ogg-Vorbis, Ogg-FLAC, Speex, Ogg-Theora(*), Ogg-Tarkin(*))
- 'ogg' => array(
- 'pattern' => '^OggS',
- 'group' => 'audio',
- 'module' => 'ogg',
- 'mime_type' => 'application/ogg',
- 'fail_id3' => 'WARNING',
- 'fail_ape' => 'WARNING',
- 'set_inline_attachments' => true,
- ),
-
- // QT - audio/video - Quicktime
- 'quicktime' => array(
- 'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
- 'group' => 'audio-video',
- 'module' => 'quicktime',
- 'mime_type' => 'video/quicktime',
- ),
-
- // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
- 'riff' => array(
- 'pattern' => '^(RIFF|SDSS|FORM)',
- 'group' => 'audio-video',
- 'module' => 'riff',
- 'mime_type' => 'audio/x-wave',
- 'fail_ape' => 'WARNING',
- ),
-
- // Real - audio/video - RealAudio, RealVideo
- 'real' => array(
- 'pattern' => '^(\\.RMF|\\.ra)',
- 'group' => 'audio-video',
- 'module' => 'real',
- 'mime_type' => 'audio/x-realaudio',
- ),
-
- // SWF - audio/video - ShockWave Flash
- 'swf' => array(
- 'pattern' => '^(F|C)WS',
- 'group' => 'audio-video',
- 'module' => 'swf',
- 'mime_type' => 'application/x-shockwave-flash',
- ),
-
-
- // Still-Image formats
-
- // BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
- 'bmp' => array(
- 'pattern' => '^BM',
- 'group' => 'graphic',
- 'module' => 'bmp',
- 'mime_type' => 'image/bmp',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // GIF - still image - Graphics Interchange Format
- 'gif' => array(
- 'pattern' => '^GIF',
- 'group' => 'graphic',
- 'module' => 'gif',
- 'mime_type' => 'image/gif',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // JPEG - still image - Joint Photographic Experts Group (JPEG)
- 'jpg' => array(
- 'pattern' => '^\xFF\xD8\xFF',
- 'group' => 'graphic',
- 'module' => 'jpg',
- 'mime_type' => 'image/jpeg',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // PCD - still image - Kodak Photo CD
- 'pcd' => array(
- 'pattern' => '^.{2048}PCD_IPI\x00',
- 'group' => 'graphic',
- 'module' => 'pcd',
- 'mime_type' => 'image/x-photo-cd',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
-
- // PNG - still image - Portable Network Graphics (PNG)
- 'png' => array(
- 'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
- 'group' => 'graphic',
- 'module' => 'png',
- 'mime_type' => 'image/png',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
-
- // SVG - still image - Scalable Vector Graphics (SVG)
- 'svg' => array(
- 'pattern' => '( 'graphic',
- 'module' => 'svg',
- 'mime_type' => 'image/svg+xml',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
-
- // TIFF - still image - Tagged Information File Format (TIFF)
- 'tiff' => array(
- 'pattern' => '^(II\x2A\x00|MM\x00\x2A)',
- 'group' => 'graphic',
- 'module' => 'tiff',
- 'mime_type' => 'image/tiff',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
-
- // EFAX - still image - eFax (TIFF derivative)
- 'bmp' => array(
- 'pattern' => '^\xDC\xFE',
- 'group' => 'graphic',
- 'module' => 'efax',
- 'mime_type' => 'image/efax',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
-
- // Data formats
-
- // ISO - data - International Standards Organization (ISO) CD-ROM Image
- 'iso' => array(
- 'pattern' => '^.{32769}CD001',
- 'group' => 'misc',
- 'module' => 'iso',
- 'mime_type' => 'application/octet-stream',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- 'iconv_req' => false,
- ),
-
- // RAR - data - RAR compressed data
- 'rar' => array(
- 'pattern' => '^Rar\!',
- 'group' => 'archive',
- 'module' => 'rar',
- 'mime_type' => 'application/octet-stream',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // SZIP - audio/data - SZIP compressed data
- 'szip' => array(
- 'pattern' => '^SZ\x0A\x04',
- 'group' => 'archive',
- 'module' => 'szip',
- 'mime_type' => 'application/octet-stream',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // TAR - data - TAR compressed data
- 'tar' => array(
- 'pattern' => '^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
- 'group' => 'archive',
- 'module' => 'tar',
- 'mime_type' => 'application/x-tar',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // GZIP - data - GZIP compressed data
- 'gz' => array(
- 'pattern' => '^\x1F\x8B\x08',
- 'group' => 'archive',
- 'module' => 'gzip',
- 'mime_type' => 'application/x-gzip',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // ZIP - data - ZIP compressed data
- 'zip' => array(
- 'pattern' => '^PK\x03\x04',
- 'group' => 'archive',
- 'module' => 'zip',
- 'mime_type' => 'application/zip',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
-
- // Misc other formats
-
- // PAR2 - data - Parity Volume Set Specification 2.0
- 'par2' => array (
- 'pattern' => '^PAR2\x00PKT',
- 'group' => 'misc',
- 'module' => 'par2',
- 'mime_type' => 'application/octet-stream',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // PDF - data - Portable Document Format
- 'pdf' => array(
- 'pattern' => '^\x25PDF',
- 'group' => 'misc',
- 'module' => 'pdf',
- 'mime_type' => 'application/pdf',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // MSOFFICE - data - ZIP compressed data
- 'msoffice' => array(
- 'pattern' => '^\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1', // D0CF11E == DOCFILE == Microsoft Office Document
- 'group' => 'misc',
- 'module' => 'msoffice',
- 'mime_type' => 'application/octet-stream',
- 'fail_id3' => 'ERROR',
- 'fail_ape' => 'ERROR',
- ),
-
- // CUE - data - CUEsheet (index to single-file disc images)
- 'cue' => array(
- 'pattern' => '', // empty pattern means cannot be automatically detected, will fall through all other formats and match based on filename and very basic file contents
- 'group' => 'misc',
- 'module' => 'cue',
- 'mime_type' => 'application/octet-stream',
- ),
-
- );
- }
-
- return $format_info;
- }
-
-
-
- function GetFileFormat(&$filedata, $filename='') {
- // this function will determine the format of a file based on usually
- // the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
- // and in the case of ISO CD image, 6 bytes offset 32kb from the start
- // of the file).
-
- // Identify file format - loop through $format_info and detect with reg expr
- foreach ($this->GetFileFormatArray() as $format_name => $info) {
- // The /s switch on preg_match() forces preg_match() NOT to treat
- // newline (0x0A) characters as special chars but do a binary match
- if (!empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) {
- $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
- return $info;
- }
- }
-
-
- if (preg_match('#\.mp[123a]$#i', $filename)) {
- // Too many mp3 encoders on the market put gabage in front of mpeg files
- // use assume format on these if format detection failed
- $GetFileFormatArray = $this->GetFileFormatArray();
- $info = $GetFileFormatArray['mp3'];
- $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
- return $info;
- } elseif (preg_match('/\.cue$/i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {
- // there's not really a useful consistent "magic" at the beginning of .cue files to identify them
- // so until I think of something better, just go by filename if all other format checks fail
- // and verify there's at least one instance of "TRACK xx AUDIO" in the file
- $GetFileFormatArray = $this->GetFileFormatArray();
- $info = $GetFileFormatArray['cue'];
- $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
- return $info;
- }
-
- return false;
- }
-
-
- // converts array to $encoding charset from $this->encoding
- function CharConvert(&$array, $encoding) {
-
- // identical encoding - end here
- if ($encoding == $this->encoding) {
- return;
- }
-
- // loop thru array
- foreach ($array as $key => $value) {
-
- // go recursive
- if (is_array($value)) {
- $this->CharConvert($array[$key], $encoding);
- }
-
- // convert string
- elseif (is_string($value)) {
- $array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
- }
- }
- }
-
-
- function HandleAllTags() {
-
- // key name => array (tag name, character encoding)
- static $tags;
- if (empty($tags)) {
- $tags = array(
- 'asf' => array('asf' , 'UTF-16LE'),
- 'midi' => array('midi' , 'ISO-8859-1'),
- 'nsv' => array('nsv' , 'ISO-8859-1'),
- 'ogg' => array('vorbiscomment' , 'UTF-8'),
- 'png' => array('png' , 'UTF-8'),
- 'tiff' => array('tiff' , 'ISO-8859-1'),
- 'quicktime' => array('quicktime' , 'UTF-8'),
- 'real' => array('real' , 'ISO-8859-1'),
- 'vqf' => array('vqf' , 'ISO-8859-1'),
- 'zip' => array('zip' , 'ISO-8859-1'),
- 'riff' => array('riff' , 'ISO-8859-1'),
- 'lyrics3' => array('lyrics3' , 'ISO-8859-1'),
- 'id3v1' => array('id3v1' , $this->encoding_id3v1),
- 'id3v2' => array('id3v2' , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
- 'ape' => array('ape' , 'UTF-8'),
- 'cue' => array('cue' , 'ISO-8859-1'),
- 'matroska' => array('matroska' , 'UTF-8'),
- );
- }
-
- // loop through comments array
- foreach ($tags as $comment_name => $tagname_encoding_array) {
- list($tag_name, $encoding) = $tagname_encoding_array;
-
- // fill in default encoding type if not already present
- if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
- $this->info[$comment_name]['encoding'] = $encoding;
- }
-
- // copy comments if key name set
- if (!empty($this->info[$comment_name]['comments'])) {
-
- foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
- foreach ($valuearray as $key => $value) {
- if (is_string($value)) {
- $value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed!
- }
- if ($value) {
- $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value;
- }
- }
- }
-
- if (!isset($this->info['tags'][$tag_name])) {
- // comments are set but contain nothing but empty strings, so skip
- continue;
- }
-
- if ($this->option_tags_html) {
- foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
- foreach ($valuearray as $key => $value) {
- if (is_string($value)) {
- //$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
- $this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('', '', trim(getid3_lib::MultiByteCharString2HTML($value, $encoding)));
- } else {
- $this->info['tags_html'][$tag_name][$tag_key][$key] = $value;
- }
- }
- }
- }
-
- $this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!
- }
-
- }
-
- // pictures can take up a lot of space, and we don't need multiple copies of them
- // let there be a single copy in [comments][picture], and not elsewhere
- if (!empty($this->info['tags'])) {
- $unset_keys = array('tags', 'tags_html');
- foreach ($this->info['tags'] as $tagtype => $tagarray) {
- foreach ($tagarray as $tagname => $tagdata) {
- if ($tagname == 'picture') {
- foreach ($tagdata as $key => $tagarray) {
- $this->info['comments']['picture'][] = $tagarray;
- if (isset($tagarray['data']) && isset($tagarray['image_mime'])) {
- if (isset($this->info['tags'][$tagtype][$tagname][$key])) {
- unset($this->info['tags'][$tagtype][$tagname][$key]);
- }
- if (isset($this->info['tags_html'][$tagtype][$tagname][$key])) {
- unset($this->info['tags_html'][$tagtype][$tagname][$key]);
- }
- }
- }
- }
- }
- foreach ($unset_keys as $unset_key) {
- // remove possible empty keys from (e.g. [tags][id3v2][picture])
- if (empty($this->info[$unset_key][$tagtype]['picture'])) {
- unset($this->info[$unset_key][$tagtype]['picture']);
- }
- if (empty($this->info[$unset_key][$tagtype])) {
- unset($this->info[$unset_key][$tagtype]);
- }
- if (empty($this->info[$unset_key])) {
- unset($this->info[$unset_key]);
- }
- }
- // remove duplicate copy of picture data from (e.g. [id3v2][comments][picture])
- if (isset($this->info[$tagtype]['comments']['picture'])) {
- unset($this->info[$tagtype]['comments']['picture']);
- }
- if (empty($this->info[$tagtype]['comments'])) {
- unset($this->info[$tagtype]['comments']);
- }
- if (empty($this->info[$tagtype])) {
- unset($this->info[$tagtype]);
- }
- }
- }
- return true;
- }
-
-
- function getHashdata($algorithm) {
- switch ($algorithm) {
- case 'md5':
- case 'sha1':
- break;
-
- default:
- return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
- break;
- }
-
- if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) {
-
- // We cannot get an identical md5_data value for Ogg files where the comments
- // span more than 1 Ogg page (compared to the same audio data with smaller
- // comments) using the normal getID3() method of MD5'ing the data between the
- // end of the comments and the end of the file (minus any trailing tags),
- // because the page sequence numbers of the pages that the audio data is on
- // do not match. Under normal circumstances, where comments are smaller than
- // the nominal 4-8kB page size, then this is not a problem, but if there are
- // very large comments, the only way around it is to strip off the comment
- // tags with vorbiscomment and MD5 that file.
- // This procedure must be applied to ALL Ogg files, not just the ones with
- // comments larger than 1 page, because the below method simply MD5's the
- // whole file with the comments stripped, not just the portion after the
- // comments block (which is the standard getID3() method.
-
- // The above-mentioned problem of comments spanning multiple pages and changing
- // page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
- // currently vorbiscomment only works on OggVorbis files.
-
- if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
-
- $this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)');
- $this->info[$algorithm.'_data'] = false;
-
- } else {
-
- // Prevent user from aborting script
- $old_abort = ignore_user_abort(true);
-
- // Create empty file
- $empty = tempnam(GETID3_TEMP_DIR, 'getID3');
- touch($empty);
-
- // Use vorbiscomment to make temp file without comments
- $temp = tempnam(GETID3_TEMP_DIR, 'getID3');
- $file = $this->info['filenamepath'];
-
- if (GETID3_OS_ISWINDOWS) {
-
- if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
-
- $commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';
- $VorbisCommentError = `$commandline`;
-
- } else {
-
- $VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
-
- }
-
- } else {
-
- $commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1';
- $commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
- $VorbisCommentError = `$commandline`;
-
- }
-
- if (!empty($VorbisCommentError)) {
-
- $this->info['warning'][] = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
- $this->info[$algorithm.'_data'] = false;
-
- } else {
-
- // Get hash of newly created file
- switch ($algorithm) {
- case 'md5':
- $this->info[$algorithm.'_data'] = md5_file($temp);
- break;
-
- case 'sha1':
- $this->info[$algorithm.'_data'] = sha1_file($temp);
- break;
- }
- }
-
- // Clean up
- unlink($empty);
- unlink($temp);
-
- // Reset abort setting
- ignore_user_abort($old_abort);
-
- }
-
- } else {
-
- if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
-
- // get hash from part of file
- $this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
-
- } else {
-
- // get hash from whole file
- switch ($algorithm) {
- case 'md5':
- $this->info[$algorithm.'_data'] = md5_file($this->info['filenamepath']);
- break;
-
- case 'sha1':
- $this->info[$algorithm.'_data'] = sha1_file($this->info['filenamepath']);
- break;
- }
- }
-
- }
- return true;
- }
-
-
- function ChannelsBitratePlaytimeCalculations() {
-
- // set channelmode on audio
- if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
- // ignore
- } elseif ($this->info['audio']['channels'] == 1) {
- $this->info['audio']['channelmode'] = 'mono';
- } elseif ($this->info['audio']['channels'] == 2) {
- $this->info['audio']['channelmode'] = 'stereo';
- }
-
- // Calculate combined bitrate - audio + video
- $CombinedBitrate = 0;
- $CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
- $CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
- if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
- $this->info['bitrate'] = $CombinedBitrate;
- }
- //if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {
- // // for example, VBR MPEG video files cannot determine video bitrate:
- // // should not set overall bitrate and playtime from audio bitrate only
- // unset($this->info['bitrate']);
- //}
-
- // video bitrate undetermined, but calculable
- if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && (!isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) {
- // if video bitrate not set
- if (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] > 0) && ($this->info['audio']['bitrate'] == $this->info['bitrate'])) {
- // AND if audio bitrate is set to same as overall bitrate
- if (isset($this->info['playtime_seconds']) && ($this->info['playtime_seconds'] > 0)) {
- // AND if playtime is set
- if (isset($this->info['avdataend']) && isset($this->info['avdataoffset'])) {
- // AND if AV data offset start/end is known
- // THEN we can calculate the video bitrate
- $this->info['bitrate'] = round((($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds']);
- $this->info['video']['bitrate'] = $this->info['bitrate'] - $this->info['audio']['bitrate'];
- }
- }
- }
- }
-
- if ((!isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && !empty($this->info['bitrate'])) {
- $this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
- }
-
- if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) {
- $this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds'];
- }
- if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) {
- if (isset($this->info['audio']['dataformat']) && empty($this->info['video']['resolution_x'])) {
- // audio only
- $this->info['audio']['bitrate'] = $this->info['bitrate'];
- } elseif (isset($this->info['video']['resolution_x']) && empty($this->info['audio']['dataformat'])) {
- // video only
- $this->info['video']['bitrate'] = $this->info['bitrate'];
- }
- }
-
- // Set playtime string
- if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
- $this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
- }
- }
-
-
- function CalculateCompressionRatioVideo() {
- if (empty($this->info['video'])) {
- return false;
- }
- if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
- return false;
- }
- if (empty($this->info['video']['bits_per_sample'])) {
- return false;
- }
-
- switch ($this->info['video']['dataformat']) {
- case 'bmp':
- case 'gif':
- case 'jpeg':
- case 'jpg':
- case 'png':
- case 'tiff':
- $FrameRate = 1;
- $PlaytimeSeconds = 1;
- $BitrateCompressed = $this->info['filesize'] * 8;
- break;
-
- default:
- if (!empty($this->info['video']['frame_rate'])) {
- $FrameRate = $this->info['video']['frame_rate'];
- } else {
- return false;
- }
- if (!empty($this->info['playtime_seconds'])) {
- $PlaytimeSeconds = $this->info['playtime_seconds'];
- } else {
- return false;
- }
- if (!empty($this->info['video']['bitrate'])) {
- $BitrateCompressed = $this->info['video']['bitrate'];
- } else {
- return false;
- }
- break;
- }
- $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
-
- $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
- return true;
- }
-
-
- function CalculateCompressionRatioAudio() {
- if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate'])) {
- return false;
- }
- $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
-
- if (!empty($this->info['audio']['streams'])) {
- foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
- if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
- $this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
- }
- }
- }
- return true;
- }
-
-
- function CalculateReplayGain() {
- if (isset($this->info['replay_gain'])) {
- if (!isset($this->info['replay_gain']['reference_volume'])) {
- $this->info['replay_gain']['reference_volume'] = (double) 89.0;
- }
- if (isset($this->info['replay_gain']['track']['adjustment'])) {
- $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
- }
- if (isset($this->info['replay_gain']['album']['adjustment'])) {
- $this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
- }
-
- if (isset($this->info['replay_gain']['track']['peak'])) {
- $this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
- }
- if (isset($this->info['replay_gain']['album']['peak'])) {
- $this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
- }
- }
- return true;
- }
-
- function ProcessAudioStreams() {
- if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
- if (!isset($this->info['audio']['streams'])) {
- foreach ($this->info['audio'] as $key => $value) {
- if ($key != 'streams') {
- $this->info['audio']['streams'][0][$key] = $value;
- }
- }
- }
- }
- return true;
- }
-
- function getid3_tempnam() {
- return tempnam($this->tempdir, 'gI3');
- }
-
-
- public function saveAttachment(&$ThisFileInfoIndex, $filename, $offset, $length) {
- try {
- if (!getid3_lib::intValueSupported($offset + $length)) {
- throw new Exception('cannot extract attachment, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
- }
-
- // do not extract at all
- if ($this->option_save_attachments === getID3::ATTACHMENTS_NONE) {
-
- unset($ThisFileInfoIndex); // do not set any
-
- // extract to return array
- } elseif ($this->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
-
- // get whole data in one pass, till it is anyway stored in memory
- $ThisFileInfoIndex = file_get_contents($this->info['filenamepath'], false, null, $offset, $length);
- if (($ThisFileInfoIndex === false) || (strlen($ThisFileInfoIndex) != $length)) { // verify
- throw new Exception('failed to read attachment data');
- }
-
- // assume directory path is given
- } else {
-
- $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->option_save_attachments), DIRECTORY_SEPARATOR);
- // check supplied directory
- if (!is_dir($dir) || !is_writable($dir)) {
- throw new Exception('getID3::saveAttachment() -- supplied path ('.$dir.') does not exist, or is not writable');
- }
-
- // set up destination path
- $dest = $dir.DIRECTORY_SEPARATOR.$filename;
-
- // optimize speed if read buffer size is configured to be large enough
- // here stream_copy_to_stream() may also be used. need to do speed-compare tests
- if ($length <= $this->fread_buffer_size()) {
- $data = file_get_contents($this->info['filenamepath'], false, null, $offset, $length);
- if (($data === false) || (strlen($data) != $length)) { // verify
- throw new Exception('failed to read attachment data');
- }
- if (!file_put_contents($dest, $data)) {
- throw new Exception('failed to create file '.$dest);
- }
- } else {
- // optimization not available - copy data in loop
- // here stream_copy_to_stream() shouldn't be used because it's internal read buffer may be larger than ours!
- getid3_lib::CopyFileParts($this->info['filenamepath'], $dest, $offset, $length);
- }
- $ThisFileInfoIndex = $dest;
- }
-
- } catch (Exception $e) {
-
- unset($ThisFileInfoIndex); // do not set any is case of error
- $this->warning('Failed to extract attachment '.$filename.': '.$e->getMessage());
- return false;
-
- }
- return true;
- }
-
-
- public function include_module($name) {
- //if (!file_exists($this->include_path.'module.'.$name.'.php')) {
- if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
- throw new getid3_exception('Required module.'.$name.'.php is missing.');
- }
- include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php');
- return true;
- }
-
-}
-
-
-abstract class getid3_handler
-{
- 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
-
-
- public function __construct(getID3 $getid3) {
- $this->getid3 = $getid3;
- }
-
-
- // Analyze from file pointer
- abstract public function Analyze();
-
-
- // Analyze from string instead
- public function AnalyzeString(&$string) {
- // Enter string mode
- $this->data_string_flag = true;
- $this->data_string = $string;
-
- // Save info
- $saved_avdataoffset = $this->getid3->info['avdataoffset'];
- $saved_avdataend = $this->getid3->info['avdataend'];
- $saved_filesize = $this->getid3->info['filesize'];
-
- // Reset some info
- $this->getid3->info['avdataoffset'] = 0;
- $this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = strlen($string);
-
- // 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;
- }
-
-
- 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);
- }
- 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;
- return;
-
- case SEEK_CUR:
- $this->data_string_position += $bytes;
- return;
-
- case SEEK_END:
- $this->data_string_position = strlen($this->data_string) + $bytes;
- return;
- }
- }
- return fseek($this->getid3->fp, $bytes, $whence);
- }
-
-}
-
-
-class getid3_exception extends Exception
-{
- public $message;
-}
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.archive.gzip.php b/app/library/getid3/module.archive.gzip.php
deleted file mode 100644
index c30052ed..00000000
--- a/app/library/getid3/module.archive.gzip.php
+++ /dev/null
@@ -1,280 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.archive.gzip.php //
-// module for analyzing GZIP files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-// //
-// Module originally written by //
-// Mike Mozolin //
-// //
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_gzip extends getid3_handler {
-
- // public: Optional file list - disable for speed.
- var $option_gzip_parse_contents = false; // decode gzipped files, if possible, and parse recursively (.tar.gz for example)
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- $info['fileformat'] = 'gzip';
-
- $start_length = 10;
- $unpack_header = 'a1id1/a1id2/a1cmethod/a1flags/a4mtime/a1xflags/a1os';
- //+---+---+---+---+---+---+---+---+---+---+
- //|ID1|ID2|CM |FLG| MTIME |XFL|OS |
- //+---+---+---+---+---+---+---+---+---+---+
-
- if ($info['filesize'] > $info['php_memory_limit']) {
- $info['error'][] = 'File is too large ('.number_format($info['filesize']).' bytes) to read into memory (limit: '.number_format($info['php_memory_limit'] / 1048576).'MB)';
- return false;
- }
- fseek($this->getid3->fp, 0);
- $buffer = fread($this->getid3->fp, $info['filesize']);
-
- $arr_members = explode("\x1F\x8B\x08", $buffer);
- while (true) {
- $is_wrong_members = false;
- $num_members = intval(count($arr_members));
- for ($i = 0; $i < $num_members; $i++) {
- if (strlen($arr_members[$i]) == 0) {
- continue;
- }
- $buf = "\x1F\x8B\x08".$arr_members[$i];
-
- $attr = unpack($unpack_header, substr($buf, 0, $start_length));
- if (!$this->get_os_type(ord($attr['os']))) {
- // Merge member with previous if wrong OS type
- $arr_members[$i - 1] .= $buf;
- $arr_members[$i] = '';
- $is_wrong_members = true;
- continue;
- }
- }
- if (!$is_wrong_members) {
- break;
- }
- }
-
- $info['gzip']['files'] = array();
-
- $fpointer = 0;
- $idx = 0;
- for ($i = 0; $i < $num_members; $i++) {
- if (strlen($arr_members[$i]) == 0) {
- continue;
- }
- $thisInfo = &$info['gzip']['member_header'][++$idx];
-
- $buff = "\x1F\x8B\x08".$arr_members[$i];
-
- $attr = unpack($unpack_header, substr($buff, 0, $start_length));
- $thisInfo['filemtime'] = getid3_lib::LittleEndian2Int($attr['mtime']);
- $thisInfo['raw']['id1'] = ord($attr['cmethod']);
- $thisInfo['raw']['id2'] = ord($attr['cmethod']);
- $thisInfo['raw']['cmethod'] = ord($attr['cmethod']);
- $thisInfo['raw']['os'] = ord($attr['os']);
- $thisInfo['raw']['xflags'] = ord($attr['xflags']);
- $thisInfo['raw']['flags'] = ord($attr['flags']);
-
- $thisInfo['flags']['crc16'] = (bool) ($thisInfo['raw']['flags'] & 0x02);
- $thisInfo['flags']['extra'] = (bool) ($thisInfo['raw']['flags'] & 0x04);
- $thisInfo['flags']['filename'] = (bool) ($thisInfo['raw']['flags'] & 0x08);
- $thisInfo['flags']['comment'] = (bool) ($thisInfo['raw']['flags'] & 0x10);
-
- $thisInfo['compression'] = $this->get_xflag_type($thisInfo['raw']['xflags']);
-
- $thisInfo['os'] = $this->get_os_type($thisInfo['raw']['os']);
- if (!$thisInfo['os']) {
- $info['error'][] = 'Read error on gzip file';
- return false;
- }
-
- $fpointer = 10;
- $arr_xsubfield = array();
- // bit 2 - FLG.FEXTRA
- //+---+---+=================================+
- //| XLEN |...XLEN bytes of "extra field"...|
- //+---+---+=================================+
- if ($thisInfo['flags']['extra']) {
- $w_xlen = substr($buff, $fpointer, 2);
- $xlen = getid3_lib::LittleEndian2Int($w_xlen);
- $fpointer += 2;
-
- $thisInfo['raw']['xfield'] = substr($buff, $fpointer, $xlen);
- // Extra SubFields
- //+---+---+---+---+==================================+
- //|SI1|SI2| LEN |... LEN bytes of subfield data ...|
- //+---+---+---+---+==================================+
- $idx = 0;
- while (true) {
- if ($idx >= $xlen) {
- break;
- }
- $si1 = ord(substr($buff, $fpointer + $idx++, 1));
- $si2 = ord(substr($buff, $fpointer + $idx++, 1));
- if (($si1 == 0x41) && ($si2 == 0x70)) {
- $w_xsublen = substr($buff, $fpointer + $idx, 2);
- $xsublen = getid3_lib::LittleEndian2Int($w_xsublen);
- $idx += 2;
- $arr_xsubfield[] = substr($buff, $fpointer + $idx, $xsublen);
- $idx += $xsublen;
- } else {
- break;
- }
- }
- $fpointer += $xlen;
- }
- // bit 3 - FLG.FNAME
- //+=========================================+
- //|...original file name, zero-terminated...|
- //+=========================================+
- // GZIP files may have only one file, with no filename, so assume original filename is current filename without .gz
- $thisInfo['filename'] = preg_replace('#\.gz$#i', '', $info['filename']);
- if ($thisInfo['flags']['filename']) {
- while (true) {
- if (ord($buff[$fpointer]) == 0) {
- $fpointer++;
- break;
- }
- $thisInfo['filename'] .= $buff[$fpointer];
- $fpointer++;
- }
- }
- // bit 4 - FLG.FCOMMENT
- //+===================================+
- //|...file comment, zero-terminated...|
- //+===================================+
- if ($thisInfo['flags']['comment']) {
- while (true) {
- if (ord($buff[$fpointer]) == 0) {
- $fpointer++;
- break;
- }
- $thisInfo['comment'] .= $buff[$fpointer];
- $fpointer++;
- }
- }
- // bit 1 - FLG.FHCRC
- //+---+---+
- //| CRC16 |
- //+---+---+
- if ($thisInfo['flags']['crc16']) {
- $w_crc = substr($buff, $fpointer, 2);
- $thisInfo['crc16'] = getid3_lib::LittleEndian2Int($w_crc);
- $fpointer += 2;
- }
- // bit 0 - FLG.FTEXT
- //if ($thisInfo['raw']['flags'] & 0x01) {
- // Ignored...
- //}
- // bits 5, 6, 7 - reserved
-
- $thisInfo['crc32'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 8, 4));
- $thisInfo['filesize'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 4));
-
- $info['gzip']['files'] = getid3_lib::array_merge_clobber($info['gzip']['files'], getid3_lib::CreateDeepArray($thisInfo['filename'], '/', $thisInfo['filesize']));
-
- if ($this->option_gzip_parse_contents) {
- // Try to inflate GZip
- $csize = 0;
- $inflated = '';
- $chkcrc32 = '';
- if (function_exists('gzinflate')) {
- $cdata = substr($buff, $fpointer);
- $cdata = substr($cdata, 0, strlen($cdata) - 8);
- $csize = strlen($cdata);
- $inflated = gzinflate($cdata);
-
- // Calculate CRC32 for inflated content
- $thisInfo['crc32_valid'] = (bool) (sprintf('%u', crc32($inflated)) == $thisInfo['crc32']);
-
- // determine format
- $formattest = substr($inflated, 0, 32774);
- $getid3_temp = new getID3();
- $determined_format = $getid3_temp->GetFileFormat($formattest);
- unset($getid3_temp);
-
- // file format is determined
- $determined_format['module'] = (isset($determined_format['module']) ? $determined_format['module'] : '');
- switch ($determined_format['module']) {
- case 'tar':
- // view TAR-file info
- if (file_exists(GETID3_INCLUDEPATH.$determined_format['include']) && include_once(GETID3_INCLUDEPATH.$determined_format['include'])) {
- if (($temp_tar_filename = tempnam(GETID3_TEMP_DIR, 'getID3')) === false) {
- // can't find anywhere to create a temp file, abort
- $info['error'][] = 'Unable to create temp file to parse TAR inside GZIP file';
- break;
- }
- if ($fp_temp_tar = fopen($temp_tar_filename, 'w+b')) {
- fwrite($fp_temp_tar, $inflated);
- fclose($fp_temp_tar);
- $getid3_temp = new getID3();
- $getid3_temp->openfile($temp_tar_filename);
- $getid3_tar = new getid3_tar($getid3_temp);
- $getid3_tar->Analyze();
- $info['gzip']['member_header'][$idx]['tar'] = $getid3_temp->info['tar'];
- unset($getid3_temp, $getid3_tar);
- unlink($temp_tar_filename);
- } else {
- $info['error'][] = 'Unable to fopen() temp file to parse TAR inside GZIP file';
- break;
- }
- }
- break;
-
- case '':
- default:
- // unknown or unhandled format
- break;
- }
- }
- }
- }
- return true;
- }
-
- // Converts the OS type
- function get_os_type($key) {
- static $os_type = array(
- '0' => 'FAT filesystem (MS-DOS, OS/2, NT/Win32)',
- '1' => 'Amiga',
- '2' => 'VMS (or OpenVMS)',
- '3' => 'Unix',
- '4' => 'VM/CMS',
- '5' => 'Atari TOS',
- '6' => 'HPFS filesystem (OS/2, NT)',
- '7' => 'Macintosh',
- '8' => 'Z-System',
- '9' => 'CP/M',
- '10' => 'TOPS-20',
- '11' => 'NTFS filesystem (NT)',
- '12' => 'QDOS',
- '13' => 'Acorn RISCOS',
- '255' => 'unknown'
- );
- return (isset($os_type[$key]) ? $os_type[$key] : '');
- }
-
- // Converts the eXtra FLags
- function get_xflag_type($key) {
- static $xflag_type = array(
- '0' => 'unknown',
- '2' => 'maximum compression',
- '4' => 'fastest algorithm'
- );
- return (isset($xflag_type[$key]) ? $xflag_type[$key] : '');
- }
-}
-
-?>
diff --git a/app/library/getid3/module.archive.rar.php b/app/library/getid3/module.archive.rar.php
deleted file mode 100644
index 4f5d46f8..00000000
--- a/app/library/getid3/module.archive.rar.php
+++ /dev/null
@@ -1,53 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.archive.rar.php //
-// module for analyzing RAR files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_rar extends getid3_handler
-{
-
- var $option_use_rar_extension = false;
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- $info['fileformat'] = 'rar';
-
- if ($this->option_use_rar_extension === true) {
- if (function_exists('rar_open')) {
- if ($rp = rar_open($info['filenamepath'])) {
- $info['rar']['files'] = array();
- $entries = rar_list($rp);
- foreach ($entries as $entry) {
- $info['rar']['files'] = getid3_lib::array_merge_clobber($info['rar']['files'], getid3_lib::CreateDeepArray($entry->getName(), '/', $entry->getUnpackedSize()));
- }
- rar_close($rp);
- return true;
- } else {
- $info['error'][] = 'failed to rar_open('.$info['filename'].')';
- }
- } else {
- $info['error'][] = 'RAR support does not appear to be available in this PHP installation';
- }
- } else {
- $info['error'][] = 'PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)';
- }
- return false;
-
- }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.archive.szip.php b/app/library/getid3/module.archive.szip.php
deleted file mode 100644
index 3be62532..00000000
--- a/app/library/getid3/module.archive.szip.php
+++ /dev/null
@@ -1,96 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.archive.szip.php //
-// module for analyzing SZIP compressed files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_szip extends getid3_handler
-{
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
- $SZIPHeader = fread($this->getid3->fp, 6);
- if (substr($SZIPHeader, 0, 4) != "SZ\x0A\x04") {
- $info['error'][] = 'Expecting "53 5A 0A 04" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($SZIPHeader, 0, 4)).'"';
- return false;
- }
- $info['fileformat'] = 'szip';
- $info['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 4, 1));
- $info['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 5, 1));
-
- while (!feof($this->getid3->fp)) {
- $NextBlockID = fread($this->getid3->fp, 2);
- switch ($NextBlockID) {
- case 'SZ':
- // Note that szip files can be concatenated, this has the same effect as
- // concatenating the files. this also means that global header blocks
- // might be present between directory/data blocks.
- fseek($this->getid3->fp, 4, SEEK_CUR);
- break;
-
- case 'BH':
- $BHheaderbytes = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 3));
- $BHheaderdata = fread($this->getid3->fp, $BHheaderbytes);
- $BHheaderoffset = 0;
- while (strpos($BHheaderdata, "\x00", $BHheaderoffset) > 0) {
- //filename as \0 terminated string (empty string indicates end)
- //owner as \0 terminated string (empty is same as last file)
- //group as \0 terminated string (empty is same as last file)
- //3 byte filelength in this block
- //2 byte access flags
- //4 byte creation time (like in unix)
- //4 byte modification time (like in unix)
- //4 byte access time (like in unix)
-
- $BHdataArray['filename'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00"));
- $BHheaderoffset += (strlen($BHdataArray['filename']) + 1);
-
- $BHdataArray['owner'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00"));
- $BHheaderoffset += (strlen($BHdataArray['owner']) + 1);
-
- $BHdataArray['group'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00"));
- $BHheaderoffset += (strlen($BHdataArray['group']) + 1);
-
- $BHdataArray['filelength'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 3));
- $BHheaderoffset += 3;
-
- $BHdataArray['access_flags'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 2));
- $BHheaderoffset += 2;
-
- $BHdataArray['creation_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
- $BHheaderoffset += 4;
-
- $BHdataArray['modification_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
- $BHheaderoffset += 4;
-
- $BHdataArray['access_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
- $BHheaderoffset += 4;
-
- $info['szip']['BH'][] = $BHdataArray;
- }
- break;
-
- default:
- break 2;
- }
- }
-
- return true;
-
- }
-
-}
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.archive.tar.php b/app/library/getid3/module.archive.tar.php
deleted file mode 100644
index 94d32039..00000000
--- a/app/library/getid3/module.archive.tar.php
+++ /dev/null
@@ -1,178 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.archive.tar.php //
-// module for analyzing TAR files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-// //
-// Module originally written by //
-// Mike Mozolin //
-// //
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_tar extends getid3_handler
-{
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- $info['fileformat'] = 'tar';
- $info['tar']['files'] = array();
-
- $unpack_header = 'a100fname/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typflag/a100lnkname/a6magic/a2ver/a32uname/a32gname/a8devmaj/a8devmin/a155prefix';
- $null_512k = str_repeat("\x00", 512); // end-of-file marker
-
- fseek($this->getid3->fp, 0);
- while (!feof($this->getid3->fp)) {
- $buffer = fread($this->getid3->fp, 512);
- if (strlen($buffer) < 512) {
- break;
- }
-
- // check the block
- $checksum = 0;
- for ($i = 0; $i < 148; $i++) {
- $checksum += ord($buffer{$i});
- }
- for ($i = 148; $i < 156; $i++) {
- $checksum += ord(' ');
- }
- for ($i = 156; $i < 512; $i++) {
- $checksum += ord($buffer{$i});
- }
- $attr = unpack($unpack_header, $buffer);
- $name = (isset($attr['fname'] ) ? trim($attr['fname'] ) : '');
- $mode = octdec(isset($attr['mode'] ) ? trim($attr['mode'] ) : '');
- $uid = octdec(isset($attr['uid'] ) ? trim($attr['uid'] ) : '');
- $gid = octdec(isset($attr['gid'] ) ? trim($attr['gid'] ) : '');
- $size = octdec(isset($attr['size'] ) ? trim($attr['size'] ) : '');
- $mtime = octdec(isset($attr['mtime'] ) ? trim($attr['mtime'] ) : '');
- $chksum = octdec(isset($attr['chksum'] ) ? trim($attr['chksum'] ) : '');
- $typflag = (isset($attr['typflag']) ? trim($attr['typflag']) : '');
- $lnkname = (isset($attr['lnkname']) ? trim($attr['lnkname']) : '');
- $magic = (isset($attr['magic'] ) ? trim($attr['magic'] ) : '');
- $ver = (isset($attr['ver'] ) ? trim($attr['ver'] ) : '');
- $uname = (isset($attr['uname'] ) ? trim($attr['uname'] ) : '');
- $gname = (isset($attr['gname'] ) ? trim($attr['gname'] ) : '');
- $devmaj = octdec(isset($attr['devmaj'] ) ? trim($attr['devmaj'] ) : '');
- $devmin = octdec(isset($attr['devmin'] ) ? trim($attr['devmin'] ) : '');
- $prefix = (isset($attr['prefix'] ) ? trim($attr['prefix'] ) : '');
- if (($checksum == 256) && ($chksum == 0)) {
- // EOF Found
- break;
- }
- if ($prefix) {
- $name = $prefix.'/'.$name;
- }
- if ((preg_match('#/$#', $name)) && !$name) {
- $typeflag = 5;
- }
- if ($buffer == $null_512k) {
- // it's the end of the tar-file...
- break;
- }
-
- // Read to the next chunk
- fseek($this->getid3->fp, $size, SEEK_CUR);
-
- $diff = $size % 512;
- if ($diff != 0) {
- // Padding, throw away
- fseek($this->getid3->fp, (512 - $diff), SEEK_CUR);
- }
- // Protect against tar-files with garbage at the end
- if ($name == '') {
- break;
- }
- $info['tar']['file_details'][$name] = array (
- 'name' => $name,
- 'mode_raw' => $mode,
- 'mode' => getid3_tar::display_perms($mode),
- 'uid' => $uid,
- 'gid' => $gid,
- 'size' => $size,
- 'mtime' => $mtime,
- 'chksum' => $chksum,
- 'typeflag' => getid3_tar::get_flag_type($typflag),
- 'linkname' => $lnkname,
- 'magic' => $magic,
- 'version' => $ver,
- 'uname' => $uname,
- 'gname' => $gname,
- 'devmajor' => $devmaj,
- 'devminor' => $devmin
- );
- $info['tar']['files'] = getid3_lib::array_merge_clobber($info['tar']['files'], getid3_lib::CreateDeepArray($info['tar']['file_details'][$name]['name'], '/', $size));
- }
- return true;
- }
-
- // Parses the file mode to file permissions
- function display_perms($mode) {
- // Determine Type
- if ($mode & 0x1000) $type='p'; // FIFO pipe
- elseif ($mode & 0x2000) $type='c'; // Character special
- elseif ($mode & 0x4000) $type='d'; // Directory
- elseif ($mode & 0x6000) $type='b'; // Block special
- elseif ($mode & 0x8000) $type='-'; // Regular
- elseif ($mode & 0xA000) $type='l'; // Symbolic Link
- elseif ($mode & 0xC000) $type='s'; // Socket
- else $type='u'; // UNKNOWN
-
- // Determine permissions
- $owner['read'] = (($mode & 00400) ? 'r' : '-');
- $owner['write'] = (($mode & 00200) ? 'w' : '-');
- $owner['execute'] = (($mode & 00100) ? 'x' : '-');
- $group['read'] = (($mode & 00040) ? 'r' : '-');
- $group['write'] = (($mode & 00020) ? 'w' : '-');
- $group['execute'] = (($mode & 00010) ? 'x' : '-');
- $world['read'] = (($mode & 00004) ? 'r' : '-');
- $world['write'] = (($mode & 00002) ? 'w' : '-');
- $world['execute'] = (($mode & 00001) ? 'x' : '-');
-
- // Adjust for SUID, SGID and sticky bit
- if ($mode & 0x800) $owner['execute'] = ($owner['execute'] == 'x') ? 's' : 'S';
- if ($mode & 0x400) $group['execute'] = ($group['execute'] == 'x') ? 's' : 'S';
- if ($mode & 0x200) $world['execute'] = ($world['execute'] == 'x') ? 't' : 'T';
-
- $s = sprintf('%1s', $type);
- $s .= sprintf('%1s%1s%1s', $owner['read'], $owner['write'], $owner['execute']);
- $s .= sprintf('%1s%1s%1s', $group['read'], $group['write'], $group['execute']);
- $s .= sprintf('%1s%1s%1s'."\n", $world['read'], $world['write'], $world['execute']);
- return $s;
- }
-
- // Converts the file type
- function get_flag_type($typflag) {
- static $flag_types = array(
- '0' => 'LF_NORMAL',
- '1' => 'LF_LINK',
- '2' => 'LF_SYNLINK',
- '3' => 'LF_CHR',
- '4' => 'LF_BLK',
- '5' => 'LF_DIR',
- '6' => 'LF_FIFO',
- '7' => 'LF_CONFIG',
- 'D' => 'LF_DUMPDIR',
- 'K' => 'LF_LONGLINK',
- 'L' => 'LF_LONGNAME',
- 'M' => 'LF_MULTIVOL',
- 'N' => 'LF_NAMES',
- 'S' => 'LF_SPARSE',
- 'V' => 'LF_VOLHDR'
- );
- return (isset($flag_types[$typflag]) ? $flag_types[$typflag] : '');
- }
-
-}
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.archive.zip.php b/app/library/getid3/module.archive.zip.php
deleted file mode 100644
index 7db8fd23..00000000
--- a/app/library/getid3/module.archive.zip.php
+++ /dev/null
@@ -1,424 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.archive.zip.php //
-// module for analyzing pkZip files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_zip extends getid3_handler
-{
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- $info['fileformat'] = 'zip';
- $info['zip']['encoding'] = 'ISO-8859-1';
- $info['zip']['files'] = array();
-
- $info['zip']['compressed_size'] = 0;
- $info['zip']['uncompressed_size'] = 0;
- $info['zip']['entries_count'] = 0;
-
- if (!getid3_lib::intValueSupported($info['filesize'])) {
- $info['error'][] = 'File is larger than '.round(PHP_INT_MAX / 1073741824).'GB, not supported by PHP';
- return false;
- } else {
- $EOCDsearchData = '';
- $EOCDsearchCounter = 0;
- while ($EOCDsearchCounter++ < 512) {
-
- fseek($this->getid3->fp, -128 * $EOCDsearchCounter, SEEK_END);
- $EOCDsearchData = fread($this->getid3->fp, 128).$EOCDsearchData;
-
- if (strstr($EOCDsearchData, 'PK'."\x05\x06")) {
-
- $EOCDposition = strpos($EOCDsearchData, 'PK'."\x05\x06");
- fseek($this->getid3->fp, (-128 * $EOCDsearchCounter) + $EOCDposition, SEEK_END);
- $info['zip']['end_central_directory'] = $this->ZIPparseEndOfCentralDirectory();
-
- fseek($this->getid3->fp, $info['zip']['end_central_directory']['directory_offset'], SEEK_SET);
- $info['zip']['entries_count'] = 0;
- while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($this->getid3->fp)) {
- $info['zip']['central_directory'][] = $centraldirectoryentry;
- $info['zip']['entries_count']++;
- $info['zip']['compressed_size'] += $centraldirectoryentry['compressed_size'];
- $info['zip']['uncompressed_size'] += $centraldirectoryentry['uncompressed_size'];
-
- if ($centraldirectoryentry['uncompressed_size'] > 0) {
- $info['zip']['files'] = getid3_lib::array_merge_clobber($info['zip']['files'], getid3_lib::CreateDeepArray($centraldirectoryentry['filename'], '/', $centraldirectoryentry['uncompressed_size']));
- }
- }
-
- if ($info['zip']['entries_count'] == 0) {
- $info['error'][] = 'No Central Directory entries found (truncated file?)';
- return false;
- }
-
- if (!empty($info['zip']['end_central_directory']['comment'])) {
- $info['zip']['comments']['comment'][] = $info['zip']['end_central_directory']['comment'];
- }
-
- if (isset($info['zip']['central_directory'][0]['compression_method'])) {
- $info['zip']['compression_method'] = $info['zip']['central_directory'][0]['compression_method'];
- }
- if (isset($info['zip']['central_directory'][0]['flags']['compression_speed'])) {
- $info['zip']['compression_speed'] = $info['zip']['central_directory'][0]['flags']['compression_speed'];
- }
- if (isset($info['zip']['compression_method']) && ($info['zip']['compression_method'] == 'store') && !isset($info['zip']['compression_speed'])) {
- $info['zip']['compression_speed'] = 'store';
- }
-
- return true;
-
- }
- }
- }
-
- if ($this->getZIPentriesFilepointer()) {
-
- // central directory couldn't be found and/or parsed
- // scan through actual file data entries, recover as much as possible from probable trucated file
- if ($info['zip']['compressed_size'] > ($info['filesize'] - 46 - 22)) {
- $info['error'][] = 'Warning: Truncated file! - Total compressed file sizes ('.$info['zip']['compressed_size'].' bytes) is greater than filesize minus Central Directory and End Of Central Directory structures ('.($info['filesize'] - 46 - 22).' bytes)';
- }
- $info['error'][] = 'Cannot find End Of Central Directory - returned list of files in [zip][entries] array may not be complete';
- foreach ($info['zip']['entries'] as $key => $valuearray) {
- $info['zip']['files'][$valuearray['filename']] = $valuearray['uncompressed_size'];
- }
- return true;
-
- } else {
-
- unset($info['zip']);
- $info['fileformat'] = '';
- $info['error'][] = 'Cannot find End Of Central Directory (truncated file?)';
- return false;
-
- }
- }
-
-
- function getZIPHeaderFilepointerTopDown() {
- $info = &$this->getid3->info;
-
- $info['fileformat'] = 'zip';
-
- $info['zip']['compressed_size'] = 0;
- $info['zip']['uncompressed_size'] = 0;
- $info['zip']['entries_count'] = 0;
-
- rewind($this->getid3->fp);
- while ($fileentry = $this->ZIPparseLocalFileHeader()) {
- $info['zip']['entries'][] = $fileentry;
- $info['zip']['entries_count']++;
- }
- if ($info['zip']['entries_count'] == 0) {
- $info['error'][] = 'No Local File Header entries found';
- return false;
- }
-
- $info['zip']['entries_count'] = 0;
- while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($this->getid3->fp)) {
- $info['zip']['central_directory'][] = $centraldirectoryentry;
- $info['zip']['entries_count']++;
- $info['zip']['compressed_size'] += $centraldirectoryentry['compressed_size'];
- $info['zip']['uncompressed_size'] += $centraldirectoryentry['uncompressed_size'];
- }
- if ($info['zip']['entries_count'] == 0) {
- $info['error'][] = 'No Central Directory entries found (truncated file?)';
- return false;
- }
-
- if ($EOCD = $this->ZIPparseEndOfCentralDirectory()) {
- $info['zip']['end_central_directory'] = $EOCD;
- } else {
- $info['error'][] = 'No End Of Central Directory entry found (truncated file?)';
- return false;
- }
-
- if (!empty($info['zip']['end_central_directory']['comment'])) {
- $info['zip']['comments']['comment'][] = $info['zip']['end_central_directory']['comment'];
- }
-
- return true;
- }
-
-
- function getZIPentriesFilepointer() {
- $info = &$this->getid3->info;
-
- $info['zip']['compressed_size'] = 0;
- $info['zip']['uncompressed_size'] = 0;
- $info['zip']['entries_count'] = 0;
-
- rewind($this->getid3->fp);
- while ($fileentry = $this->ZIPparseLocalFileHeader()) {
- $info['zip']['entries'][] = $fileentry;
- $info['zip']['entries_count']++;
- $info['zip']['compressed_size'] += $fileentry['compressed_size'];
- $info['zip']['uncompressed_size'] += $fileentry['uncompressed_size'];
- }
- if ($info['zip']['entries_count'] == 0) {
- $info['error'][] = 'No Local File Header entries found';
- return false;
- }
-
- return true;
- }
-
-
- function ZIPparseLocalFileHeader() {
- $LocalFileHeader['offset'] = ftell($this->getid3->fp);
-
- $ZIPlocalFileHeader = fread($this->getid3->fp, 30);
-
- $LocalFileHeader['raw']['signature'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 0, 4));
- if ($LocalFileHeader['raw']['signature'] != 0x04034B50) {
- // invalid Local File Header Signature
- fseek($this->getid3->fp, $LocalFileHeader['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
- return false;
- }
- $LocalFileHeader['raw']['extract_version'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 4, 2));
- $LocalFileHeader['raw']['general_flags'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 6, 2));
- $LocalFileHeader['raw']['compression_method'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 8, 2));
- $LocalFileHeader['raw']['last_mod_file_time'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 10, 2));
- $LocalFileHeader['raw']['last_mod_file_date'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 12, 2));
- $LocalFileHeader['raw']['crc_32'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 14, 4));
- $LocalFileHeader['raw']['compressed_size'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 18, 4));
- $LocalFileHeader['raw']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 22, 4));
- $LocalFileHeader['raw']['filename_length'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 26, 2));
- $LocalFileHeader['raw']['extra_field_length'] = getid3_lib::LittleEndian2Int(substr($ZIPlocalFileHeader, 28, 2));
-
- $LocalFileHeader['extract_version'] = sprintf('%1.1f', $LocalFileHeader['raw']['extract_version'] / 10);
- $LocalFileHeader['host_os'] = $this->ZIPversionOSLookup(($LocalFileHeader['raw']['extract_version'] & 0xFF00) >> 8);
- $LocalFileHeader['compression_method'] = $this->ZIPcompressionMethodLookup($LocalFileHeader['raw']['compression_method']);
- $LocalFileHeader['compressed_size'] = $LocalFileHeader['raw']['compressed_size'];
- $LocalFileHeader['uncompressed_size'] = $LocalFileHeader['raw']['uncompressed_size'];
- $LocalFileHeader['flags'] = $this->ZIPparseGeneralPurposeFlags($LocalFileHeader['raw']['general_flags'], $LocalFileHeader['raw']['compression_method']);
- $LocalFileHeader['last_modified_timestamp'] = $this->DOStime2UNIXtime($LocalFileHeader['raw']['last_mod_file_date'], $LocalFileHeader['raw']['last_mod_file_time']);
-
- $FilenameExtrafieldLength = $LocalFileHeader['raw']['filename_length'] + $LocalFileHeader['raw']['extra_field_length'];
- if ($FilenameExtrafieldLength > 0) {
- $ZIPlocalFileHeader .= fread($this->getid3->fp, $FilenameExtrafieldLength);
-
- if ($LocalFileHeader['raw']['filename_length'] > 0) {
- $LocalFileHeader['filename'] = substr($ZIPlocalFileHeader, 30, $LocalFileHeader['raw']['filename_length']);
- }
- if ($LocalFileHeader['raw']['extra_field_length'] > 0) {
- $LocalFileHeader['raw']['extra_field_data'] = substr($ZIPlocalFileHeader, 30 + $LocalFileHeader['raw']['filename_length'], $LocalFileHeader['raw']['extra_field_length']);
- }
- }
-
- $LocalFileHeader['data_offset'] = ftell($this->getid3->fp);
- //$LocalFileHeader['compressed_data'] = fread($this->getid3->fp, $LocalFileHeader['raw']['compressed_size']);
- fseek($this->getid3->fp, $LocalFileHeader['raw']['compressed_size'], SEEK_CUR);
-
- if ($LocalFileHeader['flags']['data_descriptor_used']) {
- $DataDescriptor = fread($this->getid3->fp, 12);
- $LocalFileHeader['data_descriptor']['crc_32'] = getid3_lib::LittleEndian2Int(substr($DataDescriptor, 0, 4));
- $LocalFileHeader['data_descriptor']['compressed_size'] = getid3_lib::LittleEndian2Int(substr($DataDescriptor, 4, 4));
- $LocalFileHeader['data_descriptor']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($DataDescriptor, 8, 4));
- }
-
- return $LocalFileHeader;
- }
-
-
- function ZIPparseCentralDirectory() {
- $CentralDirectory['offset'] = ftell($this->getid3->fp);
-
- $ZIPcentralDirectory = fread($this->getid3->fp, 46);
-
- $CentralDirectory['raw']['signature'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 0, 4));
- if ($CentralDirectory['raw']['signature'] != 0x02014B50) {
- // invalid Central Directory Signature
- fseek($this->getid3->fp, $CentralDirectory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
- return false;
- }
- $CentralDirectory['raw']['create_version'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 4, 2));
- $CentralDirectory['raw']['extract_version'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 6, 2));
- $CentralDirectory['raw']['general_flags'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 8, 2));
- $CentralDirectory['raw']['compression_method'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 10, 2));
- $CentralDirectory['raw']['last_mod_file_time'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 12, 2));
- $CentralDirectory['raw']['last_mod_file_date'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 14, 2));
- $CentralDirectory['raw']['crc_32'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 16, 4));
- $CentralDirectory['raw']['compressed_size'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 20, 4));
- $CentralDirectory['raw']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 24, 4));
- $CentralDirectory['raw']['filename_length'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 28, 2));
- $CentralDirectory['raw']['extra_field_length'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 30, 2));
- $CentralDirectory['raw']['file_comment_length'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 32, 2));
- $CentralDirectory['raw']['disk_number_start'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 34, 2));
- $CentralDirectory['raw']['internal_file_attrib'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 36, 2));
- $CentralDirectory['raw']['external_file_attrib'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 38, 4));
- $CentralDirectory['raw']['local_header_offset'] = getid3_lib::LittleEndian2Int(substr($ZIPcentralDirectory, 42, 4));
-
- $CentralDirectory['entry_offset'] = $CentralDirectory['raw']['local_header_offset'];
- $CentralDirectory['create_version'] = sprintf('%1.1f', $CentralDirectory['raw']['create_version'] / 10);
- $CentralDirectory['extract_version'] = sprintf('%1.1f', $CentralDirectory['raw']['extract_version'] / 10);
- $CentralDirectory['host_os'] = $this->ZIPversionOSLookup(($CentralDirectory['raw']['extract_version'] & 0xFF00) >> 8);
- $CentralDirectory['compression_method'] = $this->ZIPcompressionMethodLookup($CentralDirectory['raw']['compression_method']);
- $CentralDirectory['compressed_size'] = $CentralDirectory['raw']['compressed_size'];
- $CentralDirectory['uncompressed_size'] = $CentralDirectory['raw']['uncompressed_size'];
- $CentralDirectory['flags'] = $this->ZIPparseGeneralPurposeFlags($CentralDirectory['raw']['general_flags'], $CentralDirectory['raw']['compression_method']);
- $CentralDirectory['last_modified_timestamp'] = $this->DOStime2UNIXtime($CentralDirectory['raw']['last_mod_file_date'], $CentralDirectory['raw']['last_mod_file_time']);
-
- $FilenameExtrafieldCommentLength = $CentralDirectory['raw']['filename_length'] + $CentralDirectory['raw']['extra_field_length'] + $CentralDirectory['raw']['file_comment_length'];
- if ($FilenameExtrafieldCommentLength > 0) {
- $FilenameExtrafieldComment = fread($this->getid3->fp, $FilenameExtrafieldCommentLength);
-
- if ($CentralDirectory['raw']['filename_length'] > 0) {
- $CentralDirectory['filename'] = substr($FilenameExtrafieldComment, 0, $CentralDirectory['raw']['filename_length']);
- }
- if ($CentralDirectory['raw']['extra_field_length'] > 0) {
- $CentralDirectory['raw']['extra_field_data'] = substr($FilenameExtrafieldComment, $CentralDirectory['raw']['filename_length'], $CentralDirectory['raw']['extra_field_length']);
- }
- if ($CentralDirectory['raw']['file_comment_length'] > 0) {
- $CentralDirectory['file_comment'] = substr($FilenameExtrafieldComment, $CentralDirectory['raw']['filename_length'] + $CentralDirectory['raw']['extra_field_length'], $CentralDirectory['raw']['file_comment_length']);
- }
- }
-
- return $CentralDirectory;
- }
-
- function ZIPparseEndOfCentralDirectory() {
- $EndOfCentralDirectory['offset'] = ftell($this->getid3->fp);
-
- $ZIPendOfCentralDirectory = fread($this->getid3->fp, 22);
-
- $EndOfCentralDirectory['signature'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 0, 4));
- if ($EndOfCentralDirectory['signature'] != 0x06054B50) {
- // invalid End Of Central Directory Signature
- fseek($this->getid3->fp, $EndOfCentralDirectory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
- return false;
- }
- $EndOfCentralDirectory['disk_number_current'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 4, 2));
- $EndOfCentralDirectory['disk_number_start_directory'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 6, 2));
- $EndOfCentralDirectory['directory_entries_this_disk'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 8, 2));
- $EndOfCentralDirectory['directory_entries_total'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 10, 2));
- $EndOfCentralDirectory['directory_size'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 12, 4));
- $EndOfCentralDirectory['directory_offset'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 16, 4));
- $EndOfCentralDirectory['comment_length'] = getid3_lib::LittleEndian2Int(substr($ZIPendOfCentralDirectory, 20, 2));
-
- if ($EndOfCentralDirectory['comment_length'] > 0) {
- $EndOfCentralDirectory['comment'] = fread($this->getid3->fp, $EndOfCentralDirectory['comment_length']);
- }
-
- return $EndOfCentralDirectory;
- }
-
-
- static function ZIPparseGeneralPurposeFlags($flagbytes, $compressionmethod) {
- $ParsedFlags['encrypted'] = (bool) ($flagbytes & 0x0001);
-
- switch ($compressionmethod) {
- case 6:
- $ParsedFlags['dictionary_size'] = (($flagbytes & 0x0002) ? 8192 : 4096);
- $ParsedFlags['shannon_fano_trees'] = (($flagbytes & 0x0004) ? 3 : 2);
- break;
-
- case 8:
- case 9:
- switch (($flagbytes & 0x0006) >> 1) {
- case 0:
- $ParsedFlags['compression_speed'] = 'normal';
- break;
- case 1:
- $ParsedFlags['compression_speed'] = 'maximum';
- break;
- case 2:
- $ParsedFlags['compression_speed'] = 'fast';
- break;
- case 3:
- $ParsedFlags['compression_speed'] = 'superfast';
- break;
- }
- break;
- }
- $ParsedFlags['data_descriptor_used'] = (bool) ($flagbytes & 0x0008);
-
- return $ParsedFlags;
- }
-
-
- static function ZIPversionOSLookup($index) {
- static $ZIPversionOSLookup = array(
- 0 => 'MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)',
- 1 => 'Amiga',
- 2 => 'OpenVMS',
- 3 => 'Unix',
- 4 => 'VM/CMS',
- 5 => 'Atari ST',
- 6 => 'OS/2 H.P.F.S.',
- 7 => 'Macintosh',
- 8 => 'Z-System',
- 9 => 'CP/M',
- 10 => 'Windows NTFS',
- 11 => 'MVS',
- 12 => 'VSE',
- 13 => 'Acorn Risc',
- 14 => 'VFAT',
- 15 => 'Alternate MVS',
- 16 => 'BeOS',
- 17 => 'Tandem'
- );
-
- return (isset($ZIPversionOSLookup[$index]) ? $ZIPversionOSLookup[$index] : '[unknown]');
- }
-
- static function ZIPcompressionMethodLookup($index) {
- static $ZIPcompressionMethodLookup = array(
- 0 => 'store',
- 1 => 'shrink',
- 2 => 'reduce-1',
- 3 => 'reduce-2',
- 4 => 'reduce-3',
- 5 => 'reduce-4',
- 6 => 'implode',
- 7 => 'tokenize',
- 8 => 'deflate',
- 9 => 'deflate64',
- 10 => 'PKWARE Date Compression Library Imploding'
- );
-
- return (isset($ZIPcompressionMethodLookup[$index]) ? $ZIPcompressionMethodLookup[$index] : '[unknown]');
- }
-
- static function DOStime2UNIXtime($DOSdate, $DOStime) {
- // wFatDate
- // Specifies the MS-DOS date. The date is a packed 16-bit value with the following format:
- // Bits Contents
- // 0-4 Day of the month (1-31)
- // 5-8 Month (1 = January, 2 = February, and so on)
- // 9-15 Year offset from 1980 (add 1980 to get actual year)
-
- $UNIXday = ($DOSdate & 0x001F);
- $UNIXmonth = (($DOSdate & 0x01E0) >> 5);
- $UNIXyear = (($DOSdate & 0xFE00) >> 9) + 1980;
-
- // wFatTime
- // Specifies the MS-DOS time. The time is a packed 16-bit value with the following format:
- // Bits Contents
- // 0-4 Second divided by 2
- // 5-10 Minute (0-59)
- // 11-15 Hour (0-23 on a 24-hour clock)
-
- $UNIXsecond = ($DOStime & 0x001F) * 2;
- $UNIXminute = (($DOStime & 0x07E0) >> 5);
- $UNIXhour = (($DOStime & 0xF800) >> 11);
-
- return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
- }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.audio-video.asf.php b/app/library/getid3/module.audio-video.asf.php
deleted file mode 100644
index 0bb095f5..00000000
--- a/app/library/getid3/module.audio-video.asf.php
+++ /dev/null
@@ -1,2021 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio-video.asf.php //
-// module for analyzing ASF, WMA and WMV files //
-// dependencies: module.audio-video.riff.php //
-// ///
-/////////////////////////////////////////////////////////////////
-
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
-
-class getid3_asf extends getid3_handler
-{
-
- function __construct(getID3 $getid3) {
- parent::__construct($getid3); // extends getid3_handler::__construct()
-
- // initialize all GUID constants
- $GUIDarray = $this->KnownGUIDs();
- foreach ($GUIDarray as $GUIDname => $hexstringvalue) {
- if (!defined($GUIDname)) {
- define($GUIDname, $this->GUIDtoBytestring($hexstringvalue));
- }
- }
- }
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- // Shortcuts
- $thisfile_audio = &$info['audio'];
- $thisfile_video = &$info['video'];
- $info['asf'] = array();
- $thisfile_asf = &$info['asf'];
- $thisfile_asf['comments'] = array();
- $thisfile_asf_comments = &$thisfile_asf['comments'];
- $thisfile_asf['header_object'] = array();
- $thisfile_asf_headerobject = &$thisfile_asf['header_object'];
-
-
- // ASF structure:
- // * Header Object [required]
- // * File Properties Object [required] (global file attributes)
- // * Stream Properties Object [required] (defines media stream & characteristics)
- // * Header Extension Object [required] (additional functionality)
- // * Content Description Object (bibliographic information)
- // * Script Command Object (commands for during playback)
- // * Marker Object (named jumped points within the file)
- // * Data Object [required]
- // * Data Packets
- // * Index Object
-
- // Header Object: (mandatory, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for header object - GETID3_ASF_Header_Object
- // Object Size QWORD 64 // size of header object, including 30 bytes of Header Object header
- // Number of Header Objects DWORD 32 // number of objects in header object
- // Reserved1 BYTE 8 // hardcoded: 0x01
- // Reserved2 BYTE 8 // hardcoded: 0x02
-
- $info['fileformat'] = 'asf';
-
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
- $HeaderObjectData = fread($this->getid3->fp, 30);
-
- $thisfile_asf_headerobject['objectid'] = substr($HeaderObjectData, 0, 16);
- $thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']);
- if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) {
- $info['warning'][] = 'ASF header GUID {'.$this->BytestringToGUID($thisfile_asf_headerobject['objectid']).'} does not match expected "GETID3_ASF_Header_Object" GUID {'.$this->BytestringToGUID(GETID3_ASF_Header_Object).'}';
- unset($info['fileformat']);
- unset($info['asf']);
- return false;
- break;
- }
- $thisfile_asf_headerobject['objectsize'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8));
- $thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4));
- $thisfile_asf_headerobject['reserved1'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1));
- $thisfile_asf_headerobject['reserved2'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1));
-
- $NextObjectOffset = ftell($this->getid3->fp);
- $ASFHeaderData = fread($this->getid3->fp, $thisfile_asf_headerobject['objectsize'] - 30);
- $offset = 0;
-
- for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) {
- $NextObjectGUID = substr($ASFHeaderData, $offset, 16);
- $offset += 16;
- $NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID);
- $NextObjectSize = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $offset += 8;
- switch ($NextObjectGUID) {
-
- case GETID3_ASF_File_Properties_Object:
- // File Properties Object: (mandatory, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for file properties object - GETID3_ASF_File_Properties_Object
- // Object Size QWORD 64 // size of file properties object, including 104 bytes of File Properties Object header
- // File ID GUID 128 // unique ID - identical to File ID in Data Object
- // File Size QWORD 64 // entire file in bytes. Invalid if Broadcast Flag == 1
- // Creation Date QWORD 64 // date & time of file creation. Maybe invalid if Broadcast Flag == 1
- // Data Packets Count QWORD 64 // number of data packets in Data Object. Invalid if Broadcast Flag == 1
- // Play Duration QWORD 64 // playtime, in 100-nanosecond units. Invalid if Broadcast Flag == 1
- // Send Duration QWORD 64 // time needed to send file, in 100-nanosecond units. Players can ignore this value. Invalid if Broadcast Flag == 1
- // Preroll QWORD 64 // time to buffer data before starting to play file, in 1-millisecond units. If <> 0, PlayDuration and PresentationTime have been offset by this amount
- // Flags DWORD 32 //
- // * Broadcast Flag bits 1 (0x01) // file is currently being written, some header values are invalid
- // * Seekable Flag bits 1 (0x02) // is file seekable
- // * Reserved bits 30 (0xFFFFFFFC) // reserved - set to zero
- // Minimum Data Packet Size DWORD 32 // in bytes. should be same as Maximum Data Packet Size. Invalid if Broadcast Flag == 1
- // Maximum Data Packet Size DWORD 32 // in bytes. should be same as Minimum Data Packet Size. Invalid if Broadcast Flag == 1
- // Maximum Bitrate DWORD 32 // maximum instantaneous bitrate in bits per second for entire file, including all data streams and ASF overhead
-
- // shortcut
- $thisfile_asf['file_properties_object'] = array();
- $thisfile_asf_filepropertiesobject = &$thisfile_asf['file_properties_object'];
-
- $thisfile_asf_filepropertiesobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_filepropertiesobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_filepropertiesobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_filepropertiesobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_filepropertiesobject['fileid'] = substr($ASFHeaderData, $offset, 16);
- $offset += 16;
- $thisfile_asf_filepropertiesobject['fileid_guid'] = $this->BytestringToGUID($thisfile_asf_filepropertiesobject['fileid']);
- $thisfile_asf_filepropertiesobject['filesize'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $offset += 8;
- $thisfile_asf_filepropertiesobject['creation_date'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $thisfile_asf_filepropertiesobject['creation_date_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_filepropertiesobject['creation_date']);
- $offset += 8;
- $thisfile_asf_filepropertiesobject['data_packets'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $offset += 8;
- $thisfile_asf_filepropertiesobject['play_duration'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $offset += 8;
- $thisfile_asf_filepropertiesobject['send_duration'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $offset += 8;
- $thisfile_asf_filepropertiesobject['preroll'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $offset += 8;
- $thisfile_asf_filepropertiesobject['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $thisfile_asf_filepropertiesobject['flags']['broadcast'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0001);
- $thisfile_asf_filepropertiesobject['flags']['seekable'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0002);
-
- $thisfile_asf_filepropertiesobject['min_packet_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $thisfile_asf_filepropertiesobject['max_packet_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $thisfile_asf_filepropertiesobject['max_bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
-
- if ($thisfile_asf_filepropertiesobject['flags']['broadcast']) {
-
- // broadcast flag is set, some values invalid
- unset($thisfile_asf_filepropertiesobject['filesize']);
- unset($thisfile_asf_filepropertiesobject['data_packets']);
- unset($thisfile_asf_filepropertiesobject['play_duration']);
- unset($thisfile_asf_filepropertiesobject['send_duration']);
- unset($thisfile_asf_filepropertiesobject['min_packet_size']);
- unset($thisfile_asf_filepropertiesobject['max_packet_size']);
-
- } else {
-
- // broadcast flag NOT set, perform calculations
- $info['playtime_seconds'] = ($thisfile_asf_filepropertiesobject['play_duration'] / 10000000) - ($thisfile_asf_filepropertiesobject['preroll'] / 1000);
-
- //$info['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate'];
- $info['bitrate'] = ((isset($thisfile_asf_filepropertiesobject['filesize']) ? $thisfile_asf_filepropertiesobject['filesize'] : $info['filesize']) * 8) / $info['playtime_seconds'];
- }
- break;
-
- case GETID3_ASF_Stream_Properties_Object:
- // Stream Properties Object: (mandatory, one per media stream)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for stream properties object - GETID3_ASF_Stream_Properties_Object
- // Object Size QWORD 64 // size of stream properties object, including 78 bytes of Stream Properties Object header
- // Stream Type GUID 128 // GETID3_ASF_Audio_Media, GETID3_ASF_Video_Media or GETID3_ASF_Command_Media
- // Error Correction Type GUID 128 // GETID3_ASF_Audio_Spread for audio-only streams, GETID3_ASF_No_Error_Correction for other stream types
- // Time Offset QWORD 64 // 100-nanosecond units. typically zero. added to all timestamps of samples in the stream
- // Type-Specific Data Length DWORD 32 // number of bytes for Type-Specific Data field
- // Error Correction Data Length DWORD 32 // number of bytes for Error Correction Data field
- // Flags WORD 16 //
- // * Stream Number bits 7 (0x007F) // number of this stream. 1 <= valid <= 127
- // * Reserved bits 8 (0x7F80) // reserved - set to zero
- // * Encrypted Content Flag bits 1 (0x8000) // stream contents encrypted if set
- // Reserved DWORD 32 // reserved - set to zero
- // Type-Specific Data BYTESTREAM variable // type-specific format data, depending on value of Stream Type
- // Error Correction Data BYTESTREAM variable // error-correction-specific format data, depending on value of Error Correct Type
-
- // There is one GETID3_ASF_Stream_Properties_Object for each stream (audio, video) but the
- // stream number isn't known until halfway through decoding the structure, hence it
- // it is decoded to a temporary variable and then stuck in the appropriate index later
-
- $StreamPropertiesObjectData['offset'] = $NextObjectOffset + $offset;
- $StreamPropertiesObjectData['objectid'] = $NextObjectGUID;
- $StreamPropertiesObjectData['objectid_guid'] = $NextObjectGUIDtext;
- $StreamPropertiesObjectData['objectsize'] = $NextObjectSize;
- $StreamPropertiesObjectData['stream_type'] = substr($ASFHeaderData, $offset, 16);
- $offset += 16;
- $StreamPropertiesObjectData['stream_type_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['stream_type']);
- $StreamPropertiesObjectData['error_correct_type'] = substr($ASFHeaderData, $offset, 16);
- $offset += 16;
- $StreamPropertiesObjectData['error_correct_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['error_correct_type']);
- $StreamPropertiesObjectData['time_offset'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $offset += 8;
- $StreamPropertiesObjectData['type_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $StreamPropertiesObjectData['error_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $StreamPropertiesObjectData['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $StreamPropertiesObjectStreamNumber = $StreamPropertiesObjectData['flags_raw'] & 0x007F;
- $StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000);
-
- $offset += 4; // reserved - DWORD
- $StreamPropertiesObjectData['type_specific_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['type_data_length']);
- $offset += $StreamPropertiesObjectData['type_data_length'];
- $StreamPropertiesObjectData['error_correct_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['error_data_length']);
- $offset += $StreamPropertiesObjectData['error_data_length'];
-
- switch ($StreamPropertiesObjectData['stream_type']) {
-
- case GETID3_ASF_Audio_Media:
- $thisfile_audio['dataformat'] = (!empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf');
- $thisfile_audio['bitrate_mode'] = (!empty($thisfile_audio['bitrate_mode']) ? $thisfile_audio['bitrate_mode'] : 'cbr');
-
- $audiodata = getid3_riff::RIFFparseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
- unset($audiodata['raw']);
- $thisfile_audio = getid3_lib::array_merge_noclobber($audiodata, $thisfile_audio);
- break;
-
- case GETID3_ASF_Video_Media:
- $thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf');
- $thisfile_video['bitrate_mode'] = (!empty($thisfile_video['bitrate_mode']) ? $thisfile_video['bitrate_mode'] : 'cbr');
- break;
-
- case GETID3_ASF_Command_Media:
- default:
- // do nothing
- break;
-
- }
-
- $thisfile_asf['stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData;
- unset($StreamPropertiesObjectData); // clear for next stream, if any
- break;
-
- case GETID3_ASF_Header_Extension_Object:
- // Header Extension Object: (mandatory, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Header Extension object - GETID3_ASF_Header_Extension_Object
- // Object Size QWORD 64 // size of Header Extension object, including 46 bytes of Header Extension Object header
- // Reserved Field 1 GUID 128 // hardcoded: GETID3_ASF_Reserved_1
- // Reserved Field 2 WORD 16 // hardcoded: 0x00000006
- // Header Extension Data Size DWORD 32 // in bytes. valid: 0, or > 24. equals object size minus 46
- // Header Extension Data BYTESTREAM variable // array of zero or more extended header objects
-
- // shortcut
- $thisfile_asf['header_extension_object'] = array();
- $thisfile_asf_headerextensionobject = &$thisfile_asf['header_extension_object'];
-
- $thisfile_asf_headerextensionobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_headerextensionobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_headerextensionobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_headerextensionobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_headerextensionobject['reserved_1'] = substr($ASFHeaderData, $offset, 16);
- $offset += 16;
- $thisfile_asf_headerextensionobject['reserved_1_guid'] = $this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']);
- if ($thisfile_asf_headerextensionobject['reserved_1'] != GETID3_ASF_Reserved_1) {
- $info['warning'][] = 'header_extension_object.reserved_1 GUID ('.$this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']).') does not match expected "GETID3_ASF_Reserved_1" GUID ('.$this->BytestringToGUID(GETID3_ASF_Reserved_1).')';
- //return false;
- break;
- }
- $thisfile_asf_headerextensionobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- if ($thisfile_asf_headerextensionobject['reserved_2'] != 6) {
- $info['warning'][] = 'header_extension_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_headerextensionobject['reserved_2']).') does not match expected value of "6"';
- //return false;
- break;
- }
- $thisfile_asf_headerextensionobject['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $thisfile_asf_headerextensionobject['extension_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']);
- $unhandled_sections = 0;
- $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->ASF_HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections);
- if ($unhandled_sections === 0) {
- unset($thisfile_asf_headerextensionobject['extension_data']);
- }
- $offset += $thisfile_asf_headerextensionobject['extension_data_size'];
- break;
-
- case GETID3_ASF_Codec_List_Object:
- // Codec List Object: (optional, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Codec List object - GETID3_ASF_Codec_List_Object
- // Object Size QWORD 64 // size of Codec List object, including 44 bytes of Codec List Object header
- // Reserved GUID 128 // hardcoded: 86D15241-311D-11D0-A3A4-00A0C90348F6
- // Codec Entries Count DWORD 32 // number of entries in Codec Entries array
- // Codec Entries array of: variable //
- // * Type WORD 16 // 0x0001 = Video Codec, 0x0002 = Audio Codec, 0xFFFF = Unknown Codec
- // * Codec Name Length WORD 16 // number of Unicode characters stored in the Codec Name field
- // * Codec Name WCHAR variable // array of Unicode characters - name of codec used to create the content
- // * Codec Description Length WORD 16 // number of Unicode characters stored in the Codec Description field
- // * Codec Description WCHAR variable // array of Unicode characters - description of format used to create the content
- // * Codec Information Length WORD 16 // number of Unicode characters stored in the Codec Information field
- // * Codec Information BYTESTREAM variable // opaque array of information bytes about the codec used to create the content
-
- // shortcut
- $thisfile_asf['codec_list_object'] = array();
- $thisfile_asf_codeclistobject = &$thisfile_asf['codec_list_object'];
-
- $thisfile_asf_codeclistobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_codeclistobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_codeclistobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_codeclistobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_codeclistobject['reserved'] = substr($ASFHeaderData, $offset, 16);
- $offset += 16;
- $thisfile_asf_codeclistobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']);
- if ($thisfile_asf_codeclistobject['reserved'] != $this->GUIDtoBytestring('86D15241-311D-11D0-A3A4-00A0C90348F6')) {
- $info['warning'][] = 'codec_list_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}';
- //return false;
- break;
- }
- $thisfile_asf_codeclistobject['codec_entries_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- for ($CodecEntryCounter = 0; $CodecEntryCounter < $thisfile_asf_codeclistobject['codec_entries_count']; $CodecEntryCounter++) {
- // shortcut
- $thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter] = array();
- $thisfile_asf_codeclistobject_codecentries_current = &$thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter];
-
- $thisfile_asf_codeclistobject_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_codeclistobject_codecentries_current['type'] = $this->ASFCodecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']);
-
- $CodecNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
- $offset += 2;
- $thisfile_asf_codeclistobject_codecentries_current['name'] = substr($ASFHeaderData, $offset, $CodecNameLength);
- $offset += $CodecNameLength;
-
- $CodecDescriptionLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
- $offset += 2;
- $thisfile_asf_codeclistobject_codecentries_current['description'] = substr($ASFHeaderData, $offset, $CodecDescriptionLength);
- $offset += $CodecDescriptionLength;
-
- $CodecInformationLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_codeclistobject_codecentries_current['information'] = substr($ASFHeaderData, $offset, $CodecInformationLength);
- $offset += $CodecInformationLength;
-
- if ($thisfile_asf_codeclistobject_codecentries_current['type_raw'] == 2) { // audio codec
-
- if (strpos($thisfile_asf_codeclistobject_codecentries_current['description'], ',') === false) {
- $info['warning'][] = '[asf][codec_list_object][codec_entries]['.$CodecEntryCounter.'][description] expected to contain comma-seperated list of parameters: "'.$thisfile_asf_codeclistobject_codecentries_current['description'].'"';
- } else {
-
- list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']));
- $thisfile_audio['codec'] = $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']);
-
- if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) {
- $thisfile_audio['bitrate'] = (int) (trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000);
- }
- //if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) {
- if (empty($thisfile_video['bitrate']) && !empty($thisfile_audio['bitrate']) && !empty($info['bitrate'])) {
- //$thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate'];
- $thisfile_video['bitrate'] = $info['bitrate'] - $thisfile_audio['bitrate'];
- }
-
- $AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency));
- switch ($AudioCodecFrequency) {
- case 8:
- case 8000:
- $thisfile_audio['sample_rate'] = 8000;
- break;
-
- case 11:
- case 11025:
- $thisfile_audio['sample_rate'] = 11025;
- break;
-
- case 12:
- case 12000:
- $thisfile_audio['sample_rate'] = 12000;
- break;
-
- case 16:
- case 16000:
- $thisfile_audio['sample_rate'] = 16000;
- break;
-
- case 22:
- case 22050:
- $thisfile_audio['sample_rate'] = 22050;
- break;
-
- case 24:
- case 24000:
- $thisfile_audio['sample_rate'] = 24000;
- break;
-
- case 32:
- case 32000:
- $thisfile_audio['sample_rate'] = 32000;
- break;
-
- case 44:
- case 441000:
- $thisfile_audio['sample_rate'] = 44100;
- break;
-
- case 48:
- case 48000:
- $thisfile_audio['sample_rate'] = 48000;
- break;
-
- default:
- $info['warning'][] = 'unknown frequency: "'.$AudioCodecFrequency.'" ('.$this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']).')';
- break;
- }
-
- if (!isset($thisfile_audio['channels'])) {
- if (strstr($AudioCodecChannels, 'stereo')) {
- $thisfile_audio['channels'] = 2;
- } elseif (strstr($AudioCodecChannels, 'mono')) {
- $thisfile_audio['channels'] = 1;
- }
- }
-
- }
- }
- }
- break;
-
- case GETID3_ASF_Script_Command_Object:
- // Script Command Object: (optional, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Script Command object - GETID3_ASF_Script_Command_Object
- // Object Size QWORD 64 // size of Script Command object, including 44 bytes of Script Command Object header
- // Reserved GUID 128 // hardcoded: 4B1ACBE3-100B-11D0-A39B-00A0C90348F6
- // Commands Count WORD 16 // number of Commands structures in the Script Commands Objects
- // Command Types Count WORD 16 // number of Command Types structures in the Script Commands Objects
- // Command Types array of: variable //
- // * Command Type Name Length WORD 16 // number of Unicode characters for Command Type Name
- // * Command Type Name WCHAR variable // array of Unicode characters - name of a type of command
- // Commands array of: variable //
- // * Presentation Time DWORD 32 // presentation time of that command, in milliseconds
- // * Type Index WORD 16 // type of this command, as a zero-based index into the array of Command Types of this object
- // * Command Name Length WORD 16 // number of Unicode characters for Command Name
- // * Command Name WCHAR variable // array of Unicode characters - name of this command
-
- // shortcut
- $thisfile_asf['script_command_object'] = array();
- $thisfile_asf_scriptcommandobject = &$thisfile_asf['script_command_object'];
-
- $thisfile_asf_scriptcommandobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_scriptcommandobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_scriptcommandobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_scriptcommandobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_scriptcommandobject['reserved'] = substr($ASFHeaderData, $offset, 16);
- $offset += 16;
- $thisfile_asf_scriptcommandobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']);
- if ($thisfile_asf_scriptcommandobject['reserved'] != $this->GUIDtoBytestring('4B1ACBE3-100B-11D0-A39B-00A0C90348F6')) {
- $info['warning'][] = 'script_command_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}';
- //return false;
- break;
- }
- $thisfile_asf_scriptcommandobject['commands_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_scriptcommandobject['command_types_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- for ($CommandTypesCounter = 0; $CommandTypesCounter < $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) {
- $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
- $offset += 2;
- $thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
- $offset += $CommandTypeNameLength;
- }
- for ($CommandsCounter = 0; $CommandsCounter < $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) {
- $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['type_index'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
-
- $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
- $offset += 2;
- $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
- $offset += $CommandTypeNameLength;
- }
- break;
-
- case GETID3_ASF_Marker_Object:
- // Marker Object: (optional, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Marker object - GETID3_ASF_Marker_Object
- // Object Size QWORD 64 // size of Marker object, including 48 bytes of Marker Object header
- // Reserved GUID 128 // hardcoded: 4CFEDB20-75F6-11CF-9C0F-00A0C90349CB
- // Markers Count DWORD 32 // number of Marker structures in Marker Object
- // Reserved WORD 16 // hardcoded: 0x0000
- // Name Length WORD 16 // number of bytes in the Name field
- // Name WCHAR variable // name of the Marker Object
- // Markers array of: variable //
- // * Offset QWORD 64 // byte offset into Data Object
- // * Presentation Time QWORD 64 // in 100-nanosecond units
- // * Entry Length WORD 16 // length in bytes of (Send Time + Flags + Marker Description Length + Marker Description + Padding)
- // * Send Time DWORD 32 // in milliseconds
- // * Flags DWORD 32 // hardcoded: 0x00000000
- // * Marker Description Length DWORD 32 // number of bytes in Marker Description field
- // * Marker Description WCHAR variable // array of Unicode characters - description of marker entry
- // * Padding BYTESTREAM variable // optional padding bytes
-
- // shortcut
- $thisfile_asf['marker_object'] = array();
- $thisfile_asf_markerobject = &$thisfile_asf['marker_object'];
-
- $thisfile_asf_markerobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_markerobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_markerobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_markerobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_markerobject['reserved'] = substr($ASFHeaderData, $offset, 16);
- $offset += 16;
- $thisfile_asf_markerobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_markerobject['reserved']);
- if ($thisfile_asf_markerobject['reserved'] != $this->GUIDtoBytestring('4CFEDB20-75F6-11CF-9C0F-00A0C90349CB')) {
- $info['warning'][] = 'marker_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_markerobject['reserved_1']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}';
- break;
- }
- $thisfile_asf_markerobject['markers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $thisfile_asf_markerobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- if ($thisfile_asf_markerobject['reserved_2'] != 0) {
- $info['warning'][] = 'marker_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_markerobject['reserved_2']).') does not match expected value of "0"';
- break;
- }
- $thisfile_asf_markerobject['name_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_markerobject['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['name_length']);
- $offset += $thisfile_asf_markerobject['name_length'];
- for ($MarkersCounter = 0; $MarkersCounter < $thisfile_asf_markerobject['markers_count']; $MarkersCounter++) {
- $thisfile_asf_markerobject['markers'][$MarkersCounter]['offset'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $offset += 8;
- $thisfile_asf_markerobject['markers'][$MarkersCounter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
- $offset += 8;
- $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_markerobject['markers'][$MarkersCounter]['send_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $thisfile_asf_markerobject['markers'][$MarkersCounter]['flags'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length']);
- $offset += $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'];
- $PaddingLength = $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length'] - 4 - 4 - 4 - $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'];
- if ($PaddingLength > 0) {
- $thisfile_asf_markerobject['markers'][$MarkersCounter]['padding'] = substr($ASFHeaderData, $offset, $PaddingLength);
- $offset += $PaddingLength;
- }
- }
- break;
-
- case GETID3_ASF_Bitrate_Mutual_Exclusion_Object:
- // Bitrate Mutual Exclusion Object: (optional)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Bitrate Mutual Exclusion object - GETID3_ASF_Bitrate_Mutual_Exclusion_Object
- // Object Size QWORD 64 // size of Bitrate Mutual Exclusion object, including 42 bytes of Bitrate Mutual Exclusion Object header
- // Exlusion Type GUID 128 // nature of mutual exclusion relationship. one of: (GETID3_ASF_Mutex_Bitrate, GETID3_ASF_Mutex_Unknown)
- // Stream Numbers Count WORD 16 // number of video streams
- // Stream Numbers WORD variable // array of mutually exclusive video stream numbers. 1 <= valid <= 127
-
- // shortcut
- $thisfile_asf['bitrate_mutual_exclusion_object'] = array();
- $thisfile_asf_bitratemutualexclusionobject = &$thisfile_asf['bitrate_mutual_exclusion_object'];
-
- $thisfile_asf_bitratemutualexclusionobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_bitratemutualexclusionobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_bitratemutualexclusionobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_bitratemutualexclusionobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_bitratemutualexclusionobject['reserved'] = substr($ASFHeaderData, $offset, 16);
- $thisfile_asf_bitratemutualexclusionobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']);
- $offset += 16;
- if (($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Bitrate) && ($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Unknown)) {
- $info['warning'][] = 'bitrate_mutual_exclusion_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']).'} does not match expected "GETID3_ASF_Mutex_Bitrate" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Bitrate).'} or "GETID3_ASF_Mutex_Unknown" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Unknown).'}';
- //return false;
- break;
- }
- $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- for ($StreamNumberCounter = 0; $StreamNumberCounter < $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) {
- $thisfile_asf_bitratemutualexclusionobject['stream_numbers'][$StreamNumberCounter] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- }
- break;
-
- case GETID3_ASF_Error_Correction_Object:
- // Error Correction Object: (optional, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Error Correction object - GETID3_ASF_Error_Correction_Object
- // Object Size QWORD 64 // size of Error Correction object, including 44 bytes of Error Correction Object header
- // Error Correction Type GUID 128 // type of error correction. one of: (GETID3_ASF_No_Error_Correction, GETID3_ASF_Audio_Spread)
- // Error Correction Data Length DWORD 32 // number of bytes in Error Correction Data field
- // Error Correction Data BYTESTREAM variable // structure depends on value of Error Correction Type field
-
- // shortcut
- $thisfile_asf['error_correction_object'] = array();
- $thisfile_asf_errorcorrectionobject = &$thisfile_asf['error_correction_object'];
-
- $thisfile_asf_errorcorrectionobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_errorcorrectionobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_errorcorrectionobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_errorcorrectionobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_errorcorrectionobject['error_correction_type'] = substr($ASFHeaderData, $offset, 16);
- $offset += 16;
- $thisfile_asf_errorcorrectionobject['error_correction_guid'] = $this->BytestringToGUID($thisfile_asf_errorcorrectionobject['error_correction_type']);
- $thisfile_asf_errorcorrectionobject['error_correction_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- switch ($thisfile_asf_errorcorrectionobject['error_correction_type']) {
- case GETID3_ASF_No_Error_Correction:
- // should be no data, but just in case there is, skip to the end of the field
- $offset += $thisfile_asf_errorcorrectionobject['error_correction_data_length'];
- break;
-
- case GETID3_ASF_Audio_Spread:
- // Field Name Field Type Size (bits)
- // Span BYTE 8 // number of packets over which audio will be spread.
- // Virtual Packet Length WORD 16 // size of largest audio payload found in audio stream
- // Virtual Chunk Length WORD 16 // size of largest audio payload found in audio stream
- // Silence Data Length WORD 16 // number of bytes in Silence Data field
- // Silence Data BYTESTREAM variable // hardcoded: 0x00 * (Silence Data Length) bytes
-
- $thisfile_asf_errorcorrectionobject['span'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 1));
- $offset += 1;
- $thisfile_asf_errorcorrectionobject['virtual_packet_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_errorcorrectionobject['virtual_chunk_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_errorcorrectionobject['silence_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_errorcorrectionobject['silence_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_errorcorrectionobject['silence_data_length']);
- $offset += $thisfile_asf_errorcorrectionobject['silence_data_length'];
- break;
-
- default:
- $info['warning'][] = 'error_correction_object.error_correction_type GUID {'.$this->BytestringToGUID($thisfile_asf_errorcorrectionobject['reserved']).'} does not match expected "GETID3_ASF_No_Error_Correction" GUID {'.$this->BytestringToGUID(GETID3_ASF_No_Error_Correction).'} or "GETID3_ASF_Audio_Spread" GUID {'.$this->BytestringToGUID(GETID3_ASF_Audio_Spread).'}';
- //return false;
- break;
- }
-
- break;
-
- case GETID3_ASF_Content_Description_Object:
- // Content Description Object: (optional, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Content Description object - GETID3_ASF_Content_Description_Object
- // Object Size QWORD 64 // size of Content Description object, including 34 bytes of Content Description Object header
- // Title Length WORD 16 // number of bytes in Title field
- // Author Length WORD 16 // number of bytes in Author field
- // Copyright Length WORD 16 // number of bytes in Copyright field
- // Description Length WORD 16 // number of bytes in Description field
- // Rating Length WORD 16 // number of bytes in Rating field
- // Title WCHAR 16 // array of Unicode characters - Title
- // Author WCHAR 16 // array of Unicode characters - Author
- // Copyright WCHAR 16 // array of Unicode characters - Copyright
- // Description WCHAR 16 // array of Unicode characters - Description
- // Rating WCHAR 16 // array of Unicode characters - Rating
-
- // shortcut
- $thisfile_asf['content_description_object'] = array();
- $thisfile_asf_contentdescriptionobject = &$thisfile_asf['content_description_object'];
-
- $thisfile_asf_contentdescriptionobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_contentdescriptionobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_contentdescriptionobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_contentdescriptionobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_contentdescriptionobject['title_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_contentdescriptionobject['author_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_contentdescriptionobject['copyright_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_contentdescriptionobject['description_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_contentdescriptionobject['rating_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_contentdescriptionobject['title'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['title_length']);
- $offset += $thisfile_asf_contentdescriptionobject['title_length'];
- $thisfile_asf_contentdescriptionobject['author'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['author_length']);
- $offset += $thisfile_asf_contentdescriptionobject['author_length'];
- $thisfile_asf_contentdescriptionobject['copyright'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['copyright_length']);
- $offset += $thisfile_asf_contentdescriptionobject['copyright_length'];
- $thisfile_asf_contentdescriptionobject['description'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['description_length']);
- $offset += $thisfile_asf_contentdescriptionobject['description_length'];
- $thisfile_asf_contentdescriptionobject['rating'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['rating_length']);
- $offset += $thisfile_asf_contentdescriptionobject['rating_length'];
-
- $ASFcommentKeysToCopy = array('title'=>'title', 'author'=>'artist', 'copyright'=>'copyright', 'description'=>'comment', 'rating'=>'rating');
- foreach ($ASFcommentKeysToCopy as $keytocopyfrom => $keytocopyto) {
- if (!empty($thisfile_asf_contentdescriptionobject[$keytocopyfrom])) {
- $thisfile_asf_comments[$keytocopyto][] = $this->TrimTerm($thisfile_asf_contentdescriptionobject[$keytocopyfrom]);
- }
- }
- break;
-
- case GETID3_ASF_Extended_Content_Description_Object:
- // Extended Content Description Object: (optional, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Extended Content Description object - GETID3_ASF_Extended_Content_Description_Object
- // Object Size QWORD 64 // size of ExtendedContent Description object, including 26 bytes of Extended Content Description Object header
- // Content Descriptors Count WORD 16 // number of entries in Content Descriptors list
- // Content Descriptors array of: variable //
- // * Descriptor Name Length WORD 16 // size in bytes of Descriptor Name field
- // * Descriptor Name WCHAR variable // array of Unicode characters - Descriptor Name
- // * Descriptor Value Data Type WORD 16 // Lookup array:
- // 0x0000 = Unicode String (variable length)
- // 0x0001 = BYTE array (variable length)
- // 0x0002 = BOOL (DWORD, 32 bits)
- // 0x0003 = DWORD (DWORD, 32 bits)
- // 0x0004 = QWORD (QWORD, 64 bits)
- // 0x0005 = WORD (WORD, 16 bits)
- // * Descriptor Value Length WORD 16 // number of bytes stored in Descriptor Value field
- // * Descriptor Value variable variable // value for Content Descriptor
-
- // shortcut
- $thisfile_asf['extended_content_description_object'] = array();
- $thisfile_asf_extendedcontentdescriptionobject = &$thisfile_asf['extended_content_description_object'];
-
- $thisfile_asf_extendedcontentdescriptionobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_extendedcontentdescriptionobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_extendedcontentdescriptionobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_extendedcontentdescriptionobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) {
- // shortcut
- $thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter] = array();
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current = &$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter];
-
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['base_offset'] = $offset + 30;
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length']);
- $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length'];
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = substr($ASFHeaderData, $offset, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length']);
- $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'];
- switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type']) {
- case 0x0000: // Unicode string
- break;
-
- case 0x0001: // BYTE array
- // do nothing
- break;
-
- case 0x0002: // BOOL
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = (bool) getid3_lib::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
- break;
-
- case 0x0003: // DWORD
- case 0x0004: // QWORD
- case 0x0005: // WORD
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = getid3_lib::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
- break;
-
- default:
- $info['warning'][] = 'extended_content_description.content_descriptors.'.$ExtendedContentDescriptorsCounter.'.value_type is invalid ('.$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type'].')';
- //return false;
- break;
- }
- switch ($this->TrimConvert(strtolower($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name']))) {
-
- case 'wm/albumartist':
- case 'artist':
- // Note: not 'artist', that comes from 'author' tag
- $thisfile_asf_comments['albumartist'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
- break;
-
- case 'wm/albumtitle':
- case 'album':
- $thisfile_asf_comments['album'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
- break;
-
- case 'wm/genre':
- case 'genre':
- $thisfile_asf_comments['genre'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
- break;
-
- case 'wm/partofset':
- $thisfile_asf_comments['partofset'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
- break;
-
- case 'wm/tracknumber':
- case 'tracknumber':
- // be careful casting to int: casting unicode strings to int gives unexpected results (stops parsing at first non-numeric character)
- $thisfile_asf_comments['track'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
- foreach ($thisfile_asf_comments['track'] as $key => $value) {
- if (preg_match('/^[0-9\x00]+$/', $value)) {
- $thisfile_asf_comments['track'][$key] = intval(str_replace("\x00", '', $value));
- }
- }
- break;
-
- case 'wm/track':
- if (empty($thisfile_asf_comments['track'])) {
- $thisfile_asf_comments['track'] = array(1 + $this->TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
- }
- break;
-
- case 'wm/year':
- case 'year':
- case 'date':
- $thisfile_asf_comments['year'] = array( $this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
- break;
-
- case 'wm/lyrics':
- case 'lyrics':
- $thisfile_asf_comments['lyrics'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
- break;
-
- case 'isvbr':
- if ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']) {
- $thisfile_audio['bitrate_mode'] = 'vbr';
- $thisfile_video['bitrate_mode'] = 'vbr';
- }
- break;
-
- case 'id3':
- // id3v2 module might not be loaded
- if (class_exists('getid3_id3v2')) {
- $tempfile = tempnam(GETID3_TEMP_DIR, 'getID3');
- $tempfilehandle = fopen($tempfile, 'wb');
- $tempThisfileInfo = array('encoding'=>$info['encoding']);
- fwrite($tempfilehandle, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
- fclose($tempfilehandle);
-
- $getid3_temp = new getID3();
- $getid3_temp->openfile($tempfile);
- $getid3_id3v2 = new getid3_id3v2($getid3_temp);
- $getid3_id3v2->Analyze();
- $info['id3v2'] = $getid3_temp->info['id3v2'];
- unset($getid3_temp, $getid3_id3v2);
-
- unlink($tempfile);
- }
- break;
-
- case 'wm/encodingtime':
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
- $thisfile_asf_comments['encoding_time_unix'] = array($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix']);
- break;
-
- case 'wm/picture':
- $WMpicture = $this->ASF_WMpicture($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
- foreach ($WMpicture as $key => $value) {
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[$key] = $value;
- }
- unset($WMpicture);
-/*
- $wm_picture_offset = 0;
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 1));
- $wm_picture_offset += 1;
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type'] = $this->WMpictureTypeLookup($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id']);
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_size'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 4));
- $wm_picture_offset += 4;
-
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = '';
- do {
- $next_byte_pair = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 2);
- $wm_picture_offset += 2;
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] .= $next_byte_pair;
- } while ($next_byte_pair !== "\x00\x00");
-
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_description'] = '';
- do {
- $next_byte_pair = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 2);
- $wm_picture_offset += 2;
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_description'] .= $next_byte_pair;
- } while ($next_byte_pair !== "\x00\x00");
-
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['dataoffset'] = $wm_picture_offset;
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'] = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset);
- unset($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
-
- $imageinfo = array();
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = '';
- $imagechunkcheck = getid3_lib::GetDataImageSize($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], $imageinfo);
- unset($imageinfo);
- if (!empty($imagechunkcheck)) {
- $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
- }
- if (!isset($thisfile_asf_comments['picture'])) {
- $thisfile_asf_comments['picture'] = array();
- }
- $thisfile_asf_comments['picture'][] = array('data'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], 'image_mime'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime']);
-*/
- break;
-
- default:
- switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type']) {
- case 0: // Unicode string
- if (substr($this->TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name']), 0, 3) == 'WM/') {
- $thisfile_asf_comments[str_replace('wm/', '', strtolower($this->TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name'])))] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
- }
- break;
-
- case 1:
- break;
- }
- break;
- }
-
- }
- break;
-
- case GETID3_ASF_Stream_Bitrate_Properties_Object:
- // Stream Bitrate Properties Object: (optional, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Stream Bitrate Properties object - GETID3_ASF_Stream_Bitrate_Properties_Object
- // Object Size QWORD 64 // size of Extended Content Description object, including 26 bytes of Stream Bitrate Properties Object header
- // Bitrate Records Count WORD 16 // number of records in Bitrate Records
- // Bitrate Records array of: variable //
- // * Flags WORD 16 //
- // * * Stream Number bits 7 (0x007F) // number of this stream
- // * * Reserved bits 9 (0xFF80) // hardcoded: 0
- // * Average Bitrate DWORD 32 // in bits per second
-
- // shortcut
- $thisfile_asf['stream_bitrate_properties_object'] = array();
- $thisfile_asf_streambitratepropertiesobject = &$thisfile_asf['stream_bitrate_properties_object'];
-
- $thisfile_asf_streambitratepropertiesobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_streambitratepropertiesobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_streambitratepropertiesobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_streambitratepropertiesobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_streambitratepropertiesobject['bitrate_records_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
- $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
- $offset += 2;
- $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags']['stream_number'] = $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] & 0x007F;
- $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
- $offset += 4;
- }
- break;
-
- case GETID3_ASF_Padding_Object:
- // Padding Object: (optional)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Padding object - GETID3_ASF_Padding_Object
- // Object Size QWORD 64 // size of Padding object, including 24 bytes of ASF Padding Object header
- // Padding Data BYTESTREAM variable // ignore
-
- // shortcut
- $thisfile_asf['padding_object'] = array();
- $thisfile_asf_paddingobject = &$thisfile_asf['padding_object'];
-
- $thisfile_asf_paddingobject['offset'] = $NextObjectOffset + $offset;
- $thisfile_asf_paddingobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_paddingobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_paddingobject['objectsize'] = $NextObjectSize;
- $thisfile_asf_paddingobject['padding_length'] = $thisfile_asf_paddingobject['objectsize'] - 16 - 8;
- $thisfile_asf_paddingobject['padding'] = substr($ASFHeaderData, $offset, $thisfile_asf_paddingobject['padding_length']);
- $offset += ($NextObjectSize - 16 - 8);
- break;
-
- case GETID3_ASF_Extended_Content_Encryption_Object:
- case GETID3_ASF_Content_Encryption_Object:
- // WMA DRM - just ignore
- $offset += ($NextObjectSize - 16 - 8);
- break;
-
- default:
- // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
- if ($this->GUIDname($NextObjectGUIDtext)) {
- $info['warning'][] = 'unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8);
- } else {
- $info['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8);
- }
- $offset += ($NextObjectSize - 16 - 8);
- break;
- }
- }
- if (isset($thisfile_asf_streambitrateproperties['bitrate_records_count'])) {
- $ASFbitrateAudio = 0;
- $ASFbitrateVideo = 0;
- for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitrateproperties['bitrate_records_count']; $BitrateRecordsCounter++) {
- if (isset($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter])) {
- switch ($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter]['type_raw']) {
- case 1:
- $ASFbitrateVideo += $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['bitrate'];
- break;
-
- case 2:
- $ASFbitrateAudio += $thisfile_asf_streambitrateproperties['bitrate_records'][$BitrateRecordsCounter]['bitrate'];
- break;
-
- default:
- // do nothing
- break;
- }
- }
- }
- if ($ASFbitrateAudio > 0) {
- $thisfile_audio['bitrate'] = $ASFbitrateAudio;
- }
- if ($ASFbitrateVideo > 0) {
- $thisfile_video['bitrate'] = $ASFbitrateVideo;
- }
- }
- if (isset($thisfile_asf['stream_properties_object']) && is_array($thisfile_asf['stream_properties_object'])) {
-
- $thisfile_audio['bitrate'] = 0;
- $thisfile_video['bitrate'] = 0;
-
- foreach ($thisfile_asf['stream_properties_object'] as $streamnumber => $streamdata) {
-
- switch ($streamdata['stream_type']) {
- case GETID3_ASF_Audio_Media:
- // Field Name Field Type Size (bits)
- // Codec ID / Format Tag WORD 16 // unique ID of audio codec - defined as wFormatTag field of WAVEFORMATEX structure
- // Number of Channels WORD 16 // number of channels of audio - defined as nChannels field of WAVEFORMATEX structure
- // Samples Per Second DWORD 32 // in Hertz - defined as nSamplesPerSec field of WAVEFORMATEX structure
- // Average number of Bytes/sec DWORD 32 // bytes/sec of audio stream - defined as nAvgBytesPerSec field of WAVEFORMATEX structure
- // Block Alignment WORD 16 // block size in bytes of audio codec - defined as nBlockAlign field of WAVEFORMATEX structure
- // Bits per sample WORD 16 // bits per sample of mono data. set to zero for variable bitrate codecs. defined as wBitsPerSample field of WAVEFORMATEX structure
- // Codec Specific Data Size WORD 16 // size in bytes of Codec Specific Data buffer - defined as cbSize field of WAVEFORMATEX structure
- // Codec Specific Data BYTESTREAM variable // array of codec-specific data bytes
-
- // shortcut
- $thisfile_asf['audio_media'][$streamnumber] = array();
- $thisfile_asf_audiomedia_currentstream = &$thisfile_asf['audio_media'][$streamnumber];
-
- $audiomediaoffset = 0;
-
- $thisfile_asf_audiomedia_currentstream = getid3_riff::RIFFparseWAVEFORMATex(substr($streamdata['type_specific_data'], $audiomediaoffset, 16));
- $audiomediaoffset += 16;
-
- $thisfile_audio['lossless'] = false;
- switch ($thisfile_asf_audiomedia_currentstream['raw']['wFormatTag']) {
- case 0x0001: // PCM
- case 0x0163: // WMA9 Lossless
- $thisfile_audio['lossless'] = true;
- break;
- }
-
- if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) {
- foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
- if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
- $thisfile_asf_audiomedia_currentstream['bitrate'] = $dataarray['bitrate'];
- $thisfile_audio['bitrate'] += $dataarray['bitrate'];
- break;
- }
- }
- } else {
- if (!empty($thisfile_asf_audiomedia_currentstream['bytes_sec'])) {
- $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bytes_sec'] * 8;
- } elseif (!empty($thisfile_asf_audiomedia_currentstream['bitrate'])) {
- $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bitrate'];
- }
- }
- $thisfile_audio['streams'][$streamnumber] = $thisfile_asf_audiomedia_currentstream;
- $thisfile_audio['streams'][$streamnumber]['wformattag'] = $thisfile_asf_audiomedia_currentstream['raw']['wFormatTag'];
- $thisfile_audio['streams'][$streamnumber]['lossless'] = $thisfile_audio['lossless'];
- $thisfile_audio['streams'][$streamnumber]['bitrate'] = $thisfile_audio['bitrate'];
- $thisfile_audio['streams'][$streamnumber]['dataformat'] = 'wma';
- unset($thisfile_audio['streams'][$streamnumber]['raw']);
-
- $thisfile_asf_audiomedia_currentstream['codec_data_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $audiomediaoffset, 2));
- $audiomediaoffset += 2;
- $thisfile_asf_audiomedia_currentstream['codec_data'] = substr($streamdata['type_specific_data'], $audiomediaoffset, $thisfile_asf_audiomedia_currentstream['codec_data_size']);
- $audiomediaoffset += $thisfile_asf_audiomedia_currentstream['codec_data_size'];
-
- break;
-
- case GETID3_ASF_Video_Media:
- // Field Name Field Type Size (bits)
- // Encoded Image Width DWORD 32 // width of image in pixels
- // Encoded Image Height DWORD 32 // height of image in pixels
- // Reserved Flags BYTE 8 // hardcoded: 0x02
- // Format Data Size WORD 16 // size of Format Data field in bytes
- // Format Data array of: variable //
- // * Format Data Size DWORD 32 // number of bytes in Format Data field, in bytes - defined as biSize field of BITMAPINFOHEADER structure
- // * Image Width LONG 32 // width of encoded image in pixels - defined as biWidth field of BITMAPINFOHEADER structure
- // * Image Height LONG 32 // height of encoded image in pixels - defined as biHeight field of BITMAPINFOHEADER structure
- // * Reserved WORD 16 // hardcoded: 0x0001 - defined as biPlanes field of BITMAPINFOHEADER structure
- // * Bits Per Pixel Count WORD 16 // bits per pixel - defined as biBitCount field of BITMAPINFOHEADER structure
- // * Compression ID FOURCC 32 // fourcc of video codec - defined as biCompression field of BITMAPINFOHEADER structure
- // * Image Size DWORD 32 // image size in bytes - defined as biSizeImage field of BITMAPINFOHEADER structure
- // * Horizontal Pixels / Meter DWORD 32 // horizontal resolution of target device in pixels per meter - defined as biXPelsPerMeter field of BITMAPINFOHEADER structure
- // * Vertical Pixels / Meter DWORD 32 // vertical resolution of target device in pixels per meter - defined as biYPelsPerMeter field of BITMAPINFOHEADER structure
- // * Colors Used Count DWORD 32 // number of color indexes in the color table that are actually used - defined as biClrUsed field of BITMAPINFOHEADER structure
- // * Important Colors Count DWORD 32 // number of color index required for displaying bitmap. if zero, all colors are required. defined as biClrImportant field of BITMAPINFOHEADER structure
- // * Codec Specific Data BYTESTREAM variable // array of codec-specific data bytes
-
- // shortcut
- $thisfile_asf['video_media'][$streamnumber] = array();
- $thisfile_asf_videomedia_currentstream = &$thisfile_asf['video_media'][$streamnumber];
-
- $videomediaoffset = 0;
- $thisfile_asf_videomedia_currentstream['image_width'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['image_height'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['flags'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 1));
- $videomediaoffset += 1;
- $thisfile_asf_videomedia_currentstream['format_data_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
- $videomediaoffset += 2;
- $thisfile_asf_videomedia_currentstream['format_data']['format_data_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['format_data']['image_width'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['format_data']['image_height'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['format_data']['reserved'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
- $videomediaoffset += 2;
- $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
- $videomediaoffset += 2;
- $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc'] = substr($streamdata['type_specific_data'], $videomediaoffset, 4);
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['format_data']['image_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['format_data']['horizontal_pels'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['format_data']['vertical_pels'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['format_data']['colors_used'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['format_data']['colors_important'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
- $videomediaoffset += 4;
- $thisfile_asf_videomedia_currentstream['format_data']['codec_data'] = substr($streamdata['type_specific_data'], $videomediaoffset);
-
- if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) {
- foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
- if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
- $thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate'];
- $thisfile_video['streams'][$streamnumber]['bitrate'] = $dataarray['bitrate'];
- $thisfile_video['bitrate'] += $dataarray['bitrate'];
- break;
- }
- }
- }
-
- $thisfile_asf_videomedia_currentstream['format_data']['codec'] = getid3_riff::RIFFfourccLookup($thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']);
-
- $thisfile_video['streams'][$streamnumber]['fourcc'] = $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc'];
- $thisfile_video['streams'][$streamnumber]['codec'] = $thisfile_asf_videomedia_currentstream['format_data']['codec'];
- $thisfile_video['streams'][$streamnumber]['resolution_x'] = $thisfile_asf_videomedia_currentstream['image_width'];
- $thisfile_video['streams'][$streamnumber]['resolution_y'] = $thisfile_asf_videomedia_currentstream['image_height'];
- $thisfile_video['streams'][$streamnumber]['bits_per_sample'] = $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel'];
- break;
-
- default:
- break;
- }
- }
- }
-
- while (ftell($this->getid3->fp) < $info['avdataend']) {
- $NextObjectDataHeader = fread($this->getid3->fp, 24);
- $offset = 0;
- $NextObjectGUID = substr($NextObjectDataHeader, 0, 16);
- $offset += 16;
- $NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID);
- $NextObjectSize = getid3_lib::LittleEndian2Int(substr($NextObjectDataHeader, $offset, 8));
- $offset += 8;
-
- switch ($NextObjectGUID) {
- case GETID3_ASF_Data_Object:
- // Data Object: (mandatory, one only)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Data object - GETID3_ASF_Data_Object
- // Object Size QWORD 64 // size of Data object, including 50 bytes of Data Object header. may be 0 if FilePropertiesObject.BroadcastFlag == 1
- // File ID GUID 128 // unique identifier. identical to File ID field in Header Object
- // Total Data Packets QWORD 64 // number of Data Packet entries in Data Object. invalid if FilePropertiesObject.BroadcastFlag == 1
- // Reserved WORD 16 // hardcoded: 0x0101
-
- // shortcut
- $thisfile_asf['data_object'] = array();
- $thisfile_asf_dataobject = &$thisfile_asf['data_object'];
-
- $DataObjectData = $NextObjectDataHeader.fread($this->getid3->fp, 50 - 24);
- $offset = 24;
-
- $thisfile_asf_dataobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_dataobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_dataobject['objectsize'] = $NextObjectSize;
-
- $thisfile_asf_dataobject['fileid'] = substr($DataObjectData, $offset, 16);
- $offset += 16;
- $thisfile_asf_dataobject['fileid_guid'] = $this->BytestringToGUID($thisfile_asf_dataobject['fileid']);
- $thisfile_asf_dataobject['total_data_packets'] = getid3_lib::LittleEndian2Int(substr($DataObjectData, $offset, 8));
- $offset += 8;
- $thisfile_asf_dataobject['reserved'] = getid3_lib::LittleEndian2Int(substr($DataObjectData, $offset, 2));
- $offset += 2;
- if ($thisfile_asf_dataobject['reserved'] != 0x0101) {
- $info['warning'][] = 'data_object.reserved ('.getid3_lib::PrintHexBytes($thisfile_asf_dataobject['reserved']).') does not match expected value of "0x0101"';
- //return false;
- break;
- }
-
- // Data Packets array of: variable //
- // * Error Correction Flags BYTE 8 //
- // * * Error Correction Data Length bits 4 // if Error Correction Length Type == 00, size of Error Correction Data in bytes, else hardcoded: 0000
- // * * Opaque Data Present bits 1 //
- // * * Error Correction Length Type bits 2 // number of bits for size of the error correction data. hardcoded: 00
- // * * Error Correction Present bits 1 // If set, use Opaque Data Packet structure, else use Payload structure
- // * Error Correction Data
-
- $info['avdataoffset'] = ftell($this->getid3->fp);
- fseek($this->getid3->fp, ($thisfile_asf_dataobject['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data
- $info['avdataend'] = ftell($this->getid3->fp);
- break;
-
- case GETID3_ASF_Simple_Index_Object:
- // Simple Index Object: (optional, recommended, one per video stream)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for Simple Index object - GETID3_ASF_Data_Object
- // Object Size QWORD 64 // size of Simple Index object, including 56 bytes of Simple Index Object header
- // File ID GUID 128 // unique identifier. may be zero or identical to File ID field in Data Object and Header Object
- // Index Entry Time Interval QWORD 64 // interval between index entries in 100-nanosecond units
- // Maximum Packet Count DWORD 32 // maximum packet count for all index entries
- // Index Entries Count DWORD 32 // number of Index Entries structures
- // Index Entries array of: variable //
- // * Packet Number DWORD 32 // number of the Data Packet associated with this index entry
- // * Packet Count WORD 16 // number of Data Packets to sent at this index entry
-
- // shortcut
- $thisfile_asf['simple_index_object'] = array();
- $thisfile_asf_simpleindexobject = &$thisfile_asf['simple_index_object'];
-
- $SimpleIndexObjectData = $NextObjectDataHeader.fread($this->getid3->fp, 56 - 24);
- $offset = 24;
-
- $thisfile_asf_simpleindexobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_simpleindexobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_simpleindexobject['objectsize'] = $NextObjectSize;
-
- $thisfile_asf_simpleindexobject['fileid'] = substr($SimpleIndexObjectData, $offset, 16);
- $offset += 16;
- $thisfile_asf_simpleindexobject['fileid_guid'] = $this->BytestringToGUID($thisfile_asf_simpleindexobject['fileid']);
- $thisfile_asf_simpleindexobject['index_entry_time_interval'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 8));
- $offset += 8;
- $thisfile_asf_simpleindexobject['maximum_packet_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
- $offset += 4;
- $thisfile_asf_simpleindexobject['index_entries_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
- $offset += 4;
-
- $IndexEntriesData = $SimpleIndexObjectData.fread($this->getid3->fp, 6 * $thisfile_asf_simpleindexobject['index_entries_count']);
- for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) {
- $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
- $offset += 4;
- $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_count'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
- $offset += 2;
- }
-
- break;
-
- case GETID3_ASF_Index_Object:
- // 6.2 ASF top-level Index Object (optional but recommended when appropriate, 0 or 1)
- // Field Name Field Type Size (bits)
- // Object ID GUID 128 // GUID for the Index Object - GETID3_ASF_Index_Object
- // Object Size QWORD 64 // Specifies the size, in bytes, of the Index Object, including at least 34 bytes of Index Object header
- // Index Entry Time Interval DWORD 32 // Specifies the time interval between each index entry in ms.
- // Index Specifiers Count WORD 16 // Specifies the number of Index Specifiers structures in this Index Object.
- // Index Blocks Count DWORD 32 // Specifies the number of Index Blocks structures in this Index Object.
-
- // Index Entry Time Interval DWORD 32 // Specifies the time interval between index entries in milliseconds. This value cannot be 0.
- // Index Specifiers Count WORD 16 // Specifies the number of entries in the Index Specifiers list. Valid values are 1 and greater.
- // Index Specifiers array of: varies //
- // * Stream Number WORD 16 // Specifies the stream number that the Index Specifiers refer to. Valid values are between 1 and 127.
- // * Index Type WORD 16 // Specifies Index Type values as follows:
- // 1 = Nearest Past Data Packet - indexes point to the data packet whose presentation time is closest to the index entry time.
- // 2 = Nearest Past Media Object - indexes point to the closest data packet containing an entire object or first fragment of an object.
- // 3 = Nearest Past Cleanpoint. - indexes point to the closest data packet containing an entire object (or first fragment of an object) that has the Cleanpoint Flag set.
- // Nearest Past Cleanpoint is the most common type of index.
- // Index Entry Count DWORD 32 // Specifies the number of Index Entries in the block.
- // * Block Positions QWORD varies // Specifies a list of byte offsets of the beginnings of the blocks relative to the beginning of the first Data Packet (i.e., the beginning of the Data Object + 50 bytes). The number of entries in this list is specified by the value of the Index Specifiers Count field. The order of those byte offsets is tied to the order in which Index Specifiers are listed.
- // * Index Entries array of: varies //
- // * * Offsets DWORD varies // An offset value of 0xffffffff indicates an invalid offset value
-
- // shortcut
- $thisfile_asf['asf_index_object'] = array();
- $thisfile_asf_asfindexobject = &$thisfile_asf['asf_index_object'];
-
- $ASFIndexObjectData = $NextObjectDataHeader.fread($this->getid3->fp, 34 - 24);
- $offset = 24;
-
- $thisfile_asf_asfindexobject['objectid'] = $NextObjectGUID;
- $thisfile_asf_asfindexobject['objectid_guid'] = $NextObjectGUIDtext;
- $thisfile_asf_asfindexobject['objectsize'] = $NextObjectSize;
-
- $thisfile_asf_asfindexobject['entry_time_interval'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
- $offset += 4;
- $thisfile_asf_asfindexobject['index_specifiers_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
- $offset += 2;
- $thisfile_asf_asfindexobject['index_blocks_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
- $offset += 4;
-
- $ASFIndexObjectData .= fread($this->getid3->fp, 4 * $thisfile_asf_asfindexobject['index_specifiers_count']);
- for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
- $IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
- $offset += 2;
- $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['stream_number'] = $IndexSpecifierStreamNumber;
- $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
- $offset += 2;
- $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type_text'] = $this->ASFIndexObjectIndexTypeLookup($thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']);
- }
-
- $ASFIndexObjectData .= fread($this->getid3->fp, 4);
- $thisfile_asf_asfindexobject['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
- $offset += 4;
-
- $ASFIndexObjectData .= fread($this->getid3->fp, 8 * $thisfile_asf_asfindexobject['index_specifiers_count']);
- for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
- $thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8));
- $offset += 8;
- }
-
- $ASFIndexObjectData .= fread($this->getid3->fp, 4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']);
- for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; $IndexEntryCounter++) {
- for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
- $thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
- $offset += 4;
- }
- }
- break;
-
-
- default:
- // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
- if ($this->GUIDname($NextObjectGUIDtext)) {
- $info['warning'][] = 'unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF body at offset '.($offset - 16 - 8);
- } else {
- $info['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF body at offset '.(ftell($this->getid3->fp) - 16 - 8);
- }
- fseek($this->getid3->fp, ($NextObjectSize - 16 - 8), SEEK_CUR);
- break;
- }
- }
-
- if (isset($thisfile_asf_codeclistobject['codec_entries']) && is_array($thisfile_asf_codeclistobject['codec_entries'])) {
- foreach ($thisfile_asf_codeclistobject['codec_entries'] as $streamnumber => $streamdata) {
- switch ($streamdata['information']) {
- case 'WMV1':
- case 'WMV2':
- case 'WMV3':
- case 'MSS1':
- case 'MSS2':
- case 'WMVA':
- case 'WVC1':
- case 'WMVP':
- case 'WVP2':
- $thisfile_video['dataformat'] = 'wmv';
- $info['mime_type'] = 'video/x-ms-wmv';
- break;
-
- case 'MP42':
- case 'MP43':
- case 'MP4S':
- case 'mp4s':
- $thisfile_video['dataformat'] = 'asf';
- $info['mime_type'] = 'video/x-ms-asf';
- break;
-
- default:
- switch ($streamdata['type_raw']) {
- case 1:
- if (strstr($this->TrimConvert($streamdata['name']), 'Windows Media')) {
- $thisfile_video['dataformat'] = 'wmv';
- if ($info['mime_type'] == 'video/x-ms-asf') {
- $info['mime_type'] = 'video/x-ms-wmv';
- }
- }
- break;
-
- case 2:
- if (strstr($this->TrimConvert($streamdata['name']), 'Windows Media')) {
- $thisfile_audio['dataformat'] = 'wma';
- if ($info['mime_type'] == 'video/x-ms-asf') {
- $info['mime_type'] = 'audio/x-ms-wma';
- }
- }
- break;
-
- }
- break;
- }
- }
- }
-
- switch (isset($thisfile_audio['codec']) ? $thisfile_audio['codec'] : '') {
- case 'MPEG Layer-3':
- $thisfile_audio['dataformat'] = 'mp3';
- break;
-
- default:
- break;
- }
-
- if (isset($thisfile_asf_codeclistobject['codec_entries'])) {
- foreach ($thisfile_asf_codeclistobject['codec_entries'] as $streamnumber => $streamdata) {
- switch ($streamdata['type_raw']) {
-
- case 1: // video
- $thisfile_video['encoder'] = $this->TrimConvert($thisfile_asf_codeclistobject['codec_entries'][$streamnumber]['name']);
- break;
-
- case 2: // audio
- $thisfile_audio['encoder'] = $this->TrimConvert($thisfile_asf_codeclistobject['codec_entries'][$streamnumber]['name']);
-
- // AH 2003-10-01
- $thisfile_audio['encoder_options'] = $this->TrimConvert($thisfile_asf_codeclistobject['codec_entries'][0]['description']);
-
- $thisfile_audio['codec'] = $thisfile_audio['encoder'];
- break;
-
- default:
- $info['warning'][] = 'Unknown streamtype: [codec_list_object][codec_entries]['.$streamnumber.'][type_raw] == '.$streamdata['type_raw'];
- break;
-
- }
- }
- }
-
- if (isset($info['audio'])) {
- $thisfile_audio['lossless'] = (isset($thisfile_audio['lossless']) ? $thisfile_audio['lossless'] : false);
- $thisfile_audio['dataformat'] = (!empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf');
- }
- if (!empty($thisfile_video['dataformat'])) {
- $thisfile_video['lossless'] = (isset($thisfile_audio['lossless']) ? $thisfile_audio['lossless'] : false);
- $thisfile_video['pixel_aspect_ratio'] = (isset($thisfile_audio['pixel_aspect_ratio']) ? $thisfile_audio['pixel_aspect_ratio'] : (float) 1);
- $thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf');
- }
- if (!empty($thisfile_video['streams'])) {
- $thisfile_video['streams']['resolution_x'] = 0;
- $thisfile_video['streams']['resolution_y'] = 0;
- foreach ($thisfile_video['streams'] as $key => $valuearray) {
- if (($valuearray['resolution_x'] > $thisfile_video['streams']['resolution_x']) || ($valuearray['resolution_y'] > $thisfile_video['streams']['resolution_y'])) {
- $thisfile_video['resolution_x'] = $valuearray['resolution_x'];
- $thisfile_video['resolution_y'] = $valuearray['resolution_y'];
- }
- }
- }
- $info['bitrate'] = (isset($thisfile_audio['bitrate']) ? $thisfile_audio['bitrate'] : 0) + (isset($thisfile_video['bitrate']) ? $thisfile_video['bitrate'] : 0);
-
- if ((!isset($info['playtime_seconds']) || ($info['playtime_seconds'] <= 0)) && ($info['bitrate'] > 0)) {
- $info['playtime_seconds'] = ($info['filesize'] - $info['avdataoffset']) / ($info['bitrate'] / 8);
- }
-
- return true;
- }
-
- static function ASFCodecListObjectTypeLookup($CodecListType) {
- static $ASFCodecListObjectTypeLookup = array();
- if (empty($ASFCodecListObjectTypeLookup)) {
- $ASFCodecListObjectTypeLookup[0x0001] = 'Video Codec';
- $ASFCodecListObjectTypeLookup[0x0002] = 'Audio Codec';
- $ASFCodecListObjectTypeLookup[0xFFFF] = 'Unknown Codec';
- }
-
- return (isset($ASFCodecListObjectTypeLookup[$CodecListType]) ? $ASFCodecListObjectTypeLookup[$CodecListType] : 'Invalid Codec Type');
- }
-
- static function KnownGUIDs() {
- static $GUIDarray = array(
- 'GETID3_ASF_Extended_Stream_Properties_Object' => '14E6A5CB-C672-4332-8399-A96952065B5A',
- 'GETID3_ASF_Padding_Object' => '1806D474-CADF-4509-A4BA-9AABCB96AAE8',
- 'GETID3_ASF_Payload_Ext_Syst_Pixel_Aspect_Ratio' => '1B1EE554-F9EA-4BC8-821A-376B74E4C4B8',
- 'GETID3_ASF_Script_Command_Object' => '1EFB1A30-0B62-11D0-A39B-00A0C90348F6',
- 'GETID3_ASF_No_Error_Correction' => '20FB5700-5B55-11CF-A8FD-00805F5C442B',
- 'GETID3_ASF_Content_Branding_Object' => '2211B3FA-BD23-11D2-B4B7-00A0C955FC6E',
- 'GETID3_ASF_Content_Encryption_Object' => '2211B3FB-BD23-11D2-B4B7-00A0C955FC6E',
- 'GETID3_ASF_Digital_Signature_Object' => '2211B3FC-BD23-11D2-B4B7-00A0C955FC6E',
- 'GETID3_ASF_Extended_Content_Encryption_Object' => '298AE614-2622-4C17-B935-DAE07EE9289C',
- 'GETID3_ASF_Simple_Index_Object' => '33000890-E5B1-11CF-89F4-00A0C90349CB',
- 'GETID3_ASF_Degradable_JPEG_Media' => '35907DE0-E415-11CF-A917-00805F5C442B',
- 'GETID3_ASF_Payload_Extension_System_Timecode' => '399595EC-8667-4E2D-8FDB-98814CE76C1E',
- 'GETID3_ASF_Binary_Media' => '3AFB65E2-47EF-40F2-AC2C-70A90D71D343',
- 'GETID3_ASF_Timecode_Index_Object' => '3CB73FD0-0C4A-4803-953D-EDF7B6228F0C',
- 'GETID3_ASF_Metadata_Library_Object' => '44231C94-9498-49D1-A141-1D134E457054',
- 'GETID3_ASF_Reserved_3' => '4B1ACBE3-100B-11D0-A39B-00A0C90348F6',
- 'GETID3_ASF_Reserved_4' => '4CFEDB20-75F6-11CF-9C0F-00A0C90349CB',
- 'GETID3_ASF_Command_Media' => '59DACFC0-59E6-11D0-A3AC-00A0C90348F6',
- 'GETID3_ASF_Header_Extension_Object' => '5FBF03B5-A92E-11CF-8EE3-00C00C205365',
- 'GETID3_ASF_Media_Object_Index_Parameters_Obj' => '6B203BAD-3F11-4E84-ACA8-D7613DE2CFA7',
- 'GETID3_ASF_Header_Object' => '75B22630-668E-11CF-A6D9-00AA0062CE6C',
- 'GETID3_ASF_Content_Description_Object' => '75B22633-668E-11CF-A6D9-00AA0062CE6C',
- 'GETID3_ASF_Error_Correction_Object' => '75B22635-668E-11CF-A6D9-00AA0062CE6C',
- 'GETID3_ASF_Data_Object' => '75B22636-668E-11CF-A6D9-00AA0062CE6C',
- 'GETID3_ASF_Web_Stream_Media_Subtype' => '776257D4-C627-41CB-8F81-7AC7FF1C40CC',
- 'GETID3_ASF_Stream_Bitrate_Properties_Object' => '7BF875CE-468D-11D1-8D82-006097C9A2B2',
- 'GETID3_ASF_Language_List_Object' => '7C4346A9-EFE0-4BFC-B229-393EDE415C85',
- 'GETID3_ASF_Codec_List_Object' => '86D15240-311D-11D0-A3A4-00A0C90348F6',
- 'GETID3_ASF_Reserved_2' => '86D15241-311D-11D0-A3A4-00A0C90348F6',
- 'GETID3_ASF_File_Properties_Object' => '8CABDCA1-A947-11CF-8EE4-00C00C205365',
- 'GETID3_ASF_File_Transfer_Media' => '91BD222C-F21C-497A-8B6D-5AA86BFC0185',
- 'GETID3_ASF_Old_RTP_Extension_Data' => '96800C63-4C94-11D1-837B-0080C7A37F95',
- 'GETID3_ASF_Advanced_Mutual_Exclusion_Object' => 'A08649CF-4775-4670-8A16-6E35357566CD',
- 'GETID3_ASF_Bandwidth_Sharing_Object' => 'A69609E6-517B-11D2-B6AF-00C04FD908E9',
- 'GETID3_ASF_Reserved_1' => 'ABD3D211-A9BA-11cf-8EE6-00C00C205365',
- 'GETID3_ASF_Bandwidth_Sharing_Exclusive' => 'AF6060AA-5197-11D2-B6AF-00C04FD908E9',
- 'GETID3_ASF_Bandwidth_Sharing_Partial' => 'AF6060AB-5197-11D2-B6AF-00C04FD908E9',
- 'GETID3_ASF_JFIF_Media' => 'B61BE100-5B4E-11CF-A8FD-00805F5C442B',
- 'GETID3_ASF_Stream_Properties_Object' => 'B7DC0791-A9B7-11CF-8EE6-00C00C205365',
- 'GETID3_ASF_Video_Media' => 'BC19EFC0-5B4D-11CF-A8FD-00805F5C442B',
- 'GETID3_ASF_Audio_Spread' => 'BFC3CD50-618F-11CF-8BB2-00AA00B4E220',
- 'GETID3_ASF_Metadata_Object' => 'C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA',
- 'GETID3_ASF_Payload_Ext_Syst_Sample_Duration' => 'C6BD9450-867F-4907-83A3-C77921B733AD',
- 'GETID3_ASF_Group_Mutual_Exclusion_Object' => 'D1465A40-5A79-4338-B71B-E36B8FD6C249',
- 'GETID3_ASF_Extended_Content_Description_Object' => 'D2D0A440-E307-11D2-97F0-00A0C95EA850',
- 'GETID3_ASF_Stream_Prioritization_Object' => 'D4FED15B-88D3-454F-81F0-ED5C45999E24',
- 'GETID3_ASF_Payload_Ext_System_Content_Type' => 'D590DC20-07BC-436C-9CF7-F3BBFBF1A4DC',
- 'GETID3_ASF_Old_File_Properties_Object' => 'D6E229D0-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_ASF_Header_Object' => 'D6E229D1-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_ASF_Data_Object' => 'D6E229D2-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Index_Object' => 'D6E229D3-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Stream_Properties_Object' => 'D6E229D4-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Content_Description_Object' => 'D6E229D5-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Script_Command_Object' => 'D6E229D6-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Marker_Object' => 'D6E229D7-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Component_Download_Object' => 'D6E229D8-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Stream_Group_Object' => 'D6E229D9-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Scalable_Object' => 'D6E229DA-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Prioritization_Object' => 'D6E229DB-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Bitrate_Mutual_Exclusion_Object' => 'D6E229DC-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Inter_Media_Dependency_Object' => 'D6E229DD-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Rating_Object' => 'D6E229DE-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Index_Parameters_Object' => 'D6E229DF-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Color_Table_Object' => 'D6E229E0-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Language_List_Object' => 'D6E229E1-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Audio_Media' => 'D6E229E2-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Video_Media' => 'D6E229E3-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Image_Media' => 'D6E229E4-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Timecode_Media' => 'D6E229E5-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Text_Media' => 'D6E229E6-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_MIDI_Media' => 'D6E229E7-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Command_Media' => 'D6E229E8-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_No_Error_Concealment' => 'D6E229EA-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Scrambled_Audio' => 'D6E229EB-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_No_Color_Table' => 'D6E229EC-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_SMPTE_Time' => 'D6E229ED-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_ASCII_Text' => 'D6E229EE-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Unicode_Text' => 'D6E229EF-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_HTML_Text' => 'D6E229F0-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_URL_Command' => 'D6E229F1-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Filename_Command' => 'D6E229F2-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_ACM_Codec' => 'D6E229F3-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_VCM_Codec' => 'D6E229F4-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_QuickTime_Codec' => 'D6E229F5-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_DirectShow_Transform_Filter' => 'D6E229F6-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_DirectShow_Rendering_Filter' => 'D6E229F7-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_No_Enhancement' => 'D6E229F8-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Unknown_Enhancement_Type' => 'D6E229F9-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Temporal_Enhancement' => 'D6E229FA-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Spatial_Enhancement' => 'D6E229FB-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Quality_Enhancement' => 'D6E229FC-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Number_of_Channels_Enhancement' => 'D6E229FD-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Frequency_Response_Enhancement' => 'D6E229FE-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Media_Object' => 'D6E229FF-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Mutex_Language' => 'D6E22A00-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Mutex_Bitrate' => 'D6E22A01-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Mutex_Unknown' => 'D6E22A02-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_ASF_Placeholder_Object' => 'D6E22A0E-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Old_Data_Unit_Extension_Object' => 'D6E22A0F-35DA-11D1-9034-00A0C90349BE',
- 'GETID3_ASF_Web_Stream_Format' => 'DA1E6B13-8359-4050-B398-388E965BF00C',
- 'GETID3_ASF_Payload_Ext_System_File_Name' => 'E165EC0E-19ED-45D7-B4A7-25CBD1E28E9B',
- 'GETID3_ASF_Marker_Object' => 'F487CD01-A951-11CF-8EE6-00C00C205365',
- 'GETID3_ASF_Timecode_Index_Parameters_Object' => 'F55E496D-9797-4B5D-8C8B-604DFE9BFB24',
- 'GETID3_ASF_Audio_Media' => 'F8699E40-5B4D-11CF-A8FD-00805F5C442B',
- 'GETID3_ASF_Media_Object_Index_Object' => 'FEB103F8-12AD-4C64-840F-2A1D2F7AD48C',
- 'GETID3_ASF_Alt_Extended_Content_Encryption_Obj' => 'FF889EF1-ADEE-40DA-9E71-98704BB928CE',
- 'GETID3_ASF_Index_Placeholder_Object' => 'D9AADE20-7C17-4F9C-BC28-8555DD98E2A2', // http://cpan.uwinnipeg.ca/htdocs/Audio-WMA/Audio/WMA.pm.html
- 'GETID3_ASF_Compatibility_Object' => '26F18B5D-4584-47EC-9F5F-0E651F0452C9', // http://cpan.uwinnipeg.ca/htdocs/Audio-WMA/Audio/WMA.pm.html
- );
- return $GUIDarray;
- }
-
- static function GUIDname($GUIDstring) {
- static $GUIDarray = array();
- if (empty($GUIDarray)) {
- $GUIDarray = getid3_asf::KnownGUIDs();
- }
- return array_search($GUIDstring, $GUIDarray);
- }
-
- static function ASFIndexObjectIndexTypeLookup($id) {
- static $ASFIndexObjectIndexTypeLookup = array();
- if (empty($ASFIndexObjectIndexTypeLookup)) {
- $ASFIndexObjectIndexTypeLookup[1] = 'Nearest Past Data Packet';
- $ASFIndexObjectIndexTypeLookup[2] = 'Nearest Past Media Object';
- $ASFIndexObjectIndexTypeLookup[3] = 'Nearest Past Cleanpoint';
- }
- return (isset($ASFIndexObjectIndexTypeLookup[$id]) ? $ASFIndexObjectIndexTypeLookup[$id] : 'invalid');
- }
-
- static function GUIDtoBytestring($GUIDstring) {
- // Microsoft defines these 16-byte (128-bit) GUIDs in the strangest way:
- // first 4 bytes are in little-endian order
- // next 2 bytes are appended in little-endian order
- // next 2 bytes are appended in little-endian order
- // next 2 bytes are appended in big-endian order
- // next 6 bytes are appended in big-endian order
-
- // AaBbCcDd-EeFf-GgHh-IiJj-KkLlMmNnOoPp is stored as this 16-byte string:
- // $Dd $Cc $Bb $Aa $Ff $Ee $Hh $Gg $Ii $Jj $Kk $Ll $Mm $Nn $Oo $Pp
-
- $hexbytecharstring = chr(hexdec(substr($GUIDstring, 6, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 4, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 2, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 0, 2)));
-
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 11, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 9, 2)));
-
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 16, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 14, 2)));
-
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 19, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 21, 2)));
-
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 24, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 26, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 28, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 30, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 32, 2)));
- $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 34, 2)));
-
- return $hexbytecharstring;
- }
-
- static function BytestringToGUID($Bytestring) {
- $GUIDstring = str_pad(dechex(ord($Bytestring{3})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{2})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{1})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{0})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= '-';
- $GUIDstring .= str_pad(dechex(ord($Bytestring{5})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{4})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= '-';
- $GUIDstring .= str_pad(dechex(ord($Bytestring{7})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{6})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= '-';
- $GUIDstring .= str_pad(dechex(ord($Bytestring{8})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{9})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= '-';
- $GUIDstring .= str_pad(dechex(ord($Bytestring{10})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{11})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{12})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{13})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{14})), 2, '0', STR_PAD_LEFT);
- $GUIDstring .= str_pad(dechex(ord($Bytestring{15})), 2, '0', STR_PAD_LEFT);
-
- return strtoupper($GUIDstring);
- }
-
- static function FILETIMEtoUNIXtime($FILETIME, $round=true) {
- // FILETIME is a 64-bit unsigned integer representing
- // the number of 100-nanosecond intervals since January 1, 1601
- // UNIX timestamp is number of seconds since January 1, 1970
- // 116444736000000000 = 10000000 * 60 * 60 * 24 * 365 * 369 + 89 leap days
- if ($round) {
- return intval(round(($FILETIME - 116444736000000000) / 10000000));
- }
- return ($FILETIME - 116444736000000000) / 10000000;
- }
-
- static function WMpictureTypeLookup($WMpictureType) {
- static $WMpictureTypeLookup = array();
- if (empty($WMpictureTypeLookup)) {
- $WMpictureTypeLookup[0x03] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Front Cover');
- $WMpictureTypeLookup[0x04] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Back Cover');
- $WMpictureTypeLookup[0x00] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'User Defined');
- $WMpictureTypeLookup[0x05] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Leaflet Page');
- $WMpictureTypeLookup[0x06] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Media Label');
- $WMpictureTypeLookup[0x07] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Lead Artist');
- $WMpictureTypeLookup[0x08] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Artist');
- $WMpictureTypeLookup[0x09] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Conductor');
- $WMpictureTypeLookup[0x0A] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Band');
- $WMpictureTypeLookup[0x0B] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Composer');
- $WMpictureTypeLookup[0x0C] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Lyricist');
- $WMpictureTypeLookup[0x0D] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Recording Location');
- $WMpictureTypeLookup[0x0E] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'During Recording');
- $WMpictureTypeLookup[0x0F] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'During Performance');
- $WMpictureTypeLookup[0x10] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Video Screen Capture');
- $WMpictureTypeLookup[0x12] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Illustration');
- $WMpictureTypeLookup[0x13] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Band Logotype');
- $WMpictureTypeLookup[0x14] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Publisher Logotype');
- }
- return (isset($WMpictureTypeLookup[$WMpictureType]) ? $WMpictureTypeLookup[$WMpictureType] : '');
- }
-
- function ASF_HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) {
- // http://msdn.microsoft.com/en-us/library/bb643323.aspx
-
- $offset = 0;
- $objectOffset = 0;
- $HeaderExtensionObjectParsed = array();
- while ($objectOffset < strlen($asf_header_extension_object_data)) {
- $offset = $objectOffset;
- $thisObject = array();
-
- $thisObject['guid'] = substr($asf_header_extension_object_data, $offset, 16);
- $offset += 16;
- $thisObject['guid_text'] = $this->BytestringToGUID($thisObject['guid']);
- $thisObject['guid_name'] = $this->GUIDname($thisObject['guid_text']);
-
- $thisObject['size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 8));
- $offset += 8;
- if ($thisObject['size'] <= 0) {
- break;
- }
-
- switch ($thisObject['guid']) {
- case GETID3_ASF_Extended_Stream_Properties_Object:
- $thisObject['start_time'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 8));
- $offset += 8;
- $thisObject['start_time_unix'] = $this->FILETIMEtoUNIXtime($thisObject['start_time']);
-
- $thisObject['end_time'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 8));
- $offset += 8;
- $thisObject['end_time_unix'] = $this->FILETIMEtoUNIXtime($thisObject['end_time']);
-
- $thisObject['data_bitrate'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $thisObject['buffer_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $thisObject['initial_buffer_fullness'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $thisObject['alternate_data_bitrate'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $thisObject['alternate_buffer_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $thisObject['alternate_initial_buffer_fullness'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $thisObject['maximum_object_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $thisObject['flags_raw'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
- $thisObject['flags']['reliable'] = (bool) $thisObject['flags_raw'] & 0x00000001;
- $thisObject['flags']['seekable'] = (bool) $thisObject['flags_raw'] & 0x00000002;
- $thisObject['flags']['no_cleanpoints'] = (bool) $thisObject['flags_raw'] & 0x00000004;
- $thisObject['flags']['resend_live_cleanpoints'] = (bool) $thisObject['flags_raw'] & 0x00000008;
-
- $thisObject['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $thisObject['stream_language_id_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $thisObject['average_time_per_frame'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $thisObject['stream_name_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $thisObject['payload_extension_system_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- for ($i = 0; $i < $thisObject['stream_name_count']; $i++) {
- $streamName = array();
-
- $streamName['language_id_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $streamName['stream_name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $streamName['stream_name'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, $streamName['stream_name_length']));
- $offset += $streamName['stream_name_length'];
-
- $thisObject['stream_names'][$i] = $streamName;
- }
-
- for ($i = 0; $i < $thisObject['payload_extension_system_count']; $i++) {
- $payloadExtensionSystem = array();
-
- $payloadExtensionSystem['extension_system_id'] = substr($asf_header_extension_object_data, $offset, 16);
- $offset += 16;
- $payloadExtensionSystem['extension_system_id_text'] = $this->BytestringToGUID($payloadExtensionSystem['extension_system_id']);
-
- $payloadExtensionSystem['extension_system_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
- if ($payloadExtensionSystem['extension_system_size'] <= 0) {
- break 2;
- }
-
- $payloadExtensionSystem['extension_system_info_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $payloadExtensionSystem['extension_system_info_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, $payloadExtensionSystem['extension_system_info_length']));
- $offset += $payloadExtensionSystem['extension_system_info_length'];
-
- $thisObject['payload_extension_systems'][$i] = $payloadExtensionSystem;
- }
-
- break;
-
- case GETID3_ASF_Padding_Object:
- // padding, skip it
- break;
-
- case GETID3_ASF_Metadata_Object:
- $thisObject['description_record_counts'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- for ($i = 0; $i < $thisObject['description_record_counts']; $i++) {
- $descriptionRecord = array();
-
- $descriptionRecord['reserved_1'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); // must be zero
- $offset += 2;
-
- $descriptionRecord['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
- $descriptionRecord['data_type_text'] = $this->ASFmetadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']);
-
- $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']);
- $offset += $descriptionRecord['name_length'];
-
- $descriptionRecord['data'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['data_length']);
- $offset += $descriptionRecord['data_length'];
- switch ($descriptionRecord['data_type']) {
- case 0x0000: // Unicode string
- break;
-
- case 0x0001: // BYTE array
- // do nothing
- break;
-
- case 0x0002: // BOOL
- $descriptionRecord['data'] = (bool) getid3_lib::LittleEndian2Int($descriptionRecord['data']);
- break;
-
- case 0x0003: // DWORD
- case 0x0004: // QWORD
- case 0x0005: // WORD
- $descriptionRecord['data'] = getid3_lib::LittleEndian2Int($descriptionRecord['data']);
- break;
-
- case 0x0006: // GUID
- $descriptionRecord['data_text'] = $this->BytestringToGUID($descriptionRecord['data']);
- break;
- }
-
- $thisObject['description_record'][$i] = $descriptionRecord;
- }
- break;
-
- case GETID3_ASF_Language_List_Object:
- $thisObject['language_id_record_counts'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- for ($i = 0; $i < $thisObject['language_id_record_counts']; $i++) {
- $languageIDrecord = array();
-
- $languageIDrecord['language_id_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 1));
- $offset += 1;
-
- $languageIDrecord['language_id'] = substr($asf_header_extension_object_data, $offset, $languageIDrecord['language_id_length']);
- $offset += $languageIDrecord['language_id_length'];
-
- $thisObject['language_id_record'][$i] = $languageIDrecord;
- }
- break;
-
- case GETID3_ASF_Metadata_Library_Object:
- $thisObject['description_records_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- for ($i = 0; $i < $thisObject['description_records_count']; $i++) {
- $descriptionRecord = array();
-
- $descriptionRecord['language_list_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $descriptionRecord['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
-
- $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
- $offset += 2;
- $descriptionRecord['data_type_text'] = $this->ASFmetadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']);
-
- $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
- $offset += 4;
-
- $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']);
- $offset += $descriptionRecord['name_length'];
-
- $descriptionRecord['data'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['data_length']);
- $offset += $descriptionRecord['data_length'];
-
- if (preg_match('#^WM/Picture$#', str_replace("\x00", '', trim($descriptionRecord['name'])))) {
- $WMpicture = $this->ASF_WMpicture($descriptionRecord['data']);
- foreach ($WMpicture as $key => $value) {
- $descriptionRecord['data'] = $WMpicture;
- }
- unset($WMpicture);
- }
-
- $thisObject['description_record'][$i] = $descriptionRecord;
- }
- break;
-
- default:
- $unhandled_sections++;
- if ($this->GUIDname($thisObject['guid_text'])) {
- $this->getid3->info['warning'][] = 'unhandled Header Extension Object GUID "'.$this->GUIDname($thisObject['guid_text']).'" {'.$thisObject['guid_text'].'} at offset '.($offset - 16 - 8);
- } else {
- $this->getid3->info['warning'][] = 'unknown Header Extension Object GUID {'.$thisObject['guid_text'].'} in at offset '.($offset - 16 - 8);
- }
- break;
- }
- $HeaderExtensionObjectParsed[] = $thisObject;
-
- $objectOffset += $thisObject['size'];
- }
- return $HeaderExtensionObjectParsed;
- }
-
-
- static function ASFmetadataLibraryObjectDataTypeLookup($id) {
- static $ASFmetadataLibraryObjectDataTypeLookup = array(
- 0x0000 => 'Unicode string', // The data consists of a sequence of Unicode characters
- 0x0001 => 'BYTE array', // The type of the data is implementation-specific
- 0x0002 => 'BOOL', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer. Only 0x0000 or 0x0001 are permitted values
- 0x0003 => 'DWORD', // The data is 4 bytes long and should be interpreted as a 32-bit unsigned integer
- 0x0004 => 'QWORD', // The data is 8 bytes long and should be interpreted as a 64-bit unsigned integer
- 0x0005 => 'WORD', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer
- 0x0006 => 'GUID', // The data is 16 bytes long and should be interpreted as a 128-bit GUID
- );
- return (isset($ASFmetadataLibraryObjectDataTypeLookup[$id]) ? $ASFmetadataLibraryObjectDataTypeLookup[$id] : 'invalid');
- }
-
- function ASF_WMpicture(&$data) {
- //typedef struct _WMPicture{
- // LPWSTR pwszMIMEType;
- // BYTE bPictureType;
- // LPWSTR pwszDescription;
- // DWORD dwDataLen;
- // BYTE* pbData;
- //} WM_PICTURE;
-
- $WMpicture = array();
-
- $offset = 0;
- $WMpicture['image_type_id'] = getid3_lib::LittleEndian2Int(substr($data, $offset, 1));
- $offset += 1;
- $WMpicture['image_type'] = $this->WMpictureTypeLookup($WMpicture['image_type_id']);
- $WMpicture['image_size'] = getid3_lib::LittleEndian2Int(substr($data, $offset, 4));
- $offset += 4;
-
- $WMpicture['image_mime'] = '';
- do {
- $next_byte_pair = substr($data, $offset, 2);
- $offset += 2;
- $WMpicture['image_mime'] .= $next_byte_pair;
- } while ($next_byte_pair !== "\x00\x00");
-
- $WMpicture['image_description'] = '';
- do {
- $next_byte_pair = substr($data, $offset, 2);
- $offset += 2;
- $WMpicture['image_description'] .= $next_byte_pair;
- } while ($next_byte_pair !== "\x00\x00");
-
- $WMpicture['dataoffset'] = $offset;
- $WMpicture['data'] = substr($data, $offset);
-
- $imageinfo = array();
- $WMpicture['image_mime'] = '';
- $imagechunkcheck = getid3_lib::GetDataImageSize($WMpicture['data'], $imageinfo);
- unset($imageinfo);
- if (!empty($imagechunkcheck)) {
- $WMpicture['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
- }
- if (!isset($this->getid3->info['asf']['comments']['picture'])) {
- $this->getid3->info['asf']['comments']['picture'] = array();
- }
- $this->getid3->info['asf']['comments']['picture'][] = array('data'=>$WMpicture['data'], 'image_mime'=>$WMpicture['image_mime']);
-
- return $WMpicture;
- }
-
-
- // Remove terminator 00 00 and convert UTF-16LE to Latin-1
- static function TrimConvert($string) {
- return trim(getid3_lib::iconv_fallback('UTF-16LE', 'ISO-8859-1', getid3_asf::TrimTerm($string)), ' ');
- }
-
-
- // Remove terminator 00 00
- static function TrimTerm($string) {
- // remove terminator, only if present (it should be, but...)
- if (substr($string, -2) === "\x00\x00") {
- $string = substr($string, 0, -2);
- }
- return $string;
- }
-
-}
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.audio-video.bink.php b/app/library/getid3/module.audio-video.bink.php
deleted file mode 100644
index 0a321396..00000000
--- a/app/library/getid3/module.audio-video.bink.php
+++ /dev/null
@@ -1,73 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.bink.php //
-// module for analyzing Bink or Smacker audio-video files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_bink extends getid3_handler
-{
-
- function Analyze() {
- $info = &$this->getid3->info;
-
-$info['error'][] = 'Bink / Smacker files not properly processed by this version of getID3() ['.$this->getid3->version().']';
-
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
- $fileTypeID = fread($this->getid3->fp, 3);
- switch ($fileTypeID) {
- case 'BIK':
- return $this->ParseBink();
- break;
-
- case 'SMK':
- return $this->ParseSmacker();
- break;
-
- default:
- $info['error'][] = 'Expecting "BIK" or "SMK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($fileTypeID).'"';
- return false;
- break;
- }
-
- return true;
-
- }
-
- function ParseBink() {
- $info = &$this->getid3->info;
- $info['fileformat'] = 'bink';
- $info['video']['dataformat'] = 'bink';
-
- $fileData = 'BIK'.fread($this->getid3->fp, 13);
-
- $info['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
- $info['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
-
- if (($info['avdataend'] - $info['avdataoffset']) != ($info['bink']['data_size'] + 8)) {
- $info['error'][] = 'Probably truncated file: expecting '.$info['bink']['data_size'].' bytes, found '.($info['avdataend'] - $info['avdataoffset']);
- }
-
- return true;
- }
-
- function ParseSmacker() {
- $info = &$this->getid3->info;
- $info['fileformat'] = 'smacker';
- $info['video']['dataformat'] = 'smacker';
-
- return true;
- }
-
-}
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.audio-video.flv.php b/app/library/getid3/module.audio-video.flv.php
deleted file mode 100644
index ba3cd908..00000000
--- a/app/library/getid3/module.audio-video.flv.php
+++ /dev/null
@@ -1,731 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-// //
-// FLV module by Seth Kaufman //
-// //
-// * version 0.1 (26 June 2005) //
-// //
-// //
-// * version 0.1.1 (15 July 2005) //
-// minor modifications by James Heinrich //
-// //
-// * version 0.2 (22 February 2006) //
-// Support for On2 VP6 codec and meta information //
-// by Steve Webster //
-// //
-// * version 0.3 (15 June 2006) //
-// Modified to not read entire file into memory //
-// by James Heinrich //
-// //
-// * version 0.4 (07 December 2007) //
-// Bugfixes for incorrectly parsed FLV dimensions //
-// and incorrect parsing of onMetaTag //
-// by Evgeny Moysevich //
-// //
-// * version 0.5 (21 May 2009) //
-// Fixed parsing of audio tags and added additional codec //
-// details. The duration is now read from onMetaTag (if //
-// exists), rather than parsing whole file //
-// by Nigel Barnes //
-// //
-// * version 0.6 (24 May 2009) //
-// Better parsing of files with h264 video //
-// by Evgeny Moysevich //
-// //
-// * version 0.6.1 (30 May 2011) //
-// prevent infinite loops in expGolombUe() //
-// //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio-video.flv.php //
-// module for analyzing Shockwave Flash Video files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-define('GETID3_FLV_TAG_AUDIO', 8);
-define('GETID3_FLV_TAG_VIDEO', 9);
-define('GETID3_FLV_TAG_META', 18);
-
-define('GETID3_FLV_VIDEO_H263', 2);
-define('GETID3_FLV_VIDEO_SCREEN', 3);
-define('GETID3_FLV_VIDEO_VP6FLV', 4);
-define('GETID3_FLV_VIDEO_VP6FLV_ALPHA', 5);
-define('GETID3_FLV_VIDEO_SCREENV2', 6);
-define('GETID3_FLV_VIDEO_H264', 7);
-
-define('H264_AVC_SEQUENCE_HEADER', 0);
-define('H264_PROFILE_BASELINE', 66);
-define('H264_PROFILE_MAIN', 77);
-define('H264_PROFILE_EXTENDED', 88);
-define('H264_PROFILE_HIGH', 100);
-define('H264_PROFILE_HIGH10', 110);
-define('H264_PROFILE_HIGH422', 122);
-define('H264_PROFILE_HIGH444', 144);
-define('H264_PROFILE_HIGH444_PREDICTIVE', 244);
-
-class getid3_flv extends getid3_handler
-{
- var $max_frames = 100000; // break out of the loop if too many frames have been scanned; only scan this many if meta frame does not contain useful duration
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
-
- $FLVdataLength = $info['avdataend'] - $info['avdataoffset'];
- $FLVheader = fread($this->getid3->fp, 5);
-
- $info['fileformat'] = 'flv';
- $info['flv']['header']['signature'] = substr($FLVheader, 0, 3);
- $info['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
- $TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));
-
- $magic = 'FLV';
- if ($info['flv']['header']['signature'] != $magic) {
- $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"';
- unset($info['flv']);
- unset($info['fileformat']);
- return false;
- }
-
- $info['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
- $info['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);
-
- $FrameSizeDataLength = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4));
- $FLVheaderFrameLength = 9;
- if ($FrameSizeDataLength > $FLVheaderFrameLength) {
- fseek($this->getid3->fp, $FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
- }
- $Duration = 0;
- $found_video = false;
- $found_audio = false;
- $found_meta = false;
- $found_valid_meta_playtime = false;
- $tagParseCount = 0;
- $info['flv']['framecount'] = array('total'=>0, 'audio'=>0, 'video'=>0);
- $flv_framecount = &$info['flv']['framecount'];
- while (((ftell($this->getid3->fp) + 16) < $info['avdataend']) && (($tagParseCount++ <= $this->max_frames) || !$found_valid_meta_playtime)) {
- $ThisTagHeader = fread($this->getid3->fp, 16);
-
- $PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4));
- $TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1));
- $DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3));
- $Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3));
- $LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1));
- $NextOffset = ftell($this->getid3->fp) - 1 + $DataLength;
- if ($Timestamp > $Duration) {
- $Duration = $Timestamp;
- }
-
- $flv_framecount['total']++;
- switch ($TagType) {
- case GETID3_FLV_TAG_AUDIO:
- $flv_framecount['audio']++;
- if (!$found_audio) {
- $found_audio = true;
- $info['flv']['audio']['audioFormat'] = ($LastHeaderByte >> 4) & 0x0F;
- $info['flv']['audio']['audioRate'] = ($LastHeaderByte >> 2) & 0x03;
- $info['flv']['audio']['audioSampleSize'] = ($LastHeaderByte >> 1) & 0x01;
- $info['flv']['audio']['audioType'] = $LastHeaderByte & 0x01;
- }
- break;
-
- case GETID3_FLV_TAG_VIDEO:
- $flv_framecount['video']++;
- if (!$found_video) {
- $found_video = true;
- $info['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07;
-
- $FLVvideoHeader = fread($this->getid3->fp, 11);
-
- if ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H264) {
- // this code block contributed by: moysevichgmail*com
-
- $AVCPacketType = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 0, 1));
- if ($AVCPacketType == H264_AVC_SEQUENCE_HEADER) {
- // read AVCDecoderConfigurationRecord
- $configurationVersion = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 1));
- $AVCProfileIndication = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 1));
- $profile_compatibility = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 1));
- $lengthSizeMinusOne = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 1));
- $numOfSequenceParameterSets = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 8, 1));
-
- if (($numOfSequenceParameterSets & 0x1F) != 0) {
- // there is at least one SequenceParameterSet
- // read size of the first SequenceParameterSet
- //$spsSize = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 9, 2));
- $spsSize = getid3_lib::LittleEndian2Int(substr($FLVvideoHeader, 9, 2));
- // read the first SequenceParameterSet
- $sps = fread($this->getid3->fp, $spsSize);
- if (strlen($sps) == $spsSize) { // make sure that whole SequenceParameterSet was red
- $spsReader = new AVCSequenceParameterSetReader($sps);
- $spsReader->readData();
- $info['video']['resolution_x'] = $spsReader->getWidth();
- $info['video']['resolution_y'] = $spsReader->getHeight();
- }
- }
- }
- // end: moysevichgmail*com
-
- } elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H263) {
-
- $PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2))) >> 7;
- $PictureSizeType = $PictureSizeType & 0x0007;
- $info['flv']['header']['videoSizeType'] = $PictureSizeType;
- switch ($PictureSizeType) {
- case 0:
- //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
- //$PictureSizeEnc <<= 1;
- //$info['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8;
- //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
- //$PictureSizeEnc <<= 1;
- //$info['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8;
-
- $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 2));
- $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
- $PictureSizeEnc['x'] >>= 7;
- $PictureSizeEnc['y'] >>= 7;
- $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFF;
- $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFF;
- break;
-
- case 1:
- $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 3));
- $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 3));
- $PictureSizeEnc['x'] >>= 7;
- $PictureSizeEnc['y'] >>= 7;
- $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFFFF;
- $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFFFF;
- break;
-
- case 2:
- $info['video']['resolution_x'] = 352;
- $info['video']['resolution_y'] = 288;
- break;
-
- case 3:
- $info['video']['resolution_x'] = 176;
- $info['video']['resolution_y'] = 144;
- break;
-
- case 4:
- $info['video']['resolution_x'] = 128;
- $info['video']['resolution_y'] = 96;
- break;
-
- case 5:
- $info['video']['resolution_x'] = 320;
- $info['video']['resolution_y'] = 240;
- break;
-
- case 6:
- $info['video']['resolution_x'] = 160;
- $info['video']['resolution_y'] = 120;
- break;
-
- default:
- $info['video']['resolution_x'] = 0;
- $info['video']['resolution_y'] = 0;
- break;
-
- }
- }
- $info['video']['pixel_aspect_ratio'] = $info['video']['resolution_x'] / $info['video']['resolution_y'];
- }
- break;
-
- // Meta tag
- case GETID3_FLV_TAG_META:
- if (!$found_meta) {
- $found_meta = true;
- fseek($this->getid3->fp, -1, SEEK_CUR);
- $datachunk = fread($this->getid3->fp, $DataLength);
- $AMFstream = new AMFStream($datachunk);
- $reader = new AMFReader($AMFstream);
- $eventName = $reader->readData();
- $info['flv']['meta'][$eventName] = $reader->readData();
- unset($reader);
-
- $copykeys = array('framerate'=>'frame_rate', 'width'=>'resolution_x', 'height'=>'resolution_y', 'audiodatarate'=>'bitrate', 'videodatarate'=>'bitrate');
- foreach ($copykeys as $sourcekey => $destkey) {
- if (isset($info['flv']['meta']['onMetaData'][$sourcekey])) {
- switch ($sourcekey) {
- case 'width':
- case 'height':
- $info['video'][$destkey] = intval(round($info['flv']['meta']['onMetaData'][$sourcekey]));
- break;
- case 'audiodatarate':
- $info['audio'][$destkey] = getid3_lib::CastAsInt(round($info['flv']['meta']['onMetaData'][$sourcekey] * 1000));
- break;
- case 'videodatarate':
- case 'frame_rate':
- default:
- $info['video'][$destkey] = $info['flv']['meta']['onMetaData'][$sourcekey];
- break;
- }
- }
- }
- if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
- $found_valid_meta_playtime = true;
- }
- }
- break;
-
- default:
- // noop
- break;
- }
- fseek($this->getid3->fp, $NextOffset, SEEK_SET);
- }
-
- $info['playtime_seconds'] = $Duration / 1000;
- if ($info['playtime_seconds'] > 0) {
- $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
- }
-
- if ($info['flv']['header']['hasAudio']) {
- $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['audio']['audioFormat']);
- $info['audio']['sample_rate'] = $this->FLVaudioRate($info['flv']['audio']['audioRate']);
- $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info['flv']['audio']['audioSampleSize']);
-
- $info['audio']['channels'] = $info['flv']['audio']['audioType'] + 1; // 0=mono,1=stereo
- $info['audio']['lossless'] = ($info['flv']['audio']['audioFormat'] ? false : true); // 0=uncompressed
- $info['audio']['dataformat'] = 'flv';
- }
- if (!empty($info['flv']['header']['hasVideo'])) {
- $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['video']['videoCodec']);
- $info['video']['dataformat'] = 'flv';
- $info['video']['lossless'] = false;
- }
-
- // Set information from meta
- if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
- $info['playtime_seconds'] = $info['flv']['meta']['onMetaData']['duration'];
- $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
- }
- if (isset($info['flv']['meta']['onMetaData']['audiocodecid'])) {
- $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['meta']['onMetaData']['audiocodecid']);
- }
- if (isset($info['flv']['meta']['onMetaData']['videocodecid'])) {
- $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['meta']['onMetaData']['videocodecid']);
- }
- return true;
- }
-
-
- function FLVaudioFormat($id) {
- $FLVaudioFormat = array(
- 0 => 'Linear PCM, platform endian',
- 1 => 'ADPCM',
- 2 => 'mp3',
- 3 => 'Linear PCM, little endian',
- 4 => 'Nellymoser 16kHz mono',
- 5 => 'Nellymoser 8kHz mono',
- 6 => 'Nellymoser',
- 7 => 'G.711A-law logarithmic PCM',
- 8 => 'G.711 mu-law logarithmic PCM',
- 9 => 'reserved',
- 10 => 'AAC',
- 11 => false, // unknown?
- 12 => false, // unknown?
- 13 => false, // unknown?
- 14 => 'mp3 8kHz',
- 15 => 'Device-specific sound',
- );
- return (isset($FLVaudioFormat[$id]) ? $FLVaudioFormat[$id] : false);
- }
-
- function FLVaudioRate($id) {
- $FLVaudioRate = array(
- 0 => 5500,
- 1 => 11025,
- 2 => 22050,
- 3 => 44100,
- );
- return (isset($FLVaudioRate[$id]) ? $FLVaudioRate[$id] : false);
- }
-
- function FLVaudioBitDepth($id) {
- $FLVaudioBitDepth = array(
- 0 => 8,
- 1 => 16,
- );
- return (isset($FLVaudioBitDepth[$id]) ? $FLVaudioBitDepth[$id] : false);
- }
-
- function FLVvideoCodec($id) {
- $FLVvideoCodec = array(
- GETID3_FLV_VIDEO_H263 => 'Sorenson H.263',
- GETID3_FLV_VIDEO_SCREEN => 'Screen video',
- GETID3_FLV_VIDEO_VP6FLV => 'On2 VP6',
- GETID3_FLV_VIDEO_VP6FLV_ALPHA => 'On2 VP6 with alpha channel',
- GETID3_FLV_VIDEO_SCREENV2 => 'Screen video v2',
- GETID3_FLV_VIDEO_H264 => 'Sorenson H.264',
- );
- return (isset($FLVvideoCodec[$id]) ? $FLVvideoCodec[$id] : false);
- }
-}
-
-class AMFStream {
- var $bytes;
- var $pos;
-
- function AMFStream(&$bytes) {
- $this->bytes =& $bytes;
- $this->pos = 0;
- }
-
- function readByte() {
- return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
- }
-
- function readInt() {
- return ($this->readByte() << 8) + $this->readByte();
- }
-
- function readLong() {
- return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
- }
-
- function readDouble() {
- return getid3_lib::BigEndian2Float($this->read(8));
- }
-
- function readUTF() {
- $length = $this->readInt();
- return $this->read($length);
- }
-
- function readLongUTF() {
- $length = $this->readLong();
- return $this->read($length);
- }
-
- function read($length) {
- $val = substr($this->bytes, $this->pos, $length);
- $this->pos += $length;
- return $val;
- }
-
- function peekByte() {
- $pos = $this->pos;
- $val = $this->readByte();
- $this->pos = $pos;
- return $val;
- }
-
- function peekInt() {
- $pos = $this->pos;
- $val = $this->readInt();
- $this->pos = $pos;
- return $val;
- }
-
- function peekLong() {
- $pos = $this->pos;
- $val = $this->readLong();
- $this->pos = $pos;
- return $val;
- }
-
- function peekDouble() {
- $pos = $this->pos;
- $val = $this->readDouble();
- $this->pos = $pos;
- return $val;
- }
-
- function peekUTF() {
- $pos = $this->pos;
- $val = $this->readUTF();
- $this->pos = $pos;
- return $val;
- }
-
- function peekLongUTF() {
- $pos = $this->pos;
- $val = $this->readLongUTF();
- $this->pos = $pos;
- return $val;
- }
-}
-
-class AMFReader {
- var $stream;
-
- function AMFReader(&$stream) {
- $this->stream =& $stream;
- }
-
- function readData() {
- $value = null;
-
- $type = $this->stream->readByte();
- switch ($type) {
-
- // Double
- case 0:
- $value = $this->readDouble();
- break;
-
- // Boolean
- case 1:
- $value = $this->readBoolean();
- break;
-
- // String
- case 2:
- $value = $this->readString();
- break;
-
- // Object
- case 3:
- $value = $this->readObject();
- break;
-
- // null
- case 6:
- return null;
- break;
-
- // Mixed array
- case 8:
- $value = $this->readMixedArray();
- break;
-
- // Array
- case 10:
- $value = $this->readArray();
- break;
-
- // Date
- case 11:
- $value = $this->readDate();
- break;
-
- // Long string
- case 13:
- $value = $this->readLongString();
- break;
-
- // XML (handled as string)
- case 15:
- $value = $this->readXML();
- break;
-
- // Typed object (handled as object)
- case 16:
- $value = $this->readTypedObject();
- break;
-
- // Long string
- default:
- $value = '(unknown or unsupported data type)';
- break;
- }
-
- return $value;
- }
-
- function readDouble() {
- return $this->stream->readDouble();
- }
-
- function readBoolean() {
- return $this->stream->readByte() == 1;
- }
-
- function readString() {
- return $this->stream->readUTF();
- }
-
- function readObject() {
- // Get highest numerical index - ignored
-// $highestIndex = $this->stream->readLong();
-
- $data = array();
-
- while ($key = $this->stream->readUTF()) {
- $data[$key] = $this->readData();
- }
- // Mixed array record ends with empty string (0x00 0x00) and 0x09
- if (($key == '') && ($this->stream->peekByte() == 0x09)) {
- // Consume byte
- $this->stream->readByte();
- }
- return $data;
- }
-
- function readMixedArray() {
- // Get highest numerical index - ignored
- $highestIndex = $this->stream->readLong();
-
- $data = array();
-
- while ($key = $this->stream->readUTF()) {
- if (is_numeric($key)) {
- $key = (float) $key;
- }
- $data[$key] = $this->readData();
- }
- // Mixed array record ends with empty string (0x00 0x00) and 0x09
- if (($key == '') && ($this->stream->peekByte() == 0x09)) {
- // Consume byte
- $this->stream->readByte();
- }
-
- return $data;
- }
-
- function readArray() {
- $length = $this->stream->readLong();
- $data = array();
-
- for ($i = 0; $i < $length; $i++) {
- $data[] = $this->readData();
- }
- return $data;
- }
-
- function readDate() {
- $timestamp = $this->stream->readDouble();
- $timezone = $this->stream->readInt();
- return $timestamp;
- }
-
- function readLongString() {
- return $this->stream->readLongUTF();
- }
-
- function readXML() {
- return $this->stream->readLongUTF();
- }
-
- function readTypedObject() {
- $className = $this->stream->readUTF();
- return $this->readObject();
- }
-}
-
-class AVCSequenceParameterSetReader {
- var $sps;
- var $start = 0;
- var $currentBytes = 0;
- var $currentBits = 0;
- var $width;
- var $height;
-
- function AVCSequenceParameterSetReader($sps) {
- $this->sps = $sps;
- }
-
- function readData() {
- $this->skipBits(8);
- $this->skipBits(8);
- $profile = $this->getBits(8); // read profile
- $this->skipBits(16);
- $this->expGolombUe(); // read sps id
- if (in_array($profile, array(H264_PROFILE_HIGH, H264_PROFILE_HIGH10, H264_PROFILE_HIGH422, H264_PROFILE_HIGH444, H264_PROFILE_HIGH444_PREDICTIVE))) {
- if ($this->expGolombUe() == 3) {
- $this->skipBits(1);
- }
- $this->expGolombUe();
- $this->expGolombUe();
- $this->skipBits(1);
- if ($this->getBit()) {
- for ($i = 0; $i < 8; $i++) {
- if ($this->getBit()) {
- $size = $i < 6 ? 16 : 64;
- $lastScale = 8;
- $nextScale = 8;
- for ($j = 0; $j < $size; $j++) {
- if ($nextScale != 0) {
- $deltaScale = $this->expGolombUe();
- $nextScale = ($lastScale + $deltaScale + 256) % 256;
- }
- if ($nextScale != 0) {
- $lastScale = $nextScale;
- }
- }
- }
- }
- }
- }
- $this->expGolombUe();
- $pocType = $this->expGolombUe();
- if ($pocType == 0) {
- $this->expGolombUe();
- } elseif ($pocType == 1) {
- $this->skipBits(1);
- $this->expGolombSe();
- $this->expGolombSe();
- $pocCycleLength = $this->expGolombUe();
- for ($i = 0; $i < $pocCycleLength; $i++) {
- $this->expGolombSe();
- }
- }
- $this->expGolombUe();
- $this->skipBits(1);
- $this->width = ($this->expGolombUe() + 1) * 16;
- $heightMap = $this->expGolombUe() + 1;
- $this->height = (2 - $this->getBit()) * $heightMap * 16;
- }
-
- function skipBits($bits) {
- $newBits = $this->currentBits + $bits;
- $this->currentBytes += (int)floor($newBits / 8);
- $this->currentBits = $newBits % 8;
- }
-
- function getBit() {
- $result = (getid3_lib::BigEndian2Int(substr($this->sps, $this->currentBytes, 1)) >> (7 - $this->currentBits)) & 0x01;
- $this->skipBits(1);
- return $result;
- }
-
- function getBits($bits) {
- $result = 0;
- for ($i = 0; $i < $bits; $i++) {
- $result = ($result << 1) + $this->getBit();
- }
- return $result;
- }
-
- function expGolombUe() {
- $significantBits = 0;
- $bit = $this->getBit();
- while ($bit == 0) {
- $significantBits++;
- $bit = $this->getBit();
-
- if ($significantBits > 31) {
- // something is broken, this is an emergency escape to prevent infinite loops
- return 0;
- }
- }
- return (1 << $significantBits) + $this->getBits($significantBits) - 1;
- }
-
- function expGolombSe() {
- $result = $this->expGolombUe();
- if (($result & 0x01) == 0) {
- return -($result >> 1);
- } else {
- return ($result + 1) >> 1;
- }
- }
-
- function getWidth() {
- return $this->width;
- }
-
- function getHeight() {
- return $this->height;
- }
-}
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.audio-video.matroska.php b/app/library/getid3/module.audio-video.matroska.php
deleted file mode 100644
index b7ab6679..00000000
--- a/app/library/getid3/module.audio-video.matroska.php
+++ /dev/null
@@ -1,1706 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio-video.matriska.php //
-// module for analyzing Matroska containers //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-// from: http://www.matroska.org/technical/specs/index.html
-define('EBML_ID_CHAPTERS', 0x0043A770); // [10][43][A7][70] -- A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation.
-define('EBML_ID_SEEKHEAD', 0x014D9B74); // [11][4D][9B][74] -- Contains the position of other level 1 elements.
-define('EBML_ID_TAGS', 0x0254C367); // [12][54][C3][67] -- Element containing elements specific to Tracks/Chapters. A list of valid tags can be found .
-define('EBML_ID_INFO', 0x0549A966); // [15][49][A9][66] -- Contains miscellaneous general information and statistics on the file.
-define('EBML_ID_TRACKS', 0x0654AE6B); // [16][54][AE][6B] -- A top-level block of information with many tracks described.
-define('EBML_ID_SEGMENT', 0x08538067); // [18][53][80][67] -- This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment.
-define('EBML_ID_ATTACHMENTS', 0x0941A469); // [19][41][A4][69] -- Contain attached files.
-define('EBML_ID_EBML', 0x0A45DFA3); // [1A][45][DF][A3] -- Set the EBML characteristics of the data to follow. Each EBML document has to start with this.
-define('EBML_ID_CUES', 0x0C53BB6B); // [1C][53][BB][6B] -- A top-level element to speed seeking access. All entries are local to the segment.
-define('EBML_ID_CLUSTER', 0x0F43B675); // [1F][43][B6][75] -- The lower level element containing the (monolithic) Block structure.
-define('EBML_ID_LANGUAGE', 0x02B59C); // [22][B5][9C] -- Specifies the language of the track in the Matroska languages form.
-define('EBML_ID_TRACKTIMECODESCALE', 0x03314F); // [23][31][4F] -- The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs).
-define('EBML_ID_DEFAULTDURATION', 0x03E383); // [23][E3][83] -- Number of nanoseconds (i.e. not scaled) per frame.
-define('EBML_ID_CODECNAME', 0x058688); // [25][86][88] -- A human-readable string specifying the codec.
-define('EBML_ID_CODECDOWNLOADURL', 0x06B240); // [26][B2][40] -- A URL to download about the codec used.
-define('EBML_ID_TIMECODESCALE', 0x0AD7B1); // [2A][D7][B1] -- Timecode scale in nanoseconds (1.000.000 means all timecodes in the segment are expressed in milliseconds).
-define('EBML_ID_COLOURSPACE', 0x0EB524); // [2E][B5][24] -- Same value as in AVI (32 bits).
-define('EBML_ID_GAMMAVALUE', 0x0FB523); // [2F][B5][23] -- Gamma Value.
-define('EBML_ID_CODECSETTINGS', 0x1A9697); // [3A][96][97] -- A string describing the encoding setting used.
-define('EBML_ID_CODECINFOURL', 0x1B4040); // [3B][40][40] -- A URL to find information about the codec used.
-define('EBML_ID_PREVFILENAME', 0x1C83AB); // [3C][83][AB] -- An escaped filename corresponding to the previous segment.
-define('EBML_ID_PREVUID', 0x1CB923); // [3C][B9][23] -- A unique ID to identify the previous chained segment (128 bits).
-define('EBML_ID_NEXTFILENAME', 0x1E83BB); // [3E][83][BB] -- An escaped filename corresponding to the next segment.
-define('EBML_ID_NEXTUID', 0x1EB923); // [3E][B9][23] -- A unique ID to identify the next chained segment (128 bits).
-define('EBML_ID_CONTENTCOMPALGO', 0x0254); // [42][54] -- The compression algorithm used. Algorithms that have been specified so far are:
-define('EBML_ID_CONTENTCOMPSETTINGS', 0x0255); // [42][55] -- Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track.
-define('EBML_ID_DOCTYPE', 0x0282); // [42][82] -- A string that describes the type of document that follows this EBML header ('matroska' in our case).
-define('EBML_ID_DOCTYPEREADVERSION', 0x0285); // [42][85] -- The minimum DocType version an interpreter has to support to read this file.
-define('EBML_ID_EBMLVERSION', 0x0286); // [42][86] -- The version of EBML parser used to create the file.
-define('EBML_ID_DOCTYPEVERSION', 0x0287); // [42][87] -- The version of DocType interpreter used to create the file.
-define('EBML_ID_EBMLMAXIDLENGTH', 0x02F2); // [42][F2] -- The maximum length of the IDs you'll find in this file (4 or less in Matroska).
-define('EBML_ID_EBMLMAXSIZELENGTH', 0x02F3); // [42][F3] -- The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid.
-define('EBML_ID_EBMLREADVERSION', 0x02F7); // [42][F7] -- The minimum EBML version a parser has to support to read this file.
-define('EBML_ID_CHAPLANGUAGE', 0x037C); // [43][7C] -- The languages corresponding to the string, in the bibliographic ISO-639-2 form.
-define('EBML_ID_CHAPCOUNTRY', 0x037E); // [43][7E] -- The countries corresponding to the string, same 2 octets as in Internet domains.
-define('EBML_ID_SEGMENTFAMILY', 0x0444); // [44][44] -- A randomly generated unique ID that all segments related to each other must use (128 bits).
-define('EBML_ID_DATEUTC', 0x0461); // [44][61] -- Date of the origin of timecode (value 0), i.e. production date.
-define('EBML_ID_TAGLANGUAGE', 0x047A); // [44][7A] -- Specifies the language of the tag specified, in the Matroska languages form.
-define('EBML_ID_TAGDEFAULT', 0x0484); // [44][84] -- Indication to know if this is the default/original language to use for the given tag.
-define('EBML_ID_TAGBINARY', 0x0485); // [44][85] -- The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString.
-define('EBML_ID_TAGSTRING', 0x0487); // [44][87] -- The value of the Tag.
-define('EBML_ID_DURATION', 0x0489); // [44][89] -- Duration of the segment (based on TimecodeScale).
-define('EBML_ID_CHAPPROCESSPRIVATE', 0x050D); // [45][0D] -- Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the "DVD level" equivalent.
-define('EBML_ID_CHAPTERFLAGENABLED', 0x0598); // [45][98] -- Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter.
-define('EBML_ID_TAGNAME', 0x05A3); // [45][A3] -- The name of the Tag that is going to be stored.
-define('EBML_ID_EDITIONENTRY', 0x05B9); // [45][B9] -- Contains all information about a segment edition.
-define('EBML_ID_EDITIONUID', 0x05BC); // [45][BC] -- A unique ID to identify the edition. It's useful for tagging an edition.
-define('EBML_ID_EDITIONFLAGHIDDEN', 0x05BD); // [45][BD] -- If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks).
-define('EBML_ID_EDITIONFLAGDEFAULT', 0x05DB); // [45][DB] -- If a flag is set (1) the edition should be used as the default one.
-define('EBML_ID_EDITIONFLAGORDERED', 0x05DD); // [45][DD] -- Specify if the chapters can be defined multiple times and the order to play them is enforced.
-define('EBML_ID_FILEDATA', 0x065C); // [46][5C] -- The data of the file.
-define('EBML_ID_FILEMIMETYPE', 0x0660); // [46][60] -- MIME type of the file.
-define('EBML_ID_FILENAME', 0x066E); // [46][6E] -- Filename of the attached file.
-define('EBML_ID_FILEREFERRAL', 0x0675); // [46][75] -- A binary value that a track/codec can refer to when the attachment is needed.
-define('EBML_ID_FILEDESCRIPTION', 0x067E); // [46][7E] -- A human-friendly name for the attached file.
-define('EBML_ID_FILEUID', 0x06AE); // [46][AE] -- Unique ID representing the file, as random as possible.
-define('EBML_ID_CONTENTENCALGO', 0x07E1); // [47][E1] -- The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values:
-define('EBML_ID_CONTENTENCKEYID', 0x07E2); // [47][E2] -- For public key algorithms this is the ID of the public key the the data was encrypted with.
-define('EBML_ID_CONTENTSIGNATURE', 0x07E3); // [47][E3] -- A cryptographic signature of the contents.
-define('EBML_ID_CONTENTSIGKEYID', 0x07E4); // [47][E4] -- This is the ID of the private key the data was signed with.
-define('EBML_ID_CONTENTSIGALGO', 0x07E5); // [47][E5] -- The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
-define('EBML_ID_CONTENTSIGHASHALGO', 0x07E6); // [47][E6] -- The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
-define('EBML_ID_MUXINGAPP', 0x0D80); // [4D][80] -- Muxing application or library ("libmatroska-0.4.3").
-define('EBML_ID_SEEK', 0x0DBB); // [4D][BB] -- Contains a single seek entry to an EBML element.
-define('EBML_ID_CONTENTENCODINGORDER', 0x1031); // [50][31] -- Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment.
-define('EBML_ID_CONTENTENCODINGSCOPE', 0x1032); // [50][32] -- A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values:
-define('EBML_ID_CONTENTENCODINGTYPE', 0x1033); // [50][33] -- A value describing what kind of transformation has been done. Possible values:
-define('EBML_ID_CONTENTCOMPRESSION', 0x1034); // [50][34] -- Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking.
-define('EBML_ID_CONTENTENCRYPTION', 0x1035); // [50][35] -- Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise.
-define('EBML_ID_CUEREFNUMBER', 0x135F); // [53][5F] -- Number of the referenced Block of Track X in the specified Cluster.
-define('EBML_ID_NAME', 0x136E); // [53][6E] -- A human-readable track name.
-define('EBML_ID_CUEBLOCKNUMBER', 0x1378); // [53][78] -- Number of the Block in the specified Cluster.
-define('EBML_ID_TRACKOFFSET', 0x137F); // [53][7F] -- A value to add to the Block's Timecode. This can be used to adjust the playback offset of a track.
-define('EBML_ID_SEEKID', 0x13AB); // [53][AB] -- The binary ID corresponding to the element name.
-define('EBML_ID_SEEKPOSITION', 0x13AC); // [53][AC] -- The position of the element in the segment in octets (0 = first level 1 element).
-define('EBML_ID_STEREOMODE', 0x13B8); // [53][B8] -- Stereo-3D video mode on 2 bits (0: mono, 1: right eye, 2: left eye, 3: both eyes).
-define('EBML_ID_PIXELCROPBOTTOM', 0x14AA); // [54][AA] -- The number of video pixels to remove at the bottom of the image (for HDTV content).
-define('EBML_ID_DISPLAYWIDTH', 0x14B0); // [54][B0] -- Width of the video frames to display.
-define('EBML_ID_DISPLAYUNIT', 0x14B2); // [54][B2] -- Type of the unit for DisplayWidth/Height (0: pixels, 1: centimeters, 2: inches).
-define('EBML_ID_ASPECTRATIOTYPE', 0x14B3); // [54][B3] -- Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed).
-define('EBML_ID_DISPLAYHEIGHT', 0x14BA); // [54][BA] -- Height of the video frames to display.
-define('EBML_ID_PIXELCROPTOP', 0x14BB); // [54][BB] -- The number of video pixels to remove at the top of the image.
-define('EBML_ID_PIXELCROPLEFT', 0x14CC); // [54][CC] -- The number of video pixels to remove on the left of the image.
-define('EBML_ID_PIXELCROPRIGHT', 0x14DD); // [54][DD] -- The number of video pixels to remove on the right of the image.
-define('EBML_ID_FLAGFORCED', 0x15AA); // [55][AA] -- Set if that track MUST be used during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind.
-define('EBML_ID_MAXBLOCKADDITIONID', 0x15EE); // [55][EE] -- The maximum value of BlockAddID. A value 0 means there is no BlockAdditions for this track.
-define('EBML_ID_WRITINGAPP', 0x1741); // [57][41] -- Writing application ("mkvmerge-0.3.3").
-define('EBML_ID_CLUSTERSILENTTRACKS', 0x1854); // [58][54] -- The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use.
-define('EBML_ID_CLUSTERSILENTTRACKNUMBER', 0x18D7); // [58][D7] -- One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster.
-define('EBML_ID_ATTACHEDFILE', 0x21A7); // [61][A7] -- An attached file.
-define('EBML_ID_CONTENTENCODING', 0x2240); // [62][40] -- Settings for one content encoding like compression or encryption.
-define('EBML_ID_BITDEPTH', 0x2264); // [62][64] -- Bits per sample, mostly used for PCM.
-define('EBML_ID_CODECPRIVATE', 0x23A2); // [63][A2] -- Private data only known to the codec.
-define('EBML_ID_TARGETS', 0x23C0); // [63][C0] -- Contain all UIDs where the specified meta data apply. It is void to describe everything in the segment.
-define('EBML_ID_CHAPTERPHYSICALEQUIV', 0x23C3); // [63][C3] -- Specify the physical equivalent of this ChapterAtom like "DVD" (60) or "SIDE" (50), see complete list of values.
-define('EBML_ID_TAGCHAPTERUID', 0x23C4); // [63][C4] -- A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment.
-define('EBML_ID_TAGTRACKUID', 0x23C5); // [63][C5] -- A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment.
-define('EBML_ID_TAGATTACHMENTUID', 0x23C6); // [63][C6] -- A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment.
-define('EBML_ID_TAGEDITIONUID', 0x23C9); // [63][C9] -- A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment.
-define('EBML_ID_TARGETTYPE', 0x23CA); // [63][CA] -- An informational string that can be used to display the logical level of the target like "ALBUM", "TRACK", "MOVIE", "CHAPTER", etc (see TargetType).
-define('EBML_ID_TRACKTRANSLATE', 0x2624); // [66][24] -- The track identification for the given Chapter Codec.
-define('EBML_ID_TRACKTRANSLATETRACKID', 0x26A5); // [66][A5] -- The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used.
-define('EBML_ID_TRACKTRANSLATECODEC', 0x26BF); // [66][BF] -- The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).
-define('EBML_ID_TRACKTRANSLATEEDITIONUID', 0x26FC); // [66][FC] -- Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment.
-define('EBML_ID_SIMPLETAG', 0x27C8); // [67][C8] -- Contains general information about the target.
-define('EBML_ID_TARGETTYPEVALUE', 0x28CA); // [68][CA] -- A number to indicate the logical level of the target (see TargetType).
-define('EBML_ID_CHAPPROCESSCOMMAND', 0x2911); // [69][11] -- Contains all the commands associated to the Atom.
-define('EBML_ID_CHAPPROCESSTIME', 0x2922); // [69][22] -- Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter).
-define('EBML_ID_CHAPTERTRANSLATE', 0x2924); // [69][24] -- A tuple of corresponding ID used by chapter codecs to represent this segment.
-define('EBML_ID_CHAPPROCESSDATA', 0x2933); // [69][33] -- Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands.
-define('EBML_ID_CHAPPROCESS', 0x2944); // [69][44] -- Contains all the commands associated to the Atom.
-define('EBML_ID_CHAPPROCESSCODECID', 0x2955); // [69][55] -- Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later.
-define('EBML_ID_CHAPTERTRANSLATEID', 0x29A5); // [69][A5] -- The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used.
-define('EBML_ID_CHAPTERTRANSLATECODEC', 0x29BF); // [69][BF] -- The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).
-define('EBML_ID_CHAPTERTRANSLATEEDITIONUID', 0x29FC); // [69][FC] -- Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment.
-define('EBML_ID_CONTENTENCODINGS', 0x2D80); // [6D][80] -- Settings for several content encoding mechanisms like compression or encryption.
-define('EBML_ID_MINCACHE', 0x2DE7); // [6D][E7] -- The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used.
-define('EBML_ID_MAXCACHE', 0x2DF8); // [6D][F8] -- The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed.
-define('EBML_ID_CHAPTERSEGMENTUID', 0x2E67); // [6E][67] -- A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used.
-define('EBML_ID_CHAPTERSEGMENTEDITIONUID', 0x2EBC); // [6E][BC] -- The edition to play from the segment linked in ChapterSegmentUID.
-define('EBML_ID_TRACKOVERLAY', 0x2FAB); // [6F][AB] -- Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc.
-define('EBML_ID_TAG', 0x3373); // [73][73] -- Element containing elements specific to Tracks/Chapters.
-define('EBML_ID_SEGMENTFILENAME', 0x3384); // [73][84] -- A filename corresponding to this segment.
-define('EBML_ID_SEGMENTUID', 0x33A4); // [73][A4] -- A randomly generated unique ID to identify the current segment between many others (128 bits).
-define('EBML_ID_CHAPTERUID', 0x33C4); // [73][C4] -- A unique ID to identify the Chapter.
-define('EBML_ID_TRACKUID', 0x33C5); // [73][C5] -- A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file.
-define('EBML_ID_ATTACHMENTLINK', 0x3446); // [74][46] -- The UID of an attachment that is used by this codec.
-define('EBML_ID_CLUSTERBLOCKADDITIONS', 0x35A1); // [75][A1] -- Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data.
-define('EBML_ID_CHANNELPOSITIONS', 0x347B); // [7D][7B] -- Table of horizontal angles for each successive channel, see appendix.
-define('EBML_ID_OUTPUTSAMPLINGFREQUENCY', 0x38B5); // [78][B5] -- Real output sampling frequency in Hz (used for SBR techniques).
-define('EBML_ID_TITLE', 0x3BA9); // [7B][A9] -- General name of the segment.
-define('EBML_ID_CHAPTERDISPLAY', 0x00); // [80] -- Contains all possible strings to use for the chapter display.
-define('EBML_ID_TRACKTYPE', 0x03); // [83] -- A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control).
-define('EBML_ID_CHAPSTRING', 0x05); // [85] -- Contains the string to use as the chapter atom.
-define('EBML_ID_CODECID', 0x06); // [86] -- An ID corresponding to the codec, see the codec page for more info.
-define('EBML_ID_FLAGDEFAULT', 0x08); // [88] -- Set if that track (audio, video or subs) SHOULD be used if no language found matches the user preference.
-define('EBML_ID_CHAPTERTRACKNUMBER', 0x09); // [89] -- UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks.
-define('EBML_ID_CLUSTERSLICES', 0x0E); // [8E] -- Contains slices description.
-define('EBML_ID_CHAPTERTRACK', 0x0F); // [8F] -- List of tracks on which the chapter applies. If this element is not present, all tracks apply
-define('EBML_ID_CHAPTERTIMESTART', 0x11); // [91] -- Timecode of the start of Chapter (not scaled).
-define('EBML_ID_CHAPTERTIMEEND', 0x12); // [92] -- Timecode of the end of Chapter (timecode excluded, not scaled).
-define('EBML_ID_CUEREFTIME', 0x16); // [96] -- Timecode of the referenced Block.
-define('EBML_ID_CUEREFCLUSTER', 0x17); // [97] -- Position of the Cluster containing the referenced Block.
-define('EBML_ID_CHAPTERFLAGHIDDEN', 0x18); // [98] -- If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks).
-define('EBML_ID_FLAGINTERLACED', 0x1A); // [9A] -- Set if the video is interlaced.
-define('EBML_ID_CLUSTERBLOCKDURATION', 0x1B); // [9B] -- The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track. When not written and with no DefaultDuration, the value is assumed to be the difference between the timecode of this Block and the timecode of the next Block in "display" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks.
-define('EBML_ID_FLAGLACING', 0x1C); // [9C] -- Set if the track may contain blocks using lacing.
-define('EBML_ID_CHANNELS', 0x1F); // [9F] -- Numbers of channels in the track.
-define('EBML_ID_CLUSTERBLOCKGROUP', 0x20); // [A0] -- Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock.
-define('EBML_ID_CLUSTERBLOCK', 0x21); // [A1] -- Block containing the actual data to be rendered and a timecode relative to the Cluster Timecode.
-define('EBML_ID_CLUSTERBLOCKVIRTUAL', 0x22); // [A2] -- A Block with no data. It must be stored in the stream at the place the real Block should be in display order.
-define('EBML_ID_CLUSTERSIMPLEBLOCK', 0x23); // [A3] -- Similar to Block but without all the extra information, mostly used to reduced overhead when no extra feature is needed.
-define('EBML_ID_CLUSTERCODECSTATE', 0x24); // [A4] -- The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry.
-define('EBML_ID_CLUSTERBLOCKADDITIONAL', 0x25); // [A5] -- Interpreted by the codec as it wishes (using the BlockAddID).
-define('EBML_ID_CLUSTERBLOCKMORE', 0x26); // [A6] -- Contain the BlockAdditional and some parameters.
-define('EBML_ID_CLUSTERPOSITION', 0x27); // [A7] -- Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.
-define('EBML_ID_CODECDECODEALL', 0x2A); // [AA] -- The codec can decode potentially damaged data.
-define('EBML_ID_CLUSTERPREVSIZE', 0x2B); // [AB] -- Size of the previous Cluster, in octets. Can be useful for backward playing.
-define('EBML_ID_TRACKENTRY', 0x2E); // [AE] -- Describes a track with all elements.
-define('EBML_ID_CLUSTERENCRYPTEDBLOCK', 0x2F); // [AF] -- Similar to SimpleBlock but the data inside the Block are Transformed (encrypt and/or signed).
-define('EBML_ID_PIXELWIDTH', 0x30); // [B0] -- Width of the encoded video frames in pixels.
-define('EBML_ID_CUETIME', 0x33); // [B3] -- Absolute timecode according to the segment time base.
-define('EBML_ID_SAMPLINGFREQUENCY', 0x35); // [B5] -- Sampling frequency in Hz.
-define('EBML_ID_CHAPTERATOM', 0x36); // [B6] -- Contains the atom information to use as the chapter atom (apply to all tracks).
-define('EBML_ID_CUETRACKPOSITIONS', 0x37); // [B7] -- Contain positions for different tracks corresponding to the timecode.
-define('EBML_ID_FLAGENABLED', 0x39); // [B9] -- Set if the track is used.
-define('EBML_ID_PIXELHEIGHT', 0x3A); // [BA] -- Height of the encoded video frames in pixels.
-define('EBML_ID_CUEPOINT', 0x3B); // [BB] -- Contains all information relative to a seek point in the segment.
-define('EBML_ID_CRC32', 0x3F); // [BF] -- The CRC is computed on all the data of the Master element it's in, regardless of its position. It's recommended to put the CRC value at the beggining of the Master element for easier reading. All level 1 elements should include a CRC-32.
-define('EBML_ID_CLUSTERBLOCKADDITIONID', 0x4B); // [CB] -- The ID of the BlockAdditional element (0 is the main Block).
-define('EBML_ID_CLUSTERLACENUMBER', 0x4C); // [CC] -- The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.
-define('EBML_ID_CLUSTERFRAMENUMBER', 0x4D); // [CD] -- The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame).
-define('EBML_ID_CLUSTERDELAY', 0x4E); // [CE] -- The (scaled) delay to apply to the element.
-define('EBML_ID_CLUSTERDURATION', 0x4F); // [CF] -- The (scaled) duration to apply to the element.
-define('EBML_ID_TRACKNUMBER', 0x57); // [D7] -- The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number).
-define('EBML_ID_CUEREFERENCE', 0x5B); // [DB] -- The Clusters containing the required referenced Blocks.
-define('EBML_ID_VIDEO', 0x60); // [E0] -- Video settings.
-define('EBML_ID_AUDIO', 0x61); // [E1] -- Audio settings.
-define('EBML_ID_CLUSTERTIMESLICE', 0x68); // [E8] -- Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.
-define('EBML_ID_CUECODECSTATE', 0x6A); // [EA] -- The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry.
-define('EBML_ID_CUEREFCODECSTATE', 0x6B); // [EB] -- The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry.
-define('EBML_ID_VOID', 0x6C); // [EC] -- Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use.
-define('EBML_ID_CLUSTERTIMECODE', 0x67); // [E7] -- Absolute timecode of the cluster (based on TimecodeScale).
-define('EBML_ID_CLUSTERBLOCKADDID', 0x6E); // [EE] -- An ID to identify the BlockAdditional level.
-define('EBML_ID_CUECLUSTERPOSITION', 0x71); // [F1] -- The position of the Cluster containing the required Block.
-define('EBML_ID_CUETRACK', 0x77); // [F7] -- The track for which a position is given.
-define('EBML_ID_CLUSTERREFERENCEPRIORITY', 0x7A); // [FA] -- This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced.
-define('EBML_ID_CLUSTERREFERENCEBLOCK', 0x7B); // [FB] -- Timecode of another frame used as a reference (ie: B or P frame). The timecode is relative to the block it's attached to.
-define('EBML_ID_CLUSTERREFERENCEVIRTUAL', 0x7D); // [FD] -- Relative position of the data that should be in position of the virtual block.
-
-
-class getid3_matroska extends getid3_handler
-{
- // public options
- public static $hide_clusters = true; // if true, do not return information about CLUSTER chunks, since there's a lot of them and they're not usually useful [default: TRUE]
- public static $parse_whole_file = false; // true to parse the whole file, not only header [default: FALSE]
-
- // private parser settings/placeholders
- private $EBMLbuffer = '';
- private $EBMLbuffer_offset = 0;
- private $EBMLbuffer_length = 0;
- private $current_offset = 0;
- private $unuseful_elements = array(EBML_ID_CRC32, EBML_ID_VOID);
-
- public function Analyze()
- {
- $info = &$this->getid3->info;
-
- // parse container
- try {
- $this->parseEBML($info);
- }
- catch (Exception $e) {
- $info['error'][] = 'EBML parser: '.$e->getMessage();
- }
-
- // calculate playtime
- if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
- foreach ($info['matroska']['info'] as $key => $infoarray) {
- if (isset($infoarray['Duration'])) {
- // TimecodeScale is how many nanoseconds each Duration unit is
- $info['playtime_seconds'] = $infoarray['Duration'] * ((isset($infoarray['TimecodeScale']) ? $infoarray['TimecodeScale'] : 1000000) / 1000000000);
- break;
- }
- }
- }
-
- // extract tags
- if (isset($info['matroska']['tags']) && is_array($info['matroska']['tags'])) {
- foreach ($info['matroska']['tags'] as $key => $infoarray) {
- $this->ExtractCommentsSimpleTag($infoarray);
- }
- }
-
- // process tracks
- if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
- foreach ($info['matroska']['tracks']['tracks'] as $key => $trackarray) {
-
- $track_info = array();
- $track_info['dataformat'] = self::MatroskaCodecIDtoCommonName($trackarray['CodecID']);
- $track_info['default'] = (isset($trackarray['FlagDefault']) ? $trackarray['FlagDefault'] : true);
- if (isset($trackarray['Name'])) { $track_info['name'] = $trackarray['Name']; }
-
- switch ($trackarray['TrackType']) {
-
- case 1: // Video
- $track_info['resolution_x'] = $trackarray['PixelWidth'];
- $track_info['resolution_y'] = $trackarray['PixelHeight'];
- if (isset($trackarray['DisplayWidth'])) { $track_info['display_x'] = $trackarray['DisplayWidth']; }
- if (isset($trackarray['DisplayHeight'])) { $track_info['display_y'] = $trackarray['DisplayHeight']; }
- if (isset($trackarray['DefaultDuration'])) { $track_info['frame_rate'] = round(1000000000 / $trackarray['DefaultDuration'], 3); }
- //if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; }
-
- switch ($trackarray['CodecID']) {
- case 'V_MS/VFW/FOURCC':
- if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) {
- $this->getid3->warning('Unable to parse codec private data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"');
- break;
- }
- $parsed = getid3_riff::ParseBITMAPINFOHEADER($trackarray['CodecPrivate']);
- $track_info['codec'] = getid3_riff::RIFFfourccLookup($parsed['fourcc']);
- $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
- break;
- }
-
- $info['video']['streams'][] = $track_info;
- break;
-
- case 2: // Audio
- $track_info['sample_rate'] = (isset($trackarray['SamplingFrequency']) ? $trackarray['SamplingFrequency'] : 8000.0);
- $track_info['channels'] = (isset($trackarray['Channels']) ? $trackarray['Channels'] : 1);
- $track_info['language'] = (isset($trackarray['Language']) ? $trackarray['Language'] : 'eng');
- if (isset($trackarray['BitDepth'])) { $track_info['bits_per_sample'] = $trackarray['BitDepth']; }
- //if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; }
-
- switch ($trackarray['CodecID']) {
- case 'A_PCM/INT/LIT':
- case 'A_PCM/INT/BIG':
- $track_info['bitrate'] = $trackarray['SamplingFrequency'] * $trackarray['Channels'] * $trackarray['BitDepth'];
- break;
-
- case 'A_AC3':
- case 'A_DTS':
- case 'A_MPEG/L3':
- //case 'A_FLAC':
- if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.'.$track_info['dataformat'].'.php', __FILE__, false)) {
- $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.'.$track_info['dataformat'].'.php"');
- break;
- }
-
- if (!isset($info['matroska']['track_data_offsets'][$trackarray['TrackNumber']])) {
- $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because $info[matroska][track_data_offsets]['.$trackarray['TrackNumber'].'] not set');
- break;
- }
-
- // create temp instance
- $getid3_temp = new getID3();
- $getid3_temp->openfile($this->getid3->filename);
- $getid3_temp->info['avdataoffset'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'];
- if ($track_info['dataformat'] == 'mp3' || $track_info['dataformat'] == 'flac') {
- $getid3_temp->info['avdataend'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'] + $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['length'];
- }
-
- // analyze
- $class = 'getid3_'.$track_info['dataformat'];
- $header_data_key = $track_info['dataformat'] == 'mp3' ? 'mpeg' : $track_info['dataformat'];
- $getid3_audio = new $class($getid3_temp);
- if ($track_info['dataformat'] == 'mp3') {
- $getid3_audio->allow_bruteforce = true;
- }
- if ($track_info['dataformat'] == 'flac') {
- $getid3_audio->AnalyzeString($trackarray['CodecPrivate']);
- }
- else {
- $getid3_audio->Analyze();
- }
- if (!empty($getid3_temp->info[$header_data_key])) {
- unset($getid3_temp->info[$header_data_key]['GETID3_VERSION']);
- $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info[$header_data_key];
- if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) {
- foreach ($getid3_temp->info['audio'] as $key => $value) {
- $track_info[$key] = $value;
- }
- }
- }
- else {
- $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because '.$class.'::Analyze() failed at offset '.$getid3_temp->info['avdataoffset']);
- }
-
- // copy errors and warnings
- if (!empty($getid3_temp->info['error'])) {
- foreach ($getid3_temp->info['error'] as $newerror) {
- $this->getid3->warning($class.'() says: ['.$newerror.']');
- }
- }
- if (!empty($getid3_temp->info['warning'])) {
- foreach ($getid3_temp->info['warning'] as $newerror) {
- if ($track_info['dataformat'] == 'mp3' && preg_match('/^Probable truncated file: expecting \d+ bytes of audio data, only found \d+ \(short by \d+ bytes\)$/', $newerror)) {
- // LAME/Xing header is probably set, but audio data is chunked into Matroska file and near-impossible to verify if audio stream is complete, so ignore useless warning
- continue;
- }
- $this->getid3->warning($class.'() says: ['.$newerror.']');
- }
- }
- unset($getid3_temp, $getid3_audio);
- break;
-
- case 'A_AAC':
- case 'A_AAC/MPEG2/LC':
- case 'A_AAC/MPEG4/LC':
- case 'A_AAC/MPEG4/LC/SBR':
- $this->getid3->warning($trackarray['CodecID'].' audio data contains no header, audio/video bitrates can\'t be calculated');
- break;
-
- case 'A_VORBIS':
- if (!isset($trackarray['CodecPrivate'])) {
- $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because CodecPrivate data not set');
- break;
- }
- $vorbis_offset = strpos($trackarray['CodecPrivate'], 'vorbis', 1);
- if ($vorbis_offset === false) {
- $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because CodecPrivate data does not contain "vorbis" keyword');
- break;
- }
- $vorbis_offset -= 1;
-
- if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, false)) {
- $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.ogg.php"');
- }
-
- // create temp instance
- $getid3_temp = new getID3();
- $getid3_temp->openfile($this->getid3->filename);
-
- // analyze
- $getid3_ogg = new getid3_ogg($getid3_temp);
- $oggpageinfo['page_seqno'] = 0;
- $getid3_ogg->ParseVorbisPageHeader($trackarray['CodecPrivate'], $vorbis_offset, $oggpageinfo);
- if (!empty($getid3_temp->info['ogg'])) {
- $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info['ogg'];
- if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) {
- foreach ($getid3_temp->info['audio'] as $key => $value) {
- $track_info[$key] = $value;
- }
- }
- }
-
- // copy errors and warnings
- if (!empty($getid3_temp->info['error'])) {
- foreach ($getid3_temp->info['error'] as $newerror) {
- $this->getid3->warning('getid3_ogg() says: ['.$newerror.']');
- }
- }
- if (!empty($getid3_temp->info['warning'])) {
- foreach ($getid3_temp->info['warning'] as $newerror) {
- $this->getid3->warning('getid3_ogg() says: ['.$newerror.']');
- }
- }
-
- if (!empty($getid3_temp->info['ogg']['bitrate_nominal'])) {
- $track_info['bitrate'] = $getid3_temp->info['ogg']['bitrate_nominal'];
- }
- unset($getid3_temp, $getid3_ogg, $oggpageinfo, $vorbis_offset);
- break;
-
- case 'A_MS/ACM':
- if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) {
- $this->getid3->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"');
- break;
- }
-
- $parsed = getid3_riff::RIFFparseWAVEFORMATex($trackarray['CodecPrivate']);
- foreach ($parsed as $key => $value) {
- if ($key != 'raw') {
- $track_info[$key] = $value;
- }
- }
- $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
- break;
-
- default:
- $this->getid3->warning('Unhandled audio type "'.(isset($trackarray['CodecID']) ? $trackarray['CodecID'] : '').'"');
- }
-
- $info['audio']['streams'][] = $track_info;
- break;
- }
- }
-
- if (!empty($info['video']['streams'])) {
- $info['video'] = self::getDefaultStreamInfo($info['video']['streams']);
- }
- if (!empty($info['audio']['streams'])) {
- $info['audio'] = self::getDefaultStreamInfo($info['audio']['streams']);
- }
- }
-
- // determine mime type
- if (!empty($info['video']['streams'])) {
- $info['mime_type'] = ($info['matroska']['doctype'] == 'webm' ? 'video/webm' : 'video/x-matroska');
- } elseif (!empty($info['audio']['streams'])) {
- $info['mime_type'] = ($info['matroska']['doctype'] == 'webm' ? 'audio/webm' : 'audio/x-matroska');
- } elseif (isset($info['mime_type'])) {
- unset($info['mime_type']);
- }
-
- return true;
- }
-
-
-///////////////////////////////////////
-
- private function parseEBML(&$info)
- {
- // http://www.matroska.org/technical/specs/index.html#EBMLBasics
- $this->current_offset = $info['avdataoffset'];
-
- while ($this->getEBMLelement($top_element, $info['avdataend'])) {
- switch ($top_element['id']) {
-
- case EBML_ID_EBML:
- $info['fileformat'] = 'matroska';
- $info['matroska']['header']['offset'] = $top_element['offset'];
- $info['matroska']['header']['length'] = $top_element['length'];
-
- while ($this->getEBMLelement($element_data, $top_element['end'], true)) {
- switch ($element_data['id']) {
-
- case EBML_ID_EBMLVERSION:
- case EBML_ID_EBMLREADVERSION:
- case EBML_ID_EBMLMAXIDLENGTH:
- case EBML_ID_EBMLMAXSIZELENGTH:
- case EBML_ID_DOCTYPEVERSION:
- case EBML_ID_DOCTYPEREADVERSION:
- $element_data['data'] = getid3_lib::BigEndian2Int($element_data['data']);
- break;
-
- case EBML_ID_DOCTYPE:
- $element_data['data'] = getid3_lib::trimNullByte($element_data['data']);
- $info['matroska']['doctype'] = $element_data['data'];
- break;
-
- case EBML_ID_CRC32: // not useful, ignore
- $this->current_offset = $element_data['end'];
- unset($element_data);
- break;
-
- default:
- $this->unhandledElement('header', __LINE__, $element_data);
- }
- if (!empty($element_data)) {
- unset($element_data['offset'], $element_data['end']);
- $info['matroska']['header']['elements'][] = $element_data;
- }
- }
- break;
-
- case EBML_ID_SEGMENT:
- $info['matroska']['segment'][0]['offset'] = $top_element['offset'];
- $info['matroska']['segment'][0]['length'] = $top_element['length'];
-
- while ($this->getEBMLelement($element_data, $top_element['end'])) {
- if ($element_data['id'] != EBML_ID_CLUSTER || !self::$hide_clusters) { // collect clusters only if required
- $info['matroska']['segments'][] = $element_data;
- }
- switch ($element_data['id']) {
-
- case EBML_ID_SEEKHEAD: // Contains the position of other level 1 elements.
-
- while ($this->getEBMLelement($seek_entry, $element_data['end'])) {
- switch ($seek_entry['id']) {
-
- case EBML_ID_SEEK: // Contains a single seek entry to an EBML element
- while ($this->getEBMLelement($sub_seek_entry, $seek_entry['end'], true)) {
-
- switch ($sub_seek_entry['id']) {
-
- case EBML_ID_SEEKID:
- $seek_entry['target_id'] = self::EBML2Int($sub_seek_entry['data']);
- $seek_entry['target_name'] = self::EBMLidName($seek_entry['target_id']);
- break;
-
- case EBML_ID_SEEKPOSITION:
- $seek_entry['target_offset'] = $element_data['offset'] + getid3_lib::BigEndian2Int($sub_seek_entry['data']);
- break;
-
- default:
- $this->unhandledElement('seekhead.seek', __LINE__, $sub_seek_entry); }
- }
-
- if ($seek_entry['target_id'] != EBML_ID_CLUSTER || !self::$hide_clusters) { // collect clusters only if required
- $info['matroska']['seek'][] = $seek_entry;
- }
- break;
-
- default:
- $this->unhandledElement('seekhead', __LINE__, $seek_entry);
- }
- }
- break;
-
- case EBML_ID_TRACKS: // A top-level block of information with many tracks described.
- $info['matroska']['tracks'] = $element_data;
-
- while ($this->getEBMLelement($track_entry, $element_data['end'])) {
- switch ($track_entry['id']) {
-
- case EBML_ID_TRACKENTRY: //subelements: Describes a track with all elements.
-
- while ($this->getEBMLelement($subelement, $track_entry['end'], array(EBML_ID_VIDEO, EBML_ID_AUDIO, EBML_ID_CONTENTENCODINGS))) {
- switch ($subelement['id']) {
-
- case EBML_ID_TRACKNUMBER:
- case EBML_ID_TRACKUID:
- case EBML_ID_TRACKTYPE:
- case EBML_ID_MINCACHE:
- case EBML_ID_MAXCACHE:
- case EBML_ID_MAXBLOCKADDITIONID:
- case EBML_ID_DEFAULTDURATION: // nanoseconds per frame
- $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
- break;
-
- case EBML_ID_TRACKTIMECODESCALE:
- $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Float($subelement['data']);
- break;
-
- case EBML_ID_CODECID:
- case EBML_ID_LANGUAGE:
- case EBML_ID_NAME:
- case EBML_ID_CODECNAME:
- $track_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
- break;
-
- case EBML_ID_CODECPRIVATE:
- $track_entry[$subelement['id_name']] = $subelement['data'];
- break;
-
- case EBML_ID_FLAGENABLED:
- case EBML_ID_FLAGDEFAULT:
- case EBML_ID_FLAGFORCED:
- case EBML_ID_FLAGLACING:
- case EBML_ID_CODECDECODEALL:
- $track_entry[$subelement['id_name']] = (bool) getid3_lib::BigEndian2Int($subelement['data']);
- break;
-
- case EBML_ID_VIDEO:
-
- while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
- switch ($sub_subelement['id']) {
-
- case EBML_ID_PIXELWIDTH:
- case EBML_ID_PIXELHEIGHT:
- case EBML_ID_STEREOMODE:
- case EBML_ID_PIXELCROPBOTTOM:
- case EBML_ID_PIXELCROPTOP:
- case EBML_ID_PIXELCROPLEFT:
- case EBML_ID_PIXELCROPRIGHT:
- case EBML_ID_DISPLAYWIDTH:
- case EBML_ID_DISPLAYHEIGHT:
- case EBML_ID_DISPLAYUNIT:
- case EBML_ID_ASPECTRATIOTYPE:
- $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
- break;
-
- case EBML_ID_FLAGINTERLACED:
- $track_entry[$sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_subelement['data']);
- break;
-
- case EBML_ID_GAMMAVALUE:
- $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']);
- break;
-
- case EBML_ID_COLOURSPACE:
- $track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
- break;
-
- default:
- $this->unhandledElement('track.video', __LINE__, $sub_subelement);
- }
- }
- break;
-
- case EBML_ID_AUDIO:
-
- while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
- switch ($sub_subelement['id']) {
-
- case EBML_ID_CHANNELS:
- case EBML_ID_BITDEPTH:
- $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
- break;
-
- case EBML_ID_SAMPLINGFREQUENCY:
- case EBML_ID_OUTPUTSAMPLINGFREQUENCY:
- $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']);
- break;
-
- case EBML_ID_CHANNELPOSITIONS:
- $track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
- break;
-
- default:
- $this->unhandledElement('track.audio', __LINE__, $sub_subelement);
- }
- }
- break;
-
- case EBML_ID_CONTENTENCODINGS:
-
- while ($this->getEBMLelement($sub_subelement, $subelement['end'])) {
- switch ($sub_subelement['id']) {
-
- case EBML_ID_CONTENTENCODING:
-
- while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], array(EBML_ID_CONTENTCOMPRESSION, EBML_ID_CONTENTENCRYPTION))) {
- switch ($sub_sub_subelement['id']) {
-
- case EBML_ID_CONTENTENCODINGORDER:
- case EBML_ID_CONTENTENCODINGSCOPE:
- case EBML_ID_CONTENTENCODINGTYPE:
- $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
- break;
-
- case EBML_ID_CONTENTCOMPRESSION:
-
- while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
- switch ($sub_sub_sub_subelement['id']) {
-
- case EBML_ID_CONTENTCOMPALGO:
- $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']);
- break;
-
- case EBML_ID_CONTENTCOMPSETTINGS:
- $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data'];
- break;
-
- default:
- $this->unhandledElement('track.contentencodings.contentencoding.contentcompression', __LINE__, $sub_sub_sub_subelement);
- }
- }
- break;
-
- case EBML_ID_CONTENTENCRYPTION:
-
- while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
- switch ($sub_sub_sub_subelement['id']) {
-
- case EBML_ID_CONTENTENCALGO:
- case EBML_ID_CONTENTSIGALGO:
- case EBML_ID_CONTENTSIGHASHALGO:
- $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']);
- break;
-
- case EBML_ID_CONTENTENCKEYID:
- case EBML_ID_CONTENTSIGNATURE:
- case EBML_ID_CONTENTSIGKEYID:
- $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data'];
- break;
-
- default:
- $this->unhandledElement('track.contentencodings.contentencoding.contentcompression', __LINE__, $sub_sub_sub_subelement);
- }
- }
- break;
-
- default:
- $this->unhandledElement('track.contentencodings.contentencoding', __LINE__, $sub_sub_subelement);
- }
- }
- break;
-
- default:
- $this->unhandledElement('track.contentencodings', __LINE__, $sub_subelement);
- }
- }
- break;
-
- default:
- $this->unhandledElement('track', __LINE__, $subelement);
- }
- }
-
- $info['matroska']['tracks']['tracks'][] = $track_entry;
- break;
-
- default:
- $this->unhandledElement('tracks', __LINE__, $track_entry);
- }
- }
- break;
-
- case EBML_ID_INFO: // Contains miscellaneous general information and statistics on the file.
- $info_entry = array();
-
- while ($this->getEBMLelement($subelement, $element_data['end'], true)) {
- switch ($subelement['id']) {
-
- case EBML_ID_CHAPTERTRANSLATEEDITIONUID:
- case EBML_ID_CHAPTERTRANSLATECODEC:
- case EBML_ID_TIMECODESCALE:
- $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
- break;
-
- case EBML_ID_DURATION:
- $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Float($subelement['data']);
- break;
-
- case EBML_ID_DATEUTC:
- $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
- $info_entry[$subelement['id_name'].'_unix'] = self::EBMLdate2unix($info_entry[$subelement['id_name']]);
- break;
-
- case EBML_ID_SEGMENTUID:
- case EBML_ID_PREVUID:
- case EBML_ID_NEXTUID:
- case EBML_ID_SEGMENTFAMILY:
- case EBML_ID_CHAPTERTRANSLATEID:
- $info_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
- break;
-
- case EBML_ID_SEGMENTFILENAME:
- case EBML_ID_PREVFILENAME:
- case EBML_ID_NEXTFILENAME:
- case EBML_ID_TITLE:
- case EBML_ID_MUXINGAPP:
- case EBML_ID_WRITINGAPP:
- $info_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
- $info['matroska']['comments'][strtolower($subelement['id_name'])][] = $info_entry[$subelement['id_name']];
- break;
-
- default:
- $this->unhandledElement('info', __LINE__, $subelement);
- }
- }
- $info['matroska']['info'][] = $info_entry;
- break;
-
- case EBML_ID_CUES: // A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams.
- if (self::$hide_clusters) { // do not parse cues if hide clusters is "ON" till they point to clusters anyway
- $this->current_offset = $element_data['end'];
- break;
- }
- $cues_entry = array();
-
- while ($this->getEBMLelement($subelement, $element_data['end'])) {
- switch ($subelement['id']) {
-
- case EBML_ID_CUEPOINT:
- $cuepoint_entry = array();
-
- while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CUETRACKPOSITIONS))) {
- switch ($sub_subelement['id']) {
-
- case EBML_ID_CUETRACKPOSITIONS:
- $cuetrackpositions_entry = array();
-
- while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], true)) {
- switch ($sub_sub_subelement['id']) {
-
- case EBML_ID_CUETRACK:
- case EBML_ID_CUECLUSTERPOSITION:
- case EBML_ID_CUEBLOCKNUMBER:
- case EBML_ID_CUECODECSTATE:
- $cuetrackpositions_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
- break;
-
- default:
- $this->unhandledElement('cues.cuepoint.cuetrackpositions', __LINE__, $sub_sub_subelement);
- }
- }
- $cuepoint_entry[$sub_subelement['id_name']][] = $cuetrackpositions_entry;
- break;
-
- case EBML_ID_CUETIME:
- $cuepoint_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
- break;
-
- default:
- $this->unhandledElement('cues.cuepoint', __LINE__, $sub_subelement);
- }
- }
- $cues_entry[] = $cuepoint_entry;
- break;
-
- default:
- $this->unhandledElement('cues', __LINE__, $subelement);
- }
- }
- $info['matroska']['cues'] = $cues_entry;
- break;
-
- case EBML_ID_TAGS: // Element containing elements specific to Tracks/Chapters.
- $tags_entry = array();
-
- while ($this->getEBMLelement($subelement, $element_data['end'], false)) {
- switch ($subelement['id']) {
-
- case EBML_ID_TAG:
- $tag_entry = array();
-
- while ($this->getEBMLelement($sub_subelement, $subelement['end'], false)) {
- switch ($sub_subelement['id']) {
-
- case EBML_ID_TARGETS:
- $targets_entry = array();
-
- while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], true)) {
- switch ($sub_sub_subelement['id']) {
-
- case EBML_ID_TARGETTYPEVALUE:
- $targets_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
- $targets_entry[strtolower($sub_sub_subelement['id_name']).'_long'] = self::MatroskaTargetTypeValue($targets_entry[$sub_sub_subelement['id_name']]);
- break;
-
- case EBML_ID_TARGETTYPE:
- $targets_entry[$sub_sub_subelement['id_name']] = $sub_sub_subelement['data'];
- break;
-
- case EBML_ID_TAGTRACKUID:
- case EBML_ID_TAGEDITIONUID:
- case EBML_ID_TAGCHAPTERUID:
- case EBML_ID_TAGATTACHMENTUID:
- $targets_entry[$sub_sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
- break;
-
- default:
- $this->unhandledElement('tags.tag.targets', __LINE__, $sub_sub_subelement);
- }
- }
- $tag_entry[$sub_subelement['id_name']] = $targets_entry;
- break;
-
- case EBML_ID_SIMPLETAG:
- $tag_entry[$sub_subelement['id_name']][] = $this->HandleEMBLSimpleTag($sub_subelement['end']);
- break;
-
- default:
- $this->unhandledElement('tags.tag', __LINE__, $sub_subelement);
- }
- }
- $tags_entry[] = $tag_entry;
- break;
-
- default:
- $this->unhandledElement('tags', __LINE__, $subelement);
- }
- }
- $info['matroska']['tags'] = $tags_entry;
- break;
-
- case EBML_ID_ATTACHMENTS: // Contain attached files.
-
- while ($this->getEBMLelement($subelement, $element_data['end'])) {
- switch ($subelement['id']) {
-
- case EBML_ID_ATTACHEDFILE:
- $attachedfile_entry = array();
-
- while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_FILEDATA))) {
- switch ($sub_subelement['id']) {
-
- case EBML_ID_FILEDESCRIPTION:
- case EBML_ID_FILENAME:
- case EBML_ID_FILEMIMETYPE:
- $attachedfile_entry[$sub_subelement['id_name']] = $sub_subelement['data'];
- break;
-
- case EBML_ID_FILEDATA:
- $attachedfile_entry['data_offset'] = $this->current_offset;
- $attachedfile_entry['data_length'] = $sub_subelement['length'];
-
- $this->getid3->saveAttachment(
- $attachedfile_entry[$sub_subelement['id_name']],
- $attachedfile_entry['FileName'],
- $attachedfile_entry['data_offset'],
- $attachedfile_entry['data_length']);
-
- if (@$attachedfile_entry[$sub_subelement['id_name']] && is_file($attachedfile_entry[$sub_subelement['id_name']])) {
- $attachedfile_entry[$sub_subelement['id_name'].'_filename'] = $attachedfile_entry[$sub_subelement['id_name']];
- unset($attachedfile_entry[$sub_subelement['id_name']]);
- }
-
- $this->current_offset = $sub_subelement['end'];
- break;
-
- case EBML_ID_FILEUID:
- $attachedfile_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
- break;
-
- default:
- $this->unhandledElement('attachments.attachedfile', __LINE__, $sub_subelement);
- }
- }
- if (!empty($attachedfile_entry['FileData']) && !empty($attachedfile_entry['FileMimeType']) && preg_match('#^image/#i', $attachedfile_entry['FileMimeType'])) {
- if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
- $attachedfile_entry['data'] = $attachedfile_entry['FileData'];
- $attachedfile_entry['image_mime'] = $attachedfile_entry['FileMimeType'];
- $info['matroska']['comments']['picture'][] = array('data' => $attachedfile_entry['data'], 'image_mime' => $attachedfile_entry['image_mime'], 'filename' => (!empty($attachedfile_entry['FileName']) ? $attachedfile_entry['FileName'] : ''));
- unset($attachedfile_entry['FileData'], $attachedfile_entry['FileMimeType']);
- }
- }
- if (!empty($attachedfile_entry['image_mime']) && preg_match('#^image/#i', $attachedfile_entry['image_mime'])) {
- // don't add a second copy of attached images, which are grouped under the standard location [comments][picture]
- } else {
- $info['matroska']['attachments'][] = $attachedfile_entry;
- }
- break;
-
- default:
- $this->unhandledElement('attachments', __LINE__, $subelement);
- }
- }
- break;
-
- case EBML_ID_CHAPTERS:
-
- while ($this->getEBMLelement($subelement, $element_data['end'])) {
- switch ($subelement['id']) {
-
- case EBML_ID_EDITIONENTRY:
- $editionentry_entry = array();
-
- while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CHAPTERATOM))) {
- switch ($sub_subelement['id']) {
-
- case EBML_ID_EDITIONUID:
- $editionentry_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
- break;
-
- case EBML_ID_EDITIONFLAGHIDDEN:
- case EBML_ID_EDITIONFLAGDEFAULT:
- case EBML_ID_EDITIONFLAGORDERED:
- $editionentry_entry[$sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_subelement['data']);
- break;
-
- case EBML_ID_CHAPTERATOM:
- $chapteratom_entry = array();
-
- while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], array(EBML_ID_CHAPTERTRACK, EBML_ID_CHAPTERDISPLAY))) {
- switch ($sub_sub_subelement['id']) {
-
- case EBML_ID_CHAPTERSEGMENTUID:
- case EBML_ID_CHAPTERSEGMENTEDITIONUID:
- $chapteratom_entry[$sub_sub_subelement['id_name']] = $sub_sub_subelement['data'];
- break;
-
- case EBML_ID_CHAPTERFLAGENABLED:
- case EBML_ID_CHAPTERFLAGHIDDEN:
- $chapteratom_entry[$sub_sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
- break;
-
- case EBML_ID_CHAPTERUID:
- case EBML_ID_CHAPTERTIMESTART:
- case EBML_ID_CHAPTERTIMEEND:
- $chapteratom_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
- break;
-
- case EBML_ID_CHAPTERTRACK:
- $chaptertrack_entry = array();
-
- while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
- switch ($sub_sub_sub_subelement['id']) {
-
- case EBML_ID_CHAPTERTRACKNUMBER:
- $chaptertrack_entry[$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']);
- break;
-
- default:
- $this->unhandledElement('chapters.editionentry.chapteratom.chaptertrack', __LINE__, $sub_sub_sub_subelement);
- }
- }
- $chapteratom_entry[$sub_sub_subelement['id_name']][] = $chaptertrack_entry;
- break;
-
- case EBML_ID_CHAPTERDISPLAY:
- $chapterdisplay_entry = array();
-
- while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
- switch ($sub_sub_sub_subelement['id']) {
-
- case EBML_ID_CHAPSTRING:
- case EBML_ID_CHAPLANGUAGE:
- case EBML_ID_CHAPCOUNTRY:
- $chapterdisplay_entry[$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data'];
- break;
-
- default:
- $this->unhandledElement('chapters.editionentry.chapteratom.chapterdisplay', __LINE__, $sub_sub_sub_subelement);
- }
- }
- $chapteratom_entry[$sub_sub_subelement['id_name']][] = $chapterdisplay_entry;
- break;
-
- default:
- $this->unhandledElement('chapters.editionentry.chapteratom', __LINE__, $sub_sub_subelement);
- }
- }
- $editionentry_entry[$sub_subelement['id_name']][] = $chapteratom_entry;
- break;
-
- default:
- $this->unhandledElement('chapters.editionentry', __LINE__, $sub_subelement);
- }
- }
- $info['matroska']['chapters'][] = $editionentry_entry;
- break;
-
- default:
- $this->unhandledElement('chapters', __LINE__, $subelement);
- }
- }
- break;
-
- case EBML_ID_CLUSTER: // The lower level element containing the (monolithic) Block structure.
- $cluster_entry = array();
-
- while ($this->getEBMLelement($subelement, $element_data['end'], array(EBML_ID_CLUSTERSILENTTRACKS, EBML_ID_CLUSTERBLOCKGROUP, EBML_ID_CLUSTERSIMPLEBLOCK))) {
- switch ($subelement['id']) {
-
- case EBML_ID_CLUSTERTIMECODE:
- case EBML_ID_CLUSTERPOSITION:
- case EBML_ID_CLUSTERPREVSIZE:
- $cluster_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
- break;
-
- case EBML_ID_CLUSTERSILENTTRACKS:
- $cluster_silent_tracks = array();
-
- while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
- switch ($sub_subelement['id']) {
-
- case EBML_ID_CLUSTERSILENTTRACKNUMBER:
- $cluster_silent_tracks[] = getid3_lib::BigEndian2Int($sub_subelement['data']);
- break;
-
- default:
- $this->unhandledElement('cluster.silenttracks', __LINE__, $sub_subelement);
- }
- }
- $cluster_entry[$subelement['id_name']][] = $cluster_silent_tracks;
- break;
-
- case EBML_ID_CLUSTERBLOCKGROUP:
- $cluster_block_group = array('offset' => $this->current_offset);
-
- while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CLUSTERBLOCK))) {
- switch ($sub_subelement['id']) {
-
- case EBML_ID_CLUSTERBLOCK:
- $cluster_block_group[$sub_subelement['id_name']] = $this->HandleEMBLClusterBlock($sub_subelement, EBML_ID_CLUSTERBLOCK, $info);
- break;
-
- case EBML_ID_CLUSTERREFERENCEPRIORITY: // unsigned-int
- case EBML_ID_CLUSTERBLOCKDURATION: // unsigned-int
- $cluster_block_group[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
- break;
-
- case EBML_ID_CLUSTERREFERENCEBLOCK: // signed-int
- $cluster_block_group[$sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_subelement['data'], false, true);
- break;
-
- case EBML_ID_CLUSTERCODECSTATE:
- $cluster_block_group[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
- break;
-
- default:
- $this->unhandledElement('clusters.blockgroup', __LINE__, $sub_subelement);
- }
- }
- $cluster_entry[$subelement['id_name']][] = $cluster_block_group;
- break;
-
- case EBML_ID_CLUSTERSIMPLEBLOCK:
- $cluster_entry[$subelement['id_name']][] = $this->HandleEMBLClusterBlock($subelement, EBML_ID_CLUSTERSIMPLEBLOCK, $info);
- break;
-
- default:
- $this->unhandledElement('cluster', __LINE__, $subelement);
- }
- $this->current_offset = $subelement['end'];
- }
- if (!self::$hide_clusters) {
- $info['matroska']['cluster'][] = $cluster_entry;
- }
-
- // check to see if all the data we need exists already, if so, break out of the loop
- if (!self::$parse_whole_file) {
- if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
- if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
- return;
- }
- }
- }
- break;
-
- default:
- $this->unhandledElement('segment', __LINE__, $element_data);
- }
- }
- break;
-
- default:
- $this->unhandledElement('root', __LINE__, $top_element);
- }
- }
- }
-
- private function EnsureBufferHasEnoughData($min_data = 1024)
- {
- if (($this->current_offset - $this->EBMLbuffer_offset) >= ($this->EBMLbuffer_length - $min_data)) {
-
- if (!getid3_lib::intValueSupported($this->current_offset + $this->getid3->fread_buffer_size())) {
- $this->getid3->info['error'][] = 'EBML parser: cannot read past '.$this->current_offset;
- return false;
- }
-
- fseek($this->getid3->fp, $this->current_offset, SEEK_SET);
- $this->EBMLbuffer_offset = $this->current_offset;
- $this->EBMLbuffer = fread($this->getid3->fp, max($min_data, $this->getid3->fread_buffer_size()));
- $this->EBMLbuffer_length = strlen($this->EBMLbuffer);
-
- if ($this->EBMLbuffer_length == 0 && feof($this->getid3->fp)) {
- $this->getid3->info['error'][] = 'EBML parser: ran out of file at offset '.$this->current_offset;
- return false;
- }
- }
-
- return true;
- }
-
- private function readEBMLint()
- {
- $actual_offset = $this->current_offset - $this->EBMLbuffer_offset;
-
- // get length of integer
- $first_byte_int = ord($this->EBMLbuffer[$actual_offset]);
- if (0x80 & $first_byte_int) {
- $length = 1;
- } elseif (0x40 & $first_byte_int) {
- $length = 2;
- } elseif (0x20 & $first_byte_int) {
- $length = 3;
- } elseif (0x10 & $first_byte_int) {
- $length = 4;
- } elseif (0x08 & $first_byte_int) {
- $length = 5;
- } elseif (0x04 & $first_byte_int) {
- $length = 6;
- } elseif (0x02 & $first_byte_int) {
- $length = 7;
- } elseif (0x01 & $first_byte_int) {
- $length = 8;
- } else {
- throw new Exception('invalid EBML integer (leading 0x00) at '.$this->current_offset);
- }
-
- // read
- $int_value = self::EBML2Int(substr($this->EBMLbuffer, $actual_offset, $length));
- $this->current_offset += $length;
-
- return $int_value;
- }
-
- private function readEBMLelementData($length)
- {
- $data = substr($this->EBMLbuffer, $this->current_offset - $this->EBMLbuffer_offset, $length);
- $this->current_offset += $length;
-
- return $data;
- }
-
- private function getEBMLelement(&$element, $parent_end, $get_data = false)
- {
- if ($this->current_offset >= $parent_end) {
- return false;
- }
-
- if (!$this->EnsureBufferHasEnoughData()) {
- $this->current_offset = PHP_INT_MAX; // do not exit parser right now, allow to finish current loop to gather maximum information
- return false;
- }
-
- $element = array();
-
- // set offset
- $element['offset'] = $this->current_offset;
-
- // get ID
- $element['id'] = $this->readEBMLint();
-
- // get name
- $element['id_name'] = self::EBMLidName($element['id']);
-
- // get length
- $element['length'] = $this->readEBMLint();
-
- // get end offset
- $element['end'] = $this->current_offset + $element['length'];
-
- // get raw data
- $dont_parse = (in_array($element['id'], $this->unuseful_elements) || $element['id_name'] == dechex($element['id']));
- if (($get_data === true || (is_array($get_data) && !in_array($element['id'], $get_data))) && !$dont_parse) {
- $element['data'] = $this->readEBMLelementData($element['length'], $element);
- }
-
- return true;
- }
-
- private function unhandledElement($type, $line, $element)
- {
- // warn only about unknown and missed elements, not about unuseful
- if (!in_array($element['id'], $this->unuseful_elements)) {
- $this->getid3->warning('Unhandled '.$type.' element ['.basename(__FILE__).':'.$line.'] ('.$element['id'].'::'.$element['id_name'].' ['.$element['length'].' bytes]) at '.$element['offset']);
- }
-
- // increase offset for unparsed elements
- if (!isset($element['data'])) {
- $this->current_offset = $element['end'];
- }
- }
-
- private function ExtractCommentsSimpleTag($SimpleTagArray)
- {
- if (!empty($SimpleTagArray['SimpleTag'])) {
- foreach ($SimpleTagArray['SimpleTag'] as $SimpleTagKey => $SimpleTagData) {
- if (!empty($SimpleTagData['TagName']) && !empty($SimpleTagData['TagString'])) {
- $this->getid3->info['matroska']['comments'][strtolower($SimpleTagData['TagName'])][] = $SimpleTagData['TagString'];
- }
- if (!empty($SimpleTagData['SimpleTag'])) {
- $this->ExtractCommentsSimpleTag($SimpleTagData);
- }
- }
- }
-
- return true;
- }
-
- private function HandleEMBLSimpleTag($parent_end)
- {
- $simpletag_entry = array();
-
- while ($this->getEBMLelement($element, $parent_end, array(EBML_ID_SIMPLETAG))) {
- switch ($element['id']) {
-
- case EBML_ID_TAGNAME:
- case EBML_ID_TAGLANGUAGE:
- case EBML_ID_TAGSTRING:
- case EBML_ID_TAGBINARY:
- $simpletag_entry[$element['id_name']] = $element['data'];
- break;
-
- case EBML_ID_SIMPLETAG:
- $simpletag_entry[$element['id_name']][] = $this->HandleEMBLSimpleTag($element['end']);
- break;
-
- case EBML_ID_TAGDEFAULT:
- $simpletag_entry[$element['id_name']] = (bool)getid3_lib::BigEndian2Int($element['data']);
- break;
-
- default:
- $this->unhandledElement('tag.simpletag', __LINE__, $element);
- }
- }
-
- return $simpletag_entry;
- }
-
- private function HandleEMBLClusterBlock($element, $block_type, &$info)
- {
- // http://www.matroska.org/technical/specs/index.html#block_structure
- // http://www.matroska.org/technical/specs/index.html#simpleblock_structure
-
- $cluster_block_data = array();
- $cluster_block_data['tracknumber'] = $this->readEBMLint();
- $cluster_block_data['timecode'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(2));
- $cluster_block_data['flags_raw'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1));
-
- if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) {
- $cluster_block_data['flags']['keyframe'] = (($cluster_block_data['flags_raw'] & 0x80) >> 7);
- //$cluster_block_data['flags']['reserved1'] = (($cluster_block_data['flags_raw'] & 0x70) >> 4);
- }
- else {
- //$cluster_block_data['flags']['reserved1'] = (($cluster_block_data['flags_raw'] & 0xF0) >> 4);
- }
- $cluster_block_data['flags']['invisible'] = (bool)(($cluster_block_data['flags_raw'] & 0x08) >> 3);
- $cluster_block_data['flags']['lacing'] = (($cluster_block_data['flags_raw'] & 0x06) >> 1); // 00=no lacing; 01=Xiph lacing; 11=EBML lacing; 10=fixed-size lacing
- if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) {
- $cluster_block_data['flags']['discardable'] = (($cluster_block_data['flags_raw'] & 0x01));
- }
- else {
- //$cluster_block_data['flags']['reserved2'] = (($cluster_block_data['flags_raw'] & 0x01) >> 0);
- }
- $cluster_block_data['flags']['lacing_type'] = self::MatroskaBlockLacingType($cluster_block_data['flags']['lacing']);
-
- // Lace (when lacing bit is set)
- if ($cluster_block_data['flags']['lacing'] > 0) {
- $cluster_block_data['lace_frames'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1)) + 1; // Number of frames in the lace-1 (uint8)
- if ($cluster_block_data['flags']['lacing'] != 0x02) { // Lace-coded size of each frame of the lace, except for the last one (multiple uint8). *This is not used with Fixed-size lacing as it is calculated automatically from (total size of lace) / (number of frames in lace).
- for ($i = 1; $i < $cluster_block_data['lace_frames']; $i ++) {
- if ($cluster_block_data['flags']['lacing'] == 0x03) { // EBML lacing
- // TODO: read size correctly, calc size for the last frame. For now offsets are deteminded OK with readEBMLint() and that's the most important thing.
- $cluster_block_data['lace_frames_size'][$i] = $this->readEBMLint();
- }
- else { // Xiph lacing
- $cluster_block_data['lace_frames_size'][$i] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1));
- }
- }
- }
- }
-
- if (!isset($info['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']])) {
- $info['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']]['offset'] = $this->current_offset;
- $info['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']]['length'] = $element['end'] - $this->current_offset;
- }
-
- // set offset manually
- $this->current_offset = $element['end'];
-
- return $cluster_block_data;
- }
-
- private static function EBML2Int($EBMLstring) {
- // http://matroska.org/specs/
-
- // Element ID coded with an UTF-8 like system:
- // 1xxx xxxx - Class A IDs (2^7 -2 possible values) (base 0x8X)
- // 01xx xxxx xxxx xxxx - Class B IDs (2^14-2 possible values) (base 0x4X 0xXX)
- // 001x xxxx xxxx xxxx xxxx xxxx - Class C IDs (2^21-2 possible values) (base 0x2X 0xXX 0xXX)
- // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - Class D IDs (2^28-2 possible values) (base 0x1X 0xXX 0xXX 0xXX)
- // Values with all x at 0 and 1 are reserved (hence the -2).
-
- // Data size, in octets, is also coded with an UTF-8 like system :
- // 1xxx xxxx - value 0 to 2^7-2
- // 01xx xxxx xxxx xxxx - value 0 to 2^14-2
- // 001x xxxx xxxx xxxx xxxx xxxx - value 0 to 2^21-2
- // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^28-2
- // 0000 1xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^35-2
- // 0000 01xx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^42-2
- // 0000 001x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^49-2
- // 0000 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^56-2
-
- $first_byte_int = ord($EBMLstring[0]);
- if (0x80 & $first_byte_int) {
- $EBMLstring[0] = chr($first_byte_int & 0x7F);
- } elseif (0x40 & $first_byte_int) {
- $EBMLstring[0] = chr($first_byte_int & 0x3F);
- } elseif (0x20 & $first_byte_int) {
- $EBMLstring[0] = chr($first_byte_int & 0x1F);
- } elseif (0x10 & $first_byte_int) {
- $EBMLstring[0] = chr($first_byte_int & 0x0F);
- } elseif (0x08 & $first_byte_int) {
- $EBMLstring[0] = chr($first_byte_int & 0x07);
- } elseif (0x04 & $first_byte_int) {
- $EBMLstring[0] = chr($first_byte_int & 0x03);
- } elseif (0x02 & $first_byte_int) {
- $EBMLstring[0] = chr($first_byte_int & 0x01);
- } elseif (0x01 & $first_byte_int) {
- $EBMLstring[0] = chr($first_byte_int & 0x00);
- }
-
- return getid3_lib::BigEndian2Int($EBMLstring);
- }
-
- private static function EBMLdate2unix($EBMLdatestamp) {
- // Date - signed 8 octets integer in nanoseconds with 0 indicating the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC)
- // 978307200 == mktime(0, 0, 0, 1, 1, 2001) == January 1, 2001 12:00:00am UTC
- return round(($EBMLdatestamp / 1000000000) + 978307200);
- }
-
- public static function MatroskaTargetTypeValue($target_type) {
- // http://www.matroska.org/technical/specs/tagging/index.html
- static $MatroskaTargetTypeValue = array();
- if (empty($MatroskaTargetTypeValue)) {
- $MatroskaTargetTypeValue[10] = 'A: ~ V:shot'; // the lowest hierarchy found in music or movies
- $MatroskaTargetTypeValue[20] = 'A:subtrack/part/movement ~ V:scene'; // corresponds to parts of a track for audio (like a movement)
- $MatroskaTargetTypeValue[30] = 'A:track/song ~ V:chapter'; // the common parts of an album or a movie
- $MatroskaTargetTypeValue[40] = 'A:part/session ~ V:part/session'; // when an album or episode has different logical parts
- $MatroskaTargetTypeValue[50] = 'A:album/opera/concert ~ V:movie/episode/concert'; // the most common grouping level of music and video (equals to an episode for TV series)
- $MatroskaTargetTypeValue[60] = 'A:edition/issue/volume/opus ~ V:season/sequel/volume'; // a list of lower levels grouped together
- $MatroskaTargetTypeValue[70] = 'A:collection ~ V:collection'; // the high hierarchy consisting of many different lower items
- }
- return (isset($MatroskaTargetTypeValue[$target_type]) ? $MatroskaTargetTypeValue[$target_type] : $target_type);
- }
-
- public static function MatroskaBlockLacingType($lacingtype) {
- // http://matroska.org/technical/specs/index.html#block_structure
- static $MatroskaBlockLacingType = array();
- if (empty($MatroskaBlockLacingType)) {
- $MatroskaBlockLacingType[0x00] = 'no lacing';
- $MatroskaBlockLacingType[0x01] = 'Xiph lacing';
- $MatroskaBlockLacingType[0x02] = 'fixed-size lacing';
- $MatroskaBlockLacingType[0x03] = 'EBML lacing';
- }
- return (isset($MatroskaBlockLacingType[$lacingtype]) ? $MatroskaBlockLacingType[$lacingtype] : $lacingtype);
- }
-
- public static function MatroskaCodecIDtoCommonName($codecid) {
- // http://www.matroska.org/technical/specs/codecid/index.html
- static $MatroskaCodecIDlist = array();
- if (empty($MatroskaCodecIDlist)) {
- $MatroskaCodecIDlist['A_AAC'] = 'aac';
- $MatroskaCodecIDlist['A_AAC/MPEG2/LC'] = 'aac';
- $MatroskaCodecIDlist['A_AC3'] = 'ac3';
- $MatroskaCodecIDlist['A_DTS'] = 'dts';
- $MatroskaCodecIDlist['A_FLAC'] = 'flac';
- $MatroskaCodecIDlist['A_MPEG/L1'] = 'mp1';
- $MatroskaCodecIDlist['A_MPEG/L2'] = 'mp2';
- $MatroskaCodecIDlist['A_MPEG/L3'] = 'mp3';
- $MatroskaCodecIDlist['A_PCM/INT/LIT'] = 'pcm'; // PCM Integer Little Endian
- $MatroskaCodecIDlist['A_PCM/INT/BIG'] = 'pcm'; // PCM Integer Big Endian
- $MatroskaCodecIDlist['A_QUICKTIME/QDMC'] = 'quicktime'; // Quicktime: QDesign Music
- $MatroskaCodecIDlist['A_QUICKTIME/QDM2'] = 'quicktime'; // Quicktime: QDesign Music v2
- $MatroskaCodecIDlist['A_VORBIS'] = 'vorbis';
- $MatroskaCodecIDlist['V_MPEG1'] = 'mpeg';
- $MatroskaCodecIDlist['V_THEORA'] = 'theora';
- $MatroskaCodecIDlist['V_REAL/RV40'] = 'real';
- $MatroskaCodecIDlist['V_REAL/RV10'] = 'real';
- $MatroskaCodecIDlist['V_REAL/RV20'] = 'real';
- $MatroskaCodecIDlist['V_REAL/RV30'] = 'real';
- $MatroskaCodecIDlist['V_QUICKTIME'] = 'quicktime'; // Quicktime
- $MatroskaCodecIDlist['V_MPEG4/ISO/AP'] = 'mpeg4';
- $MatroskaCodecIDlist['V_MPEG4/ISO/ASP'] = 'mpeg4';
- $MatroskaCodecIDlist['V_MPEG4/ISO/AVC'] = 'h264';
- $MatroskaCodecIDlist['V_MPEG4/ISO/SP'] = 'mpeg4';
- $MatroskaCodecIDlist['V_VP8'] = 'vp8';
- $MatroskaCodecIDlist['V_MS/VFW/FOURCC'] = 'riff';
- $MatroskaCodecIDlist['A_MS/ACM'] = 'riff';
- }
- return (isset($MatroskaCodecIDlist[$codecid]) ? $MatroskaCodecIDlist[$codecid] : $codecid);
- }
-
- private static function EBMLidName($value) {
- static $EBMLidList = array();
- if (empty($EBMLidList)) {
- $EBMLidList[EBML_ID_ASPECTRATIOTYPE] = 'AspectRatioType';
- $EBMLidList[EBML_ID_ATTACHEDFILE] = 'AttachedFile';
- $EBMLidList[EBML_ID_ATTACHMENTLINK] = 'AttachmentLink';
- $EBMLidList[EBML_ID_ATTACHMENTS] = 'Attachments';
- $EBMLidList[EBML_ID_AUDIO] = 'Audio';
- $EBMLidList[EBML_ID_BITDEPTH] = 'BitDepth';
- $EBMLidList[EBML_ID_CHANNELPOSITIONS] = 'ChannelPositions';
- $EBMLidList[EBML_ID_CHANNELS] = 'Channels';
- $EBMLidList[EBML_ID_CHAPCOUNTRY] = 'ChapCountry';
- $EBMLidList[EBML_ID_CHAPLANGUAGE] = 'ChapLanguage';
- $EBMLidList[EBML_ID_CHAPPROCESS] = 'ChapProcess';
- $EBMLidList[EBML_ID_CHAPPROCESSCODECID] = 'ChapProcessCodecID';
- $EBMLidList[EBML_ID_CHAPPROCESSCOMMAND] = 'ChapProcessCommand';
- $EBMLidList[EBML_ID_CHAPPROCESSDATA] = 'ChapProcessData';
- $EBMLidList[EBML_ID_CHAPPROCESSPRIVATE] = 'ChapProcessPrivate';
- $EBMLidList[EBML_ID_CHAPPROCESSTIME] = 'ChapProcessTime';
- $EBMLidList[EBML_ID_CHAPSTRING] = 'ChapString';
- $EBMLidList[EBML_ID_CHAPTERATOM] = 'ChapterAtom';
- $EBMLidList[EBML_ID_CHAPTERDISPLAY] = 'ChapterDisplay';
- $EBMLidList[EBML_ID_CHAPTERFLAGENABLED] = 'ChapterFlagEnabled';
- $EBMLidList[EBML_ID_CHAPTERFLAGHIDDEN] = 'ChapterFlagHidden';
- $EBMLidList[EBML_ID_CHAPTERPHYSICALEQUIV] = 'ChapterPhysicalEquiv';
- $EBMLidList[EBML_ID_CHAPTERS] = 'Chapters';
- $EBMLidList[EBML_ID_CHAPTERSEGMENTEDITIONUID] = 'ChapterSegmentEditionUID';
- $EBMLidList[EBML_ID_CHAPTERSEGMENTUID] = 'ChapterSegmentUID';
- $EBMLidList[EBML_ID_CHAPTERTIMEEND] = 'ChapterTimeEnd';
- $EBMLidList[EBML_ID_CHAPTERTIMESTART] = 'ChapterTimeStart';
- $EBMLidList[EBML_ID_CHAPTERTRACK] = 'ChapterTrack';
- $EBMLidList[EBML_ID_CHAPTERTRACKNUMBER] = 'ChapterTrackNumber';
- $EBMLidList[EBML_ID_CHAPTERTRANSLATE] = 'ChapterTranslate';
- $EBMLidList[EBML_ID_CHAPTERTRANSLATECODEC] = 'ChapterTranslateCodec';
- $EBMLidList[EBML_ID_CHAPTERTRANSLATEEDITIONUID] = 'ChapterTranslateEditionUID';
- $EBMLidList[EBML_ID_CHAPTERTRANSLATEID] = 'ChapterTranslateID';
- $EBMLidList[EBML_ID_CHAPTERUID] = 'ChapterUID';
- $EBMLidList[EBML_ID_CLUSTER] = 'Cluster';
- $EBMLidList[EBML_ID_CLUSTERBLOCK] = 'ClusterBlock';
- $EBMLidList[EBML_ID_CLUSTERBLOCKADDID] = 'ClusterBlockAddID';
- $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONAL] = 'ClusterBlockAdditional';
- $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONID] = 'ClusterBlockAdditionID';
- $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONS] = 'ClusterBlockAdditions';
- $EBMLidList[EBML_ID_CLUSTERBLOCKDURATION] = 'ClusterBlockDuration';
- $EBMLidList[EBML_ID_CLUSTERBLOCKGROUP] = 'ClusterBlockGroup';
- $EBMLidList[EBML_ID_CLUSTERBLOCKMORE] = 'ClusterBlockMore';
- $EBMLidList[EBML_ID_CLUSTERBLOCKVIRTUAL] = 'ClusterBlockVirtual';
- $EBMLidList[EBML_ID_CLUSTERCODECSTATE] = 'ClusterCodecState';
- $EBMLidList[EBML_ID_CLUSTERDELAY] = 'ClusterDelay';
- $EBMLidList[EBML_ID_CLUSTERDURATION] = 'ClusterDuration';
- $EBMLidList[EBML_ID_CLUSTERENCRYPTEDBLOCK] = 'ClusterEncryptedBlock';
- $EBMLidList[EBML_ID_CLUSTERFRAMENUMBER] = 'ClusterFrameNumber';
- $EBMLidList[EBML_ID_CLUSTERLACENUMBER] = 'ClusterLaceNumber';
- $EBMLidList[EBML_ID_CLUSTERPOSITION] = 'ClusterPosition';
- $EBMLidList[EBML_ID_CLUSTERPREVSIZE] = 'ClusterPrevSize';
- $EBMLidList[EBML_ID_CLUSTERREFERENCEBLOCK] = 'ClusterReferenceBlock';
- $EBMLidList[EBML_ID_CLUSTERREFERENCEPRIORITY] = 'ClusterReferencePriority';
- $EBMLidList[EBML_ID_CLUSTERREFERENCEVIRTUAL] = 'ClusterReferenceVirtual';
- $EBMLidList[EBML_ID_CLUSTERSILENTTRACKNUMBER] = 'ClusterSilentTrackNumber';
- $EBMLidList[EBML_ID_CLUSTERSILENTTRACKS] = 'ClusterSilentTracks';
- $EBMLidList[EBML_ID_CLUSTERSIMPLEBLOCK] = 'ClusterSimpleBlock';
- $EBMLidList[EBML_ID_CLUSTERTIMECODE] = 'ClusterTimecode';
- $EBMLidList[EBML_ID_CLUSTERTIMESLICE] = 'ClusterTimeSlice';
- $EBMLidList[EBML_ID_CODECDECODEALL] = 'CodecDecodeAll';
- $EBMLidList[EBML_ID_CODECDOWNLOADURL] = 'CodecDownloadURL';
- $EBMLidList[EBML_ID_CODECID] = 'CodecID';
- $EBMLidList[EBML_ID_CODECINFOURL] = 'CodecInfoURL';
- $EBMLidList[EBML_ID_CODECNAME] = 'CodecName';
- $EBMLidList[EBML_ID_CODECPRIVATE] = 'CodecPrivate';
- $EBMLidList[EBML_ID_CODECSETTINGS] = 'CodecSettings';
- $EBMLidList[EBML_ID_COLOURSPACE] = 'ColourSpace';
- $EBMLidList[EBML_ID_CONTENTCOMPALGO] = 'ContentCompAlgo';
- $EBMLidList[EBML_ID_CONTENTCOMPRESSION] = 'ContentCompression';
- $EBMLidList[EBML_ID_CONTENTCOMPSETTINGS] = 'ContentCompSettings';
- $EBMLidList[EBML_ID_CONTENTENCALGO] = 'ContentEncAlgo';
- $EBMLidList[EBML_ID_CONTENTENCKEYID] = 'ContentEncKeyID';
- $EBMLidList[EBML_ID_CONTENTENCODING] = 'ContentEncoding';
- $EBMLidList[EBML_ID_CONTENTENCODINGORDER] = 'ContentEncodingOrder';
- $EBMLidList[EBML_ID_CONTENTENCODINGS] = 'ContentEncodings';
- $EBMLidList[EBML_ID_CONTENTENCODINGSCOPE] = 'ContentEncodingScope';
- $EBMLidList[EBML_ID_CONTENTENCODINGTYPE] = 'ContentEncodingType';
- $EBMLidList[EBML_ID_CONTENTENCRYPTION] = 'ContentEncryption';
- $EBMLidList[EBML_ID_CONTENTSIGALGO] = 'ContentSigAlgo';
- $EBMLidList[EBML_ID_CONTENTSIGHASHALGO] = 'ContentSigHashAlgo';
- $EBMLidList[EBML_ID_CONTENTSIGKEYID] = 'ContentSigKeyID';
- $EBMLidList[EBML_ID_CONTENTSIGNATURE] = 'ContentSignature';
- $EBMLidList[EBML_ID_CRC32] = 'CRC32';
- $EBMLidList[EBML_ID_CUEBLOCKNUMBER] = 'CueBlockNumber';
- $EBMLidList[EBML_ID_CUECLUSTERPOSITION] = 'CueClusterPosition';
- $EBMLidList[EBML_ID_CUECODECSTATE] = 'CueCodecState';
- $EBMLidList[EBML_ID_CUEPOINT] = 'CuePoint';
- $EBMLidList[EBML_ID_CUEREFCLUSTER] = 'CueRefCluster';
- $EBMLidList[EBML_ID_CUEREFCODECSTATE] = 'CueRefCodecState';
- $EBMLidList[EBML_ID_CUEREFERENCE] = 'CueReference';
- $EBMLidList[EBML_ID_CUEREFNUMBER] = 'CueRefNumber';
- $EBMLidList[EBML_ID_CUEREFTIME] = 'CueRefTime';
- $EBMLidList[EBML_ID_CUES] = 'Cues';
- $EBMLidList[EBML_ID_CUETIME] = 'CueTime';
- $EBMLidList[EBML_ID_CUETRACK] = 'CueTrack';
- $EBMLidList[EBML_ID_CUETRACKPOSITIONS] = 'CueTrackPositions';
- $EBMLidList[EBML_ID_DATEUTC] = 'DateUTC';
- $EBMLidList[EBML_ID_DEFAULTDURATION] = 'DefaultDuration';
- $EBMLidList[EBML_ID_DISPLAYHEIGHT] = 'DisplayHeight';
- $EBMLidList[EBML_ID_DISPLAYUNIT] = 'DisplayUnit';
- $EBMLidList[EBML_ID_DISPLAYWIDTH] = 'DisplayWidth';
- $EBMLidList[EBML_ID_DOCTYPE] = 'DocType';
- $EBMLidList[EBML_ID_DOCTYPEREADVERSION] = 'DocTypeReadVersion';
- $EBMLidList[EBML_ID_DOCTYPEVERSION] = 'DocTypeVersion';
- $EBMLidList[EBML_ID_DURATION] = 'Duration';
- $EBMLidList[EBML_ID_EBML] = 'EBML';
- $EBMLidList[EBML_ID_EBMLMAXIDLENGTH] = 'EBMLMaxIDLength';
- $EBMLidList[EBML_ID_EBMLMAXSIZELENGTH] = 'EBMLMaxSizeLength';
- $EBMLidList[EBML_ID_EBMLREADVERSION] = 'EBMLReadVersion';
- $EBMLidList[EBML_ID_EBMLVERSION] = 'EBMLVersion';
- $EBMLidList[EBML_ID_EDITIONENTRY] = 'EditionEntry';
- $EBMLidList[EBML_ID_EDITIONFLAGDEFAULT] = 'EditionFlagDefault';
- $EBMLidList[EBML_ID_EDITIONFLAGHIDDEN] = 'EditionFlagHidden';
- $EBMLidList[EBML_ID_EDITIONFLAGORDERED] = 'EditionFlagOrdered';
- $EBMLidList[EBML_ID_EDITIONUID] = 'EditionUID';
- $EBMLidList[EBML_ID_FILEDATA] = 'FileData';
- $EBMLidList[EBML_ID_FILEDESCRIPTION] = 'FileDescription';
- $EBMLidList[EBML_ID_FILEMIMETYPE] = 'FileMimeType';
- $EBMLidList[EBML_ID_FILENAME] = 'FileName';
- $EBMLidList[EBML_ID_FILEREFERRAL] = 'FileReferral';
- $EBMLidList[EBML_ID_FILEUID] = 'FileUID';
- $EBMLidList[EBML_ID_FLAGDEFAULT] = 'FlagDefault';
- $EBMLidList[EBML_ID_FLAGENABLED] = 'FlagEnabled';
- $EBMLidList[EBML_ID_FLAGFORCED] = 'FlagForced';
- $EBMLidList[EBML_ID_FLAGINTERLACED] = 'FlagInterlaced';
- $EBMLidList[EBML_ID_FLAGLACING] = 'FlagLacing';
- $EBMLidList[EBML_ID_GAMMAVALUE] = 'GammaValue';
- $EBMLidList[EBML_ID_INFO] = 'Info';
- $EBMLidList[EBML_ID_LANGUAGE] = 'Language';
- $EBMLidList[EBML_ID_MAXBLOCKADDITIONID] = 'MaxBlockAdditionID';
- $EBMLidList[EBML_ID_MAXCACHE] = 'MaxCache';
- $EBMLidList[EBML_ID_MINCACHE] = 'MinCache';
- $EBMLidList[EBML_ID_MUXINGAPP] = 'MuxingApp';
- $EBMLidList[EBML_ID_NAME] = 'Name';
- $EBMLidList[EBML_ID_NEXTFILENAME] = 'NextFilename';
- $EBMLidList[EBML_ID_NEXTUID] = 'NextUID';
- $EBMLidList[EBML_ID_OUTPUTSAMPLINGFREQUENCY] = 'OutputSamplingFrequency';
- $EBMLidList[EBML_ID_PIXELCROPBOTTOM] = 'PixelCropBottom';
- $EBMLidList[EBML_ID_PIXELCROPLEFT] = 'PixelCropLeft';
- $EBMLidList[EBML_ID_PIXELCROPRIGHT] = 'PixelCropRight';
- $EBMLidList[EBML_ID_PIXELCROPTOP] = 'PixelCropTop';
- $EBMLidList[EBML_ID_PIXELHEIGHT] = 'PixelHeight';
- $EBMLidList[EBML_ID_PIXELWIDTH] = 'PixelWidth';
- $EBMLidList[EBML_ID_PREVFILENAME] = 'PrevFilename';
- $EBMLidList[EBML_ID_PREVUID] = 'PrevUID';
- $EBMLidList[EBML_ID_SAMPLINGFREQUENCY] = 'SamplingFrequency';
- $EBMLidList[EBML_ID_SEEK] = 'Seek';
- $EBMLidList[EBML_ID_SEEKHEAD] = 'SeekHead';
- $EBMLidList[EBML_ID_SEEKID] = 'SeekID';
- $EBMLidList[EBML_ID_SEEKPOSITION] = 'SeekPosition';
- $EBMLidList[EBML_ID_SEGMENT] = 'Segment';
- $EBMLidList[EBML_ID_SEGMENTFAMILY] = 'SegmentFamily';
- $EBMLidList[EBML_ID_SEGMENTFILENAME] = 'SegmentFilename';
- $EBMLidList[EBML_ID_SEGMENTUID] = 'SegmentUID';
- $EBMLidList[EBML_ID_SIMPLETAG] = 'SimpleTag';
- $EBMLidList[EBML_ID_CLUSTERSLICES] = 'ClusterSlices';
- $EBMLidList[EBML_ID_STEREOMODE] = 'StereoMode';
- $EBMLidList[EBML_ID_TAG] = 'Tag';
- $EBMLidList[EBML_ID_TAGATTACHMENTUID] = 'TagAttachmentUID';
- $EBMLidList[EBML_ID_TAGBINARY] = 'TagBinary';
- $EBMLidList[EBML_ID_TAGCHAPTERUID] = 'TagChapterUID';
- $EBMLidList[EBML_ID_TAGDEFAULT] = 'TagDefault';
- $EBMLidList[EBML_ID_TAGEDITIONUID] = 'TagEditionUID';
- $EBMLidList[EBML_ID_TAGLANGUAGE] = 'TagLanguage';
- $EBMLidList[EBML_ID_TAGNAME] = 'TagName';
- $EBMLidList[EBML_ID_TAGTRACKUID] = 'TagTrackUID';
- $EBMLidList[EBML_ID_TAGS] = 'Tags';
- $EBMLidList[EBML_ID_TAGSTRING] = 'TagString';
- $EBMLidList[EBML_ID_TARGETS] = 'Targets';
- $EBMLidList[EBML_ID_TARGETTYPE] = 'TargetType';
- $EBMLidList[EBML_ID_TARGETTYPEVALUE] = 'TargetTypeValue';
- $EBMLidList[EBML_ID_TIMECODESCALE] = 'TimecodeScale';
- $EBMLidList[EBML_ID_TITLE] = 'Title';
- $EBMLidList[EBML_ID_TRACKENTRY] = 'TrackEntry';
- $EBMLidList[EBML_ID_TRACKNUMBER] = 'TrackNumber';
- $EBMLidList[EBML_ID_TRACKOFFSET] = 'TrackOffset';
- $EBMLidList[EBML_ID_TRACKOVERLAY] = 'TrackOverlay';
- $EBMLidList[EBML_ID_TRACKS] = 'Tracks';
- $EBMLidList[EBML_ID_TRACKTIMECODESCALE] = 'TrackTimecodeScale';
- $EBMLidList[EBML_ID_TRACKTRANSLATE] = 'TrackTranslate';
- $EBMLidList[EBML_ID_TRACKTRANSLATECODEC] = 'TrackTranslateCodec';
- $EBMLidList[EBML_ID_TRACKTRANSLATEEDITIONUID] = 'TrackTranslateEditionUID';
- $EBMLidList[EBML_ID_TRACKTRANSLATETRACKID] = 'TrackTranslateTrackID';
- $EBMLidList[EBML_ID_TRACKTYPE] = 'TrackType';
- $EBMLidList[EBML_ID_TRACKUID] = 'TrackUID';
- $EBMLidList[EBML_ID_VIDEO] = 'Video';
- $EBMLidList[EBML_ID_VOID] = 'Void';
- $EBMLidList[EBML_ID_WRITINGAPP] = 'WritingApp';
- }
-
- return (isset($EBMLidList[$value]) ? $EBMLidList[$value] : dechex($value));
- }
-
- private static function getDefaultStreamInfo($streams)
- {
- foreach (array_reverse($streams) as $stream) {
- if ($stream['default']) {
- break;
- }
- }
- unset($stream['default']);
- if (isset($stream['name'])) {
- unset($stream['name']);
- }
-
- $info = $stream;
- $info['streams'] = $streams;
-
- return $info;
- }
-
-}
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.audio-video.mpeg.php b/app/library/getid3/module.audio-video.mpeg.php
deleted file mode 100644
index 499b740c..00000000
--- a/app/library/getid3/module.audio-video.mpeg.php
+++ /dev/null
@@ -1,299 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio-video.mpeg.php //
-// module for analyzing MPEG files //
-// dependencies: module.audio.mp3.php //
-// ///
-/////////////////////////////////////////////////////////////////
-
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
-
-define('GETID3_MPEG_VIDEO_PICTURE_START', "\x00\x00\x01\x00");
-define('GETID3_MPEG_VIDEO_USER_DATA_START', "\x00\x00\x01\xB2");
-define('GETID3_MPEG_VIDEO_SEQUENCE_HEADER', "\x00\x00\x01\xB3");
-define('GETID3_MPEG_VIDEO_SEQUENCE_ERROR', "\x00\x00\x01\xB4");
-define('GETID3_MPEG_VIDEO_EXTENSION_START', "\x00\x00\x01\xB5");
-define('GETID3_MPEG_VIDEO_SEQUENCE_END', "\x00\x00\x01\xB7");
-define('GETID3_MPEG_VIDEO_GROUP_START', "\x00\x00\x01\xB8");
-define('GETID3_MPEG_AUDIO_START', "\x00\x00\x01\xC0");
-
-
-class getid3_mpeg extends getid3_handler
-{
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- if ($info['avdataend'] <= $info['avdataoffset']) {
- $info['error'][] = '"avdataend" ('.$info['avdataend'].') is unexpectedly less-than-or-equal-to "avdataoffset" ('.$info['avdataoffset'].')';
- return false;
- }
- $info['fileformat'] = 'mpeg';
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
- $MPEGstreamData = fread($this->getid3->fp, min(100000, $info['avdataend'] - $info['avdataoffset']));
- $MPEGstreamDataLength = strlen($MPEGstreamData);
-
- $foundVideo = true;
- $VideoChunkOffset = 0;
- while (substr($MPEGstreamData, $VideoChunkOffset++, 4) !== GETID3_MPEG_VIDEO_SEQUENCE_HEADER) {
- if ($VideoChunkOffset >= $MPEGstreamDataLength) {
- $foundVideo = false;
- break;
- }
- }
- if ($foundVideo) {
-
- // Start code 32 bits
- // horizontal frame size 12 bits
- // vertical frame size 12 bits
- // pixel aspect ratio 4 bits
- // frame rate 4 bits
- // bitrate 18 bits
- // marker bit 1 bit
- // VBV buffer size 10 bits
- // constrained parameter flag 1 bit
- // intra quant. matrix flag 1 bit
- // intra quant. matrix values 512 bits (present if matrix flag == 1)
- // non-intra quant. matrix flag 1 bit
- // non-intra quant. matrix values 512 bits (present if matrix flag == 1)
-
- $info['video']['dataformat'] = 'mpeg';
-
- $VideoChunkOffset += (strlen(GETID3_MPEG_VIDEO_SEQUENCE_HEADER) - 1);
-
- $FrameSizeDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 3));
- $VideoChunkOffset += 3;
-
- $AspectRatioFrameRateDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 1));
- $VideoChunkOffset += 1;
-
- $assortedinformation = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 4));
- $VideoChunkOffset += 4;
-
- $info['mpeg']['video']['raw']['framesize_horizontal'] = ($FrameSizeDWORD & 0xFFF000) >> 12; // 12 bits for horizontal frame size
- $info['mpeg']['video']['raw']['framesize_vertical'] = ($FrameSizeDWORD & 0x000FFF); // 12 bits for vertical frame size
- $info['mpeg']['video']['raw']['pixel_aspect_ratio'] = ($AspectRatioFrameRateDWORD & 0xF0) >> 4;
- $info['mpeg']['video']['raw']['frame_rate'] = ($AspectRatioFrameRateDWORD & 0x0F);
-
- $info['mpeg']['video']['framesize_horizontal'] = $info['mpeg']['video']['raw']['framesize_horizontal'];
- $info['mpeg']['video']['framesize_vertical'] = $info['mpeg']['video']['raw']['framesize_vertical'];
-
- $info['mpeg']['video']['pixel_aspect_ratio'] = $this->MPEGvideoAspectRatioLookup($info['mpeg']['video']['raw']['pixel_aspect_ratio']);
- $info['mpeg']['video']['pixel_aspect_ratio_text'] = $this->MPEGvideoAspectRatioTextLookup($info['mpeg']['video']['raw']['pixel_aspect_ratio']);
- $info['mpeg']['video']['frame_rate'] = $this->MPEGvideoFramerateLookup($info['mpeg']['video']['raw']['frame_rate']);
-
- $info['mpeg']['video']['raw']['bitrate'] = getid3_lib::Bin2Dec(substr($assortedinformation, 0, 18));
- $info['mpeg']['video']['raw']['marker_bit'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 18, 1));
- $info['mpeg']['video']['raw']['vbv_buffer_size'] = getid3_lib::Bin2Dec(substr($assortedinformation, 19, 10));
- $info['mpeg']['video']['raw']['constrained_param_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 29, 1));
- $info['mpeg']['video']['raw']['intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 30, 1));
- if ($info['mpeg']['video']['raw']['intra_quant_flag']) {
-
- // read 512 bits
- $info['mpeg']['video']['raw']['intra_quant'] = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64));
- $VideoChunkOffset += 64;
-
- $info['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($info['mpeg']['video']['raw']['intra_quant'], 511, 1));
- $info['mpeg']['video']['raw']['intra_quant'] = getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1)).substr(getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64)), 0, 511);
-
- if ($info['mpeg']['video']['raw']['non_intra_quant_flag']) {
- $info['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
- $VideoChunkOffset += 64;
- }
-
- } else {
-
- $info['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1));
- if ($info['mpeg']['video']['raw']['non_intra_quant_flag']) {
- $info['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
- $VideoChunkOffset += 64;
- }
-
- }
-
- if ($info['mpeg']['video']['raw']['bitrate'] == 0x3FFFF) { // 18 set bits
-
- $info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] cannot determine average bitrate of VBR MPEG video files';
- $info['mpeg']['video']['bitrate_mode'] = 'vbr';
-
- } else {
-
- $info['mpeg']['video']['bitrate'] = $info['mpeg']['video']['raw']['bitrate'] * 400;
- $info['mpeg']['video']['bitrate_mode'] = 'cbr';
- $info['video']['bitrate'] = $info['mpeg']['video']['bitrate'];
-
- }
-
- $info['video']['resolution_x'] = $info['mpeg']['video']['framesize_horizontal'];
- $info['video']['resolution_y'] = $info['mpeg']['video']['framesize_vertical'];
- $info['video']['frame_rate'] = $info['mpeg']['video']['frame_rate'];
- $info['video']['bitrate_mode'] = $info['mpeg']['video']['bitrate_mode'];
- $info['video']['pixel_aspect_ratio'] = $info['mpeg']['video']['pixel_aspect_ratio'];
- $info['video']['lossless'] = false;
- $info['video']['bits_per_sample'] = 24;
-
- } else {
-
- $info['error'][] = 'Could not find start of video block in the first 100,000 bytes (or before end of file) - this might not be an MPEG-video file?';
-
- }
-
- //0x000001B3 begins the sequence_header of every MPEG video stream.
- //But in MPEG-2, this header must immediately be followed by an
- //extension_start_code (0x000001B5) with a sequence_extension ID (1).
- //(This extension contains all the additional MPEG-2 stuff.)
- //MPEG-1 doesn't have this extension, so that's a sure way to tell the
- //difference between MPEG-1 and MPEG-2 video streams.
-
- if (substr($MPEGstreamData, $VideoChunkOffset, 4) == GETID3_MPEG_VIDEO_EXTENSION_START) {
- $info['video']['codec'] = 'MPEG-2';
- } else {
- $info['video']['codec'] = 'MPEG-1';
- }
-
-
- $AudioChunkOffset = 0;
- while (true) {
- while (substr($MPEGstreamData, $AudioChunkOffset++, 4) !== GETID3_MPEG_AUDIO_START) {
- if ($AudioChunkOffset >= $MPEGstreamDataLength) {
- break 2;
- }
- }
-
- $getid3_temp = new getID3();
- $getid3_temp->openfile($this->getid3->filename);
- $getid3_temp->info = $info;
- $getid3_mp3 = new getid3_mp3($getid3_temp);
- for ($i = 0; $i <= 7; $i++) {
- // some files have the MPEG-audio header 8 bytes after the end of the $00 $00 $01 $C0 signature, some have it up to 13 bytes (or more?) after
- // I have no idea why or what the difference is, so this is a stupid hack.
- // If anybody has any better idea of what's going on, please let me know - info@getid3.org
- fseek($getid3_temp->fp, ftell($this->getid3->fp), SEEK_SET);
- $getid3_temp->info = $info; // only overwrite real data if valid header found
- if ($getid3_mp3->decodeMPEGaudioHeader(($AudioChunkOffset + 3) + 8 + $i, $getid3_temp->info, false)) {
- $info = $getid3_temp->info;
- $info['audio']['bitrate_mode'] = 'cbr';
- $info['audio']['lossless'] = false;
- unset($getid3_temp, $getid3_mp3);
- break 2;
- }
- }
- unset($getid3_temp, $getid3_mp3);
- }
-
- // Temporary hack to account for interleaving overhead:
- if (!empty($info['video']['bitrate']) && !empty($info['audio']['bitrate'])) {
- $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['video']['bitrate'] + $info['audio']['bitrate']);
-
- // Interleaved MPEG audio/video files have a certain amount of overhead that varies
- // by both video and audio bitrates, and not in any sensible, linear/logarithmic patter
- // Use interpolated lookup tables to approximately guess how much is overhead, because
- // playtime is calculated as filesize / total-bitrate
- $info['playtime_seconds'] *= $this->MPEGsystemNonOverheadPercentage($info['video']['bitrate'], $info['audio']['bitrate']);
-
- //switch ($info['video']['bitrate']) {
- // case('5000000'):
- // $multiplier = 0.93292642112380355828048824319889;
- // break;
- // case('5500000'):
- // $multiplier = 0.93582895375200989965359777343219;
- // break;
- // case('6000000'):
- // $multiplier = 0.93796247714820932532911373859139;
- // break;
- // case('7000000'):
- // $multiplier = 0.9413264083635103463010117778776;
- // break;
- // default:
- // $multiplier = 1;
- // break;
- //}
- //$info['playtime_seconds'] *= $multiplier;
- //$info['warning'][] = 'Interleaved MPEG audio/video playtime may be inaccurate. With current hack should be within a few seconds of accurate. Report to info@getid3.org if off by more than 10 seconds.';
- if ($info['video']['bitrate'] < 50000) {
- $info['warning'][] = 'Interleaved MPEG audio/video playtime may be slightly inaccurate for video bitrates below 100kbps. Except in extreme low-bitrate situations, error should be less than 1%. Report to info@getid3.org if greater than this.';
- }
- }
-
- return true;
- }
-
-
- function MPEGsystemNonOverheadPercentage($VideoBitrate, $AudioBitrate) {
- $OverheadPercentage = 0;
-
- $AudioBitrate = max(min($AudioBitrate / 1000, 384), 32); // limit to range of 32kbps - 384kbps (should be only legal bitrates, but maybe VBR?)
- $VideoBitrate = max(min($VideoBitrate / 1000, 10000), 10); // limit to range of 10kbps - 10Mbps (beyond that curves flatten anyways, no big loss)
-
-
- //OMBB[audiobitrate] = array(video-10kbps, video-100kbps, video-1000kbps, video-10000kbps)
- $OverheadMultiplierByBitrate[32] = array(0, 0.9676287944368530, 0.9802276264360310, 0.9844916183244460, 0.9852821845179940);
- $OverheadMultiplierByBitrate[48] = array(0, 0.9779100089209830, 0.9787770035359320, 0.9846738664076130, 0.9852683013799960);
- $OverheadMultiplierByBitrate[56] = array(0, 0.9731249855367600, 0.9776624308938040, 0.9832606361852130, 0.9843922606633340);
- $OverheadMultiplierByBitrate[64] = array(0, 0.9755642683275760, 0.9795256705493390, 0.9836573009193170, 0.9851122539404470);
- $OverheadMultiplierByBitrate[96] = array(0, 0.9788025247497290, 0.9798553314148700, 0.9822956869792560, 0.9834815119124690);
- $OverheadMultiplierByBitrate[128] = array(0, 0.9816940050925480, 0.9821675936072120, 0.9829756927470870, 0.9839763420152050);
- $OverheadMultiplierByBitrate[160] = array(0, 0.9825894094561180, 0.9820913399073960, 0.9823907143253970, 0.9832821783651570);
- $OverheadMultiplierByBitrate[192] = array(0, 0.9832038474336260, 0.9825731694317960, 0.9821028622712400, 0.9828262076447620);
- $OverheadMultiplierByBitrate[224] = array(0, 0.9836516298538770, 0.9824718601823890, 0.9818302180625380, 0.9823735101626480);
- $OverheadMultiplierByBitrate[256] = array(0, 0.9845863022094920, 0.9837229411967540, 0.9824521662210830, 0.9828645172100790);
- $OverheadMultiplierByBitrate[320] = array(0, 0.9849565280263180, 0.9837683142805110, 0.9822885275960400, 0.9824424382727190);
- $OverheadMultiplierByBitrate[384] = array(0, 0.9856094774357600, 0.9844573394432720, 0.9825970399837330, 0.9824673808303890);
-
- $BitrateToUseMin = 32;
- $BitrateToUseMax = 32;
- $previousBitrate = 32;
- foreach ($OverheadMultiplierByBitrate as $key => $value) {
- if ($AudioBitrate >= $previousBitrate) {
- $BitrateToUseMin = $previousBitrate;
- }
- if ($AudioBitrate < $key) {
- $BitrateToUseMax = $key;
- break;
- }
- $previousBitrate = $key;
- }
- $FactorA = ($BitrateToUseMax - $AudioBitrate) / ($BitrateToUseMax - $BitrateToUseMin);
-
- $VideoBitrateLog10 = log10($VideoBitrate);
- $VideoFactorMin1 = $OverheadMultiplierByBitrate[$BitrateToUseMin][floor($VideoBitrateLog10)];
- $VideoFactorMin2 = $OverheadMultiplierByBitrate[$BitrateToUseMax][floor($VideoBitrateLog10)];
- $VideoFactorMax1 = $OverheadMultiplierByBitrate[$BitrateToUseMin][ceil($VideoBitrateLog10)];
- $VideoFactorMax2 = $OverheadMultiplierByBitrate[$BitrateToUseMax][ceil($VideoBitrateLog10)];
- $FactorV = $VideoBitrateLog10 - floor($VideoBitrateLog10);
-
- $OverheadPercentage = $VideoFactorMin1 * $FactorA * $FactorV;
- $OverheadPercentage += $VideoFactorMin2 * (1 - $FactorA) * $FactorV;
- $OverheadPercentage += $VideoFactorMax1 * $FactorA * (1 - $FactorV);
- $OverheadPercentage += $VideoFactorMax2 * (1 - $FactorA) * (1 - $FactorV);
-
- return $OverheadPercentage;
- }
-
-
- function MPEGvideoFramerateLookup($rawframerate) {
- $MPEGvideoFramerateLookup = array(0, 23.976, 24, 25, 29.97, 30, 50, 59.94, 60);
- return (isset($MPEGvideoFramerateLookup[$rawframerate]) ? (float) $MPEGvideoFramerateLookup[$rawframerate] : (float) 0);
- }
-
- function MPEGvideoAspectRatioLookup($rawaspectratio) {
- $MPEGvideoAspectRatioLookup = array(0, 1, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, 1.2015, 0);
- return (isset($MPEGvideoAspectRatioLookup[$rawaspectratio]) ? (float) $MPEGvideoAspectRatioLookup[$rawaspectratio] : (float) 0);
- }
-
- function MPEGvideoAspectRatioTextLookup($rawaspectratio) {
- $MPEGvideoAspectRatioTextLookup = array('forbidden', 'square pixels', '0.6735', '16:9, 625 line, PAL', '0.7615', '0.8055', '16:9, 525 line, NTSC', '0.8935', '4:3, 625 line, PAL, CCIR601', '0.9815', '1.0255', '1.0695', '4:3, 525 line, NTSC, CCIR601', '1.1575', '1.2015', 'reserved');
- return (isset($MPEGvideoAspectRatioTextLookup[$rawaspectratio]) ? $MPEGvideoAspectRatioTextLookup[$rawaspectratio] : '');
- }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.audio-video.nsv.php b/app/library/getid3/module.audio-video.nsv.php
deleted file mode 100644
index 5a587e67..00000000
--- a/app/library/getid3/module.audio-video.nsv.php
+++ /dev/null
@@ -1,226 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio.nsv.php //
-// module for analyzing Nullsoft NSV files //
-// dependencies: NONE //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-class getid3_nsv extends getid3_handler
-{
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
- $NSVheader = fread($this->getid3->fp, 4);
-
- switch ($NSVheader) {
- case 'NSVs':
- if ($this->getNSVsHeaderFilepointer(0)) {
- $info['fileformat'] = 'nsv';
- $info['audio']['dataformat'] = 'nsv';
- $info['video']['dataformat'] = 'nsv';
- $info['audio']['lossless'] = false;
- $info['video']['lossless'] = false;
- }
- break;
-
- case 'NSVf':
- if ($this->getNSVfHeaderFilepointer(0)) {
- $info['fileformat'] = 'nsv';
- $info['audio']['dataformat'] = 'nsv';
- $info['video']['dataformat'] = 'nsv';
- $info['audio']['lossless'] = false;
- $info['video']['lossless'] = false;
- $this->getNSVsHeaderFilepointer($info['nsv']['NSVf']['header_length']);
- }
- break;
-
- default:
- $info['error'][] = 'Expecting "NSVs" or "NSVf" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($NSVheader).'"';
- return false;
- break;
- }
-
- if (!isset($info['nsv']['NSVf'])) {
- $info['warning'][] = 'NSVf header not present - cannot calculate playtime or bitrate';
- }
-
- return true;
- }
-
- function getNSVsHeaderFilepointer($fileoffset) {
- $info = &$this->getid3->info;
- fseek($this->getid3->fp, $fileoffset, SEEK_SET);
- $NSVsheader = fread($this->getid3->fp, 28);
- $offset = 0;
-
- $info['nsv']['NSVs']['identifier'] = substr($NSVsheader, $offset, 4);
- $offset += 4;
-
- if ($info['nsv']['NSVs']['identifier'] != 'NSVs') {
- $info['error'][] = 'expected "NSVs" at offset ('.$fileoffset.'), found "'.$info['nsv']['NSVs']['identifier'].'" instead';
- unset($info['nsv']['NSVs']);
- return false;
- }
-
- $info['nsv']['NSVs']['offset'] = $fileoffset;
-
- $info['nsv']['NSVs']['video_codec'] = substr($NSVsheader, $offset, 4);
- $offset += 4;
- $info['nsv']['NSVs']['audio_codec'] = substr($NSVsheader, $offset, 4);
- $offset += 4;
- $info['nsv']['NSVs']['resolution_x'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
- $offset += 2;
- $info['nsv']['NSVs']['resolution_y'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
- $offset += 2;
-
- $info['nsv']['NSVs']['framerate_index'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$info['nsv']['NSVs']['unknown1b'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$info['nsv']['NSVs']['unknown1c'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$info['nsv']['NSVs']['unknown1d'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$info['nsv']['NSVs']['unknown2a'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$info['nsv']['NSVs']['unknown2b'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$info['nsv']['NSVs']['unknown2c'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- //$info['nsv']['NSVs']['unknown2d'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
-
- switch ($info['nsv']['NSVs']['audio_codec']) {
- case 'PCM ':
- $info['nsv']['NSVs']['bits_channel'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- $info['nsv']['NSVs']['channels'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 1));
- $offset += 1;
- $info['nsv']['NSVs']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 2));
- $offset += 2;
-
- $info['audio']['sample_rate'] = $info['nsv']['NSVs']['sample_rate'];
- break;
-
- case 'MP3 ':
- case 'NONE':
- default:
- //$info['nsv']['NSVs']['unknown3'] = getid3_lib::LittleEndian2Int(substr($NSVsheader, $offset, 4));
- $offset += 4;
- break;
- }
-
- $info['video']['resolution_x'] = $info['nsv']['NSVs']['resolution_x'];
- $info['video']['resolution_y'] = $info['nsv']['NSVs']['resolution_y'];
- $info['nsv']['NSVs']['frame_rate'] = $this->NSVframerateLookup($info['nsv']['NSVs']['framerate_index']);
- $info['video']['frame_rate'] = $info['nsv']['NSVs']['frame_rate'];
- $info['video']['bits_per_sample'] = 24;
- $info['video']['pixel_aspect_ratio'] = (float) 1;
-
- return true;
- }
-
- function getNSVfHeaderFilepointer($fileoffset, $getTOCoffsets=false) {
- $info = &$this->getid3->info;
- fseek($this->getid3->fp, $fileoffset, SEEK_SET);
- $NSVfheader = fread($this->getid3->fp, 28);
- $offset = 0;
-
- $info['nsv']['NSVf']['identifier'] = substr($NSVfheader, $offset, 4);
- $offset += 4;
-
- if ($info['nsv']['NSVf']['identifier'] != 'NSVf') {
- $info['error'][] = 'expected "NSVf" at offset ('.$fileoffset.'), found "'.$info['nsv']['NSVf']['identifier'].'" instead';
- unset($info['nsv']['NSVf']);
- return false;
- }
-
- $info['nsv']['NSVs']['offset'] = $fileoffset;
-
- $info['nsv']['NSVf']['header_length'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $info['nsv']['NSVf']['file_size'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
-
- if ($info['nsv']['NSVf']['file_size'] > $info['avdataend']) {
- $info['warning'][] = 'truncated file - NSVf header indicates '.$info['nsv']['NSVf']['file_size'].' bytes, file actually '.$info['avdataend'].' bytes';
- }
-
- $info['nsv']['NSVf']['playtime_ms'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $info['nsv']['NSVf']['meta_size'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $info['nsv']['NSVf']['TOC_entries_1'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $info['nsv']['NSVf']['TOC_entries_2'] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
-
- if ($info['nsv']['NSVf']['playtime_ms'] == 0) {
- $info['error'][] = 'Corrupt NSV file: NSVf.playtime_ms == zero';
- return false;
- }
-
- $NSVfheader .= fread($this->getid3->fp, $info['nsv']['NSVf']['meta_size'] + (4 * $info['nsv']['NSVf']['TOC_entries_1']) + (4 * $info['nsv']['NSVf']['TOC_entries_2']));
- $NSVfheaderlength = strlen($NSVfheader);
- $info['nsv']['NSVf']['metadata'] = substr($NSVfheader, $offset, $info['nsv']['NSVf']['meta_size']);
- $offset += $info['nsv']['NSVf']['meta_size'];
-
- if ($getTOCoffsets) {
- $TOCcounter = 0;
- while ($TOCcounter < $info['nsv']['NSVf']['TOC_entries_1']) {
- if ($TOCcounter < $info['nsv']['NSVf']['TOC_entries_1']) {
- $info['nsv']['NSVf']['TOC_1'][$TOCcounter] = getid3_lib::LittleEndian2Int(substr($NSVfheader, $offset, 4));
- $offset += 4;
- $TOCcounter++;
- }
- }
- }
-
- if (trim($info['nsv']['NSVf']['metadata']) != '') {
- $info['nsv']['NSVf']['metadata'] = str_replace('`', "\x01", $info['nsv']['NSVf']['metadata']);
- $CommentPairArray = explode("\x01".' ', $info['nsv']['NSVf']['metadata']);
- foreach ($CommentPairArray as $CommentPair) {
- if (strstr($CommentPair, '='."\x01")) {
- list($key, $value) = explode('='."\x01", $CommentPair, 2);
- $info['nsv']['comments'][strtolower($key)][] = trim(str_replace("\x01", '', $value));
- }
- }
- }
-
- $info['playtime_seconds'] = $info['nsv']['NSVf']['playtime_ms'] / 1000;
- $info['bitrate'] = ($info['nsv']['NSVf']['file_size'] * 8) / $info['playtime_seconds'];
-
- return true;
- }
-
-
- static function NSVframerateLookup($framerateindex) {
- if ($framerateindex <= 127) {
- return (float) $framerateindex;
- }
- static $NSVframerateLookup = array();
- if (empty($NSVframerateLookup)) {
- $NSVframerateLookup[129] = (float) 29.970;
- $NSVframerateLookup[131] = (float) 23.976;
- $NSVframerateLookup[133] = (float) 14.985;
- $NSVframerateLookup[197] = (float) 59.940;
- $NSVframerateLookup[199] = (float) 47.952;
- }
- return (isset($NSVframerateLookup[$framerateindex]) ? $NSVframerateLookup[$framerateindex] : false);
- }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/app/library/getid3/module.audio-video.quicktime.php b/app/library/getid3/module.audio-video.quicktime.php
deleted file mode 100644
index 3e96ea1a..00000000
--- a/app/library/getid3/module.audio-video.quicktime.php
+++ /dev/null
@@ -1,2134 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
-/////////////////////////////////////////////////////////////////
-// //
-// module.audio-video.quicktime.php //
-// module for analyzing Quicktime and MP3-in-MP4 files //
-// dependencies: module.audio.mp3.php //
-// ///
-/////////////////////////////////////////////////////////////////
-
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
-
-class getid3_quicktime extends getid3_handler
-{
-
- var $ReturnAtomData = true;
- var $ParseAllPossibleAtoms = false;
-
- function Analyze() {
- $info = &$this->getid3->info;
-
- $info['fileformat'] = 'quicktime';
- $info['quicktime']['hinting'] = false;
- $info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present
-
- fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
-
- $offset = 0;
- $atomcounter = 0;
-
- while ($offset < $info['avdataend']) {
- if (!getid3_lib::intValueSupported($offset)) {
- $info['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
- break;
- }
- fseek($this->getid3->fp, $offset, SEEK_SET);
- $AtomHeader = fread($this->getid3->fp, 8);
-
- $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
- $atomname = substr($AtomHeader, 4, 4);
-
- // 64-bit MOV patch by jlegatektnc*com
- if ($atomsize == 1) {
- $atomsize = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 8));
- }
-
- $info['quicktime'][$atomname]['name'] = $atomname;
- $info['quicktime'][$atomname]['size'] = $atomsize;
- $info['quicktime'][$atomname]['offset'] = $offset;
-
- if (($offset + $atomsize) > $info['avdataend']) {
- $info['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)';
- return false;
- }
-
- if ($atomsize == 0) {
- // Furthermore, for historical reasons the list of atoms is optionally
- // terminated by a 32-bit integer set to 0. If you are writing a program
- // to read user data atoms, you should allow for the terminating 0.
- break;
- }
- switch ($atomname) {
- case 'mdat': // Media DATa atom
- // 'mdat' contains the actual data for the audio/video
- if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) {
-
- $info['avdataoffset'] = $info['quicktime'][$atomname]['offset'] + 8;
- $OldAVDataEnd = $info['avdataend'];
- $info['avdataend'] = $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];
-
- $getid3_temp = new getID3();
- $getid3_temp->openfile($this->getid3->filename);
- $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
- $getid3_temp->info['avdataend'] = $info['avdataend'];
- $getid3_mp3 = new getid3_mp3($getid3_temp);
- if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode(fread($this->getid3->fp, 4)))) {
- $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
- if (!empty($getid3_temp->info['warning'])) {
- foreach ($getid3_temp->info['warning'] as $value) {
- $info['warning'][] = $value;
- }
- }
- if (!empty($getid3_temp->info['mpeg'])) {
- $info['mpeg'] = $getid3_temp->info['mpeg'];
- if (isset($info['mpeg']['audio'])) {
- $info['audio']['dataformat'] = 'mp3';
- $info['audio']['codec'] = (!empty($info['mpeg']['audio']['encoder']) ? $info['mpeg']['audio']['encoder'] : (!empty($info['mpeg']['audio']['codec']) ? $info['mpeg']['audio']['codec'] : (!empty($info['mpeg']['audio']['LAME']) ? 'LAME' :'mp3')));
- $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
- $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
- $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
- $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
- $info['bitrate'] = $info['audio']['bitrate'];
- }
- }
- }
- unset($getid3_mp3, $getid3_temp);
- $info['avdataend'] = $OldAVDataEnd;
- unset($OldAVDataEnd);
-
- }
- break;
-
- case 'free': // FREE space atom
- case 'skip': // SKIP atom
- case 'wide': // 64-bit expansion placeholder atom
- // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
- break;
-
- default:
- $atomHierarchy = array();
- $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($this->getid3->fp, $atomsize), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
- break;
- }
-
- $offset += $atomsize;
- $atomcounter++;
- }
-
- if (!empty($info['avdataend_tmp'])) {
- // this value is assigned to a temp value and then erased because
- // otherwise any atoms beyond the 'mdat' atom would not get parsed
- $info['avdataend'] = $info['avdataend_tmp'];
- unset($info['avdataend_tmp']);
- }
-
- if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) {
- $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
- }
- if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info['quicktime']['video'])) {
- $info['audio']['bitrate'] = $info['bitrate'];
- }
- if (!empty($info['playtime_seconds']) && !isset($info['video']['frame_rate']) && !empty($info['quicktime']['stts_framecount'])) {
- foreach ($info['quicktime']['stts_framecount'] as $key => $samples_count) {
- $samples_per_second = $samples_count / $info['playtime_seconds'];
- if ($samples_per_second > 240) {
- // has to be audio samples
- } else {
- $info['video']['frame_rate'] = $samples_per_second;
- break;
- }
- }
- }
- if (($info['audio']['dataformat'] == 'mp4') && empty($info['video']['resolution_x'])) {
- $info['fileformat'] = 'mp4';
- $info['mime_type'] = 'audio/mp4';
- unset($info['video']['dataformat']);
- }
-
- if (!$this->ReturnAtomData) {
- unset($info['quicktime']['moov']);
- }
-
- if (empty($info['audio']['dataformat']) && !empty($info['quicktime']['audio'])) {
- $info['audio']['dataformat'] = 'quicktime';
- }
- if (empty($info['video']['dataformat']) && !empty($info['quicktime']['video'])) {
- $info['video']['dataformat'] = 'quicktime';
- }
-
- return true;
- }
-
- function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
- // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
-
- $info = &$this->getid3->info;
-
- $atom_parent = array_pop($atomHierarchy);
- array_push($atomHierarchy, $atomname);
- $atom_structure['hierarchy'] = implode(' ', $atomHierarchy);
- $atom_structure['name'] = $atomname;
- $atom_structure['size'] = $atomsize;
- $atom_structure['offset'] = $baseoffset;
-//echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8)).' ';
-//echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8), false).'
';
- switch ($atomname) {
- case 'moov': // MOVie container atom
- case 'trak': // TRAcK container atom
- case 'clip': // CLIPping container atom
- case 'matt': // track MATTe container atom
- case 'edts': // EDiTS container atom
- case 'tref': // Track REFerence container atom
- case 'mdia': // MeDIA container atom
- case 'minf': // Media INFormation container atom
- case 'dinf': // Data INFormation container atom
- case 'udta': // User DaTA container atom
- case 'cmov': // Compressed MOVie container atom
- case 'rmra': // Reference Movie Record Atom
- case 'rmda': // Reference Movie Descriptor Atom
- case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)
- $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
- break;
-
- case 'ilst': // Item LiST container atom
- $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
-
- // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted
- $allnumericnames = true;
- foreach ($atom_structure['subatoms'] as $subatomarray) {
- if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) {
- $allnumericnames = false;
- break;
- }
- }
- if ($allnumericnames) {
- $newData = array();
- foreach ($atom_structure['subatoms'] as $subatomarray) {
- foreach ($subatomarray['subatoms'] as $newData_subatomarray) {
- unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']);
- $newData[$subatomarray['name']] = $newData_subatomarray;
- break;
- }
- }
- $atom_structure['data'] = $newData;
- unset($atom_structure['subatoms']);
- }
- break;
-
- case "\x00\x00\x00\x01":
- case "\x00\x00\x00\x02":
- case "\x00\x00\x00\x03":
- case "\x00\x00\x00\x04":
- case "\x00\x00\x00\x05":
- $atomname = getid3_lib::BigEndian2Int($atomname);
- $atom_structure['name'] = $atomname;
- $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
- break;
-
- case 'stbl': // Sample TaBLe container atom
- $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
- $isVideo = false;
- $framerate = 0;
- $framecount = 0;
- foreach ($atom_structure['subatoms'] as $key => $value_array) {
- if (isset($value_array['sample_description_table'])) {
- foreach ($value_array['sample_description_table'] as $key2 => $value_array2) {
- if (isset($value_array2['data_format'])) {
- switch ($value_array2['data_format']) {
- case 'avc1':
- case 'mp4v':
- // video data
- $isVideo = true;
- break;
- case 'mp4a':
- // audio data
- break;
- }
- }
- }
- } elseif (isset($value_array['time_to_sample_table'])) {
- foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) {
- if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) {
- $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3);
- $framecount = $value_array2['sample_count'];
- }
- }
- }
- }
- if ($isVideo && $framerate) {
- $info['quicktime']['video']['frame_rate'] = $framerate;
- $info['video']['frame_rate'] = $info['quicktime']['video']['frame_rate'];
- }
- if ($isVideo && $framecount) {
- $info['quicktime']['video']['frame_count'] = $framecount;
- }
- break;
-
-
- case 'aART': // Album ARTist
- case 'catg': // CaTeGory
- case 'covr': // COVeR artwork
- case 'cpil': // ComPILation
- case 'cprt': // CoPyRighT
- case 'desc': // DESCription
- case 'disk': // DISK number
- case 'egid': // Episode Global ID
- case 'gnre': // GeNRE
- case 'keyw': // KEYWord
- case 'ldes':
- case 'pcst': // PodCaST
- case 'pgap': // GAPless Playback
- case 'purd': // PURchase Date
- case 'purl': // Podcast URL
- case 'rati':
- case 'rndu':
- case 'rpdu':
- case 'rtng': // RaTiNG
- case 'stik':
- case 'tmpo': // TeMPO (BPM)
- case 'trkn': // TRacK Number
- case 'tves': // TV EpiSode
- case 'tvnn': // TV Network Name
- case 'tvsh': // TV SHow Name
- case 'tvsn': // TV SeasoN
- case 'akID': // iTunes store account type
- case 'apID':
- case 'atID':
- case 'cmID':
- case 'cnID':
- case 'geID':
- case 'plID':
- case 'sfID': // iTunes store country
- case 'alb': // ALBum
- case 'art': // ARTist
- case 'ART':
- case 'aut':
- case 'cmt': // CoMmenT
- case 'com': // COMposer
- case 'cpy':
- case 'day': // content created year
- case 'dir':
- case 'ed1':
- case 'ed2':
- case 'ed3':
- case 'ed4':
- case 'ed5':
- case 'ed6':
- case 'ed7':
- case 'ed8':
- case 'ed9':
- case 'enc':
- case 'fmt':
- case 'gen': // GENre
- case 'grp': // GRouPing
- case 'hst':
- case 'inf':
- case 'lyr': // LYRics
- case 'mak':
- case 'mod':
- case 'nam': // full NAMe
- case 'ope':
- case 'PRD':
- case 'prd':
- case 'prf':
- case 'req':
- case 'src':
- case 'swr':
- case 'too': // encoder
- case 'trk': // TRacK
- case 'url':
- case 'wrn':
- case 'wrt': // WRiTer
- case '----': // itunes specific
- if ($atom_parent == 'udta') {
- // User data atom handler
- $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
- $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
- $atom_structure['data'] = substr($atom_data, 4);
-
- $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
- if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
- $info['comments']['language'][] = $atom_structure['language'];
- }
- } else {
- // Apple item list box atom handler
- $atomoffset = 0;
- if (substr($atom_data, 2, 2) == "\x10\xB5") {
- // not sure what it means, but observed on iPhone4 data.
- // Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data
- while ($atomoffset < strlen($atom_data)) {
- $boxsmallsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 2));
- $boxsmalltype = substr($atom_data, $atomoffset + 2, 2);
- $boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize);
- switch ($boxsmalltype) {
- case "\x10\xB5":
- $atom_structure['data'] = $boxsmalldata;
- break;
- default:
- $info['warning'][] = 'Unknown QuickTime smallbox type: "'.getid3_lib::PrintHexBytes($boxsmalltype).'" at offset '.$baseoffset;
- $atom_structure['data'] = $atom_data;
- break;
- }
- $atomoffset += (4 + $boxsmallsize);
- }
- } else {
- while ($atomoffset < strlen($atom_data)) {
- $boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4));
- $boxtype = substr($atom_data, $atomoffset + 4, 4);
- $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8);
-
- switch ($boxtype) {
- case 'mean':
- case 'name':
- $atom_structure[$boxtype] = substr($boxdata, 4);
- break;
-
- case 'data':
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3));
- switch ($atom_structure['flags_raw']) {
- case 0: // data flag
- case 21: // tmpo/cpil flag
- switch ($atomname) {
- case 'cpil':
- case 'pcst':
- case 'pgap':
- $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
- break;
-
- case 'tmpo':
- $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2));
- break;
-
- case 'disk':
- case 'trkn':
- $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2));
- $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2));
- $atom_structure['data'] = empty($num) ? '' : $num;
- $atom_structure['data'] .= empty($num_total) ? '' : '/'.$num_total;
- break;
-
- case 'gnre':
- $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
- $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1);
- break;
-
- case 'rtng':
- $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
- $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]);
- break;
-
- case 'stik':
- $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
- $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]);
- break;
-
- case 'sfID':
- $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
- $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]);
- break;
-
- case 'egid':
- case 'purl':
- $atom_structure['data'] = substr($boxdata, 8);
- break;
-
- default:
- $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
- }
- break;
-
- case 1: // text flag
- case 13: // image flag
- default:
- $atom_structure['data'] = substr($boxdata, 8);
- break;
-
- }
- break;
-
- default:
- $info['warning'][] = 'Unknown QuickTime box type: "'.getid3_lib::PrintHexBytes($boxtype).'" at offset '.$baseoffset;
- $atom_structure['data'] = $atom_data;
-
- }
- $atomoffset += $boxsize;
- }
- }
- }
- $this->CopyToAppropriateCommentsSection($atomname, $atom_structure['data'], $atom_structure['name']);
- break;
-
-
- case 'play': // auto-PLAY atom
- $atom_structure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
-
- $info['quicktime']['autoplay'] = $atom_structure['autoplay'];
- break;
-
-
- case 'WLOC': // Window LOCation atom
- $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
- $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
- break;
-
-
- case 'LOOP': // LOOPing atom
- case 'SelO': // play SELection Only atom
- case 'AllF': // play ALL Frames atom
- $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data);
- break;
-
-
- case 'name': //
- case 'MCPS': // Media Cleaner PRo
- case '@PRM': // adobe PReMiere version
- case '@PRQ': // adobe PRemiere Quicktime version
- $atom_structure['data'] = $atom_data;
- break;
-
-
- case 'cmvd': // Compressed MooV Data atom
- // Code by ubergeekubergeek*tv based on information from
- // http://developer.apple.com/quicktime/icefloe/dispatch012.html
- $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
-
- $CompressedFileData = substr($atom_data, 4);
- if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
- $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy, $ParseAllPossibleAtoms);
- } else {
- $info['warning'][] = 'Error decompressing compressed MOV atom at offset '.$atom_structure['offset'];
- }
- break;
-
-
- case 'dcom': // Data COMpression atom
- $atom_structure['compression_id'] = $atom_data;
- $atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data);
- break;
-
-
- case 'rdrf': // Reference movie Data ReFerence atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
- $atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x000001);
-
- $atom_structure['reference_type_name'] = substr($atom_data, 4, 4);
- $atom_structure['reference_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
- switch ($atom_structure['reference_type_name']) {
- case 'url ':
- $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12));
- break;
-
- case 'alis':
- $atom_structure['file_alias'] = substr($atom_data, 12);
- break;
-
- case 'rsrc':
- $atom_structure['resource_alias'] = substr($atom_data, 12);
- break;
-
- default:
- $atom_structure['data'] = substr($atom_data, 12);
- break;
- }
- break;
-
-
- case 'rmqu': // Reference Movie QUality atom
- $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data);
- break;
-
-
- case 'rmcs': // Reference Movie Cpu Speed atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
- break;
-
-
- case 'rmvc': // Reference Movie Version Check atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['gestalt_selector'] = substr($atom_data, 4, 4);
- $atom_structure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
- $atom_structure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
- $atom_structure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
- break;
-
-
- case 'rmcd': // Reference Movie Component check atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['component_type'] = substr($atom_data, 4, 4);
- $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
- $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
- $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
- $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
- $atom_structure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 4));
- break;
-
-
- case 'rmdr': // Reference Movie Data Rate atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['data_rate'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
-
- $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10;
- break;
-
-
- case 'rmla': // Reference Movie Language Atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
-
- $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
- if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
- $info['comments']['language'][] = $atom_structure['language'];
- }
- break;
-
-
- case 'rmla': // Reference Movie Language Atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
- break;
-
-
- case 'ptv ': // Print To Video - defines a movie's full screen mode
- // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
- $atom_structure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
- $atom_structure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); // hardcoded: 0x0000
- $atom_structure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x0000
- $atom_structure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 1));
- $atom_structure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 7, 1));
-
- $atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag'];
- $atom_structure['flags']['slide_show'] = (bool) $atom_structure['slide_show_flag'];
-
- $ptv_lookup[0] = 'normal';
- $ptv_lookup[1] = 'double';
- $ptv_lookup[2] = 'half';
- $ptv_lookup[3] = 'full';
- $ptv_lookup[4] = 'current';
- if (isset($ptv_lookup[$atom_structure['display_size_raw']])) {
- $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']];
- } else {
- $info['warning'][] = 'unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')';
- }
- break;
-
-
- case 'stsd': // Sample Table Sample Description atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $stsdEntriesDataOffset = 8;
- for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
- $atom_structure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4));
- $stsdEntriesDataOffset += 4;
- $atom_structure['sample_description_table'][$i]['data_format'] = substr($atom_data, $stsdEntriesDataOffset, 4);
- $stsdEntriesDataOffset += 4;
- $atom_structure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 6));
- $stsdEntriesDataOffset += 6;
- $atom_structure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 2));
- $stsdEntriesDataOffset += 2;
- $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
- $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
-
- $atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2));
- $atom_structure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 2, 2));
- $atom_structure['sample_description_table'][$i]['encoder_vendor'] = substr($atom_structure['sample_description_table'][$i]['data'], 4, 4);
-
- switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) {
-
- case "\x00\x00\x00\x00":
- // audio atom
- $atom_structure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 2));
- $atom_structure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 10, 2));
- $atom_structure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 2));
- $atom_structure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 14, 2));
- $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4));
-
- switch ($atom_structure['sample_description_table'][$i]['data_format']) {
- case 'avc1':
- case 'mp4v':
- $info['fileformat'] = 'mp4';
- $info['video']['fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
- //$info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] does not fully support MPEG-4 audio/video streams'; // 2011-02-18: why am I warning about this again? What's not supported?
- break;
-
- case 'qtvr':
- $info['video']['dataformat'] = 'quicktimevr';
- break;
-
- case 'mp4a':
- default:
- $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
- $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate'];
- $info['quicktime']['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels'];
- $info['quicktime']['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth'];
- $info['audio']['codec'] = $info['quicktime']['audio']['codec'];
- $info['audio']['sample_rate'] = $info['quicktime']['audio']['sample_rate'];
- $info['audio']['channels'] = $info['quicktime']['audio']['channels'];
- $info['audio']['bits_per_sample'] = $info['quicktime']['audio']['bit_depth'];
- switch ($atom_structure['sample_description_table'][$i]['data_format']) {
- case 'raw ': // PCM
- case 'alac': // Apple Lossless Audio Codec
- $info['audio']['lossless'] = true;
- break;
- default:
- $info['audio']['lossless'] = false;
- break;
- }
- break;
- }
- break;
-
- default:
- switch ($atom_structure['sample_description_table'][$i]['data_format']) {
- case 'mp4s':
- $info['fileformat'] = 'mp4';
- break;
-
- default:
- // video atom
- $atom_structure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));
- $atom_structure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));
- $atom_structure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));
- $atom_structure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));
- $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4));
- $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
- $atom_structure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));
- $atom_structure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 2));
- $atom_structure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 34, 1));
- $atom_structure['sample_description_table'][$i]['video_encoder_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 35, $atom_structure['sample_description_table'][$i]['video_encoder_name_len']);
- $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2));
- $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2));
-
- $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');
- $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']);
-
- if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') {
- $info['quicktime']['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
- $info['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
- $info['quicktime']['video']['codec'] = (($atom_structure['sample_description_table'][$i]['video_encoder_name_len'] > 0) ? $atom_structure['sample_description_table'][$i]['video_encoder_name'] : $atom_structure['sample_description_table'][$i]['data_format']);
- $info['quicktime']['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'];
- $info['quicktime']['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name'];
-
- $info['video']['codec'] = $info['quicktime']['video']['codec'];
- $info['video']['bits_per_sample'] = $info['quicktime']['video']['color_depth'];
- }
- $info['video']['lossless'] = false;
- $info['video']['pixel_aspect_ratio'] = (float) 1;
- break;
- }
- break;
- }
- switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) {
- case 'mp4a':
- $info['audio']['dataformat'] = 'mp4';
- $info['quicktime']['audio']['codec'] = 'mp4';
- break;
-
- case '3ivx':
- case '3iv1':
- case '3iv2':
- $info['video']['dataformat'] = '3ivx';
- break;
-
- case 'xvid':
- $info['video']['dataformat'] = 'xvid';
- break;
-
- case 'mp4v':
- $info['video']['dataformat'] = 'mpeg4';
- break;
-
- case 'divx':
- case 'div1':
- case 'div2':
- case 'div3':
- case 'div4':
- case 'div5':
- case 'div6':
- $info['video']['dataformat'] = 'divx';
- break;
-
- default:
- // do nothing
- break;
- }
- unset($atom_structure['sample_description_table'][$i]['data']);
- }
- break;
-
-
- case 'stts': // Sample Table Time-to-Sample atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $sttsEntriesDataOffset = 8;
- //$FrameRateCalculatorArray = array();
- $frames_count = 0;
- for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
- $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
- $sttsEntriesDataOffset += 4;
- $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
- $sttsEntriesDataOffset += 4;
-
- $frames_count += $atom_structure['time_to_sample_table'][$i]['sample_count'];
-
- // THIS SECTION REPLACED WITH CODE IN "stbl" ATOM
- //if (!empty($info['quicktime']['time_scale']) && ($atom_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
- // $stts_new_framerate = $info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'];
- // if ($stts_new_framerate <= 60) {
- // // some atoms have durations of "1" giving a very large framerate, which probably is not right
- // $info['video']['frame_rate'] = max($info['video']['frame_rate'], $stts_new_framerate);
- // }
- //}
- //
- //$FrameRateCalculatorArray[($info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count'];
- }
- $info['quicktime']['stts_framecount'][] = $frames_count;
- //$sttsFramesTotal = 0;
- //$sttsSecondsTotal = 0;
- //foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) {
- // if (($frames_per_second > 60) || ($frames_per_second < 1)) {
- // // not video FPS information, probably audio information
- // $sttsFramesTotal = 0;
- // $sttsSecondsTotal = 0;
- // break;
- // }
- // $sttsFramesTotal += $frame_count;
- // $sttsSecondsTotal += $frame_count / $frames_per_second;
- //}
- //if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) {
- // if (($sttsFramesTotal / $sttsSecondsTotal) > $info['video']['frame_rate']) {
- // $info['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal;
- // }
- //}
- break;
-
-
- case 'stss': // Sample Table Sync Sample (key frames) atom
- if ($ParseAllPossibleAtoms) {
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $stssEntriesDataOffset = 8;
- for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
- $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stssEntriesDataOffset, 4));
- $stssEntriesDataOffset += 4;
- }
- }
- break;
-
-
- case 'stsc': // Sample Table Sample-to-Chunk atom
- if ($ParseAllPossibleAtoms) {
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $stscEntriesDataOffset = 8;
- for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
- $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
- $stscEntriesDataOffset += 4;
- $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
- $stscEntriesDataOffset += 4;
- $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
- $stscEntriesDataOffset += 4;
- }
- }
- break;
-
-
- case 'stsz': // Sample Table SiZe atom
- if ($ParseAllPossibleAtoms) {
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
- $stszEntriesDataOffset = 12;
- if ($atom_structure['sample_size'] == 0) {
- for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
- $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stszEntriesDataOffset, 4));
- $stszEntriesDataOffset += 4;
- }
- }
- }
- break;
-
-
- case 'stco': // Sample Table Chunk Offset atom
- if ($ParseAllPossibleAtoms) {
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $stcoEntriesDataOffset = 8;
- for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
- $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 4));
- $stcoEntriesDataOffset += 4;
- }
- }
- break;
-
-
- case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files)
- if ($ParseAllPossibleAtoms) {
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $stcoEntriesDataOffset = 8;
- for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
- $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 8));
- $stcoEntriesDataOffset += 8;
- }
- }
- break;
-
-
- case 'dref': // Data REFerence atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $drefDataOffset = 8;
- for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
- $atom_structure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 4));
- $drefDataOffset += 4;
- $atom_structure['data_references'][$i]['type'] = substr($atom_data, $drefDataOffset, 4);
- $drefDataOffset += 4;
- $atom_structure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 1));
- $drefDataOffset += 1;
- $atom_structure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 3)); // hardcoded: 0x0000
- $drefDataOffset += 3;
- $atom_structure['data_references'][$i]['data'] = substr($atom_data, $drefDataOffset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
- $drefDataOffset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
-
- $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool) ($atom_structure['data_references'][$i]['flags_raw'] & 0x001);
- }
- break;
-
-
- case 'gmin': // base Media INformation atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
- $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
- $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
- $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
- $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 2));
- $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
- break;
-
-
- case 'smhd': // Sound Media information HeaDer atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
- $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
- break;
-
-
- case 'vmhd': // Video Media information HeaDer atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
- $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
- $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
- $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
- $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
-
- $atom_structure['flags']['no_lean_ahead'] = (bool) ($atom_structure['flags_raw'] & 0x001);
- break;
-
-
- case 'hdlr': // HanDLeR reference atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['component_type'] = substr($atom_data, 4, 4);
- $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
- $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
- $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
- $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
- $atom_structure['component_name'] = $this->Pascal2String(substr($atom_data, 24));
-
- if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) {
- $info['video']['dataformat'] = 'quicktimevr';
- }
- break;
-
-
- case 'mdhd': // MeDia HeaDer atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
- $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
- $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
- $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 2));
- $atom_structure['quality'] = getid3_lib::BigEndian2Int(substr($atom_data, 22, 2));
-
- if ($atom_structure['time_scale'] == 0) {
- $info['error'][] = 'Corrupt Quicktime file: mdhd.time_scale == zero';
- return false;
- }
- $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
-
- $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
- $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
- $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
- $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
- if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
- $info['comments']['language'][] = $atom_structure['language'];
- }
- break;
-
-
- case 'pnot': // Preview atom
- $atom_structure['modification_date'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // "standard Macintosh format"
- $atom_structure['version_number'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x00
- $atom_structure['atom_type'] = substr($atom_data, 6, 4); // usually: 'PICT'
- $atom_structure['atom_index'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); // usually: 0x01
-
- $atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']);
- break;
-
-
- case 'crgn': // Clipping ReGioN atom
- $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box,
- $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields
- $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region.
- break;
-
-
- case 'load': // track LOAD settings atom
- $atom_structure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
- $atom_structure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $atom_structure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
- $atom_structure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
-
- $atom_structure['default_hints']['double_buffer'] = (bool) ($atom_structure['default_hints_raw'] & 0x0020);
- $atom_structure['default_hints']['high_quality'] = (bool) ($atom_structure['default_hints_raw'] & 0x0100);
- break;
-
-
- case 'tmcd': // TiMe CoDe atom
- case 'chap': // CHAPter list atom
- case 'sync': // SYNChronization atom
- case 'scpt': // tranSCriPT atom
- case 'ssrc': // non-primary SouRCe atom
- for ($i = 0; $i < (strlen($atom_data) % 4); $i++) {
- $atom_structure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $i * 4, 4));
- }
- break;
-
-
- case 'elst': // Edit LiST atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) {
- $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4));
- $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4));
- $atom_structure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4));
- }
- break;
-
-
- case 'kmat': // compressed MATte atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
- $atom_structure['matte_data_raw'] = substr($atom_data, 4);
- break;
-
-
- case 'ctab': // Color TABle atom
- $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000
- $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000
- $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1;
- for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) {
- $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2));
- $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2));
- $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2));
- $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2));
- }
- break;
-
-
- case 'mvhd': // MoVie HeaDer atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
- $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
- $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
- $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
- $atom_structure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 20, 4));
- $atom_structure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 24, 2));
- $atom_structure['reserved'] = substr($atom_data, 26, 10);
- $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 36, 4));
- $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
- $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 44, 4));
- $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));
- $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
- $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 56, 4));
- $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));
- $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));
- $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));
- $atom_structure['preview_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 72, 4));
- $atom_structure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 76, 4));
- $atom_structure['poster_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 80, 4));
- $atom_structure['selection_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 84, 4));
- $atom_structure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 88, 4));
- $atom_structure['current_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 92, 4));
- $atom_structure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 96, 4));
-
- if ($atom_structure['time_scale'] == 0) {
- $info['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero';
- return false;
- }
- $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
- $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
- $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
- $info['quicktime']['display_scale'] = $atom_structure['matrix_a'];
- $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
- break;
-
-
- case 'tkhd': // TracK HeaDer atom
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
- $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
- $atom_structure['trackid'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
- $atom_structure['reserved1'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
- $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
- $atom_structure['reserved2'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 8));
- $atom_structure['layer'] = getid3_lib::BigEndian2Int(substr($atom_data, 32, 2));
- $atom_structure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atom_data, 34, 2));
- $atom_structure['volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 36, 2));
- $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2));
- $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
- $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 44, 4));
- $atom_structure['matrix_u'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));
- $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
- $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 56, 4));
- $atom_structure['matrix_v'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));
- $atom_structure['matrix_x'] = getid3_lib::FixedPoint2_30(substr($atom_data, 64, 4));
- $atom_structure['matrix_y'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));
- $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 72, 4));
- $atom_structure['width'] = getid3_lib::FixedPoint16_16(substr($atom_data, 76, 4));
- $atom_structure['height'] = getid3_lib::FixedPoint16_16(substr($atom_data, 80, 4));
-
- $atom_structure['flags']['enabled'] = (bool) ($atom_structure['flags_raw'] & 0x0001);
- $atom_structure['flags']['in_movie'] = (bool) ($atom_structure['flags_raw'] & 0x0002);
- $atom_structure['flags']['in_preview'] = (bool) ($atom_structure['flags_raw'] & 0x0004);
- $atom_structure['flags']['in_poster'] = (bool) ($atom_structure['flags_raw'] & 0x0008);
- $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
- $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
-
- if ($atom_structure['flags']['enabled'] == 1) {
- if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) {
- $info['video']['resolution_x'] = $atom_structure['width'];
- $info['video']['resolution_y'] = $atom_structure['height'];
- }
- $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']);
- $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']);
- $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];
- $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];
- } else {
- if (isset($info['video']['resolution_x'])) { unset($info['video']['resolution_x']); }
- if (isset($info['video']['resolution_y'])) { unset($info['video']['resolution_y']); }
- if (isset($info['quicktime']['video'])) { unset($info['quicktime']['video']); }
- }
- break;
-
-
- case 'iods': // Initial Object DeScriptor atom
- // http://www.koders.com/c/fid1FAB3E762903DC482D8A246D4A4BF9F28E049594.aspx?s=windows.h
- // http://libquicktime.sourcearchive.com/documentation/1.0.2plus-pdebian/iods_8c-source.html
- $offset = 0;
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
- $offset += 1;
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 3));
- $offset += 3;
- $atom_structure['mp4_iod_tag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
- $offset += 1;
- $atom_structure['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
- //$offset already adjusted by quicktime_read_mp4_descr_length()
- $atom_structure['object_descriptor_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2));
- $offset += 2;
- $atom_structure['od_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
- $offset += 1;
- $atom_structure['scene_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
- $offset += 1;
- $atom_structure['audio_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
- $offset += 1;
- $atom_structure['video_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
- $offset += 1;
- $atom_structure['graphics_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
- $offset += 1;
-
- $atom_structure['num_iods_tracks'] = ($atom_structure['length'] - 7) / 6; // 6 bytes would only be right if all tracks use 1-byte length fields
- for ($i = 0; $i < $atom_structure['num_iods_tracks']; $i++) {
- $atom_structure['track'][$i]['ES_ID_IncTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
- $offset += 1;
- $atom_structure['track'][$i]['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
- //$offset already adjusted by quicktime_read_mp4_descr_length()
- $atom_structure['track'][$i]['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4));
- $offset += 4;
- }
-
- $atom_structure['audio_profile_name'] = $this->QuicktimeIODSaudioProfileName($atom_structure['audio_profile_id']);
- $atom_structure['video_profile_name'] = $this->QuicktimeIODSvideoProfileName($atom_structure['video_profile_id']);
- break;
-
- case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)
- $atom_structure['signature'] = substr($atom_data, 0, 4);
- $atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
- $atom_structure['fourcc'] = substr($atom_data, 8, 4);
- break;
-
- case 'mdat': // Media DATa atom
- case 'free': // FREE space atom
- case 'skip': // SKIP atom
- case 'wide': // 64-bit expansion placeholder atom
- // 'mdat' data is too big to deal with, contains no useful metadata
- // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
-
- // When writing QuickTime files, it is sometimes necessary to update an atom's size.
- // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom
- // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime
- // puts an 8-byte placeholder atom before any atoms it may have to update the size of.
- // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the
- // placeholder atom can be overwritten to obtain the necessary 8 extra bytes.
- // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).
- break;
-
-
- case 'nsav': // NoSAVe atom
- // http://developer.apple.com/technotes/tn/tn2038.html
- $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
- break;
-
- case 'ctyp': // Controller TYPe atom (seen on QTVR)
- // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
- // some controller names are:
- // 0x00 + 'std' for linear movie
- // 'none' for no controls
- $atom_structure['ctyp'] = substr($atom_data, 0, 4);
- $info['quicktime']['controller'] = $atom_structure['ctyp'];
- switch ($atom_structure['ctyp']) {
- case 'qtvr':
- $info['video']['dataformat'] = 'quicktimevr';
- break;
- }
- break;
-
- case 'pano': // PANOrama track (seen on QTVR)
- $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
- break;
-
- case 'hint': // HINT track
- case 'hinf': //
- case 'hinv': //
- case 'hnti': //
- $info['quicktime']['hinting'] = true;
- break;
-
- case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)
- for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) {
- $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));
- }
- break;
-
-
- // Observed-but-not-handled atom types are just listed here to prevent warnings being generated
- case 'FXTC': // Something to do with Adobe After Effects (?)
- case 'PrmA':
- case 'code':
- case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
- case 'tapt': // TrackApertureModeDimensionsAID - http://developer.apple.com/documentation/QuickTime/Reference/QT7-1_Update_Reference/Constants/Constants.html
- // tapt seems to be used to compute the video size [http://www.getid3.org/phpBB3/viewtopic.php?t=838]
- // * http://lists.apple.com/archives/quicktime-api/2006/Aug/msg00014.html
- // * http://handbrake.fr/irclogs/handbrake-dev/handbrake-dev20080128_pg2.html
- case 'ctts':// STCompositionOffsetAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
- case 'cslg':// STCompositionShiftLeastGreatestAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
- case 'sdtp':// STSampleDependencyAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
- case 'stps':// STPartialSyncSampleAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
- //$atom_structure['data'] = $atom_data;
- break;
-
- case 'xyz': // GPS latitude+longitude+altitude
- $atom_structure['data'] = $atom_data;
- if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) {
- @list($all, $latitude, $longitude, $altitude) = $matches;
- $info['quicktime']['comments']['gps_latitude'][] = floatval($latitude);
- $info['quicktime']['comments']['gps_longitude'][] = floatval($longitude);
- if (!empty($altitude)) {
- $info['quicktime']['comments']['gps_altitude'][] = floatval($altitude);
- }
- } else {
- $info['warning'][] = 'QuickTime atom "xyz" data does not match expected data pattern at offset '.$baseoffset.'. Please report as getID3() bug.';
- }
- break;
-
- case 'NCDT':
- // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
- // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
- $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms);
- break;
- case 'NCTH': // Nikon Camera THumbnail image
- case 'NCVW': // Nikon Camera preVieW image
- // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
- if (preg_match('/^\xFF\xD8\xFF/', $atom_data)) {
- $atom_structure['data'] = $atom_data;
- $atom_structure['image_mime'] = 'image/jpeg';
- $atom_structure['description'] = (($atomname == 'NCTH') ? 'Nikon Camera Thumbnail Image' : (($atomname == 'NCVW') ? 'Nikon Camera Preview Image' : 'Nikon preview image'));
- $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']);
- }
- break;
- case 'NCHD': // MakerNoteVersion
- // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
- $atom_structure['data'] = $atom_data;
- break;
- case 'NCTG': // NikonTags
- // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
- $atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data);
- break;
- case 'NCDB': // NikonTags
- // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
- $atom_structure['data'] = $atom_data;
- break;
-
- case "\x00\x00\x00\x00":
- case 'meta': // METAdata atom
- // some kind of metacontainer, may contain a big data dump such as:
- // mdta keys mdtacom.apple.quicktime.make (mdtacom.apple.quicktime.creationdate ,mdtacom.apple.quicktime.location.ISO6709 $mdtacom.apple.quicktime.software !mdtacom.apple.quicktime.model ilst data DEApple 0 (data DE2011-05-11T17:54:04+0200 2 *data DE+52.4936+013.3897+040.247/ data DE4.3.1 data DEiPhone 4
- // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
-
- $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
- $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
- $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_data, 4), $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
- //$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
- break;
-
- case 'data': // metaDATA atom
- // seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data
- $atom_structure['language'] = substr($atom_data, 4 + 0, 2);
- $atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2));
- $atom_structure['data'] = substr($atom_data, 4 + 4);
- break;
-
- default:
- $info['warning'][] = 'Unknown QuickTime atom type: "'.getid3_lib::PrintHexBytes($atomname).'" at offset '.$baseoffset;
- $atom_structure['data'] = $atom_data;
- break;
- }
- array_pop($atomHierarchy);
- return $atom_structure;
- }
-
- function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
-//echo 'QuicktimeParseContainerAtom('.substr($atom_data, 4, 4).') @ '.$baseoffset.'