diff --git a/apps/contacts/templates/part.addpropertyform.php b/apps/contacts/templates/part.addpropertyform.php
index 32affde9526..885330e5778 100644
--- a/apps/contacts/templates/part.addpropertyform.php
+++ b/apps/contacts/templates/part.addpropertyform.php
@@ -17,24 +17,24 @@
t('Work'); ?>
t('Home'); ?>
- t('PO Box'); ?>
- t('Extended Address'); ?>
- t('Street Name'); ?>
- t('City'); ?>
- t('Region'); ?>
- t('Postal Code'); ?>
- t('Country'); ?>
+ t('PO Box'); ?>
+ t('Extended'); ?>
+ t('Street'); ?>
+ t('City'); ?>
+ t('Region'); ?>
+ t('Zipcode'); ?>
+ t('Country'); ?>
- t('tel_home'); ?>
- t('tel_cell'); ?>
- t('tel_work'); ?>
- t('tel_text'); ?>
- t('tel_voice'); ?>
- t('tel_fax'); ?>
- t('tel_video'); ?>
- t('tel_pager'); ?>
+ t('Home'); ?>
+ t('Mobile'); ?>
+ t('Work'); ?>
+ t('Text'); ?>
+ t('Voice'); ?>
+ t('Fax'); ?>
+ t('Video'); ?>
+ t('Pager'); ?>
diff --git a/apps/contacts/templates/part.details.php b/apps/contacts/templates/part.details.php
index c6bedcdd913..438f84d45d4 100644
--- a/apps/contacts/templates/part.details.php
+++ b/apps/contacts/templates/part.details.php
@@ -1,5 +1,5 @@
-
+
+
+
+
+
-
-
-
-
-
diff --git a/apps/contacts/templates/part.property.php b/apps/contacts/templates/part.property.php
index d0d2b773ef3..31fb187a0d3 100644
--- a/apps/contacts/templates/part.property.php
+++ b/apps/contacts/templates/part.property.php
@@ -1,8 +1,8 @@
- t('Name'); ?>
+
-
+
@@ -12,7 +12,7 @@
- t('Organisation'); ?>
+ t('Organization'); ?>
@@ -26,11 +26,11 @@
- t('Telephone'); ?>
+ t('Phone'); ?>
- (t('tel_'.strtolower($_['property']['parameters']['TYPE'])); ?>)
+ ()
@@ -40,7 +40,7 @@
t('Address'); ?>
- (t('adr_'.strtolower($_['property']['parameters']['TYPE'])); ?>)
+ ()
@@ -48,10 +48,10 @@
t('PO Box'); ?>
- t('Extended Address'); ?>
+ t('Extended'); ?>
- t('Street Name'); ?>
+ t('Street'); ?>
t('City'); ?>
@@ -60,7 +60,7 @@
t('Region'); ?>
- t('Postal Code'); ?>
+ t('Zipcode'); ?>
t('Country'); ?>
diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php
index 52483ebf4b7..69c789795e5 100644
--- a/apps/contacts/templates/part.setpropertyform.php
+++ b/apps/contacts/templates/part.setpropertyform.php
@@ -3,11 +3,11 @@
t('PO Box'); ?>
- t('Extended Address'); ?>
- t('Street Name'); ?>
+ t('Extended'); ?>
+ t('Street'); ?>
t('City'); ?>
t('Region'); ?>
- t('Postal Code'); ?>
+ t('Zipcode'); ?>
t('Country'); ?>
diff --git a/apps/contacts/templates/settings.php b/apps/contacts/templates/settings.php
new file mode 100644
index 00000000000..f5c37c5a044
--- /dev/null
+++ b/apps/contacts/templates/settings.php
@@ -0,0 +1,7 @@
+
+
+ Contacts
+ CardDAV syncing address:
+
+
+
diff --git a/apps/files_imageviewer/appinfo/info.xml b/apps/files_imageviewer/appinfo/info.xml
index f3b5a67960e..00b55c254dd 100644
--- a/apps/files_imageviewer/appinfo/info.xml
+++ b/apps/files_imageviewer/appinfo/info.xml
@@ -7,4 +7,5 @@
AGPL
Robin Appelman
2
-
\ No newline at end of file
+
+
diff --git a/apps/files_publiclink/admin.php b/apps/files_publiclink/admin.php
deleted file mode 100644
index 33d8f04a603..00000000000
--- a/apps/files_publiclink/admin.php
+++ /dev/null
@@ -1,49 +0,0 @@
-.
-*
-*/
-
-
-// Init owncloud
-require_once('../../lib/base.php');
-require_once( 'lib_public.php' );
-
-
-// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( "index.php" ));
- exit();
-}
-
-OC_App::setActiveNavigationEntry( "files_publiclink_administration" );
-
-OC_Util::addScript( 'files_publiclink', 'admin' );
-
-$baseUrl = OC_Helper::linkTo('files_publiclink','get.php', null, true);
-
-
-// return template
-$tmpl = new OC_Template( "files_publiclink", "admin", "user" );
-$tmpl->assign( 'links', OC_PublicLink::getLinks());
-$tmpl->assign('baseUrl',$baseUrl);
-$tmpl->printPage();
-
-?>
diff --git a/apps/files_publiclink/ajax/deletelink.php b/apps/files_publiclink/ajax/deletelink.php
deleted file mode 100644
index e2e4ff944a6..00000000000
--- a/apps/files_publiclink/ajax/deletelink.php
+++ /dev/null
@@ -1,11 +0,0 @@
-
\ No newline at end of file
diff --git a/apps/files_publiclink/ajax/getlink.php b/apps/files_publiclink/ajax/getlink.php
deleted file mode 100644
index 551bcc8780c..00000000000
--- a/apps/files_publiclink/ajax/getlink.php
+++ /dev/null
@@ -1,8 +0,0 @@
-getToken();
-?>
diff --git a/apps/files_publiclink/appinfo/app.php b/apps/files_publiclink/appinfo/app.php
deleted file mode 100644
index 5866e2d1c5e..00000000000
--- a/apps/files_publiclink/appinfo/app.php
+++ /dev/null
@@ -1,6 +0,0 @@
- "files_publiclink_administration", "order" => 2, "href" => OC_Helper::linkTo( "files_publiclink", "admin.php" ), "name" => "Public Links"));
-
-
-?>
diff --git a/apps/files_publiclink/appinfo/database.xml b/apps/files_publiclink/appinfo/database.xml
deleted file mode 100644
index 4fe6be47d8d..00000000000
--- a/apps/files_publiclink/appinfo/database.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
- *dbname*
- true
- false
- latin1
-
- *dbprefix*publiclink
-
-
- token
- text
-
- true
- 40
-
-
- path
- text
-
- true
- 128
-
-
- user
- text
-
-
- true
- 64
-
-
- expire_time
- timestamp
- true
-
-
- a_files_publiclink_token
- true
-
- token
- ascending
-
-
-
-
-
diff --git a/apps/files_publiclink/appinfo/info.xml b/apps/files_publiclink/appinfo/info.xml
deleted file mode 100644
index 1d41ea96662..00000000000
--- a/apps/files_publiclink/appinfo/info.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- files_publiclink
- Share by Publiclink
- Simple file sharing by creating a public link to a file
- 0.2
- AGPL
- Robin Appelman
- 2
-
\ No newline at end of file
diff --git a/apps/files_publiclink/get.php b/apps/files_publiclink/get.php
deleted file mode 100644
index 2e1ba4bf363..00000000000
--- a/apps/files_publiclink/get.php
+++ /dev/null
@@ -1,83 +0,0 @@
-assign('file',$subPath);
- $tmpl->printPage();
- exit;
- }
- if(OC_Filesystem::is_dir($path)){
- $files = array();
- $rootLength=strlen($root);
- foreach( OC_Files::getdirectorycontent( $path ) as $i ){
- $i['date'] = OC_Util::formatDate($i['mtime'] );
- $i['directory']=substr($i['directory'],$rootLength);
- if($i['directory']=='/'){
- $i['directory']='';
- }
- $files[] = $i;
- }
-
- // Make breadcrumb
- $breadcrumb = array();
- $pathtohere = "/";
- foreach( explode( "/", $subPath ) as $i ){
- if( $i != "" ){
- $pathtohere .= "$i/";
- $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
- }
- }
-
- $breadcrumbNav = new OC_Template( "files_publiclink", "breadcrumb", "" );
- $breadcrumbNav->assign( "breadcrumb", $breadcrumb );
- $breadcrumbNav->assign('token',$token);
-
- $list = new OC_Template( 'files_publiclink', 'files', '' );
- $list->assign( 'files', $files );
- $list->assign('token',$token);
-
- $tmpl = new OC_Template( 'files_publiclink', 'index', 'user' );
- $tmpl->assign('fileList', $list->fetchPage());
- $tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() );
- $tmpl->printPage();
- }else{
- //get time mimetype and set the headers
- $mimetype=OC_Filesystem::getMimeType($path);
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
- header('Content-Disposition: filename="'.basename($path).'"');
- header('Content-Type: ' . $mimetype);
- header('Content-Length: ' . OC_Filesystem::filesize($path));
-
- //download the file
- @ob_clean();
- OC_Filesystem::readfile($path);
- }
-}else{
- header("HTTP/1.0 404 Not Found");
- $tmpl = new OC_Template( '', '404', 'guest' );
- $tmpl->printPage();
- die();
-}
-?>
\ No newline at end of file
diff --git a/apps/files_publiclink/js/admin.js b/apps/files_publiclink/js/admin.js
deleted file mode 100644
index 91ee58beda8..00000000000
--- a/apps/files_publiclink/js/admin.js
+++ /dev/null
@@ -1,45 +0,0 @@
-$(document).ready(function() {
- $( "#path" ).autocomplete({
- source: "../../files/ajax/autocomplete.php",
- minLength: 1
- });
- $(".delete").live('click', function( event ) {
- event.preventDefault();
- var token=$(this).attr('data-token');
- var data="token="+token;
- $.ajax({
- type: 'GET',
- url: 'ajax/deletelink.php',
- cache: false,
- data: data,
- success: function(){
- $('#'+token).remove();
- }
- });
- });
- $('#newlink').submit(function( event ){
- event.preventDefault();
- var path=$('#path').val();
- var expire=0;
- var data='path='+path+'&expire='+expire;
- $.ajax({
- type: 'GET',
- url: 'ajax/makelink.php',
- cache: false,
- data: data,
- success: function(token){
- if(token){
- var html=" ";
- html+=""+path+" ";
- html+=" "
- html+=" "
- html+=" "
- $(html).insertAfter($('#newlink_row'));
- $('#path').val('');
- $('#'+token+' input').focus();
- $('#'+token+' input').select();
- }
- }
- });
- });
-});
diff --git a/apps/files_publiclink/lib_public.php b/apps/files_publiclink/lib_public.php
deleted file mode 100644
index ece0a540d39..00000000000
--- a/apps/files_publiclink/lib_public.php
+++ /dev/null
@@ -1,84 +0,0 @@
-execute(array($token,$path,$user,$expiretime));
- if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'" ';
- $entry .= 'Offending command was: '.$result->getDebugInfo().' ';
- error_log( $entry );
- die( $entry );
- }
- $this->token=$token;
- }
- }
-
- /**
- * get the path of that shared file
- */
- public static function getPath($token) {
- //get the path and the user
- $query=OC_DB::prepare("SELECT user,path FROM *PREFIX*publiclink WHERE token=?");
- $result=$query->execute(array($token));
- $data=$result->fetchAll();
- if(count($data)>0){
- $path=$data[0]['path'];
- $user=$data[0]['user'];
-
- //prepare the filesystem
- OC_Util::setupFS($user);
-
- return $path;
- }else{
- return false;
- }
- }
-
- /**
- * get the token for the public link
- * @return string
- */
- public function getToken(){
- return $this->token;
- }
-
- public static function getLink($path) {
- $query=OC_DB::prepare("SELECT token FROM *PREFIX*publiclink WHERE user=? AND path=? LIMIT 1");
- $result=$query->execute(array(OC_User::getUser(),$path))->fetchAll();
- if(count($result)>0){
- return $result[0]['token'];
- }
- }
-
- /**
- * gets all public links
- * @return array
- */
- static public function getLinks(){
- $query=OC_DB::prepare("SELECT * FROM *PREFIX*publiclink WHERE user=?");
- return $query->execute(array(OC_User::getUser()))->fetchAll();
- }
-
- /**
- * delete a public link
- */
- static public function delete($token){
- $query=OC_DB::prepare("SELECT user,path FROM *PREFIX*publiclink WHERE token=?");
- $result=$query->execute(array($token))->fetchAll();
- if(count($result)>0 and $result[0]['user']==OC_User::getUser()){
- $query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE token=?");
- $query->execute(array($token));
- }
- }
-
- private $token;
-}
-?>
diff --git a/apps/files_publiclink/templates/admin.php b/apps/files_publiclink/templates/admin.php
deleted file mode 100644
index b5c04b838bd..00000000000
--- a/apps/files_publiclink/templates/admin.php
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php
index 249af6cfa31..8d51c146523 100644
--- a/apps/files_sharing/ajax/getitem.php
+++ b/apps/files_sharing/ajax/getitem.php
@@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$userDirectory = "/".OC_User::getUser()."/files";
@@ -30,7 +31,7 @@ while ($source != "" && $source != "/" && $source != "." && $source != $userDire
$source = dirname($source);
}
if (!empty($users)) {
- echo json_encode($users);
+ OC_JSON::encodedPrint($users);
}
-?>
\ No newline at end of file
+?>
diff --git a/apps/files_sharing/ajax/setpermissions.php b/apps/files_sharing/ajax/setpermissions.php
index 8e0bac0b06f..7ee8f0e57bd 100644
--- a/apps/files_sharing/ajax/setpermissions.php
+++ b/apps/files_sharing/ajax/setpermissions.php
@@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$source = "/".OC_User::getUser()."/files".$_GET['source'];
@@ -9,4 +10,4 @@ $uid_shared_with = $_GET['uid_shared_with'];
$permissions = $_GET['permissions'];
OC_Share::setPermissions($source, $uid_shared_with, $permissions);
-?>
\ No newline at end of file
+?>
diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php
index e672cf02403..6a2b45b3a7d 100644
--- a/apps/files_sharing/ajax/share.php
+++ b/apps/files_sharing/ajax/share.php
@@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$userDirectory = "/".OC_User::getUser()."/files";
@@ -26,4 +27,4 @@ foreach ($sources as $source) {
}
}
-?>
\ No newline at end of file
+?>
diff --git a/apps/files_sharing/ajax/unshare.php b/apps/files_sharing/ajax/unshare.php
index b9230d257b7..a19a85cfda3 100644
--- a/apps/files_sharing/ajax/unshare.php
+++ b/apps/files_sharing/ajax/unshare.php
@@ -2,10 +2,11 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$source = "/".OC_User::getUser()."/files".$_GET['source'];
$uid_shared_with = $_GET['uid_shared_with'];
OC_Share::unshare($source, $uid_shared_with);
-?>
\ No newline at end of file
+?>
diff --git a/apps/files_sharing/ajax/userautocomplete.php b/apps/files_sharing/ajax/userautocomplete.php
index 6da7afb659c..21516c3d091 100644
--- a/apps/files_sharing/ajax/userautocomplete.php
+++ b/apps/files_sharing/ajax/userautocomplete.php
@@ -3,10 +3,9 @@ $RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
-if (!OC_User::isLoggedIn()) {
- echo json_encode(array("status" => "error", "data" => array("message" => "Authentication error")));
- exit();
-}
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('files_sharing');
+
$users = array();
$ocusers = OC_User::getUsers();
$self = OC_User::getUser();
@@ -23,6 +22,6 @@ foreach ($groups as $group) {
$users[] = "".$group." ";
}
$users[] = "";
-echo json_encode($users);
+OC_JSON::encodedPrint($users);
?>
diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml
index 2fbb3300f69..abf847b4483 100644
--- a/apps/files_sharing/appinfo/info.xml
+++ b/apps/files_sharing/appinfo/info.xml
@@ -7,4 +7,5 @@
AGPL
Michael Gapczynski
2
-
\ No newline at end of file
+
+
diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php
index a1b6c316cd5..ca95a68c6ce 100644
--- a/apps/files_sharing/get.php
+++ b/apps/files_sharing/get.php
@@ -3,6 +3,7 @@ $RUNTIME_NOAPPS=true; //no need to load the apps
$RUNTIME_NOSETUPFS=true; //don't setup the fs yet
require_once '../../lib/base.php';
+OC_JSON::checkAppEnabled('files_sharing');
require_once 'lib_share.php';
//get the path of the shared file
@@ -29,8 +30,9 @@ if ($source !== false) {
foreach (OC_Files::getdirectorycontent($source) as $i) {
$i['date'] = OC_Util::formatDate($i['mtime'] );
if ($i['type'] == 'file') {
- $i['extention'] = substr($i['name'], strrpos($i['name'], "."));
- $i['basename'] = substr($i['name'], 0, strrpos($i['name'], "."));
+ $fileinfo = pathinfo($i['name']);
+ $i['basename'] = $fileinfo['filename'];
+ $i['extention'] = isset($fileinfo['extension']) ? ('.'.$fileinfo['extension']) : '';
}
$i['directory'] = substr($i['directory'], $rootLength);
if ($i['directory'] == "/") {
@@ -56,9 +58,11 @@ if ($source !== false) {
$list->assign("files", $files);
$list->assign("baseURL", OC_Helper::linkTo("files_sharing", "get.php")."?token=".$token."&path=");
$list->assign("downloadURL", OC_Helper::linkTo("files_sharing", "get.php")."?token=".$token."&path=");
+ $list->assign("readonly", true);
$tmpl = new OC_Template("files", "index", "user");
$tmpl->assign("fileList", $list->fetchPage());
$tmpl->assign("breadcrumb", $breadcrumbNav->fetchPage());
+ $tmpl->assign("readonly", true);
$tmpl->printPage();
} else {
//get time mimetype and set the headers
@@ -67,7 +71,7 @@ if ($source !== false) {
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
- header("Content-Disposition: filename=".basename($source));
+ header('Content-Disposition: filename="'.basename($source).'"');
header("Content-Type: " . $mimetype);
header("Content-Length: " . OC_Filesystem::filesize($source));
//download the file
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 1bd1ac1075b..aaffc3824ea 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -215,9 +215,12 @@ function addUser(uid_shared_with, permissions, parentFolder) {
} else {
var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"');
var style = ((permissions == 0) ? 'style="display:none;"' : '');
- var user = ''+uid_shared_with;
- user += 'can edit ';
- user += ' ';
+ var user = '';
+ user += ' ';
+ user += uid_shared_with;
+ user += ' ';
+ user += 'can edit ';
+ user += ' ';
}
$('#share_with option[value="'+uid_shared_with+'"]').remove();
$('#share_with').trigger('liszt:updated');
diff --git a/apps/files_sharing/list.php b/apps/files_sharing/list.php
index 0a11f438eb7..721620dc922 100644
--- a/apps/files_sharing/list.php
+++ b/apps/files_sharing/list.php
@@ -23,10 +23,8 @@
require_once('../../lib/base.php');
require_once('lib_share.php');
-if (!OC_User::isLoggedIn()){
- header( "Location: ".OC_HELPER::linkTo( "index.php" ));
- exit();
-}
+OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('files_sharing');
OC_App::setActiveNavigationEntry("files_sharing_list");
@@ -36,4 +34,4 @@ $tmpl = new OC_Template("files_sharing", "list", "user");
$tmpl->assign("shared_items", OC_Share::getMySharedItems());
$tmpl->printPage();
-?>
\ No newline at end of file
+?>
diff --git a/apps/files_sharing/templates/list.php b/apps/files_sharing/templates/list.php
index 7faf2cf4ba6..d46ff818ac1 100644
--- a/apps/files_sharing/templates/list.php
+++ b/apps/files_sharing/templates/list.php
@@ -1,11 +1,11 @@
- Your Shared Files
+ t('Your Shared Files');?>
- Item
- Shared With
- Permissions
+ t('Item');?>
+ t('Shared With');?>
+ t('Permissions');?>
@@ -13,8 +13,8 @@
-
- Delete
+ t('Read'); echo($item['permissions'] & OC_SHARE::WRITE ? ", ".$l->t('Edit') : ""); echo($item['permissions'] & OC_SHARE::DELETE ? ", ".$l->t('Delete') : "");?>
+ t('Delete');?>
diff --git a/apps/files_textviewer/appinfo/info.xml b/apps/files_textviewer/appinfo/info.xml
index 209b4140346..becfd5e35c8 100644
--- a/apps/files_textviewer/appinfo/info.xml
+++ b/apps/files_textviewer/appinfo/info.xml
@@ -6,4 +6,5 @@
AGPL
Robin Appelman
2
+
diff --git a/apps/gallery/ajax/cover.php b/apps/gallery/ajax/cover.php
new file mode 100644
index 00000000000..d83f4daaa52
--- /dev/null
+++ b/apps/gallery/ajax/cover.php
@@ -0,0 +1,59 @@
+ $ratio_orig) {
+ $new_height = $thumbnail_width/$ratio_orig;
+ $new_width = $thumbnail_width;
+ } else {
+ $new_width = $thumbnail_height*$ratio_orig;
+ $new_height = $thumbnail_height;
+ }
+
+ $x_mid = $new_width/2; //horizontal middle
+ $y_mid = $new_height/2; //vertical middle
+
+ $process = imagecreatetruecolor(round($new_width), round($new_height));
+
+ imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
+ $thumb = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
+ imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height);
+
+ imagedestroy($process);
+ imagedestroy($myImage);
+ return $thumb;
+}
+
+$box_size = 200;
+$album_name = $_GET['album'];
+$x = $_GET['x'];
+
+$stmt = OC_DB::prepare('SELECT `file_path` FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.`uid_owner` = ? AND `album_name` = ? AND *PREFIX*gallery_photos.`album_id` == *PREFIX*gallery_albums.`album_id`');
+$result = $stmt->execute(array(OC_User::getUser(), $album_name));
+$x = min((int)($x/($box_size/$result->numRows())), $result->numRows()-1); // get image to display
+$result->seek($x); // never throws
+$path = $result->fetchRow();
+$path = $path['file_path'];
+$tmp = OC::$CONFIG_DATADIRECTORY . $path;
+$imagesize = getimagesize($tmp);
+
+header('Content-Type: image/png');
+$image = CroppedThumbnail($tmp, $box_size, $box_size);
+
+imagepng($image);
+imagedestroy($image);
+?>
diff --git a/apps/gallery/ajax/createAlbum.php b/apps/gallery/ajax/createAlbum.php
new file mode 100644
index 00000000000..610f761b72a
--- /dev/null
+++ b/apps/gallery/ajax/createAlbum.php
@@ -0,0 +1,11 @@
+execute(array());
+
+OC_JSON::success(array('name' => $_GET['album_name']));
+
+?>
diff --git a/apps/gallery/ajax/getAlbums.php b/apps/gallery/ajax/getAlbums.php
new file mode 100644
index 00000000000..38bea74636f
--- /dev/null
+++ b/apps/gallery/ajax/getAlbums.php
@@ -0,0 +1,19 @@
+execute(array(OC_User::getUser()));
+
+while ($r = $result->fetchRow()) {
+ $album_name = $r['album_name'];
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE `album_id` = ?');
+ $tmp_res = $stmt->execute(array($r['album_id']));
+ $a[] = array('name' => $album_name, 'numOfItems' => min($tmp_res->numRows(), 10));
+}
+
+OC_JSON::success(array('albums'=>$a));
+
+?>
diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php
new file mode 100644
index 00000000000..d84bf2a7903
--- /dev/null
+++ b/apps/gallery/ajax/getCovers.php
@@ -0,0 +1,69 @@
+ $ratio_orig) {
+ $new_height = $thumbnail_width/$ratio_orig;
+ $new_width = $thumbnail_width;
+ } else {
+ $new_width = $thumbnail_height*$ratio_orig;
+ $new_height = $thumbnail_height;
+ }
+
+ $x_mid = $new_width/2; //horizontal middle
+ $y_mid = $new_height/2; //vertical middle
+
+ $process = imagecreatetruecolor(round($new_width), round($new_height));
+
+ imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
+ imagecopyresampled($tgtImg, $process, $shift, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height);
+
+ imagedestroy($process);
+ imagedestroy($myImage);
+}
+
+$box_size = 200;
+$album_name= $_GET['album_name'];
+
+$stmt = OC_DB::prepare('SELECT `file_path` FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.`uid_owner` = ? AND `album_name` = ? AND *PREFIX*gallery_photos.`album_id` = *PREFIX*gallery_albums.`album_id`');
+$result = $stmt->execute(array(OC_User::getUser(), $album_name));
+
+$numOfItems = min($result->numRows(),10);
+
+$targetImg = imagecreatetruecolor($numOfItems*$box_size, $box_size);
+$counter = 0;
+while (($i = $result->fetchRow()) && $counter < $numOfItems) {
+ $imagePath = OC::$CONFIG_DATADIRECTORY . $i['file_path'];
+ CroppedThumbnail($imagePath, $box_size, $box_size, $targetImg, $counter*$box_size);
+ $counter++;
+}
+
+header('Content-Type: image/png');
+
+$offset = 3600 * 24;
+// calc the string in GMT not localtime and add the offset
+header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
+header('Cache-Control: max-age=3600, must-revalidate');
+header('Pragma: public');
+
+imagepng($targetImg);
+imagedestroy($targetImg);
+?>
diff --git a/apps/gallery/ajax/scanForAlbums.php b/apps/gallery/ajax/scanForAlbums.php
new file mode 100644
index 00000000000..de0b141a367
--- /dev/null
+++ b/apps/gallery/ajax/scanForAlbums.php
@@ -0,0 +1,11 @@
+ OC_GALLERY_SCANNER::scan('')));
+//OC_JSON::success(array('albums' => array(array('name' => 'test', 'imagesCount' => 1, 'images' => array('dupa')))));
+
+?>
diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php
new file mode 100644
index 00000000000..f24782390f6
--- /dev/null
+++ b/apps/gallery/ajax/thumbnail.php
@@ -0,0 +1,55 @@
+ $ratio_orig) {
+ $new_height = $thumbnail_width/$ratio_orig;
+ $new_width = $thumbnail_width;
+ } else {
+ $new_width = $thumbnail_height*$ratio_orig;
+ $new_height = $thumbnail_height;
+ }
+
+ $x_mid = $new_width/2; //horizontal middle
+ $y_mid = $new_height/2; //vertical middle
+
+ $process = imagecreatetruecolor(round($new_width), round($new_height));
+
+ imagecopyresampled($process, $myImage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
+ $thumb = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
+ imagecopyresampled($thumb, $process, 0, 0, ($x_mid-($thumbnail_width/2)), ($y_mid-($thumbnail_height/2)), $thumbnail_width, $thumbnail_height, $thumbnail_width, $thumbnail_height);
+
+ imagedestroy($process);
+ imagedestroy($myImage);
+ return $thumb;
+}
+
+$box_size = 200;
+$img = $_GET['img'];
+
+$tmp = OC::$CONFIG_DATADIRECTORY . $img;
+
+header('Content-Type: image/png');
+$image = CroppedThumbnail($tmp, $box_size, $box_size);
+
+imagepng($image);
+imagedestroy($image);
+?>
diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php
new file mode 100644
index 00000000000..8f855c470e5
--- /dev/null
+++ b/apps/gallery/appinfo/app.php
@@ -0,0 +1,27 @@
+ 20,
+ 'id' => 'gallery',
+ 'name' => 'Gallery'));
+
+OC_App::addNavigationEntry( array(
+ 'id' => 'gallery_index',
+ 'order' => 20,
+ 'href' => OC_Helper::linkTo('gallery', 'index.php'),
+ 'icon' => OC_Helper::imagePath('core', 'places/picture.svg'),
+ 'name' => 'Gallery'));
+
+ class OC_GallerySearchProvider extends OC_Search_Provider{
+ function search($query){
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name LIKE ?');
+ $result = $stmt->execute(array(OC_User::getUser(),'%'.$query.'%'));
+ $results=array();
+ while($row=$result->fetchRow()){
+ $results[]=new OC_Search_Result($row['album_name'],'',OC_Helper::linkTo('apps/gallery', 'index.php?view='.$row['album_name']),'Galleries');
+ }
+ return $results;
+ }
+}
+
+new OC_GallerySearchProvider();
+?>
diff --git a/apps/gallery/appinfo/database.xml b/apps/gallery/appinfo/database.xml
new file mode 100644
index 00000000000..fd55b3a6fb4
--- /dev/null
+++ b/apps/gallery/appinfo/database.xml
@@ -0,0 +1,58 @@
+
+
+ *dbname*
+ true
+ false
+ latin1
+
+ *dbprefix*gallery_albums
+
+
+ album_id
+ integer
+ 0
+ true
+ 1
+ 4
+
+
+ uid_owner
+ text
+ true
+ 64
+
+
+ album_name
+ text
+ true
+ 100
+
+
+
+
+ *dbprefix*gallery_photos
+
+
+ photo_id
+ integer
+ 0
+ true
+ 1
+ 4
+
+
+ album_id
+ integer
+ 0
+ true
+ 4
+
+
+ file_path
+ text
+ true
+ 100
+
+
+
+
diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml
new file mode 100644
index 00000000000..054ddb6f139
--- /dev/null
+++ b/apps/gallery/appinfo/info.xml
@@ -0,0 +1,10 @@
+
+
+ gallery
+ Gallery
+ 0.1
+ AGPL
+ Bartosz Przybylski
+ 2
+
+
\ No newline at end of file
diff --git a/apps/gallery/css/styles.css b/apps/gallery/css/styles.css
new file mode 100644
index 00000000000..03b179138e6
--- /dev/null
+++ b/apps/gallery/css/styles.css
@@ -0,0 +1,23 @@
+div#gallery_list {
+ margin: 90pt 20pt;
+}
+
+div#gallery_album_box {
+ width: 200px;
+ text-align: center;
+ border: 0;
+ float: left;
+ margin: 5pt;
+}
+
+div#gallery_album_box h1 {
+ font-size: 12pt;
+ font-family: Arial;
+}
+
+div#gallery_album_cover {
+ width: 199px;
+ height: 199px;
+ border: solid 1px black;
+}
+
diff --git a/apps/gallery/index.php b/apps/gallery/index.php
new file mode 100644
index 00000000000..87fdafcf13c
--- /dev/null
+++ b/apps/gallery/index.php
@@ -0,0 +1,34 @@
+execute(array(OC_User::getUser()));
+
+ $r = array();
+ while ($row = $result->fetchRow())
+ $r[] = $row;
+
+ $tmpl = new OC_Template( 'gallery', 'index', 'user' );
+ $tmpl->assign('r', $r);
+ $tmpl->printPage();
+} else {
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos, *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name = ? AND *PREFIX*gallery_albums.album_id = *PREFIX*gallery_photos.album_id');
+
+ $result = $stmt->execute(array(OC_User::getUser(), $_GET['view']));
+
+ $photos = array();
+ while ($p = $result->fetchRow())
+ $photos[] = $p['file_path'];
+
+ $tmpl = new OC_Template( 'gallery', 'view_album', 'user' );
+ $tmpl->assign('photos', $photos);
+ $tmpl->assign('albumName', $_GET['view']);
+ $tmpl->printPage();
+}
+?>
diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js
new file mode 100644
index 00000000000..776feae32cc
--- /dev/null
+++ b/apps/gallery/js/album_cover.js
@@ -0,0 +1,41 @@
+var actual_cover;
+$(document).ready(function() {
+ $.getJSON('ajax/getAlbums.php', function(r) {
+ if (r.status == 'success') {
+ for (var i in r.albums) {
+ var a = r.albums[i];
+ Albums.add(a.name, a.numOfItems);
+ }
+ var targetDiv = document.getElementById('gallery_list');
+ if (targetDiv) {
+ Albums.display(targetDiv);
+ } else {
+ alert('Error occured: no such layer `gallery_list`');
+ }
+ } else {
+ alert('Error occured: ' + r.message);
+ }
+ });
+});
+
+function createNewAlbum() {
+ var name = prompt("album name", "");
+ if (name != null && name != "") {
+ $.getJSON("ajax/createAlbum.php", {album_name: name}, function(r) {
+ if (r.status == "success") {
+ var v = ''+r.name+' ';
+ $('div#gallery_list').append(v);
+ }
+ });
+ }
+}
+
+function scanForAlbums() {
+ $.getJSON('ajax/scanForAlbums.php', function(r) {
+ if (r.status == 'success') {
+ window.location.reload(true);
+ } else {
+ alert('Error occured: ' + r.message);
+ }
+ });
+}
diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js
new file mode 100644
index 00000000000..7ab243ededf
--- /dev/null
+++ b/apps/gallery/js/albums.js
@@ -0,0 +1,80 @@
+Albums={
+ // album item in this array should look as follow
+ // {name: string,
+ // numOfCovers: int}
+ //
+ // previews array should be an array of base64 decoded images
+ // to display to user as preview picture when scrolling throught
+ // the album cover
+ albums:new Array(),
+ // add simply adds new album to internal structure
+ // however albums names must be unique so other
+ // album with the same name wont be insered,
+ // and false will be returned
+ // true on success
+ add: function(album_name, num) {
+ for (var a in Albums.albums) {
+ if (a.name == album_name) {
+ return false;
+ }
+ }
+ Albums.albums.push({name: album_name, numOfCovers: num});
+ return true;
+ },
+ // remove element with given name
+ // returns remove element or undefined if no such element was present
+ remove: function(name) {
+ var i = -1, tmp = 0;
+ for (var a in Albums.albums) {
+ if (a.name == name) {
+ i = tmp;
+ break;
+ }
+ tmp++;
+ }
+ if (i != -1) {
+ return Albums.albums.splice(i,1);
+ }
+ return undefined;
+ },
+ // return element which match given name
+ // of undefined if such element do not exist
+ find: function(name) {
+ var i = -1, tmp = 0;
+ for (var k in Albums.albums) {
+ var a = Albums.albums[k];
+ if (a.name == name) {
+ i = tmp;
+ break;
+ }
+ tmp++;
+ }
+ if (i != -1) {
+ return Albums.albums[i];
+ }
+ return undefined;
+ },
+ // displays gallery in linear representation
+ // on given element, and apply default styles for gallery
+ display: function(element) {
+ var displayTemplate = '';
+ for (var i in Albums.albums) {
+ var a = Albums.albums[i];
+ var local = $(displayTemplate.replace(/\*NAME\*/g, a.name));
+ local.css('background-repeat', 'no-repeat');
+ local.css('background-position', '0 0');
+ local.css('background-image','url("ajax/getCovers.php?album_name='+a.name+'")');
+ local.mousemove(function(e) {
+ var albumMetadata = Albums.find(this.title);
+ if (albumMetadata == undefined) {
+ return;
+ }
+ var x = Math.min(Math.floor((e.clientX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)), albumMetadata.numOfCovers-1);
+ x *= this.offsetWidth;
+ $(this).css('background-position', -x+'px 0');
+ });
+ $(element).append(local);
+ }
+ }
+
+}
diff --git a/apps/gallery/lib_scanner.php b/apps/gallery/lib_scanner.php
new file mode 100644
index 00000000000..5490c4a55ad
--- /dev/null
+++ b/apps/gallery/lib_scanner.php
@@ -0,0 +1,57 @@
+ $path, 'imagesCount' => 0, 'images' => array());
+ $current_album['name'] = str_replace('/', '.', str_replace(OC::$CONFIG_DATADIRECTORY, '', $current_album['name']));
+ $current_album['name'] = ($current_album['name']==='')?'main':$current_album['name'];
+
+ if ($dh = OC_Filesystem::opendir($path)) {
+ while (($filename = readdir($dh)) !== false) {
+ $filepath = $path.'/'.$filename;
+ if (substr($filename, 0, 1) == '.') continue;
+ if (OC_Filesystem::is_dir($filepath)) {
+ self::scanDir($filepath, $albums);
+ } elseif (self::isPhoto($path.'/'.$filename)) {
+ $current_album['images'][] = $filepath;
+ }
+ }
+ }
+ $current_album['imagesCount'] = count($current_album['images']);
+ $albums[] = $current_album;
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ? AND `album_name` = ?');
+ $result = $stmt->execute(array(OC_User::getUser(), $current_album['name']));
+ if ($result->numRows() == 0 && count($current_album['images'])) {
+ $stmt = OC_DB::prepare('REPLACE INTO *PREFIX*gallery_albums (`uid_owner`, `album_name`) VALUES (?, ?)');
+ $stmt->execute(array(OC_User::getUser(), $current_album['name']));
+ }
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ? AND `album_name` = ?');
+ $result = $stmt->execute(array(OC_User::getUser(), $current_album['name']));
+ $albumId = $result->fetchRow();
+ $albumId = $albumId['album_id'];
+ foreach ($current_album['images'] as $img) {
+ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE `album_id` = ? AND `file_path` = ?');
+ $result = $stmt->execute(array($albumId, $img));
+ if ($result->numRows() == 0) {
+ $stmt = OC_DB::prepare('REPLACE INTO *PREFIX*gallery_photos (`album_id`, `file_path`) VALUES (?, ?)');
+ $stmt->execute(array($albumId, $img));
+ }
+ }
+ }
+
+ public static function isPhoto($filename) {
+ if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/")
+ return 1;
+ return 0;
+ }
+}
+?>
diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php
new file mode 100644
index 00000000000..0e89e448768
--- /dev/null
+++ b/apps/gallery/templates/index.php
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php
new file mode 100644
index 00000000000..ea2969e0110
--- /dev/null
+++ b/apps/gallery/templates/view_album.php
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php
index 3b4932728da..29f61a2207f 100644
--- a/apps/media/ajax/api.php
+++ b/apps/media/ajax/api.php
@@ -27,6 +27,7 @@ header('Content-type: text/html; charset=UTF-8') ;
$RUNTIME_NOAPPS=true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('media');
require_once('../lib_collection.php');
require_once('../lib_scanner.php');
@@ -41,7 +42,6 @@ if(!isset($_POST['action']) and isset($_GET['action'])){
foreach($arguments as &$argument){
$argument=stripslashes($argument);
}
-global $CONFIG_DATADIRECTORY;
@ob_clean();
if(!isset($arguments['artist'])){
$arguments['artist']=0;
@@ -68,7 +68,7 @@ if($arguments['action']){
$data['artists']=OC_MEDIA_COLLECTION::getArtists();
$data['albums']=OC_MEDIA_COLLECTION::getAlbums();
$data['songs']=OC_MEDIA_COLLECTION::getSongs();
- echo json_encode($data);
+ OC_JSON::encodedPrint($data);
break;
case 'scan':
OC_DB::beginTransaction();
@@ -82,13 +82,13 @@ if($arguments['action']){
echo (OC_MEDIA_SCANNER::scanFile($arguments['path']))?'true':'false';
break;
case 'get_artists':
- echo json_encode(OC_MEDIA_COLLECTION::getArtists($arguments['search']));
+ OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getArtists($arguments['search']));
break;
case 'get_albums':
- echo json_encode(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'],$arguments['search']));
+ OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'],$arguments['search']));
break;
case 'get_songs':
- echo json_encode(OC_MEDIA_COLLECTION::getSongs($arguments['artist'],$arguments['album'],$arguments['search']));
+ OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getSongs($arguments['artist'],$arguments['album'],$arguments['search']));
break;
case 'get_path_info':
if(OC_Filesystem::file_exists($arguments['path'])){
@@ -101,7 +101,7 @@ if($arguments['action']){
$song=OC_MEDIA_COLLECTION::getSong($songId);
$song['artist']=OC_MEDIA_COLLECTION::getArtistName($song['song_artist']);
$song['album']=OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
- echo json_encode($song);
+ OC_JSON::encodedPrint($song);
}
}
break;
@@ -130,12 +130,12 @@ if($arguments['action']){
OC_Filesystem::readfile($arguments['path']);
exit;
case 'find_music':
- echo json_encode(findMusic());
+ OC_JSON::encodedPrint(findMusic());
exit;
}
}
-function findMusic($path='/'){
+function findMusic($path=''){
$music=array();
$dh=OC_Filesystem::opendir($path);
if($dh){
@@ -155,4 +155,4 @@ function findMusic($path='/'){
return $music;
}
-?>
\ No newline at end of file
+?>
diff --git a/apps/media/ajax/autoupdate.php b/apps/media/ajax/autoupdate.php
index ded1fd02bc3..ff0923ca032 100644
--- a/apps/media/ajax/autoupdate.php
+++ b/apps/media/ajax/autoupdate.php
@@ -28,12 +28,13 @@ $RUNTIME_NOAPPS=true;
$RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
+OC_JSON::checkAppEnabled('media');
-error_log($_GET['autoupdate']);
+if(defined("DEBUG") && DEBUG) {error_log($_GET['autoupdate']);}
$autoUpdate=(isset($_GET['autoupdate']) and $_GET['autoupdate']=='true');
-error_log((integer)$autoUpdate);
+if(defined("DEBUG") && DEBUG) {error_log((integer)$autoUpdate);}
OC_Preferences::setValue(OC_User::getUser(),'media','autoupdate',(integer)$autoUpdate);
-echo json_encode( array( "status" => "success", "data" => $autoUpdate));
-?>
\ No newline at end of file
+OC_JSON::success(array('data' => $autoUpdate));
+?>
diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php
index 0d36217bd4d..475a33500f4 100644
--- a/apps/media/appinfo/app.php
+++ b/apps/media/appinfo/app.php
@@ -25,8 +25,9 @@ $l=new OC_L10N('media');
require_once('apps/media/lib_media.php');
OC_Util::addScript('media','loader');
+OC_APP::registerPersonal('media','settings');
OC_App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' ));
-OC_App::addNavigationEntry( array( 'id' => 'media_index', 'order' => 2, 'href' => OC_Helper::linkTo( 'media', 'index.php' ), 'icon' => OC_Helper::imagePath( 'core', 'filetypes/audio.svg' ), 'name' => $l->t('Music') ));
+OC_App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OC_Helper::linkTo('media', 'index.php'), 'icon' => OC_Helper::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music')));
?>
diff --git a/apps/media/appinfo/info.xml b/apps/media/appinfo/info.xml
index 044abade53f..795c9a4dd71 100644
--- a/apps/media/appinfo/info.xml
+++ b/apps/media/appinfo/info.xml
@@ -7,4 +7,5 @@
AGPL
Robin Appelman
2
-
\ No newline at end of file
+
+
diff --git a/apps/media/css/music.css b/apps/media/css/music.css
index 59d10f74db5..67d56075194 100644
--- a/apps/media/css/music.css
+++ b/apps/media/css/music.css
@@ -1,6 +1,6 @@
#controls ul.jp-controls { padding:0; }
#controls ul.jp-controls li { display:inline; }
-#controls ul.jp-controls li a { position:absolute; padding:.8em 1em; }
+#controls ul.jp-controls li a { position:absolute; padding:.8em 1em .8em 0; }
a.jp-play, a.jp-pause { left:2.5em; }
a.jp-pause { display:none; }
a.jp-next { left:5em; }
@@ -9,32 +9,37 @@ div.jp-progress { position:absolute; overflow:hidden; top:.5em; left:8em; width:
div.jp-seek-bar { background:#eee; width:0; height:100%; cursor:pointer; }
div.jp-play-bar { background:#ccc; width:0; height:100%; }
div.jp-seeking-bg { background:url("../img/pbar-ani.gif"); }
-div.jp-current-time,div.jp-duration { position:absolute; font-size:.64em; font-style:oblique; top:1em; left:13.5em; width:22em; }
+div.jp-current-time,div.jp-duration { position:absolute; font-size:.64em; font-style:oblique; top:0.9em; left:13.5em; }
+div.jp-duration { display: none }
+div.jp-current-song { left: 33em; position: absolute; top: 0.9em; }
div.jp-duration { text-align:right; }
a.jp-mute,a.jp-unmute { left:24em; }
div.jp-volume-bar { position:absolute; overflow:hidden; background:#eee; width:4em; height:0.4em; cursor:pointer; top:1.3em; left:27em; }
div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; }
-#collection { padding-top:1em; position:relative; width:70em; float:left; }
+#collection { padding-top:1em; position:relative; width:100%; float:left; }
#collection li.album,#collection li.song { margin-left:3em; }
#leftcontent img.remove { display:none; float:right; cursor:pointer; }
#leftcontent li:hover img.remove { display:inline; }
+#leftcontent li {white-space: normal; }
#collection li button { float:right; }
#collection li,#playlist li { list-style-type:none; }
.template { display:none; }
+.collection_playing { background:#eee; }
#collection li { padding-right:10px; }
#searchresults input.play, #searchresults input.add { float:left; height:1em; width:1em; }
#collection tr.collapsed td.album, #collection tr.collapsed td.title { color:#ddd; }
-a.expander { }
-tr.active { background-color:#eee; }
-tr.artist, tr.artist td {
- border-top: 1px solid lightgrey;
-}
-tr.album td.artist {
- padding-left: 20px;
-}
-tr.song td.artist {
- padding-left: 40px;
-}
+a.expander { float:right; padding:0 1em; }
+tr.active td { background-color:#eee; font-weight:bold; }
+tr td { border-top:1px solid #eee; height:2.2em; }
+tr .artist img { vertical-align:middle; }
+tr.album td.artist { padding-left:1em; }
+tr.song td.artist { padding-left:2em; }
+.add {margin: 0 0.5em 0 0; }
+
+#scan { position:absolute; right:13.5em; top:0em; }
+#scan .start { position:relative; display:inline; float:right; }
+#scan .stop { position:relative; display:inline; float:right; }
+#scan #scanprogressbar { position:relative; display:inline-block; width:10em; height:1.5em; top:.4em; }
diff --git a/apps/media/css/player.css b/apps/media/css/player.css
index 8b137891791..c4a098543d1 100644
--- a/apps/media/css/player.css
+++ b/apps/media/css/player.css
@@ -1 +1,23 @@
-
+#playercontrols{
+ display:inline;
+ margin-left:1em;
+ width:7em;
+ height:1em;
+ position:fixed;
+ top:auto;
+ left:auto;
+ background:transparent;
+ box-shadow:none;
+ -webkit-box-shadow:none;
+}
+#playercontrols li{
+ float:left;
+}
+#playercontrols a, #playercontrols li{
+ margin:0px;
+ padding:0;
+ left:0;
+ background:transparent !important;
+ border:none !important;
+ text-shadow:none;
+}
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.audioinfo.class.php b/apps/media/getID3/demos/demo.audioinfo.class.php
deleted file mode 100644
index d38ec19807f..00000000000
--- a/apps/media/getID3/demos/demo.audioinfo.class.php
+++ /dev/null
@@ -1,319 +0,0 @@
-Info('file.flac'); |
-// +----------------------------------------------------------------------+
-// | Authors: Allan Hansen |
-// +----------------------------------------------------------------------+
-//
-
-
-
-/**
-* getID3() settings
-*/
-
-require_once('../getid3/getid3.php');
-
-
-
-
-/**
-* Class for extracting information from audio files with getID3().
-*/
-
-class AudioInfo {
-
- /**
- * Private variables
- */
- var $result = NULL;
- var $info = NULL;
-
-
-
-
- /**
- * Constructor
- */
-
- function AudioInfo() {
-
- // Initialize getID3 engine
- $this->getID3 = new getID3;
- $this->getID3->option_md5_data = true;
- $this->getID3->option_md5_data_source = true;
- $this->getID3->encoding = 'UTF-8';
- }
-
-
-
-
- /**
- * Extract information - only public function
- *
- * @access public
- * @param string file Audio file to extract info from.
- */
-
- function Info($file) {
-
- // Analyze file
- $this->info = $this->getID3->analyze($file);
-
- // Exit here on error
- if (isset($this->info['error'])) {
- return array ('error' => $this->info['error']);
- }
-
- // Init wrapper object
- $this->result = array ();
- $this->result['format_name'] = @$this->info['fileformat'].'/'.@$this->info['audio']['dataformat'].(isset($this->info['video']['dataformat']) ? '/'.@$this->info['video']['dataformat'] : '');
- $this->result['encoder_version'] = @$this->info['audio']['encoder'];
- $this->result['encoder_options'] = @$this->info['audio']['encoder_options'];
- $this->result['bitrate_mode'] = @$this->info['audio']['bitrate_mode'];
- $this->result['channels'] = @$this->info['audio']['channels'];
- $this->result['sample_rate'] = @$this->info['audio']['sample_rate'];
- $this->result['bits_per_sample'] = @$this->info['audio']['bits_per_sample'];
- $this->result['playing_time'] = @$this->info['playtime_seconds'];
- $this->result['avg_bit_rate'] = @$this->info['audio']['bitrate'];
- $this->result['tags'] = @$this->info['tags'];
- $this->result['comments'] = @$this->info['comments'];
- $this->result['warning'] = @$this->info['warning'];
- $this->result['md5'] = @$this->info['md5_data'];
-
- // Post getID3() data handling based on file format
- $method = @$this->info['fileformat'].'Info';
- if (@$this->info['fileformat'] && method_exists($this, $method)) {
- $this->$method();
- }
-
- return $this->result;
- }
-
-
-
-
- /**
- * post-getID3() data handling for AAC files.
- *
- * @access private
- */
-
- function aacInfo() {
- $this->result['format_name'] = 'AAC';
- }
-
-
-
-
- /**
- * post-getID3() data handling for Wave files.
- *
- * @access private
- */
-
- function riffInfo() {
- if ($this->info['audio']['dataformat'] == 'wav') {
-
- $this->result['format_name'] = 'Wave';
-
- } else if (ereg('^mp[1-3]$', $this->info['audio']['dataformat'])) {
-
- $this->result['format_name'] = strtoupper($this->info['audio']['dataformat']);
-
- } else {
-
- $this->result['format_name'] = 'riff/'.$this->info['audio']['dataformat'];
-
- }
- }
-
-
-
-
- /**
- * * post-getID3() data handling for FLAC files.
- *
- * @access private
- */
-
- function flacInfo() {
- $this->result['format_name'] = 'FLAC';
- }
-
-
-
-
-
- /**
- * post-getID3() data handling for Monkey's Audio files.
- *
- * @access private
- */
-
- function macInfo() {
- $this->result['format_name'] = 'Monkey\'s Audio';
- }
-
-
-
-
-
- /**
- * post-getID3() data handling for Lossless Audio files.
- *
- * @access private
- */
-
- function laInfo() {
- $this->result['format_name'] = 'La';
- }
-
-
-
-
-
- /**
- * post-getID3() data handling for Ogg Vorbis files.
- *
- * @access private
- */
-
- function oggInfo() {
- if ($this->info['audio']['dataformat'] == 'vorbis') {
-
- $this->result['format_name'] = 'Ogg Vorbis';
-
- } else if ($this->info['audio']['dataformat'] == 'flac') {
-
- $this->result['format_name'] = 'Ogg FLAC';
-
- } else if ($this->info['audio']['dataformat'] == 'speex') {
-
- $this->result['format_name'] = 'Ogg Speex';
-
- } else {
-
- $this->result['format_name'] = 'Ogg '.$this->info['audio']['dataformat'];
-
- }
- }
-
-
-
-
- /**
- * post-getID3() data handling for Musepack files.
- *
- * @access private
- */
-
- function mpcInfo() {
- $this->result['format_name'] = 'Musepack';
- }
-
-
-
-
- /**
- * post-getID3() data handling for MPEG files.
- *
- * @access private
- */
-
- function mp3Info() {
- $this->result['format_name'] = 'MP3';
- }
-
-
-
-
- /**
- * post-getID3() data handling for MPEG files.
- *
- * @access private
- */
-
- function mp2Info() {
- $this->result['format_name'] = 'MP2';
- }
-
-
-
-
-
- /**
- * post-getID3() data handling for MPEG files.
- *
- * @access private
- */
-
- function mp1Info() {
- $this->result['format_name'] = 'MP1';
- }
-
-
-
-
- /**
- * post-getID3() data handling for WMA files.
- *
- * @access private
- */
-
- function asfInfo() {
- $this->result['format_name'] = strtoupper($this->info['audio']['dataformat']);
- }
-
-
-
- /**
- * post-getID3() data handling for Real files.
- *
- * @access private
- */
-
- function realInfo() {
- $this->result['format_name'] = 'Real';
- }
-
-
-
-
-
- /**
- * post-getID3() data handling for VQF files.
- *
- * @access private
- */
-
- function vqfInfo() {
- $this->result['format_name'] = 'VQF';
- }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.basic.php b/apps/media/getID3/demos/demo.basic.php
deleted file mode 100644
index ddd56e51521..00000000000
--- a/apps/media/getID3/demos/demo.basic.php
+++ /dev/null
@@ -1,38 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.basic.php - part of getID3() //
-// Sample script showing most basic use of getID3() //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-// include getID3() library (can be in a different directory if full path is specified)
-require_once('../getid3/getid3.php');
-
-// Initialize getID3 engine
-$getID3 = new getID3;
-
-// Analyze file and store returned data in $ThisFileInfo
-$ThisFileInfo = $getID3->analyze($filename);
-
-// Optional: copies data from all subarrays of [tags] into [comments] so
-// metadata is all available in one location for all tag formats
-// metainformation is always available under [tags] even if this is not called
-getid3_lib::CopyTagsToComments($ThisFileInfo);
-
-// Output desired information in whatever format you want
-// Note: all entries in [comments] or [tags] are arrays of strings
-// See structure.txt for information on what information is available where
-// or check out the output of /demos/demo.browse.php for a particular file
-// to see the full detail of what information is returned where in the array
-echo @$ThisFileInfo['comments_html']['artist'][0]; // artist from any/all available tag formats
-echo @$ThisFileInfo['tags']['id3v2']['title'][0]; // title from ID3v2
-echo @$ThisFileInfo['audio']['bitrate']; // audio bitrate
-echo @$ThisFileInfo['playtime_string']; // playtime in minutes:seconds, formatted string
-
-?>
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.browse.php b/apps/media/getID3/demos/demo.browse.php
deleted file mode 100644
index 5d027b63b2f..00000000000
--- a/apps/media/getID3/demos/demo.browse.php
+++ /dev/null
@@ -1,679 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.browse.php - part of getID3() //
-// Sample script for browsing/scanning files and displaying //
-// information returned by getID3() //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-//die('Due to a security issue, this demo has been disabled. It can be enabled by removing line '.__LINE__.' in demos/'.basename(__FILE__));
-
-
-/////////////////////////////////////////////////////////////////
-// set predefined variables as if magic_quotes_gpc was off,
-// whether the server's got it or not:
-UnifyMagicQuotes(false);
-/////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////
-// showfile is used to display embedded images from table_var_dump()
-// md5 of requested file is required to prevent abuse where any
-// random file on the server could be viewed
-if (@$_REQUEST['showfile']) {
- if (is_readable($_REQUEST['showfile'])) {
- if (md5_file($_REQUEST['showfile']) == @$_REQUEST['md5']) {
- readfile($_REQUEST['showfile']);
- exit;
- }
- }
- die('Cannot display "'.$_REQUEST['showfile'].'"');
-}
-/////////////////////////////////////////////////////////////////
-
-
-if (!function_exists('getmicrotime')) {
- function getmicrotime() {
- list($usec, $sec) = explode(' ', microtime());
- return ((float) $usec + (float) $sec);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-
-$writescriptfilename = 'demo.write.php';
-
-require_once('../getid3/getid3.php');
-
-// Needed for windows only
-define('GETID3_HELPERAPPSDIR', 'C:/helperapps/');
-
-// Initialize getID3 engine
-$getID3 = new getID3;
-$getID3->setOption(array('encoding' => 'UTF-8'));
-
-$getID3checkColor_Head = 'CCCCDD';
-$getID3checkColor_DirectoryLight = 'FFCCCC';
-$getID3checkColor_DirectoryDark = 'EEBBBB';
-$getID3checkColor_FileLight = 'EEEEEE';
-$getID3checkColor_FileDark = 'DDDDDD';
-$getID3checkColor_UnknownLight = 'CCCCFF';
-$getID3checkColor_UnknownDark = 'BBBBDD';
-
-
-///////////////////////////////////////////////////////////////////////////////
-
-
-header('Content-Type: text/html; charset=UTF-8');
-ob_start();
-echo '';
-echo '';
-echo 'getID3() - /demo/demo.browse.php (sample script) ';
-echo ' ';
-echo '';
-
-if (isset($_REQUEST['deletefile'])) {
- if (file_exists($_REQUEST['deletefile'])) {
- if (unlink($_REQUEST['deletefile'])) {
- $deletefilemessage = 'Successfully deleted '.addslashes($_REQUEST['deletefile']);
- } else {
- $deletefilemessage = 'FAILED to delete '.addslashes($_REQUEST['deletefile']).' - error deleting file';
- }
- } else {
- $deletefilemessage = 'FAILED to delete '.addslashes($_REQUEST['deletefile']).' - file does not exist';
- }
- if (isset($_REQUEST['noalert'])) {
- echo ''.$deletefilemessage.' ';
- } else {
- echo '';
- }
-}
-
-
-if (isset($_REQUEST['filename'])) {
-
- if (!file_exists($_REQUEST['filename']) || !is_file($_REQUEST['filename'])) {
- die(getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-8', $_REQUEST['filename'].' does not exist'));
- }
- $starttime = getmicrotime();
-
- //$getID3->setOption(array(
- // 'option_md5_data' => $AutoGetHashes,
- // 'option_sha1_data' => $AutoGetHashes,
- //));
- $ThisFileInfo = $getID3->analyze($_REQUEST['filename']);
- $AutoGetHashes = (bool) ((@$ThisFileInfo['filesize'] > 0) && ($ThisFileInfo['filesize'] < (50 * 1048576))); // auto-get md5_data, md5_file, sha1_data, sha1_file if filesize < 50MB, and NOT zero (which may indicate a file>2GB)
- if ($AutoGetHashes) {
- $ThisFileInfo['md5_file'] = getid3_lib::md5_file($_REQUEST['filename']);
- $ThisFileInfo['sha1_file'] = getid3_lib::sha1_file($_REQUEST['filename']);
- }
-
-
- getid3_lib::CopyTagsToComments($ThisFileInfo);
-
- $listdirectory = dirname(getid3_lib::SafeStripSlashes($_REQUEST['filename']));
- $listdirectory = realpath($listdirectory); // get rid of /../../ references
-
- if (GETID3_OS_ISWINDOWS) {
- // this mostly just gives a consistant look to Windows and *nix filesystems
- // (windows uses \ as directory seperator, *nix uses /)
- $listdirectory = str_replace('\\', '/', $listdirectory.'/');
- }
-
- if (strstr($_REQUEST['filename'], 'http://') || strstr($_REQUEST['filename'], 'ftp://')) {
- echo 'Cannot browse remote filesystems ';
- } else {
- echo 'Browse: '.getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-8', $listdirectory).' ';
- }
-
- echo table_var_dump($ThisFileInfo);
- $endtime = getmicrotime();
- echo 'File parsed in '.number_format($endtime - $starttime, 3).' seconds. ';
-
-} else {
-
- $listdirectory = (isset($_REQUEST['listdirectory']) ? getid3_lib::SafeStripSlashes($_REQUEST['listdirectory']) : '.');
- $listdirectory = realpath($listdirectory); // get rid of /../../ references
- $currentfulldir = $listdirectory.'/';
-
- if (GETID3_OS_ISWINDOWS) {
- // this mostly just gives a consistant look to Windows and *nix filesystems
- // (windows uses \ as directory seperator, *nix uses /)
- $currentfulldir = str_replace('\\', '/', $listdirectory.'/');
- }
-
- if ($handle = @opendir($listdirectory)) {
-
- echo str_repeat(' ', 300); // IE buffers the first 300 or so chars, making this progressive display useless - fill the buffer with spaces
- echo 'Processing';
-
- $starttime = getmicrotime();
-
- $TotalScannedUnknownFiles = 0;
- $TotalScannedKnownFiles = 0;
- $TotalScannedPlaytimeFiles = 0;
- $TotalScannedBitrateFiles = 0;
- $TotalScannedFilesize = 0;
- $TotalScannedPlaytime = 0;
- $TotalScannedBitrate = 0;
- $FilesWithWarnings = 0;
- $FilesWithErrors = 0;
-
- while ($file = readdir($handle)) {
- $currentfilename = $listdirectory.'/'.$file;
- set_time_limit(30); // allocate another 30 seconds to process this file - should go much quicker than this unless intense processing (like bitrate histogram analysis) is enabled
- echo ' .'; // progress indicator dot
- flush(); // make sure the dot is shown, otherwise it's useless
-
- switch ($file) {
- case '..':
- $ParentDir = realpath($file.'/..').'/';
- if (GETID3_OS_ISWINDOWS) {
- $ParentDir = str_replace('\\', '/', $ParentDir);
- }
- $DirectoryContents[$currentfulldir]['dir'][$file]['filename'] = $ParentDir;
- continue 2;
- break;
-
- case '.':
- // ignore
- continue 2;
- break;
- }
-
- // symbolic-link-resolution enhancements by davidbullock״ech-center*com
- $TargetObject = realpath($currentfilename); // Find actual file path, resolve if it's a symbolic link
- $TargetObjectType = filetype($TargetObject); // Check file type without examining extension
-
- if ($TargetObjectType == 'dir') {
-
- $DirectoryContents[$currentfulldir]['dir'][$file]['filename'] = $file;
-
- } elseif ($TargetObjectType == 'file') {
-
- $getID3->setOption(array('option_md5_data' => isset($_REQUEST['ShowMD5'])));
- $fileinformation = $getID3->analyze($currentfilename);
-
- getid3_lib::CopyTagsToComments($fileinformation);
-
- $TotalScannedFilesize += @$fileinformation['filesize'];
-
- if (isset($_REQUEST['ShowMD5'])) {
- $fileinformation['md5_file'] = md5($currentfilename);
- $fileinformation['md5_file'] = getid3_lib::md5_file($currentfilename);
- }
-
- if (!empty($fileinformation['fileformat'])) {
- $DirectoryContents[$currentfulldir]['known'][$file] = $fileinformation;
- $TotalScannedPlaytime += @$fileinformation['playtime_seconds'];
- $TotalScannedBitrate += @$fileinformation['bitrate'];
- $TotalScannedKnownFiles++;
- } else {
- $DirectoryContents[$currentfulldir]['other'][$file] = $fileinformation;
- $DirectoryContents[$currentfulldir]['other'][$file]['playtime_string'] = '-';
- $TotalScannedUnknownFiles++;
- }
- if (isset($fileinformation['playtime_seconds']) && ($fileinformation['playtime_seconds'] > 0)) {
- $TotalScannedPlaytimeFiles++;
- }
- if (isset($fileinformation['bitrate']) && ($fileinformation['bitrate'] > 0)) {
- $TotalScannedBitrateFiles++;
- }
- }
- }
- $endtime = getmicrotime();
- closedir($handle);
- echo 'done ';
- echo 'Directory scanned in '.number_format($endtime - $starttime, 2).' seconds. ';
- flush();
-
- $columnsintable = 14;
- echo '';
-
- echo 'Files in '.getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-8', $currentfulldir).' ';
- $rowcounter = 0;
- foreach ($DirectoryContents as $dirname => $val) {
- if (isset($DirectoryContents[$dirname]['dir']) && is_array($DirectoryContents[$dirname]['dir'])) {
- uksort($DirectoryContents[$dirname]['dir'], 'MoreNaturalSort');
- foreach ($DirectoryContents[$dirname]['dir'] as $filename => $fileinfo) {
- echo '';
- if ($filename == '..') {
- echo '';
- echo '';
- echo 'Parent directory: ';
- echo ' ';
- echo ' ';
- } else {
- echo ''.FixTextFields($filename).' ';
- }
- echo ' ';
- }
- }
-
- echo '';
- echo 'Filename ';
- echo 'File Size ';
- echo 'Format ';
- echo 'Playtime ';
- echo 'Bitrate ';
- echo 'Artist ';
- echo 'Title ';
- if (isset($_REQUEST['ShowMD5'])) {
- echo 'MD5 File (File) (disable ) ';
- echo 'MD5 Data (File) (disable ) ';
- echo 'MD5 Data (Source) (disable ) ';
- } else {
- echo 'MD5 Data (enable ) ';
- }
- echo 'Tags ';
- echo 'Errors & Warnings ';
- echo 'Edit ';
- echo 'Delete ';
- echo ' ';
-
- if (isset($DirectoryContents[$dirname]['known']) && is_array($DirectoryContents[$dirname]['known'])) {
- uksort($DirectoryContents[$dirname]['known'], 'MoreNaturalSort');
- foreach ($DirectoryContents[$dirname]['known'] as $filename => $fileinfo) {
- echo '';
- echo ''.FixTextFields(getid3_lib::SafeStripSlashes($filename)).' ';
- echo ' '.number_format($fileinfo['filesize']).' ';
- echo ' '.NiceDisplayFiletypeFormat($fileinfo).' ';
- echo ' '.(isset($fileinfo['playtime_string']) ? $fileinfo['playtime_string'] : '-').' ';
- echo ' '.(isset($fileinfo['bitrate']) ? BitrateText($fileinfo['bitrate'] / 1000, 0, ((@$fileinfo['audio']['bitrate_mode'] == 'vbr') ? true : false)) : '-').' ';
- echo ' '.(isset($fileinfo['comments_html']['artist']) ? implode(' ', $fileinfo['comments_html']['artist']) : '').' ';
- echo ' '.(isset($fileinfo['comments_html']['title']) ? implode(' ', $fileinfo['comments_html']['title']) : '').' ';
- if (isset($_REQUEST['ShowMD5'])) {
- echo ''.(isset($fileinfo['md5_file']) ? $fileinfo['md5_file'] : ' ').' ';
- echo ''.(isset($fileinfo['md5_data']) ? $fileinfo['md5_data'] : ' ').' ';
- echo ''.(isset($fileinfo['md5_data_source']) ? $fileinfo['md5_data_source'] : ' ').' ';
- } else {
- echo '- ';
- }
- echo ' '.@implode(', ', array_keys($fileinfo['tags'])).' ';
-
- echo ' ';
- if (!empty($fileinfo['warning'])) {
- $FilesWithWarnings++;
- echo 'warning ';
- }
- if (!empty($fileinfo['error'])) {
- $FilesWithErrors++;
- echo 'error ';
- }
- echo ' ';
-
- echo ' ';
- switch (@$fileinfo['fileformat']) {
- case 'mp3':
- case 'mp2':
- case 'mp1':
- case 'flac':
- case 'mpc':
- case 'real':
- echo 'edit tags ';
- break;
- case 'ogg':
- switch (@$fileinfo['audio']['dataformat']) {
- case 'vorbis':
- echo 'edit tags ';
- break;
- }
- break;
- default:
- break;
- }
- echo ' ';
- echo ' delete ';
- echo ' ';
- }
- }
-
- if (isset($DirectoryContents[$dirname]['other']) && is_array($DirectoryContents[$dirname]['other'])) {
- uksort($DirectoryContents[$dirname]['other'], 'MoreNaturalSort');
- foreach ($DirectoryContents[$dirname]['other'] as $filename => $fileinfo) {
- echo '';
- echo ''.$filename.' ';
- echo ' '.(isset($fileinfo['filesize']) ? number_format($fileinfo['filesize']) : '-').' ';
- echo ' '.NiceDisplayFiletypeFormat($fileinfo).' ';
- echo ' '.(isset($fileinfo['playtime_string']) ? $fileinfo['playtime_string'] : '-').' ';
- echo ' '.(isset($fileinfo['bitrate']) ? BitrateText($fileinfo['bitrate'] / 1000) : '-').' ';
- echo ' '; // Artist
- echo ' '; // Title
- echo ' '; // MD5_data
- echo ' '; // Tags
-
- //echo ' '; // Warning/Error
- echo ' ';
- if (!empty($fileinfo['warning'])) {
- $FilesWithWarnings++;
- echo 'warning ';
- }
- if (!empty($fileinfo['error'])) {
- if ($fileinfo['error'][0] != 'unable to determine file format') {
- $FilesWithErrors++;
- echo 'error ';
- }
- }
- echo ' ';
-
- echo ' '; // Edit
- echo ' delete ';
- echo ' ';
- }
- }
-
- echo '';
- echo 'Average: ';
- echo ''.number_format($TotalScannedFilesize / max($TotalScannedKnownFiles, 1)).' ';
- echo ' ';
- echo ''.getid3_lib::PlaytimeString($TotalScannedPlaytime / max($TotalScannedPlaytimeFiles, 1)).' ';
- echo ''.BitrateText(round(($TotalScannedBitrate / 1000) / max($TotalScannedBitrateFiles, 1))).' ';
- echo 'Identified Files: '.number_format($TotalScannedKnownFiles).' Errors: '.number_format($FilesWithErrors).' Unknown Files: '.number_format($TotalScannedUnknownFiles).' Warnings: '.number_format($FilesWithWarnings).'
';
- echo ' ';
- echo '';
- echo 'Total: ';
- echo ''.number_format($TotalScannedFilesize).' ';
- echo ' ';
- echo ''.getid3_lib::PlaytimeString($TotalScannedPlaytime).' ';
- echo ' ';
- echo ' ';
- }
- echo '
';
- } else {
- echo 'ERROR: Could not open directory: '.$currentfulldir.' ';
- }
-}
-echo PoweredBygetID3();
-echo 'Running on PHP v'.phpversion();
-echo '';
-ob_end_flush();
-
-
-/////////////////////////////////////////////////////////////////
-
-
-function RemoveAccents($string) {
- // Revised version by markstewardרotmail*com
- // Again revised by James Heinrich (19-June-2006)
- return strtr(
- strtr(
- $string,
- "\x8A\x8E\x9A\x9E\x9F\xC0\xC1\xC2\xC3\xC4\xC5\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xE0\xE1\xE2\xE3\xE4\xE5\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFF",
- 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'
- ),
- array(
- "\xDE" => 'TH',
- "\xFE" => 'th',
- "\xD0" => 'DH',
- "\xF0" => 'dh',
- "\xDF" => 'ss',
- "\x8C" => 'OE',
- "\x9C" => 'oe',
- "\xC6" => 'AE',
- "\xE6" => 'ae',
- "\xB5" => 'u'
- )
- );
-}
-
-
-function BitrateColor($bitrate, $BitrateMaxScale=768) {
- // $BitrateMaxScale is bitrate of maximum-quality color (bright green)
- // below this is gradient, above is solid green
-
- $bitrate *= (256 / $BitrateMaxScale); // scale from 1-[768]kbps to 1-256
- $bitrate = round(min(max($bitrate, 1), 256));
- $bitrate--; // scale from 1-256kbps to 0-255kbps
-
- $Rcomponent = max(255 - ($bitrate * 2), 0);
- $Gcomponent = max(($bitrate * 2) - 255, 0);
- if ($bitrate > 127) {
- $Bcomponent = max((255 - $bitrate) * 2, 0);
- } else {
- $Bcomponent = max($bitrate * 2, 0);
- }
- return str_pad(dechex($Rcomponent), 2, '0', STR_PAD_LEFT).str_pad(dechex($Gcomponent), 2, '0', STR_PAD_LEFT).str_pad(dechex($Bcomponent), 2, '0', STR_PAD_LEFT);
-}
-
-function BitrateText($bitrate, $decimals=0, $vbr=false) {
- return ''.number_format($bitrate, $decimals).' kbps ';
-}
-
-function FixTextFields($text) {
- $text = getid3_lib::SafeStripSlashes($text);
- $text = htmlentities($text, ENT_QUOTES);
- return $text;
-}
-
-
-function string_var_dump($variable) {
- ob_start();
- var_dump($variable);
- $dumpedvariable = ob_get_contents();
- ob_end_clean();
- return $dumpedvariable;
-}
-
-
-function table_var_dump($variable, $wrap_in_td=false) {
- $returnstring = '';
- switch (gettype($variable)) {
- case 'array':
- $returnstring .= ($wrap_in_td ? '' : '');
- $returnstring .= '';
- foreach ($variable as $key => $value) {
- $returnstring .= ''.str_replace("\x00", ' ', $key).' ';
- $returnstring .= ''.gettype($value);
- if (is_array($value)) {
- $returnstring .= ' ('.count($value).')';
- } elseif (is_string($value)) {
- $returnstring .= ' ('.strlen($value).')';
- }
- if (($key == 'data') && isset($variable['image_mime']) && isset($variable['dataoffset'])) {
- $imageinfo = array();
- $imagechunkcheck = getid3_lib::GetDataImageSize($value, $imageinfo);
- $DumpedImageSRC = (!empty($_REQUEST['filename']) ? $_REQUEST['filename'] : '.getid3').'.'.$variable['dataoffset'].'.'.getid3_lib::ImageTypesLookup($imagechunkcheck[2]);
- if ($tempimagefile = @fopen($DumpedImageSRC, 'wb')) {
- fwrite($tempimagefile, $value);
- fclose($tempimagefile);
- }
- $returnstring .= ' ';
- } else {
- $returnstring .= ''.table_var_dump($value, true).'';
- }
- }
- $returnstring .= '
';
- $returnstring .= ($wrap_in_td ? ' ' : '');
- break;
-
- case 'boolean':
- $returnstring .= ($wrap_in_td ? '' : '').($variable ? 'TRUE' : 'FALSE').($wrap_in_td ? ' ' : '');
- break;
-
- case 'integer':
- $returnstring .= ($wrap_in_td ? '' : '').$variable.($wrap_in_td ? ' ' : '');
- break;
-
- case 'double':
- case 'float':
- $returnstring .= ($wrap_in_td ? '' : '').$variable.($wrap_in_td ? ' ' : '');
- break;
-
- case 'object':
- case 'null':
- $returnstring .= ($wrap_in_td ? '' : '').string_var_dump($variable).($wrap_in_td ? ' ' : '');
- break;
-
- case 'string':
- $variable = str_replace("\x00", ' ', $variable);
- $varlen = strlen($variable);
- for ($i = 0; $i < $varlen; $i++) {
- if (ereg('['."\x0A\x0D".' -;0-9A-Za-z]', $variable{$i})) {
- $returnstring .= $variable{$i};
- } else {
- $returnstring .= ''.str_pad(ord($variable{$i}), 3, '0', STR_PAD_LEFT).';';
- }
- }
- $returnstring = ($wrap_in_td ? '' : '').nl2br($returnstring).($wrap_in_td ? ' ' : '');
- break;
-
- default:
- $imageinfo = array();
- $imagechunkcheck = getid3_lib::GetDataImageSize($variable, $imageinfo);
- if (($imagechunkcheck[2] >= 1) && ($imagechunkcheck[2] <= 3)) {
- $returnstring .= ($wrap_in_td ? '' : '');
- $returnstring .= '';
- $returnstring .= 'type '.getid3_lib::ImageTypesLookup($imagechunkcheck[2]).' ';
- $returnstring .= 'width '.number_format($imagechunkcheck[0]).' px ';
- $returnstring .= 'height '.number_format($imagechunkcheck[1]).' px ';
- $returnstring .= 'size '.number_format(strlen($variable)).' bytes
';
- $returnstring .= ($wrap_in_td ? ' ' : '');
- } else {
- $returnstring .= ($wrap_in_td ? '' : '').nl2br(htmlspecialchars(str_replace("\x00", ' ', $variable))).($wrap_in_td ? ' ' : '');
- }
- break;
- }
- return $returnstring;
-}
-
-
-function NiceDisplayFiletypeFormat(&$fileinfo) {
-
- if (empty($fileinfo['fileformat'])) {
- return '-';
- }
-
- $output = $fileinfo['fileformat'];
- if (empty($fileinfo['video']['dataformat']) && empty($fileinfo['audio']['dataformat'])) {
- return $output; // 'gif'
- }
- if (empty($fileinfo['video']['dataformat']) && !empty($fileinfo['audio']['dataformat'])) {
- if ($fileinfo['fileformat'] == $fileinfo['audio']['dataformat']) {
- return $output; // 'mp3'
- }
- $output .= '.'.$fileinfo['audio']['dataformat']; // 'ogg.flac'
- return $output;
- }
- if (!empty($fileinfo['video']['dataformat']) && empty($fileinfo['audio']['dataformat'])) {
- if ($fileinfo['fileformat'] == $fileinfo['video']['dataformat']) {
- return $output; // 'mpeg'
- }
- $output .= '.'.$fileinfo['video']['dataformat']; // 'riff.avi'
- return $output;
- }
- if ($fileinfo['video']['dataformat'] == $fileinfo['audio']['dataformat']) {
- if ($fileinfo['fileformat'] == $fileinfo['video']['dataformat']) {
- return $output; // 'real'
- }
- $output .= '.'.$fileinfo['video']['dataformat']; // any examples?
- return $output;
- }
- $output .= '.'.$fileinfo['video']['dataformat'];
- $output .= '.'.$fileinfo['audio']['dataformat']; // asf.wmv.wma
- return $output;
-
-}
-
-function MoreNaturalSort($ar1, $ar2) {
- if ($ar1 === $ar2) {
- return 0;
- }
- $len1 = strlen($ar1);
- $len2 = strlen($ar2);
- $shortest = min($len1, $len2);
- if (substr($ar1, 0, $shortest) === substr($ar2, 0, $shortest)) {
- // the shorter argument is the beginning of the longer one, like "str" and "string"
- if ($len1 < $len2) {
- return -1;
- } elseif ($len1 > $len2) {
- return 1;
- }
- return 0;
- }
- $ar1 = RemoveAccents(strtolower(trim($ar1)));
- $ar2 = RemoveAccents(strtolower(trim($ar2)));
- $translatearray = array('\''=>'', '"'=>'', '_'=>' ', '('=>'', ')'=>'', '-'=>' ', ' '=>' ', '.'=>'', ','=>'');
- foreach ($translatearray as $key => $val) {
- $ar1 = str_replace($key, $val, $ar1);
- $ar2 = str_replace($key, $val, $ar2);
- }
-
- if ($ar1 < $ar2) {
- return -1;
- } elseif ($ar1 > $ar2) {
- return 1;
- }
- return 0;
-}
-
-function PoweredBygetID3($string=' ') {
- return str_replace('', GETID3_VERSION, $string);
-}
-
-
-/////////////////////////////////////////////////////////////////
-// Unify the contents of GPC,
-// whether magic_quotes_gpc is on or off
-
-function AddStripSlashesArray($input, $addslashes=false) {
- if (is_array($input)) {
-
- $output = $input;
- foreach ($input as $key => $value) {
- $output[$key] = AddStripSlashesArray($input[$key]);
- }
- return $output;
-
- } elseif ($addslashes) {
- return addslashes($input);
- }
- return stripslashes($input);
-}
-
-function UnifyMagicQuotes($turnon=false) {
- global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS;
-
- if (get_magic_quotes_gpc() && !$turnon) {
-
- // magic_quotes_gpc is on and we want it off!
- $_GET = AddStripSlashesArray($_GET, true);
- $_POST = AddStripSlashesArray($_POST, true);
- $_COOKIE = AddStripSlashesArray($_COOKIE, true);
-
- unset($_REQUEST);
- $_REQUEST = array_merge_recursive($_GET, $_POST, $_COOKIE);
-
- } elseif (!get_magic_quotes_gpc() && $turnon) {
-
- // magic_quotes_gpc is off and we want it on (why??)
- $_GET = AddStripSlashesArray($_GET, true);
- $_POST = AddStripSlashesArray($_POST, true);
- $_COOKIE = AddStripSlashesArray($_COOKIE, true);
-
- unset($_REQUEST);
- $_REQUEST = array_merge_recursive($_GET, $_POST, $_COOKIE);
-
- }
- $HTTP_GET_VARS = $_GET;
- $HTTP_POST_VARS = $_POST;
- $HTTP_COOKIE_VARS = $_COOKIE;
-
- return true;
-}
-/////////////////////////////////////////////////////////////////
-
-?>
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.cache.dbm.php b/apps/media/getID3/demos/demo.cache.dbm.php
deleted file mode 100644
index acaaa0f3f2f..00000000000
--- a/apps/media/getID3/demos/demo.cache.dbm.php
+++ /dev/null
@@ -1,29 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.cache.dbm.php - part of getID3() //
-// Sample script demonstrating the use of the DBM caching //
-// extension for getID3() //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-require_once('../getid3/getid3.php');
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'extension.cache.dbm.php', __FILE__, true);
-
-$getID3 = new getID3_cached_dbm('db3', '/zimweb/test/test.dbm', '/zimweb/test/test.lock');
-
-$r = $getID3->analyze('/path/to/files/filename.mp3');
-
-echo '';
-var_dump($r);
-echo ' ';
-
-// uncomment to clear cache
-// $getID3->clear_cache();
-
-?>
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.cache.mysql.php b/apps/media/getID3/demos/demo.cache.mysql.php
deleted file mode 100644
index 537b2f0ceb6..00000000000
--- a/apps/media/getID3/demos/demo.cache.mysql.php
+++ /dev/null
@@ -1,29 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.cache.mysql.php - part of getID3() //
-// Sample script demonstrating the use of the DBM caching //
-// extension for getID3() //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-require_once('../getid3/getid3.php');
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'extension.cache.mysql.php', __FILE__, true);
-
-$getID3 = new getID3_cached_mysql('localhost', 'database', 'username', 'password');
-
-$r = $getID3->analyze('/path/to/files/filename.mp3');
-
-echo '';
-var_dump($r);
-echo ' ';
-
-// uncomment to clear cache
-//$getID3->clear_cache();
-
-?>
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.joinmp3.php b/apps/media/getID3/demos/demo.joinmp3.php
deleted file mode 100644
index 976884f92eb..00000000000
--- a/apps/media/getID3/demos/demo.joinmp3.php
+++ /dev/null
@@ -1,96 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.joinmp3.php - part of getID3() //
-// Sample script for splicing two or more MP3s together into //
-// one file. Does not attempt to fix VBR header frames. //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-// sample usage:
-// $FilenameOut = 'combined.mp3';
-// $FilenamesIn[] = 'file1.mp3';
-// $FilenamesIn[] = 'file2.mp3';
-// $FilenamesIn[] = 'file3.mp3';
-//
-// if (CombineMultipleMP3sTo($FilenameOut, $FilenamesIn)) {
-// echo 'Successfully copied '.implode(' + ', $FilenamesIn).' to '.$FilenameOut;
-// } else {
-// echo 'Failed to copy '.implode(' + ', $FilenamesIn).' to '.$FilenameOut;
-// }
-
-function CombineMultipleMP3sTo($FilenameOut, $FilenamesIn) {
-
- foreach ($FilenamesIn as $nextinputfilename) {
- if (!is_readable($nextinputfilename)) {
- echo 'Cannot read "'.$nextinputfilename.'" ';
- return false;
- }
- }
- if (!is_writeable($FilenameOut)) {
- echo 'Cannot write "'.$FilenameOut.'" ';
- return false;
- }
-
- require_once('../getid3/getid3.php');
- if ($fp_output = @fopen($FilenameOut, 'wb')) {
-
- // Initialize getID3 engine
- $getID3 = new getID3;
- foreach ($FilenamesIn as $nextinputfilename) {
-
- $CurrentFileInfo = $getID3->analyze($nextinputfilename);
- if ($CurrentFileInfo['fileformat'] == 'mp3') {
-
- if ($fp_source = @fopen($nextinputfilename, 'rb')) {
-
- $CurrentOutputPosition = ftell($fp_output);
-
- // copy audio data from first file
- fseek($fp_source, $CurrentFileInfo['avdataoffset'], SEEK_SET);
- while (!feof($fp_source) && (ftell($fp_source) < $CurrentFileInfo['avdataend'])) {
- fwrite($fp_output, fread($fp_source, 32768));
- }
- fclose($fp_source);
-
- // trim post-audio data (if any) copied from first file that we don't need or want
- $EndOfFileOffset = $CurrentOutputPosition + ($CurrentFileInfo['avdataend'] - $CurrentFileInfo['avdataoffset']);
- fseek($fp_output, $EndOfFileOffset, SEEK_SET);
- ftruncate($fp_output, $EndOfFileOffset);
-
- } else {
-
- echo 'failed to open '.$nextinputfilename.' for reading';
- fclose($fp_output);
- return false;
-
- }
-
- } else {
-
- echo $nextinputfilename.' is not MP3 format';
- fclose($fp_output);
- return false;
-
- }
-
- }
-
- } else {
-
- echo 'failed to open '.$FilenameOut.' for writing';
- return false;
-
- }
-
- fclose($fp_output);
- return true;
-}
-
-?>
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.mimeonly.php b/apps/media/getID3/demos/demo.mimeonly.php
deleted file mode 100644
index dd6dec6fe3d..00000000000
--- a/apps/media/getID3/demos/demo.mimeonly.php
+++ /dev/null
@@ -1,53 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.mimeonly.php - part of getID3() //
-// Sample script for scanning a single file and returning only //
-// the MIME information //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-echo '';
-
-if (!empty($_REQUEST['filename'])) {
-
- echo 'The file "'.$_REQUEST['filename'].'" has a MIME type of "'.GetMIMEtype($_REQUEST['filename']).'"';
-
-} else {
-
- echo 'Usage: '.$_SERVER['PHP_SELF'].'?filename=filename.ext ';
-
-}
-
-
-function GetMIMEtype($filename) {
- // include getID3() library (can be in a different directory if full path is specified)
- require_once('../getid3/getid3.php');
- // Initialize getID3 engine
- $getID3 = new getID3;
-
- $DeterminedMIMEtype = '';
- if ($fp = fopen($filename, 'rb')) {
- $ThisFileInfo = array('avdataoffset'=>0, 'avdataend'=>0);
-
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true);
- $tag = new getid3_id3v2($fp, $ThisFileInfo);
-
- fseek($fp, $ThisFileInfo['avdataoffset'], SEEK_SET);
- $formattest = fread($fp, 16); // 16 bytes is sufficient for any format except ISO CD-image
- fclose($fp);
-
- $DeterminedFormatInfo = $getID3->GetFileFormat($formattest);
- $DeterminedMIMEtype = $DeterminedFormatInfo['mime_type'];
- }
- return $DeterminedMIMEtype;
-}
-
-?>
-
-
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.mp3header.php b/apps/media/getID3/demos/demo.mp3header.php
deleted file mode 100644
index 2c9c1f22328..00000000000
--- a/apps/media/getID3/demos/demo.mp3header.php
+++ /dev/null
@@ -1,2890 +0,0 @@
-';
- foreach ($variable as $key => $value) {
- $returnstring .= ''.str_replace(chr(0), ' ', $key).' ';
- $returnstring .= ''.gettype($value);
- if (is_array($value)) {
- $returnstring .= ' ('.count($value).')';
- } elseif (is_string($value)) {
- $returnstring .= ' ('.strlen($value).')';
- }
- if (($key == 'data') && isset($variable['image_mime']) && isset($variable['dataoffset'])) {
- require_once(GETID3_INCLUDEPATH.'getid3.getimagesize.php');
- $imageinfo = array();
- $imagechunkcheck = GetDataImageSize($value, $imageinfo);
- $DumpedImageSRC = (!empty($_REQUEST['filename']) ? $_REQUEST['filename'] : '.getid3').'.'.$variable['dataoffset'].'.'.ImageTypesLookup($imagechunkcheck[2]);
- if ($tempimagefile = fopen($DumpedImageSRC, 'wb')) {
- fwrite($tempimagefile, $value);
- fclose($tempimagefile);
- }
- $returnstring .= ' ';
- } else {
- $returnstring .= ''.table_var_dump($value).' ';
- }
- }
- $returnstring .= '
';
- break;
-
- case 'boolean':
- $returnstring .= ($variable ? 'TRUE' : 'FALSE');
- break;
-
- case 'integer':
- case 'double':
- case 'float':
- $returnstring .= $variable;
- break;
-
- case 'object':
- case 'null':
- $returnstring .= string_var_dump($variable);
- break;
-
- case 'string':
- $variable = str_replace(chr(0), ' ', $variable);
- $varlen = strlen($variable);
- for ($i = 0; $i < $varlen; $i++) {
- if (ereg('['.chr(0x0A).chr(0x0D).' -;0-9A-Za-z]', $variable{$i})) {
- $returnstring .= $variable{$i};
- } else {
- $returnstring .= ''.str_pad(ord($variable{$i}), 3, '0', STR_PAD_LEFT).';';
- }
- }
- $returnstring = nl2br($returnstring);
- break;
-
- default:
- require_once(GETID3_INCLUDEPATH.'getid3.getimagesize.php');
- $imageinfo = array();
- $imagechunkcheck = GetDataImageSize(substr($variable, 0, FREAD_BUFFER_SIZE), $imageinfo);
-
- if (($imagechunkcheck[2] >= 1) && ($imagechunkcheck[2] <= 3)) {
- $returnstring .= '';
- $returnstring .= 'type '.ImageTypesLookup($imagechunkcheck[2]).' ';
- $returnstring .= 'width '.number_format($imagechunkcheck[0]).' px ';
- $returnstring .= 'height '.number_format($imagechunkcheck[1]).' px ';
- $returnstring .= 'size '.number_format(strlen($variable)).' bytes
';
- } else {
- $returnstring .= nl2br(htmlspecialchars(str_replace(chr(0), ' ', $variable)));
- }
- break;
- }
- return $returnstring;
- }
-}
-
-if (!function_exists('string_var_dump')) {
- function string_var_dump($variable) {
- ob_start();
- var_dump($variable);
- $dumpedvariable = ob_get_contents();
- ob_end_clean();
- return $dumpedvariable;
- }
-}
-
-if (!function_exists('fileextension')) {
- 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 '';
- }
-}
-
-if (!function_exists('RemoveAccents')) {
- function RemoveAccents($string) {
- // return strtr($string, '', 'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy');
- // Revised version by marksteward@hotmail.com
- return strtr(strtr($string, '', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'), array('' => 'TH', '' => 'th', '' => 'DH', '' => 'dh', '' => 'ss', '' => 'OE', '' => 'oe', '' => 'AE', '' => 'ae', '' => 'u'));
- }
-}
-
-if (!function_exists('MoreNaturalSort')) {
- function MoreNaturalSort($ar1, $ar2) {
- if ($ar1 === $ar2) {
- return 0;
- }
- $len1 = strlen($ar1);
- $len2 = strlen($ar2);
- $shortest = min($len1, $len2);
- if (substr($ar1, 0, $shortest) === substr($ar2, 0, $shortest)) {
- // the shorter argument is the beginning of the longer one, like "str" and "string"
- if ($len1 < $len2) {
- return -1;
- } elseif ($len1 > $len2) {
- return 1;
- }
- return 0;
- }
- $ar1 = RemoveAccents(strtolower(trim($ar1)));
- $ar2 = RemoveAccents(strtolower(trim($ar2)));
- $translatearray = array('\''=>'', '"'=>'', '_'=>' ', '('=>'', ')'=>'', '-'=>' ', ' '=>' ', '.'=>'', ','=>'');
- foreach ($translatearray as $key => $val) {
- $ar1 = str_replace($key, $val, $ar1);
- $ar2 = str_replace($key, $val, $ar2);
- }
-
- if ($ar1 < $ar2) {
- return -1;
- } elseif ($ar1 > $ar2) {
- return 1;
- }
- return 0;
- }
-}
-
-if (!function_exists('trunc')) {
- 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 ($truncatednumber <= pow(2, 30)) {
- $truncatednumber = (int) $truncatednumber;
- }
- return $truncatednumber;
- }
-}
-
-if (!function_exists('CastAsInt')) {
- function CastAsInt($floatnum) {
- // convert to float if not already
- $floatnum = (float) $floatnum;
-
- // convert a float to type int, only if possible
- if (trunc($floatnum) == $floatnum) {
- // it's not floating point
- if ($floatnum <= pow(2, 30)) {
- // it's within int range
- $floatnum = (int) $floatnum;
- }
- }
- return $floatnum;
- }
-}
-
-if (!function_exists('getmicrotime')) {
- function getmicrotime() {
- list($usec, $sec) = explode(' ', microtime());
- return ((float) $usec + (float) $sec);
- }
-}
-
-if (!function_exists('DecimalBinary2Float')) {
- function DecimalBinary2Float($binarynumerator) {
- $numerator = Bin2Dec($binarynumerator);
- $denominator = Bin2Dec(str_repeat('1', strlen($binarynumerator)));
- return ($numerator / $denominator);
- }
-}
-
-if (!function_exists('NormalizeBinaryPoint')) {
- 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);
- }
-}
-
-if (!function_exists('Float2BinaryDecimal')) {
- 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 = trunc($floatvalue);
- $floatpart = abs($floatvalue - $intpart);
- $pointbitstring = '';
- while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
- $floatpart *= 2;
- $pointbitstring .= (string) trunc($floatpart);
- $floatpart -= trunc($floatpart);
- }
- $binarypointnumber = decbin($intpart).'.'.$pointbitstring;
- return $binarypointnumber;
- }
-}
-
-if (!function_exists('Float2String')) {
- 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 = NormalizeBinaryPoint(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 BigEndian2String(Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
- }
-}
-
-if (!function_exists('LittleEndian2Float')) {
- function LittleEndian2Float($byteword) {
- return BigEndian2Float(strrev($byteword));
- }
-}
-
-if (!function_exists('BigEndian2Float')) {
- 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 = BigEndian2Bin($byteword);
- $signbit = $bitword{0};
-
- switch (strlen($byteword) * 8) {
- case 32:
- $exponentbits = 8;
- $fractionbits = 23;
- break;
-
- case 64:
- $exponentbits = 11;
- $fractionbits = 52;
- break;
-
- case 80:
- $exponentbits = 16;
- $fractionbits = 64;
- break;
-
- default:
- return false;
- break;
- }
- $exponentstring = substr($bitword, 1, $exponentbits - 1);
- $fractionstring = substr($bitword, $exponentbits, $fractionbits);
- $exponent = Bin2Dec($exponentstring);
- $fraction = Bin2Dec($fractionstring);
-
- if (($exponentbits == 16) && ($fractionbits == 64)) {
- // 80-bit
- // As used in Apple AIFF for sample_rate
- // A bit of a hack, but it works ;)
- return pow(2, ($exponent - 16382)) * DecimalBinary2Float($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))) * DecimalBinary2Float($fractionstring);
- if ($signbit == '1') {
- $floatvalue *= -1;
- }
- } elseif ($exponent != 0) {
- $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + DecimalBinary2Float($fractionstring));
- if ($signbit == '1') {
- $floatvalue *= -1;
- }
- }
- return (float) $floatvalue;
- }
-}
-
-if (!function_exists('BigEndian2Int')) {
- function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
- $intvalue = 0;
- $bytewordlen = strlen($byteword);
- for ($i = 0; $i < $bytewordlen; $i++) {
- if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
- $intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($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
- switch ($bytewordlen) {
- case 1:
- case 2:
- case 3:
- case 4:
- $signmaskbit = 0x80 << (8 * ($bytewordlen - 1));
- if ($intvalue & $signmaskbit) {
- $intvalue = 0 - ($intvalue & ($signmaskbit - 1));
- }
- break;
-
- default:
- die('ERROR: Cannot have signed integers larger than 32-bits in BigEndian2Int()');
- break;
- }
- }
- return CastAsInt($intvalue);
- }
-}
-
-if (!function_exists('LittleEndian2Int')) {
- function LittleEndian2Int($byteword, $signed=false) {
- return BigEndian2Int(strrev($byteword), false, $signed);
- }
-}
-
-if (!function_exists('BigEndian2Bin')) {
- 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;
- }
-}
-
-if (!function_exists('BigEndian2String')) {
- function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
- if ($number < 0) {
- return false;
- }
- $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
- $intstring = '';
- if ($signed) {
- if ($minbytes > 4) {
- die('ERROR: Cannot have signed integers larger than 32-bits in 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, chr(0), STR_PAD_LEFT);
- }
-}
-
-if (!function_exists('Dec2Bin')) {
- 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;
- }
-}
-
-if (!function_exists('Bin2Dec')) {
- function Bin2Dec($binstring) {
- $decvalue = 0;
- for ($i = 0; $i < strlen($binstring); $i++) {
- $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
- }
- return CastAsInt($decvalue);
- }
-}
-
-if (!function_exists('Bin2String')) {
- function Bin2String($binstring) {
- // return 'hi' for input of '0110100001101001'
- $string = '';
- $binstringreversed = strrev($binstring);
- for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
- $string = chr(Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
- }
- return $string;
- }
-}
-
-if (!function_exists('LittleEndian2String')) {
- 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, chr(0), STR_PAD_RIGHT);
- }
-}
-
-if (!function_exists('Bool2IntString')) {
- function Bool2IntString($intvalue) {
- return ($intvalue ? '1' : '0');
- }
-}
-
-if (!function_exists('IntString2Bool')) {
- function IntString2Bool($char) {
- if ($char == '1') {
- return true;
- } elseif ($char == '0') {
- return false;
- }
- return null;
- }
-}
-
-if (!function_exists('InverseBoolean')) {
- function InverseBoolean($value) {
- return ($value ? false : true);
- }
-}
-
-if (!function_exists('DeUnSynchronise')) {
- function DeUnSynchronise($data) {
- return str_replace(chr(0xFF).chr(0x00), chr(0xFF), $data);
- }
-}
-
-if (!function_exists('Unsynchronise')) {
- function Unsynchronise($data) {
- // Whenever a false synchronisation is found within the tag, one zeroed
- // byte is inserted after the first false synchronisation byte. The
- // format of a correct sync that should be altered by ID3 encoders is as
- // follows:
- // %11111111 111xxxxx
- // And should be replaced with:
- // %11111111 00000000 111xxxxx
- // This has the side effect that all $FF 00 combinations have to be
- // altered, so they won't be affected by the decoding process. Therefore
- // all the $FF 00 combinations have to be replaced with the $FF 00 00
- // combination during the unsynchronisation.
-
- $data = str_replace(chr(0xFF).chr(0x00), chr(0xFF).chr(0x00).chr(0x00), $data);
- $unsyncheddata = '';
- for ($i = 0; $i < strlen($data); $i++) {
- $thischar = $data{$i};
- $unsyncheddata .= $thischar;
- if ($thischar == chr(255)) {
- $nextchar = ord(substr($data, $i + 1, 1));
- if (($nextchar | 0xE0) == 0xE0) {
- // previous byte = 11111111, this byte = 111?????
- $unsyncheddata .= chr(0);
- }
- }
- }
- return $unsyncheddata;
- }
-}
-
-if (!function_exists('is_hash')) {
- function is_hash($var) {
- // written by dev-null@christophe.vg
- // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
- if (is_array($var)) {
- $keys = array_keys($var);
- $all_num = true;
- for ($i = 0; $i < count($keys); $i++) {
- if (is_string($keys[$i])) {
- return true;
- }
- }
- }
- return false;
- }
-}
-
-if (!function_exists('array_join_merge')) {
- function array_join_merge($arr1, $arr2) {
- // written by dev-null@christophe.vg
- // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
- if (is_array($arr1) && is_array($arr2)) {
- // the same -> merge
- $new_array = array();
-
- if (is_hash($arr1) && is_hash($arr2)) {
- // hashes -> merge based on keys
- $keys = array_merge(array_keys($arr1), array_keys($arr2));
- foreach ($keys as $key) {
- $new_array[$key] = array_join_merge(@$arr1[$key], @$arr2[$key]);
- }
- } else {
- // two real arrays -> merge
- $new_array = array_reverse(array_unique(array_reverse(array_merge($arr1,$arr2))));
- }
- return $new_array;
- } else {
- // not the same ... take new one if defined, else the old one stays
- return $arr2 ? $arr2 : $arr1;
- }
- }
-}
-
-if (!function_exists('array_merge_clobber')) {
- 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] = array_merge_clobber($newarray[$key], $val);
- } else {
- $newarray[$key] = $val;
- }
- }
- return $newarray;
- }
-}
-
-if (!function_exists('array_merge_noclobber')) {
- 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] = array_merge_noclobber($newarray[$key], $val);
- } elseif (!isset($newarray[$key])) {
- $newarray[$key] = $val;
- }
- }
- return $newarray;
- }
-}
-
-if (!function_exists('RoughTranslateUnicodeToASCII')) {
- function RoughTranslateUnicodeToASCII($rawdata, $frame_textencoding) {
- // rough translation of data for application that can't handle Unicode data
-
- $tempstring = '';
- switch ($frame_textencoding) {
- case 0: // ISO-8859-1. Terminated with $00.
- $asciidata = $rawdata;
- break;
-
- case 1: // UTF-16 encoded Unicode with BOM. Terminated with $00 00.
- $asciidata = $rawdata;
- if (substr($asciidata, 0, 2) == chr(0xFF).chr(0xFE)) {
- // remove BOM, only if present (it should be, but...)
- $asciidata = substr($asciidata, 2);
- }
- if (substr($asciidata, strlen($asciidata) - 2, 2) == chr(0).chr(0)) {
- $asciidata = substr($asciidata, 0, strlen($asciidata) - 2); // remove terminator, only if present (it should be, but...)
- }
- for ($i = 0; $i < strlen($asciidata); $i += 2) {
- if ((ord($asciidata{$i}) <= 0x7F) || (ord($asciidata{$i}) >= 0xA0)) {
- $tempstring .= $asciidata{$i};
- } else {
- $tempstring .= '?';
- }
- }
- $asciidata = $tempstring;
- break;
-
- case 2: // UTF-16BE encoded Unicode without BOM. Terminated with $00 00.
- $asciidata = $rawdata;
- if (substr($asciidata, strlen($asciidata) - 2, 2) == chr(0).chr(0)) {
- $asciidata = substr($asciidata, 0, strlen($asciidata) - 2); // remove terminator, only if present (it should be, but...)
- }
- for ($i = 0; $i < strlen($asciidata); $i += 2) {
- if ((ord($asciidata{$i}) <= 0x7F) || (ord($asciidata{$i}) >= 0xA0)) {
- $tempstring .= $asciidata{$i};
- } else {
- $tempstring .= '?';
- }
- }
- $asciidata = $tempstring;
- break;
-
- case 3: // UTF-8 encoded Unicode. Terminated with $00.
- $asciidata = utf8_decode($rawdata);
- break;
-
- case 255: // Unicode, Big-Endian. Terminated with $00 00.
- $asciidata = $rawdata;
- if (substr($asciidata, strlen($asciidata) - 2, 2) == chr(0).chr(0)) {
- $asciidata = substr($asciidata, 0, strlen($asciidata) - 2); // remove terminator, only if present (it should be, but...)
- }
- for ($i = 0; ($i + 1) < strlen($asciidata); $i += 2) {
- if ((ord($asciidata{($i + 1)}) <= 0x7F) || (ord($asciidata{($i + 1)}) >= 0xA0)) {
- $tempstring .= $asciidata{($i + 1)};
- } else {
- $tempstring .= '?';
- }
- }
- $asciidata = $tempstring;
- break;
-
-
- default:
- // shouldn't happen, but in case $frame_textencoding is not 1 <= $frame_textencoding <= 4
- // just pass the data through unchanged.
- $asciidata = $rawdata;
- break;
- }
- if (substr($asciidata, strlen($asciidata) - 1, 1) == chr(0)) {
- // remove null terminator, if present
- $asciidata = NoNullString($asciidata);
- }
- return $asciidata;
- // return str_replace(chr(0), '', $asciidata); // just in case any nulls slipped through
- }
-}
-
-if (!function_exists('PlaytimeString')) {
- function PlaytimeString($playtimeseconds) {
- $contentseconds = round((($playtimeseconds / 60) - floor($playtimeseconds / 60)) * 60);
- $contentminutes = floor($playtimeseconds / 60);
- if ($contentseconds >= 60) {
- $contentseconds -= 60;
- $contentminutes++;
- }
- return number_format($contentminutes).':'.str_pad($contentseconds, 2, 0, STR_PAD_LEFT);
- }
-}
-
-if (!function_exists('CloseMatch')) {
- function CloseMatch($value1, $value2, $tolerance) {
- return (abs($value1 - $value2) <= $tolerance);
- }
-}
-
-if (!function_exists('ID3v1matchesID3v2')) {
- function ID3v1matchesID3v2($id3v1, $id3v2) {
-
- $requiredindices = array('title', 'artist', 'album', 'year', 'genre', 'comment');
- foreach ($requiredindices as $requiredindex) {
- if (!isset($id3v1["$requiredindex"])) {
- $id3v1["$requiredindex"] = '';
- }
- if (!isset($id3v2["$requiredindex"])) {
- $id3v2["$requiredindex"] = '';
- }
- }
-
- if (trim($id3v1['title']) != trim(substr($id3v2['title'], 0, 30))) {
- return false;
- }
- if (trim($id3v1['artist']) != trim(substr($id3v2['artist'], 0, 30))) {
- return false;
- }
- if (trim($id3v1['album']) != trim(substr($id3v2['album'], 0, 30))) {
- return false;
- }
- if (trim($id3v1['year']) != trim(substr($id3v2['year'], 0, 4))) {
- return false;
- }
- if (trim($id3v1['genre']) != trim($id3v2['genre'])) {
- return false;
- }
- if (isset($id3v1['track'])) {
- if (!isset($id3v1['track']) || (trim($id3v1['track']) != trim($id3v2['track']))) {
- return false;
- }
- if (trim($id3v1['comment']) != trim(substr($id3v2['comment'], 0, 28))) {
- return false;
- }
- } else {
- if (trim($id3v1['comment']) != trim(substr($id3v2['comment'], 0, 30))) {
- return false;
- }
- }
- return true;
- }
-}
-
-if (!function_exists('FILETIMEtoUNIXtime')) {
- 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 round(($FILETIME - 116444736000000000) / 10000000);
- }
- return ($FILETIME - 116444736000000000) / 10000000;
- }
-}
-
-if (!function_exists('GUIDtoBytestring')) {
- 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;
- }
-}
-
-if (!function_exists('BytestringToGUID')) {
- 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);
- }
-}
-
-if (!function_exists('BitrateColor')) {
- function BitrateColor($bitrate) {
- $bitrate /= 3; // scale from 1-768kbps to 1-256kbps
- $bitrate--; // scale from 1-256kbps to 0-255kbps
- $bitrate = max($bitrate, 0);
- $bitrate = min($bitrate, 255);
- //$bitrate = max($bitrate, 32);
- //$bitrate = min($bitrate, 143);
- //$bitrate = ($bitrate * 2) - 32;
-
- $Rcomponent = max(255 - ($bitrate * 2), 0);
- $Gcomponent = max(($bitrate * 2) - 255, 0);
- if ($bitrate > 127) {
- $Bcomponent = max((255 - $bitrate) * 2, 0);
- } else {
- $Bcomponent = max($bitrate * 2, 0);
- }
- return str_pad(dechex($Rcomponent), 2, '0', STR_PAD_LEFT).str_pad(dechex($Gcomponent), 2, '0', STR_PAD_LEFT).str_pad(dechex($Bcomponent), 2, '0', STR_PAD_LEFT);
- }
-}
-
-if (!function_exists('BitrateText')) {
- function BitrateText($bitrate) {
- return ''.round($bitrate).' kbps ';
- }
-}
-
-if (!function_exists('image_type_to_mime_type')) {
- function image_type_to_mime_type($imagetypeid) {
- // only available in PHP v4.3.0+
- static $image_type_to_mime_type = array();
- if (empty($image_type_to_mime_type)) {
- $image_type_to_mime_type[1] = 'image/gif'; // GIF
- $image_type_to_mime_type[2] = 'image/jpeg'; // JPEG
- $image_type_to_mime_type[3] = 'image/png'; // PNG
- $image_type_to_mime_type[4] = 'application/x-shockwave-flash'; // Flash
- $image_type_to_mime_type[5] = 'image/psd'; // PSD
- $image_type_to_mime_type[6] = 'image/bmp'; // BMP
- $image_type_to_mime_type[7] = 'image/tiff'; // TIFF: little-endian (Intel)
- $image_type_to_mime_type[8] = 'image/tiff'; // TIFF: big-endian (Motorola)
- //$image_type_to_mime_type[9] = 'image/jpc'; // JPC
- //$image_type_to_mime_type[10] = 'image/jp2'; // JPC
- //$image_type_to_mime_type[11] = 'image/jpx'; // JPC
- //$image_type_to_mime_type[12] = 'image/jb2'; // JPC
- $image_type_to_mime_type[13] = 'application/x-shockwave-flash'; // Shockwave
- $image_type_to_mime_type[14] = 'image/iff'; // IFF
- }
- return (isset($image_type_to_mime_type[$imagetypeid]) ? $image_type_to_mime_type[$imagetypeid] : 'application/octet-stream');
- }
-}
-
-if (!function_exists('utf8_decode')) {
- // PHP has this function built-in if it's configured with the --with-xml option
- // This version of the function is only provided in case XML isn't installed
- function utf8_decode($utf8text) {
- // http://www.php.net/manual/en/function.utf8-encode.php
- // bytes bits representation
- // 1 7 0bbbbbbb
- // 2 11 110bbbbb 10bbbbbb
- // 3 16 1110bbbb 10bbbbbb 10bbbbbb
- // 4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
-
- $utf8length = strlen($utf8text);
- $decodedtext = '';
- for ($i = 0; $i < $utf8length; $i++) {
- if ((ord($utf8text{$i}) & 0x80) == 0) {
- $decodedtext .= $utf8text{$i};
- } elseif ((ord($utf8text{$i}) & 0xF0) == 0xF0) {
- $decodedtext .= '?';
- $i += 3;
- } elseif ((ord($utf8text{$i}) & 0xE0) == 0xE0) {
- $decodedtext .= '?';
- $i += 2;
- } elseif ((ord($utf8text{$i}) & 0xC0) == 0xC0) {
- // 2 11 110bbbbb 10bbbbbb
- $decodedchar = Bin2Dec(substr(Dec2Bin(ord($utf8text{$i})), 3, 5).substr(Dec2Bin(ord($utf8text{($i + 1)})), 2, 6));
- if ($decodedchar <= 255) {
- $decodedtext .= chr($decodedchar);
- } else {
- $decodedtext .= '?';
- }
- $i += 1;
- }
- }
- return $decodedtext;
- }
-}
-
-if (!function_exists('DateMac2Unix')) {
- function DateMac2Unix($macdate) {
- // Macintosh timestamp: seconds since 00:00h January 1, 1904
- // UNIX timestamp: seconds since 00:00h January 1, 1970
- return CastAsInt($macdate - 2082844800);
- }
-}
-
-
-if (!function_exists('FixedPoint8_8')) {
- function FixedPoint8_8($rawdata) {
- return BigEndian2Int(substr($rawdata, 0, 1)) + (float) (BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
- }
-}
-
-
-if (!function_exists('FixedPoint16_16')) {
- function FixedPoint16_16($rawdata) {
- return BigEndian2Int(substr($rawdata, 0, 2)) + (float) (BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
- }
-}
-
-
-if (!function_exists('FixedPoint2_30')) {
- function FixedPoint2_30($rawdata) {
- $binarystring = BigEndian2Bin($rawdata);
- return Bin2Dec(substr($binarystring, 0, 2)) + (float) (Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
- }
-}
-
-
-if (!function_exists('Pascal2String')) {
- function Pascal2String($pascalstring) {
- // Pascal strings have 1 byte at the beginning saying how many chars are in the string
- return substr($pascalstring, 1);
- }
-}
-
-if (!function_exists('NoNullString')) {
- function NoNullString($nullterminatedstring) {
- // remove the single null terminator on null terminated strings
- if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === chr(0)) {
- return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1);
- }
- return $nullterminatedstring;
- }
-}
-
-if (!function_exists('FileSizeNiceDisplay')) {
- function FileSizeNiceDisplay($filesize, $precision=2) {
- if ($filesize < 1000) {
- $sizeunit = 'bytes';
- $precision = 0;
- } else {
- $filesize /= 1024;
- $sizeunit = 'kB';
- }
- if ($filesize >= 1000) {
- $filesize /= 1024;
- $sizeunit = 'MB';
- }
- if ($filesize >= 1000) {
- $filesize /= 1024;
- $sizeunit = 'GB';
- }
- return number_format($filesize, $precision).' '.$sizeunit;
- }
-}
-
-if (!function_exists('DOStime2UNIXtime')) {
- 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 mktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
- }
-}
-
-if (!function_exists('CreateDeepArray')) {
- function CreateDeepArray($ArrayPath, $Separator, $Value) {
- // assigns $Value to a nested array path:
- // $foo = 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{0} == $Separator) {
- $ArrayPath = substr($ArrayPath, 1);
- }
- if (($pos = strpos($ArrayPath, $Separator)) !== false) {
- $ReturnedArray[substr($ArrayPath, 0, $pos)] = CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
- } else {
- $ReturnedArray["$ArrayPath"] = $Value;
- }
- return $ReturnedArray;
- }
-}
-
-if (!function_exists('md5_file')) {
- // Allan Hansen
- // md5_file() exists in PHP 4.2.0.
- // The following works under UNIX only, but dies on windows
- function md5_file($file) {
- if (substr(php_uname(), 0, 7) == 'Windows') {
- die('PHP 4.2.0 or newer required for md5_file()');
- }
-
- $file = str_replace('`', '\\`', $file);
- if (ereg("^([0-9a-f]{32})[ \t\n\r]", `md5sum "$file"`, $r)) {
- return $r[1];
- }
- return false;
- }
-}
-
-if (!function_exists('md5_data')) {
- // Allan Hansen
- // md5_data() - returns md5sum for a file from startuing position to absolute end position
-
- function md5_data($file, $offset, $end, $invertsign=false) {
- // first try and create a temporary file in the same directory as the file being scanned
- if (($dataMD5filename = tempnam(dirname($file), eregi_replace('[^[:alnum:]]', '', basename($file)))) === false) {
- // if that fails, create a temporary file in the system temp directory
- if (($dataMD5filename = tempnam('/tmp', 'getID3')) === false) {
- // if that fails, create a temporary file in the current directory
- if (($dataMD5filename = tempnam('.', eregi_replace('[^[:alnum:]]', '', basename($file)))) === false) {
- // can't find anywhere to create a temp file, just die
- return false;
- }
- }
- }
- $md5 = false;
- set_time_limit(max(filesize($file) / 1000000, 30));
-
- // copy parts of file
- if ($fp = @fopen($file, 'rb')) {
-
- if ($MD5fp = @fopen($dataMD5filename, 'wb')) {
-
- if ($invertsign) {
- // Load conversion lookup strings for 8-bit unsigned->signed conversion below
- $from = '';
- $to = '';
- for ($i = 0; $i < 128; $i++) {
- $from .= chr($i);
- $to .= chr($i + 128);
- }
- for ($i = 128; $i < 256; $i++) {
- $from .= chr($i);
- $to .= chr($i - 128);
- }
- }
-
- fseek($fp, $offset, SEEK_SET);
- $byteslefttowrite = $end - $offset;
- while (($byteslefttowrite > 0) && ($buffer = fread($fp, FREAD_BUFFER_SIZE))) {
- if ($invertsign) {
- // Possibly FLAC-specific (?)
- // FLAC calculates the MD5sum of the source data of 8-bit files
- // not on the actual byte values in the source file, but of those
- // values converted from unsigned to signed, or more specifcally,
- // with the MSB inverted. ex: 01 -> 81; F5 -> 75; etc
-
- // Therefore, 8-bit WAV data has to be converted before getting the
- // md5_data value so as to match the FLAC value
-
- // Flip the MSB for each byte in the buffer before copying
- $buffer = strtr($buffer, $from, $to);
- }
- $byteswritten = fwrite($MD5fp, $buffer, $byteslefttowrite);
- $byteslefttowrite -= $byteswritten;
- }
- fclose($MD5fp);
- $md5 = md5_file($dataMD5filename);
-
- }
- fclose($fp);
-
- }
- unlink($dataMD5filename);
- return $md5;
- }
-}
-
-if (!function_exists('TwosCompliment2Decimal')) {
- function TwosCompliment2Decimal($BinaryValue) {
- // http://sandbox.mc.edu/~bennet/cs110/tc/tctod.html
- // First check if the number is negative or positive by looking at the sign bit.
- // If it is positive, simply convert it to decimal.
- // If it is negative, make it positive by inverting the bits and adding one.
- // Then, convert the result to decimal.
- // The negative of this number is the value of the original binary.
-
- if ($BinaryValue & 0x80) {
-
- // negative number
- return (0 - ((~$BinaryValue & 0xFF) + 1));
-
- } else {
-
- // positive number
- return $BinaryValue;
-
- }
-
- }
-}
-
-if (!function_exists('LastArrayElement')) {
- function LastArrayElement($MyArray) {
- if (!is_array($MyArray)) {
- return false;
- }
- if (empty($MyArray)) {
- return null;
- }
- foreach ($MyArray as $key => $value) {
- }
- return $value;
- }
-}
-
-if (!function_exists('safe_inc')) {
- function safe_inc(&$variable, $increment=1) {
- if (isset($variable)) {
- $variable += $increment;
- } else {
- $variable = $increment;
- }
- return true;
- }
-}
-
-if (!function_exists('CalculateCompressionRatioVideo')) {
- function CalculateCompressionRatioVideo(&$ThisFileInfo) {
- if (empty($ThisFileInfo['video'])) {
- return false;
- }
- if (empty($ThisFileInfo['video']['resolution_x']) || empty($ThisFileInfo['video']['resolution_y'])) {
- return false;
- }
- if (empty($ThisFileInfo['video']['bits_per_sample'])) {
- return false;
- }
-
- switch ($ThisFileInfo['video']['dataformat']) {
- case 'bmp':
- case 'gif':
- case 'jpeg':
- case 'jpg':
- case 'png':
- case 'tiff':
- $FrameRate = 1;
- $PlaytimeSeconds = 1;
- $BitrateCompressed = $ThisFileInfo['filesize'] * 8;
- break;
-
- default:
- if (!empty($ThisFileInfo['video']['frame_rate'])) {
- $FrameRate = $ThisFileInfo['video']['frame_rate'];
- } else {
- return false;
- }
- if (!empty($ThisFileInfo['playtime_seconds'])) {
- $PlaytimeSeconds = $ThisFileInfo['playtime_seconds'];
- } else {
- return false;
- }
- if (!empty($ThisFileInfo['video']['bitrate'])) {
- $BitrateCompressed = $ThisFileInfo['video']['bitrate'];
- } else {
- return false;
- }
- break;
- }
- $BitrateUncompressed = $ThisFileInfo['video']['resolution_x'] * $ThisFileInfo['video']['resolution_y'] * $ThisFileInfo['video']['bits_per_sample'] * $FrameRate;
-
- $ThisFileInfo['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
- return true;
- }
-}
-
-if (!function_exists('CalculateCompressionRatioAudio')) {
- function CalculateCompressionRatioAudio(&$ThisFileInfo) {
- if (empty($ThisFileInfo['audio']['bitrate']) || empty($ThisFileInfo['audio']['channels']) || empty($ThisFileInfo['audio']['sample_rate']) || empty($ThisFileInfo['audio']['bits_per_sample'])) {
- return false;
- }
- $ThisFileInfo['audio']['compression_ratio'] = $ThisFileInfo['audio']['bitrate'] / ($ThisFileInfo['audio']['channels'] * $ThisFileInfo['audio']['sample_rate'] * $ThisFileInfo['audio']['bits_per_sample']);
- return true;
- }
-}
-
-if (!function_exists('IsValidMIMEstring')) {
- function IsValidMIMEstring($mimestring) {
- if ((strlen($mimestring) >= 3) && (strpos($mimestring, '/') > 0) && (strpos($mimestring, '/') < (strlen($mimestring) - 1))) {
- return true;
- }
- return false;
- }
-}
-
-if (!function_exists('IsWithinBitRange')) {
- function IsWithinBitRange($number, $maxbits, $signed=false) {
- if ($signed) {
- if (($number > (0 - pow(2, $maxbits - 1))) && ($number <= pow(2, $maxbits - 1))) {
- return true;
- }
- } else {
- if (($number >= 0) && ($number <= pow(2, $maxbits))) {
- return true;
- }
- }
- return false;
- }
-}
-
-if (!function_exists('safe_parse_url')) {
- function safe_parse_url($url) {
- $parts = @parse_url($url);
- $parts['scheme'] = (isset($parts['scheme']) ? $parts['scheme'] : '');
- $parts['host'] = (isset($parts['host']) ? $parts['host'] : '');
- $parts['user'] = (isset($parts['user']) ? $parts['user'] : '');
- $parts['pass'] = (isset($parts['pass']) ? $parts['pass'] : '');
- $parts['path'] = (isset($parts['path']) ? $parts['path'] : '');
- $parts['query'] = (isset($parts['query']) ? $parts['query'] : '');
- return $parts;
- }
-}
-
-if (!function_exists('IsValidURL')) {
- function IsValidURL($url, $allowUserPass=false) {
- if ($url == '') {
- return false;
- }
- if ($allowUserPass !== true) {
- if (strstr($url, '@')) {
- // in the format http://user:pass@example.com or http://user@example.com
- // but could easily be somebody incorrectly entering an email address in place of a URL
- return false;
- }
- }
- if ($parts = safe_parse_url($url)) {
- if (($parts['scheme'] != 'http') && ($parts['scheme'] != 'https') && ($parts['scheme'] != 'ftp') && ($parts['scheme'] != 'gopher')) {
- return false;
- } elseif (!eregi("^[[:alnum:]]([-.]?[0-9a-z])*\.[a-z]{2,3}$", $parts['host'], $regs) && !IsValidDottedIP($parts['host'])) {
- return false;
- } elseif (!eregi("^([[:alnum:]-]|[\_])*$", $parts['user'], $regs)) {
- return false;
- } elseif (!eregi("^([[:alnum:]-]|[\_])*$", $parts['pass'], $regs)) {
- return false;
- } elseif (!eregi("^[[:alnum:]/_\.@~-]*$", $parts['path'], $regs)) {
- return false;
- } elseif (!eregi("^[[:alnum:]?&=+:;_()%#/,\.-]*$", $parts['query'], $regs)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- }
-}
-
-echo '';
-echo 'Enter 4 hex bytes of MPEG-audio header (ie FF FA 92 44 ) ';
-echo ' ';
-echo ' ';
-echo ' ';
-
-echo '';
-echo 'Generate a MPEG-audio 4-byte header from these values: ';
-echo '';
-
-$MPEGgenerateValues = array(
- 'version'=>array('1', '2', '2.5'),
- 'layer'=>array('I', 'II', 'III'),
- 'protection'=>array('Y', 'N'),
- 'bitrate'=>array('free', '8', '16', '24', '32', '40', '48', '56', '64', '80', '96', '112', '128', '144', '160', '176', '192', '224', '256', '288', '320', '352', '384', '416', '448'),
- 'frequency'=>array('8000', '11025', '12000', '16000', '22050', '24000', '32000', '44100', '48000'),
- 'padding'=>array('Y', 'N'),
- 'private'=>array('Y', 'N'),
- 'channelmode'=>array('stereo', 'joint stereo', 'dual channel', 'mono'),
- 'modeextension'=>array('none', 'IS', 'MS', 'IS+MS', '4-31', '8-31', '12-31', '16-31'),
- 'copyright'=>array('Y', 'N'),
- 'original'=>array('Y', 'N'),
- 'emphasis'=>array('none', '50/15ms', 'CCIT J.17')
- );
-
-foreach ($MPEGgenerateValues as $name => $dataarray) {
- echo ''.$name.': ';
- foreach ($dataarray as $key => $value) {
- echo ''.$value.' ';
- }
- echo ' ';
-}
-
-if (isset($_POST['bitrate'])) {
- echo 'Frame Length: '.(int) MPEGaudioFrameLength($_POST['bitrate'], $_POST['version'], $_POST['layer'], (($_POST['padding'] == 'Y') ? '1' : '0'), $_POST['frequency']).' ';
-}
-echo '
';
-echo ' ';
-echo ' ';
-
-
-if (isset($_POST['Analyze']) && $_POST['HeaderHexBytes']) {
-
- $headerbytearray = explode(' ', $_POST['HeaderHexBytes']);
- if (count($headerbytearray) != 4) {
- die('Invalid byte pattern');
- }
- $headerstring = '';
- foreach ($headerbytearray as $textbyte) {
- $headerstring .= chr(hexdec($textbyte));
- }
-
- $MP3fileInfo['error'] = '';
-
- $MPEGheaderRawArray = MPEGaudioHeaderDecode(substr($headerstring, 0, 4));
-
- if (MPEGaudioHeaderValid($MPEGheaderRawArray, true)) {
-
- $MP3fileInfo['raw'] = $MPEGheaderRawArray;
-
- $MP3fileInfo['version'] = MPEGaudioVersionLookup($MP3fileInfo['raw']['version']);
- $MP3fileInfo['layer'] = MPEGaudioLayerLookup($MP3fileInfo['raw']['layer']);
- $MP3fileInfo['protection'] = MPEGaudioCRCLookup($MP3fileInfo['raw']['protection']);
- $MP3fileInfo['bitrate'] = MPEGaudioBitrateLookup($MP3fileInfo['version'], $MP3fileInfo['layer'], $MP3fileInfo['raw']['bitrate']);
- $MP3fileInfo['frequency'] = MPEGaudioFrequencyLookup($MP3fileInfo['version'], $MP3fileInfo['raw']['sample_rate']);
- $MP3fileInfo['padding'] = (bool) $MP3fileInfo['raw']['padding'];
- $MP3fileInfo['private'] = (bool) $MP3fileInfo['raw']['private'];
- $MP3fileInfo['channelmode'] = MPEGaudioChannelModeLookup($MP3fileInfo['raw']['channelmode']);
- $MP3fileInfo['channels'] = (($MP3fileInfo['channelmode'] == 'mono') ? 1 : 2);
- $MP3fileInfo['modeextension'] = MPEGaudioModeExtensionLookup($MP3fileInfo['layer'], $MP3fileInfo['raw']['modeextension']);
- $MP3fileInfo['copyright'] = (bool) $MP3fileInfo['raw']['copyright'];
- $MP3fileInfo['original'] = (bool) $MP3fileInfo['raw']['original'];
- $MP3fileInfo['emphasis'] = MPEGaudioEmphasisLookup($MP3fileInfo['raw']['emphasis']);
-
- if ($MP3fileInfo['protection']) {
- $MP3fileInfo['crc'] = BigEndian2Int(substr($headerstring, 4, 2));
- }
-
- if ($MP3fileInfo['frequency'] > 0) {
- $MP3fileInfo['framelength'] = MPEGaudioFrameLength($MP3fileInfo['bitrate'], $MP3fileInfo['version'], $MP3fileInfo['layer'], (int) $MP3fileInfo['padding'], $MP3fileInfo['frequency']);
- }
- if ($MP3fileInfo['bitrate'] != 'free') {
- $MP3fileInfo['bitrate'] *= 1000;
- }
-
- } else {
-
- $MP3fileInfo['error'] .= "\n".'Invalid MPEG audio header';
-
- }
-
- if (!$MP3fileInfo['error']) {
- unset($MP3fileInfo['error']);
- }
-
- echo table_var_dump($MP3fileInfo);
-
-} elseif (isset($_POST['Generate'])) {
-
- // AAAA AAAA AAAB BCCD EEEE FFGH IIJJ KLMM
-
- $headerbitstream = '11111111111'; // A - Frame sync (all bits set)
-
- $MPEGversionLookup = array('2.5'=>'00', '2'=>'10', '1'=>'11');
- $headerbitstream .= $MPEGversionLookup[$_POST['version']]; // B - MPEG Audio version ID
-
- $MPEGlayerLookup = array('III'=>'01', 'II'=>'10', 'I'=>'11');
- $headerbitstream .= $MPEGlayerLookup[$_POST['layer']]; // C - Layer description
-
- $headerbitstream .= (($_POST['protection'] == 'Y') ? '0' : '1'); // D - Protection bit
-
- $MPEGaudioBitrateLookup['1']['I'] = array('free'=>'0000', '32'=>'0001', '64'=>'0010', '96'=>'0011', '128'=>'0100', '160'=>'0101', '192'=>'0110', '224'=>'0111', '256'=>'1000', '288'=>'1001', '320'=>'1010', '352'=>'1011', '384'=>'1100', '416'=>'1101', '448'=>'1110');
- $MPEGaudioBitrateLookup['1']['II'] = array('free'=>'0000', '32'=>'0001', '48'=>'0010', '56'=>'0011', '64'=>'0100', '80'=>'0101', '96'=>'0110', '112'=>'0111', '128'=>'1000', '160'=>'1001', '192'=>'1010', '224'=>'1011', '256'=>'1100', '320'=>'1101', '384'=>'1110');
- $MPEGaudioBitrateLookup['1']['III'] = array('free'=>'0000', '32'=>'0001', '40'=>'0010', '48'=>'0011', '56'=>'0100', '64'=>'0101', '80'=>'0110', '96'=>'0111', '112'=>'1000', '128'=>'1001', '160'=>'1010', '192'=>'1011', '224'=>'1100', '256'=>'1101', '320'=>'1110');
- $MPEGaudioBitrateLookup['2']['I'] = array('free'=>'0000', '32'=>'0001', '48'=>'0010', '56'=>'0011', '64'=>'0100', '80'=>'0101', '96'=>'0110', '112'=>'0111', '128'=>'1000', '144'=>'1001', '160'=>'1010', '176'=>'1011', '192'=>'1100', '224'=>'1101', '256'=>'1110');
- $MPEGaudioBitrateLookup['2']['II'] = array('free'=>'0000', '8'=>'0001', '16'=>'0010', '24'=>'0011', '32'=>'0100', '40'=>'0101', '48'=>'0110', '56'=>'0111', '64'=>'1000', '80'=>'1001', '96'=>'1010', '112'=>'1011', '128'=>'1100', '144'=>'1101', '160'=>'1110');
- $MPEGaudioBitrateLookup['2']['III'] = $MPEGaudioBitrateLookup['2']['II'];
- $MPEGaudioBitrateLookup['2.5']['I'] = $MPEGaudioBitrateLookup['2']['I'];
- $MPEGaudioBitrateLookup['2.5']['II'] = $MPEGaudioBitrateLookup['2']['II'];
- $MPEGaudioBitrateLookup['2.5']['III'] = $MPEGaudioBitrateLookup['2']['II'];
- if (isset($MPEGaudioBitrateLookup[$_POST['version']][$_POST['layer']][$_POST['bitrate']])) {
- $headerbitstream .= $MPEGaudioBitrateLookup[$_POST['version']][$_POST['layer']][$_POST['bitrate']]; // E - Bitrate index
- } else {
- die('Invalid Bitrate ');
- }
-
- $MPEGaudioFrequencyLookup['1'] = array('44100'=>'00', '48000'=>'01', '32000'=>'10');
- $MPEGaudioFrequencyLookup['2'] = array('22050'=>'00', '24000'=>'01', '16000'=>'10');
- $MPEGaudioFrequencyLookup['2.5'] = array('11025'=>'00', '12000'=>'01', '8000'=>'10');
- if (isset($MPEGaudioFrequencyLookup[$_POST['version']][$_POST['frequency']])) {
- $headerbitstream .= $MPEGaudioFrequencyLookup[$_POST['version']][$_POST['frequency']]; // F - Sampling rate frequency index
- } else {
- die('Invalid Frequency ');
- }
-
- $headerbitstream .= (($_POST['padding'] == 'Y') ? '1' : '0'); // G - Padding bit
-
- $headerbitstream .= (($_POST['private'] == 'Y') ? '1' : '0'); // H - Private bit
-
- $MPEGaudioChannelModeLookup = array('stereo'=>'00', 'joint stereo'=>'01', 'dual channel'=>'10', 'mono'=>'11');
- $headerbitstream .= $MPEGaudioChannelModeLookup[$_POST['channelmode']]; // I - Channel Mode
-
- $MPEGaudioModeExtensionLookup['I'] = array('4-31'=>'00', '8-31'=>'01', '12-31'=>'10', '16-31'=>'11');
- $MPEGaudioModeExtensionLookup['II'] = $MPEGaudioModeExtensionLookup['I'];
- $MPEGaudioModeExtensionLookup['III'] = array('none'=>'00', 'IS'=>'01', 'MS'=>'10', 'IS+MS'=>'11');
- if ($_POST['channelmode'] != 'joint stereo') {
- $headerbitstream .= '00';
- } elseif (isset($MPEGaudioModeExtensionLookup[$_POST['layer']][$_POST['modeextension']])) {
- $headerbitstream .= $MPEGaudioModeExtensionLookup[$_POST['layer']][$_POST['modeextension']]; // J - Mode extension (Only if Joint stereo)
- } else {
- die('Invalid Mode Extension ');
- }
-
- $headerbitstream .= (($_POST['copyright'] == 'Y') ? '1' : '0'); // K - Copyright
-
- $headerbitstream .= (($_POST['original'] == 'Y') ? '1' : '0'); // L - Original
-
- $MPEGaudioEmphasisLookup = array('none'=>'00', '50/15ms'=>'01', 'CCIT J.17'=>'11');
- if (isset($MPEGaudioEmphasisLookup[$_POST['emphasis']])) {
- $headerbitstream .= $MPEGaudioEmphasisLookup[$_POST['emphasis']]; // M - Emphasis
- } else {
- die('Invalid Emphasis ');
- }
-
- echo strtoupper(str_pad(dechex(bindec(substr($headerbitstream, 0, 8))), 2, '0', STR_PAD_LEFT)).' ';
- echo strtoupper(str_pad(dechex(bindec(substr($headerbitstream, 8, 8))), 2, '0', STR_PAD_LEFT)).' ';
- echo strtoupper(str_pad(dechex(bindec(substr($headerbitstream, 16, 8))), 2, '0', STR_PAD_LEFT)).' ';
- echo strtoupper(str_pad(dechex(bindec(substr($headerbitstream, 24, 8))), 2, '0', STR_PAD_LEFT)).' ';
-
-}
-
-function MPEGaudioVersionLookup($rawversion) {
- $MPEGaudioVersionLookup = array('2.5', FALSE, '2', '1');
- return (isset($MPEGaudioVersionLookup["$rawversion"]) ? $MPEGaudioVersionLookup["$rawversion"] : FALSE);
-}
-
-function MPEGaudioLayerLookup($rawlayer) {
- $MPEGaudioLayerLookup = array(FALSE, 'III', 'II', 'I');
- return (isset($MPEGaudioLayerLookup["$rawlayer"]) ? $MPEGaudioLayerLookup["$rawlayer"] : FALSE);
-}
-
-function MPEGaudioBitrateLookup($version, $layer, $rawbitrate) {
- static $MPEGaudioBitrateLookup;
- if (empty($MPEGaudioBitrateLookup)) {
- $MPEGaudioBitrateLookup = MPEGaudioBitrateArray();
- }
- return (isset($MPEGaudioBitrateLookup["$version"]["$layer"]["$rawbitrate"]) ? $MPEGaudioBitrateLookup["$version"]["$layer"]["$rawbitrate"] : FALSE);
-}
-
-function MPEGaudioFrequencyLookup($version, $rawfrequency) {
- static $MPEGaudioFrequencyLookup;
- if (empty($MPEGaudioFrequencyLookup)) {
- $MPEGaudioFrequencyLookup = MPEGaudioFrequencyArray();
- }
- return (isset($MPEGaudioFrequencyLookup["$version"]["$rawfrequency"]) ? $MPEGaudioFrequencyLookup["$version"]["$rawfrequency"] : FALSE);
-}
-
-function MPEGaudioChannelModeLookup($rawchannelmode) {
- $MPEGaudioChannelModeLookup = array('stereo', 'joint stereo', 'dual channel', 'mono');
- return (isset($MPEGaudioChannelModeLookup["$rawchannelmode"]) ? $MPEGaudioChannelModeLookup["$rawchannelmode"] : FALSE);
-}
-
-function MPEGaudioModeExtensionLookup($layer, $rawmodeextension) {
- $MPEGaudioModeExtensionLookup['I'] = array('4-31', '8-31', '12-31', '16-31');
- $MPEGaudioModeExtensionLookup['II'] = array('4-31', '8-31', '12-31', '16-31');
- $MPEGaudioModeExtensionLookup['III'] = array('', 'IS', 'MS', 'IS+MS');
- return (isset($MPEGaudioModeExtensionLookup["$layer"]["$rawmodeextension"]) ? $MPEGaudioModeExtensionLookup["$layer"]["$rawmodeextension"] : FALSE);
-}
-
-function MPEGaudioEmphasisLookup($rawemphasis) {
- $MPEGaudioEmphasisLookup = array('none', '50/15ms', FALSE, 'CCIT J.17');
- return (isset($MPEGaudioEmphasisLookup["$rawemphasis"]) ? $MPEGaudioEmphasisLookup["$rawemphasis"] : FALSE);
-}
-
-function MPEGaudioCRCLookup($CRCbit) {
- // inverse boolean cast :)
- if ($CRCbit == '0') {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-/////////////////////////////////////////////////////////////////
-/// getID3() by James Heinrich //
-// available at http://getid3.sourceforge.net ///
-// or http://www.getid3.org ///
-/////////////////////////////////////////////////////////////////
-// //
-// getid3.mp3.php - part of getID3() //
-// See getid3.readme.txt for more details //
-// //
-/////////////////////////////////////////////////////////////////
-
-// number of frames to scan to determine if MPEG-audio sequence is valid
-// Lower this number to 5-20 for faster scanning
-// Increase this number to 50+ for most accurate detection of valid VBR/CBR
-// mpeg-audio streams
-define('MPEG_VALID_CHECK_FRAMES', 35);
-
-function getMP3headerFilepointer(&$fd, &$ThisFileInfo) {
-
- getOnlyMPEGaudioInfo($fd, $ThisFileInfo, $ThisFileInfo['avdataoffset']);
-
- if (isset($ThisFileInfo['mpeg']['audio']['bitrate_mode'])) {
- $ThisFileInfo['audio']['bitrate_mode'] = strtolower($ThisFileInfo['mpeg']['audio']['bitrate_mode']);
- }
-
- if (((isset($ThisFileInfo['id3v2']) && ($ThisFileInfo['avdataoffset'] > $ThisFileInfo['id3v2']['headerlength'])) || (!isset($ThisFileInfo['id3v2']) && ($ThisFileInfo['avdataoffset'] > 0)))) {
-
- $ThisFileInfo['warning'] .= "\n".'Unknown data before synch ';
- if (isset($ThisFileInfo['id3v2']['headerlength'])) {
- $ThisFileInfo['warning'] .= '(ID3v2 header ends at '.$ThisFileInfo['id3v2']['headerlength'].', then '.($ThisFileInfo['avdataoffset'] - $ThisFileInfo['id3v2']['headerlength']).' bytes garbage, ';
- } else {
- $ThisFileInfo['warning'] .= '(should be at beginning of file, ';
- }
- $ThisFileInfo['warning'] .= 'synch detected at '.$ThisFileInfo['avdataoffset'].')';
- if ($ThisFileInfo['audio']['bitrate_mode'] == 'cbr') {
- if (!empty($ThisFileInfo['id3v2']['headerlength']) && (($ThisFileInfo['avdataoffset'] - $ThisFileInfo['id3v2']['headerlength']) == $ThisFileInfo['mpeg']['audio']['framelength'])) {
- $ThisFileInfo['warning'] .= '. This is a known problem with some versions of LAME (3.91, 3.92) DLL in CBR mode.';
- $ThisFileInfo['audio']['codec'] = 'LAME';
- } elseif (empty($ThisFileInfo['id3v2']['headerlength']) && ($ThisFileInfo['avdataoffset'] == $ThisFileInfo['mpeg']['audio']['framelength'])) {
- $ThisFileInfo['warning'] .= '. This is a known problem with some versions of LAME (3.91, 3.92) DLL in CBR mode.';
- $ThisFileInfo['audio']['codec'] = 'LAME';
- }
- }
-
- }
-
- if (isset($ThisFileInfo['mpeg']['audio']['layer']) && ($ThisFileInfo['mpeg']['audio']['layer'] == 'II')) {
- $ThisFileInfo['audio']['dataformat'] = 'mp2';
- } elseif (isset($ThisFileInfo['mpeg']['audio']['layer']) && ($ThisFileInfo['mpeg']['audio']['layer'] == 'I')) {
- $ThisFileInfo['audio']['dataformat'] = 'mp1';
- }
- if ($ThisFileInfo['fileformat'] == 'mp3') {
- switch ($ThisFileInfo['audio']['dataformat']) {
- case 'mp1':
- case 'mp2':
- case 'mp3':
- $ThisFileInfo['fileformat'] = $ThisFileInfo['audio']['dataformat'];
- break;
-
- default:
- $ThisFileInfo['warning'] .= "\n".'Expecting [audio][dataformat] to be mp1/mp2/mp3 when fileformat == mp3, [audio][dataformat] actually "'.$ThisFileInfo['audio']['dataformat'].'"';
- break;
- }
- }
-
- if (empty($ThisFileInfo['fileformat'])) {
- $ThisFileInfo['error'] .= "\n".'Synch not found';
- unset($ThisFileInfo['fileformat']);
- unset($ThisFileInfo['audio']['bitrate_mode']);
- unset($ThisFileInfo['avdataoffset']);
- unset($ThisFileInfo['avdataend']);
- return false;
- }
-
- $ThisFileInfo['mime_type'] = 'audio/mpeg';
- $ThisFileInfo['audio']['lossless'] = false;
-
- // Calculate playtime
- if (!isset($ThisFileInfo['playtime_seconds']) && isset($ThisFileInfo['audio']['bitrate']) && ($ThisFileInfo['audio']['bitrate'] > 0)) {
- $ThisFileInfo['playtime_seconds'] = ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8 / $ThisFileInfo['audio']['bitrate'];
- }
-
- if (isset($ThisFileInfo['mpeg']['audio']['LAME'])) {
- $ThisFileInfo['audio']['codec'] = 'LAME';
- if (!empty($ThisFileInfo['mpeg']['audio']['LAME']['long_version'])) {
- $ThisFileInfo['audio']['encoder'] = trim($ThisFileInfo['mpeg']['audio']['LAME']['long_version']);
- }
- }
-
- return true;
-}
-
-
-function decodeMPEGaudioHeader($fd, $offset, &$ThisFileInfo, $recursivesearch=true, $ScanAsCBR=false, $FastMPEGheaderScan=false) {
-
- static $MPEGaudioVersionLookup;
- static $MPEGaudioLayerLookup;
- static $MPEGaudioBitrateLookup;
- static $MPEGaudioFrequencyLookup;
- static $MPEGaudioChannelModeLookup;
- static $MPEGaudioModeExtensionLookup;
- static $MPEGaudioEmphasisLookup;
- if (empty($MPEGaudioVersionLookup)) {
- $MPEGaudioVersionLookup = MPEGaudioVersionArray();
- $MPEGaudioLayerLookup = MPEGaudioLayerArray();
- $MPEGaudioBitrateLookup = MPEGaudioBitrateArray();
- $MPEGaudioFrequencyLookup = MPEGaudioFrequencyArray();
- $MPEGaudioChannelModeLookup = MPEGaudioChannelModeArray();
- $MPEGaudioModeExtensionLookup = MPEGaudioModeExtensionArray();
- $MPEGaudioEmphasisLookup = MPEGaudioEmphasisArray();
- }
-
- if ($offset >= $ThisFileInfo['avdataend']) {
- $ThisFileInfo['error'] .= "\n".'end of file encounter looking for MPEG synch';
- return false;
- }
- fseek($fd, $offset, SEEK_SET);
- $headerstring = fread($fd, 1441); // worse-case max length = 32kHz @ 320kbps layer 3 = 1441 bytes/frame
-
- // MP3 audio frame structure:
- // $aa $aa $aa $aa [$bb $bb] $cc...
- // where $aa..$aa is the four-byte mpeg-audio header (below)
- // $bb $bb is the optional 2-byte CRC
- // and $cc... is the audio data
-
- $head4 = substr($headerstring, 0, 4);
-
- static $MPEGaudioHeaderDecodeCache = array();
- if (isset($MPEGaudioHeaderDecodeCache[$head4])) {
- $MPEGheaderRawArray = $MPEGaudioHeaderDecodeCache[$head4];
- } else {
- $MPEGheaderRawArray = MPEGaudioHeaderDecode($head4);
- $MPEGaudioHeaderDecodeCache[$head4] = $MPEGheaderRawArray;
- }
-
- static $MPEGaudioHeaderValidCache = array();
-
- // Not in cache
- if (!isset($MPEGaudioHeaderValidCache[$head4])) {
- $MPEGaudioHeaderValidCache[$head4] = MPEGaudioHeaderValid($MPEGheaderRawArray);
- }
-
- if ($MPEGaudioHeaderValidCache[$head4]) {
- $ThisFileInfo['mpeg']['audio']['raw'] = $MPEGheaderRawArray;
- } else {
- $ThisFileInfo['error'] .= "\n".'Invalid MPEG audio header at offset '.$offset;
- return false;
- }
-
- if (!$FastMPEGheaderScan) {
-
- $ThisFileInfo['mpeg']['audio']['version'] = $MPEGaudioVersionLookup[$ThisFileInfo['mpeg']['audio']['raw']['version']];
- $ThisFileInfo['mpeg']['audio']['layer'] = $MPEGaudioLayerLookup[$ThisFileInfo['mpeg']['audio']['raw']['layer']];
-
- $ThisFileInfo['mpeg']['audio']['channelmode'] = $MPEGaudioChannelModeLookup[$ThisFileInfo['mpeg']['audio']['raw']['channelmode']];
- $ThisFileInfo['mpeg']['audio']['channels'] = (($ThisFileInfo['mpeg']['audio']['channelmode'] == 'mono') ? 1 : 2);
- $ThisFileInfo['mpeg']['audio']['sample_rate'] = $MPEGaudioFrequencyLookup[$ThisFileInfo['mpeg']['audio']['version']][$ThisFileInfo['mpeg']['audio']['raw']['sample_rate']];
- $ThisFileInfo['mpeg']['audio']['protection'] = !$ThisFileInfo['mpeg']['audio']['raw']['protection'];
- $ThisFileInfo['mpeg']['audio']['private'] = (bool) $ThisFileInfo['mpeg']['audio']['raw']['private'];
- $ThisFileInfo['mpeg']['audio']['modeextension'] = $MPEGaudioModeExtensionLookup[$ThisFileInfo['mpeg']['audio']['layer']][$ThisFileInfo['mpeg']['audio']['raw']['modeextension']];
- $ThisFileInfo['mpeg']['audio']['copyright'] = (bool) $ThisFileInfo['mpeg']['audio']['raw']['copyright'];
- $ThisFileInfo['mpeg']['audio']['original'] = (bool) $ThisFileInfo['mpeg']['audio']['raw']['original'];
- $ThisFileInfo['mpeg']['audio']['emphasis'] = $MPEGaudioEmphasisLookup[$ThisFileInfo['mpeg']['audio']['raw']['emphasis']];
-
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
-
- if ($ThisFileInfo['mpeg']['audio']['protection']) {
- $ThisFileInfo['mpeg']['audio']['crc'] = BigEndian2Int(substr($headerstring, 4, 2));
- }
-
- }
-
- if ($ThisFileInfo['mpeg']['audio']['raw']['bitrate'] == 15) {
- // http://www.hydrogenaudio.org/?act=ST&f=16&t=9682&st=0
- $ThisFileInfo['warning'] .= "\n".'Invalid bitrate index (15), this is a known bug in free-format MP3s encoded by LAME v3.90 - 3.93.1';
- $ThisFileInfo['mpeg']['audio']['raw']['bitrate'] = 0;
- }
- $ThisFileInfo['mpeg']['audio']['padding'] = (bool) $ThisFileInfo['mpeg']['audio']['raw']['padding'];
- $ThisFileInfo['mpeg']['audio']['bitrate'] = $MPEGaudioBitrateLookup[$ThisFileInfo['mpeg']['audio']['version']][$ThisFileInfo['mpeg']['audio']['layer']][$ThisFileInfo['mpeg']['audio']['raw']['bitrate']];
-
- if (($ThisFileInfo['mpeg']['audio']['bitrate'] == 'free') && ($offset == $ThisFileInfo['avdataoffset'])) {
- // only skip multiple frame check if free-format bitstream found at beginning of file
- // otherwise is quite possibly simply corrupted data
- $recursivesearch = false;
- }
-
- // For Layer II there are some combinations of bitrate and mode which are not allowed.
- if (!$FastMPEGheaderScan && ($ThisFileInfo['mpeg']['audio']['layer'] == 'II')) {
-
- $ThisFileInfo['audio']['dataformat'] = 'mp2';
- switch ($ThisFileInfo['mpeg']['audio']['channelmode']) {
-
- case 'mono':
- if (($ThisFileInfo['mpeg']['audio']['bitrate'] == 'free') || ($ThisFileInfo['mpeg']['audio']['bitrate'] <= 192)) {
- // these are ok
- } else {
- $ThisFileInfo['error'] .= "\n".$ThisFileInfo['mpeg']['audio']['bitrate'].'kbps not allowed in Layer II, '.$ThisFileInfo['mpeg']['audio']['channelmode'].'.';
- return false;
- }
- break;
-
- case 'stereo':
- case 'joint stereo':
- case 'dual channel':
- if (($ThisFileInfo['mpeg']['audio']['bitrate'] == 'free') || ($ThisFileInfo['mpeg']['audio']['bitrate'] == 64) || ($ThisFileInfo['mpeg']['audio']['bitrate'] >= 96)) {
- // these are ok
- } else {
- $ThisFileInfo['error'] .= "\n".$ThisFileInfo['mpeg']['audio']['bitrate'].'kbps not allowed in Layer II, '.$ThisFileInfo['mpeg']['audio']['channelmode'].'.';
- return false;
- }
- break;
-
- }
-
- }
-
-
- if ($ThisFileInfo['audio']['sample_rate'] > 0) {
- $ThisFileInfo['mpeg']['audio']['framelength'] = MPEGaudioFrameLength($ThisFileInfo['mpeg']['audio']['bitrate'], $ThisFileInfo['mpeg']['audio']['version'], $ThisFileInfo['mpeg']['audio']['layer'], (int) $ThisFileInfo['mpeg']['audio']['padding'], $ThisFileInfo['audio']['sample_rate']);
- }
-
- if ($ThisFileInfo['mpeg']['audio']['bitrate'] != 'free') {
-
- $ThisFileInfo['audio']['bitrate'] = 1000 * $ThisFileInfo['mpeg']['audio']['bitrate'];
-
- if (isset($ThisFileInfo['mpeg']['audio']['framelength'])) {
- $nextframetestoffset = $offset + $ThisFileInfo['mpeg']['audio']['framelength'];
- } else {
- $ThisFileInfo['error'] .= "\n".'Frame at offset('.$offset.') is has an invalid frame length.';
- return false;
- }
-
- }
-
- $ExpectedNumberOfAudioBytes = 0;
-
- ////////////////////////////////////////////////////////////////////////////////////
- // Variable-bitrate headers
-
- if (substr($headerstring, 4 + 32, 4) == 'VBRI') {
- // Fraunhofer VBR header is hardcoded 'VBRI' at offset 0x24 (36)
- // specs taken from http://minnie.tuhs.org/pipermail/mp3encoder/2001-January/001800.html
-
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'vbr';
- $ThisFileInfo['mpeg']['audio']['VBR_method'] = 'Fraunhofer';
- $ThisFileInfo['audio']['codec'] = 'Fraunhofer';
-
- $SideInfoData = substr($headerstring, 4 + 2, 32);
-
- $FraunhoferVBROffset = 36;
-
- $ThisFileInfo['mpeg']['audio']['VBR_encoder_version'] = BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 4, 2));
- $ThisFileInfo['mpeg']['audio']['VBR_encoder_delay'] = BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 6, 2));
- $ThisFileInfo['mpeg']['audio']['VBR_quality'] = BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 8, 2));
- $ThisFileInfo['mpeg']['audio']['VBR_bytes'] = BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 10, 4));
- $ThisFileInfo['mpeg']['audio']['VBR_frames'] = BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 14, 4));
- $ThisFileInfo['mpeg']['audio']['VBR_seek_offsets'] = BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 18, 2));
- //$ThisFileInfo['mpeg']['audio']['reserved'] = BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 20, 4)); // hardcoded $00 $01 $00 $02 - purpose unknown
- $ThisFileInfo['mpeg']['audio']['VBR_seek_offsets_stride'] = BigEndian2Int(substr($headerstring, $FraunhoferVBROffset + 24, 2));
-
- $ExpectedNumberOfAudioBytes = $ThisFileInfo['mpeg']['audio']['VBR_bytes'];
-
- $previousbyteoffset = $offset;
- for ($i = 0; $i < $ThisFileInfo['mpeg']['audio']['VBR_seek_offsets']; $i++) {
- $Fraunhofer_OffsetN = BigEndian2Int(substr($headerstring, $FraunhoferVBROffset, 2));
- $FraunhoferVBROffset += 2;
- $ThisFileInfo['mpeg']['audio']['VBR_offsets_relative'][$i] = $Fraunhofer_OffsetN;
- $ThisFileInfo['mpeg']['audio']['VBR_offsets_absolute'][$i] = $Fraunhofer_OffsetN + $previousbyteoffset;
- $previousbyteoffset += $Fraunhofer_OffsetN;
- }
-
-
- } else {
-
- // Xing VBR header is hardcoded 'Xing' at a offset 0x0D (13), 0x15 (21) or 0x24 (36)
- // depending on MPEG layer and number of channels
-
- if ($ThisFileInfo['mpeg']['audio']['version'] == '1') {
- if ($ThisFileInfo['mpeg']['audio']['channelmode'] == 'mono') {
- // MPEG-1 (mono)
- $VBRidOffset = 4 + 17; // 0x15
- $SideInfoData = substr($headerstring, 4 + 2, 17);
- } else {
- // MPEG-1 (stereo, joint-stereo, dual-channel)
- $VBRidOffset = 4 + 32; // 0x24
- $SideInfoData = substr($headerstring, 4 + 2, 32);
- }
- } else { // 2 or 2.5
- if ($ThisFileInfo['mpeg']['audio']['channelmode'] == 'mono') {
- // MPEG-2, MPEG-2.5 (mono)
- $VBRidOffset = 4 + 9; // 0x0D
- $SideInfoData = substr($headerstring, 4 + 2, 9);
- } else {
- // MPEG-2, MPEG-2.5 (stereo, joint-stereo, dual-channel)
- $VBRidOffset = 4 + 17; // 0x15
- $SideInfoData = substr($headerstring, 4 + 2, 17);
- }
- }
-
- if ((substr($headerstring, $VBRidOffset, strlen('Xing')) == 'Xing') || (substr($headerstring, $VBRidOffset, strlen('Info')) == 'Info')) {
- // 'Xing' is traditional Xing VBR frame
- // 'Info' is LAME-encoded CBR (This was done to avoid CBR files to be recognized as traditional Xing VBR files by some decoders.)
-
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'vbr';
- $ThisFileInfo['mpeg']['audio']['VBR_method'] = 'Xing';
-
- $ThisFileInfo['mpeg']['audio']['xing_flags_raw'] = BigEndian2Int(substr($headerstring, $VBRidOffset + 4, 4));
-
- $ThisFileInfo['mpeg']['audio']['xing_flags']['frames'] = (bool) ($ThisFileInfo['mpeg']['audio']['xing_flags_raw'] & 0x00000001);
- $ThisFileInfo['mpeg']['audio']['xing_flags']['bytes'] = (bool) ($ThisFileInfo['mpeg']['audio']['xing_flags_raw'] & 0x00000002);
- $ThisFileInfo['mpeg']['audio']['xing_flags']['toc'] = (bool) ($ThisFileInfo['mpeg']['audio']['xing_flags_raw'] & 0x00000004);
- $ThisFileInfo['mpeg']['audio']['xing_flags']['vbr_scale'] = (bool) ($ThisFileInfo['mpeg']['audio']['xing_flags_raw'] & 0x00000008);
-
- if ($ThisFileInfo['mpeg']['audio']['xing_flags']['frames']) {
- $ThisFileInfo['mpeg']['audio']['VBR_frames'] = BigEndian2Int(substr($headerstring, $VBRidOffset + 8, 4));
- }
- if ($ThisFileInfo['mpeg']['audio']['xing_flags']['bytes']) {
- $ThisFileInfo['mpeg']['audio']['VBR_bytes'] = BigEndian2Int(substr($headerstring, $VBRidOffset + 12, 4));
- }
-
- if (($ThisFileInfo['mpeg']['audio']['bitrate'] == 'free') && !empty($ThisFileInfo['mpeg']['audio']['VBR_frames']) && !empty($ThisFileInfo['mpeg']['audio']['VBR_bytes'])) {
- $framelengthfloat = $ThisFileInfo['mpeg']['audio']['VBR_bytes'] / $ThisFileInfo['mpeg']['audio']['VBR_frames'];
- if ($ThisFileInfo['mpeg']['audio']['layer'] == 'I') {
- // BitRate = (((FrameLengthInBytes / 4) - Padding) * SampleRate) / 12
- $ThisFileInfo['audio']['bitrate'] = ((($framelengthfloat / 4) - intval($ThisFileInfo['mpeg']['audio']['padding'])) * $ThisFileInfo['mpeg']['audio']['sample_rate']) / 12;
- } else {
- // Bitrate = ((FrameLengthInBytes - Padding) * SampleRate) / 144
- $ThisFileInfo['audio']['bitrate'] = (($framelengthfloat - intval($ThisFileInfo['mpeg']['audio']['padding'])) * $ThisFileInfo['mpeg']['audio']['sample_rate']) / 144;
- }
- $ThisFileInfo['mpeg']['audio']['framelength'] = floor($framelengthfloat);
- }
-
- if ($ThisFileInfo['mpeg']['audio']['xing_flags']['toc']) {
- $LAMEtocData = substr($headerstring, $VBRidOffset + 16, 100);
- for ($i = 0; $i < 100; $i++) {
- $ThisFileInfo['mpeg']['audio']['toc'][$i] = ord($LAMEtocData{$i});
- }
- }
- if ($ThisFileInfo['mpeg']['audio']['xing_flags']['vbr_scale']) {
- $ThisFileInfo['mpeg']['audio']['VBR_scale'] = BigEndian2Int(substr($headerstring, $VBRidOffset + 116, 4));
- }
-
- // http://gabriel.mp3-tech.org/mp3infotag.html
- if (substr($headerstring, $VBRidOffset + 120, 4) == 'LAME') {
- $ThisFileInfo['mpeg']['audio']['LAME']['long_version'] = substr($headerstring, $VBRidOffset + 120, 20);
- $ThisFileInfo['mpeg']['audio']['LAME']['short_version'] = substr($ThisFileInfo['mpeg']['audio']['LAME']['long_version'], 0, 9);
- $ThisFileInfo['mpeg']['audio']['LAME']['long_version'] = rtrim($ThisFileInfo['mpeg']['audio']['LAME']['long_version'], "\x55\xAA");
-
- if ($ThisFileInfo['mpeg']['audio']['LAME']['short_version'] >= 'LAME3.90.') {
-
- // It the LAME tag was only introduced in LAME v3.90
- // http://www.hydrogenaudio.org/?act=ST&f=15&t=9933
-
- // Offsets of various bytes in http://gabriel.mp3-tech.org/mp3infotag.html
- // are assuming a 'Xing' identifier offset of 0x24, which is the case for
- // MPEG-1 non-mono, but not for other combinations
- $LAMEtagOffsetContant = $VBRidOffset - 0x24;
-
- // byte $9B VBR Quality
- // This field is there to indicate a quality level, although the scale was not precised in the original Xing specifications.
- // Actually overwrites original Xing bytes
- unset($ThisFileInfo['mpeg']['audio']['VBR_scale']);
- $ThisFileInfo['mpeg']['audio']['LAME']['vbr_quality'] = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0x9B, 1));
-
- // bytes $9C-$A4 Encoder short VersionString
- $ThisFileInfo['mpeg']['audio']['LAME']['short_version'] = substr($headerstring, $LAMEtagOffsetContant + 0x9C, 9);
- $ThisFileInfo['mpeg']['audio']['LAME']['long_version'] = $ThisFileInfo['mpeg']['audio']['LAME']['short_version'];
-
- // byte $A5 Info Tag revision + VBR method
- $LAMEtagRevisionVBRmethod = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA5, 1));
-
- $ThisFileInfo['mpeg']['audio']['LAME']['tag_revision'] = ($LAMEtagRevisionVBRmethod & 0xF0) >> 4;
- $ThisFileInfo['mpeg']['audio']['LAME']['raw']['vbr_method'] = $LAMEtagRevisionVBRmethod & 0x0F;
- $ThisFileInfo['mpeg']['audio']['LAME']['vbr_method'] = LAMEvbrMethodLookup($ThisFileInfo['mpeg']['audio']['LAME']['raw']['vbr_method']);
-
- // byte $A6 Lowpass filter value
- $ThisFileInfo['mpeg']['audio']['LAME']['lowpass_frequency'] = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xA6, 1)) * 100;
-
- // bytes $A7-$AE Replay Gain
- // http://privatewww.essex.ac.uk/~djmrob/replaygain/rg_data_format.html
- // bytes $A7-$AA : 32 bit floating point "Peak signal amplitude"
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['peak_amplitude'] = BigEndian2Float(substr($headerstring, $LAMEtagOffsetContant + 0xA7, 4));
- $ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_radio'] = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAB, 2));
- $ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_audiophile'] = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAD, 2));
-
- if ($ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['peak_amplitude'] == 0) {
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['peak_amplitude'] = false;
- }
-
- if ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_radio'] != 0) {
- require_once(GETID3_INCLUDEPATH.'getid3.rgad.php');
-
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['raw']['name'] = ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_radio'] & 0xE000) >> 13;
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['raw']['originator'] = ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_radio'] & 0x1C00) >> 10;
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['raw']['sign_bit'] = ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_radio'] & 0x0200) >> 9;
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['raw']['gain_adjust'] = $ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_radio'] & 0x01FF;
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['name'] = RGADnameLookup($ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['raw']['name']);
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['originator'] = RGADoriginatorLookup($ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['raw']['originator']);
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['gain_db'] = RGADadjustmentLookup($ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['raw']['gain_adjust'], $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['raw']['sign_bit']);
-
- if ($ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['peak_amplitude'] !== false) {
- $ThisFileInfo['replay_gain']['radio']['peak'] = $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['peak_amplitude'];
- }
- $ThisFileInfo['replay_gain']['radio']['originator'] = $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['originator'];
- $ThisFileInfo['replay_gain']['radio']['adjustment'] = $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['radio']['gain_db'];
- }
- if ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_audiophile'] != 0) {
- require_once(GETID3_INCLUDEPATH.'getid3.rgad.php');
-
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['raw']['name'] = ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_audiophile'] & 0xE000) >> 13;
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['raw']['originator'] = ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_audiophile'] & 0x1C00) >> 10;
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['raw']['sign_bit'] = ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_audiophile'] & 0x0200) >> 9;
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['raw']['gain_adjust'] = $ThisFileInfo['mpeg']['audio']['LAME']['raw']['RGAD_audiophile'] & 0x01FF;
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['name'] = RGADnameLookup($ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['raw']['name']);
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['originator'] = RGADoriginatorLookup($ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['raw']['originator']);
- $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['gain_db'] = RGADadjustmentLookup($ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['raw']['gain_adjust'], $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['raw']['sign_bit']);
-
- if ($ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['peak_amplitude'] !== false) {
- $ThisFileInfo['replay_gain']['audiophile']['peak'] = $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['peak_amplitude'];
- }
- $ThisFileInfo['replay_gain']['audiophile']['originator'] = $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['originator'];
- $ThisFileInfo['replay_gain']['audiophile']['adjustment'] = $ThisFileInfo['mpeg']['audio']['LAME']['RGAD']['audiophile']['gain_db'];
- }
-
-
- // byte $AF Encoding flags + ATH Type
- $EncodingFlagsATHtype = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xAF, 1));
- $ThisFileInfo['mpeg']['audio']['LAME']['encoding_flags']['nspsytune'] = (bool) ($EncodingFlagsATHtype & 0x10);
- $ThisFileInfo['mpeg']['audio']['LAME']['encoding_flags']['nssafejoint'] = (bool) ($EncodingFlagsATHtype & 0x20);
- $ThisFileInfo['mpeg']['audio']['LAME']['encoding_flags']['nogap_next'] = (bool) ($EncodingFlagsATHtype & 0x40);
- $ThisFileInfo['mpeg']['audio']['LAME']['encoding_flags']['nogap_prev'] = (bool) ($EncodingFlagsATHtype & 0x80);
- $ThisFileInfo['mpeg']['audio']['LAME']['ath_type'] = $EncodingFlagsATHtype & 0x0F;
-
- // byte $B0 if ABR {specified bitrate} else {minimal bitrate}
- $ABRbitrateMinBitrate = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB0, 1));
- if ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['vbr_method'] == 2) { // Average BitRate (ABR)
- $ThisFileInfo['mpeg']['audio']['LAME']['bitrate_abr'] = $ABRbitrateMinBitrate;
- } elseif ($ABRbitrateMinBitrate > 0) { // Variable BitRate (VBR) - minimum bitrate
- $ThisFileInfo['mpeg']['audio']['LAME']['bitrate_min'] = $ABRbitrateMinBitrate;
- }
-
- // bytes $B1-$B3 Encoder delays
- $EncoderDelays = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB1, 3));
- $ThisFileInfo['mpeg']['audio']['LAME']['encoder_delay'] = ($EncoderDelays & 0xFFF000) >> 12;
- $ThisFileInfo['mpeg']['audio']['LAME']['end_padding'] = $EncoderDelays & 0x000FFF;
-
- // byte $B4 Misc
- $MiscByte = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB4, 1));
- $ThisFileInfo['mpeg']['audio']['LAME']['raw']['noise_shaping'] = ($MiscByte & 0x03);
- $ThisFileInfo['mpeg']['audio']['LAME']['raw']['stereo_mode'] = ($MiscByte & 0x1C) >> 2;
- $ThisFileInfo['mpeg']['audio']['LAME']['raw']['not_optimal_quality'] = ($MiscByte & 0x20) >> 5;
- $ThisFileInfo['mpeg']['audio']['LAME']['raw']['source_sample_freq'] = ($MiscByte & 0xC0) >> 6;
- $ThisFileInfo['mpeg']['audio']['LAME']['noise_shaping'] = $ThisFileInfo['mpeg']['audio']['LAME']['raw']['noise_shaping'];
- $ThisFileInfo['mpeg']['audio']['LAME']['stereo_mode'] = LAMEmiscStereoModeLookup($ThisFileInfo['mpeg']['audio']['LAME']['raw']['stereo_mode']);
- $ThisFileInfo['mpeg']['audio']['LAME']['not_optimal_quality'] = (bool) $ThisFileInfo['mpeg']['audio']['LAME']['raw']['not_optimal_quality'];
- $ThisFileInfo['mpeg']['audio']['LAME']['source_sample_freq'] = LAMEmiscSourceSampleFrequencyLookup($ThisFileInfo['mpeg']['audio']['LAME']['raw']['source_sample_freq']);
-
- // byte $B5 MP3 Gain
- $ThisFileInfo['mpeg']['audio']['LAME']['raw']['mp3_gain'] = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB5, 1), false, true);
- $ThisFileInfo['mpeg']['audio']['LAME']['mp3_gain_db'] = 1.5 * $ThisFileInfo['mpeg']['audio']['LAME']['raw']['mp3_gain'];
- $ThisFileInfo['mpeg']['audio']['LAME']['mp3_gain_factor'] = pow(2, ($ThisFileInfo['mpeg']['audio']['LAME']['mp3_gain_db'] / 6));
-
- // bytes $B6-$B7 Preset and surround info
- $PresetSurroundBytes = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB6, 2));
- // Reserved = ($PresetSurroundBytes & 0xC000);
- $ThisFileInfo['mpeg']['audio']['LAME']['raw']['surround_info'] = ($PresetSurroundBytes & 0x3800);
- $ThisFileInfo['mpeg']['audio']['LAME']['surround_info'] = LAMEsurroundInfoLookup($ThisFileInfo['mpeg']['audio']['LAME']['raw']['surround_info']);
- $ThisFileInfo['mpeg']['audio']['LAME']['preset_used_id'] = ($PresetSurroundBytes & 0x07FF);
-
- // bytes $B8-$BB MusicLength
- $ThisFileInfo['mpeg']['audio']['LAME']['audio_bytes'] = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xB8, 4));
- $ExpectedNumberOfAudioBytes = (($ThisFileInfo['mpeg']['audio']['LAME']['audio_bytes'] > 0) ? $ThisFileInfo['mpeg']['audio']['LAME']['audio_bytes'] : $ThisFileInfo['mpeg']['audio']['VBR_bytes']);
-
- // bytes $BC-$BD MusicCRC
- $ThisFileInfo['mpeg']['audio']['LAME']['music_crc'] = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xBC, 2));
-
- // bytes $BE-$BF CRC-16 of Info Tag
- $ThisFileInfo['mpeg']['audio']['LAME']['lame_tag_crc'] = BigEndian2Int(substr($headerstring, $LAMEtagOffsetContant + 0xBE, 2));
-
-
- // LAME CBR
- if ($ThisFileInfo['mpeg']['audio']['LAME']['raw']['vbr_method'] == 1) {
-
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'cbr';
- if (empty($ThisFileInfo['mpeg']['audio']['bitrate']) || ($ThisFileInfo['mpeg']['audio']['LAME']['bitrate_min'] != 255)) {
- $ThisFileInfo['mpeg']['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['LAME']['bitrate_min'];
- }
-
- }
-
- }
- }
-
- } else {
-
- // not Fraunhofer or Xing VBR methods, most likely CBR (but could be VBR with no header)
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'cbr';
- if ($recursivesearch) {
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'vbr';
- if (RecursiveFrameScanning($fd, $ThisFileInfo, $offset, $nextframetestoffset, true)) {
- $recursivesearch = false;
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'cbr';
- }
- if ($ThisFileInfo['mpeg']['audio']['bitrate_mode'] == 'vbr') {
- $ThisFileInfo['warning'] .= "\n".'VBR file with no VBR header. Bitrate values calculated from actual frame bitrates.';
- }
- }
-
- }
-
- }
-
- if (($ExpectedNumberOfAudioBytes > 0) && ($ExpectedNumberOfAudioBytes != ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']))) {
- if (($ExpectedNumberOfAudioBytes - ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'])) == 1) {
- $ThisFileInfo['warning'] .= "\n".'Last byte of data truncated (this is a known bug in Meracl ID3 Tag Writer before v1.3.5)';
- } elseif ($ExpectedNumberOfAudioBytes > ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'])) {
- $ThisFileInfo['warning'] .= "\n".'Probable truncated file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, only found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']).' (short by '.($ExpectedNumberOfAudioBytes - ($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'])).' bytes)';
- } else {
- $ThisFileInfo['warning'] .= "\n".'Too much data in file: expecting '.$ExpectedNumberOfAudioBytes.' bytes of audio data, found '.($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']).' ('.(($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) - $ExpectedNumberOfAudioBytes).' bytes too many)';
- }
- }
-
- if (($ThisFileInfo['mpeg']['audio']['bitrate'] == 'free') && empty($ThisFileInfo['audio']['bitrate'])) {
- if (($offset == $ThisFileInfo['avdataoffset']) && empty($ThisFileInfo['mpeg']['audio']['VBR_frames'])) {
- $framebytelength = FreeFormatFrameLength($fd, $offset, $ThisFileInfo, true);
- if ($framebytelength > 0) {
- $ThisFileInfo['mpeg']['audio']['framelength'] = $framebytelength;
- if ($ThisFileInfo['mpeg']['audio']['layer'] == 'I') {
- // BitRate = (((FrameLengthInBytes / 4) - Padding) * SampleRate) / 12
- $ThisFileInfo['audio']['bitrate'] = ((($framebytelength / 4) - intval($ThisFileInfo['mpeg']['audio']['padding'])) * $ThisFileInfo['mpeg']['audio']['sample_rate']) / 12;
- } else {
- // Bitrate = ((FrameLengthInBytes - Padding) * SampleRate) / 144
- $ThisFileInfo['audio']['bitrate'] = (($framebytelength - intval($ThisFileInfo['mpeg']['audio']['padding'])) * $ThisFileInfo['mpeg']['audio']['sample_rate']) / 144;
- }
- } else {
- $ThisFileInfo['error'] .= "\n".'Error calculating frame length of free-format MP3 without Xing/LAME header';
- }
- }
- }
-
- if (($ThisFileInfo['mpeg']['audio']['bitrate_mode'] == 'vbr') && isset($ThisFileInfo['mpeg']['audio']['VBR_frames']) && ($ThisFileInfo['mpeg']['audio']['VBR_frames'] > 1)) {
- $ThisFileInfo['mpeg']['audio']['VBR_frames']--; // don't count the Xing / VBRI frame
- if (($ThisFileInfo['mpeg']['audio']['version'] == '1') && ($ThisFileInfo['mpeg']['audio']['layer'] == 'I')) {
- $ThisFileInfo['mpeg']['audio']['VBR_bitrate'] = ((($ThisFileInfo['mpeg']['audio']['VBR_bytes'] / $ThisFileInfo['mpeg']['audio']['VBR_frames']) * 8) * ($ThisFileInfo['audio']['sample_rate'] / 384)) / 1000;
- } elseif ((($ThisFileInfo['mpeg']['audio']['version'] == '2') || ($ThisFileInfo['mpeg']['audio']['version'] == '2.5')) && ($ThisFileInfo['mpeg']['audio']['layer'] == 'III')) {
- $ThisFileInfo['mpeg']['audio']['VBR_bitrate'] = ((($ThisFileInfo['mpeg']['audio']['VBR_bytes'] / $ThisFileInfo['mpeg']['audio']['VBR_frames']) * 8) * ($ThisFileInfo['audio']['sample_rate'] / 576)) / 1000;
- } else {
- $ThisFileInfo['mpeg']['audio']['VBR_bitrate'] = ((($ThisFileInfo['mpeg']['audio']['VBR_bytes'] / $ThisFileInfo['mpeg']['audio']['VBR_frames']) * 8) * ($ThisFileInfo['audio']['sample_rate'] / 1152)) / 1000;
- }
- if ($ThisFileInfo['mpeg']['audio']['VBR_bitrate'] > 0) {
- $ThisFileInfo['audio']['bitrate'] = 1000 * $ThisFileInfo['mpeg']['audio']['VBR_bitrate'];
- $ThisFileInfo['mpeg']['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['VBR_bitrate']; // to avoid confusion
- }
- }
-
- // End variable-bitrate headers
- ////////////////////////////////////////////////////////////////////////////////////
-
- if ($recursivesearch) {
-
- if (!RecursiveFrameScanning($fd, $ThisFileInfo, $offset, $nextframetestoffset, $ScanAsCBR)) {
- return false;
- }
-
- }
-
-
- //if (false) {
- // // experimental side info parsing section - not returning anything useful yet
- //
- // $SideInfoBitstream = BigEndian2Bin($SideInfoData);
- // $SideInfoOffset = 0;
- //
- // if ($ThisFileInfo['mpeg']['audio']['version'] == '1') {
- // if ($ThisFileInfo['mpeg']['audio']['channelmode'] == 'mono') {
- // // MPEG-1 (mono)
- // $ThisFileInfo['mpeg']['audio']['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 9);
- // $SideInfoOffset += 9;
- // $SideInfoOffset += 5;
- // } else {
- // // MPEG-1 (stereo, joint-stereo, dual-channel)
- // $ThisFileInfo['mpeg']['audio']['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 9);
- // $SideInfoOffset += 9;
- // $SideInfoOffset += 3;
- // }
- // } else { // 2 or 2.5
- // if ($ThisFileInfo['mpeg']['audio']['channelmode'] == 'mono') {
- // // MPEG-2, MPEG-2.5 (mono)
- // $ThisFileInfo['mpeg']['audio']['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 8);
- // $SideInfoOffset += 8;
- // $SideInfoOffset += 1;
- // } else {
- // // MPEG-2, MPEG-2.5 (stereo, joint-stereo, dual-channel)
- // $ThisFileInfo['mpeg']['audio']['side_info']['main_data_begin'] = substr($SideInfoBitstream, $SideInfoOffset, 8);
- // $SideInfoOffset += 8;
- // $SideInfoOffset += 2;
- // }
- // }
- //
- // if ($ThisFileInfo['mpeg']['audio']['version'] == '1') {
- // for ($channel = 0; $channel < $ThisFileInfo['audio']['channels']; $channel++) {
- // for ($scfsi_band = 0; $scfsi_band < 4; $scfsi_band++) {
- // $ThisFileInfo['mpeg']['audio']['scfsi'][$channel][$scfsi_band] = substr($SideInfoBitstream, $SideInfoOffset, 1);
- // $SideInfoOffset += 2;
- // }
- // }
- // }
- // for ($granule = 0; $granule < (($ThisFileInfo['mpeg']['audio']['version'] == '1') ? 2 : 1); $granule++) {
- // for ($channel = 0; $channel < $ThisFileInfo['audio']['channels']; $channel++) {
- // $ThisFileInfo['mpeg']['audio']['part2_3_length'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 12);
- // $SideInfoOffset += 12;
- // $ThisFileInfo['mpeg']['audio']['big_values'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 9);
- // $SideInfoOffset += 9;
- // $ThisFileInfo['mpeg']['audio']['global_gain'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 8);
- // $SideInfoOffset += 8;
- // if ($ThisFileInfo['mpeg']['audio']['version'] == '1') {
- // $ThisFileInfo['mpeg']['audio']['scalefac_compress'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 4);
- // $SideInfoOffset += 4;
- // } else {
- // $ThisFileInfo['mpeg']['audio']['scalefac_compress'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 9);
- // $SideInfoOffset += 9;
- // }
- // $ThisFileInfo['mpeg']['audio']['window_switching_flag'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
- // $SideInfoOffset += 1;
- //
- // if ($ThisFileInfo['mpeg']['audio']['window_switching_flag'][$granule][$channel] == '1') {
- //
- // $ThisFileInfo['mpeg']['audio']['block_type'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 2);
- // $SideInfoOffset += 2;
- // $ThisFileInfo['mpeg']['audio']['mixed_block_flag'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
- // $SideInfoOffset += 1;
- //
- // for ($region = 0; $region < 2; $region++) {
- // $ThisFileInfo['mpeg']['audio']['table_select'][$granule][$channel][$region] = substr($SideInfoBitstream, $SideInfoOffset, 5);
- // $SideInfoOffset += 5;
- // }
- // $ThisFileInfo['mpeg']['audio']['table_select'][$granule][$channel][2] = 0;
- //
- // for ($window = 0; $window < 3; $window++) {
- // $ThisFileInfo['mpeg']['audio']['subblock_gain'][$granule][$channel][$window] = substr($SideInfoBitstream, $SideInfoOffset, 3);
- // $SideInfoOffset += 3;
- // }
- //
- // } else {
- //
- // for ($region = 0; $region < 3; $region++) {
- // $ThisFileInfo['mpeg']['audio']['table_select'][$granule][$channel][$region] = substr($SideInfoBitstream, $SideInfoOffset, 5);
- // $SideInfoOffset += 5;
- // }
- //
- // $ThisFileInfo['mpeg']['audio']['region0_count'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 4);
- // $SideInfoOffset += 4;
- // $ThisFileInfo['mpeg']['audio']['region1_count'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 3);
- // $SideInfoOffset += 3;
- // $ThisFileInfo['mpeg']['audio']['block_type'][$granule][$channel] = 0;
- // }
- //
- // if ($ThisFileInfo['mpeg']['audio']['version'] == '1') {
- // $ThisFileInfo['mpeg']['audio']['preflag'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
- // $SideInfoOffset += 1;
- // }
- // $ThisFileInfo['mpeg']['audio']['scalefac_scale'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
- // $SideInfoOffset += 1;
- // $ThisFileInfo['mpeg']['audio']['count1table_select'][$granule][$channel] = substr($SideInfoBitstream, $SideInfoOffset, 1);
- // $SideInfoOffset += 1;
- // }
- // }
- //}
-
- return true;
-}
-
-function RecursiveFrameScanning(&$fd, &$ThisFileInfo, &$offset, &$nextframetestoffset, $ScanAsCBR) {
- for ($i = 0; $i < MPEG_VALID_CHECK_FRAMES; $i++) {
- // check next MPEG_VALID_CHECK_FRAMES frames for validity, to make sure we haven't run across a false synch
- if (($nextframetestoffset + 4) >= $ThisFileInfo['avdataend']) {
- // end of file
- return true;
- }
-
- $nextframetestarray = array('error'=>'', 'warning'=>'', 'avdataend'=>$ThisFileInfo['avdataend'], 'avdataoffset'=>$ThisFileInfo['avdataoffset']);
- if (decodeMPEGaudioHeader($fd, $nextframetestoffset, $nextframetestarray, false)) {
- if ($ScanAsCBR) {
- // force CBR mode, used for trying to pick out invalid audio streams with
- // valid(?) VBR headers, or VBR streams with no VBR header
- if (!isset($nextframetestarray['mpeg']['audio']['bitrate']) || !isset($ThisFileInfo['mpeg']['audio']['bitrate']) || ($nextframetestarray['mpeg']['audio']['bitrate'] != $ThisFileInfo['mpeg']['audio']['bitrate'])) {
- return false;
- }
- }
-
-
- // next frame is OK, get ready to check the one after that
- if (isset($nextframetestarray['mpeg']['audio']['framelength']) && ($nextframetestarray['mpeg']['audio']['framelength'] > 0)) {
- $nextframetestoffset += $nextframetestarray['mpeg']['audio']['framelength'];
- } else {
- $ThisFileInfo['error'] .= "\n".'Frame at offset ('.$offset.') is has an invalid frame length.';
- return false;
- }
-
- } else {
-
- // next frame is not valid, note the error and fail, so scanning can contiue for a valid frame sequence
- $ThisFileInfo['error'] .= "\n".'Frame at offset ('.$offset.') is valid, but the next one at ('.$nextframetestoffset.') is not.';
-
- return false;
- }
- }
- return true;
-}
-
-function FreeFormatFrameLength($fd, $offset, &$ThisFileInfo, $deepscan=false) {
- fseek($fd, $offset, SEEK_SET);
- $MPEGaudioData = fread($fd, 32768);
-
- $SyncPattern1 = substr($MPEGaudioData, 0, 4);
- // may be different pattern due to padding
- $SyncPattern2 = $SyncPattern1{0}.$SyncPattern1{1}.chr(ord($SyncPattern1{2}) | 0x02).$SyncPattern1{3};
- if ($SyncPattern2 === $SyncPattern1) {
- $SyncPattern2 = $SyncPattern1{0}.$SyncPattern1{1}.chr(ord($SyncPattern1{2}) & 0xFD).$SyncPattern1{3};
- }
-
- $framelength = false;
- $framelength1 = strpos($MPEGaudioData, $SyncPattern1, 4);
- $framelength2 = strpos($MPEGaudioData, $SyncPattern2, 4);
- if ($framelength1 > 4) {
- $framelength = $framelength1;
- }
- if (($framelength2 > 4) && ($framelength2 < $framelength1)) {
- $framelength = $framelength2;
- }
- if (!$framelength) {
-
- // LAME 3.88 has a different value for modeextension on the first frame vs the rest
- $framelength1 = strpos($MPEGaudioData, substr($SyncPattern1, 0, 3), 4);
- $framelength2 = strpos($MPEGaudioData, substr($SyncPattern2, 0, 3), 4);
-
- if ($framelength1 > 4) {
- $framelength = $framelength1;
- }
- if (($framelength2 > 4) && ($framelength2 < $framelength1)) {
- $framelength = $framelength2;
- }
- if (!$framelength) {
- $ThisFileInfo['error'] .= "\n".'Cannot find next free-format synch pattern ('.PrintHexBytes($SyncPattern1).' or '.PrintHexBytes($SyncPattern2).') after offset '.$offset;
- return false;
- } else {
- $ThisFileInfo['warning'] .= "\n".'ModeExtension varies between first frame and other frames (known free-format issue in LAME 3.88)';
- $ThisFileInfo['audio']['codec'] = 'LAME';
- $ThisFileInfo['audio']['encoder'] = 'LAME3.88';
- $SyncPattern1 = substr($SyncPattern1, 0, 3);
- $SyncPattern2 = substr($SyncPattern2, 0, 3);
- }
- }
-
- if ($deepscan) {
-
- $ActualFrameLengthValues = array();
- $nextoffset = $offset + $framelength;
- while ($nextoffset < ($ThisFileInfo['avdataend'] - 6)) {
- fseek($fd, $nextoffset - 1, SEEK_SET);
- $NextSyncPattern = fread($fd, 6);
- if ((substr($NextSyncPattern, 1, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 1, strlen($SyncPattern2)) == $SyncPattern2)) {
- // good - found where expected
- $ActualFrameLengthValues[] = $framelength;
- } elseif ((substr($NextSyncPattern, 0, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 0, strlen($SyncPattern2)) == $SyncPattern2)) {
- // ok - found one byte earlier than expected (last frame wasn't padded, first frame was)
- $ActualFrameLengthValues[] = ($framelength - 1);
- $nextoffset--;
- } elseif ((substr($NextSyncPattern, 2, strlen($SyncPattern1)) == $SyncPattern1) || (substr($NextSyncPattern, 2, strlen($SyncPattern2)) == $SyncPattern2)) {
- // ok - found one byte later than expected (last frame was padded, first frame wasn't)
- $ActualFrameLengthValues[] = ($framelength + 1);
- $nextoffset++;
- } else {
- $ThisFileInfo['error'] .= "\n".'Did not find expected free-format sync pattern at offset '.$nextoffset;
- return false;
- }
- $nextoffset += $framelength;
- }
- if (count($ActualFrameLengthValues) > 0) {
- $framelength = round(array_sum($ActualFrameLengthValues) / count($ActualFrameLengthValues));
- }
- }
- return $framelength;
-}
-
-
-function getOnlyMPEGaudioInfo($fd, &$ThisFileInfo, $avdataoffset, $BitrateHistogram=false) {
- // looks for synch, decodes MPEG audio header
-
- fseek($fd, $avdataoffset, SEEK_SET);
- $header = '';
- $SynchSeekOffset = 0;
-
- if (!defined('CONST_FF')) {
- define('CONST_FF', chr(0xFF));
- define('CONST_E0', chr(0xE0));
- }
-
- static $MPEGaudioVersionLookup;
- static $MPEGaudioLayerLookup;
- static $MPEGaudioBitrateLookup;
- if (empty($MPEGaudioVersionLookup)) {
- $MPEGaudioVersionLookup = MPEGaudioVersionArray();
- $MPEGaudioLayerLookup = MPEGaudioLayerArray();
- $MPEGaudioBitrateLookup = MPEGaudioBitrateArray();
-
- }
-
- $header_len = strlen($header) - round(FREAD_BUFFER_SIZE / 2);
- while (true) {
-
- if (($SynchSeekOffset > $header_len) && (($avdataoffset + $SynchSeekOffset) < $ThisFileInfo['avdataend']) && !feof($fd)) {
-
- if ($SynchSeekOffset > 131072) {
- // if a synch's not found within the first 128k bytes, then give up
- $ThisFileInfo['error'] .= "\n".'could not find valid MPEG synch within the first 131072 bytes';
- if (isset($ThisFileInfo['audio']['bitrate'])) {
- unset($ThisFileInfo['audio']['bitrate']);
- }
- if (isset($ThisFileInfo['mpeg']['audio'])) {
- unset($ThisFileInfo['mpeg']['audio']);
- }
- if (isset($ThisFileInfo['mpeg']) && (!is_array($ThisFileInfo['mpeg']) || (count($ThisFileInfo['mpeg']) == 0))) {
- unset($ThisFileInfo['mpeg']);
- }
- return false;
-
- } elseif ($header .= fread($fd, FREAD_BUFFER_SIZE)) {
-
- // great
- $header_len = strlen($header) - round(FREAD_BUFFER_SIZE / 2);
-
- } else {
-
- $ThisFileInfo['error'] .= "\n".'could not find valid MPEG synch before end of file';
- if (isset($ThisFileInfo['audio']['bitrate'])) {
- unset($ThisFileInfo['audio']['bitrate']);
- }
- if (isset($ThisFileInfo['mpeg']['audio'])) {
- unset($ThisFileInfo['mpeg']['audio']);
- }
- if (isset($ThisFileInfo['mpeg']) && (!is_array($ThisFileInfo['mpeg']) || (count($ThisFileInfo['mpeg']) == 0))) {
- unset($ThisFileInfo['mpeg']);
- }
- return false;
-
- }
- }
-
- if (($SynchSeekOffset + 1) >= strlen($header)) {
- $ThisFileInfo['error'] .= "\n".'could not find valid MPEG synch before end of file';
- return false;
- }
-
- if (($header{$SynchSeekOffset} == CONST_FF) && ($header{($SynchSeekOffset + 1)} > CONST_E0)) { // synch detected
-
- if (!isset($FirstFrameThisfileInfo) && !isset($ThisFileInfo['mpeg']['audio'])) {
- $FirstFrameThisfileInfo = $ThisFileInfo;
- $FirstFrameAVDataOffset = $avdataoffset + $SynchSeekOffset;
- if (!decodeMPEGaudioHeader($fd, $avdataoffset + $SynchSeekOffset, $FirstFrameThisfileInfo, false)) {
- // if this is the first valid MPEG-audio frame, save it in case it's a VBR header frame and there's
- // garbage between this frame and a valid sequence of MPEG-audio frames, to be restored below
- unset($FirstFrameThisfileInfo);
- }
- }
- $dummy = $ThisFileInfo; // only overwrite real data if valid header found
-
- if (decodeMPEGaudioHeader($fd, $avdataoffset + $SynchSeekOffset, $dummy, true)) {
-
- $ThisFileInfo = $dummy;
- $ThisFileInfo['avdataoffset'] = $avdataoffset + $SynchSeekOffset;
- switch ($ThisFileInfo['fileformat']) {
- case '':
- case 'id3':
- case 'ape':
- case 'mp3':
- $ThisFileInfo['fileformat'] = 'mp3';
- $ThisFileInfo['audio']['dataformat'] = 'mp3';
- }
- if (isset($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode']) && ($FirstFrameThisfileInfo['mpeg']['audio']['bitrate_mode'] == 'vbr')) {
- if (!CloseMatch($ThisFileInfo['audio']['bitrate'], $FirstFrameThisfileInfo['audio']['bitrate'], 1)) {
- // If there is garbage data between a valid VBR header frame and a sequence
- // of valid MPEG-audio frames the VBR data is no longer discarded.
- $ThisFileInfo = $FirstFrameThisfileInfo;
- $ThisFileInfo['avdataoffset'] = $FirstFrameAVDataOffset;
- $ThisFileInfo['fileformat'] = 'mp3';
- $ThisFileInfo['audio']['dataformat'] = 'mp3';
- $dummy = $ThisFileInfo;
- unset($dummy['mpeg']['audio']);
- $GarbageOffsetStart = $FirstFrameAVDataOffset + $FirstFrameThisfileInfo['mpeg']['audio']['framelength'];
- $GarbageOffsetEnd = $avdataoffset + $SynchSeekOffset;
- if (decodeMPEGaudioHeader($fd, $GarbageOffsetEnd, $dummy, true, true)) {
-
- $ThisFileInfo = $dummy;
- $ThisFileInfo['avdataoffset'] = $GarbageOffsetEnd;
- $ThisFileInfo['warning'] .= "\n".'apparently-valid VBR header not used because could not find '.MPEG_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.'), but did find valid CBR stream starting at '.$GarbageOffsetEnd;
-
- } else {
-
- $ThisFileInfo['warning'] .= "\n".'using data from VBR header even though could not find '.MPEG_VALID_CHECK_FRAMES.' consecutive MPEG-audio frames immediately after VBR header (garbage data for '.($GarbageOffsetEnd - $GarbageOffsetStart).' bytes between '.$GarbageOffsetStart.' and '.$GarbageOffsetEnd.')';
-
- }
- }
- }
-
- if (isset($ThisFileInfo['mpeg']['audio']['bitrate_mode']) && ($ThisFileInfo['mpeg']['audio']['bitrate_mode'] == 'vbr') && !isset($ThisFileInfo['mpeg']['audio']['VBR_method'])) {
- // VBR file with no VBR header
- $BitrateHistogram = true;
- }
-
- if ($BitrateHistogram) {
-
- $ThisFileInfo['mpeg']['audio']['stereo_distribution'] = array('stereo'=>0, 'joint stereo'=>0, 'dual channel'=>0, 'mono'=>0);
- $ThisFileInfo['mpeg']['audio']['version_distribution'] = array('1'=>0, '2'=>0, '2.5'=>0);
-
- if ($ThisFileInfo['mpeg']['audio']['version'] == '1') {
- if ($ThisFileInfo['mpeg']['audio']['layer'] == 'III') {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32=>0, 40=>0, 48=>0, 56=>0, 64=>0, 80=>0, 96=>0, 112=>0, 128=>0, 160=>0, 192=>0, 224=>0, 256=>0, 320=>0);
- } elseif ($ThisFileInfo['mpeg']['audio']['layer'] == 'II') {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32=>0, 48=>0, 56=>0, 64=>0, 80=>0, 96=>0, 112=>0, 128=>0, 160=>0, 192=>0, 224=>0, 256=>0, 320=>0, 384=>0);
- } elseif ($ThisFileInfo['mpeg']['audio']['layer'] == 'I') {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32=>0, 64=>0, 96=>0, 128=>0, 160=>0, 192=>0, 224=>0, 256=>0, 288=>0, 320=>0, 352=>0, 384=>0, 416=>0, 448=>0);
- }
- } elseif ($ThisFileInfo['mpeg']['audio']['layer'] == 'I') {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 32=>0, 48=>0, 56=>0, 64=>0, 80=>0, 96=>0, 112=>0, 128=>0, 144=>0, 160=>0, 176=>0, 192=>0, 224=>0, 256=>0);
- } else {
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'] = array('free'=>0, 8=>0, 16=>0, 24=>0, 32=>0, 40=>0, 48=>0, 56=>0, 64=>0, 80=>0, 96=>0, 112=>0, 128=>0, 144=>0, 160=>0);
- }
-
- $dummy = array('error'=>$ThisFileInfo['error'], 'warning'=>$ThisFileInfo['warning'], 'avdataend'=>$ThisFileInfo['avdataend'], 'avdataoffset'=>$ThisFileInfo['avdataoffset']);
- $synchstartoffset = $ThisFileInfo['avdataoffset'];
-
- $FastMode = false;
- while (decodeMPEGaudioHeader($fd, $synchstartoffset, $dummy, false, false, $FastMode)) {
- $FastMode = true;
- $thisframebitrate = $MPEGaudioBitrateLookup[$MPEGaudioVersionLookup[$dummy['mpeg']['audio']['raw']['version']]][$MPEGaudioLayerLookup[$dummy['mpeg']['audio']['raw']['layer']]][$dummy['mpeg']['audio']['raw']['bitrate']];
-
- $ThisFileInfo['mpeg']['audio']['bitrate_distribution'][$thisframebitrate]++;
- $ThisFileInfo['mpeg']['audio']['stereo_distribution'][$dummy['mpeg']['audio']['channelmode']]++;
- $ThisFileInfo['mpeg']['audio']['version_distribution'][$dummy['mpeg']['audio']['version']]++;
- if (empty($dummy['mpeg']['audio']['framelength'])) {
- $ThisFileInfo['warning'] .= "\n".'Invalid/missing framelength in histogram analysis - aborting';
-$synchstartoffset += 4;
-// return false;
- }
- $synchstartoffset += $dummy['mpeg']['audio']['framelength'];
- }
-
- $bittotal = 0;
- $framecounter = 0;
- foreach ($ThisFileInfo['mpeg']['audio']['bitrate_distribution'] as $bitratevalue => $bitratecount) {
- $framecounter += $bitratecount;
- if ($bitratevalue != 'free') {
- $bittotal += ($bitratevalue * $bitratecount);
- }
- }
- if ($framecounter == 0) {
- $ThisFileInfo['error'] .= "\n".'Corrupt MP3 file: framecounter == zero';
- return false;
- }
- $ThisFileInfo['mpeg']['audio']['frame_count'] = $framecounter;
- $ThisFileInfo['mpeg']['audio']['bitrate'] = 1000 * ($bittotal / $framecounter);
-
- $ThisFileInfo['audio']['bitrate'] = $ThisFileInfo['mpeg']['audio']['bitrate'];
-
-
- // Definitively set VBR vs CBR, even if the Xing/LAME/VBRI header says differently
- $distinct_bitrates = 0;
- foreach ($ThisFileInfo['mpeg']['audio']['bitrate_distribution'] as $bitrate_value => $bitrate_count) {
- if ($bitrate_count > 0) {
- $distinct_bitrates++;
- }
- }
- if ($distinct_bitrates > 1) {
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'vbr';
- } else {
- $ThisFileInfo['mpeg']['audio']['bitrate_mode'] = 'cbr';
- }
- $ThisFileInfo['audio']['bitrate_mode'] = $ThisFileInfo['mpeg']['audio']['bitrate_mode'];
-
- }
-
- break; // exit while()
- }
- }
-
- $SynchSeekOffset++;
- if (($avdataoffset + $SynchSeekOffset) >= $ThisFileInfo['avdataend']) {
- // end of file/data
-
- if (empty($ThisFileInfo['mpeg']['audio'])) {
-
- $ThisFileInfo['error'] .= "\n".'could not find valid MPEG synch before end of file';
- if (isset($ThisFileInfo['audio']['bitrate'])) {
- unset($ThisFileInfo['audio']['bitrate']);
- }
- if (isset($ThisFileInfo['mpeg']['audio'])) {
- unset($ThisFileInfo['mpeg']['audio']);
- }
- if (isset($ThisFileInfo['mpeg']) && (!is_array($ThisFileInfo['mpeg']) || empty($ThisFileInfo['mpeg']))) {
- unset($ThisFileInfo['mpeg']);
- }
- return false;
-
- }
- break;
- }
-
- }
- $ThisFileInfo['audio']['bits_per_sample'] = 16;
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['mpeg']['audio']['channels'];
- $ThisFileInfo['audio']['channelmode'] = $ThisFileInfo['mpeg']['audio']['channelmode'];
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['mpeg']['audio']['sample_rate'];
- return true;
-}
-
-
-function MPEGaudioVersionArray() {
- static $MPEGaudioVersion = array('2.5', false, '2', '1');
- return $MPEGaudioVersion;
-}
-
-function MPEGaudioLayerArray() {
- static $MPEGaudioLayer = array(false, 'III', 'II', 'I');
- return $MPEGaudioLayer;
-}
-
-function MPEGaudioBitrateArray() {
- static $MPEGaudioBitrate;
- if (empty($MPEGaudioBitrate)) {
- $MPEGaudioBitrate['1']['I'] = array('free', 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448);
- $MPEGaudioBitrate['1']['II'] = array('free', 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384);
- $MPEGaudioBitrate['1']['III'] = array('free', 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320);
- $MPEGaudioBitrate['2']['I'] = array('free', 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256);
- $MPEGaudioBitrate['2']['II'] = array('free', 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160);
- $MPEGaudioBitrate['2']['III'] = $MPEGaudioBitrate['2']['II'];
- $MPEGaudioBitrate['2.5']['I'] = $MPEGaudioBitrate['2']['I'];
- $MPEGaudioBitrate['2.5']['II'] = $MPEGaudioBitrate['2']['II'];
- $MPEGaudioBitrate['2.5']['III'] = $MPEGaudioBitrate['2']['III'];
- }
- return $MPEGaudioBitrate;
-}
-
-function MPEGaudioFrequencyArray() {
- static $MPEGaudioFrequency;
- if (empty($MPEGaudioFrequency)) {
- $MPEGaudioFrequency['1'] = array(44100, 48000, 32000);
- $MPEGaudioFrequency['2'] = array(22050, 24000, 16000);
- $MPEGaudioFrequency['2.5'] = array(11025, 12000, 8000);
- }
- return $MPEGaudioFrequency;
-}
-
-function MPEGaudioChannelModeArray() {
- static $MPEGaudioChannelMode = array('stereo', 'joint stereo', 'dual channel', 'mono');
- return $MPEGaudioChannelMode;
-}
-
-function MPEGaudioModeExtensionArray() {
- static $MPEGaudioModeExtension;
- if (empty($MPEGaudioModeExtension)) {
- $MPEGaudioModeExtension['I'] = array('4-31', '8-31', '12-31', '16-31');
- $MPEGaudioModeExtension['II'] = array('4-31', '8-31', '12-31', '16-31');
- $MPEGaudioModeExtension['III'] = array('', 'IS', 'MS', 'IS+MS');
- }
- return $MPEGaudioModeExtension;
-}
-
-function MPEGaudioEmphasisArray() {
- static $MPEGaudioEmphasis = array('none', '50/15ms', false, 'CCIT J.17');
- return $MPEGaudioEmphasis;
-}
-
-
-function MPEGaudioHeaderBytesValid($head4) {
- return MPEGaudioHeaderValid(MPEGaudioHeaderDecode($head4));
-}
-
-function MPEGaudioHeaderValid($rawarray, $echoerrors=false) {
-
- if (($rawarray['synch'] & 0x0FFE) != 0x0FFE) {
- return false;
- }
-
- static $MPEGaudioVersionLookup;
- static $MPEGaudioLayerLookup;
- static $MPEGaudioBitrateLookup;
- static $MPEGaudioFrequencyLookup;
- static $MPEGaudioChannelModeLookup;
- static $MPEGaudioModeExtensionLookup;
- static $MPEGaudioEmphasisLookup;
- if (empty($MPEGaudioVersionLookup)) {
- $MPEGaudioVersionLookup = MPEGaudioVersionArray();
- $MPEGaudioLayerLookup = MPEGaudioLayerArray();
- $MPEGaudioBitrateLookup = MPEGaudioBitrateArray();
- $MPEGaudioFrequencyLookup = MPEGaudioFrequencyArray();
- $MPEGaudioChannelModeLookup = MPEGaudioChannelModeArray();
- $MPEGaudioModeExtensionLookup = MPEGaudioModeExtensionArray();
- $MPEGaudioEmphasisLookup = MPEGaudioEmphasisArray();
- }
-
- if (isset($MPEGaudioVersionLookup[$rawarray['version']])) {
- $decodedVersion = $MPEGaudioVersionLookup[$rawarray['version']];
- } else {
- if ($echoerrors) {
- echo "\n".'invalid Version ('.$rawarray['version'].')';
- }
- return false;
- }
- if (isset($MPEGaudioLayerLookup[$rawarray['layer']])) {
- $decodedLayer = $MPEGaudioLayerLookup[$rawarray['layer']];
- } else {
- if ($echoerrors) {
- echo "\n".'invalid Layer ('.$rawarray['layer'].')';
- }
- return false;
- }
- if (!isset($MPEGaudioBitrateLookup[$decodedVersion][$decodedLayer][$rawarray['bitrate']])) {
- if ($echoerrors) {
- echo "\n".'invalid Bitrate ('.$rawarray['bitrate'].')';
- }
- if ($rawarray['bitrate'] == 15) {
- // known issue in LAME 3.90 - 3.93.1 where free-format has bitrate ID of 15 instead of 0
- // let it go through here otherwise file will not be identified
- } else {
- return false;
- }
- }
- if (!isset($MPEGaudioFrequencyLookup[$decodedVersion][$rawarray['sample_rate']])) {
- if ($echoerrors) {
- echo "\n".'invalid Frequency ('.$rawarray['sample_rate'].')';
- }
- return false;
- }
- if (!isset($MPEGaudioChannelModeLookup[$rawarray['channelmode']])) {
- if ($echoerrors) {
- echo "\n".'invalid ChannelMode ('.$rawarray['channelmode'].')';
- }
- return false;
- }
- if (!isset($MPEGaudioModeExtensionLookup[$decodedLayer][$rawarray['modeextension']])) {
- if ($echoerrors) {
- echo "\n".'invalid Mode Extension ('.$rawarray['modeextension'].')';
- }
- return false;
- }
- if (!isset($MPEGaudioEmphasisLookup[$rawarray['emphasis']])) {
- if ($echoerrors) {
- echo "\n".'invalid Emphasis ('.$rawarray['emphasis'].')';
- }
- return false;
- }
- // These are just either set or not set, you can't mess that up :)
- // $rawarray['protection'];
- // $rawarray['padding'];
- // $rawarray['private'];
- // $rawarray['copyright'];
- // $rawarray['original'];
-
- return true;
-}
-
-function MPEGaudioHeaderDecode($Header4Bytes) {
- // AAAA AAAA AAAB BCCD EEEE FFGH IIJJ KLMM
- // A - Frame sync (all bits set)
- // B - MPEG Audio version ID
- // C - Layer description
- // D - Protection bit
- // E - Bitrate index
- // F - Sampling rate frequency index
- // G - Padding bit
- // H - Private bit
- // I - Channel Mode
- // J - Mode extension (Only if Joint stereo)
- // K - Copyright
- // L - Original
- // M - Emphasis
-
- if (strlen($Header4Bytes) != 4) {
- return false;
- }
-
- $MPEGrawHeader['synch'] = (BigEndian2Int(substr($Header4Bytes, 0, 2)) & 0xFFE0) >> 4;
- $MPEGrawHeader['version'] = (ord($Header4Bytes{1}) & 0x18) >> 3; // BB
- $MPEGrawHeader['layer'] = (ord($Header4Bytes{1}) & 0x06) >> 1; // CC
- $MPEGrawHeader['protection'] = (ord($Header4Bytes{1}) & 0x01); // D
- $MPEGrawHeader['bitrate'] = (ord($Header4Bytes{2}) & 0xF0) >> 4; // EEEE
- $MPEGrawHeader['sample_rate'] = (ord($Header4Bytes{2}) & 0x0C) >> 2; // FF
- $MPEGrawHeader['padding'] = (ord($Header4Bytes{2}) & 0x02) >> 1; // G
- $MPEGrawHeader['private'] = (ord($Header4Bytes{2}) & 0x01); // H
- $MPEGrawHeader['channelmode'] = (ord($Header4Bytes{3}) & 0xC0) >> 6; // II
- $MPEGrawHeader['modeextension'] = (ord($Header4Bytes{3}) & 0x30) >> 4; // JJ
- $MPEGrawHeader['copyright'] = (ord($Header4Bytes{3}) & 0x08) >> 3; // K
- $MPEGrawHeader['original'] = (ord($Header4Bytes{3}) & 0x04) >> 2; // L
- $MPEGrawHeader['emphasis'] = (ord($Header4Bytes{3}) & 0x03); // MM
-
- return $MPEGrawHeader;
-}
-
-function MPEGaudioFrameLength(&$bitrate, &$version, &$layer, $padding, &$samplerate) {
- static $AudioFrameLengthCache = array();
-
- if (!isset($AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate])) {
- $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate] = false;
- if ($bitrate != 'free') {
-
- if ($version == '1') {
-
- if ($layer == 'I') {
-
- // For Layer I slot is 32 bits long
- $FrameLengthCoefficient = 48;
- $SlotLength = 4;
-
- } else { // Layer II / III
-
- // for Layer II and Layer III slot is 8 bits long.
- $FrameLengthCoefficient = 144;
- $SlotLength = 1;
-
- }
-
- } else { // MPEG-2 / MPEG-2.5
-
- if ($layer == 'I') {
-
- // For Layer I slot is 32 bits long
- $FrameLengthCoefficient = 24;
- $SlotLength = 4;
-
- } elseif ($layer == 'II') {
-
- // for Layer II and Layer III slot is 8 bits long.
- $FrameLengthCoefficient = 144;
- $SlotLength = 1;
-
- } else { // III
-
- // for Layer II and Layer III slot is 8 bits long.
- $FrameLengthCoefficient = 72;
- $SlotLength = 1;
-
- }
-
- }
-
- // FrameLengthInBytes = ((Coefficient * BitRate) / SampleRate) + Padding
- // http://66.96.216.160/cgi-bin/YaBB.pl?board=c&action=display&num=1018474068
- // -> [Finding the next frame synch] on www.r3mix.net forums if the above link goes dead
- if ($samplerate > 0) {
- $NewFramelength = ($FrameLengthCoefficient * $bitrate * 1000) / $samplerate;
- $NewFramelength = floor($NewFramelength / $SlotLength) * $SlotLength; // round to next-lower multiple of SlotLength (1 byte for Layer II/III, 4 bytes for Layer I)
- if ($padding) {
- $NewFramelength += $SlotLength;
- }
- $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate] = (int) $NewFramelength;
- }
- }
- }
- return $AudioFrameLengthCache[$bitrate][$version][$layer][$padding][$samplerate];
-}
-
-function LAMEvbrMethodLookup($VBRmethodID) {
- static $LAMEvbrMethodLookup = array();
- if (empty($LAMEvbrMethodLookup)) {
- $LAMEvbrMethodLookup[0x00] = 'unknown';
- $LAMEvbrMethodLookup[0x01] = 'cbr';
- $LAMEvbrMethodLookup[0x02] = 'abr';
- $LAMEvbrMethodLookup[0x03] = 'vbr-old / vbr-rh';
- $LAMEvbrMethodLookup[0x04] = 'vbr-mtrh';
- $LAMEvbrMethodLookup[0x05] = 'vbr-new / vbr-mt';
- }
- return (isset($LAMEvbrMethodLookup[$VBRmethodID]) ? $LAMEvbrMethodLookup[$VBRmethodID] : '');
-}
-
-function LAMEmiscStereoModeLookup($StereoModeID) {
- static $LAMEmiscStereoModeLookup = array();
- if (empty($LAMEmiscStereoModeLookup)) {
- $LAMEmiscStereoModeLookup[0] = 'mono';
- $LAMEmiscStereoModeLookup[1] = 'stereo';
- $LAMEmiscStereoModeLookup[2] = 'dual';
- $LAMEmiscStereoModeLookup[3] = 'joint';
- $LAMEmiscStereoModeLookup[4] = 'forced';
- $LAMEmiscStereoModeLookup[5] = 'auto';
- $LAMEmiscStereoModeLookup[6] = 'intensity';
- $LAMEmiscStereoModeLookup[7] = 'other';
- }
- return (isset($LAMEmiscStereoModeLookup[$StereoModeID]) ? $LAMEmiscStereoModeLookup[$StereoModeID] : '');
-}
-
-function LAMEmiscSourceSampleFrequencyLookup($SourceSampleFrequencyID) {
- static $LAMEmiscSourceSampleFrequencyLookup = array();
- if (empty($LAMEmiscSourceSampleFrequencyLookup)) {
- $LAMEmiscSourceSampleFrequencyLookup[0] = '<= 32 kHz';
- $LAMEmiscSourceSampleFrequencyLookup[1] = '44.1 kHz';
- $LAMEmiscSourceSampleFrequencyLookup[2] = '48 kHz';
- $LAMEmiscSourceSampleFrequencyLookup[3] = '> 48kHz';
- }
- return (isset($LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID]) ? $LAMEmiscSourceSampleFrequencyLookup[$SourceSampleFrequencyID] : '');
-}
-
-function LAMEsurroundInfoLookup($SurroundInfoID) {
- static $LAMEsurroundInfoLookup = array();
- if (empty($LAMEsurroundInfoLookup)) {
- $LAMEsurroundInfoLookup[0] = 'no surround info';
- $LAMEsurroundInfoLookup[1] = 'DPL encoding';
- $LAMEsurroundInfoLookup[2] = 'DPL2 encoding';
- $LAMEsurroundInfoLookup[3] = 'Ambisonic encoding';
- }
- return (isset($LAMEsurroundInfoLookup[$SurroundInfoID]) ? $LAMEsurroundInfoLookup[$SurroundInfoID] : 'reserved');
-}
-
-?>
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.mysql.php b/apps/media/getID3/demos/demo.mysql.php
deleted file mode 100644
index c6b7c6b5eff..00000000000
--- a/apps/media/getID3/demos/demo.mysql.php
+++ /dev/null
@@ -1,2182 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.mysql.php - part of getID3() //
-// Sample script for recursively scanning directories and //
-// storing the results in a database //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-//die('Due to a security issue, this demo has been disabled. It can be enabled by removing line 16 in demos/demo.mysql.php');
-
-
-// OPTIONS:
-$getid3_demo_mysql_encoding = 'ISO-8859-1';
-$getid3_demo_mysql_md5_data = false; // All data hashes are by far the slowest part of scanning
-$getid3_demo_mysql_md5_file = false;
-
-define('GETID3_DB_HOST', 'localhost');
-define('GETID3_DB_USER', 'root');
-define('GETID3_DB_PASS', 'password');
-define('GETID3_DB_DB', 'getid3');
-define('GETID3_DB_TABLE', 'files');
-
-// CREATE DATABASE `getid3`;
-
-if (!@mysql_connect(GETID3_DB_HOST, GETID3_DB_USER, GETID3_DB_PASS)) {
- die('Could not connect to MySQL host: '.mysql_error().' ');
-}
-if (!@mysql_select_db(GETID3_DB_DB)) {
- die('Could not select database: '.mysql_error().' ');
-}
-
-if (!@include_once('../getid3/getid3.php')) {
- die('Cannot open '.realpath('../getid3/getid3.php'));
-}
-// Initialize getID3 engine
-$getID3 = new getID3;
-$getID3->setOption(array(
- 'option_md5_data' => $getid3_demo_mysql_md5_data,
- 'encoding' => $getid3_demo_mysql_encoding,
-));
-
-
-function RemoveAccents($string) {
- // Revised version by markstewardhotmail*com
- return strtr(strtr($string, '', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'), array('' => 'TH', '' => 'th', '' => 'DH', '' => 'dh', '' => 'ss', '' => 'OE', '' => 'oe', '' => 'AE', '' => 'ae', '' => 'u'));
-}
-
-function FixTextFields($text) {
- $text = getid3_lib::SafeStripSlashes($text);
- $text = htmlentities($text, ENT_QUOTES);
- return $text;
-}
-
-function BitrateColor($bitrate, $BitrateMaxScale=768) {
- // $BitrateMaxScale is bitrate of maximum-quality color (bright green)
- // below this is gradient, above is solid green
-
- $bitrate *= (256 / $BitrateMaxScale); // scale from 1-[768]kbps to 1-256
- $bitrate = round(min(max($bitrate, 1), 256));
- $bitrate--; // scale from 1-256kbps to 0-255kbps
-
- $Rcomponent = max(255 - ($bitrate * 2), 0);
- $Gcomponent = max(($bitrate * 2) - 255, 0);
- if ($bitrate > 127) {
- $Bcomponent = max((255 - $bitrate) * 2, 0);
- } else {
- $Bcomponent = max($bitrate * 2, 0);
- }
- return str_pad(dechex($Rcomponent), 2, '0', STR_PAD_LEFT).str_pad(dechex($Gcomponent), 2, '0', STR_PAD_LEFT).str_pad(dechex($Bcomponent), 2, '0', STR_PAD_LEFT);
-}
-
-function BitrateText($bitrate, $decimals=0) {
- return ''.number_format($bitrate, $decimals).' kbps ';
-}
-
-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 '';
-}
-
-function RenameFileFromTo($from, $to, &$results) {
- $success = true;
- if ($from === $to) {
- $results = 'Source and Destination filenames identical FAILED to rename';
- } elseif (!file_exists($from)) {
- $results = 'Source file does not exist FAILED to rename';
- } elseif (file_exists($to) && (strtolower($from) !== strtolower($to))) {
- $results = 'Destination file already exists FAILED to rename';
- } elseif (@rename($from, $to)) {
- $SQLquery = 'DELETE FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`filename` = "'.mysql_escape_string($from).'")';
- safe_mysql_query($SQLquery);
- $results = 'Successfully renamed';
- } else {
- $results = 'FAILED to rename';
- $success = false;
- }
- $results .= ' from:'.$from.' to:'.$to.' ';
- return $success;
-}
-
-if (!empty($_REQUEST['renamefilefrom']) && !empty($_REQUEST['renamefileto'])) {
-
- $results = '';
- RenameFileFromTo($_REQUEST['renamefilefrom'], $_REQUEST['renamefileto'], $results);
- echo $results;
- exit;
-
-} elseif (!empty($_REQUEST['m3ufilename'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- echo WindowsShareSlashTranslate($_REQUEST['m3ufilename'])."\n";
- exit;
-
-} elseif (!isset($_REQUEST['m3u']) && !isset($_REQUEST['m3uartist']) && !isset($_REQUEST['m3utitle'])) {
-
- echo '';
- echo 'getID3() demo - /demo/mysql.php ';
-
-}
-
-
-function WindowsShareSlashTranslate($filename) {
- if (substr($filename, 0, 2) == '//') {
- return str_replace('/', '\\', $filename);
- }
- return $filename;
-}
-
-function safe_mysql_query($SQLquery) {
- $result = @mysql_query($SQLquery);
- if (mysql_error()) {
- die(''.mysql_error().' '.$SQLquery.' ');
- }
- return $result;
-}
-
-function mysql_table_exists($tablename) {
- return (bool) mysql_query('DESCRIBE '.$tablename);
-}
-
-function AcceptableExtensions($fileformat, $audio_dataformat='', $video_dataformat='') {
- static $AcceptableExtensionsAudio = array();
- if (empty($AcceptableExtensionsAudio)) {
- $AcceptableExtensionsAudio['mp3']['mp3'] = array('mp3');
- $AcceptableExtensionsAudio['mp2']['mp2'] = array('mp2');
- $AcceptableExtensionsAudio['mp1']['mp1'] = array('mp1');
- $AcceptableExtensionsAudio['asf']['asf'] = array('asf');
- $AcceptableExtensionsAudio['asf']['wma'] = array('wma');
- $AcceptableExtensionsAudio['riff']['mp3'] = array('wav');
- $AcceptableExtensionsAudio['riff']['wav'] = array('wav');
- }
- static $AcceptableExtensionsVideo = array();
- if (empty($AcceptableExtensionsVideo)) {
- $AcceptableExtensionsVideo['mp3']['mp3'] = array('mp3');
- $AcceptableExtensionsVideo['mp2']['mp2'] = array('mp2');
- $AcceptableExtensionsVideo['mp1']['mp1'] = array('mp1');
- $AcceptableExtensionsVideo['asf']['asf'] = array('asf');
- $AcceptableExtensionsVideo['asf']['wmv'] = array('wmv');
- $AcceptableExtensionsVideo['gif']['gif'] = array('gif');
- $AcceptableExtensionsVideo['jpg']['jpg'] = array('jpg');
- $AcceptableExtensionsVideo['png']['png'] = array('png');
- $AcceptableExtensionsVideo['bmp']['bmp'] = array('bmp');
- }
- if (!empty($video_dataformat)) {
- return (isset($AcceptableExtensionsVideo[$fileformat][$video_dataformat]) ? $AcceptableExtensionsVideo[$fileformat][$video_dataformat] : array());
- } else {
- return (isset($AcceptableExtensionsAudio[$fileformat][$audio_dataformat]) ? $AcceptableExtensionsAudio[$fileformat][$audio_dataformat] : array());
- }
-}
-
-
-if (!empty($_REQUEST['scan'])) {
- if (mysql_table_exists(GETID3_DB_TABLE)) {
- $SQLquery = 'DROP TABLE `'.GETID3_DB_TABLE.'`';
- safe_mysql_query($SQLquery);
- }
-}
-if (!mysql_table_exists(GETID3_DB_TABLE)) {
- $SQLquery = 'CREATE TABLE `'.GETID3_DB_TABLE.'` (';
- $SQLquery .= ' `ID` mediumint(8) unsigned NOT NULL auto_increment,';
- $SQLquery .= ' `filename` text NOT NULL,';
- $SQLquery .= ' `LastModified` int(11) NOT NULL default "0",';
- $SQLquery .= ' `md5_file` varchar(32) NOT NULL default "",';
- $SQLquery .= ' `md5_data` varchar(32) NOT NULL default "",';
- $SQLquery .= ' `md5_data_source` varchar(32) NOT NULL default "",';
- $SQLquery .= ' `filesize` int(10) unsigned NOT NULL default "0",';
- $SQLquery .= ' `fileformat` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `audio_dataformat` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `video_dataformat` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `audio_bitrate` float NOT NULL default "0",';
- $SQLquery .= ' `video_bitrate` float NOT NULL default "0",';
- $SQLquery .= ' `playtime_seconds` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `tags` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `artist` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `title` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `remix` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `album` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `genre` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `comment` text NOT NULL,';
- $SQLquery .= ' `track` varchar(7) NOT NULL default "",';
- $SQLquery .= ' `comments_all` text NOT NULL,';
- $SQLquery .= ' `comments_id3v2` text NOT NULL,';
- $SQLquery .= ' `comments_ape` text NOT NULL,';
- $SQLquery .= ' `comments_lyrics3` text NOT NULL,';
- $SQLquery .= ' `comments_id3v1` text NOT NULL,';
- $SQLquery .= ' `warning` text NOT NULL,';
- $SQLquery .= ' `error` text NOT NULL,';
- $SQLquery .= ' `track_volume` float NOT NULL default "0",';
- $SQLquery .= ' `encoder_options` varchar(255) NOT NULL default "",';
- $SQLquery .= ' `vbr_method` varchar(255) NOT NULL default "",';
- $SQLquery .= ' PRIMARY KEY (`ID`)';
- $SQLquery .= ') TYPE=MyISAM;';
-
- safe_mysql_query($SQLquery);
-}
-
-$ExistingTableFields = array();
-$result = mysql_query('DESCRIBE `'.GETID3_DB_TABLE.'`');
-while ($row = mysql_fetch_array($result)) {
- $ExistingTableFields[$row['Field']] = $row;
-}
-if (!isset($ExistingTableFields['encoder_options'])) { // Added in 1.7.0b2
- echo 'adding field `encoder_options` ';
- mysql_query('ALTER TABLE `'.GETID3_DB_TABLE.'` ADD `encoder_options` VARCHAR(255) DEFAULT "" NOT NULL AFTER `error`');
- mysql_query('OPTIMIZE TABLE `'.GETID3_DB_TABLE.'`');
-}
-if (isset($ExistingTableFields['track']) && ($ExistingTableFields['track']['Type'] != 'varchar(7)')) { // Changed in 1.7.0b2
- echo 'changing field `track` to VARCHAR(7) ';
- mysql_query('ALTER TABLE `'.GETID3_DB_TABLE.'` CHANGE `track` `track` VARCHAR(7) DEFAULT "" NOT NULL');
- mysql_query('OPTIMIZE TABLE `'.GETID3_DB_TABLE.'`');
-}
-if (!isset($ExistingTableFields['track_volume'])) { // Added in 1.7.0b5
- echo 'WARNING! You should erase your database and rescan everything because the comment storing has been changed since the last version ';
- echo 'adding field `track_volume` ';
- mysql_query('ALTER TABLE `'.GETID3_DB_TABLE.'` ADD `track_volume` FLOAT NOT NULL AFTER `error`');
- mysql_query('OPTIMIZE TABLE `'.GETID3_DB_TABLE.'`');
-}
-if (!isset($ExistingTableFields['remix'])) { // Added in 1.7.3b1
- echo 'adding field `encoder_options`, `alternate_name`, `parody` ';
- mysql_query('ALTER TABLE `'.GETID3_DB_TABLE.'` ADD `remix` VARCHAR(255) DEFAULT "" NOT NULL AFTER `title`');
- mysql_query('ALTER TABLE `'.GETID3_DB_TABLE.'` ADD `alternate_name` VARCHAR(255) DEFAULT "" NOT NULL AFTER `track`');
- mysql_query('ALTER TABLE `'.GETID3_DB_TABLE.'` ADD `parody` VARCHAR(255) DEFAULT "" NOT NULL AFTER `alternate_name`');
- mysql_query('OPTIMIZE TABLE `'.GETID3_DB_TABLE.'`');
-}
-
-
-function SynchronizeAllTags($filename, $synchronizefrom='all', $synchronizeto='A12', &$errors) {
- global $getID3;
-
- set_time_limit(30);
-
- $ThisFileInfo = $getID3->analyze($filename);
- getid3_lib::CopyTagsToComments($ThisFileInfo);
-
- if ($synchronizefrom == 'all') {
- $SourceArray = @$ThisFileInfo['comments'];
- } elseif (!empty($ThisFileInfo['tags'][$synchronizefrom])) {
- $SourceArray = @$ThisFileInfo['tags'][$synchronizefrom];
- } else {
- die('ERROR: $ThisFileInfo[tags]['.$synchronizefrom.'] does not exist');
- }
-
- $SQLquery = 'DELETE FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`filename` = "'.mysql_escape_string($filename).'")';
- safe_mysql_query($SQLquery);
-
-
- $TagFormatsToWrite = array();
- if ((strpos($synchronizeto, '2') !== false) && ($synchronizefrom != 'id3v2')) {
- $TagFormatsToWrite[] = 'id3v2.3';
- }
- if ((strpos($synchronizeto, 'A') !== false) && ($synchronizefrom != 'ape')) {
- $TagFormatsToWrite[] = 'ape';
- }
- if ((strpos($synchronizeto, 'L') !== false) && ($synchronizefrom != 'lyrics3')) {
- $TagFormatsToWrite[] = 'lyrics3';
- }
- if ((strpos($synchronizeto, '1') !== false) && ($synchronizefrom != 'id3v1')) {
- $TagFormatsToWrite[] = 'id3v1';
- }
-
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.php', __FILE__, true);
- $tagwriter = new getid3_writetags;
- $tagwriter->filename = $filename;
- $tagwriter->tagformats = $TagFormatsToWrite;
- $tagwriter->overwrite_tags = true;
- $tagwriter->tag_encoding = $getID3->encoding;
- $tagwriter->tag_data = $SourceArray;
-
- if ($tagwriter->WriteTags()) {
- $errors = $tagwriter->errors;
- return true;
- }
- $errors = $tagwriter->errors;
- return false;
-}
-
-$IgnoreNoTagFormats = array('', 'png', 'jpg', 'gif', 'bmp', 'swf', 'pdf', 'zip', 'rar', 'mid', 'mod', 'xm', 'it', 's3m');
-
-if (!empty($_REQUEST['scan']) || !empty($_REQUEST['newscan']) || !empty($_REQUEST['rescanerrors'])) {
-
- $SQLquery = 'DELETE from `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`fileformat` = "")';
- safe_mysql_query($SQLquery);
-
- $FilesInDir = array();
-
- if (!empty($_REQUEST['rescanerrors'])) {
-
- echo 'abort ';
-
- echo 'Re-scanning all media files already in database that had errors and/or warnings in last scan ';
-
- $SQLquery = 'SELECT `filename`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`error` <> "")';
- $SQLquery .= ' OR (`warning` <> "")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- while ($row = mysql_fetch_array($result)) {
-
- if (!file_exists($row['filename'])) {
- echo 'File missing: '.$row['filename'].' ';
- $SQLquery = 'DELETE FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`filename` = "'.mysql_escape_string($row['filename']).'")';
- safe_mysql_query($SQLquery);
- } else {
- $FilesInDir[] = $row['filename'];
- }
-
- }
-
- } elseif (!empty($_REQUEST['scan']) || !empty($_REQUEST['newscan'])) {
-
- echo 'abort ';
-
- echo 'Scanning all media files in '.str_replace('\\', '/', realpath(!empty($_REQUEST['scan']) ? $_REQUEST['scan'] : $_REQUEST['newscan'])).' (and subdirectories) ';
-
- $SQLquery = 'SELECT COUNT(*) AS `num`, `filename`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' GROUP BY `filename`';
- $SQLquery .= ' ORDER BY `num` DESC';
- $result = safe_mysql_query($SQLquery);
- $DupesDeleted = 0;
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- if ($row['num'] <= 1) {
- break;
- }
- $SQLquery = 'DELETE FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE `filename` LIKE "'.mysql_escape_string($row['filename']).'"';
- safe_mysql_query($SQLquery);
- $DupesDeleted++;
- }
- if ($DupesDeleted > 0) {
- echo 'Deleted '.number_format($DupesDeleted).' duplicate filenames ';
- }
-
- if (!empty($_REQUEST['newscan'])) {
- $AlreadyInDatabase = array();
- set_time_limit(60);
- $SQLquery = 'SELECT `filename`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- while ($row = mysql_fetch_array($result)) {
- //$AlreadyInDatabase[] = strtolower($row['filename']);
- $AlreadyInDatabase[] = $row['filename'];
- }
- }
-
- $DirectoriesToScan = array(@$_REQUEST['scan'] ? $_REQUEST['scan'] : $_REQUEST['newscan']);
- $DirectoriesScanned = array();
- while (count($DirectoriesToScan) > 0) {
- foreach ($DirectoriesToScan as $DirectoryKey => $startingdir) {
- if ($dir = opendir($startingdir)) {
- set_time_limit(30);
- echo ''.str_replace('\\', '/', $startingdir).' ';
- flush();
- while (($file = readdir($dir)) !== false) {
- if (($file != '.') && ($file != '..')) {
- $RealPathName = realpath($startingdir.'/'.$file);
- if (is_dir($RealPathName)) {
- if (!in_array($RealPathName, $DirectoriesScanned) && !in_array($RealPathName, $DirectoriesToScan)) {
- $DirectoriesToScan[] = $RealPathName;
- }
- } else if (is_file($RealPathName)) {
- if (!empty($_REQUEST['newscan'])) {
- if (!in_array(str_replace('\\', '/', $RealPathName), $AlreadyInDatabase)) {
- $FilesInDir[] = $RealPathName;
- }
- } elseif (!empty($_REQUEST['scan'])) {
- $FilesInDir[] = $RealPathName;
- }
- }
- }
- }
- closedir($dir);
- } else {
- echo 'Failed to open directory "'.$startingdir.' " ';
- }
- $DirectoriesScanned[] = $startingdir;
- unset($DirectoriesToScan[$DirectoryKey]);
- }
- }
- echo 'List of files to scan complete (added '.number_format(count($FilesInDir)).' files to scan) ';
- flush();
- }
-
- $FilesInDir = array_unique($FilesInDir);
- sort($FilesInDir);
-
- $starttime = time();
- $rowcounter = 0;
- $totaltoprocess = count($FilesInDir);
-
- foreach ($FilesInDir as $filename) {
- set_time_limit(300);
-
- echo ' '.date('H:i:s').' ['.number_format(++$rowcounter).' / '.number_format($totaltoprocess).'] '.str_replace('\\', '/', $filename);
-
- $ThisFileInfo = $getID3->analyze($filename);
- getid3_lib::CopyTagsToComments($ThisFileInfo);
-
- if (file_exists($filename)) {
- $ThisFileInfo['file_modified_time'] = filemtime($filename);
- $ThisFileInfo['md5_file'] = ($getid3_demo_mysql_md5_file ? md5_file($filename) : '');
- }
-
- if (empty($ThisFileInfo['fileformat'])) {
-
- echo ' (unknown file type )';
-
- } else {
-
- if (!empty($ThisFileInfo['error'])) {
- echo ' (errors )';
- } elseif (!empty($ThisFileInfo['warning'])) {
- echo ' (warnings )';
- } else {
- echo ' (OK )';
- }
-
- $this_track_track = '';
- if (!empty($ThisFileInfo['comments']['track'])) {
- foreach ($ThisFileInfo['comments']['track'] as $key => $value) {
- if (strlen($value) > strlen($this_track_track)) {
- $this_track_track = str_pad($value, 2, '0', STR_PAD_LEFT);
- }
- }
- if (ereg('^([0-9]+)/([0-9]+)$', $this_track_track, $matches)) {
- // change "1/5"->"01/05", "3/12"->"03/12", etc
- $this_track_track = str_pad($matches[1], 2, '0', STR_PAD_LEFT).'/'.str_pad($matches[2], 2, '0', STR_PAD_LEFT);
- }
- }
-
- $this_track_remix = '';
- $this_track_title = '';
- if (!empty($ThisFileInfo['comments']['title'])) {
- foreach ($ThisFileInfo['comments']['title'] as $possible_title) {
- if (strlen($possible_title) > strlen($this_track_title)) {
- $this_track_title = $possible_title;
- }
- }
- }
-
- $ParenthesesPairs = array('()', '[]', '{}');
- foreach ($ParenthesesPairs as $pair) {
- if (preg_match_all('/(.*) '.preg_quote($pair{0}).'(([^'.preg_quote($pair).']*[\- '.preg_quote($pair{0}).'])?(cut|dub|edit|version|live|reprise|[a-z]*mix))'.preg_quote($pair{1}).'/iU', $this_track_title, $matches)) {
- $this_track_title = $matches[1][0];
- $this_track_remix = implode("\t", $matches[2]);
- }
- }
-
-
-
- if (!empty($_REQUEST['rescanerrors'])) {
-
- $SQLquery = 'UPDATE `'.GETID3_DB_TABLE.'` SET ';
- $SQLquery .= '`LastModified` = "'.mysql_escape_string(@$ThisFileInfo['file_modified_time']).'", ';
- $SQLquery .= '`md5_file` = "'.mysql_escape_string(@$ThisFileInfo['md5_file']).'", ';
- $SQLquery .= '`md5_data` = "'.mysql_escape_string(@$ThisFileInfo['md5_data']).'", ';
- $SQLquery .= '`md5_data_source` = "'.mysql_escape_string(@$ThisFileInfo['md5_data_source']).'", ';
- $SQLquery .= '`filesize` = "'.mysql_escape_string(@$ThisFileInfo['filesize']).'", ';
- $SQLquery .= '`fileformat` = "'.mysql_escape_string(@$ThisFileInfo['fileformat']).'", ';
- $SQLquery .= '`audio_dataformat` = "'.mysql_escape_string(@$ThisFileInfo['audio']['dataformat']).'", ';
- $SQLquery .= '`video_dataformat` = "'.mysql_escape_string(@$ThisFileInfo['video']['dataformat']).'", ';
- $SQLquery .= '`audio_bitrate` = "'.mysql_escape_string(floatval(@$ThisFileInfo['audio']['bitrate'])).'", ';
- $SQLquery .= '`video_bitrate` = "'.mysql_escape_string(floatval(@$ThisFileInfo['video']['bitrate'])).'", ';
- $SQLquery .= '`playtime_seconds` = "'.mysql_escape_string(floatval(@$ThisFileInfo['playtime_seconds'])).'", ';
- $SQLquery .= '`tags` = "'.mysql_escape_string(@implode("\t", @array_keys(@$ThisFileInfo['tags']))).'", ';
- $SQLquery .= '`artist` = "'.mysql_escape_string(@implode("\t", @$ThisFileInfo['comments']['artist'])).'", ';
-
- $SQLquery .= '`title` = "'.mysql_escape_string($this_track_title).'", ';
- $SQLquery .= '`remix` = "'.mysql_escape_string($this_track_remix).'", ';
-
- $SQLquery .= '`album` = "'.mysql_escape_string(@implode("\t", @$ThisFileInfo['comments']['album'])).'", ';
- $SQLquery .= '`genre` = "'.mysql_escape_string(@implode("\t", @$ThisFileInfo['comments']['genre'])).'", ';
- $SQLquery .= '`comment` = "'.mysql_escape_string(@implode("\t", @$ThisFileInfo['comments']['comment'])).'", ';
-
- $SQLquery .= '`track` = "'.mysql_escape_string($this_track_track).'", ';
-
- $SQLquery .= '`comments_all` = "'.mysql_escape_string(@serialize(@$ThisFileInfo['comments'])).'", ';
- $SQLquery .= '`comments_id3v2` = "'.mysql_escape_string(@serialize(@$ThisFileInfo['tags']['id3v2'])).'", ';
- $SQLquery .= '`comments_ape` = "'.mysql_escape_string(@serialize(@$ThisFileInfo['tags']['ape'])).'", ';
- $SQLquery .= '`comments_lyrics3` = "'.mysql_escape_string(@serialize(@$ThisFileInfo['tags']['lyrics3'])).'", ';
- $SQLquery .= '`comments_id3v1` = "'.mysql_escape_string(@serialize(@$ThisFileInfo['tags']['id3v1'])).'", ';
- $SQLquery .= '`warning` = "'.mysql_escape_string(@implode("\t", @$ThisFileInfo['warning'])).'", ';
- $SQLquery .= '`error` = "'.mysql_escape_string(@implode("\t", @$ThisFileInfo['error'])).'", ';
- $SQLquery .= '`encoder_options` = "'.mysql_escape_string(trim(@$ThisFileInfo['audio']['encoder'].' '.@$ThisFileInfo['audio']['encoder_options'])).'", ';
- $SQLquery .= '`vbr_method` = "'.mysql_escape_string(@$ThisFileInfo['mpeg']['audio']['VBR_method']).'", ';
- $SQLquery .= '`track_volume` = "'.mysql_escape_string(floatval(@$ThisFileInfo['replay_gain']['track']['volume'])).'" ';
- $SQLquery .= 'WHERE (`filename` = "'.mysql_escape_string(@$ThisFileInfo['filenamepath']).'")';
-
- } elseif (!empty($_REQUEST['scan']) || !empty($_REQUEST['newscan'])) {
-
- $SQLquery = 'INSERT INTO `'.GETID3_DB_TABLE.'` (`filename`, `LastModified`, `md5_file`, `md5_data`, `md5_data_source`, `filesize`, `fileformat`, `audio_dataformat`, `video_dataformat`, `audio_bitrate`, `video_bitrate`, `playtime_seconds`, `tags`, `artist`, `title`, `remix`, `album`, `genre`, `comment`, `track`, `comments_all`, `comments_id3v2`, `comments_ape`, `comments_lyrics3`, `comments_id3v1`, `warning`, `error`, `encoder_options`, `vbr_method`, `track_volume`) VALUES (';
- $SQLquery .= '"'.mysql_escape_string(@$ThisFileInfo['filenamepath']).'", ';
- $SQLquery .= '"'.mysql_escape_string(@$ThisFileInfo['file_modified_time']).'", ';
- $SQLquery .= '"'.mysql_escape_string(@$ThisFileInfo['md5_file']).'", ';
- $SQLquery .= '"'.mysql_escape_string(@$ThisFileInfo['md5_data']).'", ';
- $SQLquery .= '"'.mysql_escape_string(@$ThisFileInfo['md5_data_source']).'", ';
- $SQLquery .= '"'.mysql_escape_string(@$ThisFileInfo['filesize']).'", ';
- $SQLquery .= '"'.mysql_escape_string(@$ThisFileInfo['fileformat']).'", ';
- $SQLquery .= '"'.mysql_escape_string(@$ThisFileInfo['audio']['dataformat']).'", ';
- $SQLquery .= '"'.mysql_escape_string(@$ThisFileInfo['video']['dataformat']).'", ';
- $SQLquery .= '"'.mysql_escape_string(floatval(@$ThisFileInfo['audio']['bitrate'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(floatval(@$ThisFileInfo['video']['bitrate'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(floatval(@$ThisFileInfo['playtime_seconds'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(@implode("\t", @array_keys(@$ThisFileInfo['tags']))).'", ';
- $SQLquery .= '"'.mysql_escape_string(@implode("\t", @$ThisFileInfo['comments']['artist'])).'", ';
-
- $SQLquery .= '"'.mysql_escape_string($this_track_title).'", ';
- $SQLquery .= '"'.mysql_escape_string($this_track_remix).'", ';
-
- $SQLquery .= '"'.mysql_escape_string(@implode("\t", @$ThisFileInfo['comments']['album'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(@implode("\t", @$ThisFileInfo['comments']['genre'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(@implode("\t", @$ThisFileInfo['comments']['comment'])).'", ';
-
- $SQLquery .= '"'.mysql_escape_string($this_track_track).'", ';
-
- $SQLquery .= '"'.mysql_escape_string(@serialize(@$ThisFileInfo['comments'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(@serialize(@$ThisFileInfo['tags']['id3v2'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(@serialize(@$ThisFileInfo['tags']['ape'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(@serialize(@$ThisFileInfo['tags']['lyrics3'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(@serialize(@$ThisFileInfo['tags']['id3v1'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(@implode("\t", @$ThisFileInfo['warning'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(@implode("\t", @$ThisFileInfo['error'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(trim(@$ThisFileInfo['audio']['encoder'].' '.@$ThisFileInfo['audio']['encoder_options'])).'", ';
- $SQLquery .= '"'.mysql_escape_string(!empty($ThisFileInfo['mpeg']['audio']['LAME']) ? 'LAME' : @$ThisFileInfo['mpeg']['audio']['VBR_method']).'", ';
- $SQLquery .= '"'.mysql_escape_string(floatval(@$ThisFileInfo['replay_gain']['track']['volume'])).'")';
-
- }
- flush();
- safe_mysql_query($SQLquery);
- }
-
- }
-
- $SQLquery = 'OPTIMIZE TABLE `'.GETID3_DB_TABLE.'`';
- safe_mysql_query($SQLquery);
-
- echo ' Done scanning! ';
-
-} elseif (!empty($_REQUEST['missingtrackvolume'])) {
-
- $MissingTrackVolumeFilesScanned = 0;
- $MissingTrackVolumeFilesAdjusted = 0;
- $MissingTrackVolumeFilesDeleted = 0;
- $SQLquery = 'SELECT `filename`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`track_volume` = "0")';
- $SQLquery .= ' AND (`audio_bitrate` > "0")';
- $result = safe_mysql_query($SQLquery);
- echo 'Scanning 0 / '.number_format(mysql_num_rows($result)).' files for track volume information: ';
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- echo '. ';
- flush();
- if (file_exists($row['filename'])) {
-
- $ThisFileInfo = $getID3->analyze($row['filename']);
- if (!empty($ThisFileInfo['replay_gain']['track']['volume'])) {
- $MissingTrackVolumeFilesAdjusted++;
- $SQLquery = 'UPDATE `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' SET `track_volume` = "'.$ThisFileInfo['replay_gain']['track']['volume'].'"';
- $SQLquery .= ' WHERE (`filename` = "'.mysql_escape_string($row['filename']).'")';
- safe_mysql_query($SQLquery);
- }
-
- } else {
-
- $MissingTrackVolumeFilesDeleted++;
- $SQLquery = 'DELETE FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`filename` = "'.mysql_escape_string($row['filename']).'")';
- safe_mysql_query($SQLquery);
-
- }
- }
- echo ' Scanned '.number_format($MissingTrackVolumeFilesScanned).' files with no track volume information. ';
- echo 'Found track volume information for '.number_format($MissingTrackVolumeFilesAdjusted).' of them (could not find info for '.number_format($MissingTrackVolumeFilesScanned - $MissingTrackVolumeFilesAdjusted).' files; deleted '.number_format($MissingTrackVolumeFilesDeleted).' records of missing files) ';
-
-} elseif (!empty($_REQUEST['deadfilescheck'])) {
-
- $SQLquery = 'SELECT COUNT(*) AS `num`, `filename`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' GROUP BY `filename`';
- $SQLquery .= ' ORDER BY `num` DESC';
- $result = safe_mysql_query($SQLquery);
- $DupesDeleted = 0;
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- if ($row['num'] <= 1) {
- break;
- }
- echo ' '.FixTextFields($row['filename']).' (duplicate )';
- $SQLquery = 'DELETE FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE `filename` LIKE "'.mysql_escape_string($row['filename']).'"';
- safe_mysql_query($SQLquery);
- $DupesDeleted++;
- }
- if ($DupesDeleted > 0) {
- echo ' Deleted '.number_format($DupesDeleted).' duplicate filenames ';
- }
-
- $SQLquery = 'SELECT `filename`, `filesize`, `LastModified`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- $totalchecked = 0;
- $totalremoved = 0;
- $previousdir = '';
- while ($row = mysql_fetch_array($result)) {
- $totalchecked++;
- set_time_limit(30);
- $reason = '';
- if (!file_exists($row['filename'])) {
- $reason = 'deleted';
- } elseif (filesize($row['filename']) != $row['filesize']) {
- $reason = 'filesize changed';
- } elseif (filemtime($row['filename']) != $row['LastModified']) {
- if (abs(filemtime($row['filename']) - $row['LastModified']) != 3600) {
- // off by exactly one hour == daylight savings time
- $reason = 'last-modified time changed';
- }
- }
-
- $thisdir = dirname($row['filename']);
- if ($reason) {
-
- $totalremoved++;
- echo ' '.FixTextFields($row['filename']).' ('.$reason.' )';
- flush();
- $SQLquery = 'DELETE FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`filename` = "'.mysql_escape_string($row['filename']).'")';
- safe_mysql_query($SQLquery);
-
- } elseif ($thisdir != $previousdir) {
-
- echo '. ';
- flush();
-
- }
- $previousdir = $thisdir;
- }
-
- echo ''.number_format($totalremoved).' of '.number_format($totalchecked).' files in database no longer exist, or have been altered since last scan. Removed from database. ';
-
-} elseif (!empty($_REQUEST['encodedbydistribution'])) {
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
-
- $SQLquery = 'SELECT `filename`, `comments_id3v2`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`encoder_options` = "'.mysql_escape_string($_REQUEST['encodedbydistribution']).'")';
- $result = mysql_query($SQLquery);
- $NonBlankEncodedBy = '';
- $BlankEncodedBy = '';
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- $CommentArray = unserialize($row['comments_id3v2']);
- if (isset($CommentArray['encoded_by'][0])) {
- $NonBlankEncodedBy .= WindowsShareSlashTranslate($row['filename'])."\n";
- } else {
- $BlankEncodedBy .= WindowsShareSlashTranslate($row['filename'])."\n";
- }
- }
- echo $NonBlankEncodedBy;
- echo $BlankEncodedBy;
- exit;
-
- } elseif (!empty($_REQUEST['showfiles'])) {
-
- echo 'show all ';
- echo '';
-
- $SQLquery = 'SELECT `filename`, `comments_id3v2`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $result = mysql_query($SQLquery);
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- $CommentArray = unserialize($row['comments_id3v2']);
- if (($_REQUEST['encodedbydistribution'] == '%') || (!empty($CommentArray['encoded_by'][0]) && ($_REQUEST['encodedbydistribution'] == $CommentArray['encoded_by'][0]))) {
- echo 'm3u ';
- echo ''.FixTextFields($row['filename']).' ';
- }
- }
- echo '
';
-
- } else {
-
- $SQLquery = 'SELECT `encoder_options`, `comments_id3v2`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' ORDER BY (`encoder_options` LIKE "LAME%") DESC, (`encoder_options` LIKE "CBR%") DESC';
- $result = mysql_query($SQLquery);
- $EncodedBy = array();
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- $CommentArray = unserialize($row['comments_id3v2']);
- if (isset($EncodedBy[$row['encoder_options']][@$CommentArray['encoded_by'][0]])) {
- $EncodedBy[$row['encoder_options']][@$CommentArray['encoded_by'][0]]++;
- } else {
- $EncodedBy[$row['encoder_options']][@$CommentArray['encoded_by'][0]] = 1;
- }
- }
- echo '.m3u version ';
- echo 'm3u Encoder Options Encoded By (ID3v2) ';
- foreach ($EncodedBy as $key => $value) {
- echo 'm3u ';
- echo ''.$key.' ';
- echo '';
- arsort($value);
- foreach ($value as $string => $count) {
- echo ''.number_format($count).' ';
- echo ''.$string.' ';
- }
- echo '
';
- }
- echo '
';
-
- }
-
-} elseif (!empty($_REQUEST['audiobitrates'])) {
-
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
- $BitrateDistribution = array();
- $SQLquery = 'SELECT ROUND(audio_bitrate / 1000) AS `RoundBitrate`, COUNT(*) AS `num`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`audio_bitrate` > 0)';
- $SQLquery .= ' GROUP BY `RoundBitrate`';
- $result = safe_mysql_query($SQLquery);
- while ($row = mysql_fetch_array($result)) {
- @$BitrateDistribution[getid3_mp3::ClosestStandardMP3Bitrate($row['RoundBitrate'] * 1000)] += $row['num']; // safe_inc
- }
-
- echo '';
- echo 'Bitrate Count ';
- foreach ($BitrateDistribution as $Bitrate => $Count) {
- echo '';
- echo ''.round($Bitrate / 1000).' kbps ';
- echo ''.number_format($Count).' ';
- echo ' ';
- }
- echo '
';
-
-
-} elseif (!empty($_REQUEST['emptygenres'])) {
-
- $SQLquery = 'SELECT `fileformat`, `filename`, `genre`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`genre` = "")';
- $SQLquery .= ' OR (`genre` = "Unknown")';
- $SQLquery .= ' OR (`genre` = "Other")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while ($row = mysql_fetch_array($result)) {
- if (!in_array($row['fileformat'], $IgnoreNoTagFormats)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- }
- exit;
-
- } else {
-
- echo '.m3u version ';
- $EmptyGenreCounter = 0;
- echo '';
- echo 'm3u filename ';
- while ($row = mysql_fetch_array($result)) {
- if (!in_array($row['fileformat'], $IgnoreNoTagFormats)) {
- $EmptyGenreCounter++;
- echo '';
- echo 'm3u ';
- echo ''.FixTextFields($row['filename']).' ';
- echo ' ';
- }
- }
- echo '
';
- echo ''.number_format($EmptyGenreCounter).' files with empty genres';
-
- }
-
-} elseif (!empty($_REQUEST['nonemptycomments'])) {
-
- $SQLquery = 'SELECT `filename`, `comment`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`comment` <> "")';
- $SQLquery .= ' ORDER BY `comment` ASC';
- $result = safe_mysql_query($SQLquery);
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while ($row = mysql_fetch_array($result)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- exit;
-
- } else {
-
- $NonEmptyCommentsCounter = 0;
- echo '.m3u version ';
- echo '';
- echo 'm3u filename comments ';
- while ($row = mysql_fetch_array($result)) {
- $NonEmptyCommentsCounter++;
- echo '';
- echo 'm3u ';
- echo ''.FixTextFields($row['filename']).' ';
- if (strlen(trim($row['comment'])) > 0) {
- echo ''.FixTextFields($row['comment']).' ';
- } else {
- echo 'space ';
- }
- echo ' ';
- }
- echo '
';
- echo ''.number_format($NonEmptyCommentsCounter).' files with non-empty comments';
-
- }
-
-} elseif (!empty($_REQUEST['trackzero'])) {
-
- $SQLquery = 'SELECT `filename`, `track`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`track` <> "")';
- $SQLquery .= ' AND ((`track` < "1")';
- $SQLquery .= ' OR (`track` > "99"))';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while ($row = mysql_fetch_array($result)) {
- if ((strlen($row['track']) > 0) && ($row['track'] < 1) || ($row['track'] > 99)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- }
- exit;
-
- } else {
-
- echo '.m3u version ';
- $TrackZeroCounter = 0;
- echo '';
- echo 'm3u filename track ';
- while ($row = mysql_fetch_array($result)) {
- if ((strlen($row['track']) > 0) && ($row['track'] < 1) || ($row['track'] > 99)) {
- $TrackZeroCounter++;
- echo '';
- echo 'm3u ';
- echo ''.FixTextFields($row['filename']).' ';
- echo ''.FixTextFields($row['track']).' ';
- echo ' ';
- }
- }
- echo '
';
- echo ''.number_format($TrackZeroCounter).' files with track "zero"';
-
- }
-
-
-} elseif (!empty($_REQUEST['titlefeat'])) {
-
- $SQLquery = 'SELECT `filename`, `title`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`title` LIKE "%feat.%")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while ($row = mysql_fetch_array($result)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- exit;
-
- } else {
-
- echo ''.number_format(mysql_num_rows($result)).' files with "feat." in the title (instead of the artist) ';
- echo '.m3u version ';
- echo '';
- echo 'm3u filename title ';
- while ($row = mysql_fetch_array($result)) {
- echo '';
- echo 'm3u ';
- echo ''.FixTextFields($row['filename']).' ';
- echo ''.eregi_replace('(feat\. .*)', '\\1 ', FixTextFields($row['title'])).' ';
- echo ' ';
- }
- echo '
';
-
- }
-
-
-} elseif (!empty($_REQUEST['tracknoalbum'])) {
-
- $SQLquery = 'SELECT `filename`, `track`, `album`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`track` <> "")';
- $SQLquery .= ' AND (`album` = "")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while ($row = mysql_fetch_array($result)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- exit;
-
- } else {
-
- echo ''.number_format(mysql_num_rows($result)).' files with a track number, but no album ';
- echo '.m3u version ';
- echo '';
- echo 'm3u filename track album ';
- while ($row = mysql_fetch_array($result)) {
- echo '';
- echo 'm3u ';
- echo ''.FixTextFields($row['filename']).' ';
- echo ''.FixTextFields($row['track']).' ';
- echo ''.FixTextFields($row['album']).' ';
- echo ' ';
- }
- echo '
';
-
- }
-
-
-} elseif (!empty($_REQUEST['synchronizetagsfrom']) && !empty($_REQUEST['filename'])) {
-
- echo 'Applying new tags from '.$_REQUEST['synchronizetagsfrom'].' in '.FixTextFields($_REQUEST['filename']).' ';
- $errors = array();
- if (SynchronizeAllTags($_REQUEST['filename'], $_REQUEST['synchronizetagsfrom'], 'A12', $errors)) {
- echo 'Sucessfully wrote tags ';
- } else {
- echo 'Tag writing had errors: ';
- }
- echo ' ';
-
-
-} elseif (!empty($_REQUEST['unsynchronizedtags'])) {
-
- $NotOKfiles = 0;
- $Autofixedfiles = 0;
- $FieldsToCompare = array('title', 'artist', 'album', 'year', 'genre', 'comment', 'track');
- $TagsToCompare = array('id3v2'=>false, 'ape'=>false, 'lyrics3'=>false, 'id3v1'=>false);
- $ID3v1FieldLengths = array('title'=>30, 'artist'=>30, 'album'=>30, 'year'=>4, 'genre'=>99, 'comment'=>28);
- if (strpos($_REQUEST['unsynchronizedtags'], '2') !== false) {
- $TagsToCompare['id3v2'] = true;
- }
- if (strpos($_REQUEST['unsynchronizedtags'], 'A') !== false) {
- $TagsToCompare['ape'] = true;
- }
- if (strpos($_REQUEST['unsynchronizedtags'], 'L') !== false) {
- $TagsToCompare['lyrics3'] = true;
- }
- if (strpos($_REQUEST['unsynchronizedtags'], '1') !== false) {
- $TagsToCompare['id3v1'] = true;
- }
-
- echo 'Auto-fix empty tags ';
- echo '
';
- echo '';
- echo '';
- echo 'View ';
- echo 'Filename ';
- echo 'Combined ';
- if ($TagsToCompare['id3v2']) {
- echo 'ID3v2 ';
- }
- if ($TagsToCompare['ape']) {
- echo 'APE ';
- }
- if ($TagsToCompare['lyrics3']) {
- echo 'Lyrics3 ';
- }
- if ($TagsToCompare['id3v1']) {
- echo 'ID3v1 ';
- }
- echo ' ';
-
- $SQLquery = 'SELECT `filename`, `comments_all`, `comments_id3v2`, `comments_ape`, `comments_lyrics3`, `comments_id3v1`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`fileformat` = "mp3")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- $lastdir = '';
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- if ($lastdir != dirname($row['filename'])) {
- echo '';
- flush();
- }
-
- $FileOK = true;
- $Mismatched = array('id3v2'=>false, 'ape'=>false, 'lyrics3'=>false, 'id3v1'=>false);
- $SemiMatched = array('id3v2'=>false, 'ape'=>false, 'lyrics3'=>false, 'id3v1'=>false);
- $EmptyTags = array('id3v2'=>true, 'ape'=>true, 'lyrics3'=>true, 'id3v1'=>true);
-
- $Comments['all'] = @unserialize($row['comments_all']);
- $Comments['id3v2'] = @unserialize($row['comments_id3v2']);
- $Comments['ape'] = @unserialize($row['comments_ape']);
- $Comments['lyrics3'] = @unserialize($row['comments_lyrics3']);
- $Comments['id3v1'] = @unserialize($row['comments_id3v1']);
-
- if (isset($Comments['ape']['tracknumber'])) {
- $Comments['ape']['track'] = $Comments['ape']['tracknumber'];
- unset($Comments['ape']['tracknumber']);
- }
- if (isset($Comments['ape']['track_number'])) {
- $Comments['ape']['track'] = $Comments['ape']['track_number'];
- unset($Comments['ape']['track_number']);
- }
- if (isset($Comments['id3v2']['track_number'])) {
- $Comments['id3v2']['track'] = $Comments['id3v2']['track_number'];
- unset($Comments['id3v2']['track_number']);
- }
- if (!empty($Comments['all']['track'])) {
- $besttrack = '';
- foreach ($Comments['all']['track'] as $key => $value) {
- if (strlen($value) > strlen($besttrack)) {
- $besttrack = $value;
- }
- }
- $Comments['all']['track'] = array(0=>$besttrack);
- }
-
- $ThisLine = '';
- $ThisLine .= 'view ';
- $ThisLine .= ''.FixTextFields($row['filename']).' ';
- $tagvalues = '';
- foreach ($FieldsToCompare as $fieldname) {
- $tagvalues .= $fieldname.' = '.@implode(" \n", @$Comments['all'][$fieldname])." \n";
- }
- $ThisLine .= 'all ';
- foreach ($TagsToCompare as $tagtype => $CompareThisTagType) {
- if ($CompareThisTagType) {
- $tagvalues = '';
- foreach ($FieldsToCompare as $fieldname) {
-
- if ($tagtype == 'id3v1') {
-
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE__, true);
- if (($fieldname == 'genre') && !getid3_id3v1::LookupGenreID(@$Comments['all'][$fieldname][0])) {
-
- // non-standard genres can never match, so just ignore
- $tagvalues .= $fieldname.' = '.@$Comments[$tagtype][$fieldname][0]."\n";
-
- } elseif ($fieldname == 'comment') {
-
- if (rtrim(substr(@$Comments[$tagtype][$fieldname][0], 0, 28)) != rtrim(substr(@$Comments['all'][$fieldname][0], 0, 28))) {
-//echo __LINE__.' ';
-//echo '';
-//var_dump($tagtype);
-//var_dump($fieldname);
-//echo '';
-//exit;
- $tagvalues .= $fieldname.' = [['.@$Comments[$tagtype][$fieldname][0].']]'."\n";
- if (trim(strtolower(RemoveAccents(substr(@$Comments[$tagtype][$fieldname][0], 0, 28)))) == trim(strtolower(RemoveAccents(substr(@$Comments['all'][$fieldname][0], 0, 28))))) {
- $SemiMatched[$tagtype] = true;
- } else {
- $Mismatched[$tagtype] = true;
- }
- $FileOK = false;
- } else {
- $tagvalues .= $fieldname.' = '.@$Comments[$tagtype][$fieldname][0]."\n";
- }
-
- } elseif ($fieldname == 'track') {
-
- // intval('01/20') == intval('1')
- if (intval(@$Comments[$tagtype][$fieldname][0]) != intval(@$Comments['all'][$fieldname][0])) {
-//echo __LINE__.' ';
-//echo '';
-//var_dump($tagtype);
-//var_dump($fieldname);
-//echo '';
-//exit;
- $tagvalues .= $fieldname.' = [['.@$Comments[$tagtype][$fieldname][0].']]'."\n";
- $Mismatched[$tagtype] = true;
- $FileOK = false;
- } else {
- $tagvalues .= $fieldname.' = '.@$Comments[$tagtype][$fieldname][0]."\n";
- }
-
- } elseif (rtrim(substr(@$Comments[$tagtype][$fieldname][0], 0, 30)) != rtrim(substr(@$Comments['all'][$fieldname][0], 0, 30))) {
-
-//echo __LINE__.' ';
-//echo '';
-//var_dump($tagtype);
-//var_dump($fieldname);
-//echo '';
-//exit;
- $tagvalues .= $fieldname.' = [['.@$Comments[$tagtype][$fieldname][0].']]'."\n";
- if (strtolower(RemoveAccents(trim(substr(@$Comments[$tagtype][$fieldname][0], 0, 30)))) == strtolower(RemoveAccents(trim(substr(@$Comments['all'][$fieldname][0], 0, 30))))) {
- $SemiMatched[$tagtype] = true;
- } else {
- $Mismatched[$tagtype] = true;
- }
- $FileOK = false;
- if (strlen(trim(@$Comments[$tagtype][$fieldname][0])) > 0) {
- $EmptyTags[$tagtype] = false;
- }
-
- } else {
-
- $tagvalues .= $fieldname.' = '.@$Comments[$tagtype][$fieldname][0]."\n";
- if (strlen(trim(@$Comments[$tagtype][$fieldname][0])) > 0) {
- $EmptyTags[$tagtype] = false;
- }
-
- }
-
- } elseif (($tagtype == 'ape') && ($fieldname == 'year')) {
-
- if ((@$Comments['ape']['date'][0] != @$Comments['all']['year'][0]) && (@$Comments['ape']['year'][0] != @$Comments['all']['year'][0])) {
-
- $tagvalues .= $fieldname.' = [['.@$Comments['ape']['date'][0].']]'."\n";
- $Mismatched[$tagtype] = true;
- $FileOK = false;
- if (strlen(trim(@$Comments['ape']['date'][0])) > 0) {
- $EmptyTags[$tagtype] = false;
- }
-
- } else {
-
- $tagvalues .= $fieldname.' = '.@$Comments[$tagtype][$fieldname][0]."\n";
- if (strlen(trim(@$Comments[$tagtype][$fieldname][0])) > 0) {
- $EmptyTags[$tagtype] = false;
- }
-
- }
-
- } elseif (($fieldname == 'genre') && !empty($Comments['all'][$fieldname]) && !empty($Comments[$tagtype][$fieldname]) && in_array($Comments[$tagtype][$fieldname][0], $Comments['all'][$fieldname])) {
-
- $tagvalues .= $fieldname.' = '.@$Comments[$tagtype][$fieldname][0]."\n";
- if (strlen(trim(@$Comments[$tagtype][$fieldname][0])) > 0) {
- $EmptyTags[$tagtype] = false;
- }
-
- } elseif (@$Comments[$tagtype][$fieldname][0] != @$Comments['all'][$fieldname][0]) {
-
-//echo __LINE__.' ';
-//echo '';
-//var_dump($tagtype);
-//var_dump($fieldname);
-//var_dump($Comments[$tagtype][$fieldname][0]);
-//var_dump($Comments['all'][$fieldname][0]);
-//echo '';
-//exit;
- $skiptracknumberfield = false;
- switch ($fieldname) {
- case 'track':
- case 'tracknumber':
- case 'track_number':
- if (intval(@$Comments[$tagtype][$fieldname][0]) == intval(@$Comments['all'][$fieldname][0])) {
- $skiptracknumberfield = true;
- }
- break;
- }
- if (!$skiptracknumberfield) {
- $tagvalues .= $fieldname.' = [['.@$Comments[$tagtype][$fieldname][0].']]'."\n";
- if (trim(strtolower(RemoveAccents(@$Comments[$tagtype][$fieldname][0]))) == trim(strtolower(RemoveAccents(@$Comments['all'][$fieldname][0])))) {
- $SemiMatched[$tagtype] = true;
- } else {
- $Mismatched[$tagtype] = true;
- }
- $FileOK = false;
- if (strlen(trim(@$Comments[$tagtype][$fieldname][0])) > 0) {
- $EmptyTags[$tagtype] = false;
- }
- }
-
- } else {
-
- $tagvalues .= $fieldname.' = '.@$Comments[$tagtype][$fieldname][0]."\n";
- if (strlen(trim(@$Comments[$tagtype][$fieldname][0])) > 0) {
- $EmptyTags[$tagtype] = false;
- }
-
- }
- }
-
- if ($EmptyTags[$tagtype]) {
- $FileOK = false;
- $ThisLine .= '';
- } elseif ($SemiMatched[$tagtype]) {
- $ThisLine .= ' ';
- } elseif ($Mismatched[$tagtype]) {
- $ThisLine .= ' ';
- } else {
- $ThisLine .= ' ';
- }
- $ThisLine .= ''.$tagtype.' ';
- $ThisLine .= ' ';
- }
- }
- $ThisLine .= ' ';
-
- if (!$FileOK) {
- $NotOKfiles++;
-
- echo '';
- flush();
-
- if (!empty($_REQUEST['autofix'])) {
-
- $AnyMismatched = false;
- foreach ($Mismatched as $key => $value) {
- if ($value && ($EmptyTags["$key"] === false)) {
- $AnyMismatched = true;
- }
- }
- if ($AnyMismatched && empty($_REQUEST['autofixforcesource'])) {
-
- echo $ThisLine;
-
- } else {
-
- $TagsToSynch = '';
- foreach ($EmptyTags as $key => $value) {
- if ($value) {
- switch ($key) {
- case 'id3v1':
- $TagsToSynch .= '1';
- break;
- case 'id3v2':
- $TagsToSynch .= '2';
- break;
- case 'ape':
- $TagsToSynch .= 'A';
- break;
- }
- }
- }
-
- $autofixforcesource = (@$_REQUEST['autofixforcesource'] ? $_REQUEST['autofixforcesource'] : 'all');
- $TagsToSynch = (@$_REQUEST['autofixforcedest'] ? $_REQUEST['autofixforcedest'] : $TagsToSynch);
-
- $errors = array();
- if (SynchronizeAllTags($row['filename'], $autofixforcesource, $TagsToSynch, $errors)) {
- $Autofixedfiles++;
- echo '';
- } else {
- echo ' ';
- }
- echo ' ';
- echo ' '.FixTextFields($row['filename']).' ';
- echo '';
- echo ''.$TagsToSynch.' ';
- echo '
';
- }
-
- } else {
-
- echo $ThisLine;
-
- }
- }
- }
-
- echo '
';
- echo '';
- echo 'Found '.number_format($NotOKfiles).' files with unsynchronized tags, and auto-fixed '.number_format($Autofixedfiles).' of them.';
-
-} elseif (!empty($_REQUEST['filenamepattern'])) {
-
- $patterns['A'] = 'artist';
- $patterns['T'] = 'title';
- $patterns['M'] = 'album';
- $patterns['N'] = 'track';
- $patterns['G'] = 'genre';
- $patterns['R'] = 'remix';
-
- $FieldsToUse = explode(' ', wordwrap(eregi_replace('[^A-Z]', '', $_REQUEST['filenamepattern']), 1, ' ', 1));
- //$FieldsToUse = explode(' ', wordwrap($_REQUEST['filenamepattern'], 1, ' ', 1));
- foreach ($FieldsToUse as $FieldID) {
- $FieldNames[] = $patterns["$FieldID"];
- }
-
- $SQLquery = 'SELECT `filename`, `fileformat`, '.implode(', ', $FieldNames);
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`fileformat` NOT LIKE "'.implode('") AND (`fileformat` NOT LIKE "', $IgnoreNoTagFormats).'")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- echo 'Files that do not match naming pattern: (auto-fix ) ';
- echo '';
- echo 'view Why Actual filename (click to play/edit file)Correct filename (based on tags) '.(!@$_REQUEST['autofix'] ? ' (click to rename file to this)' : '').' ';
- $nonmatchingfilenames = 0;
- $Pattern = $_REQUEST['filenamepattern'];
- $PatternLength = strlen($Pattern);
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(10);
- $PatternFilename = '';
- for ($i = 0; $i < $PatternLength; $i++) {
- if (isset($patterns[$Pattern{$i}])) {
- $PatternFilename .= trim(strtr($row[$patterns[$Pattern{$i}]], ':\\*<>|', ';-'), ' ');
- } else {
- $PatternFilename .= $Pattern{$i};
- }
- }
-
- // Replace "~" with "-" if characters immediately before and after are both numbers,
- // "/" has been replaced with "~" above which is good for multi-song medley dividers,
- // but for things like 24/7, 7/8ths, etc it looks better if it's 24-7, 7-8ths, etc.
- $PatternFilename = eregi_replace('([ a-z]+)/([ a-z]+)', '\\1~\\2', $PatternFilename);
- $PatternFilename = str_replace('/', '', $PatternFilename);
-
- $PatternFilename = str_replace('?', '', $PatternFilename);
- $PatternFilename = str_replace(' "', ' ', $PatternFilename);
- $PatternFilename = str_replace('("', '(', $PatternFilename);
- $PatternFilename = str_replace('-"', '-', $PatternFilename);
- $PatternFilename = str_replace('" ', ' ', $PatternFilename.' ');
- $PatternFilename = str_replace('"', '', $PatternFilename);
- $PatternFilename = str_replace(' ', ' ', $PatternFilename);
-
-
- $ParenthesesPairs = array('()', '[]', '{}');
- foreach ($ParenthesesPairs as $pair) {
-
- // multiple remixes are stored tab-seperated in the database.
- // change "{2000 Version\tSomebody Remix}" into "{2000 Version} {Somebody Remix}"
- while (ereg('^(.*)'.preg_quote($pair{0}).'([^'.preg_quote($pair{1}).']*)('."\t".')([^'.preg_quote($pair{0}).']*)'.preg_quote($pair{1}), $PatternFilename, $matches)) {
- $PatternFilename = $matches[1].$pair{0}.$matches[2].$pair{1}.' '.$pair{0}.$matches[4].$pair{1};
- }
-
- // remove empty parenthesized pairs (probably where no track numbers, remix version, etc)
- $PatternFilename = ereg_replace(preg_quote($pair), '', $PatternFilename);
-
- // "[01] - Title With No Artist.mp3" ==> "[01] Title With No Artist.mp3"
- $PatternFilename = ereg_replace(preg_quote($pair{1}).' +\- ', $pair{1}.' ', $PatternFilename);
-
- }
-
- // get rid of leading & trailing spaces if end items (artist or title for example) are missing
- $PatternFilename = trim($PatternFilename, ' -');
-
- if (!$PatternFilename) {
- // no tags to create a filename from -- skip this file
- continue;
- }
- $PatternFilename .= '.'.$row['fileformat'];
-
- $ActualFilename = basename($row['filename']);
- if ($ActualFilename != $PatternFilename) {
-
- $NotMatchedReasons = '';
- if (strtolower($ActualFilename) === strtolower($PatternFilename)) {
- $NotMatchedReasons .= 'Aa ';
- } elseif (RemoveAccents($ActualFilename) === RemoveAccents($PatternFilename)) {
- $NotMatchedReasons .= 'e ';
- }
-
-
- $actualExt = '.'.fileextension($ActualFilename);
- $patternExt = '.'.fileextension($PatternFilename);
- $ActualFilenameNoExt = (($actualExt != '.') ? substr($ActualFilename, 0, 0 - strlen($actualExt)) : $ActualFilename);
- $PatternFilenameNoExt = (($patternExt != '.') ? substr($PatternFilename, 0, 0 - strlen($patternExt)) : $PatternFilename);
-
- if (strpos($PatternFilenameNoExt, $ActualFilenameNoExt) !== false) {
- $DifferenceBoldedName = str_replace($ActualFilenameNoExt, ''.$ActualFilenameNoExt.'', $PatternFilenameNoExt);
- } else {
- $ShortestNameLength = min(strlen($ActualFilenameNoExt), strlen($PatternFilenameNoExt));
- for ($DifferenceOffset = 0; $DifferenceOffset < $ShortestNameLength; $DifferenceOffset++) {
- if ($ActualFilenameNoExt{$DifferenceOffset} !== $PatternFilenameNoExt{$DifferenceOffset}) {
- break;
- }
- }
- $DifferenceBoldedName = ' '.substr($PatternFilenameNoExt, 0, $DifferenceOffset).''.substr($PatternFilenameNoExt, $DifferenceOffset);
- }
- $DifferenceBoldedName .= (($actualExt == $patternExt) ? ' '.$patternExt.'' : $patternExt);
-
-
- echo '';
- echo 'view ';
- echo ' '.$NotMatchedReasons.' ';
- echo ''.FixTextFields($ActualFilename).' ';
-
- if (@$_REQUEST['autofix']) {
-
- $results = '';
- if (RenameFileFromTo($row['filename'], dirname($row['filename']).'/'.$PatternFilename, $results)) {
- echo '';
- } else {
- echo ' ';
- }
- echo ''.$DifferenceBoldedName.' ';
-
-
- } else {
-
- echo '';
- echo ''.$DifferenceBoldedName.' ';
-
- }
- echo ' ';
-
- $nonmatchingfilenames++;
- }
- }
- echo '
';
- echo 'Found '.number_format($nonmatchingfilenames).' files that do not match naming pattern ';
-
-
-} elseif (!empty($_REQUEST['encoderoptionsdistribution'])) {
-
- if (isset($_REQUEST['showtagfiles'])) {
- $SQLquery = 'SELECT `filename`, `encoder_options` FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`encoder_options` LIKE "'.mysql_escape_string($_REQUEST['showtagfiles']).'")';
- $SQLquery .= ' AND (`fileformat` NOT LIKE "'.implode('") AND (`fileformat` NOT LIKE "', $IgnoreNoTagFormats).'")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while ($row = mysql_fetch_array($result)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- exit;
-
- } else {
-
- echo 'Show all Encoder Options ';
- echo 'Files with Encoder Options '.$_REQUEST['showtagfiles'].' : ';
- echo '';
-
- }
-
- } elseif (!isset($_REQUEST['m3u'])) {
-
- $SQLquery = 'SELECT `encoder_options`, COUNT(*) AS `num` FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`fileformat` NOT LIKE "'.implode('") AND (`fileformat` NOT LIKE "', $IgnoreNoTagFormats).'")';
- $SQLquery .= ' GROUP BY `encoder_options`';
- $SQLquery .= ' ORDER BY (`encoder_options` LIKE "LAME%") DESC, (`encoder_options` LIKE "CBR%") DESC, `num` DESC, `encoder_options` ASC';
- $result = safe_mysql_query($SQLquery);
- echo 'Files with Encoder Options: ';
- echo '';
- echo 'Encoder Options Count M3U ';
- while ($row = mysql_fetch_array($result)) {
- echo '';
- echo ''.$row['encoder_options'].' ';
- echo ''.number_format($row['num']).' ';
- echo 'm3u ';
- echo ' ';
- }
- echo '
';
-
- }
-
-} elseif (!empty($_REQUEST['tagtypes'])) {
-
- if (!isset($_REQUEST['m3u'])) {
- $SQLquery = 'SELECT `tags`, COUNT(*) AS `num` FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`fileformat` NOT LIKE "'.implode('") AND (`fileformat` NOT LIKE "', $IgnoreNoTagFormats).'")';
- $SQLquery .= ' GROUP BY `tags`';
- $SQLquery .= ' ORDER BY `num` DESC';
- $result = safe_mysql_query($SQLquery);
- echo 'Files with tags: ';
- echo '';
- echo 'Tags Count M3U ';
- while ($row = mysql_fetch_array($result)) {
- echo '';
- echo ''.$row['tags'].' ';
- echo ''.number_format($row['num']).' ';
- echo 'm3u ';
- echo ' ';
- }
- echo '
';
- }
-
- if (isset($_REQUEST['showtagfiles'])) {
- $SQLquery = 'SELECT `filename`, `tags` FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`tags` LIKE "'.mysql_escape_string($_REQUEST['showtagfiles']).'")';
- $SQLquery .= ' AND (`fileformat` NOT LIKE "'.implode('") AND (`fileformat` NOT LIKE "', $IgnoreNoTagFormats).'")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while ($row = mysql_fetch_array($result)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- exit;
-
- } else {
-
- echo '';
-
- }
- }
-
-
-} elseif (!empty($_REQUEST['md5datadupes'])) {
-
- $OtherFormats = '';
- $AVFormats = '';
-
- $SQLquery = 'SELECT `md5_data`, `filename`, COUNT(*) AS `num`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`md5_data` <> "")';
- $SQLquery .= ' GROUP BY `md5_data`';
- $SQLquery .= ' ORDER BY `num` DESC';
- $result = safe_mysql_query($SQLquery);
- while (($row = mysql_fetch_array($result)) && ($row['num'] > 1)) {
- set_time_limit(30);
-
- $filenames = array();
- $tags = array();
- $md5_data = array();
- $SQLquery = 'SELECT `fileformat`, `filename`, `tags`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`md5_data` = "'.mysql_escape_string($row['md5_data']).'")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result2 = safe_mysql_query($SQLquery);
- while ($row2 = mysql_fetch_array($result2)) {
- $thisfileformat = $row2['fileformat'];
- $filenames[] = $row2['filename'];
- $tags[] = $row2['tags'];
- $md5_data[] = $row['md5_data'];
- }
-
- $thisline = '';
- $thisline .= ''.implode(' ', $md5_data).' ';
- $thisline .= ''.implode(' ', $tags).' ';
- $thisline .= ''.implode(' ', $filenames).' ';
- $thisline .= ' ';
-
- if (in_array($thisfileformat, $IgnoreNoTagFormats)) {
- $OtherFormats .= $thisline;
- } else {
- $AVFormats .= $thisline;
- }
- }
- echo 'Duplicated MD5_DATA (Audio/Video files): ';
- echo 'Duplicated MD5_DATA (Other files):';
- echo $OtherFormats.'
';
-
-
-} elseif (!empty($_REQUEST['artisttitledupes'])) {
-
- if (isset($_REQUEST['m3uartist']) && isset($_REQUEST['m3utitle'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- $SQLquery = 'SELECT `filename`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`artist` = "'.mysql_escape_string($_REQUEST['m3uartist']).'")';
- $SQLquery .= ' AND (`title` = "'.mysql_escape_string($_REQUEST['m3utitle']).'")';
- $SQLquery .= ' ORDER BY `playtime_seconds` ASC, `remix` ASC, `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- while ($row = mysql_fetch_array($result)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- exit;
-
- }
-
- $SQLquery = 'SELECT `artist`, `title`, `filename`, COUNT(*) AS `num`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`artist` <> "")';
- $SQLquery .= ' AND (`title` <> "")';
- $SQLquery .= ' GROUP BY `artist`, `title`'.(@$_REQUEST['samemix'] ? ', `remix`' : '');
- $SQLquery .= ' ORDER BY `num` DESC, `artist` ASC, `title` ASC, `playtime_seconds` ASC, `remix` ASC';
- $result = safe_mysql_query($SQLquery);
- $uniquetitles = 0;
- $uniquefiles = 0;
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while (($row = mysql_fetch_array($result)) && ($row['num'] > 1)) {
- $SQLquery = 'SELECT `filename`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`artist` = "'.mysql_escape_string($row['artist']).'")';
- $SQLquery .= ' AND (`title` = "'.mysql_escape_string($row['title']).'")';
- if (@$_REQUEST['samemix']) {
- $SQLquery .= ' AND (`remix` = "'.mysql_escape_string($row['remix']).'")';
- }
- $SQLquery .= ' ORDER BY `playtime_seconds` ASC, `remix` ASC, `filename` ASC';
- $result2 = safe_mysql_query($SQLquery);
- while ($row2 = mysql_fetch_array($result2)) {
- echo WindowsShareSlashTranslate($row2['filename'])."\n";
- }
- }
- exit;
-
- } else {
-
- echo 'Duplicated aritst + title: (Identical Mix/Version only ) ';
- echo '(.m3u version ) ';
- echo '';
- echo ' Artist Title Version Filename ';
-
- while (($row = mysql_fetch_array($result)) && ($row['num'] > 1)) {
- $uniquetitles++;
- set_time_limit(30);
-
- $filenames = array();
- $artists = array();
- $titles = array();
- $remixes = array();
- $bitrates = array();
- $playtimes = array();
- $SQLquery = 'SELECT `filename`, `artist`, `title`, `remix`, `audio_bitrate`, `vbr_method`, `playtime_seconds`, `encoder_options`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`artist` = "'.mysql_escape_string($row['artist']).'")';
- $SQLquery .= ' AND (`title` = "'.mysql_escape_string($row['title']).'")';
- $SQLquery .= ' ORDER BY `playtime_seconds` ASC, `remix` ASC, `filename` ASC';
- $result2 = safe_mysql_query($SQLquery);
- while ($row2 = mysql_fetch_array($result2)) {
- $uniquefiles++;
- $filenames[] = $row2['filename'];
- $artists[] = $row2['artist'];
- $titles[] = $row2['title'];
- $remixes[] = $row2['remix'];
- if ($row2['vbr_method']) {
- $bitrates[] = ''.BitrateText($row2['audio_bitrate'] / 1000).' ';
- } else {
- $bitrates[] = BitrateText($row2['audio_bitrate'] / 1000);
- }
- $playtimes[] = getid3_lib::PlaytimeString($row2['playtime_seconds']);
- }
-
- echo '';
- echo '';
- foreach ($filenames as $file) {
- echo 'delete ';
- }
- echo ' ';
- echo '';
- foreach ($filenames as $file) {
- echo 'play ';
- }
- echo ' ';
- echo 'play all ';
- echo ''.implode(' ', $artists).' ';
- echo ''.implode(' ', $titles).' ';
- echo ''.implode(' ', $remixes).' ';
- echo ''.implode(' ', $bitrates).' ';
- echo ''.implode(' ', $playtimes).' ';
-
- echo ' ';
-
- echo ' ';
- }
-
- }
- echo '
';
- echo number_format($uniquefiles).' files with '.number_format($uniquetitles).' unique aritst + title ';
- echo ' ';
-
-} elseif (!empty($_REQUEST['filetypelist'])) {
-
- list($fileformat, $audioformat) = explode('|', $_REQUEST['filetypelist']);
- $SQLquery = 'SELECT `filename`, `fileformat`, `audio_dataformat`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`fileformat` = "'.mysql_escape_string($fileformat).'")';
- $SQLquery .= ' AND (`audio_dataformat` = "'.mysql_escape_string($audioformat).'")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- echo 'Files of format '.$fileformat.'.'.$audioformat.' :';
- echo 'file audio filename ';
- while ($row = mysql_fetch_array($result)) {
- echo '';
- echo ''.$row['fileformat'].' ';
- echo ''.$row['audio_dataformat'].' ';
- echo ''.FixTextFields($row['filename']).' ';
- echo ' ';
- }
- echo '
';
-
-} elseif (!empty($_REQUEST['trackinalbum'])) {
-
- $SQLquery = 'SELECT `filename`, `album`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`album` LIKE "% [%")';
- $SQLquery .= ' ORDER BY `album` ASC, `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while ($row = mysql_fetch_array($result)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- exit;
-
- } elseif (!empty($_REQUEST['autofix'])) {
-
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE__, true);
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true);
-
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- $ThisFileInfo = $getID3->analyze($filename);
- getid3_lib::CopyTagsToComments($ThisFileInfo);
-
- if (!empty($ThisFileInfo['tags'])) {
-
- $Album = trim(str_replace(strstr($ThisFileInfo['comments']['album'][0], ' ['), '', $ThisFileInfo['comments']['album'][0]));
- $Track = (string) intval(str_replace(' [', '', str_replace(']', '', strstr($ThisFileInfo['comments']['album'][0], ' ['))));
- if ($Track == '0') {
- $Track = '';
- }
- if ($Album && $Track) {
- echo ' '.FixTextFields($row['filename']).' ';
- echo ''.$Album.' (track #'.$Track.') ';
- echo 'ID3v2: '.(RemoveID3v2($row['filename'], false) ? 'removed' : 'REMOVAL FAILED!').', ';
- echo 'ID3v1: '.(WriteID3v1($row['filename'], @$ThisFileInfo['comments']['title'][0], @$ThisFileInfo['comments']['artist'][0], $Album, @$ThisFileInfo['comments']['year'][0], @$ThisFileInfo['comments']['comment'][0], @$ThisFileInfo['comments']['genreid'][0], $Track, false) ? 'updated' : 'UPDATE FAILED').' ';
- } else {
- echo ' . ';
- }
-
- } else {
-
- echo ' FAILED '.FixTextFields($row['filename']).' ';
-
- }
- flush();
- }
-
- } else {
-
- echo ''.number_format(mysql_num_rows($result)).' files with [??] -format track numbers in album field: ';
- if (mysql_num_rows($result) > 0) {
- echo '(.m3u version ) ';
- echo 'Try to auto-fix ';
- echo '';
- }
- echo ' ';
-
- }
-
-} elseif (!empty($_REQUEST['fileextensions'])) {
-
- $SQLquery = 'SELECT `filename`, `fileformat`, `audio_dataformat`, `video_dataformat`, `tags`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- $invalidextensionfiles = 0;
- $invalidextensionline = '';
- $invalidextensionline .= 'file audio video tags actual correct filename ';
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
-
- $acceptableextensions = AcceptableExtensions($row['fileformat'], $row['audio_dataformat'], $row['video_dataformat']);
- $actualextension = strtolower(fileextension($row['filename']));
- if ($acceptableextensions && !in_array($actualextension, $acceptableextensions)) {
- $invalidextensionfiles++;
-
- $invalidextensionline .= '';
- $invalidextensionline .= ''.$row['fileformat'].' ';
- $invalidextensionline .= ''.$row['audio_dataformat'].' ';
- $invalidextensionline .= ''.$row['video_dataformat'].' ';
- $invalidextensionline .= ''.$row['tags'].' ';
- $invalidextensionline .= ''.$actualextension.' ';
- $invalidextensionline .= ''.implode('; ', $acceptableextensions).' ';
- $invalidextensionline .= ''.FixTextFields($row['filename']).' ';
- $invalidextensionline .= ' ';
- }
- }
- $invalidextensionline .= '
';
- echo number_format($invalidextensionfiles).' files with incorrect filename extension: ';
- echo $invalidextensionline;
-
-} elseif (isset($_REQUEST['genredistribution'])) {
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- $SQLquery = 'SELECT `filename`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (BINARY `genre` = "'.$_REQUEST['genredistribution'].'")';
- $SQLquery .= ' AND (`fileformat` NOT LIKE "'.implode('") AND (`fileformat` NOT LIKE "', $IgnoreNoTagFormats).'")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- while ($row = mysql_fetch_array($result)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- exit;
-
- } else {
-
- if ($_REQUEST['genredistribution'] == '%') {
-
- $SQLquery = 'SELECT COUNT(*) AS `num`, `genre`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`fileformat` NOT LIKE "'.implode('") AND (`fileformat` NOT LIKE "', $IgnoreNoTagFormats).'")';
- $SQLquery .= ' GROUP BY `genre`';
- $SQLquery .= ' ORDER BY `num` DESC';
- $result = safe_mysql_query($SQLquery);
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE__, true);
- echo '';
- echo 'Count Genre m3u ';
- while ($row = mysql_fetch_array($result)) {
- $GenreID = getid3_id3v1::LookupGenreID($row['genre']);
- if (is_numeric($GenreID)) {
- echo '';
- } else {
- echo ' ';
- }
- echo ''.number_format($row['num']).' ';
- echo ''.str_replace("\t", ' ', $row['genre']).' ';
- echo '.m3u ';
- echo ' ';
- }
- echo '
';
-
- } else {
-
- $SQLquery = 'SELECT `filename`, `genre`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`genre` LIKE "'.mysql_escape_string($_REQUEST['genredistribution']).'")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- echo 'All Genres ';
- echo '';
- echo 'Genre m3u Filename ';
- while ($row = mysql_fetch_array($result)) {
- echo '';
- echo ''.str_replace("\t", ' ', $row['genre']).' ';
- echo 'm3u ';
- echo ''.FixTextFields($row['filename']).' ';
- echo ' ';
- }
- echo '
';
-
- }
-
-
- }
-
-} elseif (!empty($_REQUEST['formatdistribution'])) {
-
- $SQLquery = 'SELECT `fileformat`, `audio_dataformat`, COUNT(*) AS `num`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' GROUP BY `fileformat`, `audio_dataformat`';
- $SQLquery .= ' ORDER BY `num` DESC';
- $result = safe_mysql_query($SQLquery);
- echo 'File format distribution: ';
-
-} elseif (!empty($_REQUEST['errorswarnings'])) {
-
- $SQLquery = 'SELECT `filename`, `error`, `warning`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`error` <> "")';
- $SQLquery .= ' OR (`warning` <> "")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
-
- if (!empty($_REQUEST['m3u'])) {
-
- header('Content-type: audio/x-mpegurl');
- echo '#EXTM3U'."\n";
- while ($row = mysql_fetch_array($result)) {
- echo WindowsShareSlashTranslate($row['filename'])."\n";
- }
- exit;
-
- } else {
-
- echo number_format(mysql_num_rows($result)).' files with errors or warnings: ';
- echo '(.m3u version ) ';
- echo '';
- echo 'Filename Error Warning ';
- while ($row = mysql_fetch_array($result)) {
- echo '';
- echo ''.FixTextFields($row['filename']).' ';
- echo ''.(!empty($row['error']) ? ''.str_replace("\t", ' ', FixTextFields($row['error'])).' ' : ' ').' ';
- echo ''.(!empty($row['warning']) ? ''.str_replace("\t", ' ', FixTextFields($row['warning'])).' ' : ' ').' ';
- echo ' ';
- }
- }
- echo '
';
-
-} elseif (!empty($_REQUEST['fixid3v1padding'])) {
-
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.id3v1.php', __FILE__, true);
- $id3v1_writer = new getid3_write_id3v1;
-
- $SQLquery = 'SELECT `filename`, `error`, `warning`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`fileformat` = "mp3")';
- $SQLquery .= ' AND (`warning` <> "")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- $totaltofix = mysql_num_rows($result);
- $rowcounter = 0;
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- if (strpos($row['warning'], 'Some ID3v1 fields do not use NULL characters for padding') !== false) {
- set_time_limit(30);
- $id3v1_writer->filename = $row['filename'];
- echo ($id3v1_writer->FixID3v1Padding() ? 'fixed - ' : 'error - ');
- } else {
- echo 'No error? - ';
- }
- echo '['.++$rowcounter.' / '.$totaltofix.'] ';
- echo FixTextFields($row['filename']).' ';
- flush();
- }
-
-} elseif (!empty($_REQUEST['vbrmethod'])) {
-
- if ($_REQUEST['vbrmethod'] == '1') {
-
- $SQLquery = 'SELECT COUNT(*) AS `num`, `vbr_method`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' GROUP BY `vbr_method`';
- $SQLquery .= ' ORDER BY `vbr_method`';
- $result = safe_mysql_query($SQLquery);
- echo 'VBR methods:';
- echo 'Count VBR Method ';
- while ($row = mysql_fetch_array($result)) {
- echo '';
- echo ''.FixTextFields(number_format($row['num'])).' ';
- if ($row['vbr_method']) {
- echo ''.FixTextFields($row['vbr_method']).' ';
- } else {
- echo 'CBR ';
- }
- echo ' ';
- }
- echo '
';
-
- } else {
-
- $SQLquery = 'SELECT `filename`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`vbr_method` = "'.mysql_escape_string($_REQUEST['vbrmethod']).'")';
- $result = safe_mysql_query($SQLquery);
- echo number_format(mysql_num_rows($result)).' files with VBR_method of "'.$_REQUEST['vbrmethod'].'":';
-
- }
- echo ' ';
-
-} elseif (!empty($_REQUEST['correctcase'])) {
-
- $SQLquery = 'SELECT `filename`, `fileformat`';
- $SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
- $SQLquery .= ' WHERE (`fileformat` <> "")';
- $SQLquery .= ' ORDER BY `filename` ASC';
- $result = safe_mysql_query($SQLquery);
- echo 'Copy and paste the following into a DOS batch file. You may have to run this script more than once to catch all the changes (remember to scan for deleted/changed files and rescan directory between scans) ';
- echo '';
- $lastdir = '';
- while ($row = mysql_fetch_array($result)) {
- set_time_limit(30);
- $CleanedFilename = CleanUpFileName($row['filename']);
- if ($row['filename'] != $CleanedFilename) {
- if (strtolower($lastdir) != strtolower(str_replace('/', '\\', dirname($row['filename'])))) {
- $lastdir = str_replace('/', '\\', dirname($row['filename']));
- echo 'cd "'.$lastdir.'"'."\n";
- }
- echo 'ren "'.basename($row['filename']).'" "'.basename(CleanUpFileName($row['filename'])).'"'."\n";
- }
- }
- echo ' ';
- echo ' ';
-
-}
-
-function CleanUpFileName($filename) {
- $DirectoryName = dirname($filename);
- $FileExtension = fileextension(basename($filename));
- $BaseFilename = basename($filename, '.'.$FileExtension);
-
- $BaseFilename = strtolower($BaseFilename);
- $BaseFilename = str_replace('_', ' ', $BaseFilename);
- //$BaseFilename = str_replace('-', ' - ', $BaseFilename);
- $BaseFilename = str_replace('(', ' (', $BaseFilename);
- $BaseFilename = str_replace('( ', '(', $BaseFilename);
- $BaseFilename = str_replace(')', ') ', $BaseFilename);
- $BaseFilename = str_replace(' )', ')', $BaseFilename);
- $BaseFilename = str_replace(' \'\'', ' ', $BaseFilename);
- $BaseFilename = str_replace('\'\' ', ' ', $BaseFilename);
- $BaseFilename = str_replace(' vs ', ' vs. ', $BaseFilename);
- while (strstr($BaseFilename, ' ') !== false) {
- $BaseFilename = str_replace(' ', ' ', $BaseFilename);
- }
- $BaseFilename = trim($BaseFilename);
-
- return $DirectoryName.'/'.BetterUCwords($BaseFilename).'.'.strtolower($FileExtension);
-}
-
-function BetterUCwords($string) {
- $stringlength = strlen($string);
-
- $string{0} = strtoupper($string{0});
- for ($i = 1; $i < $stringlength; $i++) {
- if (($string{$i - 1} == '\'') && ($i > 1) && (($string{$i - 2} == 'O') || ($string{$i - 2} == ' '))) {
- // O'Clock, 'Em
- $string{$i} = strtoupper($string{$i});
- } elseif (ereg('^[\'A-Za-z0-9-]$', $string{$i - 1})) {
- $string{$i} = strtolower($string{$i});
- } else {
- $string{$i} = strtoupper($string{$i});
- }
- }
-
- static $LowerCaseWords = array('vs.', 'feat.');
- static $UpperCaseWords = array('DJ', 'USA', 'II', 'MC', 'CD', 'TV', '\'N\'');
-
- $OutputListOfWords = array();
- $ListOfWords = explode(' ', $string);
- foreach ($ListOfWords as $ThisWord) {
- if (in_array(strtolower(str_replace('(', '', $ThisWord)), $LowerCaseWords)) {
- $ThisWord = strtolower($ThisWord);
- } elseif (in_array(strtoupper(str_replace('(', '', $ThisWord)), $UpperCaseWords)) {
- $ThisWord = strtoupper($ThisWord);
- } elseif ((substr($ThisWord, 0, 2) == 'Mc') && (strlen($ThisWord) > 2)) {
- $ThisWord{2} = strtoupper($ThisWord{2});
- } elseif ((substr($ThisWord, 0, 3) == 'Mac') && (strlen($ThisWord) > 3)) {
- $ThisWord{3} = strtoupper($ThisWord{3});
- }
- $OutputListOfWords[] = $ThisWord;
- }
- $UCstring = implode(' ', $OutputListOfWords);
- $UCstring = str_replace(' From ', ' from ', $UCstring);
- $UCstring = str_replace(' \'n\' ', ' \'N\' ', $UCstring);
-
- return $UCstring;
-}
-
-
-
-echo '';
-echo 'Warning: Scanning a new directory will erase all previous entries in the database! ';
-echo 'Directory: ';
-echo ' ';
-echo ' ';
-echo '';
-echo 'Re-scanning a new directory will only add new, previously unscanned files into the list (and not erase the database). ';
-echo 'Directory: ';
-echo ' ';
-echo ' ';
-echo '';
-
-$SQLquery = 'SELECT COUNT(*) AS `TotalFiles`, SUM(`playtime_seconds`) AS `TotalPlaytime`, SUM(`filesize`) AS `TotalFilesize`, AVG(`playtime_seconds`) AS `AvgPlaytime`, AVG(`filesize`) AS `AvgFilesize`, AVG(`audio_bitrate` + `video_bitrate`) AS `AvgBitrate`';
-$SQLquery .= ' FROM `'.GETID3_DB_TABLE.'`';
-$result = mysql_query($SQLquery);
-if ($row = mysql_fetch_array($result)) {
- echo 'Currently in the database: ';
- echo 'Total Files '.number_format($row['TotalFiles']).' ';
- echo 'Total Filesize '.number_format($row['TotalFilesize'] / 1048576).' MB ';
- echo 'Total Playtime '.number_format($row['TotalPlaytime'] / 3600, 1).' hours ';
- echo 'Average Filesize '.number_format($row['AvgFilesize'] / 1048576, 1).' MB ';
- echo 'Average Playtime '.getid3_lib::PlaytimeString($row['AvgPlaytime']).' ';
- echo 'Average Bitrate '.BitrateText($row['AvgBitrate'] / 1000, 1).' ';
- echo '
';
-}
-
-?>
-
-
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.simple.php b/apps/media/getID3/demos/demo.simple.php
deleted file mode 100644
index db937f1e2da..00000000000
--- a/apps/media/getID3/demos/demo.simple.php
+++ /dev/null
@@ -1,53 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.simple.php - part of getID3() //
-// Sample script for scanning a single directory and //
-// displaying a few pieces of information for each file //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-echo '';
-echo 'getID3() - /demo/demo.simple.php (sample script) ';
-echo '';
-echo '';
-
-
-// include getID3() library (can be in a different directory if full path is specified)
-require_once('../getid3/getid3.php');
-
-// Initialize getID3 engine
-$getID3 = new getID3;
-
-$DirectoryToScan = '/change/to/directory/you/want/to/scan'; // change to whatever directory you want to scan
-$dir = opendir($DirectoryToScan);
-echo '';
-echo 'Filename Artist Title Bitrate Playtime ';
-while (($file = readdir($dir)) !== false) {
- $FullFileName = realpath($DirectoryToScan.'/'.$file);
- if (is_file($FullFileName)) {
- set_time_limit(30);
-
- $ThisFileInfo = $getID3->analyze($FullFileName);
-
- getid3_lib::CopyTagsToComments($ThisFileInfo);
-
- // output desired information in whatever format you want
- echo '';
- echo ''.$ThisFileInfo['filenamepath'].' ';
- echo ''.(!empty($ThisFileInfo['comments_html']['artist']) ? implode(' ', $ThisFileInfo['comments_html']['artist']) : ' ').' ';
- echo ''.(!empty($ThisFileInfo['comments_html']['title']) ? implode(' ', $ThisFileInfo['comments_html']['title']) : ' ').' ';
- echo ''.(!empty($ThisFileInfo['audio']['bitrate']) ? round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : ' ').' ';
- echo ''.(!empty($ThisFileInfo['playtime_string']) ? $ThisFileInfo['playtime_string'] : ' ').' ';
- echo ' ';
- }
-}
-
-?>
-
-
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.simple.write.php b/apps/media/getID3/demos/demo.simple.write.php
deleted file mode 100644
index 468984e39e0..00000000000
--- a/apps/media/getID3/demos/demo.simple.write.php
+++ /dev/null
@@ -1,54 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.simple.write.php - part of getID3() //
-// Sample script showing basic syntax for writing tags //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-$TaggingFormat = 'UTF-8';
-
-require_once('../getid3/getid3.php');
-// Initialize getID3 engine
-$getID3 = new getID3;
-$getID3->setOption(array('encoding'=>$TaggingFormat));
-
-require_once('../getid3/write.php');
-// Initialize getID3 tag-writing module
-$tagwriter = new getid3_writetags;
-//$tagwriter->filename = '/path/to/file.mp3';
-$tagwriter->filename = 'd:/file.mp3';
-$tagwriter->tagformats = array('id3v1', 'id3v2.3');
-
-// set various options (optional)
-$tagwriter->overwrite_tags = true;
-$tagwriter->tag_encoding = $TaggingFormat;
-$tagwriter->remove_other_tags = true;
-
-// populate data array
-$TagData['title'][] = 'My Song';
-$TagData['artist'][] = 'The Artist';
-$TagData['album'][] = 'Greatest Hits';
-$TagData['year'][] = '2004';
-$TagData['genre'][] = 'Rock';
-$TagData['comment'][] = 'excellent!';
-$TagData['track'][] = '04/16';
-
-$tagwriter->tag_data = $TagData;
-
-// write tags
-if ($tagwriter->WriteTags()) {
- echo 'Successfully wrote tags ';
- if (!empty($tagwriter->warnings)) {
- echo 'There were some warnings: '.implode(' ', $tagwriter->warnings);
- }
-} else {
- echo 'Failed to write tags! '.implode(' ', $tagwriter->errors);
-}
-
-?>
\ No newline at end of file
diff --git a/apps/media/getID3/demos/demo.write.php b/apps/media/getID3/demos/demo.write.php
deleted file mode 100644
index 6f03b478383..00000000000
--- a/apps/media/getID3/demos/demo.write.php
+++ /dev/null
@@ -1,271 +0,0 @@
- //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-/////////////////////////////////////////////////////////////////
-// //
-// /demo/demo.write.php - part of getID3() //
-// sample script for demonstrating writing ID3v1 and ID3v2 //
-// tags for MP3, or Ogg comment tags for Ogg Vorbis //
-// See readme.txt for more details //
-// ///
-/////////////////////////////////////////////////////////////////
-
-
-die('Due to a security issue, this demo has been disabled. It can be enabled by removing line 16 in demos/demo.write.php');
-
-
-$TaggingFormat = 'UTF-8';
-
-header('Content-Type: text/html; charset='.$TaggingFormat);
-echo 'getID3() - Sample tag writer ';
-
-require_once('../getid3/getid3.php');
-// Initialize getID3 engine
-$getID3 = new getID3;
-$getID3->setOption(array('encoding'=>$TaggingFormat));
-
-getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'write.php', __FILE__, true);
-
-$browsescriptfilename = 'demo.browse.php';
-
-function FixTextFields($text) {
- return htmlentities(getid3_lib::SafeStripSlashes($text), ENT_QUOTES);
-}
-
-$Filename = (isset($_REQUEST['Filename']) ? getid3_lib::SafeStripSlashes($_REQUEST['Filename']) : '');
-
-
-
-if (isset($_POST['WriteTags'])) {
-
- $TagFormatsToWrite = (isset($_POST['TagFormatsToWrite']) ? $_POST['TagFormatsToWrite'] : array());
- if (!empty($TagFormatsToWrite)) {
- echo 'starting to write tag(s) ';
-
- $tagwriter = new getid3_writetags;
- $tagwriter->filename = $Filename;
- $tagwriter->tagformats = $TagFormatsToWrite;
- $tagwriter->overwrite_tags = true;
- $tagwriter->tag_encoding = $TaggingFormat;
- if (!empty($_POST['remove_other_tags'])) {
- $tagwriter->remove_other_tags = true;
- }
-
- $commonkeysarray = array('Title', 'Artist', 'Album', 'Year', 'Comment');
- foreach ($commonkeysarray as $key) {
- if (!empty($_POST[$key])) {
- $TagData[strtolower($key)][] = getid3_lib::SafeStripSlashes($_POST[$key]);
- }
- }
- if (!empty($_POST['Genre'])) {
- $TagData['genre'][] = getid3_lib::SafeStripSlashes($_POST['Genre']);
- }
- if (!empty($_POST['GenreOther'])) {
- $TagData['genre'][] = getid3_lib::SafeStripSlashes($_POST['GenreOther']);
- }
- if (!empty($_POST['Track'])) {
- $TagData['track'][] = getid3_lib::SafeStripSlashes($_POST['Track'].(!empty($_POST['TracksTotal']) ? '/'.$_POST['TracksTotal'] : ''));
- }
-
- if (!empty($_FILES['userfile']['tmp_name'])) {
- if (in_array('id3v2.4', $tagwriter->tagformats) || in_array('id3v2.3', $tagwriter->tagformats) || in_array('id3v2.2', $tagwriter->tagformats)) {
- if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
- if ($fd = @fopen($_FILES['userfile']['tmp_name'], 'rb')) {
- $APICdata = fread($fd, filesize($_FILES['userfile']['tmp_name']));
- fclose ($fd);
-
- list($APIC_width, $APIC_height, $APIC_imageTypeID) = GetImageSize($_FILES['userfile']['tmp_name']);
- $imagetypes = array(1=>'gif', 2=>'jpeg', 3=>'png');
- if (isset($imagetypes[$APIC_imageTypeID])) {
-
- $TagData['attached_picture'][0]['data'] = $APICdata;
- $TagData['attached_picture'][0]['picturetypeid'] = $_POST['APICpictureType'];
- $TagData['attached_picture'][0]['description'] = $_FILES['userfile']['name'];
- $TagData['attached_picture'][0]['mime'] = 'image/'.$imagetypes[$APIC_imageTypeID];
-
- } else {
- echo 'invalid image format (only GIF, JPEG, PNG) ';
- }
- } else {
- echo 'cannot open '.$_FILES['userfile']['tmp_name'].' ';
- }
- } else {
- echo '!is_uploaded_file('.$_FILES['userfile']['tmp_name'].') ';
- }
- } else {
- echo 'WARNING: Can only embed images for ID3v2 ';
- }
- }
-
- $tagwriter->tag_data = $TagData;
- if ($tagwriter->WriteTags()) {
- echo 'Successfully wrote tags ';
- if (!empty($tagwriter->warnings)) {
- echo 'There were some warnings:'.implode(' ', $tagwriter->warnings).' ';
- }
- } else {
- echo 'Failed to write tags!'.implode(' ', $tagwriter->errors).' ';
- }
-
- } else {
-
- echo 'WARNING: no tag formats selected for writing - nothing written';
-
- }
- echo ' ';
-
-}
-
-
-echo 'Sample tag editor/writer ';
-echo 'Browse current directory ';
-if (!empty($Filename)) {
- echo 'Start Over ';
- echo '';
-
-}
-
-?>
-
-
\ No newline at end of file
diff --git a/apps/media/getID3/demos/getid3.css b/apps/media/getID3/demos/getid3.css
deleted file mode 100644
index 0694eff2ad1..00000000000
--- a/apps/media/getID3/demos/getid3.css
+++ /dev/null
@@ -1,195 +0,0 @@
-
-/**
-* Common elements
-*/
-
-body {
- font: 12px Verdana, sans-serif;
- background-color: white;
- color: black;
- margin-top: 6px;
- margin-bottom: 30px;
- margin-left: 12px;
- margin-right: 12px;
-}
-
-
-h1 {
- font: bold 18px Verdana, sans-serif;
- line-height: 26px;
- margin-top: 12px;
- margin-bottom: 15px;
- margin-left: 0px;
- margin-right: 7px;
- background-color: #e6eaf6;
- padding-left: 10px;
- padding-top: 2px;
- padding-bottom: 4px;
-}
-
-
-h3 {
- font: bold 13px Verdana, sans-serif;
- line-height: 26px;
- margin-top: 12px;
- margin-bottom: 0px;
- margin-left: 0px;
- margin-right: 7px;
- padding-left: 4px;
-}
-
-
-ul {
- margin-top: 0px;
-}
-
-
-p, li {
- font: 9pt/135% sans-serif;
- margin-top: 1x;
- margin-bottom: 0x;
-}
-
-
-a, a:link, a:visited {
- color: #0000cc;
-}
-
-
-hr {
- height: 0;
- border: solid gray 0;
- border-top-width: thin;
- width: 700px;
-}
-
-
-table.table td {
- font: 9pt sans-serif;
- padding-top: 1px;
- padding-bottom: 1px;
- padding-left: 5px;
- padding-right: 5px;
-}
-
-
-table.table td.header {
- background-color: #cccccc;
- padding-top: 2px;
- padding-bottom: 2px;
- font-weight: bold;
-}
-
-
-table.table tr.even_files {
- background-color: #fefefe;
-}
-
-
-table.table tr.odd_files {
- background-color: #e9e9e9;
-}
-
-
-table.dump {
- border-top: solid 1px #cccccc;
- border-left: solid 1px #cccccc;
- margin: 2px;
-}
-
-
-table.dump td {
- font: 9pt sans-serif;
- padding-top: 1px;
- padding-bottom: 1px;
- padding-left: 5px;
- padding-right: 5px;
- border-right: solid 1px #cccccc;
- border-bottom: solid 1px #cccccc;
-}
-
-
-td.dump_string {
- font-weight: bold;
- color: #0000cc;
-}
-
-
-td.dump_integer {
- color: #cc0000;
- font-weight: bold;
-}
-
-
-td.dump_double {
- color: orange;
- font-weight: bold;
-}
-
-
-td.dump_boolean {
- color: #333333;
- font-weight: bold;
-}
-
-
-.error {
- color: red
-}
-
-
-
-
-/**
-* Tool Tips
-*/
-
-.tooltip {
- font: 9pt sans-serif;
- background: #ffffe1;
- color: black;
- border: black 1px solid;
- margin: 2px;
- padding: 7px;
- position: absolute;
- top: 10px;
- left: 10px;
- z-index: 10000;
- visibility: hidden;
-}
-
-
-.tooltip p {
- margin-top: -2px;
- margin-bottom: 4px;
-}
-
-
-
-
- /**
- * Forms
- */
-
-table.form td {
- font: 9pt/135% sans-serif;
- padding: 2px;
-}
-
-
-select, input {
- font: 9pt/135% sans-serif;
-}
-
-.select, .field {
- width: 260px;
-}
-
-#sel_field {
- width: 85px;
-}
-
-
-.button {
- margin-top: 10px;
-}
diff --git a/apps/media/getID3/demos/index.php b/apps/media/getID3/demos/index.php
deleted file mode 100644
index 13783f0daf4..00000000000
--- a/apps/media/getID3/demos/index.php
+++ /dev/null
@@ -1 +0,0 @@
-In this directory are a number of examples of how to use getID3() - if you don't know what to run, take a look at demo.browse.php
\ No newline at end of file
diff --git a/apps/media/getID3/getid3/getid3.lib.php b/apps/media/getID3/getid3/getid3.lib.php
index 4ed5e361f50..9322cae4dd8 100644
--- a/apps/media/getID3/getid3/getid3.lib.php
+++ b/apps/media/getID3/getid3/getid3.lib.php
@@ -1006,7 +1006,7 @@ class getid3_lib
}
- function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
+ static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
$HTMLstring = '';
switch ($charset) {
@@ -1187,7 +1187,7 @@ class getid3_lib
return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
}
- function CopyTagsToComments(&$ThisFileInfo) {
+ static function CopyTagsToComments(&$ThisFileInfo) {
// Copy all entries from ['tags'] into common ['comments']
if (!empty($ThisFileInfo['tags'])) {
diff --git a/apps/media/img/jplayer.blue.monday.jpg b/apps/media/img/jplayer.blue.monday.jpg
deleted file mode 100644
index 29c9382df74..00000000000
Binary files a/apps/media/img/jplayer.blue.monday.jpg and /dev/null differ
diff --git a/apps/media/img/jplayer.blue.monday.png b/apps/media/img/jplayer.blue.monday.png
deleted file mode 100644
index 16cf2892993..00000000000
Binary files a/apps/media/img/jplayer.blue.monday.png and /dev/null differ
diff --git a/apps/media/img/pbar-ani.gif b/apps/media/img/pbar-ani.gif
deleted file mode 100644
index 0dfd45b885a..00000000000
Binary files a/apps/media/img/pbar-ani.gif and /dev/null differ
diff --git a/apps/media/index.php b/apps/media/index.php
index fe724b45ddf..419d4ae0bde 100644
--- a/apps/media/index.php
+++ b/apps/media/index.php
@@ -25,10 +25,8 @@
require_once('../../lib/base.php');
// Check if we are a user
-if( !OC_User::isLoggedIn()){
- header( "Location: ".OC_Helper::linkTo( '', 'index.php' ));
- exit();
-}
+OC_Util::checkLoggedIn();
+OC_Util::checkAppEnabled('media');
require_once('lib_collection.php');
require_once('lib_scanner.php');
@@ -39,7 +37,6 @@ OC_Util::addScript('media','playlist');
OC_Util::addScript('media','collection');
OC_Util::addScript('media','scanner');
OC_Util::addScript('media','jquery.jplayer.min');
-OC_Util::addStyle('media','player');
OC_Util::addStyle('media','music');
OC_App::setActiveNavigationEntry( 'media_index' );
diff --git a/apps/media/js/collection.js b/apps/media/js/collection.js
index 13eb0aff7d9..29ba45919cf 100644
--- a/apps/media/js/collection.js
+++ b/apps/media/js/collection.js
@@ -50,6 +50,10 @@ Collection={
}
}
+ Collection.artists.sort(function(a,b){
+ return a.name.localeCompare(b.name);
+ });
+
Collection.loaded=true;
Collection.loading=false;
for(var i=0;i0){
var tr=template.clone().removeClass('template');
- tr.find('td.title a').text(artist.songs.length+' '+t('media','songs'));
- tr.find('td.album a').text(artist.albums.length+' '+t('media','albums'));
+ if(artist.songs.length>1){
+ tr.find('td.title a').text(artist.songs.length+' '+t('media','songs'));
+ tr.find('td.album a').text(artist.albums.length+' '+t('media','albums'));
+ }else{
+ tr.find('td.title a').text(artist.songs[0].name);
+ tr.find('td.album a').text(artist.albums[0].name);
+ }
tr.find('td.artist a').text(artist.name);
tr.data('artistData',artist);
tr.find('td.artist a').click(function(event){
@@ -90,18 +99,20 @@ Collection={
Collection.parent.find('tr').removeClass('active');
$('tr[data-artist="'+artist.name+'"]').addClass('active');
});
- var expander=$('> ');
- expander.data('expanded',false);
- expander.click(function(event){
- var tr=$(this).parent().parent();
- if(expander.data('expanded')){
- Collection.hideArtist(tr.data('artist'));
- }else{
- Collection.showArtist(tr.data('artist'));
- }
- });
- tr.find('td.artist').addClass('buttons');
- Collection.addButtons(tr,artist);
+ if(artist.songs.length>1){
+ var expander=$('> ');
+ expander.data('expanded',false);
+ expander.click(function(event){
+ var tr=$(this).parent().parent();
+ if(expander.data('expanded')){
+ Collection.hideArtist(tr.data('artist'));
+ }else{
+ Collection.showArtist(tr.data('artist'));
+ }
+ });
+ }
+ tr.find('td.artist').addClass('buttons');
+ Collection.addButtons(tr,artist);
tr.children('td.artist').append(expander);
tr.attr('data-artist',artist.name);
Collection.parent.find('tbody').append(tr);
@@ -115,14 +126,16 @@ Collection={
var nextRow=tr.next();
var artist=tr.data('artistData');
var first=true;
- $.each(artist.albums,function(foo,album){
+ $.each(artist.albums,function(j,album){
$.each(album.songs,function(i,song){
if(first){
newRow=tr;
}else{
var newRow=tr.clone();
+ newRow.find('td.artist').text('');
+ newRow.find('.expander').remove();
}
- newRow.find('.expander').remove();
+ newRow.find('td.album .expander').remove();
if(i==0){
newRow.find('td.album a').text(album.name);
newRow.find('td.album a').click(function(event){
@@ -132,21 +145,23 @@ Collection={
Collection.parent.find('tr').removeClass('active');
$('tr[data-album="'+album.name+'"]').addClass('active');
});
- var expander=$('v ');
- expander.data('expanded',true);
- expander.click(function(event){
- var tr=$(this).parent().parent();
- if(expander.data('expanded')) {
- Collection.hideAlbum(tr.data('artist'),tr.data('album'));
- } else {
- Collection.showAlbum(tr.data('artist'),tr.data('album'));
- }
- });
- newRow.children('td.artist').append(expander);
- Collection.addButtons(newRow,album);
+ if(album.songs.length>1){
+ var expander=$('v ');
+ expander.data('expanded',true);
+ expander.click(function(event){
+ var tr=$(this).parent().parent();
+ if(expander.data('expanded')) {
+ Collection.hideAlbum(tr.data('artist'),tr.data('album'));
+ } else {
+ Collection.showAlbum(tr.data('artist'),tr.data('album'));
+ }
+ });
+ newRow.children('td.album').append(expander);
+ }
+ Collection.addButtons(newRow,album);
} else {
newRow.find('td.album a').text('');
- Collection.addButtons(newRow,song);
+ Collection.addButtons(newRow,song);
}
newRow.find('td.title a').text(song.name);
newRow.find('td.title a').click(function(event){
@@ -159,6 +174,7 @@ Collection={
newRow.attr('data-album',album.name);
newRow.attr('data-title',song.name);
newRow.attr('data-artist',artist.name);
+ newRow.data('albumData',album);
if(!first){
nextRow.before(newRow);
}
@@ -166,43 +182,62 @@ Collection={
});
});
tr.removeClass('collapsed');
- tr.find('a.expander').data('expanded',true);
- tr.find('a.expander').addClass('expanded');
- tr.find('a.expander').text('v');
+ tr.find('td.artist a.expander').data('expanded',true);
+ tr.find('td.artist a.expander').addClass('expanded');
+ tr.find('td.artist a.expander').text('v');
},
hideArtist:function(artist){
var tr=Collection.parent.find('tr[data-artist="'+artist+'"]');
- if(tr.length>1){
- var artist=tr.first().data('artistData');
- tr.first().find('td.album a').text(artist.albums.length+' '+t('media','albums'));
- tr.first().find('td.title a').text(artist.songs.length+' '+t('media','songs'));
- tr.first().find('td.album a').unbind('click');
- tr.first().find('td.title a').unbind('click');
- tr.each(function(i,row){
- if(i>0){
- $(row).remove();
- }
- });
- tr.find('a.expander').data('expanded',false);
- tr.find('a.expander').removeClass('expanded');
- tr.find('a.expander').text('>');
- Collection.addButtons(tr,artist);
- }
+ var artist=tr.first().data('artistData');
+ tr.first().find('td.album a').first().text(artist.albums.length+' '+t('media','albums'));
+ tr.first().find('td.album a.expander').remove();
+ tr.first().find('td.title a').text(artist.songs.length+' '+t('media','songs'));
+ tr.first().find('td.album a').unbind('click');
+ tr.first().find('td.title a').unbind('click');
+ tr.each(function(i,row){
+ if(i>0){
+ $(row).remove();
+ }
+ });
+ tr.find('td.artist a.expander').data('expanded',false);
+ tr.find('td.artist a.expander').removeClass('expanded');
+ tr.find('td.artist a.expander').text('>');
+ Collection.addButtons(tr,artist);
},
showAlbum:function(artist,album){
- var tr = Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]');
- tr.find('a.expander').data('expanded',true);
- tr.find('a.expander').addClass('expanded');
- tr.find('a.expander').text('v ');
- tr.show();
+ var tr = Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]');
+ var albumData=tr.data('albumData');
+ tr.find('td.album a.expander').data('expanded',true);
+ tr.find('td.album a.expander').addClass('expanded');
+ tr.find('td.album a.expander').text('v');
+ var nextRow=tr.next();
+ $.each(albumData.songs,function(i,song){
+ if(i>0){
+ var newRow=tr.clone();
+ newRow.find('a.expander').remove();
+ newRow.find('td.album a').text('');
+ newRow.find('td.artist a').text('');
+ }else{
+ var newRow=tr;
+ }
+ newRow.find('td.title a').text(song.name);
+ if(i>0){
+ nextRow.before(newRow);
+ }
+ });
},
hideAlbum:function(artist,album){
var tr = Collection.parent.find('tr[data-artist="'+artist+'"][data-album="'+album+'"]');
- tr.find('a.expander').data('expanded',false);
- tr.find('a.expander').removeClass('expanded');
- tr.find('a.expander').text('> ');
- tr.hide();
- tr.first().show();
+ var albumData=tr.data('albumData');
+ tr.first().find('td.title a').text(albumData.songs.length+' '+t('media','songs'));
+ tr.find('td.album a.expander').data('expanded',false);
+ tr.find('td.album a.expander').removeClass('expanded');
+ tr.find('td.album a.expander').text('> ');
+ tr.each(function(i,row){
+ if(i>0){
+ $(row).remove();
+ }
+ });
},
parent:null,
hide:function(){
@@ -217,25 +252,15 @@ Collection={
}
},
addButtons:function(parent,data){
- buttons = parent.find('.buttons');
- if(buttons.find('.add').length<=0) {
- buttons.append(' ');
- }
- if(buttons.find('.play').length<=0) {
- buttons.append(' ');
- }
+ buttons = parent.find('.buttons');
+ if(buttons.find('.add').length<=0) {
+ buttons.prepend(' ');
+ }
buttons.find('.add').unbind('click');
buttons.find('.add').click(function(event){
- event.preventDefault();
+ event.preventDefault();
PlayList.add(data,true);
- PlayList.render();
- });
- buttons.find('.play').unbind('click');
- buttons.find('.play').click(function(event){
- event.preventDefault();
- PlayList.add(data);
- PlayList.play(0,0);
- PlayList.render();
+ PlayList.render();
});
},
find:function(artistName,albumName,songName){
@@ -249,7 +274,7 @@ Collection={
},
findArtist:function(name){
for(var i=0;i '))
- $('#playerPlaceholder').append($('
')).load(OC.filePath('media','templates','player.php'),function(){
- loadPlayer.done=true;
+ var navItem=$('#apps a[href="'+OC.linkTo('media','index.php')+'"]');
+ navItem.height(navItem.height());
+ navItem.load(OC.filePath('media','templates','player.php'),function(){
PlayList.init(type,ready);
});
});
});
- OC.addStyle('media','player');
}else{
ready();
}
@@ -52,7 +53,7 @@ $(document).ready(function() {
var oc_current_user=OC.currentUser;
if(typeof PlayList==='undefined'){
if(typeof localStorage !== 'undefined' && localStorage){
- if(localStorage.hasOwnProperty(oc_current_user+'oc_playlist_items') && localStorage.getItem(oc_current_user+'oc_playlist_items')!='[]' && localStorage.getItem(oc_current_user+'oc_playlist_active')!='true'){
+ if(localStorage.getItem(oc_current_user+'oc_playlist_items') && localStorage.getItem(oc_current_user+'oc_playlist_items')!='[]' && localStorage.getItem(oc_current_user+'oc_playlist_active')!='true'){
loadPlayer();
}
}
diff --git a/apps/media/js/music.js b/apps/media/js/music.js
index c04c579d1ca..bf082207829 100644
--- a/apps/media/js/music.js
+++ b/apps/media/js/music.js
@@ -15,7 +15,7 @@ $(document).ready(function(){
PlayList.play(oldSize);
PlayList.render();
});
- var button=$(' ');
+ var button=$(' ');
button.css('background-image','url('+OC.imagePath('core','actions/play-add')+')')
button.click(function(event){
event.stopPropagation();
@@ -23,6 +23,7 @@ $(document).ready(function(){
PlayList.render();
});
row.find('div.name').append(button);
+ button.tipsy({gravity:'n', fade:true, delayIn: 400, live:true});
}
Collection.display();
});
diff --git a/apps/media/js/player.js b/apps/media/js/player.js
index f696b87bbde..3c022e9f8c4 100644
--- a/apps/media/js/player.js
+++ b/apps/media/js/player.js
@@ -28,17 +28,19 @@ var PlayList={
if(index==null){
index=PlayList.current;
}
+ PlayList.save();
if(index>-1 && index0){
@@ -56,6 +58,7 @@ var PlayList={
if (typeof Collection !== 'undefined') {
Collection.registerPlay();
}
+ PlayList.render();
if(ready){
ready();
}
@@ -63,10 +66,12 @@ var PlayList={
}else{
localStorage.setItem(oc_current_user+'oc_playlist_time',time);
localStorage.setItem(oc_current_user+'oc_playlist_playing','true');
- PlayList.save(); // so that the init don't lose the playlist
+// PlayList.save(); // so that the init don't lose the playlist
PlayList.init(items[index].type,null); // init calls load that calls play
}
}
+ $(".song").removeClass("collection_playing");
+ $(".jp-playlist-" + index).addClass("collection_playing");
},
init:function(type,ready){
if(!PlayList.player){
@@ -82,7 +87,7 @@ var PlayList={
PlayList.render();
return false;
});
- PlayList.player=$('#controls div.player');
+ PlayList.player=$('#jp-player');
}
$(PlayList.player).jPlayer({
ended:PlayList.next,
@@ -100,7 +105,7 @@ var PlayList={
}
},
volume:PlayList.volume,
- cssSelectorAncestor:'#controls',
+ cssSelectorAncestor:'.player-controls',
swfPath:OC.linkTo('media','js'),
});
},
@@ -127,7 +132,7 @@ var PlayList={
var type=musicTypeFromFile(song.path);
var item={name:song.name,type:type,artist:song.artist,album:song.album,length:song.length,playcount:song.playCount};
item[type]=PlayList.urlBase+encodeURIComponent(song.path);
- PlayList.items.push(item);
+ PlayList.items.push(item);
}
},
addFile:function(path){
@@ -157,17 +162,15 @@ var PlayList={
if(typeof localStorage !== 'undefined' && localStorage){
localStorage.setItem(oc_current_user+'oc_playlist_items',JSON.stringify(PlayList.items));
localStorage.setItem(oc_current_user+'oc_playlist_current',PlayList.current);
- if(PlayList.player) {
- if(PlayList.player.data('jPlayer')) {
- var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
- localStorage.setItem(oc_current_user+'oc_playlist_time',time);
- var volume=PlayList.player.data('jPlayer').options.volume*100;
- localStorage.setItem(oc_current_user+'oc_playlist_volume',volume);
- }
- }
- if(PlayList.active){
- localStorage.setItem(oc_current_user+'oc_playlist_active','false');
+ if(PlayList.player) {
+ if(PlayList.player.data('jPlayer')) {
+ var time=Math.round(PlayList.player.data('jPlayer').status.currentTime);
+ localStorage.setItem(oc_current_user+'oc_playlist_time',time);
+ var volume=PlayList.player.data('jPlayer').options.volume*100;
+ localStorage.setItem(oc_current_user+'oc_playlist_volume',volume);
+ }
}
+ localStorage.setItem(oc_current_user+'oc_playlist_active','true');
}
},
load:function(){
@@ -204,6 +207,9 @@ var PlayList={
$(document).ready(function(){
$(window).bind('beforeunload', function (){
PlayList.save();
+ if(PlayList.active){
+ localStorage.setItem(oc_current_user+'oc_playlist_active','false');
+ }
});
$('jp-previous').tipsy({gravity:'n', fade:true, live:true});
diff --git a/apps/media/js/playlist.js b/apps/media/js/playlist.js
index cb7f24522a4..57180b3be7b 100644
--- a/apps/media/js/playlist.js
+++ b/apps/media/js/playlist.js
@@ -5,6 +5,7 @@ PlayList.render=function(){
var item=PlayList.items[i];
var li=$(' ');
li.append(item.name);
+ li.attr('class', 'jp-playlist-' + i);
var img=$(' ');
img.click(function(event){
event.stopPropagation();
@@ -18,6 +19,7 @@ PlayList.render=function(){
li.addClass('song');
PlayList.parent.append(li);
}
+ $(".jp-playlist-" + PlayList.current).addClass("collection_playing");
}
PlayList.getSelected=function(){
return $('tbody td.name input:checkbox:checked').parent().parent();
@@ -28,6 +30,7 @@ PlayList.hide=function(){
$(document).ready(function(){
PlayList.parent=$('#leftcontent');
+ PlayList.init();
$('#selectAll').click(function(){
if($(this).attr('checked')){
// Check all
diff --git a/apps/media/l10n/bg_BG.php b/apps/media/l10n/bg_BG.php
new file mode 100644
index 00000000000..411ab0a8956
--- /dev/null
+++ b/apps/media/l10n/bg_BG.php
@@ -0,0 +1,14 @@
+ "Музика",
+"Play" => "Пусни",
+"Pause" => "Пауза",
+"Previous" => "Предишна",
+"Next" => "Следваща",
+"Mute" => "Отнеми",
+"Unmute" => "Върни",
+"Songs scanned" => "Сканирани песни",
+"Rescan Collection" => "Повторно сканиране",
+"Artist" => "Артист",
+"Album" => "Албум",
+"Title" => "Заглавие"
+);
diff --git a/apps/media/l10n/et_EE.php b/apps/media/l10n/et_EE.php
new file mode 100644
index 00000000000..c516ca64f26
--- /dev/null
+++ b/apps/media/l10n/et_EE.php
@@ -0,0 +1,14 @@
+ "Muusika",
+"Play" => "Esita",
+"Pause" => "Paus",
+"Previous" => "Eelmine",
+"Next" => "Järgmine",
+"Mute" => "Vaikseks",
+"Unmute" => "Hääl tagasi",
+"Songs scanned" => "Skännitud lood",
+"Rescan Collection" => "Skänni kollekttsiooni uuesti",
+"Artist" => "Esitaja",
+"Album" => "Album",
+"Title" => "Pealkiri"
+);
diff --git a/apps/media/l10n/ms_MY.php b/apps/media/l10n/ms_MY.php
new file mode 100644
index 00000000000..43cc47c81d7
--- /dev/null
+++ b/apps/media/l10n/ms_MY.php
@@ -0,0 +1,14 @@
+ "Muzik",
+"Play" => "Main",
+"Pause" => "Jeda",
+"Previous" => "Sebelum",
+"Next" => "Seterus",
+"Mute" => "Bisu",
+"Unmute" => "Nyahbisu",
+"Songs scanned" => "Lagu telah diimbas",
+"Rescan Collection" => "Imbas semula koleksi",
+"Artist" => "Artis",
+"Album" => "Album",
+"Title" => "Judul"
+);
diff --git a/apps/media/l10n/sr.php b/apps/media/l10n/sr.php
new file mode 100644
index 00000000000..7440bf43019
--- /dev/null
+++ b/apps/media/l10n/sr.php
@@ -0,0 +1,14 @@
+ "Музика",
+"Play" => "Пусти",
+"Pause" => "Паузирај",
+"Previous" => "Претходна",
+"Next" => "Следећа",
+"Mute" => "Искључи звук",
+"Unmute" => "Укључи звук",
+"Songs scanned" => "Претражених песама",
+"Rescan Collection" => "Поново претражи збирку",
+"Artist" => "Извођач",
+"Album" => "Албум",
+"Title" => "Наслов"
+);
diff --git a/apps/media/l10n/sr@latin.php b/apps/media/l10n/sr@latin.php
new file mode 100644
index 00000000000..fecdb0a5a74
--- /dev/null
+++ b/apps/media/l10n/sr@latin.php
@@ -0,0 +1,14 @@
+ "Muzika",
+"Play" => "Pusti",
+"Pause" => "Pauziraj",
+"Previous" => "Prethodna",
+"Next" => "Sledeća",
+"Mute" => "Isključi zvuk",
+"Unmute" => "Uključi zvuk",
+"Songs scanned" => "Pretraženih pesama",
+"Rescan Collection" => "Ponovo pretraži zbirku",
+"Artist" => "Izvođač",
+"Album" => "Album",
+"Title" => "Naslov"
+);
diff --git a/apps/media/l10n/sv.php b/apps/media/l10n/sv.php
index b3a7f18f7b2..f20fb2c6a57 100644
--- a/apps/media/l10n/sv.php
+++ b/apps/media/l10n/sv.php
@@ -1,6 +1,11 @@
"Musik",
+"Play" => "Spela",
"Pause" => "Paus",
+"Previous" => "Föregående",
+"Next" => "Nästa",
+"Mute" => "Ljudlös",
+"Unmute" => "Ljud på",
"Songs scanned" => "Skannade låtar",
"Rescan Collection" => "Sök igenom samlingen",
"Artist" => "Artist",
diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php
index b3bd7b16189..87291958af3 100644
--- a/apps/media/lib_ampache.php
+++ b/apps/media/lib_ampache.php
@@ -157,7 +157,6 @@ class OC_MEDIA_AMPACHE{
}
private static function printSong($song,$artistName=false,$albumName=false){
- global $WEBROOT;
if(!$artistName){
$artistName=OC_MEDIA_COLLECTION::getArtistName($song['song_artist']);
}
@@ -196,7 +195,7 @@ class OC_MEDIA_AMPACHE{
$filter=isset($params['filter'])?$params['filter']:'';
$exact=isset($params['exact'])?($params['exact']=='true'):false;
$artists=OC_MEDIA_COLLECTION::getArtists($filter,$exact);
- error_log('artists found: '.print_r($artists,true));
+ if(defined("DEBUG") && DEBUG) {error_log('artists found: '.print_r($artists,true));}
echo('');
foreach($artists as $artist){
self::printArtist($artist);
@@ -363,4 +362,4 @@ class OC_MEDIA_AMPACHE{
}
}
-?>
\ No newline at end of file
+?>
diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php
index 273ea2494f8..82c4afedd0a 100644
--- a/apps/media/lib_collection.php
+++ b/apps/media/lib_collection.php
@@ -251,10 +251,12 @@ class OC_MEDIA_COLLECTION{
if($name=='' or $path==''){
return 0;
}
- $uid=$_SESSION['user_id'];
+ $uid=OC_User::getUser();
//check if the song is already in the database
$songId=self::getSongId($name,$artist,$album);
if($songId!=0){
+ $songInfo=self::getSong($songId);
+ self::moveSong($songInfo['song_path'],$path);
return $songId;
}else{
if(!isset(self::$queries['addsong'])){
@@ -357,13 +359,23 @@ class OC_MEDIA_COLLECTION{
*/
public static function getSongByPath($path){
$query=OC_DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_path = ?");
- $result=$query->execute(array($path))->fetchAll();
- if(count($result)>0){
- return $result[0]['song_id'];
+ $result=$query->execute(array($path));
+ if($row=$result->fetchRow()){
+ return $row['song_id'];
}else{
return 0;
}
}
+
+ /**
+ * set the path of a song
+ * @param string $oldPath
+ * @param string $newPath
+ */
+ public static function moveSong($oldPath,$newPath){
+ $query=OC_DB::prepare("UPDATE *PREFIX*media_songs SET song_path = ? WHERE song_path = ?");
+ $query->execute(array($newPath,$oldPath));
+ }
}
?>
\ No newline at end of file
diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php
index 3086f84a93a..7a666be8c27 100644
--- a/apps/media/lib_media.php
+++ b/apps/media/lib_media.php
@@ -30,6 +30,9 @@ OC_Hook::connect('OC_Filesystem','post_write','OC_MEDIA','updateFile');
//listen for file deletions to clean the database if a song is deleted
OC_Hook::connect('OC_Filesystem','delete','OC_MEDIA','deleteFile');
+//list for file moves to update the database
+OC_Hook::connect('OC_Filesystem','post_rename','OC_MEDIA','moveFile');
+
class OC_MEDIA{
/**
* get the sha256 hash of the password needed for ampache
@@ -37,7 +40,7 @@ class OC_MEDIA{
*/
public static function loginListener($params){
if(isset($_POST['user']) and $_POST['password']){
- error_log('postlogin');
+ if(defined("DEBUG") && DEBUG) {error_log('postlogin');}
$name=$_POST['user'];
$query=OC_DB::prepare("SELECT user_id from *PREFIX*media_users WHERE user_id LIKE ?");
$uid=$query->execute(array($name))->fetchAll();
@@ -61,6 +64,7 @@ class OC_MEDIA{
$path=substr($path,1);
}
$path='/'.$path;
+ error_log("$path was updated");
OC_MEDIA_SCANNER::scanFile($path);
}
@@ -72,6 +76,11 @@ class OC_MEDIA{
require_once 'lib_collection.php';
OC_MEDIA_COLLECTION::deleteSongByPath($path);
}
+
+ public static function moveFile($params){
+ require_once 'lib_collection.php';
+ OC_MEDIA_COLLECTION::moveSong($params['oldpath'],$params['newpath']);
+ }
}
class OC_MediaSearchProvider extends OC_Search_Provider{
diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php
index c774c3c9fdb..9bf9397b19a 100644
--- a/apps/media/lib_scanner.php
+++ b/apps/media/lib_scanner.php
@@ -97,25 +97,25 @@ class OC_MEDIA_SCANNER{
$data=@self::$getID3->analyze($file);
getid3_lib::CopyTagsToComments($data);
if(!isset($data['comments'])){
- error_log("error reading id3 tags in '$file'");
+ if(defined("DEBUG") && DEBUG) {error_log("error reading id3 tags in '$file'");}
return;
}
if(!isset($data['comments']['artist'])){
- error_log("error reading artist tag in '$file'");
+ if(defined("DEBUG") && DEBUG) {error_log("error reading artist tag in '$file'");}
$artist='unknown';
}else{
$artist=stripslashes($data['comments']['artist'][0]);
$artist=utf8_encode($artist);
}
if(!isset($data['comments']['album'])){
- error_log("error reading album tag in '$file'");
+ if(defined("DEBUG") && DEBUG) {error_log("error reading album tag in '$file'");}
$album='unknown';
}else{
$album=stripslashes($data['comments']['album'][0]);
$album=utf8_encode($album);
}
if(!isset($data['comments']['title'])){
- error_log("error reading title tag in '$file'");
+ if(defined("DEBUG") && DEBUG) {error_log("error reading title tag in '$file'");}
$title='unknown';
}else{
$title=stripslashes($data['comments']['title'][0]);
diff --git a/apps/media/server/xml.server.php b/apps/media/server/xml.server.php
index 516ab740072..44a16793bf2 100644
--- a/apps/media/server/xml.server.php
+++ b/apps/media/server/xml.server.php
@@ -23,6 +23,7 @@
require_once('../../../lib/base.php');
+OC_Util::checkAppEnabled('media');
require_once('../lib_collection.php');
require_once('../lib_ampache.php');
@@ -35,9 +36,8 @@ foreach($arguments as &$argument){
$argument=stripslashes($argument);
}
ob_clean();
-global $CONFIG_DATADIRECTORY;
if(isset($arguments['action'])){
- error_log($arguments['action']);
+ if(defined("DEBUG") && DEBUG) {error_log($arguments['action']);}
switch($arguments['action']){
case 'url_to_song':
OC_MEDIA_AMPACHE::url_to_song($arguments);
diff --git a/apps/media/settings.php b/apps/media/settings.php
new file mode 100644
index 00000000000..133440a9af6
--- /dev/null
+++ b/apps/media/settings.php
@@ -0,0 +1,6 @@
+fetchPage();
+?>
diff --git a/apps/media/templates/music.php b/apps/media/templates/music.php
index 9b40faa9619..7764a315a8f 100644
--- a/apps/media/templates/music.php
+++ b/apps/media/templates/music.php
@@ -1,4 +1,4 @@
-
+
@@ -17,20 +17,20 @@
+
+
+
-
-
0 t('Songs scanned')?>
-
-
-
-
-
diff --git a/apps/media/templates/player.php b/apps/media/templates/player.php
new file mode 100644
index 00000000000..295f33ab9e0
--- /dev/null
+++ b/apps/media/templates/player.php
@@ -0,0 +1,17 @@
+printPage();
+ exit;
+}
+?>
+Music
+
\ No newline at end of file
diff --git a/apps/media/templates/settings.php b/apps/media/templates/settings.php
new file mode 100644
index 00000000000..ac813c20850
--- /dev/null
+++ b/apps/media/templates/settings.php
@@ -0,0 +1,7 @@
+
+
+ Media
+ Ampache address:
+
+
+
diff --git a/apps/media/tomahawk.php b/apps/media/tomahawk.php
index bf0c2c2a756..68401db67ae 100644
--- a/apps/media/tomahawk.php
+++ b/apps/media/tomahawk.php
@@ -24,6 +24,7 @@
$_POST=$_GET; //debug
require_once('../../lib/base.php');
+OC_JSON::checkAppEnabled('media');
require_once('lib_collection.php');
$user=isset($_POST['user'])?$_POST['user']:'';
@@ -77,5 +78,5 @@ foreach($songs as $song) {
'score' => (float)1.0
);
}
-echo json_encode($results);
-?>
\ No newline at end of file
+OC_JSON::encodedPrint($results);
+?>
diff --git a/apps/remoteStorage/appinfo/app.php b/apps/remoteStorage/appinfo/app.php
new file mode 100644
index 00000000000..ac1ecde5082
--- /dev/null
+++ b/apps/remoteStorage/appinfo/app.php
@@ -0,0 +1,5 @@
+ 10,
+ 'id' => 'remoteStorage',
+ 'name' => 'remoteStorage compatibility' ));
diff --git a/apps/unhosted/appinfo/database.xml b/apps/remoteStorage/appinfo/database.xml
similarity index 96%
rename from apps/unhosted/appinfo/database.xml
rename to apps/remoteStorage/appinfo/database.xml
index db25657085b..b4e1ac7d8af 100644
--- a/apps/unhosted/appinfo/database.xml
+++ b/apps/remoteStorage/appinfo/database.xml
@@ -43,7 +43,7 @@
64
- a_app_unhostedweb_user
+ a_app_remotestorage_user
true
user
diff --git a/apps/remoteStorage/appinfo/info.xml b/apps/remoteStorage/appinfo/info.xml
new file mode 100644
index 00000000000..a20c6ff4cd4
--- /dev/null
+++ b/apps/remoteStorage/appinfo/info.xml
@@ -0,0 +1,10 @@
+
+
+ remoteStorage
+ remoteStorage compatibility
+ Enables your users to use ownCloud as their remote storage for unhosted applications.
+ 0.1
+ AGPL
+ Michiel de Jong
+ 2
+
diff --git a/apps/unhosted/compat.php b/apps/remoteStorage/compat.php
similarity index 80%
rename from apps/unhosted/compat.php
rename to apps/remoteStorage/compat.php
index 5034d04de31..35a133c43c7 100644
--- a/apps/unhosted/compat.php
+++ b/apps/remoteStorage/compat.php
@@ -30,20 +30,21 @@
$RUNTIME_NOSETUPFS = true;
require_once('../../lib/base.php');
+OC_Util::checkAppEnabled('remoteStorage');
require_once('Sabre/autoload.php');
-require_once('lib_unhosted.php');
+require_once('lib_remoteStorage.php');
require_once('oauth_ro_auth.php');
ini_set('default_charset', 'UTF-8');
#ini_set('error_reporting', '');
@ob_clean();
-//allow use as unhosted storage for other websites
+//allow use as remote storage for other websites
if(isset($_SERVER['HTTP_ORIGIN'])) {
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Max-Age: 3600');
header('Access-Control-Allow-Methods: OPTIONS, GET, PUT, DELETE, PROPFIND');
- header('Access-Control-Allow-Headers: Authorization');
+ header('Access-Control-Allow-Headers: Authorization, Content-Type');
} else {
header('Access-Control-Allow-Origin: *');
}
@@ -52,12 +53,12 @@ $path = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"]));
$pathParts = explode('/', $path);
// for webdav:
// 0/ 1 / 2 / 3 / 4 / 5 / 6 / 7
-// /$ownCloudUser/unhosted/webdav/$userHost/$userName/$dataScope/$key
+// /$ownCloudUser/remoteStorage/webdav/$userHost/$userName/$dataScope/$key
// for oauth:
// 0/ 1 / 2 / 3 / 4
-// /$ownCloudUser/unhosted/oauth/auth
+// /$ownCloudUser/remoteStorage/oauth/auth
-if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'unhosted' && $pathParts[3] == 'webdav') {
+if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'remoteStorage' && $pathParts[3] == 'webdav') {
list($dummy0, $ownCloudUser, $dummy2, $dummy3, $userHost, $userName, $dataScope) = $pathParts;
OC_Util::setupFS($ownCloudUser);
@@ -67,10 +68,10 @@ if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'unhosted'
$server = new Sabre_DAV_Server($publicDir);
// Path to our script
- $server->setBaseUri("$WEBROOT/apps/unhosted/compat.php/$ownCloudUser");
+ $server->setBaseUri(OC::$WEBROOT."/apps/remoteStorage/compat.php/$ownCloudUser");
// Auth backend
- $authBackend = new OC_Connector_Sabre_Auth_ro_oauth(OC_UnhostedWeb::getValidTokens($ownCloudUser, $userName.'@'.$userHost, $dataScope));
+ $authBackend = new OC_Connector_Sabre_Auth_ro_oauth(OC_remoteStorage::getValidTokens($ownCloudUser, $userName.'@'.$userHost, $dataScope));
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud');//should use $validTokens here
$server->addPlugin($authPlugin);
@@ -82,7 +83,7 @@ if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'unhosted'
// And off we go!
$server->exec();
-} else if(count($pathParts) >= 4 && $pathParts[0] == '' && $pathParts[2] == 'unhosted' && $pathParts[3] == 'oauth2' && $pathParts[4] = 'auth') {
+} else if(count($pathParts) >= 4 && $pathParts[0] == '' && $pathParts[2] == 'remoteStorage' && $pathParts[3] == 'oauth2' && $pathParts[4] = 'auth') {
if(isset($_POST['allow'])) {
//TODO: input checking. these explodes may fail to produces the desired arrays:
$ownCloudUser = $pathParts[1];
@@ -97,8 +98,8 @@ if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'unhosted'
}
if(OC_User::getUser() == $ownCloudUser) {
//TODO: check if this can be faked by editing the cookie in firebug!
- $token=OC_UnhostedWeb::createDataScope($appUrl, $userAddress, $dataScope);
- header('Location: '.$_GET['redirect_uri'].'#access_token='.$token.'&token_type=unhosted');
+ $token=OC_remoteStorage::createDataScope($appUrl, $userAddress, $dataScope);
+ header('Location: '.$_GET['redirect_uri'].'#access_token='.$token.'&token_type=remoteStorage');
} else {
if($_SERVER['HTTPS']){
$url = "https://";
@@ -106,7 +107,7 @@ if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'unhosted'
$url = "http://";
}
$url .= $_SERVER['SERVER_NAME'];
- $url .= substr($_SERVER['SCRIPT_NAME'], 0, -strlen('apps/unhosted/compat.php'));
+ $url .= substr($_SERVER['SCRIPT_NAME'], 0, -strlen('apps/remoteStorage/compat.php'));
die('Please '
.' execute(array($user,$userAddress,$dataScope));
+ $result=$query->execute(array($ownCloudUser,$userAddress,$dataScope));
if( PEAR::isError($result)) {
$entry = 'DB Error: "'.$result->getMessage().'" ';
$entry .= 'Offending command was: '.$result->getDebugInfo().' ';
- error_log( $entry );
+ if(defined("DEBUG") && DEBUG) {error_log( $entry );}
die( $entry );
}
$ret = array();
@@ -24,7 +24,7 @@ class OC_UnhostedWeb {
if( PEAR::isError($result)) {
$entry = 'DB Error: "'.$result->getMessage().'" ';
$entry .= 'Offending command was: '.$result->getDebugInfo().' ';
- error_log( $entry );
+ if(defined("DEBUG") && DEBUG) {error_log( $entry );}
die( $entry );
}
$ret = array();
@@ -45,7 +45,7 @@ class OC_UnhostedWeb {
if( PEAR::isError($result)) {
$entry = 'DB Error: "'.$result->getMessage().'" ';
$entry .= 'Offending command was: '.$result->getDebugInfo().' ';
- error_log( $entry );
+ if(defined("DEBUG") && DEBUG) {error_log( $entry );}
die( $entry );
}
}
@@ -56,7 +56,7 @@ class OC_UnhostedWeb {
if( PEAR::isError($result)) {
$entry = 'DB Error: "'.$result->getMessage().'" ';
$entry .= 'Offending command was: '.$result->getDebugInfo().' ';
- error_log( $entry );
+ if(defined("DEBUG") && DEBUG) {error_log( $entry );}
die( $entry );
}
}
@@ -66,7 +66,7 @@ class OC_UnhostedWeb {
//TODO: input checking on $userAddress and $dataScope
list($userName, $userHost) = explode('@', $userAddress);
OC_Util::setupFS(OC_User::getUser());
- $scopePathParts = array('unhosted', 'webdav', $userHost, $userName, $dataScope);
+ $scopePathParts = array('remoteStorage', 'webdav', $userHost, $userName, $dataScope);
for($i=0;$i<=count($scopePathParts);$i++){
$thisPath = '/'.implode('/', array_slice($scopePathParts, 0, $i));
if(!OC_Filesystem::file_exists($thisPath)) {
diff --git a/apps/unhosted/oauth_ro_auth.php b/apps/remoteStorage/oauth_ro_auth.php
similarity index 100%
rename from apps/unhosted/oauth_ro_auth.php
rename to apps/remoteStorage/oauth_ro_auth.php
diff --git a/apps/unhosted/appinfo/app.php b/apps/unhosted/appinfo/app.php
deleted file mode 100644
index 84e07304534..00000000000
--- a/apps/unhosted/appinfo/app.php
+++ /dev/null
@@ -1,5 +0,0 @@
- 10,
- 'id' => 'unhosted',
- 'name' => 'Unhosted Web' ));
diff --git a/apps/unhosted/appinfo/info.xml b/apps/unhosted/appinfo/info.xml
deleted file mode 100644
index 359620f4578..00000000000
--- a/apps/unhosted/appinfo/info.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- unhosted
- Unhosted Web
- On websites that allow unhosted accounts, use your owncloud as the storage for your user data
- 0.1
- AGPL
- Michiel de Jong
- 2
-
diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php
index e8e9fd2296b..546f9f4565a 100644
--- a/apps/user_openid/appinfo/app.php
+++ b/apps/user_openid/appinfo/app.php
@@ -26,29 +26,28 @@ OC_User::useBackend('openid');
//check for results from openid requests
if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){
- error_log('openid retured');
+ if(defined("DEBUG") && DEBUG) {error_log('openid retured');}
$openid = new SimpleOpenID;
$openid->SetIdentity($_GET['openid_identity']);
$openid_validation_result = $openid->ValidateWithServer();
if ($openid_validation_result == true){ // OK HERE KEY IS VALID
- error_log('auth sucessfull');
- global $WEBROOT;
+ if(defined("DEBUG") && DEBUG) {error_log('auth sucessfull');}
$identity=$openid->GetIdentity();
- error_log("auth as $identity");
+ if(defined("DEBUG") && DEBUG) {error_log("auth as $identity");}
$user=OC_USER_OPENID::findUserForIdentity($identity);
if($user){
$_SESSION['user_id']=$user;
- header("Location: $WEBROOT");
+ header("Location: ".OC::$WEBROOT);
}
}else if($openid->IsError() == true){ // ON THE WAY, WE GOT SOME ERROR
$error = $openid->GetError();
- error_log("ERROR CODE: " . $error['code']);
- error_log("ERROR DESCRIPTION: " . $error['description']);
+ if(defined("DEBUG") && DEBUG) {error_log("ERROR CODE: " . $error['code']);}
+ if(defined("DEBUG") && DEBUG) {error_log("ERROR DESCRIPTION: " . $error['description']);}
}else{ // Signature Verification Failed
- error_log("INVALID AUTHORIZATION");
+ if(defined("DEBUG") && DEBUG) {error_log("INVALID AUTHORIZATION");}
}
}else if (isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'cancel'){ // User Canceled your Request
- error_log("USER CANCELED REQUEST");
+ if(defined("DEBUG") && DEBUG) {error_log("USER CANCELED REQUEST");}
return false;
}
diff --git a/apps/user_openid/appinfo/info.xml b/apps/user_openid/appinfo/info.xml
index 32525009d61..37be15abfda 100644
--- a/apps/user_openid/appinfo/info.xml
+++ b/apps/user_openid/appinfo/info.xml
@@ -7,4 +7,4 @@
AGPL
Robin Appelman
2
-
\ No newline at end of file
+
diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php
index 24fab44ca7a..5009fa410aa 100644
--- a/apps/user_openid/phpmyid.php
+++ b/apps/user_openid/phpmyid.php
@@ -1054,7 +1054,7 @@ function debug ($x, $m = null) {
$x .= "\n";
}
- error_log($x . "\n", 3, $profile['logfile']);
+ if(defined("DEBUG") && DEBUG) {error_log($x . "\n", 3, $profile['logfile']);}
}
@@ -1069,6 +1069,9 @@ function destroy_assoc_handle ( $id ) {
session_write_close();
session_id($id);
+ if (OC_Config::getValue( "forcessl", false )) {
+ ini_set("session.cookie_secure", "on");
+ }
session_start();
session_destroy();
@@ -1194,6 +1197,9 @@ function new_assoc ( $expiration ) {
session_write_close();
}
+ if (OC_Config::getValue( "forcessl", false )) {
+ ini_set("session.cookie_secure", "on");
+ }
session_start();
session_regenerate_id('false');
@@ -1265,6 +1271,9 @@ function secret ( $handle ) {
}
session_id($handle);
+ if (OC_Config::getValue( "forcessl", false )) {
+ ini_set("session.cookie_secure", "on");
+ }
session_start();
debug('Started session to acquire key: ' . session_id());
@@ -1467,6 +1476,9 @@ function user_session () {
global $proto, $profile;
session_name('phpMyID_Server');
+ if (OC_Config::getValue( "forcessl", false )) {
+ ini_set("session.cookie_secure", "on");
+ }
@session_start();
$profile['authorized'] = (isset($_SESSION['auth_username'])
@@ -1501,7 +1513,7 @@ function wrap_html ( $message ) {