summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul 'flowerysong' Arthur <flowerysong00@yahoo.com>2010-03-14 20:14:52 +0000
committerPaul 'flowerysong' Arthur <flowerysong00@yahoo.com>2010-03-14 20:14:52 +0000
commit1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc (patch)
tree54655ff3e692a71a17f1d37cd97374b263557ca1
parentef48bf3fbdca2a4d25f5d025f4c6ad23905e5369 (diff)
downloadampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.tar.gz
ampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.tar.bz2
ampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.zip
Cosmetics: remove trailing whitespace
-rw-r--r--admin/access.php164
-rw-r--r--admin/catalog.php186
-rw-r--r--admin/duplicates.php14
-rw-r--r--admin/export.php34
-rw-r--r--admin/flag.php204
-rw-r--r--admin/index.php18
-rw-r--r--admin/mail.php28
-rw-r--r--admin/modules.php116
-rw-r--r--admin/shout.php26
-rw-r--r--admin/system.php28
-rw-r--r--admin/users.php114
-rw-r--r--albums.php122
-rw-r--r--artists.php76
-rw-r--r--batch.php42
-rw-r--r--browse.php84
-rw-r--r--democratic.php144
-rw-r--r--flag.php8
-rw-r--r--genre.php38
-rw-r--r--image.php50
-rw-r--r--index.php8
-rw-r--r--lib/batch.lib.php58
-rw-r--r--lib/class/access.class.php334
-rw-r--r--lib/class/ajax.class.php94
-rw-r--r--lib/class/album.class.php644
-rw-r--r--lib/class/ampacherss.class.php126
-rw-r--r--lib/class/api.class.php240
-rw-r--r--lib/class/art.class.php6
-rw-r--r--lib/class/artist.class.php154
-rw-r--r--lib/class/browse.class.php248
-rw-r--r--lib/class/catalog.class.php494
-rw-r--r--lib/class/config.class.php36
-rw-r--r--lib/class/core.class.php90
-rw-r--r--lib/class/democratic.class.php396
-rw-r--r--lib/class/error.class.php70
-rw-r--r--lib/class/flag.class.php212
-rw-r--r--lib/class/localplay.abstract.php76
-rw-r--r--lib/class/localplay.class.php322
-rw-r--r--lib/class/media.interface.php12
-rw-r--r--lib/class/playlist.class.php240
-rw-r--r--lib/class/plugin.class.php158
-rw-r--r--lib/class/preference.class.php298
-rw-r--r--lib/class/query.class.php20
-rw-r--r--lib/class/radio.class.php166
-rw-r--r--lib/class/random.class.php426
-rw-r--r--lib/class/rating.class.php158
-rw-r--r--lib/class/registration.class.php20
-rw-r--r--lib/class/scrobbler.class.php86
-rw-r--r--lib/class/shoutbox.class.php152
-rw-r--r--lib/class/song.class.php528
-rw-r--r--lib/class/stats.class.php126
-rw-r--r--lib/class/stream.class.php488
-rw-r--r--lib/class/tag.class.php470
-rw-r--r--lib/class/tmpplaylist.class.php160
-rw-r--r--lib/class/update.class.php64
-rw-r--r--lib/class/user.class.php12
-rw-r--r--lib/class/vainfo.class.php482
-rw-r--r--lib/class/vauth.class.php14
-rw-r--r--lib/class/video.class.php70
-rw-r--r--lib/class/xmldata.class.php500
-rw-r--r--lib/gettext.php8
-rw-r--r--lib/init.php144
-rw-r--r--lib/install.php40
-rw-r--r--lib/log.lib.php52
-rw-r--r--lib/preferences.php8
-rw-r--r--lib/rating.lib.php12
-rw-r--r--lib/search.php138
-rw-r--r--lib/themes.php34
-rw-r--r--localplay.php92
-rw-r--r--login.php78
-rw-r--r--logout.php2
-rw-r--r--modules/captcha/captcha.php84
-rw-r--r--modules/emulator/gettext.php12
-rw-r--r--modules/flash/xspf_player.php2
-rw-r--r--modules/getid3/extension.cache.dbm.php2
-rw-r--r--modules/getid3/extension.cache.mysql.php2
-rw-r--r--modules/getid3/module.archive.gzip.php54
-rw-r--r--modules/getid3/module.archive.szip.php10
-rw-r--r--modules/getid3/module.archive.tar.php26
-rw-r--r--modules/getid3/module.archive.zip.php108
-rw-r--r--modules/getid3/module.audio-video.asf.php536
-rw-r--r--modules/getid3/module.audio-video.flv.php86
-rw-r--r--modules/getid3/module.audio-video.mpeg.php44
-rw-r--r--modules/getid3/module.audio-video.nsv.php32
-rw-r--r--modules/getid3/module.audio-video.real.php94
-rw-r--r--modules/getid3/module.audio-video.riff.php366
-rw-r--r--modules/getid3/module.audio-video.swf.php16
-rw-r--r--modules/getid3/module.audio.aac_adif.php58
-rw-r--r--modules/getid3/module.audio.aac_adts.php66
-rw-r--r--modules/getid3/module.audio.ac3.php40
-rw-r--r--modules/getid3/module.audio.au.php16
-rw-r--r--modules/getid3/module.audio.avr.php10
-rw-r--r--modules/getid3/module.audio.bonk.php28
-rw-r--r--modules/getid3/module.audio.dts.php48
-rw-r--r--modules/getid3/module.audio.la.php36
-rw-r--r--modules/getid3/module.audio.lpac.php30
-rw-r--r--modules/getid3/module.audio.midi.php202
-rw-r--r--modules/getid3/module.audio.monkey.php86
-rw-r--r--modules/getid3/module.audio.mpc_old.php20
-rw-r--r--modules/getid3/module.audio.optimfrog.php70
-rw-r--r--modules/getid3/module.audio.rkau.php20
-rw-r--r--modules/getid3/module.audio.shorten.php26
-rw-r--r--modules/getid3/module.audio.tta.php32
-rw-r--r--modules/getid3/module.audio.voc.php38
-rw-r--r--modules/getid3/module.audio.vqf.php24
-rw-r--r--modules/getid3/module.audio.wavpack.php46
-rw-r--r--modules/getid3/module.audio.xiph.php232
-rw-r--r--modules/getid3/module.graphic.bmp.php68
-rw-r--r--modules/getid3/module.graphic.gif.php18
-rw-r--r--modules/getid3/module.graphic.jpeg.php8
-rw-r--r--modules/getid3/module.graphic.pcd.php6
-rw-r--r--modules/getid3/module.graphic.png.php80
-rw-r--r--modules/getid3/module.graphic.tiff.php16
-rw-r--r--modules/getid3/module.lib.data_hash.php60
-rw-r--r--modules/getid3/module.lib.iconv_replacement.php80
-rw-r--r--modules/getid3/module.lib.image_size.php50
-rw-r--r--modules/getid3/module.misc.iso.php78
-rw-r--r--modules/getid3/module.tag.id3v1.php28
-rw-r--r--modules/getid3/module.tag.lyrics3.php80
-rw-r--r--modules/getid3/write.apetag.php90
-rw-r--r--modules/getid3/write.id3v1.php62
-rw-r--r--modules/getid3/write.id3v2.php68
-rw-r--r--modules/getid3/write.lyrics3.php68
-rw-r--r--modules/getid3/write.vorbis.php70
-rw-r--r--modules/infotools/Snoopy.class.php268
-rw-r--r--modules/infotools/jamendoSearch.class.php26
-rw-r--r--modules/mpd/mpd.class.php276
-rw-r--r--modules/php_musicbrainz/mbArtist.php4
-rw-r--r--modules/php_musicbrainz/mbArtistAlias.php2
-rw-r--r--modules/php_musicbrainz/mbDisc.php6
-rw-r--r--modules/php_musicbrainz/mbEntity.php2
-rw-r--r--modules/php_musicbrainz/mbFilter.php18
-rw-r--r--modules/php_musicbrainz/mbLabel.php2
-rw-r--r--modules/php_musicbrainz/mbMetadata.php4
-rw-r--r--modules/php_musicbrainz/mbQuery.php18
-rw-r--r--modules/php_musicbrainz/mbRelation.php4
-rw-r--r--modules/php_musicbrainz/mbRelease.php4
-rw-r--r--modules/php_musicbrainz/mbReleaseEvent.php2
-rw-r--r--modules/php_musicbrainz/mbUser.php14
-rw-r--r--modules/php_musicbrainz/mbUtil.php6
-rw-r--r--modules/php_musicbrainz/mbUtil_countrynames.php2
-rw-r--r--modules/php_musicbrainz/mbUtil_languagenames.php2
-rw-r--r--modules/php_musicbrainz/mbUtil_releasetypenames.php2
-rw-r--r--modules/php_musicbrainz/mbWebService.php24
-rw-r--r--modules/php_musicbrainz/mbXmlParser.php40
-rw-r--r--modules/php_musicbrainz/xml/xmlParser.php12
-rw-r--r--modules/plugins/Lastfm.plugin.php198
-rw-r--r--modules/plugins/Librefm.plugin.php198
-rw-r--r--modules/validatemail/validateEmail.php166
-rw-r--r--modules/validatemail/validateEmailFormat.php34
-rw-r--r--play/index.php258
-rw-r--r--playlist.php48
-rw-r--r--preferences.php136
-rw-r--r--radio.php56
-rw-r--r--random.php22
-rw-r--r--register.php54
-rw-r--r--rss.php6
-rw-r--r--search.php36
-rw-r--r--server/ajax.server.php422
-rw-r--r--server/browse.ajax.php88
-rw-r--r--server/democratic.ajax.php158
-rw-r--r--server/flag.ajax.php70
-rw-r--r--server/index.ajax.php58
-rw-r--r--server/localplay.ajax.php216
-rw-r--r--server/playlist.ajax.php170
-rw-r--r--server/random.ajax.php44
-rw-r--r--server/song.ajax.php40
-rw-r--r--server/stats.ajax.php12
-rw-r--r--server/stream.ajax.php92
-rw-r--r--server/tag.ajax.php10
-rw-r--r--server/xml.server.php50
-rw-r--r--shout.php54
-rw-r--r--stats.php34
-rw-r--r--stream.php84
-rw-r--r--templates/footer.inc.php2
-rw-r--r--templates/header.inc.php4
-rw-r--r--templates/list_header.inc.php48
-rw-r--r--templates/rightbar.inc.php56
-rw-r--r--templates/show_access_list.inc.php8
-rw-r--r--templates/show_adds_catalog.inc.php6
-rw-r--r--templates/show_album_art.inc.php18
-rw-r--r--templates/show_album_row.inc.php4
-rw-r--r--templates/show_albums.inc.php20
-rw-r--r--templates/show_all_popular.inc.php8
-rw-r--r--templates/show_alphabet_form.inc.php2
-rw-r--r--templates/show_artist_row.inc.php2
-rw-r--r--templates/show_artists.inc.php12
-rw-r--r--templates/show_box_top.inc.php2
-rw-r--r--templates/show_catalog_row.inc.php2
-rw-r--r--templates/show_catalogs.inc.php8
-rw-r--r--templates/show_clean_catalog.inc.php6
-rw-r--r--templates/show_confirmation.inc.php2
-rw-r--r--templates/show_create_democratic.inc.php2
-rw-r--r--templates/show_debug.inc.php24
-rw-r--r--templates/show_democratic.inc.php4
-rw-r--r--templates/show_democratic_playlist.inc.php16
-rw-r--r--templates/show_disabled_songs.inc.php2
-rw-r--r--templates/show_duplicate.inc.php4
-rw-r--r--templates/show_duplicates.inc.php16
-rw-r--r--templates/show_edit_album_row.inc.php18
-rw-r--r--templates/show_edit_artist_row.inc.php2
-rw-r--r--templates/show_edit_catalog.inc.php2
-rw-r--r--templates/show_edit_live_stream_row.inc.php2
-rw-r--r--templates/show_edit_playlist_row.inc.php8
-rw-r--r--templates/show_edit_playlist_song_row.inc.php2
-rw-r--r--templates/show_edit_song_row.inc.php2
-rw-r--r--templates/show_export.inc.php14
-rw-r--r--templates/show_flagged.inc.php10
-rw-r--r--templates/show_gather_art.inc.php4
-rw-r--r--templates/show_genre.inc.php2
-rw-r--r--templates/show_genres.inc.php6
-rw-r--r--templates/show_import_playlist.inc.php2
-rw-r--r--templates/show_index.inc.php26
-rw-r--r--templates/show_install.inc.php8
-rw-r--r--templates/show_install_account.inc.php2
-rw-r--r--templates/show_install_check.inc.php108
-rw-r--r--templates/show_install_config.inc.php18
-rw-r--r--templates/show_install_lang.inc.php2
-rw-r--r--templates/show_ip_history.inc.php2
-rw-r--r--templates/show_live_stream_row.inc.php2
-rw-r--r--templates/show_live_streams.inc.php14
-rw-r--r--templates/show_localplay_controllers.inc.php26
-rw-r--r--templates/show_localplay_instances.inc.php4
-rw-r--r--templates/show_localplay_playlist.inc.php10
-rw-r--r--templates/show_localplay_status.inc.php8
-rw-r--r--templates/show_login_form.inc.php12
-rw-r--r--templates/show_mail_users.inc.php4
-rw-r--r--templates/show_manage_catalogs.inc.php2
-rw-r--r--templates/show_manage_democratic.inc.php10
-rw-r--r--templates/show_manage_shoutbox.inc.php8
-rw-r--r--templates/show_now_playing.inc.php4
-rw-r--r--templates/show_object_rating.inc.php6
-rw-r--r--templates/show_object_rating_static.inc.php4
-rw-r--r--templates/show_object_row.inc.php4
-rw-r--r--templates/show_objects.inc.php8
-rw-r--r--templates/show_playlist.inc.php10
-rw-r--r--templates/show_playlist_row.inc.php2
-rw-r--r--templates/show_playlist_songs.inc.php14
-rw-r--r--templates/show_playlists.inc.php12
-rw-r--r--templates/show_playtype_switch.inc.php4
-rw-r--r--templates/show_plugins.inc.php10
-rw-r--r--templates/show_preference_admin.inc.php4
-rw-r--r--templates/show_preference_box.inc.php12
-rw-r--r--templates/show_preferences.inc.php8
-rw-r--r--templates/show_random.inc.php12
-rw-r--r--templates/show_random_albums.inc.php14
-rw-r--r--templates/show_recently_played.inc.php24
-rw-r--r--templates/show_registration_confirmation.inc.php2
-rw-r--r--templates/show_run_add_catalog.inc.php2
-rw-r--r--templates/show_search.inc.php2
-rw-r--r--templates/show_shoutbox.inc.php14
-rw-r--r--templates/show_song_row.inc.php2
-rw-r--r--templates/show_songs.inc.php12
-rw-r--r--templates/show_stats.inc.php10
-rw-r--r--templates/show_stats_popular.inc.php20
-rw-r--r--templates/show_tagcloud.inc.php16
-rw-r--r--templates/show_test.inc.php84
-rw-r--r--templates/show_test_config.inc.php16
-rw-r--r--templates/show_update_items.inc.php4
-rw-r--r--templates/show_user.inc.php24
-rw-r--r--templates/show_user_activate.inc.php6
-rw-r--r--templates/show_user_preferences.inc.php6
-rw-r--r--templates/show_user_recommendations.inc.php18
-rw-r--r--templates/show_user_registration.inc.php2
-rw-r--r--templates/show_user_row.inc.php4
-rw-r--r--templates/show_user_stats.inc.php28
-rw-r--r--templates/show_users.inc.php6
-rw-r--r--templates/show_verify_catalog.inc.php6
-rw-r--r--templates/show_video_row.inc.php2
-rw-r--r--templates/show_videos.inc.php10
-rw-r--r--templates/show_xspf_player.inc.php8
-rw-r--r--templates/sidebar.inc.php14
-rw-r--r--templates/sidebar_localplay.inc.php18
-rw-r--r--templates/sidebar_modules.inc.php4
-rw-r--r--templates/sidebar_preferences.inc.php12
-rw-r--r--templates/subnavbar.inc.php8
-rw-r--r--test.php20
-rw-r--r--themes/classic/theme.cfg.php4
-rw-r--r--update.php10
-rw-r--r--util.php16
279 files changed, 9313 insertions, 9313 deletions
diff --git a/admin/access.php b/admin/access.php
index a6ea8dd1..0c35b4fc 100644
--- a/admin/access.php
+++ b/admin/access.php
@@ -22,127 +22,127 @@
require '../lib/init.php';
-if (!Access::check('interface','100')) {
+if (!Access::check('interface','100')) {
access_denied();
exit();
}
-show_header();
+show_header();
-switch ($_REQUEST['action']) {
+switch ($_REQUEST['action']) {
case 'delete_record':
- if (!Core::form_verify('delete_access')) {
- access_denied();
- exit;
- }
+ if (!Core::form_verify('delete_access')) {
+ access_denied();
+ exit;
+ }
Access::delete($_REQUEST['access_id']);
$url = Config::get('web_path') . '/admin/access.php';
show_confirmation(_('Deleted'),_('Your Access List Entry has been removed'),$url);
break;
- case 'show_delete_record':
- if (Config::get('demo_mode')) { break; }
- $access = new Access($_GET['access_id']);
+ case 'show_delete_record':
+ if (Config::get('demo_mode')) { break; }
+ $access = new Access($_GET['access_id']);
show_confirmation(_('Deletion Request'),_('Are you sure you want to permanently delete') . ' ' . $access->name,
- 'admin/access.php?action=delete_record&amp;access_id=' . $access->id,1,'delete_access');
- break;
+ 'admin/access.php?action=delete_record&amp;access_id=' . $access->id,1,'delete_access');
+ break;
case 'add_host':
// Make sure we've got a valid form submission
- if (!Core::form_verify('add_acl','post')) {
- access_denied();
- exit;
- }
+ if (!Core::form_verify('add_acl','post')) {
+ access_denied();
+ exit;
+ }
// We need to pre-process this a little bit as stuff is coming in from all over
- switch ($_GET['method']) {
- case 'advanced':
- Access::create($_POST);
- break;
- case 'local':
- $_POST['type'] = 'network';
- Access::create($_POST);
-
+ switch ($_GET['method']) {
+ case 'advanced':
+ Access::create($_POST);
+ break;
+ case 'local':
+ $_POST['type'] = 'network';
+ Access::create($_POST);
+
// Create Additional stuff based on the type
- if ($_POST['addtype'] == 'streamnetwork' OR $_POST['addtype'] == 'allnetwork') {
- $_POST['type'] = 'stream';
- Access::create($_POST);
- }
- if ($_POST['addtype'] == 'allnetwork') {
- $_POST['type'] = 'interface';
- Access::create($_POST);
- }
- break;
- case 'current':
- $_POST['start'] = $_SERVER['REMOTE_ADDR'];
- $_POST['end'] = $_SERVER['REMOTE_ADDR'];
- $_POST['type'] = 'interface';
- Access::create($_POST);
- $_POST['type'] = 'stream';
- Access::create($_POST);
- break;
- case 'rpc':
+ if ($_POST['addtype'] == 'streamnetwork' OR $_POST['addtype'] == 'allnetwork') {
+ $_POST['type'] = 'stream';
+ Access::create($_POST);
+ }
+ if ($_POST['addtype'] == 'allnetwork') {
+ $_POST['type'] = 'interface';
+ Access::create($_POST);
+ }
+ break;
+ case 'current':
+ $_POST['start'] = $_SERVER['REMOTE_ADDR'];
+ $_POST['end'] = $_SERVER['REMOTE_ADDR'];
+ $_POST['type'] = 'interface';
+ Access::create($_POST);
+ $_POST['type'] = 'stream';
+ Access::create($_POST);
+ break;
+ case 'rpc':
$_POST['type'] = 'rpc';
- Access::create($_POST);
+ Access::create($_POST);
// Create Additional stuff based on the type
- if ($_POST['addtype'] == 'streamrpc' OR $_POST['addtype'] == 'allrpc') {
- $_POST['type'] = 'stream';
- Access::create($_POST);
+ if ($_POST['addtype'] == 'streamrpc' OR $_POST['addtype'] == 'allrpc') {
+ $_POST['type'] = 'stream';
+ Access::create($_POST);
}
- if ($_POST['addtype'] == 'allrpc') {
- $_POST['type'] = 'interface';
- Access::create($_POST);
- }
- break;
- default:
+ if ($_POST['addtype'] == 'allrpc') {
+ $_POST['type'] = 'interface';
+ Access::create($_POST);
+ }
+ break;
+ default:
// Do nothing they f'ed something up
- break;
+ break;
} // end switch on method
- if (!Error::occurred()) {
+ if (!Error::occurred()) {
$url = Config::get('web_path') . '/admin/access.php';
show_confirmation(_('Added'),_('Your new Access Control List(s) have been created'),$url);
- }
- else {
- switch ($_GET['method']) {
+ }
+ else {
+ switch ($_GET['method']) {
case 'rpc': require_once Config::get('prefix') . '/templates/show_add_access_rpc.inc.php'; break;
- case 'local': require_once Config::get('prefix') . '/templates/show_add_access_local.inc.php'; break;
+ case 'local': require_once Config::get('prefix') . '/templates/show_add_access_local.inc.php'; break;
case 'current': require_once Config::get('prefix') . '/templates/show_add_access_current.inc.php'; break;
- case 'advanced': require_once Config::get('prefix') . '/templates/show_add_access.inc.php'; break;
- default: require_once Config::get('prefix') . '/templates/show_access_list.inc.php'; break;
- }
- }
+ case 'advanced': require_once Config::get('prefix') . '/templates/show_add_access.inc.php'; break;
+ default: require_once Config::get('prefix') . '/templates/show_access_list.inc.php'; break;
+ }
+ }
break;
case 'update_record':
- if (!Core::form_verify('edit_acl')) {
- access_denied();
- exit;
- }
- $access = new Access($_REQUEST['access_id']);
+ if (!Core::form_verify('edit_acl')) {
+ access_denied();
+ exit;
+ }
+ $access = new Access($_REQUEST['access_id']);
$access->update($_POST);
- if (!Error::occurred()) {
+ if (!Error::occurred()) {
show_confirmation(_('Updated'),_('Access List Entry updated'), Config::get('web_path').'/admin/access.php');
- }
- else {
- $access->format();
- require_once Config::get('prefix') . '/templates/show_edit_access.inc.php';
}
+ else {
+ $access->format();
+ require_once Config::get('prefix') . '/templates/show_edit_access.inc.php';
+ }
+ break;
+ case 'show_add_current':
+ require_once Config::get('prefix') . '/templates/show_add_access_current.inc.php';
+ break;
+ case 'show_add_rpc':
+ require_once Config::get('prefix') . '/templates/show_add_access_rpc.inc.php';
+ break;
+ case 'show_add_local':
+ require_once Config::get('prefix') . '/templates/show_add_access_local.inc.php';
break;
- case 'show_add_current':
- require_once Config::get('prefix') . '/templates/show_add_access_current.inc.php';
- break;
- case 'show_add_rpc':
- require_once Config::get('prefix') . '/templates/show_add_access_rpc.inc.php';
- break;
- case 'show_add_local':
- require_once Config::get('prefix') . '/templates/show_add_access_local.inc.php';
- break;
case 'show_add_advanced':
require_once Config::get('prefix') . '/templates/show_add_access.inc.php';
break;
case 'show_edit_record':
$access = new Access($_REQUEST['access_id']);
- $access->format();
+ $access->format();
require_once Config::get('prefix') . '/templates/show_edit_access.inc.php';
break;
default:
diff --git a/admin/catalog.php b/admin/catalog.php
index 7dcc0f10..9dee29eb 100644
--- a/admin/catalog.php
+++ b/admin/catalog.php
@@ -25,10 +25,10 @@ require_once '../lib/init.php';
if (!Access::check('interface','100')) {
access_denied();
- exit;
+ exit;
}
-show_header();
+show_header();
/* Big switch statement to handle various actions */
switch ($_REQUEST['action']) {
@@ -42,8 +42,8 @@ switch ($_REQUEST['action']) {
$catalog = new Catalog();
$_REQUEST['catalogs'] = $catalog->get_catalog_ids();
case 'add_to_catalog':
- toggle_visible('ajax-loading');
- ob_end_flush();
+ toggle_visible('ajax-loading');
+ ob_end_flush();
if (Config::get('demo_mode')) { break; }
if ($_REQUEST['catalogs'] ) {
foreach ($_REQUEST['catalogs'] as $catalog_id) {
@@ -55,19 +55,19 @@ switch ($_REQUEST['action']) {
$title = _('Catalog Updated');
$body = '';
show_confirmation($title,$body,$url);
- toggle_visible('ajax-loading');
+ toggle_visible('ajax-loading');
break;
case 'update_all_catalogs':
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
case 'update_catalog':
- toggle_visible('ajax-loading');
- ob_end_flush();
+ toggle_visible('ajax-loading');
+ ob_end_flush();
/* If they are in demo mode stop here */
if (Config::get('demo_mode')) { break; }
if (isset($_REQUEST['catalogs'])) {
foreach ($_REQUEST['catalogs'] as $catalog_id) {
- $catalog = new Catalog($catalog_id);
+ $catalog = new Catalog($catalog_id);
$catalog->verify_catalog($catalog_id);
}
}
@@ -75,59 +75,59 @@ switch ($_REQUEST['action']) {
$title = _('Catalog Updated');
$body = '';
show_confirmation($title,$body,$url);
- toggle_visible('ajax-loading');
+ toggle_visible('ajax-loading');
break;
case 'full_service':
- toggle_visible('ajax-loading');
- ob_end_flush();
+ toggle_visible('ajax-loading');
+ ob_end_flush();
/* Make sure they aren't in demo mode */
- if (Config::get('demo_mode')) { access_denied(); break; }
+ if (Config::get('demo_mode')) { access_denied(); break; }
- if (!$_REQUEST['catalogs']) {
+ if (!$_REQUEST['catalogs']) {
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
}
/* This runs the clean/verify/add in that order */
- foreach ($_REQUEST['catalogs'] as $catalog_id) {
+ foreach ($_REQUEST['catalogs'] as $catalog_id) {
$catalog = new Catalog($catalog_id);
$catalog->clean_catalog($catalog_id);
$catalog->count = 0;
$catalog->verify_catalog($catalog_id);
$catalog->count = 0;
$catalog->add_to_catalog($catalog_id);
- }
+ }
$url = Config::get('web_path') . '/admin/catalog.php';
$title = _('Catalog Updated');
$body = '';
show_confirmation($title,$body,$url);
- toggle_visible('ajax-loading');
+ toggle_visible('ajax-loading');
break;
case 'delete_catalog':
/* Make sure they aren't in demo mode */
if (Config::get('demo_mode')) { break; }
- if (!Core::form_verify('delete_catalog')) {
- access_denied();
- exit;
- }
-
+ if (!Core::form_verify('delete_catalog')) {
+ access_denied();
+ exit;
+ }
+
/* Delete the sucker, we don't need to check perms as thats done above */
- Catalog::delete($_GET['catalog_id']);
+ Catalog::delete($_GET['catalog_id']);
$next_url = Config::get('web_path') . '/admin/catalog.php';
show_confirmation(_('Catalog Deleted'),_('The Catalog and all associated records have been deleted'),$next_url);
break;
- case 'show_delete_catalog':
- $catalog_id = scrub_in($_GET['catalog_id']);
+ case 'show_delete_catalog':
+ $catalog_id = scrub_in($_GET['catalog_id']);
- $next_url = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($catalog_id);
- show_confirmation(_('Catalog Delete'),_('Confirm Deletion Request'),$next_url,1,'delete_catalog');
- break;
+ $next_url = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($catalog_id);
+ show_confirmation(_('Catalog Delete'),_('Confirm Deletion Request'),$next_url,1,'delete_catalog');
+ break;
case 'remove_disabled':
if (conf('demo_mode')) { break; }
$song = $_REQUEST['song'];
- if (count($song)) {
+ if (count($song)) {
$catalog->remove_songs($song);
$body = ngettext('Song Removed', 'Songs Removed', count($song));
}
@@ -139,27 +139,27 @@ switch ($_REQUEST['action']) {
show_confirmation($title,$body,$url);
break;
case 'clean_all_catalogs':
- $catalog = new Catalog();
+ $catalog = new Catalog();
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
case 'clean_catalog':
- toggle_visible('ajax-loading');
- ob_end_flush();
+ toggle_visible('ajax-loading');
+ ob_end_flush();
/* If they are in demo mode stop them here */
if (Config::get('demo_mode')) { break; }
-
+
// Make sure they checked something
- if (isset($_REQUEST['catalogs'])) {
- foreach($_REQUEST['catalogs'] as $catalog_id) {
+ if (isset($_REQUEST['catalogs'])) {
+ foreach($_REQUEST['catalogs'] as $catalog_id) {
$catalog = new Catalog($catalog_id);
$catalog->clean_catalog(0,1);
} // end foreach catalogs
}
-
+
$url = Config::get('web_path') . '/admin/catalog.php';
$title = _('Catalog Cleaned');
$body = '';
show_confirmation($title,$body,$url);
- toggle_visible('ajax-loading');
+ toggle_visible('ajax-loading');
break;
case 'update_catalog_settings':
/* No Demo Here! */
@@ -167,82 +167,82 @@ switch ($_REQUEST['action']) {
/* Update the catalog */
Catalog::update_settings($_REQUEST);
-
+
$url = Config::get('web_path') . '/admin/catalog.php';
$title = _('Catalog Updated');
$body = '';
show_confirmation($title,$body,$url);
break;
- case 'update_from':
- if (Config::get('demo_mode')) { break; }
+ case 'update_from':
+ if (Config::get('demo_mode')) { break; }
// First see if we need to do an add
- if ($_POST['add_path'] != '/' AND strlen($_POST['add_path'])) {
- if ($catalog_id = Catalog::get_from_path($_POST['add_path'])) {
- $catalog = new Catalog($catalog_id);
- $catalog->run_add(array('subdirectory'=>$_POST['add_path']));
- }
+ if ($_POST['add_path'] != '/' AND strlen($_POST['add_path'])) {
+ if ($catalog_id = Catalog::get_from_path($_POST['add_path'])) {
+ $catalog = new Catalog($catalog_id);
+ $catalog->run_add(array('subdirectory'=>$_POST['add_path']));
+ }
} // end if add
-
+
// Now check for an update
- if ($_POST['update_path'] != '/' AND strlen($_POST['update_path'])) {
- if ($catalog_id = Catalog::get_from_path($_POST['update_path'])) {
- $songs = Song::get_from_path($_POST['update_path']);
- foreach ($songs as $song_id) { Catalog::update_single_item('song',$song_id); }
- }
+ if ($_POST['update_path'] != '/' AND strlen($_POST['update_path'])) {
+ if ($catalog_id = Catalog::get_from_path($_POST['update_path'])) {
+ $songs = Song::get_from_path($_POST['update_path']);
+ foreach ($songs as $song_id) { Catalog::update_single_item('song',$song_id); }
+ }
} // end if update
- break;
+ break;
case 'add_catalog':
/* Wah Demo! */
if (Config::get('demo_mode')) { break; }
- ob_end_flush();
+ ob_end_flush();
- if (!strlen($_POST['path']) || !strlen($_POST['name'])) {
- Error::add('general',_('Error: Name and path not specified'));
- }
+ if (!strlen($_POST['path']) || !strlen($_POST['name'])) {
+ Error::add('general',_('Error: Name and path not specified'));
+ }
- if (substr($_POST['path'],0,7) != 'http://' && $_POST['type'] == 'remote') {
+ if (substr($_POST['path'],0,7) != 'http://' && $_POST['type'] == 'remote') {
Error::add('general',_('Error: Remote selected, but path is not a URL'));
- }
-
- if ($_POST['type'] == 'remote' && !strlen($_POST['key'])) {
+ }
+
+ if ($_POST['type'] == 'remote' && !strlen($_POST['key'])) {
Error::add('general',_('Error: Remote Catalog specified, but no key provided'));
- }
+ }
- if (!Core::form_verify('add_catalog','post')) {
- access_denied();
- exit;
- }
+ if (!Core::form_verify('add_catalog','post')) {
+ access_denied();
+ exit;
+ }
// Make sure that there isn't a catalog with a directory above this one
- if (Catalog::get_from_path($_POST['path'])) {
+ if (Catalog::get_from_path($_POST['path'])) {
Error::add('general',_('Error: Defined Path is inside an existing catalog'));
- }
+ }
// If an error hasn't occured
- if (!Error::occurred()) {
+ if (!Error::occurred()) {
- $catalog_id = Catalog::Create($_POST);
+ $catalog_id = Catalog::Create($_POST);
- if (!$catalog_id) {
- require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
- break;
+ if (!$catalog_id) {
+ require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
+ break;
}
- $catalog = new Catalog($catalog_id);
+ $catalog = new Catalog($catalog_id);
// Run our initial add
- $catalog->run_add($_POST);
+ $catalog->run_add($_POST);
- show_box_top();
+ show_box_top();
echo "<h2>" . _('Catalog Created') . "</h2>";
- Error::display('general');
- Error::display('catalog_add');
- show_box_bottom();
+ Error::display('general');
+ Error::display('catalog_add');
+ show_box_bottom();
- show_confirmation('','', Config::get('web_path').'/admin/catalog.php');
+ show_confirmation('','', Config::get('web_path').'/admin/catalog.php');
}
else {
@@ -251,16 +251,16 @@ switch ($_REQUEST['action']) {
break;
case 'clear_stats':
if (Config::get('demo_mode')) { access_denied(); break; }
-
- Catalog::clear_stats();
+
+ Catalog::clear_stats();
$url = Config::get('web_path') . '/admin/catalog.php';
$title = _('Catalog statistics cleared');
$body = '';
show_confirmation($title,$body,$url);
break;
- default:
- case 'show_catalogs':
- require_once Config::get('prefix') . '/templates/show_manage_catalogs.inc.php';
+ default:
+ case 'show_catalogs':
+ require_once Config::get('prefix') . '/templates/show_manage_catalogs.inc.php';
break;
case 'show_add_catalog':
require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
@@ -273,9 +273,9 @@ switch ($_REQUEST['action']) {
case 'show_disabled':
/* Stop the demo hippies */
if (conf('demo_mode')) { break; }
-
+
$songs = $catalog->get_disabled();
- if (count($songs)) {
+ if (count($songs)) {
require (conf('prefix') . '/templates/show_disabled_songs.inc.php');
}
else {
@@ -284,27 +284,27 @@ switch ($_REQUEST['action']) {
break;
case 'show_delete_catalog':
/* Stop the demo hippies */
- if (Config::get('demo_mode')) { access_denied(); break; }
+ if (Config::get('demo_mode')) { access_denied(); break; }
- $catalog = new Catalog($_REQUEST['catalog_id']);
+ $catalog = new Catalog($_REQUEST['catalog_id']);
$nexturl = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&amp;catalog_id=' . scrub_out($_REQUEST['catalog_id']);
show_confirmation(_('Delete Catalog'),_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1);
break;
case 'show_customize_catalog':
- $catalog = new Catalog($_REQUEST['catalog_id']);
+ $catalog = new Catalog($_REQUEST['catalog_id']);
require_once Config::get('prefix') . '/templates/show_edit_catalog.inc.php';
break;
case 'gather_album_art':
- toggle_visible('ajax-loading');
- ob_end_flush();
+ toggle_visible('ajax-loading');
+ ob_end_flush();
$catalogs = $_REQUEST['catalogs'] ? $_REQUEST['catalogs'] : Catalog::get_catalogs();
// Itterate throught the catalogs and gather as needed
- foreach ($catalogs as $catalog_id) {
+ foreach ($catalogs as $catalog_id) {
$catalog = new Catalog($catalog_id);
- require Config::get('prefix') . '/templates/show_gather_art.inc.php';
- flush();
+ require Config::get('prefix') . '/templates/show_gather_art.inc.php';
+ flush();
$catalog->get_album_art('',1);
}
$url = Config::get('web_path') . '/admin/catalog.php';
diff --git a/admin/duplicates.php b/admin/duplicates.php
index d61f5170..e2f82815 100644
--- a/admin/duplicates.php
+++ b/admin/duplicates.php
@@ -22,22 +22,22 @@
require_once '../lib/init.php';
-if (!Access::check('interface','100')) {
- access_denied();
+if (!Access::check('interface','100')) {
+ access_denied();
exit;
}
-show_header();
+show_header();
/* Switch on Action */
switch ($_REQUEST['action']) {
case 'find_duplicates':
- $duplicates = Catalog::get_duplicate_songs($_REQUEST['search_type']);
- require_once Config::get('prefix') . '/templates/show_duplicate.inc.php';
- require_once Config::get('prefix') . '/templates/show_duplicates.inc.php';
+ $duplicates = Catalog::get_duplicate_songs($_REQUEST['search_type']);
+ require_once Config::get('prefix') . '/templates/show_duplicate.inc.php';
+ require_once Config::get('prefix') . '/templates/show_duplicates.inc.php';
break;
default:
- require_once Config::get('prefix') . '/templates/show_duplicate.inc.php';
+ require_once Config::get('prefix') . '/templates/show_duplicate.inc.php';
break;
} // end switch on action
diff --git a/admin/export.php b/admin/export.php
index 4e423647..7b22cd8c 100644
--- a/admin/export.php
+++ b/admin/export.php
@@ -22,24 +22,24 @@
require_once '../lib/init.php';
-if (!Access::check('interface','100')) {
- access_denied();
+if (!Access::check('interface','100')) {
+ access_denied();
exit;
}
-show_header();
+show_header();
/* Switch on Action */
switch ($_REQUEST['action']) {
case 'export':
-
+
// This may take a while
- set_time_limit(0);
-
+ set_time_limit(0);
+
$catalog = new Catalog($_REQUEST['export_catalog']);
// Clear everything we've done so far
- ob_end_clean();
+ ob_end_clean();
// This will disable buffering so contents are sent immediately to browser.
// This is very useful for large catalogs because it will immediately display the download dialog to user,
@@ -49,7 +49,7 @@ switch ($_REQUEST['action']) {
header("Content-Transfer-Encoding: binary");
header("Cache-control: public");
- $date = date("d/m/Y",time());
+ $date = date("d/m/Y",time());
switch($_REQUEST['export_format']) {
case 'itunes':
@@ -57,19 +57,19 @@ switch ($_REQUEST['action']) {
header("Content-Disposition: attachment; filename=\"ampache-itunes-$date.xml\"");
$catalog->export('itunes');
break;
- case 'csv':
- header("Content-Type: application/vnd.ms-excel");
- header("Content-Disposition: filename=\"ampache-export-$date.csv\"");
- $catalog->export('csv');
- break;
- } // end switch on format
+ case 'csv':
+ header("Content-Type: application/vnd.ms-excel");
+ header("Content-Disposition: filename=\"ampache-export-$date.csv\"");
+ $catalog->export('csv');
+ break;
+ } // end switch on format
// We don't want the footer so we're done here
- exit;
-
+ exit;
+
break;
default:
- require_once Config::get('prefix') . '/templates/show_export.inc.php';
+ require_once Config::get('prefix') . '/templates/show_export.inc.php';
break;
} // end switch on action
diff --git a/admin/flag.php b/admin/flag.php
index 79d9c81b..1d419421 100644
--- a/admin/flag.php
+++ b/admin/flag.php
@@ -21,52 +21,52 @@
*/
require '../lib/init.php';
-if (!Access::check('interface','100')) {
+if (!Access::check('interface','100')) {
access_denied();
exit();
}
-show_header();
+show_header();
switch ($_REQUEST['action']) {
case 'edit_song':
$catalog = new Catalog();
$song = new Song($_REQUEST['song_id']);
$new_song = new Song();
-
- /* Setup the vars so we can use the update_song function */
+
+ /* Setup the vars so we can use the update_song function */
$new_song->title = revert_string(scrub_in($_REQUEST['title']));
$new_song->track = revert_string(scrub_in($_REQUEST['track']));
$new_song->year = revert_string(scrub_in($_REQUEST['year']));
$new_song->comment = revert_string(scrub_in($_REQUEST['comment']));
/* If no change in string take Drop down */
- if (strcasecmp(stripslashes($_REQUEST['genre_string']),$song->get_genre_name()) == 0) {
+ if (strcasecmp(stripslashes($_REQUEST['genre_string']),$song->get_genre_name()) == 0) {
$genre = $song->get_genre_name($_REQUEST['genre']);
}
- else {
+ else {
$genre = scrub_in($_REQUEST['genre_string']);
}
-
- if (strcasecmp(stripslashes($_REQUEST['album_string']),$song->get_album_name()) == 0) {
+
+ if (strcasecmp(stripslashes($_REQUEST['album_string']),$song->get_album_name()) == 0) {
$album = $song->get_album_name($_REQUEST['album']);
}
- else {
+ else {
$album = scrub_in($_REQUEST['album_string']);
}
-
- if (strcasecmp(stripslashes($_REQUEST['artist_string']),$song->get_artist_name()) == 0) {
+
+ if (strcasecmp(stripslashes($_REQUEST['artist_string']),$song->get_artist_name()) == 0) {
$artist = $song->get_artist_name($_REQUEST['artist']);
}
- else {
+ else {
$artist = scrub_in($_REQUEST['artist_string']);
}
-
+
/* Use the check functions to get / create ids for this info */
$new_song->genre = $catalog->check_genre(revert_string($genre));
$new_song->album = $catalog->check_album(revert_string($album));
$new_song->artist = $catalog->check_artist(revert_string($artist));
-
+
/* Update this mofo, store an old copy for cleaning */
$old_song = new Song();
$old_song->artist = $song->artist;
@@ -75,129 +75,129 @@ switch ($_REQUEST['action']) {
$song->update_song($song->id,$new_song);
/* Now that it's been updated clean old junk entries */
- $catalog = new Catalog();
+ $catalog = new Catalog();
$cleaned = $catalog->clean_single_song($old_song);
-
+
/* Add a tagging record of this so we can fix the file */
- if ($_REQUEST['flag']) {
+ if ($_REQUEST['flag']) {
$flag = new Flag();
$flag->add($song->id,'song','retag','Edited Song, auto-tag');
}
- if (isset($cleaned['artist']) || isset($cleaned['album'])) { $_SESSION['source'] = Config::get('web_path') . '/index.php'; }
-
+ if (isset($cleaned['artist']) || isset($cleaned['album'])) { $_SESSION['source'] = Config::get('web_path') . '/index.php'; }
+
show_confirmation(_('Song Updated'),_('The requested song has been updated'),$_SESSION['source']);
break;
// Show the page for editing a full album
case 'show_edit_album':
- $album = new Album($_REQUEST['album_id']);
-
- require_once(conf('prefix') . '/templates/show_edit_album.inc.php');
+ $album = new Album($_REQUEST['album_id']);
+
+ require_once(conf('prefix') . '/templates/show_edit_album.inc.php');
break;
// Update all songs from this album
case 'edit_album':
-
- // Build the needed album
- $album = new Album($_REQUEST['album_id']);
- // Create the needed catalog object cause we can't do
- // static class methods :(
- $catalog = new Catalog();
- $flag = new Flag();
+ // Build the needed album
+ $album = new Album($_REQUEST['album_id']);
+
+ // Create the needed catalog object cause we can't do
+ // static class methods :(
+ $catalog = new Catalog();
+ $flag = new Flag();
/* Check the new Name */
- $album_id = $catalog->check_album($_REQUEST['name'],$_REQUEST['year']);
+ $album_id = $catalog->check_album($_REQUEST['name'],$_REQUEST['year']);
- $songs = $album->get_songs();
+ $songs = $album->get_songs();
- foreach ($songs as $song) {
- // Make that copy and change the album
+ foreach ($songs as $song) {
+ // Make that copy and change the album
$new_song = $song;
$new_song->album = $album_id;
$song->update_song($song->id,$new_song);
- if ($_REQUEST['flag'] == '1') {
+ if ($_REQUEST['flag'] == '1') {
$flag->add($song->id,'song','retag','Edited Song, auto-tag');
- }
+ }
} // end foreach songs
- // Clean out the old album
+ // Clean out the old album
$catalog->clean_albums();
- show_confirmation(_('Album Updated'),'',Config::get('web_path') . '/admin/index.php');
+ show_confirmation(_('Album Updated'),'',Config::get('web_path') . '/admin/index.php');
break;
// Show the page for editing a full artist
case 'show_edit_artist':
- $artist = new Artist($_REQUEST['artist_id']);
+ $artist = new Artist($_REQUEST['artist_id']);
- require_once(conf('prefix') . '/templates/show_edit_artist.inc.php');
+ require_once(conf('prefix') . '/templates/show_edit_artist.inc.php');
break;
// Update all songs by this artist
case 'edit_artist':
// Build the needed artist
- $artist = new Artist($_REQUEST['artist_id']);
+ $artist = new Artist($_REQUEST['artist_id']);
// Create the needed objects, a pox on PHP4
- $catalog = new Catalog();
- $flag = new Flag();
+ $catalog = new Catalog();
+ $flag = new Flag();
/* Check the new Name */
- $artist_id = $catalog->check_artist($_REQUEST['name']);
+ $artist_id = $catalog->check_artist($_REQUEST['name']);
- $songs = $artist->get_songs();
+ $songs = $artist->get_songs();
- foreach ($songs as $song) {
+ foreach ($songs as $song) {
// Make that copy and change the artist
- $new_song = $song;
- $new_song->artist = $artist_id;
-
- $song->update_song($song->id,$new_song);
+ $new_song = $song;
+ $new_song->artist = $artist_id;
- if ($_REQUEST['flag'] == '1') {
- $flag->add($song->id,'song','retag','Edited Song, auto-tag');
- }
+ $song->update_song($song->id,$new_song);
+
+ if ($_REQUEST['flag'] == '1') {
+ $flag->add($song->id,'song','retag','Edited Song, auto-tag');
+ }
} // end foreach songs
// Clean out the old artist(s)
- $catalog->clean_artists();
+ $catalog->clean_artists();
show_confirmation(_('Artist Updated'),'',Config::get('web_path') . '/admin/index.php');
- break;
+ break;
/* Done by 'Select' code passes array of song ids */
- case 'mass_update':
- $songs = $_REQUEST['song'];
+ case 'mass_update':
+ $songs = $_REQUEST['song'];
$catalog = new Catalog();
- $object = $_REQUEST['update_field'];
- $flag = new Flag();
+ $object = $_REQUEST['update_field'];
+ $flag = new Flag();
/* If this is an album we need to pull the songs */
- if ($_REQUEST['type'] == 'album') {
+ if ($_REQUEST['type'] == 'album') {
- // Define the results array
- $results = array();
+ // Define the results array
+ $results = array();
- foreach ($songs as $album_id) {
- $album = new Album($album_id);
- $results = array_merge($results,$album->get_song_ids());
+ foreach ($songs as $album_id) {
+ $album = new Album($album_id);
+ $results = array_merge($results,$album->get_song_ids());
} // end foreach albums
- // Re-assign the variable... HACK ALERT :(
- $songs = $results;
+ // Re-assign the variable... HACK ALERT :(
+ $songs = $results;
- } // is album
+ } // is album
/* Foreach the songs we need to update */
- foreach ($songs as $song_id) {
+ foreach ($songs as $song_id) {
$new_song = new Song($song_id);
$old_song = new Song();
@@ -206,21 +206,21 @@ switch ($_REQUEST['action']) {
$old_song->genre = $new_song->genre;
/* Restrict which fields can be updated */
- switch ($object) {
- case 'genre':
- $new_song->genre = $catalog->check_genre(revert_string($_REQUEST['update_value']));
+ switch ($object) {
+ case 'genre':
+ $new_song->genre = $catalog->check_genre(revert_string($_REQUEST['update_value']));
break;
case 'album':
- $new_song->album = $catalog->check_album(revert_string($_REQUEST['update_value']));
+ $new_song->album = $catalog->check_album(revert_string($_REQUEST['update_value']));
break;
case 'artist':
- $new_song->artist = $catalog->check_artist(revert_string($_REQUEST['update_value']));
- break;
+ $new_song->artist = $catalog->check_artist(revert_string($_REQUEST['update_value']));
+ break;
case 'year':
- $new_song->year = intval($_REQUEST['update_value']);
+ $new_song->year = intval($_REQUEST['update_value']);
break;
- default:
- // Rien a faire
+ default:
+ // Rien a faire
break;
} // end switch
@@ -235,14 +235,14 @@ switch ($_REQUEST['action']) {
} // end foreach songs
// Show a confirmation that this worked
- show_confirmation(_('Songs Updated'),'',return_referer());
- break;
+ show_confirmation(_('Songs Updated'),'',return_referer());
+ break;
case 'reject_flag':
$flag_id = scrub_in($_REQUEST['flag_id']);
$flag = new Flag($flag_id);
- $flag->delete_flag();
+ $flag->delete_flag();
$flag->format_name();
- $url = return_referer();
+ $url = return_referer();
$title = _('Flag Removed');
$body = _('Flag Removed from') . " " . $flag->name;
show_confirmation($title,$body,$url);
@@ -250,22 +250,22 @@ switch ($_REQUEST['action']) {
case 'reject_flags':
$flags = $_REQUEST['song'];
- foreach ($flags as $flag_id) {
- $flag = new Flag($flag_id);
- if ($_REQUEST['update_action'] == 'reject') {
- $flag->delete_flag();
- }
- else {
- $flag->approve();
- }
+ foreach ($flags as $flag_id) {
+ $flag = new Flag($flag_id);
+ if ($_REQUEST['update_action'] == 'reject') {
+ $flag->delete_flag();
+ }
+ else {
+ $flag->approve();
+ }
} // end foreach flags
- $title = _('Flags Updated');
- show_confirmation($title,'',return_referer());
+ $title = _('Flags Updated');
+ show_confirmation($title,'',return_referer());
break;
case 'show_edit_song':
$_SESSION['source'] = return_referer();
$song = new Song($_REQUEST['song']);
- $song->fill_ext_info();
+ $song->fill_ext_info();
$song->format_song();
require_once (conf('prefix') . '/templates/show_edit_song.inc.php');
break;
@@ -291,20 +291,20 @@ switch ($_REQUEST['action']) {
} // end else
show_confirmation(_('Songs Enabled'),_('The requested song(s) have been enabled'),return_referer());
break;
- case 'show_disabled':
- $disabled = Flag::get_disabled();
- Browse::set_type('song');
- Browse::set_static_content(1);
- Browse::save_objects($disabled);
- Browse::show_objects($disabled);
- break;
+ case 'show_disabled':
+ $disabled = Flag::get_disabled();
+ Browse::set_type('song');
+ Browse::set_static_content(1);
+ Browse::save_objects($disabled);
+ Browse::show_objects($disabled);
+ break;
default:
case 'show_flagged':
$flagged = Flag::get_all();
- Flag::build_cache($flagged);
- Browse::set_type('flagged');
+ Flag::build_cache($flagged);
+ Browse::set_type('flagged');
Browse::set_static_content(1);
- Browse::save_objects($flagged);
+ Browse::save_objects($flagged);
Browse::show_objects($flagged);
break;
} // end switch
diff --git a/admin/index.php b/admin/index.php
index 24f358ad..ccb77661 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -22,21 +22,21 @@
require '../lib/init.php';
-if (!Access::check('interface',100)) {
+if (!Access::check('interface',100)) {
access_denied();
exit();
}
-show_header();
+show_header();
-switch ($_REQUEST['action']) {
- default:
+switch ($_REQUEST['action']) {
+ default:
// Show Catalogs
- $catalog_ids = Catalog::get_catalogs();
- Browse::set_type('catalog');
- Browse::show_objects($catalog_ids);
+ $catalog_ids = Catalog::get_catalogs();
+ Browse::set_type('catalog');
+ Browse::show_objects($catalog_ids);
break;
-}
+}
-show_footer();
+show_footer();
?>
diff --git a/admin/mail.php b/admin/mail.php
index e1eaf0c2..18bcb100 100644
--- a/admin/mail.php
+++ b/admin/mail.php
@@ -22,20 +22,20 @@
require_once '../lib/init.php';
-if (!Access::check('interface','75')) {
+if (!Access::check('interface','75')) {
access_denied();
exit();
}
-show_header();
+show_header();
// Action switch
-switch ($_REQUEST['action']) {
+switch ($_REQUEST['action']) {
case 'send_mail':
- if (Config::get('demo_mode')) {
- access_denied();
+ if (Config::get('demo_mode')) {
+ access_denied();
exit;
- }
+ }
// Multi-byte Character Mail
if(function_exists('mb_language')) {
@@ -43,21 +43,21 @@ switch ($_REQUEST['action']) {
mb_language("uni");
}
- $clients = AmpacheMail::get_users($_REQUEST['to']);
+ $clients = AmpacheMail::get_users($_REQUEST['to']);
- foreach ($clients as $client) {
+ foreach ($clients as $client) {
if(function_exists('mb_encode_mimeheader')) {
$recipient .= mb_encode_mimeheader($client['fullname']) ." <" . $client['email'] . ">, ";
} else {
$recipient .= $client['fullname'] ." <" . $client['email'] . ">, ";
}
}
-
+
// Remove the last , from the recipient
$recipient = rtrim($recipient,", ");
-
+
// Set the vars on the object
- AmpacheMail::$recipient = $recipient;
+ AmpacheMail::$recipient = $recipient;
if(function_exists('mb_encode_mimeheader')) {
AmpacheMail::$fullname = mb_encode_mimeheader($GLOBALS['user']->fullname);
} else {
@@ -77,16 +77,16 @@ switch ($_REQUEST['action']) {
/* Confirmation Send */
$url = Config::get('web_path') . '/admin/mail.php';
- $title = _('E-mail Sent');
+ $title = _('E-mail Sent');
$body = _('Your E-mail was successfully sent.');
show_confirmation($title,$body,$url);
break;
- default:
+ default:
require_once Config::get('prefix') . '/templates/show_mail_users.inc.php';
break;
} // end switch
-show_footer();
+show_footer();
?>
diff --git a/admin/modules.php b/admin/modules.php
index 5f3270d1..fd1e14b9 100644
--- a/admin/modules.php
+++ b/admin/modules.php
@@ -30,40 +30,40 @@ if (!$GLOBALS['user']->has_access(100)) {
/* Always show the header */
-show_header();
-
-switch ($_REQUEST['action']) {
- case 'install_localplay':
- $localplay = new Localplay($_REQUEST['type']);
- if (!$localplay->player_loaded()) {
- Error::add('general',_('Install Failed, Controller Error'));
- Error::display('general');
+show_header();
+
+switch ($_REQUEST['action']) {
+ case 'install_localplay':
+ $localplay = new Localplay($_REQUEST['type']);
+ if (!$localplay->player_loaded()) {
+ Error::add('general',_('Install Failed, Controller Error'));
+ Error::display('general');
break;
- }
+ }
// Install it!
- $localplay->install();
+ $localplay->install();
// Go ahead and enable Localplay (Admin->System) as we assume they want to do that
// if they are enabling this
- Preference::update('allow_localplay_playback','-1','1');
- Preference::update('localplay_level',$GLOBALS['user']->id,'100');
+ Preference::update('allow_localplay_playback','-1','1');
+ Preference::update('localplay_level',$GLOBALS['user']->id,'100');
Preference::update('localplay_controller',$GLOBALS['user']->id,$localplay->type);
- header("Location:" . Config::get('web_path') . '/admin/modules.php?action=show_localplay');
+ header("Location:" . Config::get('web_path') . '/admin/modules.php?action=show_localplay');
break;
- case 'confirm_uninstall_localplay':
- $type = scrub_in($_REQUEST['type']);
- $url = Config::get('web_path') . '/admin/modules.php?action=uninstall_localplay&amp;type=' . $type;
- $title = _('Are you sure you want to remove this plugin?');
- $body = '';
- show_confirmation($title,$body,$url,1);
+ case 'confirm_uninstall_localplay':
+ $type = scrub_in($_REQUEST['type']);
+ $url = Config::get('web_path') . '/admin/modules.php?action=uninstall_localplay&amp;type=' . $type;
+ $title = _('Are you sure you want to remove this plugin?');
+ $body = '';
+ show_confirmation($title,$body,$url,1);
break;
- case 'uninstall_localplay':
- $type = scrub_in($_REQUEST['type']);
+ case 'uninstall_localplay':
+ $type = scrub_in($_REQUEST['type']);
+
+ $localplay = new Localplay($type);
+ $localplay->uninstall();
- $localplay = new Localplay($type);
- $localplay->uninstall();
-
/* Show Confirmation */
$url = Config::get('web_path') . '/admin/modules.php?action=show_localplay';
$title = _('Plugin Deactivated');
@@ -72,49 +72,49 @@ switch ($_REQUEST['action']) {
break;
case 'install_plugin':
/* Verify that this plugin exists */
- $plugins = Plugin::get_plugins();
- if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
- debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
+ $plugins = Plugin::get_plugins();
+ if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
+ debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
break;
}
- $plugin = new Plugin($_REQUEST['plugin']);
- if (!$plugin->install()) {
- debug_event('plugins','Error: Plugin Install Failed, ' . $_REQUEST['plugin'],'1');
+ $plugin = new Plugin($_REQUEST['plugin']);
+ if (!$plugin->install()) {
+ debug_event('plugins','Error: Plugin Install Failed, ' . $_REQUEST['plugin'],'1');
$url = Config::get('web_path') . '/admin/modules.php?action=show_plugins';
- $title = _('Unable to Install Plugin');
- $body = '';
- show_confirmation($title,$body,$url);
- break;
- }
+ $title = _('Unable to Install Plugin');
+ $body = '';
+ show_confirmation($title,$body,$url);
+ break;
+ }
// Don't trust the plugin to this stuff
- User::rebuild_all_preferences();
-
+ User::rebuild_all_preferences();
+
/* Show Confirmation */
$url = Config::get('web_path') . '/admin/modules.php?action=show_plugins';
- $title = _('Plugin Activated');
+ $title = _('Plugin Activated');
$body = '';
- show_confirmation($title,$body,$url);
+ show_confirmation($title,$body,$url);
break;
case 'confirm_uninstall_plugin':
- $plugin = scrub_in($_REQUEST['plugin']);
+ $plugin = scrub_in($_REQUEST['plugin']);
$url = Config::get('web_path') . '/admin/modules.php?action=uninstall_plugin&amp;plugin=' . $plugin;
- $title = _('Are you sure you want to remove this plugin?');
+ $title = _('Are you sure you want to remove this plugin?');
$body = '';
- show_confirmation($title,$body,$url,1);
- break;
+ show_confirmation($title,$body,$url,1);
+ break;
case 'uninstall_plugin':
/* Verify that this plugin exists */
- $plugins = Plugin::get_plugins();
+ $plugins = Plugin::get_plugins();
if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
break;
}
$plugin = new Plugin($_REQUEST['plugin']);
- $plugin->uninstall();
+ $plugin->uninstall();
// Don't trust the plugin to do it
- User::rebuild_all_preferences();
+ User::rebuild_all_preferences();
/* Show Confirmation */
$url = Config::get('web_path') . '/admin/modules.php?action=show_plugins';
@@ -125,23 +125,23 @@ switch ($_REQUEST['action']) {
case 'upgrade_plugin':
break;
- case 'show_plugins':
- $plugins = Plugin::get_plugins();
- show_box_top(_('Plugins'));
- require_once Config::get('prefix') . '/templates/show_plugins.inc.php';
- show_box_bottom();
+ case 'show_plugins':
+ $plugins = Plugin::get_plugins();
+ show_box_top(_('Plugins'));
+ require_once Config::get('prefix') . '/templates/show_plugins.inc.php';
+ show_box_bottom();
break;
- case 'show_localplay':
- $controllers = Localplay::get_controllers();
- show_box_top(_('Localplay Controllers'));
- require_once Config::get('prefix') . '/templates/show_localplay_controllers.inc.php';
- show_box_bottom();
+ case 'show_localplay':
+ $controllers = Localplay::get_controllers();
+ show_box_top(_('Localplay Controllers'));
+ require_once Config::get('prefix') . '/templates/show_localplay_controllers.inc.php';
+ show_box_bottom();
break;
- default:
+ default:
// Rien a faire
break;
} // end switch
-show_footer();
+show_footer();
?>
diff --git a/admin/shout.php b/admin/shout.php
index 31b7405a..b88ab1c1 100644
--- a/admin/shout.php
+++ b/admin/shout.php
@@ -26,18 +26,18 @@ if (!Access::check('interface','100')) {
exit;
}
-show_header();
+show_header();
// Switch on the incomming action
-switch ($_REQUEST['action']) {
- case 'edit_shout':
- $shout_id = $_POST['shout_id'];
- $update = shoutBox::update($_POST);
+switch ($_REQUEST['action']) {
+ case 'edit_shout':
+ $shout_id = $_POST['shout_id'];
+ $update = shoutBox::update($_POST);
show_confirmation(_('Shoutbox Post Updated'),'',Config::get('web_path').'/admin/shout.php');
- break;
+ break;
case 'show_edit':
$shout = new shoutBox($_REQUEST['shout_id']);
- $object = shoutBox::get_object($shout->object_type,$shout->object_id);
+ $object = shoutBox::get_object($shout->object_type,$shout->object_id);
$object->format();
$client = new User($shout->user);
$client->format();
@@ -48,12 +48,12 @@ switch ($_REQUEST['action']) {
show_confirmation(_('Shoutbox Post Deleted'),'',Config::get('web_path').'/admin/shout.php');
break;
default:
- Browse::set_type('shoutbox');
- Browse::set_simple_browse(1);
- $shoutbox_ids = Browse::get_objects();
- Browse::show_objects($shoutbox_ids);
- break;
+ Browse::set_type('shoutbox');
+ Browse::set_simple_browse(1);
+ $shoutbox_ids = Browse::get_objects();
+ Browse::show_objects($shoutbox_ids);
+ break;
} // end switch on action
-show_footer();
+show_footer();
?>
diff --git a/admin/system.php b/admin/system.php
index 85cf143e..c986cb51 100644
--- a/admin/system.php
+++ b/admin/system.php
@@ -29,35 +29,35 @@ if (!Access::check('interface',100) OR Config::get('demo_mode')) {
exit();
}
-show_header();
+show_header();
/* Switch on action boys */
-switch ($_REQUEST['action']) {
+switch ($_REQUEST['action']) {
/* This re-generates the config file comparing
* /config/ampache.cfg to .cfg.dist
*/
case 'generate_config':
- ob_end_clean();
+ ob_end_clean();
$current = parse_ini_file(Config::get('prefix') . '/config/ampache.cfg.php');
$final = generate_config($current);
- $browser = new Browser();
- $browser->downloadHeaders('ampache.cfg.php','text/plain',false,filesize(Config::get('prefix') . '/config/ampache.cfg.php.dist'));
- echo $final;
- exit;
+ $browser = new Browser();
+ $browser->downloadHeaders('ampache.cfg.php','text/plain',false,filesize(Config::get('prefix') . '/config/ampache.cfg.php.dist'));
+ echo $final;
+ exit;
break;
case 'reset_db_charset':
- Dba::reset_db_charset();
- show_confirmation(_('Database Charset Updated'),_('Your Database and associated tables have been updated to match your currently configured charset'), Config::get('web_path').'/admin/system.php?action=show_debug');
- break;
- case 'show_debug':
+ Dba::reset_db_charset();
+ show_confirmation(_('Database Charset Updated'),_('Your Database and associated tables have been updated to match your currently configured charset'), Config::get('web_path').'/admin/system.php?action=show_debug');
+ break;
+ case 'show_debug':
$configuration = Config::get_all();
require_once Config::get('prefix') . '/templates/show_debug.inc.php';
- break;
- default:
+ break;
+ default:
// Rien a faire
break;
} // end switch
-show_footer();
+show_footer();
?>
diff --git a/admin/users.php b/admin/users.php
index c871a5e7..5ed49043 100644
--- a/admin/users.php
+++ b/admin/users.php
@@ -22,22 +22,22 @@
require_once '../lib/init.php';
-if (!Access::check('interface','100')) {
+if (!Access::check('interface','100')) {
access_denied();
exit();
}
-show_header();
+show_header();
-// Switch on the actions
+// Switch on the actions
switch ($_REQUEST['action']) {
case 'update_user':
if (Config::get('demo_mode')) { break; }
- if (!Core::form_verify('edit_user','post')) {
- access_denied();
- exit;
- }
+ if (!Core::form_verify('edit_user','post')) {
+ access_denied();
+ exit;
+ }
/* Clean up the variables */
$user_id = scrub_in($_POST['user_id']);
@@ -47,49 +47,49 @@ switch ($_REQUEST['action']) {
$access = scrub_in($_POST['access']);
$pass1 = scrub_in($_POST['password_1']);
$pass2 = scrub_in($_POST['password_2']);
-
- /* Setup the temp user */
+
+ /* Setup the temp user */
$client = new User($user_id);
-
+
/* Verify Input */
- if (empty($username)) {
+ if (empty($username)) {
Error::add('username',_("Error Username Required"));
}
- if ($pass1 !== $pass2 && !empty($pass1)) {
+ if ($pass1 !== $pass2 && !empty($pass1)) {
Error::add('password',_("Error Passwords don't match"));
}
/* If we've got an error then break! */
- if (Error::occurred()) {
+ if (Error::occurred()) {
$_REQUEST['action'] = 'show_edit';
break;
} // if we've had an oops!
- if ($access != $client->access) {
+ if ($access != $client->access) {
$client->update_access($access);
}
- if ($email != $client->email) {
+ if ($email != $client->email) {
$client->update_email($email);
}
- if ($username != $client->username) {
+ if ($username != $client->username) {
$client->update_username($username);
- }
+ }
if ($fullname != $client->fullname) {
$client->update_fullname($fullname);
}
- if ($pass1 == $pass2 && strlen($pass1)) {
+ if ($pass1 == $pass2 && strlen($pass1)) {
$client->update_password($pass1);
- }
-
+ }
+
show_confirmation(_('User Updated'), $client->fullname . "(" . $client->username . ")" . _('updated'), Config::get('web_path'). '/admin/users.php');
break;
case 'add_user':
if (Config::get('demo_mode')) { break; }
- if (!Core::form_verify('add_user','post')) {
+ if (!Core::form_verify('add_user','post')) {
access_denied();
exit;
- }
+ }
$username = scrub_in($_POST['username']);
$fullname = scrub_in($_POST['fullname']);
@@ -98,74 +98,74 @@ switch ($_REQUEST['action']) {
$pass1 = scrub_in($_POST['password_1']);
$pass2 = scrub_in($_POST['password_2']);
- if ($pass1 !== $pass2 || !strlen($pass1)) {
+ if ($pass1 !== $pass2 || !strlen($pass1)) {
Error::add('password',_("Error Passwords don't match"));
}
- if (empty($username)) {
+ if (empty($username)) {
Error::add('username',_('Error Username Required'));
}
/* make sure the username doesn't already exist */
- if (!User::check_username($username)) {
+ if (!User::check_username($username)) {
Error::add('username',_('Error Username already exists'));
- }
+ }
- if (!Error::occurred()) {
+ if (!Error::occurred()) {
/* Attempt to create the user */
$user_id = User::create($username, $fullname, $email, $pass1, $access);
- if (!$user_id) {
+ if (!$user_id) {
Error::add('general',_("Error: Insert Failed"));
}
} // if no errors
- else {
+ else {
$_REQUEST['action'] = 'show_add_user';
break;
}
if ($access == 5){ $access = _('Guest');}
elseif ($access == 25){ $access = _('User');}
elseif ($access == 100){ $access = _('Admin');}
-
+
/* HINT: %1 Username, %2 Access num */
show_confirmation(_('New User Added'),sprintf(_('%1$s has been created with an access level of %2$s'), $username, $access), Config::get('web_path').'/admin/users.php');
break;
case 'enable':
- $client = new User($_REQUEST['user_id']);
- $client->enable();
- show_confirmation(_('User Enabled'),$client->fullname . ' (' . $client->username . ')', Config::get('web_path'). '/admin/users.php');
+ $client = new User($_REQUEST['user_id']);
+ $client->enable();
+ show_confirmation(_('User Enabled'),$client->fullname . ' (' . $client->username . ')', Config::get('web_path'). '/admin/users.php');
break;
case 'disable':
- $client = new User($_REQUEST['user_id']);
- if ($client->disable()) {
- show_confirmation(_('User Disabled'),$client->fullname . ' (' . $client->username . ')', Config::get('web_path'). '/admin/users.php');
- }
- else {
- show_confirmation(_('Error'),_('Unable to Disabled last Administrator'), Config::get('web_path').'/admin/users.php');
- }
+ $client = new User($_REQUEST['user_id']);
+ if ($client->disable()) {
+ show_confirmation(_('User Disabled'),$client->fullname . ' (' . $client->username . ')', Config::get('web_path'). '/admin/users.php');
+ }
+ else {
+ show_confirmation(_('Error'),_('Unable to Disabled last Administrator'), Config::get('web_path').'/admin/users.php');
+ }
break;
case 'show_edit':
if (Config::get('demo_mode')) { break; }
- $client = new User($_REQUEST['user_id']);
+ $client = new User($_REQUEST['user_id']);
require_once Config::get('prefix') . '/templates/show_edit_user.inc.php';
break;
case 'confirm_delete':
if (Config::get('demo_mode')) { break; }
- if (!Core::form_verify('delete_user')) {
- access_denied();
- exit;
- }
- $client = new User($_REQUEST['user_id']);
- if ($client->delete()) {
+ if (!Core::form_verify('delete_user')) {
+ access_denied();
+ exit;
+ }
+ $client = new User($_REQUEST['user_id']);
+ if ($client->delete()) {
show_confirmation(_('User Deleted'), sprintf(_('%s has been Deleted'), $client->username), Config::get('web_path'). "/admin/users.php");
}
- else {
+ else {
show_confirmation(_('Delete Error'), _("Unable to delete last Admin User"), Config::get('web_path')."/admin/users.php");
}
break;
case 'delete':
if (Config::get('demo_mode')) { break; }
- $client = new User($_REQUEST['user_id']);
+ $client = new User($_REQUEST['user_id']);
show_confirmation(_('Deletion Request'),
sprintf(_('Are you sure you want to permanently delete %s?'), $client->fullname),
Config::get('web_path')."/admin/users.php?action=confirm_delete&amp;user_id=" . $_REQUEST['user_id'],1,'delete_user');
@@ -173,11 +173,11 @@ switch ($_REQUEST['action']) {
/* Show IP History for the Specified User */
case 'show_ip_history':
/* get the user and their history */
- $working_user = new User($_REQUEST['user_id']);
+ $working_user = new User($_REQUEST['user_id']);
if (!isset($_REQUEST['all'])){
$history = $working_user->get_ip_history(0,1);
- }
+ }
else {
$history = $working_user->get_ip_history();
}
@@ -187,18 +187,18 @@ switch ($_REQUEST['action']) {
if (Config::get('demo_mode')) { break; }
require_once Config::get('prefix') . '/templates/show_add_user.inc.php';
break;
- case 'show_preferences':
- $client = new User($_REQUEST['user_id']);
- $preferences = Preference::get_all($client->id);
+ case 'show_preferences':
+ $client = new User($_REQUEST['user_id']);
+ $preferences = Preference::get_all($client->id);
require_once Config::get('prefix') . '/templates/show_user_preferences.inc.php';
break;
default:
Browse::reset_filters();
- Browse::set_type('user');
+ Browse::set_type('user');
Browse::set_simple_browse(1);
Browse::set_sort('name','ASC');
- $user_ids = Browse::get_objects();
- Browse::show_objects($user_ids);
+ $user_ids = Browse::get_objects();
+ Browse::show_objects($user_ids);
break;
} // end switch on action
diff --git a/albums.php b/albums.php
index 74f85ad2..3fce3720 100644
--- a/albums.php
+++ b/albums.php
@@ -25,9 +25,9 @@ require_once 'lib/init.php';
require_once Config::get('prefix') . '/templates/header.inc.php';
/* Switch on Action */
-switch ($_REQUEST['action']) {
+switch ($_REQUEST['action']) {
case 'clear_art':
- if (!$GLOBALS['user']->has_access('75')) { access_denied(); }
+ if (!$GLOBALS['user']->has_access('75')) { access_denied(); }
$album = new Album($_REQUEST['album_id']);
$album->clear_art();
show_confirmation(_('Album Art Cleared'),_('Album Art information has been removed from the database'),"/albums.php?action=show&amp;album=" . $album->id);
@@ -35,29 +35,29 @@ switch ($_REQUEST['action']) {
// Upload album art
case 'upload_art':
- // we didn't find anything
- if (empty($_FILES['file']['tmp_name'])) {
+ // we didn't find anything
+ if (empty($_FILES['file']['tmp_name'])) {
show_confirmation(_('Album Art Not Located'),_('Album Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'),"/albums.php?action=show&amp;album=" . $album->id);
break;
}
- $album = new Album($_REQUEST['album_id']);
-
+ $album = new Album($_REQUEST['album_id']);
+
// Pull the image information
- $data = array('file'=>$_FILES['file']['tmp_name']);
- $image_data = Album::get_image_from_source($data);
+ $data = array('file'=>$_FILES['file']['tmp_name']);
+ $image_data = Album::get_image_from_source($data);
// If we got something back insert it
- if ($image_data) {
+ if ($image_data) {
$album->insert_art($image_data,$_FILES['file']['type']);
show_confirmation(_('Album Art Inserted'),'',"/albums.php?action=show&amp;album=" . $album->id);
- }
+ }
// Else it failed
- else {
+ else {
show_confirmation(_('Album Art Not Located'),_('Album Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'),"/albums.php?action=show&amp;album=" . $album->id);
- }
+ }
- break;
+ break;
case 'find_art':
// If not a user then kick em out
@@ -65,61 +65,61 @@ switch ($_REQUEST['action']) {
// get the Album information
$album = new Album($_REQUEST['album_id']);
- $album->format();
- $images = array();
- $cover_url = array();
+ $album->format();
+ $images = array();
+ $cover_url = array();
// If we've got an upload ignore the rest and just insert it
- if (!empty($_FILES['file']['tmp_name'])) {
- $path_info = pathinfo($_FILES['file']['name']);
+ if (!empty($_FILES['file']['tmp_name'])) {
+ $path_info = pathinfo($_FILES['file']['name']);
$upload['file'] = $_FILES['file']['tmp_name'];
- $upload['mime'] = 'image/' . $path_info['extension'];
- $image_data = Album::get_image_from_source($upload);
+ $upload['mime'] = 'image/' . $path_info['extension'];
+ $image_data = Album::get_image_from_source($upload);
- if ($image_data) {
- $album->insert_art($image_data,$upload['0']['mime']);
+ if ($image_data) {
+ $album->insert_art($image_data,$upload['0']['mime']);
show_confirmation(_('Album Art Inserted'),'',"/albums.php?action=show&amp;album=" . $_REQUEST['album_id']);
break;
} // if image data
} // if it's an upload
-
+
// Build the options for our search
- if (isset($_REQUEST['artist_name'])) {
+ if (isset($_REQUEST['artist_name'])) {
$artist = scrub_in($_REQUEST['artist_name']);
- }
- elseif ($album->artist_count == '1') {
+ }
+ elseif ($album->artist_count == '1') {
$artist = $album->f_artist_name;
}
- if (isset($_REQUEST['album_name'])) {
+ if (isset($_REQUEST['album_name'])) {
$album_name = scrub_in($_REQUEST['album_name']);
}
- else {
+ else {
$album_name = $album->full_name;
}
-
- $options['artist'] = $artist;
- $options['album_name'] = $album_name;
- $options['keyword'] = $artist . " " . $album_name;
-
- // Attempt to find the art.
+
+ $options['artist'] = $artist;
+ $options['album_name'] = $album_name;
+ $options['keyword'] = $artist . " " . $album_name;
+
+ // Attempt to find the art.
$images = $album->find_art($options,'6');
- if (!empty($_REQUEST['cover'])) {
- $path_info = pathinfo($_REQUEST['cover']);
- $cover_url[0]['url'] = scrub_in($_REQUEST['cover']);
+ if (!empty($_REQUEST['cover'])) {
+ $path_info = pathinfo($_REQUEST['cover']);
+ $cover_url[0]['url'] = scrub_in($_REQUEST['cover']);
$cover_url[0]['mime'] = 'image/' . $path_info['extension'];
}
- $images = array_merge($cover_url,$images);
+ $images = array_merge($cover_url,$images);
- // If we've found anything then go for it!
+ // If we've found anything then go for it!
if (count($images)) {
// We don't want to store raw's in here so we need to strip them out into a seperate array
- foreach ($images as $index=>$image) {
- if ($image['raw']) {
- unset($images[$index]['raw']);
- }
+ foreach ($images as $index=>$image) {
+ if ($image['raw']) {
+ unset($images[$index]['raw']);
+ }
} // end foreach
// Store the results for further use
$_SESSION['form']['images'] = $images;
@@ -129,42 +129,42 @@ switch ($_REQUEST['action']) {
else {
show_confirmation(_('Album Art Not Located'),_('Album Art could not be located at this time. This may be due to write access error, or the file is not received correctly.'),"/albums.php?action=show&amp;album=" . $album->id);
}
-
+
$albumname = $album->name;
$artistname = $artist;
-
+
// Remember the last typed entry, if there was one
if (!empty($_REQUEST['album_name'])) { $albumname = scrub_in($_REQUEST['album_name']); }
if (!empty($_REQUEST['artist_name'])) { $artistname = scrub_in($_REQUEST['artist_name']); }
-
+
require_once Config::get('prefix') . '/templates/show_get_albumart.inc.php';
-
+
break;
- case 'select_art':
+ case 'select_art':
/* Check to see if we have the image url still */
$image_id = $_REQUEST['image'];
$album_id = $_REQUEST['album_id'];
-
+
$image = Album::get_image_from_source($_SESSION['form']['images'][$image_id]);
$mime = $_SESSION['form']['images'][$image_id]['mime'];
-
+
$album = new Album($album_id);
$album->insert_art($image,$mime);
- header("Location:" . Config::get('web_path') . "/albums.php?action=show&album=" . $album->id);
+ header("Location:" . Config::get('web_path') . "/albums.php?action=show&album=" . $album->id);
break;
case 'update_from_tags':
// Make sure they are a 'power' user at least
- if (!Access::check('interface','75')) {
- access_denied();
- exit;
- }
-
- $type = 'album';
- $object_id = intval($_REQUEST['album_id']);
- $target_url = Config::get('web_path') . '/albums.php?action=show&amp;album=' . $object_id;
- require_once Config::get('prefix') . '/templates/show_update_items.inc.php';
+ if (!Access::check('interface','75')) {
+ access_denied();
+ exit;
+ }
+
+ $type = 'album';
+ $object_id = intval($_REQUEST['album_id']);
+ $target_url = Config::get('web_path') . '/albums.php?action=show&amp;album=' . $object_id;
+ require_once Config::get('prefix') . '/templates/show_update_items.inc.php';
break;
// Browse by Album
default:
@@ -173,7 +173,7 @@ switch ($_REQUEST['action']) {
$album->format();
Browse::reset_filters();
require Config::get('prefix') . '/templates/show_album.inc.php';
-
+
break;
} // switch on view
diff --git a/artists.php b/artists.php
index 634521dc..1f915d94 100644
--- a/artists.php
+++ b/artists.php
@@ -22,32 +22,32 @@
require_once 'lib/init.php';
-show_header();
+show_header();
/**
- * Display Switch
+ * Display Switch
*/
switch($_REQUEST['action']) {
case 'show':
$artist = new Artist($_REQUEST['artist']);
- $artist->format();
- $object_ids = $artist->get_albums();
- $object_type = 'album';
+ $artist->format();
+ $object_ids = $artist->get_albums();
+ $object_type = 'album';
require_once Config::get('prefix') . '/templates/show_artist.inc.php';
break;
case 'show_all_songs':
$artist = new Artist($_REQUEST['artist']);
$artist->format();
- $object_type = 'song';
- $object_ids = $artist->get_songs();
+ $object_type = 'song';
+ $object_ids = $artist->get_songs();
require_once Config::get('prefix') . '/templates/show_artist.inc.php';
break;
case 'update_from_tags':
- $type = 'artist';
- $object_id = intval($_REQUEST['artist']);
- $target_url = Config::get('web_path') . "/artists.php?action=show&amp;artist=" . $object_id;
- require_once Config::get('prefix') . '/templates/show_update_items.inc.php';
+ $type = 'artist';
+ $object_id = intval($_REQUEST['artist']);
+ $target_url = Config::get('web_path') . "/artists.php?action=show&amp;artist=" . $object_id;
+ require_once Config::get('prefix') . '/templates/show_update_items.inc.php';
break;
case 'rename_similar':
if (!$user->has_access('100')) { access_denied(); }
@@ -81,14 +81,14 @@ switch($_REQUEST['action']) {
} else {
$GLOBALS['error']->print_error('general');
}
-
+
break;
case 'show_similar':
- if (!$GLOBALS['user']->has_access('75')) {
- access_denied();
- exit;
+ if (!$GLOBALS['user']->has_access('75')) {
+ access_denied();
+ exit;
}
-
+
$artist = new Artist($_REQUEST['artist']);
//options
$similar_artists = $artist->get_similar_artists(
@@ -103,23 +103,23 @@ switch($_REQUEST['action']) {
$artist_id = $artist->id;
$artist_name = $artist->name;
require Config::get('prefix') . '/templates/show_similar_artists.inc.php';
-
+
break;
case 'rename':
//die if not enough permissions
if (!$user->has_access('100')) { access_denied(); }
-
+
/* Get the artist */
$artist = new Artist($_REQUEST['artist']);
$catalog = new Catalog();
-
+
//check if we've been given a target
if ((isset($_POST['artist_id']) && $_POST['artist_id'] != $artist->id ) || (isset($_POST['artist_name']) && $_POST['artist_name'] != "")) {
-
+
//if we want to update id3 tags, then get the array of ids now, it's too late afterwards
if (make_bool($_POST['update_id3']))
- $songs = $artist->get_songs();
-
+ $songs = $artist->get_songs();
+
$ret = 0;
//the manual rename takes priority, but if they tested out the insert thing ignore
if ($_POST['artist_name'] != "" && $_POST['artist_name'] != $artist->name) {
@@ -134,24 +134,24 @@ switch($_REQUEST['action']) {
$ret = $artist->merge($_POST['artist_id']);
$newid = $_POST['artist_id'];
$newname = $ret;
- } // elseif different artist and id
+ } // elseif different artist and id
//if no changes, no changes
-
+
//now flag for id3tag update if selected, and something actually happaned
if ($ret && make_bool($_POST['update_id3'])) {
-
+
/* Set the rename information in the db */
foreach ($songs as $song) {
$flag = new Flag();
$flag->add($song->id,"song","retag","Renamed artist, retag");
- $flag_qstring = "REPLACE INTO flagged " .
+ $flag_qstring = "REPLACE INTO flagged " .
"SET type = 'setid3', song = '" . $song->id . "', date = '" . time() . "', user = '" . $GLOBALS['user']->username . "'";
- mysql_query($flag_qstring, dbh());
+ mysql_query($flag_qstring, dbh());
}
-
+
} // end if they wanted to update
-
- // show something other than a blank screen after this
+
+ // show something other than a blank screen after this
if ($ret) {
show_confirmation (
"Renamed artist",
@@ -159,25 +159,25 @@ switch($_REQUEST['action']) {
conf('web_path') . "/artists.php?action=show&artist=" . $newid
);
}
-
+
} // if we've got the needed variables
/* Else we've got an error! But be lenient, and just show the form again */
- else {
+ else {
require (conf('prefix') . '/templates/show_rename_artist.inc.php');
}
- break;
+ break;
case 'show_rename':
$artist = new Artist($_REQUEST['artist']);
- require (conf('prefix') . '/templates/show_rename_artist.inc.php');
+ require (conf('prefix') . '/templates/show_rename_artist.inc.php');
break;
case 'match':
case 'Match':
$match = scrub_in($_REQUEST['match']);
if ($match == "Browse" || $match == "Show_all") { $chr = ""; }
- else { $chr = $match; }
+ else { $chr = $match; }
/* Enclose this in the purty box! */
- require (conf('prefix') . '/templates/show_box_top.inc.php');
+ require (conf('prefix') . '/templates/show_box_top.inc.php');
show_alphabet_list('artists','artists.php',$match);
show_alphabet_form($chr,_('Show Artists starting with'),"artists.php?action=match");
require (conf('prefix') . '/templates/show_box_bottom.inc.php');
@@ -188,7 +188,7 @@ switch($_REQUEST['action']) {
elseif ($match === "Show_all") {
$offset_limit = 999999;
show_artists();
- }
+ }
else {
if ($chr == '') {
show_artists('A');
@@ -197,7 +197,7 @@ switch($_REQUEST['action']) {
show_artists($chr);
}
}
- break;
+ break;
} // end switch
show_footer();
diff --git a/batch.php b/batch.php
index b0684f38..3860cd44 100644
--- a/batch.php
+++ b/batch.php
@@ -21,20 +21,20 @@
*/
require_once 'lib/init.php';
-ob_end_clean();
+ob_end_clean();
//test that batch download is permitted
-if (!Access::check_function('batch_download')) {
- access_denied();
- exit;
+if (!Access::check_function('batch_download')) {
+ access_denied();
+ exit;
}
/* Drop the normal Time limit constraints, this can take a while */
set_time_limit(0);
switch ($_REQUEST['action']) {
- case 'tmp_playlist':
- $media_ids = $GLOBALS['user']->playlist->get_items();
+ case 'tmp_playlist':
+ $media_ids = $GLOBALS['user']->playlist->get_items();
$name = $GLOBALS['user']->username . ' - Playlist';
break;
case 'playlist':
@@ -47,28 +47,28 @@ switch ($_REQUEST['action']) {
$media_ids = $album->get_songs();
$name = $album->name;
break;
- case 'artist':
- $artist = new Artist($_REQUEST['id']);
- $media_ids = $artist->get_songs();
- $name = $artist->name;
+ case 'artist':
+ $artist = new Artist($_REQUEST['id']);
+ $media_ids = $artist->get_songs();
+ $name = $artist->name;
break;
case 'genre':
- $id = scrub_in($_REQUEST['id']);
- $genre = new Genre($id);
+ $id = scrub_in($_REQUEST['id']);
+ $genre = new Genre($id);
$media_ids = $genre->get_songs();
- $name = $genre->name;
+ $name = $genre->name;
break;
- case 'browse':
- $media_ids = Browse::get_saved();
- $name = 'Batch-' . date("dmY",time());
+ case 'browse':
+ $media_ids = Browse::get_saved();
+ $name = 'Batch-' . date("dmY",time());
default:
// Rien a faire
break;
-} // action switch
+} // action switch
// Take whatever we've got and send the zip
-$song_files = get_song_files($media_ids);
-set_memory_limit($song_files['1']+32);
-send_zip($name,$song_files['0']);
-exit;
+$song_files = get_song_files($media_ids);
+set_memory_limit($song_files['1']+32);
+send_zip($name,$song_files['0']);
+exit;
?>
diff --git a/browse.php b/browse.php
index 73cd37d1..616f2588 100644
--- a/browse.php
+++ b/browse.php
@@ -24,7 +24,7 @@
*
* Browse By Page
* This page shows the browse menu, which allows you to browse by many different
- * fields including genre, artist, album, catalog, ???
+ * fields including genre, artist, album, catalog, ???
* this page also handles the actuall browse action
*
*/
@@ -34,70 +34,70 @@ require_once 'lib/init.php';
// This page is a little wonky we don't want the sidebar until we know what type we're dealing with
// so we've got a little switch here that creates the type.. this feels hackish...
-switch ($_REQUEST['action']) {
- case 'tag':
- case 'file':
- case 'album':
- case 'artist':
- case 'playlist':
- case 'live_stream':
- case 'video':
- case 'song':
- Browse::set_type($_REQUEST['action']);
- Browse::reset();
- Browse::set_simple_browse(true);
- break;
-} // end switch
+switch ($_REQUEST['action']) {
+ case 'tag':
+ case 'file':
+ case 'album':
+ case 'artist':
+ case 'playlist':
+ case 'live_stream':
+ case 'video':
+ case 'song':
+ Browse::set_type($_REQUEST['action']);
+ Browse::reset();
+ Browse::set_simple_browse(true);
+ break;
+} // end switch
-show_header();
+show_header();
switch($_REQUEST['action']) {
case 'file':
- break;
+ break;
case 'album':
Browse::set_sort('name','ASC');
- Browse::show_objects();
+ Browse::show_objects();
break;
- case 'tag':
- Browse::set_sort('count','ASC');
+ case 'tag':
+ Browse::set_sort('count','ASC');
// This one's a doozy
- Browse::set_simple_browse(0);
- Browse::save_objects(Tag::get_tags(Config::get('offset_limit'),array()));
- $keys = array_keys(Browse::get_saved());
- Tag::build_cache($keys);
- $object_ids = Browse::get_saved();
- show_box_top(_('Tag Cloud'),$class);
- require_once Config::get('prefix') . '/templates/show_tagcloud.inc.php';
- show_box_bottom();
- require_once Config::get('prefix') . '/templates/browse_content.inc.php';
- break;
+ Browse::set_simple_browse(0);
+ Browse::save_objects(Tag::get_tags(Config::get('offset_limit'),array()));
+ $keys = array_keys(Browse::get_saved());
+ Tag::build_cache($keys);
+ $object_ids = Browse::get_saved();
+ show_box_top(_('Tag Cloud'),$class);
+ require_once Config::get('prefix') . '/templates/show_tagcloud.inc.php';
+ show_box_bottom();
+ require_once Config::get('prefix') . '/templates/browse_content.inc.php';
+ break;
case 'artist':
Browse::set_sort('name','ASC');
- Browse::show_objects();
+ Browse::show_objects();
break;
case 'song':
Browse::set_sort('title','ASC');
- Browse::show_objects();
+ Browse::show_objects();
break;
case 'live_stream':
Browse::set_sort('name','ASC');
- Browse::show_objects();
+ Browse::show_objects();
break;
case 'catalog':
-
+
break;
- case 'playlist':
+ case 'playlist':
Browse::set_sort('type','ASC');
Browse::set_filter('playlist_type','1');
- Browse::show_objects();
+ Browse::show_objects();
break;
- case 'video':
- Browse::set_sort('title','ASC');
- Browse::show_objects();
- break;
- default:
+ case 'video':
+ Browse::set_sort('title','ASC');
+ Browse::show_objects();
+ break;
+ default:
- break;
+ break;
} // end Switch $action
/* Show the Footer */
diff --git a/democratic.php b/democratic.php
index 65e1a846..76279c66 100644
--- a/democratic.php
+++ b/democratic.php
@@ -23,104 +23,104 @@
require_once 'lib/init.php';
/* Make sure they have access to this */
-if (!Config::get('allow_democratic_playback')) {
- access_denied();
+if (!Config::get('allow_democratic_playback')) {
+ access_denied();
exit;
}
-show_header();
+show_header();
// Switch on their action
-switch ($_REQUEST['action']) {
- case 'manage':
+switch ($_REQUEST['action']) {
+ case 'manage':
$democratic = Democratic::get_current_playlist();
$democratic->set_parent();
$democratic->format();
- case 'show_create':
- if (!Access::check('interface','75')) {
- access_denied();
+ case 'show_create':
+ if (!Access::check('interface','75')) {
+ access_denied();
break;
- }
+ }
// Show the create page
- require_once Config::get('prefix') . '/templates/show_create_democratic.inc.php';
- break;
- case 'delete':
- if (!Access::check('interface','75')) {
- access_denied();
- break;
- }
-
- Democratic::delete($_REQUEST['democratic_id']);
-
- $title = '';
- $text = _('The Requested Playlist has been deleted.');
- $url = Config::get('web_path') . '/democratic.php?action=manage_playlists';
- show_confirmation($title,$text,$url);
- break;
- case 'create':
- // Only power users here
- if (!Access::check('interface','75')) {
- access_denied();
+ require_once Config::get('prefix') . '/templates/show_create_democratic.inc.php';
+ break;
+ case 'delete':
+ if (!Access::check('interface','75')) {
+ access_denied();
+ break;
+ }
+
+ Democratic::delete($_REQUEST['democratic_id']);
+
+ $title = '';
+ $text = _('The Requested Playlist has been deleted.');
+ $url = Config::get('web_path') . '/democratic.php?action=manage_playlists';
+ show_confirmation($title,$text,$url);
+ break;
+ case 'create':
+ // Only power users here
+ if (!Access::check('interface','75')) {
+ access_denied();
break;
- }
+ }
- if (!Core::form_verify('create_democratic')) {
- access_denied();
- exit;
- }
-
- $democratic = Democratic::get_current_playlist();
+ if (!Core::form_verify('create_democratic')) {
+ access_denied();
+ exit;
+ }
+
+ $democratic = Democratic::get_current_playlist();
// If we don't have anything currently create something
- if (!$democratic->id) {
+ if (!$democratic->id) {
// Create the playlist
- Democratic::create($_POST);
- $democratic = Democratic::get_current_playlist();
- }
- else {
- $democratic->update($_POST);
- }
+ Democratic::create($_POST);
+ $democratic = Democratic::get_current_playlist();
+ }
+ else {
+ $democratic->update($_POST);
+ }
// Now check for additional things we might have to do
- if ($_POST['force_democratic']) {
- Democratic::set_user_preferences();
- }
-
- header("Location: " . Config::get('web_path') . "/democratic.php?action=show");
- break;
- case 'manage_playlists':
- if (!Access::check('interface','75')) {
- access_denied();
+ if ($_POST['force_democratic']) {
+ Democratic::set_user_preferences();
+ }
+
+ header("Location: " . Config::get('web_path') . "/democratic.php?action=show");
+ break;
+ case 'manage_playlists':
+ if (!Access::check('interface','75')) {
+ access_denied();
break;
- }
+ }
// Get all of the non-user playlists
- $playlists = Democratic::get_playlists();
+ $playlists = Democratic::get_playlists();
- require_once Config::get('prefix') . '/templates/show_manage_democratic.inc.php';
+ require_once Config::get('prefix') . '/templates/show_manage_democratic.inc.php';
break;
- case 'show_playlist':
- default:
- $democratic = Democratic::get_current_playlist();
- if (!$democratic->id) {
- require_once Config::get('prefix') . '/templates/show_democratic.inc.php';
- break;
- }
-
- $democratic->set_parent();
- $democratic->format();
- require_once Config::get('prefix') . '/templates/show_democratic.inc.php';
+ case 'show_playlist':
+ default:
+ $democratic = Democratic::get_current_playlist();
+ if (!$democratic->id) {
+ require_once Config::get('prefix') . '/templates/show_democratic.inc.php';
+ break;
+ }
+
+ $democratic->set_parent();
+ $democratic->format();
+ require_once Config::get('prefix') . '/templates/show_democratic.inc.php';
$objects = $democratic->get_items();
- Song::build_cache($democratic->object_ids);
- Democratic::build_vote_cache($democratic->vote_ids);
- Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($objects);
+ Song::build_cache($democratic->object_ids);
+ Democratic::build_vote_cache($democratic->vote_ids);
+ Browse::set_type('democratic');
+ Browse::reset();
+ Browse::set_static_content(1);
+ Browse::show_objects($objects);
break;
} // end switch on action
-show_footer();
+show_footer();
?>
diff --git a/flag.php b/flag.php
index da031bc2..da71c4cc 100644
--- a/flag.php
+++ b/flag.php
@@ -34,7 +34,7 @@ $action = scrub_in($_REQUEST['action']);
$flag = new Flag($_REQUEST['flag_id']);
/* Switch on the action */
-switch ($action) {
+switch ($action) {
case 'remove_flag':
break;
case 'flag':
@@ -42,7 +42,7 @@ switch ($action) {
$type = scrub_in($_REQUEST['type']);
$flag_type = scrub_in($_REQUEST['flag_type']);
$comment = scrub_in($_REQUEST['comment']);
- $flag->add($id,$type,$flag_type,$comment);
+ $flag->add($id,$type,$flag_type,$comment);
show_confirmation(_('Item Flagged'),_('The specified item has been flagged'),$_SESSION['source_page']);
break;
case 'show_flag':
@@ -51,10 +51,10 @@ switch ($action) {
include(conf('prefix') . '/templates/show_flag.inc.php');
break;
case 'show_remove_flag':
-
+
break;
default:
-
+
break;
} // end action switch
diff --git a/genre.php b/genre.php
index 7355b73d..d8a37620 100644
--- a/genre.php
+++ b/genre.php
@@ -28,19 +28,19 @@ require_once 'lib/init.php';
show_header();
/**
- * switch on action
+ * switch on action
*/
-switch($_REQUEST['action']) {
+switch($_REQUEST['action']) {
case 'show_songs':
$genre = new Genre($_REQUEST['genre_id']);
show_genre($_REQUEST['genre_id']);
$object_ids = $genre->get_songs();
- Browse::reset_filters();
- Browse::set_type('song');
- Browse::set_sort('name','ASC');
- Browse::set_static_content(1);
+ Browse::reset_filters();
+ Browse::set_type('song');
+ Browse::set_sort('name','ASC');
+ Browse::set_static_content(1);
Browse::save_objects($object_ids);
- Browse::show_objects($object_ids);
+ Browse::show_objects($object_ids);
break;
case 'show_genre':
default:
@@ -48,23 +48,23 @@ switch($_REQUEST['action']) {
$genre = new Genre($_REQUEST['genre_id']);
show_genre($_REQUEST['genre_id']);
$object_ids = $genre->get_albums();
- Browse::reset_filters();
- Browse::set_type('album');
- Browse::set_sort('name','ASC');
- Browse::set_static_content(1);
- Browse::save_objects($object_ids);
- Browse::show_objects($object_ids);
+ Browse::reset_filters();
+ Browse::set_type('album');
+ Browse::set_sort('name','ASC');
+ Browse::set_static_content(1);
+ Browse::save_objects($object_ids);
+ Browse::show_objects($object_ids);
break;
case 'show_artists':
$genre = new Genre($_REQUEST['genre_id']);
show_genre($_REQUEST['genre_id']);
$object_ids = $genre->get_artists();
- Browse::reset_filters();
- Browse::set_type('artist');
- Browse::set_sort('name','ASC');
- Browse::set_static_content(1);
- Browse::save_objects($object_ids);
- Browse::show_objects($object_ids);
+ Browse::reset_filters();
+ Browse::set_type('artist');
+ Browse::set_sort('name','ASC');
+ Browse::set_static_content(1);
+ Browse::save_objects($object_ids);
+ Browse::show_objects($object_ids);
break;
} // action
diff --git a/image.php b/image.php
index 7e30c176..cd629013 100644
--- a/image.php
+++ b/image.php
@@ -23,22 +23,22 @@
* Album Art
* This pulls album art out of the file using the getid3 library
* and dumps it to the browser as an image mime type.
- *
+ *
*/
// This file is a little weird it needs to allow API session
// this needs to be done a little better, but for now... eah
-define('NO_SESSION','1');
+define('NO_SESSION','1');
require 'lib/init.php';
// Check to see if they've got an interface session or a valid API session, if not GTFO
-if (!vauth::session_exists('interface',$_COOKIE[Config::get('session_name')]) AND !vauth::session_exists('api',$_REQUEST['auth']) AND !vauth::session_exists('xml-rpc',$_REQUEST['auth'])) {
+if (!vauth::session_exists('interface',$_COOKIE[Config::get('session_name')]) AND !vauth::session_exists('api',$_REQUEST['auth']) AND !vauth::session_exists('xml-rpc',$_REQUEST['auth'])) {
debug_event('DENIED','Image Access, Checked Cookie Session:' . $_COOKIE[Config::get('session_name')] . ' and Auth:' . $_REQUEST['auth'],'1');
- exit;
-}
+ exit;
+}
/* Decide what size this image is */
-switch ($_REQUEST['thumb']) {
+switch ($_REQUEST['thumb']) {
case '1':
/* This is used by the now_playing stuff */
$size['height'] = '75';
@@ -47,13 +47,13 @@ switch ($_REQUEST['thumb']) {
case '2':
$size['height'] = '128';
$size['width'] = '128';
- // $return_raw = true;
+ // $return_raw = true;
break;
case '3':
/* This is used by the flash player */
$size['height'] = '80';
$size['width'] = '80';
- // $return_raw = true;
+ // $return_raw = true;
break;
default:
$size['height'] = '275';
@@ -62,35 +62,35 @@ switch ($_REQUEST['thumb']) {
break;
} // define size based on thumbnail
-switch ($_REQUEST['type']) {
+switch ($_REQUEST['type']) {
case 'popup':
require_once Config::get('prefix') . '/templates/show_big_art.inc.php';
break;
- // If we need to pull the data out of the session
+ // If we need to pull the data out of the session
case 'session':
- vauth::check_session();
- $key = scrub_in($_REQUEST['image_index']);
+ vauth::check_session();
+ $key = scrub_in($_REQUEST['image_index']);
$image = Album::get_image_from_source($_SESSION['form']['images'][$key]);
$mime = $_SESSION['form']['images'][$key]['mime'];
- $data = explode("/",$mime);
- $extension = $data['1'];
+ $data = explode("/",$mime);
+ $extension = $data['1'];
// Send the headers and output the image
header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
- header("Content-type: $mime");
- header("Content-Disposition: filename=" . $key . "." . $extension);
- echo $image;
+ header("Content-type: $mime");
+ header("Content-Disposition: filename=" . $key . "." . $extension);
+ echo $image;
break;
- default:
+ default:
$album = new Album($_REQUEST['id']);
// Attempt to pull art from the database
$art = $album->get_art($return_raw);
$mime = $art['mime'];
- if (!$mime) {
+ if (!$mime) {
header('Content-type: image/jpeg');
readfile(Config::get('prefix') . Config::get('theme_path') . '/images/blankalbum.jpg');
break;
@@ -99,21 +99,21 @@ switch ($_REQUEST['type']) {
// Print the album art
$data = explode("/",$mime);
$extension = $data['1'];
-
- if (empty($_REQUEST['thumb'])) {
+
+ if (empty($_REQUEST['thumb'])) {
$art_data = $art['raw'];
}
- else {
+ else {
$art_data = img_resize($art,array('width'=>'275','height'=>'275'),$extension,$_REQUEST['id']);
}
-
+
// Send the headers and output the image
- header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
+ header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: $mime");
- header("Content-Disposition: filename=" . $album->name . "." . $extension);
+ header("Content-Disposition: filename=" . $album->name . "." . $extension);
echo $art_data;
break;
diff --git a/index.php b/index.php
index f25db948..d6cb7f7d 100644
--- a/index.php
+++ b/index.php
@@ -22,7 +22,7 @@
require_once 'lib/init.php';
-show_header();
+show_header();
$action = scrub_in($_REQUEST['action']);
@@ -31,14 +31,14 @@ $action = scrub_in($_REQUEST['action']);
* refresh_javascript include. Must be greater then 5, I'm not
* going to let them break their servers
*/
-if (Config::get('refresh_limit') > 5) {
- $refresh_limit = Config::get('refresh_limit');
+if (Config::get('refresh_limit') > 5) {
+ $refresh_limit = Config::get('refresh_limit');
$ajax_url = Config::get('ajax_url') . '?page=index&action=reloadnp';
require_once Config::get('prefix') . '/templates/javascript_refresh.inc.php';
}
require_once Config::get('prefix') . '/templates/show_index.inc.php';
-show_footer();
+show_footer();
?>
diff --git a/lib/batch.lib.php b/lib/batch.lib.php
index aca73874..e79a55d0 100644
--- a/lib/batch.lib.php
+++ b/lib/batch.lib.php
@@ -8,7 +8,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
as published by the Free Software Foundation.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -28,20 +28,20 @@
*/
function get_song_files($media_ids) {
- $media_files = array();
-
+ $media_files = array();
+
foreach ($media_ids as $element) {
- if (is_array($element)) {
- $type = array_shift($element);
- $media = new $type(array_shift($element));
- }
- else {
- $media = new Song($element);
- }
- if ($media->enabled) {
+ if (is_array($element)) {
+ $type = array_shift($element);
+ $media = new $type(array_shift($element));
+ }
+ else {
+ $media = new Song($element);
+ }
+ if ($media->enabled) {
$total_size += sprintf("%.2f",($media->size/1048576));
array_push($media_files, $media->file);
- }
+ }
}
return array($media_files,$total_size);
@@ -59,19 +59,19 @@ function send_zip( $name, $song_files ) {
// Check if they want to save it to a file, if so then make sure they've got
// a defined path as well and that it's writeable
- if (Config::get('file_zip_download') && Config::get('file_zip_path')) {
+ if (Config::get('file_zip_download') && Config::get('file_zip_path')) {
// Check writeable
- if (!is_writable(Config::get('file_zip_path'))) {
- $in_memory = '1';
- debug_event('Error','File Zip Path:' . Config::get('file_zip_path') . ' is not writeable','1');
- }
- else {
- $in_memory = '0';
- $basedir = Config::get('file_zip_path');
- }
+ if (!is_writable(Config::get('file_zip_path'))) {
+ $in_memory = '1';
+ debug_event('Error','File Zip Path:' . Config::get('file_zip_path') . ' is not writeable','1');
+ }
+ else {
+ $in_memory = '0';
+ $basedir = Config::get('file_zip_path');
+ }
} else {
- $in_memory = '1';
+ $in_memory = '1';
} // if file downloads
/* Require needed library */
@@ -84,20 +84,20 @@ function send_zip( $name, $song_files ) {
'level' => 0, // no compression
'comment' => Config::get('file_zip_comment')
);
-
+
$arc->set_options( $options );
$arc->add_files( $song_files );
- if (count($arc->error)) {
+ if (count($arc->error)) {
debug_event('archive',"Error: unable to add songs",'3');
- return false;
+ return false;
} // if failed to add songs
-
- if (!$arc->create_archive()) {
+
+ if (!$arc->create_archive()) {
debug_event('archive',"Error: unable to create archive",'3');
- return false;
+ return false;
} // if failed to create archive
-
+
$arc->download_file();
} // send_zip
diff --git a/lib/class/access.class.php b/lib/class/access.class.php
index 3652715d..7f986fef 100644
--- a/lib/class/access.class.php
+++ b/lib/class/access.class.php
@@ -16,10 +16,10 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/**
+/**
* Access Class
* This class handles the access list mojo for Ampache, it is ment to restrict
* access based on IP and maybe something else in the future
@@ -38,7 +38,7 @@ class Access {
/**
* constructor
- * Takes an ID of the access_id dealie :)
+ * Takes an ID of the access_id dealie :)
*/
public function __construct($access_id='') {
@@ -48,9 +48,9 @@ class Access {
$this->id = intval($access_id);
$info = $this->_get_info();
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
return true;
@@ -58,7 +58,7 @@ class Access {
/**
* _get_info
- * get's the vars for $this out of the database
+ * get's the vars for $this out of the database
* Taken from the object
*/
private function _get_info() {
@@ -75,16 +75,16 @@ class Access {
/**
* format
- * This makes the Access object a nice fuzzy human readable object, spiffy ain't it.
+ * This makes the Access object a nice fuzzy human readable object, spiffy ain't it.
*/
- public function format() {
+ public function format() {
- $this->f_start = inet_ntop($this->start);
- $this->f_end = inet_ntop($this->end);
+ $this->f_start = inet_ntop($this->start);
+ $this->f_end = inet_ntop($this->end);
- $this->f_user = $this->get_user_name();
- $this->f_level = $this->get_level_name();
- $this->f_type = $this->get_type_name();
+ $this->f_user = $this->get_user_name();
+ $this->f_level = $this->get_level_name();
+ $this->f_type = $this->get_type_name();
} // format
@@ -92,7 +92,7 @@ class Access {
* update
* This function takes a named array as a datasource and updates the current access list entry
*/
- public function update($data) {
+ public function update($data) {
/* We need to verify the incomming data a littlebit */
$start = @inet_pton($data['start']);
@@ -113,16 +113,16 @@ class Access {
return false;
}
- $name = Dba::escape($data['name']);
- $type = self::validate_type($data['type']);
+ $name = Dba::escape($data['name']);
+ $type = self::validate_type($data['type']);
$start = Dba::escape(inet_pton($data['start']));
- $end = Dba::escape(inet_pton($data['end']));
+ $end = Dba::escape(inet_pton($data['end']));
$level = Dba::escape($data['level']);
- $user = $data['user'] ? Dba::escape($data['user']) : '-1';
- $enabled = make_bool($data['enabled']);
-
- $sql = "UPDATE `access_list` " .
- "SET `start`='$start', `end`='$end', `level`='$level', `user`='$user', " .
+ $user = $data['user'] ? Dba::escape($data['user']) : '-1';
+ $enabled = make_bool($data['enabled']);
+
+ $sql = "UPDATE `access_list` " .
+ "SET `start`='$start', `end`='$end', `level`='$level', `user`='$user', " .
"`name`='$name', `type`='$type',`enabled`='$enabled' WHERE `id`='" . Dba::escape($this->id) . "'";
$db_results = Dba::write($sql);
@@ -132,45 +132,45 @@ class Access {
/**
* create
- * This takes a key'd array of data and trys to insert it as a
+ * This takes a key'd array of data and trys to insert it as a
* new ACL entry
*/
- public static function create($data) {
+ public static function create($data) {
/* We need to verify the incomming data a littlebit */
- $start = @inet_pton($data['start']);
- $end = @inet_pton($data['end']);
-
- if (!$start AND $data['start'] != '0.0.0.0' AND $data['start'] != '::') {
- Error::add('start',_('Invalid IPv4 / IPv6 Address Entered'));
- return false;
- }
- if (!$end) {
- Error::add('end',_('Invalid IPv4 / IPv6 Address Entered'));
- return false;
- }
-
- if (strlen(bin2hex($start)) != strlen(bin2hex($end))) {
- Error::add('start',_('IP Address Version Mismatch'));
- Error::add('end',_('IP Address Version Mismatch'));
- return false;
- }
+ $start = @inet_pton($data['start']);
+ $end = @inet_pton($data['end']);
+
+ if (!$start AND $data['start'] != '0.0.0.0' AND $data['start'] != '::') {
+ Error::add('start',_('Invalid IPv4 / IPv6 Address Entered'));
+ return false;
+ }
+ if (!$end) {
+ Error::add('end',_('Invalid IPv4 / IPv6 Address Entered'));
+ return false;
+ }
+
+ if (strlen(bin2hex($start)) != strlen(bin2hex($end))) {
+ Error::add('start',_('IP Address Version Mismatch'));
+ Error::add('end',_('IP Address Version Mismatch'));
+ return false;
+ }
// Check existing ACL's to make sure we're not duplicating values here
- if (self::exists($data)) {
- debug_event('ACL Create','Error did not create duplicate ACL entrie for ' . $data['start'] . ' - ' . $data['end'],'1');
- return false;
- }
+ if (self::exists($data)) {
+ debug_event('ACL Create','Error did not create duplicate ACL entrie for ' . $data['start'] . ' - ' . $data['end'],'1');
+ return false;
+ }
- $start = Dba::escape($start);
+ $start = Dba::escape($start);
$end = Dba::escape($end);
$name = Dba::escape($data['name']);
- $user = $data['user'] ? Dba::escape($data['user']) : '-1';
+ $user = $data['user'] ? Dba::escape($data['user']) : '-1';
$level = intval($data['level']);
$type = self::validate_type($data['type']);
- $enabled = make_bool($data['enabled']);
+ $enabled = make_bool($data['enabled']);
- $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`user`,`type`,`enabled`) " .
+ $sql = "INSERT INTO `access_list` (`name`,`level`,`start`,`end`,`user`,`type`,`enabled`) " .
"VALUES ('$name','$level','$start','$end','$user','$type','$enabled')";
$db_results = Dba::write($sql);
@@ -182,22 +182,22 @@ class Access {
* exists
* this sees if the ACL that we've specified already exists, prevent duplicates. This ignores the name
*/
- public static function exists($data) {
+ public static function exists($data) {
- $start = Dba::escape(inet_pton($data['start']));
- $end = Dba::escape(inet_pton($data['end']));
- $type = self::validate_type($data['type']);
- $user = $data['user'] ? Dba::escape($data['user']) : '-1';
+ $start = Dba::escape(inet_pton($data['start']));
+ $end = Dba::escape(inet_pton($data['end']));
+ $type = self::validate_type($data['type']);
+ $user = $data['user'] ? Dba::escape($data['user']) : '-1';
- $sql = "SELECT * FROM `access_list` WHERE `start`='$start' AND `end` = '$end' " .
- "AND `type`='$type' AND `user`='$user'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `access_list` WHERE `start`='$start' AND `end` = '$end' " .
+ "AND `type`='$type' AND `user`='$user'";
+ $db_results = Dba::read($sql);
- if (Dba::fetch_assoc($db_results)) {
- return true;
- }
+ if (Dba::fetch_assoc($db_results)) {
+ return true;
+ }
- return false;
+ return false;
} // exists
@@ -205,23 +205,23 @@ class Access {
* delete
* deletes the specified access_list entry
*/
- public static function delete($access_id) {
+ public static function delete($access_id) {
$sql = "DELETE FROM `access_list` WHERE `id`='" . Dba::escape($access_id) . "'";
$db_results = Dba::write($sql);
} // delete
-
+
/**
* check_function
* This checks if a specific functionality is enabled
* it takes a type only
*/
- public static function check_function($type) {
+ public static function check_function($type) {
- switch ($type) {
- case 'download':
- return Config::get('download');
+ switch ($type) {
+ case 'download':
+ return Config::get('download');
break ;
case 'batch_download':
if (!function_exists('gzcompress')) {
@@ -233,37 +233,37 @@ class Access {
}
break;
default:
- return false;
+ return false;
break;
- } // end switch
+ } // end switch
} // check_function
/**
* check_network
- * This takes a type, ip, user, level and key
+ * This takes a type, ip, user, level and key
* and then returns true or false if they have access to this
* the IP is passed as a dotted quad
*/
- public static function check_network($type,$user,$level,$ip='') {
-
- if (!Config::get('access_control')) {
- switch ($type) {
- case 'interface':
- case 'stream':
- return true;
- break;
- default:
- return false;
+ public static function check_network($type,$user,$level,$ip='') {
+
+ if (!Config::get('access_control')) {
+ switch ($type) {
+ case 'interface':
+ case 'stream':
+ return true;
+ break;
+ default:
+ return false;
} // end switch
} // end if access control is turned off
// Clean incomming variables
- $ip = $ip ? Dba::escape(inet_pton($ip)) : Dba::escape(inet_pton($_SERVER['REMOTE_ADDR']));
+ $ip = $ip ? Dba::escape(inet_pton($ip)) : Dba::escape(inet_pton($_SERVER['REMOTE_ADDR']));
$user = Dba::escape($user);
$level = Dba::escape($level);
- switch ($type) {
+ switch ($type) {
/* This is here because we want to at least check IP before even creating the xml-rpc server
* however we don't have the key that was passed yet so we've got to do just ip
*/
@@ -272,39 +272,39 @@ class Access {
$sql = "SELECT `id` FROM `access_list`" .
" WHERE `start` <= '$ip' AND `end` >= '$ip' AND `type`='rpc' AND `level` >= '$level'";
break;
- case 'rpc':
+ case 'rpc':
case 'xml-rpc':
- $sql = "SELECT `id` FROM `access_list`" .
- " WHERE `start` <= '$ip' AND `end` >= '$ip'" .
+ $sql = "SELECT `id` FROM `access_list`" .
+ " WHERE `start` <= '$ip' AND `end` >= '$ip'" .
" AND `level` >= '$level' AND `type`='rpc'";
break;
case 'init-api':
$type = 'rpc';
- if ($user) {
- $client = User::get_from_username($user);
- $user = $client->id;
- }
+ if ($user) {
+ $client = User::get_from_username($user);
+ $user = $client->id;
+ }
case 'network':
case 'interface':
case 'stream':
default:
- $sql = "SELECT `id` FROM `access_list`" .
+ $sql = "SELECT `id` FROM `access_list`" .
" WHERE `start` <= '$ip' AND `end` >= '$ip'" .
" AND `level` >= '$level' AND `type` = '$type'";
if (strlen($user)) { $sql .= " AND (`user` = '$user' OR `user` = '-1')"; }
else { $sql .= " AND `user` = '-1'"; }
break;
} // end switch on type
-
+
$db_results = Dba::read($sql);
// Yah they have access they can use the mojo
- if (Dba::fetch_row($db_results)) {
+ if (Dba::fetch_row($db_results)) {
return true;
}
// No Access Sucks to be them.
- else {
+ else {
return false;
}
@@ -315,40 +315,40 @@ class Access {
* This is the global 'has_access' function it can check for any 'type' of object
* everything uses the global 0,5,25,50,75,100 stuff. GLOBALS['user'] is always used
*/
- public static function check($type,$level) {
+ public static function check($type,$level) {
- if (Config::get('demo_mode')) { return true; }
- if (INSTALL == '1') { return true; }
+ if (Config::get('demo_mode')) { return true; }
+ if (INSTALL == '1') { return true; }
- $level = intval($level);
+ $level = intval($level);
// Switch on the type
- switch ($type) {
- case 'localplay':
- // Check their localplay_level
- if (Config::get('localplay_level') >= $level OR $GLOBALS['user']->access >= '100') {
- return true;
- }
- else {
- return false;
- }
+ switch ($type) {
+ case 'localplay':
+ // Check their localplay_level
+ if (Config::get('localplay_level') >= $level OR $GLOBALS['user']->access >= '100') {
+ return true;
+ }
+ else {
+ return false;
+ }
break;
- case 'interface':
+ case 'interface':
// Check their standard user level
- if ($GLOBALS['user']->access >= $level) {
- return true;
- }
- else {
- return false;
- }
+ if ($GLOBALS['user']->access >= $level) {
+ return true;
+ }
+ else {
+ return false;
+ }
break;
default:
- return false;
- break;
+ return false;
+ break;
} // end switch on type
// Default false
- return false;
+ return false;
} // check
@@ -356,9 +356,9 @@ class Access {
* validate_type
* This cleans up and validates the specified type
*/
- public static function validate_type($type) {
+ public static function validate_type($type) {
- switch($type) {
+ switch($type) {
case 'rpc':
case 'interface':
case 'network':
@@ -366,8 +366,8 @@ class Access {
break;
case 'xml-rpc':
return 'rpc';
- break;
- default:
+ break;
+ default:
return 'stream';
break;
} // end switch
@@ -378,13 +378,13 @@ class Access {
* get_access_lists
* returns a full listing of all access rules on this server
*/
- public static function get_access_lists() {
+ public static function get_access_lists() {
$sql = "SELECT `id` FROM `access_list`";
$db_results = Dba::read($sql);
-
- $results = array();
-
+
+ $results = array();
+
// Man this is the wrong way to do it...
while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row['id'];
@@ -395,22 +395,22 @@ class Access {
} // get_access_lists
- /**
+ /**
* get_level_name
* take the int level and return a named level
*/
- public function get_level_name() {
+ public function get_level_name() {
- if ($this->level >= '75') {
+ if ($this->level >= '75') {
return _('All');
}
- if ($this->level == '5') {
- return _('View');
+ if ($this->level == '5') {
+ return _('View');
}
- if ($this->level == '25') {
+ if ($this->level == '25') {
return _('Read');
}
- if ($this->level == '50') {
+ if ($this->level == '50') {
return _('Read/Write');
}
@@ -420,23 +420,23 @@ class Access {
* get_user_name
* Take a user and return their full name
*/
- public function get_user_name() {
+ public function get_user_name() {
+
+ if ($this->user == '-1') { return _('All'); }
- if ($this->user == '-1') { return _('All'); }
-
$user = new User($this->user);
return $user->fullname . " (" . $user->username . ")";
-
+
} // get_user_name
/**
* get_type_name
* This function returns the pretty name for our current type
*/
- public function get_type_name() {
+ public function get_type_name() {
- switch ($this->type) {
- case 'xml-rpc':
+ switch ($this->type) {
+ case 'xml-rpc':
case 'rpc':
return _('API/RPC');
break;
@@ -447,7 +447,7 @@ class Access {
return _('Web Interface');
break;
case 'stream':
- default:
+ default:
return _('Stream Access');
break;
} // end switch
@@ -460,35 +460,35 @@ class Access {
* exists, it also provides an array of key'd data that may be required
* based on the type
*/
- public static function session_exists($data,$key,$type) {
+ public static function session_exists($data,$key,$type) {
// Switch on the type they pass
- switch ($type) {
- case 'api':
- $key = Dba::escape($key);
- $time = time();
- $sql = "SELECT * FROM `session_api` WHERE `id`='$key' AND `expire` > '$time'";
- $db_results = Dba::read($sql);
-
- if (Dba::num_rows($db_results)) {
- $time = $time + 3600;
- $sql = "UPDATE `session_api` WHERE `id`='$key' SET `expire`='$time'";
- $db_results = Dba::write($sql);
- return true;
- }
-
- return false;
-
- break;
- case 'stream':
-
- break;
- case 'interface':
-
- break;
- default:
- return false;
- break;
+ switch ($type) {
+ case 'api':
+ $key = Dba::escape($key);
+ $time = time();
+ $sql = "SELECT * FROM `session_api` WHERE `id`='$key' AND `expire` > '$time'";
+ $db_results = Dba::read($sql);
+
+ if (Dba::num_rows($db_results)) {
+ $time = $time + 3600;
+ $sql = "UPDATE `session_api` WHERE `id`='$key' SET `expire`='$time'";
+ $db_results = Dba::write($sql);
+ return true;
+ }
+
+ return false;
+
+ break;
+ case 'stream':
+
+ break;
+ case 'interface':
+
+ break;
+ default:
+ return false;
+ break;
} // type
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php
index 5381f529..38c451a9 100644
--- a/lib/class/ajax.class.php
+++ b/lib/class/ajax.class.php
@@ -25,15 +25,15 @@
* This class is specifically for setuping/printing out ajax related
* elements onto a page it takes care of the observing and all that raz-a-ma-taz
*/
-class Ajax {
+class Ajax {
- private static $include_override;
+ private static $include_override;
/**
* constructor
* This is what is called when the class is loaded
*/
- public function __construct() {
+ public function __construct() {
// Rien a faire
@@ -43,7 +43,7 @@ class Ajax {
* observe
* This returns a string with the correct and full ajax 'observe' stuff from prototype
*/
- public static function observe($source,$method,$action,$post='') {
+ public static function observe($source,$method,$action,$post='') {
$non_quoted = array('document','window');
@@ -55,15 +55,15 @@ class Ajax {
}
// If it's a post then we need to stop events
- if ($post) {
- $action = 'Event.stop(e); ' . $action;
- }
+ if ($post) {
+ $action = 'Event.stop(e); ' . $action;
+ }
$observe = "<script type=\"text/javascript\">";
$observe .= "Event.observe($source_txt,'$method',function(e){" . $action . ";});";
$observe .= "</script>";
- return $observe;
+ return $observe;
} // observe
@@ -72,9 +72,9 @@ class Ajax {
* This takes the action, the source and the post (if passed) and generated the full
* ajax link
*/
- public static function action($action,$source,$post='') {
+ public static function action($action,$source,$post='') {
- $url = Config::get('ajax_url') . $action;
+ $url = Config::get('ajax_url') . $action;
$non_quoted = array('document','window');
@@ -85,14 +85,14 @@ class Ajax {
$source_txt = "'$source'";
}
- if ($post) {
- $ajax_string = "ajaxPost('$url','$post',$source_txt)";
+ if ($post) {
+ $ajax_string = "ajaxPost('$url','$post',$source_txt)";
+ }
+ else {
+ $ajax_string = "ajaxPut('$url',$source_txt)";
}
- else {
- $ajax_string = "ajaxPut('$url',$source_txt)";
- }
-
- return $ajax_string;
+
+ return $ajax_string;
} // action
@@ -101,24 +101,24 @@ class Ajax {
* This prints out an img of the specified icon with the specified alt text
* and then sets up the required ajax for it
*/
- public static function button($action,$icon,$alt,$source='',$post='',$class='') {
+ public static function button($action,$icon,$alt,$source='',$post='',$class='') {
// Get the correct action
- $ajax_string = self::action($action,$source,$post);
+ $ajax_string = self::action($action,$source,$post);
// If they passed a span class
- if ($class) {
- $class_txt = ' class="' . $class . '"';
- }
+ if ($class) {
+ $class_txt = ' class="' . $class . '"';
+ }
- $string = get_user_icon($icon,$alt);
+ $string = get_user_icon($icon,$alt);
// Generate a <a> so that it's more compliant with older browsers
// (ie :hover actions) and also to unify linkbuttons (w/o ajax) display
- $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class_txt>".$string."</a>\n";
+ $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class_txt>".$string."</a>\n";
- $string .= self::observe($source,'click',$ajax_string);
+ $string .= self::observe($source,'click',$ajax_string);
return $string;
@@ -129,22 +129,22 @@ class Ajax {
* This prints out the specified text as a link and setups the required
* ajax for the link so it works correctly
*/
- public static function text($action,$text,$source,$post='',$class='') {
+ public static function text($action,$text,$source,$post='',$class='') {
// Format the string we wanna use
- $ajax_string = self::action($action,$source,$post);
+ $ajax_string = self::action($action,$source,$post);
// If they passed a span class
- if ($class) {
- $class_txt = ' class="' . $class . '"';
- }
+ if ($class) {
+ $class_txt = ' class="' . $class . '"';
+ }
// If we pass a source put it in the ID
- $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class_txt>$text</a>\n";
+ $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class_txt>$text</a>\n";
- $string .= self::observe($source,'click',$ajax_string);
+ $string .= self::observe($source,'click',$ajax_string);
- return $string;
+ return $string;
} // text
@@ -152,11 +152,11 @@ class Ajax {
* run
* This runs the specified action no questions asked
*/
- public static function run($action) {
+ public static function run($action) {
- echo "<script type=\"text/javascript\"><!--\n";
- echo "$action";
- echo "\n--></script>";
+ echo "<script type=\"text/javascript\"><!--\n";
+ echo "$action";
+ echo "\n--></script>";
} // run
@@ -164,22 +164,22 @@ class Ajax {
* set_include_override
* This sets the cinlduing div override, used only one place kind of a hack
*/
- public static function set_include_override($value) {
+ public static function set_include_override($value) {
- self::$include_override = make_bool($value);
+ self::$include_override = make_bool($value);
} // set_include_override
/**
* start_container
- * This checks to see if we're AJAX'in if we aren't then it echos out the
+ * This checks to see if we're AJAX'in if we aren't then it echos out the
* html needed to start a container that can be replaced by Ajax
*/
- public static function start_container($name) {
+ public static function start_container($name) {
- if (AJAX_INCLUDE == '1' AND !self::$include_override) { return true; }
+ if (AJAX_INCLUDE == '1' AND !self::$include_override) { return true; }
- echo '<div id="' . scrub_out($name) . '">';
+ echo '<div id="' . scrub_out($name) . '">';
} // start_container
@@ -187,13 +187,13 @@ class Ajax {
* end_container
* This ends the container if we're not doing the AJAX thing
*/
- public static function end_container() {
+ public static function end_container() {
- if (AJAX_INCLUDE == '1' AND !self::$include_override) { return true; }
+ if (AJAX_INCLUDE == '1' AND !self::$include_override) { return true; }
- echo "</div>";
+ echo "</div>";
- self::$include_override = false;
+ self::$include_override = false;
} // end_container
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 144fcf4f..bf8c6d40 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
@@ -30,20 +30,20 @@ class Album extends database_object {
/* Variables from DB */
public $id;
public $name;
- public $full_name; // Prefix + Name, genereated by format();
- public $disk;
+ public $full_name; // Prefix + Name, genereated by format();
+ public $disk;
public $year;
public $prefix;
public $mbid; // MusicBrainz ID
/* Art Related Fields */
public $art;
- public $art_mime;
- public $thumb;
+ public $art_mime;
+ public $thumb;
public $thumb_mime;
// cached information
- public $_songs=array();
+ public $_songs=array();
/**
* __construct
@@ -54,20 +54,20 @@ class Album extends database_object {
*/
public function __construct($id='') {
- if (!$id) { return false; }
+ if (!$id) { return false; }
/* Get the information from the db */
$info = $this->get_info($id);
-
+
// Foreach what we've got
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
// Little bit of formating here
$this->full_name = trim($info['prefix'] . ' ' . $info['name']);
- return true;
+ return true;
} // constructor
@@ -76,17 +76,17 @@ class Album extends database_object {
* This is often used by the metadata class, it fills out an album object from a
* named array, _fake is set to true
*/
- public static function construct_from_array($data) {
+ public static function construct_from_array($data) {
- $album = new Album(0);
- foreach ($data as $key=>$value) {
- $album->$key = $value;
- }
+ $album = new Album(0);
+ foreach ($data as $key=>$value) {
+ $album->$key = $value;
+ }
// Make sure that we tell em it's fake
- $album->_fake = true;
+ $album->_fake = true;
- return $album;
+ return $album;
} // construct_from_array
@@ -98,19 +98,19 @@ class Album extends database_object {
public static function build_cache($ids,$extra=false) {
// Nothing to do if they pass us nothing
- if (!is_array($ids) OR !count($ids)) { return false; }
+ if (!is_array($ids) OR !count($ids)) { return false; }
$idlist = '(' . implode(',', $ids) . ')';
$sql = "SELECT * FROM `album` WHERE `id` IN $idlist";
$db_results = Dba::read($sql);
-
+
while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('album',$row['id'],$row);
+ parent::add_to_cache('album',$row['id'],$row);
}
// If we're extra'ing cache the extra info as well
- if ($extra) {
+ if ($extra) {
$sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,COUNT(song.id) AS song_count,artist.name AS artist_name" .
",artist.prefix AS artist_prefix,album_data.art AS has_art,album_data.thumb AS has_thumb, artist.id AS artist_id,`song`.`album`".
"FROM `song` " .
@@ -118,12 +118,12 @@ class Album extends database_object {
"LEFT JOIN `album_data` ON `album_data`.`album_id` = `song`.`album` " .
"WHERE `song`.`album` IN $idlist GROUP BY `song`.`album`";
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- $row['has_art'] = make_bool($row['has_art']);
- $row['has_thumb'] = make_bool($row['has_thumb']);
- parent::add_to_cache('album_extra',$row['album'],$row);
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $row['has_art'] = make_bool($row['has_art']);
+ $row['has_thumb'] = make_bool($row['has_thumb']);
+ parent::add_to_cache('album_extra',$row['album'],$row);
} // while rows
} // if extra
@@ -136,28 +136,28 @@ class Album extends database_object {
* This pulls the extra information from our tables, this is a 3 table join, which is why we don't normally
* do it
*/
- private function _get_extra_info() {
+ private function _get_extra_info() {
- if (parent::is_cached('album_extra',$this->id)) {
- return parent::get_from_cache('album_extra',$this->id);
- }
+ if (parent::is_cached('album_extra',$this->id)) {
+ return parent::get_from_cache('album_extra',$this->id);
+ }
- $sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,COUNT(song.id) AS song_count,artist.name AS artist_name" .
+ $sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,COUNT(song.id) AS song_count,artist.name AS artist_name" .
",artist.prefix AS artist_prefix,album_data.art AS has_art,album_data.thumb AS has_thumb, artist.id AS artist_id ".
"FROM `song` " .
"INNER JOIN `artist` ON `artist`.`id`=`song`.`artist` " .
- "LEFT JOIN `album_data` ON `album_data`.`album_id` = `song`.`album` " .
+ "LEFT JOIN `album_data` ON `album_data`.`album_id` = `song`.`album` " .
"WHERE `song`.`album`='$this->id' GROUP BY `song`.`album`";
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
- if ($results['has_art']) { $results['has_art'] = 1; }
- if ($results['has_thumb']) { $results['has_thumb'] = 1; }
+ if ($results['has_art']) { $results['has_art'] = 1; }
+ if ($results['has_thumb']) { $results['has_thumb'] = 1; }
- parent::add_to_cache('album_extra',$this->id,$results);
+ parent::add_to_cache('album_extra',$this->id,$results);
- return $results;
+ return $results;
} // _get_extra_info
@@ -167,19 +167,19 @@ class Album extends database_object {
* and an optional artist, if artist is passed it only gets
* songs with this album + specified artist
*/
- public function get_songs($limit = 0,$artist='') {
+ public function get_songs($limit = 0,$artist='') {
$results = array();
-
- if ($artist) {
+
+ if ($artist) {
$artist_sql = "AND `artist`='" . Dba::escape($artist) . "'";
- }
+ }
$sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' $artist_sql ORDER BY `track`, `title`";
if ($limit) { $sql .= " LIMIT $limit"; }
$db_results = Dba::read($sql);
- while ($r = Dba::fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id'];
}
@@ -189,20 +189,20 @@ class Album extends database_object {
/**
* has_art
- * This returns true or false depending on if we find any art for this
- * album.
+ * This returns true or false depending on if we find any art for this
+ * album.
*/
- public function has_art() {
+ public function has_art() {
- $sql = "SELECT `album_id` FROM `album_data` WHERE `album_id`='" . $this->id . "' AND art IS NOT NULL";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `album_id` FROM `album_data` WHERE `album_id`='" . $this->id . "' AND art IS NOT NULL";
+ $db_results = Dba::read($sql);
- if (Dba::fetch_assoc($db_results)) {
- $this->has_art = true;
- return true;
- }
+ if (Dba::fetch_assoc($db_results)) {
+ $this->has_art = true;
+ return true;
+ }
- return false;
+ return false;
} // has_art
@@ -210,16 +210,16 @@ class Album extends database_object {
* has_track
* This checks to see if this album has a track of the specified title
*/
- public function has_track($title) {
+ public function has_track($title) {
- $title = Dba::escape($title);
+ $title = Dba::escape($title);
- $sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' AND `title`='$title'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' AND `title`='$title'";
+ $db_results = Dba::read($sql);
- $data = Dba::fetch_assoc($db_results);
+ $data = Dba::fetch_assoc($db_results);
- return $data;
+ return $data;
} // has_track
@@ -229,48 +229,48 @@ class Album extends database_object {
* album information with the base required
* f_link, f_name
*/
- public function format() {
+ public function format() {
$web_path = Config::get('web_path');
/* Pull the advanced information */
- $data = $this->_get_extra_info();
- foreach ($data as $key=>$value) { $this->$key = $value; }
-
+ $data = $this->_get_extra_info();
+ foreach ($data as $key=>$value) { $this->$key = $value; }
+
/* Truncate the string if it's to long */
$this->f_name = truncate_with_ellipsis($this->full_name,Config::get('ellipse_threshold_album'));
$this->f_name_link = "<a href=\"$web_path/albums.php?action=show&amp;album=" . scrub_out($this->id) . "\" title=\"" . scrub_out($this->full_name) . "\">" . $this->f_name;
// If we've got a disk append it
- if ($this->disk) {
+ if ($this->disk) {
$this->f_name_link .= " <span class=\"discnb disc" .$this->disk. "\">[" . _('Disk') . " " . $this->disk . "]</span>";
- }
+ }
$this->f_name_link .="</a>";
-
- $this->f_link = $this->f_name_link;
- $this->f_title = $full_name;
- if ($this->artist_count == '1') {
+
+ $this->f_link = $this->f_name_link;
+ $this->f_title = $full_name;
+ if ($this->artist_count == '1') {
$artist = scrub_out(truncate_with_ellipsis(trim($this->artist_prefix . ' ' . $this->artist_name),Config::get('ellipse_threshold_artist')));
$this->f_artist_link = "<a href=\"$web_path/artists.php?action=show&amp;artist=" . $this->artist_id . "\" title=\"" . scrub_out($this->artist_name) . "\">" . $artist . "</a>";
- $this->f_artist = $artist;
+ $this->f_artist = $artist;
}
else {
- $this->f_artist_link = "<span title=\"$this->artist_count " . _('Artists') . "\">" . _('Various') . "</span>";
+ $this->f_artist_link = "<span title=\"$this->artist_count " . _('Artists') . "\">" . _('Various') . "</span>";
$this->f_artist = _('Various');
}
- if ($this->year == '0') {
+ if ($this->year == '0') {
$this->year = "N/A";
}
- $tags = Tag::get_top_tags('album',$this->id);
- $this->tags = $tags;
+ $tags = Tag::get_top_tags('album',$this->id);
+ $this->tags = $tags;
+
+ $this->f_tags = Tag::get_display($tags,$this->id,'album');
- $this->f_tags = Tag::get_display($tags,$this->id,'album');
-
// Format the artist name to include the prefix
- $this->f_artist_name = trim($this->artist_prefix . ' ' . $this->artist_name);
+ $this->f_artist_name = trim($this->artist_prefix . ' ' . $this->artist_name);
} // format
@@ -280,15 +280,15 @@ class Album extends database_object {
* it trys to pull the resized art instead, if resized art is found then
* it returns an additional resized=true in the array
*/
- public function get_art($return_raw=false) {
+ public function get_art($return_raw=false) {
// Attempt to get the resized art first
- if (!$return_raw) {
- $art = $this->get_resized_db_art();
- }
-
- if (!is_array($art)) {
- $art = $this->get_db_art();
+ if (!$return_raw) {
+ $art = $this->get_resized_db_art();
+ }
+
+ if (!is_array($art)) {
+ $art = $this->get_db_art();
}
return $art['0'];
@@ -300,57 +300,57 @@ class Album extends database_object {
* This function searches for album art using all configured methods
* for the current album. There is an optional 'limit' passed that will
* gather up to the specified number of possible album covers.
- * There is also an optional array of options the possible options are
+ * There is also an optional array of options the possible options are
* ['keyword'] = STRING
* ['artist'] = STRING
* ['album_name'] = STRING
*/
- public function find_art($options=array(),$limit='') {
+ public function find_art($options=array(),$limit='') {
/* Create Base Vars */
- $results = array();
+ $results = array();
/* Attempt to retrive the album art order */
$config_value = Config::get('album_art_order');
- $class_methods = get_class_methods('Album');
-
+ $class_methods = get_class_methods('Album');
+
/* If it's not set */
- if (empty($config_value)) {
+ if (empty($config_value)) {
// They don't want art!
- return array();
+ return array();
}
- elseif (!is_array($config_value)) {
- $config_value = array($config_value);
+ elseif (!is_array($config_value)) {
+ $config_value = array($config_value);
}
-
- foreach ($config_value AS $method) {
-
- $data = array();
-
+
+ foreach ($config_value AS $method) {
+
+ $data = array();
+
$method_name = "get_" . $method . "_art";
- if (in_array($method_name,$class_methods)) {
+ if (in_array($method_name,$class_methods)) {
// Some of these take options!
- switch ($method_name) {
+ switch ($method_name) {
case 'get_amazon_art':
- $data = $this->{$method_name}($options['keyword'],$limit);
+ $data = $this->{$method_name}($options['keyword'],$limit);
break;
case 'get_lastfm_art':
- $data = $this->{$method_name}($limit,$options);
+ $data = $this->{$method_name}($limit,$options);
+ break;
+ case 'get_google_art':
+ $data = $this->{$method_name}($limit);
break;
- case 'get_google_art':
- $data = $this->{$method_name}($limit);
- break;
default:
- $data = $this->{$method_name}($limit);
- break;
- }
+ $data = $this->{$method_name}($limit);
+ break;
+ }
// Add the results we got to the current set
- $total_results += count($data);
- // HACK for PHP 5, $data must be cast as array $results = array_merge($results, (array)$data);
- $results = array_merge($results,(array)$data);
-
- if ($total_results > $limit AND $limit > 0) {
+ $total_results += count($data);
+ // HACK for PHP 5, $data must be cast as array $results = array_merge($results, (array)$data);
+ $results = array_merge($results,(array)$data);
+
+ if ($total_results > $limit AND $limit > 0) {
return $results;
}
@@ -358,28 +358,28 @@ class Album extends database_object {
} // end foreach
- return $results;
-
+ return $results;
+
} // find_art
/**
* get_lastfm_art
* This returns the art as pulled from lastFM. This doesn't require
- * a special account, we just parse and run with it.
+ * a special account, we just parse and run with it.
*/
- public function get_lastfm_art($limit,$options='') {
+ public function get_lastfm_art($limit,$options='') {
// Create the parser object
- $lastfm = new LastFMSearch();
+ $lastfm = new LastFMSearch();
- if (is_array($options)) {
+ if (is_array($options)) {
$artist = $options['artist'];
- $album = $options['album_name'];
- }
- else {
- $artist = $this->artist_name;
- $album = $this->full_name;
- }
+ $album = $options['album_name'];
+ }
+ else {
+ $artist = $this->artist_name;
+ $album = $this->full_name;
+ }
if(Config::get('proxy_host') AND Config::get('proxy_port')) {
$proxyhost = Config::get('proxy_host');
@@ -389,31 +389,31 @@ class Album extends database_object {
debug_event("lastfm", "set Proxy", "5");
$lastfm->setProxy($proxyhost, $proxyport, $proxyuser, $proxypass);
}
- $raw_data = $lastfm->album_search($artist,$album);
+ $raw_data = $lastfm->album_search($artist,$album);
- if (!count($raw_data)) { return array(); }
+ if (!count($raw_data)) { return array(); }
- $coverart = $raw_data['coverart'];
+ $coverart = $raw_data['coverart'];
- ksort($coverart);
-
- foreach ($coverart as $key=>$value) {
- $i++;
- $url = $coverart[$key];
+ ksort($coverart);
+
+ foreach ($coverart as $key=>$value) {
+ $i++;
+ $url = $coverart[$key];
// We need to check the URL for the /noimage/ stuff
- if (strstr($url,"/noimage/")) {
- debug_event('LastFM','Detected as noimage, skipped ' . $url,'3');
- continue;
- }
-
- $results = pathinfo($url);
- $mime = 'image/' . $results['extension'];
- $data[] = array('url'=>$url,'mime'=>$mime);
- if ($i >= $limit) { return $data; }
+ if (strstr($url,"/noimage/")) {
+ debug_event('LastFM','Detected as noimage, skipped ' . $url,'3');
+ continue;
+ }
+
+ $results = pathinfo($url);
+ $mime = 'image/' . $results['extension'];
+ $data[] = array('url'=>$url,'mime'=>$mime);
+ if ($i >= $limit) { return $data; }
} // end foreach
- return $data;
+ return $data;
} // get_lastfm_art
@@ -423,29 +423,29 @@ class Album extends database_object {
*/
public function get_google_art($limit='') {
$images = array();
-
+
$search = $this->full_name;
-
+
if ($this->artist_count == '1')
$search = $this->artist_name . ', ' . $search;
-
+
$search = rawurlencode($search);
-
+
//$size = ''; // Any
$size = '&imgsz=m'; // Medium
//$size = '&imgsz=l'; // Large
-
+
$html = file_get_contents("http://images.google.com/images?source=hp&q=$search&oq=&um=1&ie=UTF-8&sa=N&tab=wi&start=0&tbo=1$size");
-
+
if(preg_match_all("|\ssrc\=\"(http.+?)\"|", $html, $matches, PREG_PATTERN_ORDER))
foreach ($matches[1] as $match) {
$extension = "image/jpeg";
-
+
if (strrpos($extension, '.') !== false) $extension = substr($extension, strrpos($extension, '.') + 1);
-
+
$images[] = array('url' => $match, 'mime' => $extension);
}
-
+
return $images;
} // get_google_art
@@ -453,39 +453,39 @@ class Album extends database_object {
@function get_id3_art
@discussion looks for art from the id3 tags
*/
- function get_id3_art($limit='') {
+ function get_id3_art($limit='') {
// grab the songs and define our results
- if (!count($this->_songs)) {
- $this->_songs = $this->get_songs();
- }
- $data = array();
+ if (!count($this->_songs)) {
+ $this->_songs = $this->get_songs();
+ }
+ $data = array();
// Foreach songs in this album
- foreach ($this->_songs as $song_id) {
- $song = new Song($song_id);
+ foreach ($this->_songs as $song_id) {
+ $song = new Song($song_id);
// If we find a good one, stop looking
$getID3 = new getID3();
- try { $id3 = $getID3->analyze($song->file); }
- catch (Exception $error) {
- debug_event('getid3',$error->message,'1');
- }
+ try { $id3 = $getID3->analyze($song->file); }
+ catch (Exception $error) {
+ debug_event('getid3',$error->message,'1');
+ }
- if ($id3['format_name'] == "WMA") {
+ if ($id3['format_name'] == "WMA") {
$image = $id3['asf']['extended_content_description_object']['content_descriptors']['13'];
$data[] = array('song'=>$song->file,'raw'=>$image['data'],'mime'=>$image['mime']);
}
- elseif (isset($id3['id3v2']['APIC'])) {
- // Foreach incase they have more then one
- foreach ($id3['id3v2']['APIC'] as $image) {
+ elseif (isset($id3['id3v2']['APIC'])) {
+ // Foreach incase they have more then one
+ foreach ($id3['id3v2']['APIC'] as $image) {
$data[] = array('song'=>$song->file,'raw'=>$image['data'],'mime'=>$image['mime']);
- }
+ }
}
- if (!empty($limit) && $limit < count($data)) {
- return $data;
+ if (!empty($limit) && $limit < count($data)) {
+ return $data;
}
-
+
} // end foreach
return $data;
@@ -498,32 +498,32 @@ class Album extends database_object {
* If a limit is passed or the preferred filename is found the current results set
* is returned
*/
- function get_folder_art($limit='') {
+ function get_folder_art($limit='') {
- if (!count($this->_songs)) {
+ if (!count($this->_songs)) {
$this->_songs = $this->get_songs();
- }
- $data = array();
+ }
+ $data = array();
/* See if we are looking for a specific filename */
$preferred_filename = Config::get('album_art_preferred_filename');
// Init a horrible hack array of lameness
- $cache =array();
-
+ $cache =array();
+
/* Thanks to dromio for origional code */
/* Added search for any .jpg, png or .gif - Vollmer */
- foreach($this->_songs as $song_id) {
+ foreach($this->_songs as $song_id) {
$song = new Song($song_id);
$dir = dirname($song->file);
- debug_event('folder_art',"Opening $dir and checking for Album Art",'3');
+ debug_event('folder_art',"Opening $dir and checking for Album Art",'3');
/* Open up the directory */
$handle = @opendir($dir);
if (!is_resource($handle)) {
- Error::add('general',_('Error: Unable to open') . ' ' . $dir);
+ Error::add('general',_('Error: Unable to open') . ' ' . $dir);
debug_event('read',"Error: Unable to open $dir for album art read",'2');
}
@@ -532,18 +532,18 @@ class Album extends database_object {
$extension = substr($file,strlen($file)-3,4);
/* If it's an image file */
- if ($extension == "jpg" || $extension == "gif" || $extension == "png" || $extension == "jp2" || $extension == "bmp") {
+ if ($extension == "jpg" || $extension == "gif" || $extension == "png" || $extension == "jp2" || $extension == "bmp") {
- if ($extension == 'jpg') { $extension = 'jpeg'; }
+ if ($extension == 'jpg') { $extension = 'jpeg'; }
// HACK ALERT this is to prevent duplicate filenames
- $full_filename = $dir . '/' . $file;
- $index = md5($full_filename);
+ $full_filename = $dir . '/' . $file;
+ $index = md5($full_filename);
/* Make sure it's got something in it */
- if (!filesize($dir . '/' . $file)) { continue; }
+ if (!filesize($dir . '/' . $file)) { continue; }
- if ($file == $preferred_filename) {
+ if ($file == $preferred_filename) {
// If we found the preferred filename we're done, wipe out previous results
$data = array(array('file' => $full_filename, 'mime' => 'image/' . $extension));
return $data;
@@ -551,17 +551,17 @@ class Album extends database_object {
elseif (!isset($cache[$index])) {
$data[] = array('file' => $full_filename, 'mime' => 'image/' . $extension);
}
-
- $cache[$index] = '1';
-
+
+ $cache[$index] = '1';
+
} // end if it's an image
-
+
} // end while reading dir
@closedir($handle);
-
- if (!empty($limit) && $limit < count($data)) {
- return $data;
- }
+
+ if (!empty($limit) && $limit < count($data)) {
+ return $data;
+ }
} // end foreach songs
@@ -574,18 +574,18 @@ class Album extends database_object {
* This looks to see if we have a resized thumbnail that we can load rather then taking
* the fullsized and resizing that
*/
- public function get_resized_db_art() {
+ public function get_resized_db_art() {
- $id = Dba::escape($this->id);
+ $id = Dba::escape($this->id);
$sql = "SELECT `thumb` AS `art`,`thumb_mime` AS `art_mime` FROM `album_data` WHERE `album_id`='$id'";
- $db_results = Dba::read($sql);
-
- $results = Dba::fetch_assoc($db_results);
- if (strlen($results['art_mime'])) {
- $results['resized'] = true;
- }
- else { return false; }
+ $db_results = Dba::read($sql);
+
+ $results = Dba::fetch_assoc($db_results);
+ if (strlen($results['art_mime'])) {
+ $results['resized'] = true;
+ }
+ else { return false; }
$data = array(array('db_resized'=>$this->id,'raw'=>$results['art'],'mime'=>$results['art_mime']));
@@ -604,10 +604,10 @@ class Album extends database_object {
$results = Dba::fetch_assoc($db_results);
- if (!$results['art']) { return array(); }
+ if (!$results['art']) { return array(); }
+
+ $data = array(array('db'=>$this->id,'raw'=>$results['art'],'mime'=>$results['art_mime']));
- $data = array(array('db'=>$this->id,'raw'=>$results['art'],'mime'=>$results['art_mime']));
-
return $data;
} // get_db_art
@@ -672,7 +672,7 @@ class Album extends database_object {
}
// The next bit is based directly on the MusicBrainz server code that displays cover art.
- // I'm leaving in the releaseuri info for the moment, though it's not going to be used.
+ // I'm leaving in the releaseuri info for the moment, though it's not going to be used.
$coverartsites[] = array(
name => "CD Baby",
domain => "cdbaby.com",
@@ -729,7 +729,7 @@ class Album extends database_object {
imguri => '$matches[1]',
releaseuri => '',
);
-
+
foreach ($release->getRelations($mbRelation->TO_URL) as $ar) {
$arurl = $ar->getTargetId();
debug_event('mbz-gatherart', "Found URL AR: " . $arurl , '5');
@@ -766,16 +766,16 @@ class Album extends database_object {
$images = array();
$final_results = array();
$possible_keys = array("LargeImage","MediumImage","SmallImage");
-
+
// Prevent the script from timing out
set_time_limit(0);
- if (empty($keywords)) {
+ if (empty($keywords)) {
$keywords = $this->full_name;
/* If this isn't a various album combine with artist name */
if ($this->artist_count == '1') { $keywords .= ' ' . $this->artist_name; }
}
-
+
/* Create Base Vars */
$amazon_base_urls = array();
@@ -783,18 +783,18 @@ class Album extends database_object {
$config_value = Config::get('amazon_base_urls');
/* If it's not set */
- if (empty($config_value)) {
+ if (empty($config_value)) {
$amazon_base_urls = array('http://webservices.amazon.com');
}
- elseif (!is_array($config_value)) {
+ elseif (!is_array($config_value)) {
array_push($amazon_base_urls,$config_value);
}
- else {
+ else {
$amazon_base_urls = array_merge($amazon_base_urls, Config::get('amazon_base_urls'));
}
/* Foreach through the base urls that we should check */
- foreach ($amazon_base_urls AS $amazon_base) {
+ foreach ($amazon_base_urls AS $amazon_base) {
// Create the Search Object
$amazon = new AmazonSearch(Config::get('amazon_developer_public_key'), Config::get('amazon_developer_private_key'), $amazon_base);
@@ -813,24 +813,24 @@ class Album extends database_object {
$max_pages_to_search = max(Config::get('max_amazon_results_pages'),$amazon->_default_results_pages);
$pages_to_search = $max_pages_to_search; //init to max until we know better.
- // while we have pages to search
+ // while we have pages to search
do {
- $raw_results = $amazon->search(array('artist'=>$artist,'album'=>$albumname,'keywords'=>$keywords));
+ $raw_results = $amazon->search(array('artist'=>$artist,'album'=>$albumname,'keywords'=>$keywords));
- $total = count($raw_results) + count($search_results);
+ $total = count($raw_results) + count($search_results);
// If we've gotten more then we wanted
- if (!empty($limit) && $total > $limit) {
+ if (!empty($limit) && $total > $limit) {
// We don't want ot re-count every loop
- $i = $total;
- while ($i > $limit) {
- array_pop($raw_results);
+ $i = $total;
+ while ($i > $limit) {
+ array_pop($raw_results);
$i--;
- }
+ }
- debug_event('amazon-xml',"Found $total, Limit $limit reducing and breaking from loop",'5');
+ debug_event('amazon-xml',"Found $total, Limit $limit reducing and breaking from loop",'5');
// Merge the results and BREAK!
- $search_results = array_merge($search_results,$raw_results);
+ $search_results = array_merge($search_results,$raw_results);
break;
} // if limit defined
@@ -840,10 +840,10 @@ class Album extends database_object {
$amazon->_currentPage++;
} while($amazon->_currentPage < $pages_to_search);
-
+
// Only do the second search if the first actually returns something
- if (count($search_results)) {
+ if (count($search_results)) {
$final_results = $amazon->lookup($search_results);
}
@@ -851,30 +851,30 @@ class Album extends database_object {
debug_event('amazon-xml',"Searched using $keywords with " . Config::get('amazon_developer_key') . " as key " . count($final_results) . " results found",'5');
// If we've hit our limit
- if (!empty($limit) && count($final_results) >= $limit) {
- break;
- }
-
+ if (!empty($limit) && count($final_results) >= $limit) {
+ break;
+ }
+
} // end foreach
/* Foreach through what we've found */
- foreach ($final_results as $result) {
+ foreach ($final_results as $result) {
/* Recurse through the images found */
- foreach ($possible_keys as $key) {
- if (strlen($result[$key])) {
+ foreach ($possible_keys as $key) {
+ if (strlen($result[$key])) {
break;
- }
+ }
} // foreach
// Rudimentary image type detection, only JPG and GIF allowed.
if (substr($result[$key], -4 == '.jpg')) {
$mime = "image/jpeg";
}
- elseif (substr($result[$key], -4 == '.gif')) {
+ elseif (substr($result[$key], -4 == '.gif')) {
$mime = "image/gif";
}
- elseif (substr($result[$key], -4 == '.png')) {
+ elseif (substr($result[$key], -4 == '.png')) {
$mime = "image/png";
}
else {
@@ -884,31 +884,31 @@ class Album extends database_object {
$data['url'] = $result[$key];
$data['mime'] = $mime;
-
+
$images[] = $data;
- if (!empty($limit)) {
- if (count($images) >= $limit) {
- return $images;
- }
- }
+ if (!empty($limit)) {
+ if (count($images) >= $limit) {
+ return $images;
+ }
+ }
} // if we've got something
-
+
return $images;
- } // get_amazon_art
+ } // get_amazon_art
/**
* get_random_songs
* gets a random number, and a random assortment of songs from this album
*/
- function get_random_songs() {
+ function get_random_songs() {
$sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' ORDER BY RAND()";
$db_results = Dba::read($sql);
- while ($r = Dba::fetch_row($db_results)) {
+ while ($r = Dba::fetch_row($db_results)) {
$results[] = $r['0'];
}
@@ -921,49 +921,49 @@ class Album extends database_object {
* This function takes a key'd array of data and updates this object
* as needed, and then throws down with a flag
*/
- public function update($data) {
+ public function update($data) {
- $year = $data['year'];
- $artist = $data['artist'];
- $name = $data['name'];
+ $year = $data['year'];
+ $artist = $data['artist'];
+ $name = $data['name'];
$disk = $data['disk'];
- $mbid = $data['mbid'];
+ $mbid = $data['mbid'];
- $current_id = $this->id;
+ $current_id = $this->id;
- if ($artist != $this->artist_id AND $artist) {
+ if ($artist != $this->artist_id AND $artist) {
// Update every song
- $songs = $this->get_songs();
- foreach ($songs as $song_id) {
- Song::update_artist($artist,$song_id);
- }
- $updated = 1;
- Catalog::clean_artists();
- }
-
- $album_id = Catalog::check_album($name,$year,$disk,$mbid);
- if ($album_id != $this->id) {
- if (!is_array($songs)) { $songs = $this->get_songs(); }
- foreach ($songs as $song_id) {
- Song::update_album($album_id,$song_id);
+ $songs = $this->get_songs();
+ foreach ($songs as $song_id) {
+ Song::update_artist($artist,$song_id);
+ }
+ $updated = 1;
+ Catalog::clean_artists();
+ }
+
+ $album_id = Catalog::check_album($name,$year,$disk,$mbid);
+ if ($album_id != $this->id) {
+ if (!is_array($songs)) { $songs = $this->get_songs(); }
+ foreach ($songs as $song_id) {
+ Song::update_album($album_id,$song_id);
Song::update_year($year,$song_id);
- }
- $current_id = $album_id;
- $updated = 1;
- Catalog::clean_albums();
- }
+ }
+ $current_id = $album_id;
+ $updated = 1;
+ Catalog::clean_albums();
+ }
- if ($updated) {
+ if ($updated) {
// Flag all songs
- foreach ($songs as $song_id) {
- Flag::add($song_id,'song','retag','Interface Album Update');
- Song::update_utime($song_id);
+ foreach ($songs as $song_id) {
+ Flag::add($song_id,'song','retag','Interface Album Update');
+ Song::update_utime($song_id);
} // foreach song of album
- Catalog::clean_stats();
+ Catalog::clean_stats();
} // if updated
- return $current_id;
+ return $current_id;
} // update
@@ -971,8 +971,8 @@ class Album extends database_object {
* clear_art
* clears the album art from the DB
*/
- public function clear_art() {
-
+ public function clear_art() {
+
$sql = "UPDATE `album_data` SET `art`=NULL, `art_mime`=NULL, `thumb`=NULL, `thumb_mime`=NULL WHERE `album_id`='$this->id'";
$db_results = Dba::write($sql);
@@ -983,12 +983,12 @@ class Album extends database_object {
* this takes a string representation of an image
* and inserts it into the database. You must pass the mime type as well
*/
- public function insert_art($image, $mime) {
+ public function insert_art($image, $mime) {
/* Have to disable this for Demo because people suck and try to
- * insert PORN :(
+ * insert PORN :(
*/
- if (Config::get('demo_mode')) { return false; }
+ if (Config::get('demo_mode')) { return false; }
// Check for PHP:GD and if we have it make sure this image is of some size
if (function_exists('ImageCreateFromString')) {
@@ -997,17 +997,17 @@ class Album extends database_object {
return false;
}
} // if we have PHP:GD
- elseif (strlen($image) < 5) {
- return false;
- }
+ elseif (strlen($image) < 5) {
+ return false;
+ }
// Default to image/jpeg as a guess if there is no passed mime type
- $mime = $mime ? $mime : 'image/jpeg';
+ $mime = $mime ? $mime : 'image/jpeg';
// Push the image into the database
$sql = "REPLACE INTO `album_data` SET `art` = '" . Dba::escape($image) . "'," .
" `art_mime` = '" . Dba::escape($mime) . "'" .
- ", `album_id` = '$this->id'," .
+ ", `album_id` = '$this->id'," .
"`thumb` = NULL, `thumb_mime`=NULL";
$db_results = Dba::write($sql);
@@ -1020,18 +1020,18 @@ class Album extends database_object {
* This takes data from a gd resize operation and saves
* it back into the database as a thumbnail
*/
- public static function save_resized_art($data,$mime,$album) {
+ public static function save_resized_art($data,$mime,$album) {
// Make sure there's actually something to save
- if (strlen($data) < '5') { return false; }
+ if (strlen($data) < '5') { return false; }
- $data = Dba::escape($data);
- $mime = Dba::escape($mime);
- $album = Dba::escape($album);
+ $data = Dba::escape($data);
+ $mime = Dba::escape($mime);
+ $album = Dba::escape($album);
- $sql = "UPDATE `album_data` SET `thumb`='$data',`thumb_mime`='$mime' " .
+ $sql = "UPDATE `album_data` SET `thumb`='$data',`thumb_mime`='$mime' " .
"WHERE `album_data`.`album_id`='$album'";
- $db_results = Dba::write($sql);
+ $db_results = Dba::write($sql);
} // save_resized_art
@@ -1063,18 +1063,18 @@ class Album extends database_object {
while ($row = Dba::fetch_assoc($db_results)) {
$results[$row['album_id']] = $row['no_art'];
} // end for
-
+
asort($results);
$albums = array_keys($results);
$results = array_slice($albums,0,$count);
-
+
return $results;
} // get_random_albums
/**
* get_image_from_source
- * This gets an image for the album art from a source as
+ * This gets an image for the album art from a source as
* defined in the passed array. Because we don't know where
* its comming from we are a passed an array that can look like
* ['url'] = URL *** OPTIONAL ***
@@ -1090,7 +1090,7 @@ class Album extends database_object {
// If it came from the database
if (isset($data['db'])) {
- // Repull it
+ // Repull it
$album_id = Dba::escape($data['db']);
$sql = "SELECT * FROM `album_data` WHERE `album_id`='$album_id'";
$db_results = Dba::read($sql);
@@ -1118,18 +1118,18 @@ class Album extends database_object {
fclose($handle);
return $image_data;
}
-
+
// Check to see if it is embedded in id3 of a song
if (isset($data['song'])) {
// If we find a good one, stop looking
$getID3 = new getID3();
$id3 = $getID3->analyze($data['song']);
-
+
if ($id3['format_name'] == "WMA") {
return $id3['asf']['extended_content_description_object']['content_descriptors']['13']['data'];
}
elseif (isset($id3['id3v2']['APIC'])) {
- // Foreach incase they have more then one
+ // Foreach incase they have more then one
foreach ($id3['id3v2']['APIC'] as $image) {
return $image['data'];
}
@@ -1144,35 +1144,35 @@ class Album extends database_object {
* get_art_url
* This returns the art URL for the album
*/
- public static function get_art_url($album_id,$sid=false) {
+ public static function get_art_url($album_id,$sid=false) {
- $sid = $sid ? scrub_out($sid) : session_id();
+ $sid = $sid ? scrub_out($sid) : session_id();
- $sql = "SELECT `art_mime`,`thumb_mime` FROM `album_data` WHERE `album_id`='" . Dba::escape($album_id) . "'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `art_mime`,`thumb_mime` FROM `album_data` WHERE `album_id`='" . Dba::escape($album_id) . "'";
+ $db_results = Dba::read($sql);
- $row = Dba::fetch_assoc($db_results);
+ $row = Dba::fetch_assoc($db_results);
- $mime = $row['thumb_mime'] ? $row['thumb_mime'] : $row['art_mime'];
+ $mime = $row['thumb_mime'] ? $row['thumb_mime'] : $row['art_mime'];
- switch ($type) {
- case 'image/gif':
- $type = 'gif';
- break;
- case 'image/png':
- $type = 'png';
- break;
+ switch ($type) {
+ case 'image/gif':
+ $type = 'gif';
+ break;
+ case 'image/png':
+ $type = 'png';
+ break;
default:
- case 'image/jpeg':
- $type = 'jpg';
- break;
+ case 'image/jpeg':
+ $type = 'jpg';
+ break;
} // end type translation
- $name = 'art.' . $type;
+ $name = 'art.' . $type;
$url = Config::get('web_path') . '/image.php?id=' . scrub_out($album_id) . '&auth=' . $sid . '&name=' . $name;
- return $url;
+ return $url;
} // get_art_url
diff --git a/lib/class/ampacherss.class.php b/lib/class/ampacherss.class.php
index 8276bf77..897601bc 100644
--- a/lib/class/ampacherss.class.php
+++ b/lib/class/ampacherss.class.php
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
@@ -28,17 +28,17 @@
*/
class AmpacheRSS {
- private $type;
- public $data;
+ private $type;
+ public $data;
/**
* Constructor
* This takes a flagged.id and then pulls in the information for said flag entry
*/
- public function __construct($type) {
+ public function __construct($type) {
+
+ $this->type = self::validate_type($type);
- $this->type = self::validate_type($type);
-
} // constructor
/**
@@ -46,19 +46,19 @@ class AmpacheRSS {
* This returns the xmldocument for the current rss type, it calls a sub function that gathers the data
* and then uses the xmlDATA class to build the document
*/
- public function get_xml() {
+ public function get_xml() {
// Function call name
- $data_function = 'load_' . $this->type;
- $pub_date_function = 'pubdate_' . $this->type;
+ $data_function = 'load_' . $this->type;
+ $pub_date_function = 'pubdate_' . $this->type;
- $data = call_user_func(array('AmpacheRSS',$data_function));
- $pub_date = call_user_func(array('AmpacheRSS',$pub_date_function));
+ $data = call_user_func(array('AmpacheRSS',$data_function));
+ $pub_date = call_user_func(array('AmpacheRSS',$pub_date_function));
- xmlData::set_type('rss');
- $xml_document = xmlData::rss_feed($data,$this->get_title(),$this->get_description(),$pub_date);
+ xmlData::set_type('rss');
+ $xml_document = xmlData::rss_feed($data,$this->get_title(),$this->get_description(),$pub_date);
- return $xml_document;
+ return $xml_document;
} // get_xml
@@ -66,14 +66,14 @@ class AmpacheRSS {
* get_title
* This returns the standardized title for the rss feed based on this->type
*/
- public function get_title() {
+ public function get_title() {
$titles = array('now_playing'=>_('Now Playing'),
'recently_played'=>_('Recently Played'),
'latest_album'=>_('Newest Albums'),
- 'latest_artist'=>_('Newest Artists'));
+ 'latest_artist'=>_('Newest Artists'));
- return scrub_out(Config::get('site_title')) . ' - ' . $titles[$this->type];
+ return scrub_out(Config::get('site_title')) . ' - ' . $titles[$this->type];
} // get_title
@@ -81,10 +81,10 @@ class AmpacheRSS {
* get_description
* This returns the standardized description for the rss feed based on this->type
*/
- public function get_description() {
+ public function get_description() {
//FIXME: For now don't do any kind of translating
- return 'Ampache RSS Feeds';
+ return 'Ampache RSS Feeds';
} // get_description
@@ -92,16 +92,16 @@ class AmpacheRSS {
* validate_type
* this returns a valid type for an rss feed, if the specified type is invalid it returns a default value
*/
- public static function validate_type($type) {
+ public static function validate_type($type) {
$valid_types = array('now_playing','recently_played','latest_album','latest_artist','latest_song',
- 'popular_song','popular_album','popular_artist');
-
- if (!in_array($type,$valid_types)) {
- return 'now_playing';
- }
+ 'popular_song','popular_album','popular_artist');
+
+ if (!in_array($type,$valid_types)) {
+ return 'now_playing';
+ }
- return $type;
+ return $type;
} // validate_type
@@ -109,14 +109,14 @@ class AmpacheRSS {
* get_display
* This dumps out some html and an icon for the type of rss that we specify
*/
- public static function get_display($type='now_playing') {
+ public static function get_display($type='now_playing') {
// Default to now playing
- $type = self::validate_type($type);
+ $type = self::validate_type($type);
- $string = '<a href="' . Config::get('web_path') . '/rss.php?type=' . $type . '">' . get_user_icon('feed',_('RSS Feed')) . '</a>';
+ $string = '<a href="' . Config::get('web_path') . '/rss.php?type=' . $type . '">' . get_user_icon('feed',_('RSS Feed')) . '</a>';
- return $string;
+ return $string;
} // get_display
@@ -127,41 +127,41 @@ class AmpacheRSS {
* This loads in the now playing information. This is just the raw data with key=>value pairs that could be turned
* into an xml document if we so wished
*/
- public static function load_now_playing() {
+ public static function load_now_playing() {
- $data = Stream::get_now_playing();
+ $data = Stream::get_now_playing();
- $results = array();
+ $results = array();
- foreach ($data as $element) {
- $song = $element['media'];
- $client = $element['user'];
+ foreach ($data as $element) {
+ $song = $element['media'];
+ $client = $element['user'];
$xml_array = array('title'=>$song->f_title . ' - ' . $song->f_artist . ' - ' . $song->f_album,
'link'=>$song->link,
'description'=>$song->title . ' - ' . $song->f_artist_full . ' - ' . $song->f_album_full,
'comments'=>$client->fullname . ' - ' . $element['agent'],
'pubDate'=>date("r",$element['expire'])
- );
- $results[] = $xml_array;
- } // end foreach
+ );
+ $results[] = $xml_array;
+ } // end foreach
- return $results;
+ return $results;
} // load_now_playing
/**
* pubdate_now_playing
- * this is the pub date we should use for the now playing information,
+ * this is the pub date we should use for the now playing information,
* this is a little specific as it uses the 'newest' expire we can find
*/
- public static function pubdate_now_playing() {
+ public static function pubdate_now_playing() {
// Little redundent, should be fixed by an improvement in the get_now_playing stuff
- $data = Stream::get_now_playing();
+ $data = Stream::get_now_playing();
- $element = array_shift($data);
+ $element = array_shift($data);
- return $element['expire'];
+ return $element['expire'];
} // pubdate_now_playing
@@ -169,21 +169,21 @@ class AmpacheRSS {
* load_recently_played
* This loads in the recently played information and formats it up real nice like
*/
- public static function load_recently_played() {
+ public static function load_recently_played() {
//FIXME: The time stuff should be centralized, it's currently in two places, lame
$time_unit = array('',_('seconds ago'),_('minutes ago'),_('hours ago'),_('days ago'),_('weeks ago'),_('months ago'),_('years ago'));
- $data = Song::get_recently_played();
+ $data = Song::get_recently_played();
- $results = array();
+ $results = array();
- foreach ($data as $item) {
- $client = new User($item['user']);
- $song = new Song($item['object_id']);
- $song->format();
- $amount = intval(time() - $item['date']+2);
- $time_place = '0';
+ foreach ($data as $item) {
+ $client = new User($item['user']);
+ $song = new Song($item['object_id']);
+ $song->format();
+ $amount = intval(time() - $item['date']+2);
+ $time_place = '0';
while ($amount >= 1) {
$final = $amount;
$time_place++;
@@ -205,7 +205,7 @@ class AmpacheRSS {
if ($time_place > '6') {
$final = $amount . '+';
break;
- }
+ }
} // end while
$time_string = $final . ' ' . $time_unit[$time_place];
@@ -214,12 +214,12 @@ class AmpacheRSS {
'link'=>str_replace('&amp;', '&', $song->link),
'description'=>$song->title . ' - ' . $song->f_artist_full . ' - ' . $song->f_album_full . ' - ' . $time_string,
'comments'=>$client->username,
- 'pubDate'=>date("r",$item['date']));
- $results[] = $xml_array;
+ 'pubDate'=>date("r",$item['date']));
+ $results[] = $xml_array;
- } // end foreach
+ } // end foreach
- return $results;
+ return $results;
} // load_recently_played
@@ -227,13 +227,13 @@ class AmpacheRSS {
* pubdate_recently_played
* This just returns the 'newest' recently played entry
*/
- public static function pubdate_recently_played() {
+ public static function pubdate_recently_played() {
- $data = Song::get_recently_played();
+ $data = Song::get_recently_played();
$element = array_shift($data);
-
- return $element['date'];
+
+ return $element['date'];
} // pubdate_recently_played
diff --git a/lib/class/api.class.php b/lib/class/api.class.php
index fecab380..5c2575fd 100644
--- a/lib/class/api.class.php
+++ b/lib/class/api.class.php
@@ -25,15 +25,15 @@
* This handles functions relating to the API written for ampache, initially this is very focused
* on providing functionality for Amarok so it can integrate with Ampache
*/
-class Api {
+class Api {
+
+ public static $version = '350001';
- public static $version = '350001';
-
/**
* constructor
* This really isn't anything to do here, so it's private
*/
- private function __construct() {
+ private function __construct() {
// Rien a faire
@@ -45,12 +45,12 @@ class Api {
* and vastly simplier way to the end users so we have to do a little handy work to make them
* work internally
*/
- public static function set_filter($filter,$value) {
+ public static function set_filter($filter,$value) {
- if (!strlen($value)) { return false; }
+ if (!strlen($value)) { return false; }
- switch ($filter) {
- case 'add':
+ switch ($filter) {
+ case 'add':
// Check for a range, if no range default to gt
if (strpos('/',$value)) {
$elements = explode('/',$value);
@@ -60,30 +60,30 @@ class Api {
else {
Browse::set_filter('add_gt',strtotime($value));
}
- break;
- case 'update':
+ break;
+ case 'update':
// Check for a range, if no range default to gt
- if (strpos('/',$value)) {
- $elements = explode('/',$value);
- Browse::set_filter('update_lt',strtotime($elements['1']));
- Browse::set_filter('update_gt',strtotime($elements['0']));
+ if (strpos('/',$value)) {
+ $elements = explode('/',$value);
+ Browse::set_filter('update_lt',strtotime($elements['1']));
+ Browse::set_filter('update_gt',strtotime($elements['0']));
}
- else {
- Browse::set_filter('update_gt',strtotime($value));
+ else {
+ Browse::set_filter('update_gt',strtotime($value));
}
- break;
+ break;
case 'alpha_match':
- Browse::set_filter('alpha_match',$value);
- break;
- case 'exact_match':
+ Browse::set_filter('alpha_match',$value);
+ break;
+ case 'exact_match':
Browse::set_filter('exact_match',$value);
- break;
- default:
+ break;
+ default:
// Rien a faire
- break;
+ break;
} // end filter
- return true;
+ return true;
} // set_filter
@@ -91,106 +91,106 @@ class Api {
* handshake
* This is the function that handles the verifying a new handshake
* this takes a timestamp, auth key, and client IP. Optionally it
- * can take a username, if non is passed the ACL must be non-use
+ * can take a username, if non is passed the ACL must be non-use
* specific
*/
- public static function handshake($input) {
+ public static function handshake($input) {
- $timestamp = $input['timestamp'];
- $passphrase = $input['auth'];
- $ip = $_SERVER['REMOTE_ADDR'];
- $username = $input['user'];
- $version = $input['version'];
+ $timestamp = $input['timestamp'];
+ $passphrase = $input['auth'];
+ $ip = $_SERVER['REMOTE_ADDR'];
+ $username = $input['user'];
+ $version = $input['version'];
// Let them know we're attempting
- debug_event('API',"Attempting Handshake IP:$ip User:$username Version:$version",'5');
+ debug_event('API',"Attempting Handshake IP:$ip User:$username Version:$version",'5');
- if (intval($version) < self::$version) {
- debug_event('API','Login Failed version too old','1');
- Error::add('api','Login Failed version too old');
- return false;
- }
+ if (intval($version) < self::$version) {
+ debug_event('API','Login Failed version too old','1');
+ Error::add('api','Login Failed version too old');
+ return false;
+ }
// If the timestamp is over 2hr old sucks to be them
- if ($timestamp < (time() - 14400)) {
- debug_event('API','Login Failed, timestamp too old','1');
- Error::add('api','Login Failed, timestamp too old');
- return false;
- }
-
- // First we'll filter by username and IP
- if (!trim($username)) {
- $user_id = '-1';
- }
- else {
- $client = User::get_from_username($username);
- $user_id =$client->id;
- }
+ if ($timestamp < (time() - 14400)) {
+ debug_event('API','Login Failed, timestamp too old','1');
+ Error::add('api','Login Failed, timestamp too old');
+ return false;
+ }
+
+ // First we'll filter by username and IP
+ if (!trim($username)) {
+ $user_id = '-1';
+ }
+ else {
+ $client = User::get_from_username($username);
+ $user_id =$client->id;
+ }
// Clean incomming variables
- $user_id = Dba::escape($user_id);
- $timestamp = intval($timestamp);
+ $user_id = Dba::escape($user_id);
+ $timestamp = intval($timestamp);
$ip = inet_pton($ip);
// Log this attempt
- debug_event('API','Login Attempt, IP:' . inet_ntop($ip) . ' Time:' . $timestamp . ' User:' . $username . '(' . $user_id . ') Auth:' . $passphrase,'1');
+ debug_event('API','Login Attempt, IP:' . inet_ntop($ip) . ' Time:' . $timestamp . ' User:' . $username . '(' . $user_id . ') Auth:' . $passphrase,'1');
+
+ $ip = Dba::escape($ip);
- $ip = Dba::escape($ip);
-
// Run the query and return the passphrases as we'll have to mangle them
// to figure out if they match what we've got
- $sql = "SELECT * FROM `access_list` " .
- "WHERE `type`='rpc' AND (`user`='$user_id' OR `access_list`.`user`='-1') " .
- "AND `start` <= '$ip' AND `end` >= '$ip'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `access_list` " .
+ "WHERE `type`='rpc' AND (`user`='$user_id' OR `access_list`.`user`='-1') " .
+ "AND `start` <= '$ip' AND `end` >= '$ip'";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
+ while ($row = Dba::fetch_assoc($db_results)) {
- // Now we're sure that there is an ACL line that matches this user or ALL USERS,
- // pull the users password and then see what we come out with
- $sql = "SELECT * FROM `user` WHERE `id`='$user_id'";
- $user_results = Dba::read($sql);
+ // Now we're sure that there is an ACL line that matches this user or ALL USERS,
+ // pull the users password and then see what we come out with
+ $sql = "SELECT * FROM `user` WHERE `id`='$user_id'";
+ $user_results = Dba::read($sql);
- $row = Dba::fetch_assoc($user_results);
+ $row = Dba::fetch_assoc($user_results);
- if (!$row['password']) {
- debug_event('API','Unable to find user with username of ' . $user_id,'1');
- Error::add('api','Invalid Username/Password');
- return false;
- }
+ if (!$row['password']) {
+ debug_event('API','Unable to find user with username of ' . $user_id,'1');
+ Error::add('api','Invalid Username/Password');
+ return false;
+ }
- $sha1pass = hash('sha256',$timestamp . $row['password']);
+ $sha1pass = hash('sha256',$timestamp . $row['password']);
- if ($sha1pass === $passphrase) {
+ if ($sha1pass === $passphrase) {
// Create the Session, in this class for now needs to be moved
- $data['username'] = $client->username;
- $data['type'] = 'api';
- $data['value'] = $timestamp;
- $token = vauth::session_create($data);
+ $data['username'] = $client->username;
+ $data['type'] = 'api';
+ $data['value'] = $timestamp;
+ $token = vauth::session_create($data);
// Insert the token into the streamer
- Stream::insert_session($token,$client->id);
- debug_event('API','Login Success, passphrase matched','1');
+ Stream::insert_session($token,$client->id);
+ debug_event('API','Login Success, passphrase matched','1');
// We need to also get the 'last update' of the catalog information in an RFC 2822 Format
- $sql = "SELECT MAX(`last_update`) AS `update`,MAX(`last_add`) AS `add`, MAX(`last_clean`) AS `clean` FROM `catalog`";
- $db_results = Dba::read($sql);
- $row = Dba::fetch_assoc($db_results);
+ $sql = "SELECT MAX(`last_update`) AS `update`,MAX(`last_add`) AS `add`, MAX(`last_clean`) AS `clean` FROM `catalog`";
+ $db_results = Dba::read($sql);
+ $row = Dba::fetch_assoc($db_results);
// Now we need to quickly get the totals of songs
- $sql = "SELECT COUNT(`id`) AS `song`,COUNT(DISTINCT(`album`)) AS `album`," .
+ $sql = "SELECT COUNT(`id`) AS `song`,COUNT(DISTINCT(`album`)) AS `album`," .
"COUNT(DISTINCT(`artist`)) AS `artist` FROM `song`";
- $db_results = Dba::read($sql);
- $counts = Dba::fetch_assoc($db_results);
+ $db_results = Dba::read($sql);
+ $counts = Dba::fetch_assoc($db_results);
// Next the video counts
- $sql = "SELECT COUNT(`id`) AS `video` FROM `video`";
- $db_results = Dba::read($sql);
- $vcounts = Dba::fetch_assoc($db_results);
+ $sql = "SELECT COUNT(`id`) AS `video` FROM `video`";
+ $db_results = Dba::read($sql);
+ $vcounts = Dba::fetch_assoc($db_results);
- $sql = "SELECT COUNT(`id`) AS `playlist` FROM `playlist`";
+ $sql = "SELECT COUNT(`id`) AS `playlist` FROM `playlist`";
$db_results = Dba::read($sql);
- $playlist = Dba::fetch_assoc($db_results);
+ $playlist = Dba::fetch_assoc($db_results);
echo xmlData::keyed_array(array('auth'=>$token,
'api'=>self::$version,
@@ -201,13 +201,13 @@ class Api {
'albums'=>$counts['album'],
'artists'=>$counts['artist'],
'playlists'=>$playlist['playlist'],
- 'videos'=>$vcounts['video']));
- } // match
+ 'videos'=>$vcounts['video']));
+ } // match
} // end while
- debug_event('API','Login Failed, unable to match passphrase','1');
- xmlData::error('401',_('Error Invalid Handshake - ') . _('Invalid Username/Password'));
+ debug_event('API','Login Failed, unable to match passphrase','1');
+ xmlData::error('401',_('Error Invalid Handshake - ') . _('Invalid Username/Password'));
} // handshake
@@ -216,7 +216,7 @@ class Api {
* This can be called without being authenticated, it is useful for determining if what the status
* of the server is, and what version it is running/compatible with
*/
- public static function ping($input) {
+ public static function ping($input) {
$xmldata = array('server'=>Config::get('version'),'version'=>Api::$version,'compatible'=>'350001');
@@ -239,7 +239,7 @@ class Api {
* artist objects. This function is deprecated!
* //DEPRECATED
*/
- public static function artists($input) {
+ public static function artists($input) {
Browse::reset_filters();
Browse::set_type('artist');
@@ -266,7 +266,7 @@ class Api {
* This returns a single artist based on the UID of said artist
* //DEPRECATED
*/
- public static function artist($input) {
+ public static function artist($input) {
$uid = scrub_in($input['filter']);
echo xmlData::artists(array($uid));
@@ -277,7 +277,7 @@ class Api {
* artist_albums
* This returns the albums of an artist
*/
- public static function artist_albums($input) {
+ public static function artist_albums($input) {
$artist = new Artist($input['filter']);
@@ -295,7 +295,7 @@ class Api {
* artist_songs
* This returns the songs of the specified artist
*/
- public static function artist_songs($input) {
+ public static function artist_songs($input) {
$artist = new Artist($input['filter']);
$songs = $artist->get_songs();
@@ -312,7 +312,7 @@ class Api {
* albums
* This returns albums based on the provided search filters
*/
- public static function albums($input) {
+ public static function albums($input) {
Browse::reset_filters();
Browse::set_type('album');
@@ -336,7 +336,7 @@ class Api {
* album
* This returns a single album based on the UID provided
*/
- public static function album($input) {
+ public static function album($input) {
$uid = scrub_in($input['filter']);
echo xmlData::albums(array($uid));
@@ -347,7 +347,7 @@ class Api {
* album_songs
* This returns the songs of a specified album
*/
- public static function album_songs($input) {
+ public static function album_songs($input) {
$album = new Album($input['filter']);
$songs = $album->get_songs();
@@ -359,13 +359,13 @@ class Api {
ob_end_clean();
echo xmlData::songs($songs);
- } // album_songs
+ } // album_songs
/**
* tags
* This returns the tags based on the specified filter
*/
- public static function tags($input) {
+ public static function tags($input) {
Browse::reset_filters();
Browse::set_type('tag');
@@ -388,7 +388,7 @@ class Api {
* tag
* This returns a single tag based on UID
*/
- public static function tag($input) {
+ public static function tag($input) {
$uid = scrub_in($input['filter']);
ob_end_clean();
@@ -400,7 +400,7 @@ class Api {
* tag_artists
* This returns the artists assoicated with the tag in question as defined by the UID
*/
- public static function tag_artists($input) {
+ public static function tag_artists($input) {
$artists = Tag::get_tag_objects('artist',$input['filter']);
@@ -416,7 +416,7 @@ class Api {
* tag_albums
* This returns the albums assoicated with the tag in question
*/
- public static function tag_albums($input) {
+ public static function tag_albums($input) {
$albums = Tag::get_tag_objects('album',$input['filter']);
@@ -432,7 +432,7 @@ class Api {
* tag_songs
* returns the songs for this tag
*/
- public static function tag_songs($input) {
+ public static function tag_songs($input) {
$songs = Tag::get_tag_objects('song',$input['filter']);
@@ -448,7 +448,7 @@ class Api {
* songs
* Returns songs based on the specified filter
*/
- public static function songs($input) {
+ public static function songs($input) {
Browse::reset_filters();
Browse::set_type('song');
@@ -474,7 +474,7 @@ class Api {
* song
* returns a single song
*/
- public static function song($input) {
+ public static function song($input) {
$uid = scrub_in($input['filter']);
@@ -487,7 +487,7 @@ class Api {
* url_to_song
* This takes a url and returns the song object in question
*/
- public static function url_to_song($input) {
+ public static function url_to_song($input) {
// Don't scrub in we need to give her raw and juicy to the function
$url = $input['url'];
@@ -503,7 +503,7 @@ class Api {
* playlists
* This returns playlists based on the specified filter
*/
- public static function playlists($input) {
+ public static function playlists($input) {
Browse::reset_filters();
Browse::set_type('playlist');
@@ -526,7 +526,7 @@ class Api {
* playlist
* This returns a single playlist
*/
- public static function playlist($input) {
+ public static function playlist($input) {
$uid = scrub_in($input['filter']);
@@ -539,7 +539,7 @@ class Api {
* playlist_songs
* This returns the songs for a playlist
*/
- public static function playlist_songs($input) {
+ public static function playlist_songs($input) {
$playlist = new Playlist($input['filter']);
$items = $playlist->get_items();
@@ -561,7 +561,7 @@ class Api {
* search_songs
* This returns the songs and returns... songs
*/
- public static function search_songs($input) {
+ public static function search_songs($input) {
$array['s_all'] = $input['filter'];
ob_end_clean();
@@ -583,7 +583,7 @@ class Api {
* videos
* This returns video objects!
*/
- public static function videos($input) {
+ public static function videos($input) {
Browse::reset_filters();
Browse::set_type('video');
@@ -602,10 +602,10 @@ class Api {
} // videos
/**
- * video
+ * video
* This returns a single video
*/
- public static function video($input) {
+ public static function video($input) {
$video_id = scrub_in($input['filter']);
@@ -618,7 +618,7 @@ class Api {
* localplay
* This is for controling localplay
*/
- public static function localplay($input) {
+ public static function localplay($input) {
// Load their localplay instance
$localplay = new Localplay(Config::get('localplay_controller'));
@@ -645,7 +645,7 @@ class Api {
* democratic
* This is for controlling democratic play
*/
- public static function democratic($input) {
+ public static function democratic($input) {
// Load up democratic information
$democratic = Democratic::get_current_playlist();
diff --git a/lib/class/art.class.php b/lib/class/art.class.php
index 2fe672d8..12f76631 100644
--- a/lib/class/art.class.php
+++ b/lib/class/art.class.php
@@ -23,17 +23,17 @@
/**
* Art
* This class handles the images / artwork in ampache
- * This was initially in the album class, but was pulled out
+ * This was initially in the album class, but was pulled out
* to be more general, and apply to albums, artists, movies etc
*/
-class Art extends database_object {
+class Art extends database_object {
/**
* Constructor
* Art constructor, not sure what's here for now
*/
- public function __construct() {
+ public function __construct() {
diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php
index a0ca2ad3..c30b20e4 100644
--- a/lib/class/artist.class.php
+++ b/lib/class/artist.class.php
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
@@ -44,16 +44,16 @@ class Artist extends database_object {
public function __construct($id='') {
/* If they failed to pass in an id, just run for it */
- if (!$id) { return false; }
+ if (!$id) { return false; }
/* Get the information from the db */
$info = $this->get_info($id);
-
- foreach ($info as $key=>$value) {
- $this->$key = $value;
+
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
} // foreach info
- return true;
+ return true;
} //constructor
@@ -62,15 +62,15 @@ class Artist extends database_object {
* This is used by the metadata class specifically but fills out a Artist object
* based on a key'd array, it sets $_fake to true
*/
- public static function construct_from_array($data) {
+ public static function construct_from_array($data) {
- $artist = new Artist(0);
- foreach ($data as $key=>$value) {
- $artist->$key = $value;
- }
+ $artist = new Artist(0);
+ foreach ($data as $key=>$value) {
+ $artist->$key = $value;
+ }
//Ack that this is not a real object from the DB
- $artist->_fake = true;
+ $artist->_fake = true;
return $artist;
@@ -88,18 +88,18 @@ class Artist extends database_object {
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('artist',$row['id'],$row);
+ parent::add_to_cache('artist',$row['id'],$row);
}
// If we need to also pull the extra information, this is normally only used when we are doing the human display
- if ($extra) {
+ if ($extra) {
$sql = "SELECT `song`.`artist`, COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " .
"WHERE `song`.`artist` IN $idlist GROUP BY `song`.`artist`";
$db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('artist_extra',$row['artist'],$row);
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ parent::add_to_cache('artist_extra',$row['artist'],$row);
+ }
} // end if extra
@@ -111,51 +111,51 @@ class Artist extends database_object {
* get_from_name
* This gets an artist object based on the artist name
*/
- public static function get_from_name($name) {
+ public static function get_from_name($name) {
- $name = Dba::escape($name);
- $sql = "SELECT `id` FROM `artist` WHERE `name`='$name'";
- $db_results = Dba::write($sql);
+ $name = Dba::escape($name);
+ $sql = "SELECT `id` FROM `artist` WHERE `name`='$name'";
+ $db_results = Dba::write($sql);
- $row = Dba::fetch_assoc($db_results);
+ $row = Dba::fetch_assoc($db_results);
- $object = new Artist($row['id']);
+ $object = new Artist($row['id']);
- return $object;
+ return $object;
- } // get_from_name
+ } // get_from_name
/**
* get_albums
* gets the album ids that this artist is a part
* of
*/
- public function get_albums() {
+ public function get_albums() {
$results = array();
- $sql = "SELECT `album`.`id` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` " .
+ $sql = "SELECT `album`.`id` FROM album LEFT JOIN `song` ON `song`.`album`=`album`.`id` " .
"WHERE `song`.`artist`='$this->id' GROUP BY `album`.`id` ORDER BY `album`.`name`,`album`.`disk`,`album`.`year`";
$db_results = Dba::read($sql);
- while ($r = Dba::fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id'];
}
return $results;
-
+
} // get_albums
- /**
+ /**
* get_songs
* gets the songs for this artist
*/
- public function get_songs() {
-
+ public function get_songs() {
+
$sql = "SELECT `song`.`id` FROM `song` WHERE `song`.`artist`='" . Dba::escape($this->id) . "' ORDER BY album, track";
$db_results = Dba::read($sql);
- while ($r = Dba::fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id'];
}
@@ -186,27 +186,27 @@ class Artist extends database_object {
* _get_extra info
* This returns the extra information for the artist, this means totals etc
*/
- private function _get_extra_info() {
+ private function _get_extra_info() {
// Try to find it in the cache and save ourselves the trouble
- if (parent::is_cached('artist_extra',$this->id)) {
- $row = parent::get_from_cache('artist_extra',$this->id);
- }
- else {
- $uid = Dba::escape($this->id);
- $sql = "SELECT `song`.`artist`,COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " .
+ if (parent::is_cached('artist_extra',$this->id)) {
+ $row = parent::get_from_cache('artist_extra',$this->id);
+ }
+ else {
+ $uid = Dba::escape($this->id);
+ $sql = "SELECT `song`.`artist`,COUNT(`song`.`id`) AS `song_count`, COUNT(DISTINCT `song`.`album`) AS `album_count`, SUM(`song`.`time`) AS `time` FROM `song` " .
"WHERE `song`.`artist`='$uid' GROUP BY `song`.`artist`";
$db_results = Dba::read($sql);
- $row = Dba::fetch_assoc($db_results);
- parent::add_to_cache('artist_extra',$row['artist'],$row);
- }
-
+ $row = Dba::fetch_assoc($db_results);
+ parent::add_to_cache('artist_extra',$row['artist'],$row);
+ }
+
/* Set Object Vars */
$this->songs = $row['song_count'];
$this->albums = $row['album_count'];
- $this->time = $row['time'];
+ $this->time = $row['time'];
- return $row;
+ return $row;
} // _get_extra_info
@@ -222,30 +222,30 @@ class Artist extends database_object {
/* Combine prefix and name, trim then add ... if needed */
$name = truncate_with_ellipsis(trim($this->prefix . " " . $this->name),Config::get('ellipse_threshold_artist'));
$this->f_name = $name;
- $this->f_full_name = trim($this->prefix . " " . $this->name);
+ $this->f_full_name = trim($this->prefix . " " . $this->name);
// If this is a fake object, we're done here
- if ($this->_fake) { return true; }
+ if ($this->_fake) { return true; }
$this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&amp;artist=" . $this->id . "\" title=\"" . $this->full_name . "\">" . $name . "</a>";
- $this->f_link = Config::get('web_path') . '/artists.php?action=show&amp;artist=' . $this->id;
+ $this->f_link = Config::get('web_path') . '/artists.php?action=show&amp;artist=' . $this->id;
- // Get the counts
- $extra_info = $this->_get_extra_info();
+ // Get the counts
+ $extra_info = $this->_get_extra_info();
//Format the new time thingy that we just got
- $min = sprintf("%02d",(floor($extra_info['time']/60)%60));
-
- $sec = sprintf("%02d",($extra_info['time']%60));
+ $min = sprintf("%02d",(floor($extra_info['time']/60)%60));
+
+ $sec = sprintf("%02d",($extra_info['time']%60));
$hours = floor($extra_info['time']/3600);
- $this->f_time = ltrim($hours . ':' . $min . ':' . $sec,'0:');
+ $this->f_time = ltrim($hours . ':' . $min . ':' . $sec,'0:');
- $this->tags = Tag::get_top_tags('artist',$this->id);
+ $this->tags = Tag::get_top_tags('artist',$this->id);
- $this->f_tags = Tag::get_display($this->tags,$this->id,'artist');
+ $this->f_tags = Tag::get_display($this->tags,$this->id,'artist');
- return true;
+ return true;
} // format
@@ -254,30 +254,30 @@ class Artist extends database_object {
* This takes a key'd array of data and updates the current artist
* it will flag songs as neeed
*/
- public function update($data) {
+ public function update($data) {
// Save our current ID
- $current_id = $this->id;
+ $current_id = $this->id;
- $artist_id = Catalog::check_artist($data['name'], $this->mbid);
+ $artist_id = Catalog::check_artist($data['name'], $this->mbid);
// If it's changed we need to update
- if ($artist_id != $this->id) {
- $songs = $this->get_songs();
- foreach ($songs as $song_id) {
- Song::update_artist($artist_id,$song_id);
- }
- $updated = 1;
- $current_id = $artist_id;
- Catalog::clean_artists();
+ if ($artist_id != $this->id) {
+ $songs = $this->get_songs();
+ foreach ($songs as $song_id) {
+ Song::update_artist($artist_id,$song_id);
+ }
+ $updated = 1;
+ $current_id = $artist_id;
+ Catalog::clean_artists();
} // end if it changed
- if ($updated) {
- foreach ($songs as $song_id) {
- Flag::add($song_id,'song','retag','Interface Artist Update');
- Song::update_utime($song_id);
- }
- Catalog::clean_stats();
+ if ($updated) {
+ foreach ($songs as $song_id) {
+ Flag::add($song_id,'song','retag','Interface Artist Update');
+ Song::update_utime($song_id);
+ }
+ Catalog::clean_stats();
} // if updated
return $current_id;
@@ -293,8 +293,8 @@ class Artist extends database_object {
debug_event("lyrics", "Initialized Function", "5");
$sql = "SELECT `song_data`.`lyrics` FROM `song_data` WHERE `song_id`='" . Dba::escape($song_id) . "'";
- $db_results = Dba::read($sql);
- $results = Dba::fetch_assoc($db_results);
+ $db_results = Dba::read($sql);
+ $results = Dba::fetch_assoc($db_results);
// Get Lyrics From id3tag (Lyrics3)
$rs = Dba::read("SELECT `song`.`file` FROM `song` WHERE `id`='" . Dba::escape($song_id) . "'");
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index 8a176bb0..17408a37 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -27,29 +27,29 @@
* it also handles pulling back the object_ids and then
* calling the correct template for the object we are displaying
*/
-class Browse extends Query {
+class Browse extends Query {
// Public static vars that are cached
- public static $sql;
+ public static $sql;
public static $start;
- public static $offset;
- public static $total_objects;
- public static $type;
+ public static $offset;
+ public static $total_objects;
+ public static $type;
// Boolean if this is a simple browse method (use different paging code)
- public static $simple_browse;
+ public static $simple_browse;
// Static Content, this is defaulted to false, if set to true then when we can't
- // apply any filters that would change the result set.
- public static $static_content = false;
- private static $_cache = array();
+ // apply any filters that would change the result set.
+ public static $static_content = false;
+ private static $_cache = array();
/**
* constructor
* This should never be called
*/
- private function __construct() {
+ private function __construct() {
// Rien a faire
@@ -60,9 +60,9 @@ class Browse extends Query {
* This sets the current browse object to a 'simple' browse method
* which means use the base query provided and expand from there
*/
- public static function set_simple_browse($value) {
+ public static function set_simple_browse($value) {
- parent::set_is_simple($value);
+ parent::set_is_simple($value);
} // set_simple_browse
@@ -70,11 +70,11 @@ class Browse extends Query {
* add_supplemental_object
* Legacy function, need to find a better way to do that
*/
- public static function add_supplemental_object($class,$uid) {
+ public static function add_supplemental_object($class,$uid) {
- $_SESSION['browse']['supplemental'][$class] = intval($uid);
+ $_SESSION['browse']['supplemental'][$class] = intval($uid);
- return true;
+ return true;
} // add_supplemental_object
@@ -83,36 +83,36 @@ class Browse extends Query {
* This returns an array of 'class','id' for additional objects that need to be
* created before we start this whole browsing thing
*/
- public static function get_supplemental_objects() {
+ public static function get_supplemental_objects() {
- $objects = $_SESSION['browse']['supplemental'];
-
- if (!is_array($objects)) { $objects = array(); }
+ $objects = $_SESSION['browse']['supplemental'];
- return $objects;
+ if (!is_array($objects)) { $objects = array(); }
+
+ return $objects;
} // get_supplemental_objects
- /**
+ /**
* is_enabled
* This checks if the specified function/feature
* of browsing is enabled, not sure if this is the best
* way to go about it, but hey. Returns boolean t/f
*/
- public static function is_enabled($item) {
-
- switch ($item) {
- case 'show_art':
- if (Browse::get_filter('show_art')) {
- return true;
- }
- if (Config::get('bandwidth') > 25) {
- return true;
- }
- break;
+ public static function is_enabled($item) {
+
+ switch ($item) {
+ case 'show_art':
+ if (Browse::get_filter('show_art')) {
+ return true;
+ }
+ if (Config::get('bandwidth') > 25) {
+ return true;
+ }
+ break;
} // end switch
- return false;
+ return false;
} // is_enabled
@@ -122,147 +122,147 @@ class Browse extends Query {
* and requires the correct template based on the
* type that we are currently browsing
*/
- public static function show_objects($object_ids=false) {
-
- if (parent::is_simple()) {
- $object_ids = parent::get_saved();
- }
- else {
+ public static function show_objects($object_ids=false) {
+
+ if (parent::is_simple()) {
+ $object_ids = parent::get_saved();
+ }
+ else {
$object_ids = is_array($object_ids) ? $object_ids : parent::get_saved();
- parent::save_objects($object_ids);
- }
-
+ parent::save_objects($object_ids);
+ }
+
// Reset the total items
- self::$total_objects = parent::get_total($object_ids);
-
+ self::$total_objects = parent::get_total($object_ids);
+
// Limit is based on the users preferences if this is not a simple browse because we've got too much here
- if (count($object_ids) > parent::get_start() AND !parent::is_simple()) {
- $object_ids = array_slice($object_ids,parent::get_start(),parent::get_offset(),TRUE);
- }
+ if (count($object_ids) > parent::get_start() AND !parent::is_simple()) {
+ $object_ids = array_slice($object_ids,parent::get_start(),parent::get_offset(),TRUE);
+ }
// Load any additional object we need for this
- $extra_objects = self::get_supplemental_objects();
+ $extra_objects = self::get_supplemental_objects();
- foreach ($extra_objects as $class_name => $id) {
- ${$class_name} = new $class_name($id);
- }
+ foreach ($extra_objects as $class_name => $id) {
+ ${$class_name} = new $class_name($id);
+ }
// Format any matches we have so we can show them to the masses
- if ($filter_value = parent::get_filter('alpha_match')) {
- $match = ' (' . $filter_value . ')';
+ if ($filter_value = parent::get_filter('alpha_match')) {
+ $match = ' (' . $filter_value . ')';
+ }
+ elseif ($filter_value = parent::get_filter('starts_with')) {
+ $match = ' (' . $filter_value . ')';
}
- elseif ($filter_value = parent::get_filter('starts_with')) {
- $match = ' (' . $filter_value . ')';
- }
// Set the correct classes based on type
$class = "box browse_".self::$type;
Ajax::start_container('browse_content');
// Switch on the type of browsing we're doing
- switch (parent::get_type()) {
- case 'song':
- show_box_top(_('Songs') . $match, $class);
- Song::build_cache($object_ids);
- require_once Config::get('prefix') . '/templates/show_songs.inc.php';
- show_box_bottom();
+ switch (parent::get_type()) {
+ case 'song':
+ show_box_top(_('Songs') . $match, $class);
+ Song::build_cache($object_ids);
+ require_once Config::get('prefix') . '/templates/show_songs.inc.php';
+ show_box_bottom();
break;
- case 'album':
- show_box_top(_('Albums') . $match, $class);
+ case 'album':
+ show_box_top(_('Albums') . $match, $class);
Album::build_cache($object_ids,'extra');
require_once Config::get('prefix') . '/templates/show_albums.inc.php';
- show_box_bottom();
+ show_box_bottom();
break;
case 'user':
- show_box_top(_('Manage Users') . $match, $class);
- require_once Config::get('prefix') . '/templates/show_users.inc.php';
- show_box_bottom();
+ show_box_top(_('Manage Users') . $match, $class);
+ require_once Config::get('prefix') . '/templates/show_users.inc.php';
+ show_box_bottom();
break;
case 'artist':
- show_box_top(_('Artists') . $match, $class);
- Artist::build_cache($object_ids,'extra');
- require_once Config::get('prefix') . '/templates/show_artists.inc.php';
- show_box_bottom();
+ show_box_top(_('Artists') . $match, $class);
+ Artist::build_cache($object_ids,'extra');
+ require_once Config::get('prefix') . '/templates/show_artists.inc.php';
+ show_box_bottom();
break;
- case 'live_stream':
- require_once Config::get('prefix') . '/templates/show_live_stream.inc.php';
- show_box_top(_('Radio Stations') . $match, $class);
+ case 'live_stream':
+ require_once Config::get('prefix') . '/templates/show_live_stream.inc.php';
+ show_box_top(_('Radio Stations') . $match, $class);
require_once Config::get('prefix') . '/templates/show_live_streams.inc.php';
- show_box_bottom();
+ show_box_bottom();
break;
- case 'playlist':
- Playlist::build_cache($object_ids);
+ case 'playlist':
+ Playlist::build_cache($object_ids);
show_box_top(_('Playlists') . $match, $class);
- require_once Config::get('prefix') . '/templates/show_playlists.inc.php';
- show_box_bottom();
+ require_once Config::get('prefix') . '/templates/show_playlists.inc.php';
+ show_box_bottom();
+ break;
+ case 'playlist_song':
+ show_box_top(_('Playlist Songs') . $match,$class);
+ require_once Config::get('prefix') . '/templates/show_playlist_songs.inc.php';
+ show_box_bottom();
break;
- case 'playlist_song':
- show_box_top(_('Playlist Songs') . $match,$class);
- require_once Config::get('prefix') . '/templates/show_playlist_songs.inc.php';
- show_box_bottom();
- break;
- case 'playlist_localplay':
- show_box_top(_('Current Playlist'));
- require_once Config::get('prefix') . '/templates/show_localplay_playlist.inc.php';
- show_box_bottom();
+ case 'playlist_localplay':
+ show_box_top(_('Current Playlist'));
+ require_once Config::get('prefix') . '/templates/show_localplay_playlist.inc.php';
+ show_box_bottom();
break;
- case 'catalog':
- show_box_top(_('Catalogs'), $class);
+ case 'catalog':
+ show_box_top(_('Catalogs'), $class);
require_once Config::get('prefix') . '/templates/show_catalogs.inc.php';
- show_box_bottom();
+ show_box_bottom();
+ break;
+ case 'shoutbox':
+ show_box_top(_('Shoutbox Records'),$class);
+ require_once Config::get('prefix') . '/templates/show_manage_shoutbox.inc.php';
+ show_box_bottom();
break;
- case 'shoutbox':
- show_box_top(_('Shoutbox Records'),$class);
- require_once Config::get('prefix') . '/templates/show_manage_shoutbox.inc.php';
- show_box_bottom();
- break;
case 'flagged':
- show_box_top(_('Flagged Records'),$class);
- require_once Config::get('prefix') . '/templates/show_flagged.inc.php';
- show_box_bottom();
+ show_box_top(_('Flagged Records'),$class);
+ require_once Config::get('prefix') . '/templates/show_flagged.inc.php';
+ show_box_bottom();
+ break;
+ case 'tag':
+ Tag::build_cache($tags);
+ show_box_top(_('Tag Cloud'),$class);
+ require_once Config::get('prefix') . '/templates/show_tagcloud.inc.php';
+ show_box_bottom();
+ break;
+ case 'video':
+ Video::build_cache($object_ids);
+ show_box_top(_('Videos'),$class);
+ require_once Config::get('prefix') . '/templates/show_videos.inc.php';
+ show_box_bottom();
break;
- case 'tag':
- Tag::build_cache($tags);
- show_box_top(_('Tag Cloud'),$class);
- require_once Config::get('prefix') . '/templates/show_tagcloud.inc.php';
- show_box_bottom();
- break;
- case 'video':
- Video::build_cache($object_ids);
- show_box_top(_('Videos'),$class);
- require_once Config::get('prefix') . '/templates/show_videos.inc.php';
- show_box_bottom();
- break;
- case 'democratic':
- show_box_top(_('Democratic Playlist'),$class);
- require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php';
- show_box_bottom();
- default:
+ case 'democratic':
+ show_box_top(_('Democratic Playlist'),$class);
+ require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php';
+ show_box_bottom();
+ default:
// Rien a faire
break;
} // end switch on type
- Ajax::end_container();
+ Ajax::end_container();
} // show_object
/**
* _auto_init
- * this function reloads information back from the session
+ * this function reloads information back from the session
* it is called on creation of the class
*/
- public static function _auto_init() {
+ public static function _auto_init() {
$offset = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
- parent::set_offset($offset);
+ parent::set_offset($offset);
} // _auto_init
-
+
/**
* set_filter_from_request
* //FIXME
- */
- public static function set_filter_from_request($r) {
+ */
+ public static function set_filter_from_request($r) {
foreach($r as $k=>$v) {
//reinterpret v as a list of int
$vl = explode(',', $v);
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 99e750ab..96766b92 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -30,7 +30,7 @@ class Catalog extends database_object {
public $name;
public $last_update;
public $last_add;
- public $last_clean;
+ public $last_clean;
public $key;
public $rename_pattern;
public $sort_pattern;
@@ -88,15 +88,15 @@ class Catalog extends database_object {
$this->_filecache[strtolower($results['file'])] = $results['id'];
}
- $sql = "SELECT `id`,`file` FROM `video` WHERE `catalog`='$catalog_id'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id`,`file` FROM `video` WHERE `catalog`='$catalog_id'";
+ $db_results = Dba::read($sql);
- while ($results = Dba::fetch_assoc($db_results)) {
- $this->_filecache[strtolower($results['file'])] = 'v_' . $results['id'];
- }
+ while ($results = Dba::fetch_assoc($db_results)) {
+ $this->_filecache[strtolower($results['file'])] = 'v_' . $results['id'];
+ }
} // end if empty filecache
- return true;
+ return true;
} // _create_filecache
@@ -105,33 +105,33 @@ class Catalog extends database_object {
* Try to figure out which catalog path most closely resembles this one
* This is useful when creating a new catalog to make sure we're not doubling up here
*/
- public static function get_from_path($path) {
+ public static function get_from_path($path) {
// First pull a list of all of the paths for the different catalogs
- $sql = "SELECT `id`,`path` FROM `catalog` WHERE `catalog_type`='local'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id`,`path` FROM `catalog` WHERE `catalog_type`='local'";
+ $db_results = Dba::read($sql);
- $catalog_paths = array();
- $component_path = $path;
+ $catalog_paths = array();
+ $component_path = $path;
- while ($row = Dba::fetch_assoc($db_results)) {
+ while ($row = Dba::fetch_assoc($db_results)) {
$catalog_paths[$row['path']] = $row['id'];
- }
+ }
// Break it down into its component parts and start looking for a catalog
- do {
- if ($catalog_paths[$component_path]) {
- return $catalog_paths[$component_path];
- }
+ do {
+ if ($catalog_paths[$component_path]) {
+ return $catalog_paths[$component_path];
+ }
// Keep going until the path stops changing
- $old_path = $component_path;
- $component_path = realpath($component_path . '/../');
+ $old_path = $component_path;
+ $component_path = realpath($component_path . '/../');
- } while (strcmp($component_path,$old_path) != 0);
+ } while (strcmp($component_path,$old_path) != 0);
- return false;
+ return false;
} // get_from_path
@@ -146,7 +146,7 @@ class Catalog extends database_object {
$this->f_path = truncate_with_ellipsis($this->path,Config::get('ellipse_threshold_title'));
$this->f_update = $this->last_update ? date('d/m/Y h:i',$this->last_update) : _('Never');
$this->f_add = $this->last_add ? date('d/m/Y h:i',$this->last_add) : _('Never');
- $this->f_clean = $this->last_clean ? date('d/m/Y h:i',$this->last_clean) : _('Never');
+ $this->f_clean = $this->last_clean ? date('d/m/Y h:i',$this->last_clean) : _('Never');
} // format
@@ -197,8 +197,8 @@ class Catalog extends database_object {
$results = self::count_songs($catalog_id);
$results = array_merge(self::count_users($catalog_id),$results);
- $results['tags'] = self::count_tags();
- $results = array_merge(self::count_video($catalog_id),$results);
+ $results['tags'] = self::count_tags();
+ $results = array_merge(self::count_video($catalog_id),$results);
$hours = floor($results['time']/3600);
// Calculate catalog size in bytes, divided by 1000
@@ -347,7 +347,7 @@ class Catalog extends database_object {
$this->get_album_art('',1);
}
- if ($options['parse_m3u'] AND count($this->_playlists)) {
+ if ($options['parse_m3u'] AND count($this->_playlists)) {
foreach ($this->_playlists as $playlist_file) {
$result = $this->import_m3u($playlist_file);
}
@@ -361,31 +361,31 @@ class Catalog extends database_object {
* count_video
* This returns the current # of video files we've got in the db
*/
- public static function count_video($catalog_id=0) {
+ public static function count_video($catalog_id=0) {
- $catalog_search = $catalog_id ? "WHERE `catalog`='" . Dba::escape($catalog_id) . "'" : '';
+ $catalog_search = $catalog_id ? "WHERE `catalog`='" . Dba::escape($catalog_id) . "'" : '';
+
+ $sql = "SELECT COUNT(`id`) AS `video` FROM `video` $catalog_search";
+ $db_results = Dba::read($sql);
- $sql = "SELECT COUNT(`id`) AS `video` FROM `video` $catalog_search";
- $db_results = Dba::read($sql);
+ $row = Dba::fetch_assoc($db_results);
- $row = Dba::fetch_assoc($db_results);
-
- return $row;
+ return $row;
- } // count_video
+ } // count_video
/**
* count_tags
* This returns the current # of unique tags that exist in the database
*/
- public static function count_tags($catalog_id=0) {
+ public static function count_tags($catalog_id=0) {
- $sql = "SELECT COUNT(`id`) FROM `tag`";
- $db_results = Dba::read($sql);
+ $sql = "SELECT COUNT(`id`) FROM `tag`";
+ $db_results = Dba::read($sql);
- $info = Dba::fetch_row($db_results);
+ $info = Dba::fetch_row($db_results);
- return $info['0'];
+ return $info['0'];
} // count_tags
@@ -396,7 +396,7 @@ class Catalog extends database_object {
*/
public static function count_songs($catalog_id='') {
- $catalog_search = $catalog_id ? "WHERE `catalog`='" . Dba::escape($catalog_id) . "'" : '';
+ $catalog_search = $catalog_id ? "WHERE `catalog`='" . Dba::escape($catalog_id) . "'" : '';
$sql = "SELECT COUNT(`id`),SUM(`time`),SUM(`size`) FROM `song` $catalog_search";
$db_results = Dba::read($sql);
@@ -462,13 +462,13 @@ class Catalog extends database_object {
public function add_files($path,$options) {
// Profile the memory a bit
- debug_event('Memory',memory_get_usage(true)/1024/1024 . "MB",1);
+ debug_event('Memory',memory_get_usage(true)/1024/1024 . "MB",1);
// See if we want a non-root path for the add
- if (isset($options['subdirectory'])) {
- $path = $options['subdirectory'];
- unset($options['subdirectory']);
- }
+ if (isset($options['subdirectory'])) {
+ $path = $options['subdirectory'];
+ unset($options['subdirectory']);
+ }
// Correctly detect the slash we need to use here
if (strstr($path,"/")) {
@@ -497,10 +497,10 @@ class Catalog extends database_object {
// Ensure that we've got our cache
$this->_create_filecache();
- debug_event('Memory',memory_get_usage(true)/1024/1024 . "MB",1);
+ debug_event('Memory',memory_get_usage(true)/1024/1024 . "MB",1);
// Set the base "ticker" we will only update ever 5+ seconds
- $ticker = time();
+ $ticker = time();
/* Recurse through this dir and create the files array */
while ( false !== ( $file = readdir($handle) ) ) {
@@ -509,7 +509,7 @@ class Catalog extends database_object {
if (substr($file,0,1) == '.') { continue; }
debug_event('read',"Starting work on $file inside $path",'5','ampache-catalog');
- debug_event('Memory',memory_get_usage(true)/1024/1024 . "MB",1);
+ debug_event('Memory',memory_get_usage(true)/1024/1024 . "MB",1);
/* Create the new path */
$full_file = $path.$slash_type.$file;
@@ -520,7 +520,7 @@ class Catalog extends database_object {
if (isset($this->_filecache[strtolower($full_file)])) {
continue;
}
-
+
// Incase this is the second time through clear this variable
// if it was set the day before
unset($failed_check);
@@ -559,12 +559,12 @@ class Catalog extends database_object {
$pattern .= ")$/i";
}
- $is_audio_file = preg_match($pattern,$file);
-
+ $is_audio_file = preg_match($pattern,$file);
+
// Define the Video file pattern
if (!$is_audio_file AND Config::get('catalog_video_pattern')) {
- $video_pattern = "/\.(" . Config::get('catalog_video_pattern') . ")$/i";
- $is_video_file = preg_match($video_pattern,$file);
+ $video_pattern = "/\.(" . Config::get('catalog_video_pattern') . ")$/i";
+ $is_video_file = preg_match($video_pattern,$file);
}
/* see if this is a valid audio file or playlist file */
@@ -603,9 +603,9 @@ class Catalog extends database_object {
else {
if ($is_audio_file) { $this->insert_local_song($full_file,$file_size); }
- else { $this->insert_local_video($full_file,$file_size); }
+ else { $this->insert_local_video($full_file,$file_size); }
- $this->count++;
+ $this->count++;
if ( (time() > $ticker+1)) {
$file = str_replace(array('(',')','\''),'',$full_file);
echo "<script type=\"text/javascript\">\n";
@@ -613,7 +613,7 @@ class Catalog extends database_object {
echo "update_txt('" . addslashes(htmlentities($file)) . "','add_dir_" . $this->id . "');";
echo "\n</script>\n";
flush();
- $ticker = time();
+ $ticker = time();
} // update our current state
} // if it's not an m3u
@@ -691,7 +691,7 @@ class Catalog extends database_object {
}
// Start the ticker
- $ticker = time();
+ $ticker = time();
// Run through them an get the art!
foreach ($albums as $album_id) {
@@ -700,19 +700,19 @@ class Catalog extends database_object {
$album = new Album($album_id);
// We're going to need the name here
$album->format();
-
+
debug_event('gather_art','Gathering art for ' . $album->name,'5');
-
+
// Define the options we want to use for the find art function
$options = array(
'album_name' => $album->full_name,
'artist' => $album->artist_name,
- 'keyword' => $album->artist_name . ' ' . $album->full_name
+ 'keyword' => $album->artist_name . ' ' . $album->full_name
);
// Return results
$results = $album->find_art($options,1);
-
+
if (count($results)) {
// Pull the string representation from the source
$image = Album::get_image_from_source($results['0']);
@@ -733,9 +733,9 @@ class Catalog extends database_object {
echo "update_txt('" . addslashes($album->name) . "','read_art_" . $this->id . "');";
echo "\n</script>\n";
flush();
- $ticker = time();
+ $ticker = time();
} //echos song count
-
+
unset($found);
} // foreach albums
@@ -830,9 +830,9 @@ class Catalog extends database_object {
// Setup the base SQL
$sql = "SELECT song.id AS song,artist.id AS artist,album.id AS album,title,COUNT(title) AS ctitle".
- " FROM `song` LEFT JOIN `artist` ON `artist`.`id`=`song`.`artist` " .
+ " FROM `song` LEFT JOIN `artist` ON `artist`.`id`=`song`.`artist` " .
" LEFT JOIN `album` ON `album`.`id`=`song`.`album` $where_sql GROUP BY `song`.`title`";
-
+
// Add any Additional constraints
if ($search_method == "artist_title" OR $search_method == "artist_album_title") {
$sql = $sql.",artist.name";
@@ -924,7 +924,7 @@ class Catalog extends database_object {
else {
$extension = substr($image['0']['mime'],strlen($image['0']['mime'])-3,3);
}
-
+
// Try the preferred filename, if that fails use folder.???
$preferred_filename = Config::get('album_art_preferred_filename');
if (!$preferred_filename || strstr($preferred_filename,"%")) { $preferred_filename = "folder.$extension"; }
@@ -1002,11 +1002,11 @@ class Catalog extends database_object {
* update_last_clean
* This updates the last clean information
*/
- public function update_last_clean() {
+ public function update_last_clean() {
- $date = time();
- $sql = "UPDATE `catalog` SET `last_clean`='$date' WHERE `id`='$this->id'";
- $db_results = Dba::write($sql);
+ $date = time();
+ $sql = "UPDATE `catalog` SET `last_clean`='$date' WHERE `id`='$this->id'";
+ $db_results = Dba::write($sql);
} // update_last_clean
@@ -1075,7 +1075,7 @@ class Catalog extends database_object {
}
} // foreach songs
- self::clean();
+ self::clean();
} // update_single_item
@@ -1084,33 +1084,33 @@ class Catalog extends database_object {
* This is a 'wrapper' function calls the update function for the media type
* in question
*/
- public static function update_media_from_tags(&$media,$sort_pattern='',$rename_pattern='') {
+ public static function update_media_from_tags(&$media,$sort_pattern='',$rename_pattern='') {
// Check for patterns
- if (!$sort_pattern OR !$rename_pattern) {
- $catalog = new Catalog($media->catalog);
- $sort_pattern = $catalog->sort_pattern;
- $rename_pattern = $catalog->rename_pattern;
- }
+ if (!$sort_pattern OR !$rename_pattern) {
+ $catalog = new Catalog($media->catalog);
+ $sort_pattern = $catalog->sort_pattern;
+ $rename_pattern = $catalog->rename_pattern;
+ }
- debug_event('tag-read','Reading tags from ' . $media->file,'5','ampache-catalog');
+ debug_event('tag-read','Reading tags from ' . $media->file,'5','ampache-catalog');
- $vainfo = new vainfo($media->file,'','','',$sort_pattern,$rename_pattern);
- $vainfo->get_info();
+ $vainfo = new vainfo($media->file,'','','',$sort_pattern,$rename_pattern);
+ $vainfo->get_info();
- $key = vainfo::get_tag_type($vainfo->tags);
+ $key = vainfo::get_tag_type($vainfo->tags);
- $results = vainfo::clean_tag_info($vainfo->tags,$key,$media->file);
+ $results = vainfo::clean_tag_info($vainfo->tags,$key,$media->file);
// Figure out what type of object this is and call the right function
// giving it the stuff we've figured out above
- $name = (get_class($media) == 'Song') ? 'song' : 'video';
+ $name = (get_class($media) == 'Song') ? 'song' : 'video';
- $function = 'update_' . $name . '_from_tags';
+ $function = 'update_' . $name . '_from_tags';
- $return = call_user_func(array('Catalog',$function),$results,$media);
+ $return = call_user_func(array('Catalog',$function),$results,$media);
- return $return;
+ return $return;
} // update_media_from_tags
@@ -1119,10 +1119,10 @@ class Catalog extends database_object {
* updates the video info based on tags this is called from a bunch of different places
* and passes in a full song object and the vainfo results
*/
- public static function update_video_from_tags($results,$video) {
+ public static function update_video_from_tags($results,$video) {
// Pretty sweet function here
- return $results;
+ return $results;
} // update_video_from_tags
@@ -1140,20 +1140,20 @@ class Catalog extends database_object {
$new_song->title = $results['title'];
$new_song->year = $results['year'];
$new_song->comment = $results['comment'];
- $new_song->language = $results['language'];
- $new_song->lyrics = $results['lyrics'];
+ $new_song->language = $results['language'];
+ $new_song->lyrics = $results['lyrics'];
$new_song->bitrate = $results['bitrate'];
$new_song->rate = $results['rate'];
- $new_song->mode = ($results['mode'] == 'cbr') ? 'cbr' : 'vbr';
+ $new_song->mode = ($results['mode'] == 'cbr') ? 'cbr' : 'vbr';
$new_song->size = $results['size'];
$new_song->time = $results['time'];
- $new_song->mime = $results['mime'];
- $new_song->track = intval($results['track']);
- $new_song->mbid = $results['mb_trackid'];
+ $new_song->mime = $results['mime'];
+ $new_song->track = intval($results['track']);
+ $new_song->mbid = $results['mb_trackid'];
$artist = $results['artist'];
- $artist_mbid = $results['mb_artistid'];
+ $artist_mbid = $results['mb_artistid'];
$album = $results['album'];
- $album_mbid = $results['mb_albumid'];
+ $album_mbid = $results['mb_albumid'];
$disk = $results['disk'];
$tags = $results['genre']; // multiple genre support makes this an array
@@ -1166,7 +1166,7 @@ class Catalog extends database_object {
$new_song->album = self::check_album($album,$new_song->year,$disk,$album_mbid);
$new_song->f_album = $album . " - " . $new_song->year;
$new_song->title = self::check_title($new_song->title,$new_song->file);
-
+
// Nothing to assign here this is a multi-value doodly
// multiple genre support
foreach ($tags as $tag) {
@@ -1271,7 +1271,7 @@ class Catalog extends database_object {
* the XML RPC stuff and a key to be passed
*/
public function get_remote_catalog($type=0) {
-
+
if (!class_exists('XML_RPC_Client')) {
debug_event('xmlrpc',"Unable to load pear XMLRPC library",'1');
echo "<span class=\"error\"><b>" . _("Error") . "</b>: " . _('Unable to load pear XMLRPC library, make sure XML-RPC is enabled') . "</span><br />\n";
@@ -1317,9 +1317,9 @@ class Catalog extends database_object {
echo "<p class=\"error\">$error_msg</p>";
return;
}
-
+
$data = XML_RPC_Decode($response->value());
-
+
// Print out the catalogs we are going to sync
foreach ($data as $vars) {
$catalog_name = $vars['name'];
@@ -1343,13 +1343,13 @@ class Catalog extends database_object {
echo "<p>" . _('Completed updating remote catalog(s)') . ".</p><hr />\n";
flush();
-
+
// Try to sync the album images from the remote catalog
echo "<p>" . _('Starting synchronisation of album images') . ".</p><br />\n";
$this->get_remote_album_images($client, $token, $path);
echo "<p>" . _('Completed synchronisation of album images') . ".</p><hr />\n";
flush();
-
+
// Update the last update value
$this->update_last_update();
@@ -1400,11 +1400,11 @@ class Catalog extends database_object {
* This function retrieves the album information from the remote server
*/
public function get_remote_album_images($client,$token,$path) {
-
+
$encoded_key = new XML_RPC_Value($token,'string');
$query_array = array($encoded_key);
$xmlrpc_message = new XML_RPC_Message('xmlrpcserver.get_album_images',$query_array);
-
+
/* Depending upon the size of the target catalog this can be a very slow/long process */
set_time_limit(0);
@@ -1427,7 +1427,7 @@ class Catalog extends database_object {
return;
} // get_album_images
-
+
/**
* update_remote_catalog
* actually updates from the remote data, takes an array of songs that are base64 encoded and parses them
@@ -1444,7 +1444,7 @@ class Catalog extends database_object {
// Prevent a timeout
set_time_limit(0);
-
+
$song = unserialize($serialized_song);
$song->artist = self::check_artist($song->artist);
$song->album = self::check_album($song->album,$song->year);
@@ -1473,7 +1473,7 @@ class Catalog extends database_object {
*/
public function update_remote_album_images($data, $remote_server, $auth, $path) {
$label = "catalog.class.php::update_remote_album_images";
-
+
$total_updated = 0;
/* If album images don't exist, return value will be 0. */
@@ -1491,15 +1491,15 @@ class Catalog extends database_object {
$remote_album = new Album();
$remote_album = unserialize($serialized_album);
$remote_album->format(); //this will set the fullname
-
+
$debug_text = "remote_album id, name, year: ";
- $debug_text.= $remote_album->id . ", " . $remote_album->name . ", " . $remote_album->year;
+ $debug_text.= $remote_album->id . ", " . $remote_album->name . ", " . $remote_album->year;
debug_event($label, $debug_text, '4');
-
+
// check the album if it exists by checking the name and the year of the album
$local_album_id = self::check_album($remote_album->name, $remote_album->year,"","", true);
- debug_event($label, "local_album_id: " . $local_album_id, '4');
-
+ debug_event($label, "local_album_id: " . $local_album_id, '4');
+
if ($local_album_id != 0) {
// Local album found lets add the cover
if(isset($path) AND !preg_match("/^\//", $path)) { $path = "/".$path; }
@@ -1509,23 +1509,23 @@ class Catalog extends database_object {
$server_path.= "&auth=" . $auth;
debug_event($label, "image_url: " . $server_path,'4');
$data['url'] = $server_path;
-
+
$local_album = new Album($local_album_id);
$image_data = $local_album->get_image_from_source($data);
-
+
// If we got something back insert it
- if ($image_data) {
+ if ($image_data) {
$local_album->insert_art($image_data,"");
$total_updated++;
debug_event($label, "adding album image succes", '4');
- } else {
+ } else {
debug_event($label, "adding album image failed ", '4');
- }
+ }
}
}
-
+
return $total_updated;
-
+
} // update_remote_album_images
/**
@@ -1537,9 +1537,9 @@ class Catalog extends database_object {
// Added set time limit because this runs out of time for some people
set_time_limit(0);
-
- $dead_video = array();
- $dead_song = array();
+
+ $dead_video = array();
+ $dead_song = array();
require_once Config::get('prefix') . '/templates/show_clean_catalog.inc.php';
flush();
@@ -1555,15 +1555,15 @@ class Catalog extends database_object {
}
/* Get all songs in this catalog */
- $sql = "SELECT `id`,`file`,'song' AS `type` FROM `song` WHERE `catalog`='$this->id' AND `enabled`='1' " .
- "UNION ALL " .
- "SELECT `id`,`file`,'video' AS `type` FROM `video` WHERE `catalog`='$this->id' AND `enabled`='1'";
+ $sql = "SELECT `id`,`file`,'song' AS `type` FROM `song` WHERE `catalog`='$this->id' AND `enabled`='1' " .
+ "UNION ALL " .
+ "SELECT `id`,`file`,'video' AS `type` FROM `video` WHERE `catalog`='$this->id' AND `enabled`='1'";
$db_results = Dba::read($sql);
// Set to 0 our starting point
$dead_files = 0;
- $ticker = time();
+ $ticker = time();
/* Recurse through files, put @ to prevent errors poping up */
while ($results = Dba::fetch_assoc($db_results)) {
@@ -1577,31 +1577,31 @@ class Catalog extends database_object {
echo "update_txt('" . addslashes(htmlentities($file)) . "','clean_dir_" . $this->id . "');";
echo "\n</script>\n";
flush();
- $ticker = time();
+ $ticker = time();
} //echos song count
-
+
/* Also check the file information */
if($this->catalog_type == 'local') {
$file_info = filesize($results['file']);
-
+
/* If it errors somethings splated, or the files empty */
if (!file_exists($results['file']) OR $file_info < 1) {
-
+
/* Add Error */
Error::add('general',_('Error File Not Found or 0 Bytes:') . $results['file']);
- $table = ($results['type'] == 'video') ? 'dead_video' : 'dead_song';
+ $table = ($results['type'] == 'video') ? 'dead_video' : 'dead_song';
- // Store it in an array we'll delete it later...
- ${$table}[] = $results['id'];
+ // Store it in an array we'll delete it later...
+ ${$table}[] = $results['id'];
// Count em!
$dead_files++;
} //if error
- if (!is_readable($results['file'])) {
- debug_event('Clean','Error ' . $results['file'] . ' is not readable, but does exist','1');
- }
+ if (!is_readable($results['file'])) {
+ debug_event('Clean','Error ' . $results['file'] . ' is not readable, but does exist','1');
+ }
} // if localtype
else {
//do remote url check
@@ -1613,10 +1613,10 @@ class Catalog extends database_object {
Error::add('general',_('Error Remote File Not Found or 0 Bytes:') . $results['file']);
- $table = ($results['type'] == 'video') ? 'dead_video' : 'dead_song';
+ $table = ($results['type'] == 'video') ? 'dead_video' : 'dead_song';
- // Store it in an array we'll delete it later...
- ${$table}[] = $results['id'];
+ // Store it in an array we'll delete it later...
+ ${$table}[] = $results['id'];
// Count em!
$dead_files++;
@@ -1628,21 +1628,21 @@ class Catalog extends database_object {
// Check and see if _everything_ has gone away, might indicate a dead mount
// We call this the AlmightyOatmeal Sanity check
- if ($dead_files == $count) {
- Error::add('general',_('Error All songs would be removed, doing nothing'));
- return false;
- }
- else {
- if (count($dead_video)) {
- $idlist = '(' . implode(',',$dead_video) . ')';
- $sql = "DELETE FROM `video` WHERE `id` IN $idlist";
- $db_results = Dba::write($sql);
- }
- if (count($dead_song)) {
- $idlist = '(' . implode(',',$dead_song) . ')';
- $sql = "DELETE FROM `song` WHERE `id` IN $idlist";
- $db_results = Dba::write($sql);
- }
+ if ($dead_files == $count) {
+ Error::add('general',_('Error All songs would be removed, doing nothing'));
+ return false;
+ }
+ else {
+ if (count($dead_video)) {
+ $idlist = '(' . implode(',',$dead_video) . ')';
+ $sql = "DELETE FROM `video` WHERE `id` IN $idlist";
+ $db_results = Dba::write($sql);
+ }
+ if (count($dead_song)) {
+ $idlist = '(' . implode(',',$dead_song) . ')';
+ $sql = "DELETE FROM `song` WHERE `id` IN $idlist";
+ $db_results = Dba::write($sql);
+ }
}
/* Step two find orphaned Arists/Albums
@@ -1665,7 +1665,7 @@ class Catalog extends database_object {
flush();
// Set the last clean date
- $this->update_last_clean();
+ $this->update_last_clean();
} //clean_catalog
@@ -1677,7 +1677,7 @@ class Catalog extends database_object {
public static function clean_tags() {
$sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `song` ON `song`.`id`=`tag_map`.`object_id` " .
- "WHERE `tag_map`.`object_type`='song' AND `song`.`id` IS NULL";
+ "WHERE `tag_map`.`object_type`='song' AND `song`.`id` IS NULL";
$db_results = Dba::write($sql);
$sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `album` ON `album`.`id`=`tag_map`.`object_id` " .
@@ -1688,13 +1688,13 @@ class Catalog extends database_object {
"WHERE `tag_map`.`object_type`='artist' AND `artist`.`id` IS NULL";
$db_results = Dba::write($sql);
- $sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `video` ON `video`.`id`=`tag_map`.`object_id` " .
- "WHERE `tag_map`.`object_type`='video' AND `video`.`id` IS NULL";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `video` ON `video`.`id`=`tag_map`.`object_id` " .
+ "WHERE `tag_map`.`object_type`='video' AND `video`.`id` IS NULL";
+ $db_results = Dba::write($sql);
// Now nuke the tags themselves
$sql = "DELETE FROM `tag` USING `tag` LEFT JOIN `tag_map` ON `tag`.`id`=`tag_map`.`tag_id` " .
- "WHERE `tag_map`.`id` IS NULL";
+ "WHERE `tag_map`.`id` IS NULL";
$db_results = Dba::write($sql);
} // clean_tags
@@ -1707,7 +1707,7 @@ class Catalog extends database_object {
// Clean songs
$sql = "DELETE FROM `user_shout` USING `user_shout` LEFT JOIN `song` ON `song`.`id`=`user_shout`.`object_id` " .
- "WHERE `song`.`id` IS NULL AND `user_shout`.`object_type`='song'";
+ "WHERE `song`.`id` IS NULL AND `user_shout`.`object_type`='song'";
$db_results = Dba::write($sql);
// Clean albums
@@ -1780,7 +1780,7 @@ class Catalog extends database_object {
// Clear TMP Playlist information as well
$sql = "DELETE FROM `tmp_playlist_data` USING `tmp_playlist_data` LEFT JOIN `song` ON `tmp_playlist_data`.`object_id` = `song`.`id` " .
- "WHERE `song`.`id` IS NULL";
+ "WHERE `song`.`id` IS NULL";
$db_results = Dba::write($sql);
} // clean_playlists
@@ -1792,7 +1792,7 @@ class Catalog extends database_object {
public static function clean_ext_info() {
$sql = "DELETE FROM `song_data` USING `song_data` LEFT JOIN `song` ON `song`.`id` = `song_data`.`song_id` " .
- "WHERE `song`.`id` IS NULL";
+ "WHERE `song`.`id` IS NULL";
$db_results = Dba::write($sql);
} // clean_ext_info
@@ -1820,9 +1820,9 @@ class Catalog extends database_object {
$db_results = Dba::write($sql);
// Clean the stats
- $sql = "DELETE FROM `object_count` USING `object_count` LEFT JOIN `video` ON `video`.`id`=`object_count`.`object_id` " .
- "WHERE `object_count`.`object_type`='video' AND `video`.`id` IS NULL";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `object_count` USING `object_count` LEFT JOIN `video` ON `video`.`id`=`object_count`.`object_id` " .
+ "WHERE `object_count`.`object_type`='video' AND `video`.`id` IS NULL";
+ $db_results = Dba::write($sql);
// Delete Song Ratings information
$sql = "DELETE FROM rating USING rating LEFT JOIN song ON song.id=rating.object_id WHERE object_type='song' AND song.id IS NULL";
@@ -1837,8 +1837,8 @@ class Catalog extends database_object {
$db_results = Dba::write($sql);
// Delete the Video Rating Informations
- $sql = "DELETE FROM `rating` USING `rating` LEFT JOIN `video` ON `video`.`id`=`rating`.`object_id` " .
- "WHERE `rating`.`object_type`='video' AND `video`.`id` IS NULL";
+ $sql = "DELETE FROM `rating` USING `rating` LEFT JOIN `video` ON `video`.`id`=`rating`.`object_id` " .
+ "WHERE `rating`.`object_type`='video' AND `video`.`id` IS NULL";
$db_results = Dba::write($sql);
} // clean_stats
@@ -1852,44 +1852,44 @@ class Catalog extends database_object {
// Create the object so we have some information on it
$catalog = new Catalog($catalog_id);
- $cache = array();
- $songs = array();
+ $cache = array();
+ $songs = array();
// Record that we're caching this stuff so it makes debugging easier
debug_event('Verify','Starting Verify of '. $catalog->name . ' caching data...','5');
/* First get the filenames for the catalog */
$sql = "SELECT `id`,`file`,`artist`,`album`,'song' AS `type` FROM `song` WHERE `song`.`catalog`='$catalog_id' ";
- $db_results = Dba::read($sql);
-
- while ($row = Dba::fetch_assoc($db_results)) {
- $cache[] = $row['id'];
- $artists[] = $row['artist'];
- $albums[] = $row['album'];
- $songs[] = $row;
- }
-
- Song::build_cache($cache);
- Flag::build_map_cache($cache,'song');
- Tag::build_map_cache('album',$albums);
- Tag::build_map_cache('artist',$artists);
- Tag::build_map_cache('song',$cache);
-
- $cache = array();
- $videos = array();
- $sql = "SELECT `id`,`file`,'video' AS `type` FROM `video` WHERE `video`.`catalog`='$catalog_id'";
- $db_results = Dba::read($sql);
-
- while ($row = Dba::fetch_assoc($db_results)) {
+ $db_results = Dba::read($sql);
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $cache[] = $row['id'];
+ $artists[] = $row['artist'];
+ $albums[] = $row['album'];
+ $songs[] = $row;
+ }
+
+ Song::build_cache($cache);
+ Flag::build_map_cache($cache,'song');
+ Tag::build_map_cache('album',$albums);
+ Tag::build_map_cache('artist',$artists);
+ Tag::build_map_cache('song',$cache);
+
+ $cache = array();
+ $videos = array();
+ $sql = "SELECT `id`,`file`,'video' AS `type` FROM `video` WHERE `video`.`catalog`='$catalog_id'";
+ $db_results = Dba::read($sql);
+
+ while ($row = Dba::fetch_assoc($db_results)) {
$cache[] = $row['id'];
- $videos[] = $row;
- }
- Video::build_cache($cache);
- Flag::build_map_cache($cache,'video');
+ $videos[] = $row;
+ }
+ Video::build_cache($cache);
+ Flag::build_map_cache($cache,'video');
- $cached_results = array_merge($songs,$videos);
+ $cached_results = array_merge($songs,$videos);
- $number = count($cached_results);
+ $number = count($cached_results);
require_once Config::get('prefix') . '/templates/show_verify_catalog.inc.php';
flush();
@@ -1899,18 +1899,18 @@ class Catalog extends database_object {
// Caching array for album art, save us some time here
$album_art_check_cache = array();
- $ticker = time();
+ $ticker = time();
/* Recurse through this catalogs files
* and get the id3 tage information,
* if it's not blank, and different in
* in the file then update!
*/
- foreach ($cached_results as $results) {
+ foreach ($cached_results as $results) {
debug_event('verify',"Starting work on " . $results['file'],'5','ampache-catalog');
$type = ($results['type'] == 'video') ? 'video' : 'song';
-
+
if (is_readable($results['file'])) {
/* Create the object from the existing database information */
@@ -1923,9 +1923,9 @@ class Catalog extends database_object {
$skip = true;
}
- if (filemtime($results['file']) <= $media->update_time) {
- $skip = true;
- }
+ if (filemtime($results['file']) <= $media->update_time) {
+ $skip = true;
+ }
// if the file hasn't been modified since the last_update
if (!$skip) {
@@ -1951,7 +1951,7 @@ class Catalog extends database_object {
echo "update_txt('" . scrub_out($file) . "','verify_dir_" . $catalog_id . "');";
echo "\n</script>\n";
flush();
- $ticker = time();
+ $ticker = time();
} //echos song count
} // end if file exists
@@ -2014,8 +2014,8 @@ class Catalog extends database_object {
public static function optimize_tables() {
$sql = "OPTIMIZE TABLE `song_data`,`song`,`rating`,`catalog`,`session`,`object_count`,`album`,`album_data`" .
- ",`artist`,`ip_history`,`flagged`,`now_playing`,`user_preference`,`tag`,`tag_map`,`tmp_playlist`" .
- ",`tmp_playlist_data`,`playlist`,`playlist_data`,`session_stream`,`video`";
+ ",`artist`,`ip_history`,`flagged`,`now_playing`,`user_preference`,`tag`,`tag_map`,`tmp_playlist`" .
+ ",`tmp_playlist_data`,`playlist`,`playlist_data`,`session_stream`,`video`";
$db_results = Dba::write($sql);
$sql = "ANALYZE TABLE `song_data`,`song`,`rating`,`catalog`,`session`,`object_count`,`album`,`album_data`" .
@@ -2098,7 +2098,7 @@ class Catalog extends database_object {
unset($id_array);
}
} // fuzzy matching
-
+
/* If not found create */
if (!$readonly && !$exists) {
@@ -2205,7 +2205,7 @@ class Catalog extends database_object {
}
// Save the cache
- self::$albums[$album][$album_year][$disk][$mbid] = $album_id;
+ self::$albums[$album][$album_year][$disk][$mbid] = $album_id;
return $album_id;
@@ -2213,18 +2213,18 @@ class Catalog extends database_object {
/**
* check_tag
- * This checks the tag we've been passed (name)
+ * This checks the tag we've been passed (name)
* and sees if it exists, and if so if it's mapped
* to this object, this is only done for songs for now
*/
- public static function check_tag($value,$object_id,$object_type='song') {
+ public static function check_tag($value,$object_id,$object_type='song') {
- $map_id = Tag::add($object_type,$object_id,$value,'0');
+ $map_id = Tag::add($object_type,$object_id,$value,'0');
- return $map_id;
+ return $map_id;
} // check_tag
-
+
/**
* check_title
* this checks to make sure something is
@@ -2294,21 +2294,21 @@ class Catalog extends database_object {
debug_event('insert',"Unable to insert $file -- $sql" . Dba::error(),'5','ampache-catalog');
Error::add('catalog_add','SQL Error Adding ' . $file);
}
-
+
$song_id = Dba::insert_id();
// multiple genre support
foreach ($tags as $tag) {
$tag = trim($tag);
self::check_tag($tag,$song_id);
- self::check_tag($tag,$album_id,'album');
+ self::check_tag($tag,$album_id,'album');
self::check_tag($tag,$artist_id,'artist');
}
/* Add the EXT information */
$sql = "INSERT INTO `song_data` (`song_id`,`comment`,`lyrics`) " .
- " VALUES ('$song_id','$comment','$lyrics')";
+ " VALUES ('$song_id','$comment','$lyrics')";
$db_results = Dba::write($sql);
if (!$db_results) {
@@ -2339,7 +2339,7 @@ class Catalog extends database_object {
echo "<span style=\"color: #FOO;\">Error Adding Remote $url </span><br />$sql<br />\n";
flush();
}
-
+
} // insert_remote_song
/**
@@ -2348,36 +2348,36 @@ class Catalog extends database_object {
* information we can get is super sketchy so it's kind of a crap shoot
* here
*/
- public function insert_local_video($file,$filesize) {
+ public function insert_local_video($file,$filesize) {
/* Create the vainfo object and get info */
$vainfo = new vainfo($file,'','','',$this->sort_pattern,$this->rename_pattern);
$vainfo->get_info();
- $tag_name = vainfo::get_tag_type($vainfo->tags);
- $results = vainfo::clean_tag_info($vainfo->tags,$tag_name,$file);
+ $tag_name = vainfo::get_tag_type($vainfo->tags);
+ $results = vainfo::clean_tag_info($vainfo->tags,$tag_name,$file);
- $file = Dba::escape($file);
- $catalog_id = Dba::escape($this->id);
- $title = Dba::escape($results['title']);
- $vcodec = $results['video_codec'];
- $acodec = $results['audio_codec'];
- $rezx = intval($results['resolution_x']);
- $rezy = intval($results['resolution_y']);
- $filesize = Dba::escape($filesize);
- $time = Dba::escape($results['time']);
- $mime = Dba::escape($results['mime']);
+ $file = Dba::escape($file);
+ $catalog_id = Dba::escape($this->id);
+ $title = Dba::escape($results['title']);
+ $vcodec = $results['video_codec'];
+ $acodec = $results['audio_codec'];
+ $rezx = intval($results['resolution_x']);
+ $rezy = intval($results['resolution_y']);
+ $filesize = Dba::escape($filesize);
+ $time = Dba::escape($results['time']);
+ $mime = Dba::escape($results['mime']);
// UNUSED CURRENTLY
- $comment = Dba::escape($results['comment']);
- $year = Dba::escape($results['year']);
- $disk = Dba::escape($results['disk']);
+ $comment = Dba::escape($results['comment']);
+ $year = Dba::escape($results['year']);
+ $disk = Dba::escape($results['disk']);
- $sql = "INSERT INTO `video` (`file`,`catalog`,`title`,`video_codec`,`audio_codec`,`resolution_x`,`resolution_y`,`size`,`time`,`mime`) " .
- " VALUES ('$file','$catalog_id','$title','$vcodec','$acodec','$rezx','$rezy','$filesize','$time','$mime')";
- $db_results = Dba::write($sql);
+ $sql = "INSERT INTO `video` (`file`,`catalog`,`title`,`video_codec`,`audio_codec`,`resolution_x`,`resolution_y`,`size`,`time`,`mime`) " .
+ " VALUES ('$file','$catalog_id','$title','$vcodec','$acodec','$rezx','$rezy','$filesize','$time','$mime')";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // insert_local_video
@@ -2541,7 +2541,7 @@ class Catalog extends database_object {
$name = "M3U - " . basename($filename,'.m3u');
$playlist_id = Playlist::create($name,'public');
- if (!$playlist_id) {
+ if (!$playlist_id) {
$reason = _('Playlist creation error.');
return false;
}
@@ -2549,13 +2549,13 @@ class Catalog extends database_object {
/* Recreate the Playlist */
$playlist = new Playlist($playlist_id);
$playlist->add_songs($songs);
- $reason = sprintf(ngettext('Playlist Import and Recreate Successful. Total: %d Song',
+ $reason = sprintf(ngettext('Playlist Import and Recreate Successful. Total: %d Song',
'Playlist Import and Recreate Successful. Total: %d Songs',
count($songs)), count($songs));
return true;
}
/* HINT: filename */
- $reason = sprintf(ngettext('Parsing %s - Not Found: %d Song. Please check your m3u file.',
+ $reason = sprintf(ngettext('Parsing %s - Not Found: %d Song. Please check your m3u file.',
'Parsing %s - Not Found: %d Songs. Please check your m3u file.',
count($songs)), $filename, count($songs));
return false;
@@ -2578,10 +2578,10 @@ class Catalog extends database_object {
// Only if the previous one works do we go on
if (!$db_results) { return false; }
- $sql = "DELETE FROM `video` WHERE `catalog` = '$catalog_id'";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `video` WHERE `catalog` = '$catalog_id'";
+ $db_results = Dba::write($sql);
- if (!$db_results) { return false; }
+ if (!$db_results) { return false; }
// Next Remove the Catalog Entry it's self
$sql = "DELETE FROM `catalog` WHERE `id` = '$catalog_id'";
@@ -2601,7 +2601,7 @@ class Catalog extends database_object {
// Select all songs in catalog
if($this->id) {
$sql = "SELECT id FROM song WHERE catalog = '$this->id' ORDER BY album,track";
- }
+ }
else {
$sql = "SELECT id FROM song ORDER BY album,track";
}
@@ -2642,9 +2642,9 @@ class Catalog extends database_object {
$song = new Song($results['id']);
$song->format();
echo '"' . $song->id . '","' . $song->title . '","' . $song->f_artist_full . '","' . $song->f_album_full .
- '","' . $song->f_genre . '","' . $song->f_time . '","' . $song->f_track . '","' . $song->year .
- '","' . date("Y-m-d\TH:i:s\Z",$song->addition_time) . '","' . $song->f_bitrate .
- '","' . $song->played . '","' . $song->file . "\n";
+ '","' . $song->f_genre . '","' . $song->f_time . '","' . $song->f_track . '","' . $song->year .
+ '","' . date("Y-m-d\TH:i:s\Z",$song->addition_time) . '","' . $song->f_bitrate .
+ '","' . $song->played . '","' . $song->file . "\n";
}
break;
} // end switch
diff --git a/lib/class/config.class.php b/lib/class/config.class.php
index 1bd18806..601a7813 100644
--- a/lib/class/config.class.php
+++ b/lib/class/config.class.php
@@ -23,25 +23,25 @@
/* config class
* used to store static arrays of
* config values, can read from ini files
- *
+ *
* has static methods, this uses the global config
* creating a 'Config' object will allow for local
* config overides and/or local configs (for like dba)
- * The class should be a static var in the other classes
+ * The class should be a static var in the other classes
*/
class Config {
// These are the settings for this specific class
- private $_local = array();
+ private $_local = array();
// These are the global settings they go where it goes
- private static $_global = array();
+ private static $_global = array();
/**
* constructor
* This is what is called when the class is loaded
*/
- public function __construct() {
+ public function __construct() {
// Rien a faire
@@ -62,12 +62,12 @@ class Config {
* get_all
* This returns all of the current config variables as an array
*/
- public static function get_all() {
+ public static function get_all() {
- return self::$_global;
+ return self::$_global;
} // get_all
-
+
/**
* set
* This checks to see if this is an instance or procedure calls
@@ -75,13 +75,13 @@ class Config {
*/
public static function set($name, $value, $clobber = 0) {
- if (isset(self::$_global[$name]) && !$clobber) {
- Error::add('Config Global',"Trying to clobber'$name' without setting clobber");
+ if (isset(self::$_global[$name]) && !$clobber) {
+ Error::add('Config Global',"Trying to clobber'$name' without setting clobber");
return;
}
- else {
- self::$_global[$name] = $value;
- }
+ else {
+ self::$_global[$name] = $value;
+ }
} // set
@@ -90,12 +90,12 @@ class Config {
* This is the same as the set function except it takes an array as input
*/
public static function set_by_array($array, $clobber = 0) {
-
- foreach ($array as $name => $value) {
- self::set($name,$value,$clobber);
- }
+
+ foreach ($array as $name => $value) {
+ self::set($name,$value,$clobber);
+ }
} // set_by_array
-
+
} // end Config class
?>
diff --git a/lib/class/core.class.php b/lib/class/core.class.php
index 5162c20b..683107d3 100644
--- a/lib/class/core.class.php
+++ b/lib/class/core.class.php
@@ -31,9 +31,9 @@ class Core {
* constructor
* This doesn't do anything
*/
- private function __construct() {
+ private function __construct() {
- return false;
+ return false;
} // construction
@@ -42,25 +42,25 @@ class Core {
* This registers a form with a SID, inserts it into the session variables
* and then returns a string for use in the HTML form
*/
- public static function form_register($name,$type='post') {
+ public static function form_register($name,$type='post') {
// Make ourselves a nice little sid
$sid = md5(uniqid(rand(), true));
// Register it
- $_SESSION['forms'][$name] = array('sid'=>$sid,'expire'=>time() + Config::get('session_length'));
-
- switch ($type) {
- default:
- case 'post':
- $string = '<input type="hidden" name="form_validation" value="' . $sid . '" />';
- break;
- case 'get':
- $string = $sid;
- break;
+ $_SESSION['forms'][$name] = array('sid'=>$sid,'expire'=>time() + Config::get('session_length'));
+
+ switch ($type) {
+ default:
+ case 'post':
+ $string = '<input type="hidden" name="form_validation" value="' . $sid . '" />';
+ break;
+ case 'get':
+ $string = $sid;
+ break;
} // end switch on type
- return $string;
+ return $string;
} // form_register
@@ -69,30 +69,30 @@ class Core {
* This takes a form name and then compares it with the posted sid, if they don't match
* then it returns false and doesn't let the person continue
*/
- public static function form_verify($name,$method='post') {
+ public static function form_verify($name,$method='post') {
- switch ($method) {
- case 'post':
- $source = $_POST['form_validation'];
- break;
- case 'get':
+ switch ($method) {
+ case 'post':
+ $source = $_POST['form_validation'];
+ break;
+ case 'get':
$source = $_GET['form_validation'];
- break;
- case 'cookie':
- $source = $_COOKIE['form_validation'];
- break;
- case 'request':
- $source = $_REQUEST['form_validation'];
- break;
- }
-
- if ($source == $_SESSION['forms'][$name]['sid'] AND $_SESSION['forms'][$name]['expire'] > time()) {
- unset($_SESSION['forms'][$name]);
- return true;
- }
-
- unset($_SESSION['forms'][$name]);
- return false;
+ break;
+ case 'cookie':
+ $source = $_COOKIE['form_validation'];
+ break;
+ case 'request':
+ $source = $_REQUEST['form_validation'];
+ break;
+ }
+
+ if ($source == $_SESSION['forms'][$name]['sid'] AND $_SESSION['forms'][$name]['expire'] > time()) {
+ unset($_SESSION['forms'][$name]);
+ return true;
+ }
+
+ unset($_SESSION['forms'][$name]);
+ return false;
} // form_verify
@@ -101,21 +101,21 @@ class Core {
* This returns the dimensions of the passed song of the passed type
* returns an empty array if PHP-GD is not currently installed, returns
* false on error
- */
- public static function image_dimensions($image_data) {
+ */
+ public static function image_dimensions($image_data) {
- if (!function_exists('ImageCreateFromString')) { return false; }
+ if (!function_exists('ImageCreateFromString')) { return false; }
- $image = ImageCreateFromString($image_data);
+ $image = ImageCreateFromString($image_data);
- if (!$image) { return false; }
+ if (!$image) { return false; }
- $width = imagesx($image);
- $height = imagesy($image);
+ $width = imagesx($image);
+ $height = imagesy($image);
- if (!$width || !$height) { return false; }
+ if (!$width || !$height) { return false; }
- return array('width'=>$width,'height'=>$height);
+ return array('width'=>$width,'height'=>$height);
} // image_dimensions
diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php
index 4d592b0b..1c6afbdc 100644
--- a/lib/class/democratic.class.php
+++ b/lib/class/democratic.class.php
@@ -27,32 +27,32 @@
*/
class Democratic extends tmpPlaylist {
- public $name;
- public $cooldown;
- public $level;
- public $user;
- public $primary;
- public $base_playlist;
+ public $name;
+ public $cooldown;
+ public $level;
+ public $user;
+ public $primary;
+ public $base_playlist;
// Build local, buy local
- public $tmp_playlist;
- public $object_ids = array();
- public $vote_ids = array();
- public $user_votes = array();
+ public $tmp_playlist;
+ public $object_ids = array();
+ public $vote_ids = array();
+ public $user_votes = array();
/**
* constructor
* We need a constructor for this class. It does it's own thing now
*/
- public function __construct($id='') {
+ public function __construct($id='') {
- if (!$id) { return false; }
+ if (!$id) { return false; }
- $info = $this->get_info($id);
-
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
+ $info = $this->get_info($id);
+
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
} // constructor
@@ -60,20 +60,20 @@ class Democratic extends tmpPlaylist {
* build_vote_cache
* This builds a vote cache of the objects we've got in the playlist
*/
- public static function build_vote_cache($ids) {
+ public static function build_vote_cache($ids) {
- if (!is_array($ids) OR !count($ids)) { return false; }
+ if (!is_array($ids) OR !count($ids)) { return false; }
- $idlist = '(' . implode(',',$ids) . ')';
+ $idlist = '(' . implode(',',$ids) . ')';
- $sql = "SELECT `object_id`,COUNT(`user`) AS `count` FROM user_vote WHERE `object_id` IN $idlist GROUP BY `object_id`";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `object_id`,COUNT(`user`) AS `count` FROM user_vote WHERE `object_id` IN $idlist GROUP BY `object_id`";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('democratic_vote',$row['object_id'],$row['count']);
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ parent::add_to_cache('democratic_vote',$row['object_id'],$row['count']);
+ }
- return true;
+ return true;
} // build_vote_cache
@@ -82,11 +82,11 @@ class Democratic extends tmpPlaylist {
* This function just returns true / false if the current democraitc playlist
* is currently enabled / configured
*/
- public function is_enabled() {
+ public function is_enabled() {
- if ($this->tmp_playlist) { return true; }
+ if ($this->tmp_playlist) { return true; }
- return false;
+ return false;
} // is_enabled
@@ -94,16 +94,16 @@ class Democratic extends tmpPlaylist {
* set_parent
* This returns the tmpPlaylist for this democratic play instance
*/
- public function set_parent() {
+ public function set_parent() {
- $demo_id = Dba::escape($this->id);
+ $demo_id = Dba::escape($this->id);
- $sql = "SELECT * FROM `tmp_playlist` WHERE `session`='$demo_id'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `tmp_playlist` WHERE `session`='$demo_id'";
+ $db_results = Dba::read($sql);
- $row = Dba::fetch_assoc($db_results);
+ $row = Dba::fetch_assoc($db_results);
- $this->tmp_playlist = $row['id'];
+ $this->tmp_playlist = $row['id'];
} // set_parent
@@ -111,24 +111,24 @@ class Democratic extends tmpPlaylist {
/**
* set_user_preferences
* This sets up a (or all) user(s) to use democratic play. This sets their play method
- * and playlist method (clear on send) If no user is passed it does it for everyone and
+ * and playlist method (clear on send) If no user is passed it does it for everyone and
* also locks down the ability to change to admins only
*/
- public static function set_user_preferences($user=NULL) {
+ public static function set_user_preferences($user=NULL) {
//FIXME: Code in single user stuff
- $preference_id = Preference::id_from_name('play_type');
- Preference::update_level($preference_id,'75');
- Preference::update_all($preference_id,'democratic');
+ $preference_id = Preference::id_from_name('play_type');
+ Preference::update_level($preference_id,'75');
+ Preference::update_all($preference_id,'democratic');
- $allow_demo = Preference::id_from_name('allow_democratic_playback');
- Preference::update_all($allow_demo,'1');
+ $allow_demo = Preference::id_from_name('allow_democratic_playback');
+ Preference::update_all($allow_demo,'1');
- $play_method = Preference::id_from_name('playlist_method');
- Preference::update_all($play_method,'clear');
+ $play_method = Preference::id_from_name('playlist_method');
+ Preference::update_all($play_method,'clear');
- return true;
+ return true;
} // set_user_preferences
@@ -136,28 +136,28 @@ class Democratic extends tmpPlaylist {
* format
* This makes the objects variables all purrty so that they can be displayed
*/
- public function format() {
-
- $this->f_cooldown = $this->cooldown . ' ' . _('minutes');
- $this->f_primary = $this->primary ? _('Primary') : '';
-
- switch ($this->level) {
- case '5':
- $this->f_level = _('Guest');
- break;
- case '25':
- $this->f_level = _('User');
- break;
- case '50':
- $this->f_level = _('Content Manager');
- break;
- case '75':
- $this->f_level = _('Catalog Manager');
- break;
- case '100':
- $this->f_level = _('Admin');
- break;
- }
+ public function format() {
+
+ $this->f_cooldown = $this->cooldown . ' ' . _('minutes');
+ $this->f_primary = $this->primary ? _('Primary') : '';
+
+ switch ($this->level) {
+ case '5':
+ $this->f_level = _('Guest');
+ break;
+ case '25':
+ $this->f_level = _('User');
+ break;
+ case '50':
+ $this->f_level = _('Content Manager');
+ break;
+ case '75':
+ $this->f_level = _('Catalog Manager');
+ break;
+ case '100':
+ $this->f_level = _('Admin');
+ break;
+ }
} // format
@@ -166,21 +166,21 @@ class Democratic extends tmpPlaylist {
* This returns all of the current valid 'Democratic' Playlists
* that have been created.
*/
- public static function get_playlists() {
+ public static function get_playlists() {
- // Pull all tmp playlsits with a session of < 0 (as those are fake)
+ // Pull all tmp playlsits with a session of < 0 (as those are fake)
// This is kind of hackish, should really think about tweaking the db
- // and doing this right.
- $sql = "SELECT `id` FROM `democratic` ORDER BY `name`";
- $db_results = Dba::read($sql);
+ // and doing this right.
+ $sql = "SELECT `id` FROM `democratic` ORDER BY `name`";
+ $db_results = Dba::read($sql);
- $results = array();
+ $results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
- return $results;
+ return $results;
} // get_playlists
@@ -189,22 +189,22 @@ class Democratic extends tmpPlaylist {
* This returns the curren users current playlist, or if specified
* this current playlist of the user
*/
- public static function get_current_playlist() {
+ public static function get_current_playlist() {
- $democratic_id = Config::get('democratic_id');
+ $democratic_id = Config::get('democratic_id');
- if (!$democratic_id) {
- $level = Dba::escape($GLOBALS['user']->access);
- $sql = "SELECT `id` FROM `democratic` WHERE `level` <= '$level' " .
- " ORDER BY `level` DESC,`primary` DESC";
- $db_results = Dba::read($sql);
- $row = Dba::fetch_assoc($db_results);
+ if (!$democratic_id) {
+ $level = Dba::escape($GLOBALS['user']->access);
+ $sql = "SELECT `id` FROM `democratic` WHERE `level` <= '$level' " .
+ " ORDER BY `level` DESC,`primary` DESC";
+ $db_results = Dba::read($sql);
+ $row = Dba::fetch_assoc($db_results);
$democratic_id = $row['id'];
- }
+ }
- $object = new Democratic($democratic_id);
+ $object = new Democratic($democratic_id);
- return $object;
+ return $object;
} // get_current_playlist
@@ -214,7 +214,7 @@ class Democratic extends tmpPlaylist {
* has gotten a little more complicated because of type, the values are an array
* 0 being ID 1 being TYPE
* FIXME: This is too complex, it makes my brain hurt
- * [VOTE COUNT]
+ * [VOTE COUNT]
* [DATE OF NEWEST VOTE]
* [ROW ID]
* [OBJECT_ID]
@@ -237,46 +237,46 @@ class Democratic extends tmpPlaylist {
/* Define the array */
$items = array();
- $votes = array();
- $object_ids = array();
+ $votes = array();
+ $object_ids = array();
// Itterate and build the sortable array
while ($results = Dba::fetch_assoc($db_results)) {
-
+
// Extra set of data for caching!
- $this->object_ids[] = $results['object_id'];
- $this->vote_ids[] = $results['vote_id'];
+ $this->object_ids[] = $results['object_id'];
+ $this->vote_ids[] = $results['vote_id'];
// First build a variable that holds the number of votes for an object
$name = 'vc_' . $results['object_id'];
// Check if the vote is older then our current vote for this object
- if ($votes[$results['object_id']] < $results['date'] OR !isset($votes[$results['object_id']])) {
- $votes[$results['object_id']] = $results['date'];
- }
+ if ($votes[$results['object_id']] < $results['date'] OR !isset($votes[$results['object_id']])) {
+ $votes[$results['object_id']] = $results['date'];
+ }
// Append one to the vote
- ${$name}++;
- $primary_key = ${$name};
- $secondary_key = $votes[$results['object_id']];
+ ${$name}++;
+ $primary_key = ${$name};
+ $secondary_key = $votes[$results['object_id']];
$items[$primary_key][$secondary_key][$results['id']] = array('object_id'=>$results['object_id'],'object_type'=>$results['object_type'],'id'=>$results['id']);
} // gather data
// Sort highest voted stuff to the top
- krsort($items);
+ krsort($items);
- $sorted_items = array();
+ $sorted_items = array();
// re-collapse the array
- foreach ($items as $vote_count=>$date_array) {
- ksort($date_array);
- foreach ($date_array as $object_array) {
- foreach ($object_array as $key=>$sorted_array) {
+ foreach ($items as $vote_count=>$date_array) {
+ ksort($date_array);
+ foreach ($date_array as $object_array) {
+ foreach ($object_array as $key=>$sorted_array) {
$sorted_items[$key] = $sorted_array;
- }
- }
- }
+ }
+ }
+ }
return $sorted_items;
@@ -288,7 +288,7 @@ class Democratic extends tmpPlaylist {
*/
public function play_url() {
- $link = Stream::get_base_url() . 'uid=' . scrub_out($GLOBALS['user']->id) . '&demo_id=' . scrub_out($this->id);
+ $link = Stream::get_base_url() . 'uid=' . scrub_out($GLOBALS['user']->id) . '&demo_id=' . scrub_out($this->id);
return $link;
@@ -296,22 +296,22 @@ class Democratic extends tmpPlaylist {
/**
* get_next_object
- * This returns the next object in the tmp_playlist most of the time this
+ * This returns the next object in the tmp_playlist most of the time this
* will just be the top entry, but if there is a base_playlist and no
* items in the playlist then it returns a random entry from the base_playlist
*/
public function get_next_object($offset='') {
-
- $offset = $offset ? intval($offset) : '0';
+
+ $offset = $offset ? intval($offset) : '0';
// We have to get all because of the pysco sorting
- $items = self::get_items();
+ $items = self::get_items();
- if (count($items) > $offset) {
- $array = array_slice($items,$offset,1);
- $item = array_shift($array);
+ if (count($items) > $offset) {
+ $array = array_slice($items,$offset,1);
+ $item = array_shift($array);
$results['object_id'] = $item['object_id'];
- }
+ }
/* If nothing was found and this is a voting playlist then get from base_playlist */
if (!$results['object_id']) {
@@ -321,7 +321,7 @@ class Democratic extends tmpPlaylist {
/* We need to pull a random one from the base_playlist */
$base_playlist = new Playlist($this->base_playlist);
$data = $base_playlist->get_random_items(1);
- $results['object_id'] = $data['0']['object_id'];
+ $results['object_id'] = $data['0']['object_id'];
}
else {
$sql = "SELECT `id` as `object_id` FROM `song` WHERE `enabled`='1' ORDER BY RAND() LIMIT 1";
@@ -338,42 +338,42 @@ class Democratic extends tmpPlaylist {
* get_uid_from_object_id
* This takes an object_id and an object type and returns the ID for the row
*/
- public function get_uid_from_object_id($object_id,$object_type='') {
+ public function get_uid_from_object_id($object_id,$object_type='') {
- $object_id = Dba::escape($object_id);
- $object_type = $object_type ? Dba::escape($object_type) : 'song';
+ $object_id = Dba::escape($object_id);
+ $object_type = $object_type ? Dba::escape($object_type) : 'song';
$tmp_id = Dba::escape($this->tmp_playlist);
- $sql = "SELECT `tmp_playlist_data`.`id` FROM `tmp_playlist_data` WHERE `object_type`='$object_type' AND " .
- "`tmp_playlist`='$tmp_id' AND `object_id`='$object_id'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `tmp_playlist_data`.`id` FROM `tmp_playlist_data` WHERE `object_type`='$object_type' AND " .
+ "`tmp_playlist`='$tmp_id' AND `object_id`='$object_id'";
+ $db_results = Dba::read($sql);
- $row = Dba::fetch_assoc($db_results);
+ $row = Dba::fetch_assoc($db_results);
- return $row['id'];
+ return $row['id'];
} // get_uid_from_object_id
/**
* get_cool_songs
* This returns all of the song_ids for songs that have happened within the last 'cooldown'
- * for this user.
+ * for this user.
*/
- public function get_cool_songs() {
+ public function get_cool_songs() {
// Convert cooldown time to a timestamp in the past
- $cool_time = time() - ($this->cooldown * 60);
+ $cool_time = time() - ($this->cooldown * 60);
- $song_ids = Stats::get_object_history($GLOBALS['user']->id,$cool_time);
+ $song_ids = Stats::get_object_history($GLOBALS['user']->id,$cool_time);
- return $song_ids;
+ return $song_ids;
} // get_cool_songs
/**
* vote
* This function is called by users to vote on a system wide playlist
- * This adds the specified objects to the tmp_playlist and adds a 'vote'
+ * This adds the specified objects to the tmp_playlist and adds a 'vote'
* by this user, naturally it checks to make sure that the user hasn't
* already voted on any of these objects
*/
@@ -381,8 +381,8 @@ class Democratic extends tmpPlaylist {
/* Itterate through the objects if no vote, add to playlist and vote */
foreach ($items as $element) {
- $type = array_shift($element);
- $object_id = array_shift($element);
+ $type = array_shift($element);
+ $object_id = array_shift($element);
if (!$this->has_vote($object_id,$type)) {
$this->add_vote($object_id,$type);
}
@@ -397,9 +397,9 @@ class Democratic extends tmpPlaylist {
public function has_vote($object_id,$type='') {
$tmp_id = Dba::escape($this->tmp_playlist);
- $object_id = Dba::escape($object_id);
- $type = $type ? Dba::escape($type) : 'song';
- $user_id = Dba::escape($GLOBALS['user']->id);
+ $object_id = Dba::escape($object_id);
+ $type = $type ? Dba::escape($type) : 'song';
+ $user_id = Dba::escape($GLOBALS['user']->id);
/* Query vote table */
$sql = "SELECT tmp_playlist_data.object_id FROM `user_vote` " .
@@ -423,13 +423,13 @@ class Democratic extends tmpPlaylist {
* This takes a object id and user and actually inserts the row
*/
public function add_vote($object_id,$object_type='') {
-
+
$object_id = Dba::escape($object_id);
$tmp_playlist = Dba::escape($this->tmp_playlist);
- $object_type = $object_type ? Dba::escape($object_type) : 'song';
- $media = new $object_type($object_id);
- $track = isset($media->track) ? "'" . intval($media->track) . "'" : "NULL";
-
+ $object_type = $object_type ? Dba::escape($object_type) : 'song';
+ $media = new $object_type($object_id);
+ $track = isset($media->track) ? "'" . intval($media->track) . "'" : "NULL";
+
/* If it's on the playlist just vote */
$sql = "SELECT `id` FROM `tmp_playlist_data` " .
"WHERE `tmp_playlist_data`.`object_id`='$object_id' AND `tmp_playlist_data`.`tmp_playlist`='$tmp_playlist'";
@@ -478,17 +478,17 @@ class Democratic extends tmpPlaylist {
* delete_votes
* This removes the votes for the specified object on the current playlist
*/
- public function delete_votes($row_id) {
+ public function delete_votes($row_id) {
- $row_id = Dba::escape($row_id);
+ $row_id = Dba::escape($row_id);
- $sql = "DELETE FROM `user_vote` WHERE `object_id`='$row_id'";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `user_vote` WHERE `object_id`='$row_id'";
+ $db_results = Dba::write($sql);
- $sql = "DELETE FROM `tmp_playlist_data` WHERE `id`='$row_id'";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `tmp_playlist_data` WHERE `id`='$row_id'";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // delete_votes
@@ -496,19 +496,19 @@ class Democratic extends tmpPlaylist {
* delete
* This deletes a democratic playlist
*/
- public static function delete($democratic_id) {
-
- $democratic_id = Dba::escape($democratic_id);
+ public static function delete($democratic_id) {
- $sql = "DELETE FROM `democratic` WHERE `id`='$democratic_id'";
- $db_results = Dba::write($sql);
+ $democratic_id = Dba::escape($democratic_id);
- $sql = "DELETE FROM `tmp_playlist` WHERE `session`='$democratic_id'";
- $db_results = Dba::write($sql);
-
- self::prune_tracks();
+ $sql = "DELETE FROM `democratic` WHERE `id`='$democratic_id'";
+ $db_results = Dba::write($sql);
+
+ $sql = "DELETE FROM `tmp_playlist` WHERE `session`='$democratic_id'";
+ $db_results = Dba::write($sql);
+
+ self::prune_tracks();
- return true;
+ return true;
} // delete
@@ -516,17 +516,17 @@ class Democratic extends tmpPlaylist {
* update
* This updates an existing democratic playlist item. It takes a key'd array just like the create
*/
- public function update($data) {
+ public function update($data) {
- $name = Dba::escape($data['name']);
- $base = Dba::escape($data['democratic']);
- $cool = Dba::escape($data['cooldown']);
- $id = Dba::escape($this->id);
+ $name = Dba::escape($data['name']);
+ $base = Dba::escape($data['democratic']);
+ $cool = Dba::escape($data['cooldown']);
+ $id = Dba::escape($this->id);
- $sql = "UPDATE `democratic` SET `name`='$name', `base_playlist`='$base',`cooldown`='$cool' WHERE `id`='$id'";
- $db_results = Dba::write($sql);
+ $sql = "UPDATE `democratic` SET `name`='$name', `base_playlist`='$base',`cooldown`='$cool' WHERE `id`='$id'";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // update
@@ -534,26 +534,26 @@ class Democratic extends tmpPlaylist {
* create
* This is the democratic play create function it inserts this into the democratic table
*/
- public static function create($data) {
+ public static function create($data) {
// Clean up the input
- $name = Dba::escape($data['name']);
- $base = Dba::escape($data['democratic']);
- $cool = Dba::escape($data['cooldown']);
- $level = Dba::escape($data['level']);
- $default = Dba::escape($data['make_default']);
- $user = Dba::escape($GLOBALS['user']->id);
-
- $sql = "INSERT INTO `democratic` (`name`,`base_playlist`,`cooldown`,`level`,`user`,`primary`) " .
- "VALUES ('$name','$base','$cool','$level','$user','$default')";
- $db_results = Dba::write($sql);
+ $name = Dba::escape($data['name']);
+ $base = Dba::escape($data['democratic']);
+ $cool = Dba::escape($data['cooldown']);
+ $level = Dba::escape($data['level']);
+ $default = Dba::escape($data['make_default']);
+ $user = Dba::escape($GLOBALS['user']->id);
+
+ $sql = "INSERT INTO `democratic` (`name`,`base_playlist`,`cooldown`,`level`,`user`,`primary`) " .
+ "VALUES ('$name','$base','$cool','$level','$user','$default')";
+ $db_results = Dba::write($sql);
- if ($db_results) {
- $insert_id = Dba::insert_id();
- parent::create($insert_id,'vote','song');
- }
+ if ($db_results) {
+ $insert_id = Dba::insert_id();
+ parent::create($insert_id,'vote','song');
+ }
- return $db_results;
+ return $db_results;
} // create
@@ -562,7 +562,7 @@ class Democratic extends tmpPlaylist {
* This replaces the normal prune tracks and correctly removes the votes
* as well
*/
- public static function prune_tracks() {
+ public static function prune_tracks() {
// This deletes data without votes, if it's a voting democratic playlist
$sql = "DELETE FROM `tmp_playlist_data` USING `tmp_playlist_data` " .
@@ -578,7 +578,7 @@ class Democratic extends tmpPlaylist {
/**
* clear
* This is really just a wrapper function, it clears the entire playlist
- * including all votes etc.
+ * including all votes etc.
*/
public function clear() {
@@ -594,7 +594,7 @@ class Democratic extends tmpPlaylist {
self::prune_tracks();
// Clean the votes
- self::clear_votes();
+ self::clear_votes();
return true;
@@ -604,14 +604,14 @@ class Democratic extends tmpPlaylist {
* clean_votes
* This removes in left over garbage in the votes table
*/
- public function clear_votes() {
+ public function clear_votes() {
- $sql = "DELETE FROM `user_vote` USING `user_vote` " .
- "LEFT JOIN `tmp_playlist_data` ON `user_vote`.`object_id`=`tmp_playlist_data`.`id` " .
- "WHERE `tmp_playlist_data`.`id` IS NULL";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `user_vote` USING `user_vote` " .
+ "LEFT JOIN `tmp_playlist_data` ON `user_vote`.`object_id`=`tmp_playlist_data`.`id` " .
+ "WHERE `tmp_playlist_data`.`id` IS NULL";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // clear_votes
@@ -621,9 +621,9 @@ class Democratic extends tmpPlaylist {
*/
public function get_vote($object_id) {
- if (parent::is_cached('democratic_vote',$object_id)) {
- return parent::get_from_cache('democratic_vote',$object_id);
- }
+ if (parent::is_cached('democratic_vote',$object_id)) {
+ return parent::get_from_cache('democratic_vote',$object_id);
+ }
$object_id = Dba::escape($object_id);
@@ -642,9 +642,9 @@ class Democratic extends tmpPlaylist {
* This returns the users that voted for the specified object
* This is an array of user ids
*/
- public function get_voters($object_id) {
+ public function get_voters($object_id) {
- return parent::get_from_cache('democratic_voters',$object_id);
+ return parent::get_from_cache('democratic_voters',$object_id);
} // get_voters
diff --git a/lib/class/error.class.php b/lib/class/error.class.php
index 2da2a7d1..2ed4a034 100644
--- a/lib/class/error.class.php
+++ b/lib/class/error.class.php
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
*/
@@ -26,7 +26,7 @@
* This is the baic error class, its better now that we can use php5
* hello static functions and variables
*/
-class Error {
+class Error {
private static $state = false; // set to one when an error occurs
private static $errors = array(); // Errors array key'd array with errors that have occured
@@ -35,62 +35,62 @@ class Error {
* __constructor
* This does nothing... amazing isn't it!
*/
- private function __construct() {
+ private function __construct() {
// Rien a faire
-
+
} // __construct
/**
* __destruct
* This saves all of the errors that are left into the session
*/
- public function __destruct() {
+ public function __destruct() {
- foreach (self::$errors as $key=>$error) {
- $_SESSION['errors'][$key] = $error;
- }
+ foreach (self::$errors as $key=>$error) {
+ $_SESSION['errors'][$key] = $error;
+ }
} // __destruct
/**
* add
- * This is a public static function it adds a new error message to the array
+ * This is a public static function it adds a new error message to the array
* It can optionally clobber rather then adding to the error message
*/
- public static function add($name,$message,$clobber=0) {
+ public static function add($name,$message,$clobber=0) {
- // Make sure its set first
- if (!isset(Error::$errors[$name])) {
- Error::$errors[$name] = $message;
+ // Make sure its set first
+ if (!isset(Error::$errors[$name])) {
+ Error::$errors[$name] = $message;
Error::$state = 1;
- $_SESSION['errors'][$key] = $message;
- }
+ $_SESSION['errors'][$key] = $message;
+ }
// They want us to clobber it
- elseif ($clobber) {
+ elseif ($clobber) {
Error::$state = 1;
Error::$errors[$name] = $message;
- $_SESSION['errors'][$key] = $message;
- }
+ $_SESSION['errors'][$key] = $message;
+ }
// They want us to append the error, add a BR\n and then the message
- else {
+ else {
Error::$state = 1;
Error::$errors[$name] .= "<br />\n" . $message;
- $_SESSION['errors'][$key] .= "<br />\n" . $message;
- }
+ $_SESSION['errors'][$key] .= "<br />\n" . $message;
+ }
} // add
- /**
+ /**
* occurred
* This returns true / false if an error has occured anywhere
*/
- public static function occurred() {
+ public static function occurred() {
- if (self::$state == '1') { return true; }
+ if (self::$state == '1') { return true; }
- return false;
+ return false;
} // occurred
@@ -98,9 +98,9 @@ class Error {
* get
* This returns an error by name
*/
- public static function get($name) {
+ public static function get($name) {
- if (!isset(Error::$errors[$name])) { return ''; }
+ if (!isset(Error::$errors[$name])) { return ''; }
return Error::$errors[$name];
@@ -111,27 +111,27 @@ class Error {
* This prints the error out with a standard Error class span
* Ben Goska: Renamed from print to display, print is reserved
*/
- public static function display($name) {
+ public static function display($name) {
// Be smart about this, if no error don't print
- if (!isset(Error::$errors[$name])) { return ''; }
+ if (!isset(Error::$errors[$name])) { return ''; }
echo '<span class="error">' . Error::$errors[$name] . '</span>';
} // display
/**
- * auto_init
+ * auto_init
* This loads the errors from the session back into Ampache
*/
- public static function auto_init() {
+ public static function auto_init() {
- if (!is_array($_SESSION['errors'])) { return false; }
+ if (!is_array($_SESSION['errors'])) { return false; }
- // Re-insert them
- foreach ($_SESSION['errors'] as $key=>$error) {
+ // Re-insert them
+ foreach ($_SESSION['errors'] as $key=>$error) {
self::add($key,$error);
- }
+ }
} // auto_init
diff --git a/lib/class/flag.class.php b/lib/class/flag.class.php
index 8105a247..3394019d 100644
--- a/lib/class/flag.class.php
+++ b/lib/class/flag.class.php
@@ -17,17 +17,17 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* Flag Class
- * This handles flagging of songs, albums and artists
+ * This handles flagging of songs, albums and artists
*/
class Flag extends database_object {
- public $id;
+ public $id;
public $user;
public $object_id;
public $object_type;
@@ -44,13 +44,13 @@ class Flag extends database_object {
* Constructor
* This takes a flagged.id and then pulls in the information for said flag entry
*/
- public function __construct($flag_id) {
+ public function __construct($flag_id) {
$info = $this->get_info($flag_id,'flagged');
-
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
+
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
return true;
@@ -61,18 +61,18 @@ class Flag extends database_object {
* This takes an array of ids and builds up a nice little cache
* for us
*/
- public static function build_cache($ids) {
+ public static function build_cache($ids) {
- if (!is_array($ids) OR !count($ids)) { return false; }
+ if (!is_array($ids) OR !count($ids)) { return false; }
- $idlist = '(' . implode(',',$ids) . ')';
+ $idlist = '(' . implode(',',$ids) . ')';
- $sql = "SELECT * FROM `flagged` WHERE `id` IN $idlist";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `flagged` WHERE `id` IN $idlist";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('flagged',$row['id'],$row);
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ parent::add_to_cache('flagged',$row['id'],$row);
+ }
} // build_cache
@@ -81,27 +81,27 @@ class Flag extends database_object {
* This takes an array of ids and builds a map cache to avoid some of the object_type calls
* we would normally have to make
*/
- public static function build_map_cache($ids,$type) {
+ public static function build_map_cache($ids,$type) {
- if (!is_array($ids) OR !count($ids)) { return false; }
+ if (!is_array($ids) OR !count($ids)) { return false; }
- $idlist = '(' . implode(',',$ids) . ')';
- $type = Dba::escape($type);
+ $idlist = '(' . implode(',',$ids) . ')';
+ $type = Dba::escape($type);
- $sql = "SELECT * FROM `flagged` " .
- "WHERE `flagged`.`object_type`='$type' AND `flagged`.`object_id` IN $idlist";
- $db_results = Dba::read($sql);
-
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[$row['object_id']] = $row;
- }
-
- // Itterate through the passed ids as we need to cache 'nulls'
- foreach ($ids as $id) {
- parent::add_to_cache('flagged_' . $type,$id,$results[$id]);
- }
+ $sql = "SELECT * FROM `flagged` " .
+ "WHERE `flagged`.`object_type`='$type' AND `flagged`.`object_id` IN $idlist";
+ $db_results = Dba::read($sql);
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[$row['object_id']] = $row;
+ }
+
+ // Itterate through the passed ids as we need to cache 'nulls'
+ foreach ($ids as $id) {
+ parent::add_to_cache('flagged_' . $type,$id,$results[$id]);
+ }
- return true;
+ return true;
} // build_map_cache
@@ -109,23 +109,23 @@ class Flag extends database_object {
* has_flag
* Static function, tries to check the cache, but falls back on a query
*/
- public static function has_flag($id,$type) {
+ public static function has_flag($id,$type) {
+
+ if (parent::is_cached('flagged_' . $type,$id)) {
+ $data = parent::get_from_cache('flagged_' . $type,$id);
+ return $data['date'];
+ }
- if (parent::is_cached('flagged_' . $type,$id)) {
- $data = parent::get_from_cache('flagged_' . $type,$id);
- return $data['date'];
- }
-
// Ok we have to query this
- $type = Dba::escape($type);
+ $type = Dba::escape($type);
- $sql = "SELECT * FROM `flagged` WHERE `flagged`.`object_type`='$type' AND `flagged`.`object_id`='$id'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `flagged` WHERE `flagged`.`object_type`='$type' AND `flagged`.`object_id`='$id'";
+ $db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
- parent::add_to_cache('flagged_' . $type,$row['object_id'],$row);
+ parent::add_to_cache('flagged_' . $type,$row['object_id'],$row);
- return $row['date'];
+ return $row['date'];
} // has_flag
@@ -134,19 +134,19 @@ class Flag extends database_object {
* This returns the id's of the most recently flagged songs, it takes an int
* as an argument which is the count of the object you want to return
*/
- public static function get_recent($count=0) {
+ public static function get_recent($count=0) {
- if ($count) { $limit = " LIMIT " . intval($count); }
+ if ($count) { $limit = " LIMIT " . intval($count); }
$results = array();
$sql = "SELECT id FROM flagged ORDER BY date " . $limit;
$db_results = Dba::read($sql);
- while ($r = Dba::fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id'];
}
-
+
return $results;
} // get_recent
@@ -156,18 +156,18 @@ class Flag extends database_object {
* This returns all of the songs that have been disabled, this is
* a form of being flagged
*/
- public static function get_disabled() {
+ public static function get_disabled() {
- $sql = "SELECT `id` FROM `song` WHERE `enabled`='0'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id` FROM `song` WHERE `enabled`='0'";
+ $db_results = Dba::read($sql);
+
+ $results = array();
- $results = array();
-
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
- return $results;
+ return $results;
} // get_disabled
@@ -176,10 +176,10 @@ class Flag extends database_object {
* This returns an array of ids of flagged songs if no limit is passed
* it gets everything
*/
- public static function get_all($count=0) {
+ public static function get_all($count=0) {
+
+ if ($count) { $limit_clause = "LIMIT " . intval($count); }
- if ($count) { $limit_clause = "LIMIT " . intval($count); }
-
$sql = "SELECT `id` FROM `flagged` $limit_clause";
$db_results = Dba::read($sql);
@@ -187,7 +187,7 @@ class Flag extends database_object {
$results = array();
/* While the query */
- while ($row = Dba::fetch_assoc($db_results)) {
+ while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row['id'];
}
@@ -199,17 +199,17 @@ class Flag extends database_object {
* get_approved
* This returns an array of approved flagged songs
*/
- public static function get_approved() {
+ public static function get_approved() {
$sql = "SELECT `id` FROM `flagged` WHERE `approved`='1'";
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
/* Default the results array */
- $results = array();
+ $results = array();
/* While it */
- while ($r = Dba::fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id'];
}
@@ -222,8 +222,8 @@ class Flag extends database_object {
* This adds a flag entry for an item, it takes an id, a type, the flag type
* and a comment and then inserts the mofo
*/
- public static function add($id,$type,$flag,$comment) {
-
+ public static function add($id,$type,$flag,$comment) {
+
$id = Dba::escape($id);
$type = Dba::escape($type);
$flag = self::validate_flag($flag);
@@ -233,9 +233,9 @@ class Flag extends database_object {
$approved = '0';
/* If they are an content manager or higher, it's auto approved */
- if (Access::check('interface','75')) { $approved = '1'; }
+ if (Access::check('interface','75')) { $approved = '1'; }
- $sql = "INSERT INTO `flagged` (`object_id`,`object_type`,`flag`,`comment`,`date`,`approved`,`user`) VALUES " .
+ $sql = "INSERT INTO `flagged` (`object_id`,`object_type`,`flag`,`comment`,`date`,`approved`,`user`) VALUES " .
" ('$id','$type','$flag','$comment','$time','$approved','$user')";
$db_results = Dba::write($sql);
@@ -249,18 +249,18 @@ class Flag extends database_object {
* state, in a perfect world, I could just roll the changes back... not until 3.4
* or.. haha 3.5!
*/
- public function delete() {
+ public function delete() {
// Re-scan the file
- $song = new Song($this->object_id);
- $info = Catalog::update_media_from_tags($song);
+ $song = new Song($this->object_id);
+ $info = Catalog::update_media_from_tags($song);
// Delete the row
$sql = "DELETE FROM `flagged` WHERE `id`='$this->id'";
$db_results = Dba::write($sql);
- // Reset the Last-Updated date so that it'll get re-scaned
- $song->update_utime($song->id,1);
+ // Reset the Last-Updated date so that it'll get re-scaned
+ $song->update_utime($song->id,1);
return true;
@@ -271,44 +271,44 @@ class Flag extends database_object {
* This approves the current flag object ($this->id) by setting approved to
* 1
*/
- public function approve() {
+ public function approve() {
$sql = "UPDATE `flagged` SET `approved`='1' WHERE `id`='$this->id'";
$db_results = Dba::write($sql);
- $this->approved = 1;
+ $this->approved = 1;
return true;
-
+
} // approve
-
+
/**
* format
* This function figures out what kind of object we've got and sets up all the
* vars all nice and fuzzy like
*/
- public function format() {
+ public function format() {
- switch ($this->object_type) {
- case 'song':
+ switch ($this->object_type) {
+ case 'song':
$song = new Song($this->object_id);
- $song->format();
+ $song->format();
$this->f_name = $song->f_link;
break;
- } // end switch on type
+ } // end switch on type
$client = new User($this->user);
- $client->format();
- $this->f_user = $client->f_link;
+ $client->format();
+ $this->f_user = $client->f_link;
} // format
-
+
/**
* print_status
* This prints out a userfriendly version of the current status for this flagged
* object
*/
- public function print_status() {
+ public function print_status() {
if ($this->approved) { echo _('Approved'); }
else { echo _('Pending'); }
@@ -319,20 +319,20 @@ class Flag extends database_object {
* print_flag
* This prints out a userfriendly version of the current flag type
*/
- public function print_flag() {
+ public function print_flag() {
- switch ($this->flag) {
+ switch ($this->flag) {
case 'delete':
$name = _('Delete');
break;
case 'retag':
- $name = _('Re-Tag');
+ $name = _('Re-Tag');
break;
case 'reencode':
$name = _('Re-encode');
break;
case 'other':
- $name = _('Other');
+ $name = _('Other');
break;
default:
$name = _('Unknown');
@@ -340,7 +340,7 @@ class Flag extends database_object {
} // end switch
echo $name;
-
+
} // print_flag
/**
@@ -348,17 +348,17 @@ class Flag extends database_object {
* This takes a flag input and makes sure it's one of the reigstered
* and valid 'flag' values
*/
- public static function validate_flag($flag) {
-
- switch ($flag) {
- case 'delete':
- case 'retag':
- case 'reencode':
- case 'other':
- return $flag;
+ public static function validate_flag($flag) {
+
+ switch ($flag) {
+ case 'delete':
+ case 'retag':
+ case 'reencode':
+ case 'other':
+ return $flag;
break;
- default:
- return 'other';
+ default:
+ return 'other';
break;
} // end switch
@@ -366,14 +366,14 @@ class Flag extends database_object {
/**
* fill_tags
- * This is used by the write_tags script.
+ * This is used by the write_tags script.
*/
public static function fill_tags( $tagWriter, $song, $type = 'comment' ) {
// Set all of the attributes for the tag to be written(All pulled from the song object)
// Use a function since ID3v1, ID3v2, and vorbis/flac/ape are different
- switch ($type) {
- case 'comment':
+ switch ($type) {
+ case 'comment':
$tagWriter->comments['title'] = $song->title;
$tagWriter->comments['date'] = $song->year;
$tagWriter->comments['year'] = $song->year;
@@ -384,7 +384,7 @@ class Flag extends database_object {
$tagWriter->comments['artist'] = $song->get_artist_name();
$tagWriter->comments['genre'] = $song->get_genre_name();
$tagWriter->comments['track'] = $song->track;
- break;
+ break;
case 'id3v1':
$tagWriter->title = $song->title;
$tagWriter->year = $song->year;
diff --git a/lib/class/localplay.abstract.php b/lib/class/localplay.abstract.php
index 6cc3d078..c544c14c 100644
--- a/lib/class/localplay.abstract.php
+++ b/lib/class/localplay.abstract.php
@@ -23,85 +23,85 @@
/*
* This is the abstract class for any localplay controller
*/
-abstract class localplay_controller {
-
+abstract class localplay_controller {
+
// Required Functions
abstract public function add($objects); // Takes an array of song_ids
abstract public function delete_track($object_id); // Takes a single object_id and removes it from the playlist
- abstract public function play();
- abstract public function stop();
- abstract public function get();
- abstract public function connect();
- abstract public function status();
+ abstract public function play();
+ abstract public function stop();
+ abstract public function get();
+ abstract public function connect();
+ abstract public function status();
abstract public function get_version(); // Returns the version of this plugin
- abstract public function get_description(); // Returns the description
- abstract public function is_installed(); // Returns an boolean t/f
- abstract public function install();
- abstract public function uninstall();
+ abstract public function get_description(); // Returns the description
+ abstract public function is_installed(); // Returns an boolean t/f
+ abstract public function install();
+ abstract public function uninstall();
// For display we need the following 'instance' functions
- abstract public function add_instance($data);
- abstract public function delete_instance($id);
- abstract public function update_instance($id,$post);
- abstract public function get_instances();
+ abstract public function add_instance($data);
+ abstract public function delete_instance($id);
+ abstract public function update_instance($id,$post);
+ abstract public function get_instances();
abstract public function instance_fields();
- abstract public function set_active_instance($uid);
- abstract public function get_active_instance();
+ abstract public function set_active_instance($uid);
+ abstract public function get_active_instance();
/**
* get_url
* This returns the URL for the passed object
*/
- public function get_url($object) {
+ public function get_url($object) {
// This might not be an object!
- if (!is_object($object)) {
+ if (!is_object($object)) {
// Stupiidly we'll just blindly add it for now
- return $object;
- }
+ return $object;
+ }
+
+ $class = get_class($object);
- $class = get_class($object);
-
- $url = call_user_func(array($class,'play_url'),$object->id);
+ $url = call_user_func(array($class,'play_url'),$object->id);
return $url;
- } // get_url
+ } // get_url
/**
* get_file
* This returns the Filename for the passed object, not
* always possible
*/
- public function get_file($object) {
+ public function get_file($object) {
- } // get_file
+ } // get_file
/**
- * parse_url
+ * parse_url
* This takes an Ampache URL and then returns the 'primary' part of it
* So that it's easier for localplay modules to return valid song information
*/
- public function parse_url($url) {
+ public function parse_url($url) {
// Define possible 'primary' keys
- $primary_array = array('oid','demo_id','random');
- $data = array();
+ $primary_array = array('oid','demo_id','random');
+ $data = array();
- $variables = parse_url($url,PHP_URL_QUERY);
- parse_str($variables,$data);
+ $variables = parse_url($url,PHP_URL_QUERY);
+ parse_str($variables,$data);
- foreach ($primary_array as $pkey) {
- if ($data[$pkey]) {
- $data['primary_key'] = $pkey;
- return $data;
+ foreach ($primary_array as $pkey) {
+ if ($data[$pkey]) {
+ $data['primary_key'] = $pkey;
+ return $data;
}
} // end foreach
return $data;
- } // parse_url
+ } // parse_url
} // end localplay_controller interface
diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php
index 186bea7e..26b39aba 100644
--- a/lib/class/localplay.class.php
+++ b/lib/class/localplay.class.php
@@ -26,10 +26,10 @@ class Localplay {
public $type;
/* Built Variables */
- private $_function_map = array();
+ private $_function_map = array();
private $_template;
private $_preferences = array();
- private $_player;
+ private $_player;
/**
* Constructor
@@ -37,7 +37,7 @@ class Localplay {
* file for the specified type and attempts to load in the function
* map, the preferences and the template
*/
- public function __construct($type) {
+ public function __construct($type) {
$this->type = $type;
@@ -47,12 +47,12 @@ class Localplay {
/**
* _get_info
- * This functions takes the type and attempts to get all the
+ * This functions takes the type and attempts to get all the
* information needed to load it. Will log errors if there are
* any failures, fatal errors will actually return something to the
* gui
*/
- private function _get_info() {
+ private function _get_info() {
$this->_load_player();
@@ -63,29 +63,29 @@ class Localplay {
* This returns true / false if the player load
* failed / worked
*/
- public function player_loaded() {
+ public function player_loaded() {
- if (is_object($this->_player)) {
- return true;
- }
- else {
- return false;
- }
+ if (is_object($this->_player)) {
+ return true;
+ }
+ else {
+ return false;
+ }
} // player_loaded
/**
* format
- * This makes the localplay/plugin information
- * human readable
+ * This makes the localplay/plugin information
+ * human readable
*/
- public function format() {
+ public function format() {
- if (!is_object($this->_player)) { return false; }
+ if (!is_object($this->_player)) { return false; }
- $this->f_name = ucfirst($this->type);
- $this->f_description = $this->_player->get_description();
- $this->f_version = $this->_player->get_version();
+ $this->f_name = ucfirst($this->type);
+ $this->f_description = $this->_player->get_description();
+ $this->f_version = $this->_player->get_version();
} // format
@@ -96,40 +96,40 @@ class Localplay {
* Will interface with in order to make all this magical stuf work
* all LocalPlay modules should be located in /modules/<name>/<name>.class.php
*/
- private function _load_player() {
+ private function _load_player() {
- if (!$this->type) { return false; }
+ if (!$this->type) { return false; }
$filename = Config::get('prefix') . '/modules/localplay/' . $this->type . '.controller.php';
$include = require_once ($filename);
-
- if (!$include) {
+
+ if (!$include) {
/* Throw Error Here */
debug_event('localplay','Unable to load ' . $this->type . ' controller','2');
- return false;
+ return false;
} // include
- else {
+ else {
$class_name = "Ampache" . $this->type;
$this->_player = new $class_name();
- if (!($this->_player instanceof localplay_controller)) {
- debug_event('Localplay',$this->type . ' not an instance of controller abstract, unable to load','1');
- unset($this->_player);
- return false;
- }
+ if (!($this->_player instanceof localplay_controller)) {
+ debug_event('Localplay',$this->type . ' not an instance of controller abstract, unable to load','1');
+ unset($this->_player);
+ return false;
+ }
}
-
+
} // _load_player
/**
* format_name
- * This function takes the track name and checks to see if 'skip'
+ * This function takes the track name and checks to see if 'skip'
* is supported in the current player, if so it returns a 'skip to'
* link, otherwise it returns just the text
*/
- public function format_name($name,$id) {
+ public function format_name($name,$id) {
$name = scrub_out($name);
- $name = Ajax::text('?page=localplay&action=command&command=skip&id=' . $id,$name,'localplay_skip_' . $id);
+ $name = Ajax::text('?page=localplay&action=command&command=skip&id=' . $id,$name,'localplay_skip_' . $id);
return $name;
} // format_name
@@ -138,31 +138,31 @@ class Localplay {
* get_controllers
* This returns the controllers that are currently loaded into this instance
*/
- public static function get_controllers() {
+ public static function get_controllers() {
/* First open the dir */
- $handle = opendir(Config::get('prefix') . '/modules/localplay');
-
- if (!is_resource($handle)) {
- debug_event('Localplay','Error: Unable to read localplay controller directory','1');
- return array();
+ $handle = opendir(Config::get('prefix') . '/modules/localplay');
+
+ if (!is_resource($handle)) {
+ debug_event('Localplay','Error: Unable to read localplay controller directory','1');
+ return array();
}
- $results = array();
+ $results = array();
- while ($file = readdir($handle)) {
+ while ($file = readdir($handle)) {
- if (substr($file,-14,14) != 'controller.php') { continue; }
+ if (substr($file,-14,14) != 'controller.php') { continue; }
/* Make sure it isn't a dir */
- if (!is_dir($file)) {
+ if (!is_dir($file)) {
/* Get the basename and then everything before controller */
- $filename = basename($file,'.controller.php');
- $results[] = $filename;
- }
+ $filename = basename($file,'.controller.php');
+ $results[] = $filename;
+ }
} // end while
- return $results;
+ return $results;
} // get_controllers
@@ -171,14 +171,14 @@ class Localplay {
* This returns true or false depending on if the specified controller
* is currently enabled
*/
- public static function is_enabled($controller) {
+ public static function is_enabled($controller) {
// Load the controller and then check for its preferences
- $localplay = new Localplay($controller);
- // If we can't even load it no sense in going on
- if (!isset($localplay->_player)) { return false; }
+ $localplay = new Localplay($controller);
+ // If we can't even load it no sense in going on
+ if (!isset($localplay->_player)) { return false; }
- return $localplay->_player->is_installed();
+ return $localplay->_player->is_installed();
} // is_enabled
@@ -187,48 +187,48 @@ class Localplay {
* This runs the install for the localplay controller we've
* currently got pimped out
*/
- public function install() {
+ public function install() {
// Run the player's installer
- $installed = $this->_player->install();
-
- return $installed;
+ $installed = $this->_player->install();
+
+ return $installed;
} // install
/**
* uninstall
- * This runs the uninstall for the localplay controller we've
+ * This runs the uninstall for the localplay controller we've
* currently pimped out
*/
- public function uninstall() {
+ public function uninstall() {
// Run the players uninstaller
- $this->_player->uninstall();
+ $this->_player->uninstall();
// If its our current player, reset player to nothing
- if (Config::get('localplay_controller') == $this->type) {
- Preference::update('localplay_controller',$GLOBALS['user']->id,'');
- }
+ if (Config::get('localplay_controller') == $this->type) {
+ Preference::update('localplay_controller',$GLOBALS['user']->id,'');
+ }
- return true;
+ return true;
} // uninstall
/**
* connect
- * This function attempts to connect to the localplay
+ * This function attempts to connect to the localplay
* player that we are using
*/
- public function connect() {
+ public function connect() {
- if (!$this->_player->connect()) {
+ if (!$this->_player->connect()) {
debug_event('localplay','Error Unable to connect, check ' . $this->type . ' controller','1');
return false;
}
return true;
-
+
} // connect
/**
@@ -236,13 +236,13 @@ class Localplay {
* This function passes NULL and calls the play function of the player
* object
*/
- public function play() {
-
- if (!$this->_player->play()) {
+ public function play() {
+
+ if (!$this->_player->play()) {
debug_event('localplay','Error Unable to start playback, check ' . $this->type . ' controller','1');
return false;
}
-
+
return true;
} // play
@@ -252,9 +252,9 @@ class Localplay {
* This functions passes NULl and calls the stop function of the player
* object, it should recieve a true/false boolean value
*/
- public function stop() {
+ public function stop() {
- if (!$this->_player->stop()) {
+ if (!$this->_player->stop()) {
debug_event('localplay','Error Unable to stop playback, check ' . $this->type . ' controller','1');
return false;
}
@@ -266,48 +266,48 @@ class Localplay {
/**
* add
* This function takes a single object and then passes it to
- * to the player, this is a required function.
+ * to the player, this is a required function.
*/
- public function add($object) {
+ public function add($object) {
- if (!$this->_player->add($object)) {
+ if (!$this->_player->add($object)) {
debug_event('localplay','Error Unable to add songs, check ' . $this->type . ' controller','1');
return false;
}
-
+
return true;
} // add
/**
- * add_url
+ * add_url
* This directly adds an array of URLs to the localplay module. This is really how I should
* have done add, will migrate to this eventually
*/
- public function add_url($urls) {
+ public function add_url($urls) {
$function = $this->_function_map['add_url'];
-
- if (!$this->_player->$function($urls)) {
+
+ if (!$this->_player->$function($urls)) {
debug_event('localplay','Error Unable to add urls, check ' . $this->type . ' controller','1');
- return false;
- }
+ return false;
+ }
- return true;
+ return true;
} // add_url
/**
* repeat
- * This turns the repeat feature of a localplay method on or
+ * This turns the repeat feature of a localplay method on or
* off, takes a 0/1 value
*/
- public function repeat($state) {
+ public function repeat($state) {
$data = $this->_player->repeat($state);
- if (!$data) {
+ if (!$data) {
debug_event('localplay',"Error Unable to set Repeat to $state",'1');
}
@@ -318,16 +318,16 @@ class Localplay {
/**
* random
* This turns on the random feature of a localplay method
- * It takes a 0/1 value
+ * It takes a 0/1 value
*/
- public function random($state) {
-
- $data = $this->_player->random($state);
+ public function random($state) {
+
+ $data = $this->_player->random($state);
- if (!$data) {
+ if (!$data) {
debug_event('localplay',"Error Unable to set Random to $state",'1');
}
-
+
return $data;
} // random
@@ -337,11 +337,11 @@ class Localplay {
* This returns current information about the state of the player
* There is an expected array format
*/
- public function status() {
+ public function status() {
$data = $this->_player->status();
- if (!count($data)) {
+ if (!count($data)) {
debug_event('localplay','Error Unable to get status, check ' . $this->type . ' controller','1');
return false;
}
@@ -356,15 +356,15 @@ class Localplay {
* the array of current songs for display or whatever
* an empty array is passed on failure
*/
- public function get() {
+ public function get() {
$data = $this->_player->get();
-
- if (!count($data) OR !is_array($data)) {
+
+ if (!count($data) OR !is_array($data)) {
debug_event('localplay','Error Unable to get song info, check ' . $this->type . ' controller','1');
- return array();
+ return array();
}
-
+
return $data;
} // get
@@ -372,18 +372,18 @@ class Localplay {
/**
* volume_set
* This isn't a required function, it sets the volume to a specified value
- * as passed in the variable it is a 0 - 100 scale the controller is
+ * as passed in the variable it is a 0 - 100 scale the controller is
* responsible for adjusting the scale if nessecary
*/
- public function volume_set($value) {
-
+ public function volume_set($value) {
+
/* Make sure it's int and 0 - 100 */
$value = int($value);
/* Make sure that it's between 0 and 100 */
if ($value > 100 OR $value < 0) { return false; }
- if (!$this->_player->volume($value)) {
+ if (!$this->_player->volume($value)) {
debug_event('localplay','Error: Unable to set volume, check ' . $this->type . ' controller','1');
return false;
}
@@ -397,11 +397,11 @@ class Localplay {
* This function isn't required. It tells the daemon to increase the volume
* by a pre-defined amount controlled by the controller
*/
- public function volume_up() {
+ public function volume_up() {
- if (!$this->_player->volume_up()) {
+ if (!$this->_player->volume_up()) {
debug_event('localplay','Error: Unable to increase volume, check ' . $this->type . ' controller','1');
- return false;
+ return false;
}
return true;
@@ -413,12 +413,12 @@ class Localplay {
* This function isn't required. It tells the daemon to decrese the volume
* by a pre-defined amount controlled by the controller.
*/
- public function volume_down() {
+ public function volume_down() {
- if (!$this->_player->volume_down()) {
+ if (!$this->_player->volume_down()) {
debug_event('localplay','Error: Unable to decrese volume, check ' . $this->type . ' controller','1');
- return false;
- }
+ return false;
+ }
return true;
@@ -429,14 +429,14 @@ class Localplay {
* This function isn't required, It tells the daemon to mute all output
* It's up to the controller to decide what that actually entails
*/
- public function volume_mute() {
+ public function volume_mute() {
- if (!$this->_player->volume(0)){
+ if (!$this->_player->volume(0)){
debug_event('localplay','Error: Unable to mute volume, check ' . $this->type . ' controller','1');
- return false;
+ return false;
}
- return true;
+ return true;
} // volume_mute
@@ -444,11 +444,11 @@ class Localplay {
* skip
* This isn't a required function, it tells the daemon to skip to the specified song
*/
- public function skip($track_id) {
+ public function skip($track_id) {
- if (!$this->_player->skip($track_id)) {
+ if (!$this->_player->skip($track_id)) {
debug_event('localplay','Error: Unable to skip to next song, check ' . $this->type . ' controller','1');
- return false;
+ return false;
}
return true;
@@ -457,14 +457,14 @@ class Localplay {
/**
* next
- * This isn't a required function, it tells the daemon to go to the next
+ * This isn't a required function, it tells the daemon to go to the next
* song
*/
- public function next() {
+ public function next() {
- if (!$this->_player->next()) {
+ if (!$this->_player->next()) {
debug_event('localplay','Error: Unable to skip to next song, check ' . $this->type . ' controller','1');
- return false;
+ return false;
}
return true;
@@ -476,10 +476,10 @@ class Localplay {
* This isn't a required function, it tells the daemon to go the the previous
* song
*/
- public function prev() {
-
+ public function prev() {
+
- if (!$this->_player->prev()) {
+ if (!$this->_player->prev()) {
debug_event('localplay','Error: Unable to skip to previous song, check ' . $this->type . ' controller','1');
return false;
}
@@ -508,11 +508,11 @@ class Localplay {
* get_instances
* This returns the instances of the current type
*/
- public function get_instances() {
+ public function get_instances() {
- $instances = $this->_player->get_instances();
+ $instances = $this->_player->get_instances();
- return $instances;
+ return $instances;
} // get_instances
@@ -520,11 +520,11 @@ class Localplay {
* current_instance
* This returns the UID of the current Instance
*/
- public function current_instance() {
+ public function current_instance() {
- $data = $this->_player->get_instance();
+ $data = $this->_player->get_instance();
- return $data['id'];
+ return $data['id'];
} // current_instance
@@ -532,11 +532,11 @@ class Localplay {
* get_instance
* This returns the specified instance
*/
- public function get_instance($uid) {
+ public function get_instance($uid) {
- $data = $this->_player->get_instance($uid);
-
- return $data;
+ $data = $this->_player->get_instance($uid);
+
+ return $data;
} // get_instance
@@ -544,11 +544,11 @@ class Localplay {
* update_instance
* This updates the specified instance with a named array of data (_POST most likely)
*/
- public function update_instance($uid,$data) {
+ public function update_instance($uid,$data) {
- $data = $this->_player->update_instance($uid,$data);
+ $data = $this->_player->update_instance($uid,$data);
- return $data;
+ return $data;
} // update_instance
@@ -556,9 +556,9 @@ class Localplay {
* add_instance
* This adds a new instance for the current controller type
*/
- public function add_instance($data) {
+ public function add_instance($data) {
- $this->_player->add_instance($data);
+ $this->_player->add_instance($data);
} // add_instance
@@ -566,9 +566,9 @@ class Localplay {
* delete_instance
* This removes an instance (it actually calls the players function)
*/
- public function delete_instance($instance_uid) {
+ public function delete_instance($instance_uid) {
- $this->_player->delete_instance($instance_uid);
+ $this->_player->delete_instance($instance_uid);
} // delete_instance
@@ -576,9 +576,9 @@ class Localplay {
* set_active_instance
* This sets the active instance of the localplay controller
*/
- public function set_active_instance($instance) {
+ public function set_active_instance($instance) {
- $this->_player->set_active_instance($instance);
+ $this->_player->set_active_instance($instance);
} // set_active_instance
@@ -587,9 +587,9 @@ class Localplay {
* This removes songs from the players playlist it takes a single ID as provided
* by the get command
*/
- public function delete_track($object_id) {
+ public function delete_track($object_id) {
- if (!$this->_player->delete_track($object_id)) {
+ if (!$this->_player->delete_track($object_id)) {
debug_event('localplay','Error: Unable to remove songs, check ' . $this->type . ' controller','1');
return false;
}
@@ -604,11 +604,11 @@ class Localplay {
* This removes every song from the players playlist as defined by the delete_all function
* map
*/
- public function delete_all() {
+ public function delete_all() {
- if (!$this->_player->clear_playlist()) {
+ if (!$this->_player->clear_playlist()) {
debug_event('localplay','Error: Unable to delete entire playlist, check ' . $this->type . ' controller','1');
- return false;
+ return false;
}
return true;
@@ -617,12 +617,12 @@ class Localplay {
/**
* get_instance_fields
- * This loads the fields from the localplay
- * player and returns them
+ * This loads the fields from the localplay
+ * player and returns them
*/
- public function get_instance_fields() {
+ public function get_instance_fields() {
- $fields = $this->_player->instance_fields();
+ $fields = $this->_player->instance_fields();
return $fields;
@@ -633,9 +633,9 @@ class Localplay {
* This function returns a user friendly version
* of the current player state
*/
- public function get_user_state($state) {
-
- switch ($state) {
+ public function get_user_state($state) {
+
+ switch ($state) {
case 'play':
return _('Now Playing');
break;
@@ -648,7 +648,7 @@ class Localplay {
default:
return _('Unknown');
break;
- } // switch on state
+ } // switch on state
} // get_user_state
@@ -657,10 +657,10 @@ class Localplay {
* This attempts to return a nice user friendly
* currently playing string
*/
- public function get_user_playing() {
+ public function get_user_playing() {
$status = $this->status();
-
+
/* Format the track name */
$track_name = $status['track_artist'] . ' - ' . $status['track_album'] . ' - ' . $status['track_title'];
@@ -672,7 +672,7 @@ class Localplay {
$track_name = "[" . $status['track'] . "] - " . $track_name;
return $track_name;
-
+
} // get_user_playing
diff --git a/lib/class/media.interface.php b/lib/class/media.interface.php
index 14bfd4f4..60d01967 100644
--- a/lib/class/media.interface.php
+++ b/lib/class/media.interface.php
@@ -25,13 +25,13 @@
* work, this lists all required functions and the expected
* input
*/
-interface media {
+interface media {
- public function format();
- public function native_stream();
- public static function play_url($oid);
- public function stream_cmd();
- public function has_flag();
+ public function format();
+ public function native_stream();
+ public static function play_url($oid);
+ public function stream_cmd();
+ public function has_flag();
} // end interface
diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php
index 8c4eb7f9..042716b2 100644
--- a/lib/class/playlist.class.php
+++ b/lib/class/playlist.class.php
@@ -24,50 +24,50 @@
* Playlist Class
* This class handles playlists in ampache. it references the playlist* tables
*/
-class Playlist extends database_object {
+class Playlist extends database_object {
/* Variables from the Datbase */
public $id;
public $name;
public $user;
public $type;
- public $genre;
+ public $genre;
public $date;
/* Generated Elements */
public $items = array();
/**
- * Constructor
+ * Constructor
* This takes a playlist_id as an optional argument and gathers the information
- * if not playlist_id is passed returns false (or if it isn't found
+ * if not playlist_id is passed returns false (or if it isn't found
*/
- public function __construct($id) {
+ public function __construct($id) {
$info = $this->get_info($id);
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
-
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
+
} // Playlist
/**
* build_cache
* This is what builds the cache from the objects
*/
- public static function build_cache($ids) {
-
- if (!count($ids)) { return false; }
+ public static function build_cache($ids) {
- $idlist = '(' . implode(',',$ids) . ')';
+ if (!count($ids)) { return false; }
- $sql = "SELECT * FROM `playlist` WHERE `id` IN $idlist";
- $db_results = Dba::read($sql);
+ $idlist = '(' . implode(',',$ids) . ')';
+
+ $sql = "SELECT * FROM `playlist` WHERE `id` IN $idlist";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('playlist',$row['id'],$row);
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ parent::add_to_cache('playlist',$row['id'],$row);
+ }
} // build_cache
@@ -76,16 +76,16 @@ class Playlist extends database_object {
* This takes the current playlist object and gussies it up a little
* bit so it is presentable to the users
*/
- public function format() {
+ public function format() {
$this->f_name = truncate_with_ellipsis($this->name,Config::get('ellipse_threshold_title'));
- $this->f_link = '<a href="' . Config::get('web_path') . '/playlist.php?action=show_playlist&amp;playlist_id=' . $this->id . '">' . $this->f_name . '</a>';
+ $this->f_link = '<a href="' . Config::get('web_path') . '/playlist.php?action=show_playlist&amp;playlist_id=' . $this->id . '">' . $this->f_name . '</a>';
- $this->f_type = ($this->type == 'private') ? get_user_icon('lock',_('Private')) : '';
+ $this->f_type = ($this->type == 'private') ? get_user_icon('lock',_('Private')) : '';
- $client = new User($this->user);
+ $client = new User($this->user);
- $this->f_user = $client->fullname;
+ $this->f_user = $client->fullname;
} // format
@@ -94,19 +94,19 @@ class Playlist extends database_object {
* This function returns true or false if the current user
* has access to this playlist
*/
- public function has_access() {
-
- if (!Access::check('interface','25')) {
- return false;
- }
- if ($this->user == $GLOBALS['user']->id) {
- return true;
- }
+ public function has_access() {
+
+ if (!Access::check('interface','25')) {
+ return false;
+ }
+ if ($this->user == $GLOBALS['user']->id) {
+ return true;
+ }
else {
- return Access::check('interface','100');
- }
+ return Access::check('interface','100');
+ }
- return false;
+ return false;
} // has_access
@@ -115,17 +115,17 @@ class Playlist extends database_object {
* Returns the single item on the playlist and all of it's information, restrict
* it to this Playlist
*/
- public function get_track($track_id) {
+ public function get_track($track_id) {
- $track_id = Dba::escape($track_id);
- $playlist_id = Dba::escape($this->id);
+ $track_id = Dba::escape($track_id);
+ $playlist_id = Dba::escape($this->id);
$sql = "SELECT * FROM `playlist_data` WHERE `id`='$track_id' AND `playlist`='$playlist_id'";
$db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results);
- return $row;
+ return $row;
} // get_track
@@ -134,15 +134,15 @@ class Playlist extends database_object {
* This returns an array of playlist songs that are in this playlist. Because the same
* song can be on the same playlist twice they are key'd by the uid from playlist_data
*/
- public function get_items() {
+ public function get_items() {
- $results = array();
+ $results = array();
$sql = "SELECT `id`,`object_id`,`object_type`,`track` FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY `track`";
$db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = array('type'=>$row['object_type'],'object_id'=>$row['object_id'],'track'=>$row['track'],'track_id'=>$row['id']);
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = array('type'=>$row['object_type'],'object_id'=>$row['object_id'],'track'=>$row['track'],'track_id'=>$row['id']);
} // end while
return $results;
@@ -153,17 +153,17 @@ class Playlist extends database_object {
* get_random_items
* This is the same as before but we randomize the buggers!
*/
- public function get_random_items($limit='') {
+ public function get_random_items($limit='') {
- $results = array();
+ $results = array();
- $limit_sql = $limit ? 'LIMIT ' . intval($limit) : '';
+ $limit_sql = $limit ? 'LIMIT ' . intval($limit) : '';
- $sql = "SELECT `object_id`,`object_type` FROM `playlist_data` " .
- "WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY RAND() $limit_sql";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `object_id`,`object_type` FROM `playlist_data` " .
+ "WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY RAND() $limit_sql";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
+ while ($row = Dba::fetch_assoc($db_results)) {
$results[] = array('type'=>$row['object_type'],'object_id'=>$row['object_id']);
} // end while
@@ -177,21 +177,21 @@ class Playlist extends database_object {
* This is called by the batch script, because we can't pass in Dynamic objects they pulled once and then their
* target song.id is pushed into the array
*/
- function get_songs() {
+ function get_songs() {
$results = array();
$sql = "SELECT * FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY `track`";
$db_results = Dba::read($sql);
- while ($r = Dba::fetch_assoc($db_results)) {
- if ($r['dyn_song']) {
+ while ($r = Dba::fetch_assoc($db_results)) {
+ if ($r['dyn_song']) {
$array = $this->get_dyn_songs($r['dyn_song']);
$results = array_merge($array,$results);
}
- else {
+ else {
$results[] = $r['object_id'];
- }
+ }
} // end while
@@ -204,7 +204,7 @@ class Playlist extends database_object {
* This simply returns a int of how many song elements exist in this playlist
* For now let's consider a dyn_song a single entry
*/
- public function get_song_count() {
+ public function get_song_count() {
$sql = "SELECT COUNT(`id`) FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "'";
$db_results = Dba::read($sql);
@@ -220,19 +220,19 @@ class Playlist extends database_object {
* This returns the specified users playlists as an array of
* playlist ids
*/
- public static function get_users($user_id) {
+ public static function get_users($user_id) {
- $user_id = Dba::escape($user_id);
- $results = array();
+ $user_id = Dba::escape($user_id);
+ $results = array();
- $sql = "SELECT `id` FROM `playlist` WHERE `user`='$user_id' ORDER BY `name`";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id` FROM `playlist` WHERE `user`='$user_id' ORDER BY `name`";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
- return $results;
+ return $results;
} // get_users
@@ -240,24 +240,24 @@ class Playlist extends database_object {
* update
* This function takes a key'd array of data and runs updates
*/
- public function update($data) {
+ public function update($data) {
- if ($data['name'] != $this->name) {
- $this->update_name($data['name']);
- }
- if ($data['pl_type'] != $this->type) {
- $this->update_type($data['pl_type']);
- }
+ if ($data['name'] != $this->name) {
+ $this->update_name($data['name']);
+ }
+ if ($data['pl_type'] != $this->type) {
+ $this->update_type($data['pl_type']);
+ }
} // update
/**
* update_type
- * This updates the playlist type, it calls the generic update_item function
+ * This updates the playlist type, it calls the generic update_item function
*/
- private function update_type($new_type) {
+ private function update_type($new_type) {
- if ($this->_update_item('type',$new_type,'50')) {
+ if ($this->_update_item('type',$new_type,'50')) {
$this->type = $new_type;
}
@@ -267,9 +267,9 @@ class Playlist extends database_object {
* update_name
* This updates the playlist name, it calls the generic update_item function
*/
- private function update_name($new_name) {
+ private function update_name($new_name) {
- if ($this->_update_item('name',$new_name,'50')) {
+ if ($this->_update_item('name',$new_name,'50')) {
$this->name = $new_name;
}
@@ -279,10 +279,10 @@ class Playlist extends database_object {
* _update_item
* This is the generic update function, it does the escaping and error checking
*/
- private function _update_item($field,$value,$level) {
+ private function _update_item($field,$value,$level) {
- if ($GLOBALS['user']->id != $this->user AND !Access::check('interface',$level)) {
- return false;
+ if ($GLOBALS['user']->id != $this->user AND !Access::check('interface',$level)) {
+ return false;
}
$value = Dba::escape($value);
@@ -298,14 +298,14 @@ class Playlist extends database_object {
* update_track_number
* This takes a playlist_data.id and a track (int) and updates the track value
*/
- public function update_track_number($track_id,$track) {
+ public function update_track_number($track_id,$track) {
- $playlist_id = Dba::escape($this->id);
- $track_id = Dba::escape($track_id);
- $track = Dba::escape($track);
+ $playlist_id = Dba::escape($this->id);
+ $track_id = Dba::escape($track_id);
+ $track = Dba::escape($track);
- $sql = "UPDATE `playlist_data` SET `track`='$track' WHERE `id`='$track_id' AND `playlist`='$playlist_id'";
- $db_results = Dba::write($sql);
+ $sql = "UPDATE `playlist_data` SET `track`='$track' WHERE `id`='$track_id' AND `playlist`='$playlist_id'";
+ $db_results = Dba::write($sql);
} // update_track_number
@@ -315,10 +315,10 @@ class Playlist extends database_object {
* if you want to add a dyn_song you need to use the one shot function
* add_dyn_song
*/
- public function add_songs($song_ids=array(),$ordered=false) {
+ public function add_songs($song_ids=array(),$ordered=false) {
/* We need to pull the current 'end' track and then use that to
- * append, rather then integrate take end track # and add it to
+ * append, rather then integrate take end track # and add it to
* $song->track add one to make sure it really is 'next'
*/
$sql = "SELECT `track` FROM `playlist_data` WHERE `playlist`='" . $this->id . "' ORDER BY `track` DESC LIMIT 1";
@@ -327,24 +327,24 @@ class Playlist extends database_object {
$base_track = $data['track'];
debug_event('add_songs', 'Track number: '.$base_track, '5');
- foreach ($song_ids as $song_id) {
+ foreach ($song_ids as $song_id) {
/* We need the songs track */
$song = new Song($song_id);
-
+
// Based on the ordered prop we use track + base or just $i++
- if (!$ordered) {
+ if (!$ordered) {
$track = Dba::escape($song->track+$base_track);
- }
- else {
- $i++;
- $track = Dba::escape($base_track+$i);
- }
+ }
+ else {
+ $i++;
+ $track = Dba::escape($base_track+$i);
+ }
$id = Dba::escape($song->id);
$pl_id = Dba::escape($this->id);
/* Don't insert dead songs */
- if ($id) {
- $sql = "INSERT INTO `playlist_data` (`playlist`,`object_id`,`object_type`,`track`) " .
+ if ($id) {
+ $sql = "INSERT INTO `playlist_data` (`playlist`,`object_id`,`object_type`,`track`) " .
" VALUES ('$pl_id','$id','song','$track')";
$db_results = Dba::write($sql);
} // if valid id
@@ -358,14 +358,14 @@ class Playlist extends database_object {
* This function creates an empty playlist, gives it a name and type
* Assumes $GLOBALS['user']->id as the user
*/
- public static function create($name,$type) {
+ public static function create($name,$type) {
$name = Dba::escape($name);
$type = Dba::escape($type);
$user = Dba::escape($GLOBALS['user']->id);
$date = time();
- $sql = "INSERT INTO `playlist` (`name`,`user`,`type`,`date`) " .
+ $sql = "INSERT INTO `playlist` (`name`,`user`,`type`,`date`) " .
" VALUES ('$name','$user','$type','$date')";
$db_results = Dba::write($sql);
@@ -379,7 +379,7 @@ class Playlist extends database_object {
* set_items
* This calles the get_items function and sets it to $this->items which is an array in this object
*/
- function set_items() {
+ function set_items() {
$this->items = $this->get_items();
@@ -391,7 +391,7 @@ class Playlist extends database_object {
* and numbers them in a liner fashion, not allowing for
* the same track # twice, this is an optional funcition
*/
- public function normalize_tracks() {
+ public function normalize_tracks() {
/* First get all of the songs in order of their tracks */
$sql = "SELECT `id` FROM `playlist_data` WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY `track` ASC";
@@ -400,7 +400,7 @@ class Playlist extends database_object {
$i = 1;
$results = array();
- while ($r = Dba::fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$new_data = array();
$new_data['id'] = $r['id'];
$new_data['track'] = $i;
@@ -408,8 +408,8 @@ class Playlist extends database_object {
$i++;
} // end while results
- foreach($results as $data) {
- $sql = "UPDATE `playlist_data` SET `track`='" . $data['track'] . "' WHERE" .
+ foreach($results as $data) {
+ $sql = "UPDATE `playlist_data` SET `track`='" . $data['track'] . "' WHERE" .
" `id`='" . $data['id'] . "'";
$db_results = Dba::write($sql);
} // foreach re-ordered results
@@ -417,42 +417,42 @@ class Playlist extends database_object {
return true;
} // normalize_tracks
-
+
/**
* delete_track
* this deletes a single track, you specify the playlist_data.id here
*/
- public function delete_track($id) {
+ public function delete_track($id) {
- $this_id = Dba::escape($this->id);
- $id = Dba::escape($id);
-
- $sql = "DELETE FROM `playlist_data` WHERE `playlist_data`.`playlist`='$this_id' AND `playlist_data`.`id`='$id' LIMIT 1";
- $db_results = Dba::write($sql);
+ $this_id = Dba::escape($this->id);
+ $id = Dba::escape($id);
- return true;
+ $sql = "DELETE FROM `playlist_data` WHERE `playlist_data`.`playlist`='$this_id' AND `playlist_data`.`id`='$id' LIMIT 1";
+ $db_results = Dba::write($sql);
+
+ return true;
- } // delete_track
+ } // delete_track
/**
* delete
* This deletes the current playlist and all assoicated data
*/
- public function delete() {
+ public function delete() {
+
+ $id = Dba::escape($this->id);
- $id = Dba::escape($this->id);
-
$sql = "DELETE FROM `playlist_data` WHERE `playlist` = '$id'";
$db_results = Dba::write($sql);
$sql = "DELETE FROM `playlist` WHERE `id`='$id'";
$db_results = Dba::write($sql);
- $sql = "DELETE FROM `object_count` WHERE `object_type`='playlist' AND `object_id`='$id'";
- $db_results = Dba::write($sql);
-
+ $sql = "DELETE FROM `object_count` WHERE `object_type`='playlist' AND `object_id`='$id'";
+ $db_results = Dba::write($sql);
+
return true;
-
+
} // delete
} // class Playlist
diff --git a/lib/class/plugin.class.php b/lib/class/plugin.class.php
index 3e0d70a9..63eeb593 100644
--- a/lib/class/plugin.class.php
+++ b/lib/class/plugin.class.php
@@ -26,21 +26,21 @@ class Plugin {
public $name;
/* constructed objects */
- public $_plugin;
+ public $_plugin;
/**
* Constructor
- * This constructor loads the Plugin config file which defines how to
+ * This constructor loads the Plugin config file which defines how to
* install/uninstall the plugin from Ampache's database
*/
- public function __construct($name) {
+ public function __construct($name) {
/* Load the plugin */
- if (!$this->_get_info($name)) {
- return false;
+ if (!$this->_get_info($name)) {
+ return false;
}
- return true;
+ return true;
} // Constructor
@@ -50,20 +50,20 @@ class Plugin {
* This actually loads the config file for the plugin the name of the
* class contained within the config file must be Plugin[NAME OF FILE]
*/
- public function _get_info($name) {
+ public function _get_info($name) {
/* Require the file we want */
require_once Config::get('prefix') . '/modules/plugins/' . $name . '.plugin.php';
$plugin_name = "Ampache$name";
- $this->_plugin = new $plugin_name();
+ $this->_plugin = new $plugin_name();
- if (!$this->is_valid()) {
- return false;
+ if (!$this->is_valid()) {
+ return false;
}
- return true;
+ return true;
} // _get_info
@@ -71,33 +71,33 @@ class Plugin {
* get_plugins
* This returns an array of plugin names
*/
- public static function get_plugins() {
+ public static function get_plugins() {
- $results = array();
+ $results = array();
// Open up the plugin dir
- $handle = opendir(Config::get('prefix') . '/modules/plugins');
+ $handle = opendir(Config::get('prefix') . '/modules/plugins');
- if (!is_resource($handle)) {
- debug_event('Plugins','Unable to read plugins directory','1');
- }
+ if (!is_resource($handle)) {
+ debug_event('Plugins','Unable to read plugins directory','1');
+ }
// Recurse the directory
- while ($file = readdir($handle)) {
+ while ($file = readdir($handle)) {
// Ignore non-plugin files
- if (substr($file,-10,10) != 'plugin.php') { continue; }
- if (is_dir($file)) { continue; }
+ if (substr($file,-10,10) != 'plugin.php') { continue; }
+ if (is_dir($file)) { continue; }
// It's a plugin record it
- $plugin_name = basename($file,'.plugin.php');
- $results[$plugin_name] = $plugin_name;
+ $plugin_name = basename($file,'.plugin.php');
+ $results[$plugin_name] = $plugin_name;
} // end while
// Little stupid but hey
- ksort($results);
+ ksort($results);
- return $results;
+ return $results;
} // get_plugins
@@ -108,41 +108,41 @@ class Plugin {
* install & uninstall method and Ampache must be within the min/max
* version specifications
*/
- function is_valid() {
+ function is_valid() {
- /* Check the plugin to make sure it's got the needed vars */
- if (!strlen($this->_plugin->name)) {
- return false;
+ /* Check the plugin to make sure it's got the needed vars */
+ if (!strlen($this->_plugin->name)) {
+ return false;
+ }
+ if (!strlen($this->_plugin->description)) {
+ return false;
}
- if (!strlen($this->_plugin->description)) {
- return false;
+ if (!strlen($this->_plugin->version)) {
+ return false;
}
- if (!strlen($this->_plugin->version)) {
- return false;
- }
/* Make sure we've got the required methods */
- if (!method_exists($this->_plugin,'install')) {
- return false;
+ if (!method_exists($this->_plugin,'install')) {
+ return false;
}
- if (!method_exists($this->_plugin,'uninstall')) {
- return false;
- }
+ if (!method_exists($this->_plugin,'uninstall')) {
+ return false;
+ }
/* Make sure it's within the version confines */
- $db_version = $this->get_ampache_db_version();
+ $db_version = $this->get_ampache_db_version();
- if ($db_version < $this->_plugin->min_ampache) {
- return false;
- }
+ if ($db_version < $this->_plugin->min_ampache) {
+ return false;
+ }
- if ($db_version > $this->_plugin->max_ampache) {
- return false;
- }
+ if ($db_version > $this->_plugin->max_ampache) {
+ return false;
+ }
/* We've passed all of the tests its good */
- return true;
+ return true;
} // is_valid
@@ -151,42 +151,42 @@ class Plugin {
* This checks to see if the specified plugin is currently installed in the
* database, it doesn't check the files for integrity
*/
- public static function is_installed($plugin_name) {
+ public static function is_installed($plugin_name) {
- /* All we do is check the version */
- return self::get_plugin_version($plugin_name);
+ /* All we do is check the version */
+ return self::get_plugin_version($plugin_name);
} // is_installed
/**
* install
- * This runs the install function of the plugin (must be called install)
+ * This runs the install function of the plugin (must be called install)
* at the end it inserts a row into the update_info table to indicate
* That it's installed
*/
- public function install() {
+ public function install() {
- $installed = $this->_plugin->install();
+ $installed = $this->_plugin->install();
- $version = $this->set_plugin_version($this->_plugin->version);
+ $version = $this->set_plugin_version($this->_plugin->version);
- if (!$installed OR !$version) { return false; }
+ if (!$installed OR !$version) { return false; }
- return true;
+ return true;
} // install
- /**
+ /**
* uninstall
- * This runs the uninstall function of the plugin (must be called uninstall)
+ * This runs the uninstall function of the plugin (must be called uninstall)
* at the end it removes the row from the update_info table to indicate
* that it isn't installed
*/
- public function uninstall() {
+ public function uninstall() {
- $this->_plugin->uninstall();
+ $this->_plugin->uninstall();
- $this->remove_plugin_version();
+ $this->remove_plugin_version();
} // uninstall
@@ -194,15 +194,15 @@ class Plugin {
* get_plugin_version
* This returns the version of the specified plugin
*/
- public static function get_plugin_version($plugin_name) {
+ public static function get_plugin_version($plugin_name) {
+
+ $name = Dba::escape('Plugin_' . $plugin_name);
- $name = Dba::escape('Plugin_' . $plugin_name);
+ $sql = "SELECT * FROM `update_info` WHERE `key`='$name'";
+ $db_results = Dba::read($sql);
- $sql = "SELECT * FROM `update_info` WHERE `key`='$name'";
- $db_results = Dba::read($sql);
+ $results = Dba::fetch_assoc($db_results);
- $results = Dba::fetch_assoc($db_results);
-
return $results['value'];
} // get_plugin_version
@@ -211,12 +211,12 @@ class Plugin {
* get_ampache_db_version
* This function returns the Ampache database version
*/
- function get_ampache_db_version() {
+ function get_ampache_db_version() {
- $sql = "SELECT * FROM `update_info` WHERE `key`='db_version'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `update_info` WHERE `key`='db_version'";
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
return $results['value'];
@@ -226,15 +226,15 @@ class Plugin {
* set_plugin_version
* This sets the plugin version in the update_info table
*/
- public function set_plugin_version($version) {
+ public function set_plugin_version($version) {
$name = Dba::escape('Plugin_' . $this->_plugin->name);
$version = Dba::escape($version);
$sql = "INSERT INTO `update_info` SET `key`='$name', `value`='$version'";
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
- return true;
+ return true;
} // set_plugin_version
@@ -242,14 +242,14 @@ class Plugin {
* remove_plugin_version
* This removes the version row from the db done on uninstall
*/
- public function remove_plugin_version() {
-
+ public function remove_plugin_version() {
+
$name = Dba::escape('Plugin_' . $this->_plugin->name);
-
- $sql = "DELETE FROM `update_info` WHERE `key`='$name'";
- $db_results = Dba::read($sql);
- return true;
+ $sql = "DELETE FROM `update_info` WHERE `key`='$name'";
+ $db_results = Dba::read($sql);
+
+ return true;
} // remove_plugin_version
diff --git a/lib/class/preference.class.php b/lib/class/preference.class.php
index 766859ea..528e6de9 100644
--- a/lib/class/preference.class.php
+++ b/lib/class/preference.class.php
@@ -1,7 +1,7 @@
<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
/*
-
+
Copyright (c) Ampache.org
All Rights Reserved
@@ -18,86 +18,86 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
+
+*/
/**
* preference Class
* This handles all of the preference stuff for ampache it replaces
* /lib/preference.lib.php
*/
-class Preference {
+class Preference {
/**
* __constructor
* This does nothing... amazing isn't it!
*/
- private function __construct() {
+ private function __construct() {
// Rien a faire
-
+
} // __construct
/**
* update
* This updates a single preference from the given name or id
*/
- public static function update($preference,$user_id,$value,$applytoall='') {
+ public static function update($preference,$user_id,$value,$applytoall='') {
// First prepare
- if (!is_numeric($preference)) {
- $id = self::id_from_name($preference);
- $name = $preference;
- }
- else {
- $name = self::name_from_id($preference);
- $id = $preference;
- }
- if ($applytoall AND Access::check('interface','100')) {
+ if (!is_numeric($preference)) {
+ $id = self::id_from_name($preference);
+ $name = $preference;
+ }
+ else {
+ $name = self::name_from_id($preference);
+ $id = $preference;
+ }
+ if ($applytoall AND Access::check('interface','100')) {
$user_check = "";
}
- else {
+ else {
$user_check = " AND `user`='$user_id'";
- }
+ }
// Now do
- if (self::has_access($name)) {
- $value = Dba::escape($value);
- $user_id = Dba::escape($user_id);
- $sql = "UPDATE `user_preference` SET `value`='$value' " .
- "WHERE `preference`='$id'$user_check";
- $db_results = Dba::write($sql);
+ if (self::has_access($name)) {
+ $value = Dba::escape($value);
+ $user_id = Dba::escape($user_id);
+ $sql = "UPDATE `user_preference` SET `value`='$value' " .
+ "WHERE `preference`='$id'$user_check";
+ $db_results = Dba::write($sql);
Preference::clear_from_session();
- return true;
- }
- else {
- debug_event('denied',$GLOBALS['user']->username . ' attempted to update ' . $name . ' but does not have sufficient permissions','3');
+ return true;
+ }
+ else {
+ debug_event('denied',$GLOBALS['user']->username . ' attempted to update ' . $name . ' but does not have sufficient permissions','3');
}
- return false;
+ return false;
} // update
/**
* update_level
* This takes a preference ID and updates the level required to update it (performed by an admin)
*/
- public static function update_level($preference,$level) {
+ public static function update_level($preference,$level) {
// First prepare
- if (!is_numeric($preference)) {
+ if (!is_numeric($preference)) {
$preference_id = self::id_from_name($preference);
- }
- else {
+ }
+ else {
$preference_id = $preference;
- }
+ }
$preference_id = Dba::escape($preference_id);
- $level = Dba::escape($level);
+ $level = Dba::escape($level);
- $sql = "UPDATE `preference` SET `level`='$level' WHERE `id`='$preference_id'";
- $db_results = Dba::write($sql);
+ $sql = "UPDATE `preference` SET `level`='$level' WHERE `id`='$preference_id'";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // update_level
@@ -105,15 +105,15 @@ class Preference {
* update_all
* This takes a preference id and a value and updates all users with the new info
*/
- public static function update_all($preference_id,$value) {
+ public static function update_all($preference_id,$value) {
$preference_id = Dba::escape($preference_id);
- $value = Dba::escape($value);
+ $value = Dba::escape($value);
- $sql = "UPDATE `user_preference` SET `value`='$value' WHERE `preference`='$preference_id'";
- $db_results = Dba::write($sql);
+ $sql = "UPDATE `user_preference` SET `value`='$value' WHERE `preference`='$preference_id'";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // update_all
@@ -121,14 +121,14 @@ class Preference {
* exists
* This just checks to see if a preference currently exists
*/
- public static function exists($preference) {
+ public static function exists($preference) {
// We assume it's the name
- $name = Dba::escape($preference);
- $sql = "SELECT * FROM `preference` WHERE `name`='$name'";
- $db_results = Dba::read($sql);
+ $name = Dba::escape($preference);
+ $sql = "SELECT * FROM `preference` WHERE `name`='$name'";
+ $db_results = Dba::read($sql);
- return Dba::num_rows($db_results);
+ return Dba::num_rows($db_results);
} // exists
@@ -137,22 +137,22 @@ class Preference {
* This checks to see if the current user has access to modify this preference
* as defined by the preference name
*/
- public static function has_access($preference) {
+ public static function has_access($preference) {
// Nothing for those demo thugs
- if (Config::get('demo_mode')) { return false; }
+ if (Config::get('demo_mode')) { return false; }
- $preference = Dba::escape($preference);
+ $preference = Dba::escape($preference);
- $sql = "SELECT `level` FROM `preference` WHERE `name`='$preference'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `level` FROM `preference` WHERE `name`='$preference'";
+ $db_results = Dba::read($sql);
$data = Dba::fetch_assoc($db_results);
- if (Access::check('interface',$data['level'])) {
- return true;
- }
+ if (Access::check('interface',$data['level'])) {
+ return true;
+ }
- return false;
+ return false;
} // has_access
@@ -160,16 +160,16 @@ class Preference {
* id_from_name
* This takes a name and returns the id
*/
- public static function id_from_name($name) {
+ public static function id_from_name($name) {
- $name = Dba::escape($name);
+ $name = Dba::escape($name);
- $sql = "SELECT `id` FROM `preference` WHERE `name`='$name'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id` FROM `preference` WHERE `name`='$name'";
+ $db_results = Dba::read($sql);
- $row = Dba::fetch_assoc($db_results);
+ $row = Dba::fetch_assoc($db_results);
- return $row['id'];
+ return $row['id'];
} // id_from_name
@@ -178,16 +178,16 @@ class Preference {
* This returns the name from an id, it's the exact opposite
* of the function above it, amazing!
*/
- public static function name_from_id($id) {
+ public static function name_from_id($id) {
- $id = Dba::escape($id);
+ $id = Dba::escape($id);
- $sql = "SELECT `name` FROM `preference` WHERE `id`='$id'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `name` FROM `preference` WHERE `id`='$id'";
+ $db_results = Dba::read($sql);
- $row = Dba::fetch_assoc($db_results);
+ $row = Dba::fetch_assoc($db_results);
- return $row['name'];
+ return $row['name'];
} // name_from_id
@@ -196,20 +196,20 @@ class Preference {
* This returns an array of the names of the different possible sections
* it ignores the 'internal' catagory
*/
- public static function get_catagories() {
+ public static function get_catagories() {
- $sql = "SELECT `preference`.`catagory` FROM `preference` GROUP BY `catagory` ORDER BY `catagory`";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `preference`.`catagory` FROM `preference` GROUP BY `catagory` ORDER BY `catagory`";
+ $db_results = Dba::read($sql);
- $results = array();
+ $results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- if ($row['catagory'] != 'internal') {
- $results[] = $row['catagory'];
+ while ($row = Dba::fetch_assoc($db_results)) {
+ if ($row['catagory'] != 'internal') {
+ $results[] = $row['catagory'];
}
} // end while
- return $results;
+ return $results;
} // get_catagories
@@ -217,52 +217,52 @@ class Preference {
* get_all
* This returns a nice flat array of all of the possible preferences for the specified user
*/
- public static function get_all($user_id) {
+ public static function get_all($user_id) {
- $user_id = Dba::escape($user_id);
+ $user_id = Dba::escape($user_id);
if ($user_id != '-1') {
$user_limit = "AND `preference`.`catagory` != 'system'";
}
-
- $sql = "SELECT `preference`.`name`,`preference`.`description`,`user_preference`.`value` FROM `preference` " .
- " INNER JOIN `user_preference` ON `user_preference`.`preference`=`preference`.`id` " .
- " WHERE `user_preference`.`user`='$user_id' AND `preference`.`catagory` != 'internal' $user_limit " .
- " ORDER BY `preference`.`description`";
- $db_results = Dba::read($sql);
- $results = array();
+ $sql = "SELECT `preference`.`name`,`preference`.`description`,`user_preference`.`value` FROM `preference` " .
+ " INNER JOIN `user_preference` ON `user_preference`.`preference`=`preference`.`id` " .
+ " WHERE `user_preference`.`user`='$user_id' AND `preference`.`catagory` != 'internal' $user_limit " .
+ " ORDER BY `preference`.`description`";
+ $db_results = Dba::read($sql);
+
+ $results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
+ while ($row = Dba::fetch_assoc($db_results)) {
$results[] = array('name'=>$row['name'],'level'=>$row['level'],'description'=>$row['description'],'value'=>$row['value']);
- }
+ }
- return $results;
+ return $results;
- } // get_all
+ } // get_all
/**
* insert
* This inserts a new preference into the preference table
* it does NOT sync up the users, that should be done independtly
*/
- public static function insert($name,$description,$default,$level,$type,$catagory) {
+ public static function insert($name,$description,$default,$level,$type,$catagory) {
- // Clean em up
- $name = Dba::escape($name);
- $description = Dba::escape($description);
- $default = Dba::escape($default);
- $level = Dba::escape($level);
- $type = Dba::escape($type);
- $catagory = Dba::escape($catagory);
+ // Clean em up
+ $name = Dba::escape($name);
+ $description = Dba::escape($description);
+ $default = Dba::escape($default);
+ $level = Dba::escape($level);
+ $type = Dba::escape($type);
+ $catagory = Dba::escape($catagory);
- $sql = "INSERT INTO `preference` (`name`,`description`,`value`,`level`,`type`,`catagory`) " .
- "VALUES ('$name','$description','$default','$level','$type','$catagory')";
- $db_results = Dba::write($sql);
+ $sql = "INSERT INTO `preference` (`name`,`description`,`value`,`level`,`type`,`catagory`) " .
+ "VALUES ('$name','$description','$default','$level','$type','$catagory')";
+ $db_results = Dba::write($sql);
- if (!$db_results) { return false; }
+ if (!$db_results) { return false; }
- return true;
+ return true;
} // insert
@@ -270,21 +270,21 @@ class Preference {
* delete
* This deletes the specified preference, a name or a ID can be passed
*/
- public static function delete($preference) {
+ public static function delete($preference) {
// First prepare
if (!is_numeric($preference)) {
- $name = Dba::escape($preference);
- $sql = "DELETE FROM `preference` WHERE `name`='$name'";
+ $name = Dba::escape($preference);
+ $sql = "DELETE FROM `preference` WHERE `name`='$name'";
}
else {
- $id = Dba::escape($preference);
- $sql = "DELETE FROM `preference` WHERE `id`='$id'";
+ $id = Dba::escape($preference);
+ $sql = "DELETE FROM `preference` WHERE `id`='$id'";
}
- $db_results = Dba::write($sql);
+ $db_results = Dba::write($sql);
- self::rebuild_preferences();
+ self::rebuild_preferences();
} // delete
@@ -292,34 +292,34 @@ class Preference {
* rebuild_preferences
* This removes any garbage and then adds back in anything missing preferences wise
*/
- public static function rebuild_preferences() {
+ public static function rebuild_preferences() {
// First remove garbage
- $sql = "DELETE FROM `user_preference` USING `user_preference` LEFT JOIN `preference` ON `preference`.`id`=`user_preference`.`preference` " .
- "WHERE `preference`.`id` IS NULL";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `user_preference` USING `user_preference` LEFT JOIN `preference` ON `preference`.`id`=`user_preference`.`preference` " .
+ "WHERE `preference`.`id` IS NULL";
+ $db_results = Dba::write($sql);
// Now add anything that we are missing back in, except System
- $sql = "SELECT * FROM `preference` WHERE `type`!='system'";
+ $sql = "SELECT * FROM `preference` WHERE `type`!='system'";
//FIXME: Uhh WTF shouldn't there be something here??
} // rebuild_preferences
/**
* fix_preferences
- * This takes the preferences, explodes what needs to
+ * This takes the preferences, explodes what needs to
* become an array and boolean everythings
*/
public static function fix_preferences($results) {
- $results['auth_methods'] = trim($results['auth_methods']) ? explode(",",$results['auth_methods']) : array();
- $results['tag_order'] = trim($results['tag_order']) ? explode(",",$results['tag_order']) : array();
- $results['album_art_order'] = trim($results['album_art_order']) ? explode(",",$results['album_art_order']) : array();
+ $results['auth_methods'] = trim($results['auth_methods']) ? explode(",",$results['auth_methods']) : array();
+ $results['tag_order'] = trim($results['tag_order']) ? explode(",",$results['tag_order']) : array();
+ $results['album_art_order'] = trim($results['album_art_order']) ? explode(",",$results['album_art_order']) : array();
if (isset($results['amazin_base_urls']))
$results['amazon_base_urls'] = trim($results['amazin_base_urls']) ? explode(",",$results['amazon_base_urls']) : array();
- else
+ else
$results['amazon_base_urls']= array();
-
+
foreach ($results as $key=>$data) {
if (!is_array($data)) {
if (strcasecmp($data,"true") == "0") { $results[$key] = 1; }
@@ -334,15 +334,15 @@ class Preference {
/**
* load_from_session
* This loads the preferences from the session rather then creating a connection to the database
- */
- public static function load_from_session($uid=-1) {
+ */
+ public static function load_from_session($uid=-1) {
- if (is_array($_SESSION['userdata']['preferences']) AND $_SESSION['userdata']['uid'] == $uid) {
- Config::set_by_array($_SESSION['userdata']['preferences'],1);
- return true;
- }
+ if (is_array($_SESSION['userdata']['preferences']) AND $_SESSION['userdata']['uid'] == $uid) {
+ Config::set_by_array($_SESSION['userdata']['preferences'],1);
+ return true;
+ }
- return false;
+ return false;
} // load_from_session
@@ -351,9 +351,9 @@ class Preference {
* This clears the users preferences, this is done whenever modifications are made to the preferences
* or the admin resets something
*/
- public static function clear_from_session() {
+ public static function clear_from_session() {
- unset($_SESSION['userdata']['preferences']);
+ unset($_SESSION['userdata']['preferences']);
} // clear_from_session
@@ -363,7 +363,7 @@ class Preference {
* This is currently only used by the debug view, could be used other places.. wouldn't be a half
* bad idea
*/
- public static function is_boolean($key) {
+ public static function is_boolean($key) {
$boolean_array = array('session_cookiesecure','require_session',
'access_control','require_localnet_session',
@@ -377,13 +377,13 @@ class Preference {
'allow_stream_playback','allow_democratic_playback',
'use_auth','allow_localplay_playback','debug','lock_songs',
'transcode_m4a','transcode_mp3','transcode_ogg','transcode_flac',
- 'shoutcast_active','httpq_active','show_lyrics');
+ 'shoutcast_active','httpq_active','show_lyrics');
- if (in_array($key,$boolean_array)) {
- return true;
- }
+ if (in_array($key,$boolean_array)) {
+ return true;
+ }
- return false;
+ return false;
} // is_boolean
@@ -392,25 +392,25 @@ class Preference {
* This grabs the preferences and then loads them into conf it should be run on page load
* to initialize the needed variables
*/
- public static function init() {
+ public static function init() {
- $user_id = $GLOBALS['user']->id ? Dba::escape($GLOBALS['user']->id) : '-1';
+ $user_id = $GLOBALS['user']->id ? Dba::escape($GLOBALS['user']->id) : '-1';
// First go ahead and try to load it from the preferences
- if (self::load_from_session($user_id)) {
- return true;
- }
-
+ if (self::load_from_session($user_id)) {
+ return true;
+ }
+
/* Get Global Preferences */
- $sql = "SELECT `preference`.`name`,`user_preference`.`value`,`syspref`.`value` AS `system_value` FROM `preference` " .
- "LEFT JOIN `user_preference` `syspref` ON `syspref`.`preference`=`preference`.`id` AND `syspref`.`user`='-1' AND `preference`.`catagory`='system' " .
- "LEFT JOIN `user_preference` ON `user_preference`.`preference`=`preference`.`id` AND `user_preference`.`user`='$user_id' AND `preference`.`catagory`!='system'";
+ $sql = "SELECT `preference`.`name`,`user_preference`.`value`,`syspref`.`value` AS `system_value` FROM `preference` " .
+ "LEFT JOIN `user_preference` `syspref` ON `syspref`.`preference`=`preference`.`id` AND `syspref`.`user`='-1' AND `preference`.`catagory`='system' " .
+ "LEFT JOIN `user_preference` ON `user_preference`.`preference`=`preference`.`id` AND `user_preference`.`user`='$user_id' AND `preference`.`catagory`!='system'";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
- $value = $row['system_value'] ? $row['system_value'] : $row['value'];
+ $value = $row['system_value'] ? $row['system_value'] : $row['value'];
$name = $row['name'];
- $results[$name] = $value;
+ $results[$name] = $value;
} // end while sys prefs
/* Set the Theme mojo */
@@ -425,8 +425,8 @@ class Preference {
}
Config::set_by_array($results,1);
- $_SESSION['userdata']['preferences'] = $results;
- $_SESSION['userdata']['uid'] = $user_id;
+ $_SESSION['userdata']['preferences'] = $results;
+ $_SESSION['userdata']['uid'] = $user_id;
} // init
diff --git a/lib/class/query.class.php b/lib/class/query.class.php
index 057897e2..109cef1f 100644
--- a/lib/class/query.class.php
+++ b/lib/class/query.class.php
@@ -817,15 +817,15 @@ class Query {
switch (self::$type) {
case 'song':
switch($filter) {
- case 'tag':
+ case 'tag':
self::set_join('left','`tag_map`','`tag_map`.`object_id`','`song`.`id`');
- $filter_sql = " `tag_map`.`object_type`='song' AND (";
-
- foreach ($value as $tag_id) {
- $filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
+ $filter_sql = " `tag_map`.`object_type`='song' AND (";
+
+ foreach ($value as $tag_id) {
+ $filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
}
- $filter_sql = rtrim($filter_sql,'AND') . ') AND ';
- break;
+ $filter_sql = rtrim($filter_sql,'AND') . ') AND ';
+ break;
case 'exact_match':
$filter_sql = " `song`.`title` = '" . Dba::escape($value) . "' AND ";
break;
@@ -971,9 +971,9 @@ class Query {
case 'exact_match':
$filter_sql = " `tag`.`name` = '" . Dba::escape($value) . "' AND ";
break;
- case 'tag':
- $filter_sql = " `tag`.`id` = '" . Dba::escape($value) . "' AND ";
- break;
+ case 'tag':
+ $filter_sql = " `tag`.`id` = '" . Dba::escape($value) . "' AND ";
+ break;
default:
// Rien a faire
break;
diff --git a/lib/class/radio.class.php b/lib/class/radio.class.php
index 65cdf1d0..7112ea5c 100644
--- a/lib/class/radio.class.php
+++ b/lib/class/radio.class.php
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
@@ -29,26 +29,26 @@
class Radio extends database_object implements media {
/* DB based variables */
- public $id;
- public $name;
- public $site_url;
- public $url;
+ public $id;
+ public $name;
+ public $site_url;
+ public $url;
public $frequency;
public $call_sign;
- public $catalog;
+ public $catalog;
/**
* Constructor
* This takes a flagged.id and then pulls in the information for said flag entry
*/
- public function __construct($id) {
+ public function __construct($id) {
$info = $this->get_info($id,'live_stream');
// Set the vars
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
} // constructor
@@ -57,111 +57,111 @@ class Radio extends database_object implements media {
* This takes the normal data from the database and makes it pretty
* for the users, the new variables are put in f_??? and f_???_link
*/
- public function format() {
+ public function format() {
// Default link used on the rightbar
- $this->f_link = "<a href=\"$this->url\">$this->name</a>";
+ $this->f_link = "<a href=\"$this->url\">$this->name</a>";
- $this->f_name_link = "<a target=\"_blank\" href=\"$this->site_url\">$this->name</a>";
- $this->f_callsign = scrub_out($this->call_sign);
- $this->f_frequency = scrub_out($this->frequency);
+ $this->f_name_link = "<a target=\"_blank\" href=\"$this->site_url\">$this->name</a>";
+ $this->f_callsign = scrub_out($this->call_sign);
+ $this->f_frequency = scrub_out($this->frequency);
- return true;
+ return true;
} // format
/**
* update
* This is a static function that takes a key'd array for input
- * it depends on a ID element to determine which radio element it
+ * it depends on a ID element to determine which radio element it
* should be updating
*/
- public static function update($data) {
+ public static function update($data) {
// Verify the incoming data
- if (!$data['id']) {
+ if (!$data['id']) {
// FIXME: Untranslated
- Error::add('general','Missing ID');
- }
+ Error::add('general','Missing ID');
+ }
- if (!$data['name']) {
+ if (!$data['name']) {
// FIXME: Untranslated
- Error::add('general','Name Required');
- }
+ Error::add('general','Name Required');
+ }
- $allowed_array = array('https','http','mms','mmsh','mmsu','mmst','rtsp');
+ $allowed_array = array('https','http','mms','mmsh','mmsu','mmst','rtsp');
- $elements = explode(":",$data['url']);
-
- if (!in_array($elements['0'],$allowed_array)) {
+ $elements = explode(":",$data['url']);
+
+ if (!in_array($elements['0'],$allowed_array)) {
// FIXME: Untranslated
- Error::add('general','Invalid URL must be mms:// , https:// or http://');
- }
+ Error::add('general','Invalid URL must be mms:// , https:// or http://');
+ }
- if (Error::occurred()) {
- return false;
- }
+ if (Error::occurred()) {
+ return false;
+ }
// Setup the data
- $name = Dba::escape($data['name']);
- $site_url = Dba::escape($data['site_url']);
- $url = Dba::escape($data['url']);
- $frequency = Dba::escape($data['frequency']);
- $call_sign = Dba::escape($data['call_sign']);
- $id = Dba::escape($data['id']);
+ $name = Dba::escape($data['name']);
+ $site_url = Dba::escape($data['site_url']);
+ $url = Dba::escape($data['url']);
+ $frequency = Dba::escape($data['frequency']);
+ $call_sign = Dba::escape($data['call_sign']);
+ $id = Dba::escape($data['id']);
- $sql = "UPDATE `live_stream` SET `name`='$name',`site_url`='$site_url',`url`='$url'" .
- ",`frequency`='$frequency',`call_sign`='$call_sign' WHERE `id`='$id'";
- $db_results = Dba::write($sql);
+ $sql = "UPDATE `live_stream` SET `name`='$name',`site_url`='$site_url',`url`='$url'" .
+ ",`frequency`='$frequency',`call_sign`='$call_sign' WHERE `id`='$id'";
+ $db_results = Dba::write($sql);
- return $db_results;
+ return $db_results;
} // update
/**
* create
* This is a static function that takes a key'd array for input
- * and if everything is good creates the object.
+ * and if everything is good creates the object.
*/
- public static function create($data) {
+ public static function create($data) {
// Make sure we've got a name
- if (!strlen($data['name'])) {
+ if (!strlen($data['name'])) {
// FIXME: Untranslated
- Error::add('name','Name Required');
- }
+ Error::add('name','Name Required');
+ }
+
+ $allowed_array = array('https','http','mms','mmsh','mmsu','mmst','rtsp');
- $allowed_array = array('https','http','mms','mmsh','mmsu','mmst','rtsp');
+ $elements = explode(":",$data['url']);
- $elements = explode(":",$data['url']);
-
- if (!in_array($elements['0'],$allowed_array)) {
- Error::add('url','Invalid URL must be http:// or https://');
- }
+ if (!in_array($elements['0'],$allowed_array)) {
+ Error::add('url','Invalid URL must be http:// or https://');
+ }
// Make sure it's a real catalog
- $catalog = new Catalog($data['catalog']);
- if (!$catalog->name) {
+ $catalog = new Catalog($data['catalog']);
+ if (!$catalog->name) {
// FIXME: Untranslated
- Error::add('catalog','Invalid Catalog');
- }
+ Error::add('catalog','Invalid Catalog');
+ }
- if (Error::occurred()) { return false; }
+ if (Error::occurred()) { return false; }
// Clean up the input
- $name = Dba::escape($data['name']);
- $site_url = Dba::escape($data['site_url']);
- $url = Dba::escape($data['url']);
- $catalog = $catalog->id;
- $frequency = Dba::escape($data['frequency']);
- $call_sign = Dba::escape($data['call_sign']);
+ $name = Dba::escape($data['name']);
+ $site_url = Dba::escape($data['site_url']);
+ $url = Dba::escape($data['url']);
+ $catalog = $catalog->id;
+ $frequency = Dba::escape($data['frequency']);
+ $call_sign = Dba::escape($data['call_sign']);
// If we've made it this far everything must be ok... I hope
- $sql = "INSERT INTO `live_stream` (`name`,`site_url`,`url`,`catalog`,`frequency`,`call_sign`) " .
- "VALUES ('$name','$site_url','$url','$catalog','$frequency','$call_sign')";
- $db_results = Dba::write($sql);
+ $sql = "INSERT INTO `live_stream` (`name`,`site_url`,`url`,`catalog`,`frequency`,`call_sign`) " .
+ "VALUES ('$name','$site_url','$url','$catalog','$frequency','$call_sign')";
+ $db_results = Dba::write($sql);
- return $db_results;
+ return $db_results;
} // create
@@ -169,14 +169,14 @@ class Radio extends database_object implements media {
* delete
* This deletes the current object from the database
*/
- public function delete() {
+ public function delete() {
- $id = Dba::escape($this->id);
+ $id = Dba::escape($this->id);
- $sql = "DELETE FROM `live_stream` WHERE `id`='$id'";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `live_stream` WHERE `id`='$id'";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // delete
@@ -184,29 +184,29 @@ class Radio extends database_object implements media {
* native_stream
* This is needed by the media interface
*/
- public function native_stream() {
+ public function native_stream() {
- } // native_stream
+ } // native_stream
/**
* play_url
* This is needed by the media interface
*/
- public static function play_url($oid,$sid='',$force_http='') {
+ public static function play_url($oid,$sid='',$force_http='') {
+
+ $radio = new Radio($oid);
- $radio = new Radio($oid);
-
- return $radio->url;
+ return $radio->url;
- } // play_url
+ } // play_url
/**
* has_flag
* This is needed by the media interface
*/
- public function has_flag() {
+ public function has_flag() {
@@ -216,7 +216,7 @@ class Radio extends database_object implements media {
* stream_cmd
* Needed by the media interface
*/
- public function stream_cmd() {
+ public function stream_cmd() {
} // stream_cmd
diff --git a/lib/class/random.class.php b/lib/class/random.class.php
index eab6b3f9..582d00ac 100644
--- a/lib/class/random.class.php
+++ b/lib/class/random.class.php
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
@@ -30,17 +30,17 @@
class Random implements media {
public $type;
- public $id;
+ public $id;
/**
* Constructor
* nothing to see here, move along
*/
- public function __construct($id) {
+ public function __construct($id) {
- $this->type = Random::get_id_type($id);
- $this->id = intval($id);
+ $this->type = Random::get_id_type($id);
+ $this->id = intval($id);
} // constructor
@@ -48,14 +48,14 @@ class Random implements media {
* album
* This returns the ID of a random album, nothing special
*/
- public static function album() {
+ public static function album() {
- $sql = "SELECT `id` FROM `album` ORDER BY RAND() LIMIT 1";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id` FROM `album` ORDER BY RAND() LIMIT 1";
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
- return $results['id'];
+ return $results['id'];
} // album
@@ -63,14 +63,14 @@ class Random implements media {
* artist
* This returns the ID of a random artist, nothing special here for now
*/
- public static function artist() {
+ public static function artist() {
- $sql = "SELECT `id` FROM `artist` ORDER BY RAND() LIMIT 1";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id` FROM `artist` ORDER BY RAND() LIMIT 1";
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
- return $results['id'];
+ return $results['id'];
} // artist
@@ -79,16 +79,16 @@ class Random implements media {
* This returns a random Playlist with songs little bit of extra
* logic require
*/
- public static function playlist() {
+ public static function playlist() {
- $sql = "SELECT `playlist`.`id` FROM `playlist` LEFT JOIN `playlist_data` " .
- " ON `playlist`.`id`=`playlist_data`.`playlist` WHERE `playlist_data`.`object_id` IS NOT NULL " .
- " ORDER BY RAND()";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `playlist`.`id` FROM `playlist` LEFT JOIN `playlist_data` " .
+ " ON `playlist`.`id`=`playlist_data`.`playlist` WHERE `playlist_data`.`object_id` IS NOT NULL " .
+ " ORDER BY RAND()";
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
- return $results['id'];
+ return $results['id'];
} // playlist
@@ -97,38 +97,38 @@ class Random implements media {
* This generates a random play url based on the passed type
* and returns it
*/
- public static function play_url($id,$sid='',$force_http='') {
-
- if (!$type = self::get_id_type($id)) {
- return false;
- }
-
- $uid = $GLOBALS['user']->id;
-
+ public static function play_url($id,$sid='',$force_http='') {
+
+ if (!$type = self::get_id_type($id)) {
+ return false;
+ }
+
+ $uid = $GLOBALS['user']->id;
+
$url = Stream::get_base_url() . "random=1&type=$type&uid=$uid";
- return $url;
+ return $url;
- } // play_url
+ } // play_url
/**
* get_single_song
* This returns a single song pulled based on the passed random method
*/
- public static function get_single_song($type) {
+ public static function get_single_song($type) {
- if (!$type = self::validate_type($type)) {
- return false;
- }
+ if (!$type = self::validate_type($type)) {
+ return false;
+ }
+
+ $method_name = 'get_' . $type;
- $method_name = 'get_' . $type;
+ if (method_exists('Random',$method_name)) {
+ $song_ids = self::$method_name(1);
+ $song_id = array_pop($song_ids);
+ }
- if (method_exists('Random',$method_name)) {
- $song_ids = self::$method_name(1);
- $song_id = array_pop($song_ids);
- }
-
- return $song_id;
+ return $song_id;
} // get_single_song
@@ -136,19 +136,19 @@ class Random implements media {
* get_default
* This just randomly picks a song at whim from all catalogs
* nothing special here...
- */
- public static function get_default($limit) {
+ */
+ public static function get_default($limit) {
- $results = array();
+ $results = array();
- $sql = "SELECT `id` FROM `song` ORDER BY RAND() LIMIT $limit";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id` FROM `song` ORDER BY RAND() LIMIT $limit";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['id'];
- }
-
- return $results;
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
+
+ return $results;
} // get_default
@@ -157,24 +157,24 @@ class Random implements media {
* This looks at the last object played by the current user and
* then picks a song of the same genre at random...
*/
- public static function get_genre($limit) {
+ public static function get_genre($limit) {
- $results = array();
+ $results = array();
// Get the last genre played by us
- $data = $GLOBALS['user']->get_recently_played('1','genre');
- if ($data['0']) {
- $where_sql = " WHERE `genre`='" . $data['0'] . "' ";
- }
+ $data = $GLOBALS['user']->get_recently_played('1','genre');
+ if ($data['0']) {
+ $where_sql = " WHERE `genre`='" . $data['0'] . "' ";
+ }
- $sql = "SELECT `id` FROM `song` $where_sql ORDER BY RAND() LIMIT $limit";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id` FROM `song` $where_sql ORDER BY RAND() LIMIT $limit";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
- return $results;
+ return $results;
} // get_genre
@@ -183,24 +183,24 @@ class Random implements media {
* This looks at the last album played by the current user and
* picks something else in the same album
*/
- public static function get_album($limit) {
+ public static function get_album($limit) {
- $results = array();
+ $results = array();
// Get the last album playbed by us
- $data = $GLOBALS['user']->get_recently_played('1','album');
- if ($data['0']) {
+ $data = $GLOBALS['user']->get_recently_played('1','album');
+ if ($data['0']) {
$where_sql = " WHERE `album`='" . $data['0'] . "' ";
- }
+ }
- $sql = "SELECT `id` FROM `song` $where_sql ORDER BY RAND() LIMIT $limit";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `id` FROM `song` $where_sql ORDER BY RAND() LIMIT $limit";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
- return $results;
+ return $results;
} // get_album
@@ -209,59 +209,59 @@ class Random implements media {
* This looks at the last artist played and then randomly picks a song from the
* same artist
*/
- public static function get_artist($limit) {
+ public static function get_artist($limit) {
+
+ $results = array();
- $results = array();
+ $data = $GLOBALS['user']->get_recently_played('1','artist');
+ if ($data['0']) {
+ $where_sql = " WHERE `artist`='" . $data['0'] . "' ";
+ }
- $data = $GLOBALS['user']->get_recently_played('1','artist');
- if ($data['0']) {
- $where_sql = " WHERE `artist`='" . $data['0'] . "' ";
- }
+ $sql = "SELECT `id` FROM `song` $where_sql ORDER BY RAND() LIMIT $limit";
+ $db_results = Dba::read($sql);
- $sql = "SELECT `id` FROM `song` $where_sql ORDER BY RAND() LIMIT $limit";
- $db_results = Dba::read($sql);
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['id'];
- }
-
- return $results;
+ return $results;
} // get_artist
/**
* advanced
- * This processes the results of a post from a form and returns an
- * array of song items that were returned from said randomness
+ * This processes the results of a post from a form and returns an
+ * array of song items that were returned from said randomness
*/
- public static function advanced($data) {
+ public static function advanced($data) {
/* Figure out our object limit */
- $limit = intval($data['random']);
+ $limit = intval($data['random']);
// Generate our matchlist
if ($data['catalog'] != '-1') {
- $matchlist['catalog'] = $data['catalog'];
+ $matchlist['catalog'] = $data['catalog'];
}
- if ($data['genre'][0] != '-1') {
- $matchlist['genre'] = $data['genre'];
- }
-
+ if ($data['genre'][0] != '-1') {
+ $matchlist['genre'] = $data['genre'];
+ }
+
/* If they've passed -1 as limit then don't get everything */
if ($data['random'] == "-1") { unset($data['random']); }
else { $limit_sql = "LIMIT " . Dba::escape($limit); }
$where = "1=1 ";
- if (is_array($matchlist)) {
+ if (is_array($matchlist)) {
foreach ($matchlist as $type => $value) {
if (is_array($value)) {
foreach ($value as $v) {
- if (!strlen($v)) { continue; }
+ if (!strlen($v)) { continue; }
$v = Dba::escape($v);
if ($v != $value[0]) { $where .= " OR $type='$v' "; }
else { $where .= " AND ( $type='$v'"; }
}
- $where .= ")";
+ $where .= ")";
}
elseif (strlen($value)) {
$value = Dba::escape($value);
@@ -269,10 +269,10 @@ class Random implements media {
}
} // end foreach
} // end if matchlist
-
- switch ($data['random_type']) {
- case 'full_album':
- $query = "SELECT `album`.`id` FROM `song` INNER JOIN `album` ON `song`.`album`=`album`.`id` " .
+
+ switch ($data['random_type']) {
+ case 'full_album':
+ $query = "SELECT `album`.`id` FROM `song` INNER JOIN `album` ON `song`.`album`=`album`.`id` " .
"WHERE $where GROUP BY `song`.`album` ORDER BY RAND() $limit_sql";
$db_results = Dba::read($query);
while ($row = Dba::fetch_assoc($db_results)) {
@@ -280,9 +280,9 @@ class Random implements media {
}
$albums_where = ltrim($albums_where," OR");
$sql = "SELECT `song`.`id`,`song`.`size`,`song`.`time` FROM `song` WHERE $albums_where ORDER BY `song`.`album`,`song`.`track` ASC";
- break;
- case 'full_artist':
- $query = "SELECT `artist`.`id` FROM `song` INNER JOIN `artist` ON `song`.`artist`=`artist`.`id` " .
+ break;
+ case 'full_artist':
+ $query = "SELECT `artist`.`id` FROM `song` INNER JOIN `artist` ON `song`.`artist`=`artist`.`id` " .
"WHERE $where GROUP BY `song`.`artist` ORDER BY RAND() $limit_sql";
$db_results = Dba::read($query);
while ($row = Dba::fetch_row($db_results)) {
@@ -291,114 +291,114 @@ class Random implements media {
$artists_where = ltrim($artists_where," OR");
$sql = "SELECT song.id,song.size,song.time FROM song WHERE $artists_where ORDER BY RAND()";
break;
- case 'unplayed':
- $uid = Dba::escape($GLOBALS['user']->id);
+ case 'unplayed':
+ $uid = Dba::escape($GLOBALS['user']->id);
$sql = "SELECT object_id,COUNT(`id`) AS `total` FROM `object_count` WHERE `user`='$uid' GROUP BY `object_id`";
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
$in_sql = "`id` IN (";
- while ($row = Dba::fetch_assoc($db_results)) {
- $row['object_id'] = Dba::escape($row['object_id']);
- $in_sql .= "'" . $row['object_id'] . "',";
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $row['object_id'] = Dba::escape($row['object_id']);
+ $in_sql .= "'" . $row['object_id'] . "',";
+ }
$in_sql = rtrim($in_sql,',') . ')';
$sql = "SELECT song.id,song.size,song.time FROM song " .
"WHERE ($where) AND $in_sql ORDER BY RAND() $limit_sql";
- break;
- case 'high_rating':
- $sql = "SELECT `rating`.`object_id`,`rating`.`rating` FROM `rating` " .
- "WHERE `rating`.`object_type`='song' ORDER BY `rating` DESC";
- $db_results = Dba::read($sql);
+ break;
+ case 'high_rating':
+ $sql = "SELECT `rating`.`object_id`,`rating`.`rating` FROM `rating` " .
+ "WHERE `rating`.`object_type`='song' ORDER BY `rating` DESC";
+ $db_results = Dba::read($sql);
// Get all of the ratings for songs
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[$row['object_id']][] = $row['rating'];
- }
- // Calculate the averages
- foreach ($results as $key=>$rating_array) {
- $average = intval(array_sum($rating_array) / count($rating_array));
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[$row['object_id']][] = $row['rating'];
+ }
+ // Calculate the averages
+ foreach ($results as $key=>$rating_array) {
+ $average = intval(array_sum($rating_array) / count($rating_array));
// We have to do this because array_slice doesn't maintain indexes
- $new_key = $average . $key;
+ $new_key = $average . $key;
$ratings[$new_key] = $key;
- }
+ }
// Sort it by the value and slice at $limit * 2 so we have a little bit of randomness
- krsort($ratings);
- $ratings = array_slice($ratings,0,$limit*2);
-
- $in_sql = "`song`.`id` IN (";
-
+ krsort($ratings);
+ $ratings = array_slice($ratings,0,$limit*2);
+
+ $in_sql = "`song`.`id` IN (";
+
// Build the IN query, cause if you're OUT it ain't cool
- foreach ($ratings as $song_id) {
+ foreach ($ratings as $song_id) {
$key = Dba::escape($song_id);
- $in_sql .= "'$key',";
- }
+ $in_sql .= "'$key',";
+ }
- $in_sql = rtrim($in_sql,',') . ')';
+ $in_sql = rtrim($in_sql,',') . ')';
// Apply true limit and order by rand
- $sql = "SELECT song.id,song.size,song.time FROM song " .
- "WHERE ($where) AND $in_sql ORDER BY RAND() $limit_sql";
+ $sql = "SELECT song.id,song.size,song.time FROM song " .
+ "WHERE ($where) AND $in_sql ORDER BY RAND() $limit_sql";
break;
- default:
- $sql = "SELECT `id`,`size`,`time` FROM `song` WHERE $where ORDER BY RAND() $limit_sql";
+ default:
+ $sql = "SELECT `id`,`size`,`time` FROM `song` WHERE $where ORDER BY RAND() $limit_sql";
break;
- } // end switch on type of random play
+ } // end switch on type of random play
// Run the query generated above so we can while it
- $db_results = Dba::read($sql);
- $results = array();
+ $db_results = Dba::read($sql);
+ $results = array();
+
+ while ($row = Dba::fetch_assoc($db_results)) {
- while ($row = Dba::fetch_assoc($db_results)) {
-
// If size limit is specified
- if ($data['size_limit']) {
+ if ($data['size_limit']) {
// Convert
- $new_size = ($row['size'] / 1024) / 1024;
-
+ $new_size = ($row['size'] / 1024) / 1024;
+
// Only fuzzy 10 times
- if ($fuzzy_size > 10) { return $results; }
+ if ($fuzzy_size > 10) { return $results; }
// Add and check, skip if over don't return incase theres a smaller one commin round
- if (($size_total + $new_size) > $data['size_limit']) { $fuzzy_size++; continue; }
-
- $size_total = $size_total + $new_size;
- $results[] = $row['id'];
+ if (($size_total + $new_size) > $data['size_limit']) { $fuzzy_size++; continue; }
+
+ $size_total = $size_total + $new_size;
+ $results[] = $row['id'];
// If we are within 4mb of target then jump ship
- if (($data['size_limit'] - floor($size_total)) < 4) { return $results; }
+ if (($data['size_limit'] - floor($size_total)) < 4) { return $results; }
} // if size_limit
// If length really does matter
- if ($data['length']) {
+ if ($data['length']) {
// base on min, seconds are for chumps and chumpettes
- $new_time = floor($row['time'] / 60);
+ $new_time = floor($row['time'] / 60);
+
+ if ($fuzzy_time > 10) { return $results; }
- if ($fuzzy_time > 10) { return $results; }
-
// If the new one would go voer skip!
- if (($time_total + $new_time) > $data['length']) { $fuzzy_time++; continue; }
+ if (($time_total + $new_time) > $data['length']) { $fuzzy_time++; continue; }
- $time_total = $time_total + $new_time;
- $results[] = $row['id'];
+ $time_total = $time_total + $new_time;
+ $results[] = $row['id'];
- // If there are less then 2 min of free space return
- if (($data['length'] - $time_total) < 2) { return $results; }
+ // If there are less then 2 min of free space return
+ if (($data['length'] - $time_total) < 2) { return $results; }
- } // if length does matter
+ } // if length does matter
- if (!$data['size_limit'] AND !$data['length']) {
- $results[] = $row['id'];
- }
+ if (!$data['size_limit'] AND !$data['length']) {
+ $results[] = $row['id'];
+ }
} // end while results
- return $results;
+ return $results;
} // advanced
@@ -406,22 +406,22 @@ class Random implements media {
* get_type_name
* This returns a 'purrty' name for the differnt random types
*/
- public static function get_type_name($type) {
+ public static function get_type_name($type) {
- switch ($type) {
+ switch ($type) {
case 'album':
- return _('Related Album');
+ return _('Related Album');
break;
- case 'genre':
- return _('Related Genre');
+ case 'genre':
+ return _('Related Genre');
break;
- case 'artist':
- return _('Related Artist');
+ case 'artist':
+ return _('Related Artist');
break;
- default:
- return _('Pure Random');
+ default:
+ return _('Pure Random');
break;
- } // end switch
+ } // end switch
} // get_type_name
@@ -431,22 +431,22 @@ class Random implements media {
* MOTHER OF PEARL THIS MAKES BABY JESUS CRY
* HACK HACK HACK HACK HACK HACK HACK HACK
*/
- public static function get_type_id($type) {
-
- switch ($type) {
- case 'album':
- return '1';
- break;
- case 'artist':
- return '2';
- break;
- case 'tag':
- return '3';
- break;
- default:
- return '4';
- break;
- }
+ public static function get_type_id($type) {
+
+ switch ($type) {
+ case 'album':
+ return '1';
+ break;
+ case 'artist':
+ return '2';
+ break;
+ case 'tag':
+ return '3';
+ break;
+ default:
+ return '4';
+ break;
+ }
} // get_type_id
@@ -454,24 +454,24 @@ class Random implements media {
* get_id_name
* This takes an ID and returns the 'name' of the random dealie
* HACK HACK HACK HACK HACK HACK HACK
- * Can you tell I don't like this code?
+ * Can you tell I don't like this code?
*/
- public static function get_id_type($id) {
+ public static function get_id_type($id) {
- switch ($id) {
- case '1':
+ switch ($id) {
+ case '1':
return 'album';
break;
- case '2':
+ case '2':
return 'artist';
- break;
- case '3':
+ break;
+ case '3':
return 'tag';
- break;
- default:
- return 'default';
- break;
- } // end switch
+ break;
+ default:
+ return 'default';
+ break;
+ } // end switch
} // get_id_name
@@ -479,7 +479,7 @@ class Random implements media {
* validiate_type
* this validates the random type
*/
- public static function validate_type($type) {
+ public static function validate_type($type) {
switch ($type) {
case 'default':
@@ -487,19 +487,19 @@ class Random implements media {
case 'album':
case 'artist':
case 'rated':
- return $type;
+ return $type;
break;
default:
return 'default';
break;
} // end switch
-
- return $type;
+
+ return $type;
} // validate_type
- public function native_stream() { }
- public function stream_cmd() { }
+ public function native_stream() { }
+ public function stream_cmd() { }
public function has_flag() { }
public function format() { }
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index f5af5519..5c2bb3e9 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -23,7 +23,7 @@
/**
* Rating class
* This is an amalgamation(sp?) of code from SoundOfEmotion
- * to track ratings for songs, albums and artists.
+ * to track ratings for songs, albums and artists.
*/
class Rating extends database_object {
@@ -40,21 +40,21 @@ class Rating extends database_object {
* This is run every time a new object is created, it requires
* the id and type of object that we need to pull the raiting for
*/
- public function __construct($id,$type) {
+ public function __construct($id,$type) {
$this->id = intval($id);
$this->type = Dba::escape($type);
// Check for the users rating
- if ($rating = $this->get_user($GLOBALS['user']->id)) {
+ if ($rating = $this->get_user($GLOBALS['user']->id)) {
$this->rating = $rating;
$this->preciserating = $rating;
- }
- else {
+ }
+ else {
$this->get_average();
}
-
- return true;
+
+ return true;
} // Constructor
@@ -65,44 +65,44 @@ class Rating extends database_object {
* //FIXME: Improve logic so that misses get cached as average
*/
public static function build_cache($type, $ids) {
-
+
if (!is_array($ids) OR !count($ids)) { return false; }
- $user_id = Dba::escape($GLOBALS['user']->id);
+ $user_id = Dba::escape($GLOBALS['user']->id);
$idlist = '(' . implode(',', $ids) . ')';
- $sql = "SELECT `rating`, `object_id`,`rating`.`rating` FROM `rating` WHERE `user`='$user_id' AND `object_id` IN $idlist " .
+ $sql = "SELECT `rating`, `object_id`,`rating`.`rating` FROM `rating` WHERE `user`='$user_id' AND `object_id` IN $idlist " .
"AND `object_type`='$type'";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
- $user[$row['object_id']] = $row['rating'];
+ $user[$row['object_id']] = $row['rating'];
}
-
- $sql = "SELECT `rating`,`object_id` FROM `rating` WHERE `object_id` IN $idlist AND `object_type`='$type'";
- $db_results = Dba::read($sql);
-
- while ($row = Dba::fetch_assoc($db_results)) {
- $rating[$row['object_id']]['rating'] += $row['rating'];
- $rating[$row['object_id']]['total']++;
- }
-
- foreach ($ids as $id) {
- parent::add_to_cache('rating_' . $type . '_user',$id,intval($user[$id]));
+
+ $sql = "SELECT `rating`,`object_id` FROM `rating` WHERE `object_id` IN $idlist AND `object_type`='$type'";
+ $db_results = Dba::read($sql);
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $rating[$row['object_id']]['rating'] += $row['rating'];
+ $rating[$row['object_id']]['total']++;
+ }
+
+ foreach ($ids as $id) {
+ parent::add_to_cache('rating_' . $type . '_user',$id,intval($user[$id]));
// Do the bit of math required to store this
- if (!isset($rating[$id])) {
- $entry = array('average'=>'0','percise'=>'0');
- }
- else {
- $average = round($rating[$id]['rating']/$rating[$id]['total'],1);
- $entry = array('average'=>floor($average),'percise'=>$average);
- }
-
- parent::add_to_cache('rating_' . $type . '_all',$id,$entry);
- }
-
- return true;
+ if (!isset($rating[$id])) {
+ $entry = array('average'=>'0','percise'=>'0');
+ }
+ else {
+ $average = round($rating[$id]['rating']/$rating[$id]['total'],1);
+ $entry = array('average'=>floor($average),'percise'=>$average);
+ }
+
+ parent::add_to_cache('rating_' . $type . '_all',$id,$entry);
+ }
+
+ return true;
} // build_cache
@@ -112,22 +112,22 @@ class Rating extends database_object {
* in user. It returns the value
*/
public function get_user($user_id) {
-
- $id = intval($this->id);
-
- if (parent::is_cached('rating_' . $this->type . '_user',$id)) {
- return parent::get_from_cache('rating_' . $this->type . '_user',$id);
- }
- $user_id = Dba::escape($user_id);
+ $id = intval($this->id);
+
+ if (parent::is_cached('rating_' . $this->type . '_user',$id)) {
+ return parent::get_from_cache('rating_' . $this->type . '_user',$id);
+ }
+
+ $user_id = Dba::escape($user_id);
$sql = "SELECT `rating` FROM `rating` WHERE `user`='$user_id' AND `object_id`='$id' AND `object_type`='$this->type'";
$db_results = Dba::read($sql);
-
+
$results = Dba::fetch_assoc($db_results);
- parent::add_to_cache('rating_' . $this->type . '_user',$id,$results['rating']);
-
+ parent::add_to_cache('rating_' . $this->type . '_user',$id,$results['rating']);
+
return $results['rating'];
} // get_user
@@ -136,79 +136,79 @@ class Rating extends database_object {
* get_average
* Get the users average rating this is based off the floor'd average
* of what everyone has rated this album as. This is shown if there
- * is no personal rating, and used for random play mojo. It sets
+ * is no personal rating, and used for random play mojo. It sets
* $this->average_rating and returns the value
*/
- public function get_average() {
+ public function get_average() {
- $id = intval($this->id);
+ $id = intval($this->id);
- if (parent::is_cached('rating_' . $this->type . '_all',$id)) {
- $data = parent::get_from_cache('rating_' . $this->type . '_user',$id);
- $this->rating = $data['rating'];
- $this->perciserating = $data['percise'];
- return true;
- }
+ if (parent::is_cached('rating_' . $this->type . '_all',$id)) {
+ $data = parent::get_from_cache('rating_' . $this->type . '_user',$id);
+ $this->rating = $data['rating'];
+ $this->perciserating = $data['percise'];
+ return true;
+ }
$sql = "SELECT `rating` FROM `rating` WHERE `object_id`='$id' AND `object_type`='$this->type'";
$db_results = Dba::read($sql);
$i = 0;
- while ($r = Dba::fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$i++;
$total += $r['rating'];
} // while we're pulling results
- if ($total > 0) {
+ if ($total > 0) {
$average = round($total/$i, 1);
}
- elseif ($i >= '1' AND $total == '0') {
+ elseif ($i >= '1' AND $total == '0') {
$average = -1;
}
- else {
+ else {
$average = 0;
}
-
+
$this->preciserating = $average;
$this->rating = floor($average);
-
+
return $this->rating;
} // get_average
/**
* set_rating
- * This function sets a rating for the current $this object.
+ * This function sets a rating for the current $this object.
* This uses the currently logged in user for the 'user' who is rating
* the object. Returns true on success, false on failure
*/
- public function set_rating($score) {
-
+ public function set_rating($score) {
+
$score = Dba::escape($score);
// If score is -1, then remove rating
if ($score == '-1') {
- $sql = "DELETE FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type' " .
+ $sql = "DELETE FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type' " .
"AND `user`='" . Dba::escape($GLOBALS['user']->id) . "'";
$db_results = Dba::read($sql);
return true;
}
/* Check if it exists */
- $sql = "SELECT `id` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type' " .
+ $sql = "SELECT `id` FROM `rating` WHERE `object_id`='$this->id' AND `object_type`='$this->type' " .
"AND `user`='" . Dba::escape($GLOBALS['user']->id) . "'";
$db_results = Dba::read($sql);
- if ($existing = Dba::fetch_assoc($db_results)) {
+ if ($existing = Dba::fetch_assoc($db_results)) {
$sql = "UPDATE `rating` SET `rating`='$score' WHERE `id`='" . $existing['id'] . "'";
$db_results = Dba::write($sql);
}
- else {
- $sql = "INSERT INTO `rating` (`object_id`,`object_type`,`rating`,`user`) VALUES " .
+ else {
+ $sql = "INSERT INTO `rating` (`object_id`,`object_type`,`rating`,`user`) VALUES " .
" ('$this->id','$this->type','$score','" . $GLOBALS['user']->id . "')";
$db_results = Dba::write($sql);
- }
+ }
return true;
@@ -216,31 +216,31 @@ class Rating extends database_object {
/**
* show
- * This takes an id and a type and displays the rating if ratings are enabled.
+ * This takes an id and a type and displays the rating if ratings are enabled.
*/
- public static function show ($object_id,$type) {
+ public static function show ($object_id,$type) {
// If there aren't ratings don't return anything
- if (!Config::get('ratings')) { return false; }
+ if (!Config::get('ratings')) { return false; }
- $rating = new Rating($object_id,$type);
+ $rating = new Rating($object_id,$type);
- require Config::get('prefix') . '/templates/show_object_rating.inc.php';
+ require Config::get('prefix') . '/templates/show_object_rating.inc.php';
- } // show
+ } // show
/**
* show_static
- * This is a static version of the ratings created by Andy90
+ * This is a static version of the ratings created by Andy90
*/
- public static function show_static ($object_id,$type) {
+ public static function show_static ($object_id,$type) {
// If there aren't ratings don't return anything
- if (!Config::get('ratings')) { return false; }
+ if (!Config::get('ratings')) { return false; }
- $rating = new Rating($object_id,$type);
+ $rating = new Rating($object_id,$type);
- require Config::get('prefix') . '/templates/show_static_object_rating.inc.php';
+ require Config::get('prefix') . '/templates/show_static_object_rating.inc.php';
} // show_static
diff --git a/lib/class/registration.class.php b/lib/class/registration.class.php
index 30987011..ae85670d 100644
--- a/lib/class/registration.class.php
+++ b/lib/class/registration.class.php
@@ -30,7 +30,7 @@ class Registration {
* constructor
* This is what is called when the class is loaded
*/
- public function __construct() {
+ public function __construct() {
// Rien a faire
@@ -40,7 +40,7 @@ class Registration {
* send_confirmation
* This sends the confirmation e-mail for the specified user
*/
- public static function send_confirmation($username,$fullname,$email,$password,$validation) {
+ public static function send_confirmation($username,$fullname,$email,$password,$validation) {
// Multi-byte Character Mail
if(function_exists('mb_language')) {
@@ -76,7 +76,7 @@ Password: %s
Your account is currently inactive. You cannot use it until you've visited the following link:
-%s
+%s
Thank you for registering
"), $username, $password, Config::get('web_path') . "/register.php?action=validate&username=$username&auth=$validation");
@@ -96,7 +96,7 @@ Thank you for registering
}
// Check to see if the admin should be notified
- if (Config::get('admin_notify_reg')) {
+ if (Config::get('admin_notify_reg')) {
$body = sprintf(_("A new user has registered
The following values were entered.
@@ -113,11 +113,11 @@ E-mail: %s
implode("\n", $additional_header),
'-f'.Config::get('mail_from'));
} else {
- mail(Config::get('mail_from'),$subject,$body,implode("\r\n", $additional_header),'-f'.Config::get('mail_from'));
+ mail(Config::get('mail_from'),$subject,$body,implode("\r\n", $additional_header),'-f'.Config::get('mail_from'));
}
- }
-
- return true;
+ }
+
+ return true;
} // send_confirmation
@@ -125,11 +125,11 @@ E-mail: %s
* show_agreement
* This shows the registration agreement, /config/registration_agreement.php
*/
- public static function show_agreement() {
+ public static function show_agreement() {
$filename = Config::get('prefix') . '/config/registration_agreement.php';
- if (!file_exists($filename)) { return false; }
+ if (!file_exists($filename)) { return false; }
/* Check for existance */
$fp = fopen($filename,'r');
diff --git a/lib/class/scrobbler.class.php b/lib/class/scrobbler.class.php
index ee1ae8a2..537b1490 100644
--- a/lib/class/scrobbler.class.php
+++ b/lib/class/scrobbler.class.php
@@ -30,7 +30,7 @@ class scrobbler {
public $submit_port;
public $submit_url;
public $queued_tracks;
- public $reset_handshake = false;
+ public $reset_handshake = false;
public $scrobble_host = 'post.audioscrobbler.com';
/**
@@ -43,11 +43,11 @@ class scrobbler {
$this->username = trim($username);
$this->password = trim($password);
$this->challenge = $challenge;
- $this->submit_host = $host;
- $this->submit_port = $port;
- $this->submit_url = $url;
+ $this->submit_host = $host;
+ $this->submit_port = $port;
+ $this->submit_url = $url;
$this->queued_tracks = array();
- if ($scrobble_host) { $this->scrobble_host = $scrobble_host; }
+ if ($scrobble_host) { $this->scrobble_host = $scrobble_host; }
} // scrobbler
@@ -71,8 +71,8 @@ class scrobbler {
/**
* handshake
- * This does a handshake with the audioscrobber server it doesn't pass the password, but
- * it does pass the username and has a 10 second timeout
+ * This does a handshake with the audioscrobber server it doesn't pass the password, but
+ * it does pass the username and has a 10 second timeout
*/
public function handshake() {
@@ -83,11 +83,11 @@ class scrobbler {
}
$username = rawurlencode($this->username);
- $timestamp = time();
- $auth_token = rawurlencode(md5($this->password . $timestamp));
-
+ $timestamp = time();
+ $auth_token = rawurlencode(md5($this->password . $timestamp));
+
$get_string = "GET /?hs=true&p=1.2&c=apa&v=0.1&u=$username&t=$timestamp&a=$auth_token HTTP/1.1\r\n";
-
+
fwrite($as_socket, $get_string);
fwrite($as_socket, "Host: $this->scrobble_host\r\n");
fwrite($as_socket, "Accept: */*\r\n\r\n");
@@ -111,23 +111,23 @@ class scrobbler {
$this->error_msg = 'Invalid Username';
return false;
}
- if(substr($response[0],0,7) == 'BADTIME') {
- $this->error_msg = 'Your time is too far off from the server, or your PHP timezone is incorrect';
- return false;
- }
+ if(substr($response[0],0,7) == 'BADTIME') {
+ $this->error_msg = 'Your time is too far off from the server, or your PHP timezone is incorrect';
+ return false;
+ }
if(substr($response[0], 0, 6) == 'UPDATE') {
$this->error_msg = 'You need to update your client: '.substr($response[0], 7);
return false;
}
if(preg_match('/http:\/\/([^\/]+)\/(.*)$/', $response[3], $matches)) {
- $host_parts = explode(":",$matches[1]);
+ $host_parts = explode(":",$matches[1]);
$data['submit_host'] = $host_parts[0];
- $data['submit_port'] = $host_parts[1] ? $host_parts[1] : '80';
+ $data['submit_port'] = $host_parts[1] ? $host_parts[1] : '80';
$data['submit_url'] = '/' . $matches[2];
} else {
- $this->error_msg = "Invalid POST URL returned, unable to continue. Sent:\n$get_string\n----\nReceived:\n" . $buffer .
- "\n---------\nExpeceted:" . print_r($response,1);
+ $this->error_msg = "Invalid POST URL returned, unable to continue. Sent:\n$get_string\n----\nReceived:\n" . $buffer .
+ "\n---------\nExpeceted:" . print_r($response,1);
return false;
}
@@ -137,36 +137,36 @@ class scrobbler {
} // handshake
/**
- * queue_track
+ * queue_track
* This queues the LastFM track by storing it in this object, it doesn't actually
* submit the track or talk to LastFM in anyway, kind of useless for our uses but its
- * here, and that's how it is.
+ * here, and that's how it is.
*/
public function queue_track($artist, $album, $title, $timestamp, $length,$track) {
if ($length < 30) {
debug_event('Scrobbler',"Not queuing track, too short",'5');
return false;
- }
+ }
$newtrack = array();
$newtrack['artist'] = $artist;
$newtrack['album'] = $album;
- $newtrack['title'] = $title;
+ $newtrack['title'] = $title;
$newtrack['track'] = $track;
$newtrack['length'] = $length;
$newtrack['time'] = $timestamp;
$this->queued_tracks[$timestamp] = $newtrack;
- return true;
-
+ return true;
+
} // queue_track
/**
* submit_tracks
* This actually talks to LastFM submiting the tracks that are queued up. It
* passed the md5'd password combinted with the challenge, which is then md5'd
- */
+ */
public function submit_tracks() {
// Check and make sure that we've got some queued tracks
@@ -176,7 +176,7 @@ class scrobbler {
}
//sort array by timestamp
- ksort($this->queued_tracks);
+ ksort($this->queued_tracks);
// build the query string
$query_str = 's='.rawurlencode($this->challenge).'&';
@@ -186,20 +186,20 @@ class scrobbler {
foreach($this->queued_tracks as $track) {
$query_str .= "a[$i]=".rawurlencode($track['artist'])."&t[$i]=".rawurlencode($track['title'])."&b[$i]=".rawurlencode($track['album'])."&";
$query_str .= "m[$i]=&l[$i]=".rawurlencode($track['length'])."&i[$i]=".rawurlencode($track['time'])."&";
- $query_str .= "n[$i]=" . rawurlencode($track['track']) . "&o[$i]=P&r[$i]=&";
+ $query_str .= "n[$i]=" . rawurlencode($track['track']) . "&o[$i]=P&r[$i]=&";
$i++;
}
- if (!trim($this->submit_host) || !$this->submit_port) {
- $this->reset_handshake = true;
- return false;
- }
+ if (!trim($this->submit_host) || !$this->submit_port) {
+ $this->reset_handshake = true;
+ return false;
+ }
$as_socket = fsockopen($this->submit_host, intval($this->submit_port), $errno, $errstr, 2);
if(!$as_socket) {
$this->error_msg = $errstr;
- $this->reset_handshake = true;
+ $this->reset_handshake = true;
return false;
}
@@ -212,7 +212,7 @@ class scrobbler {
fwrite($as_socket, "Content-length: ".strlen($query_str)."\r\n\r\n");
fwrite($as_socket, $query_str."\r\n\r\n");
-
+
$buffer = '';
while(!feof($as_socket)) {
$buffer .= fread($as_socket, 8192);
@@ -222,34 +222,34 @@ class scrobbler {
$split_response = preg_split("/\r\n\r\n/", $buffer);
if(!isset($split_response[1])) {
$this->error_msg = 'Did not receive a valid response';
- $this->reset_handshake = true;
+ $this->reset_handshake = true;
return false;
}
$response = explode("\n", $split_response[1]);
if(!isset($response[0])) {
$this->error_msg = 'Unknown error submitting tracks'.
"\nDebug output:\n".$buffer;
- $this->reset_handshake = true;
+ $this->reset_handshake = true;
return false;
}
if(substr($response[0], 0, 6) == 'FAILED') {
$this->error_msg = $response[0];
- $this->reset_handshake = true;
+ $this->reset_handshake = true;
return false;
}
if(substr($response[0], 0, 7) == 'BADAUTH') {
$this->error_msg = 'Invalid username/password (' . $response[0] . ')';
return false;
}
- if (substr($response[0],0,10) == 'BADSESSION') {
- $this->error_msg = 'Invalid Session passed (' . trim($response[0]) . ')';
- $this->reset_handshake = true;
- return false;
- }
+ if (substr($response[0],0,10) == 'BADSESSION') {
+ $this->error_msg = 'Invalid Session passed (' . trim($response[0]) . ')';
+ $this->reset_handshake = true;
+ return false;
+ }
if(substr($response[0], 0, 2) != 'OK') {
$this->error_msg = 'Response Not ok, unknown error'.
"\nDebug output:\n".$buffer;
- $this->reset_handshake = true;
+ $this->reset_handshake = true;
return false;
}
diff --git a/lib/class/shoutbox.class.php b/lib/class/shoutbox.class.php
index 2de151d4..6c1bf145 100644
--- a/lib/class/shoutbox.class.php
+++ b/lib/class/shoutbox.class.php
@@ -22,19 +22,19 @@
class shoutBox {
- public $id;
+ public $id;
/**
* Constructor
* This pulls the shoutbox information from the database and returns
* a constructed object, uses user_shout table
*/
- public function __construct($shout_id) {
+ public function __construct($shout_id) {
// Load the data from the database
$this->_get_info($shout_id);
- return true;
+ return true;
} // Constructor
@@ -42,48 +42,48 @@ class shoutBox {
* _get_info
* does the db call, reads from the user_shout table
*/
- private function _get_info($shout_id) {
+ private function _get_info($shout_id) {
- $sticky_id = Dba::escape($shout_id);
+ $sticky_id = Dba::escape($shout_id);
- $sql = "SELECT * FROM `user_shout` WHERE `id`='$shout_id'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `user_shout` WHERE `id`='$shout_id'";
+ $db_results = Dba::read($sql);
- $data = Dba::fetch_assoc($db_results);
+ $data = Dba::fetch_assoc($db_results);
- foreach ($data as $key=>$value) {
- $this->$key = $value;
- }
+ foreach ($data as $key=>$value) {
+ $this->$key = $value;
+ }
- return true;
+ return true;
} // _get_info
/**
- * get_top
+ * get_top
* This returns the top user_shouts, shoutbox objects are always shown regardless and count against the total
* number of objects shown
*/
- public static function get_top($limit) {
+ public static function get_top($limit) {
- $shouts = self::get_sticky();
+ $shouts = self::get_sticky();
// If we've already got too many stop here
- if (count($shouts) > $limit) {
- $shouts = array_slice($shouts,0,$limit);
- return $shouts;
- }
+ if (count($shouts) > $limit) {
+ $shouts = array_slice($shouts,0,$limit);
+ return $shouts;
+ }
// Only get as many as we need
- $limit = intval($limit) - count($shouts);
- $sql = "SELECT * FROM `user_shout` WHERE `sticky`='0' ORDER BY `date` DESC LIMIT $limit";
- $db_results = Dba::read($sql);
+ $limit = intval($limit) - count($shouts);
+ $sql = "SELECT * FROM `user_shout` WHERE `sticky`='0' ORDER BY `date` DESC LIMIT $limit";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- $shouts[] = $row['id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $shouts[] = $row['id'];
+ }
- return $shouts;
+ return $shouts;
} // get_top
@@ -91,18 +91,18 @@ class shoutBox {
* get_sticky
* This returns all current sticky shoutbox items
*/
- public static function get_sticky() {
+ public static function get_sticky() {
- $sql = "SELECT * FROM `user_shout` WHERE `sticky`='1' ORDER BY `date` DESC";
+ $sql = "SELECT * FROM `user_shout` WHERE `sticky`='1' ORDER BY `date` DESC";
$db_results = Dba::read($sql);
- $results = array();
+ $results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['id'];
+ }
- return $results;
+ return $results;
} // get_sticky
@@ -110,67 +110,67 @@ class shoutBox {
* get_object
* This takes a type and an ID and returns a created object
*/
- public static function get_object($type,$object_id) {
+ public static function get_object($type,$object_id) {
- $allowed_objects = array('song','genre','album','artist','radio');
+ $allowed_objects = array('song','genre','album','artist','radio');
- if (!in_array($type,$allowed_objects)) {
- return false;
- }
+ if (!in_array($type,$allowed_objects)) {
+ return false;
+ }
- $object = new $type($object_id);
+ $object = new $type($object_id);
- return $object;
+ return $object;
} // get_object
/**
* get_image
- * This returns an image tag if the type of object we're currently rolling with
+ * This returns an image tag if the type of object we're currently rolling with
* has an image assoicated with it
*/
- public function get_image() {
+ public function get_image() {
- switch ($this->object_type) {
- case 'album':
- $image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . Config::get('web_path') . "/image.php?id=" . $this->object_id . "&amp;thumb=1\" />";
- break;
- case 'artist':
+ switch ($this->object_type) {
+ case 'album':
+ $image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . Config::get('web_path') . "/image.php?id=" . $this->object_id . "&amp;thumb=1\" />";
+ break;
+ case 'artist':
break;
- case 'song':
- $song = new Song($this->object_id);
- $image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . Config::get('web_path') . "/image.php?id=" . $song->album . "&amp;thumb=1\" />";
+ case 'song':
+ $song = new Song($this->object_id);
+ $image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . Config::get('web_path') . "/image.php?id=" . $song->album . "&amp;thumb=1\" />";
break;
- default:
+ default:
// Rien a faire
- break;
+ break;
} // end switch
- return $image_string;
+ return $image_string;
} // get_image
/**
* create
- * This takes a key'd array of data as input and inserts a new shoutbox entry, it returns the auto_inc id
+ * This takes a key'd array of data as input and inserts a new shoutbox entry, it returns the auto_inc id
*/
- public static function create($data) {
+ public static function create($data) {
- $user = Dba::escape($GLOBALS['user']->id);
- $text = Dba::escape(strip_tags($data['comment']));
- $date = time();
- $sticky = make_bool($data['sticky']);
- $object_id = Dba::escape($data['object_id']);
- $object_type = Dba::escape($data['object_type']);
+ $user = Dba::escape($GLOBALS['user']->id);
+ $text = Dba::escape(strip_tags($data['comment']));
+ $date = time();
+ $sticky = make_bool($data['sticky']);
+ $object_id = Dba::escape($data['object_id']);
+ $object_type = Dba::escape($data['object_type']);
- $sql = "INSERT INTO `user_shout` (`user`,`date`,`text`,`sticky`,`object_id`,`object_type`) " .
- "VALUES ('$user','$date','$text','$sticky','$object_id','$object_type')";
- $db_results = Dba::write($sql);
+ $sql = "INSERT INTO `user_shout` (`user`,`date`,`text`,`sticky`,`object_id`,`object_type`) " .
+ "VALUES ('$user','$date','$text','$sticky','$object_id','$object_type')";
+ $db_results = Dba::write($sql);
- $insert_id = Dba::insert_id();
+ $insert_id = Dba::insert_id();
- return $insert_id;
+ return $insert_id;
} // create
@@ -178,16 +178,16 @@ class shoutBox {
* update
* This takes a key'd array of data as input and updates a shoutbox entry
*/
- public static function update($data) {
+ public static function update($data) {
- $id = Dba::escape($data['shout_id']);
- $text = Dba::escape(strip_tags($data['comment']));
- $sticky = make_bool($data['sticky']);
+ $id = Dba::escape($data['shout_id']);
+ $text = Dba::escape(strip_tags($data['comment']));
+ $sticky = make_bool($data['sticky']);
$sql = "UPDATE `user_shout` SET `text`='$text', `sticky`='$sticky' WHERE `id`='$id'";
- $db_results = Dba::write($sql);
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // create
@@ -195,12 +195,12 @@ class shoutBox {
* format
* this function takes the object and reformats some values
*/
-
+
public function format() {
$this->sticky = ($this->sticky == "0") ? 'No' : 'Yes';
$this->date = date("m\/d\/Y - H:i", $this->date);
return true;
-
+
} //format
/**
@@ -211,10 +211,10 @@ class shoutBox {
public function delete($shout_id) {
// Delete the shoutbox post
- $shout_id = Dba::escape($shout_id);
+ $shout_id = Dba::escape($shout_id);
$sql = "DELETE FROM `user_shout` WHERE `id`='$shout_id'";
$db_results = Dba::write($sql);
-
+
} // delete
} // shoutBox class
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index df37d9f7..f376c1dc 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -55,7 +55,7 @@ class Song extends database_object implements media {
*/
public function __construct($id='') {
- if (!$id) { return false; }
+ if (!$id) { return false; }
/* Assign id for use in get_info() */
$this->id = intval($id);
@@ -63,14 +63,14 @@ class Song extends database_object implements media {
/* Get the information from the db */
if ($info = $this->_get_info()) {
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
// Format the Type of the song
$this->format_type();
}
- return true;
+ return true;
} // constructor
@@ -85,59 +85,59 @@ class Song extends database_object implements media {
if (!is_array($song_ids) OR !count($song_ids)) { return false; }
$idlist = '(' . implode(',', $song_ids) . ')';
-
+
// Song data cache
$sql = "SELECT song.id,file,catalog,album,year,artist,".
"title,bitrate,rate,mode,size,time,track,played,song.enabled,update_time,tag_map.tag_id,".
"mbid,".
"addition_time FROM `song` " .
- "LEFT JOIN `tag_map` ON `tag_map`.`object_id`=`song`.`id` AND `tag_map`.`object_type`='song' " .
+ "LEFT JOIN `tag_map` ON `tag_map`.`object_id`=`song`.`id` AND `tag_map`.`object_type`='song' " .
"WHERE `song`.`id` IN $idlist";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('song',$row['id'],$row);
- $artists[$row['artist']] = $row['artist'];
- $albums[$row['album']] = $row['album'];
- if ($row['tag_id']) {
- $tags[$row['tag_id']] = $row['tag_id'];
- }
+ parent::add_to_cache('song',$row['id'],$row);
+ $artists[$row['artist']] = $row['artist'];
+ $albums[$row['album']] = $row['album'];
+ if ($row['tag_id']) {
+ $tags[$row['tag_id']] = $row['tag_id'];
+ }
}
Artist::build_cache($artists);
- Album::build_cache($albums);
- Tag::build_cache($tags);
- Tag::build_map_cache('song',$song_ids);
+ Album::build_cache($albums);
+ Tag::build_cache($tags);
+ Tag::build_map_cache('song',$song_ids);
// If we're rating this then cache them as well
- if (Config::get('ratings')) {
- Rating::build_cache('song',$song_ids);
- }
+ if (Config::get('ratings')) {
+ Rating::build_cache('song',$song_ids);
+ }
// Build a cache for the song's extended table
- $sql = "SELECT * FROM `song_data` WHERE `song_id` IN $idlist";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `song_data` WHERE `song_id` IN $idlist";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('song_data',$row['song_id'],$row);
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ parent::add_to_cache('song_data',$row['song_id'],$row);
+ }
return true;
-
+
} // build_cache
/**
* _get_info
- * get's the vars for $this out of the database
+ * get's the vars for $this out of the database
* Taken from the object
*/
private function _get_info() {
-
- $id = intval($this->id);
- if (parent::is_cached('song',$id)) {
- return parent::get_from_cache('song',$id);
- }
+ $id = intval($this->id);
+
+ if (parent::is_cached('song',$id)) {
+ return parent::get_from_cache('song',$id);
+ }
/* Grab the basic information from the catalog and return it */
$sql = "SELECT song.id,file,catalog,album,year,artist,".
@@ -148,7 +148,7 @@ class Song extends database_object implements media {
$results = Dba::fetch_assoc($db_results);
- parent::add_to_cache('song',$id,$results);
+ parent::add_to_cache('song',$id,$results);
return $results;
@@ -159,22 +159,22 @@ class Song extends database_object implements media {
* This function gathers information from the song_ext_info table and adds it to the
* current object
*/
- public function _get_ext_info() {
+ public function _get_ext_info() {
- $id = intval($this->id);
+ $id = intval($this->id);
- if (parent::is_cached('song_data',$id)) {
+ if (parent::is_cached('song_data',$id)) {
return parent::get_from_cache('song_data',$id);
- }
+ }
$sql = "SELECT * FROM song_data WHERE `song_id`='$id'";
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
- parent::add_to_cache('song_data',$id,$results);
+ parent::add_to_cache('song_data',$id,$results);
- return $results;
+ return $results;
} // _get_ext_info
@@ -182,13 +182,13 @@ class Song extends database_object implements media {
* fill_ext_info
* This calls the _get_ext_info and then sets the correct vars
*/
- public function fill_ext_info() {
+ public function fill_ext_info() {
- $info = $this->_get_ext_info();
+ $info = $this->_get_ext_info();
- foreach ($info as $key=>$value) {
- if ($key != 'song_id') {
- $this->$key = $value;
+ foreach ($info as $key=>$value) {
+ if ($key != 'song_id') {
+ $this->$key = $value;
}
} // end foreach
@@ -196,22 +196,22 @@ class Song extends database_object implements media {
/**
* format_type
- * gets the type of song we are trying to
- * play, used to set mime headers and to trick
+ * gets the type of song we are trying to
+ * play, used to set mime headers and to trick
* players into playing them correctly
*/
- public function format_type($override='') {
+ public function format_type($override='') {
// If we pass an override for downsampling or whatever then use it
- if (!empty($override)) {
- $this->type = $override;
+ if (!empty($override)) {
+ $this->type = $override;
}
else {
- $data = pathinfo($this->file);
- $this->type = strtolower($data['extension']);
- }
-
- switch ($this->type) {
+ $data = pathinfo($this->file);
+ $this->type = strtolower($data['extension']);
+ }
+
+ switch ($this->type) {
case 'spx':
case 'ogg':
$this->mime = "application/ogg";
@@ -247,19 +247,19 @@ class Song extends database_object implements media {
break;
}
- return true;
+ return true;
} // format_type
-
+
/**
* get_album_name
- * gets the name of $this->album, allows passing of id
+ * gets the name of $this->album, allows passing of id
*/
public function get_album_name($album_id=0) {
- if (!$album_id) { $album_id = $this->album; }
+ if (!$album_id) { $album_id = $this->album; }
$album = new Album($album_id);
if ($album->prefix)
- return $album->prefix . " " . $album->name;
+ return $album->prefix . " " . $album->name;
else
return $album->name;
} // get_album_name
@@ -270,10 +270,10 @@ class Song extends database_object implements media {
*/
public function get_artist_name($artist_id=0) {
- if (!$artist_id) { $artist_id = $this->artist; }
+ if (!$artist_id) { $artist_id = $this->artist; }
$artist = new Artist($artist_id);
if ($artist->prefix)
- return $artist->prefix . " " . $artist->name;
+ return $artist->prefix . " " . $artist->name;
else
return $artist->name;
@@ -284,12 +284,12 @@ class Song extends database_object implements media {
* This just returns true or false depending on if this song is flagged for something
* We don't care what so we limit the SELECT to 1
*/
- public function has_flag() {
+ public function has_flag() {
$sql = "SELECT `id` FROM `flagged` WHERE `object_type`='song' AND `object_id`='$this->id' LIMIT 1";
$db_results = Dba::read($sql);
- if (Dba::fetch_assoc($db_results)) {
+ if (Dba::fetch_assoc($db_results)) {
return true;
}
@@ -302,9 +302,9 @@ class Song extends database_object implements media {
* this checks to see if the current object has been played
* if not then it sets it to played
*/
- public function set_played() {
+ public function set_played() {
- if ($this->played) {
+ if ($this->played) {
return true;
}
@@ -314,12 +314,12 @@ class Song extends database_object implements media {
return true;
} // set_played
-
+
/**
* compare_song_information
* this compares the new ID3 tags of a file against
* the ones in the database to see if they have changed
- * it returns false if nothing has changes, or the true
+ * it returns false if nothing has changes, or the true
* if they have. Static because it doesn't need this
*/
public static function compare_song_information($song,$new_song) {
@@ -327,81 +327,81 @@ class Song extends database_object implements media {
// Remove some stuff we don't care about
unset($song->catalog,$song->played,$song->enabled,$song->addition_time,$song->update_time,$song->type);
- $string_array = array('title','comment','lyrics');
- $skip_array = array('id','tag_id','mime','mb_artistid','mbid');
+ $string_array = array('title','comment','lyrics');
+ $skip_array = array('id','tag_id','mime','mb_artistid','mbid');
// Pull out all the currently set vars
- $fields = get_object_vars($song);
+ $fields = get_object_vars($song);
// Foreach them
- foreach ($fields as $key=>$value) {
- if (in_array($key,$skip_array)) { continue; }
+ foreach ($fields as $key=>$value) {
+ if (in_array($key,$skip_array)) { continue; }
// If it's a stringie thing
- if (in_array($key,$string_array)) {
- if (trim(stripslashes($song->$key)) != trim(stripslashes($new_song->$key))) {
- $array['change'] = true;
+ if (in_array($key,$string_array)) {
+ if (trim(stripslashes($song->$key)) != trim(stripslashes($new_song->$key))) {
+ $array['change'] = true;
$array['element'][$key] = 'OLD: ' . $song->$key . ' --> ' . $new_song->$key;
}
} // in array of stringies
- else {
- if ($song->$key != $new_song->$key) {
- $array['change'] = true;
+ else {
+ if ($song->$key != $new_song->$key) {
+ $array['change'] = true;
$array['element'][$key] = 'OLD:' . $song->$key . ' --> ' . $new_song->$key;
- }
+ }
} // end else
} // end foreach
- if ($array['change']) {
- debug_event('song-diff',print_r($array['element'],1),'5','ampache-catalog');
- }
+ if ($array['change']) {
+ debug_event('song-diff',print_r($array['element'],1),'5','ampache-catalog');
+ }
return $array;
} // compare_song_information
-
+
/**
* update
* This takes a key'd array of data does any cleaning it needs to
- * do and then calls the helper functions as needed. This will also
+ * do and then calls the helper functions as needed. This will also
* cause the song to be flagged
*/
- public function update($data) {
+ public function update($data) {
- foreach ($data as $key=>$value) {
- switch ($key) {
+ foreach ($data as $key=>$value) {
+ switch ($key) {
case 'artist':
// Don't do anything if we've negative one'd this baby
- if ($value == '-1') {
- $value = Catalog::check_artist($data['artist_name'], $data['mb_artistid']);
- }
+ if ($value == '-1') {
+ $value = Catalog::check_artist($data['artist_name'], $data['mb_artistid']);
+ }
case 'album':
- if ($value == '-1') {
- $value = Catalog::check_album($data['album_name'], $data['year'], $data['disk'], $data['mb_albumid']);
- }
- case 'title':
+ if ($value == '-1') {
+ $value = Catalog::check_album($data['album_name'], $data['year'], $data['disk'], $data['mb_albumid']);
+ }
+ case 'title':
case 'track':
// Check to see if it needs to be updated
- if ($value != $this->$key) {
- $function = 'update_' . $key;
- self::$function($value,$this->id);
- $this->$key = $value;
- $updated = 1;
- }
+ if ($value != $this->$key) {
+ $function = 'update_' . $key;
+ self::$function($value,$this->id);
+ $this->$key = $value;
+ $updated = 1;
+ }
break;
- default:
+ default:
// Rien a faire
break;
} // end whitelist
} // end foreach
// If a field was changed then we need to flag this mofo
- if ($updated) {
- Flag::add($this->id,'song','retag','Interface Update');
- }
+ if ($updated) {
+ Flag::add($this->id,'song','retag','Interface Update');
+ }
- return true;
+ return true;
} // update
@@ -414,36 +414,36 @@ class Song extends database_object implements media {
*/
public static function update_song($song_id, $new_song) {
- $title = Dba::escape($new_song->title);
- $bitrate = Dba::escape($new_song->bitrate);
- $rate = Dba::escape($new_song->rate);
- $mode = Dba::escape($new_song->mode);
- $size = Dba::escape($new_song->size);
- $time = Dba::escape($new_song->time);
- $track = Dba::escape($new_song->track);
+ $title = Dba::escape($new_song->title);
+ $bitrate = Dba::escape($new_song->bitrate);
+ $rate = Dba::escape($new_song->rate);
+ $mode = Dba::escape($new_song->mode);
+ $size = Dba::escape($new_song->size);
+ $time = Dba::escape($new_song->time);
+ $track = Dba::escape($new_song->track);
$mbid = Dba::escape($new_song->mbid);
- $artist = Dba::escape($new_song->artist);
- $album = Dba::escape($new_song->album);
- $year = Dba::escape($new_song->year);
- $song_id = Dba::escape($song_id);
- $update_time = time();
-
-
- $sql = "UPDATE `song` SET `album`='$album', `year`='$year', `artist`='$artist', " .
- "`title`='$title', `bitrate`='$bitrate', `rate`='$rate', `mode`='$mode', " .
- "`size`='$size', `time`='$time', `track`='$track', " .
+ $artist = Dba::escape($new_song->artist);
+ $album = Dba::escape($new_song->album);
+ $year = Dba::escape($new_song->year);
+ $song_id = Dba::escape($song_id);
+ $update_time = time();
+
+
+ $sql = "UPDATE `song` SET `album`='$album', `year`='$year', `artist`='$artist', " .
+ "`title`='$title', `bitrate`='$bitrate', `rate`='$rate', `mode`='$mode', " .
+ "`size`='$size', `time`='$time', `track`='$track', " .
"`mbid`='$mbid', " .
- "`update_time`='$update_time' WHERE `id`='$song_id'";
- $db_results = Dba::write($sql);
-
-
- $comment = Dba::escape($new_song->comment);
- $language = Dba::escape($new_song->language);
- $lyrics = Dba::escape($new_song->lyrics);
-
- $sql = "UPDATE `song_data` SET `lyrics`='$lyrics', `language`='$language', `comment`='$comment' " .
- "WHERE `song_id`='$song_id'";
- $db_results = Dba::write($sql);
+ "`update_time`='$update_time' WHERE `id`='$song_id'";
+ $db_results = Dba::write($sql);
+
+
+ $comment = Dba::escape($new_song->comment);
+ $language = Dba::escape($new_song->language);
+ $lyrics = Dba::escape($new_song->lyrics);
+
+ $sql = "UPDATE `song_data` SET `lyrics`='$lyrics', `language`='$language', `comment`='$comment' " .
+ "WHERE `song_id`='$song_id'";
+ $db_results = Dba::write($sql);
} // update_song
@@ -452,18 +452,18 @@ class Song extends database_object implements media {
* update the year tag
*/
public static function update_year($new_year,$song_id) {
-
- self::_update_item('year',$new_year,$song_id,'50');
-
+
+ self::_update_item('year',$new_year,$song_id,'50');
+
} // update_year
/**
* update_language
* This updates the language tag of the song
*/
- public static function update_language($new_lang,$song_id) {
+ public static function update_language($new_lang,$song_id) {
- self::_update_ext_item('language',$new_lang,$song_id,'50');
+ self::_update_ext_item('language',$new_lang,$song_id,'50');
} // update_language
@@ -471,19 +471,19 @@ class Song extends database_object implements media {
* update_comment
* updates the comment field
*/
- public static function update_comment($new_comment,$song_id) {
-
+ public static function update_comment($new_comment,$song_id) {
+
self::_update_ext_item('comment',$new_comment,$song_id,'50');
-
+
} // update_comment
/**
* update_lyrics
* updates the lyrics field
*/
- public static function update_lyrics($new_lyrics,$song_id) {
-
- self::_update_ext_item('lyrics',$new_lyrics,$song_id,'50');
+ public static function update_lyrics($new_lyrics,$song_id) {
+
+ self::_update_ext_item('lyrics',$new_lyrics,$song_id,'50');
} // update_lyrics
@@ -492,9 +492,9 @@ class Song extends database_object implements media {
* updates the title field
*/
public static function update_title($new_title,$song_id) {
-
+
self::_update_item('title',$new_title,$song_id,'50');
-
+
} // update_title
/**
@@ -502,7 +502,7 @@ class Song extends database_object implements media {
* updates the bitrate field
*/
public static function update_bitrate($new_bitrate,$song_id) {
-
+
self::_update_item('bitrate',$new_bitrate,$song_id,'50');
} // update_bitrate
@@ -512,7 +512,7 @@ class Song extends database_object implements media {
* updates the rate field
*/
public static function update_rate($new_rate,$song_id) {
-
+
self::_update_item('rate',$new_rate,$song_id,'50');
} // update_rate
@@ -531,8 +531,8 @@ class Song extends database_object implements media {
* update_size
* updates the size field
*/
- public static function update_size($new_size,$song_id) {
-
+ public static function update_size($new_size,$song_id) {
+
self::_update_item('size',$new_size,$song_id,'50');
} // update_size
@@ -541,8 +541,8 @@ class Song extends database_object implements media {
* update_time
* updates the time field
*/
- public static function update_time($new_time,$song_id) {
-
+ public static function update_time($new_time,$song_id) {
+
self::_update_item('time',$new_time,$song_id,'50');
} // update_time
@@ -551,7 +551,7 @@ class Song extends database_object implements media {
* update_track
* this updates the track field
*/
- public static function update_track($new_track,$song_id) {
+ public static function update_track($new_track,$song_id) {
self::_update_item('track',$new_track,$song_id,'50');
@@ -577,7 +577,7 @@ class Song extends database_object implements media {
* update_album
* updates the album field
*/
- public static function update_album($new_album,$song_id) {
+ public static function update_album($new_album,$song_id) {
self::_update_item('album',$new_album,$song_id,'50');
@@ -599,7 +599,7 @@ class Song extends database_object implements media {
* update_played
* sets the played flag
*/
- public static function update_played($new_played,$song_id) {
+ public static function update_played($new_played,$song_id) {
self::_update_item('played',$new_played,$song_id,'25');
@@ -610,14 +610,14 @@ class Song extends database_object implements media {
* sets the enabled flag
*/
public static function update_enabled($new_enabled,$song_id) {
-
+
self::_update_item('enabled',$new_enabled,$song_id,'75');
} // update_enabled
/**
* _update_item
- * This is a private function that should only be called from within the song class.
+ * This is a private function that should only be called from within the song class.
* It takes a field, value song id and level. first and foremost it checks the level
* against $GLOBALS['user'] to make sure they are allowed to update this record
* it then updates it and sets $this->{$field} to the new value
@@ -628,7 +628,7 @@ class Song extends database_object implements media {
if (!Access::check('interface',$level)) { return false; }
/* Can't update to blank */
- if (!strlen(trim($value)) && $field != 'comment') { return false; }
+ if (!strlen(trim($value)) && $field != 'comment') { return false; }
$value = Dba::escape($value);
@@ -644,17 +644,17 @@ class Song extends database_object implements media {
* This updates a song record that is housed in the song_ext_info table
* These are items that aren't used normally, and often large/informational only
*/
- private static function _update_ext_item($field,$value,$song_id,$level) {
+ private static function _update_ext_item($field,$value,$song_id,$level) {
/* Check them rights boy! */
- if (!Access::check('interface',$level)) { return false; }
-
- $value = Dba::escape($value);
+ if (!Access::check('interface',$level)) { return false; }
+
+ $value = Dba::escape($value);
$sql = "UPDATE `song_data` SET `$field`='$value' WHERE `song_id`='$song_id'";
- $db_results = Dba::write($sql);
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // _update_ext_item
@@ -664,9 +664,9 @@ class Song extends database_object implements media {
* and does a ton of formating on it creating f_??? variables on the current
* object
*/
- public function format() {
+ public function format() {
- $this->fill_ext_info();
+ $this->fill_ext_info();
// Format the filename
preg_match("/^.*\/(.*?)$/",$this->file, $short);
@@ -683,11 +683,11 @@ class Song extends database_object implements media {
// Format the title
$this->f_title = truncate_with_ellipsis($this->title,Config::get('ellipse_threshold_title'));
- // Create Links for the different objects
+ // Create Links for the different objects
$this->link = Config::get('web_path') . "/song.php?action=show_song&song_id=" . $this->id;
$this->f_link = "<a href=\"" . scrub_out($this->link) . "\" title=\"" . scrub_out($this->title) . "\"> " . scrub_out($this->f_title) . "</a>";
$this->f_album_link = "<a href=\"" . Config::get('web_path') . "/albums.php?action=show&amp;album=" . $this->album . "\" title=\"" . scrub_out($this->f_album_full) . "\"> " . scrub_out($this->f_album) . "</a>";
- $this->f_artist_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&amp;artist=" . $this->artist . "\" title=\"" . scrub_out($this->f_artist_full) . "\"> " . scrub_out($this->f_artist) . "</a>";
+ $this->f_artist_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&amp;artist=" . $this->artist . "\" title=\"" . scrub_out($this->f_artist_full) . "\"> " . scrub_out($this->f_artist) . "</a>";
// Format the Bitrate
$this->f_bitrate = intval($this->bitrate/1000) . "-" . strtoupper($this->mode);
@@ -698,13 +698,13 @@ class Song extends database_object implements media {
$this->f_time = $min . ":" . $sec;
// Format the track (there isn't really anything to do here)
- $this->f_track = $this->track;
+ $this->f_track = $this->track;
// Get the top tags
- $tags = Tag::get_top_tags('song',$this->id);
- $this->tags = $tags;
-
- $this->f_tags = Tag::get_display($tags,$this->id,'song');
+ $tags = Tag::get_top_tags('song',$this->id);
+ $this->tags = $tags;
+
+ $this->f_tags = Tag::get_display($tags,$this->id,'song');
// Format the size
$this->f_size = sprintf("%.2f",($this->size/1048576));
@@ -715,21 +715,21 @@ class Song extends database_object implements media {
/**
* format_pattern
- * This reformates the song information based on the catalog
- * rename patterns
+ * This reformates the song information based on the catalog
+ * rename patterns
*/
- public function format_pattern() {
+ public function format_pattern() {
$extension = ltrim(substr($this->file,strlen($this->file)-4,4),".");
- $catalog = new Catalog($this->catalog);
+ $catalog = new Catalog($this->catalog);
// If we don't have a rename pattern then just return it
- if (!trim($catalog->rename_pattern)) {
+ if (!trim($catalog->rename_pattern)) {
$this->f_pattern = $this->title;
$this->f_file = $this->title . '.' . $extension;
- return;
- }
+ return;
+ }
/* Create the filename that this file should have */
$album = $this->f_album_full;
@@ -743,10 +743,10 @@ class Song extends database_object implements media {
$content_array = array($artist,$album,$title,$track,$year,'-','-');
$rename_pattern = str_replace($replace_array,$content_array,$catalog->rename_pattern);
-
+
$rename_pattern = preg_replace("[\-\:\!]","_",$rename_pattern);
-
- $this->f_pattern = $rename_pattern;
+
+ $this->f_pattern = $rename_pattern;
$this->f_file = $rename_pattern . "." . $extension;
} // format_pattern
@@ -756,20 +756,20 @@ class Song extends database_object implements media {
* This returns all of the 'data' fields for this object, we need to filter out some that we don't
* want to present to a user, and add some that don't exist directly on the object but are related
*/
- public static function get_fields() {
+ public static function get_fields() {
- $fields = get_class_vars('Song');
+ $fields = get_class_vars('Song');
- unset($fields['id'],$fields['_transcoded'],$fields['_fake'],$fields['cache_hit'],$fields['mime'],$fields['type']);
+ unset($fields['id'],$fields['_transcoded'],$fields['_fake'],$fields['cache_hit'],$fields['mime'],$fields['type']);
// Some additional fields
- $fields['tag'] = true;
- $fields['catalog'] = true;
+ $fields['tag'] = true;
+ $fields['catalog'] = true;
//FIXME: These are here to keep the ideas, don't want to have to worry about them for now
-// $fields['rating'] = true;
-// $fields['recently Played'] = true;
+// $fields['rating'] = true;
+// $fields['recently Played'] = true;
- return $fields;
+ return $fields;
} // get_fields
@@ -777,35 +777,35 @@ class Song extends database_object implements media {
* get_from_path
* This returns all of the songs that exist under the specified path
*/
- public static function get_from_path($path) {
+ public static function get_from_path($path) {
- $path = Dba::escape($path);
+ $path = Dba::escape($path);
- $sql = "SELECT * FROM `song` WHERE `file` LIKE '$path%'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `song` WHERE `file` LIKE '$path%'";
+ $db_results = Dba::read($sql);
- $songs = array();
+ $songs = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- $songs[] = $row['id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $songs[] = $row['id'];
+ }
- return $songs;
+ return $songs;
} // get_from_path
/**
* @function get_rel_path
* @discussion returns the path of the song file stripped of the catalog path
- * used for mpd playback
+ * used for mpd playback
*/
public function get_rel_path($file_path=0,$catalog_id=0) {
- if (!$file_path) {
+ if (!$file_path) {
$info = $this->_get_info();
$file_path = $info->file;
}
- if (!$catalog_id) {
+ if (!$catalog_id) {
$catalog_id = $info->catalog;
}
$catalog = new Catalog( $catalog_id );
@@ -817,29 +817,29 @@ class Song extends database_object implements media {
} // get_rel_path
- /*!
+ /*!
@function fill_info
@discussion this takes the $results from getid3 and attempts to fill
as much information as possible from the file name using the
pattern set in the current catalog
*/
- function fill_info($results,$pattern,$catalog_id,$key) {
+ function fill_info($results,$pattern,$catalog_id,$key) {
$filename = $this->get_rel_path($results['file'],$catalog_id);
- if (!strlen($results[$key]['title'])) {
+ if (!strlen($results[$key]['title'])) {
$results[$key]['title'] = $this->get_info_from_filename($filename,$pattern,"%t");
}
- if (!strlen($results[$key]['track'])) {
+ if (!strlen($results[$key]['track'])) {
$results[$key]['track'] = $this->get_info_from_filename($filename,$pattern,"%T");
}
- if (!strlen($results[$key]['year'])) {
+ if (!strlen($results[$key]['year'])) {
$results[$key]['year'] = $this->get_info_from_filename($filename,$pattern,"%y");
}
- if (!strlen($results[$key]['album'])) {
+ if (!strlen($results[$key]['album'])) {
$results[$key]['album'] = $this->get_info_from_filename($filename,$pattern,"%A");
}
- if (!strlen($results[$key]['artist'])) {
+ if (!strlen($results[$key]['artist'])) {
$results[$key]['artist'] = $this->get_info_from_filename($filename,$pattern,"%a");
}
@@ -847,11 +847,11 @@ class Song extends database_object implements media {
} // fill_info
- /*!
+ /*!
@function get_info_from_filename
@discussion get information from a filename based on pattern
*/
- function get_info_from_filename($file,$pattern,$tag) {
+ function get_info_from_filename($file,$pattern,$tag) {
$preg_pattern = str_replace("$tag","(.+)",$pattern);
$preg_pattern = preg_replace("/\%\w/",".+",$preg_pattern);
@@ -869,20 +869,20 @@ class Song extends database_object implements media {
* a stream URL taking into account the downsmapling mojo and everything
* else, this is the true function
*/
- public static function play_url($oid) {
+ public static function play_url($oid) {
- $song = new Song($oid);
- $user_id = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
+ $song = new Song($oid);
+ $user_id = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
$type = $song->type;
- // Required for some versions of winamp that won't work if the stream doesn't end in
- // .ogg This will not break any properly working player, don't report this as a bug!
- if ($song->type == 'flac') { $type = 'ogg'; }
+ // Required for some versions of winamp that won't work if the stream doesn't end in
+ // .ogg This will not break any properly working player, don't report this as a bug!
+ if ($song->type == 'flac') { $type = 'ogg'; }
$song->format();
$song_name = rawurlencode($song->f_artist_full . " - " . $song->title . "." . $type);
-
+
$url = Stream::get_base_url() . "oid=$song->id&uid=$user_id$session_string$ds_string&name=/$song_name";
return $url;
@@ -895,23 +895,23 @@ class Song extends database_object implements media {
* used by the API, and used to parse out stream urls for localplay
* right now just gets song id might do more later, hence the complexity
*/
- public static function parse_song_url($url) {
+ public static function parse_song_url($url) {
// We only care about the question mark stuff
- $query = parse_url($url,PHP_URL_QUERY);
+ $query = parse_url($url,PHP_URL_QUERY);
- $elements = explode("&",$query);
+ $elements = explode("&",$query);
- foreach ($elements as $items) {
- list($key,$value) = explode("=",$items);
- if ($key == 'oid') {
- return $value;
- }
- } // end foreach
+ foreach ($elements as $items) {
+ list($key,$value) = explode("=",$items);
+ if ($key == 'oid') {
+ return $value;
+ }
+ } // end foreach
- return false;
+ return false;
- } // parse_song_url
+ } // parse_song_url
/**
* get_recently_played
@@ -919,28 +919,28 @@ class Song extends database_object implements media {
* it uses the popular threshold to figure out how many to pull
* it will only return unique object
*/
- public static function get_recently_played($user_id='') {
+ public static function get_recently_played($user_id='') {
- if ($user_id) {
- $user_limit = " AND `object_count`.`user`='" . Dba::escape($user_id) . "'";
- }
+ if ($user_id) {
+ $user_limit = " AND `object_count`.`user`='" . Dba::escape($user_id) . "'";
+ }
- $sql = "SELECT `object_count`.`object_id`,`object_count`.`user`,`object_count`.`object_type`, " .
- "`object_count`.`date` " .
- "FROM `object_count` " .
- "WHERE `object_type`='song'$user_limit " .
+ $sql = "SELECT `object_count`.`object_id`,`object_count`.`user`,`object_count`.`object_type`, " .
+ "`object_count`.`date` " .
+ "FROM `object_count` " .
+ "WHERE `object_type`='song'$user_limit " .
"ORDER BY `object_count`.`date` DESC ";
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
$results = array();
-
- while ($row = Dba::fetch_assoc($db_results)) {
- if (isset($results[$row['object_id']])) { continue; }
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ if (isset($results[$row['object_id']])) { continue; }
$results[$row['object_id']] = $row;
- if (count($results) >= Config::get('popular_threshold')) { break; }
- }
+ if (count($results) >= Config::get('popular_threshold')) { break; }
+ }
- return $results;
+ return $results;
} // get_recently_played
@@ -949,25 +949,25 @@ class Song extends database_object implements media {
* This returns true/false if this can be nativly streamed
*/
public function native_stream() {
-
+
if ($this->_transcode) { return false; }
$conf_var = 'transcode_' . $this->type;
- $conf_type = 'transcode_' . $this->type . '_target';
-
- if (Config::get($conf_var)) {
- $this->_transcode = true;
- debug_event('auto_transcode','Transcoding to ' . $this->type,'5');
- return false;
- }
-
+ $conf_type = 'transcode_' . $this->type . '_target';
+
+ if (Config::get($conf_var)) {
+ $this->_transcode = true;
+ debug_event('auto_transcode','Transcoding to ' . $this->type,'5');
+ return false;
+ }
+
return true;
} // end native_stream
-
+
/**
* stream_cmd
- * test if the song type streams natively and
+ * test if the song type streams natively and
* if not returns a transcoding command from the config
* we can't use this->type because its been formated for the
* downsampling
@@ -976,18 +976,18 @@ class Song extends database_object implements media {
// Find the target for this transcode
$conf_type = 'transcode_' . $this->type . '_target';
- $stream_cmd = 'transcode_cmd_' . $this->type;
+ $stream_cmd = 'transcode_cmd_' . $this->type;
$this->format_type(Config::get($conf_type));
- if (Config::get($stream_cmd)) {
+ if (Config::get($stream_cmd)) {
return $stream_cmd;
- }
- else {
- debug_event('Downsample','Error: Transcode ' . $stream_cmd . ' for ' . $this->type . ' not found, using downsample','2');
}
-
+ else {
+ debug_event('Downsample','Error: Transcode ' . $stream_cmd . ' for ' . $this->type . ' not found, using downsample','2');
+ }
+
return false;
-
+
} // end stream_cmd
} // end of song class
diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php
index 88556f7d..61b61a17 100644
--- a/lib/class/stats.class.php
+++ b/lib/class/stats.class.php
@@ -24,13 +24,13 @@
* Stats
* this class handles the object_count
* Stuff, before this was done in the user class
- * but that's not good, all done through here.
+ * but that's not good, all done through here.
*/
class Stats {
/* Base vars */
- var $id;
- var $object_type;
+ var $id;
+ var $object_type;
var $object_id;
var $date;
var $user;
@@ -40,7 +40,7 @@ class Stats {
* Constructor
* This doesn't do anything currently
*/
- public function __construct() {
+ public function __construct() {
return true;
@@ -49,25 +49,25 @@ class Stats {
/**
* insert
* This inserts a new record for the specified object
- * with the specified information, amazing!
+ * with the specified information, amazing!
*/
- public static function insert($type,$oid,$user) {
+ public static function insert($type,$oid,$user) {
$type = self::validate_type($type);
$oid = Dba::escape($oid);
- $user = Dba::escape($user);
+ $user = Dba::escape($user);
$date = time();
- $sql = "INSERT INTO `object_count` (`object_type`,`object_id`,`date`,`user`) " .
+ $sql = "INSERT INTO `object_count` (`object_type`,`object_id`,`date`,`user`) " .
" VALUES ('$type','$oid','$date','$user')";
$db_results = Dba::write($sql);
- if (!$db_results) {
+ if (!$db_results) {
debug_event('statistics','Unabled to insert statistics:' . $sql,'3');
- }
+ }
} // insert
-
+
/**
* get_last_song
* This returns the full data for the last song that was played, including when it
@@ -75,18 +75,18 @@ class Stats {
* if we should re-submit or if this is a duplicate / if it's too soon. This takes an
* optional user_id because when streaming we don't have $GLOBALS()
*/
- public static function get_last_song($user_id='') {
+ public static function get_last_song($user_id='') {
- $user_id = $user_id ? $user_id : $GLOBALS['user']->id;
+ $user_id = $user_id ? $user_id : $GLOBALS['user']->id;
$user_id = Dba::escape($user_id);
- $sql = "SELECT * FROM `object_count` WHERE `user`='$user_id' AND `object_type`='song' ORDER BY `date` DESC LIMIT 1";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `object_count` WHERE `user`='$user_id' AND `object_type`='song' ORDER BY `date` DESC LIMIT 1";
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
- return $results;
+ return $results;
} // get_last_song
@@ -95,25 +95,25 @@ class Stats {
* This returns the objects that have happened for $user_id sometime after $time
* used primarly by the democratic cooldown code
*/
- public static function get_object_history($user_id='',$time) {
+ public static function get_object_history($user_id='',$time) {
$user_id = $user_id ? $user_id : $GLOBALS['user']->id;
$user_id = Dba::escape($user_id);
- $time = Dba::escape($time);
+ $time = Dba::escape($time);
- $sql = "SELECT * FROM `object_count` WHERE `user`='$user_id' AND `object_type`='song' AND `date`>='$time' " .
- "ORDER BY `date` DESC";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `object_count` WHERE `user`='$user_id' AND `object_type`='song' AND `date`>='$time' " .
+ "ORDER BY `date` DESC";
+ $db_results = Dba::read($sql);
- $results = array();
+ $results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['object_id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['object_id'];
+ }
- return $results;
+ return $results;
} // get_object_history
@@ -122,31 +122,31 @@ class Stats {
* This returns the top X for type Y from the
* last conf('stats_threshold') days
*/
- public static function get_top($type,$count='',$threshold = '') {
+ public static function get_top($type,$count='',$threshold = '') {
/* If they don't pass one, then use the preference */
- if (!$threshold) {
+ if (!$threshold) {
$threshold = Config::get('stats_threshold');
}
- if (!$count) {
- $count = Config::get('popular_threshold');
- }
+ if (!$count) {
+ $count = Config::get('popular_threshold');
+ }
$count = intval($count);
$type = self::validate_type($type);
$date = time() - (86400*$threshold);
-
+
/* Select Top objects counting by # of rows */
- $sql = "SELECT object_id,COUNT(id) AS `count` FROM object_count" .
+ $sql = "SELECT object_id,COUNT(id) AS `count` FROM object_count" .
" WHERE object_type='$type' AND date >= '$date'" .
" GROUP BY object_id ORDER BY `count` DESC LIMIT $count";
$db_results = Dba::read($sql);
$results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['object_id'];
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['object_id'];
}
return $results;
@@ -156,34 +156,34 @@ class Stats {
/**
* get_user
* This gets all stats for atype based on user with thresholds and all
- * If full is passed, doesn't limit based on date
+ * If full is passed, doesn't limit based on date
*/
- public static function get_user($count,$type,$user,$full='') {
+ public static function get_user($count,$type,$user,$full='') {
$count = intval($count);
$type = self::validate_type($type);
$user = Dba::escape($user);
-
- /* If full then don't limit on date */
- if ($full) {
+
+ /* If full then don't limit on date */
+ if ($full) {
$date = '0';
}
- else {
+ else {
$date = time() - (86400*Config::get('stats_threshold'));
}
/* Select Objects based on user */
- //FIXME:: Requires table scan, look at improving
- $sql = "SELECT object_id,COUNT(id) AS `count` FROM object_count" .
- " WHERE object_type='$type' AND date >= '$date' AND user = '$user'" .
+ //FIXME:: Requires table scan, look at improving
+ $sql = "SELECT object_id,COUNT(id) AS `count` FROM object_count" .
+ " WHERE object_type='$type' AND date >= '$date' AND user = '$user'" .
" GROUP BY object_id ORDER BY `count` DESC LIMIT $count";
$db_results = Dba::read($sql);
-
+
$results = array();
- while ($r = Dba::fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r;
- }
+ }
return $results;
@@ -194,15 +194,15 @@ class Stats {
* This function takes a type and returns only those
* which are allowed, ensures good data gets put into the db
*/
- public static function validate_type($type) {
+ public static function validate_type($type) {
- switch ($type) {
+ switch ($type) {
case 'artist':
case 'album':
case 'genre':
case 'song':
- case 'video':
- return $type;
+ case 'video':
+ return $type;
default:
return 'song';
break;
@@ -215,24 +215,24 @@ class Stats {
* This returns an array of the newest artists/albums/whatever
* in this ampache instance
*/
- public static function get_newest($type,$limit='') {
+ public static function get_newest($type,$limit='') {
if (!$limit) { $limit = Config::get('popular_threshold'); }
-
- $type = self::validate_type($type);
- $object_name = ucfirst($type);
- $sql = "SELECT DISTINCT($type) FROM `song` ORDER BY `addition_time` DESC " .
- "LIMIT $limit";
- $db_results = Dba::read($sql);
+ $type = self::validate_type($type);
+ $object_name = ucfirst($type);
+
+ $sql = "SELECT DISTINCT($type) FROM `song` ORDER BY `addition_time` DESC " .
+ "LIMIT $limit";
+ $db_results = Dba::read($sql);
- $items = array();
+ $items = array();
- while ($row = Dba::fetch_row($db_results)) {
- $items[] = $row['0'];
+ while ($row = Dba::fetch_row($db_results)) {
+ $items[] = $row['0'];
} // end while results
- return $items;
+ return $items;
} // get_newest
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index 3ae532e1..1b4a7225 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -3,7 +3,7 @@
/*
Copyright (c) Ampache.org
- All rights reserved.
+ All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
@@ -33,15 +33,15 @@ class Stream {
public $type;
public $web_path;
public $media = array();
- public $urls = array();
+ public $urls = array();
public $sess;
- public $user_id;
+ public $user_id;
// Generate once an object is constructed
- public static $session;
+ public static $session;
// Let's us tell if the session has been activated
- private static $session_inserted;
+ private static $session_inserted;
/**
* Constructor for the stream class takes a type and an array
@@ -52,8 +52,8 @@ class Stream {
$this->type = $type;
$this->media = $media_ids;
$this->user_id = $GLOBALS['user']->id;
-
- if (!is_array($this->media)) { settype($this->media,'array'); }
+
+ if (!is_array($this->media)) { settype($this->media,'array'); }
} // Constructor
@@ -64,26 +64,26 @@ class Stream {
*/
public function start() {
- if (!count($this->media) AND !count($this->urls)) {
+ if (!count($this->media) AND !count($this->urls)) {
debug_event('stream','Error: No Songs Passed on ' . $this->type . ' stream','2');
- return false;
+ return false;
}
// We're starting insert the session into session_stream
- if (!self::get_session()) {
- debug_event('stream','Session Insertion failure, aborting','3');
- return false;
+ if (!self::get_session()) {
+ debug_event('stream','Session Insertion failure, aborting','3');
+ return false;
}
$methods = get_class_methods('Stream');
- $create_function = "create_" . $this->type;
+ $create_function = "create_" . $this->type;
// If in the class, call it
if (in_array($create_function,$methods)) {
$this->{$create_function}();
}
// Assume M3u incase they've pooched the type
- else {
+ else {
$this->create_m3u();
}
@@ -91,14 +91,14 @@ class Stream {
/**
* add_urls
- * Add an array of urls, it may be a single one who knows, this
+ * Add an array of urls, it may be a single one who knows, this
* is used for things that aren't coming from media objects
*/
- public function add_urls($urls=array()) {
+ public function add_urls($urls=array()) {
+
+ if (!is_array($urls)) { return false; }
- if (!is_array($urls)) { return false; }
-
- $this->urls = array_merge($urls,$this->urls);
+ $this->urls = array_merge($urls,$this->urls);
} // manual_url_add
@@ -106,13 +106,13 @@ class Stream {
* get_session
* This returns the current stream session
*/
- public static function get_session() {
+ public static function get_session() {
- if (!self::$session_inserted) {
+ if (!self::$session_inserted) {
self::insert_session(self::$session);
- }
+ }
- return self::$session;
+ return self::$session;
} // get_session
@@ -122,10 +122,10 @@ class Stream {
* an additional session into the database, should be called
* with care
*/
- public static function set_session($sid) {
+ public static function set_session($sid) {
- self::$session_inserted = true;
- self::$session=$sid;
+ self::$session_inserted = true;
+ self::$session=$sid;
} // set_session
@@ -133,42 +133,42 @@ class Stream {
* insert_session
* This inserts a row into the session_stream table
*/
- public static function insert_session($sid='',$uid='') {
+ public static function insert_session($sid='',$uid='') {
- $sid = $sid ? Dba::escape($sid) : Dba::escape(self::$session);
- $uid = $uid ? Dba::escape($uid) : Dba::escape($GLOBALS['user']->id);
+ $sid = $sid ? Dba::escape($sid) : Dba::escape(self::$session);
+ $uid = $uid ? Dba::escape($uid) : Dba::escape($GLOBALS['user']->id);
- $expire = time() + Config::get('stream_length');
+ $expire = time() + Config::get('stream_length');
- $sql = "INSERT INTO `session_stream` (`id`,`expire`,`user`) " .
- "VALUES('$sid','$expire','$uid')";
- $db_results = Dba::write($sql);
+ $sql = "INSERT INTO `session_stream` (`id`,`expire`,`user`) " .
+ "VALUES('$sid','$expire','$uid')";
+ $db_results = Dba::write($sql);
- if (!$db_results) { return false; }
+ if (!$db_results) { return false; }
- self::$session_inserted = true;
+ self::$session_inserted = true;
- return true;
+ return true;
} // insert_session
/**
* session_exists
- * This checks to see if the passed stream session exists and is valid
+ * This checks to see if the passed stream session exists and is valid
*/
- public static function session_exists($sid) {
+ public static function session_exists($sid) {
- $sid = Dba::escape($sid);
- $time = time();
+ $sid = Dba::escape($sid);
+ $time = time();
- $sql = "SELECT * FROM `session_stream` WHERE `id`='$sid' AND `expire` > '$time'";
- $db_results = Dba::write($sql);
+ $sql = "SELECT * FROM `session_stream` WHERE `id`='$sid' AND `expire` > '$time'";
+ $db_results = Dba::write($sql);
- if ($row = Dba::fetch_assoc($db_results)) {
- return true;
- }
-
- return false;
+ if ($row = Dba::fetch_assoc($db_results)) {
+ return true;
+ }
+
+ return false;
} // session_exists
@@ -177,49 +177,49 @@ class Stream {
* This function performes the garbage collection stuff, run on extend and on now playing refresh
* There is an array of agents that we will never GC because of their nature, MPD being the best example
*/
- public static function gc_session($ip='',$agent='',$uid='',$sid='') {
+ public static function gc_session($ip='',$agent='',$uid='',$sid='') {
- $append_array = array('MPD');
+ $append_array = array('MPD');
- $time = time();
- $sql = "DELETE FROM `session_stream` WHERE `expire` < '$time'";
- $db_results = Dba::write($sql);
-
- foreach ($append_array as $append_agent) {
- if (strstr(strtoupper($agent),$append_agent)) {
+ $time = time();
+ $sql = "DELETE FROM `session_stream` WHERE `expire` < '$time'";
+ $db_results = Dba::write($sql);
+
+ foreach ($append_array as $append_agent) {
+ if (strstr(strtoupper($agent),$append_agent)) {
// We're done here jump ship!
- return true;
- }
+ return true;
+ }
} // end foreach
// We need all of this to run this query
- if ($ip AND $agent AND $uid AND $sid) {
- $sql = "DELETE FROM `session_stream` WHERE `ip`='$ip' AND `agent`='$agent' AND `user`='$uid' AND `id` != '$sid'";
- $db_results = Dba::write($sql);
- }
+ if ($ip AND $agent AND $uid AND $sid) {
+ $sql = "DELETE FROM `session_stream` WHERE `ip`='$ip' AND `agent`='$agent' AND `user`='$uid' AND `id` != '$sid'";
+ $db_results = Dba::write($sql);
+ }
- } // gc_session
+ } // gc_session
/**
* extend_session
* This takes the passed sid and does a replace into also setting the user
* agent and IP also do a little GC in this function
*/
- public static function extend_session($sid,$uid) {
+ public static function extend_session($sid,$uid) {
- $expire = time() + Config::get('stream_length');
- $sid = Dba::escape($sid);
- $agent = Dba::escape($_SERVER['HTTP_USER_AGENT']);
- $ip = Dba::escape(inet_pton($_SERVER['REMOTE_ADDR']));
- $uid = Dba::escape($uid);
+ $expire = time() + Config::get('stream_length');
+ $sid = Dba::escape($sid);
+ $agent = Dba::escape($_SERVER['HTTP_USER_AGENT']);
+ $ip = Dba::escape(inet_pton($_SERVER['REMOTE_ADDR']));
+ $uid = Dba::escape($uid);
- $sql = "UPDATE `session_stream` SET `expire`='$expire', `agent`='$agent', `ip`='$ip' " .
- "WHERE `id`='$sid'";
- $db_results = Dba::write($sql);
+ $sql = "UPDATE `session_stream` SET `expire`='$expire', `agent`='$agent', `ip`='$ip' " .
+ "WHERE `id`='$sid'";
+ $db_results = Dba::write($sql);
- self::gc_session($ip,$agent,$uid,$sid);
+ self::gc_session($ip,$agent,$uid,$sid);
- return true;
+ return true;
} // extend_session
@@ -234,16 +234,16 @@ class Stream {
header("Content-Type: audio/x-mpegurl;");
// Flip for the poping!
- asort($this->urls);
+ asort($this->urls);
/* Foreach songs */
- foreach ($this->media as $element) {
+ foreach ($this->media as $element) {
$type = array_shift($element);
- echo call_user_func(array($type,'play_url'),array_shift($element)) . "\n";
+ echo call_user_func(array($type,'play_url'),array_shift($element)) . "\n";
} // end foreach
/* Foreach the additional URLs */
- foreach ($this->urls as $url) {
+ foreach ($this->urls as $url) {
echo "$url\n";
}
@@ -254,7 +254,7 @@ class Stream {
* creates an m3u file, this includes the EXTINFO and as such can be
* large with very long playlsits
*/
- public function create_m3u() {
+ public function create_m3u() {
// Send the client an m3u playlist
header("Cache-control: public");
@@ -264,31 +264,31 @@ class Stream {
// Foreach the songs in this stream object
foreach ($this->media as $element) {
- $type = array_shift($element);
- $media = new $type(array_shift($element));
- $media->format();
- switch ($type) {
- case 'song':
+ $type = array_shift($element);
+ $media = new $type(array_shift($element));
+ $media->format();
+ switch ($type) {
+ case 'song':
echo "#EXTINF:$media->time," . $media->f_artist_full . " - " . $media->title . "\n";
break;
- case 'video':
+ case 'video':
echo "#EXTINF: Video - $media->title\n";
break;
- case 'radio':
- echo "#EXTINF: Radio - $media->name [$media->frequency] ($media->site_url)\n";
- break;
- case 'random':
- echo "#EXTINF:Random URL\n";
- break;
- default:
+ case 'radio':
+ echo "#EXTINF: Radio - $media->name [$media->frequency] ($media->site_url)\n";
+ break;
+ case 'random':
+ echo "#EXTINF:Random URL\n";
+ break;
+ default:
echo "#EXTINF:URL-Add\n";
break;
- }
- echo call_user_func(array($type,'play_url'),$media->id) . "\n";
+ }
+ echo call_user_func(array($type,'play_url'),$media->id) . "\n";
} // end foreach
/* Foreach URLS */
- foreach ($this->urls as $url) {
+ foreach ($this->urls as $url) {
echo "#EXTINF: URL-Add\n";
echo $url . "\n";
}
@@ -300,10 +300,10 @@ class Stream {
* This creates a new pls file from an array of songs and
* urls, exciting I know
*/
- public function create_pls() {
+ public function create_pls() {
/* Count entries */
- $total_entries = count($this->media) + count($this->urls);
+ $total_entries = count($this->media) + count($this->urls);
// Send the client a pls playlist
header("Cache-control: public");
@@ -311,30 +311,30 @@ class Stream {
header("Content-Type: audio/x-scpls;");
echo "[Playlist]\n";
echo "NumberOfEntries=$total_entries\n";
- foreach ($this->media as $element) {
+ foreach ($this->media as $element) {
$i++;
- $type = array_shift($element);
- $media = new $type(array_shift($element));
- $media->format();
- switch ($type) {
- case 'song':
+ $type = array_shift($element);
+ $media = new $type(array_shift($element));
+ $media->format();
+ switch ($type) {
+ case 'song':
$name = $media->f_artist_full . " - " . $media->title . "." . $media->type;
- $length = $media->time;
- break;
- default:
- $name = 'URL-Add';
- $length='-1';
- break;
- }
+ $length = $media->time;
+ break;
+ default:
+ $name = 'URL-Add';
+ $length='-1';
+ break;
+ }
$url = call_user_func(array($type,'play_url'),$media->id);
echo "File" . $i . "=$url\n";
echo "Title" . $i . "=$name\n";
echo "Length" . $i . "=$length\n";
- } // end foreach songs
+ } // end foreach songs
/* Foreach Additional URLs */
- foreach ($this->urls as $url) {
+ foreach ($this->urls as $url) {
$i++;
echo "File" . $i ."=$url\n";
echo "Title". $i . "=AddedURL\n";
@@ -348,32 +348,32 @@ class Stream {
/**
* create_asx
* creates an ASX playlist (Thx Samir Kuthiala) This should really only be used
- * if all of the content is ASF files.
+ * if all of the content is ASF files.
*/
- public function create_asx() {
+ public function create_asx() {
header("Cache-control: public");
header("Content-Disposition: filename=ampache_playlist.asx");
header("Content-Type: video/x-ms-wmv;");
-
+
echo "<ASX version = \"3.0\" BANNERBAR=\"AUTO\">\n";
echo "<TITLE>Ampache ASX Playlist</TITLE>";
-
+
foreach ($this->media as $element) {
- $type = array_shift($element);
- $media = new $type(array_shift($element));
- $media->format();
- switch ($type) {
- case 'song':
+ $type = array_shift($element);
+ $media = new $type(array_shift($element));
+ $media->format();
+ switch ($type) {
+ case 'song':
$name = $media->f_album_full . " - " . $media->title . "." . $media->type;
- $author = $media->f_artist_full;
- break;
+ $author = $media->f_artist_full;
+ break;
default:
- $author = 'Ampache';
+ $author = 'Ampache';
$name = 'URL-Add';
- break;
- } // end switch
- $url = call_user_func(array($type,'play_url'),$media->id);
+ break;
+ } // end switch
+ $url = call_user_func(array($type,'play_url'),$media->id);
echo "<ENTRY>\n";
echo "<TITLE>$name</TITLE>\n";
@@ -386,17 +386,17 @@ class Stream {
echo "\t\t<PARAM NAME=\"Prebuffer\" Value=\"false\" />\n";
echo "<REF HREF = \"". $url . "\" />\n";
echo "</ENTRY>\n";
-
+
} // end foreach
/* Foreach urls */
- foreach ($this->urls as $url) {
+ foreach ($this->urls as $url) {
echo "<ENTRY>\n";
echo "<TITLE>AddURL</TITLE>\n";
echo "<AUTHOR>AddURL</AUTHOR>\n";
echo "<REF HREF=\"$url\" />\n";
echo "</ENTRY>\n";
- } // end foreach
+ } // end foreach
echo "</ASX>\n";
@@ -406,26 +406,26 @@ class Stream {
* create_xspf
* creates an XSPF playlist (Thx PB1DFT)
*/
- public function create_xspf() {
+ public function create_xspf() {
// Itterate through the songs
foreach ($this->media as $element) {
- $type = array_shift($element);
- $media = new $type(array_shift($element));
- $media->format();
+ $type = array_shift($element);
+ $media = new $type(array_shift($element));
+ $media->format();
$xml = array();
- switch ($type) {
+ switch ($type) {
default:
- case 'song':
+ case 'song':
$xml['track']['title'] = $media->title;
$xml['track']['creator'] = $media->f_artist_full;
$xml['track']['info'] = Config::get('web_path') . "/albums.php?action=show&album=" . $media->album;
$xml['track']['image'] = Config::get('web_path') . "/image.php?id=" . $media->album . "&thumb=3";
$xml['track']['album'] = $media->f_album_full;
- $length = $media->time;
- break;
+ $length = $media->time;
+ break;
} // type
$xml['track']['location'] = call_user_func(array($type,'play_url'),$media->id);
@@ -435,15 +435,15 @@ class Stream {
$result .= xmlData::keyed_array($xml,1);
} // end foreach
-
- xmlData::set_type('xspf');
+
+ xmlData::set_type('xspf');
header("Cache-control: public");
header("Content-Disposition: filename=ampache_playlist.xspf");
header("Content-Type: application/xspf+xml; charset=utf-8");
- echo xmlData::header();
+ echo xmlData::header();
echo $result;
- echo xmlData::footer();
+ echo xmlData::footer();
} // create_xspf
@@ -453,7 +453,7 @@ class Stream {
* have to do a little 'cheating' to make this work, we are going to take
* advantage of tmp_playlists to do all of this hotness
*/
- public function create_xspf_player() {
+ public function create_xspf_player() {
/* Build the extra info we need to have it pass */
$play_info = "?action=show&tmpplaylist_id=" . $GLOBALS['user']->playlist->id;
@@ -462,7 +462,7 @@ class Stream {
//FIXME: This needs to go in a template, here for now though
//FIXME: This preference doesn't even exists, we'll eventually
//FIXME: just make it the default
- if (Config::get('embed_xspf') == 1 ){
+ if (Config::get('embed_xspf') == 1 ){
header("Location: ".Config::get('web_path')."/index.php?xspf&play_info=".$GLOBALS['user']->playlist->id);
}
else {
@@ -474,13 +474,13 @@ class Stream {
// We do a little check here to see if it's a Wii!
if (false !== stristr($_SERVER['HTTP_USER_AGENT'], 'Nintendo Wii')) {
echo "window.location=URL;\n";
- }
+ }
// Else go ahead and do the normal stuff
else {
echo "window.open(URL, 'XSPF_player', 'width=400,height=170,scrollbars=0,toolbar=0,location=0,directories=0,status=0,resizable=0');\n";
echo "window.location = '" . return_referer() . "';\n";
echo "return false;\n";
- }
+ }
echo "}\n";
echo "// end -->\n";
echo "</script>\n";
@@ -491,41 +491,41 @@ class Stream {
echo "</html>\n";
}
} // create_xspf_player
-
+
/**
* create_localplay
- * This calls the Localplay API and attempts to
+ * This calls the Localplay API and attempts to
* add, and then start playback
*/
- public function create_localplay() {
+ public function create_localplay() {
// First figure out what their current one is and create the object
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->connect();
- foreach ($this->media as $element) {
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->connect();
+ foreach ($this->media as $element) {
$type = array_shift($element);
- switch ($type) {
- case 'video':
+ switch ($type) {
+ case 'video':
// Add check for video support
- case 'song':
- case 'radio':
- case 'random':
- $media = new $type(array_shift($element));
- break;
- default:
- $media = array_shift($element);
- break;
- } // switch on types
- $localplay->add($media);
+ case 'song':
+ case 'radio':
+ case 'random':
+ $media = new $type(array_shift($element));
+ break;
+ default:
+ $media = array_shift($element);
+ break;
+ } // switch on types
+ $localplay->add($media);
} // foreach object
/**
* Add urls after the fact
*/
- foreach ($this->urls as $url) {
- $localplay->add($url);
- }
-
+ foreach ($this->urls as $url) {
+ $localplay->add($url);
+ }
+
$localplay->play();
} // create_localplay
@@ -535,10 +535,10 @@ class Stream {
* This 'votes' on the songs it inserts them into
* a tmp_playlist with user of -1 (System)
*/
- public function create_democratic() {
+ public function create_democratic() {
$democratic = Democratic::get_current_playlist();
- $democratic->set_parent();
+ $democratic->set_parent();
$democratic->vote($this->media);
} // create_democratic
@@ -548,21 +548,21 @@ class Stream {
* This prompts for a download of the song, only a single
* element can by in song_ids
*/
- private function create_download() {
+ private function create_download() {
- // There should only be one here...
- foreach ($this->media as $element) {
+ // There should only be one here...
+ foreach ($this->media as $element) {
$type = array_shift($element);
$media = new $type(array_shift($element));
- $url = call_user_func(array($type,'play_url'),$media->id);
-
+ $url = call_user_func(array($type,'play_url'),$media->id);
+
// Append the fact we are downloading
- $url .= '&action=download';
+ $url .= '&action=download';
// Header redirect baby!
- header("Location: $url");
- exit;
- }
+ header("Location: $url");
+ exit;
+ }
} //create_download
@@ -570,26 +570,26 @@ class Stream {
* create_ram
*this functions creates a RAM file for use by Real Player
*/
- public function create_ram() {
+ public function create_ram() {
header("Cache-control: public");
header("Content-Disposition: filename=ampache_playlist.ram");
header("Content-Type: audio/x-pn-realaudio ram;");
foreach ($this->media as $element) {
$type = array_shift($element);
- echo $url = call_user_func(array($type,'play_url'),array_shift($element)) . "\n";
+ echo $url = call_user_func(array($type,'play_url'),array_shift($element)) . "\n";
} // foreach songs
} // create_ram
/**
* start_downsample
- * This is a rather complext function that starts the downsampling of a song and returns the
+ * This is a rather complext function that starts the downsampling of a song and returns the
* opened file handled a reference to the song object is passed so that the changes we make
- * in here affect the external object, References++
+ * in here affect the external object, References++
*/
public static function start_downsample(&$song,$now_playing_id=0,$song_name=0,$start=0) {
-
+
/* Check to see if bitrates are set if so let's go ahead and optomize! */
$max_bitrate = Config::get('max_bit_rate');
$min_bitrate = Config::get('min_bit_rate');
@@ -611,8 +611,8 @@ class Stream {
$results = Dba::fetch_row($db_results);
// Current number of active streams (current is already in now playing, worst case make it 1)
- $active_streams = intval($results[0]);
- if (!$active_streams) { $active_streams = '1'; }
+ $active_streams = intval($results[0]);
+ if (!$active_streams) { $active_streams = '1'; }
/* If only one user, they'll get all available. Otherwise split up equally. */
$sample_rate = floor($max_bitrate/$active_streams);
@@ -630,7 +630,7 @@ class Stream {
$sample_rate = floor($max_bitrate/$active_streams);
} // end else
- // Never go over the users sample rate
+ // Never go over the users sample rate
if ($sample_rate > $user_sample_rate) { $sample_rate = $user_sample_rate; }
debug_event('downsample',"Downsampled: $active_streams current active streams, downsampling to $sample_rate",'2');
@@ -653,7 +653,7 @@ class Stream {
/* Set the Sample Ratio */
$sample_ratio = $sample_rate/($song->bitrate/1000);
}
-
+
// Set the new size for the song
$song->size = floor($sample_ratio*$song->size);
@@ -677,9 +677,9 @@ class Stream {
$downsample_command = str_replace("%EOF%",$eof,$downsample_command,$eof_exists);
$downsample_command = str_replace("%SAMPLE%",$sample_rate,$downsample_command,$sample_exists);
- if (!$file_exists || !$offset_exists || !$eof_exists || !$sample_exists) {
- debug_event('downsample','Error: Downsample command missing a varaible values are File:' . $file_exists . ' Offset:' . $offset_exists . ' Eof:' . $eof_exists . ' Sample:' . $sample_exists,'1');
- }
+ if (!$file_exists || !$offset_exists || !$eof_exists || !$sample_exists) {
+ debug_event('downsample','Error: Downsample command missing a varaible values are File:' . $file_exists . ' Offset:' . $offset_exists . ' Eof:' . $eof_exists . ' Sample:' . $sample_exists,'1');
+ }
// If we are debugging log this event
$message = "Start Downsample: $downsample_command";
@@ -692,7 +692,7 @@ class Stream {
} // start_downsample
- /**
+ /**
* validate_bitrate
* this function takes a bitrate and returns a valid one
*/
@@ -701,17 +701,17 @@ class Stream {
/* Round to standard bitrates */
$sample_rate = 16*(floor($bitrate/16));
- return $sample_rate;
+ return $sample_rate;
} // validate_bitrate
/**
* gc_now_playing
- * This will garbage collect the now playing data,
+ * This will garbage collect the now playing data,
* this is done on every play start
*/
- public static function gc_now_playing() {
+ public static function gc_now_playing() {
// Remove any now playing entries for session_streams that have been GC'd
$sql = "DELETE FROM `now_playing` USING `now_playing` " .
@@ -731,7 +731,7 @@ class Stream {
$time = intval(time()+$length);
$session_id = Dba::escape($sid);
- $object_type = Dba::escape(strtolower($type));
+ $object_type = Dba::escape(strtolower($type));
// Do a replace into ensuring that this client always only has a single row
$sql = "REPLACE INTO `now_playing` (`id`,`object_id`,`object_type`, `user`, `expire`)" .
@@ -758,7 +758,7 @@ class Stream {
* get_now_playing
* This returns the now playing information
*/
- public static function get_now_playing($filter=NULL) {
+ public static function get_now_playing($filter=NULL) {
$sql = "SELECT `session_stream`.`agent`,`now_playing`.* " .
"FROM `now_playing` " .
@@ -766,17 +766,17 @@ class Stream {
"ORDER BY `now_playing`.`expire` DESC";
$db_results = Dba::read($sql);
- $results = array();
+ $results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- $type = $row['object_type'];
- $media = new $type($row['object_id']);
- $media->format();
- $client = new User($row['user']);
- $results[] = array('media'=>$media,'client'=>$client,'agent'=>$row['agent'],'expire'=>$row['expire']);
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $type = $row['object_type'];
+ $media = new $type($row['object_id']);
+ $media->format();
+ $client = new User($row['user']);
+ $results[] = array('media'=>$media,'client'=>$client,'agent'=>$row['agent'],'expire'=>$row['expire']);
} // end while
- return $results;
+ return $results;
} // get_now_playing
@@ -785,20 +785,20 @@ class Stream {
* This checks to see if the media is already being played, if it is then it returns false
* else return true
*/
- public static function check_lock_media($media_id,$type) {
+ public static function check_lock_media($media_id,$type) {
- $media_id = Dba::escape($media_id);
- $type = Dba::escape($type);
+ $media_id = Dba::escape($media_id);
+ $type = Dba::escape($type);
- $sql = "SELECT `object_id` FROM `now_playing` WHERE `object_id`='$media_id' AND `object_type`='$type'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `object_id` FROM `now_playing` WHERE `object_id`='$media_id' AND `object_type`='$type'";
+ $db_results = Dba::read($sql);
- if (Dba::num_rows($db_results)) {
- debug_event('Stream','Unable to play media currently locked by another user','3');
+ if (Dba::num_rows($db_results)) {
+ debug_event('Stream','Unable to play media currently locked by another user','3');
return false;
- }
+ }
- return true;
+ return true;
} // check_lock_media
@@ -806,7 +806,7 @@ class Stream {
* auto_init
* This is called on class load it sets the session
*/
- public static function _auto_init() {
+ public static function _auto_init() {
// Generate the session ID
self::$session = md5(uniqid(rand(), true));
@@ -817,31 +817,31 @@ class Stream {
* run_playlist_method
* This takes care of the different types of 'playlist methods' the reason this is here
* is because it deals with streaming rather then playlist mojo. If something needs to happen
- * this will echo the javascript required to cause a reload of the iframe.
+ * this will echo the javascript required to cause a reload of the iframe.
*/
- public static function run_playlist_method() {
+ public static function run_playlist_method() {
- // If this wasn't ajax included run away
- if (AJAX_INCLUDE != '1') { return false; }
+ // If this wasn't ajax included run away
+ if (AJAX_INCLUDE != '1') { return false; }
// If we're doin the flash magic then run away as well
- if (Config::get('play_type') == 'xspf_player') { return false; }
+ if (Config::get('play_type') == 'xspf_player') { return false; }
- switch (Config::get('playlist_method')) {
- default:
- case 'clear':
- case 'default':
- return true;
+ switch (Config::get('playlist_method')) {
+ default:
+ case 'clear':
+ case 'default':
+ return true;
break;
- case 'send':
+ case 'send':
$_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket';
break;
- case 'send_clear':
- $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket&playlist_method=clear';
- break;
- } // end switch on method
+ case 'send_clear':
+ $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket&playlist_method=clear';
+ break;
+ } // end switch on method
- // Load our javascript
+ // Load our javascript
echo "<script type=\"text/javascript\">";
//echo "reload_util();";
echo "reload_util('".$_SESSION['iframe']['target']."');";
@@ -853,7 +853,7 @@ class Stream {
* get_base_url
* This returns the base requirements for a stream URL this does not include anything after the index.php?sid=????
*/
- public static function get_base_url() {
+ public static function get_base_url() {
if (Config::get('require_session')) {
$session_string = 'ssid=' . Stream::get_session() . '&';
@@ -864,18 +864,18 @@ class Stream {
if (Config::get('force_http_play') OR !empty(self::$force_http)) {
$web_path = str_replace("https://", "http://",$web_path);
}
- if (Config::get('http_port') != '80') {
- if (preg_match("/:(\d+)/",$web_path,$matches)) {
- $web_path = str_replace(':' . $matches['1'],':' . Config::get('http_port'),$web_path);
- }
- else {
- $web_path = str_replace($_SERVER['HTTP_HOST'],$_SERVER['HTTP_HOST'] . ':' . Config::get('http_port'),$web_path);
- }
- }
-
- $url = $web_path . "/play/index.php?$session_string";
-
- return $url;
+ if (Config::get('http_port') != '80') {
+ if (preg_match("/:(\d+)/",$web_path,$matches)) {
+ $web_path = str_replace(':' . $matches['1'],':' . Config::get('http_port'),$web_path);
+ }
+ else {
+ $web_path = str_replace($_SERVER['HTTP_HOST'],$_SERVER['HTTP_HOST'] . ':' . Config::get('http_port'),$web_path);
+ }
+ }
+
+ $url = $web_path . "/play/index.php?$session_string";
+
+ return $url;
} // get_base_url
diff --git a/lib/class/tag.class.php b/lib/class/tag.class.php
index 1fa9b48b..5fb6cc18 100644
--- a/lib/class/tag.class.php
+++ b/lib/class/tag.class.php
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
@@ -26,26 +26,26 @@
*/
class Tag extends database_object {
- public $id;
- public $name;
+ public $id;
+ public $name;
// constructed
- public $weight=0;
- public $count=0;
- public $owner=0;
+ public $weight=0;
+ public $count=0;
+ public $owner=0;
/**
* constructor
* This takes a tag id and returns all of the relevent information
*/
- public function __construct($id) {
+ public function __construct($id) {
- if (!$id) { return false; }
+ if (!$id) { return false; }
- $info = $this->get_info($id);
+ $info = $this->get_info($id);
- foreach ($info as $key=>$value) {
- $this->$key = $value;
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
} // end foreach
} // constructor
@@ -54,14 +54,14 @@ class Tag extends database_object {
* construct_from_name
* This attempts to construct the tag from a name, rather then the ID
*/
- public static function construct_from_name($name) {
+ public static function construct_from_name($name) {
- $tag_id = self::tag_exists($name);
+ $tag_id = self::tag_exists($name);
- $tag = new Tag($tag_id);
+ $tag = new Tag($tag_id);
+
+ return $tag;
- return $tag;
-
} // construct_from_name
/**
@@ -69,31 +69,31 @@ class Tag extends database_object {
* This makes the tag presentable to the great humans that use this program, other life forms
* will just have to fend for themselves
*/
- public function format($type=0,$object_id=0) {
+ public function format($type=0,$object_id=0) {
- if ($type AND !self::validate_type($type)) { return false; }
+ if ($type AND !self::validate_type($type)) { return false; }
- if ($type) {
- $this->set_object($type,$object_id);
- }
+ if ($type) {
+ $this->set_object($type,$object_id);
+ }
- $size = 3 + ($this->weight-1) - ($this->count-1);
- if (abs($size) > 4) { $size = 4; }
- if (abs($size) < 1) { $size = 1; }
+ $size = 3 + ($this->weight-1) - ($this->count-1);
+ if (abs($size) > 4) { $size = 4; }
+ if (abs($size) < 1) { $size = 1; }
- if ($this->owner == $GLOBALS['user']->id) {
- $action = '?page=tag&action=remove_tag&type=' . scrub_out($type) . '&tag_id=' . intval($this->id) . '&object_id=' . intval($object_id);
- $class = "hover-remove ";
- }
- else {
- $action = '?page=tag&action=add_tag&type=' . scrub_out($type) . '&tag_id=' . intval($this->id) . '&object_id=' . intval($object_id);
- $class = "hover-add ";
- }
+ if ($this->owner == $GLOBALS['user']->id) {
+ $action = '?page=tag&action=remove_tag&type=' . scrub_out($type) . '&tag_id=' . intval($this->id) . '&object_id=' . intval($object_id);
+ $class = "hover-remove ";
+ }
+ else {
+ $action = '?page=tag&action=add_tag&type=' . scrub_out($type) . '&tag_id=' . intval($this->id) . '&object_id=' . intval($object_id);
+ $class = "hover-add ";
+ }
- $class .= 'tag_size' . $size;
- $this->f_class = $class;
+ $class .= 'tag_size' . $size;
+ $this->f_class = $class;
- $this->f_name = Ajax::text($action,$this->name,'modify_tag_' . $this->id . '_' . $object_id,'',$class);
+ $this->f_name = Ajax::text($action,$this->name,'modify_tag_' . $this->id . '_' . $object_id,'',$class);
} // format
@@ -102,26 +102,26 @@ class Tag extends database_object {
* This assoicates the tag with a specified object, we try to get the data
* from the map cache, otherwise I guess we'll just have to look it up
*/
- public function set_object($type,$object_id) {
+ public function set_object($type,$object_id) {
- if (parent::is_cached('tag_top_' . $type,$object_id)) {
- $data = parent::get_from_cache('tag_top_' . $type,$object_id);
- }
- else {
- $data = self::get_top_tags($type,$object_id);
- }
+ if (parent::is_cached('tag_top_' . $type,$object_id)) {
+ $data = parent::get_from_cache('tag_top_' . $type,$object_id);
+ }
+ else {
+ $data = self::get_top_tags($type,$object_id);
+ }
// If nothing is found, then go ahead and return false
- if (!is_array($data) OR !count($data)) { return false; }
+ if (!is_array($data) OR !count($data)) { return false; }
+
+ $this->weight = $data[$this->id]['count'];
+
+ if (in_array($GLOBALS['user']->id,$data[$this->id]['users'])) {
+ $this->owner = $GLOBALS['user']->id;
+ }
- $this->weight = $data[$this->id]['count'];
+ $this->count = count($data);
- if (in_array($GLOBALS['user']->id,$data[$this->id]['users'])) {
- $this->owner = $GLOBALS['user']->id;
- }
-
- $this->count = count($data);
-
} // set_object
/**
@@ -129,18 +129,18 @@ class Tag extends database_object {
* This takes an array of object ids and caches all of their information
* in a single query, cuts down on the connections
*/
- public static function build_cache($ids) {
-
+ public static function build_cache($ids) {
+
if (!is_array($ids) OR !count($ids)) { return false; }
- $idlist = '(' . implode(',',$ids) . ')';
-
- $sql = "SELECT * FROM `tag` WHERE `id` IN $idlist";
- $db_results = Dba::read($sql);
+ $idlist = '(' . implode(',',$ids) . ')';
+
+ $sql = "SELECT * FROM `tag` WHERE `id` IN $idlist";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('tag',$row['id'],$row);
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ parent::add_to_cache('tag',$row['id'],$row);
+ }
return true;
} // build_cache
@@ -149,69 +149,69 @@ class Tag extends database_object {
* build_map_cache
* This builds a cache of the mappings for the specified object, no limit is given
*/
- public static function build_map_cache($type,$ids) {
+ public static function build_map_cache($type,$ids) {
if (!is_array($ids) OR !count($ids)) { return false; }
$type = self::validate_type($type);
- $idlist = '(' . implode(',',$ids) . ')';
+ $idlist = '(' . implode(',',$ids) . ')';
$sql = "SELECT `tag_map`.`id`,`tag_map`.`tag_id`,`tag_map`.`object_id`,`tag_map`.`user` FROM `tag_map` " .
"WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id` IN $idlist ";
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
- $tags = array();
+ $tags = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- $tags[$row['object_id']][$row['tag_id']]['users'][] = $row['user'];
- $tags[$row['object_id']][$row['tag_id']]['count']++;
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $tags[$row['object_id']][$row['tag_id']]['users'][] = $row['user'];
+ $tags[$row['object_id']][$row['tag_id']]['count']++;
$tag_map[$row['object_id']] = array('id'=>$row['id'],'tag_id'=>$row['tag_id'],'user'=>$row['user'],'object_type'=>$type,'object_id'=>$row['object_id']);
}
// Run through our origional ids as we want to cache NULL results
- foreach ($ids as $id) {
- parent::add_to_cache('tag_top_' . $type,$id,$tags[$id]);
- parent::add_to_cache('tag_map_' . $type,$id,$tag_map[$id]);
- }
+ foreach ($ids as $id) {
+ parent::add_to_cache('tag_top_' . $type,$id,$tags[$id]);
+ parent::add_to_cache('tag_map_' . $type,$id,$tag_map[$id]);
+ }
- return true;
+ return true;
} // build_map_cache
/**
* add
* This is a wrapper function, it figures out what we need to add, be it a tag
- * and map, or just the mapping
+ * and map, or just the mapping
*/
- public static function add($type,$id,$value,$user=false) {
+ public static function add($type,$id,$value,$user=false) {
// Validate the tag type
- if (!self::validate_type($type)) { return false; }
+ if (!self::validate_type($type)) { return false; }
- if (!is_numeric($id)) { return false; }
+ if (!is_numeric($id)) { return false; }
- $cleaned_value = self::clean_tag($value);
+ $cleaned_value = self::clean_tag($value);
- if (!strlen($cleaned_value)) { return false; }
+ if (!strlen($cleaned_value)) { return false; }
$uid = ($user === false) ? intval($user) : intval($GLOBALS['user']->id);
// Check and see if the tag exists, if not create it, we need the tag id from this
- if (!$tag_id = self::tag_exists($cleaned_value)) {
- $tag_id = self::add_tag($cleaned_value);
- }
+ if (!$tag_id = self::tag_exists($cleaned_value)) {
+ $tag_id = self::add_tag($cleaned_value);
+ }
- if (!$tag_id) {
- debug_event('Error','Error unable to create tag value:' . $cleaned_value . ' unknown error','1');
- return false;
- }
+ if (!$tag_id) {
+ debug_event('Error','Error unable to create tag value:' . $cleaned_value . ' unknown error','1');
+ return false;
+ }
// We've got the tag id, let's see if it's already got a map, if not then create the map and return the value
- if (!$map_id = self::tag_map_exists($type,$id,$tag_id,$user)) {
- $map_id = self::add_tag_map($type,$id,$tag_id,$user);
+ if (!$map_id = self::tag_map_exists($type,$id,$tag_id,$user)) {
+ $map_id = self::add_tag_map($type,$id,$tag_id,$user);
}
- return $map_id;
+ return $map_id;
} // add
@@ -220,21 +220,21 @@ class Tag extends database_object {
* This function adds a new tag, for now we're going to limit the tagging a bit
*/
public static function add_tag($value) {
-
+
// Clean it up and make it tagish
- $value = self::clean_tag($value);
+ $value = self::clean_tag($value);
+
+ if (!strlen($value)) { return false; }
- if (!strlen($value)) { return false; }
-
- $value = Dba::escape($value);
+ $value = Dba::escape($value);
$sql = "REPLACE INTO `tag` SET `name`='$value'";
$db_results = Dba::write($sql);
- $insert_id = Dba::insert_id();
+ $insert_id = Dba::insert_id();
- parent::add_to_cache('tag_name',$value,$insert_id);
+ parent::add_to_cache('tag_name',$value,$insert_id);
- return $insert_id;
+ return $insert_id;
} // add_tag
@@ -242,75 +242,75 @@ class Tag extends database_object {
* add_tag_map
* This adds a specific tag to the map for specified object
*/
- public static function add_tag_map($type,$object_id,$tag_id,$user='') {
-
- $uid = ($user == '') ? intval($GLOBALS['user']->id) : intval($user);
- $tag_id = intval($tag_id);
- if (!self::validate_type($type)) { return false; }
- $id = intval($object_id);
-
- if (!$tag_id || !$id) { return false; }
-
+ public static function add_tag_map($type,$object_id,$tag_id,$user='') {
+
+ $uid = ($user == '') ? intval($GLOBALS['user']->id) : intval($user);
+ $tag_id = intval($tag_id);
+ if (!self::validate_type($type)) { return false; }
+ $id = intval($object_id);
+
+ if (!$tag_id || !$id) { return false; }
+
$sql = "INSERT INTO `tag_map` (`tag_id`,`user`,`object_type`,`object_id`) " .
"VALUES ('$tag_id','$uid','$type','$id')";
$db_results = Dba::write($sql);
- $insert_id = Dba::insert_id();
+ $insert_id = Dba::insert_id();
- parent::add_to_cache('tag_map_' . $type,$insert_id,array('tag_id'=>$tag_id,'user'=>$uid,'object_type'=>$type,'object_id'=>$id));
+ parent::add_to_cache('tag_map_' . $type,$insert_id,array('tag_id'=>$tag_id,'user'=>$uid,'object_type'=>$type,'object_id'=>$id));
- return $insert_id;
+ return $insert_id;
} // add_tag_map
/**
* tag_exists
- * This checks to see if a tag exists, this has nothing to do with objects or maps
+ * This checks to see if a tag exists, this has nothing to do with objects or maps
*/
- public static function tag_exists($value) {
+ public static function tag_exists($value) {
- if (parent::is_cached('tag_name',$value)) {
- return parent::get_from_cache('tag_name',$value);
- }
+ if (parent::is_cached('tag_name',$value)) {
+ return parent::get_from_cache('tag_name',$value);
+ }
- $value = Dba::escape($value);
- $sql = "SELECT * FROM `tag` WHERE `name`='$value'";
- $db_results = Dba::read($sql);
+ $value = Dba::escape($value);
+ $sql = "SELECT * FROM `tag` WHERE `name`='$value'";
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
- parent::add_to_cache('tag_name',$results['name'],$results['id']);
+ parent::add_to_cache('tag_name',$results['name'],$results['id']);
- return $results['id'];
+ return $results['id'];
} // tag_exists
/**
* tag_map_exists
* This looks to see if the current mapping of the current object of the current tag of the current
- * user exists, lots of currents... taste good in scones.
+ * user exists, lots of currents... taste good in scones.
*/
- public static function tag_map_exists($type,$object_id,$tag_id,$user) {
+ public static function tag_map_exists($type,$object_id,$tag_id,$user) {
- if (!self::validate_type($type)) { return false; }
+ if (!self::validate_type($type)) { return false; }
- if (parent::is_cached('tag_map_' . $type,$object_id)) {
+ if (parent::is_cached('tag_map_' . $type,$object_id)) {
$data = parent::get_from_cache('tag_map_' . $type,$object_id);
- return $data['id'];
- }
+ return $data['id'];
+ }
- $object_id = Dba::escape($object_id);
- $tag_id = Dba::escape($tag_id);
- $user = Dba::escape($user);
- $type = Dba::escape($type);
+ $object_id = Dba::escape($object_id);
+ $tag_id = Dba::escape($tag_id);
+ $user = Dba::escape($user);
+ $type = Dba::escape($type);
+
+ $sql = "SELECT * FROM `tag_map` WHERE `tag_id`='$tag_id' AND `user`='$user' AND `object_id`='$object_id' AND `object_type`='$type'";
+ $db_results = Dba::read($sql);
- $sql = "SELECT * FROM `tag_map` WHERE `tag_id`='$tag_id' AND `user`='$user' AND `object_id`='$object_id' AND `object_type`='$type'";
- $db_results = Dba::read($sql);
-
- $results = Dba::fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
- parent::add_to_cache('tag_map_' . $type,$results['id'],$results);
+ parent::add_to_cache('tag_map_' . $type,$results['id'],$results);
- return $results['id'];
+ return $results['id'];
} // tag_map_exists
@@ -318,32 +318,32 @@ class Tag extends database_object {
* get_top_tags
* This gets the top tags for the specified object using limit
*/
- public static function get_top_tags($type,$object_id,$limit='10') {
+ public static function get_top_tags($type,$object_id,$limit='10') {
- if (!self::validate_type($type)) { return false; }
+ if (!self::validate_type($type)) { return false; }
- if (parent::is_cached('tag_top_' . $type,$object_id)) {
- return parent::get_from_cache('tag_top_' . $type,$object_id);
- }
+ if (parent::is_cached('tag_top_' . $type,$object_id)) {
+ return parent::get_from_cache('tag_top_' . $type,$object_id);
+ }
- $object_id = intval($object_id);
- $limit = intval($limit);
+ $object_id = intval($object_id);
+ $limit = intval($limit);
- $sql = "SELECT `tag_map`.`tag_id`,`tag_map`.`user` FROM `tag_map` " .
- "WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id`='$object_id' " .
- "LIMIT $limit";
- $db_results = Dba::read($sql);
+ $sql = "SELECT `tag_map`.`tag_id`,`tag_map`.`user` FROM `tag_map` " .
+ "WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id`='$object_id' " .
+ "LIMIT $limit";
+ $db_results = Dba::read($sql);
- $results = array();
+ $results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[$row['tag_id']]['users'][] = $row['user'];
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[$row['tag_id']]['users'][] = $row['user'];
$results[$row['tag_id']]['count']++;
- }
+ }
- parent::add_to_cache('tag_top_' . $type,$object_id,$results);
+ parent::add_to_cache('tag_top_' . $type,$object_id,$results);
- return $results;
+ return $results;
} // get_top_tags
@@ -354,21 +354,21 @@ class Tag extends database_object {
*/
public static function get_object_tags($type, $id) {
- if (!self::validate_type($type)) { return array(); }
-
- $id = Dba::escape($id);
+ if (!self::validate_type($type)) { return array(); }
+
+ $id = Dba::escape($id);
+
+ $sql = "SELECT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " .
+ "LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " .
+ "WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id`='$id'";
- $sql = "SELECT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " .
- "LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " .
- "WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id`='$id'";
-
$results = array();
$db_results = Dba::read($sql);
-
- while ($row = Dba::fetch_assoc($db_results)) {
+
+ while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row;
}
-
+
return $results;
} // get_object_tags
@@ -377,23 +377,23 @@ class Tag extends database_object {
* get_tag_objects
* This gets the objects from a specified tag and returns an array of object ids, nothing more
*/
- public static function get_tag_objects($type,$tag_id) {
+ public static function get_tag_objects($type,$tag_id) {
- if (!self::validate_type($type)) { return array(); }
+ if (!self::validate_type($type)) { return array(); }
- $tag_id = Dba::escape($tag_id);
+ $tag_id = Dba::escape($tag_id);
- $sql = "SELECT DISTINCT `tag_map`.`object_id` FROM `tag_map` " .
- "WHERE `tag_map`.`tag_id`='$tag_id' AND `tag_map`.`object_type`='$type'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT DISTINCT `tag_map`.`object_id` FROM `tag_map` " .
+ "WHERE `tag_map`.`tag_id`='$tag_id' AND `tag_map`.`object_type`='$type'";
+ $db_results = Dba::read($sql);
- $results = array();
+ $results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- $results[] = $row['object_id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $results[] = $row['object_id'];
+ }
- return $results;
+ return $results;
} // get_tag_objects
@@ -403,27 +403,27 @@ class Tag extends database_object {
* This is a non-object non type depedent function that just returns tags
* we've got, it can take filters (this is used by the tag cloud)
*/
- public static function get_tags($limit,$filters=array()) {
+ public static function get_tags($limit,$filters=array()) {
- $sql = "SELECT `tag_map`.`tag_id`,COUNT(`tag_map`.`object_id`) AS `count` " .
+ $sql = "SELECT `tag_map`.`tag_id`,COUNT(`tag_map`.`object_id`) AS `count` " .
"FROM `tag_map` " .
- "LEFT JOIN `tag` ON `tag`.`id`=`tag_map`.`tag_id` " .
- "GROUP BY `tag`.`name` ORDER BY `count` DESC " .
+ "LEFT JOIN `tag` ON `tag`.`id`=`tag_map`.`tag_id` " .
+ "GROUP BY `tag`.`name` ORDER BY `count` DESC " .
"LIMIT $limit";
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
- $results = array();
+ $results = array();
- while ($row = Dba::fetch_assoc($db_results)) {
- if ($row['count'] > $top) { $top = $row['count']; }
- $results[$row['tag_id']] = array('id'=>$row['tag_id'],'count'=>$row['count']);
- $count+= $row['count'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ if ($row['count'] > $top) { $top = $row['count']; }
+ $results[$row['tag_id']] = array('id'=>$row['tag_id'],'count'=>$row['count']);
+ $count+= $row['count'];
+ }
// Do something with this
- $min = $row['count'];
+ $min = $row['count'];
- return $results;
+ return $results;
} // get_tags
@@ -433,22 +433,22 @@ class Tag extends database_object {
* it also takes a type so that it knows how to return it, this is used
* by the formating functions of the different objects
*/
- public static function get_display($tags,$element_id,$type='song') {
+ public static function get_display($tags,$element_id,$type='song') {
- if (!is_array($tags)) { return ''; }
+ if (!is_array($tags)) { return ''; }
- $results = '';
+ $results = '';
// Itterate through the tags, format them according to type and element id
- foreach ($tags as $tag_id=>$value) {
- $tag = new Tag($tag_id);
- $tag->format($type,$element_id);
- $results .= $tag->f_name . ', ';
- }
+ foreach ($tags as $tag_id=>$value) {
+ $tag = new Tag($tag_id);
+ $tag->format($type,$element_id);
+ $results .= $tag->f_name . ', ';
+ }
- $results = rtrim($results,', ');
+ $results = rtrim($results,', ');
- return $results;
+ return $results;
} // get_display
@@ -457,20 +457,20 @@ class Tag extends database_object {
* This returns the count for the all objects assoicated with this tag
* If a type is specific only counts for said type are returned
*/
- public function count($type='') {
+ public function count($type='') {
- if ($type) {
- $filter_sql = " AND `object_type`='" . Dba::escape($type) . "'";
- }
+ if ($type) {
+ $filter_sql = " AND `object_type`='" . Dba::escape($type) . "'";
+ }
- $results = array();
+ $results = array();
- $sql = "SELECT COUNT(`id`) AS `count`,`object_type` FROM `tag_map` WHERE `tag_id`='" . Dba::escape($this->id) . "'" . $filter_sql . " GROUP BY `object_type`";
- $db_results = Dba::read($sql);
+ $sql = "SELECT COUNT(`id`) AS `count`,`object_type` FROM `tag_map` WHERE `tag_id`='" . Dba::escape($this->id) . "'" . $filter_sql . " GROUP BY `object_type`";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
+ while ($row = Dba::fetch_assoc($db_results)) {
$results[$row['object_type']] = $row['count'];
- }
+ }
return $results;
@@ -484,7 +484,7 @@ class Tag extends database_object {
$colors = array('#0000FF',
'#00FF00', '#FFFF00', '#00FFFF','#FF00FF','#FF0000');
- $prefs = 'tag company';
+ $prefs = 'tag company';
// $prefs = Config::get('tags_userlist');
$ulist = explode(' ', $prefs);
@@ -496,41 +496,41 @@ class Tag extends database_object {
$req = rtrim($req, ',');
$sql = 'SELECT `id`,`username` FROM `user` WHERE ';
-
- if ($prefs=='all') {
+
+ if ($prefs=='all') {
$sql .= '1';
- }
- else {
+ }
+ else {
$sql .= 'username in ('.$req.')';
}
- $db_results = Dba::read($sql);
+ $db_results = Dba::read($sql);
$uids=array();
$usernames = array();
$p = 0;
- while ($r = Dba::fetch_assoc($db_results)) {
+ while ($r = Dba::fetch_assoc($db_results)) {
$usernames[$r['id']] = $r['username'];
$uids[$r['id']] = $colors[$p];
$p++;
- if ($p == sizeof($colors)) {
+ if ($p == sizeof($colors)) {
$p = 0;
- }
+ }
}
-
+
$res = array();
-
+
foreach ($l as $i) {
- if ($GLOBALS['user']->id == $i['user']) {
+ if ($GLOBALS['user']->id == $i['user']) {
$res[] = $i;
- }
+ }
elseif (isset($uids[$i['user']])) {
$i['color'] = $uids[$i['user']];
$i['username'] = $usernames[$i['user']];
$res[] = $i;
}
}
-
+
return $res;
} // filter_with_prefs
@@ -539,19 +539,19 @@ class Tag extends database_object {
* remove_map
* This will only remove tag maps for the current user
*/
- public function remove_map($type,$object_id) {
+ public function remove_map($type,$object_id) {
- if (!self::validate_type($type)) { return false; }
+ if (!self::validate_type($type)) { return false; }
- $type = Dba::escape($type);
- $tag_id = Dba::escape($this->id);
- $object_id = Dba::escape($object_id);
- $user_id = Dba::escape($GLOBALS['user']->id);
+ $type = Dba::escape($type);
+ $tag_id = Dba::escape($this->id);
+ $object_id = Dba::escape($object_id);
+ $user_id = Dba::escape($GLOBALS['user']->id);
- $sql = "DELETE FROM `tag_map` WHERE `tag_id`='$tag_id' AND `object_type`='$type' AND `object_id`='$object_id' AND `user`='$user_id'";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `tag_map` WHERE `tag_id`='$tag_id' AND `object_type`='$type' AND `object_id`='$object_id' AND `user`='$user_id'";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // remove_map
@@ -560,13 +560,13 @@ class Tag extends database_object {
* This validates the type of the object the user wants to tag, we limit this to types
* we currently support
*/
- public static function validate_type($type) {
+ public static function validate_type($type) {
+
+ $valid_array = array('song','artist','album','video','playlist','live_stream');
- $valid_array = array('song','artist','album','video','playlist','live_stream');
-
- if (in_array($type,$valid_array)) { return $type; }
+ if (in_array($type,$valid_array)) { return $type; }
- return false;
+ return false;
} // validate_type
@@ -574,11 +574,11 @@ class Tag extends database_object {
* clean_tag
* This takes a string and makes it Tagish
*/
- public static function clean_tag($value) {
+ public static function clean_tag($value) {
- $tag = preg_replace("/[^\w\_\-\s\&]/","",$value);
+ $tag = preg_replace("/[^\w\_\-\s\&]/","",$value);
- return $tag;
+ return $tag;
} // clean_tag
diff --git a/lib/class/tmpplaylist.class.php b/lib/class/tmpplaylist.class.php
index 615897bb..a2be6e18 100644
--- a/lib/class/tmpplaylist.class.php
+++ b/lib/class/tmpplaylist.class.php
@@ -23,10 +23,10 @@
/**
* TempPlaylist Class
* This class handles the temporary playlists in ampache, it handles the
- * tmp_playlist and tmp_playlist_data tables, and sneaks out at night to
+ * tmp_playlist and tmp_playlist_data tables, and sneaks out at night to
* visit user_vote from time to time
*/
-class tmpPlaylist extends database_object {
+class tmpPlaylist extends database_object {
/* Variables from the Datbase */
public $id;
@@ -36,36 +36,36 @@ class tmpPlaylist extends database_object {
public $base_playlist;
/* Generated Elements */
- public $items = array();
+ public $items = array();
/**
- * Constructor
+ * Constructor
* This takes a playlist_id as an optional argument and gathers the information
- * if not playlist_id is passed returns false (or if it isn't found
+ * if not playlist_id is passed returns false (or if it isn't found
*/
- public function __construct($playlist_id='') {
+ public function __construct($playlist_id='') {
if (!$playlist_id) { return false; }
-
+
$this->id = intval($playlist_id);
$info = $this->_get_info();
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
return true;
} // __construct
- /**
+ /**
* _get_info
- * This is an internal (private) function that gathers the information for this object from the
- * playlist_id that was passed in.
+ * This is an internal (private) function that gathers the information for this object from the
+ * playlist_id that was passed in.
*/
- private function _get_info() {
+ private function _get_info() {
- $sql = "SELECT * FROM `tmp_playlist` WHERE `id`='" . Dba::escape($this->id) . "'";
+ $sql = "SELECT * FROM `tmp_playlist` WHERE `id`='" . Dba::escape($this->id) . "'";
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
@@ -79,22 +79,22 @@ class tmpPlaylist extends database_object {
* This returns a playlist object based on the session that is passed to us
* this is used by the load_playlist on user for the most part
*/
- public static function get_from_session($session_id) {
+ public static function get_from_session($session_id) {
+
+ $session_id = Dba::escape($session_id);
- $session_id = Dba::escape($session_id);
+ $sql = "SELECT `id` FROM `tmp_playlist` WHERE `session`='$session_id'";
+ $db_results = Dba::read($sql);
- $sql = "SELECT `id` FROM `tmp_playlist` WHERE `session`='$session_id'";
- $db_results = Dba::read($sql);
+ $results = Dba::fetch_row($db_results);
- $results = Dba::fetch_row($db_results);
-
- if (!$results['0']) {
- $results['0'] = tmpPlaylist::create($session_id,'user','song');
- }
+ if (!$results['0']) {
+ $results['0'] = tmpPlaylist::create($session_id,'user','song');
+ }
- $playlist = new tmpPlaylist($results['0']);
+ $playlist = new tmpPlaylist($results['0']);
- return $playlist;
+ return $playlist;
} // get_from_session
@@ -103,20 +103,20 @@ class tmpPlaylist extends database_object {
* This returns a tmp playlist object based on a userid passed
* this is used for the user profiles page
*/
- public static function get_from_userid($user_id) {
+ public static function get_from_userid($user_id) {
// This is a little stupid, because we don't have the user_id in the session or
// in the tmp_playlist table we have to do it this way.
- $client = new User($user_id);
- $username = Dba::escape($client->username);
+ $client = new User($user_id);
+ $username = Dba::escape($client->username);
+
+ $sql = "SELECT `tmp_playlist`.`id` FROM `tmp_playlist` LEFT JOIN `session` ON `session`.`id`=`tmp_playlist`.`session` " .
+ " WHERE `session`.`username`='$username' ORDER BY `session`.`expire` DESC";
+ $db_results = Dba::read($sql);
- $sql = "SELECT `tmp_playlist`.`id` FROM `tmp_playlist` LEFT JOIN `session` ON `session`.`id`=`tmp_playlist`.`session` " .
- " WHERE `session`.`username`='$username' ORDER BY `session`.`expire` DESC";
- $db_results = Dba::read($sql);
+ $data = Dba::fetch_assoc($db_results);
- $data = Dba::fetch_assoc($db_results);
-
- return $data['id'];
+ return $data['id'];
} // get_from_userid
@@ -126,20 +126,20 @@ class tmpPlaylist extends database_object {
* has gotten a little more complicated because of type, the values are an array
* 0 being ID 1 being TYPE
*/
- public function get_items() {
+ public function get_items() {
$order = 'ORDER BY id ASC';
-
+
/* Select all objects from this playlist */
- $sql = "SELECT tmp_playlist_data.object_type, tmp_playlist_data.id, tmp_playlist_data.object_id " .
- "FROM tmp_playlist_data " .
+ $sql = "SELECT tmp_playlist_data.object_type, tmp_playlist_data.id, tmp_playlist_data.object_id " .
+ "FROM tmp_playlist_data " .
"WHERE tmp_playlist_data.tmp_playlist='" . Dba::escape($this->id) . "' $order";
$db_results = Dba::read($sql);
-
+
/* Define the array */
$items = array();
- while ($results = Dba::fetch_assoc($db_results)) {
+ while ($results = Dba::fetch_assoc($db_results)) {
$key = $results['id'];
$items[$key] = array($results['object_type'],$results['object_id']);
}
@@ -150,16 +150,16 @@ class tmpPlaylist extends database_object {
/**
* get_next_object
- * This returns the next object in the tmp_playlist most of the time this
+ * This returns the next object in the tmp_playlist most of the time this
* will just be the top entry, but if there is a base_playlist and no
* items in the playlist then it returns a random entry from the base_playlist
*/
- public function get_next_object() {
+ public function get_next_object() {
$tmp_id = Dba::escape($this->id);
$order = " ORDER BY tmp_playlist_data.id DESC";
- $sql = "SELECT tmp_playlist_data.object_id FROM tmp_playlist_data " .
+ $sql = "SELECT tmp_playlist_data.object_id FROM tmp_playlist_data " .
"WHERE tmp_playlist_data.tmp_playlist = '$tmp_id' $order LIMIT 1";
$db_results = Dba::read($sql);
@@ -173,14 +173,14 @@ class tmpPlaylist extends database_object {
* count_items
* This returns a count of the total number of tracks that are in this tmp playlist
*/
- public function count_items() {
+ public function count_items() {
- $sql = "SELECT COUNT(`id`) FROM `tmp_playlist_data` WHERE `tmp_playlist_data`.`tmp_playlist`='" . $this->id . "'";
- $db_results = Dba::read($sql);
+ $sql = "SELECT COUNT(`id`) FROM `tmp_playlist_data` WHERE `tmp_playlist_data`.`tmp_playlist`='" . $this->id . "'";
+ $db_results = Dba::read($sql);
- $results = Dba::fetch_row($db_results);
+ $results = Dba::fetch_row($db_results);
- return $results['0'];
+ return $results['0'];
} // count_items
@@ -188,50 +188,50 @@ class tmpPlaylist extends database_object {
* clear
* This clears all the objects out of a single playlist
*/
- public function clear() {
+ public function clear() {
- $sql = "DELETE FROM `tmp_playlist_data` WHERE `tmp_playlist_data`.`tmp_playlist`='" . $this->id . "'";
- $db_results = Dba::write($sql);
+ $sql = "DELETE FROM `tmp_playlist_data` WHERE `tmp_playlist_data`.`tmp_playlist`='" . $this->id . "'";
+ $db_results = Dba::write($sql);
- return true;
+ return true;
} // clear
- /**
+ /**
* create
* This function initializes a new tmpPlaylist it is assoicated with the current
* session rather then a user, as you could have same user multiple locations
*/
- public static function create($sessid,$type,$object_type) {
+ public static function create($sessid,$type,$object_type) {
$sessid = Dba::escape($sessid);
$type = Dba::escape($type);
$object_type = Dba::escape($object_type);
- $sql = "INSERT INTO `tmp_playlist` (`session`,`type`,`object_type`) " .
+ $sql = "INSERT INTO `tmp_playlist` (`session`,`type`,`object_type`) " .
" VALUES ('$sessid','$type','$object_type')";
$db_results = Dba::write($sql);
$id = Dba::insert_id();
- $do_prune = rand(0,4);
- if ($do_prune%2) {
+ $do_prune = rand(0,4);
+ if ($do_prune%2) {
self::prune_playlists();
- self::prune_tracks();
- }
+ self::prune_tracks();
+ }
/* Clean any other playlists assoicated with this session */
self::delete($sessid,$id);
return $id;
- } // create
+ } // create
/**
* update_playlist
* This updates the base_playlist on this tmp_playlist
*/
- public function update_playlist($playlist_id) {
+ public function update_playlist($playlist_id) {
$playlist_id = Dba::escape($playlist_id);
$tmp_id = Dba::escape($this->id);
@@ -246,9 +246,9 @@ class tmpPlaylist extends database_object {
/**
* delete
* This deletes any other tmp_playlists assoicated with this
- * session
+ * session
*/
- public static function delete($sessid,$id) {
+ public static function delete($sessid,$id) {
$sessid = Dba::escape($sessid);
$id = Dba::escape($id);
@@ -267,11 +267,11 @@ class tmpPlaylist extends database_object {
* prune_playlists
* This deletes and playlists that don't have an assoicated session
*/
- public static function prune_playlists() {
+ public static function prune_playlists() {
/* Just delete if no matching session row */
- $sql = "DELETE FROM `tmp_playlist` USING `tmp_playlist` " .
- "LEFT JOIN session ON session.id=tmp_playlist.session " .
+ $sql = "DELETE FROM `tmp_playlist` USING `tmp_playlist` " .
+ "LEFT JOIN session ON session.id=tmp_playlist.session " .
"WHERE session.id IS NULL AND tmp_playlist.type != 'vote'";
$db_results = Dba::write($sql);
@@ -281,13 +281,13 @@ class tmpPlaylist extends database_object {
/**
* prune_tracks
- * This prunes tracks that don't have playlists or don't have votes
+ * This prunes tracks that don't have playlists or don't have votes
*/
- public static function prune_tracks() {
+ public static function prune_tracks() {
// This prue is always run clears data for playlists that don't have tmp_playlist anymore
- $sql = "DELETE FROM tmp_playlist_data USING tmp_playlist_data " .
- "LEFT JOIN tmp_playlist ON tmp_playlist_data.tmp_playlist=tmp_playlist.id " .
+ $sql = "DELETE FROM tmp_playlist_data USING tmp_playlist_data " .
+ "LEFT JOIN tmp_playlist ON tmp_playlist_data.tmp_playlist=tmp_playlist.id " .
"WHERE tmp_playlist.id IS NULL";
$db_results = Dba::write($sql);
@@ -298,13 +298,13 @@ class tmpPlaylist extends database_object {
* This adds the object of $this->object_type to this tmp playlist
* it takes an optional type, default is song
*/
- public function add_object($object_id,$object_type) {
+ public function add_object($object_id,$object_type) {
$object_id = Dba::escape($object_id);
$playlist_id = Dba::escape($this->id);
- $object_type = $object_type ? Dba::escape($object_type) : 'song';
+ $object_type = $object_type ? Dba::escape($object_type) : 'song';
- $sql = "INSERT INTO `tmp_playlist_data` (`object_id`,`tmp_playlist`,`object_type`) " .
+ $sql = "INSERT INTO `tmp_playlist_data` (`object_id`,`tmp_playlist`,`object_type`) " .
" VALUES ('$object_id','$playlist_id','$object_type')";
$db_results = Dba::write($sql);
@@ -315,12 +315,12 @@ class tmpPlaylist extends database_object {
/**
* vote_active
* This checks to see if this playlist is a voting playlist
- * and if it is active
+ * and if it is active
*/
- public function vote_active() {
+ public function vote_active() {
/* Going to do a little more here later */
- if ($this->type == 'vote') { return true; }
+ if ($this->type == 'vote') { return true; }
return false;
@@ -330,17 +330,17 @@ class tmpPlaylist extends database_object {
* delete_track
* This deletes a track from the tmpplaylist
*/
- public function delete_track($id) {
+ public function delete_track($id) {
$id = Dba::escape($id);
/* delete the track its self */
- $sql = "DELETE FROM `tmp_playlist_data` " .
+ $sql = "DELETE FROM `tmp_playlist_data` " .
" WHERE `id`='$id'";
$db_results = Dba::write($sql);
return true;
} // delete_track
-
+
} // class tmpPlaylist
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index f3ba888c..2fa2bb30 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -329,13 +329,13 @@ class Update {
$version[] = array('version'=>'360001','description'=>$update_string);
- $update_string = '- Add Bandwidth and Feature preferences to simplify how interface is presented<br />' .
- '- Change Tables to FULLTEXT() for improved searching<br />' .
- '- Increase Filename lengths to 4096<br />' .
- '- Remove useless "KEY" reference from ACL and Catalog tables<br />' .
- '- Add new Remote User / Remote Password fields to Catalog<br />';
+ $update_string = '- Add Bandwidth and Feature preferences to simplify how interface is presented<br />' .
+ '- Change Tables to FULLTEXT() for improved searching<br />' .
+ '- Increase Filename lengths to 4096<br />' .
+ '- Remove useless "KEY" reference from ACL and Catalog tables<br />' .
+ '- Add new Remote User / Remote Password fields to Catalog<br />';
- $version[] = array('version'=>'360002','description'=>$update_string);
+ $version[] = array('version'=>'360002','description'=>$update_string);
return $version;
@@ -1811,52 +1811,52 @@ class Update {
* This update makes changes to the cataloging to accomodate the new method for syncing between
* Ampache instances, could be adapted to sync with whatever for "full" catalog
*/
- public static function update_360002() {
+ public static function update_360002() {
// Drop the key from catalog and ACL
- $sql = "ALTER TABLE `catalog` DROP `key`";
- $db_results = Dba::write($sql);
+ $sql = "ALTER TABLE `catalog` DROP `key`";
+ $db_results = Dba::write($sql);
- $sql = "ALTER TABLE `access_list` DROP `key`";
- $db_results = Dba::write($sql);
+ $sql = "ALTER TABLE `access_list` DROP `key`";
+ $db_results = Dba::write($sql);
- // Add in Username / Password for catalog - to be used for remote catalogs
- $sql = "ALTER TABLE `catalog` ADD `remote_username` VARCHAR ( 255 ) AFTER `user`";
- $db_results = Dba::write($sql);
+ // Add in Username / Password for catalog - to be used for remote catalogs
+ $sql = "ALTER TABLE `catalog` ADD `remote_username` VARCHAR ( 255 ) AFTER `user`";
+ $db_results = Dba::write($sql);
- $sql = "ALTER TABLE `catalog` ADD `remote_password` VARCHAR ( 255 ) AFTER `remote_username`";
- $db_results = Dba::write($sql);
+ $sql = "ALTER TABLE `catalog` ADD `remote_password` VARCHAR ( 255 ) AFTER `remote_username`";
+ $db_results = Dba::write($sql);
// Adjust the Filename field in song, make it gi-normous. If someone has anything close to
- // this file length, they seriously need to reconsider what they are doing.
- $sql = "ALTER TABLE `song` CHANGE `file` `file` VARCHAR ( 4096 )";
- $db_results = Dba::write($sql);
+ // this file length, they seriously need to reconsider what they are doing.
+ $sql = "ALTER TABLE `song` CHANGE `file` `file` VARCHAR ( 4096 )";
+ $db_results = Dba::write($sql);
+
+ $sql = "ALTER TABLE `video` CHANGE `file` `file` VARCHAR ( 4096 )";
+ $db_results = Dba::write($sql);
- $sql = "ALTER TABLE `video` CHANGE `file` `file` VARCHAR ( 4096 )";
- $db_results = Dba::write($sql);
+ $sql = "ALTER TABLE `live_stream` CHANGE `url` `url` VARCHAR ( 4096 )";
+ $db_results = Dba::write($sql);
- $sql = "ALTER TABLE `live_stream` CHANGE `url` `url` VARCHAR ( 4096 )";
- $db_results = Dba::write($sql);
-
// Index the Artist, Album, and Song tables to prepare for Fulltext searches.
$sql = "ALTER TABLE `artist` ADD FULLTEXT(`name`)";
$db_results = Dba::write($sql);
-
+
$sql = "ALTER TABLE `album` ADD FULLTEXT(`name`)";
$db_results = Dba::write($sql);
-
+
$sql = "ALTER TABLE `song` ADD FULLTEXT(`title`)";
$db_results = Dba::write($sql);
-
+
// Now add in the min_object_count preference and the random_method
$sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('bandwidth','50','Bandwidth','5','integer','interface')";
$db_results = Dba::write($sql);
- $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
- "VALUES ('features','50','Features','5','integer','interface')";
- $db_results = Dba::write($sql);
-
+ $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
+ "VALUES ('features','50','Features','5','integer','interface')";
+ $db_results = Dba::write($sql);
+
/* Fix every users preferences */
$sql = "SELECT `id` FROM `user`";
$db_results = Dba::read($sql);
@@ -1866,7 +1866,7 @@ class Update {
while ($r = Dba::fetch_assoc($db_results)) {
User::fix_preferences($r['id']);
} // while results
-
+
self::set_version('db_version','360002');
} // update_360002
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index 4ba750d1..f4bc68b5 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -198,9 +198,9 @@ class User extends database_object {
$sql = "SELECT preference.name, preference.description, preference.catagory, preference.level, user_preference.value " .
"FROM preference INNER JOIN user_preference ON user_preference.preference=preference.id " .
- "WHERE user_preference.user='$user_id' " . $user_limit .
+ "WHERE user_preference.user='$user_id' " . $user_limit .
" ORDER BY preference.catagory, preference.description";
-
+
$db_results = Dba::read($sql);
/* Ok this is crapy, need to clean this up or improve the code FIXME */
@@ -729,10 +729,10 @@ class User extends database_object {
/* Get Users Last ip */
if (count($data = $this->get_ip_history(1))) {
$this->ip_history = inet_ntop($data['0']['ip']);
- }
- else {
- $this->ip_history = _('Not Enough Data');
- }
+ }
+ else {
+ $this->ip_history = _('Not Enough Data');
+ }
} // format_user
diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php
index 692d0229..152cc67d 100644
--- a/lib/class/vainfo.class.php
+++ b/lib/class/vainfo.class.php
@@ -23,15 +23,15 @@
/**
* vainfo
* This class takes the information pulled from getID3 and returns it in a
- * Ampache friendly way.
+ * Ampache friendly way.
*/
-class vainfo {
+class vainfo {
/* Default Encoding */
public $encoding = '';
public $encoding_id3v1 = 'ISO-8859-1';
public $encoding_id3v2 = 'ISO-8859-1';
-
+
/* Loaded Variables */
public $filename = '';
public $type = '';
@@ -41,33 +41,33 @@ class vainfo {
public $_raw = array();
public $_raw2 = array();
public $_getID3 = '';
- public $_iconv = false;
+ public $_iconv = false;
public $_file_encoding = '';
public $_file_pattern = '';
public $_dir_pattern = '';
/* Internal Private */
- private $_binary_parse = array();
- private $_pathinfo;
- private $_broken=false;
+ private $_binary_parse = array();
+ private $_pathinfo;
+ private $_broken=false;
/**
* Constructor
* This function just sets up the class, it doesn't
* actually pull the information
*/
- public function __construct($file,$encoding='',$encoding_id3v1='',$encoding_id3v2='',$dir_pattern,$file_pattern) {
+ public function __construct($file,$encoding='',$encoding_id3v1='',$encoding_id3v2='',$dir_pattern,$file_pattern) {
/* Check for ICONV */
- if (function_exists('iconv')) {
+ if (function_exists('iconv')) {
$this->_iconv = true;
}
$this->filename = $file;
- if ($encoding) {
+ if ($encoding) {
$this->encoding = $encoding;
}
- else {
+ else {
$this->encoding = Config::get('site_charset');
}
@@ -82,20 +82,20 @@ class vainfo {
else {
$this->_pathinfo = pathinfo(str_replace('%2F', '/', urlencode($this->filename)));
}
- $this->_pathinfo['extension'] = strtolower($this->_pathinfo['extension']);
+ $this->_pathinfo['extension'] = strtolower($this->_pathinfo['extension']);
// Before we roll the _getID3 route let's see about using exec + a binary
/*
- if (!isset($this->_binary_parse[$this->_pathinfo['extension']])) {
+ if (!isset($this->_binary_parse[$this->_pathinfo['extension']])) {
// Figure out if we've got binary parse ninja-skills here
- $this->_binary_parse[$this->_pathinfo['extension']] = $this->can_binary_parse();
- debug_event('BinaryParse','Binary Parse for ' . $this->_pathinfo['extension'] . ' set to ' . make_bool($this->_binary_parse[$this->_pathinfo['extension']]),'5');
- }
+ $this->_binary_parse[$this->_pathinfo['extension']] = $this->can_binary_parse();
+ debug_event('BinaryParse','Binary Parse for ' . $this->_pathinfo['extension'] . ' set to ' . make_bool($this->_binary_parse[$this->_pathinfo['extension']]),'5');
+ }
*/
// Initialize getID3 engine
$this->_getID3 = new getID3();
-// if ($this->_binary_parse[$this->_pathinfo['extension']]) { return true; }
+// if ($this->_binary_parse[$this->_pathinfo['extension']]) { return true; }
// get id3tag encodings
// we have to run this right here because we don't know what we have in the files
@@ -105,9 +105,9 @@ class vainfo {
}
catch (Exception $error) {
debug_event('Getid3()',"Broken file detected $file - " . $error->message,'1');
- $this->_broken = true;
- return false;
- }
+ $this->_broken = true;
+ return false;
+ }
if(function_exists('mb_detect_encoding')) {
$this->encoding_id3v1 = array();
@@ -122,7 +122,7 @@ class vainfo {
} else {
$this->encoding_id3v1 = "ISO-8859-1";
}
-
+
$this->encoding_id3v2 = array();
$this->encoding_id3v2[] = mb_detect_encoding($this->_raw2['tags']['id3v2']['artist']['0']);
@@ -147,10 +147,10 @@ class vainfo {
$this->_getID3->option_tags_html = false;
$this->_getID3->option_extra_info = true;
$this->_getID3->option_tag_lyrics3 = true;
- $this->_getID3->encoding = $this->encoding;
+ $this->_getID3->encoding = $this->encoding;
$this->_getID3->encoding_id3v1 = $this->encoding_id3v1;
$this->_getID3->encoding_id3v2 = $this->encoding_id3v2;
- $this->_getID3->option_tags_process = true;
+ $this->_getID3->option_tags_process = true;
} // vainfo
@@ -164,41 +164,41 @@ class vainfo {
*/
public function get_info() {
- // If this is broken, don't waste time figuring it out a second time, just return
+ // If this is broken, don't waste time figuring it out a second time, just return
// their rotting carcass of a media file back on the pile
- if ($this->_broken) {
- $this->tags = $this->set_broken();
- return true;
- }
+ if ($this->_broken) {
+ $this->tags = $this->set_broken();
+ return true;
+ }
// If we've got a green light try out the binary
-// if ($this->_binary_parse[$this->_pathinfo['extension']]) {
-// $this->run_binary_parse();
-// }
-
-// else {
+// if ($this->_binary_parse[$this->_pathinfo['extension']]) {
+// $this->run_binary_parse();
+// }
+
+// else {
/* Get the Raw file information */
- try {
+ try {
$this->_raw = $this->_getID3->analyze($this->filename);
- }
- catch (Exception $error) {
+ }
+ catch (Exception $error) {
debug_event('Getid3()',"Unable to catalog file:" . $error->message,'1');
- }
+ }
/* Figure out what type of file we are dealing with */
$this->type = $this->_get_type();
/* Get the general information about this file */
$info = $this->_get_info();
-// }
+// }
/* Gets the Tags */
$this->tags = $this->_get_tags();
$this->tags['info'] = $info;
unset($this->_raw);
-
+
} // get_info
/**
@@ -207,7 +207,7 @@ class vainfo {
* As defined by your config file and trys to figure out
* which tag type(s) it should use, if your tag_order
* doesn't match anything then it just takes the first one
- * it finds in the results.
+ * it finds in the results.
*/
public static function get_tag_type($results) {
@@ -217,7 +217,7 @@ class vainfo {
if (!is_array($order)) {
$order = array($order);
}
-
+
/* Foreach through the defined key order
* adding them to an ordered array as we go
*/
@@ -244,8 +244,8 @@ class vainfo {
/**
* clean_tag_info
- * This function takes the array from vainfo along with the
- * key we've decided on and the filename and returns it in a
+ * This function takes the array from vainfo along with the
+ * key we've decided on and the filename and returns it in a
* sanatized format that ampache can actually use
*/
public static function clean_tag_info($results,$keys,$filename) {
@@ -275,11 +275,11 @@ class vainfo {
// Specific Audio Flags
foreach ($keys as $key) {
- if (!$results[$key]['video_codec']) {
- $slash_point = strpos($results[$key]['disk'],'/');
- if ($slash_point !== FALSE) {
- $results[$key]['disk'] = substr($results[$key]['disk'],0,$slash_point);
- }
+ if (!$results[$key]['video_codec']) {
+ $slash_point = strpos($results[$key]['disk'],'/');
+ if ($slash_point !== FALSE) {
+ $results[$key]['disk'] = substr($results[$key]['disk'],0,$slash_point);
+ }
/* These are used to generate the correct ID's later */
$info['title'] = $info['title']
? $info['title']
@@ -331,16 +331,16 @@ class vainfo {
$info['language'] = $info['language']
? $info['language']
: Dba::escape($results[$key]['language']);
-
+
$info['lyrics'] = $info['lyrics']
? $info['lyrics']
: str_replace(array("\r\n","\r","\n"), '<br />',strip_tags($results[$key]['unsynchronised lyric']));
- $info['track'] = $info['track']
+ $info['track'] = $info['track']
? $info['track']
: intval($results[$key]['track']);
}
- else {
+ else {
$info['resolution_x'] = $info['resolution_x']
? $info['resolution_x']
: intval($results[$key]['resolution_x']);
@@ -355,7 +355,7 @@ class vainfo {
$info['video_codec'] = $info['video_codec']
? $info['video_codec']
- : Dba::escape($results[$key]['video_codec']);
+ : Dba::escape($results[$key]['video_codec']);
}
}
// Lyrics3 v2.0
@@ -370,23 +370,23 @@ class vainfo {
/**
* _get_type
* This function takes the raw information and figures out
- * what type of file we are dealing with for use by the tag
+ * what type of file we are dealing with for use by the tag
* function
*/
- public function _get_type() {
+ public function _get_type() {
/* There are a few places that the file type can
- * come from, in the end we trust the encoding
+ * come from, in the end we trust the encoding
* type
*/
- if ($type = $this->_raw['video']['dataformat']) {
+ if ($type = $this->_raw['video']['dataformat']) {
// Manually set the tag information
- if ($type == 'flv') {
- $this->_raw['tags']['flv'] = array();
- }
- if ($type == 'quicktime') {
- $this->_raw['tags']['quicktime'] = array();
- }
+ if ($type == 'flv') {
+ $this->_raw['tags']['flv'] = array();
+ }
+ if ($type == 'quicktime') {
+ $this->_raw['tags']['quicktime'] = array();
+ }
if($type == 'mpeg' OR $type == 'mpg') {
$this->_raw['tags']['mpeg'] = array();
}
@@ -396,21 +396,21 @@ class vainfo {
if($type == 'wmv') {
$this->_raw['tags']['wmv'] = array();
}
- else {
- $this->_raw['tags']['avi'] = array();
- }
- $type = $this->_clean_type($type);
- return $type;
- }
- if ($type = $this->_raw['audio']['streams']['0']['dataformat']) {
+ else {
+ $this->_raw['tags']['avi'] = array();
+ }
+ $type = $this->_clean_type($type);
+ return $type;
+ }
+ if ($type = $this->_raw['audio']['streams']['0']['dataformat']) {
$type = $this->_clean_type($type);
return $type;
}
- if ($type = $this->_raw['audio']['dataformat']) {
+ if ($type = $this->_raw['audio']['dataformat']) {
$type = $this->_clean_type($type);
return $type;
}
- if ($type = $this->_raw['fileformat']) {
+ if ($type = $this->_raw['fileformat']) {
$type = $this->_clean_type($type);
return $type;
}
@@ -426,26 +426,26 @@ class vainfo {
* attempts to gather the tags and then normalize them into
* ['tag_name']['var'] = value
*/
- public function _get_tags() {
+ public function _get_tags() {
$results = array();
/* Gather Tag information from the filenames */
$results['file'] = $this->_parse_filename($this->filename);
- /* Return false if we don't have
- * any tags to look at
+ /* Return false if we don't have
+ * any tags to look at
*/
- if (!is_array($this->_raw['tags'])) {
- return $results;
+ if (!is_array($this->_raw['tags'])) {
+ return $results;
}
- /* The tags can come in many different shapes and colors
+ /* The tags can come in many different shapes and colors
* depending on the encoding time of day and phase of the
* moon
*/
- foreach ($this->_raw['tags'] as $key=>$tag_array) {
- switch ($key) {
+ foreach ($this->_raw['tags'] as $key=>$tag_array) {
+ switch ($key) {
case 'vorbiscomment':
debug_event('_get_tags', 'Parsing vorbis', '5');
$results[$key] = $this->_parse_vorbiscomment($tag_array);
@@ -468,14 +468,14 @@ class vainfo {
break;
case 'riff':
debug_event('_get_tags', 'Parsing riff', '5');
- $results[$key] = $this->_parse_riff($tag_array);
+ $results[$key] = $this->_parse_riff($tag_array);
break;
- case 'flv':
+ case 'flv':
debug_event('_get_tags', 'Parsing flv', '5');
- $results[$key] = $this->_parse_flv($this->_raw2);
- break;
+ $results[$key] = $this->_parse_flv($this->_raw2);
+ break;
case 'mpg':
- case 'mpeg':
+ case 'mpeg':
debug_event('_get_tags', 'Parsing MPEG', '5');
$results[$key] = $this->_parse_mpg($this->_raw2);
break;
@@ -484,15 +484,15 @@ class vainfo {
debug_event('_get_tags', 'Parsing WMV/WMA/ASF', '5');
$results[$key] = $this->_parse_wmv($this->_raw2);
break;
- case 'avi':
+ case 'avi':
debug_event('_get_tags', 'Parsing avi', '5');
- $results[$key] = $this->_parse_avi($this->_raw2);
- break;
+ $results[$key] = $this->_parse_avi($this->_raw2);
+ break;
case 'lyrics3':
debug_event('_get_tags', 'Parsing lyrics3', '5');
$results[$key] = $this->_parse_lyrics($tag_array);
break;
- default:
+ default:
debug_event('vainfo','Error: Unable to determine tag type of ' . $key . ' for file ' . $this->filename . ' Assuming id3v2','5');
$results[$key] = $this->_parse_id3v2($this->_raw['id3v2']['comments']);
break;
@@ -509,35 +509,35 @@ class vainfo {
* This function gathers and returns the general information
* about a song, vbr/cbr sample rate channels etc
*/
- private function _get_info() {
+ private function _get_info() {
$array = array();
/* Try to pull the information directly from
- * the audio array
+ * the audio array
*/
- if ($this->_raw['audio']['bitrate_mode']) {
+ if ($this->_raw['audio']['bitrate_mode']) {
$array['bitrate_mode'] = $this->_raw['audio']['bitrate_mode'];
}
- if ($this->_raw['audio']['bitrate']) {
+ if ($this->_raw['audio']['bitrate']) {
$array['bitrate'] = $this->_raw['audio']['bitrate'];
}
- if ($this->_raw['audio']['channels']) {
+ if ($this->_raw['audio']['channels']) {
$array['channels'] = intval($this->_raw['audio']['channels']);
}
- if ($this->_raw['audio']['sample_rate']) {
+ if ($this->_raw['audio']['sample_rate']) {
$array['sample_rate'] = intval($this->_raw['audio']['sample_rate']);
}
- if ($this->_raw['filesize']) {
+ if ($this->_raw['filesize']) {
$array['filesize'] = intval($this->_raw['filesize']);
}
- if ($this->_raw['encoding']) {
+ if ($this->_raw['encoding']) {
$array['encoding'] = $this->_raw['encoding'];
}
- if ($this->_raw['mime_type']) {
+ if ($this->_raw['mime_type']) {
$array['mime'] = $this->_raw['mime_type'];
}
- if ($this->_raw['playtime_seconds']) {
+ if ($this->_raw['playtime_seconds']) {
$array['playing_time'] = $this->_raw['playtime_seconds'];
}
if ($this->_raw['lyrics3']) {
@@ -545,17 +545,17 @@ class vainfo {
}
return $array;
-
+
} // _get_info
/**
* _clean_type
- * This standardizes the type that we are given into a reconized
+ * This standardizes the type that we are given into a reconized
* type
*/
- private function _clean_type($type) {
+ private function _clean_type($type) {
- switch ($type) {
+ switch ($type) {
case 'mp3':
case 'mp2':
case 'mpeg3':
@@ -564,16 +564,16 @@ class vainfo {
case 'vorbis':
return 'ogg';
break;
- case 'flac':
+ case 'flac':
case 'flv':
case 'mpg':
case 'mpeg':
case 'asf':
case 'wmv':
- case 'avi':
- case 'quicktime':
- return $type;
- default:
+ case 'avi':
+ case 'quicktime':
+ return $type;
+ default:
/* Log the fact that we couldn't figure it out */
debug_event('vainfo','Unable to determine file type from ' . $type . ' on file ' . $this->filename,'5');
return $type;
@@ -609,16 +609,16 @@ class vainfo {
* returns the elements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_vorbiscomment($tags) {
+ private function _parse_vorbiscomment($tags) {
/* Results array */
$array = array();
/* go through them all! */
- foreach ($tags as $tag=>$data) {
-
+ foreach ($tags as $tag=>$data) {
+
/* We need to translate a few of these tags */
- switch ($tag) {
+ switch ($tag) {
case 'genre':
// multiple genre support
@@ -629,8 +629,8 @@ class vainfo {
case 'tracknumber':
$array['track'] = $this->_clean_tag($data['0']);
break;
- case 'discnumber':
- $array['disk'] = $this->_clean_tag($data['0']);
+ case 'discnumber':
+ $array['disk'] = $this->_clean_tag($data['0']);
break;
case 'date':
$array['year'] = $this->_clean_tag($data['0']);
@@ -649,23 +649,23 @@ class vainfo {
/**
* _parse_id3v1
* This function takes a id3v1 tag set from getid3() and then
- * returns the elements translated using iconv if needed in a
+ * returns the elements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_id3v1($tags) {
+ private function _parse_id3v1($tags) {
$array = array();
$encoding = $this->_raw['id3v1']['encoding'];
-
+
/* Go through all the tags */
- foreach ($tags as $tag=>$data) {
+ foreach ($tags as $tag=>$data) {
- /* This is our baseline for naming
- * so no translation needed
+ /* This is our baseline for naming
+ * so no translation needed
*/
$array[$tag] = $this->_clean_tag($data['0'],$encoding);
-
+
} // end foreach
return $array;
@@ -678,18 +678,18 @@ class vainfo {
* returns the lelements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_id3v2($tags) {
+ private function _parse_id3v2($tags) {
$array = array();
/* Go through the tags */
- foreach ($tags as $tag=>$data) {
+ foreach ($tags as $tag=>$data) {
/**
- * the new getid3 handles this differently
+ * the new getid3 handles this differently
* so we now need to account for it :(
*/
- switch ($tag) {
+ switch ($tag) {
case 'genre':
// multiple genre support
foreach($data as $genre) {
@@ -706,16 +706,16 @@ class vainfo {
case 'comments':
$array['comment'] = $this->_clean_tag($data['0'],'');
break;
- case 'title':
- $array['title'] = $this->_clean_tag($data['0'],'');
- break;
- default:
+ case 'title':
+ $array['title'] = $this->_clean_tag($data['0'],'');
+ break;
+ default:
$array[$tag] = $this->_clean_tag($data['0'],'');
break;
} // end switch on tag
-
+
} // end foreach
-
+
$id3v2 = $this->_raw['id3v2'];
if(!empty($id3v2['UFID'])) {
@@ -745,9 +745,9 @@ class vainfo {
* returns the elements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_ape($tags) {
+ private function _parse_ape($tags) {
- foreach ($tags as $tag=>$data) {
+ foreach ($tags as $tag=>$data) {
switch ($tag) {
case 'genre':
@@ -762,7 +762,7 @@ class vainfo {
break;
} // end switch on tag
- } // end foreach tags
+ } // end foreach tags
return $array;
@@ -770,35 +770,35 @@ class vainfo {
/**
* _parse_riff
- * this function takes the riff take information passed by getid3() and
+ * this function takes the riff take information passed by getid3() and
* then reformats it so that it matches the other formats. May require iconv
*/
- private function _parse_riff($tags) {
-
- foreach ($tags as $tag=>$data) {
+ private function _parse_riff($tags) {
+
+ foreach ($tags as $tag=>$data) {
- switch ($tag) {
+ switch ($tag) {
case 'product':
- $array['album'] = $this->_clean_tag($data['0'],$this->_file_encoding);
+ $array['album'] = $this->_clean_tag($data['0'],$this->_file_encoding);
break;
- default:
- $array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding);
+ default:
+ $array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding);
break;
} // end switch on tag
} // foreach tags
- return $array;
+ return $array;
} // _parse_riff
/**
* _parse_quicktime
* this function takes the quicktime tags set by getid3() and then
- * returns the elements translated using iconv if needed in a
+ * returns the elements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_quicktime($tags) {
+ private function _parse_quicktime($tags) {
/* Results array */
$array = array();
@@ -809,7 +809,7 @@ class vainfo {
/* We need to translate a few of these tags */
switch ($tag) {
case 'creation_date':
- if (strlen($data['0']) > 4) {
+ if (strlen($data['0']) > 4) {
/* Weird Date format, attempt to normalize */
$data['0'] = date("Y",strtotime($data['0']));
}
@@ -820,36 +820,36 @@ class vainfo {
$array[$tag] = $this->_clean_tag($data['0']);
} // end foreach
-
+
// Also add in any video related stuff we might find
- if (strpos($this->_raw2['mime_type'],'video') !== false) {
- $info = $this->_parse_avi($this->_raw2);
- $info['video_codec'] = $this->_raw2['quicktime']['ftyp']['fourcc'];
- $array = array_merge($info,$array);
- }
+ if (strpos($this->_raw2['mime_type'],'video') !== false) {
+ $info = $this->_parse_avi($this->_raw2);
+ $info['video_codec'] = $this->_raw2['quicktime']['ftyp']['fourcc'];
+ $array = array_merge($info,$array);
+ }
return $array;
} // _parse_quicktime
/**
- * _parse_avi
+ * _parse_avi
* This attempts to parse our the information on an avi file and present it in some
* kind of sane format, this is a little hard as these files don't have tags
*/
- private function _parse_avi($tags) {
+ private function _parse_avi($tags) {
- $array = array();
+ $array = array();
$array['title'] = urldecode($this->_pathinfo['filename']);
- $array['video_codec'] = $tags['video']['fourcc'];
- $array['audio_codec'] = $tags['audio']['dataformat'];
- $array['resolution_x'] = $tags['video']['resolution_x'];
- $array['resolution_y'] = $tags['video']['resolution_y'];
- $array['mime'] = $tags['mime_type'];
- $array['comment'] = $tags['video']['codec'];
+ $array['video_codec'] = $tags['video']['fourcc'];
+ $array['audio_codec'] = $tags['audio']['dataformat'];
+ $array['resolution_x'] = $tags['video']['resolution_x'];
+ $array['resolution_y'] = $tags['video']['resolution_y'];
+ $array['mime'] = $tags['mime_type'];
+ $array['comment'] = $tags['video']['codec'];
- return $array;
+ return $array;
} // _parse_avi
@@ -890,7 +890,7 @@ class vainfo {
case 'video/x-ms-wmv':
if(isset($tags['tags']['asf']['title']['0'])) {
$array['title'] = $tags['tags']['asf']['title']['0'];
- }
+ }
else {
$array['title'] = urldecode($this->_pathinfo['filename']);
}
@@ -911,17 +911,17 @@ class vainfo {
* This attempts to parse our the information on an flv file and present it in some
* kind of sane format, this is a little hard as these files don't have tags
*/
- private function _parse_flv($tags) {
+ private function _parse_flv($tags) {
- $array = array();
+ $array = array();
$array['title'] = urldecode($this->_pathinfo['filename']);
- $array['video_codec'] = $tags['video']['codec'];
- $array['audio_codec'] = $tags['audio']['dataformat'];
- $array['resolution_x'] = $tags['video']['resolution_x'];
- $array['resolution_y'] = $tags['video']['resolution_y'];
- $array['mime'] = $tags['mime_type'];
- $array['comment'] = $tags['video']['codec'];
+ $array['video_codec'] = $tags['video']['codec'];
+ $array['audio_codec'] = $tags['audio']['dataformat'];
+ $array['resolution_x'] = $tags['video']['resolution_x'];
+ $array['resolution_y'] = $tags['video']['resolution_y'];
+ $array['mime'] = $tags['mime_type'];
+ $array['comment'] = $tags['video']['codec'];
return $array;
@@ -930,10 +930,10 @@ class vainfo {
/**
* _parse_filename
* This function uses the passed file and dir patterns
- * To pull out extra tag information and populate it into
+ * To pull out extra tag information and populate it into
* it's own array
*/
- private function _parse_filename($filename) {
+ private function _parse_filename($filename) {
$results = array();
@@ -945,11 +945,11 @@ class vainfo {
$slash_type = '\\';
}
- $pattern = preg_quote($this->_dir_pattern) . $slash_type . preg_quote($this->_file_pattern);
+ $pattern = preg_quote($this->_dir_pattern) . $slash_type . preg_quote($this->_file_pattern);
preg_match_all("/\%\w/",$pattern,$elements);
-
+
$preg_pattern = preg_quote($pattern);
- $preg_pattern = preg_replace("/\%[Ty]/","([0-9]+?)",$preg_pattern);
+ $preg_pattern = preg_replace("/\%[Ty]/","([0-9]+?)",$preg_pattern);
$preg_pattern = preg_replace("/\%\w/","(.+?)",$preg_pattern);
$preg_pattern = str_replace("/","\/",$preg_pattern);
$preg_pattern = str_replace(" ","\s",$preg_pattern);
@@ -959,12 +959,12 @@ class vainfo {
array_shift($matches);
/* Foreach through what we've found */
- foreach ($matches as $key=>$value) {
+ foreach ($matches as $key=>$value) {
$new_key = translate_pattern_code($elements['0'][$key]);
- if ($new_key) {
+ if ($new_key) {
$results[$new_key] = $value;
}
- } // end foreach matches
+ } // end foreach matches
return $results;
@@ -975,7 +975,7 @@ class vainfo {
* This translates the tag name to a frame, if there a many it returns the first
* one if finds that exists in the raw
*/
- private function _id3v2_tag_to_frame($tag_name) {
+ private function _id3v2_tag_to_frame($tag_name) {
static $map = array(
'comment'=>array('COM','COMM'),
@@ -986,15 +986,15 @@ class vainfo {
'artist'=>array('TPE1'),
'year'=>array('TDRC'));
- foreach ($map[$tag_name] as $frame) {
- if (isset($this->_raw['id3v2'][$frame])) {
- return $frame;
- }
- }
+ foreach ($map[$tag_name] as $frame) {
+ if (isset($this->_raw['id3v2'][$frame])) {
+ return $frame;
+ }
+ }
- return false;
+ return false;
- } // _id3v2_tag_to_frame
+ } // _id3v2_tag_to_frame
/**
* _clean_tag
@@ -1004,10 +1004,10 @@ class vainfo {
* is, and or if it's different then the encoding recorded
* in the file
*/
- private function _clean_tag($tag,$encoding='') {
+ private function _clean_tag($tag,$encoding='') {
- // If we've got iconv then go ahead and clear her up
- if ($this->_iconv) {
+ // If we've got iconv then go ahead and clear her up
+ if ($this->_iconv) {
/* Guess that it's UTF-8 */
/* Try GNU iconv //TRANSLIT extension first */
if (!$encoding) { $encoding = $this->_getID3->encoding; }
@@ -1027,27 +1027,27 @@ class vainfo {
* This returns true/false if we can do a binary parse of the file in question
* only the extension is passed so this can be inaccurate
*/
- public function can_binary_parse() {
+ public function can_binary_parse() {
// We're going to need exec for this
- if (!is_callable('exec')) {
- return false;
- }
+ if (!is_callable('exec')) {
+ return false;
+ }
// For now I'm going to use an approved list of apps, later we should allow user config
- switch ($this->_pathinfo['extension']) {
- case 'mp3':
+ switch ($this->_pathinfo['extension']) {
+ case 'mp3':
// Verify the application is there and callable
- exec('id3v2 -v',$results,$retval);
- if ($retval == 0) { return true; }
- break;
+ exec('id3v2 -v',$results,$retval);
+ if ($retval == 0) { return true; }
+ break;
default:
//FAILURE
- break;
+ break;
}
- return false;
+ return false;
} // can_binary_parse
@@ -1056,16 +1056,16 @@ class vainfo {
* This runs the binary parse operations here down in Ampache land
* it is passed the filename, and only called if can_binary_parse passes
*/
- public function run_binary_parse() {
+ public function run_binary_parse() {
// Switch on the extension
- switch ($this->_pathinfo['extension']) {
- case 'mp3':
+ switch ($this->_pathinfo['extension']) {
+ case 'mp3':
$this->_raw['tags'] = $this->mp3_binary_parse();
- break;
+ break;
default:
- $this->_raw['tags'] = array();
- break;
+ $this->_raw['tags'] = array();
+ break;
} // switch on extension
} // run_binary_parse
@@ -1075,56 +1075,56 @@ class vainfo {
* This tries to read the tag information from mp3s using a binary and the exec() command
* This will not work on a lot of systems... but it should be faster
*/
- public function mp3_binary_parse() {
+ public function mp3_binary_parse() {
- require_once(Config::get('prefix') . '/modules/getid3/module.tag.id3v2.php');
+ require_once(Config::get('prefix') . '/modules/getid3/module.tag.id3v2.php');
- $filename = escapeshellarg($this->filename);
+ $filename = escapeshellarg($this->filename);
- exec('id3v2 -l ' . $filename,$info,$retval);
+ exec('id3v2 -l ' . $filename,$info,$retval);
- if ($retval != 0) { return array(); }
+ if ($retval != 0) { return array(); }
- $position=0;
- $results = array();
+ $position=0;
+ $results = array();
// If we've got Id3v1 tag information
- if (substr($info[$position],0,5) == 'id3v1') {
- $position++;
- $v1['title'][] = trim(substr($info[$position],8,30));
+ if (substr($info[$position],0,5) == 'id3v1') {
+ $position++;
+ $v1['title'][] = trim(substr($info[$position],8,30));
$v1['artist'][] = trim(substr($info[$position],49,79));
- $position++;
- $v1['album'][] = trim(substr($info[$position],8,30));
- $v1['year'][] = trim(substr($info[$position],47,53));
- $v1['genre'][] = trim(preg_replace("/\(\d+\)/","",substr($info[$position],60,strlen($info[$position]))));
- $position++;
- $v1['comment'][]= trim(substr($info[$position],8,30));
- $v1['track'][] = trim(substr($info[$position],48,3));
- $results['id3v1'] = $v1;
- $position++;
+ $position++;
+ $v1['album'][] = trim(substr($info[$position],8,30));
+ $v1['year'][] = trim(substr($info[$position],47,53));
+ $v1['genre'][] = trim(preg_replace("/\(\d+\)/","",substr($info[$position],60,strlen($info[$position]))));
+ $position++;
+ $v1['comment'][]= trim(substr($info[$position],8,30));
+ $v1['track'][] = trim(substr($info[$position],48,3));
+ $results['id3v1'] = $v1;
+ $position++;
}
- if (substr($info[$position],0,5) == 'id3v2') {
- $position++;
+ if (substr($info[$position],0,5) == 'id3v2') {
+ $position++;
$element_count = count($info);
- while ($position < $element_count) {
+ while ($position < $element_count) {
$position++;
$element = getid3_id3v2::FrameNameShortLookup(substr($info[$position],0,4));
- if (!$element) { continue; }
- $data = explode(":",$info[$position],2);
- $value = array_pop($data);
- $results['id3v2'][$element][] = $value;
- }
+ if (!$element) { continue; }
+ $data = explode(":",$info[$position],2);
+ $value = array_pop($data);
+ $results['id3v2'][$element][] = $value;
+ }
} // end if id3v2
- return $results;
+ return $results;
} // mp3_binary_parse
/**
* set_broken
- * This fills all tag types with Unknown (Broken)
+ * This fills all tag types with Unknown (Broken)
*/
- public function set_broken() {
+ public function set_broken() {
/* Pull In the config option */
$order = Config::get('tag_order');
@@ -1133,13 +1133,13 @@ class vainfo {
$order = array($order);
}
- $key = array_shift($order);
+ $key = array_shift($order);
- $broken[$key]['title'] = '**BROKEN** ' . $this->filename;
- $broken[$key]['album'] = 'Unknown (Broken)';
- $broken[$key]['artist'] = 'Unknown (Broken)';
+ $broken[$key]['title'] = '**BROKEN** ' . $this->filename;
+ $broken[$key]['album'] = 'Unknown (Broken)';
+ $broken[$key]['artist'] = 'Unknown (Broken)';
- return $broken;
+ return $broken;
} // set_broken
diff --git a/lib/class/vauth.class.php b/lib/class/vauth.class.php
index dad3feda..cc11328f 100644
--- a/lib/class/vauth.class.php
+++ b/lib/class/vauth.class.php
@@ -96,7 +96,7 @@ class vauth {
$key = Dba::escape($key);
// Check to see if remember me cookie is set, if so use remember length, otherwise use the session length
$expire = isset($_COOKIE[Config::get('session_name') . '_remember']) ? time() + Config::get('remember_length') : time() + Config::get('session_length');
-
+
$sql = "UPDATE `session` SET `value`='$value', `expire`='$expire' WHERE `id`='$key'";
$db_results = Dba::read($sql);
@@ -196,7 +196,7 @@ class vauth {
/**
* get_session_data
- * This takes a key and returns the raw data from the database, nothing
+ * This takes a key and returns the raw data from the database, nothing
* to see here move along people
*/
public static function get_session_data($key) {
@@ -218,7 +218,7 @@ class vauth {
/**
* create_cookie
- * This is seperated into its own function because of some flaws in
+ * This is seperated into its own function because of some flaws in
* specific webservers *cough* IIS *cough* which prevent us from setting
* a cookie at the same time as a header redirect. As such on view of a
* login a cookie is set with the proper name
@@ -402,7 +402,7 @@ class vauth {
$sid = Dba::escape($sid);
$expire = isset($_COOKIE[Config::get('session_name') . '_remember']) ? time() + Config::get('remember_length') : time() + Config::get('session_length');
- $len = $expire - time();
+ $len = $expire - time();
$sql = "UPDATE `session` SET `expire`='$expire' WHERE `id`='$sid'";
$db_results = Dba::write($sql);
@@ -583,7 +583,7 @@ class vauth {
$results['error'] = "The PAM authentication PHP module is not installed.";
return $results;
}
-
+
if (pam_auth($username, $password, &$results['error'])) {
$results['success'] = true;
$results['type'] = 'local';
@@ -593,7 +593,7 @@ class vauth {
$results['success'] = false;
$results['error'] = "PAM login attempt failed";
}
-
+
return $results;
} // local_auth
@@ -680,7 +680,7 @@ class vauth {
* This auth method relies on HTTP auth from Apache
*/
private static function http_auth($username) {
- if (($_SERVER['REMOTE_USER'] == $username) ||
+ if (($_SERVER['REMOTE_USER'] == $username) ||
($_SERVER['HTTP_REMOTE_USER'] == $username)) {
$results['success'] = true;
$results['type'] = 'http';
diff --git a/lib/class/video.class.php b/lib/class/video.class.php
index cf36eb92..1640c6b8 100644
--- a/lib/class/video.class.php
+++ b/lib/class/video.class.php
@@ -22,26 +22,26 @@
class Video extends database_object implements media {
- public $id;
- public $title;
- public $enabled;
- public $file;
- public $size;
+ public $id;
+ public $title;
+ public $enabled;
+ public $file;
+ public $size;
/**
* Constructor
* This pulls the shoutbox information from the database and returns
* a constructed object, uses user_shout table
*/
- public function __construct($id) {
+ public function __construct($id) {
// Load the data from the database
$info = $this->get_info($id);
- foreach ($info as $key=>$value) {
- $this->$key = $value;
- }
+ foreach ($info as $key=>$value) {
+ $this->$key = $value;
+ }
- return true;
+ return true;
} // Constructor
@@ -49,18 +49,18 @@ class Video extends database_object implements media {
* build_cache
* Build a cache based on the array of ids passed, saves lots of little queries
*/
- public static function build_cache($ids=array()) {
+ public static function build_cache($ids=array()) {
- if (!is_array($ids) OR !count($ids)) { return false; }
+ if (!is_array($ids) OR !count($ids)) { return false; }
- $idlist = '(' . implode(',',$ids) . ')';
+ $idlist = '(' . implode(',',$ids) . ')';
- $sql = "SELECT * FROM `video` WHERE `video`.`id` IN $idlist";
- $db_results = Dba::read($sql);
+ $sql = "SELECT * FROM `video` WHERE `video`.`id` IN $idlist";
+ $db_results = Dba::read($sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- parent::add_to_cache('video',$row['id'],$row);
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ parent::add_to_cache('video',$row['id'],$row);
+ }
} // build_cache
@@ -68,13 +68,13 @@ class Video extends database_object implements media {
* format
* This formats a video object so that it is human readable
*/
- public function format() {
+ public function format() {
- $this->f_title = scrub_out($this->title);
- $this->f_link = scrub_out($this->title);
- $this->f_codec = $this->video_codec . ' / ' . $this->audio_codec;
- $this->f_resolution = $this->resolution_x . 'x' . $this->resolution_y;
- $this->f_tags = '';
+ $this->f_title = scrub_out($this->title);
+ $this->f_link = scrub_out($this->title);
+ $this->f_codec = $this->video_codec . ' / ' . $this->audio_codec;
+ $this->f_resolution = $this->resolution_x . 'x' . $this->resolution_y;
+ $this->f_tags = '';
$this->f_length = floor($this->time/60) . ' ' . _('minutes');
} // format
@@ -83,9 +83,9 @@ class Video extends database_object implements media {
* native_stream
* This returns true or false on the downsampling mojo
*/
- public function native_stream() {
+ public function native_stream() {
- return true;
+ return true;
} // native_stream
@@ -94,18 +94,18 @@ class Video extends database_object implements media {
* This returns a "PLAY" url for the video in question here, this currently feels a little
* like a hack, might need to adjust it in the future
*/
- public static function play_url($oid,$sid='',$force_http='') {
+ public static function play_url($oid,$sid='',$force_http='') {
- $video = new Video($oid);
+ $video = new Video($oid);
- if (!$video->id) { return false; }
+ if (!$video->id) { return false; }
- $uid = intval($GLOBALS['user']->id);
- $oid = intval($video->id);
+ $uid = intval($GLOBALS['user']->id);
+ $oid = intval($video->id);
- $url = Stream::get_base_url() . "video=true&uid=$uid&oid=$oid";
+ $url = Stream::get_base_url() . "video=true&uid=$uid&oid=$oid";
- return $url;
+ return $url;
} // play_url
@@ -115,7 +115,7 @@ class Video extends database_object implements media {
* if not it returns the transocding command from the config file
* we can't use this->type because its been formated for the downsampling
*/
- public function stream_cmd() {
+ public function stream_cmd() {
@@ -126,7 +126,7 @@ class Video extends database_object implements media {
* returns true if the video has been flagged and we shouldn't try to re-read
* the meta data
*/
- public function has_flag() {
+ public function has_flag() {
diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php
index 4e13c0a1..10690670 100644
--- a/lib/class/xmldata.class.php
+++ b/lib/class/xmldata.class.php
@@ -17,27 +17,27 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* xmlData
* This class takes care of all of the xml document stuff in Ampache these
- * are all static calls
+ * are all static calls
*/
-class xmlData {
+class xmlData {
// This is added so that we don't pop any webservers
private static $limit = '5000';
- private static $offset = '0';
- private static $type = '';
+ private static $offset = '0';
+ private static $type = '';
/**
* constructor
* We don't use this, as its really a static class
*/
- private function __construct() {
+ private function __construct() {
// Rien a faire
@@ -47,10 +47,10 @@ class xmlData {
* set_offset
* This takes an int and changes the offset
*/
- public static function set_offset($offset) {
+ public static function set_offset($offset) {
- $offset = intval($offset);
- self::$offset = $offset;
+ $offset = intval($offset);
+ self::$offset = $offset;
} // set_offset
@@ -58,12 +58,12 @@ class xmlData {
* set_limit
* This sets the limit for any ampache transactions
*/
- public static function set_limit($limit) {
+ public static function set_limit($limit) {
- if (!$limit) { return false; }
+ if (!$limit) { return false; }
- $limit = intval($limit);
- self::$limit = $limit;
+ $limit = intval($limit);
+ self::$limit = $limit;
} // set_limit
@@ -71,11 +71,11 @@ class xmlData {
* set_type
* This sets the type of xmlData we are working on
*/
- public static function set_type($type) {
+ public static function set_type($type) {
- if (!in_array($type,array('rss','xspf','itunes'))) { return false; }
+ if (!in_array($type,array('rss','xspf','itunes'))) { return false; }
- self::$type = $type;
+ self::$type = $type;
} // set_type
@@ -84,10 +84,10 @@ class xmlData {
* This generates a standard XML Error message
* nothing fancy here...
*/
- public static function error($code,$string) {
-
- $string = self::_header() . "\t<error code=\"$code\"><![CDATA[$string]]></error>" . self::_footer();
- return $string;
+ public static function error($code,$string) {
+
+ $string = self::_header() . "\t<error code=\"$code\"><![CDATA[$string]]></error>" . self::_footer();
+ return $string;
} // error
@@ -95,11 +95,11 @@ class xmlData {
* single_string
* This takes two values, first the key second the string
*/
- public static function single_string($key,$string) {
+ public static function single_string($key,$string) {
- $final = self::_header() . "\t<$key><![CDATA[$string]]></$key>" . self::_footer();
+ $final = self::_header() . "\t<$key><![CDATA[$string]]></$key>" . self::_footer();
- return $final;
+ return $final;
} // single_string
@@ -107,9 +107,9 @@ class xmlData {
* header
* This returns the header
*/
- public static function header() {
+ public static function header() {
- return self::_header();
+ return self::_header();
} // header
@@ -117,56 +117,56 @@ class xmlData {
* footer
* This returns the footer
*/
- public static function footer() {
+ public static function footer() {
- return self::_footer();
+ return self::_footer();
- } // header
+ } // header
/**
* tags_string
- * This returns the formated 'tags' string for an xml document
+ * This returns the formated 'tags' string for an xml document
*/
- private static function tags_string($tags,$type,$object_id) {
+ private static function tags_string($tags,$type,$object_id) {
+
+ $string = '';
- $string = '';
+ foreach ($tags as $tag_id=>$data) {
- foreach ($tags as $tag_id=>$data) {
-
- $tag = new Tag($tag_id);
+ $tag = new Tag($tag_id);
$string .= "\t<tag id=\"" . $tag->id . "\" count=\"" . $data['count'] . "\"><![CDATA[$tag->name]]></tag>\n";
- }
+ }
- return $string;
+ return $string;
} // tags_string
/**
* keyed_array
- * This will build an xml document from a key'd array,
+ * This will build an xml document from a key'd array,
*/
- public static function keyed_array($array,$callback='') {
+ public static function keyed_array($array,$callback='') {
- $string = '';
+ $string = '';
// Foreach it
- foreach ($array as $key=>$value) {
+ foreach ($array as $key=>$value) {
// If it's an array, run again
- if (is_array($value)) {
- $value = self::keyed_array($value,1);
- $string .= "<$key>\n$value\n</$key>\n";
- }
- else {
- $string .= "\t<$key><![CDATA[$value]]></$key>\n";
- }
+ if (is_array($value)) {
+ $value = self::keyed_array($value,1);
+ $string .= "<$key>\n$value\n</$key>\n";
+ }
+ else {
+ $string .= "\t<$key><![CDATA[$value]]></$key>\n";
+ }
- } // end foreach
+ } // end foreach
- if (!$callback) {
- $string = self::_header() . $string . self::_footer();
- }
+ if (!$callback) {
+ $string = self::_header() . $string . self::_footer();
+ }
- return $string;
+ return $string;
} // keyed_array
@@ -174,69 +174,69 @@ class xmlData {
* tags
* This returns tags to the user, in a pretty xml document with the information
*/
- public static function tags($tags) {
-
- if (count($tags) > self::$limit OR self::$offset > 0) {
- $tags = array_splice($tags,self::$offset,self::$limit);
- }
-
- $string = '';
-
- foreach ($tags as $tag_id) {
- $tag = new Tag($tag_id);
- $counts = $tag->count();
- $string .= "<tag id=\"$tag_id\">\n" .
- "\t<name><![CDATA[$tag->name]]></name>\n" .
- "\t<albums>" . intval($counts['album']) . "</albums>\n" .
- "\t<artists>" . intval($counts['artist']) . "</artists>\n" .
- "\t<songs>" . intval($counts['song']) . "</songs>\n" .
- "\t<videos>" . intval($counts['video']) . "</videos>\n" .
- "\t<playlists>" . intval($count['playlist']) . "</playlists>\n" .
- "\t<stream>" . intval($count['live_stream']) . "</stream>\n" .
- "</tag>\n";
- } // end foreach
-
- $final = self::_header() . $string . self::_footer();
-
- return $final;
+ public static function tags($tags) {
+
+ if (count($tags) > self::$limit OR self::$offset > 0) {
+ $tags = array_splice($tags,self::$offset,self::$limit);
+ }
+
+ $string = '';
+
+ foreach ($tags as $tag_id) {
+ $tag = new Tag($tag_id);
+ $counts = $tag->count();
+ $string .= "<tag id=\"$tag_id\">\n" .
+ "\t<name><![CDATA[$tag->name]]></name>\n" .
+ "\t<albums>" . intval($counts['album']) . "</albums>\n" .
+ "\t<artists>" . intval($counts['artist']) . "</artists>\n" .
+ "\t<songs>" . intval($counts['song']) . "</songs>\n" .
+ "\t<videos>" . intval($counts['video']) . "</videos>\n" .
+ "\t<playlists>" . intval($count['playlist']) . "</playlists>\n" .
+ "\t<stream>" . intval($count['live_stream']) . "</stream>\n" .
+ "</tag>\n";
+ } // end foreach
+
+ $final = self::_header() . $string . self::_footer();
+
+ return $final;
} // tags
/**
* artists
- * This takes an array of artists and then returns a pretty xml document with the information
- * we want
+ * This takes an array of artists and then returns a pretty xml document with the information
+ * we want
*/
- public static function artists($artists) {
+ public static function artists($artists) {
- if (count($artists) > self::$limit OR self::$offset > 0) {
- $artists = array_splice($artists,self::$offset,self::$limit);
- }
+ if (count($artists) > self::$limit OR self::$offset > 0) {
+ $artists = array_splice($artists,self::$offset,self::$limit);
+ }
+
+ $string = '';
- $string = '';
-
- Rating::build_cache('artist',$artists);
+ Rating::build_cache('artist',$artists);
- foreach ($artists as $artist_id) {
- $artist = new Artist($artist_id);
- $artist->format();
+ foreach ($artists as $artist_id) {
+ $artist = new Artist($artist_id);
+ $artist->format();
- $rating = new Rating($artist_id,'artist');
- $tag_string = self::tags_string($artist->tags,'artist',$artist->id);
+ $rating = new Rating($artist_id,'artist');
+ $tag_string = self::tags_string($artist->tags,'artist',$artist->id);
- $string .= "<artist id=\"$artist->id\">\n" .
- "\t<name><![CDATA[$artist->f_full_name]]></name>\n" .
- $tag_string .
- "\t<albums>$artist->albums</albums>\n" .
- "\t<songs>$artist->songs</songs>\n" .
+ $string .= "<artist id=\"$artist->id\">\n" .
+ "\t<name><![CDATA[$artist->f_full_name]]></name>\n" .
+ $tag_string .
+ "\t<albums>$artist->albums</albums>\n" .
+ "\t<songs>$artist->songs</songs>\n" .
"\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
"\t<rating>" . $rating->rating . "</rating>\n" .
- "</artist>\n";
+ "</artist>\n";
} // end foreach artists
- $final = self::_header() . $string . self::_footer();
+ $final = self::_header() . $string . self::_footer();
- return $final;
+ return $final;
} // artists
@@ -244,47 +244,47 @@ class xmlData {
* albums
* This echos out a standard albums XML document, it pays attention to the limit
*/
- public static function albums($albums) {
+ public static function albums($albums) {
- if (count($albums) > self::$limit OR self::$offset > 0) {
- $albums = array_splice($albums,self::$offset,self::$limit);
- }
-
- Rating::build_cache('album',$albums);
+ if (count($albums) > self::$limit OR self::$offset > 0) {
+ $albums = array_splice($albums,self::$offset,self::$limit);
+ }
+
+ Rating::build_cache('album',$albums);
- foreach ($albums as $album_id) {
- $album = new Album($album_id);
- $album->format();
+ foreach ($albums as $album_id) {
+ $album = new Album($album_id);
+ $album->format();
- $rating = new Rating($album_id,'album');
+ $rating = new Rating($album_id,'album');
- // Build the Art URL, include session
- $art_url = Config::get('web_path') . '/image.php?id=' . $album->id . '&auth=' . scrub_out($_REQUEST['auth']);
+ // Build the Art URL, include session
+ $art_url = Config::get('web_path') . '/image.php?id=' . $album->id . '&auth=' . scrub_out($_REQUEST['auth']);
- $string .= "<album id=\"$album->id\">\n" .
- "\t<name><![CDATA[$album->name]]></name>\n";
+ $string .= "<album id=\"$album->id\">\n" .
+ "\t<name><![CDATA[$album->name]]></name>\n";
// Do a little check for artist stuff
- if ($album->artist_count != 1) {
- $string .= "\t<artist id=\"0\"><![CDATA[Various]]></artist>\n";
- }
- else {
- $string .= "\t<artist id=\"$album->artist_id\"><![CDATA[$album->artist_name]]></artist>\n";
- }
-
- $string .= "\t<year>$album->year</year>\n" .
- "\t<tracks>$album->song_count</tracks>\n" .
- "\t<disk>$album->disk</disk>\n" .
- self::tags_string($album->tags,'album',$album->id) .
- "\t<art><![CDATA[$art_url]]></art>\n" .
+ if ($album->artist_count != 1) {
+ $string .= "\t<artist id=\"0\"><![CDATA[Various]]></artist>\n";
+ }
+ else {
+ $string .= "\t<artist id=\"$album->artist_id\"><![CDATA[$album->artist_name]]></artist>\n";
+ }
+
+ $string .= "\t<year>$album->year</year>\n" .
+ "\t<tracks>$album->song_count</tracks>\n" .
+ "\t<disk>$album->disk</disk>\n" .
+ self::tags_string($album->tags,'album',$album->id) .
+ "\t<art><![CDATA[$art_url]]></art>\n" .
"\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
"\t<rating>" . $rating->rating . "</rating>\n" .
- "</album>\n";
+ "</album>\n";
} // end foreach
- $final = self::_header() . $string . self::_footer();
+ $final = self::_header() . $string . self::_footer();
- return $final;
+ return $final;
} // albums
@@ -292,33 +292,33 @@ class xmlData {
* playlists
* This takes an array of playlist ids and then returns a nice pretty XML document
*/
- public static function playlists($playlists) {
+ public static function playlists($playlists) {
- if (count($playlists) > self::$limit OR self::$offset > 0) {
- $playlists = array_slice($playlists,self::$offset,self::$limit);
- }
+ if (count($playlists) > self::$limit OR self::$offset > 0) {
+ $playlists = array_slice($playlists,self::$offset,self::$limit);
+ }
- $string = '';
+ $string = '';
// Foreach the playlist ids
- foreach ($playlists as $playlist_id) {
- $playlist = new Playlist($playlist_id);
- $playlist->format();
- $item_total = $playlist->get_song_count();
+ foreach ($playlists as $playlist_id) {
+ $playlist = new Playlist($playlist_id);
+ $playlist->format();
+ $item_total = $playlist->get_song_count();
// Build this element
- $string .= "<playlist id=\"$playlist->id\">\n" .
- "\t<name><![CDATA[$playlist->name]]></name>\n" .
- "\t<owner><![CDATA[$playlist->f_user]]></owner>\n" .
- "\t<items>$item_total</items>\n" .
- "\t<type>$playlist->type</type>\n" .
+ $string .= "<playlist id=\"$playlist->id\">\n" .
+ "\t<name><![CDATA[$playlist->name]]></name>\n" .
+ "\t<owner><![CDATA[$playlist->f_user]]></owner>\n" .
+ "\t<items>$item_total</items>\n" .
+ "\t<type>$playlist->type</type>\n" .
"</playlist>\n";
-
+
} // end foreach
- // Build the final and then send her off
- $final = self::_header() . $string . self::_footer();
+ // Build the final and then send her off
+ $final = self::_header() . $string . self::_footer();
return $final;
@@ -328,54 +328,54 @@ class xmlData {
* songs
* This returns an xml document from an array of song ids spiffy isn't it!
*/
- public static function songs($songs) {
+ public static function songs($songs) {
- if (count($songs) > self::$limit OR self::$offset > 0) {
- $songs = array_slice($songs,self::$offset,self::$limit);
- }
+ if (count($songs) > self::$limit OR self::$offset > 0) {
+ $songs = array_slice($songs,self::$offset,self::$limit);
+ }
- Rating::build_cache('song',$songs);
- Stream::set_session($_REQUEST['auth']);
+ Rating::build_cache('song',$songs);
+ Stream::set_session($_REQUEST['auth']);
// Foreach the ids!
- foreach ($songs as $song_id) {
- $song = new Song($song_id);
+ foreach ($songs as $song_id) {
+ $song = new Song($song_id);
// If the song id is invalid/null
- if (!$song->id) { continue; }
- $song->format();
+ if (!$song->id) { continue; }
+ $song->format();
- $tag_string = '';
+ $tag_string = '';
- $tag = new Tag($song->tags['0']);
+ $tag = new Tag($song->tags['0']);
$song->genre = $tag->id;
- $song->f_genre = $tag->name;
-
- $tag_string = self::tags_string($song->tags,'song',$song->id);
-
- $rating = new Rating($song_id,'song');
-
- $art_url = Album::get_art_url($song->album,$_REQUEST['auth']);
-
- $string .= "<song id=\"$song->id\">\n" .
- "\t<title><![CDATA[$song->title]]></title>\n" .
- "\t<artist id=\"$song->artist\"><![CDATA[$song->f_artist_full]]></artist>\n" .
- "\t<album id=\"$song->album\"><![CDATA[$song->f_album_full]]></album>\n" .
- "\t<genre id=\"$song->genre\"><![CDATA[$song->f_genre]]></genre>\n" .
- $tag_string .
- "\t<track>$song->track</track>\n" .
- "\t<time>$song->time</time>\n" .
- "\t<mime>$song->mime</mime>\n" .
- "\t<url><![CDATA[" . Song::play_url($song->id) . "]]></url>\n" .
- "\t<size>$song->size</size>\n" .
- "\t<art><![CDATA[" . $art_url . "]]></art>\n" .
- "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
- "\t<rating>" . $rating->rating . "</rating>\n" .
- "</song>\n";
+ $song->f_genre = $tag->name;
+
+ $tag_string = self::tags_string($song->tags,'song',$song->id);
+
+ $rating = new Rating($song_id,'song');
+
+ $art_url = Album::get_art_url($song->album,$_REQUEST['auth']);
+
+ $string .= "<song id=\"$song->id\">\n" .
+ "\t<title><![CDATA[$song->title]]></title>\n" .
+ "\t<artist id=\"$song->artist\"><![CDATA[$song->f_artist_full]]></artist>\n" .
+ "\t<album id=\"$song->album\"><![CDATA[$song->f_album_full]]></album>\n" .
+ "\t<genre id=\"$song->genre\"><![CDATA[$song->f_genre]]></genre>\n" .
+ $tag_string .
+ "\t<track>$song->track</track>\n" .
+ "\t<time>$song->time</time>\n" .
+ "\t<mime>$song->mime</mime>\n" .
+ "\t<url><![CDATA[" . Song::play_url($song->id) . "]]></url>\n" .
+ "\t<size>$song->size</size>\n" .
+ "\t<art><![CDATA[" . $art_url . "]]></art>\n" .
+ "\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
+ "\t<rating>" . $rating->rating . "</rating>\n" .
+ "</song>\n";
} // end foreach
- $final = self::_header() . $string . self::_footer();
+ $final = self::_header() . $string . self::_footer();
return $final;
@@ -385,32 +385,32 @@ class xmlData {
* videos
* This builds the xml document for displaying video objects
*/
- public static function videos($videos) {
+ public static function videos($videos) {
if (count($videos) > self::$limit OR self::$offset > 0) {
$videos = array_slice($videos,self::$offset,self::$limit);
}
- $string = '';
+ $string = '';
- foreach ($videos as $video_id) {
- $video = new Video($video_id);
- $video->format();
+ foreach ($videos as $video_id) {
+ $video = new Video($video_id);
+ $video->format();
- $string .= "<video id=\"$video->id\">\n" .
- "\t<title><![CDATA[$video->title]]></title>\n" .
- "\t<mime><![CDATA[$video->mime]]></mime>\n" .
+ $string .= "<video id=\"$video->id\">\n" .
+ "\t<title><![CDATA[$video->title]]></title>\n" .
+ "\t<mime><![CDATA[$video->mime]]></mime>\n" .
"\t<resolution>$video->f_resolution</resolution>\n" .
- "\t<size>$video->size</size>\n" .
- self::tags_string($video->tags,'video',$video->id) .
+ "\t<size>$video->size</size>\n" .
+ self::tags_string($video->tags,'video',$video->id) .
"\t<url><![CDATA[" . Video::play_url($video->id) . "]]></url>\n" .
"</video>\n";
- } // end foreach
+ } // end foreach
- $final = self::_header() . $string . self::_footer();
+ $final = self::_header() . $string . self::_footer();
- return $final;
+ return $final;
} // videos
@@ -420,17 +420,17 @@ class xmlData {
* This handles creating an xml document for democratic items, this can be a little complicated
* due to the votes and all of that
*/
- public static function democratic($object_ids=array()) {
+ public static function democratic($object_ids=array()) {
- if (!is_array($object_ids)) { $object_ids = array(); }
+ if (!is_array($object_ids)) { $object_ids = array(); }
$democratic = Democratic::get_current_playlist();
-
- $string = '';
- foreach ($object_ids as $row_id=>$data) {
- $song = new $data['object_type']($data['object_id']);
- $song->format();
+ $string = '';
+
+ foreach ($object_ids as $row_id=>$data) {
+ $song = new $data['object_type']($data['object_id']);
+ $song->format();
//FIXME: This is duplicate code and so wrong, functions need to be improved
$tag_string = '';
@@ -455,38 +455,38 @@ class xmlData {
"\t<time>$song->time</time>\n" .
"\t<mime>$song->mime</mime>\n" .
"\t<url><![CDATA[" . Song::play_url($song->id) . "]]></url>\n" .
- "\t<size>$song->size</size>\n" .
- "\t<art><![CDATA[" . $art_url . "]]></art>\n" .
+ "\t<size>$song->size</size>\n" .
+ "\t<art><![CDATA[" . $art_url . "]]></art>\n" .
"\t<preciserating>" . $rating->preciserating . "</preciserating>\n" .
"\t<rating>" . $rating->rating . "</rating>\n" .
- "\t<vote>" . $democratic->get_vote($row_id) . "</vote>\n" .
- "</song>\n";
-
- } // end foreach
-
- $final = self::_header() . $string . self::_footer();
+ "\t<vote>" . $democratic->get_vote($row_id) . "</vote>\n" .
+ "</song>\n";
- return $final;
+ } // end foreach
+
+ $final = self::_header() . $string . self::_footer();
+
+ return $final;
} // democratic
/**
* rss_feed
*/
- public static function rss_feed($data,$title,$description,$date) {
+ public static function rss_feed($data,$title,$description,$date) {
- $string = "\t<title>$title</title>\n\t<link>" . Config::get('web_path') . "</link>\n\t" .
- "<pubDate>" . date("r",$date) . "</pubDate>\n";
+ $string = "\t<title>$title</title>\n\t<link>" . Config::get('web_path') . "</link>\n\t" .
+ "<pubDate>" . date("r",$date) . "</pubDate>\n";
// Pass it to the keyed array xml function
- foreach ($data as $item) {
+ foreach ($data as $item) {
// We need to enclose it in an item tag
- $string .= self::keyed_array(array('item'=>$item),1);
- }
+ $string .= self::keyed_array(array('item'=>$item),1);
+ }
- $final = self::_header() . $string . self::_footer();
+ $final = self::_header() . $string . self::_footer();
- return $final;
+ return $final;
} // rss_feed
@@ -495,10 +495,10 @@ class xmlData {
* this returns a standard header, there are a few types
* so we allow them to pass a type if they want to
*/
- private static function _header() {
+ private static function _header() {
- switch (self::$type) {
- case 'xspf':
+ switch (self::$type) {
+ case 'xspf':
$header = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" .
"<playlist version = \"1\" xmlns=\"http://xspf.org/ns/0/\">\n " .
"<title>Ampache XSPF Playlist</title>\n" .
@@ -506,7 +506,7 @@ class xmlData {
"<annotation>" . scrub_out(Config::get('site_title')) . "</annotation>\n" .
"<info>". Config::get('web_path') ."</info>\n" .
"<trackList>\n";
- break;
+ break;
case 'itunes':
$header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" .
"<!-- XML Generated by Ampache v." . Config::get('version') . " -->\n";
@@ -520,19 +520,19 @@ class xmlData {
" <key>Features</key><integer>1</integer>\n" .
" <key>Show Content Ratings</key><true/>\n" .
" <key>Tracks</key>\n" .
- " <dict>\n";
- break;
- case 'rss':
- $header = "<?xml version=\"1.0\" encoding=\"" . Config::get('site_charset') . "\" ?>\n " .
- "<!-- RSS Generated by Ampache v." . Config::get('version') . " on " . date("r",time()) . "-->\n" .
- "<rss version=\"2.0\">\n<channel>\n";
- break;
- default:
+ " <dict>\n";
+ break;
+ case 'rss':
+ $header = "<?xml version=\"1.0\" encoding=\"" . Config::get('site_charset') . "\" ?>\n " .
+ "<!-- RSS Generated by Ampache v." . Config::get('version') . " on " . date("r",time()) . "-->\n" .
+ "<rss version=\"2.0\">\n<channel>\n";
+ break;
+ default:
$header = "<?xml version=\"1.0\" encoding=\"" . Config::get('site_charset') . "\" ?>\n<root>\n";
- break;
- } // end switch
+ break;
+ } // end switch
- return $header;
+ return $header;
} // _header
@@ -540,25 +540,25 @@ class xmlData {
* _footer
* this returns the footer for this document, these are pretty boring
*/
- private static function _footer() {
+ private static function _footer() {
- switch (self::$type) {
- case 'itunes':
+ switch (self::$type) {
+ case 'itunes':
$footer = "\t\t</dict>\t\n</dict>\n</plist>\n";
- break;
- case 'xspf':
- $footer = "</trackList>\n</playlist>\n";
- break;
- case 'rss':
- $footer = "\n</channel>\n</rss>\n";
- break;
- default:
- $footer = "\n</root>\n";
- break;
- } // end switch on type
-
-
- return $footer;
+ break;
+ case 'xspf':
+ $footer = "</trackList>\n</playlist>\n";
+ break;
+ case 'rss':
+ $footer = "\n</channel>\n</rss>\n";
+ break;
+ default:
+ $footer = "\n</root>\n";
+ break;
+ } // end switch on type
+
+
+ return $footer;
} // _footer
diff --git a/lib/gettext.php b/lib/gettext.php
index d5e828f5..6c88b057 100644
--- a/lib/gettext.php
+++ b/lib/gettext.php
@@ -24,14 +24,14 @@
@function load_gettext
@discussion sets the local
*/
-function load_gettext() {
+function load_gettext() {
/* If we have gettext */
- if (function_exists('bindtextdomain')) {
+ if (function_exists('bindtextdomain')) {
$lang = Config::get('lang');
putenv("LANG=" . $lang);
putenv("LANGUAGE=" . $lang);
/* Try lang, lang + charset and lang + utf-8 */
- setlocale(LC_ALL,
+ setlocale(LC_ALL,
$lang,
$lang . '.UTF-8', //. Config::get('site_charset'),
$lang . '.UTF-8',
@@ -41,7 +41,7 @@ function load_gettext() {
/* Bind the Text Domain */
bindtextdomain('messages', Config::get('prefix') . "/locale/");
textdomain('messages');
- if (function_exists('bind_textdomain_codeset')) {
+ if (function_exists('bind_textdomain_codeset')) {
bind_textdomain_codeset('messages',Config::get('site_charset'));
} // if we can codeset the textdomain
diff --git a/lib/init.php b/lib/init.php
index 9adc0e86..7dddb533 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -21,16 +21,16 @@
*/
// SVN Fluf
-$svn_version = 'Subversion ' . trim('$Rev$','$ ');
+$svn_version = 'Subversion ' . trim('$Rev$','$ ');
-// Use output buffering, this gains us a few things and
+// Use output buffering, this gains us a few things and
// fixes some CSS issues
ob_start();
// Do a check for PHP5 because nothing will work without it
if (floatval(phpversion()) < 5) {
echo "ERROR: Ampache requires PHP5";
- exit;
+ exit;
}
error_reporting(E_ERROR); // Only show fatal errors in production
@@ -41,7 +41,7 @@ $ampache_path = dirname(__FILE__);
$prefix = realpath($ampache_path . "/../");
$configfile = "$prefix/config/ampache.cfg.php";
require_once $prefix . '/lib/general.lib.php';
-require_once $prefix . '/lib/class/config.class.php';
+require_once $prefix . '/lib/class/config.class.php';
require_once $prefix . '/lib/class/vauth.class.php'; // Fixes synology bug with __autoload in certain cases
if (!function_exists('gettext')) {
@@ -49,15 +49,15 @@ if (!function_exists('gettext')) {
}
// Define some base level config options
-Config::set('prefix',$prefix);
+Config::set('prefix',$prefix);
/*
Check to see if this is Http or https
*/
-if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
+if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$http_type = "https://";
}
-else {
+else {
$http_type = "http://";
}
@@ -66,51 +66,51 @@ else {
then go ahead and move them over to the install
script
*/
-if (!file_exists($configfile)) {
+if (!file_exists($configfile)) {
$path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
$link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/install.php";
header ("Location: $link");
exit();
}
-// Use the built in PHP function, supress errors here so we can handle it properly
-$results = @parse_ini_file($configfile);
+// Use the built in PHP function, supress errors here so we can handle it properly
+$results = @parse_ini_file($configfile);
-if (!count($results)) {
+if (!count($results)) {
$path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
$link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/test.php?action=config";
header ("Location: $link");
exit();
-}
+}
/** Verify a few commonly removed PHP functions exist and re-direct to /test if not **/
-if (!function_exists('hash') OR !function_exists('inet_pton') OR (strtoupper(substr(PHP_OS,0,3)) == 'WIN' AND floatval(phpversion()) < 5.3)) {
+if (!function_exists('hash') OR !function_exists('inet_pton') OR (strtoupper(substr(PHP_OS,0,3)) == 'WIN' AND floatval(phpversion()) < 5.3)) {
$path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
$link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/test.php";
- header ("Location: $link");
- exit();
-}
+ header ("Location: $link");
+ exit();
+}
/** This is the version.... fluf nothing more... **/
-$results['version'] = '3.6-Alpha1 '. $svn_version;
-$results['int_config_version'] = '10';
+$results['version'] = '3.6-Alpha1 '. $svn_version;
+$results['int_config_version'] = '10';
$results['raw_web_path'] = $results['web_path'];
$results['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['web_path'];
$results['http_port'] = $_SERVER['SERVER_PORT'];
-if (!$results['http_port']) {
+if (!$results['http_port']) {
$results['http_port'] = '80';
-}
-if (!$results['site_charset']) {
+}
+if (!$results['site_charset']) {
$results['site_charset'] = "UTF-8";
}
-if (!$results['raw_web_path']) {
+if (!$results['raw_web_path']) {
$results['raw_web_path'] = '/';
}
-if (!$_SERVER['SERVER_NAME']) {
+if (!$_SERVER['SERVER_NAME']) {
$_SERVER['SERVER_NAME'] = '';
}
-if (isset($results['user_ip_cardinality']) && !$results['user_ip_cardinality']) {
+if (isset($results['user_ip_cardinality']) && !$results['user_ip_cardinality']) {
$results['user_ip_cardinality'] = 42;
}
@@ -136,8 +136,8 @@ require_once $prefix . '/lib/gettext.php';
require_once $prefix . '/lib/batch.lib.php';
require_once $prefix . '/lib/themes.php';
require_once $prefix . '/lib/class/localplay.abstract.php';
-require_once $prefix . '/lib/class/database_object.abstract.php';
-require_once $prefix . '/lib/class/media.interface.php';
+require_once $prefix . '/lib/class/database_object.abstract.php';
+require_once $prefix . '/lib/class/media.interface.php';
require_once $prefix . '/modules/getid3/getid3.php';
require_once $prefix . '/modules/nusoap/nusoap.php';
require_once $prefix . '/modules/phpmailer/class.phpmailer.php';
@@ -154,7 +154,7 @@ $results = Preference::fix_preferences($results);
Config::set_by_array($results,1);
// Modules (These are conditionaly included depending upon config values)
-if (Config::get('ratings')) {
+if (Config::get('ratings')) {
require_once $prefix . '/lib/class/rating.class.php';
require_once $prefix . '/lib/rating.lib.php';
}
@@ -164,84 +164,84 @@ $old_error_handler = set_error_handler('ampache_error_handler');
/* Check their PHP Vars to make sure we're cool here */
$post_size = @ini_get('post_max_size');
-if (substr($post_size,strlen($post_size)-1,strlen($post_size)) != 'M') {
+if (substr($post_size,strlen($post_size)-1,strlen($post_size)) != 'M') {
/* Sane value time */
ini_set('post_max_size','8M');
}
-if ($results['memory_limit'] < 24) {
+if ($results['memory_limit'] < 24) {
$results['memory_limit'] = 24;
}
-// Incase the local setting is 0
-ini_set('session.gc_probability','2');
+// Incase the local setting is 0
+ini_set('session.gc_probability','2');
set_memory_limit($results['memory_limit']);
/**** END Set PHP Vars ****/
// If we want a session
-if (NO_SESSION != '1' AND Config::get('use_auth')) {
+if (NO_SESSION != '1' AND Config::get('use_auth')) {
/* Verify Their session */
- if (!vauth::session_exists('interface',$_COOKIE[Config::get('session_name')])) { vauth::logout($_COOKIE[Config::get('session_name')]); exit; }
-
+ if (!vauth::session_exists('interface',$_COOKIE[Config::get('session_name')])) { vauth::logout($_COOKIE[Config::get('session_name')]); exit; }
+
// This actually is starting the session
vauth::check_session();
/* Create the new user */
$GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']);
-
+
/* If they user ID doesn't exist deny them */
- if (!$GLOBALS['user']->id AND !Config::get('demo_mode')) { vauth::logout(session_id()); exit; }
+ if (!$GLOBALS['user']->id AND !Config::get('demo_mode')) { vauth::logout(session_id()); exit; }
- vauth::session_extend(session_id());
+ vauth::session_extend(session_id());
/* Load preferences and theme */
$GLOBALS['user']->update_last_seen();
}
-elseif (!Config::get('use_auth')) {
+elseif (!Config::get('use_auth')) {
$auth['success'] = 1;
$auth['username'] = '-1';
$auth['fullname'] = "Ampache User";
$auth['id'] = -1;
$auth['offset_limit'] = 50;
- $auth['access'] = Config::get('default_auth_level') ? User::access_name_to_level(Config::get('default_auth_level')) : '100';
- if (!vauth::session_exists('interface',$_COOKIE[Config::get('session_name')])) {
- vauth::create_cookie();
- vauth::session_create($auth);
- vauth::check_session();
- $GLOBALS['user'] = new User($auth['username']);
- $GLOBALS['user']->username = $auth['username'];
- $GLOBALS['user']->fullname = $auth['fullname'];
- $GLOBALS['user']->access = $auth['access'];
+ $auth['access'] = Config::get('default_auth_level') ? User::access_name_to_level(Config::get('default_auth_level')) : '100';
+ if (!vauth::session_exists('interface',$_COOKIE[Config::get('session_name')])) {
+ vauth::create_cookie();
+ vauth::session_create($auth);
+ vauth::check_session();
+ $GLOBALS['user'] = new User($auth['username']);
+ $GLOBALS['user']->username = $auth['username'];
+ $GLOBALS['user']->fullname = $auth['fullname'];
+ $GLOBALS['user']->access = $auth['access'];
}
- else {
- vauth::check_session();
- if ($_SESSION['userdata']['username']) {
+ else {
+ vauth::check_session();
+ if ($_SESSION['userdata']['username']) {
$GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']);
- }
- else {
- $GLOBALS['user'] = new User($auth['username']);
- $GLOBALS['user']->id = '-1';
- $GLOBALS['user']->username = $auth['username'];
- $GLOBALS['user']->fullname = $auth['fullname'];
- $GLOBALS['user']->access = $auth['access'];
- }
+ }
+ else {
+ $GLOBALS['user'] = new User($auth['username']);
+ $GLOBALS['user']->id = '-1';
+ $GLOBALS['user']->username = $auth['username'];
+ $GLOBALS['user']->fullname = $auth['fullname'];
+ $GLOBALS['user']->access = $auth['access'];
+ }
if (!$GLOBALS['user']->id AND !Config::get('demo_mode')) { vauth::logout(session_id()); exit; }
$GLOBALS['user']->update_last_seen();
- }
+ }
}
// If Auth, but no session is set
-else {
- if (isset($_REQUEST['sid'])) {
- session_name(Config::get('session_name'));
+else {
+ if (isset($_REQUEST['sid'])) {
+ session_name(Config::get('session_name'));
session_id(scrub_in($_REQUEST['sid']));
session_start();
$GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']);
}
- else {
- $GLOBALS['user'] = new User();
- }
+ else {
+ $GLOBALS['user'] = new User();
+ }
} // If NO_SESSION passed
@@ -249,9 +249,9 @@ else {
Preference::init();
// We need to create the tmp playlist for our user only if we have a session
-if (session_id()) {
- $GLOBALS['user']->load_playlist();
-}
+if (session_id()) {
+ $GLOBALS['user']->load_playlist();
+}
/* Add in some variables for ajax done here because we need the user */
Config::set('ajax_url',Config::get('web_path') . '/server/ajax.server.php',1);
@@ -267,7 +267,7 @@ unset($array);
unset($results);
/* Setup the flip class */
-flip_class(array('odd','even'));
+flip_class(array('odd','even'));
/* Check to see if we need to perform an update */
if (!preg_match('/update\.php/', $_SERVER['PHP_SELF'])) {
@@ -277,14 +277,14 @@ if (!preg_match('/update\.php/', $_SERVER['PHP_SELF'])) {
}
}
// For the XMLRPC stuff
-$GLOBALS['xmlrpc_internalencoding'] = Config::get('site_charset');
+$GLOBALS['xmlrpc_internalencoding'] = Config::get('site_charset');
// If debug is on GIMMIE DA ERRORS
if (Config::get('debug')) {
error_reporting(E_ALL);
}
-// Merge GET then POST into REQUEST effectivly striping COOKIE without depending on
+// Merge GET then POST into REQUEST effectivly striping COOKIE without depending on
// a PHP setting change to take affect
-$_REQUEST = array_merge($_GET,$_POST);
+$_REQUEST = array_merge($_GET,$_POST);
?>
diff --git a/lib/install.php b/lib/install.php
index a851aecd..655bb25d 100644
--- a/lib/install.php
+++ b/lib/install.php
@@ -170,14 +170,14 @@ function install_insert_db($username,$password,$hostname,$database,$dbuser=false
/* Check and see if we should create a user here */
if ($_POST['db_user'] == 'create_db_user' || (strlen($dbuser) AND strlen($dbpass))) {
-
- $db_user = $_POST['db_username'] ? scrub_in($_POST['db_username']) : $dbuser;
- $db_pass = $_POST['db_password'] ? scrub_in($_POST['db_password']) : $dbpass;
- if (!strlen($db_user) || !strlen($db_pass)) {
- Error::add('general','Error: Ampache SQL Username or Password missing');
- return false;
- }
+ $db_user = $_POST['db_username'] ? scrub_in($_POST['db_username']) : $dbuser;
+ $db_pass = $_POST['db_password'] ? scrub_in($_POST['db_password']) : $dbpass;
+
+ if (!strlen($db_user) || !strlen($db_pass)) {
+ Error::add('general','Error: Ampache SQL Username or Password missing');
+ return false;
+ }
$sql = "GRANT ALL PRIVILEGES ON " . Dba::escape($database) . ".* TO " .
"'" . Dba::escape($db_user) . "'@'" . Dba::escape($hostname) . "' IDENTIFIED BY '" . Dba::escape($db_pass) . "' WITH GRANT OPTION";
@@ -235,14 +235,14 @@ function install_insert_db($username,$password,$hostname,$database,$dbuser=false
*/
function install_create_config($web_path,$username,$password,$hostname,$database) {
- $config_file = Config::get('prefix') . '/config/ampache.cfg.php';
+ $config_file = Config::get('prefix') . '/config/ampache.cfg.php';
// Make sure the directory is writeable OR the empty config file is
- if (!is_writeable(Config::get('prefix') . '/config/') AND !is_writeable($config_file)) {
+ if (!is_writeable(Config::get('prefix') . '/config/') AND !is_writeable($config_file)) {
/* HINT: Config File */
- Error::add('general',sprintf(_('%s is not writeable'),$config_file));
- return false;
- }
+ Error::add('general',sprintf(_('%s is not writeable'),$config_file));
+ return false;
+ }
$data['database_username'] = $username;
$data['database_password'] = $password;
@@ -272,14 +272,14 @@ function install_create_config($web_path,$username,$password,$hostname,$database
$final = generate_config($data);
// Open the file and try to write it
- $fhandle = fopen($config_file,'w');
- if (!fwrite($fhandle,$final)) {
- Error::add('general',"Error Writing config file");
- fclose ($fhandle);
- return false;
- }
- fclose ($fhandle);
-
+ $fhandle = fopen($config_file,'w');
+ if (!fwrite($fhandle,$final)) {
+ Error::add('general',"Error Writing config file");
+ fclose ($fhandle);
+ return false;
+ }
+ fclose ($fhandle);
+
return true;
diff --git a/lib/log.lib.php b/lib/log.lib.php
index 5be7e780..0b3e3587 100644
--- a/lib/log.lib.php
+++ b/lib/log.lib.php
@@ -25,21 +25,21 @@
@discussion logs an event either to a database
or to a defined log file based on config options
*/
-function log_event($username='Unknown',$event_name,$event_description,$log_name='ampache') {
+function log_event($username='Unknown',$event_name,$event_description,$log_name='ampache') {
/* Set it up here to make sure it's _always_ the same */
$log_time = time();
/* must have some name */
- if (!strlen($log_name)) { $log_name = 'ampache'; }
+ if (!strlen($log_name)) { $log_name = 'ampache'; }
- $username = $username ? $username : 'ampache';
+ $username = $username ? $username : 'ampache';
$log_filename = Config::get('log_path') . "/$log_name." . date("Ymd",$log_time) . ".log";
- $log_line = date("Y-m-d H:i:s",$log_time) . " [$username] ($event_name) -> $event_description \n";
+ $log_line = date("Y-m-d H:i:s",$log_time) . " [$username] ($event_name) -> $event_description \n";
$log_write = error_log($log_line, 3, $log_filename);
-
- if (!$log_write) {
+
+ if (!$log_write) {
echo "Warning: Unable to write to log ($log_filename) Please check your log_path variable in ampache.cfg.php";
}
@@ -50,12 +50,12 @@ function log_event($username='Unknown',$event_name,$event_description,$log_name=
@discussion an error handler for ampache that traps
as many errors as it can and logs em
*/
-function ampache_error_handler($errno, $errstr, $errfile, $errline) {
+function ampache_error_handler($errno, $errstr, $errfile, $errline) {
/* Default level of 1 */
$level = 1;
-
- switch ($errno) {
+
+ switch ($errno) {
case '2':
$error_name = "Runtime Error";
break;
@@ -81,36 +81,36 @@ function ampache_error_handler($errno, $errstr, $errfile, $errline) {
$level = 2;
break;
} // end switch
-
+
/* Don't log var: Deprecated we know shutup!
* Yea now getid3() spews errors I love it :(
*/
if (strstr($errstr,"var: Deprecated. Please use the public/private/protected modifiers") OR
strstr($errstr,"getimagesize() [") OR strstr($errstr,"Non-static method getid3") OR
- strstr($errstr,"Assigning the return value of new by reference is deprecated")) {
- return false;
+ strstr($errstr,"Assigning the return value of new by reference is deprecated")) {
+ return false;
}
- if (strstr($errstr,"date.timezone")) {
- $error_name = "Warning";
- $errstr = "You have not set a valid timezone (date.timezone) in your php.ini file. This may cause display issues with dates. This warning is non-critical and not caused by Ampache.";
- }
+ if (strstr($errstr,"date.timezone")) {
+ $error_name = "Warning";
+ $errstr = "You have not set a valid timezone (date.timezone) in your php.ini file. This may cause display issues with dates. This warning is non-critical and not caused by Ampache.";
+ }
- /* The XML-RPC lib is broken, well kind of
- * shut your pie hole
+ /* The XML-RPC lib is broken, well kind of
+ * shut your pie hole
*/
- if (strstr($errstr,"used as offset, casting to integer")) {
- return false;
+ if (strstr($errstr,"used as offset, casting to integer")) {
+ return false;
}
$log_line = "[$error_name] $errstr in file $errfile($errline)";
debug_event('PHP Error',$log_line,$level);
-
+
// When a dir is defined lets log it to a logfile
- if (Config::get('log_path') != "")
+ if (Config::get('log_path') != "")
log_event("ampache","PHP Error", $log_line);
-
+
} // ampache_error_handler
/**
@@ -119,13 +119,13 @@ function ampache_error_handler($errno, $errstr, $errfile, $errline) {
* log_event. It checks for conf('debug') and conf('debug_level') and only
* calls log event if both requirements are met.
*/
-function debug_event($type,$message,$level,$file='',$username='') {
+function debug_event($type,$message,$level,$file='',$username='') {
- if (!Config::get('debug') || $level > Config::get('debug_level')) {
+ if (!Config::get('debug') || $level > Config::get('debug_level')) {
return false;
}
- if (!$username) {
+ if (!$username) {
$username = $GLOBALS['user']->username;
}
diff --git a/lib/preferences.php b/lib/preferences.php
index a1a577a3..ac81c398 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -266,14 +266,14 @@ function create_preference_input($name,$value) {
echo "\t<option value=\"75\"$bandwidth_75>" . _('High') . "</option>\n";
echo "</select>\n";
break;
- case 'features':
- ${"features_$value"} = ' selected="selected"';
- echo "<select name=\"$name\">\n";
+ case 'features':
+ ${"features_$value"} = ' selected="selected"';
+ echo "<select name=\"$name\">\n";
echo "\t<option value=\"25\"$features_25>" . _('Low') . "</option>\n";
echo "\t<option value=\"50\"$features_50>" . _('Medium') . "</option>\n";
echo "\t<option value=\"75\"$features_75>" . _('High') . "</option>\n";
echo "</select>\n";
- break;
+ break;
case 'transcode':
${$value} = ' selected="selected"';
echo "<select name=\"$name\">\n";
diff --git a/lib/rating.lib.php b/lib/rating.lib.php
index aeac66d1..48ef4ab8 100644
--- a/lib/rating.lib.php
+++ b/lib/rating.lib.php
@@ -24,10 +24,10 @@
* show_rating
* This takes an artist id and includes the right file
*/
-function show_rating($object_id,$type) {
+function show_rating($object_id,$type) {
$rating = new Rating($object_id,$type);
-
+
require Config::get('prefix') . '/templates/show_object_rating.inc.php';
} // show_rating
@@ -43,11 +43,11 @@ function show_rating_static($object_id,$type) {
/**
* get_rating_name
- * This takes a score and returns the name that we should use
+ * This takes a score and returns the name that we should use
*/
-function get_rating_name($score) {
+function get_rating_name($score) {
- switch ($score) {
+ switch ($score) {
case '0':
return _("Don't Play");
break;
@@ -73,7 +73,7 @@ function get_rating_name($score) {
} // end switch
return true;
-
+
} // get_rating_name
?>
diff --git a/lib/search.php b/lib/search.php
index 06385874..2133b0fc 100644
--- a/lib/search.php
+++ b/lib/search.php
@@ -17,38 +17,38 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
This library handles all the searching!
*/
-/**
+/**
* run_search
* this function actually runs the search, and returns an array of the results. Unlike the previous
- * function it does not do the display work its self.
+ * function it does not do the display work its self.
* @package Search
* @catagory Search
*/
-function run_search($data) {
+function run_search($data) {
/* Create an array of the object we need to search on */
- foreach ($data as $key=>$value) {
+ foreach ($data as $key=>$value) {
/* Get the first two chars to check
* and see if it's s_
*/
$prefix = substr($key,0,2);
$value = trim($value);
-
- if ($prefix == 's_' AND strlen($value)) {
+
+ if ($prefix == 's_' AND strlen($value)) {
$true_name = substr($key,2,strlen($key));
$search[$true_name] = Dba::escape($value);
}
-
+
} // end foreach
-
+
/* Figure out if they want a AND based search or a OR based search */
- switch($_REQUEST['operator']) {
+ switch($_REQUEST['operator']) {
case 'or':
$operator = 'OR';
break;
@@ -58,7 +58,7 @@ function run_search($data) {
} // end switch on operator
/* Figure out what type of method they would like to use, exact or fuzzy */
- switch($_REQUEST['method']) {
+ switch($_REQUEST['method']) {
case 'fuzzy':
$method = "LIKE '%__%'";
break;
@@ -68,14 +68,14 @@ function run_search($data) {
} // end switch on method
$limit = intval($_REQUEST['limit']);
-
+
/* Switch, and run the correct function */
- switch($_REQUEST['object_type']) {
+ switch($_REQUEST['object_type']) {
case 'artist':
case 'album':
case 'song':
$function_name = 'search_' . $_REQUEST['object_type'];
- if (function_exists($function_name)) {
+ if (function_exists($function_name)) {
$results = call_user_func($function_name,$search,$operator,$method,$limit);
return $results;
}
@@ -84,20 +84,20 @@ function run_search($data) {
$results = search_song($search,$operator,$method,$limit);
return $results;
break;
- } // end switch
+ } // end switch
return array();
} // run_search
-/**
+/**
* search_song
* This function deals specificly with returning song object for the run_search
* function, it assumes that our root table is songs
* @package Search
* @catagory Search
*/
-function search_song($data,$operator,$method,$limit) {
+function search_song($data,$operator,$method,$limit) {
/* Generate BASE SQL */
@@ -108,45 +108,45 @@ function search_song($data,$operator,$method,$limit) {
$field_sql = '';
$order_sql = '';
- if ($limit > 0) {
+ if ($limit > 0) {
$limit_sql = " LIMIT $limit";
}
-
- foreach ($data as $type=>$value) {
-
+
+ foreach ($data as $type=>$value) {
+
/* Create correct Value statement based on method */
$value_string = str_replace("__",$value,$method);
-
- switch ($type) {
+
+ switch ($type) {
case 'all':
$additional_soundex = false;
-
+
if (!(strpos($value, '-'))) // if we want a fuzzier search
$additional_soundex = true;
-
+
$where_sql = " MATCH (`artist2`.`name`, `album2`.`name`, `song`.`title`) AGAINST ('$value' IN BOOLEAN MODE)";
-
+
if ($additional_soundex) {
$where_sql.= " OR `artist2`.`name` SOUNDS LIKE '$value'";
$where_sql.= " OR `album2`.`name` SOUNDS LIKE '$value'";
$where_sql.= " OR `song`.`title` SOUNDS LIKE '$value'";
}
-
+
$table_sql = " LEFT JOIN `album` as `album2` ON `song`.`album`=`album2`.`id`";
$table_sql.= " LEFT JOIN `artist` AS `artist2` ON `song`.`artist`=`artist2`.`id`";
-
+
$order_sql = " ORDER BY";
-
+
$order_sql.= " MATCH (`artist2`.`name`) AGAINST ('$value' IN BOOLEAN MODE)";
if ($additional_soundex) $order_sql.= " + (SOUNDEX(`artist2`.`name`)=SOUNDEX('$value')) DESC,"; else $order_sql.= " DESC,";
-
+
$order_sql.= " MATCH (`album2`.`name`) AGAINST ('$value' IN BOOLEAN MODE)";
if ($additional_soundex) $order_sql.= " + (SOUNDEX(`album2`.`name`)=SOUNDEX('$value')) DESC,"; else $order_sql.= " DESC,";
-
+
$order_sql.= " MATCH (`song`.`title`) AGAINST ('$value' IN BOOLEAN MODE)";
if ($additional_soundex) $order_sql.= " + (SOUNDEX(`song`.`title`)=SOUNDEX('$value')) DESC,"; else $order_sql.= " DESC,";
-
+
$order_sql.= " `artist2`.`name`,";
$order_sql.= " `album2`.`name`,";
$order_sql.= " `song`.`track`,";
@@ -171,14 +171,14 @@ function search_song($data,$operator,$method,$limit) {
$where_sql .= " (`song`.`year` BETWEEN ".$data["year"]." AND ".$data["year2"].") $operator";
}
break;
- case 'time':
- if (!empty($data['time2'])) {
- $where_sql .= " `song`.`time` <= " . Dba::escape(intval($data['time2'])*60) . " $operator";
+ case 'time':
+ if (!empty($data['time2'])) {
+ $where_sql .= " `song`.`time` <= " . Dba::escape(intval($data['time2'])*60) . " $operator";
}
- if (!empty($data['time'])) {
- $where_sql .= " `song`.`time` >= " . Dba::escape(intval($data['time'])*60) . " $operator";
- }
- break;
+ if (!empty($data['time'])) {
+ $where_sql .= " `song`.`time` >= " . Dba::escape(intval($data['time'])*60) . " $operator";
+ }
+ break;
case 'filename':
$where_sql .= " `song`.`file` $value_string $operator";
break;
@@ -199,70 +199,70 @@ function search_song($data,$operator,$method,$limit) {
$value = intval($value);
// This is a little more complext, pull a list of IDs that have this average rating
- $rating_sql = "SELECT `object_id`,AVG(`rating`.`rating`) AS `avgrating` FROM `rating` " .
- "WHERE `object_type`='song' GROUP BY `object_id`";
- $db_results = Dba::read($rating_sql);
+ $rating_sql = "SELECT `object_id`,AVG(`rating`.`rating`) AS `avgrating` FROM `rating` " .
+ "WHERE `object_type`='song' GROUP BY `object_id`";
+ $db_results = Dba::read($rating_sql);
// Fill it with one value to prevent sql error on no results
$where_sql .= " `song`.`id` IN (";
- $ids = array('0');
+ $ids = array('0');
- while ($row = Dba::fetch_assoc($db_results)) {
- if ($row['avgrating'] < $value) { continue; }
- $ids[] = $row['object_id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ if ($row['avgrating'] < $value) { continue; }
+ $ids[] = $row['object_id'];
+ }
- $where_sql .= implode(',',$ids) . ') ' . $operator;
+ $where_sql .= implode(',',$ids) . ') ' . $operator;
break;
- case 'tag':
+ case 'tag':
// Fill it with one value to prevent sql error on no results
- $ids = array('0');
+ $ids = array('0');
- $tag_sql = "SELECT `object_id` FROM `tag` LEFT JOIN `tag_map` ON `tag`.`id`=`tag_map`.`tag_id` " .
- "WHERE `tag_map`.`object_type`='song' AND `tag`.`name` $value_string ";
- $db_results = Dba::read($tag_sql);
+ $tag_sql = "SELECT `object_id` FROM `tag` LEFT JOIN `tag_map` ON `tag`.`id`=`tag_map`.`tag_id` " .
+ "WHERE `tag_map`.`object_type`='song' AND `tag`.`name` $value_string ";
+ $db_results = Dba::read($tag_sql);
- while ($row = Dba::fetch_assoc($db_results)) {
- $ids[] = $row['object_id'];
- }
+ while ($row = Dba::fetch_assoc($db_results)) {
+ $ids[] = $row['object_id'];
+ }
- $where_sql = " `song`.`id` IN (" . implode(',',$ids) . ") $operator";
+ $where_sql = " `song`.`id` IN (" . implode(',',$ids) . ") $operator";
- break;
+ break;
default:
// Notzing!
break;
} // end switch on type
-
+
} // foreach data
-
+
/* Trim off the extra $method's and ,'s then combine the sucka! */
$where_sql = rtrim($where_sql,$operator);
$group_sql = rtrim($group_sql,',');
$select_sql = rtrim($select_sql,',');
- if ($group_sql == ' GROUP BY') { $group_sql = ''; }
-
+ if ($group_sql == ' GROUP BY') { $group_sql = ''; }
+
$base_sql = "SELECT DISTINCT(`song`.`id`) $field_sql $select_sql FROM `song`";
$sql = $base_sql . $table_sql . " WHERE " . $where_sql . $group_sql . $order_sql . $limit_sql;
-
+
/**
- * Because we might need this for Dynamic Playlist Action
+ * Because we might need this for Dynamic Playlist Action
* but we don't trust users to provide this store it in the
* session where they can't get to it!
*/
-
+
$_SESSION['userdata']['stored_search'] = $sql;
$db_results = Dba::read($sql);
-
- $results = array();
-
- while ($row = Dba::fetch_assoc($db_results)) {
+
+ $results = array();
+
+ while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row['id'];
}
diff --git a/lib/themes.php b/lib/themes.php
index 2ff2c335..0fb58fdd 100644
--- a/lib/themes.php
+++ b/lib/themes.php
@@ -22,39 +22,39 @@
/**
* get_themes
- * this looks in /themes and pulls all of the
- * theme.cfg.php files it can find and returns an
+ * this looks in /themes and pulls all of the
+ * theme.cfg.php files it can find and returns an
* array of the results
*/
-function get_themes() {
+function get_themes() {
/* Open the themes dir and start reading it */
$handle = @opendir(Config::get('prefix') . '/themes');
- if (!is_resource($handle)) {
- debug_event('theme',"Error unable to open Themes Directory",'2');
- return array();
+ if (!is_resource($handle)) {
+ debug_event('theme',"Error unable to open Themes Directory",'2');
+ return array();
}
- $results = array();
+ $results = array();
+
+ while ($file = readdir($handle)) {
- while ($file = readdir($handle)) {
-
$full_file = Config::get('prefix') . '/themes/' . $file;
/* See if it's a directory */
- if (is_dir($full_file) AND substr($file,0,1) != ".") {
+ if (is_dir($full_file) AND substr($file,0,1) != ".") {
$config_file = $full_file . '/theme.cfg.php';
/* Open the theme.cfg.php file */
$r = @parse_ini_file($config_file);
$r['path'] = $file;
- $name = $r['name'];
+ $name = $r['name'];
$results[$name] = $r;
}
} // end while directory
// Sort by the theme name
- ksort($results);
+ ksort($results);
return $results;
@@ -65,7 +65,7 @@ function get_themes() {
@discussion get a single theme and read the config file
then return the results
*/
-function get_theme($name) {
+function get_theme($name) {
if (strlen($name) < 1) { return false; }
@@ -80,7 +80,7 @@ function get_theme($name) {
@function get_theme_author
@discussion returns the author of this theme
*/
-function get_theme_author($theme_name) {
+function get_theme_author($theme_name) {
$theme_path = conf('prefix') . "/themes/" . conf('theme_name') . "/theme.cfg.php";
$results = read_config($theme_path);
@@ -93,12 +93,12 @@ function get_theme_author($theme_name) {
@function theme_exists
@discussion this function checks to make sure that a theme actually exists
*/
-function theme_exists($theme_name) {
+function theme_exists($theme_name) {
$theme_path = conf('prefix') . "/themes/" . $theme_name . "/theme.cfg.php";
- if (!file_exists($theme_path)) {
- return false;
+ if (!file_exists($theme_path)) {
+ return false;
}
return true;
diff --git a/localplay.php b/localplay.php
index fc1556c5..5c325dfd 100644
--- a/localplay.php
+++ b/localplay.php
@@ -22,69 +22,69 @@
require 'lib/init.php';
-show_header();
+show_header();
// Check to see if we've got the rights to be here
-if (!Config::get('allow_localplay_playback') || !Access::check('interface','25')) {
- access_denied();
- exit;
-}
+if (!Config::get('allow_localplay_playback') || !Access::check('interface','25')) {
+ access_denied();
+ exit;
+}
-switch ($_REQUEST['action']) {
- case 'show_add_instance':
+switch ($_REQUEST['action']) {
+ case 'show_add_instance':
// This requires 50 or better
- if (!Access::check('localplay','75')) { access_denied(); break; }
-
+ if (!Access::check('localplay','75')) { access_denied(); break; }
+
// Get the current localplay fields
- $localplay = new Localplay(Config::get('localplay_controller'));
- $fields = $localplay->get_instance_fields();
- require_once Config::get('prefix') . '/templates/show_localplay_add_instance.inc.php';
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $fields = $localplay->get_instance_fields();
+ require_once Config::get('prefix') . '/templates/show_localplay_add_instance.inc.php';
break;
- case 'add_instance':
+ case 'add_instance':
// This requires 50 or better!
- if (!Access::check('localplay','75')) { access_denied(); break; }
-
+ if (!Access::check('localplay','75')) { access_denied(); break; }
+
// Setup the object
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->add_instance($_POST);
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->add_instance($_POST);
break;
- case 'update_instance':
+ case 'update_instance':
// Make sure they gots them rights
- if (!Access::check('localplay','75')) { access_denied(); break; }
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->update_instance($_REQUEST['instance'],$_POST);
- header("Location:" . Config::get('web_path') . "/localplay.php?action=show_instances");
- break;
- case 'edit_instance':
+ if (!Access::check('localplay','75')) { access_denied(); break; }
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->update_instance($_REQUEST['instance'],$_POST);
+ header("Location:" . Config::get('web_path') . "/localplay.php?action=show_instances");
+ break;
+ case 'edit_instance':
// Check to make sure they've got the access
- if (!Access::check('localplay','75')) { access_denied(); break; }
- $localplay = new Localplay(Config::get('localplay_controller'));
- $instance = $localplay->get_instance($_REQUEST['instance']);
- $fields = $localplay->get_instance_fields();
- require_once Config::get('prefix') . '/templates/show_localplay_edit_instance.inc.php';
- break;
- case 'show_instances':
+ if (!Access::check('localplay','75')) { access_denied(); break; }
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $instance = $localplay->get_instance($_REQUEST['instance']);
+ $fields = $localplay->get_instance_fields();
+ require_once Config::get('prefix') . '/templates/show_localplay_edit_instance.inc.php';
+ break;
+ case 'show_instances':
// First build the localplay object and then get the instances
- if (!Access::check('localplay','5')) { access_denied(); break; }
- $localplay = new Localplay(Config::get('localplay_controller'));
- $instances = $localplay->get_instances();
- $fields = $localplay->get_instance_fields();
- require_once Config::get('prefix') . '/templates/show_localplay_instances.inc.php';
- break;
- default:
- case 'show_playlist':
- if (!Access::check('localplay','5')) { access_denied(); break; }
+ if (!Access::check('localplay','5')) { access_denied(); break; }
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $instances = $localplay->get_instances();
+ $fields = $localplay->get_instance_fields();
+ require_once Config::get('prefix') . '/templates/show_localplay_instances.inc.php';
+ break;
+ default:
+ case 'show_playlist':
+ if (!Access::check('localplay','5')) { access_denied(); break; }
// Init and then connect to our localplay instance
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->connect();
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->connect();
// Pull the current playlist and require the template
- $objects = $localplay->get();
+ $objects = $localplay->get();
require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php';
- Browse::set_type('playlist_localplay');
- Browse::set_static_content(1);
- Browse::show_objects($objects);
+ Browse::set_type('playlist_localplay');
+ Browse::set_static_content(1);
+ Browse::show_objects($objects);
break;
} // end switch action
diff --git a/login.php b/login.php
index c4b10838..acff1833 100644
--- a/login.php
+++ b/login.php
@@ -24,21 +24,21 @@ define('NO_SESSION','1');
require_once 'lib/init.php';
/* We have to create a cookie here because IIS
- * can't handle Cookie + Redirect
+ * can't handle Cookie + Redirect
*/
-vauth::create_cookie();
+vauth::create_cookie();
Preference::init();
/**
* If Access Control is turned on then we don't
- * even want them to be able to get to the login
+ * even want them to be able to get to the login
* page if they aren't in the ACL
*/
-if (Config::get('access_control')) {
+if (Config::get('access_control')) {
if (!Access::check_network('interface','','5')) {
debug_event('access_denied','Access Denied:' . $_SERVER['REMOTE_ADDR'] . ' is not in the Interface Access list','3');
access_denied();
- exit();
+ exit();
}
} // access_control is enabled
@@ -47,13 +47,13 @@ unset($auth);
/* Check for posted username and password, or appropriate environment
variable if using HTTP auth */
-if (($_POST['username'] && $_POST['password']) ||
-(in_array('http',Config::get('auth_methods')) &&
+if (($_POST['username'] && $_POST['password']) ||
+(in_array('http',Config::get('auth_methods')) &&
($_SERVER['REMOTE_USER'] || $_SERVER['HTTP_REMOTE_USER']))) {
if ($_POST['rememberme']) {
- vauth::create_remember_cookie();
- }
+ vauth::create_remember_cookie();
+ }
/* If we are in demo mode let's force auth success */
if (Config::get('demo_mode')) {
@@ -78,39 +78,39 @@ if (($_POST['username'] && $_POST['password']) ||
}
$auth = vauth::authenticate($username, $password);
$user = User::get_from_username($username);
-
- if (!$auth['success']) {
- debug_event('Login',scrub_out($username) . ' attempted to login and failed','1');
- }
-
- if ($user->disabled == '1') {
+
+ if (!$auth['success']) {
+ debug_event('Login',scrub_out($username) . ' attempted to login and failed','1');
+ }
+
+ if ($user->disabled == '1') {
$auth['success'] = false;
- Error::add('general',_('User Disabled please contact Admin'));
- debug_event('Login',scrub_out($username) . ' is disabled and attempted to login','1');
+ Error::add('general',_('User Disabled please contact Admin'));
+ debug_event('Login',scrub_out($username) . ' is disabled and attempted to login','1');
} // if user disabled
-
-
- elseif (!$user->username AND $auth['success']) {
- /* This is run if we want to auto_create users who don't exist (usefull for non mysql auth) */
+
+
+ elseif (!$user->username AND $auth['success']) {
+ /* This is run if we want to auto_create users who don't exist (usefull for non mysql auth) */
if (Config::get('auto_create')) {
- $access = Config::get('auto_user') ? User::access_name_to_level(Config::get('auto_user')) : '5';
+ $access = Config::get('auto_user') ? User::access_name_to_level(Config::get('auto_user')) : '5';
$name = $auth['name'];
$email = $auth['email'];
-
- /* Attempt to create the user */
+
+ /* Attempt to create the user */
if (!$user->create($username, $name, $email,hash('sha256',mt_rand()), $access)) {
$auth['success'] = false;
- Error::add('general',_('Unable to create new account'));
+ Error::add('general',_('Unable to create new account'));
}
- else {
+ else {
$user = new User($username);
}
} // End if auto_create
else {
$auth['success'] = false;
- Error::add('general',_('No local account found'));
+ Error::add('general',_('No local account found'));
}
} // else user isn't disabled
@@ -129,38 +129,38 @@ if ($auth['success']) {
if ($current_ip AND $current_ip != inet_pton($_SERVER['REMOTE_ADDR'])) {
Error::add('general',_('User Already Logged in'));
require Config::get('prefix') . '/templates/show_login_form.inc.php';
- exit;
+ exit;
}
} // if prevent_multiple_logins
// $auth->info are the fields specified in the config file
// to retrieve for each user
vauth::session_create($auth);
-
+
//
// Not sure if it was me or php tripping out,
// but naming this 'user' didn't work at all
//
$_SESSION['userdata'] = $auth;
- //
+ //
// Record the IP of this person!
- //
- if (Config::get('track_user_ip')) {
- $user->insert_ip_history();
+ //
+ if (Config::get('track_user_ip')) {
+ $user->insert_ip_history();
}
- /* Make sure they are actually trying to get to this site and don't try to redirect them back into
+ /* Make sure they are actually trying to get to this site and don't try to redirect them back into
* an admin section
**/
- if (substr($_POST['referrer'],0,strlen(Config::get('web_path'))) == Config::get('web_path') AND
- !strstr($_POST['referrer'],"install.php") AND
- !strstr($_POST['referrer'],"login.php") AND
+ if (substr($_POST['referrer'],0,strlen(Config::get('web_path'))) == Config::get('web_path') AND
+ !strstr($_POST['referrer'],"install.php") AND
+ !strstr($_POST['referrer'],"login.php") AND
!strstr($_POST['referrer'],'logout.php') AND
!strstr($_POST['referrer'],"update.php") AND
!strstr($_POST['referrer'],"activate.php") AND
- !strstr($_POST['referrer'],"admin")) {
-
+ !strstr($_POST['referrer'],"admin")) {
+
header("Location: " . $_POST['referrer']);
exit();
} // if we've got a referrer
diff --git a/logout.php b/logout.php
index b9bce721..408465dd 100644
--- a/logout.php
+++ b/logout.php
@@ -1,4 +1,4 @@
-<?php
+<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
/*
diff --git a/modules/captcha/captcha.php b/modules/captcha/captcha.php
index 4ecad8bc..c23be57e 100644
--- a/modules/captcha/captcha.php
+++ b/modules/captcha/captcha.php
@@ -24,26 +24,26 @@
This library operates CAPTCHA form submissions, to block spam bots and
alike. It is easy to hook into existing web sites and scripts. It also
tries to be "smart" and more user-friendly.
-
+
While the operation logic and identifier processing are extremley safe,
this is a "weak" implementation. Specifically targetted and tweaked OCR
software could overcome the visual riddle. And if enabled, the textual
or mathematical riddles are rather simple to overcome if attacked.
Generic spambots are however blocked already with the default settings.
-
+
PRINT captcha::form()
emits the img and input fields for inclusion into your submit <form>
-
+
IF (captcha::solved())
tests for a correctly entered solution on submit, returns true if ok
-
+
Temporary files are created for tracking, verification and basic data
storage, but will get automatically removed once a CAPTCHA was solved
to prevent replay attacks. Additionally this library uses "AJAX" super
powers *lol* to enhance usability. And a short-lasting session cookie
is also added site-wide, so users may only have to solve the captcha
once (can be disabled, because that's also just security by obscurity).
-
+
Public Domain, available via http://freshmeat.net/p/captchaphp
*/
@@ -143,7 +143,7 @@ class easy_captcha {
srand(microtime() + time()/2 - 21017);
if ($this->id) { $this->prev[] = $this->id; }
$this->id = $this->new_id();
-
+
#-- meta informations
$this->created = time();
$this->{'created$'} = gmdate("r", $this->created);
@@ -160,13 +160,13 @@ class easy_captcha {
$this->failures = 0;
$this->shortcut = array();
$this->grant = 0; // unchecked access
-
+
#-- mk IMAGE/GRAPHIC
$this->image = (CAPTCHA_IMAGE_TYPE <= 1)
? new easy_captcha_graphic_image_waved()
: new easy_captcha_graphic_image_disturbed();
//$this->image = new easy_captcha_graphic_cute_ponys();
-
+
#-- mk MATH/TEXT riddle
$this->text = (CAPTCHA_NOTEXT >= 1)
? new easy_captcha_text_disable()
@@ -181,11 +181,11 @@ class easy_captcha {
if (CAPTCHA_NEW_URLS)
$this->shortcut[] = new easy_captcha_spamfree_no_new_urls();
- #-- store record
+ #-- store record
$this->save();
}
-
-
+
+
#-- examine if captcha data is fresh
function is_valid() {
return isset($this->id) && ($this->created)
@@ -212,11 +212,11 @@ class easy_captcha {
// log, this is either a frustrated user or a bot knocking
$this->log("::solved", "INVALID", "tries exhausted ($this->tries) or expired(?) captcha");
}
-
+
#-- test
elseif ($this->sent) {
$in = $_REQUEST[CAPTCHA_PARAM_INPUT]; // might be empty string
-
+
#-- check individual modules
$ok = $this->grant;
foreach ($this->shortcut as $test) {
@@ -225,12 +225,12 @@ class easy_captcha {
$ok = $ok // either letters or math formula submitted
|| isset($this->image) && $this->image->solved($in)
|| isset($this->text) && $this->text->solved($in);
-
+
#-- update state
if ($ok) {
$this->passed++;
$this->log("::solved", "OKAY", "captcha passed ($in) for image({$this->image->solution}) and text({$this->text->solution})");
-
+
#-- set cookie on success
if (CAPTCHA_PERSISTENT) {
$this->shortcut[0/*FIXME*/]->grant();
@@ -255,15 +255,15 @@ class easy_captcha {
#-- return result
return($ok);
}
-
-
+
+
#-- combines ->image and ->text data into form fields
function form($add_text="") {
#-- store object data
$this->sent++;
$this->save();
-
+
#-- prepare output vars
$p_id = CAPTCHA_PARAM_ID;
$p_input = CAPTCHA_PARAM_INPUT;
@@ -331,7 +331,7 @@ class easy_captcha {
fclose($f);
}
}
-
+
#-- remove $this data file
function delete() {
// delete current and all previous data files
@@ -347,7 +347,7 @@ class easy_captcha {
}
return(FALSE); // far if-chaining in ->is_valid()
}
-
+
#-- clean-up or init temporary directory
function straighten_temp_dir() {
// create dir
@@ -377,7 +377,7 @@ class easy_captcha {
$pfix = (int) (time() / $length*CAPTCHA_TIMEOUT) + $dtime;
return md5("captcha::$pfix:$text::".__FILE__.":$_SERVER[SERVER_NAME]:80");
}
-
+
}
@@ -493,7 +493,7 @@ class easy_captcha_graphic extends easy_captcha_fuzzy {
class easy_captcha_graphic_image_waved extends easy_captcha_graphic {
- /* returns jpeg file stream with unscannable letters encoded
+ /* returns jpeg file stream with unscannable letters encoded
in front of colorful disturbing background
*/
function jpeg() {
@@ -537,7 +537,7 @@ class easy_captcha_graphic_image_waved extends easy_captcha_graphic {
imageline($this->img, 0, $x, 250, $x, 0x333333);
}
}
-
+
#-- add lines
function fog() {
$num = rand(10,25);
@@ -556,7 +556,7 @@ class easy_captcha_graphic_image_waved extends easy_captcha_graphic {
imagesetthickness($this->img, 1);
}
-
+
#-- distortion: wave-transform
function distort() {
@@ -567,7 +567,7 @@ class easy_captcha_graphic_image_waved extends easy_captcha_graphic {
$height = $this->height;
$i = & $this->img;
$dest = imagecreatetruecolor($width, $height);
-
+
#-- URL param ?hires=1 influences used drawing scheme
if (isset($_GET["hires"])) {
$single_pixel = 0;
@@ -584,7 +584,7 @@ class easy_captcha_graphic_image_waved extends easy_captcha_graphic {
#-- pixel movement
list($dx, $dy) = $wave->dxy($x, $y); // x- and y- sinus wave
// list($qx, $qy) = $spike->dxy($x, $y);
-
+
#-- get source pixel, paint dest
if ($single_pixel) {
// single source dot: one-to-one duplicate (unsmooth, hard edges)
@@ -605,10 +605,10 @@ class easy_captcha_graphic_image_waved extends easy_captcha_graphic {
}
#-- simply overwrite ->img
- imagedestroy($i);
+ imagedestroy($i);
$this->img = $dest;
}
-
+
#-- get 4 pixels from source image, merges BLUE value simply
function get_2x2_greyscale(&$i, $x, $y) {
// this is pretty simplistic method, actually adds more artefacts
@@ -627,7 +627,7 @@ class easy_captcha_graphic_image_waved extends easy_captcha_graphic {
// get R,G,B values from 2x2 source area
$c00 = $this->get_RGB($i, $x, $y); // +------+------+
$c01 = $this->get_RGB($i, $x, $y+1); // |dx,dy | x1,y0|
- $c10 = $this->get_RGB($i, $x+1, $y); // | rx-> | |
+ $c10 = $this->get_RGB($i, $x+1, $y); // | rx-> | |
$c11 = $this->get_RGB($i, $x+1, $y+1); // +----##+------+
// weighting by $dx/$dy fraction part // | ##|<-ry |
$rx = $x - floor($x); $rx_ = 1 - $rx; // |x0,y1 | x1,y1|
@@ -674,7 +674,7 @@ class easy_captcha_dxy_wave {
$this->slow_x = $this->real_rand(7.5, 20.0); // =wave-width in pixel/3
$this->slow_y = $this->real_rand(7.5, 15.0);
}
-
+
#-- calculate source pixel position with overlapping sinus x/y-displacement
function dxy($x, $y) {
#-- adapting params
@@ -686,7 +686,7 @@ class easy_captcha_dxy_wave {
#-- result
return array($dx, $dy);
}
-
+
#-- array of values with random start/end values
function from_to_rand($max, $a, $b) {
$BEG = $this->real_rand($a, $b);
@@ -726,7 +726,7 @@ class easy_captcha_dxy_spike {
class easy_captcha_graphic_image_disturbed extends easy_captcha_graphic {
- /* returns jpeg file stream with unscannable letters encoded
+ /* returns jpeg file stream with unscannable letters encoded
in front of colorful disturbing background
*/
function jpeg() {
@@ -743,7 +743,7 @@ class easy_captcha_graphic_image_disturbed extends easy_captcha_graphic {
function create() {
$this->img = imagecreatetruecolor($this->width, $this->height);
imagefilledrectangle($this->img, 0,0, $this->width,$this->height, $this->random_color(222, 255));
-
+
#-- encolour bg
$wd = 20;
$x = 0;
@@ -752,7 +752,7 @@ class easy_captcha_graphic_image_disturbed extends easy_captcha_graphic {
$wd += max(10, rand(0, 20) - 10);
}
}
-
+
#-- make interesting background I, lines
function background_lines() {
@@ -777,8 +777,8 @@ class easy_captcha_graphic_image_disturbed extends easy_captcha_graphic {
}
}
}
-
-
+
+
#-- more disturbing II, random letters
function background_letters() {
$limit = rand(30,90);
@@ -795,7 +795,7 @@ class easy_captcha_graphic_image_disturbed extends easy_captcha_graphic {
imagettftext($this->img, $size, $rotation, $x, $y, $this->random_color(130, 240), $this->font(), $letter);
}
}
-
+
#-- add the real text to it
function text() {
@@ -905,7 +905,7 @@ class easy_captcha_persistent_grant extends easy_captcha {
function easy_captcha_persistent_grant() {
}
-
+
#-- give ok, if captach had already been solved recently
function solved($ignore=0) {
@@ -913,7 +913,7 @@ class easy_captcha_persistent_grant extends easy_captcha {
return in_array($_COOKIE[$this->cookie()], array($this->validity_token(), $this->validity_token(-1)));
}
}
-
+
#-- set captcha persistence cookie
function grant() {
if (!headers_sent()) {
@@ -986,7 +986,7 @@ class easy_captcha_utility {
#-- JS-RPC request, check entered solution on the fly
if ($test = @$_REQUEST[CAPTCHA_PARAM_INPUT]) {
-
+
#-- check
if ($expired) {
}
@@ -1000,7 +1000,7 @@ class easy_captcha_utility {
}
#-- generate and send image file
- else {
+ else {
if ($expired) {
$type = "image/png";
$bin = easy_captcha_utility::expired_png();
@@ -1043,7 +1043,7 @@ class easy_captcha_utility {
/* easy_captcha utility code */
// global vars
-captcha_url_rx = /(https?:\/\/\w[^\/,\]\[=#]+)/ig; //
+captcha_url_rx = /(https?:\/\/\w[^\/,\]\[=#]+)/ig; //
captcha_form_urls = new Array();
captcha_sol_cb = "";
captcha_rpc = 0;
diff --git a/modules/emulator/gettext.php b/modules/emulator/gettext.php
index f24aa190..e62cdcc6 100644
--- a/modules/emulator/gettext.php
+++ b/modules/emulator/gettext.php
@@ -89,12 +89,12 @@ if (!function_exists("gettext")) {
#-- give out whatever we have
return($msg);
}
-
+
#-- return plural form array index for algorithm type
# (compacted from C expression string beforehand)
function gettext___plural_guess(&$type, $n) {
-
+
#-- guess from string with C expression and set integer shorthand
if (is_string($type)) {
if (($type == "nplurals=1;plural=0;") || !strlen($type)) {
@@ -221,7 +221,7 @@ if (!function_exists("gettext")) {
. @$_ENV['LC_MESSAGE'] .',' . @$_ENV['LANG'] . ','
. @$_GETTEXT['%locale'] . ',' . @$_SERVER['HTTP_ACCEPT_LANGUAGE']
. ',C,en';
-
+
#-- add shortened language codes (en_UK.UTF-8 -> + en_UK, en)
foreach (explode(',', $langs) as $d) {
$d = trim($d);
@@ -258,7 +258,7 @@ if (!function_exists("gettext")) {
}
}
}//foreach
-
+
#-- extract headers
if ($head = $_GETTEXT[$domain][""]) {
foreach (explode("\n", $head) as $line) {
@@ -266,7 +266,7 @@ if (!function_exists("gettext")) {
$line = trim(strtok("\n"));
$_GETTEXT[$domain]['%po-header'][strtolower($header)] = $line;
}
-
+
#-- plural-forms header
if (function_exists("gettext___plural_guess")
and ($h = @$_GETTEXT[$domain]['%po-header']["plural-forms"]))
@@ -336,7 +336,7 @@ if (!function_exists("gettext")) {
global $_GETTEXT;
$c_esc = array("\\n"=>"\n", "\\r"=>"\r", "\\\\"=>"\\", "\\f"=>"\f", "\\t"=>"\t", "\\"=>"");
- #-- read line-wise from text file
+ #-- read line-wise from text file
do {
$line = trim(fgets($f));
diff --git a/modules/flash/xspf_player.php b/modules/flash/xspf_player.php
index a2598372..c6228fdb 100644
--- a/modules/flash/xspf_player.php
+++ b/modules/flash/xspf_player.php
@@ -23,7 +23,7 @@
require_once '../../lib/init.php';
// Switch on actions
-switch ($_REQUEST['action']) {
+switch ($_REQUEST['action']) {
default:
case 'tmp_playlist':
// Set for hackage!
diff --git a/modules/getid3/extension.cache.dbm.php b/modules/getid3/extension.cache.dbm.php
index 03e4a9e8..aa5092e4 100644
--- a/modules/getid3/extension.cache.dbm.php
+++ b/modules/getid3/extension.cache.dbm.php
@@ -34,7 +34,7 @@
* require_once 'getid3/getid3.php';
* $getid3 = new getid3;
* $getid3->encoding = 'UTF-8';
-* try {
+* try {
* $info1 = $getid3->Analyse('file1.flac');
* $info2 = $getid3->Analyse('file2.wv');
* ....
diff --git a/modules/getid3/extension.cache.mysql.php b/modules/getid3/extension.cache.mysql.php
index 1275c25e..f8dac5a2 100644
--- a/modules/getid3/extension.cache.mysql.php
+++ b/modules/getid3/extension.cache.mysql.php
@@ -34,7 +34,7 @@
* require_once 'getid3/getid3.php';
* $getid3 = new getid3;
* $getid3->encoding = 'UTF-8';
-* try {
+* try {
* $info1 = $getid3->Analyse('file1.flac');
* $info2 = $getid3->Analyse('file2.wv');
* ....
diff --git a/modules/getid3/module.archive.gzip.php b/modules/getid3/module.archive.gzip.php
index ed03abf5..84fae9ef 100644
--- a/modules/getid3/module.archive.gzip.php
+++ b/modules/getid3/module.archive.gzip.php
@@ -24,15 +24,15 @@
//
// $Id: module.archive.gzip.php,v 1.4 2006/12/04 16:00:35 ah Exp $
-
-
+
+
class getid3_gzip extends getid3_handler
{
// public: Optional file list - disable for speed.
public $option_gzip_parse_contents = true; // decode gzipped files, if possible, and parse recursively (.tar.gz for example)
-
+
// Reads the gzip-file
function Analyze() {
@@ -42,16 +42,16 @@ class getid3_gzip extends getid3_handler
$start_length = 10;
$unpack_header = 'a1id1/a1id2/a1cmethod/a1flags/a4mtime/a1xflags/a1os';
-
+
//+---+---+---+---+---+---+---+---+---+---+
//|ID1|ID2|CM |FLG| MTIME |XFL|OS |
//+---+---+---+---+---+---+---+---+---+---+
-
+
@fseek($this->getid3->fp, 0);
$buffer = @fread($this->getid3->fp, $info['filesize']);
$arr_members = explode("\x1F\x8B\x08", $buffer);
-
+
while (true) {
$is_wrong_members = false;
$num_members = intval(count($arr_members));
@@ -63,7 +63,7 @@ class getid3_gzip extends getid3_handler
$attr = unpack($unpack_header, substr($buf, 0, $start_length));
if (!$this->get_os_type(ord($attr['os']))) {
-
+
// Merge member with previous if wrong OS type
$arr_members[$i - 1] .= $buf;
$arr_members[$i] = '';
@@ -110,24 +110,24 @@ class getid3_gzip extends getid3_handler
$fpointer = 10;
$arr_xsubfield = array ();
-
+
// bit 2 - FLG.FEXTRA
//+---+---+=================================+
//| XLEN |...XLEN bytes of "extra field"...|
//+---+---+=================================+
-
+
if ($info_gzip_member_header_idx['flags']['extra']) {
$w_xlen = substr($buff, $fpointer, 2);
$xlen = getid3_lib::LittleEndian2Int($w_xlen);
$fpointer += 2;
$info_gzip_member_header_idx['raw']['xfield'] = substr($buff, $fpointer, $xlen);
-
+
// Extra SubFields
//+---+---+---+---+==================================+
//|SI1|SI2| LEN |... LEN bytes of subfield data ...|
//+---+---+---+---+==================================+
-
+
$idx = 0;
while (true) {
if ($idx >= $xlen) {
@@ -147,13 +147,13 @@ class getid3_gzip extends getid3_handler
}
$fpointer += $xlen;
}
-
+
// bit 3 - FLG.FNAME
//+=========================================+
//|...original file name, zero-terminated...|
//+=========================================+
// GZIP files may have only one file, with no filename, so assume original filename is current filename without .gz
-
+
$info_gzip_member_header_idx['filename'] = preg_replace('/.gz$/', '', @$info['filename']);
if ($info_gzip_member_header_idx['flags']['filename']) {
while (true) {
@@ -165,12 +165,12 @@ class getid3_gzip extends getid3_handler
$fpointer++;
}
}
-
+
// bit 4 - FLG.FCOMMENT
//+===================================+
//|...file comment, zero-terminated...|
//+===================================+
-
+
if ($info_gzip_member_header_idx['flags']['comment']) {
while (true) {
if (ord($buff[$fpointer]) == 0) {
@@ -181,18 +181,18 @@ class getid3_gzip extends getid3_handler
$fpointer++;
}
}
-
+
// bit 1 - FLG.FHCRC
//+---+---+
//| CRC16 |
//+---+---+
-
+
if ($info_gzip_member_header_idx['flags']['crc16']) {
$w_crc = substr($buff, $fpointer, 2);
$info_gzip_member_header_idx['crc16'] = getid3_lib::LittleEndian2Int($w_crc);
$fpointer += 2;
}
-
+
// bit 0 - FLG.FTEXT
//if ($info_gzip_member_header_idx['raw']['flags'] & 0x01) {
// Ignored...
@@ -205,7 +205,7 @@ class getid3_gzip extends getid3_handler
if ($this->option_gzip_parse_contents) {
// Try to inflate GZip
-
+
if (!function_exists('gzinflate')) {
$this->getid3->warning('PHP does not have zlib support - contents not parsed.');
return true;
@@ -223,9 +223,9 @@ class getid3_gzip extends getid3_handler
// Calculate CRC32 for inflated content
$info_gzip_member_header_idx['crc32_valid'] = (bool) (sprintf('%u', crc32($inflated)) == $info_gzip_member_header_idx['crc32']);
-
+
//// Analyse contents
-
+
// write content to temp file
if (($temp_file_name = tempnam('*', 'getID3')) === false) {
throw new getid3_exception('Unable to create temporary file.');
@@ -234,7 +234,7 @@ class getid3_gzip extends getid3_handler
if ($tmp = fopen($temp_file_name, 'wb')) {
fwrite($tmp, $inflated);
fclose($tmp);
-
+
// clone getid3 - we want same settings
$clone = clone $this->getid3;
unset($clone->info);
@@ -245,13 +245,13 @@ class getid3_gzip extends getid3_handler
catch (getid3_exception $e) {
// unable to parse contents
}
-
+
unlink($temp_file_name);
}
-
- // Unknown/unhandled format
+
+ // Unknown/unhandled format
else {
-
+
}
}
}
@@ -291,7 +291,7 @@ class getid3_gzip extends getid3_handler
);
return @$xflag_type[$key];
}
-
+
}
?>
diff --git a/modules/getid3/module.archive.szip.php b/modules/getid3/module.archive.szip.php
index f8f71dba..c0beea25 100644
--- a/modules/getid3/module.archive.szip.php
+++ b/modules/getid3/module.archive.szip.php
@@ -22,20 +22,20 @@
//
// $Id: module.archive.szip.php,v 1.2 2006/11/02 10:48:00 ah Exp $
-
-
+
+
class getid3_szip extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$szip_rkau = fread($getid3->fp, 6);
-
+
// Magic bytes: 'SZ'."\x0A\x04"
-
+
$getid3->info['fileformat'] = 'szip';
$getid3->info['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($szip_rkau, 4, 1));
diff --git a/modules/getid3/module.archive.tar.php b/modules/getid3/module.archive.tar.php
index cf106794..a629adeb 100644
--- a/modules/getid3/module.archive.tar.php
+++ b/modules/getid3/module.archive.tar.php
@@ -24,8 +24,8 @@
//
// $Id: module.archive.tar.php,v 1.2 2006/11/02 10:48:00 ah Exp $
-
-
+
+
class getid3_tar extends getid3_handler
{
@@ -36,9 +36,9 @@ class getid3_tar extends getid3_handler
$info['fileformat'] = 'tar';
$fp = $this->getid3->fp;
-
+
fseek($fp, 0);
-
+
$unpack_header = 'a100fname/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typflag/a100lnkname/a6magic/a2ver/a32uname/a32gname/a8devmaj/a8devmin/a155/prefix';
$null_512k = str_repeat("\0", 512); // end-of-file marker
@@ -46,9 +46,9 @@ class getid3_tar extends getid3_handler
$already_warned = false;
while (!feof($fp)) {
-
+
$buffer = fread($fp, 512);
-
+
// check the block
$checksum = 0;
for ($i = 0; $i < 148; $i++) {
@@ -93,24 +93,24 @@ class getid3_tar extends getid3_handler
}
}
}
-
+
if ($prefix) {
$name = $prefix.'/'.$name;
}
if ((preg_match('#/$#', $name)) && !$name) {
$typeflag = 5;
}
-
+
// If it's the end of the tar-file...
if ($buffer == $null_512k) {
break;
}
-
+
// Protect against tar-files with garbage at the end
if ($name == '') {
break;
}
-
+
$info['tar']['file_details'][$name] = array (
'name' => $name,
'mode_raw' => $mode,
@@ -129,7 +129,7 @@ class getid3_tar extends getid3_handler
'devmajor' => $devmaj,
'devminor' => $devmin
);
-
+
// Skip the next chunk
fseek($fp, $size, SEEK_CUR);
@@ -137,7 +137,7 @@ class getid3_tar extends getid3_handler
if ($size % 512) {
fseek($fp, 512 - $diff, SEEK_CUR);
}
-
+
}
return true;
}
@@ -226,7 +226,7 @@ class getid3_tar extends getid3_handler
return @$flag_types[$typflag];
}
-
+
}
?> \ No newline at end of file
diff --git a/modules/getid3/module.archive.zip.php b/modules/getid3/module.archive.zip.php
index 72d94f41..adeb07b4 100644
--- a/modules/getid3/module.archive.zip.php
+++ b/modules/getid3/module.archive.zip.php
@@ -30,12 +30,12 @@ class getid3_zip extends getid3_handler
public function Analyze() {
$getid3 = $this->getid3;
-
+
$getid3->info['zip'] = array ();
$info_zip = &$getid3->info['zip'];
-
+
$getid3->info['fileformat'] = 'zip';
-
+
$info_zip['encoding'] = 'ISO-8859-1';
$info_zip['files'] = array ();
$info_zip['compressed_size'] = $info_zip['uncompressed_size'] = $info_zip['entries_count'] = 0;
@@ -97,22 +97,22 @@ class getid3_zip extends getid3_handler
}
throw new getid3_exception('Cannot find End Of Central Directory - returned list of files in [zip][entries] array may not be complete');
}
-
+
//throw new getid3_exception('Cannot find End Of Central Directory (truncated file?)');
}
private function getZIPHeaderFilepointerTopDown() {
-
+
// shortcut
$getid3 = $this->getid3;
-
+
$getid3->info['fileformat'] = 'zip';
-
+
$getid3->info['zip'] = array ();
$info_zip['compressed_size'] = $info_zip['uncompressed_size'] = $info_zip['entries_count'] = 0;
-
+
rewind($getid3->fp);
while ($fileentry = $this->ZIPparseLocalFileHeader()) {
$info_zip['entries'][] = $fileentry;
@@ -149,10 +149,10 @@ class getid3_zip extends getid3_handler
private function getZIPentriesFilepointer() {
-
+
// shortcut
$getid3 = $this->getid3;
-
+
$getid3->info['zip'] = array ();
$info_zip['compressed_size'] = $info_zip['uncompressed_size'] = $info_zip['entries_count'] = 0;
@@ -173,36 +173,36 @@ class getid3_zip extends getid3_handler
private function ZIPparseLocalFileHeader() {
-
+
// shortcut
$getid3 = $this->getid3;
$local_file_header['offset'] = ftell($getid3->fp);
-
+
$zip_local_file_header = fread($getid3->fp, 30);
$local_file_header['raw']['signature'] = getid3_lib::LittleEndian2Int(substr($zip_local_file_header, 0, 4));
-
+
// Invalid Local File Header Signature
if ($local_file_header['raw']['signature'] != 0x04034B50) {
fseek($getid3->fp, $local_file_header['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
return false;
}
-
- getid3_lib::ReadSequence('LittleEndian2Int', $local_file_header['raw'], $zip_local_file_header, 4,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $local_file_header['raw'], $zip_local_file_header, 4,
array (
- 'extract_version' => 2,
- 'general_flags' => 2,
- 'compression_method' => 2,
- 'last_mod_file_time' => 2,
- 'last_mod_file_date' => 2,
- 'crc_32' => 2,
- 'compressed_size' => 2,
- 'uncompressed_size' => 2,
- 'filename_length' => 2,
+ 'extract_version' => 2,
+ 'general_flags' => 2,
+ 'compression_method' => 2,
+ 'last_mod_file_time' => 2,
+ 'last_mod_file_date' => 2,
+ 'crc_32' => 2,
+ 'compressed_size' => 2,
+ 'uncompressed_size' => 2,
+ 'filename_length' => 2,
'extra_field_length' => 2
)
- );
+ );
$local_file_header['extract_version'] = sprintf('%1.1f', $local_file_header['raw']['extract_version'] / 10);
$local_file_header['host_os'] = $this->ZIPversionOSLookup(($local_file_header['raw']['extract_version'] & 0xFF00) >> 8);
@@ -229,12 +229,12 @@ class getid3_zip extends getid3_handler
if ($local_file_header['flags']['data_descriptor_used']) {
$data_descriptor = fread($getid3->fp, 12);
-
- getid3_lib::ReadSequence('LittleEndian2Int', $local_file_header['data_descriptor'], $data_descriptor, 0,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $local_file_header['data_descriptor'], $data_descriptor, 0,
array (
'crc_32' => 4,
'compressed_size' => 4,
- 'uncompressed_size' => 4
+ 'uncompressed_size' => 4
)
);
}
@@ -245,7 +245,7 @@ class getid3_zip extends getid3_handler
private function ZIPparseCentralDirectory() {
-
+
// shortcut
$getid3 = $this->getid3;
@@ -254,14 +254,14 @@ class getid3_zip extends getid3_handler
$zip_central_directory = fread($getid3->fp, 46);
$central_directory['raw']['signature'] = getid3_lib::LittleEndian2Int(substr($zip_central_directory, 0, 4));
-
+
// invalid Central Directory Signature
if ($central_directory['raw']['signature'] != 0x02014B50) {
fseek($getid3->fp, $central_directory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
return false;
}
-
- getid3_lib::ReadSequence('LittleEndian2Int', $central_directory['raw'], $zip_central_directory, 4,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $central_directory['raw'], $zip_central_directory, 4,
array (
'create_version' => 2,
'extract_version' => 2,
@@ -281,7 +281,7 @@ class getid3_zip extends getid3_handler
'local_header_offset' => 4
)
);
-
+
$central_directory['entry_offset'] = $central_directory['raw']['local_header_offset'];
$central_directory['create_version'] = sprintf('%1.1f', $central_directory['raw']['create_version'] / 10);
$central_directory['extract_version'] = sprintf('%1.1f', $central_directory['raw']['extract_version'] / 10);
@@ -310,26 +310,26 @@ class getid3_zip extends getid3_handler
return $central_directory;
}
-
-
+
+
private function ZIPparseEndOfCentralDirectory() {
-
- // shortcut
+
+ // shortcut
$getid3 = $this->getid3;
-
+
$end_of_central_directory['offset'] = ftell($getid3->fp);
$zip_end_of_central_directory = fread($getid3->fp, 22);
$end_of_central_directory['signature'] = getid3_lib::LittleEndian2Int(substr($zip_end_of_central_directory, 0, 4));
-
+
// invalid End Of Central Directory Signature
if ($end_of_central_directory['signature'] != 0x06054B50) {
fseek($getid3->fp, $end_of_central_directory['offset'], SEEK_SET); // seek back to where filepointer originally was so it can be handled properly
return false;
}
-
- getid3_lib::ReadSequence('LittleEndian2Int', $end_of_central_directory, $zip_end_of_central_directory, 4,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $end_of_central_directory, $zip_end_of_central_directory, 4,
array (
'disk_number_current' => 2,
'disk_number_start_directory' => 2,
@@ -340,14 +340,14 @@ class getid3_zip extends getid3_handler
'comment_length' => 2
)
);
-
+
if ($end_of_central_directory['comment_length'] > 0) {
$end_of_central_directory['comment'] = fread($getid3->fp, $end_of_central_directory['comment_length']);
}
return $end_of_central_directory;
}
-
+
public static function ZIPparseGeneralPurposeFlags($flag_bytes, $compression_method) {
@@ -386,7 +386,7 @@ class getid3_zip extends getid3_handler
public static function ZIPversionOSLookup($index) {
-
+
static $lookup = array (
0 => 'MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)',
1 => 'Amiga',
@@ -461,18 +461,18 @@ class getid3_zip extends getid3_handler
*/
return gmmktime(($DOStime & 0xF800) >> 11, ($DOStime & 0x07E0) >> 5, ($DOStime & 0x001F) * 2, ($DOSdate & 0x01E0) >> 5, $DOSdate & 0x001F, (($DOSdate & 0xFE00) >> 9) + 1980);
}
-
-
-
+
+
+
public static function array_merge_clobber($array1, $array2) {
// written by kcØhireability*com
// taken from http://www.php.net/manual/en/function.array-merge-recursive.php
-
+
if (!is_array($array1) || !is_array($array2)) {
return false;
}
-
+
$newarray = $array1;
foreach ($array2 as $key => $val) {
if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
@@ -483,9 +483,9 @@ class getid3_zip extends getid3_handler
}
return $newarray;
}
-
-
-
+
+
+
public static function CreateDeepArray($array_path, $separator, $value) {
// assigns $value to a nested array path:
@@ -494,14 +494,14 @@ class getid3_zip extends getid3_handler
// $foo = array ('path'=>array('to'=>'array('my'=>array('file.txt'))));
// or
// $foo['path']['to']['my'] = 'file.txt';
-
+
while ($array_path{0} == $separator) {
$array_path = substr($array_path, 1);
}
if (($pos = strpos($array_path, $separator)) !== false) {
return array (substr($array_path, 0, $pos) => getid3_zip::CreateDeepArray(substr($array_path, $pos + 1), $separator, $value));
}
-
+
return array ($array_path => $value);
}
diff --git a/modules/getid3/module.audio-video.asf.php b/modules/getid3/module.audio-video.asf.php
index 1ffc1142..ac71de48 100644
--- a/modules/getid3/module.audio-video.asf.php
+++ b/modules/getid3/module.audio-video.asf.php
@@ -22,8 +22,8 @@
//
// $Id: module.audio-video.asf.php,v 1.7 2006/12/01 22:39:48 ah Exp $
-
-
+
+
class getid3_asf extends getid3_handler
{
@@ -139,13 +139,13 @@ class getid3_asf extends getid3_handler
public function Analyze() {
$getid3 = $this->getid3;
-
+
$getid3->include_module('audio-video.riff');
!isset($getid3->info['audio']) and $getid3->info['audio'] = array ();
!isset($getid3->info['video']) and $getid3->info['video'] = array ();
$getid3->info['asf']['comments'] = $getid3->info['asf']['header_object'] = array ();
-
+
$info_audio = &$getid3->info['audio'];
$info_video = &$getid3->info['video'];
$info_asf = &$getid3->info['asf'];
@@ -178,11 +178,11 @@ class getid3_asf extends getid3_handler
$header_object_data = fread($getid3->fp, 30);
$info_asf_header_object['objectid_guid'] = getid3_asf::BytestringToGUID(substr($header_object_data, 0, 16));
-
+
if ($info_asf_header_object['objectid_guid'] != getid3_asf::Header_Object) {
throw new getid3_exception('ASF header GUID {'.$info_asf_header_object['objectid_guid'].'} does not match expected "getid3_asf::Header_Object" GUID {'.getid3_asf::Header_Object.'}');
}
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_header_object, $header_object_data, 16,
array (
'objectsize' => 8,
@@ -196,19 +196,19 @@ class getid3_asf extends getid3_handler
$offset = 0;
for ($header_objects_counter = 0; $header_objects_counter < $info_asf_header_object['headerobjects']; $header_objects_counter++) {
-
+
$next_object_guid = substr($asf_header_data, $offset, 16);
$offset += 16;
-
+
$next_object_size = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 8));
$offset += 8;
-
+
$next_object_guidtext = getid3_asf::BytestringToGUID($next_object_guid);
-
+
switch ($next_object_guidtext) {
case getid3_asf::File_Properties_Object:
-
+
// File Properties Object: (mandatory, one only)
// Field Name Field Type Size (bits)
// Object ID GUID 128 // GUID for file properties object - getid3_asf::File_Properties_Object
@@ -233,7 +233,7 @@ class getid3_asf extends getid3_handler
$info_asf_file_properties_object['objectid_guid'] = $next_object_guidtext;
$info_asf_file_properties_object['objectsize'] = $next_object_size;
-
+
$info_asf_file_properties_object['fileid_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
$offset += 16;
@@ -251,9 +251,9 @@ class getid3_asf extends getid3_handler
'max_bitrate' => 4
)
);
-
+
$offset += 64 ;
-
+
$info_asf_file_properties_object['creation_date_unix'] = getid3_asf::FiletimeToUNIXtime($info_asf_file_properties_object['creation_date']);
$info_asf_file_properties_object['flags']['broadcast'] = (bool)($info_asf_file_properties_object['flags_raw'] & 0x0001);
$info_asf_file_properties_object['flags']['seekable'] = (bool)($info_asf_file_properties_object['flags_raw'] & 0x0002);
@@ -264,7 +264,7 @@ class getid3_asf extends getid3_handler
case getid3_asf::Stream_Properties_Object:
-
+
// Stream Properties Object: (mandatory, one per media stream)
// Field Name Field Type Size (bits)
// Object ID GUID 128 // GUID for stream properties object - getid3_asf::Stream_Properties_Object
@@ -288,7 +288,7 @@ class getid3_asf extends getid3_handler
$stream_properties_object_data['objectid_guid'] = $next_object_guidtext;
$stream_properties_object_data['objectsize'] = $next_object_size;
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $stream_properties_object_data, $asf_header_data, $offset,
array (
'stream_type' => -16,
@@ -307,17 +307,17 @@ class getid3_asf extends getid3_handler
$stream_properties_object_data['error_correct_guid'] = getid3_asf::BytestringToGUID($stream_properties_object_data['error_correct_type']);
$offset += 54; // 50 bytes + 4 bytes reserved - DWORD
-
+
$stream_properties_object_data['type_specific_data'] = substr($asf_header_data, $offset, $stream_properties_object_data['type_data_length']);
$offset += $stream_properties_object_data['type_data_length'];
-
+
$stream_properties_object_data['error_correct_data'] = substr($asf_header_data, $offset, $stream_properties_object_data['error_data_length']);
$offset += $stream_properties_object_data['error_data_length'];
switch ($stream_properties_object_data['stream_type_guid']) {
case getid3_asf::Audio_Media:
-
+
$info_audio['dataformat'] = (@$info_audio['dataformat'] ? $info_audio['dataformat'] : 'asf');
$info_audio['bitrate_mode'] = (@$info_audio['bitrate_mode'] ? $info_audio['bitrate_mode'] : 'cbr');
@@ -345,10 +345,10 @@ class getid3_asf extends getid3_handler
$info_asf['stream_properties_object'][$stream_properties_stream_number] = $stream_properties_object_data;
unset($stream_properties_object_data); // clear for next stream, if any
break;
-
+
case getid3_asf::Header_Extension_Object:
-
+
// Header Extension Object: (mandatory, one only)
// Field Name Field Type Size (bits)
// Object ID GUID 128 // GUID for Header Extension object - getid3_asf::Header_Extension_Object
@@ -365,30 +365,30 @@ class getid3_asf extends getid3_handler
$info_asf_header_extension_object['objectsize'] = $next_object_size;
$info_asf_header_extension_object['reserved_1_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
$offset += 16;
-
+
if ($info_asf_header_extension_object['reserved_1_guid'] != getid3_asf::Reserved_1) {
$getid3->warning('header_extension_object.reserved_1 GUID ('.$info_asf_header_extension_object['reserved_1_guid'].') does not match expected "getid3_asf::Reserved_1" GUID ('.getid3_asf::Reserved_1.')');
break;
}
-
+
$info_asf_header_extension_object['reserved_2'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
if ($info_asf_header_extension_object['reserved_2'] != 6) {
$getid3->warning('header_extension_object.reserved_2 ('.getid3_lib::PrintHexBytes($info_asf_header_extension_object['reserved_2']).') does not match expected value of "6"');
break;
}
-
+
$info_asf_header_extension_object['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
$offset += 4;
-
+
$info_asf_header_extension_object['extension_data'] = substr($asf_header_data, $offset, $info_asf_header_extension_object['extension_data_size']);
$offset += $info_asf_header_extension_object['extension_data_size'];
break;
-
+
case getid3_asf::Codec_List_Object:
-
+
// Codec List Object: (optional, one only)
// Field Name Field Type Size (bits)
// Object ID GUID 128 // GUID for Codec List object - getid3_asf::Codec_List_Object
@@ -409,48 +409,48 @@ class getid3_asf extends getid3_handler
$info_asf_codec_list_object['objectid_guid'] = $next_object_guidtext;
$info_asf_codec_list_object['objectsize'] = $next_object_size;
-
+
$info_asf_codec_list_object['reserved_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
$offset += 16;
-
+
if ($info_asf_codec_list_object['reserved_guid'] != '86D15241-311D-11D0-A3A4-00A0C90348F6') {
$getid3->warning('codec_list_object.reserved GUID {'.$info_asf_codec_list_object['reserved_guid'].'} does not match expected "getid3_asf::Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}');
break;
}
-
+
$info_asf_codec_list_object['codec_entries_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
$offset += 4;
-
+
for ($codec_entry_counter = 0; $codec_entry_counter < $info_asf_codec_list_object['codec_entries_count']; $codec_entry_counter++) {
-
+
$info_asf_codec_list_object['codec_entries'][$codec_entry_counter] = array ();
$info_asf_codec_list_object_codecentries_current = &$info_asf_codec_list_object['codec_entries'][$codec_entry_counter];
$info_asf_codec_list_object_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
$info_asf_codec_list_object_codecentries_current['type'] = getid3_asf::ASFCodecListObjectTypeLookup($info_asf_codec_list_object_codecentries_current['type_raw']);
$codec_name_length = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2)) * 2; // 2 bytes per character
$offset += 2;
-
+
$info_asf_codec_list_object_codecentries_current['name'] = substr($asf_header_data, $offset, $codec_name_length);
$offset += $codec_name_length;
$codec_description_length = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2)) * 2; // 2 bytes per character
$offset += 2;
-
+
$info_asf_codec_list_object_codecentries_current['description'] = substr($asf_header_data, $offset, $codec_description_length);
$offset += $codec_description_length;
$codec_information_length = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
$info_asf_codec_list_object_codecentries_current['information'] = substr($asf_header_data, $offset, $codec_information_length);
$offset += $codec_information_length;
if ($info_asf_codec_list_object_codecentries_current['type_raw'] == 2) {
-
+
// audio codec
if (strpos($info_asf_codec_list_object_codecentries_current['description'], ',') === false) {
throw new getid3_exception('[asf][codec_list_object][codec_entries]['.$codec_entry_counter.'][description] expected to contain comma-seperated list of parameters: "'.$info_asf_codec_list_object_codecentries_current['description'].'"');
@@ -465,7 +465,7 @@ class getid3_asf extends getid3_handler
if (!isset($info_video['bitrate']) && isset($info_audio['bitrate']) && isset($info_asf['file_properties_object']['max_bitrate']) && ($info_asf_codec_list_object['codec_entries_count'] > 1)) {
$info_video['bitrate'] = $info_asf['file_properties_object']['max_bitrate'] - $info_audio['bitrate'];
}
-
+
if (!@$info_video['bitrate'] && @$info_audio['bitrate'] && @$getid3->info['bitrate']) {
$info_video['bitrate'] = $getid3->info['bitrate'] - $info_audio['bitrate'];
}
@@ -529,38 +529,38 @@ class getid3_asf extends getid3_handler
$info_asf_script_command_object['objectsize'] = $next_object_size;
$info_asf_script_command_object['reserved_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
$offset += 16;
-
+
if ($info_asf_script_command_object['reserved_guid'] != '4B1ACBE3-100B-11D0-A39B-00A0C90348F6') {
$getid3->warning('script_command_object.reserved GUID {'.$info_asf_script_command_object['reserved_guid'].'} does not match expected GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}');
break;
}
-
+
$info_asf_script_command_object['commands_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
$info_asf_script_command_object['command_types_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
for ($command_types_counter = 0; $command_types_counter < $info_asf_script_command_object['command_types_count']; $command_types_counter++) {
-
+
$command_type_name_length = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2)) * 2; // 2 bytes per character
$offset += 2;
-
+
$info_asf_script_command_object['command_types'][$command_types_counter]['name'] = substr($asf_header_data, $offset, $command_type_name_length);
$offset += $command_type_name_length;
}
-
+
for ($commands_counter = 0; $commands_counter < $info_asf_script_command_object['commands_count']; $commands_counter++) {
-
+
$info_asf_script_command_object['commands'][$commands_counter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
$offset += 4;
-
+
$info_asf_script_command_object['commands'][$commands_counter]['type_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
$command_type_name_length = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2)) * 2; // 2 bytes per character
$offset += 2;
-
+
$info_asf_script_command_object['commands'][$commands_counter]['name'] = substr($asf_header_data, $offset, $command_type_name_length);
$offset += $command_type_name_length;
}
@@ -594,32 +594,32 @@ class getid3_asf extends getid3_handler
$info_asf_marker_object['objectid_guid'] = $next_object_guidtext;
$info_asf_marker_object['objectsize'] = $next_object_size;
$info_asf_marker_object['reserved_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
- $offset += 16;
-
+ $offset += 16;
+
if ($info_asf_marker_object['reserved_guid'] != '4CFEDB20-75F6-11CF-9C0F-00A0C90349CB') {
$getid3->warning('marker_object.reserved GUID {'.$info_asf_marker_object['reserved_guid'].'} does not match expected GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}');
break;
}
-
+
$info_asf_marker_object['markers_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
$offset += 4;
-
+
$info_asf_marker_object['reserved_2'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
if ($info_asf_marker_object['reserved_2'] != 0) {
$getid3->warning('marker_object.reserved_2 ('.getid3_lib::PrintHexBytes($info_asf_marker_object['reserved_2']).') does not match expected value of "0"');
break;
}
-
+
$info_asf_marker_object['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
$info_asf_marker_object['name'] = substr($asf_header_data, $offset, $info_asf_marker_object['name_length']);
$offset += $info_asf_marker_object['name_length'];
-
+
for ($markers_counter = 0; $markers_counter < $info_asf_marker_object['markers_count']; $markers_counter++) {
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_marker_object['markers'][$markers_counter], $asf_header_data, $offset,
array (
'offset' => 8,
@@ -631,10 +631,10 @@ class getid3_asf extends getid3_handler
)
);
$offset += 30;
-
+
$info_asf_marker_object['markers'][$markers_counter]['marker_description'] = substr($asf_header_data, $offset, $info_asf_marker_object['markers'][$markers_counter]['marker_description_length']);
$offset += $info_asf_marker_object['markers'][$markers_counter]['marker_description_length'];
-
+
$padding_length = $info_asf_marker_object['markers'][$markers_counter]['entry_length'] - 4 - 4 - 4 - $info_asf_marker_object['markers'][$markers_counter]['marker_description_length'];
if ($padding_length > 0) {
$info_asf_marker_object['markers'][$markers_counter]['padding'] = substr($asf_header_data, $offset, $padding_length);
@@ -642,10 +642,10 @@ class getid3_asf extends getid3_handler
}
}
break;
-
+
case getid3_asf::Bitrate_Mutual_Exclusion_Object:
-
+
// Bitrate Mutual Exclusion Object: (optional)
// Field Name Field Type Size (bits)
// Object ID GUID 128 // GUID for Bitrate Mutual Exclusion object - getid3_asf::Bitrate_Mutual_Exclusion_Object
@@ -662,15 +662,15 @@ class getid3_asf extends getid3_handler
$info_asf_bitrate_mutual_exclusion_object['objectsize'] = $next_object_size;
$info_asf_bitrate_mutual_exclusion_object['reserved_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
$offset += 16;
-
+
if ($info_asf_bitrate_mutual_exclusion_object['reserved_guid'] != getid3_asf::Mutex_Bitrate && $info_asf_bitrate_mutual_exclusion_object['reserved_guid'] != getid3_asf::Mutex_Unknown) {
$getid3->warning('bitrate_mutual_exclusion_object.reserved GUID {'.$info_asf_bitrate_mutual_exclusion_object['reserved_guid'].'} does not match expected "getid3_asf::Mutex_Bitrate" GUID {'.getid3_asf::Mutex_Bitrate.'} or "getid3_asf::Mutex_Unknown" GUID {'.getid3_asf::Mutex_Unknown.'}');
break;
}
-
+
$info_asf_bitrate_mutual_exclusion_object['stream_numbers_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
for ($stream_number_counter = 0; $stream_number_counter < $info_asf_bitrate_mutual_exclusion_object['stream_numbers_count']; $stream_number_counter++) {
$info_asf_bitrate_mutual_exclusion_object['stream_numbers'][$stream_number_counter] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
@@ -695,15 +695,15 @@ class getid3_asf extends getid3_handler
$info_asf_error_correction_object['objectsize'] = $next_object_size;
$info_asf_error_correction_object['error_correction_type'] = substr($asf_header_data, $offset, 16);
$offset += 16;
-
+
$info_asf_error_correction_object['error_correction_guid'] = getid3_asf::BytestringToGUID($info_asf_error_correction_object['error_correction_type']);
$info_asf_error_correction_object['error_correction_data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
$offset += 4;
-
+
switch ($info_asf_error_correction_object['error_correction_type_guid']) {
-
+
case getid3_asf::No_Error_Correction:
-
+
// should be no data, but just in case there is, skip to the end of the field
$offset += $info_asf_error_correction_object['error_correction_data_length'];
break;
@@ -718,7 +718,7 @@ class getid3_asf extends getid3_handler
// Silence Data Length WORD 16 // number of bytes in Silence Data field
// Silence Data BYTESTREAM variable // hardcoded: 0x00 * (Silence Data Length) bytes
- getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_error_correction_object, $asf_header_data, $offset,
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_error_correction_object, $asf_header_data, $offset,
array (
'span' => 1,
'virtual_packet_length' => 2,
@@ -727,7 +727,7 @@ class getid3_asf extends getid3_handler
)
);
$offset += 7;
-
+
$info_asf_error_correction_object['silence_data'] = substr($asf_header_data, $offset, $info_asf_error_correction_object['silence_data_length']);
$offset += $info_asf_error_correction_object['silence_data_length'];
break;
@@ -762,8 +762,8 @@ class getid3_asf extends getid3_handler
$info_asf_content_description_object['objectid_guid'] = $next_object_guidtext;
$info_asf_content_description_object['objectsize'] = $next_object_size;
-
- getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_content_description_object, $asf_header_data, $offset,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_content_description_object, $asf_header_data, $offset,
array (
'title_length' => 2,
'author_length' => 2,
@@ -773,19 +773,19 @@ class getid3_asf extends getid3_handler
)
);
$offset += 10;
-
+
$info_asf_content_description_object['title'] = substr($asf_header_data, $offset, $info_asf_content_description_object['title_length']);
$offset += $info_asf_content_description_object['title_length'];
-
+
$info_asf_content_description_object['author'] = substr($asf_header_data, $offset, $info_asf_content_description_object['author_length']);
$offset += $info_asf_content_description_object['author_length'];
-
+
$info_asf_content_description_object['copyright'] = substr($asf_header_data, $offset, $info_asf_content_description_object['copyright_length']);
$offset += $info_asf_content_description_object['copyright_length'];
-
+
$info_asf_content_description_object['description'] = substr($asf_header_data, $offset, $info_asf_content_description_object['description_length']);
$offset += $info_asf_content_description_object['description_length'];
-
+
$info_asf_content_description_object['rating'] = substr($asf_header_data, $offset, $info_asf_content_description_object['rating_length']);
$offset += $info_asf_content_description_object['rating_length'];
@@ -824,30 +824,30 @@ class getid3_asf extends getid3_handler
$info_asf_extended_content_description_object['objectsize'] = $next_object_size;
$info_asf_extended_content_description_object['content_descriptors_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
for ($extended_content_descriptors_counter = 0; $extended_content_descriptors_counter < $info_asf_extended_content_description_object['content_descriptors_count']; $extended_content_descriptors_counter++) {
-
+
$info_asf_extended_content_description_object['content_descriptors'][$extended_content_descriptors_counter] = array ();
$info_asf_extended_content_description_object_content_descriptor_current = &$info_asf_extended_content_description_object['content_descriptors'][$extended_content_descriptors_counter];
$info_asf_extended_content_description_object_content_descriptor_current['base_offset'] = $offset + 30;
$info_asf_extended_content_description_object_content_descriptor_current['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
$info_asf_extended_content_description_object_content_descriptor_current['name'] = substr($asf_header_data, $offset, $info_asf_extended_content_description_object_content_descriptor_current['name_length']);
$offset += $info_asf_extended_content_description_object_content_descriptor_current['name_length'];
-
+
$info_asf_extended_content_description_object_content_descriptor_current['value_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
$info_asf_extended_content_description_object_content_descriptor_current['value_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
$info_asf_extended_content_description_object_content_descriptor_current['value'] = substr($asf_header_data, $offset, $info_asf_extended_content_description_object_content_descriptor_current['value_length']);
$offset += $info_asf_extended_content_description_object_content_descriptor_current['value_length'];
-
+
switch ($info_asf_extended_content_description_object_content_descriptor_current['value_type']) {
-
+
case 0x0000: // Unicode string
break;
@@ -869,7 +869,7 @@ class getid3_asf extends getid3_handler
$getid3->warning('extended_content_description.content_descriptors.'.$extended_content_descriptors_counter.'.value_type is invalid ('.$info_asf_extended_content_description_object_content_descriptor_current['value_type'].')');
break;
}
-
+
switch ($this->TrimConvert(strtolower($info_asf_extended_content_description_object_content_descriptor_current['name']))) {
case 'wm/albumartist':
@@ -909,14 +909,14 @@ class getid3_asf extends getid3_handler
case 'date':
$info_asf_comments['year'] = array ( getid3_asf::TrimTerm($info_asf_extended_content_description_object_content_descriptor_current['value']));
break;
-
-
+
+
case 'wm/lyrics':
case 'lyrics':
$info_asf_comments['lyrics'] = array ( getid3_asf::TrimTerm($info_asf_extended_content_description_object_content_descriptor_current['value']));
break;
-
-
+
+
case 'isvbr':
if ($info_asf_extended_content_description_object_content_descriptor_current['value']) {
$info_audio['bitrate_mode'] = 'vbr';
@@ -926,17 +926,17 @@ class getid3_asf extends getid3_handler
case 'id3':
-
+
// id3v2 parsing might not be enabled
if (class_exists('getid3_id3v2')) {
-
- // Clone getid3
+
+ // Clone getid3
$clone = clone $getid3;
-
+
// Analyse clone by string
$id3v2 = new getid3_id3v2($clone);
$id3v2->AnalyzeString($info_asf_extended_content_description_object_content_descriptor_current['value']);
-
+
// Import from clone and destroy
$getid3->info['id3v2'] = $clone->info['id3v2'];
$getid3->warnings($clone->warnings());
@@ -952,7 +952,7 @@ class getid3_asf extends getid3_handler
case 'wm/picture':
-
+
//typedef struct _WMPicture{
// LPWSTR pwszMIMEType;
// BYTE bPictureType;
@@ -965,9 +965,9 @@ class getid3_asf extends getid3_handler
$info_asf_extended_content_description_object_content_descriptor_current['image_type'] = getid3_asf::WMpictureTypeLookup($info_asf_extended_content_description_object_content_descriptor_current['image_type_id']);
$info_asf_extended_content_description_object_content_descriptor_current['image_size'] = getid3_lib::LittleEndian2Int(substr($info_asf_extended_content_description_object_content_descriptor_current['value'], 1, 4));
$info_asf_extended_content_description_object_content_descriptor_current['image_mime'] = '';
-
+
$wm_picture_offset = 5;
-
+
do {
$next_byte_pair = substr($info_asf_extended_content_description_object_content_descriptor_current['value'], $wm_picture_offset, 2);
$wm_picture_offset += 2;
@@ -975,7 +975,7 @@ class getid3_asf extends getid3_handler
} while ($next_byte_pair !== "\x00\x00");
$info_asf_extended_content_description_object_content_descriptor_current['image_description'] = '';
-
+
do {
$next_byte_pair = substr($info_asf_extended_content_description_object_content_descriptor_current['value'], $wm_picture_offset, 2);
$wm_picture_offset += 2;
@@ -1026,14 +1026,14 @@ class getid3_asf extends getid3_handler
$info_asf_stream_bitrate_properties_object['objectsize'] = $next_object_size;
$info_asf_stream_bitrate_properties_object['bitrate_records_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
for ($bitrate_records_counter = 0; $bitrate_records_counter < $info_asf_stream_bitrate_properties_object['bitrate_records_count']; $bitrate_records_counter++) {
-
+
$info_asf_stream_bitrate_properties_object['bitrate_records'][$bitrate_records_counter]['flags_raw'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
$offset += 2;
-
+
$info_asf_stream_bitrate_properties_object['bitrate_records'][$bitrate_records_counter]['flags']['stream_number'] = $info_asf_stream_bitrate_properties_object['bitrate_records'][$bitrate_records_counter]['flags_raw'] & 0x007F;
-
+
$info_asf_stream_bitrate_properties_object['bitrate_records'][$bitrate_records_counter]['bitrate'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
$offset += 4;
}
@@ -1080,7 +1080,7 @@ class getid3_asf extends getid3_handler
break;
}
}
-
+
if (isset($info_asf_stream_bitrate_properties['bitrate_records_count'])) {
$asf_bitrate_audio = 0;
$asf_bitrate_video = 0;
@@ -1088,11 +1088,11 @@ class getid3_asf extends getid3_handler
for ($bitrate_records_counter = 0; $bitrate_records_counter < $info_asf_stream_bitrate_properties['bitrate_records_count']; $bitrate_records_counter++) {
if (isset($info_asf_codec_list_object['codec_entries'][$bitrate_records_counter])) {
switch ($info_asf_codec_list_object['codec_entries'][$bitrate_records_counter]['type_raw']) {
-
+
case 1:
$asf_bitrate_video += $info_asf_stream_bitrate_properties['bitrate_records'][$bitrate_records_counter]['bitrate'];
break;
-
+
case 2:
$asf_bitrate_audio += $info_asf_stream_bitrate_properties['bitrate_records'][$bitrate_records_counter]['bitrate'];
break;
@@ -1106,18 +1106,18 @@ class getid3_asf extends getid3_handler
$info_video['bitrate'] = $asf_bitrate_video;
}
}
-
+
if (isset($info_asf['stream_properties_object']) && is_array($info_asf['stream_properties_object'])) {
-
+
$info_audio['bitrate'] = 0;
$info_video['bitrate'] = 0;
foreach ($info_asf['stream_properties_object'] as $stream_number => $stream_data) {
-
+
switch ($stream_data['stream_type_guid']) {
-
+
case getid3_asf::Audio_Media:
-
+
// Field Name Field Type Size (bits)
// Codec ID / Format Tag WORD 16 // unique ID of audio codec - defined as wFormatTag field of WAVEFORMATEX structure
// Number of Channels WORD 16 // number of channels of audio - defined as nChannels field of WAVEFORMATEX structure
@@ -1161,7 +1161,7 @@ class getid3_asf extends getid3_handler
$info_audio['bitrate'] += $info_asf_audio_media_current_stream['bitrate'];
}
}
-
+
$info_audio['streams'][$stream_number] = $info_asf_audio_media_current_stream;
$info_audio['streams'][$stream_number]['wformattag'] = $info_asf_audio_media_current_stream['raw']['wFormatTag'];
$info_audio['streams'][$stream_number]['lossless'] = $info_audio['lossless'];
@@ -1170,7 +1170,7 @@ class getid3_asf extends getid3_handler
$info_asf_audio_media_current_stream['codec_data_size'] = getid3_lib::LittleEndian2Int(substr($stream_data['type_specific_data'], $audio_media_offset, 2));
$audio_media_offset += 2;
-
+
$info_asf_audio_media_current_stream['codec_data'] = substr($stream_data['type_specific_data'], $audio_media_offset, $info_asf_audio_media_current_stream['codec_data_size']);
$audio_media_offset += $info_asf_audio_media_current_stream['codec_data_size'];
break;
@@ -1200,7 +1200,7 @@ class getid3_asf extends getid3_handler
$info_asf['video_media'][$stream_number] = array ();
$info_asf_video_media_current_stream = &$info_asf['video_media'][$stream_number];
- getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_video_media_current_stream, $stream_data['type_specific_data'], 0,
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_video_media_current_stream, $stream_data['type_specific_data'], 0,
array (
'image_width' => 4,
'image_height' => 4,
@@ -1208,8 +1208,8 @@ class getid3_asf extends getid3_handler
'format_data_size'=> 2
)
);
-
- getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_video_media_current_stream['format_data'], $stream_data['type_specific_data'], 11,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_video_media_current_stream['format_data'], $stream_data['type_specific_data'], 11,
array (
'format_data_size' => 4,
'image_width' => 4,
@@ -1224,21 +1224,21 @@ class getid3_asf extends getid3_handler
'colors_important' => 4
)
);
-
+
$info_asf_video_media_current_stream['format_data']['codec_data'] = substr($stream_data['type_specific_data'], 51);
-
+
if (!empty($info_asf['stream_bitrate_properties_object']['bitrate_records'])) {
foreach ($info_asf['stream_bitrate_properties_object']['bitrate_records'] as $data_array) {
if (@$data_array['flags']['stream_number'] == $stream_number) {
$info_asf_video_media_current_stream['bitrate'] = $data_array['bitrate'];
$info_video['streams'][$stream_number]['bitrate'] = $data_array['bitrate'];
$info_video['bitrate'] += $data_array['bitrate'];
-
+
break;
}
}
}
-
+
$info_asf_video_media_current_stream['format_data']['codec'] = getid3_riff::RIFFfourccLookup($info_asf_video_media_current_stream['format_data']['codec_fourcc']);
$info_video['streams'][$stream_number]['fourcc'] = $info_asf_video_media_current_stream['format_data']['codec_fourcc'];
@@ -1255,21 +1255,21 @@ class getid3_asf extends getid3_handler
}
while (ftell($getid3->fp) < $getid3->info['avdataend']) {
-
+
$next_object_data_header = fread($getid3->fp, 24);
$offset = 0;
-
+
$next_object_guid = substr($next_object_data_header, 0, 16);
$offset += 16;
-
+
$next_object_guidtext = getid3_asf::BytestringToGUID($next_object_guid);
$next_object_size = getid3_lib::LittleEndian2Int(substr($next_object_data_header, $offset, 8));
$offset += 8;
switch ($next_object_guidtext) {
-
+
case getid3_asf::Data_Object:
-
+
// Data Object: (mandatory, one only)
// Field Name Field Type Size (bits)
// Object ID GUID 128 // GUID for Data object - getid3_asf::Data_Object
@@ -1290,13 +1290,13 @@ class getid3_asf extends getid3_handler
$info_asf_data_object['fileid_guid'] = getid3_asf::BytestringToGUID(substr($data_object_data, $offset, 16));
$offset += 16;
-
+
$info_asf_data_object['total_data_packets'] = getid3_lib::LittleEndian2Int(substr($data_object_data, $offset, 8));
$offset += 8;
-
+
$info_asf_data_object['reserved'] = getid3_lib::LittleEndian2Int(substr($data_object_data, $offset, 2));
$offset += 2;
-
+
if ($info_asf_data_object['reserved'] != 0x0101) {
$getid3->warning('data_object.reserved ('.getid3_lib::PrintHexBytes($info_asf_data_object['reserved']).') does not match expected value of "0x0101"');
break;
@@ -1338,7 +1338,7 @@ class getid3_asf extends getid3_handler
$info_asf_simple_index_object['objectsize'] = $next_object_size;
$simple_index_object_data = $next_object_data_header.fread($getid3->fp, 56 - 24);
-
+
$info_asf_simple_index_object['fileid_guid'] = getid3_asf::BytestringToGUID(substr($simple_index_object_data, 24, 16));
getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_simple_index_object, $simple_index_object_data, 40,
@@ -1348,15 +1348,15 @@ class getid3_asf extends getid3_handler
'index_entries_count' => 4
)
);
-
+
$offset = 56;
$index_entries_data = $simple_index_object_data.fread($getid3->fp, 6 * $info_asf_simple_index_object['index_entries_count']);
for ($index_entries_counter = 0; $index_entries_counter < $info_asf_simple_index_object['index_entries_count']; $index_entries_counter++) {
-
+
$info_asf_simple_index_object['index_entries'][$index_entries_counter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($index_entries_data, $offset, 4));
$offset += 4;
-
+
$info_asf_simple_index_object['index_entries'][$index_entries_counter]['packet_count'] = getid3_lib::LittleEndian2Int(substr($index_entries_data, $offset, 4));
$offset += 2;
}
@@ -1396,7 +1396,7 @@ class getid3_asf extends getid3_handler
$info_asf_asf_index_object['objectid_guid'] = $next_object_guidtext;
$info_asf_asf_index_object['objectsize'] = $next_object_size;
- getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_asf_index_object, $asf_index_object_data, 24,
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_asf_index_object, $asf_index_object_data, 24,
array (
'entry_time_interval' =>4,
'index_specifiers_count' =>2,
@@ -1407,17 +1407,17 @@ class getid3_asf extends getid3_handler
$offset = 34;
$asf_index_object_data .= fread($getid3->fp, 4 * $info_asf_asf_index_object['index_specifiers_count']);
-
+
for ($index_specifiers_counter = 0; $index_specifiers_counter < $info_asf_asf_index_object['index_specifiers_count']; $index_specifiers_counter++) {
-
+
$index_specifier_stream_number = getid3_lib::LittleEndian2Int(substr($asf_index_object_data, $offset, 2));
$offset += 2;
-
+
$info_asf_asf_index_object['index_specifiers'][$index_specifiers_counter]['stream_number'] = $index_specifier_stream_number;
-
+
$info_asf_asf_index_object['index_specifiers'][$index_specifiers_counter]['index_type'] = getid3_lib::LittleEndian2Int(substr($asf_index_object_data, $offset, 2));
$offset += 2;
-
+
$info_asf_asf_index_object['index_specifiers'][$index_specifiers_counter]['index_type_text'] = getid3_asf::ASFIndexObjectIndexTypeLookup($info_asf_asf_index_object['index_specifiers'][$index_specifiers_counter]['index_type']);
}
@@ -1426,14 +1426,14 @@ class getid3_asf extends getid3_handler
$offset += 4;
$asf_index_object_data .= fread($getid3->fp, 8 * $info_asf_asf_index_object['index_specifiers_count']);
-
+
for ($index_specifiers_counter = 0; $index_specifiers_counter < $info_asf_asf_index_object['index_specifiers_count']; $index_specifiers_counter++) {
$info_asf_asf_index_object['block_positions'][$index_specifiers_counter] = getid3_lib::LittleEndian2Int(substr($asf_index_object_data, $offset, 8));
$offset += 8;
}
$asf_index_object_data .= fread($getid3->fp, 4 * $info_asf_asf_index_object['index_specifiers_count'] * $info_asf_asf_index_object['index_entry_count']);
-
+
for ($index_entry_counter = 0; $index_entry_counter < $info_asf_asf_index_object['index_entry_count']; $index_entry_counter++) {
for ($index_specifiers_counter = 0; $index_specifiers_counter < $info_asf_asf_index_object['index_specifiers_count']; $index_specifiers_counter++) {
$info_asf_asf_index_object['offsets'][$index_specifiers_counter][$index_entry_counter] = getid3_lib::LittleEndian2Int(substr($asf_index_object_data, $offset, 4));
@@ -1444,7 +1444,7 @@ class getid3_asf extends getid3_handler
default:
-
+
// Implementations shall ignore any standard or non-standard object that they do not know how to handle.
if (getid3_asf::GUIDname($next_object_guidtext)) {
$getid3->warning('unhandled GUID "'.getid3_asf::GUIDname($next_object_guidtext).'" {'.$next_object_guidtext.'} in ASF body at offset '.($offset - 16 - 8));
@@ -1467,7 +1467,7 @@ class getid3_asf extends getid3_handler
case 'WMVA':
case 'WVC1':
case 'WMVP':
- case 'WVP2':
+ case 'WVP2':
$info_video['dataformat'] = 'wmv';
$getid3->info['mime_type'] = 'video/x-ms-wmv';
break;
@@ -1541,31 +1541,31 @@ class getid3_asf extends getid3_handler
$info_audio['lossless'] = (isset($info_audio['lossless']) ? $info_audio['lossless'] : false);
$info_audio['dataformat'] = (!empty($info_audio['dataformat']) ? $info_audio['dataformat'] : 'asf');
}
-
+
if (!empty($info_video['dataformat'])) {
$info_video['lossless'] = (isset($info_audio['lossless']) ? $info_audio['lossless'] : false);
$info_video['pixel_aspect_ratio'] = (isset($info_audio['pixel_aspect_ratio']) ? $info_audio['pixel_aspect_ratio'] : (float)1);
$info_video['dataformat'] = (!empty($info_video['dataformat']) ? $info_video['dataformat'] : 'asf');
}
-
+
$getid3->info['bitrate'] = @$info_audio['bitrate'] + @$info_video['bitrate'];
-
+
if (empty($info_audio)) {
unset($getid3->info['audio']);
}
-
+
if (empty($info_video)) {
unset($getid3->info['video']);
}
-
+
return true;
}
-
+
// Remove terminator 00 00 and convert UNICODE to Latin-1
private function TrimConvert($string) {
-
+
// remove terminator, only if present (it should be, but...)
if (substr($string, strlen($string) - 2, 2) == "\x00\x00") {
$string = substr($string, 0, strlen($string) - 2);
@@ -1578,7 +1578,7 @@ class getid3_asf extends getid3_handler
private function WMpictureTypeLookup($wm_picture_type) {
-
+
static $lookup = array (
0x03 => 'Front Cover',
0x04 => 'Back Cover',
@@ -1599,14 +1599,14 @@ class getid3_asf extends getid3_handler
0x13 => 'Band Logotype',
0x14 => 'Publisher Logotype'
);
-
+
return isset($lookup[$wm_picture_type]) ? $this->getid3->iconv('ISO-8859-1', 'UTF-16LE', $lookup[$wm_picture_type]) : '';
}
public static function ASFCodecListObjectTypeLookup($codec_list_type) {
-
+
static $lookup = array (
0x0001 => 'Video Codec',
0x0002 => 'Audio Codec',
@@ -1619,123 +1619,123 @@ class getid3_asf extends getid3_handler
public static function GUIDname($guid_string) {
-
+
static $lookup = array (
- getid3_asf::Extended_Stream_Properties_Object => 'Extended_Stream_Properties_Object',
- getid3_asf::Padding_Object => 'Padding_Object',
- getid3_asf::Payload_Ext_Syst_Pixel_Aspect_Ratio => 'Payload_Ext_Syst_Pixel_Aspect_Ratio',
- getid3_asf::Script_Command_Object => 'Script_Command_Object',
- getid3_asf::No_Error_Correction => 'No_Error_Correction',
- getid3_asf::Content_Branding_Object => 'Content_Branding_Object',
- getid3_asf::Content_Encryption_Object => 'Content_Encryption_Object',
- getid3_asf::Digital_Signature_Object => 'Digital_Signature_Object',
- getid3_asf::Extended_Content_Encryption_Object => 'Extended_Content_Encryption_Object',
- getid3_asf::Simple_Index_Object => 'Simple_Index_Object',
- getid3_asf::Degradable_JPEG_Media => 'Degradable_JPEG_Media',
- getid3_asf::Payload_Extension_System_Timecode => 'Payload_Extension_System_Timecode',
- getid3_asf::Binary_Media => 'Binary_Media',
- getid3_asf::Timecode_Index_Object => 'Timecode_Index_Object',
- getid3_asf::Metadata_Library_Object => 'Metadata_Library_Object',
- getid3_asf::Reserved_3 => 'Reserved_3',
- getid3_asf::Reserved_4 => 'Reserved_4',
- getid3_asf::Command_Media => 'Command_Media',
- getid3_asf::Header_Extension_Object => 'Header_Extension_Object',
- getid3_asf::Media_Object_Index_Parameters_Obj => 'Media_Object_Index_Parameters_Obj',
- getid3_asf::Header_Object => 'Header_Object',
- getid3_asf::Content_Description_Object => 'Content_Description_Object',
- getid3_asf::Error_Correction_Object => 'Error_Correction_Object',
- getid3_asf::Data_Object => 'Data_Object',
- getid3_asf::Web_Stream_Media_Subtype => 'Web_Stream_Media_Subtype',
- getid3_asf::Stream_Bitrate_Properties_Object => 'Stream_Bitrate_Properties_Object',
- getid3_asf::Language_List_Object => 'Language_List_Object',
- getid3_asf::Codec_List_Object => 'Codec_List_Object',
- getid3_asf::Reserved_2 => 'Reserved_2',
- getid3_asf::File_Properties_Object => 'File_Properties_Object',
- getid3_asf::File_Transfer_Media => 'File_Transfer_Media',
- getid3_asf::Old_RTP_Extension_Data => 'Old_RTP_Extension_Data',
- getid3_asf::Advanced_Mutual_Exclusion_Object => 'Advanced_Mutual_Exclusion_Object',
- getid3_asf::Bandwidth_Sharing_Object => 'Bandwidth_Sharing_Object',
- getid3_asf::Reserved_1 => 'Reserved_1',
- getid3_asf::Bandwidth_Sharing_Exclusive => 'Bandwidth_Sharing_Exclusive',
- getid3_asf::Bandwidth_Sharing_Partial => 'Bandwidth_Sharing_Partial',
- getid3_asf::JFIF_Media => 'JFIF_Media',
- getid3_asf::Stream_Properties_Object => 'Stream_Properties_Object',
- getid3_asf::Video_Media => 'Video_Media',
- getid3_asf::Audio_Spread => 'Audio_Spread',
- getid3_asf::Metadata_Object => 'Metadata_Object',
- getid3_asf::Payload_Ext_Syst_Sample_Duration => 'Payload_Ext_Syst_Sample_Duration',
- getid3_asf::Group_Mutual_Exclusion_Object => 'Group_Mutual_Exclusion_Object',
- getid3_asf::Extended_Content_Description_Object => 'Extended_Content_Description_Object',
- getid3_asf::Stream_Prioritization_Object => 'Stream_Prioritization_Object',
- getid3_asf::Payload_Ext_System_Content_Type => 'Payload_Ext_System_Content_Type',
- getid3_asf::Old_File_Properties_Object => 'Old_File_Properties_Object',
- getid3_asf::Old_ASF_Header_Object => 'Old_ASF_Header_Object',
- getid3_asf::Old_ASF_Data_Object => 'Old_ASF_Data_Object',
- getid3_asf::Index_Object => 'Index_Object',
- getid3_asf::Old_Stream_Properties_Object => 'Old_Stream_Properties_Object',
- getid3_asf::Old_Content_Description_Object => 'Old_Content_Description_Object',
- getid3_asf::Old_Script_Command_Object => 'Old_Script_Command_Object',
- getid3_asf::Old_Marker_Object => 'Old_Marker_Object',
- getid3_asf::Old_Component_Download_Object => 'Old_Component_Download_Object',
- getid3_asf::Old_Stream_Group_Object => 'Old_Stream_Group_Object',
- getid3_asf::Old_Scalable_Object => 'Old_Scalable_Object',
- getid3_asf::Old_Prioritization_Object => 'Old_Prioritization_Object',
- getid3_asf::Bitrate_Mutual_Exclusion_Object => 'Bitrate_Mutual_Exclusion_Object',
- getid3_asf::Old_Inter_Media_Dependency_Object => 'Old_Inter_Media_Dependency_Object',
- getid3_asf::Old_Rating_Object => 'Old_Rating_Object',
- getid3_asf::Index_Parameters_Object => 'Index_Parameters_Object',
- getid3_asf::Old_Color_Table_Object => 'Old_Color_Table_Object',
- getid3_asf::Old_Language_List_Object => 'Old_Language_List_Object',
- getid3_asf::Old_Audio_Media => 'Old_Audio_Media',
- getid3_asf::Old_Video_Media => 'Old_Video_Media',
- getid3_asf::Old_Image_Media => 'Old_Image_Media',
- getid3_asf::Old_Timecode_Media => 'Old_Timecode_Media',
- getid3_asf::Old_Text_Media => 'Old_Text_Media',
- getid3_asf::Old_MIDI_Media => 'Old_MIDI_Media',
- getid3_asf::Old_Command_Media => 'Old_Command_Media',
- getid3_asf::Old_No_Error_Concealment => 'Old_No_Error_Concealment',
- getid3_asf::Old_Scrambled_Audio => 'Old_Scrambled_Audio',
- getid3_asf::Old_No_Color_Table => 'Old_No_Color_Table',
- getid3_asf::Old_SMPTE_Time => 'Old_SMPTE_Time',
- getid3_asf::Old_ASCII_Text => 'Old_ASCII_Text',
- getid3_asf::Old_Unicode_Text => 'Old_Unicode_Text',
- getid3_asf::Old_HTML_Text => 'Old_HTML_Text',
- getid3_asf::Old_URL_Command => 'Old_URL_Command',
- getid3_asf::Old_Filename_Command => 'Old_Filename_Command',
- getid3_asf::Old_ACM_Codec => 'Old_ACM_Codec',
- getid3_asf::Old_VCM_Codec => 'Old_VCM_Codec',
- getid3_asf::Old_QuickTime_Codec => 'Old_QuickTime_Codec',
- getid3_asf::Old_DirectShow_Transform_Filter => 'Old_DirectShow_Transform_Filter',
- getid3_asf::Old_DirectShow_Rendering_Filter => 'Old_DirectShow_Rendering_Filter',
- getid3_asf::Old_No_Enhancement => 'Old_No_Enhancement',
- getid3_asf::Old_Unknown_Enhancement_Type => 'Old_Unknown_Enhancement_Type',
- getid3_asf::Old_Temporal_Enhancement => 'Old_Temporal_Enhancement',
- getid3_asf::Old_Spatial_Enhancement => 'Old_Spatial_Enhancement',
- getid3_asf::Old_Quality_Enhancement => 'Old_Quality_Enhancement',
- getid3_asf::Old_Number_of_Channels_Enhancement => 'Old_Number_of_Channels_Enhancement',
- getid3_asf::Old_Frequency_Response_Enhancement => 'Old_Frequency_Response_Enhancement',
- getid3_asf::Old_Media_Object => 'Old_Media_Object',
- getid3_asf::Mutex_Language => 'Mutex_Language',
- getid3_asf::Mutex_Bitrate => 'Mutex_Bitrate',
- getid3_asf::Mutex_Unknown => 'Mutex_Unknown',
- getid3_asf::Old_ASF_Placeholder_Object => 'Old_ASF_Placeholder_Object',
- getid3_asf::Old_Data_Unit_Extension_Object => 'Old_Data_Unit_Extension_Object',
- getid3_asf::Web_Stream_Format => 'Web_Stream_Format',
- getid3_asf::Payload_Ext_System_File_Name => 'Payload_Ext_System_File_Name',
- getid3_asf::Marker_Object => 'Marker_Object',
- getid3_asf::Timecode_Index_Parameters_Object => 'Timecode_Index_Parameters_Object',
- getid3_asf::Audio_Media => 'Audio_Media',
- getid3_asf::Media_Object_Index_Object => 'Media_Object_Index_Object',
- getid3_asf::Alt_Extended_Content_Encryption_Obj => 'Alt_Extended_Content_Encryption_Obj'
+ getid3_asf::Extended_Stream_Properties_Object => 'Extended_Stream_Properties_Object',
+ getid3_asf::Padding_Object => 'Padding_Object',
+ getid3_asf::Payload_Ext_Syst_Pixel_Aspect_Ratio => 'Payload_Ext_Syst_Pixel_Aspect_Ratio',
+ getid3_asf::Script_Command_Object => 'Script_Command_Object',
+ getid3_asf::No_Error_Correction => 'No_Error_Correction',
+ getid3_asf::Content_Branding_Object => 'Content_Branding_Object',
+ getid3_asf::Content_Encryption_Object => 'Content_Encryption_Object',
+ getid3_asf::Digital_Signature_Object => 'Digital_Signature_Object',
+ getid3_asf::Extended_Content_Encryption_Object => 'Extended_Content_Encryption_Object',
+ getid3_asf::Simple_Index_Object => 'Simple_Index_Object',
+ getid3_asf::Degradable_JPEG_Media => 'Degradable_JPEG_Media',
+ getid3_asf::Payload_Extension_System_Timecode => 'Payload_Extension_System_Timecode',
+ getid3_asf::Binary_Media => 'Binary_Media',
+ getid3_asf::Timecode_Index_Object => 'Timecode_Index_Object',
+ getid3_asf::Metadata_Library_Object => 'Metadata_Library_Object',
+ getid3_asf::Reserved_3 => 'Reserved_3',
+ getid3_asf::Reserved_4 => 'Reserved_4',
+ getid3_asf::Command_Media => 'Command_Media',
+ getid3_asf::Header_Extension_Object => 'Header_Extension_Object',
+ getid3_asf::Media_Object_Index_Parameters_Obj => 'Media_Object_Index_Parameters_Obj',
+ getid3_asf::Header_Object => 'Header_Object',
+ getid3_asf::Content_Description_Object => 'Content_Description_Object',
+ getid3_asf::Error_Correction_Object => 'Error_Correction_Object',
+ getid3_asf::Data_Object => 'Data_Object',
+ getid3_asf::Web_Stream_Media_Subtype => 'Web_Stream_Media_Subtype',
+ getid3_asf::Stream_Bitrate_Properties_Object => 'Stream_Bitrate_Properties_Object',
+ getid3_asf::Language_List_Object => 'Language_List_Object',
+ getid3_asf::Codec_List_Object => 'Codec_List_Object',
+ getid3_asf::Reserved_2 => 'Reserved_2',
+ getid3_asf::File_Properties_Object => 'File_Properties_Object',
+ getid3_asf::File_Transfer_Media => 'File_Transfer_Media',
+ getid3_asf::Old_RTP_Extension_Data => 'Old_RTP_Extension_Data',
+ getid3_asf::Advanced_Mutual_Exclusion_Object => 'Advanced_Mutual_Exclusion_Object',
+ getid3_asf::Bandwidth_Sharing_Object => 'Bandwidth_Sharing_Object',
+ getid3_asf::Reserved_1 => 'Reserved_1',
+ getid3_asf::Bandwidth_Sharing_Exclusive => 'Bandwidth_Sharing_Exclusive',
+ getid3_asf::Bandwidth_Sharing_Partial => 'Bandwidth_Sharing_Partial',
+ getid3_asf::JFIF_Media => 'JFIF_Media',
+ getid3_asf::Stream_Properties_Object => 'Stream_Properties_Object',
+ getid3_asf::Video_Media => 'Video_Media',
+ getid3_asf::Audio_Spread => 'Audio_Spread',
+ getid3_asf::Metadata_Object => 'Metadata_Object',
+ getid3_asf::Payload_Ext_Syst_Sample_Duration => 'Payload_Ext_Syst_Sample_Duration',
+ getid3_asf::Group_Mutual_Exclusion_Object => 'Group_Mutual_Exclusion_Object',
+ getid3_asf::Extended_Content_Description_Object => 'Extended_Content_Description_Object',
+ getid3_asf::Stream_Prioritization_Object => 'Stream_Prioritization_Object',
+ getid3_asf::Payload_Ext_System_Content_Type => 'Payload_Ext_System_Content_Type',
+ getid3_asf::Old_File_Properties_Object => 'Old_File_Properties_Object',
+ getid3_asf::Old_ASF_Header_Object => 'Old_ASF_Header_Object',
+ getid3_asf::Old_ASF_Data_Object => 'Old_ASF_Data_Object',
+ getid3_asf::Index_Object => 'Index_Object',
+ getid3_asf::Old_Stream_Properties_Object => 'Old_Stream_Properties_Object',
+ getid3_asf::Old_Content_Description_Object => 'Old_Content_Description_Object',
+ getid3_asf::Old_Script_Command_Object => 'Old_Script_Command_Object',
+ getid3_asf::Old_Marker_Object => 'Old_Marker_Object',
+ getid3_asf::Old_Component_Download_Object => 'Old_Component_Download_Object',
+ getid3_asf::Old_Stream_Group_Object => 'Old_Stream_Group_Object',
+ getid3_asf::Old_Scalable_Object => 'Old_Scalable_Object',
+ getid3_asf::Old_Prioritization_Object => 'Old_Prioritization_Object',
+ getid3_asf::Bitrate_Mutual_Exclusion_Object => 'Bitrate_Mutual_Exclusion_Object',
+ getid3_asf::Old_Inter_Media_Dependency_Object => 'Old_Inter_Media_Dependency_Object',
+ getid3_asf::Old_Rating_Object => 'Old_Rating_Object',
+ getid3_asf::Index_Parameters_Object => 'Index_Parameters_Object',
+ getid3_asf::Old_Color_Table_Object => 'Old_Color_Table_Object',
+ getid3_asf::Old_Language_List_Object => 'Old_Language_List_Object',
+ getid3_asf::Old_Audio_Media => 'Old_Audio_Media',
+ getid3_asf::Old_Video_Media => 'Old_Video_Media',
+ getid3_asf::Old_Image_Media => 'Old_Image_Media',
+ getid3_asf::Old_Timecode_Media => 'Old_Timecode_Media',
+ getid3_asf::Old_Text_Media => 'Old_Text_Media',
+ getid3_asf::Old_MIDI_Media => 'Old_MIDI_Media',
+ getid3_asf::Old_Command_Media => 'Old_Command_Media',
+ getid3_asf::Old_No_Error_Concealment => 'Old_No_Error_Concealment',
+ getid3_asf::Old_Scrambled_Audio => 'Old_Scrambled_Audio',
+ getid3_asf::Old_No_Color_Table => 'Old_No_Color_Table',
+ getid3_asf::Old_SMPTE_Time => 'Old_SMPTE_Time',
+ getid3_asf::Old_ASCII_Text => 'Old_ASCII_Text',
+ getid3_asf::Old_Unicode_Text => 'Old_Unicode_Text',
+ getid3_asf::Old_HTML_Text => 'Old_HTML_Text',
+ getid3_asf::Old_URL_Command => 'Old_URL_Command',
+ getid3_asf::Old_Filename_Command => 'Old_Filename_Command',
+ getid3_asf::Old_ACM_Codec => 'Old_ACM_Codec',
+ getid3_asf::Old_VCM_Codec => 'Old_VCM_Codec',
+ getid3_asf::Old_QuickTime_Codec => 'Old_QuickTime_Codec',
+ getid3_asf::Old_DirectShow_Transform_Filter => 'Old_DirectShow_Transform_Filter',
+ getid3_asf::Old_DirectShow_Rendering_Filter => 'Old_DirectShow_Rendering_Filter',
+ getid3_asf::Old_No_Enhancement => 'Old_No_Enhancement',
+ getid3_asf::Old_Unknown_Enhancement_Type => 'Old_Unknown_Enhancement_Type',
+ getid3_asf::Old_Temporal_Enhancement => 'Old_Temporal_Enhancement',
+ getid3_asf::Old_Spatial_Enhancement => 'Old_Spatial_Enhancement',
+ getid3_asf::Old_Quality_Enhancement => 'Old_Quality_Enhancement',
+ getid3_asf::Old_Number_of_Channels_Enhancement => 'Old_Number_of_Channels_Enhancement',
+ getid3_asf::Old_Frequency_Response_Enhancement => 'Old_Frequency_Response_Enhancement',
+ getid3_asf::Old_Media_Object => 'Old_Media_Object',
+ getid3_asf::Mutex_Language => 'Mutex_Language',
+ getid3_asf::Mutex_Bitrate => 'Mutex_Bitrate',
+ getid3_asf::Mutex_Unknown => 'Mutex_Unknown',
+ getid3_asf::Old_ASF_Placeholder_Object => 'Old_ASF_Placeholder_Object',
+ getid3_asf::Old_Data_Unit_Extension_Object => 'Old_Data_Unit_Extension_Object',
+ getid3_asf::Web_Stream_Format => 'Web_Stream_Format',
+ getid3_asf::Payload_Ext_System_File_Name => 'Payload_Ext_System_File_Name',
+ getid3_asf::Marker_Object => 'Marker_Object',
+ getid3_asf::Timecode_Index_Parameters_Object => 'Timecode_Index_Parameters_Object',
+ getid3_asf::Audio_Media => 'Audio_Media',
+ getid3_asf::Media_Object_Index_Object => 'Media_Object_Index_Object',
+ getid3_asf::Alt_Extended_Content_Encryption_Obj => 'Alt_Extended_Content_Encryption_Obj'
);
-
+
return @$lookup[$guid_string];
}
public static function ASFIndexObjectIndexTypeLookup($id) {
-
+
static $lookup = array (
1 => 'Nearest Past Data Packet',
2 => 'Nearest Past Media Object',
@@ -1748,7 +1748,7 @@ class getid3_asf extends getid3_handler
public static function GUIDtoBytestring($guid_string) {
-
+
// 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
@@ -1786,7 +1786,7 @@ class getid3_asf extends getid3_handler
public static function BytestringToGUID($byte_string) {
-
+
$guid_string = str_pad(dechex(ord($byte_string{3})), 2, '0', STR_PAD_LEFT);
$guid_string .= str_pad(dechex(ord($byte_string{2})), 2, '0', STR_PAD_LEFT);
$guid_string .= str_pad(dechex(ord($byte_string{1})), 2, '0', STR_PAD_LEFT);
@@ -1814,18 +1814,18 @@ class getid3_asf extends getid3_handler
public static function FiletimeToUNIXtime($file_time, $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
-
+
$time = ($file_time - 116444736000000000) / 10000000;
-
+
if ($round) {
return intval(round($time));
}
-
+
return $time;
}
diff --git a/modules/getid3/module.audio-video.flv.php b/modules/getid3/module.audio-video.flv.php
index fbf3887e..9249311e 100644
--- a/modules/getid3/module.audio-video.flv.php
+++ b/modules/getid3/module.audio-video.flv.php
@@ -44,7 +44,7 @@
class getid3_flv extends getid3_handler
{
-
+
const TAG_AUDIO = 8;
const TAG_VIDEO = 9;
const TAG_META = 18;
@@ -53,14 +53,14 @@ class getid3_flv extends getid3_handler
const VIDEO_SCREEN = 3;
const VIDEO_VP6 = 4;
-
+
public function Analyze()
{
$info = &$this->getid3->info;
-
+
$info['flv'] = array ();
$info_flv = &$info['flv'];
-
+
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$flv_data_length = $info['avdataend'] - $info['avdataoffset'];
@@ -82,7 +82,7 @@ class getid3_flv extends getid3_handler
$duration = 0;
while ((ftell($this->getid3->fp) + 1) < $info['avdataend']) {
-
+
$this_tag_header = fread($this->getid3->fp, 16);
$previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 0, 4));
@@ -93,7 +93,7 @@ class getid3_flv extends getid3_handler
$next_offset = ftell($this->getid3->fp) - 1 + $data_length;
switch ($tag_type) {
-
+
case getid3_flv::TAG_AUDIO:
if (!isset($info_flv['audio']['audioFormat'])) {
$info_flv['audio']['audioFormat'] = $last_header_byte & 0x07;
@@ -115,7 +115,7 @@ class getid3_flv extends getid3_handler
$picture_size_type = (getid3_lib::BigEndian2Int(substr($flv_video_header, 3, 2))) >> 7;
$picture_size_type = $picture_size_type & 0x0007;
$info_flv['header']['videoSizeType'] = $picture_size_type;
-
+
switch ($picture_size_type) {
case 0:
$picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 2));
@@ -221,7 +221,7 @@ class getid3_flv extends getid3_handler
public static function FLVaudioFormat($id) {
-
+
static $lookup = array(
0 => 'uncompressed',
1 => 'ADPCM',
@@ -234,7 +234,7 @@ class getid3_flv extends getid3_handler
public static function FLVaudioRate($id) {
-
+
static $lookup = array(
0 => 5500,
1 => 11025,
@@ -246,7 +246,7 @@ class getid3_flv extends getid3_handler
public static function FLVaudioBitDepth($id) {
-
+
static $lookup = array(
0 => 8,
1 => 16,
@@ -256,7 +256,7 @@ class getid3_flv extends getid3_handler
public static function FLVvideoCodec($id) {
-
+
static $lookup = array(
getid3_flv::VIDEO_H263 => 'Sorenson H.263',
getid3_flv::VIDEO_SCREEN => 'Screen video',
@@ -268,52 +268,52 @@ class getid3_flv extends getid3_handler
-class AMFStream
+class AMFStream
{
public $bytes;
public $pos;
public function AMFStream($bytes) {
-
+
$this->bytes = $bytes;
$this->pos = 0;
}
public function readByte() {
-
+
return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
}
public function readInt() {
-
+
return ($this->readByte() << 8) + $this->readByte();
}
public function readLong() {
-
+
return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
}
public function readDouble() {
-
+
return getid3_lib::BigEndian2Float($this->read(8));
}
public function readUTF() {
-
+
$length = $this->readInt();
return $this->read($length);
}
public function readLongUTF() {
-
+
$length = $this->readLong();
return $this->read($length);
}
@@ -326,9 +326,9 @@ class AMFStream
return $val;
}
-
+
public function peekByte() {
-
+
$pos = $this->pos;
$val = $this->readByte();
$this->pos = $pos;
@@ -346,7 +346,7 @@ class AMFStream
public function peekLong() {
-
+
$pos = $this->pos;
$val = $this->readLong();
$this->pos = $pos;
@@ -354,8 +354,8 @@ class AMFStream
}
- public function peekDouble() {
-
+ public function peekDouble() {
+
$pos = $this->pos;
$val = $this->readDouble();
$this->pos = $pos;
@@ -364,7 +364,7 @@ class AMFStream
public function peekUTF() {
-
+
$pos = $this->pos;
$val = $this->readUTF();
$this->pos = $pos;
@@ -373,7 +373,7 @@ class AMFStream
public function peekLongUTF() {
-
+
$pos = $this->pos;
$val = $this->readLongUTF();
$this->pos = $pos;
@@ -383,18 +383,18 @@ class AMFStream
-class AMFReader
+class AMFReader
{
public $stream;
public function __construct($stream) {
-
+
$this->stream = $stream;
}
public function readData() {
-
+
$value = null;
$type = $this->stream->readByte();
@@ -465,26 +465,26 @@ class AMFReader
}
- public function readDouble() {
-
+ public function readDouble() {
+
return $this->stream->readDouble();
}
public function readBoolean() {
-
+
return $this->stream->readByte() == 1;
}
-
-
+
+
public function readString() {
-
+
return $this->stream->readUTF();
}
public function readObject() {
-
+
// Get highest numerical index - ignored
$highestIndex = $this->stream->readLong();
@@ -506,7 +506,7 @@ class AMFReader
public function readMixedArray() {
-
+
// Get highest numerical index - ignored
$highestIndex = $this->stream->readLong();
@@ -532,7 +532,7 @@ class AMFReader
public function readArray() {
-
+
$length = $this->stream->readLong();
$data = array();
@@ -546,7 +546,7 @@ class AMFReader
public function readDate() {
-
+
$timestamp = $this->stream->readDouble();
$timezone = $this->stream->readInt();
return $timestamp;
@@ -554,19 +554,19 @@ class AMFReader
public function readLongString() {
-
+
return $this->stream->readLongUTF();
}
public function readXML() {
-
+
return $this->stream->readLongUTF();
}
- public function readTypedObject() {
-
+ public function readTypedObject() {
+
$className = $this->stream->readUTF();
return $this->readObject();
}
diff --git a/modules/getid3/module.audio-video.mpeg.php b/modules/getid3/module.audio-video.mpeg.php
index a0d2cd61..0d62b0ac 100644
--- a/modules/getid3/module.audio-video.mpeg.php
+++ b/modules/getid3/module.audio-video.mpeg.php
@@ -22,8 +22,8 @@
//
// $Id: module.audio-video.mpeg.php,v 1.3 2006/11/02 10:48:00 ah Exp $
-
-
+
+
class getid3_mpeg extends getid3_handler
{
@@ -35,21 +35,21 @@ class getid3_mpeg extends getid3_handler
const VIDEO_SEQUENCE_END = "\x00\x00\x01\xB7";
const VIDEO_GROUP_START = "\x00\x00\x01\xB8";
const AUDIO_START = "\x00\x00\x01\xC0";
-
+
public function Analyze() {
-
+
$getid3 = $this->getid3;
-
+
$getid3->info['mpeg']['video']['raw'] = array ();
$info_mpeg_video = &$getid3->info['mpeg']['video'];
$info_mpeg_video_raw = &$info_mpeg_video['raw'];
-
+
$getid3->info['video'] = array ();
$info_video = &$getid3->info['video'];
-
+
$getid3->include_module('audio.mp3');
-
+
if ($getid3->info['avdataend'] <= $getid3->info['avdataoffset']) {
throw new getid3_exception('"avdataend" ('.$getid3->info['avdataend'].') is unexpectedly less-than-or-equal-to "avdataoffset" ('.$getid3->info['avdataoffset'].')');
}
@@ -97,7 +97,7 @@ class getid3_mpeg extends getid3_handler
$info_mpeg_video_raw['framesize_vertical'] = ($frame_size_dword & 0x000FFF); // 12 bits for vertical frame size
$info_mpeg_video_raw['pixel_aspect_ratio'] = ($aspect_ratio_frame_rate_dword & 0xF0) >> 4;
$info_mpeg_video_raw['frame_rate'] = ($aspect_ratio_frame_rate_dword & 0x0F);
-
+
$info_mpeg_video['framesize_horizontal'] = $info_mpeg_video_raw['framesize_horizontal'];
$info_mpeg_video['framesize_vertical'] = $info_mpeg_video_raw['framesize_vertical'];
@@ -110,7 +110,7 @@ class getid3_mpeg extends getid3_handler
$info_mpeg_video_raw['vbv_buffer_size'] = bindec(substr($assorted_information, 19, 10));
$info_mpeg_video_raw['constrained_param_flag'] = (bool)bindec($assorted_information{29});
$info_mpeg_video_raw['intra_quant_flag'] = (bool)bindec($assorted_information{30});
-
+
if ($info_mpeg_video_raw['intra_quant_flag']) {
// read 512 bits
@@ -182,7 +182,7 @@ class getid3_mpeg extends getid3_handler
// clone getid3 - better safe than sorry
$clone = clone $this->getid3;
-
+
// check
$mp3 = new getid3_mp3($clone);
if ($mp3->decodeMPEGaudioHeader($getid3->fp, ($audio_chunk_offset + 3) + 8 + $i, $dummy, false)) {
@@ -192,7 +192,7 @@ class getid3_mpeg extends getid3_handler
$getid3->info['audio']['lossless'] = false;
break 2;
}
-
+
// destroy copy
unset($dummy);
}
@@ -227,7 +227,7 @@ class getid3_mpeg extends getid3_handler
//}
//$getid3->info['playtime_seconds'] *= $multiplier;
//$getid3->warning('Interleaved MPEG audio/video playtime may be inaccurate. With current hack should be within a few seconds of accurate. Report to info@getid3.org if off by more than 10 seconds.');
-
+
if ($info_video['bitrate'] < 50000) {
$getid3->warning('Interleaved MPEG audio/video playtime may be slightly inaccurate for video bitrates below 100kbps. Except in extreme low-bitrate situations, error should be less than 1%. Report to info@getid3.org if greater than this.');
}
@@ -239,7 +239,7 @@ class getid3_mpeg extends getid3_handler
public static function MPEGsystemNonOverheadPercentage($video_bitrate, $audio_bitrate) {
-
+
$overhead_percentage = 0;
$audio_bitrate = max(min($audio_bitrate / 1000, 384), 32); // limit to range of 32kbps - 384kbps (should be only legal bitrates, but maybe VBR?)
@@ -264,7 +264,7 @@ class getid3_mpeg extends getid3_handler
$bitrate_to_use_min = $bitrate_to_use_max = $previous_bitrate = 32;
foreach ($overhead_multiplier_by_bitrate as $key => $value) {
-
+
if ($audio_bitrate >= $previous_bitrate) {
$bitrate_to_use_min = $previous_bitrate;
}
@@ -274,7 +274,7 @@ class getid3_mpeg extends getid3_handler
}
$previous_bitrate = $key;
}
-
+
$factor_a = ($bitrate_to_use_max - $audio_bitrate) / ($bitrate_to_use_max - $bitrate_to_use_min);
$video_bitrate_log10 = log10($video_bitrate);
@@ -295,27 +295,27 @@ class getid3_mpeg extends getid3_handler
public static function MPEGvideoFramerateLookup($raw_frame_rate) {
-
+
$lookup = array (0, 23.976, 24, 25, 29.97, 30, 50, 59.94, 60);
-
+
return (float)(isset($lookup[$raw_frame_rate]) ? $lookup[$raw_frame_rate] : 0);
}
public static function MPEGvideoAspectRatioLookup($raw_aspect_ratio) {
-
+
$lookup = array (0, 1, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, 1.2015, 0);
-
+
return (float)(isset($lookup[$raw_aspect_ratio]) ? $lookup[$raw_aspect_ratio] : 0);
}
public static function MPEGvideoAspectRatioTextLookup($raw_aspect_ratio) {
-
+
$lookup = array ('forbidden', 'square pixels', '0.6735', '16:9, 625 line, PAL', '0.7615', '0.8055', '16:9, 525 line, NTSC', '0.8935', '4:3, 625 line, PAL, CCIR601', '0.9815', '1.0255', '1.0695', '4:3, 525 line, NTSC, CCIR601', '1.1575', '1.2015', 'reserved');
-
+
return (isset($lookup[$raw_aspect_ratio]) ? $lookup[$raw_aspect_ratio] : '');
}
diff --git a/modules/getid3/module.audio-video.nsv.php b/modules/getid3/module.audio-video.nsv.php
index 3744dd42..a7c533c4 100644
--- a/modules/getid3/module.audio-video.nsv.php
+++ b/modules/getid3/module.audio-video.nsv.php
@@ -22,8 +22,8 @@
//
// $Id: module.audio-video.nsv.php,v 1.3 2006/11/02 10:48:00 ah Exp $
-
-
+
+
class getid3_nsv extends getid3_handler
{
@@ -41,7 +41,7 @@ class getid3_nsv extends getid3_handler
$nsv_header = fread($getid3->fp, 4);
switch ($nsv_header) {
-
+
case 'NSVs':
$this->getNSVsHeader();
break;
@@ -67,9 +67,9 @@ class getid3_nsv extends getid3_handler
private function getNSVsHeader($file_offset = 0) {
-
+
$getid3 = $this->getid3;
-
+
fseek($getid3->fp, $file_offset, SEEK_SET);
$nsvs_header = fread($getid3->fp, 28);
@@ -80,9 +80,9 @@ class getid3_nsv extends getid3_handler
if ($info_nsv_NSVs['identifier'] != 'NSVs') {
throw new getid3_exception('expected "NSVs" at offset ('.$file_offset.'), found "'.$info_nsv_NSVs['identifier'].'" instead');
}
-
+
$info_nsv_NSVs['offset'] = $file_offset;
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_nsv_NSVs, $nsvs_header, 4,
array (
'video_codec' => -4, // string
@@ -94,7 +94,7 @@ class getid3_nsv extends getid3_handler
);
if ($info_nsv_NSVs['audio_codec'] == 'PCM ') {
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_nsv_NSVs, $nsvs_header, 24,
array (
'bits_channel' => 1,
@@ -103,7 +103,7 @@ class getid3_nsv extends getid3_handler
)
);
$getid3->info['audio']['sample_rate'] = $info_nsv_NSVs['sample_rate'];
-
+
}
$getid3->info['video']['resolution_x'] = $info_nsv_NSVs['resolution_x'];
@@ -119,15 +119,15 @@ class getid3_nsv extends getid3_handler
private function getNSVfHeader($file_offset = 0, $get_toc_offsets=false) {
-
+
$getid3 = $this->getid3;
-
+
fseek($getid3->fp, $file_offset, SEEK_SET);
$nsvf_header = fread($getid3->fp, 28);
-
+
$getid3->info['nsv']['NSVf'] = array ();
$info_nsv_NSVf = &$getid3->info['nsv']['NSVf'];
-
+
$info_nsv_NSVf['identifier'] = substr($nsvf_header, 0, 4);
if ($info_nsv_NSVf['identifier'] != 'NSVf') {
throw new getid3_exception('expected "NSVf" at offset ('.$file_offset.'), found "'.$info_nsv_NSVf['identifier'].'" instead');
@@ -145,11 +145,11 @@ class getid3_nsv extends getid3_handler
'TOC_entries_2' => 4
)
);
-
+
if ($info_nsv_NSVf['playtime_ms'] == 0) {
throw new getid3_exception('Corrupt NSV file: NSVf.playtime_ms == zero');
}
-
+
if ($info_nsv_NSVf['file_size'] > $getid3->info['avdataend']) {
$getid3->warning('truncated file - NSVf header indicates '.$info_nsv_NSVf['file_size'].' bytes, file actually '.$getid3->info['avdataend'].' bytes');
}
@@ -190,7 +190,7 @@ class getid3_nsv extends getid3_handler
public static function NSVframerateLookup($frame_rate_index) {
-
+
if ($frame_rate_index <= 127) {
return (float)$frame_rate_index;
}
diff --git a/modules/getid3/module.audio-video.real.php b/modules/getid3/module.audio-video.real.php
index 4fda21a1..c8688f72 100644
--- a/modules/getid3/module.audio-video.real.php
+++ b/modules/getid3/module.audio-video.real.php
@@ -22,15 +22,15 @@
//
// $Id: module.audio-video.real.php,v 1.4 2006/11/02 10:48:00 ah Exp $
-
-
+
+
class getid3_real extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
-
+
$getid3->include_module('audio-video.riff');
$getid3->info['fileformat'] = 'real';
@@ -41,16 +41,16 @@ class getid3_real extends getid3_handler
$chunk_counter = 0;
while (ftell($getid3->fp) < $getid3->info['avdataend']) {
-
+
$chunk_data = fread($getid3->fp, 8);
$chunk_name = substr($chunk_data, 0, 4);
$chunk_size = getid3_lib::BigEndian2Int(substr($chunk_data, 4, 4));
if ($chunk_name == '.ra'."\xFD") {
$chunk_data .= fread($getid3->fp, $chunk_size - 8);
-
+
if ($this->ParseOldRAheader(substr($chunk_data, 0, 128), $getid3->info['real']['old_ra_header'])) {
-
+
$getid3->info['audio']['dataformat'] = 'real';
$getid3->info['audio']['lossless'] = false;
$getid3->info['audio']['sample_rate'] = $getid3->info['real']['old_ra_header']['sample_rate'];
@@ -62,14 +62,14 @@ class getid3_real extends getid3_handler
$getid3->info['audio']['codec'] = $this->RealAudioCodecFourCClookup($getid3->info['real']['old_ra_header']['fourcc'], $getid3->info['audio']['bitrate']);
foreach ($getid3->info['real']['old_ra_header']['comments'] as $key => $value_array) {
-
+
if (strlen(trim($value_array[0])) > 0) {
$getid3->info['real']['comments'][$key][] = trim($value_array[0]);
}
}
return true;
}
-
+
throw new getid3_exception('There was a problem parsing this RealAudio file. Please submit it for analysis to http://www.getid3.org/upload/ or info@getid3.org');
}
@@ -79,7 +79,7 @@ class getid3_real extends getid3_handler
$info_real_chunks_current_chunk['name'] = $chunk_name;
$info_real_chunks_current_chunk['offset'] = ftell($getid3->fp) - 8;
$info_real_chunks_current_chunk['length'] = $chunk_size;
-
+
if (($info_real_chunks_current_chunk['offset'] + $info_real_chunks_current_chunk['length']) > $getid3->info['avdataend']) {
$getid3->warning('Chunk "'.$info_real_chunks_current_chunk['name'].'" at offset '.$info_real_chunks_current_chunk['offset'].' claims to be '.$info_real_chunks_current_chunk['length'].' bytes long, which is beyond end of file');
return false;
@@ -125,7 +125,7 @@ class getid3_real extends getid3_handler
$offset += 2;
if ($info_real_chunks_current_chunk['object_version'] == 0) {
-
+
getid3_lib::ReadSequence('BigEndian2Int', $info_real_chunks_current_chunk, $chunk_data, $offset,
array (
'max_bit_rate' => 4,
@@ -147,7 +147,7 @@ class getid3_real extends getid3_handler
if ($info_real_chunks_current_chunk['duration'] > 0) {
$getid3->info['bitrate'] += $info_real_chunks_current_chunk['avg_bit_rate'];
}
-
+
$info_real_chunks_current_chunk['flags']['save_enabled'] = (bool)($info_real_chunks_current_chunk['flags_raw'] & 0x0001);
$info_real_chunks_current_chunk['flags']['perfect_play'] = (bool)($info_real_chunks_current_chunk['flags_raw'] & 0x0002);
$info_real_chunks_current_chunk['flags']['live_broadcast'] = (bool)($info_real_chunks_current_chunk['flags_raw'] & 0x0004);
@@ -176,25 +176,25 @@ class getid3_real extends getid3_handler
)
);
$offset += 31;
-
+
$info_real_chunks_current_chunk['stream_name'] = substr($chunk_data, $offset, $info_real_chunks_current_chunk['stream_name_size']);
$offset += $info_real_chunks_current_chunk['stream_name_size'];
-
+
$info_real_chunks_current_chunk['mime_type_size'] = getid3_lib::BigEndian2Int($chunk_data{$offset++});
-
+
$info_real_chunks_current_chunk['mime_type'] = substr($chunk_data, $offset, $info_real_chunks_current_chunk['mime_type_size']);
$offset += $info_real_chunks_current_chunk['mime_type_size'];
-
+
$info_real_chunks_current_chunk['type_specific_len'] = getid3_lib::BigEndian2Int(substr($chunk_data, $offset, 4));
$offset += 4;
-
+
$info_real_chunks_current_chunk['type_specific_data'] = substr($chunk_data, $offset, $info_real_chunks_current_chunk['type_specific_len']);
$offset += $info_real_chunks_current_chunk['type_specific_len'];
$info_real_chunks_current_chunk_typespecificdata = &$info_real_chunks_current_chunk['type_specific_data'];
switch ($info_real_chunks_current_chunk['mime_type']) {
-
+
case 'video/x-pn-realvideo':
case 'video/x-pn-multirate-realvideo':
// http://www.freelists.org/archives/matroska-devel/07-2003/msg00010.html
@@ -266,14 +266,14 @@ class getid3_real extends getid3_handler
if (empty($getid3->info['playtime_seconds'])) {
$getid3->info['playtime_seconds'] = max($getid3->info['playtime_seconds'], ($info_real_chunks_current_chunk['duration'] + $info_real_chunks_current_chunk['start_time']) / 1000);
}
-
+
if ($info_real_chunks_current_chunk['duration'] > 0) {
-
+
switch ($info_real_chunks_current_chunk['mime_type']) {
-
+
case 'audio/x-pn-realaudio':
case 'audio/x-pn-multirate-realaudio':
-
+
$getid3->info['audio']['bitrate'] = (isset($getid3->info['audio']['bitrate']) ? $getid3->info['audio']['bitrate'] : 0) + $info_real_chunks_current_chunk['avg_bit_rate'];
$getid3->info['audio']['codec'] = $this->RealAudioCodecFourCClookup($info_real_chunks_current_chunk['parsed_audio_data']['fourcc'], $getid3->info['audio']['bitrate']);
$getid3->info['audio']['dataformat'] = 'real';
@@ -299,9 +299,9 @@ class getid3_real extends getid3_handler
$getid3->info['audio']['dataformat'] = 'real';
$getid3->info['audio']['lossless'] = true;
break;
-
+
}
-
+
$getid3->info['bitrate'] = (isset($getid3->info['video']['bitrate']) ? $getid3->info['video']['bitrate'] : 0) + (isset($getid3->info['audio']['bitrate']) ? $getid3->info['audio']['bitrate'] : 0);
}
}
@@ -361,7 +361,7 @@ class getid3_real extends getid3_handler
if ($info_real_chunks_current_chunk['object_version'] == 0) {
- getid3_lib::ReadSequence('BigEndian2Int', $info_real_chunks_current_chunk, $chunk_data, $offset,
+ getid3_lib::ReadSequence('BigEndian2Int', $info_real_chunks_current_chunk, $chunk_data, $offset,
array (
'num_indices' => 4,
'stream_number' => 2,
@@ -389,9 +389,9 @@ class getid3_real extends getid3_handler
}
if (!empty($getid3->info['audio']['streams'])) {
-
+
$getid3->info['audio']['bitrate'] = 0;
-
+
foreach ($getid3->info['audio']['streams'] as $key => $value_array) {
$getid3->info['audio']['bitrate'] += $value_array['bitrate'];
}
@@ -408,17 +408,17 @@ class getid3_real extends getid3_handler
$parsed_array = array ();
$parsed_array['magic'] = substr($old_ra_header_data, 0, 4);
-
+
if ($parsed_array['magic'] != '.ra'."\xFD") {
return false;
}
-
+
$parsed_array['version1'] = getid3_lib::BigEndian2Int(substr($old_ra_header_data, 4, 2));
if ($parsed_array['version1'] < 3) {
return false;
- }
+ }
if ($parsed_array['version1'] == 3) {
@@ -437,20 +437,20 @@ class getid3_real extends getid3_handler
'audio_bytes' => 4,
)
);
-
+
$parsed_array['comments_raw'] = substr($old_ra_header_data, 22, $parsed_array['header_size'] - 22 + 1); // not including null terminator
$comment_offset = 0;
-
+
foreach (array ('title', 'artist', 'copyright') as $name) {
$comment_length = getid3_lib::BigEndian2Int($parsed_array['comments_raw']{$comment_offset++});
$parsed_array['comments'][$name][]= substr($parsed_array['comments_raw'], $comment_offset, $comment_length);
$comment_offset += $comment_length;
}
-
+
$comment_offset++; // final null terminator (?)
$comment_offset++; // fourcc length (?) should be 4
-
+
$parsed_array['fourcc'] = substr($old_ra_header_data, 23 + $comment_offset, 4);
@@ -478,7 +478,7 @@ class getid3_real extends getid3_handler
switch ($parsed_array['version1']) {
case 4:
-
+
getid3_lib::ReadSequence('BigEndian2Int', $parsed_array, $old_ra_header_data, 48,
array (
'sample_rate' => 2,
@@ -497,7 +497,7 @@ class getid3_real extends getid3_handler
$parsed_array['comments_raw'] = substr($old_ra_header_data, 69, $parsed_array['header_size'] - 69 + 16);
$comment_offset = 0;
-
+
foreach (array ('title', 'artist', 'copyright') as $name) {
$comment_length = getid3_lib::BigEndian2Int($parsed_array['comments_raw']{$comment_offset++});
$parsed_array['comments'][$name][]= substr($parsed_array['comments_raw'], $comment_offset, $comment_length);
@@ -507,7 +507,7 @@ class getid3_real extends getid3_handler
case 5:
-
+
getid3_lib::ReadSequence('BigEndian2Int', $parsed_array, $old_ra_header_data, 48,
array (
'sample_rate' => 4,
@@ -520,15 +520,15 @@ class getid3_real extends getid3_handler
);
$parsed_array['comments'] = array ();
break;
-
+
}
-
+
$parsed_array['fourcc'] = $parsed_array['fourcc3'];
}
foreach ($parsed_array['comments'] as $key => $value) {
-
+
if ($parsed_array['comments'][$key][0] === false) {
$parsed_array['comments'][$key][0] = '';
}
@@ -541,11 +541,11 @@ class getid3_real extends getid3_handler
public static function RealAudioCodecFourCClookup($fourcc, $bitrate) {
- // http://www.its.msstate.edu/net/real/reports/config/tags.stats
+ // http://www.its.msstate.edu/net/real/reports/config/tags.stats
// http://www.freelists.org/archives/matroska-devel/06-2003/fullthread18.html
-
+
static $lookup;
-
+
if (empty($lookup)) {
$lookup['14_4'][8000] = 'RealAudio v2 (14.4kbps)';
$lookup['14.4'][8000] = 'RealAudio v2 (14.4kbps)';
@@ -572,17 +572,17 @@ class getid3_real extends getid3_handler
$lookup['cook'][0] = 'RealAudio G2';
$lookup['atrc'][0] = 'RealAudio 8';
}
-
+
$round_bitrate = intval(round($bitrate));
-
+
if (isset($lookup[$fourcc][$round_bitrate])) {
return $lookup[$fourcc][$round_bitrate];
}
-
+
if (isset($lookup[$fourcc][0])) {
return $lookup[$fourcc][0];
}
-
+
return $fourcc;
}
diff --git a/modules/getid3/module.audio-video.riff.php b/modules/getid3/module.audio-video.riff.php
index 5cecd67c..6da6b3bf 100644
--- a/modules/getid3/module.audio-video.riff.php
+++ b/modules/getid3/module.audio-video.riff.php
@@ -26,8 +26,8 @@
//
// $Id: module.audio-video.riff.php,v 1.10 2006/12/03 20:13:17 ah Exp $
-
-
+
+
class getid3_riff extends getid3_handler
{
@@ -35,7 +35,7 @@ class getid3_riff extends getid3_handler
public function Analyze() {
-
+
$getid3 = $this->getid3;
$getid3->info['riff']['raw'] = array ();
@@ -53,11 +53,11 @@ class getid3_riff extends getid3_handler
$this->fseek($info_avdataoffset, SEEK_SET);
$riff_header = $this->fread(12);
-
+
$riff_sub_type = substr($riff_header, 8, 4);
-
+
switch (substr($riff_header, 0, 4)) {
-
+
case 'FORM':
$getid3->info['fileformat'] = 'aiff';
$this->endian_function = 'BigEndian2Int';
@@ -89,18 +89,18 @@ class getid3_riff extends getid3_handler
default:
throw new getid3_exception('Cannot parse RIFF (this is maybe not a RIFF / WAV / AVI file?) - expecting "FORM|RIFF|SDSS|RMP3" found "'.$riff_sub_type.'" instead');
}
-
+
$endian_function = $this->endian_function;
$stream_index = 0;
switch ($riff_sub_type) {
case 'WAVE':
-
+
if (empty($info_audio['bitrate_mode'])) {
$info_audio['bitrate_mode'] = 'cbr';
}
-
+
if (empty($info_audio_dataformat)) {
$info_audio_dataformat = 'wav';
}
@@ -109,9 +109,9 @@ class getid3_riff extends getid3_handler
$info_avdataoffset = $info_riff_wave['data'][0]['offset'] + 8;
$info_avdataend = $info_avdataoffset + $info_riff_wave['data'][0]['size'];
}
-
+
if (isset($info_riff_wave['fmt '][0]['data'])) {
-
+
$info_riff_audio[$stream_index] = getid3_riff::RIFFparseWAVEFORMATex($info_riff_wave['fmt '][0]['data']);
$info_audio['wformattag'] = $info_riff_audio[$stream_index]['raw']['wFormatTag'];
$info_riff_raw['fmt '] = $info_riff_audio[$stream_index]['raw'];
@@ -125,11 +125,11 @@ class getid3_riff extends getid3_handler
$info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate'];
$getid3->info['playtime_seconds'] = (float)((($info_avdataend - $info_avdataoffset) * 8) / $info_audio['bitrate']);
-
+
$info_audio['lossless'] = false;
if (isset($info_riff_wave['data'][0]['offset']) && isset($info_riff_raw['fmt ']['wFormatTag'])) {
-
+
switch ($info_riff_raw['fmt ']['wFormatTag']) {
case 0x0001: // PCM
@@ -146,7 +146,7 @@ class getid3_riff extends getid3_handler
}
}
-
+
$info_audio['streams'][$stream_index]['wformattag'] = $info_audio['wformattag'];
$info_audio['streams'][$stream_index]['bitrate_mode'] = $info_audio['bitrate_mode'];
$info_audio['streams'][$stream_index]['lossless'] = $info_audio['lossless'];
@@ -169,7 +169,7 @@ class getid3_riff extends getid3_handler
$n_track_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nRadioRgAdjust']), 16, '0', STR_PAD_LEFT);
$n_album_rg_adjust_bit_string = str_pad(decbin($info_riff_raw_rgad['nAudiophileRgAdjust']), 16, '0', STR_PAD_LEFT);
-
+
$info_riff_raw_rgad_track['name'] = bindec(substr($n_track_rg_adjust_bit_string, 0, 3));
$info_riff_raw_rgad_track['originator'] = bindec(substr($n_track_rg_adjust_bit_string, 3, 3));
$info_riff_raw_rgad_track['signbit'] = bindec($n_track_rg_adjust_bit_string[6]);
@@ -185,7 +185,7 @@ class getid3_riff extends getid3_handler
$info_riff['rgad']['track']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_track['originator']);
$info_riff['rgad']['track']['adjustment'] = getid3_lib_replaygain::AdjustmentLookup($info_riff_raw_rgad_track['adjustment'], $info_riff_raw_rgad_track['signbit']);
}
-
+
if (($info_riff_raw_rgad_album['name'] != 0) && ($info_riff_raw_rgad_album['originator'] != 0)) {
$info_riff['rgad']['album']['name'] = getid3_lib_replaygain::NameLookup($info_riff_raw_rgad_album['name']);
$info_riff['rgad']['album']['originator'] = getid3_lib_replaygain::OriginatorLookup($info_riff_raw_rgad_album['originator']);
@@ -194,7 +194,7 @@ class getid3_riff extends getid3_handler
}
if (isset($info_riff_wave['fact'][0]['data'])) {
-
+
$info_riff_raw['fact']['NumberOfSamples'] = getid3_lib::$endian_function(substr($info_riff_wave['fact'][0]['data'], 0, 4));
// This should be a good way of calculating exact playtime, but some sample files have had incorrect number of samples, so cannot use this method
@@ -202,14 +202,14 @@ class getid3_riff extends getid3_handler
// $getid3->info['playtime_seconds'] = (float)$info_riff_raw['fact']['NumberOfSamples'] / $info_riff_raw['fmt ']['nSamplesPerSec'];
// }
}
-
-
+
+
if (!empty($info_riff_raw['fmt ']['nAvgBytesPerSec'])) {
$info_audio['bitrate'] = (int)$info_riff_raw['fmt ']['nAvgBytesPerSec'] * 8;
}
if (isset($info_riff_wave['bext'][0]['data'])) {
-
+
$info_riff_wave_bext_0 = &$info_riff_wave['bext'][0];
getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_wave_bext_0, $info_riff_wave_bext_0['data'], 0,
@@ -224,11 +224,11 @@ class getid3_riff extends getid3_handler
'reserved' => 254
)
);
-
+
foreach (array ('title', 'author', 'reference') as $key) {
$info_riff_wave_bext_0[$key] = trim($info_riff_wave_bext_0[$key]);
}
-
+
$info_riff_wave_bext_0['coding_history'] = explode("\r\n", trim(substr($info_riff_wave_bext_0['data'], 601)));
$info_riff_wave_bext_0['origin_date_unix'] = gmmktime(substr($info_riff_wave_bext_0['origin_time'], 0, 2),
@@ -243,7 +243,7 @@ class getid3_riff extends getid3_handler
}
if (isset($info_riff_wave['MEXT'][0]['data'])) {
-
+
$info_riff_wave_mext_0 = &$info_riff_wave['MEXT'][0];
$info_riff_wave_mext_0['raw']['sound_information'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_mext_0['data'], 0, 2));
@@ -263,7 +263,7 @@ class getid3_riff extends getid3_handler
}
if (isset($info_riff_wave['cart'][0]['data'])) {
-
+
$info_riff_wave_cart_0 = &$info_riff_wave['cart'][0];
getid3_lib::ReadSequence('LittleEndian2Int', $info_riff_wave_cart_0, $info_riff_wave_cart_0['data'], 0,
@@ -285,23 +285,23 @@ class getid3_riff extends getid3_handler
'user_defined_text' => -64,
)
);
-
+
foreach (array ('artist', 'cut_id', 'client_id', 'category', 'classification', 'out_cue', 'start_date', 'start_time', 'end_date', 'end_time', 'producer_app_id', 'producer_app_version', 'user_defined_text') as $key) {
$info_riff_wave_cart_0[$key] = trim($info_riff_wave_cart_0[$key]);
}
-
+
$info_riff_wave_cart_0['zero_db_reference'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_cart_0['data'], 680, 4), true);
-
+
for ($i = 0; $i < 8; $i++) {
$info_riff_wave_cart_0['post_time'][$i]['usage_fourcc'] = substr($info_riff_wave_cart_0['data'], 684 + ($i * 8), 4);
$info_riff_wave_cart_0['post_time'][$i]['timer_value'] = getid3_lib::LittleEndian2Int(substr($info_riff_wave_cart_0['data'], 684 + ($i * 8) + 4, 4));
- }
+ }
$info_riff_wave_cart_0['url'] = trim(substr($info_riff_wave_cart_0['data'], 748, 1024));
$info_riff_wave_cart_0['tag_text'] = explode("\r\n", trim(substr($info_riff_wave_cart_0['data'], 1772)));
-
+
$info_riff['comments']['artist'][] = $info_riff_wave_cart_0['artist'];
$info_riff['comments']['title'][] = $info_riff_wave_cart_0['title'];
- }
+ }
if (!isset($info_audio['bitrate']) && isset($info_riff_audio[$stream_index]['bitrate'])) {
$info_audio['bitrate'] = $info_riff_audio[$stream_index]['bitrate'];
@@ -309,28 +309,28 @@ class getid3_riff extends getid3_handler
}
if (@$getid3->info['wavpack']) {
-
+
if (!$this->data_string_flag) {
-
+
$info_audio_dataformat = 'wavpack';
$info_audio['bitrate_mode'] = 'vbr';
$info_audio['encoder'] = 'WavPack v'.$getid3->info['wavpack']['version'];
-
+
// Reset to the way it was - RIFF parsing will have messed this up
$info_avdataend = $original['avdataend'];
$info_audio['bitrate'] = (($info_avdataend - $info_avdataoffset) * 8) / $getid3->info['playtime_seconds'];
-
+
$this->fseek($info_avdataoffset - 44, SEEK_SET);
$riff_data = $this->fread(44);
$orignal_riff_header_size = getid3_lib::LittleEndian2Int(substr($riff_data, 4, 4)) + 8;
$orignal_riff_data_size = getid3_lib::LittleEndian2Int(substr($riff_data, 40, 4)) + 44;
-
+
if ($orignal_riff_header_size > $orignal_riff_data_size) {
$info_avdataend -= ($orignal_riff_header_size - $orignal_riff_data_size);
$this->fseek($info_avdataend, SEEK_SET);
$riff_data .= $this->fread($orignal_riff_header_size - $orignal_riff_data_size);
}
-
+
// move the data chunk after all other chunks (if any)
// so that the RIFF parser doesn't see EOF when trying
// to skip over the data chunk
@@ -339,18 +339,18 @@ class getid3_riff extends getid3_handler
// Save audio info key
$saved_info_audio = $info_audio;
- // Analyze riff_data
+ // Analyze riff_data
$this->AnalyzeString($riff_data);
-
+
// Restore info key
$info_audio = $saved_info_audio;
}
}
if (isset($info_riff_raw['fmt ']['wFormatTag'])) {
-
+
switch ($info_riff_raw['fmt ']['wFormatTag']) {
-
+
case 0x08AE: // ClearJump LiteWave
$info_audio['bitrate_mode'] = 'vbr';
$info_audio_dataformat = 'litewave';
@@ -436,7 +436,7 @@ class getid3_riff extends getid3_handler
$getid3->warning('File should probably be padded to nearest WORD boundary, but it is not (expecting '.$info_riff[$riff_sub_type]['data'][0]['size'].' bytes of data, only found '.($getid3->info['filesize'] - $info_avdataoffset).' therefore short by '.($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] - $info_avdataoffset)).' bytes)');
$info_avdataend = $getid3->info['filesize'];
break;
-
+
}
// Short by more than one byte, throw warning
$getid3->warning('Probably truncated file - expecting '.$info_riff[$riff_sub_type]['data'][0]['size'].' bytes of data, only found '.($getid3->info['filesize'] - $info_avdataoffset).' (short by '.($info_riff[$riff_sub_type]['data'][0]['size'] - ($getid3->info['filesize'] - $info_avdataoffset)).' bytes)');
@@ -444,14 +444,14 @@ class getid3_riff extends getid3_handler
break;
}
}
-
+
if (!empty($getid3->info['mpeg']['audio']['LAME']['audio_bytes'])) {
if ((($info_avdataend - $info_avdataoffset) - $getid3->info['mpeg']['audio']['LAME']['audio_bytes']) == 1) {
$info_avdataend--;
$getid3->warning('Extra null byte at end of MP3 data assumed to be RIFF padding and therefore ignored');
}
}
-
+
if (@$info_audio_dataformat == 'ac3') {
unset($info_audio['bits_per_sample']);
if (!empty($getid3->info['ac3']['bitrate']) && ($getid3->info['ac3']['bitrate'] != $info_audio['bitrate'])) {
@@ -480,8 +480,8 @@ class getid3_riff extends getid3_handler
$info_riff_raw['avih'] = array ();
$info_riff_raw_avih = &$info_riff_raw['avih'];
-
- getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_avih, $avihData, 0,
+
+ getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_avih, $avihData, 0,
array (
'dwMicroSecPerFrame' => 4, // frame display rate (or 0L)
'dwMaxBytesPerSec' => 4, // max. transfer rate
@@ -514,12 +514,12 @@ class getid3_riff extends getid3_handler
$info_riff_video_current['frame_width'] = $info_riff_raw_avih['dwWidth'];
$info_video['resolution_x'] = $info_riff_video_current['frame_width'];
}
-
+
if ($info_riff_raw_avih['dwHeight'] > 0) {
$info_riff_video_current['frame_height'] = $info_riff_raw_avih['dwHeight'];
$info_video['resolution_y'] = $info_riff_video_current['frame_height'];
}
-
+
if ($info_riff_raw_avih['dwTotalFrames'] > 0) {
$info_riff_video_current['total_frames'] = $info_riff_raw_avih['dwTotalFrames'];
$info_video['total_frames'] = $info_riff_video_current['total_frames'];
@@ -528,7 +528,7 @@ class getid3_riff extends getid3_handler
$info_riff_video_current['frame_rate'] = round(1000000 / $info_riff_raw_avih['dwMicroSecPerFrame'], 3);
$info_video['frame_rate'] = $info_riff_video_current['frame_rate'];
}
-
+
if (isset($info_riff['AVI ']['hdrl']['strl']['strh'][0]['data'])) {
if (is_array($info_riff['AVI ']['hdrl']['strl']['strh'])) {
for ($i = 0; $i < count($info_riff['AVI ']['hdrl']['strl']['strh']); $i++) {
@@ -571,7 +571,7 @@ class getid3_riff extends getid3_handler
$info_audio['lossless'] = false;
switch ($info_riff_raw_strf_strh_fcc_type_stream_index['wFormatTag']) {
-
+
case 0x0001: // PCM
$info_audio_dataformat = 'wav';
$info_audio['lossless'] = true;
@@ -618,8 +618,8 @@ class getid3_riff extends getid3_handler
// shortcut
$info_riff_raw['strh'][$i] = array ();
$info_riff_raw_strh_current = &$info_riff_raw['strh'][$i];
-
- getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_strh_current, $strh_data, 0,
+
+ getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_strh_current, $strh_data, 0,
array (
'fccType' => -4, // same as $strh_fcc_type;
'fccHandler' => -4,
@@ -640,17 +640,17 @@ class getid3_riff extends getid3_handler
$info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strh_current['fccHandler']);
$info_video['fourcc'] = $info_riff_raw_strh_current['fccHandler'];
-
+
if (!$info_riff_video_current['codec'] && isset($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) && getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'])) {
$info_riff_video_current['codec'] = getid3_riff::RIFFfourccLookup($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']);
$info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'];
}
-
+
$info_video['codec'] = $info_riff_video_current['codec'];
$info_video['pixel_aspect_ratio'] = (float)1;
-
+
switch ($info_riff_raw_strh_current['fccHandler']) {
-
+
case 'HFYU': // Huffman Lossless Codec
case 'IRAW': // Intel YUV Uncompressed
case 'YUY2': // Uncompressed YUV 4:2:2
@@ -663,7 +663,7 @@ class getid3_riff extends getid3_handler
}
switch ($strh_fcc_type) {
-
+
case 'vids':
getid3_lib::ReadSequence($this->endian_function, $info_riff_raw_strf_strh_fcc_type_stream_index, $strf_data, 0,
array (
@@ -709,7 +709,7 @@ class getid3_riff extends getid3_handler
$info_video['fourcc'] = $info_riff_raw_strf_strh_fcc_type_stream_index['fourcc'];
switch ($info_riff_raw_strf_strh_fcc_type_stream_index['fourcc']) {
-
+
case 'HFYU': // Huffman Lossless Codec
case 'IRAW': // Intel YUV Uncompressed
case 'YUY2': // Uncompressed YUV 4:2:2
@@ -739,10 +739,10 @@ class getid3_riff extends getid3_handler
$info_avdataoffset = 44;
if (isset($info_riff['CDDA']['fmt '][0]['data'])) {
-
+
$info_riff_cdda_fmt_0 = &$info_riff['CDDA']['fmt '][0];
- getid3_lib::ReadSequence($this->endian_function, $info_riff_cdda_fmt_0, $info_riff_cdda_fmt_0['data'], 0,
+ getid3_lib::ReadSequence($this->endian_function, $info_riff_cdda_fmt_0, $info_riff_cdda_fmt_0['data'], 0,
array (
'unknown1' => 2,
'track_num' => 2,
@@ -804,9 +804,9 @@ class getid3_riff extends getid3_handler
$info_riff_audio['codec_fourcc'] = substr($info_riff_RIFFsubtype_COMM_0_data, 18, 4);
$codec_name_size = getid3_lib::BigEndian2Int(substr($info_riff_RIFFsubtype_COMM_0_data, 22, 1));
$info_riff_audio['codec_name'] = substr($info_riff_RIFFsubtype_COMM_0_data, 23, $codec_name_size);
-
+
switch ($info_riff_audio['codec_name']) {
-
+
case 'NONE':
$info_audio['codec'] = 'Pulse Code Modulation (PCM)';
$info_audio['lossless'] = true;
@@ -814,7 +814,7 @@ class getid3_riff extends getid3_handler
case '':
switch ($info_riff_audio['codec_fourcc']) {
-
+
// http://developer.apple.com/qa/snd/snd07.html
case 'sowt':
$info_riff_audio['codec_name'] = 'Two\'s Compliment Little-Endian PCM';
@@ -839,31 +839,31 @@ class getid3_riff extends getid3_handler
}
$info_audio['channels'] = $info_riff_audio['channels'];
-
+
if ($info_riff_audio['bits_per_sample'] > 0) {
$info_audio['bits_per_sample'] = $info_riff_audio['bits_per_sample'];
}
-
+
$info_audio['sample_rate'] = $info_riff_audio['sample_rate'];
$getid3->info['playtime_seconds'] = $info_riff_audio['total_samples'] / $info_audio['sample_rate'];
}
if (isset($info_riff[$riff_sub_type]['COMT'])) {
-
+
$comment_count = getid3_lib::BigEndian2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], 0, 2));
$offset = 2;
-
+
for ($i = 0; $i < $comment_count; $i++) {
-
+
$getid3->info['comments_raw'][$i]['timestamp'] = getid3_lib::BigEndian2Int( substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 4));
- $offset += 4;
-
+ $offset += 4;
+
$getid3->info['comments_raw'][$i]['marker_id'] = getid3_lib::BigEndianSyncSafe2Int(substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2));
- $offset += 2;
-
+ $offset += 2;
+
$comment_length = getid3_lib::BigEndian2Int( substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, 2));
- $offset += 2;
-
+ $offset += 2;
+
$getid3->info['comments_raw'][$i]['comment'] = substr($info_riff[$riff_sub_type]['COMT'][0]['data'], $offset, $comment_length);
$offset += $comment_length;
@@ -899,7 +899,7 @@ class getid3_riff extends getid3_handler
// shortcut
$info_riff_riff_sub_type_vhdr_0 = &$info_riff[$riff_sub_type]['VHDR'][0];
- getid3_lib::ReadSequence('BigEndian2Int', $info_riff_riff_sub_type_vhdr_0, $info_riff_riff_sub_type_vhdr_0['data'], 0,
+ getid3_lib::ReadSequence('BigEndian2Int', $info_riff_riff_sub_type_vhdr_0, $info_riff_riff_sub_type_vhdr_0['data'], 0,
array (
'oneShotHiSamples' => 4,
'repeatHiSamples' => 4,
@@ -910,7 +910,7 @@ class getid3_riff extends getid3_handler
'Volume' => -4
)
);
-
+
$info_riff_riff_sub_type_vhdr_0['Volume'] = getid3_riff::FixedPoint16_16($info_riff_riff_sub_type_vhdr_0['Volume']);
$info_audio['sample_rate'] = $info_riff_riff_sub_type_vhdr_0['samplesPerSec'];
@@ -967,25 +967,25 @@ class getid3_riff extends getid3_handler
case 'CDXA':
-
+
$getid3->info['mime_type'] = 'video/mpeg';
if (!empty($info_riff['CDXA']['data'][0]['size'])) {
$GETID3_ERRORARRAY = &$getid3->info['warning'];
-
+
if (!$getid3->include_module_optional('audio-video.mpeg')) {
$getid3->warning('MPEG skipped because mpeg module is missing.');
}
-
+
else {
-
+
// Clone getid3 - messing with offsets - better safe than sorry
$clone = clone $getid3;
-
+
// Analyse
$mpeg = new getid3_mpeg($clone);
$mpeg->Analyze();
- // Import from clone and destroy
+ // Import from clone and destroy
$getid3->info['audio'] = $clone->info['audio'];
$getid3->info['video'] = $clone->info['video'];
$getid3->info['mpeg'] = $clone->info['mpeg'];
@@ -994,26 +994,26 @@ class getid3_riff extends getid3_handler
unset($clone);
}
}
-
+
break;
default:
throw new getid3_exception('Unknown RIFF type: expecting one of (WAVE|RMP3|AVI |CDDA|AIFF|AIFC|8SVX|CDXA), found "'.$riff_sub_type.'" instead');
}
-
-
+
+
if (@$info_riff_raw['fmt ']['wFormatTag'] == 1) {
-
+
// http://www.mega-nerd.com/erikd/Blog/Windiots/dts.html
$this->fseek($getid3->info['avdataoffset'], SEEK_SET);
$bytes4 = $this->fread(4);
-
+
// DTSWAV
if (preg_match('/^\xFF\x1F\x00\xE8/s', $bytes4)) {
$info_audio_dataformat = 'dts';
- }
-
+ }
+
// DTS, but this probably shouldn't happen
elseif (preg_match('/^\x7F\xFF\x80\x01/s', $bytes4)) {
$info_audio_dataformat = 'dts';
@@ -1023,13 +1023,13 @@ class getid3_riff extends getid3_handler
if (@is_array($info_riff_wave['DISP'])) {
$info_riff['comments']['title'][] = trim(substr($info_riff_wave['DISP'][count($info_riff_wave['DISP']) - 1]['data'], 4));
}
-
+
if (@is_array($info_riff_wave['INFO'])) {
getid3_riff::RIFFCommentsParse($info_riff_wave['INFO'], $info_riff['comments']);
}
-
+
if (isset($info_riff_wave['INFO']) && is_array($info_riff_wave['INFO'])) {
-
+
foreach (array ('IARL' => 'archivallocation', 'IART' => 'artist', 'ICDS' => 'costumedesigner', 'ICMS' => 'commissionedby', 'ICMT' => 'comment', 'ICNT' => 'country', 'ICOP' => 'copyright', 'ICRD' => 'creationdate', 'IDIM' => 'dimensions', 'IDIT' => 'digitizationdate', 'IDPI' => 'resolution', 'IDST' => 'distributor', 'IEDT' => 'editor', 'IENG' => 'engineers', 'IFRM' => 'accountofparts', 'IGNR' => 'genre', 'IKEY' => 'keywords', 'ILGT' => 'lightness', 'ILNG' => 'language', 'IMED' => 'orignalmedium', 'IMUS' => 'composer', 'INAM' => 'title', 'IPDS' => 'productiondesigner', 'IPLT' => 'palette', 'IPRD' => 'product', 'IPRO' => 'producer', 'IPRT' => 'part', 'IRTD' => 'rating', 'ISBJ' => 'subject', 'ISFT' => 'software', 'ISGN' => 'secondarygenre', 'ISHP' => 'sharpness', 'ISRC' => 'sourcesupplier', 'ISRF' => 'digitizationsource', 'ISTD' => 'productionstudio', 'ISTR' => 'starring', 'ITCH' => 'encoded_by', 'IWEB' => 'url', 'IWRI' => 'writer') as $key => $value) {
if (isset($info_riff_wave['INFO'][$key])) {
foreach ($info_riff_wave['INFO'][$key] as $comment_id => $comment_data) {
@@ -1157,34 +1157,34 @@ class getid3_riff extends getid3_handler
public function ParseRIFF($start_offset, $max_offset) {
-
+
$getid3 = $this->getid3;
-
+
$info = &$getid3->info;
-
+
$endian_function = $this->endian_function;
$max_offset = min($max_offset, $info['avdataend']);
-
+
$riff_chunk = false;
$this->fseek($start_offset, SEEK_SET);
-
+
while ($this->ftell() < $max_offset) {
-
+
$chunk_name = $this->fread(4);
-
+
if (strlen($chunk_name) < 4) {
throw new getid3_exception('Expecting chunk name at offset '.($this->ftell() - 4).' but found nothing. Aborting RIFF parsing.');
}
-
+
$chunk_size = getid3_lib::$endian_function($this->fread(4));
-
+
if ($chunk_size == 0) {
continue;
throw new getid3_exception('Chunk size at offset '.($this->ftell() - 4).' is zero. Aborting RIFF parsing.');
}
-
+
if (($chunk_size % 2) != 0) {
// all structures are packed on word boundaries
$chunk_size++;
@@ -1194,16 +1194,16 @@ class getid3_riff extends getid3_handler
case 'LIST':
$list_name = $this->fread(4);
-
+
switch ($list_name) {
-
+
case 'movi':
case 'rec ':
$riff_chunk[$list_name]['offset'] = $this->ftell() - 4;
$riff_chunk[$list_name]['size'] = $chunk_size;
static $parsed_audio_stream = false;
-
+
if (!$parsed_audio_stream) {
$where_we_were = $this->ftell();
$audio_chunk_header = $this->fread(12);
@@ -1214,62 +1214,62 @@ class getid3_riff extends getid3_handler
if ($audio_chunk_stream_type == 'wb') {
$first_four_bytes = substr($audio_chunk_header, 8, 4);
-
+
//// MPEG
-
+
if (preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', $first_four_bytes)) {
if (!$getid3->include_module_optional('audio.mp3')) {
$getid3->warning('MP3 skipped because mp3 module is missing.');
}
-
+
elseif (getid3_mp3::MPEGaudioHeaderBytesValid($first_four_bytes)) {
-
+
// Clone getid3 - messing with offsets - better safe than sorry
$clone = clone $getid3;
$clone->info['avdataoffset'] = $this->ftell() - 4;
$clone->info['avdataend'] = $this->ftell() + $audio_chunk_size;
-
+
$mp3 = new getid3_mp3($clone);
$mp3->AnalyzeMPEGaudioInfo();
-
+
// Import from clone and destroy
if (isset($clone->info['mpeg']['audio'])) {
-
+
$info['mpeg']['audio'] = $clone->info['mpeg']['audio'];
-
+
$info['audio']['dataformat'] = 'mp'.$info['mpeg']['audio']['layer'];
$info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
$info['audio']['channels'] = $info['mpeg']['audio']['channels'];
$info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
$info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
$info['bitrate'] = $info['audio']['bitrate'];
-
+
$getid3->warning($clone->warnings());
unset($clone);
}
}
- }
-
+ }
+
//// AC3-WAVE
-
+
elseif (preg_match('/^\x0B\x77/s', $first_four_bytes)) {
if (!$getid3->include_module_optional('audio.ac3')) {
$getid3->warning('AC3 skipped because ac3 module is missing.');
}
-
+
else {
-
+
// Clone getid3 - messing with offsets - better safe than sorry
$clone = clone $getid3;
- $clone->info['avdataoffset'] = $this->ftell() - 4;
+ $clone->info['avdataoffset'] = $this->ftell() - 4;
$clone->info['avdataend'] = $this->ftell() + $audio_chunk_size;
-
+
// Analyze clone by fp
$ac3 = new getid3_ac3($clone);
$ac3->Analyze();
-
+
// Import from clone and destroy
$info['audio'] = $clone->info['audio'];
$info['ac3'] = $clone->info['ac3'];
@@ -1301,7 +1301,7 @@ class getid3_riff extends getid3_handler
default:
-
+
$this_index = 0;
if (isset($riff_chunk[$chunk_name]) && is_array($riff_chunk[$chunk_name])) {
$this_index = count($riff_chunk[$chunk_name]);
@@ -1319,33 +1319,33 @@ class getid3_riff extends getid3_handler
//// This is probably MP3 data
if ((strlen($riff_data_chunk_contents_test) > 0) && preg_match('/^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]/s', substr($riff_data_chunk_contents_test, 0, 4))) {
-
+
try {
-
+
if (!$getid3->include_module_optional('audio.mp3')) {
$getid3->warning('MP3 skipped because mp3 module is missing.');
}
-
-
+
+
// Clone getid3 - messing with offsets - better safe than sorry
$clone = clone $getid3;
-
+
if (getid3_mp3::MPEGaudioHeaderBytesValid(substr($riff_data_chunk_contents_test, 0, 4))) {
-
+
$mp3 = new getid3_mp3($clone);
$mp3->AnalyzeMPEGaudioInfo();
-
+
// Import from clone and destroy
if (isset($clone->info['mpeg']['audio'])) {
-
+
$info['mpeg']['audio'] = $clone->info['mpeg']['audio'];
-
+
$info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
$info['audio']['channels'] = $info['mpeg']['audio']['channels'];
$info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
$info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
$info['bitrate'] = $info['audio']['bitrate'];
-
+
$getid3->warning($clone->warnings());
unset($clone);
}
@@ -1354,66 +1354,66 @@ class getid3_riff extends getid3_handler
catch (Exception $e) {
// do nothing - not MP3 data
}
- }
-
-
+ }
+
+
//// This is probably AC-3 data
-
+
elseif ((strlen($riff_data_chunk_contents_test) > 0) && (substr($riff_data_chunk_contents_test, 0, 2) == "\x0B\x77")) {
if (!$getid3->include_module_optional('audio.ac3')) {
$getid3->warning('AC3 skipped because ac3 module is missing.');
}
-
+
else {
// Clone getid3 - messing with offsets - better safe than sorry
$clone = clone $getid3;
$clone->info['avdataoffset'] = $riff_chunk[$chunk_name][$this_index]['offset'];
$clone->info['avdataend'] = $clone->info['avdataoffset'] + $riff_chunk[$chunk_name][$this_index]['size'];
-
+
// Analyze clone by fp
$ac3 = new getid3_ac3($clone);
$ac3->Analyze();
-
+
// Import from clone and destroy
$info['audio'] = $clone->info['audio'];
$info['ac3'] = $clone->info['ac3'];
$getid3->warning($clone->warnings());
unset($clone);
}
- }
-
-
+ }
+
+
// Dolby Digital WAV
// AC-3 content, but not encoded in same format as normal AC-3 file
// For one thing, byte order is swapped
-
+
elseif ((strlen($riff_data_chunk_contents_test) > 0) && (substr($riff_data_chunk_contents_test, 8, 2) == "\x77\x0B")) {
if (!$getid3->include_module_optional('audio.ac3')) {
$getid3->warning('AC3 skipped because ac3 module is missing.');
}
-
+
else {
-
+
// Extract ac3 data to string
- $ac3_data = '';
+ $ac3_data = '';
for ($i = 0; $i < 28; $i += 2) {
// swap byte order
$ac3_data .= substr($riff_data_chunk_contents_test, 8 + $i + 1, 1);
$ac3_data .= substr($riff_data_chunk_contents_test, 8 + $i + 0, 1);
}
-
+
// Clone getid3 - messing with offsets - better safe than sorry
$clone = clone $getid3;
$clone->info['avdataoffset'] = 0;
$clone->info['avdataend'] = 20;
-
+
// Analyse clone by string
$ac3 = new getid3_ac3($clone);
$ac3->AnalyzeString($ac3_data);
-
+
// Import from clone and destroy
$info['audio'] = $clone->info['audio'];
$info['ac3'] = $clone->info['ac3'];
@@ -1422,7 +1422,7 @@ class getid3_riff extends getid3_handler
}
}
-
+
if ((strlen($riff_data_chunk_contents_test) > 0) && (substr($riff_data_chunk_contents_test, 0, 4) == 'wvpk')) {
// This is WavPack data
@@ -1481,7 +1481,7 @@ class getid3_riff extends getid3_handler
private function RIFFparseWavPackHeader($wavpack3_chunk_data) {
-
+
// typedef struct {
// char ckID [4];
// long ckSize;
@@ -1496,13 +1496,13 @@ class getid3_riff extends getid3_handler
$info_wavpack = &$this->getid3->info['wavpack'];
$info_wavpack['version'] = getid3_lib::LittleEndian2Int(substr($wavpack3_chunk_data, 0, 2));
-
+
if ($info_wavpack['version'] >= 2) {
$info_wavpack['bits'] = getid3_lib::LittleEndian2Int(substr($wavpack3_chunk_data, 2, 2));
}
-
+
if ($info_wavpack['version'] >= 3) {
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_wavpack, $wavpack3_chunk_data, 4,
array (
'flags_raw' => 2,
@@ -1514,7 +1514,7 @@ class getid3_riff extends getid3_handler
'extra_bc' => 1
)
);
-
+
for ($i = 0; $i < 3; $i++) {
$info_wavpack['extras'][] = getid3_lib::LittleEndian2Int($wavpack3_chunk_data{25 + $i});
}
@@ -1546,27 +1546,27 @@ class getid3_riff extends getid3_handler
return true;
}
-
-
-
+
+
+
public function AnalyzeString(&$string) {
-
+
// Rewrite header_size in header
$new_header_size = getid3_lib::LittleEndian2String(strlen($string), 4);
for ($i = 0; $i < 4; $i++) {
$string{$i + 4} = $new_header_size{$i};
}
-
+
return parent::AnalyzeString($string);
}
-
+
public static function RIFFparseWAVEFORMATex($wave_format_ex_data) {
-
+
$wave_format_ex['raw'] = array ();
$wave_format_ex_raw = &$wave_format_ex['raw'];
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $wave_format_ex_raw, $wave_format_ex_data, 0,
array (
'wFormatTag' => 2,
@@ -1577,7 +1577,7 @@ class getid3_riff extends getid3_handler
'wBitsPerSample' => 2
)
);
-
+
if (strlen($wave_format_ex_data) > 16) {
$wave_format_ex_raw['cbSize'] = getid3_lib::LittleEndian2Int(substr($wave_format_ex_data, 16, 2));
}
@@ -1756,7 +1756,7 @@ class getid3_riff extends getid3_handler
0xFFFE => 'WAVE_FORMAT_EXTENSIBLE',
0xFFFF => 'WAVE_FORMAT_DEVELOPMENT'
);
-
+
return @$lookup[$w_format_tag];
}
@@ -2144,14 +2144,14 @@ class getid3_riff extends getid3_handler
'ZLIB' => 'Lossless Codec Library zlib compression (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm)',
'ZPEG' => 'Metheus Video Zipper'
);
-
+
return @$lookup[$four_cc];
}
public static function RIFFcommentsParse(&$riff_info_aray, &$comments_target_array) {
-
+
static $lookup = array(
'IARL' => 'archivallocation',
'IART' => 'artist',
@@ -2193,7 +2193,7 @@ class getid3_riff extends getid3_handler
'IWEB' => 'url',
'IWRI' => 'writer'
);
-
+
foreach ($lookup as $key => $value) {
if (isset($riff_info_aray[$key])) {
foreach ($riff_info_aray[$key] as $comment_id => $comment_data) {
@@ -2205,9 +2205,9 @@ class getid3_riff extends getid3_handler
}
return true;
}
-
-
-
+
+
+
public static function array_merge_noclobber($array1, $array2) {
if (!is_array($array1) || !is_array($array2)) {
return false;
@@ -2222,27 +2222,27 @@ class getid3_riff extends getid3_handler
}
return $new_array;
}
-
-
-
+
+
+
public static function DateMac2Unix($mac_date) {
-
+
// Macintosh timestamp: seconds since 00:00h January 1, 1904
// UNIX timestamp: seconds since 00:00h January 1, 1970
return (int)($mac_date - 2082844800);
}
-
-
-
+
+
+
public static function FixedPoint16_16($raw_data) {
-
+
return getid3_lib::BigEndian2Int(substr($raw_data, 0, 2)) + (float)(getid3_lib::BigEndian2Int(substr($raw_data, 2, 2)) / 65536); // pow(2, 16) = 65536
}
-
-
-
+
+
+
function BigEndian2Float($byte_word) {
-
+
// 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
diff --git a/modules/getid3/module.audio-video.swf.php b/modules/getid3/module.audio-video.swf.php
index 312a1a39..137dc85d 100644
--- a/modules/getid3/module.audio-video.swf.php
+++ b/modules/getid3/module.audio-video.swf.php
@@ -22,15 +22,15 @@
//
// $Id: module.audio-video.swf.php,v 1.2 2006/11/02 10:48:00 ah Exp $
-
-
+
+
class getid3_swf extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
-
+
$getid3->info['fileformat'] = 'swf';
$getid3->info['video']['dataformat'] = 'swf';
@@ -42,7 +42,7 @@ class getid3_swf extends getid3_handler
$getid3->info['swf']['header']['signature'] = substr($swf_file_data, 0, 3);
switch ($getid3->info['swf']['header']['signature']) {
-
+
case 'FWS':
$getid3->info['swf']['header']['compressed'] = false;
break;
@@ -75,11 +75,11 @@ class getid3_swf extends getid3_handler
$frame_size_bits_per_value = (ord(substr($swf_file_data, 8, 1)) & 0xF8) >> 3;
$frame_size_data_length = ceil((5 + (4 * $frame_size_bits_per_value)) / 8);
$frame_size_data_string = str_pad(decbin(ord($swf_file_data[8]) & 0x07), 3, '0', STR_PAD_LEFT);
-
+
for ($i = 1; $i < $frame_size_data_length; $i++) {
$frame_size_data_string .= str_pad(decbin(ord(substr($swf_file_data, 8 + $i, 1))), 8, '0', STR_PAD_LEFT);
}
-
+
list($x1, $x2, $y1, $y2) = explode("\n", wordwrap($frame_size_data_string, $frame_size_bits_per_value, "\n", 1));
$getid3->info['swf']['header']['frame_width'] = bindec($x2);
$getid3->info['swf']['header']['frame_height'] = bindec($y2);
@@ -126,7 +126,7 @@ class getid3_swf extends getid3_handler
$tag_data['id'] = $tag_ID;
$tag_data['data'] = substr($swf_file_data, $current_offset, $tag_length);
switch ($tag_ID) {
-
+
case 0: // end of movie
break 2;
diff --git a/modules/getid3/module.audio.aac_adif.php b/modules/getid3/module.audio.aac_adif.php
index 8f1a6853..9b2f72b6 100644
--- a/modules/getid3/module.audio.aac_adif.php
+++ b/modules/getid3/module.audio.aac_adif.php
@@ -22,14 +22,14 @@
//
// $Id: module.audio.aac_adif.php,v 1.3 2006/11/02 10:48:00 ah Exp $
-
-
+
+
class getid3_aac_adif extends getid3_handler
{
public function Analyze() {
- $getid3 = $this->getid3;
+ $getid3 = $this->getid3;
// http://faac.sourceforge.net/wiki/index.php?page=ADIF
// http://libmpeg.org/mpeg4/doc/w2203tfs.pdf
@@ -49,19 +49,19 @@ class getid3_aac_adif extends getid3_handler
// program_config_element()
// }
// }
-
+
$getid3->info['fileformat'] = 'aac';
$getid3->info['audio']['dataformat'] = 'aac';
$getid3->info['audio']['lossless'] = false;
-
+
$getid3->info['aac']['header'] = array () ;
$info_aac = &$getid3->info['aac'];
$info_aac_header = & $info_aac['header'];
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$aac_header_bitstream = getid3_lib::BigEndian2Bin(fread($getid3->fp, 1024));
-
+
$info_aac['header_type'] = 'ADIF';
$info_aac_header['mpeg_version'] = 4;
$bit_offset = 32;
@@ -71,7 +71,7 @@ class getid3_aac_adif extends getid3_handler
$info_aac_header['copyright_id'] = getid3_aac_adif::Bin2String(substr($aac_header_bitstream, $bit_offset, 72));
$bit_offset += 72;
}
-
+
$info_aac_header['original_copy'] = $aac_header_bitstream{$bit_offset++} == '1';
$info_aac_header['home'] = $aac_header_bitstream{$bit_offset++} == '1';
$info_aac_header['is_vbr'] = $aac_header_bitstream{$bit_offset++} == '1';
@@ -80,14 +80,14 @@ class getid3_aac_adif extends getid3_handler
$getid3->info['audio']['bitrate_mode'] = 'vbr';
$info_aac_header['bitrate_max'] = bindec(substr($aac_header_bitstream, $bit_offset, 23));
$bit_offset += 23;
- }
+ }
else {
$getid3->info['audio']['bitrate_mode'] = 'cbr';
$info_aac_header['bitrate'] = bindec(substr($aac_header_bitstream, $bit_offset, 23));
$bit_offset += 23;
$getid3->info['audio']['bitrate'] = $info_aac_header['bitrate'];
}
-
+
$info_aac_header['num_program_configs'] = 1 + bindec(substr($aac_header_bitstream, $bit_offset, 4));
$bit_offset += 4;
@@ -140,7 +140,7 @@ class getid3_aac_adif extends getid3_handler
// for (i = 0; i < comment_field_bytes; i++) {
// comment_field_data[i] 8
// }
-
+
$info_aac['program_configs'][$i] = array ();
$info_aac_program_configs_i = &$info_aac['program_configs'][$i];
@@ -148,7 +148,7 @@ class getid3_aac_adif extends getid3_handler
$info_aac_program_configs_i['buffer_fullness'] = bindec(substr($aac_header_bitstream, $bit_offset, 20));
$bit_offset += 20;
}
-
+
$info_aac_program_configs_i['element_instance_tag'] = bindec(substr($aac_header_bitstream, $bit_offset, 4));
$info_aac_program_configs_i['object_type'] = bindec(substr($aac_header_bitstream, $bit_offset + 4, 2));
$info_aac_program_configs_i['sampling_frequency_index'] = bindec(substr($aac_header_bitstream, $bit_offset + 6, 4));
@@ -159,26 +159,26 @@ class getid3_aac_adif extends getid3_handler
$info_aac_program_configs_i['num_assoc_data_elements'] = bindec(substr($aac_header_bitstream, $bit_offset + 24, 3));
$info_aac_program_configs_i['num_valid_cc_elements'] = bindec(substr($aac_header_bitstream, $bit_offset + 27, 4));
$bit_offset += 31;
-
+
$info_aac_program_configs_i['mono_mixdown_present'] = $aac_header_bitstream{$bit_offset++} == 1;
if ($info_aac_program_configs_i['mono_mixdown_present']) {
$info_aac_program_configs_i['mono_mixdown_element_number'] = bindec(substr($aac_header_bitstream, $bit_offset, 4));
$bit_offset += 4;
}
-
+
$info_aac_program_configs_i['stereo_mixdown_present'] = $aac_header_bitstream{$bit_offset++} == 1;
if ($info_aac_program_configs_i['stereo_mixdown_present']) {
$info_aac_program_configs_i['stereo_mixdown_element_number'] = bindec(substr($aac_header_bitstream, $bit_offset, 4));
$bit_offset += 4;
}
-
+
$info_aac_program_configs_i['matrix_mixdown_idx_present'] = $aac_header_bitstream{$bit_offset++} == 1;
if ($info_aac_program_configs_i['matrix_mixdown_idx_present']) {
$info_aac_program_configs_i['matrix_mixdown_idx'] = bindec(substr($aac_header_bitstream, $bit_offset, 2));
$bit_offset += 2;
$info_aac_program_configs_i['pseudo_surround_enable'] = $aac_header_bitstream{$bit_offset++} == 1;
}
-
+
for ($j = 0; $j < $info_aac_program_configs_i['num_front_channel_elements']; $j++) {
$info_aac_program_configs_i['front_element_is_cpe'][$j] = $aac_header_bitstream{$bit_offset++} == 1;
$info_aac_program_configs_i['front_element_tag_select'][$j] = bindec(substr($aac_header_bitstream, $bit_offset, 4));
@@ -212,19 +212,19 @@ class getid3_aac_adif extends getid3_handler
$info_aac_program_configs_i['comment_field_bytes'] = bindec(substr($aac_header_bitstream, $bit_offset, 8));
$bit_offset += 8;
-
+
$info_aac_program_configs_i['comment_field'] = getid3_aac_adif::Bin2String(substr($aac_header_bitstream, $bit_offset, 8 * $info_aac_program_configs_i['comment_field_bytes']));
$bit_offset += 8 * $info_aac_program_configs_i['comment_field_bytes'];
$info_aac_header['profile_text'] = getid3_aac_adif::AACprofileLookup($info_aac_program_configs_i['object_type'], $info_aac_header['mpeg_version']);
$info_aac_program_configs_i['sampling_frequency'] = $getid3->info['audio']['sample_rate'] = getid3_aac_adif::AACsampleRateLookup($info_aac_program_configs_i['sampling_frequency_index']);
$getid3->info['audio']['channels'] = getid3_aac_adif::AACchannelCountCalculate($info_aac_program_configs_i);
-
+
if ($info_aac_program_configs_i['comment_field']) {
$info_aac['comments'][] = $info_aac_program_configs_i['comment_field'];
}
}
-
+
$getid3->info['playtime_seconds'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['audio']['bitrate'];
$getid3->info['audio']['encoder_options'] = $info_aac['header_type'].' '.$info_aac_header['profile_text'];
@@ -242,11 +242,11 @@ class getid3_aac_adif extends getid3_handler
}
return $string;
}
-
-
-
+
+
+
public static function AACsampleRateLookup($samplerate_id) {
-
+
static $lookup = array (
0 => 96000,
1 => 88200,
@@ -271,14 +271,14 @@ class getid3_aac_adif extends getid3_handler
public static function AACprofileLookup($profile_id, $mpeg_version) {
-
+
static $lookup = array (
- 2 => array (
+ 2 => array (
0 => 'Main profile',
1 => 'Low Complexity profile (LC)',
2 => 'Scalable Sample Rate profile (SSR)',
3 => '(reserved)'
- ),
+ ),
4 => array (
0 => 'AAC_MAIN',
1 => 'AAC_LC',
@@ -292,17 +292,17 @@ class getid3_aac_adif extends getid3_handler
public static function AACchannelCountCalculate($program_configs) {
-
+
$channels = 0;
-
+
foreach (array ('front', 'side', 'back') as $placement) {
for ($i = 0; $i < $program_configs['num_'.$placement.'_channel_elements']; $i++) {
-
+
// Each element is channel pair (CPE = Channel Pair Element)
$channels += 1 + ($program_configs[$placement.'_element_is_cpe'][$i] ? 1 : 0);
}
}
-
+
return $channels + $program_configs['num_lfe_channel_elements'];
}
diff --git a/modules/getid3/module.audio.aac_adts.php b/modules/getid3/module.audio.aac_adts.php
index 1b98c4c6..bf252997 100644
--- a/modules/getid3/module.audio.aac_adts.php
+++ b/modules/getid3/module.audio.aac_adts.php
@@ -22,43 +22,43 @@
//
// $Id: module.audio.aac_adts.php,v 1.4 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_aac_adts extends getid3_handler
{
public $option_max_frames_to_scan = 1000000;
public $option_return_extended_info = false;
-
+
private $decbin_cache;
private $bitrate_cache;
-
+
public function __construct(getID3 $getid3) {
-
+
parent::__construct($getid3);
-
+
// Populate bindec_cache
for ($i = 0; $i < 256; $i++) {
$this->decbin_cache[chr($i)] = str_pad(decbin($i), 8, '0', STR_PAD_LEFT);
}
-
+
// Init cache
$this->bitrate_cache = array ();
-
+
// Fast scanning?
if (!$getid3->option_accurate_results) {
$this->option_max_frames_to_scan = 200;
$getid3->warning('option_accurate_results set to false - bitrate and playing time are not accurate.');
}
}
-
-
+
+
public function Analyze() {
-
+
$getid3 = $this->getid3;
// based loosely on code from AACfile by Jurgen Faul <jfaulØgmx.de>
@@ -97,7 +97,7 @@ class getid3_aac_adts extends getid3_handler
$byte_offset = $frame_number = 0;
while (true) {
-
+
// Breaks out when end-of-file encountered, or invalid data found,
// or MaxFramesToScan frames have been scanned
@@ -117,10 +117,10 @@ class getid3_aac_adts extends getid3_handler
for ($i = 0; $i < 10; $i++) {
$aac_header_bitstream .= $this->decbin_cache[$sub_string[$i]];
}
-
+
$sync_test = bindec(substr($aac_header_bitstream, 0, 12));
$bit_offset = 12;
-
+
if ($sync_test != 0x0FFF) {
throw new getid3_exception('Synch pattern (0x0FFF) not found at offset '.(ftell($getid3->fp) - 10).' (found 0x0'.strtoupper(dechex($sync_test)).' instead)');
}
@@ -130,8 +130,8 @@ class getid3_aac_adts extends getid3_handler
// MPEG-4: 20, // MPEG-2: 18
$bit_offset += $aac_header_bitstream[$bit_offset] ? 18 : 20;
- }
-
+ }
+
// Gather info for first frame only - this takes time to do 1000 times!
else {
@@ -143,30 +143,30 @@ class getid3_aac_adts extends getid3_handler
$info_aac_header['mpeg_version'] = $aac_header_bitstream{$bit_offset++} == '0' ? 4 : 2;
$info_aac_header['layer'] = bindec(substr($aac_header_bitstream, $bit_offset, 2));
$bit_offset += 2;
-
+
if ($info_aac_header['layer'] != 0) {
throw new getid3_exception('Layer error - expected 0x00, found 0x'.dechex($info_aac_header['layer']).' instead');
}
-
+
$info_aac_header['crc_present'] = $aac_header_bitstream{$bit_offset++} == '0' ? true : false;
-
+
$info_aac_header['profile_id'] = bindec(substr($aac_header_bitstream, $bit_offset, 2));
$bit_offset += 2;
-
+
$info_aac_header['profile_text'] = getid3_aac_adts::AACprofileLookup($info_aac_header['profile_id'], $info_aac_header['mpeg_version']);
$info_aac_header['sample_frequency_index'] = bindec(substr($aac_header_bitstream, $bit_offset, 4));
$bit_offset += 4;
-
+
$info_aac_header['sample_frequency'] = getid3_aac_adts::AACsampleRateLookup($info_aac_header['sample_frequency_index']);
-
+
$getid3->info['audio']['sample_rate'] = $info_aac_header['sample_frequency'];
$info_aac_header['private'] = $aac_header_bitstream{$bit_offset++} == 1;
-
+
$info_aac_header['channel_configuration'] = $getid3->info['audio']['channels'] = bindec(substr($aac_header_bitstream, $bit_offset, 3));
$bit_offset += 3;
-
+
$info_aac_header['original'] = $aac_header_bitstream{$bit_offset++} == 1;
$info_aac_header['home'] = $aac_header_bitstream{$bit_offset++} == 1;
@@ -194,12 +194,12 @@ class getid3_aac_adts extends getid3_handler
$info_aac[$frame_number]['aac_frame_length'] = $frame_length;
$bit_offset += 13;
-
+
$info_aac[$frame_number]['adts_buffer_fullness'] = bindec(substr($aac_header_bitstream, $bit_offset, 11));
$bit_offset += 11;
-
+
$getid3->info['audio']['bitrate_mode'] = ($info_aac[$frame_number]['adts_buffer_fullness'] == 0x07FF) ? 'vbr' : 'cbr';
-
+
$info_aac[$frame_number]['num_raw_data_blocks'] = bindec(substr($aac_header_bitstream, $bit_offset, 2));
$bit_offset += 2;
@@ -230,10 +230,10 @@ class getid3_aac_adts extends getid3_handler
}
}
-
-
+
+
public static function AACsampleRateLookup($samplerate_id) {
-
+
static $lookup = array (
0 => 96000,
1 => 88200,
@@ -258,14 +258,14 @@ class getid3_aac_adts extends getid3_handler
public static function AACprofileLookup($profile_id, $mpeg_version) {
-
+
static $lookup = array (
- 2 => array (
+ 2 => array (
0 => 'Main profile',
1 => 'Low Complexity profile (LC)',
2 => 'Scalable Sample Rate profile (SSR)',
3 => '(reserved)'
- ),
+ ),
4 => array (
0 => 'AAC_MAIN',
1 => 'AAC_LC',
diff --git a/modules/getid3/module.audio.ac3.php b/modules/getid3/module.audio.ac3.php
index a50c5163..53c31c92 100644
--- a/modules/getid3/module.audio.ac3.php
+++ b/modules/getid3/module.audio.ac3.php
@@ -22,15 +22,15 @@
//
// $Id: module.audio.ac3.php,v 1.3 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_ac3 extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
// http://www.atsc.org/standards/a_52a.pdf
$getid3->info['fileformat'] = 'ac3';
@@ -61,7 +61,7 @@ class getid3_ac3 extends getid3_handler
if ($info_ac3_raw['synchinfo']['synchword'] != "\x0B\x77") {
throw new getid3_exception('Expecting "\x0B\x77" at offset '.$getid3->info['avdataoffset'].', found \x'.strtoupper(dechex($ac3_header['syncinfo']{0})).'\x'.strtoupper(dechex($ac3_header['syncinfo']{1})).' instead');
- }
+ }
// syncinfo() {
@@ -117,7 +117,7 @@ class getid3_ac3 extends getid3_handler
break;
}
$getid3->info['audio']['channels'] = $info_ac3['num_channels'];
-
+
$offset = 11;
if ($info_ac3_raw_bsi['acmod'] & 0x01) {
@@ -159,7 +159,7 @@ class getid3_ac3 extends getid3_handler
if ($info_ac3_raw_bsi['compre_flag']) {
$info_ac3_raw_bsi['compr'] = bindec(substr($ac3_header['bsi'], $offset, 8));
$offset += 8;
-
+
$info_ac3['heavy_compression'] = getid3_ac3::AC3heavyCompression($info_ac3_raw_bsi['compr']);
}
@@ -173,7 +173,7 @@ class getid3_ac3 extends getid3_handler
if ($info_ac3_raw_bsi['audprodie']) {
$info_ac3_raw_bsi['mixlevel'] = bindec(substr($ac3_header['bsi'], $offset, 5));
$offset += 5;
-
+
$info_ac3_raw_bsi['roomtyp'] = bindec(substr($ac3_header['bsi'], $offset, 2));
$offset += 2;
@@ -191,14 +191,14 @@ class getid3_ac3 extends getid3_handler
// The value of 0 is reserved. The values of 1 to 31 are interpreted as -1 dB to -31 dB with respect to digital 100 percent.
$info_ac3_raw_bsi['dialnorm2'] = bindec(substr($ac3_header['bsi'], $offset, 5));
$offset += 5;
-
+
$info_ac3['dialogue_normalization2'] = '-'.$info_ac3_raw_bsi['dialnorm2'].'dB';
$info_ac3_raw_bsi['compre_flag2'] = $ac3_header['bsi']{$offset++} == '1';
if ($info_ac3_raw_bsi['compre_flag2']) {
$info_ac3_raw_bsi['compr2'] = bindec(substr($ac3_header['bsi'], $offset, 8));
$offset += 8;
-
+
$info_ac3['heavy_compression2'] = getid3_ac3::AC3heavyCompression($info_ac3_raw_bsi['compr2']);
}
@@ -212,7 +212,7 @@ class getid3_ac3 extends getid3_handler
if ($info_ac3_raw_bsi['audprodie2']) {
$info_ac3_raw_bsi['mixlevel2'] = bindec(substr($ac3_header['bsi'], $offset, 5));
$offset += 5;
-
+
$info_ac3_raw_bsi['roomtyp2'] = bindec(substr($ac3_header['bsi'], $offset, 2));
$offset += 2;
@@ -278,11 +278,11 @@ class getid3_ac3 extends getid3_handler
6 => 'associated service: emergency (E)',
7 => 'main audio service: karaoke'
);
-
+
if ($bsmod == 7 && $acmod == 1) {
return 'associated service: voice over (VO)';
}
-
+
return (isset($lookup[$bsmod]) ? $lookup[$bsmod] : false);
}
@@ -307,7 +307,7 @@ class getid3_ac3 extends getid3_handler
public static function AC3centerMixLevelLookup($cmixlev) {
-
+
static $lookup;
if (!@$lookup) {
$lookup = array (
@@ -323,7 +323,7 @@ class getid3_ac3 extends getid3_handler
public static function AC3surroundMixLevelLookup($surmixlev) {
-
+
static $lookup;
if (!@$lookup) {
$lookup = array (
@@ -348,11 +348,11 @@ class getid3_ac3 extends getid3_handler
);
return (isset($lookup[$dsurmod]) ? $lookup[$dsurmod] : false);
}
-
-
+
+
public static function AC3channelsEnabledLookup($acmod, $lfeon) {
-
+
return array (
'ch1' => $acmod == 0,
'ch2' => $acmod == 0,
@@ -422,7 +422,7 @@ class getid3_ac3 extends getid3_handler
public static function AC3roomTypeLookup($roomtyp) {
-
+
static $lookup = array (
0 => 'not indicated',
1 => 'large room, X curve monitor',
@@ -435,7 +435,7 @@ class getid3_ac3 extends getid3_handler
public static function AC3frameSizeLookup($frmsizecod, $fscod) {
-
+
$padding = (bool)($frmsizecod % 2);
$frame_size_id = floor($frmsizecod / 2);
@@ -470,7 +470,7 @@ class getid3_ac3 extends getid3_handler
public static function AC3bitrateLookup($frmsizecod) {
-
+
static $lookup = array (
0 => 32000,
1 => 40000,
diff --git a/modules/getid3/module.audio.au.php b/modules/getid3/module.audio.au.php
index d4cd8444..2fbb3f17 100644
--- a/modules/getid3/module.audio.au.php
+++ b/modules/getid3/module.audio.au.php
@@ -22,15 +22,15 @@
//
// $Id: module.audio.au.php,v 1.2 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_au extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$au_header = fread($getid3->fp, 8);
@@ -48,7 +48,7 @@ class getid3_au extends getid3_handler
$au_header .= fread($getid3->fp, $info_au['header_length'] - 8);
$getid3->info['avdataoffset'] += $info_au['header_length'];
- getid3_lib::ReadSequence('BigEndian2Int', $info_au, $au_header, 8,
+ getid3_lib::ReadSequence('BigEndian2Int', $info_au, $au_header, 8,
array (
'data_size' => 4,
'data_format_id'=> 4,
@@ -82,7 +82,7 @@ class getid3_au extends getid3_handler
public static function AUdataFormatNameLookup($id) {
-
+
static $lookup = array (
0 => 'unspecified format',
1 => '8-bit mu-law',
@@ -113,14 +113,14 @@ class getid3_au extends getid3_handler
26 => 'CCITT g.723 5-bit ADPCM',
27 => 'A-Law 8-bit'
);
-
+
return (isset($lookup[$id]) ? $lookup[$id] : false);
}
public static function AUdataFormatBitsPerSampleLookup($id) {
-
+
static $lookup = array (
1 => 8,
2 => 8,
@@ -151,7 +151,7 @@ class getid3_au extends getid3_handler
public static function AUdataFormatUsedBitsPerSampleLookup($id) {
-
+
static $lookup = array (
1 => 8,
2 => 8,
diff --git a/modules/getid3/module.audio.avr.php b/modules/getid3/module.audio.avr.php
index a3fb059f..69e8a154 100644
--- a/modules/getid3/module.audio.avr.php
+++ b/modules/getid3/module.audio.avr.php
@@ -22,15 +22,15 @@
//
// $Id: module.audio.avr.php,v 1.2 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_avr extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
// http://cui.unige.ch/OSG/info/AudioFormats/ap11.html
// http://www.btinternet.com/~AnthonyJ/Atari/programming/avr_format.html
// offset type length name comments
@@ -76,7 +76,7 @@ class getid3_avr extends getid3_handler
$getid3->info['avr'] = array ();
$info_avr = &$getid3->info['avr'];
-
+
$getid3->info['fileformat'] = 'avr';
$info_avr['raw']['magic'] = '2BIT';
@@ -86,7 +86,7 @@ class getid3_avr extends getid3_handler
$getid3->info['avdataoffset'] += 128;
$info_avr['sample_name'] = rtrim(substr($avr_header, 4, 8));
-
+
$info_avr['raw']['mono'] = getid3_lib::BigEndian2Int(substr($avr_header, 12, 2));
$info_avr['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($avr_header, 14, 2));
$info_avr['raw']['signed'] = getid3_lib::BigEndian2Int(substr($avr_header, 16, 2));
diff --git a/modules/getid3/module.audio.bonk.php b/modules/getid3/module.audio.bonk.php
index 71f27723..e9cb79cd 100644
--- a/modules/getid3/module.audio.bonk.php
+++ b/modules/getid3/module.audio.bonk.php
@@ -22,22 +22,22 @@
//
// $Id: module.audio.bonk.php,v 1.3 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_bonk extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
$getid3->info['bonk'] = array ();
$info_bonk = &$getid3->info['bonk'];
$info_bonk['dataoffset'] = $getid3->info['avdataoffset'];
$info_bonk['dataend'] = $getid3->info['avdataend'];
-
+
// Scan-from-end method, for v0.6 and higher
fseek($getid3->fp, $info_bonk['dataend'] - 8, SEEK_SET);
$possible_bonk_tag = fread($getid3->fp, 8);
@@ -54,7 +54,7 @@ class getid3_bonk extends getid3_handler
$info_bonk[$bonk_tag_name]['size'] = $bonk_tag_size;
$info_bonk[$bonk_tag_name]['offset'] = $bonk_tag_offset;
$this->HandleBonkTags($bonk_tag_name);
-
+
$next_tag_end_offset = $bonk_tag_offset - 8;
if ($next_tag_end_offset < $info_bonk['dataoffset']) {
if (empty($getid3->info['audio']['encoder'])) {
@@ -119,7 +119,7 @@ class getid3_bonk extends getid3_handler
}
-
+
private function HandleBonkTags(&$bonk_tag_name) {
// Shortcut to getid3 pointer
@@ -127,14 +127,14 @@ class getid3_bonk extends getid3_handler
$info_audio = &$getid3->info['audio'];
switch ($bonk_tag_name) {
-
+
case 'BONK':
// shortcut
$info_bonk_BONK = &$getid3->info['bonk']['BONK'];
$bonk_data = "\x00".'BONK'.fread($getid3->fp, 17);
-
- getid3_lib::ReadSequence('LittleEndian2Int', $info_bonk_BONK, $bonk_data, 5,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_bonk_BONK, $bonk_data, 5,
array (
'version' => 1,
'number_samples' => 4,
@@ -147,7 +147,7 @@ class getid3_bonk extends getid3_handler
'samples_per_packet' => 2
)
);
-
+
$info_bonk_BONK['lossless'] = (bool)$info_bonk_BONK['lossless'];
$info_bonk_BONK['joint_stereo'] = (bool)$info_bonk_BONK['joint_stereo'];
@@ -208,7 +208,7 @@ class getid3_bonk extends getid3_handler
// ID3v2 checking is optional
if (class_exists('getid3_id3v2')) {
-
+
$id3v2 = new getid3_id3v2($getid3);
$id3v2->option_starting_offset = $getid3->info['bonk'][' ID3']['offset'] + 2;
$getid3->info['bonk'][' ID3']['valid'] = $id3v2->Analyze();
@@ -223,10 +223,10 @@ class getid3_bonk extends getid3_handler
}
-
+
public static function BonkIsValidTagName($possible_bonk_tag, $ignore_case=false) {
-
- $ignore_case = $ignore_case ? 'i' : '';
+
+ $ignore_case = $ignore_case ? 'i' : '';
return preg_match('/^(BONK|INFO| ID3|META)$/'.$ignore_case, $possible_bonk_tag);
}
diff --git a/modules/getid3/module.audio.dts.php b/modules/getid3/module.audio.dts.php
index 8de0a565..75e68ed0 100644
--- a/modules/getid3/module.audio.dts.php
+++ b/modules/getid3/module.audio.dts.php
@@ -22,19 +22,19 @@
//
// $Id: module.audio.dts.php,v 1.2 2006/11/16 13:14:26 ah Exp $
-
-
+
+
// Specs taken from "DTS Coherent Acoustics;Core and Extensions, ETSI TS 102 114 V1.2.1 (2002-12)"
// (http://pda.etsi.org/pda/queryform.asp)
// With thanks to Gambit <macteam@users.sourceforge.net> http://mac.sourceforge.net/atl/
-
+
class getid3_dts extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
-
+
$getid3->info['dts'] = array ();
$info_dts = &$getid3->info['dts'];
@@ -99,7 +99,7 @@ class getid3_dts extends getid3_handler
public static function DTSbitrateLookup($index) {
-
+
static $lookup = array (
0 => 32000,
1 => 56000,
@@ -137,9 +137,9 @@ class getid3_dts extends getid3_handler
return @$lookup[$index];
}
-
+
public static function DTSsampleRateLookup($index) {
-
+
static $lookup = array (
0 => 'invalid',
1 => 8000,
@@ -161,9 +161,9 @@ class getid3_dts extends getid3_handler
return @$lookup[$index];
}
-
+
public static function DTSbitPerSampleLookup($index) {
-
+
static $lookup = array (
0 => 16,
1 => 20,
@@ -173,38 +173,38 @@ class getid3_dts extends getid3_handler
return @$lookup[$index];
}
-
+
public static function DTSnumChannelsLookup($index) {
-
+
switch ($index) {
case 0:
return 1;
-
+
case 1:
case 2:
case 3:
case 4:
return 2;
-
+
case 5:
case 6:
return 3;
-
+
case 7:
case 8:
return 4;
-
+
case 9:
return 5;
-
+
case 10:
case 11:
case 12:
return 6;
-
+
case 13:
return 7;
-
+
case 14:
case 15:
return 8;
@@ -212,9 +212,9 @@ class getid3_dts extends getid3_handler
return false;
}
-
+
public static function DTSchannelArrangementLookup($index) {
-
+
static $lookup = array (
0 => 'A',
1 => 'A + B (dual mono)',
@@ -236,13 +236,13 @@ class getid3_dts extends getid3_handler
return (@$lookup[$index] ? @$lookup[$index] : 'user-defined');
}
-
+
public static function DTSdialogNormalization($index, $version) {
-
+
switch ($version) {
case 7:
return 0 - $index;
-
+
case 6:
return 0 - 16 - $index;
}
diff --git a/modules/getid3/module.audio.la.php b/modules/getid3/module.audio.la.php
index 6b54b018..f68071e1 100644
--- a/modules/getid3/module.audio.la.php
+++ b/modules/getid3/module.audio.la.php
@@ -22,20 +22,20 @@
//
// $Id: module.audio.la.php,v 1.2 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_la extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
-
+
$getid3->include_module('audio-video.riff');
-
+
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$raw_data = fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
-
+
$getid3->info['fileformat'] = 'la';
$getid3->info['audio']['dataformat'] = 'la';
$getid3->info['audio']['lossless'] = true;
@@ -45,12 +45,12 @@ class getid3_la extends getid3_handler
$getid3->info['la']['version'] = (float)$getid3->info['la']['version_major'] + ($getid3->info['la']['version_minor'] / 10);
$getid3->info['la']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($raw_data, 4, 4));
-
+
$wave_chunk = substr($raw_data, 8, 4);
if ($wave_chunk !== 'WAVE') {
throw new getid3_exception('Expected "WAVE" ('.getid3_lib::PrintHexBytes('WAVE').') at offset 8, found "'.$wave_chunk.'" ('.getid3_lib::PrintHexBytes($wave_chunk).') instead.');
}
-
+
$offset = 12;
$getid3->info['la']['fmt_size'] = 24;
@@ -71,13 +71,13 @@ class getid3_la extends getid3_handler
throw new getid3_exception('Expected "fmt " ('.getid3_lib::PrintHexBytes('fmt ').') at offset '.$offset.', found "'.$fmt_chunk.'" ('.getid3_lib::PrintHexBytes($fmt_chunk).') instead.');
}
$offset += 4;
-
+
$fmt_size = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
$offset += 4;
$getid3->info['la']['raw']['format'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 2));
$offset += 2;
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['la'], $raw_data, $offset,
array (
'channels' => 2,
@@ -89,9 +89,9 @@ class getid3_la extends getid3_handler
)
);
$offset += 18;
-
+
$getid3->info['la']['raw']['flags'] = getid3_lib::LittleEndian2Int($raw_data{$offset++});
-
+
$getid3->info['la']['flags']['seekable'] = (bool)($getid3->info['la']['raw']['flags'] & 0x01);
if ($getid3->info['la']['version'] >= 0.4) {
$getid3->info['la']['flags']['high_compression'] = (bool)($getid3->info['la']['raw']['flags'] & 0x02);
@@ -106,7 +106,7 @@ class getid3_la extends getid3_handler
// samples, so 4 * int(totalSamples / (blockSize * seekEvery)) should
// give the number of bytes used for the seekpoints. Of course, if seeking
// is disabled, there are no seekpoints stored.
-
+
if ($getid3->info['la']['version'] >= 0.4) {
$getid3->info['la']['blocksize'] = 61440;
$getid3->info['la']['seekevery'] = 19;
@@ -130,7 +130,7 @@ class getid3_la extends getid3_handler
// Following the main header information, the program outputs all of the
// seekpoints. Following these is what I called the 'footer start',
// i.e. the position immediately after the La audio data is finished.
-
+
$getid3->info['la']['footerstart'] = getid3_lib::LittleEndian2Int(substr($raw_data, $offset, 4));
$offset += 4;
@@ -147,7 +147,7 @@ class getid3_la extends getid3_handler
}
if ($getid3->info['la']['footerstart'] < $getid3->info['avdataend']) {
-
+
// Create riff header
$riff_data = 'WAVE';
if ($getid3->info['la']['version'] == 0.2) {
@@ -160,14 +160,14 @@ class getid3_la extends getid3_handler
$riff_data .= fread($getid3->fp, $getid3->info['avdataend'] - $getid3->info['la']['footerstart']);
}
$riff_data = 'RIFF'.getid3_lib::LittleEndian2String(strlen($riff_data), 4, false).$riff_data;
-
+
// Clone getid3 - messing with offsets - better safe than sorry
$clone = clone $getid3;
-
+
// Analyze clone by string
$riff = new getid3_riff($clone);
$riff->AnalyzeString($riff_data);
-
+
// Import from clone and destroy
$getid3->info['riff'] = $clone->info['riff'];
$getid3->warnings($clone->warnings());
diff --git a/modules/getid3/module.audio.lpac.php b/modules/getid3/module.audio.lpac.php
index b86ff064..d20a59eb 100644
--- a/modules/getid3/module.audio.lpac.php
+++ b/modules/getid3/module.audio.lpac.php
@@ -22,24 +22,24 @@
//
// $Id: module.audio.lpac.php,v 1.2 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_lpac extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
-
+
$getid3->include_module('audio-video.riff');
-
+
// Magic bytes - 'LPAC'
-
+
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$lpac_header = fread($getid3->fp, 14);
-
+
$getid3->info['avdataoffset'] += 14;
-
+
$getid3->info['lpac'] = array ();
$info_lpac = &$getid3->info['lpac'];
@@ -47,7 +47,7 @@ class getid3_lpac extends getid3_handler
$getid3->info['audio']['dataformat'] = 'lpac';
$getid3->info['audio']['lossless'] = true;
$getid3->info['audio']['bitrate_mode'] = 'vbr';
-
+
$info_lpac['file_version'] = getid3_lib::BigEndian2Int($lpac_header{4});
$flags['audio_type'] = getid3_lib::BigEndian2Int($lpac_header{5});
$info_lpac['total_samples'] = getid3_lib::BigEndian2Int(substr($lpac_header, 6, 4));
@@ -74,9 +74,9 @@ class getid3_lpac extends getid3_handler
if ($info_lpac['flags']['fast_compress'] && ($info_lpac['max_prediction_order'] != 3)) {
$getid3->warning('max_prediction_order expected to be "3" if fast_compress is true, actual value is "'.$info_lpac['max_prediction_order'].'"');
}
-
+
switch ($info_lpac['file_version']) {
-
+
case 6:
if ($info_lpac['flags']['adaptive_quantization']) {
$getid3->warning('adaptive_quantization expected to be false in LPAC file stucture v6, actually true');
@@ -86,7 +86,7 @@ class getid3_lpac extends getid3_handler
}
break;
-
+
default:
//$getid3->warning('This version of getID3() only supports LPAC file format version 6, this file is version '.$info_lpac['file_version'].' - please report to info@getid3.org');
break;
@@ -94,11 +94,11 @@ class getid3_lpac extends getid3_handler
// Clone getid3 - messing with something - better safe than sorry
$clone = clone $getid3;
-
+
// Analyze clone by fp
$riff = new getid3_riff($clone);
$riff->Analyze();
-
+
// Import from clone and destroy
$getid3->info['avdataoffset'] = $clone->info['avdataoffset'];
$getid3->info['riff'] = $clone->info['riff'];
@@ -106,7 +106,7 @@ class getid3_lpac extends getid3_handler
$getid3->info['audio']['sample_rate'] = $clone->info['audio']['sample_rate'];
$getid3->warnings($clone->warnings());
unset($clone);
-
+
$getid3->info['audio']['channels'] = ($info_lpac['flags']['stereo'] ? 2 : 1);
if ($info_lpac['flags']['24_bit']) {
diff --git a/modules/getid3/module.audio.midi.php b/modules/getid3/module.audio.midi.php
index 59786f10..383c7e29 100644
--- a/modules/getid3/module.audio.midi.php
+++ b/modules/getid3/module.audio.midi.php
@@ -22,15 +22,15 @@
//
// $Id: module.audio.midi.php,v 1.5 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_midi extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
$getid3->info['midi']['raw'] = array ();
$info_midi = &$getid3->info['midi'];
$info_midi_raw = &$info_midi['raw'];
@@ -40,10 +40,10 @@ class getid3_midi extends getid3_handler
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$midi_data = fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
-
+
// Magic bytes: 'MThd'
-
- getid3_lib::ReadSequence('BigEndian2Int', $info_midi_raw, $midi_data, 4,
+
+ getid3_lib::ReadSequence('BigEndian2Int', $info_midi_raw, $midi_data, 4,
array (
'headersize' => 4,
'fileformat' => 2,
@@ -51,25 +51,25 @@ class getid3_midi extends getid3_handler
'ticksperqnote' => 2
)
);
-
+
$offset = 14;
for ($i = 0; $i < $info_midi_raw['tracks']; $i++) {
-
+
if ((strlen($midi_data) - $offset) < 8) {
$midi_data .= fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
}
-
+
$track_id = substr($midi_data, $offset, 4);
$offset += 4;
-
+
if ($track_id != 'MTrk') {
throw new getid3_exception('Expecting "MTrk" at '.$offset.', found '.$track_id.' instead');
}
-
+
$track_size = getid3_lib::BigEndian2Int(substr($midi_data, $offset, 4));
$offset += 4;
-
+
$track_data_array[$i] = substr($midi_data, $offset, $track_size);
$offset += $track_size;
}
@@ -78,7 +78,7 @@ class getid3_midi extends getid3_handler
throw new getid3_exception('Cannot find MIDI track information');
}
-
+
$info_midi['totalticks'] = 0;
$getid3->info['playtime_seconds'] = 0;
$current_ms_per_beat = 500000; // 120 beats per minute; 60,000,000 microseconds per minute -> 500,000 microseconds per beat
@@ -88,9 +88,9 @@ class getid3_midi extends getid3_handler
foreach ($track_data_array as $track_number => $track_data) {
$events_offset = $last_issued_midi_command = $last_issued_midi_channel = $cumulative_delta_time = $ticks_at_current_bpm = 0;
-
+
while ($events_offset < strlen($track_data)) {
-
+
$event_id = 0;
if (isset($midi_events[$track_number]) && is_array($midi_events[$track_number])) {
$event_id = count($midi_events[$track_number]);
@@ -105,30 +105,30 @@ class getid3_midi extends getid3_handler
break;
}
}
-
+
$cumulative_delta_time += $delta_time;
$ticks_at_current_bpm += $delta_time;
-
+
$midi_events[$track_number][$event_id]['deltatime'] = $delta_time;
-
+
$midi_event_channel = ord($track_data{$events_offset++});
-
+
// OK, normal event - MIDI command has MSB set
if ($midi_event_channel & 0x80) {
$last_issued_midi_command = $midi_event_channel >> 4;
$last_issued_midi_channel = $midi_event_channel & 0x0F;
- }
-
+ }
+
// Running event - assume last command
else {
$events_offset--;
}
-
+
$midi_events[$track_number][$event_id]['eventid'] = $last_issued_midi_command;
$midi_events[$track_number][$event_id]['channel'] = $last_issued_midi_channel;
-
+
switch ($midi_events[$track_number][$event_id]['eventid']) {
-
+
case 0x8: // Note off (key is released)
case 0x9: // Note on (key is pressed)
case 0xA: // Key after-touch
@@ -137,31 +137,31 @@ class getid3_midi extends getid3_handler
//$velocity = ord($track_data{$events_offset++});
$events_offset += 2;
break;
-
-
+
+
case 0xB: // Control Change
-
+
//$controllernum = ord($track_data{$events_offset++});
//$newvalue = ord($track_data{$events_offset++});
$events_offset += 2;
break;
-
-
+
+
case 0xC: // Program (patch) change
-
+
$new_program_num = ord($track_data{$events_offset++});
$info_midi_raw['track'][$track_number]['instrumentid'] = $new_program_num;
$info_midi_raw['track'][$track_number]['instrument'] = $track_number == 10 ? getid3_midi::GeneralMIDIpercussionLookup($new_program_num) : getid3_midi::GeneralMIDIinstrumentLookup($new_program_num);
break;
-
-
+
+
case 0xD: // Channel after-touch
-
+
//$channelnumber = ord($track_data{$events_offset++});
break;
-
-
+
+
case 0xE: // Pitch wheel change (2000H is normal or no change)
//$changeLSB = ord($track_data{$events_offset++});
@@ -169,58 +169,58 @@ class getid3_midi extends getid3_handler
//$pitchwheelchange = (($changeMSB & 0x7F) << 7) & ($changeLSB & 0x7F);
$events_offset += 2;
break;
-
-
+
+
case 0xF:
if ($midi_events[$track_number][$event_id]['channel'] == 0xF) {
-
+
$meta_event_command = ord($track_data{$events_offset++});
$meta_event_length = ord($track_data{$events_offset++});
$meta_event_data = substr($track_data, $events_offset, $meta_event_length);
$events_offset += $meta_event_length;
-
+
switch ($meta_event_command) {
-
+
case 0x00: // Set track sequence number
-
+
//$track_sequence_number = getid3_lib::BigEndian2Int(substr($meta_event_data, 0, $meta_event_length));
//$info_midi_raw['events'][$track_number][$event_id]['seqno'] = $track_sequence_number;
break;
-
-
+
+
case 0x01: // Text: generic
-
+
$text_generic = substr($meta_event_data, 0, $meta_event_length);
//$info_midi_raw['events'][$track_number][$event_id]['text'] = $text_generic;
$info_midi['comments']['comment'][] = $text_generic;
break;
-
-
+
+
case 0x02: // Text: copyright
-
+
$text_copyright = substr($meta_event_data, 0, $meta_event_length);
//$info_midi_raw['events'][$track_number][$event_id]['copyright'] = $text_copyright;
$info_midi['comments']['copyright'][] = $text_copyright;
break;
-
-
+
+
case 0x03: // Text: track name
-
+
$text_trackname = substr($meta_event_data, 0, $meta_event_length);
$info_midi_raw['track'][$track_number]['name'] = $text_trackname;
break;
-
-
+
+
case 0x04: // Text: track instrument name
-
+
//$text_instrument = substr($meta_event_data, 0, $meta_event_length);
//$info_midi_raw['events'][$track_number][$event_id]['instrument'] = $text_instrument;
break;
-
-
+
+
case 0x05: // Text: lyrics
-
+
$text_lyrics = substr($meta_event_data, 0, $meta_event_length);
//$info_midi_raw['events'][$track_number][$event_id]['lyrics'] = $text_lyrics;
if (!isset($info_midi['lyrics'])) {
@@ -228,38 +228,38 @@ class getid3_midi extends getid3_handler
}
$info_midi['lyrics'] .= $text_lyrics . "\n";
break;
-
-
+
+
case 0x06: // Text: marker
-
+
//$text_marker = substr($meta_event_data, 0, $meta_event_length);
//$info_midi_raw['events'][$track_number][$event_id]['marker'] = $text_marker;
break;
-
-
+
+
case 0x07: // Text: cue point
//$text_cuepoint = substr($meta_event_data, 0, $meta_event_length);
//$info_midi_raw['events'][$track_number][$event_id]['cuepoint'] = $text_cuepoint;
break;
-
+
case 0x2F: // End Of Track
-
+
//$info_midi_raw['events'][$track_number][$event_id]['EOT'] = $cumulative_delta_time;
break;
-
-
+
+
case 0x51: // Tempo: microseconds / quarter note
-
+
$current_ms_per_beat = getid3_lib::BigEndian2Int(substr($meta_event_data, 0, $meta_event_length));
$info_midi_raw['events'][$track_number][$cumulative_delta_time]['us_qnote'] = $current_ms_per_beat;
$current_beats_per_min = (1000000 / $current_ms_per_beat) * 60;
$ms_per_quarter_note_after[$cumulative_delta_time] = $current_ms_per_beat;
$ticks_at_current_bpm = 0;
break;
-
-
+
+
case 0x58: // Time signature
$timesig_numerator = getid3_lib::BigEndian2Int($meta_event_data[0]);
$timesig_denominator = pow(2, getid3_lib::BigEndian2Int($meta_event_data[1])); // $02 -> x/4, $03 -> x/8, etc
@@ -270,63 +270,63 @@ class getid3_midi extends getid3_handler
//$info_midi_raw['events'][$track_number][$event_id]['timesig_text'] = $timesig_numerator.'/'.$timesig_denominator;
$info_midi['timesignature'][] = $timesig_numerator.'/'.$timesig_denominator;
break;
-
-
+
+
case 0x59: // Keysignature
-
+
$keysig_sharpsflats = getid3_lib::BigEndian2Int($meta_event_data{0});
if ($keysig_sharpsflats & 0x80) {
// (-7 -> 7 flats, 0 ->key of C, 7 -> 7 sharps)
$keysig_sharpsflats -= 256;
}
-
+
$keysig_majorminor = getid3_lib::BigEndian2Int($meta_event_data{1}); // 0 -> major, 1 -> minor
$keysigs = array (-7=>'Cb', -6=>'Gb', -5=>'Db', -4=>'Ab', -3=>'Eb', -2=>'Bb', -1=>'F', 0=>'C', 1=>'G', 2=>'D', 3=>'A', 4=>'E', 5=>'B', 6=>'F#', 7=>'C#');
//$info_midi_raw['events'][$track_number][$event_id]['keysig_sharps'] = (($keysig_sharpsflats > 0) ? abs($keysig_sharpsflats) : 0);
//$info_midi_raw['events'][$track_number][$event_id]['keysig_flats'] = (($keysig_sharpsflats < 0) ? abs($keysig_sharpsflats) : 0);
//$info_midi_raw['events'][$track_number][$event_id]['keysig_minor'] = (bool)$keysig_majorminor;
//$info_midi_raw['events'][$track_number][$event_id]['keysig_text'] = $keysigs[$keysig_sharpsflats].' '.($info_midi_raw['events'][$track_number][$event_id]['keysig_minor'] ? 'minor' : 'major');
-
+
// $keysigs[$keysig_sharpsflats] gets an int key (correct) - $keysigs["$keysig_sharpsflats"] gets a string key (incorrect)
$info_midi['keysignature'][] = $keysigs[$keysig_sharpsflats].' '.((bool)$keysig_majorminor ? 'minor' : 'major');
break;
-
-
+
+
case 0x7F: // Sequencer specific information
-
+
$custom_data = substr($meta_event_data, 0, $meta_event_length);
break;
-
-
+
+
default:
-
+
$getid3->warning('Unhandled META Event Command: '.$meta_event_command);
}
}
break;
-
-
- default:
+
+
+ default:
$getid3->warning('Unhandled MIDI Event ID: '.$midi_events[$track_number][$event_id]['eventid']);
}
}
-
+
if (($track_number > 0) || (count($track_data_array) == 1)) {
$info_midi['totalticks'] = max($info_midi['totalticks'], $cumulative_delta_time);
}
}
-
+
$previous_tick_offset = null;
- ksort($ms_per_quarter_note_after);
+ ksort($ms_per_quarter_note_after);
foreach ($ms_per_quarter_note_after as $tick_offset => $ms_per_beat) {
-
+
if (is_null($previous_tick_offset)) {
$prev_ms_per_beat = $ms_per_beat;
$previous_tick_offset = $tick_offset;
continue;
}
-
+
if ($info_midi['totalticks'] > $tick_offset) {
$getid3->info['playtime_seconds'] += (($tick_offset - $previous_tick_offset) / $info_midi_raw['ticksperqnote']) * ($prev_ms_per_beat / 1000000);
@@ -334,7 +334,7 @@ class getid3_midi extends getid3_handler
$previous_tick_offset = $tick_offset;
}
}
-
+
if ($info_midi['totalticks'] > $previous_tick_offset) {
$getid3->info['playtime_seconds'] += (($info_midi['totalticks'] - $previous_tick_offset) / $info_midi_raw['ticksperqnote']) * ($ms_per_beat / 1000000);
}
@@ -351,11 +351,11 @@ class getid3_midi extends getid3_handler
}
-
+
public static function GeneralMIDIinstrumentLookup($instrument_id) {
static $lookup = array (
-
+
0 => 'Acoustic Grand',
1 => 'Bright Acoustic',
2 => 'Electric Grand',
@@ -487,14 +487,14 @@ class getid3_midi extends getid3_handler
);
return @$lookup[$instrument_id];
- }
-
-
-
+ }
+
+
+
public static function GeneralMIDIpercussionLookup($instrument_id) {
-
+
static $lookup = array (
-
+
35 => 'Acoustic Bass Drum',
36 => 'Bass Drum 1',
37 => 'Side Stick',
@@ -544,10 +544,10 @@ class getid3_midi extends getid3_handler
);
return @$lookup[$instrument_id];
- }
+ }
+
+
+}
+
-
-}
-
-
?> \ No newline at end of file
diff --git a/modules/getid3/module.audio.monkey.php b/modules/getid3/module.audio.monkey.php
index cb691fca..4ece9f59 100644
--- a/modules/getid3/module.audio.monkey.php
+++ b/modules/getid3/module.audio.monkey.php
@@ -22,8 +22,8 @@
//
// $Id: module.audio.monkey.php,v 1.2 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_monkey extends getid3_handler
{
@@ -33,7 +33,7 @@ class getid3_monkey extends getid3_handler
// based loosely on code from TMonkey by Jurgen Faul <jfaulØgmx*de>
// http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
-
+
$getid3->info['fileformat'] = 'mac';
$getid3->info['audio']['dataformat'] = 'mac';
$getid3->info['audio']['bitrate_mode'] = 'vbr';
@@ -51,10 +51,10 @@ class getid3_monkey extends getid3_handler
// Read MAC version
$info_monkeys_audio_raw['nVersion'] = getid3_lib::LittleEndian2Int(substr($mac_header_data, 4, 2)); // appears to be uint32 in 3.98+
-
+
// Parse MAC Header < v3980
if ($info_monkeys_audio_raw['nVersion'] < 3980) {
-
+
getid3_lib::ReadSequence("LittleEndian2Int", $info_monkeys_audio_raw, $mac_header_data, 6,
array (
'nCompressionLevel' => 2,
@@ -65,30 +65,30 @@ class getid3_monkey extends getid3_handler
'nWAVTerminatingBytes' => 4,
'nTotalFrames' => 4,
'nFinalFrameSamples' => 4,
- 'nPeakLevel' => 4,
+ 'nPeakLevel' => 4,
'IGNORE-1' => 2,
'nSeekElements' => 2
)
);
- }
-
+ }
+
// Parse MAC Header >= v3980
else {
- getid3_lib::ReadSequence("LittleEndian2Int", $info_monkeys_audio_raw, $mac_header_data, 8,
+ getid3_lib::ReadSequence("LittleEndian2Int", $info_monkeys_audio_raw, $mac_header_data, 8,
array (
// APE_DESCRIPTOR
'nDescriptorBytes' => 4,
- 'nHeaderBytes' => 4,
- 'nSeekTableBytes' => 4,
- 'nHeaderDataBytes' => 4,
- 'nAPEFrameDataBytes' => 4,
- 'nAPEFrameDataBytesHigh'=> 4,
- 'nTerminatingDataBytes' => 4,
-
+ 'nHeaderBytes' => 4,
+ 'nSeekTableBytes' => 4,
+ 'nHeaderDataBytes' => 4,
+ 'nAPEFrameDataBytes' => 4,
+ 'nAPEFrameDataBytesHigh'=> 4,
+ 'nTerminatingDataBytes' => 4,
+
// MD5 - string
- 'cFileMD5' => -16,
-
+ 'cFileMD5' => -16,
+
// APE_HEADER
'nCompressionLevel' => 2,
'nFormatFlags' => 2,
@@ -101,7 +101,7 @@ class getid3_monkey extends getid3_handler
)
);
}
-
+
// Process data
$info_monkeys_audio['flags']['8-bit'] = (bool)($info_monkeys_audio_raw['nFormatFlags'] & 0x0001);
$info_monkeys_audio['flags']['crc-32'] = (bool)($info_monkeys_audio_raw['nFormatFlags'] & 0x0002);
@@ -109,39 +109,39 @@ class getid3_monkey extends getid3_handler
$info_monkeys_audio['flags']['24-bit'] = (bool)($info_monkeys_audio_raw['nFormatFlags'] & 0x0008);
$info_monkeys_audio['flags']['seek_elements'] = (bool)($info_monkeys_audio_raw['nFormatFlags'] & 0x0010);
$info_monkeys_audio['flags']['no_wav_header'] = (bool)($info_monkeys_audio_raw['nFormatFlags'] & 0x0020);
-
+
$info_monkeys_audio['version'] = $info_monkeys_audio_raw['nVersion'] / 1000;
-
+
$info_monkeys_audio['compression'] = getid3_monkey::MonkeyCompressionLevelNameLookup($info_monkeys_audio_raw['nCompressionLevel']);
-
+
$info_monkeys_audio['bits_per_sample'] = ($info_monkeys_audio['flags']['24-bit'] ? 24 : ($info_monkeys_audio['flags']['8-bit'] ? 8 : 16));
-
+
$info_monkeys_audio['channels'] = $info_monkeys_audio_raw['nChannels'];
-
+
$getid3->info['audio']['channels'] = $info_monkeys_audio['channels'];
-
+
$info_monkeys_audio['sample_rate'] = $info_monkeys_audio_raw['nSampleRate'];
-
+
$getid3->info['audio']['sample_rate'] = $info_monkeys_audio['sample_rate'];
-
+
if ($info_monkeys_audio['flags']['peak_level']) {
$info_monkeys_audio['peak_level'] = $info_monkeys_audio_raw['nPeakLevel'];
$info_monkeys_audio['peak_ratio'] = $info_monkeys_audio['peak_level'] / pow(2, $info_monkeys_audio['bits_per_sample'] - 1);
}
-
+
// MAC >= v3980
if ($info_monkeys_audio_raw['nVersion'] >= 3980) {
$info_monkeys_audio['samples'] = (($info_monkeys_audio_raw['nTotalFrames'] - 1) * $info_monkeys_audio_raw['nBlocksPerFrame']) + $info_monkeys_audio_raw['nFinalFrameBlocks'];
- }
-
+ }
+
// MAC < v3980
else {
$info_monkeys_audio['samples_per_frame'] = getid3_monkey::MonkeySamplesPerFrame($info_monkeys_audio_raw['nVersion'], $info_monkeys_audio_raw['nCompressionLevel']);
$info_monkeys_audio['samples'] = (($info_monkeys_audio_raw['nTotalFrames'] - 1) * $info_monkeys_audio['samples_per_frame']) + $info_monkeys_audio_raw['nFinalFrameSamples'];
}
-
+
$info_monkeys_audio['playtime'] = $info_monkeys_audio['samples'] / $info_monkeys_audio['sample_rate'];
-
+
$getid3->info['playtime_seconds'] = $info_monkeys_audio['playtime'];
$info_monkeys_audio['compressed_size'] = $getid3->info['avdataend'] - $getid3->info['avdataoffset'];
@@ -150,17 +150,17 @@ class getid3_monkey extends getid3_handler
$info_monkeys_audio['bitrate'] = (($info_monkeys_audio['samples'] * $info_monkeys_audio['channels'] * $info_monkeys_audio['bits_per_sample']) / $info_monkeys_audio['playtime']) * $info_monkeys_audio['compression_ratio'];
$getid3->info['audio']['bitrate'] = $info_monkeys_audio['bitrate'];
-
+
$getid3->info['audio']['bits_per_sample'] = $info_monkeys_audio['bits_per_sample'];
$getid3->info['audio']['encoder'] = 'MAC v'.number_format($info_monkeys_audio['version'], 2);
$getid3->info['audio']['encoder_options'] = ucfirst($info_monkeys_audio['compression']).' compression';
-
+
// MAC >= v3980 - get avdataoffsets from MAC header
if ($info_monkeys_audio_raw['nVersion'] >= 3980) {
$getid3->info['avdataoffset'] += $info_monkeys_audio_raw['nDescriptorBytes'] + $info_monkeys_audio_raw['nHeaderBytes'] + $info_monkeys_audio_raw['nSeekTableBytes'] + $info_monkeys_audio_raw['nHeaderDataBytes'];
$getid3->info['avdataend'] -= $info_monkeys_audio_raw['nTerminatingDataBytes'];
- }
-
+ }
+
// MAC < v3980 Add size of MAC header to avdataoffset
else {
$getid3->info['avdataoffset'] += 8;
@@ -179,15 +179,15 @@ class getid3_monkey extends getid3_handler
}
}
}
-
+
return true;
}
-
-
+
+
public static function MonkeyCompressionLevelNameLookup($compression_level) {
-
+
static $lookup = array (
0 => 'unknown',
1000 => 'fast',
@@ -199,13 +199,13 @@ class getid3_monkey extends getid3_handler
return (isset($lookup[$compression_level]) ? $lookup[$compression_level] : 'invalid');
}
-
-
+
+
public static function MonkeySamplesPerFrame($version_id, $compression_level) {
if ($version_id >= 3950) {
return 73728 * 4;
- }
+ }
if (($version_id >= 3900) || (($version_id >= 3800) && ($compression_level == 4000))) {
return 73728;
}
diff --git a/modules/getid3/module.audio.mpc_old.php b/modules/getid3/module.audio.mpc_old.php
index 3a9adb9d..5e47b4b3 100644
--- a/modules/getid3/module.audio.mpc_old.php
+++ b/modules/getid3/module.audio.mpc_old.php
@@ -22,17 +22,17 @@
//
// $Id: module.audio.mpc_old.php,v 1.2 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_mpc_old extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
// http://www.uni-jena.de/~pfk/mpp/sv8/header.html
-
+
$getid3->info['mpc']['header'] = array ();
$info_mpc_header = &$getid3->info['mpc']['header'];
@@ -46,10 +46,10 @@ class getid3_mpc_old extends getid3_handler
$info_mpc_header['size'] = 8;
$getid3->info['avdataoffset'] += $info_mpc_header['size'];
-
+
$mpc_header_data = fread($getid3->fp, $info_mpc_header['size']);
-
-
+
+
// Most of this code adapted from Jurgen Faul's MPEGplus source code - thanks Jurgen! :)
$header_dword[0] = getid3_lib::LittleEndian2Int(substr($mpc_header_data, 0, 4));
$header_dword[1] = getid3_lib::LittleEndian2Int(substr($mpc_header_data, 4, 4));
@@ -69,7 +69,7 @@ class getid3_mpc_old extends getid3_handler
$info_mpc_header['intensity_stereo'] = (bool)(($header_dword[0] & 0x00400000) >> 22);
$info_mpc_header['mid-side_stereo'] = (bool)(($header_dword[0] & 0x00200000) >> 21);
$info_mpc_header['stream_major_version'] = ($header_dword[0] & 0x001FF800) >> 11;
- $info_mpc_header['stream_minor_version'] = 0;
+ $info_mpc_header['stream_minor_version'] = 0;
$info_mpc_header['max_band'] = ($header_dword[0] & 0x000007C0) >> 6; // related to lowpass frequency, not sure how it translates exactly
$info_mpc_header['block_size'] = ($header_dword[0] & 0x0000003F);
@@ -98,10 +98,10 @@ class getid3_mpc_old extends getid3_handler
$getid3->info['mpc']['bitrate'] = ($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8 * 44100 / $info_mpc_header['frame_count'] / 1152;
$getid3->info['audio']['bitrate'] = $getid3->info['mpc']['bitrate'];
$getid3->info['audio']['encoder'] = 'SV'.$info_mpc_header['stream_major_version'];
-
+
return true;
}
-
+
}
diff --git a/modules/getid3/module.audio.optimfrog.php b/modules/getid3/module.audio.optimfrog.php
index 9dde727b..3c667570 100644
--- a/modules/getid3/module.audio.optimfrog.php
+++ b/modules/getid3/module.audio.optimfrog.php
@@ -22,44 +22,44 @@
//
// $Id: module.audio.optimfrog.php,v 1.3 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_optimfrog extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
-
+
$getid3->include_module('audio-video.riff');
-
+
$getid3->info['audio']['dataformat'] = 'ofr';
$getid3->info['audio']['bitrate_mode'] = 'vbr';
$getid3->info['audio']['lossless'] = true;
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$ofr_header = fread($getid3->fp, 8);
-
+
if (substr($ofr_header, 0, 5) == '*RIFF') {
return $this->ParseOptimFROGheader42($getid3->fp, $getid3->info);
} elseif (substr($ofr_header, 0, 3) == 'OFR') {
return $this->ParseOptimFROGheader45($getid3->fp, $getid3->info);
}
-
+
throw new getid3_exception('Expecting "*RIFF" or "OFR " at offset '.$getid3->info['avdataoffset'].', found "'.$ofr_header.'"');
}
private function ParseOptimFROGheader42() {
-
+
$getid3 = $this->getid3;
-
+
// for fileformat of v4.21 and older
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
-
+
$ofr_header_data = fread($getid3->fp, 45);
$getid3->info['avdataoffset'] = 45;
@@ -79,26 +79,26 @@ class getid3_optimfrog extends getid3_handler
// move the data chunk after all other chunks (if any)
// so that the RIFF parser doesn't see EOF when trying
// to skip over the data chunk
-
+
$riff_data = substr($riff_data, 0, 36).substr($riff_data, 44).substr($riff_data, 36, 8);
-
+
// Save audio info key
$saved_info_audio = $getid3->info['audio'];
// Instantiate riff module and analyze string
$riff = new getid3_riff($getid3);
$riff->AnalyzeString($riff_data);
-
+
// Restore info key
$getid3->info['audio'] = $saved_info_audio;
-
+
$getid3->info['audio']['encoder'] = 'OptimFROG '.$ofr_encoder_version_major.'.'.$ofr_encoder_version_minor;
$getid3->info['audio']['channels'] = $getid3->info['riff']['audio'][0]['channels'];
$getid3->info['audio']['sample_rate'] = $getid3->info['riff']['audio'][0]['sample_rate'];
$getid3->info['audio']['bits_per_sample'] = $getid3->info['riff']['audio'][0]['bits_per_sample'];
$getid3->info['playtime_seconds'] = $origna_riff_data_size / ($getid3->info['audio']['channels'] * $getid3->info['audio']['sample_rate'] * ($getid3->info['audio']['bits_per_sample'] / 8));
$getid3->info['audio']['bitrate'] = (($getid3->info['avdataend'] - $getid3->info['avdataoffset']) * 8) / $getid3->info['playtime_seconds'];
-
+
$getid3->info['fileformat'] = 'ofr';
return true;
@@ -107,16 +107,16 @@ class getid3_optimfrog extends getid3_handler
private function ParseOptimFROGheader45() {
-
+
$getid3 = $this->getid3;
-
+
// for fileformat of v4.50a and higher
$riff_data = '';
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
-
+
while (!feof($getid3->fp) && (ftell($getid3->fp) < $getid3->info['avdataend'])) {
-
+
$block_offset = ftell($getid3->fp);
$block_data = fread($getid3->fp, 8);
$offset = 8;
@@ -153,10 +153,10 @@ class getid3_optimfrog extends getid3_handler
$info_ofr_this_block['total_samples'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 6));
$offset += 6;
-
+
$info_ofr_this_block['raw']['sample_type'] = getid3_lib::LittleEndian2Int($block_data{$offset++});
$info_ofr_this_block['sample_type'] = $this->OptimFROGsampleTypeLookup($info_ofr_this_block['raw']['sample_type']);
-
+
$info_ofr_this_block['channel_config'] = getid3_lib::LittleEndian2Int($block_data{$offset++});
$info_ofr_this_block['channels'] = $info_ofr_this_block['channel_config'];
@@ -210,13 +210,13 @@ class getid3_optimfrog extends getid3_handler
$comp_data['crc_32'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 4));
$offset += 4;
-
+
$comp_data['sample_count'] = getid3_lib::LittleEndian2Int(substr($block_data, $offset, 4));
$offset += 4;
-
+
$comp_data['raw']['sample_type'] = getid3_lib::LittleEndian2Int($block_data{$offset++});
$comp_data['sample_type'] = $this->OptimFROGsampleTypeLookup($comp_data['raw']['sample_type']);
-
+
$comp_data['raw']['channel_configuration'] = getid3_lib::LittleEndian2Int($block_data{$offset++});
$comp_data['channel_configuration'] = $this->OptimFROGchannelConfigurationLookup($comp_data['raw']['channel_configuration']);
@@ -306,7 +306,7 @@ class getid3_optimfrog extends getid3_handler
break;
}
}
-
+
if (isset($getid3->info['ofr']['TAIL']['offset'])) {
$getid3->info['avdataend'] = $getid3->info['ofr']['TAIL']['offset'];
}
@@ -317,19 +317,19 @@ class getid3_optimfrog extends getid3_handler
// move the data chunk after all other chunks (if any)
// so that the RIFF parser doesn't see EOF when trying
// to skip over the data chunk
-
+
$riff_data = substr($riff_data, 0, 36).substr($riff_data, 44).substr($riff_data, 36, 8);
-
+
// Save audio info key
$saved_info_audio = $getid3->info['audio'];
// Instantiate riff module and analyze string
$riff = new getid3_riff($getid3);
$riff->AnalyzeString($riff_data);
-
+
// Restore info key
$getid3->info['audio'] = $saved_info_audio;
-
+
$getid3->info['fileformat'] = 'ofr';
return true;
@@ -338,7 +338,7 @@ class getid3_optimfrog extends getid3_handler
public static function OptimFROGsampleTypeLookup($sample_type) {
-
+
static $lookup = array (
0 => 'unsigned int (8-bit)',
1 => 'signed int (8-bit)',
@@ -352,7 +352,7 @@ class getid3_optimfrog extends getid3_handler
9 => 'float 16.8 (32-bit)',
10 => 'float 24.0 (32-bit)'
);
-
+
return @$lookup[$sample_type];
}
@@ -373,19 +373,19 @@ class getid3_optimfrog extends getid3_handler
9 => 32,
10 => 32
);
-
+
return @$lookup[$sample_type];
}
public static function OptimFROGchannelConfigurationLookup($channel_configuration) {
-
+
static $lookup = array (
0 => 'mono',
1 => 'stereo'
);
-
+
return @$lookup[$channel_configuration];
}
@@ -397,7 +397,7 @@ class getid3_optimfrog extends getid3_handler
0 => 1,
1 => 2
);
-
+
return @$lookup[$channel_configuration];
}
diff --git a/modules/getid3/module.audio.rkau.php b/modules/getid3/module.audio.rkau.php
index 014c5272..35dc6253 100644
--- a/modules/getid3/module.audio.rkau.php
+++ b/modules/getid3/module.audio.rkau.php
@@ -22,28 +22,28 @@
//
// $Id: module.audio.rkau.php,v 1.2 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_rkau extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$rkau_header = fread($getid3->fp, 20);
-
+
// Magic bytes 'RKA'
-
+
$getid3->info['fileformat'] = 'rkau';
$getid3->info['audio']['dataformat'] = 'rkau';
$getid3->info['audio']['bitrate_mode'] = 'vbr';
-
+
// Shortcut
$getid3->info['rkau'] = array ();
$info_rkau = &$getid3->info['rkau'];
-
+
$info_rkau['raw']['version'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 3, 1));
$info_rkau['version'] = '1.'.str_pad($info_rkau['raw']['version'] & 0x0F, 2, '0', STR_PAD_LEFT);
if (($info_rkau['version'] > 1.07) || ($info_rkau['version'] < 1.06)) {
@@ -60,7 +60,7 @@ class getid3_rkau extends getid3_handler
);
$info_rkau['raw']['quality'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 14, 1));
-
+
$quality = $info_rkau['raw']['quality'] & 0x0F;
$info_rkau['lossless'] = (($quality == 0) ? true : false);
@@ -68,7 +68,7 @@ class getid3_rkau extends getid3_handler
if (!$info_rkau['lossless']) {
$info_rkau['quality_setting'] = $quality;
}
-
+
$info_rkau['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 15, 1));
$info_rkau['flags']['joint_stereo'] = (bool)(!($info_rkau['raw']['flags'] & 0x01));
$info_rkau['flags']['streaming'] = (bool) ($info_rkau['raw']['flags'] & 0x02);
@@ -77,7 +77,7 @@ class getid3_rkau extends getid3_handler
if ($info_rkau['flags']['streaming']) {
$getid3->info['avdataoffset'] += 20;
$info_rkau['compressed_bytes'] = getid3_lib::LittleEndian2Int(substr($rkau_header, 16, 4));
- }
+ }
else {
$getid3->info['avdataoffset'] += 16;
$info_rkau['compressed_bytes'] = $getid3->info['avdataend'] - $getid3->info['avdataoffset'] - 1;
diff --git a/modules/getid3/module.audio.shorten.php b/modules/getid3/module.audio.shorten.php
index 8a45d5fe..0c610c7c 100644
--- a/modules/getid3/module.audio.shorten.php
+++ b/modules/getid3/module.audio.shorten.php
@@ -22,15 +22,15 @@
//
// $Id: module.audio.shorten.php,v 1.5 2006/12/03 19:28:18 ah Exp $
-
-
+
+
class getid3_shorten extends getid3_handler
{
public function __construct(getID3 $getid3) {
parent::__construct($getid3);
-
+
if ((bool)ini_get('safe_mode')) {
throw new getid3_exception('PHP running in Safe Mode - backtick operator not available, cannot analyze Shorten files.');
}
@@ -38,7 +38,7 @@ class getid3_shorten extends getid3_handler
if (!`head --version`) {
throw new getid3_exception('head[.exe] binary not found in path. UNIX: typically /usr/bin. Windows: typically c:\windows\system32.');
}
-
+
if (!`shorten -l`) {
throw new getid3_exception('shorten[.exe] binary not found in path. UNIX: typically /usr/bin. Windows: typically c:\windows\system32.');
}
@@ -46,7 +46,7 @@ class getid3_shorten extends getid3_handler
public function Analyze() {
-
+
$getid3 = $this->getid3;
$getid3->include_module('audio-video.riff');
@@ -54,9 +54,9 @@ class getid3_shorten extends getid3_handler
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$shn_header = fread($getid3->fp, 8);
-
+
// Magic bytes: "ajkg"
-
+
$getid3->info['fileformat'] = 'shn';
$getid3->info['audio']['dataformat'] = 'shn';
$getid3->info['audio']['lossless'] = true;
@@ -65,21 +65,21 @@ class getid3_shorten extends getid3_handler
$getid3->info['shn']['version'] = getid3_lib::LittleEndian2Int($shn_header{4});
fseek($getid3->fp, $getid3->info['avdataend'] - 12, SEEK_SET);
-
+
$seek_table_signature_test = fread($getid3->fp, 12);
-
+
$getid3->info['shn']['seektable']['present'] = (bool)(substr($seek_table_signature_test, 4, 8) == 'SHNAMPSK');
if ($getid3->info['shn']['seektable']['present']) {
-
+
$getid3->info['shn']['seektable']['length'] = getid3_lib::LittleEndian2Int(substr($seek_table_signature_test, 0, 4));
$getid3->info['shn']['seektable']['offset'] = $getid3->info['avdataend'] - $getid3->info['shn']['seektable']['length'];
fseek($getid3->fp, $getid3->info['shn']['seektable']['offset'], SEEK_SET);
$seek_table_magic = fread($getid3->fp, 4);
-
+
if ($seek_table_magic != 'SEEK') {
throw new getid3_exception('Expecting "SEEK" at offset '.$getid3->info['shn']['seektable']['offset'].', found "'.$seek_table_magic.'"');
- }
+ }
$seek_table_data = fread($getid3->fp, $getid3->info['shn']['seektable']['length'] - 16);
$getid3->info['shn']['seektable']['entry_count'] = floor(strlen($seek_table_data) / 80);
@@ -92,7 +92,7 @@ class getid3_shorten extends getid3_handler
$fmt_size = getid3_lib::LittleEndian2Int(substr($output, 16, 4));
$decoded_wav_format_ex = getid3_riff::RIFFparseWAVEFORMATex(substr($output, 20, $fmt_size));
-
+
$getid3->info['audio']['channels'] = $decoded_wav_format_ex['channels'];
$getid3->info['audio']['bits_per_sample'] = $decoded_wav_format_ex['bits_per_sample'];
$getid3->info['audio']['sample_rate'] = $decoded_wav_format_ex['sample_rate'];
diff --git a/modules/getid3/module.audio.tta.php b/modules/getid3/module.audio.tta.php
index 3561b577..ff0e1be8 100644
--- a/modules/getid3/module.audio.tta.php
+++ b/modules/getid3/module.audio.tta.php
@@ -22,15 +22,15 @@
//
// $Id: module.audio.tta.php,v 1.2 2006/11/02 10:48:01 ah Exp $
-
-
+
+
class getid3_tta extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
$getid3->info['fileformat'] = 'tta';
$getid3->info['audio']['dataformat'] = 'tta';
$getid3->info['audio']['lossless'] = true;
@@ -40,27 +40,27 @@ class getid3_tta extends getid3_handler
$tta_header = fread($getid3->fp, 26);
$getid3->info['tta']['magic'] = 'TTA'; // Magic bytes
-
+
switch ($tta_header{3}) {
-
+
case "\x01": // TTA v1.x
case "\x02": // TTA v1.x
case "\x03": // TTA v1.x
-
+
// "It was the demo-version of the TTA encoder. There is no released format with such header. TTA encoder v1 is not supported about a year."
$getid3->info['tta']['major_version'] = 1;
$getid3->info['avdataoffset'] += 16;
-
- getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4,
array (
'channels' => 2,
'bits_per_sample' => 2,
'sample_rate' => 4,
'samples_per_channel' => 4
)
- );
+ );
$getid3->info['tta']['compression_level'] = ord($tta_header{3});
-
+
$getid3->info['audio']['encoder_options'] = '-e'.$getid3->info['tta']['compression_level'];
$getid3->info['playtime_seconds'] = $getid3->info['tta']['samples_per_channel'] / $getid3->info['tta']['sample_rate'];
break;
@@ -70,7 +70,7 @@ class getid3_tta extends getid3_handler
$getid3->info['tta']['major_version'] = 2;
$getid3->info['avdataoffset'] += 20;
- getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4,
+ getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4,
array (
'compression_level' => 2,
'audio_format' => 2,
@@ -79,8 +79,8 @@ class getid3_tta extends getid3_handler
'sample_rate' => 4,
'data_length' => 4
)
- );
-
+ );
+
$getid3->info['audio']['encoder_options'] = '-e'.$getid3->info['tta']['compression_level'];
$getid3->info['playtime_seconds'] = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate'];
break;
@@ -90,7 +90,7 @@ class getid3_tta extends getid3_handler
$getid3->info['tta']['major_version'] = 3;
$getid3->info['avdataoffset'] += 26;
- getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4,
+ getid3_lib::ReadSequence('LittleEndian2Int', $getid3->info['tta'], $tta_header, 4,
array (
'audio_format' => 2,
'channels' => 2,
@@ -98,9 +98,9 @@ class getid3_tta extends getid3_handler
'sample_rate' => 4,
'data_length' => 4,
'crc32_footer' => -4, // string
- 'seek_point' => 4
+ 'seek_point' => 4
)
- );
+ );
$getid3->info['playtime_seconds'] = $getid3->info['tta']['data_length'] / $getid3->info['tta']['sample_rate'];
break;
diff --git a/modules/getid3/module.audio.voc.php b/modules/getid3/module.audio.voc.php
index 01e7fe28..d2992c60 100644
--- a/modules/getid3/module.audio.voc.php
+++ b/modules/getid3/module.audio.voc.php
@@ -22,17 +22,17 @@
//
// $Id: module.audio.voc.php,v 1.3 2006/11/02 10:48:02 ah Exp $
-
-
+
+
class getid3_voc extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
$original_av_data_offset = $getid3->info['avdataoffset'];
-
+
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
$voc_header= fread($getid3->fp, 26);
@@ -59,9 +59,9 @@ class getid3_voc extends getid3_handler
getid3_lib::ReadSequence('LittleEndian2Int', $info_voc['header'], $voc_header, 20,
array (
- 'datablock_offset' => 2,
- 'minor_version' => 1,
- 'major_version' => 1
+ 'datablock_offset' => 2,
+ 'minor_version' => 1,
+ 'major_version' => 1
)
);
@@ -73,9 +73,9 @@ class getid3_voc extends getid3_handler
$this_block = array ();
@$info_voc['blocktypes'][$block_type]++;
-
+
switch ($block_type) {
-
+
case 0: // Terminator
// do nothing, we'll break out of the loop down below
break;
@@ -123,13 +123,13 @@ class getid3_voc extends getid3_handler
// Stereo: 65536 - (256000000 / (sample_rate * 2))
getid3_lib::ReadSequence('LittleEndian2Int', $this_block, $block_data, 4,
array (
- 'time_constant' => 2,
- 'pack_method' => 1,
- 'stereo' => 1
+ 'time_constant' => 2,
+ 'pack_method' => 1,
+ 'stereo' => 1
)
);
$this_block['stereo'] = (bool)$this_block['stereo'];
-
+
$info_audio['channels'] = ($this_block['stereo'] ? 2 : 1);
$info_audio['sample_rate'] = (int)floor((256000000 / (65536 - $this_block['time_constant'])) / $info_audio['channels']);
break;
@@ -145,11 +145,11 @@ class getid3_voc extends getid3_handler
array (
'sample_rate' => 4,
'bits_per_sample' => 1,
- 'channels' => 1,
- 'wFormat' => 2
+ 'channels' => 1,
+ 'wFormat' => 2
)
);
-
+
$this_block['compression_name'] = getid3_voc::VOCwFormatLookup($this_block['wFormat']);
if (getid3_voc::VOCwFormatActualBitsPerSampleLookup($this_block['wFormat'])) {
$info_voc['compressed_bits_per_sample'] = getid3_voc::VOCwFormatActualBitsPerSampleLookup($this_block['wFormat']);
@@ -191,7 +191,7 @@ class getid3_voc extends getid3_handler
public static function VOCcompressionTypeLookup($index) {
-
+
static $lookup = array (
0 => '8-bit',
1 => '4-bit',
@@ -204,7 +204,7 @@ class getid3_voc extends getid3_handler
public static function VOCwFormatLookup($index) {
-
+
static $lookup = array (
0x0000 => '8-bit unsigned PCM',
0x0001 => 'Creative 8-bit to 4-bit ADPCM',
@@ -221,7 +221,7 @@ class getid3_voc extends getid3_handler
public static function VOCwFormatActualBitsPerSampleLookup($index) {
-
+
static $lookup = array (
0x0000 => 8,
0x0001 => 4,
diff --git a/modules/getid3/module.audio.vqf.php b/modules/getid3/module.audio.vqf.php
index 7f4fc783..eef53d2c 100644
--- a/modules/getid3/module.audio.vqf.php
+++ b/modules/getid3/module.audio.vqf.php
@@ -22,14 +22,14 @@
//
// $Id: module.audio.vqf.php,v 1.3 2006/11/16 23:16:31 ah Exp $
-
-
+
+
class getid3_vqf extends getid3_handler
{
public function Analyze() {
-
- $getid3 = $this->getid3;
+
+ $getid3 = $this->getid3;
// based loosely on code from TTwinVQ by Jurgen Faul <jfaulØgmx*de>
// http://jfaul.de/atl or http://j-faul.virtualave.net/atl/atl.html
@@ -51,18 +51,18 @@ class getid3_vqf extends getid3_handler
$info_vqf_raw['header_tag'] = 'TWIN'; // Magic bytes
$info_vqf_raw['version'] = substr($vqf_header_data, 4, 8);
$info_vqf_raw['size'] = getid3_lib::BigEndian2Int(substr($vqf_header_data, 12, 4));
-
+
while (ftell($getid3->fp) < $getid3->info['avdataend']) {
$chunk_base_offset = ftell($getid3->fp);
$chunk_data = fread($getid3->fp, 8);
$chunk_name = substr($chunk_data, 0, 4);
-
+
if ($chunk_name == 'DATA') {
$getid3->info['avdataoffset'] = $chunk_base_offset;
break;
}
-
+
$chunk_size = getid3_lib::BigEndian2Int(substr($chunk_data, 4, 4));
if ($chunk_size > ($getid3->info['avdataend'] - ftell($getid3->fp))) {
throw new getid3_exception('Invalid chunk size ('.$chunk_size.') for chunk "'.$chunk_name.'" at offset 8.');
@@ -72,10 +72,10 @@ class getid3_vqf extends getid3_handler
}
switch ($chunk_name) {
-
+
case 'COMM':
$info_vqf['COMM'] = array ();
- getid3_lib::ReadSequence('BigEndian2Int', $info_vqf['COMM'], $chunk_data, 8,
+ getid3_lib::ReadSequence('BigEndian2Int', $info_vqf['COMM'], $chunk_data, 8,
array (
'channel_mode' => 4,
'bitrate' => 4,
@@ -131,11 +131,11 @@ class getid3_vqf extends getid3_handler
return true;
}
-
+
public static function VQFchannelFrequencyLookup($frequencyid) {
-
+
static $lookup = array (
11 => 11025,
22 => 22050,
@@ -147,7 +147,7 @@ class getid3_vqf extends getid3_handler
public static function VQFcommentNiceNameLookup($shortname) {
-
+
static $lookup = array (
'NAME' => 'title',
'AUTH' => 'artist',
diff --git a/modules/getid3/module.audio.wavpack.php b/modules/getid3/module.audio.wavpack.php
index 6a687a48..f1adf7bf 100644
--- a/modules/getid3/module.audio.wavpack.php
+++ b/modules/getid3/module.audio.wavpack.php
@@ -29,12 +29,12 @@ class getid3_wavpack extends getid3_handler
public function Analyze() {
$getid3 = $this->getid3;
-
+
$getid3->include_module('audio-video.riff');
-
+
$getid3->info['wavpack'] = array ();
$info_wavpack = &$getid3->info['wavpack'];
-
+
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
while (true) {
@@ -62,7 +62,7 @@ class getid3_wavpack extends getid3_handler
}
if ((@$info_wavpack_blockheader['block_samples'] <= 0) || (@$info_wavpack_blockheader['total_samples'] <= 0)) {
-
+
// Also, it is possible that the first block might not have
// any samples (block_samples == 0) and in this case you should skip blocks
// until you find one with samples because the other information (like
@@ -99,7 +99,7 @@ class getid3_wavpack extends getid3_handler
$info_wavpack_blockheader['track_number'] = ord($wavpack_header{10}); // unused
$info_wavpack_blockheader['index_number'] = ord($wavpack_header{11}); // unused
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_wavpack_blockheader, $wavpack_header, 12,
array (
'total_samples' => 4,
@@ -109,8 +109,8 @@ class getid3_wavpack extends getid3_handler
'crc' => 4
)
);
-
-
+
+
$info_wavpack_blockheader['flags']['bytes_per_sample'] = 1 + ($info_wavpack_blockheader['flags_raw'] & 0x00000003);
$info_wavpack_blockheader['flags']['mono'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000004);
$info_wavpack_blockheader['flags']['hybrid'] = (bool) ($info_wavpack_blockheader['flags_raw'] & 0x00000008);
@@ -146,7 +146,7 @@ class getid3_wavpack extends getid3_handler
// then the decoder simply ignores the metadata, but if it is zero
// then the decoder should quit because it means that an understanding
// of the metadata is required to correctly decode the audio.
-
+
$metablock['non_decoder'] = (bool) ($metablock['id'] & 0x20);
$metablock['padded_data'] = (bool) ($metablock['id'] & 0x40);
$metablock['large_block'] = (bool) ($metablock['id'] & 0x80);
@@ -204,24 +204,24 @@ class getid3_wavpack extends getid3_handler
switch ($metablock['function_id']) {
case 0x21: // ID_RIFF_HEADER
-
+
$original_wav_filesize = getid3_lib::LittleEndian2Int(substr($metablock['data'], 4, 4));
-
- // Clone getid3
+
+ // Clone getid3
$clone = clone $getid3;
-
+
// Analyze clone by string
$riff = new getid3_riff($clone);
$riff->AnalyzeString($metablock['data']);
-
+
// Import from clone and destroy
$metablock['riff'] = $clone->info['riff'];
$getid3->warnings($clone->warnings());
unset($clone);
-
+
// Save RIFF header - we may need it later for RIFF footer parsing
$this->riff_header = $metablock['data'];
-
+
$metablock['riff']['original_filesize'] = $original_wav_filesize;
$info_wavpack['riff_trailer_size'] = $original_wav_filesize - $metablock['riff']['WAVE']['data'][0]['size'] - $metablock['riff']['header_size'];
@@ -236,19 +236,19 @@ class getid3_wavpack extends getid3_handler
case 0x22: // ID_RIFF_TRAILER
$metablock_riff_footer = $metablock_riff_header.$metablock['data'];
-
+
$start_offset = $metablock['offset'] + ($metablock['large_block'] ? 4 : 2);
-
+
$ftell_old = ftell($getid3->fp);
-
- // Clone getid3
+
+ // Clone getid3
$clone = clone $getid3;
-
+
// Call public method that really should be private
$riff = new getid3_riff($clone);
$metablock['riff'] = $riff->ParseRIFF($start_offset, $start_offset + $metablock['size']);
unset($clone);
-
+
fseek($getid3->fp, $ftell_old, SEEK_SET);
if (!empty($metablock['riff']['INFO'])) {
@@ -342,7 +342,7 @@ class getid3_wavpack extends getid3_handler
}
}
-
+
if (!empty($metablock)) {
$info_wavpack['metablocks'][] = $metablock;
}
@@ -390,7 +390,7 @@ class getid3_wavpack extends getid3_handler
0x25 => 'Config Block',
0x26 => 'MD5 Checksum',
);
-
+
return (@$lookup[$id]);
}
diff --git a/modules/getid3/module.audio.xiph.php b/modules/getid3/module.audio.xiph.php
index b9100e8a..daf15806 100644
--- a/modules/getid3/module.audio.xiph.php
+++ b/modules/getid3/module.audio.xiph.php
@@ -23,45 +23,45 @@
//
// $Id: module.audio.xiph.php,v 1.5 2006/12/03 21:12:43 ah Exp $
-
-
+
+
class getid3_xiph extends getid3_handler
{
-
+
public function Analyze() {
-
+
$getid3 = $this->getid3;
-
- if ($getid3->option_tags_images) {
+
+ if ($getid3->option_tags_images) {
$getid3->include_module('lib.image_size');
}
-
+
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
-
+
$magic = fread($getid3->fp, 4);
-
+
if ($magic == 'OggS') {
return $this->ParseOgg();
}
-
+
if ($magic == 'fLaC') {
return $this->ParseFLAC();
}
-
+
}
-
-
-
+
+
+
private function ParseOgg() {
-
+
$getid3 = $this->getid3;
-
+
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
-
+
$getid3->info['audio'] = $getid3->info['ogg'] = array ();
- $info_ogg = &$getid3->info['ogg'];
+ $info_ogg = &$getid3->info['ogg'];
$info_audio = &$getid3->info['audio'];
-
+
$getid3->info['fileformat'] = 'ogg';
@@ -85,9 +85,9 @@ class getid3_xiph extends getid3_handler
$info_audio['bitrate_mode'] = 'vbr';
$info_audio['lossless'] = true;
- }
-
-
+ }
+
+
// Ogg Vorbis
elseif (substr($file_data, 1, 6) == 'vorbis') {
@@ -96,8 +96,8 @@ class getid3_xiph extends getid3_handler
$info_ogg['pageheader'][$ogg_page_info['page_seqno']]['packet_type'] = getid3_lib::LittleEndian2Int($file_data[0]);
$info_ogg['pageheader'][$ogg_page_info['page_seqno']]['stream_type'] = substr($file_data, 1, 6); // hard-coded to 'vorbis'
-
- getid3_lib::ReadSequence('LittleEndian2Int', $info_ogg, $file_data, 7,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_ogg, $file_data, 7,
array (
'bitstreamversion' => 4,
'numberofchannels' => 1,
@@ -107,12 +107,12 @@ class getid3_xiph extends getid3_handler
'bitrate_min' => 4
)
);
-
+
$n28 = getid3_lib::LittleEndian2Int($file_data{28});
$info_ogg['blocksize_small'] = pow(2, $n28 & 0x0F);
$info_ogg['blocksize_large'] = pow(2, ($n28 & 0xF0) >> 4);
$info_ogg['stop_bit'] = $n28;
-
+
$info_audio['channels'] = $info_ogg['numberofchannels'];
$info_audio['sample_rate'] = $info_ogg['samplerate'];
@@ -122,17 +122,17 @@ class getid3_xiph extends getid3_handler
unset($info_ogg['bitrate_max']);
$info_audio['bitrate_mode'] = 'abr';
}
-
+
if ($info_ogg['bitrate_nominal'] == 0xFFFFFFFF) {
unset($info_ogg['bitrate_nominal']);
}
-
+
if ($info_ogg['bitrate_min'] == 0xFFFFFFFF) {
unset($info_ogg['bitrate_min']);
$info_audio['bitrate_mode'] = 'abr';
}
}
-
+
// Speex
elseif (substr($file_data, 0, 8) == 'Speex ') {
@@ -144,10 +144,10 @@ class getid3_xiph extends getid3_handler
$info_audio['bitrate_mode'] = 'abr';
$info_audio['lossless'] = false;
- getid3_lib::ReadSequence('LittleEndian2Int', $info_ogg['pageheader'][$ogg_page_info['page_seqno']], $file_data, 0,
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_ogg['pageheader'][$ogg_page_info['page_seqno']], $file_data, 0,
array (
'speex_string' => -8, // hard-coded to 'Speex '
- 'speex_version' => -20, // string
+ 'speex_version' => -20, // string
'speex_version_id' => 4,
'header_size' => 4,
'rate' => 4,
@@ -163,7 +163,7 @@ class getid3_xiph extends getid3_handler
'reserved2' => 4
)
);
-
+
$getid3->info['speex']['speex_version'] = trim($info_ogg['pageheader'][$ogg_page_info['page_seqno']]['speex_version']);
$getid3->info['speex']['sample_rate'] = $info_ogg['pageheader'][$ogg_page_info['page_seqno']]['rate'];
$getid3->info['speex']['channels'] = $info_ogg['pageheader'][$ogg_page_info['page_seqno']]['nb_channels'];
@@ -172,7 +172,7 @@ class getid3_xiph extends getid3_handler
$info_audio['sample_rate'] = $getid3->info['speex']['sample_rate'];
$info_audio['channels'] = $getid3->info['speex']['channels'];
-
+
if ($getid3->info['speex']['vbr']) {
$info_audio['bitrate_mode'] = 'vbr';
}
@@ -216,7 +216,7 @@ class getid3_xiph extends getid3_handler
fseek($getid3->fp, max($getid3->info['avdataend'] - getid3::FREAD_BUFFER_SIZE, 0), SEEK_SET);
$last_chunk_of_ogg = strrev(fread($getid3->fp, getid3::FREAD_BUFFER_SIZE));
-
+
if ($last_OggS_postion = strpos($last_chunk_of_ogg, 'SggO')) {
fseek($getid3->fp, $getid3->info['avdataend'] - ($last_OggS_postion + strlen('SggO')), SEEK_SET);
$getid3->info['avdataend'] = ftell($getid3->fp);
@@ -268,15 +268,15 @@ class getid3_xiph extends getid3_handler
private function ParseOggPageHeader() {
-
+
$getid3 = $this->getid3;
-
+
// http://xiph.org/ogg/vorbis/doc/framing.html
$ogg_header['page_start_offset'] = ftell($getid3->fp); // where we started from in the file
-
+
$file_data = fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
$file_data_offset = 0;
-
+
while ((substr($file_data, $file_data_offset++, 4) != 'OggS')) {
if ((ftell($getid3->fp) - $ogg_header['page_start_offset']) >= getid3::FREAD_BUFFER_SIZE) {
// should be found before here
@@ -289,10 +289,10 @@ class getid3_xiph extends getid3_handler
}
}
}
-
+
$file_data_offset += 3; // page, delimited by 'OggS'
-
- getid3_lib::ReadSequence('LittleEndian2Int', $ogg_header, $file_data, $file_data_offset,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $ogg_header, $file_data, $file_data_offset,
array (
'stream_structver' => 1,
'flags_raw' => 1,
@@ -303,7 +303,7 @@ class getid3_xiph extends getid3_handler
'page_segments' => 1
)
);
-
+
$file_data_offset += 23;
$ogg_header['flags']['fresh'] = (bool)($ogg_header['flags_raw'] & 0x01); // fresh packet
@@ -323,9 +323,9 @@ class getid3_xiph extends getid3_handler
}
-
+
private function ParseVorbisCommentsFilepointer() {
-
+
$getid3 = $this->getid3;
$original_offset = ftell($getid3->fp);
@@ -334,7 +334,7 @@ class getid3_xiph extends getid3_handler
$vorbis_comment_page = 1;
switch ($getid3->info['audio']['dataformat']) {
-
+
case 'vorbis':
$comment_start_offset = $getid3->info['ogg']['pageheader'][$vorbis_comment_page]['page_start_offset']; // Second Ogg page, after header block
fseek($getid3->fp, $comment_start_offset, SEEK_SET);
@@ -342,13 +342,13 @@ class getid3_xiph extends getid3_handler
$comment_data = fread($getid3->fp, getid3_xiph::OggPageSegmentLength($getid3->info['ogg']['pageheader'][$vorbis_comment_page], 1) + $comment_data_offset);
$comment_data_offset += (strlen('vorbis') + 1);
break;
-
+
case 'flac':
fseek($getid3->fp, $getid3->info['flac']['VORBIS_COMMENT']['raw']['offset'] + 4, SEEK_SET);
$comment_data = fread($getid3->fp, $getid3->info['flac']['VORBIS_COMMENT']['raw']['block_length']);
break;
-
+
case 'speex':
$comment_start_offset = $getid3->info['ogg']['pageheader'][$vorbis_comment_page]['page_start_offset']; // Second Ogg page, after header block
@@ -356,7 +356,7 @@ class getid3_xiph extends getid3_handler
$comment_data_offset = 27 + $getid3->info['ogg']['pageheader'][$vorbis_comment_page]['page_segments'];
$comment_data = fread($getid3->fp, getid3_xiph::OggPageSegmentLength($getid3->info['ogg']['pageheader'][$vorbis_comment_page], 1) + $comment_data_offset);
break;
-
+
default:
return false;
@@ -370,7 +370,7 @@ class getid3_xiph extends getid3_handler
$comments_count = getid3_lib::LittleEndian2Int(substr($comment_data, $comment_data_offset, 4));
$comment_data_offset += 4;
-
+
$getid3->info['avdataoffset'] = $comment_start_offset + $comment_data_offset;
for ($i = 0; $i < $comments_count; $i++) {
@@ -405,7 +405,7 @@ class getid3_xiph extends getid3_handler
$comment_data_offset += 4;
while ((strlen($comment_data) - $comment_data_offset) < $getid3->info['ogg']['comments_raw'][$i]['size']) {
-
+
if (($getid3->info['ogg']['comments_raw'][$i]['size'] > $getid3->info['avdataend']) || ($getid3->info['ogg']['comments_raw'][$i]['size'] < 0)) {
throw new getid3_exception('Invalid Ogg comment size (comment #'.$i.', claims to be '.number_format($getid3->info['ogg']['comments_raw'][$i]['size']).' bytes) - aborting reading comments');
}
@@ -454,12 +454,12 @@ class getid3_xiph extends getid3_handler
$image_chunk_check = getid3_lib_image_size::get($getid3->info['ogg']['comments_raw'][$i]['data']);
$getid3->info['ogg']['comments_raw'][$i]['image_mime'] = image_type_to_mime_type($image_chunk_check[2]);
}
-
+
if (!@$getid3->info['ogg']['comments_raw'][$i]['image_mime'] || ($getid3->info['ogg']['comments_raw'][$i]['image_mime'] == 'application/octet-stream')) {
unset($getid3->info['ogg']['comments_raw'][$i]['image_mime']);
unset($getid3->info['ogg']['comments_raw'][$i]['data']);
}
-
+
} else {
@@ -495,7 +495,7 @@ class getid3_xiph extends getid3_handler
$getid3->info['replay_gain']['track']['peak'] = (float)$commentvalue[0];
unset($getid3->info['ogg']['comments'][$index]);
break;
-
+
case 'replaygain_reference_loudness':
$getid3->info['replay_gain']['reference_volume'] = (float)$commentvalue[0];
unset($getid3->info['ogg']['comments'][$index]);
@@ -512,9 +512,9 @@ class getid3_xiph extends getid3_handler
private function ParseFLAC() {
-
+
$getid3 = $this->getid3;
-
+
// http://flac.sourceforge.net/format.html
$getid3->info['fileformat'] = 'flac';
@@ -528,11 +528,11 @@ class getid3_xiph extends getid3_handler
private function FLACparseMETAdata() {
-
+
$getid3 = $this->getid3;
do {
-
+
$meta_data_block_offset = ftell($getid3->fp);
$meta_data_block_header = fread($getid3->fp, 4);
$meta_data_last_block_flag = (bool)(getid3_lib::BigEndian2Int($meta_data_block_header[0]) & 0x80);
@@ -590,7 +590,7 @@ class getid3_xiph extends getid3_handler
return false;
}
break;
-
+
case 'PICTURE':
if (!$this->FLACparsePICTURE($getid3->info['flac'][$meta_data_block_type_text]['raw']['block_data'])) {
return false;
@@ -648,9 +648,9 @@ class getid3_xiph extends getid3_handler
private function FLACparseSTREAMINFO($meta_data_block_data) {
-
+
$getid3 = $this->getid3;
-
+
getid3_lib::ReadSequence('BigEndian2Int', $getid3->info['flac']['STREAMINFO'], $meta_data_block_data, 0,
array (
'min_block_size' => 2,
@@ -661,7 +661,7 @@ class getid3_xiph extends getid3_handler
);
$sample_rate_channels_sample_bits_stream_samples = getid3_lib::BigEndian2Bin(substr($meta_data_block_data, 10, 8));
-
+
$getid3->info['flac']['STREAMINFO']['sample_rate'] = bindec(substr($sample_rate_channels_sample_bits_stream_samples, 0, 20));
$getid3->info['flac']['STREAMINFO']['channels'] = bindec(substr($sample_rate_channels_sample_bits_stream_samples, 20, 3)) + 1;
$getid3->info['flac']['STREAMINFO']['bits_per_sample'] = bindec(substr($sample_rate_channels_sample_bits_stream_samples, 23, 5)) + 1;
@@ -681,7 +681,7 @@ class getid3_xiph extends getid3_handler
throw new getid3_exception('Corrupt METAdata block: STREAMINFO');
}
-
+
unset($getid3->info['flac']['STREAMINFO']['raw']);
return true;
@@ -690,14 +690,14 @@ class getid3_xiph extends getid3_handler
private function FLACparseAPPLICATION($meta_data_block_data) {
-
+
$getid3 = $this->getid3;
-
+
$application_id = getid3_lib::BigEndian2Int(substr($meta_data_block_data, 0, 4));
-
+
$getid3->info['flac']['APPLICATION'][$application_id]['name'] = getid3_xiph::FLACapplicationIDLookup($application_id);
$getid3->info['flac']['APPLICATION'][$application_id]['data'] = substr($meta_data_block_data, 4);
-
+
unset($getid3->info['flac']['APPLICATION']['raw']);
return true;
@@ -706,9 +706,9 @@ class getid3_xiph extends getid3_handler
private function FLACparseSEEKTABLE($meta_data_block_data) {
-
+
$getid3 = $this->getid3;
-
+
$offset = 0;
$meta_data_block_length = strlen($meta_data_block_data);
while ($offset < $meta_data_block_length) {
@@ -723,36 +723,36 @@ class getid3_xiph extends getid3_handler
} else {
$sample_number = getid3_lib::BigEndian2Int($sample_number_string);
-
+
$getid3->info['flac']['SEEKTABLE'][$sample_number]['offset'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 8));
$offset += 8;
-
+
$getid3->info['flac']['SEEKTABLE'][$sample_number]['samples'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 2));
$offset += 2;
}
}
-
+
unset($getid3->info['flac']['SEEKTABLE']['raw']);
-
+
return true;
}
private function FLACparseCUESHEET($meta_data_block_data) {
-
+
$getid3 = $this->getid3;
-
+
$getid3->info['flac']['CUESHEET']['media_catalog_number'] = trim(substr($meta_data_block_data, 0, 128), "\0");
$getid3->info['flac']['CUESHEET']['lead_in_samples'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, 128, 8));
$getid3->info['flac']['CUESHEET']['flags']['is_cd'] = (bool)(getid3_lib::BigEndian2Int($meta_data_block_data[136]) & 0x80);
$getid3->info['flac']['CUESHEET']['number_tracks'] = getid3_lib::BigEndian2Int($meta_data_block_data[395]);
$offset = 396;
-
+
for ($track = 0; $track < $getid3->info['flac']['CUESHEET']['number_tracks']; $track++) {
-
+
$track_sample_offset = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 8));
$offset += 8;
@@ -771,74 +771,74 @@ class getid3_xiph extends getid3_handler
$getid3->info['flac']['CUESHEET']['tracks'][$track_number]['index_points'] = getid3_lib::BigEndian2Int($meta_data_block_data{$offset++});
for ($index = 0; $index < $getid3->info['flac']['CUESHEET']['tracks'][$track_number]['index_points']; $index++) {
-
+
$index_sample_offset = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 8));
$offset += 8;
-
+
$index_number = getid3_lib::BigEndian2Int($meta_data_block_data{$offset++});
$getid3->info['flac']['CUESHEET']['tracks'][$track_number]['indexes'][$index_number] = $index_sample_offset;
-
+
$offset += 3; // reserved
}
}
-
+
unset($getid3->info['flac']['CUESHEET']['raw']);
-
+
return true;
}
-
-
-
+
+
+
private function FLACparsePICTURE($meta_data_block_data) {
-
+
$getid3 = $this->getid3;
-
+
$picture = &$getid3->info['flac']['PICTURE'][sizeof($getid3->info['flac']['PICTURE']) - 1];
-
+
$offset = 0;
-
+
$picture['type'] = $this->FLACpictureTypeLookup(getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4)));
$offset += 4;
-
+
$length = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
$offset += 4;
-
+
$picture['mime_type'] = substr($meta_data_block_data, $offset, $length);
$offset += $length;
-
+
$length = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
$offset += 4;
-
+
$picture['description'] = substr($meta_data_block_data, $offset, $length);
$offset += $length;
-
+
$picture['width'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
$offset += 4;
-
+
$picture['height'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
$offset += 4;
-
+
$picture['color_depth'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
$offset += 4;
-
+
$picture['colors_indexed'] = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
$offset += 4;
-
+
$length = getid3_lib::BigEndian2Int(substr($meta_data_block_data, $offset, 4));
$offset += 4;
-
+
$picture['image_data'] = substr($meta_data_block_data, $offset, $length);
$offset += $length;
-
+
unset($getid3->info['flac']['PICTURE']['raw']);
-
+
return true;
}
-
-
-
+
+
+
public static function SpeexBandModeLookup($mode) {
-
+
static $lookup = array (
0 => 'narrow',
1 => 'wide',
@@ -851,8 +851,8 @@ class getid3_xiph extends getid3_handler
public static function OggPageSegmentLength($ogg_info_array, $segment_number=1) {
- if (!is_array($ogg_info_array['segment_table'])) { $ogg_info_array['segment_table'] = array(); }
-
+ if (!is_array($ogg_info_array['segment_table'])) { $ogg_info_array['segment_table'] = array(); }
+
for ($i = 0; $i < $segment_number; $i++) {
$segment_length = 0;
foreach ($ogg_info_array['segment_table'] as $key => $value) {
@@ -862,7 +862,7 @@ class getid3_xiph extends getid3_handler
}
}
}
- $segment_length = !$segment_length ? '1' : $segment_length;
+ $segment_length = !$segment_length ? '1' : $segment_length;
return $segment_length;
}
@@ -888,11 +888,11 @@ class getid3_xiph extends getid3_handler
}
return round($qval, 1); // 5 or 4.9
}
-
-
-
+
+
+
public static function FLACmetaBlockTypeLookup($block_type) {
-
+
static $lookup = array (
0 => 'STREAMINFO',
1 => 'PADDING',
@@ -908,24 +908,24 @@ class getid3_xiph extends getid3_handler
public static function FLACapplicationIDLookup($application_id) {
-
+
// http://flac.sourceforge.net/id.html
-
+
static $lookup = array (
0x46746F6C => 'flac-tools', // 'Ftol'
0x46746F6C => 'Sound Font FLAC', // 'SFFL'
0x7065656D => 'Parseable Embedded Extensible Metadata (specification)', // 'peem'
0x786D6364 => 'xmcd'
-
+
);
return (isset($lookup[$application_id]) ? $lookup[$application_id] : 'reserved');
}
public static function FLACpictureTypeLookup($type_id) {
-
+
static $lookup = array (
-
+
0 => 'Other',
1 => "32x32 pixels 'file icon' (PNG only)",
2 => 'Other file icon',
diff --git a/modules/getid3/module.graphic.bmp.php b/modules/getid3/module.graphic.bmp.php
index 43dc9914..1769e849 100644
--- a/modules/getid3/module.graphic.bmp.php
+++ b/modules/getid3/module.graphic.bmp.php
@@ -22,8 +22,8 @@
//
// $Id: module.graphic.bmp.php,v 1.4 2006/11/02 10:48:02 ah Exp $
-
-
+
+
class getid3_bmp extends getid3_handler
{
@@ -39,7 +39,7 @@ class getid3_bmp extends getid3_handler
// WORD bfReserved1;
// WORD bfReserved2;
// DWORD bfOffBits;
-
+
// shortcuts
$getid3->info['bmp']['header']['raw'] = array ();
$info_bmp = &$getid3->info['bmp'];
@@ -51,7 +51,7 @@ class getid3_bmp extends getid3_handler
// Magic bytes
$info_bmp_header_raw['identifier'] = 'BM';
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_bmp_header_raw, $bmp_header, 2,
array (
'filesize' => 4,
@@ -61,34 +61,34 @@ class getid3_bmp extends getid3_handler
'header_size' => 4
)
);
-
+
// Check if the hardcoded-to-1 "planes" is at offset 22 or 26
$planes22 = getid3_lib::LittleEndian2Int(substr($bmp_header, 22, 2));
$planes26 = getid3_lib::LittleEndian2Int(substr($bmp_header, 26, 2));
if (($planes22 == 1) && ($planes26 != 1)) {
$info_bmp['type_os'] = 'OS/2';
$info_bmp['type_version'] = 1;
- }
+ }
elseif (($planes26 == 1) && ($planes22 != 1)) {
$info_bmp['type_os'] = 'Windows';
$info_bmp['type_version'] = 1;
- }
+ }
elseif ($info_bmp_header_raw['header_size'] == 12) {
$info_bmp['type_os'] = 'OS/2';
$info_bmp['type_version'] = 1;
- }
+ }
elseif ($info_bmp_header_raw['header_size'] == 40) {
$info_bmp['type_os'] = 'Windows';
$info_bmp['type_version'] = 1;
- }
+ }
elseif ($info_bmp_header_raw['header_size'] == 84) {
$info_bmp['type_os'] = 'Windows';
$info_bmp['type_version'] = 4;
- }
+ }
elseif ($info_bmp_header_raw['header_size'] == 100) {
$info_bmp['type_os'] = 'Windows';
$info_bmp['type_version'] = 5;
- }
+ }
else {
throw new getid3_exception('Unknown BMP subtype (or not a BMP file)');
}
@@ -108,7 +108,7 @@ class getid3_bmp extends getid3_handler
// DWORD Height; /* Bitmap height in pixel */
// WORD NumPlanes; /* Number of bit planes (color depth) */
// WORD BitsPerPixel; /* Number of bits per pixel per plane */
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_bmp_header_raw, $bmp_header, 18,
array (
'width' => 2,
@@ -117,12 +117,12 @@ class getid3_bmp extends getid3_handler
'bits_per_pixel' => 2
)
);
-
+
$getid3->info['video']['resolution_x'] = $info_bmp_header_raw['width'];
$getid3->info['video']['resolution_y'] = $info_bmp_header_raw['height'];
$getid3->info['video']['codec'] = 'BI_RGB '.$info_bmp_header_raw['bits_per_pixel'].'-bit';
$getid3->info['video']['bits_per_sample'] = $info_bmp_header_raw['bits_per_pixel'];
-
+
if ($info_bmp['type_version'] >= 2) {
// DWORD Compression; /* Bitmap compression scheme */
// DWORD ImageDataSize; /* Size of bitmap data in bytes */
@@ -138,7 +138,7 @@ class getid3_bmp extends getid3_handler
// DWORD Size2; /* Reserved for halftoning algorithm use */
// DWORD ColorEncoding; /* Color model used in bitmap */
// DWORD Identifier; /* Reserved for application use */
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_bmp_header_raw, $bmp_header, 26,
array (
'compression' => 4,
@@ -161,11 +161,11 @@ class getid3_bmp extends getid3_handler
$info_bmp_header['compression'] = getid3_bmp::BMPcompressionOS2Lookup($info_bmp_header_raw['compression']);
$getid3->info['video']['codec'] = $info_bmp_header['compression'].' '.$info_bmp_header_raw['bits_per_pixel'].'-bit';
}
-
+
return true;
- }
-
-
+ }
+
+
if ($info_bmp['type_os'] == 'Windows') {
// Windows-format BMP
@@ -201,7 +201,7 @@ class getid3_bmp extends getid3_handler
foreach (array ('width', 'height', 'resolution_h', 'resolution_v') as $key) {
$info_bmp_header_raw[$key] = getid3_lib::LittleEndian2Int($info_bmp_header_raw[$key], true);
}
-
+
$info_bmp_header['compression'] = getid3_bmp::BMPcompressionWindowsLookup($info_bmp_header_raw['compression']);
$getid3->info['video']['resolution_x'] = $info_bmp_header_raw['width'];
$getid3->info['video']['resolution_y'] = $info_bmp_header_raw['height'];
@@ -210,8 +210,8 @@ class getid3_bmp extends getid3_handler
// should only be v4+, but BMPs with type_version==1 and BI_BITFIELDS compression have been seen
if (($info_bmp['type_version'] >= 4) || ($info_bmp_header_raw['compression'] == 3)) {
-
-
+
+
$bmp_header .= fread($getid3->fp, 44);
// BITMAPV4HEADER - [44 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_2k1e.asp
@@ -225,7 +225,7 @@ class getid3_bmp extends getid3_handler
// DWORD bV4GammaRed;
// DWORD bV4GammaGreen;
// DWORD bV4GammaBlue;
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_bmp_header_raw, $bmp_header, 54,
array (
'red_mask' => 4,
@@ -241,22 +241,22 @@ class getid3_bmp extends getid3_handler
'gamma_blue' => 4
)
);
-
+
$info_bmp_header['ciexyz_red'] = getid3_bmp::FixedPoint2_30(strrev($info_bmp_header_raw['ciexyz_red']));
$info_bmp_header['ciexyz_green'] = getid3_bmp::FixedPoint2_30(strrev($info_bmp_header_raw['ciexyz_green']));
$info_bmp_header['ciexyz_blue'] = getid3_bmp::FixedPoint2_30(strrev($info_bmp_header_raw['ciexyz_blue']));
-
+
if ($info_bmp['type_version'] >= 5) {
$bmp_header .= fread($getid3->fp, 16);
-
+
// BITMAPV5HEADER - [16 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_7c36.asp
// Win98+, Win2000+
// DWORD bV5Intent;
// DWORD bV5ProfileData;
// DWORD bV5ProfileSize;
// DWORD bV5Reserved;
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_bmp_header_raw, $bmp_header, 98,
array (
'intent' => 4,
@@ -265,16 +265,16 @@ class getid3_bmp extends getid3_handler
'reserved3' => 4
)
);
-
+
}
}
-
+
return true;
}
throw new getid3_exception('Unknown BMP format in header.');
-
+
}
@@ -295,7 +295,7 @@ class getid3_bmp extends getid3_handler
public static function BMPcompressionOS2Lookup($compression_id) {
-
+
static $lookup = array (
0 => 'BI_RGB',
1 => 'BI_RLE8',
@@ -305,10 +305,10 @@ class getid3_bmp extends getid3_handler
);
return (isset($lookup[$compression_id]) ? $lookup[$compression_id] : 'invalid');
}
-
-
+
+
public static function FixedPoint2_30($raw_data) {
-
+
$binary_string = getid3_lib::BigEndian2Bin($raw_data);
return bindec(substr($binary_string, 0, 2)) + (float)(bindec(substr($binary_string, 2, 30)) / 1073741824); // pow(2, 30) = 1073741824
}
diff --git a/modules/getid3/module.graphic.gif.php b/modules/getid3/module.graphic.gif.php
index 67e39592..b0605f29 100644
--- a/modules/getid3/module.graphic.gif.php
+++ b/modules/getid3/module.graphic.gif.php
@@ -22,20 +22,20 @@
//
// $Id: module.graphic.gif.php,v 1.2 2006/11/02 10:48:02 ah Exp $
-
-
+
+
class getid3_gif extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
$getid3->info['fileformat'] = 'gif';
$getid3->info['video']['dataformat'] = 'gif';
$getid3->info['video']['lossless'] = true;
$getid3->info['video']['pixel_aspect_ratio'] = (float)1;
-
+
$getid3->info['gif']['header'] = array ();
$info_gif_header = &$getid3->info['gif']['header'];
@@ -44,7 +44,7 @@ class getid3_gif extends getid3_handler
// Magic bytes
$info_gif_header['raw']['identifier'] = 'GIF';
-
+
getid3_lib::ReadSequence('LittleEndian2Int', $info_gif_header['raw'], $gif_header, 3,
array (
'version' => -3, // string
@@ -59,16 +59,16 @@ class getid3_gif extends getid3_handler
$getid3->info['video']['resolution_x'] = $info_gif_header['raw']['width'];
$getid3->info['video']['resolution_y'] = $info_gif_header['raw']['height'];
$getid3->info['gif']['version'] = $info_gif_header['raw']['version'];
-
+
$info_gif_header['flags']['global_color_table'] = (bool)($info_gif_header['raw']['flags'] & 0x80);
-
+
if ($info_gif_header['raw']['flags'] & 0x80) {
// Number of bits per primary color available to the original image, minus 1
$info_gif_header['bits_per_pixel'] = 3 * ((($info_gif_header['raw']['flags'] & 0x70) >> 4) + 1);
} else {
$info_gif_header['bits_per_pixel'] = 0;
}
-
+
$info_gif_header['flags']['global_color_sorted'] = (bool)($info_gif_header['raw']['flags'] & 0x40);
if ($info_gif_header['flags']['global_color_table']) {
// the number of bytes contained in the Global Color Table. To determine that
@@ -78,7 +78,7 @@ class getid3_gif extends getid3_handler
} else {
$info_gif_header['global_color_size'] = 0;
}
-
+
if ($info_gif_header['raw']['aspect_ratio'] != 0) {
// Aspect Ratio = (Pixel Aspect Ratio + 15) / 64
$info_gif_header['aspect_ratio'] = ($info_gif_header['raw']['aspect_ratio'] + 15) / 64;
diff --git a/modules/getid3/module.graphic.jpeg.php b/modules/getid3/module.graphic.jpeg.php
index 2dea8bb3..b9ae489a 100644
--- a/modules/getid3/module.graphic.jpeg.php
+++ b/modules/getid3/module.graphic.jpeg.php
@@ -22,13 +22,13 @@
//
// $Id: module.graphic.jpeg.php,v 1.4 2006/11/02 10:48:02 ah Exp $
-
-
+
+
class getid3_jpeg extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
$getid3->info['fileformat'] = 'jpg';
@@ -40,7 +40,7 @@ class getid3_jpeg extends getid3_handler
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
list($getid3->info['video']['resolution_x'], $getid3->info['video']['resolution_y'], $type) = getimagesize($getid3->filename);
-
+
if ($type != 2) {
throw new getid3_exception('File detected as JPEG, but is currupt.');
}
diff --git a/modules/getid3/module.graphic.pcd.php b/modules/getid3/module.graphic.pcd.php
index bf8288fe..c0c5dc5d 100644
--- a/modules/getid3/module.graphic.pcd.php
+++ b/modules/getid3/module.graphic.pcd.php
@@ -22,14 +22,14 @@
//
// $Id: module.graphic.pcd.php,v 1.2 2006/11/02 10:48:02 ah Exp $
-
-
+
+
class getid3_pcd extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
$getid3->info['fileformat'] = 'pcd';
diff --git a/modules/getid3/module.graphic.png.php b/modules/getid3/module.graphic.png.php
index e697e961..0593b98f 100644
--- a/modules/getid3/module.graphic.png.php
+++ b/modules/getid3/module.graphic.png.php
@@ -22,8 +22,8 @@
//
// $Id: module.graphic.png.php,v 1.4 2006/11/02 10:48:02 ah Exp $
-
-
+
+
class getid3_png extends getid3_handler
{
@@ -46,20 +46,20 @@ class getid3_png extends getid3_handler
$offset = 8;
while (((ftell($getid3->fp) - (strlen($png_filedata) - $offset)) < $getid3->info['filesize'])) {
-
+
$chunk['data_length'] = getid3_lib::BigEndian2Int(substr($png_filedata, $offset, 4));
$offset += 4;
while (((strlen($png_filedata) - $offset) < ($chunk['data_length'] + 4)) && (ftell($getid3->fp) < $getid3->info['filesize'])) {
$png_filedata .= fread($getid3->fp, getid3::FREAD_BUFFER_SIZE);
}
-
+
$chunk['type_text'] = substr($png_filedata, $offset, 4);
$chunk['type_raw'] = getid3_lib::BigEndian2Int($chunk['type_text']);
$offset += 4;
-
+
$chunk['data'] = substr($png_filedata, $offset, $chunk['data_length']);
$offset += $chunk['data_length'];
-
+
$chunk['crc'] = getid3_lib::BigEndian2Int(substr($png_filedata, $offset, 4));
$offset += 4;
@@ -78,8 +78,8 @@ class getid3_png extends getid3_handler
$info_png_chunk_type_text['header'] = $chunk;
$info_png_chunk_type_text['width'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 0, 4));
$info_png_chunk_type_text['height'] = getid3_lib::BigEndian2Int(substr($chunk['data'], 4, 4));
-
- getid3_lib::ReadSequence('BigEndian2Int', $info_png_chunk_type_text['raw'], $chunk['data'], 8,
+
+ getid3_lib::ReadSequence('BigEndian2Int', $info_png_chunk_type_text['raw'], $chunk['data'], 8,
array (
'bit_depth' => 1,
'color_type' => 1,
@@ -196,12 +196,12 @@ class getid3_png extends getid3_handler
$info_png_chunk_type_text['compression_method'] = getid3_lib::BigEndian2Int(substr($otherdata, 0, 1));
$info_png_chunk_type_text['compressed_text'] = substr($otherdata, 1);
$info_png_chunk_type_text['compression_method_text'] = getid3_png::PNGcompressionMethodLookup($info_png_chunk_type_text['compression_method']);
-
+
if ($info_png_chunk_type_text['compression_method'] != 0) {
// unknown compression method
break;
}
-
+
if (function_exists('gzuncompress')) {
$info_png_chunk_type_text['text'] = gzuncompress($info_png_chunk_type_text['compressed_text']);
}
@@ -211,7 +211,7 @@ class getid3_png extends getid3_handler
}
$this->zlib_warning = true;
}
-
+
if (isset($info_png_chunk_type_text['text'])) {
$info_png['comments'][$info_png_chunk_type_text['keyword']][] = $info_png_chunk_type_text['text'];
@@ -308,14 +308,14 @@ class getid3_png extends getid3_handler
$info_png_chunk_type_text['significant_bits_red'] = getid3_lib::BigEndian2Int($chunk['data'][0]);
$info_png_chunk_type_text['significant_bits_green'] = getid3_lib::BigEndian2Int($chunk['data'][1]);
$info_png_chunk_type_text['significant_bits_blue'] = getid3_lib::BigEndian2Int($chunk['data'][2]);
- break;
-
- case 4:
+ break;
+
+ case 4:
$info_png_chunk_type_text['significant_bits_gray'] = getid3_lib::BigEndian2Int($chunk['data'][0]);
$info_png_chunk_type_text['significant_bits_alpha'] = getid3_lib::BigEndian2Int($chunk['data'][1]);
- break;
-
- case 6:
+ break;
+
+ case 6:
$info_png_chunk_type_text['significant_bits_red'] = getid3_lib::BigEndian2Int($chunk['data'][0]);
$info_png_chunk_type_text['significant_bits_green'] = getid3_lib::BigEndian2Int($chunk['data'][1]);
$info_png_chunk_type_text['significant_bits_blue'] = getid3_lib::BigEndian2Int($chunk['data'][2]);
@@ -330,32 +330,32 @@ class getid3_png extends getid3_handler
case 'sPLT': // Suggested Palette
$info_png_chunk_type_text['header'] = $chunk;
-
+
list($palettename, $otherdata) = explode("\x00", $chunk['data'], 2);
$info_png_chunk_type_text['palette_name'] = $palettename;
-
+
$info_png_chunk_type_text['sample_depth_bits'] = getid3_lib::BigEndian2Int($otherdata[0]);
$info_png_chunk_type_text['sample_depth_bytes'] = $info_png_chunk_type_text['sample_depth_bits'] / 8;
-
+
$s_plt_offset = 1;
$paletteCounter = 0;
while ($s_plt_offset < strlen($otherdata)) {
-
+
$info_png_chunk_type_text['red'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $s_plt_offset, $info_png_chunk_type_text['sample_depth_bytes']));
$s_plt_offset += $info_png_chunk_type_text['sample_depth_bytes'];
-
+
$info_png_chunk_type_text['green'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $s_plt_offset, $info_png_chunk_type_text['sample_depth_bytes']));
$s_plt_offset += $info_png_chunk_type_text['sample_depth_bytes'];
-
+
$info_png_chunk_type_text['blue'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $s_plt_offset, $info_png_chunk_type_text['sample_depth_bytes']));
$s_plt_offset += $info_png_chunk_type_text['sample_depth_bytes'];
-
+
$info_png_chunk_type_text['alpha'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $s_plt_offset, $info_png_chunk_type_text['sample_depth_bytes']));
$s_plt_offset += $info_png_chunk_type_text['sample_depth_bytes'];
-
+
$info_png_chunk_type_text['frequency'][$paletteCounter] = getid3_lib::BigEndian2Int(substr($otherdata, $s_plt_offset, 2));
$s_plt_offset += 2;
-
+
$paletteCounter++;
}
break;
@@ -465,7 +465,7 @@ class getid3_png extends getid3_handler
public static function PNGsRGBintentLookup($sRGB) {
-
+
static $lookup = array (
0 => 'Perceptual',
1 => 'Relative colorimetric',
@@ -478,14 +478,14 @@ class getid3_png extends getid3_handler
public static function PNGcompressionMethodLookup($compression_method) {
-
+
return ($compression_method == 0 ? 'deflate/inflate' : 'invalid');
}
-
-
+
+
public static function PNGpHYsUnitLookup($unit_id) {
-
+
static $lookup = array (
0 => 'unknown',
1 => 'meter'
@@ -493,10 +493,10 @@ class getid3_png extends getid3_handler
return (isset($lookup[$unit_id]) ? $lookup[$unit_id] : 'invalid');
}
-
-
+
+
public static function PNGoFFsUnitLookup($unit_id) {
-
+
static $lookup = array (
0 => 'pixel',
1 => 'micrometer'
@@ -504,10 +504,10 @@ class getid3_png extends getid3_handler
return (isset($lookup[$unit_id]) ? $lookup[$unit_id] : 'invalid');
}
-
-
+
+
public static function PNGpCALequationTypeLookup($equation_type) {
-
+
static $lookup = array (
0 => 'Linear mapping',
1 => 'Base-e exponential mapping',
@@ -528,10 +528,10 @@ class getid3_png extends getid3_handler
return (isset($lookup[$unit_id]) ? $lookup[$unit_id] : 'invalid');
}
-
-
+
+
public static function IHDRcalculateBitsPerSample($color_type, $bit_depth) {
-
+
switch ($color_type) {
case 0: // Each pixel is a grayscale sample.
return $bit_depth;
diff --git a/modules/getid3/module.graphic.tiff.php b/modules/getid3/module.graphic.tiff.php
index 45478cb8..75663777 100644
--- a/modules/getid3/module.graphic.tiff.php
+++ b/modules/getid3/module.graphic.tiff.php
@@ -22,13 +22,13 @@
//
// $Id: module.graphic.tiff.php,v 1.2 2006/11/02 10:48:02 ah Exp $
-
-
+
+
class getid3_tiff extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
@@ -36,7 +36,7 @@ class getid3_tiff extends getid3_handler
$getid3->info['tiff']['byte_order'] = substr($tiff_header, 0, 2) == 'II' ? 'Intel' : 'Motorola';
$endian2int = substr($tiff_header, 0, 2) == 'II' ? 'LittleEndian2Int' : 'BigEndian2Int';
-
+
$getid3->info['fileformat'] = 'tiff';
$getid3->info['video']['dataformat'] = 'tiff';
$getid3->info['video']['lossless'] = true;
@@ -55,11 +55,11 @@ class getid3_tiff extends getid3_handler
$current_ifd['fieldcount'] = getid3_lib::$endian2int(fread($getid3->fp, 2));
for ($i = 0; $i < $current_ifd['fieldcount']; $i++) {
-
+
// shortcut
$current_ifd['fields'][$i] = array ();
$current_ifd_fields_i = &$current_ifd['fields'][$i];
-
+
$current_ifd_fields_i['raw']['tag'] = getid3_lib::$endian2int(fread($getid3->fp, 2));
$current_ifd_fields_i['raw']['type'] = getid3_lib::$endian2int(fread($getid3->fp, 2));
$current_ifd_fields_i['raw']['length'] = getid3_lib::$endian2int(fread($getid3->fp, 4));
@@ -183,7 +183,7 @@ class getid3_tiff extends getid3_handler
public static function TIFFcompressionMethod($id) {
-
+
static $lookup = array (
1 => 'Uncompressed',
2 => 'Huffman',
@@ -197,7 +197,7 @@ class getid3_tiff extends getid3_handler
public static function TIFFcommentName($id) {
-
+
static $lookup = array (
270 => 'imagedescription',
271 => 'make',
diff --git a/modules/getid3/module.lib.data_hash.php b/modules/getid3/module.lib.data_hash.php
index 4ec541c6..00032db8 100644
--- a/modules/getid3/module.lib.data_hash.php
+++ b/modules/getid3/module.lib.data_hash.php
@@ -26,23 +26,23 @@
class getid3_lib_data_hash
{
-
+
private $getid3;
-
-
+
+
// constructer - calculate md5/sha1 data
public function __construct(getID3 $getid3, $algorithm) {
-
+
$this->getid3 = $getid3;
-
+
// Check algorithm
if (!preg_match('/^(md5|sha1)$/', $algorithm)) {
throw new getid3_exception('Unsupported algorithm, "'.$algorithm.'", in GetHashdata()');
}
-
-
+
+
//// Handle ogg vorbis files
-
+
if ((@$getid3->info['fileformat'] == 'ogg') && (@$getid3->info['audio']['dataformat'] == 'vorbis')) {
// We cannot get an identical md5_data value for Ogg files where the comments
@@ -66,11 +66,11 @@ class getid3_lib_data_hash
if ((bool)ini_get('safe_mode')) {
throw new getid3_exception('PHP running in Safe Mode - cannot make system call to vorbiscomment[.exe] needed for '.$algorithm.'_data.');
}
-
+
if (!preg_match('/^Vorbiscomment /', `vorbiscomment --version 2>&1`)) {
throw new getid3_exception('vorbiscomment[.exe] binary not found in path. UNIX: typically /usr/bin. Windows: typically c:\windows\system32.');
}
-
+
// Prevent user from aborting script
$old_abort = ignore_user_abort(true);
@@ -80,13 +80,13 @@ class getid3_lib_data_hash
// Use vorbiscomment to make temp file without comments
$temp = tempnam('*', 'getID3');
-
+
$command_line = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg(realpath($getid3->filename)).' '.escapeshellarg($temp).' 2>&1';
// Error from vorbiscomment
if ($vorbis_comment_error = `$command_line`) {
throw new getid3_exception('System call to vorbiscomment[.exe] failed.');
- }
+ }
// Get hash of newly created file
$hash_function = $algorithm . '_file';
@@ -98,16 +98,16 @@ class getid3_lib_data_hash
// Reset abort setting
ignore_user_abort($old_abort);
-
+
// Return success
return true;
}
//// Handle other file formats
-
+
// Get hash from part of file
if (@$getid3->info['avdataoffset'] || (@$getid3->info['avdataend'] && @$getid3->info['avdataend'] < $getid3->info['filesize'])) {
-
+
if ((bool)ini_get('safe_mode')) {
$getid3->warning('PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm.');
$hash_function = 'hash_file_partial_safe_mode';
@@ -115,52 +115,52 @@ class getid3_lib_data_hash
else {
$hash_function = 'hash_file_partial';
}
-
+
$getid3->info[$algorithm.'_data'] = $this->$hash_function($getid3->filename, $getid3->info['avdataoffset'], $getid3->info['avdataend'], $algorithm);
- }
-
+ }
+
// Get hash from whole file - use built-in md5_file() and sha1_file()
else {
$hash_function = $algorithm . '_file';
$getid3->info[$algorithm.'_data'] = $hash_function($getid3->filename);
}
}
-
-
-
+
+
+
// Return md5/sha1sum for a file from starting position to absolute end position
// Using windows system call
private function hash_file_partial($file, $offset, $end, $algorithm) {
-
+
// It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
// Fall back to create-temp-file method:
if ($algorithm == 'sha1' && strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
return $this->hash_file_partial_safe_mode($file, $offset, $end, $algorithm);
}
-
+
// Check for presence of binaries and revert to safe mode if not found
if (!`head --version`) {
return $this->hash_file_partial_safe_mode($file, $offset, $end, $algorithm);
}
-
+
if (!`tail --version`) {
return $this->hash_file_partial_safe_mode($file, $offset, $end, $algorithm);
}
-
+
if (!`${algorithm}sum --version`) {
return $this->hash_file_partial_safe_mode($file, $offset, $end, $algorithm);
- }
-
+ }
+
$size = $end - $offset;
$command_line = 'head -c'.$end.' '.escapeshellarg(realpath($file)).' | tail -c'.$size.' | '.$algorithm.'sum';
return substr(`$command_line`, 0, $algorithm == 'md5' ? 32 : 40);
}
-
-
+
+
// Return md5/sha1sum for a file from starting position to absolute end position
// Using slow safe_mode temp file
- private function hash_file_partial_safe_mode($file, $offset, $end, $algorithm) {
+ private function hash_file_partial_safe_mode($file, $offset, $end, $algorithm) {
// Attempt to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
if (($data_filename = tempnam('*', 'getID3')) === false) {
diff --git a/modules/getid3/module.lib.iconv_replacement.php b/modules/getid3/module.lib.iconv_replacement.php
index 1c5b2fd0..997fe4ce 100644
--- a/modules/getid3/module.lib.iconv_replacement.php
+++ b/modules/getid3/module.lib.iconv_replacement.php
@@ -31,27 +31,27 @@ class getid3_iconv_replacement
if ($in_charset == $out_charset) {
return $string;
}
-
+
static $supported_charsets = array (
- 'ISO-8859-1' => 'iso88591',
+ 'ISO-8859-1' => 'iso88591',
'UTF-8' => 'utf8',
- 'UTF-16BE' => 'utf16be',
- 'UTF-16LE' => 'utf16le',
+ 'UTF-16BE' => 'utf16be',
+ 'UTF-16LE' => 'utf16le',
'UTF-16' => 'utf16'
);
// Convert
$function_name = 'iconv_' . @$supported_charsets[$in_charset] . '_' . @$supported_charsets[$out_charset];
-
+
if (is_callable(array('getid3_iconv_replacement', $function_name))) {
return getid3_iconv_replacement::$function_name($string);
}
-
+
// Invalid charset used
if (!@$supported_charsets[$in_charset]) {
throw new getid3_exception('PHP does not have iconv() support - cannot use ' . $in_charset . ' charset.');
}
-
+
if (!@$supported_charsets[$out_charset]) {
throw new getid3_exception('PHP does not have iconv() support - cannot use ' . $out_charset . ' charset.');
}
@@ -272,15 +272,15 @@ class getid3_iconv_replacement
return $newcharstring;
}
-
-
+
+
// UTF-8 => UTF-16
public static function iconv_utf8_utf16($string) {
return getid3_lib::iconv_utf8_utf16le($string, true);
}
-
-
+
+
// UTF-16BE => ISO-8859-1
public static function iconv_utf16be_iso88591($string) {
if (substr($string, 0, 2) == "\xFE\xFF") {
@@ -295,8 +295,8 @@ class getid3_iconv_replacement
return $newcharstring;
}
-
-
+
+
// UTF-16BE => UTF-8
public static function iconv_utf16be_utf8($string) {
if (substr($string, 0, 2) == "\xFE\xFF") {
@@ -310,23 +310,23 @@ class getid3_iconv_replacement
}
return $newcharstring;
}
-
-
-
+
+
+
// UTF-16BE => UTF-16LE
public static function iconv_utf16be_utf16le($string) {
return getid3_iconv_replacement::iconv_utf8_utf16le(getid3_iconv_replacement::iconv_utf16be_utf8($string));
}
-
-
-
+
+
+
// UTF-16BE => UTF-16
public static function iconv_utf16be_utf16($string) {
return getid3_iconv_replacement::iconv_utf8_utf16(getid3_iconv_replacement::iconv_utf16be_utf8($string));
}
-
-
-
+
+
+
// UTF-16LE => ISO-8859-1
public static function iconv_utf16le_iso88591($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
@@ -341,8 +341,8 @@ class getid3_iconv_replacement
return $newcharstring;
}
-
-
+
+
// UTF-16LE => UTF-8
public static function iconv_utf16le_utf8($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
@@ -357,22 +357,22 @@ class getid3_iconv_replacement
return $newcharstring;
}
-
-
+
+
// UTF-16LE => UTF-16BE
public static function iconv_utf16le_utf16be($string) {
return getid3_iconv_replacement::iconv_utf8_utf16be(getid3_iconv_replacement::iconv_utf16le_utf8($string));
}
-
-
-
+
+
+
// UTF-16LE => UTF-16
public static function iconv_utf16le_utf16($string) {
return getid3_iconv_replacement::iconv_utf8_utf16(getid3_iconv_replacement::iconv_utf16le_utf8($string));
}
-
-
-
+
+
+
// UTF-16 => ISO-8859-1
public static function iconv_utf16_iso88591($string) {
$bom = substr($string, 0, 2);
@@ -384,8 +384,8 @@ class getid3_iconv_replacement
return $string;
}
-
-
+
+
// UTF-16 => UTF-8
public static function iconv_utf16_utf8($string) {
$bom = substr($string, 0, 2);
@@ -396,16 +396,16 @@ class getid3_iconv_replacement
}
return $string;
}
-
-
-
+
+
+
// UTF-16 => UTF-16BE
public static function iconv_utf16_utf16be($string) {
return getid3_iconv_replacement::iconv_utf8_utf16be(getid3_iconv_replacement::iconv_utf16_utf8($string));
}
-
-
-
+
+
+
// UTF-16 => UTF-16LE
public static function iconv_utf16_utf16le($string) {
return getid3_iconv_replacement::iconv_utf8_utf16le(getid3_iconv_replacement::iconv_utf16_utf8($string));
diff --git a/modules/getid3/module.lib.image_size.php b/modules/getid3/module.lib.image_size.php
index 5d7e66f4..8a07e289 100644
--- a/modules/getid3/module.lib.image_size.php
+++ b/modules/getid3/module.lib.image_size.php
@@ -26,7 +26,7 @@
class getid3_lib_image_size
{
-
+
const GIF_SIG = "\x47\x49\x46"; // 'GIF'
const PNG_SIG = "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A";
const JPG_SIG = "\xFF\xD8\xFF";
@@ -35,53 +35,53 @@ class getid3_lib_image_size
const JPG_SOF1 = "\xC1"; // N indicates which compression process
const JPG_SOF2 = "\xC2"; // Only SOF0-SOF2 are now in common use
const JPG_SOF3 = "\xC3"; // NB: codes C4 and CC are *not* SOF markers
- const JPG_SOF5 = "\xC5";
- const JPG_SOF6 = "\xC6";
- const JPG_SOF7 = "\xC7";
- const JPG_SOF9 = "\xC9";
- const JPG_SOF10 = "\xCA";
+ const JPG_SOF5 = "\xC5";
+ const JPG_SOF6 = "\xC6";
+ const JPG_SOF7 = "\xC7";
+ const JPG_SOF9 = "\xC9";
+ const JPG_SOF10 = "\xCA";
const JPG_SOF11 = "\xCB"; // NB: codes C4 and CC are *not* SOF markers
- const JPG_SOF13 = "\xCD";
- const JPG_SOF14 = "\xCE";
- const JPG_SOF15 = "\xCF";
+ const JPG_SOF13 = "\xCD";
+ const JPG_SOF14 = "\xCE";
+ const JPG_SOF15 = "\xCF";
const JPG_EOI = "\xD9"; // End Of Image (end of datastream)
static public function get($img_data) {
$height = $width = $type = '';
-
+
if ((substr($img_data, 0, 3) == getid3_lib_image_size::GIF_SIG) && (strlen($img_data) > 10)) {
-
+
$dim = unpack('v2dim', substr($img_data, 6, 4));
$width = $dim['dim1'];
$height = $dim['dim2'];
$type = 1;
-
+
} elseif ((substr($img_data, 0, 8) == getid3_lib_image_size::PNG_SIG) && (strlen($img_data) > 24)) {
-
+
$dim = unpack('N2dim', substr($img_data, 16, 8));
$width = $dim['dim1'];
$height = $dim['dim2'];
$type = 3;
-
+
} elseif ((substr($img_data, 0, 3) == getid3_lib_image_size::JPG_SIG) && (strlen($img_data) > 4)) {
-
+
///////////////// JPG CHUNK SCAN ////////////////////
$img_pos = $type = 2;
$buffer = strlen($img_data) - 2;
while ($img_pos < strlen($img_data)) {
-
+
// synchronize to the marker 0xFF
$img_pos = strpos($img_data, 0xFF, $img_pos) + 1;
$marker = $img_data[$img_pos];
do {
$marker = ord($img_data[$img_pos++]);
} while ($marker == 255);
-
+
// find dimensions of block
switch (chr($marker)) {
-
+
// Grab width/height from SOF segment (these are acceptable chunk types)
case getid3_lib_image_size::JPG_SOF0:
case getid3_lib_image_size::JPG_SOF1:
@@ -100,23 +100,23 @@ class getid3_lib_image_size
$height = $dim['dim1'];
$width = $dim['dim2'];
break 2; // found it so exit
-
+
case getid3_lib_image_size::JPG_EOI:
case getid3_lib_image_size::JPG_SOS:
- return false;
-
+ return false;
+
default: // We're not interested in other markers
$skiplen = (ord($img_data[$img_pos++]) << 8) + ord($img_data[$img_pos++]) - 2;
// if the skip is more than what we've read in, read more
$buffer -= $skiplen;
if ($buffer < 512) { // if the buffer of data is too low, read more file.
- return false;
+ return false;
}
$img_pos += $skiplen;
break;
- }
- }
- }
+ }
+ }
+ }
return array ($width, $height, $type);
} // end function
diff --git a/modules/getid3/module.misc.iso.php b/modules/getid3/module.misc.iso.php
index 60478f09..83771ddf 100644
--- a/modules/getid3/module.misc.iso.php
+++ b/modules/getid3/module.misc.iso.php
@@ -28,9 +28,9 @@ class getid3_iso extends getid3_handler
{
public function Analyze() {
-
+
$getid3 = $this->getid3;
-
+
$getid3->info['fileformat'] = 'iso';
for ($i = 16; $i <= 19; $i++) {
@@ -68,9 +68,9 @@ class getid3_iso extends getid3_handler
private function ParsePrimaryVolumeDescriptor(&$iso_header) {
-
+
$getid3 = $this->getid3;
-
+
// ISO integer values are stored *BOTH* Little-Endian AND Big-Endian format!!
// ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
@@ -83,8 +83,8 @@ class getid3_iso extends getid3_handler
if ($info_iso_primaryVD_raw['standard_identifier'] != 'CD001') {
throw new getid3_exception('Expected "CD001" at offset ('.($info_iso_primaryVD['offset'] + 1).'), found "'.$info_iso_primaryVD_raw['standard_identifier'].'" instead');
}
-
- getid3_lib::ReadSequence('LittleEndian2Int', $info_iso_primaryVD_raw, $iso_header, 6,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_iso_primaryVD_raw, $iso_header, 6,
array (
'volume_descriptor_version' => 1,
'IGNORE-unused_1' => 1,
@@ -137,7 +137,7 @@ class getid3_iso extends getid3_handler
$info_iso_primaryVD['copyright_file_identifier'] = trim($info_iso_primaryVD_raw['copyright_file_identifier']);
$info_iso_primaryVD['abstract_file_identifier'] = trim($info_iso_primaryVD_raw['abstract_file_identifier']);
$info_iso_primaryVD['bibliographic_file_identifier'] = trim($info_iso_primaryVD_raw['bibliographic_file_identifier']);
-
+
$info_iso_primaryVD['volume_creation_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_primaryVD_raw['volume_creation_date_time']);
$info_iso_primaryVD['volume_modification_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_primaryVD_raw['volume_modification_date_time']);
$info_iso_primaryVD['volume_expiration_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_primaryVD_raw['volume_expiration_date_time']);
@@ -153,9 +153,9 @@ class getid3_iso extends getid3_handler
private function ParseSupplementaryVolumeDescriptor(&$iso_header) {
-
+
$getid3 = $this->getid3;
-
+
// ISO integer values are stored Both-Endian format!!
// ie 12345 == 0x3039 is stored as $39 $30 $30 $39 in a 4-byte field
@@ -169,7 +169,7 @@ class getid3_iso extends getid3_handler
throw new getid3_exception('Expected "CD001" at offset ('.($info_iso_supplementaryVD['offset'] + 1).'), found "'.$info_iso_supplementaryVD_raw['standard_identifier'].'" instead');
}
- getid3_lib::ReadSequence('LittleEndian2Int', $info_iso_supplementaryVD_raw, $iso_header, 6,
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_iso_supplementaryVD_raw, $iso_header, 6,
array (
'volume_descriptor_version' => 1,
'IGNORE-unused_1' => -1,
@@ -222,7 +222,7 @@ class getid3_iso extends getid3_handler
$info_iso_supplementaryVD['copyright_file_identifier'] = trim($info_iso_supplementaryVD_raw['copyright_file_identifier']);
$info_iso_supplementaryVD['abstract_file_identifier'] = trim($info_iso_supplementaryVD_raw['abstract_file_identifier']);
$info_iso_supplementaryVD['bibliographic_file_identifier'] = trim($info_iso_supplementaryVD_raw['bibliographic_file_identifier']);
-
+
$info_iso_supplementaryVD['volume_creation_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_supplementaryVD_raw['volume_creation_date_time']);
$info_iso_supplementaryVD['volume_modification_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_supplementaryVD_raw['volume_modification_date_time']);
$info_iso_supplementaryVD['volume_expiration_date_time'] = getid3_iso::ISOtimeText2UNIXtime($info_iso_supplementaryVD_raw['volume_expiration_date_time']);
@@ -238,9 +238,9 @@ class getid3_iso extends getid3_handler
private function ParsePathTable() {
-
+
$getid3 = $this->getid3;
-
+
if (!isset($getid3->info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location']) && !isset($getid3->info['iso']['primary_volume_descriptor']['raw']['path_table_l_location'])) {
return false;
}
@@ -248,7 +248,7 @@ class getid3_iso extends getid3_handler
$path_table_location = $getid3->info['iso']['supplementary_volume_descriptor']['raw']['path_table_l_location'];
$path_table_size = $getid3->info['iso']['supplementary_volume_descriptor']['raw']['path_table_size'];
$text_encoding = 'UTF-16BE'; // Big-Endian Unicode
- }
+ }
else {
$path_table_location = $getid3->info['iso']['primary_volume_descriptor']['raw']['path_table_l_location'];
$path_table_size = $getid3->info['iso']['primary_volume_descriptor']['raw']['path_table_size'];
@@ -266,11 +266,11 @@ class getid3_iso extends getid3_handler
$offset = 0;
$pathcounter = 1;
while ($offset < $path_table_size) {
-
+
$getid3->info['iso']['path_table']['directories'][$pathcounter] = array ();
$info_iso_pathtable_directories_current = &$getid3->info['iso']['path_table']['directories'][$pathcounter];
- getid3_lib::ReadSequence('LittleEndian2Int', $info_iso_pathtable_directories_current, $getid3->info['iso']['path_table']['raw'], $offset,
+ getid3_lib::ReadSequence('LittleEndian2Int', $info_iso_pathtable_directories_current, $getid3->info['iso']['path_table']['raw'], $offset,
array (
'length' => 1,
'extended_length' => 1,
@@ -278,9 +278,9 @@ class getid3_iso extends getid3_handler
'parent_directory' => 2,
)
);
-
+
$info_iso_pathtable_directories_current['name'] = substr($getid3->info['iso']['path_table']['raw'], $offset+8, $info_iso_pathtable_directories_current['length']);
-
+
$offset += 8 + $info_iso_pathtable_directories_current['length'] + ($info_iso_pathtable_directories_current['length'] % 2);
$info_iso_pathtable_directories_current['name_ascii'] = $getid3->iconv($text_encoding, $getid3->encoding, $info_iso_pathtable_directories_current['name'], true);
@@ -303,23 +303,23 @@ class getid3_iso extends getid3_handler
private function ParseDirectoryRecord($directory_data) {
-
+
$getid3 = $this->getid3;
-
- $text_encoding = isset($getid3->info['iso']['supplementary_volume_descriptor']) ? 'UTF-16BE' : 'ISO-8859-1';
+
+ $text_encoding = isset($getid3->info['iso']['supplementary_volume_descriptor']) ? 'UTF-16BE' : 'ISO-8859-1';
fseek($getid3->fp, $directory_data['location_bytes'], SEEK_SET);
$directory_record_data = fread($getid3->fp, 1);
-
+
while (ord($directory_record_data{0}) > 33) {
$directory_record_data .= fread($getid3->fp, ord($directory_record_data{0}) - 1);
-
+
$this_directory_record = array ();
$this_directory_record['raw'] = array ();
$this_directory_record_raw = &$this_directory_record['raw'];
-
- getid3_lib::ReadSequence('LittleEndian2Int', $this_directory_record_raw, $directory_record_data, 0,
+
+ getid3_lib::ReadSequence('LittleEndian2Int', $this_directory_record_raw, $directory_record_data, 0,
array (
'length' => 1,
'extended_attribute_length' => 1,
@@ -338,7 +338,7 @@ class getid3_iso extends getid3_handler
);
$this_directory_record_raw['file_identifier'] = substr($directory_record_data, 33, $this_directory_record_raw['file_identifier_length']);
-
+
$this_directory_record['file_identifier_ascii'] = $getid3->iconv($text_encoding, $getid3->encoding, $this_directory_record_raw['file_identifier'], true);
$this_directory_record['filesize'] = $this_directory_record_raw['filesize'];
$this_directory_record['offset_bytes'] = $this_directory_record_raw['offset_logical'] * 2048;
@@ -357,11 +357,11 @@ class getid3_iso extends getid3_handler
$this_directory_record['filename'] = $directory_data['full_path'].getid3_iso::ISOstripFilenameVersion($this_directory_record['file_identifier_ascii']);
$getid3->info['iso']['files'] = getid3_iso::array_merge_clobber($getid3->info['iso']['files'], getid3_iso::CreateDeepArray($this_directory_record['filename'], '/', $this_directory_record['filesize']));
}
-
+
$directory_record[] = $this_directory_record;
$directory_record_data = fread($getid3->fp, 1);
}
-
+
return $directory_record;
}
@@ -383,14 +383,14 @@ class getid3_iso extends getid3_handler
if (!(int)substr($iso_time, 0, 4)) {
return false;
}
-
+
return gmmktime((int)substr($iso_time, 8, 2), (int)substr($iso_time, 10, 2), (int)substr($iso_time, 12, 2), (int)substr($iso_time, 4, 2), (int)substr($iso_time, 6, 2), (int)substr($iso_time, 0, 4));
}
-
-
+
+
public static function ISOtime2UNIXtime($iso_time) {
-
+
// Represented by seven bytes:
// 1: Number of years since 1900
// 2: Month of the year from 1 to 12
@@ -409,11 +409,11 @@ class getid3_iso extends getid3_handler
// 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])) {
@@ -424,9 +424,9 @@ class getid3_iso extends getid3_handler
}
return $newarray;
}
-
-
-
+
+
+
public static function CreateDeepArray($array_path, $separator, $value) {
// assigns $value to a nested array path:
@@ -435,14 +435,14 @@ class getid3_iso extends getid3_handler
// $foo = array ('path'=>array('to'=>'array('my'=>array('file.txt'))));
// or
// $foo['path']['to']['my'] = 'file.txt';
-
+
while ($array_path{0} == $separator) {
$array_path = substr($array_path, 1);
}
if (($pos = strpos($array_path, $separator)) !== false) {
return array (substr($array_path, 0, $pos) => getid3_iso::CreateDeepArray(substr($array_path, $pos + 1), $separator, $value));
}
-
+
return array ($array_path => $value);
}
diff --git a/modules/getid3/module.tag.id3v1.php b/modules/getid3/module.tag.id3v1.php
index 52f01405..15da6ce8 100644
--- a/modules/getid3/module.tag.id3v1.php
+++ b/modules/getid3/module.tag.id3v1.php
@@ -22,23 +22,23 @@
//
// $Id: module.tag.id3v1.php,v 1.6 2006/11/16 16:19:52 ah Exp $
-
-
+
+
class getid3_id3v1 extends getid3_handler
{
public function Analyze() {
$getid3 = $this->getid3;
-
+
fseek($getid3->fp, -256, SEEK_END);
$pre_id3v1 = fread($getid3->fp, 128);
$id3v1_tag = fread($getid3->fp, 128);
if (substr($id3v1_tag, 0, 3) == 'TAG') {
-
+
$getid3->info['avdataend'] -= 128;
-
+
// Shortcut
$getid3->info['id3v1'] = array ();
$info_id3v1 = &$getid3->info['id3v1'];
@@ -71,8 +71,8 @@ class getid3_id3v1 extends getid3_handler
$info_id3v1['tag_offset_end'] = filesize($getid3->filename);
$info_id3v1['tag_offset_start'] = $info_id3v1['tag_offset_end'] - 128;
- }
-
+ }
+
if (substr($pre_id3v1, 0, 3) == 'TAG') {
// The way iTunes handles tags is, well, brain-damaged.
// It completely ignores v1 if ID3v2 is present.
@@ -92,18 +92,18 @@ class getid3_id3v1 extends getid3_handler
return true;
}
-
-
+
+
public static function cutfield($str) {
-
+
return trim(substr($str, 0, strcspn($str, "\x00")));
}
public static function ArrayOfGenres($allow_SCMPX_extended=false) {
-
+
static $lookup = array (
0 => 'Blues',
1 => 'Classic Rock',
@@ -290,7 +290,7 @@ class getid3_id3v1 extends getid3_handler
public static function LookupGenreName($genre_id, $allow_SCMPX_extended=true) {
-
+
switch ($genre_id) {
case 'RX':
case 'CR':
@@ -302,10 +302,10 @@ class getid3_id3v1 extends getid3_handler
$lookup = getid3_id3v1::ArrayOfGenres($allow_SCMPX_extended);
return (isset($lookup[$genre_id]) ? $lookup[$genre_id] : false);
}
-
+
public static function LookupGenreID($genre, $allow_SCMPX_extended=false) {
-
+
$lookup = getid3_id3v1::ArrayOfGenres($allow_SCMPX_extended);
$lower_case_no_space_search_term = strtolower(str_replace(' ', '', $genre));
foreach ($lookup as $key => $value) {
diff --git a/modules/getid3/module.tag.lyrics3.php b/modules/getid3/module.tag.lyrics3.php
index 4afe6d64..cb95e0ea 100644
--- a/modules/getid3/module.tag.lyrics3.php
+++ b/modules/getid3/module.tag.lyrics3.php
@@ -42,7 +42,7 @@ class getid3_lyrics3 extends getid3_handler
$lyrics3_size = 5100;
$lyrics3_offset = filesize($getid3->filename) - 128 - $lyrics3_size;
$lyrics3_version = 1;
- }
+ }
// Lyrics3v2, ID3v1, no APE
elseif ($lyrics3_end == 'LYRICS200') {
@@ -51,8 +51,8 @@ class getid3_lyrics3 extends getid3_handler
$lyrics3_size = $lyrics3_lsz + 6 + strlen('LYRICS200');
$lyrics3_offset = filesize($getid3->filename) - 128 - $lyrics3_size;
$lyrics3_version = 2;
- }
-
+ }
+
// Lyrics3v1, no ID3v1, no APE
elseif (substr(strrev($lyrics3_id3v1), 0, 9) == 'DNESCIRYL') { // strrev('LYRICSEND') = 'DNESCIRYL'
@@ -60,23 +60,23 @@ class getid3_lyrics3 extends getid3_handler
$lyrics3_offset = filesize($getid3->filename) - $lyrics3_size;
$lyrics3_version = 1;
$lyrics3_offset = filesize($getid3->filename) - $lyrics3_size;
- }
-
+ }
+
// Lyrics3v2, no ID3v1, no APE
elseif (substr(strrev($lyrics3_id3v1), 0, 9) == '002SCIRYL') { // strrev('LYRICS200') = '002SCIRYL'
$lyrics3_size = strrev(substr(strrev($lyrics3_id3v1), 9, 6)) + 15; // LSZ = lyrics + 'LYRICSBEGIN'; add 6-byte size field; add 'LYRICS200' // 15 = 6 + strlen('LYRICS200')
$lyrics3_offset = filesize($getid3->filename) - $lyrics3_size;
$lyrics3_version = 2;
- }
-
+ }
+
elseif (isset($getid3->info['ape']['tag_offset_start']) && ($getid3->info['ape']['tag_offset_start'] > 15)) {
fseek($getid3->fp, $getid3->info['ape']['tag_offset_start'] - 15, SEEK_SET);
$lyrics3_lsz = fread($getid3->fp, 6);
$lyrics3_end = fread($getid3->fp, 9);
-
+
// Lyrics3v1, APE, maybe ID3v1
if ($lyrics3_end == 'LYRICSEND') {
@@ -85,9 +85,9 @@ class getid3_lyrics3 extends getid3_handler
$getid3->info['avdataend'] = $lyrics3_offset;
$lyrics3_version = 1;
$getid3->warning('APE tag located after Lyrics3, will probably break Lyrics3 compatability');
- }
-
-
+ }
+
+
// Lyrics3v2, APE, maybe ID3v1
elseif ($lyrics3_end == 'LYRICS200') {
@@ -98,25 +98,25 @@ class getid3_lyrics3 extends getid3_handler
}
}
-
-
+
+
//// GetLyrics3Data()
-
-
+
+
if (isset($lyrics3_offset)) {
-
+
$getid3->info['avdataend'] = $lyrics3_offset;
-
+
if ($lyrics3_size <= 0) {
return false;
}
fseek($getid3->fp, $lyrics3_offset, SEEK_SET);
$raw_data = fread($getid3->fp, $lyrics3_size);
-
+
if (substr($raw_data, 0, 11) != 'LYRICSBEGIN') {
if (strpos($raw_data, 'LYRICSBEGIN') !== false) {
-
+
$getid3->warning('"LYRICSBEGIN" expected at '.$lyrics3_offset.' but actually found at '.($lyrics3_offset + strpos($raw_data, 'LYRICSBEGIN')).' - this is invalid for Lyrics3 v'.$lyrics3_version);
$getid3->info['avdataend'] = $lyrics3_offset + strpos($raw_data, 'LYRICSBEGIN');
$parsed_lyrics3['tag_offset_start'] = $getid3->info['avdataend'];
@@ -126,16 +126,16 @@ class getid3_lyrics3 extends getid3_handler
else {
throw new getid3_exception('"LYRICSBEGIN" expected at '.$lyrics3_offset.' but found "'.substr($raw_data, 0, 11).'" instead.');
}
-
+
}
-
+
$parsed_lyrics3['raw']['lyrics3version'] = $lyrics3_version;
$parsed_lyrics3['raw']['lyrics3tagsize'] = $lyrics3_size;
$parsed_lyrics3['tag_offset_start'] = $lyrics3_offset;
$parsed_lyrics3['tag_offset_end'] = $lyrics3_offset + $lyrics3_size;
-
+
switch ($lyrics3_version) {
-
+
case 1:
if (substr($raw_data, strlen($raw_data) - 9, 9) == 'LYRICSEND') {
$parsed_lyrics3['raw']['LYR'] = trim(substr($raw_data, 11, strlen($raw_data) - 11 - 9));
@@ -145,7 +145,7 @@ class getid3_lyrics3 extends getid3_handler
throw new getid3_exception('"LYRICSEND" expected at '.(ftell($getid3->fp) - 11 + $lyrics3_size - 9).' but found "'.substr($raw_data, strlen($raw_data) - 9, 9).'" instead.');
}
break;
-
+
case 2:
if (substr($raw_data, strlen($raw_data) - 9, 9) == 'LYRICS200') {
$parsed_lyrics3['raw']['unparsed'] = substr($raw_data, 11, strlen($raw_data) - 11 - 9 - 6); // LYRICSBEGIN + LYRICS200 + LSZ
@@ -156,7 +156,7 @@ class getid3_lyrics3 extends getid3_handler
$parsed_lyrics3['raw'][$fieldname] = substr($raw_data, 8, $fieldsize);
$raw_data = substr($raw_data, 3 + 5 + $fieldsize);
}
-
+
if (isset($parsed_lyrics3['raw']['IND'])) {
$i = 0;
foreach (array ('lyrics', 'timestamps', 'inhibitrandom') as $flagname) {
@@ -165,13 +165,13 @@ class getid3_lyrics3 extends getid3_handler
}
}
}
-
+
foreach (array ('ETT'=>'title', 'EAR'=>'artist', 'EAL'=>'album', 'INF'=>'comment', 'AUT'=>'author') as $key => $value) {
if (isset($parsed_lyrics3['raw'][$key])) {
$parsed_lyrics3['comments'][$value][] = trim($parsed_lyrics3['raw'][$key]);
}
}
-
+
if (isset($parsed_lyrics3['raw']['IMG'])) {
foreach (explode("\r\n", $parsed_lyrics3['raw']['IMG']) as $key => $image_string) {
if (strpos($image_string, '||') !== false) {
@@ -182,7 +182,7 @@ class getid3_lyrics3 extends getid3_handler
}
}
}
-
+
if (isset($parsed_lyrics3['raw']['LYR'])) {
getid3_lyrics3::Lyrics3LyricsTimestampParse($parsed_lyrics3);
}
@@ -191,19 +191,19 @@ class getid3_lyrics3 extends getid3_handler
throw new getid3_exception('"LYRICS200" expected at '.(ftell($getid3->fp) - 11 + $lyrics3_size - 9).' but found "'.substr($raw_data, strlen($raw_data) - 9, 9).'" instead.');
}
break;
-
+
default:
throw new getid3_exception('Cannot process Lyrics3 version '.$lyrics3_version.' (only v1 and v2)');
}
-
+
if (isset($getid3->info['id3v1']['tag_offset_start']) && ($getid3->info['id3v1']['tag_offset_start'] < $parsed_lyrics3['tag_offset_end'])) {
$getid3->warning('ID3v1 tag information ignored since it appears to be a false synch in Lyrics3 tag data');
unset($getid3->info['id3v1']);
}
-
+
$getid3->info['lyrics3'] = $parsed_lyrics3;
-
-
+
+
// Check for APE tag after lyrics3
if (!@$getid3->info['ape'] && $getid3->option_tag_apetag && class_exists('getid3_apetag')) {
$apetag = new getid3_apetag($getid3);
@@ -214,10 +214,10 @@ class getid3_lyrics3 extends getid3_handler
return true;
}
-
-
-
+
+
+
public static function Lyrics3Timestamp2Seconds($rawtimestamp) {
if (preg_match('/^\\[([0-9]{2}):([0-9]{2})\\]$/', $rawtimestamp, $regs)) {
return (int)(($regs[1] * 60) + $regs[2]);
@@ -225,13 +225,13 @@ class getid3_lyrics3 extends getid3_handler
return false;
}
-
-
+
+
public static function Lyrics3LyricsTimestampParse(&$lyrics3_data) {
$lyrics_array = explode("\r\n", $lyrics3_data['raw']['LYR']);
foreach ($lyrics_array as $key => $lyric_line) {
-
+
while (preg_match('/^(\\[[0-9]{2}:[0-9]{2}\\])/', $lyric_line, $regs)) {
$this_line_timestamps[] = getid3_lyrics3::Lyrics3Timestamp2Seconds($regs[0]);
$lyric_line = str_replace($regs[0], '', $lyric_line);
@@ -262,7 +262,7 @@ class getid3_lyrics3 extends getid3_handler
public static function IntString2Bool($char) {
-
+
return $char == '1' ? true : ($char == '0' ? false : null);
}
}
diff --git a/modules/getid3/write.apetag.php b/modules/getid3/write.apetag.php
index e154e814..32ba33b2 100644
--- a/modules/getid3/write.apetag.php
+++ b/modules/getid3/write.apetag.php
@@ -27,73 +27,73 @@
class getid3_write_apetag extends getid3_handler_write
{
-
+
public $comments;
-
+
public function read() {
-
+
$engine = new getid3;
$engine->filename = $this->filename;
$engine->fp = fopen($this->filename, 'rb');
$engine->include_module('tag.apetag');
-
+
$tag = new getid3_apetag($engine);
$tag->Analyze();
if (!isset($engine->info['ape']['comments'])) {
return;
}
-
+
$this->comments = $engine->info['ape']['comments'];
-
+
// convert single element arrays to string
foreach ($this->comments as $key => $value) {
if (sizeof($value) == 1) {
$this->comments[$key] = $value[0];
}
}
-
+
return true;
}
public function write() {
-
+
// remove existing apetag
$this->remove();
-
+
$engine = new getid3;
$engine->filename = $this->filename;
$engine->fp = fopen($this->filename, 'rb');
$engine->include_module('tag.id3v1');
$engine->include_module('tag.lyrics3');
-
+
$tag = new getid3_id3v1($engine);
$tag->Analyze();
-
+
$tag = new getid3_lyrics3($engine);
$tag->Analyze();
$apetag = $this->generate_tag();
-
+
if (!$fp = @fopen($this->filename, 'a+b')) {
throw new getid3_exception('Could not open a+b: ' . $this->filename);
}
// init: audio ends at eof
$post_audio_offset = filesize($this->filename);
-
+
// lyrics3 tag present
if (@$engine->info['lyrics3']['tag_offset_start']) {
-
+
// audio ends before lyrics3 tag
$post_audio_offset = @$engine->info['lyrics3']['tag_offset_start'];
}
// id3v1 tag present
elseif (@$engine->info['id3v1']['tag_offset_start']) {
-
+
// audio ends before id3v1 tag
$post_audio_offset = $engine->info['id3v1']['tag_offset_start'];
}
@@ -110,24 +110,24 @@ class getid3_write_apetag extends getid3_handler_write
// truncate file before start of new apetag
fseek($fp, $post_audio_offset, SEEK_SET);
ftruncate($fp, ftell($fp));
-
+
// write new apetag
fwrite($fp, $apetag, strlen($apetag));
-
- // rewrite data after audio
+
+ // rewrite data after audio
if (!empty($post_audio_data)) {
fwrite($fp, $post_audio_data, strlen($post_audio_data));
}
-
+
fclose($fp);
clearstatcache();
-
+
return true;
}
public function remove() {
-
+
$engine = new getid3;
$engine->filename = $this->filename;
$engine->fp = fopen($this->filename, 'rb');
@@ -137,7 +137,7 @@ class getid3_write_apetag extends getid3_handler_write
$tag->Analyze();
if (isset($engine->info['ape']['tag_offset_start']) && isset($engine->info['ape']['tag_offset_end'])) {
-
+
if (!$fp = @fopen($this->filename, 'a+b')) {
throw new getid3_exception('Could not open a+b: ' . $this->filename);
}
@@ -148,7 +148,7 @@ class getid3_write_apetag extends getid3_handler_write
$data_after_ape = fread($fp, filesize($this->filename) - $engine->info['ape']['tag_offset_end']);
}
- // truncate file before start of apetag
+ // truncate file before start of apetag
ftruncate($fp, $engine->info['ape']['tag_offset_start']);
// rewrite data after apetag
@@ -156,36 +156,36 @@ class getid3_write_apetag extends getid3_handler_write
fseek($fp, $engine->info['ape']['tag_offset_start'], SEEK_SET);
fwrite($fp, $data_after_ape, strlen($data_after_ape));
}
-
+
fclose($fp);
clearstatcache();
}
-
- // success when removing non-existant tag
+
+ // success when removing non-existant tag
return true;
}
protected function generate_tag() {
-
+
// NOTE: All data passed to this function must be UTF-8 format
$items = array();
if (!is_array($this->comments)) {
throw new getid3_exception('Cannot write empty tag, use remove() instead.');
}
-
+
foreach ($this->comments as $key => $values) {
-
+
// http://www.personal.uni-jena.de/~pfk/mpp/sv8/apekey.html
- // A case-insensitive vobiscomment field name that may consist of ASCII 0x20 through 0x7E.
+ // A case-insensitive vobiscomment field name that may consist of ASCII 0x20 through 0x7E.
// ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through 0x7A inclusive (a-z).
if (preg_match("/[^\x20-\x7E]/", $key)) {
throw new getid3_exception('Field name "' . $key . '" contains invalid character(s).');
}
-
+
$key = strtolower($key);
-
+
// convert single value comment to array
if (!is_array($values)) {
$values = array ($values);
@@ -199,7 +199,7 @@ class getid3_write_apetag extends getid3_handler_write
// length of the assigned value in bytes
$tag_item = getid3_lib::LittleEndian2String(strlen($value_string), 4);
-
+
$tag_item .= "\x00\x00\x00\x00" . $key . "\x00" . $value_string;
$items[] = $tag_item;
@@ -207,10 +207,10 @@ class getid3_write_apetag extends getid3_handler_write
return $this->generate_header_footer($items, true) . implode('', $items) . $this->generate_header_footer($items, false);
}
-
+
protected function generate_header_footer(&$items, $is_header=false) {
-
+
$comments_length = 0;
foreach ($items as $item_data) {
$comments_length += strlen($item_data);
@@ -225,25 +225,25 @@ class getid3_write_apetag extends getid3_handler_write
return $header;
}
-
+
protected function generate_flags($header=true, $footer=true, $is_header=false, $encoding_id=0, $read_only=false) {
-
+
$flags = array_fill(0, 4, 0);
-
+
// Tag contains a header
if ($header) {
- $flags[0] |= 0x80;
+ $flags[0] |= 0x80;
}
-
+
// Tag contains no footer
if (!$footer) {
- $flags[0] |= 0x40;
+ $flags[0] |= 0x40;
}
-
+
// This is the header, not the footer
if ($is_header) {
- $flags[0] |= 0x20;
+ $flags[0] |= 0x20;
}
// 0: Item contains text information coded in UTF-8
@@ -254,12 +254,12 @@ class getid3_write_apetag extends getid3_handler_write
// Tag or Item is Read Only
if ($read_only) {
- $flags[3] |= 0x01;
+ $flags[3] |= 0x01;
}
return chr($flags[3]).chr($flags[2]).chr($flags[1]).chr($flags[0]);
}
-
+
}
?> \ No newline at end of file
diff --git a/modules/getid3/write.id3v1.php b/modules/getid3/write.id3v1.php
index c6bd48c3..52bc1921 100644
--- a/modules/getid3/write.id3v1.php
+++ b/modules/getid3/write.id3v1.php
@@ -37,19 +37,19 @@ class getid3_write_id3v1 extends getid3_handler_write
public function read() {
-
+
$engine = new getid3;
$engine->filename = $this->filename;
$engine->fp = fopen($this->filename, 'rb');
$engine->include_module('tag.id3v1');
-
+
$tag = new getid3_id3v1($engine);
$tag->Analyze();
-
+
if (!isset($engine->info['id3v1'])) {
return;
}
-
+
$this->title = $engine->info['id3v1']['title'];
$this->artist = $engine->info['id3v1']['artist'];
$this->album = $engine->info['id3v1']['album'];
@@ -58,69 +58,69 @@ class getid3_write_id3v1 extends getid3_handler_write
$this->genre = $engine->info['id3v1']['genre'];
$this->comment = $engine->info['id3v1']['comment'];
$this->track = $engine->info['id3v1']['track'];
-
+
return true;
}
-
-
+
+
public function write() {
-
+
if (!$fp = @fopen($this->filename, 'r+b')) {
throw new getid3_exception('Could not open r+b: ' . $this->filename);
}
-
+
// seek to end minus 128 bytes
fseek($fp, -128, SEEK_END);
-
+
// overwrite existing ID3v1 tag
if (fread($fp, 3) == 'TAG') {
- fseek($fp, -128, SEEK_END);
- }
-
+ fseek($fp, -128, SEEK_END);
+ }
+
// append new ID3v1 tag
else {
- fseek($fp, 0, SEEK_END);
+ fseek($fp, 0, SEEK_END);
}
fwrite($fp, $this->generate_tag(), 128);
-
+
fclose($fp);
clearstatcache();
-
+
return true;
}
protected function generate_tag() {
-
+
$result = 'TAG';
$result .= str_pad(trim(substr($this->title, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
$result .= str_pad(trim(substr($this->artist, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
$result .= str_pad(trim(substr($this->album, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
$result .= str_pad(trim(substr($this->year, 0, 4)), 4, "\x00", STR_PAD_LEFT);
-
+
if (!empty($this->track) && ($this->track > 0) && ($this->track <= 255)) {
-
+
$result .= str_pad(trim(substr($this->comment, 0, 28)), 28, "\x00", STR_PAD_RIGHT);
$result .= "\x00";
$result .= chr($this->track);
- }
+ }
else {
$result .= str_pad(trim(substr($comment, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
}
-
+
// both genre and genre_id set
if ($this->genre && $this->genre_id) {
if ($this->genre != getid3_id3v1::LookupGenreName($this->genre_id)) {
throw new getid3_exception('Genre and genre_id does not match. Unset one and the other will be determined automatically.');
}
}
-
+
// only genre set
elseif ($this->genre) {
$this->genre_id = getid3_id3v1::LookupGenreID($this->genre);
}
-
+
// only genre_id set
else {
if ($this->genre_id < 0 || $this->genre_id > 147) {
@@ -128,27 +128,27 @@ class getid3_write_id3v1 extends getid3_handler_write
}
$this->genre = getid3_id3v1::LookupGenreName($this->genre_id);
}
-
+
$result .= chr(intval($this->genre_id));
return $result;
- }
-
-
+ }
+
+
public function remove() {
-
+
if (!$fp = @fopen($this->filename, 'r+b')) {
throw new getid3_exception('Could not open r+b: ' . $filename);
}
-
+
fseek($fp, -128, SEEK_END);
if (fread($fp, 3) == 'TAG') {
ftruncate($fp, filesize($this->filename) - 128);
fclose($fp);
clearstatcache();
}
-
- // success when removing non-existant tag
+
+ // success when removing non-existant tag
return true;
}
diff --git a/modules/getid3/write.id3v2.php b/modules/getid3/write.id3v2.php
index d3b6c3ca..d09c3548 100644
--- a/modules/getid3/write.id3v2.php
+++ b/modules/getid3/write.id3v2.php
@@ -26,13 +26,13 @@
class getid3_write_id3v2 extends getid3_handler_write
{
- // NOTE: This module ONLY writes tags in UTF-8. All strings must be UTF-8 encoded.
-
+ // NOTE: This module ONLY writes tags in UTF-8. All strings must be UTF-8 encoded.
+
// For multiple values, specify "array of type" instead of type for all T??? and IPLS params except TXXX.
/**2.4
// For multiple values, specify "array of type" instead of type for all T??? params except TXXX.
*/
-
+
// Identification frames
public $content_group_description; // TIT1 string
@@ -142,7 +142,7 @@ class getid3_write_id3v2 extends getid3_handler_write
public $play_counter; // PCNT
// Popularimeter
- public $popularimeter; // POPM
+ public $popularimeter; // POPM
// Recommended buffer size
public $recommended_buffer_size; // RBUF
@@ -291,7 +291,7 @@ class getid3_write_id3v2 extends getid3_handler_write
public $play_counter; // PCNT
// Popularimeter
- public $popularimeter; // POPM
+ public $popularimeter; // POPM
// Recommended buffer size
public $recommended_buffer_size; // RBUF
@@ -332,14 +332,14 @@ class getid3_write_id3v2 extends getid3_handler_write
// Audio seek point index
public $audio_seek_point_index; // ASPI
*/
-
-
+
+
// internal logic
protected $padded_length = 4096; // minimum length of ID3v2 tag in bytes
protected $previous_frames = array ();
const major_version = 3;
-
+
public function read() {
@@ -450,25 +450,25 @@ class getid3_write_id3v2 extends getid3_handler_write
protected function generate_tag() {
$result = '';
-
+
$some_array = array (
'content_group_description' => 'TIT1',
'title' => 'TIT2',
'subtitle' => 'TIT3',
);
-
+
foreach ($some_array as $key => $frame_name) {
-
-
+
+
if ($frame_data = $this->generate_frame_data($frame_name, $this->$key)) {
-
+
$frame_length = $this->BigEndian2String(strlen($frame_data), 4, false);
$frame_flags = $this->generate_frame_flags();
}
-
+
$result .= $frame_name.$frame_length.$frame_flags.$frame_data;
}
-
+
// calc padded length of tag
while ($this->padded_length < (strlen($result) + 10)) {
@@ -479,7 +479,7 @@ class getid3_write_id3v2 extends getid3_handler_write
if ($this->padded_length > (strlen($result) + 10)) {
$result .= @str_repeat("\x00", $this->padded_length - strlen($result) - 10);
}
-
+
$header = 'ID3';
$header .= chr(getid3_id3v2_write::major_version);
$header .= chr(0);
@@ -504,7 +504,7 @@ class getid3_write_id3v2 extends getid3_handler_write
$flag .= (@$flags['extendedheader'] ? '1' : '0'); // b - Extended header
$flag .= (@$flags['experimental'] ? '1' : '0'); // c - Experimental indicator
$flag .= (@$flags['footer'] ? '1' : '0'); // d - Footer present
- $flag .= '0000';
+ $flag .= '0000';
*/
return chr(bindec($flag));
@@ -512,29 +512,29 @@ class getid3_write_id3v2 extends getid3_handler_write
protected function generate_frame_flags($flags) {
-
+
// %abc00000 %ijk00000
$flag1 = (@$flags['tag_alter'] ? '1' : '0'); // a - Tag alter preservation (true == discard)
$flag1 .= (@$flags['file_alter'] ? '1' : '0'); // b - File alter preservation (true == discard)
$flag1 .= (@$flags['read_only'] ? '1' : '0'); // c - Read only (true == read only)
- $flag1 .= '00000';
-
+ $flag1 .= '00000';
+
$flag2 = (@$flags['compression'] ? '1' : '0'); // i - Compression (true == compressed)
$flag2 .= (@$flags['encryption'] ? '1' : '0'); // j - Encryption (true == encrypted)
$flag2 .= (@$flags['grouping_identity'] ? '1' : '0'); // k - Grouping identity (true == contains group information)
- $flag2 .= '00000';
-
- /**2.4
- // %0abc0000 %0h00kmnp
- $flag1 = '0';
+ $flag2 .= '00000';
+
+ /**2.4
+ // %0abc0000 %0h00kmnp
+ $flag1 = '0';
$flag1 = (@$flags['tag_alter'] ? '1' : '0'); // a - Tag alter preservation (true == discard)
$flag1 .= (@$flags['file_alter'] ? '1' : '0'); // b - File alter preservation (true == discard)
$flag1 .= (@$flags['read_only'] ? '1' : '0'); // c - Read only (true == read only)
- $flag1 .= '0000';
-
- $flag2 = '0';
+ $flag1 .= '0000';
+
+ $flag2 = '0';
$flag2 .= (@$flags['grouping_identity'] ? '1' : '0'); // h - Grouping identity (true == contains group information)
- $flag2 .= '00';
+ $flag2 .= '00';
$flag2 = (@$flags['compression'] ? '1' : '0'); // k - Compression (true == compressed)
$flag2 .= (@$flags['encryption'] ? '1' : '0'); // m - Encryption (true == encrypted)
$flag2 .= (@$flags['unsynchronisation'] ? '1' : '0'); // n - Unsynchronisation (true == unsynchronised)
@@ -1857,22 +1857,22 @@ class getid3_write_id3v2 extends getid3_handler_write
public static function BigEndian2String($number, $min_bytes=1, $synch_safe=false, $signed=false) {
-
+
if ($number < 0) {
return false;
}
-
+
$maskbyte = (($synch_safe || $signed) ? 0x7F : 0xFF);
-
+
$intstring = '';
-
+
if ($signed) {
if ($min_bytes > 4) {
die('INTERNAL ERROR: Cannot have signed integers larger than 32-bits in BigEndian2String()');
}
$number = $number & (0x80 << (8 * ($min_bytes - 1)));
}
-
+
while ($number != 0) {
$quotient = ($number / ($maskbyte + 1));
$intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
diff --git a/modules/getid3/write.lyrics3.php b/modules/getid3/write.lyrics3.php
index eab0d8d6..4725a3c9 100644
--- a/modules/getid3/write.lyrics3.php
+++ b/modules/getid3/write.lyrics3.php
@@ -29,7 +29,7 @@ class getid3_write_lyrics3 extends getid3_handler_write
{
public $synched;
public $random_inhibited;
-
+
public $lyrics;
public $comment;
public $author;
@@ -40,7 +40,7 @@ class getid3_write_lyrics3 extends getid3_handler_write
public function read() {
-
+
$engine = new getid3;
$engine->filename = $this->filename;
$engine->fp = fopen($this->filename, 'rb');
@@ -48,11 +48,11 @@ class getid3_write_lyrics3 extends getid3_handler_write
$tag = new getid3_lyrics3($engine);
$tag->Analyze();
-
+
if (!isset($engine->info['lyrics3']['tag_offset_start'])) {
return;
}
-
+
$this->lyrics = @$engine->info['lyrics3']['raw']['LYR'];
$this->comment = @$engine->info['lyrics3']['raw']['INF'];
$this->author = @$engine->info['lyrics3']['raw']['AUT'];
@@ -60,36 +60,36 @@ class getid3_write_lyrics3 extends getid3_handler_write
$this->artist = @$engine->info['lyrics3']['raw']['EAR'];
$this->album = @$engine->info['lyrics3']['raw']['EAL'];
$this->images = @$engine->info['lyrics3']['raw']['IMG'];
-
+
return true;
}
public function write() {
-
+
// remove existing apetag
$this->remove();
-
+
$engine = new getid3;
$engine->filename = $this->filename;
$engine->fp = fopen($this->filename, 'rb');
$engine->include_module('tag.id3v1');
-
+
$tag = new getid3_id3v1($engine);
$tag->Analyze();
$apetag = $this->generate_tag();
-
+
if (!$fp = @fopen($this->filename, 'a+b')) {
throw new getid3_exception('Could not open a+b: ' . $this->filename);
}
// init: audio ends at eof
$post_audio_offset = filesize($this->filename);
-
+
// id3v1 tag present
if (@$engine->info['id3v1']['tag_offset_start']) {
-
+
// audio ends before id3v1 tag
$post_audio_offset = $engine->info['id3v1']['tag_offset_start'];
}
@@ -106,27 +106,27 @@ class getid3_write_lyrics3 extends getid3_handler_write
// truncate file before start of new apetag
fseek($fp, $post_audio_offset, SEEK_SET);
ftruncate($fp, ftell($fp));
-
+
// write new apetag
fwrite($fp, $apetag, strlen($apetag));
-
- // rewrite data after audio
+
+ // rewrite data after audio
if (!empty($post_audio_data)) {
fwrite($fp, $post_audio_data, strlen($post_audio_data));
}
-
+
fclose($fp);
clearstatcache();
-
+
return true;
}
-
+
protected function generate_tag() {
-
+
// define fields
static $fields = array (
- 'lyrics' => 'LYR',
+ 'lyrics' => 'LYR',
'comment' => 'INF',
'author' => 'AUT',
'title' => 'ETT',
@@ -134,40 +134,40 @@ class getid3_write_lyrics3 extends getid3_handler_write
'album' => 'EAL',
'images' => 'IMG'
);
-
+
// loop thru fields and add to frames
$frames = '';
foreach ($fields as $field => $frame_name) {
-
+
// field set?
if ($this->$field) {
$frames .= $frame_name . str_pad(strlen($this->$field), 5, '0', STR_PAD_LEFT) . $this->$field;
}
}
-
+
if (!$frames) {
throw new getid3_exception('Cannot write empty tag, use remove() instead.');
}
- // header
+ // header
$result = 'LYRICSBEGIN';
-
+
// indicator frame
- $result .= 'IND00003' . ($this->lyrics ? '1' : '0') . ($this->synched ? '1' : '0') . ($this->random_inibited ? '1' : '0');
-
+ $result .= 'IND00003' . ($this->lyrics ? '1' : '0') . ($this->synched ? '1' : '0') . ($this->random_inibited ? '1' : '0');
+
// other frames
$result .= $frames;
-
+
// footer
$result .= str_pad(strlen($result), 6, '0', STR_PAD_LEFT);
$result .= 'LYRICS200';
-
+
return $result;
}
-
+
public function remove() {
-
+
$engine = new getid3;
$engine->filename = $this->filename;
$engine->fp = fopen($this->filename, 'rb');
@@ -175,9 +175,9 @@ class getid3_write_lyrics3 extends getid3_handler_write
$tag = new getid3_lyrics3($engine);
$tag->Analyze();
-
+
if (isset($engine->info['lyrics3']['tag_offset_start']) && isset($engine->info['lyrics3']['tag_offset_end'])) {
-
+
if (!$fp = @fopen($this->filename, 'a+b')) {
throw new getid3_exception('Could not open a+b: ' . $this->filename);
}
@@ -201,8 +201,8 @@ class getid3_write_lyrics3 extends getid3_handler_write
fclose($fp);
clearstatcache();
}
-
- // success when removing non-existant tag
+
+ // success when removing non-existant tag
return true;
}
}
diff --git a/modules/getid3/write.vorbis.php b/modules/getid3/write.vorbis.php
index 0e95636f..e1d4b19b 100644
--- a/modules/getid3/write.vorbis.php
+++ b/modules/getid3/write.vorbis.php
@@ -25,19 +25,19 @@
class getid3_write_vorbis extends getid3_handler_write
{
-
+
public $comments = array ();
-
-
+
+
public function __construct($filename) {
-
+
if (ini_get('safe_mode')) {
throw new getid3_exception('PHP running in Safe Mode (backtick operator not available). Cannot call vorbiscomment binary.');
}
-
+
static $initialized;
if (!$initialized) {
-
+
// check existance and version of vorbiscomment
if (!preg_match('/^Vorbiscomment ([0-9]+\.[0-9]+\.[0-9]+)/', `vorbiscomment --version 2>&1`, $r)) {
throw new getid3_exception('Fatal: vorbiscomment binary not available.');
@@ -51,20 +51,20 @@ class getid3_write_vorbis extends getid3_handler_write
parent::__construct($filename);
}
-
-
+
+
public function read() {
-
+
// read info with vorbiscomment
if (!$info = trim(`vorbiscomment -l "$this->filename"`)) {
return;
}
-
+
// process info
foreach (explode("\n", $info) as $line) {
-
+
$pos = strpos($line, '=');
-
+
$key = strtolower(substr($line, 0, $pos));
$value = substr($line, $pos+1);
@@ -77,13 +77,13 @@ class getid3_write_vorbis extends getid3_handler_write
$this->comments[$key] = $value[0];
}
}
-
+
return true;
}
-
-
+
+
public function write() {
-
+
// create temp file with new comments
$temp_filename = tempnam('*', 'getID3');
if (!$fp = @fopen($temp_filename, 'wb')) {
@@ -91,14 +91,14 @@ class getid3_write_vorbis extends getid3_handler_write
}
fwrite($fp, $this->generate_tag());
fclose($fp);
-
+
// write comments
$this->save_permissions();
if ($error = `vorbiscomment -w --raw -c "$temp_filename" "$this->filename" 2>&1`) {
- throw new getid3_exception('Fatal: vorbiscomment returned error: ' . $error);
+ throw new getid3_exception('Fatal: vorbiscomment returned error: ' . $error);
}
$this->restore_permissions();
-
+
// success
@unlink($temp_filename);
return true;
@@ -106,27 +106,27 @@ class getid3_write_vorbis extends getid3_handler_write
protected function generate_tag() {
-
+
if (!$this->comments) {
throw new getid3_exception('Cannot write empty tag, use remove() instead.');
}
$result = '';
-
+
foreach ($this->comments as $key => $values) {
-
- // A case-insensitive vobiscomment field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
+
+ // A case-insensitive vobiscomment field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
// ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through 0x7A inclusive (a-z).
if (preg_match("/[^\x20-\x7D]|\x3D/", $key)) {
throw new getid3_exception('Field name "' . $key . '" contains invalid character(s).');
}
-
+
$key = strtolower($key);
-
+
if (!is_array($values)) {
$values = array ($values);
}
-
+
foreach ($values as $value) {
if (strstr($value, "\n") || strstr($value, "\r")) {
throw new getid3_exception('Multi-line comments not supported (value contains \n or \r)');
@@ -135,13 +135,13 @@ class getid3_write_vorbis extends getid3_handler_write
}
}
-
+
return $result;
- }
-
-
+ }
+
+
public function remove() {
-
+
// create temp file with new comments
$temp_filename = tempnam('*', 'getID3');
if (!$fp = @fopen($temp_filename, 'wb')) {
@@ -149,15 +149,15 @@ class getid3_write_vorbis extends getid3_handler_write
}
fwrite($fp, '');
fclose($fp);
-
+
// write comments
$this->save_permissions();
if ($error = `vorbiscomment -w --raw -c "$temp_filename" "$this->filename" 2>&1`) {
- throw new getid3_exception('Fatal: vorbiscomment returned error: ' . $error);
+ throw new getid3_exception('Fatal: vorbiscomment returned error: ' . $error);
}
$this->restore_permissions();
-
- // success when removing non-existant tag
+
+ // success when removing non-existant tag
@unlink($temp_filename);
return true;
}
diff --git a/modules/infotools/Snoopy.class.php b/modules/infotools/Snoopy.class.php
index 63198bbd..9c458797 100644
--- a/modules/infotools/Snoopy.class.php
+++ b/modules/infotools/Snoopy.class.php
@@ -33,7 +33,7 @@ http://snoopy.sourceforge.net/
class Snoopy
{
/**** Public variables ****/
-
+
/* user definable vars */
var $host = "www.php.net"; // host name we are connecting to
@@ -42,7 +42,7 @@ class Snoopy
var $proxy_port = ""; // proxy port to use
var $proxy_user = ""; // proxy user to use
var $proxy_pass = ""; // proxy password to use
-
+
var $agent = "Snoopy v1.2.4"; // agent we masquerade as
var $referer = ""; // referer info to pass
var $cookies = array(); // array of cookies to pass
@@ -60,15 +60,15 @@ class Snoopy
var $passcookies = true; // pass set cookies back through redirects
// NOTE: this currently does not respect
// dates, domains or paths.
-
+
var $user = ""; // user for http authentication
var $pass = ""; // password for http authentication
-
+
// http accept types
var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
-
+
var $results = ""; // where the content is put
-
+
var $error = ""; // error messages sent here
var $response_code = ""; // response code returned from server
var $headers = array(); // headers returned from server sent here
@@ -94,11 +94,11 @@ class Snoopy
// library functions built into php,
// as these functions are not stable
// as of this Snoopy release.
-
- /**** Private variables ****/
-
+
+ /**** Private variables ****/
+
var $_maxlinelen = 4096; // max line length (headers)
-
+
var $_httpmethod = "GET"; // default http request method
var $_httpversion = "HTTP/1.0"; // default http request version
var $_submit_method = "POST"; // default submit method
@@ -108,7 +108,7 @@ class Snoopy
var $_redirectdepth = 0; // increments on an http redirect
var $_frameurls = array(); // frame src urls
var $_framedepth = 0; // increments on frame depth
-
+
var $_isproxy = false; // set if using a proxy server
var $_fp_timeout = 30; // timeout for socket connection
@@ -123,7 +123,7 @@ class Snoopy
function fetch($URI)
{
-
+
//preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
$URI_PARTS = parse_url($URI);
if (!empty($URI_PARTS["user"]))
@@ -134,7 +134,7 @@ class Snoopy
$URI_PARTS["query"] = '';
if (empty($URI_PARTS["path"]))
$URI_PARTS["path"] = '';
-
+
switch(strtolower($URI_PARTS["scheme"]))
{
case "http":
@@ -154,7 +154,7 @@ class Snoopy
// no proxy, send only the path
$this->_httprequest($path, $fp, $URI, $this->_httpmethod);
}
-
+
$this->_disconnect($fp);
if($this->_redirectaddr)
@@ -177,7 +177,7 @@ class Snoopy
{
$frameurls = $this->_frameurls;
$this->_frameurls = array();
-
+
while(list(,$frameurl) = each($frameurls))
{
if($this->_framedepth < $this->maxframes)
@@ -188,13 +188,13 @@ class Snoopy
else
break;
}
- }
+ }
}
else
{
return false;
}
- return true;
+ return true;
break;
case "https":
if(!$this->curl_path)
@@ -248,15 +248,15 @@ class Snoopy
else
break;
}
- }
- return true;
+ }
+ return true;
break;
default:
// not a valid protocol
$this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
return false;
break;
- }
+ }
return true;
}
@@ -274,9 +274,9 @@ class Snoopy
function submit($URI, $formvars="", $formfiles="")
{
unset($postdata);
-
+
$postdata = $this->_prepare_post_body($formvars, $formfiles);
-
+
$URI_PARTS = parse_url($URI);
if (!empty($URI_PARTS["user"]))
$this->user = $URI_PARTS["user"];
@@ -306,17 +306,17 @@ class Snoopy
// no proxy, send only the path
$this->_httprequest($path, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata);
}
-
+
$this->_disconnect($fp);
if($this->_redirectaddr)
{
/* url was redirected, check if we've hit the max depth */
if($this->maxredirs > $this->_redirectdepth)
- {
+ {
if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
- $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
-
+ $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
+
// only follow redirect if it's on this site, or offsiteok is true
if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
{
@@ -335,9 +335,9 @@ class Snoopy
{
$frameurls = $this->_frameurls;
$this->_frameurls = array();
-
+
while(list(,$frameurl) = each($frameurls))
- {
+ {
if($this->_framedepth < $this->maxframes)
{
$this->fetch($frameurl);
@@ -346,14 +346,14 @@ class Snoopy
else
break;
}
- }
-
+ }
+
}
else
{
return false;
}
- return true;
+ return true;
break;
case "https":
if(!$this->curl_path)
@@ -380,9 +380,9 @@ class Snoopy
{
/* url was redirected, check if we've hit the max depth */
if($this->maxredirs > $this->_redirectdepth)
- {
+ {
if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
- $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
+ $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
// only follow redirect if it's on this site, or offsiteok is true
if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
@@ -404,7 +404,7 @@ class Snoopy
$this->_frameurls = array();
while(list(,$frameurl) = each($frameurls))
- {
+ {
if($this->_framedepth < $this->maxframes)
{
$this->fetch($frameurl);
@@ -413,16 +413,16 @@ class Snoopy
else
break;
}
- }
- return true;
+ }
+ return true;
break;
-
+
default:
// not a valid protocol
$this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
return false;
break;
- }
+ }
return true;
}
@@ -436,7 +436,7 @@ class Snoopy
function fetchlinks($URI)
{
if ($this->fetch($URI))
- {
+ {
if($this->lastredirectaddr)
$URI = $this->lastredirectaddr;
if(is_array($this->results))
@@ -464,9 +464,9 @@ class Snoopy
function fetchform($URI)
{
-
+
if ($this->fetch($URI))
- {
+ {
if(is_array($this->results))
{
@@ -475,14 +475,14 @@ class Snoopy
}
else
$this->results = $this->_stripform($this->results);
-
+
return true;
}
else
return false;
}
-
-
+
+
/*======================================================================*\
Function: fetchtext
Purpose: fetch the text from a web page, stripping the links
@@ -493,7 +493,7 @@ class Snoopy
function fetchtext($URI)
{
if($this->fetch($URI))
- {
+ {
if(is_array($this->results))
{
for($x=0;$x<count($this->results);$x++)
@@ -517,7 +517,7 @@ class Snoopy
function submitlinks($URI, $formvars="", $formfiles="")
{
if($this->submit($URI,$formvars, $formfiles))
- {
+ {
if($this->lastredirectaddr)
$URI = $this->lastredirectaddr;
if(is_array($this->results))
@@ -551,7 +551,7 @@ class Snoopy
function submittext($URI, $formvars = "", $formfiles = "")
{
if($this->submit($URI,$formvars, $formfiles))
- {
+ {
if($this->lastredirectaddr)
$URI = $this->lastredirectaddr;
if(is_array($this->results))
@@ -575,7 +575,7 @@ class Snoopy
return false;
}
-
+
/*======================================================================*\
Function: set_submit_multipart
@@ -587,7 +587,7 @@ class Snoopy
$this->_submit_type = "multipart/form-data";
}
-
+
/*======================================================================*\
Function: set_submit_normal
Purpose: Set the form submission content type to
@@ -598,14 +598,14 @@ class Snoopy
$this->_submit_type = "application/x-www-form-urlencoded";
}
-
-
+
+
/*======================================================================*\
Private functions
\*======================================================================*/
-
-
+
+
/*======================================================================*\
Function: _striplinks
Purpose: strip the hyperlinks from an html document
@@ -614,13 +614,13 @@ class Snoopy
\*======================================================================*/
function _striplinks($document)
- {
+ {
preg_match_all("'<\s*a\s.*?href\s*=\s* # find <a href=
([\"\'])? # find single or double quote
(?(1) (.*?)\\1 | ([^\s\>]+)) # if quote found, match up to next matching
# quote, otherwise match up to next space
'isx",$document,$links);
-
+
// catenate the non-empty matches from the conditional subpattern
@@ -628,14 +628,14 @@ class Snoopy
{
if(!empty($val))
$match[] = $val;
- }
-
+ }
+
while(list($key,$val) = each($links[3]))
{
if(!empty($val))
$match[] = $val;
- }
-
+ }
+
// return the links
return $match;
}
@@ -648,18 +648,18 @@ class Snoopy
\*======================================================================*/
function _stripform($document)
- {
+ {
preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements);
-
+
// catenate the matches
$match = implode("\r\n",$elements[0]);
-
+
// return the links
return $match;
}
-
-
+
+
/*======================================================================*\
Function: _striptext
Purpose: strip the text from an html document
@@ -669,11 +669,11 @@ class Snoopy
function _striptext($document)
{
-
+
// I didn't use preg eval (//e) since that is only available in PHP 4.0.
// so, list your entities one by one here. I included some of the
// more common ones.
-
+
$search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript
"'<[\/\!]*?[^<>]*?>'si", // strip out html tags
"'([\r\n])[\s]+'", // strip out white space
@@ -722,9 +722,9 @@ class Snoopy
"Ü",
"ß",
);
-
+
$text = preg_replace($search,$replace,$document);
-
+
return $text;
}
@@ -738,7 +738,7 @@ class Snoopy
function _expandlinks($links,$URI)
{
-
+
preg_match("/^[^\?]+/",$URI,$match);
$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]);
@@ -746,21 +746,21 @@ class Snoopy
$match_part = parse_url($match);
$match_root =
$match_part["scheme"]."://".$match_part["host"];
-
+
$search = array( "|^http://".preg_quote($this->host)."|i",
"|^(\/)|i",
"|^(?!http://)(?!mailto:)|i",
"|/\./|",
"|/[^\/]+/\.\./|"
);
-
+
$replace = array( "",
$match_root."/",
$match."/",
"/",
"/"
- );
-
+ );
+
$expandedLinks = preg_replace($search,$replace,$links);
return $expandedLinks;
@@ -773,19 +773,19 @@ class Snoopy
$fp the current open file pointer
$URI the full URI
$body body contents to send if any (POST)
- Output:
+ Output:
\*======================================================================*/
-
+
function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
{
$cookie_headers = '';
if($this->passcookies && $this->_redirectaddr)
$this->setcookies();
-
+
$URI_PARTS = parse_url($URI);
if(empty($url))
$url = "/";
- $headers = $http_method." ".$url." ".$this->_httpversion."\r\n";
+ $headers = $http_method." ".$url." ".$this->_httpversion."\r\n";
if(!empty($this->agent))
$headers .= "User-Agent: ".$this->agent."\r\n";
if(!empty($this->host) && !isset($this->rawheaders['Host'])) {
@@ -799,10 +799,10 @@ class Snoopy
if(!empty($this->referer))
$headers .= "Referer: ".$this->referer."\r\n";
if(!empty($this->cookies))
- {
+ {
if(!is_array($this->cookies))
$this->cookies = (array)$this->cookies;
-
+
reset($this->cookies);
if ( count($this->cookies) > 0 ) {
$cookie_headers .= 'Cookie: ';
@@ -810,7 +810,7 @@ class Snoopy
$cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
}
$headers .= substr($cookie_headers,0,-2) . "\r\n";
- }
+ }
}
if(!empty($this->rawheaders))
{
@@ -825,28 +825,28 @@ class Snoopy
$headers .= "; boundary=".$this->_mime_boundary;
$headers .= "\r\n";
}
- if(!empty($body))
+ if(!empty($body))
$headers .= "Content-length: ".strlen($body)."\r\n";
- if(!empty($this->user) || !empty($this->pass))
+ if(!empty($this->user) || !empty($this->pass))
$headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n";
-
+
//add proxy auth headers
- if(!empty($this->proxy_user))
+ if(!empty($this->proxy_user))
$headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n";
$headers .= "\r\n";
-
+
// set the read timeout if needed
if ($this->read_timeout > 0)
socket_set_timeout($fp, $this->read_timeout);
$this->timed_out = false;
-
+
fwrite($fp,$headers.$body,strlen($headers.$body));
-
+
$this->_redirectaddr = false;
unset($this->headers);
-
+
while($currentHeader = fgets($fp,$this->_maxlinelen))
{
if ($this->read_timeout > 0 && $this->_check_timeout($fp))
@@ -854,10 +854,10 @@ class Snoopy
$this->status=-100;
return false;
}
-
+
if($currentHeader == "\r\n")
break;
-
+
// if a header begins with Location: or URI:, set the redirect
if(preg_match("/^(Location:|URI:)/i",$currentHeader))
{
@@ -877,16 +877,16 @@ class Snoopy
else
$this->_redirectaddr = $matches[2];
}
-
+
if(preg_match("|^HTTP/|",$currentHeader))
{
if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
{
$this->status= $status[1];
- }
+ }
$this->response_code = $currentHeader;
}
-
+
$this->headers[] = $currentHeader;
}
@@ -904,13 +904,13 @@ class Snoopy
$this->status=-100;
return false;
}
-
+
// check if there is a a redirect meta tag
-
+
if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
{
- $this->_redirectaddr = $this->_expandlinks($match[1],$URI);
+ $this->_redirectaddr = $this->_expandlinks($match[1],$URI);
}
// have we hit our frame depth and is there frame src to fetch?
@@ -926,7 +926,7 @@ class Snoopy
// no framed content
else
$this->results = $results;
-
+
return true;
}
@@ -936,21 +936,21 @@ class Snoopy
Input: $url the url to fetch
$URI the full URI
$body body contents to send if any (POST)
- Output:
+ Output:
\*======================================================================*/
-
+
function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
- {
+ {
if($this->passcookies && $this->_redirectaddr)
$this->setcookies();
- $headers = array();
-
+ $headers = array();
+
$URI_PARTS = parse_url($URI);
if(empty($url))
$url = "/";
// GET ... header not needed for curl
- //$headers[] = $http_method." ".$url." ".$this->_httpversion;
+ //$headers[] = $http_method." ".$url." ".$this->_httpversion;
if(!empty($this->agent))
$headers[] = "User-Agent: ".$this->agent;
if(!empty($this->host))
@@ -963,10 +963,10 @@ class Snoopy
if(!empty($this->referer))
$headers[] = "Referer: ".$this->referer;
if(!empty($this->cookies))
- {
+ {
if(!is_array($this->cookies))
$this->cookies = (array)$this->cookies;
-
+
reset($this->cookies);
if ( count($this->cookies) > 0 ) {
$cookie_str = 'Cookie: ';
@@ -989,43 +989,43 @@ class Snoopy
else
$headers[] = "Content-type: $content_type";
}
- if(!empty($body))
+ if(!empty($body))
$headers[] = "Content-length: ".strlen($body);
- if(!empty($this->user) || !empty($this->pass))
+ if(!empty($this->user) || !empty($this->pass))
$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
-
+
for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
$safer_header = strtr( $headers[$curr_header], "\"", " " );
$cmdline_params .= " -H \"".$safer_header."\"";
}
-
+
if(!empty($body))
$cmdline_params .= " -d \"$body\"";
-
+
if($this->read_timeout > 0)
$cmdline_params .= " -m ".$this->read_timeout;
-
+
$headerfile = tempnam($temp_dir, "sno");
exec($this->curl_path." -k -D \"$headerfile\"".$cmdline_params." \"".escapeshellcmd($URI)."\"",$results,$return);
-
+
if($return)
{
$this->error = "Error: cURL could not retrieve the document, error $return.";
return false;
}
-
-
+
+
$results = implode("\r\n",$results);
-
+
$result_headers = file("$headerfile");
-
+
$this->_redirectaddr = false;
unset($this->headers);
-
+
for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
{
-
+
// if a header begins with Location: or URI:, set the redirect
if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
{
@@ -1045,7 +1045,7 @@ class Snoopy
else
$this->_redirectaddr = $matches[2];
}
-
+
if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
$this->response_code = $result_headers[$currentHeader];
@@ -1053,10 +1053,10 @@ class Snoopy
}
// check if there is a a redirect meta tag
-
+
if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
{
- $this->_redirectaddr = $this->_expandlinks($match[1],$URI);
+ $this->_redirectaddr = $this->_expandlinks($match[1],$URI);
}
// have we hit our frame depth and is there frame src to fetch?
@@ -1074,7 +1074,7 @@ class Snoopy
$this->results = $results;
unlink("$headerfile");
-
+
return true;
}
@@ -1082,7 +1082,7 @@ class Snoopy
Function: setcookies()
Purpose: set cookies for a redirection
\*======================================================================*/
-
+
function setcookies()
{
for($x=0; $x<count($this->headers); $x++)
@@ -1092,7 +1092,7 @@ class Snoopy
}
}
-
+
/*======================================================================*\
Function: _check_timeout
Purpose: checks whether timeout has occurred
@@ -1116,13 +1116,13 @@ class Snoopy
Purpose: make a socket connection
Input: $fp file pointer
\*======================================================================*/
-
+
function _connect(&$fp)
{
if(!empty($this->proxy_host) && !empty($this->proxy_port))
{
$this->_isproxy = true;
-
+
$host = $this->proxy_host;
$port = $this->proxy_port;
}
@@ -1131,9 +1131,9 @@ class Snoopy
$host = $this->host;
$port = $this->port;
}
-
+
$this->status = 0;
-
+
if($fp = fsockopen(
$host,
$port,
@@ -1169,13 +1169,13 @@ class Snoopy
Purpose: disconnect a socket connection
Input: $fp file pointer
\*======================================================================*/
-
+
function _disconnect($fp)
{
return(fclose($fp));
}
-
+
/*======================================================================*\
Function: _prepare_post_body
Purpose: Prepare post body according to encoding type
@@ -1183,7 +1183,7 @@ class Snoopy
$formfiles - form upload files
Output: post body
\*======================================================================*/
-
+
function _prepare_post_body($formvars, $formfiles)
{
settype($formvars, "array");
@@ -1192,7 +1192,7 @@ class Snoopy
if (count($formvars) == 0 && count($formfiles) == 0)
return;
-
+
switch ($this->_submit_type) {
case "application/x-www-form-urlencoded":
reset($formvars);
@@ -1208,7 +1208,7 @@ class Snoopy
case "multipart/form-data":
$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
-
+
reset($formvars);
while(list($key,$val) = each($formvars)) {
if (is_array($val) || is_object($val)) {
@@ -1223,7 +1223,7 @@ class Snoopy
$postdata .= "$val\r\n";
}
}
-
+
reset($formfiles);
while (list($field_name, $file_names) = each($formfiles)) {
settype($file_names, "array");
diff --git a/modules/infotools/jamendoSearch.class.php b/modules/infotools/jamendoSearch.class.php
index 57d3c948..d234ae85 100644
--- a/modules/infotools/jamendoSearch.class.php
+++ b/modules/infotools/jamendoSearch.class.php
@@ -21,11 +21,11 @@
*/
/**
- * jamendoSearch
- * This class does XML lookups against the jamendo website
+ * jamendoSearch
+ * This class does XML lookups against the jamendo website
* and returns information
*/
-class jamendoSearch {
+class jamendoSearch {
@@ -36,29 +36,29 @@ class jamendoSearch {
* Constructor
* This function inits the searcher
*/
- function jamendoSearch() {
+ function jamendoSearch() {
/* Load the XMLRPC client */
- $this->_client = new XML_RPC_Client('/xmlrpc/','www.jamendo.com',80);
+ $this->_client = new XML_RPC_Client('/xmlrpc/','www.jamendo.com',80);
} // jamendoSearch
/**
* query
- * This runs a XMLRPC query and returns decoded data
+ * This runs a XMLRPC query and returns decoded data
*/
- function query($command,$options) {
-
+ function query($command,$options) {
+
$encoded_command = new XML_RPC_Value($command);
$encoded_options = new XML_RPC_Value($options,'struct');
- $message = new XML_RPC_Message('jamendo.get',array($encoded_command,$encoded_options));
- $response = $this->_client->send($message,15);
- $value = $response->value();
+ $message = new XML_RPC_Message('jamendo.get',array($encoded_command,$encoded_options));
+ $response = $this->_client->send($message,15);
+ $value = $response->value();
- return XML_RPC_Decode($value);
+ return XML_RPC_Decode($value);
} // query
-} // jamendoSearch
+} // jamendoSearch
?>
diff --git a/modules/mpd/mpd.class.php b/modules/mpd/mpd.class.php
index b0c9c76c..588f0604 100644
--- a/modules/mpd/mpd.class.php
+++ b/modules/mpd/mpd.class.php
@@ -21,7 +21,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
+ */
// Create common command definitions for MPD to use
define("MPD_CMD_STATUS", "status");
@@ -98,14 +98,14 @@ class mpd {
var $db_last_refreshed;
var $num_songs_played;
var $playlist_count;
-
+
var $num_artists;
var $num_albums;
var $num_songs;
-
+
var $playlist = array();
- // Misc Other Vars
+ // Misc Other Vars
var $mpd_class_version = "1.2";
var $errStr = ""; // Used for maintaining information about the last error message
@@ -115,19 +115,19 @@ class mpd {
// =================== BEGIN OBJECT METHODS ================
/* mpd() : Constructor
- *
+ *
* Builds the MPD object, connects to the server, and refreshes all local object properties.
*/
public function __construct($srv,$port,$pwd = NULL) {
$this->host = $srv;
$this->port = $port;
$this->password = $pwd;
-
+
$resp = $this->Connect();
if ( is_null($resp) ) {
$this->errStr = "Could not connect";
return;
- }
+ }
list ( $this->mpd_version ) = sscanf($resp, OK . " MPD %s\n");
@@ -137,7 +137,7 @@ class mpd {
$this->errStr = "Password supplied is incorrect or Invalid Command";
return; // bad password or command
}
-
+
if ( is_null($this->RefreshInfo()) ) { // no read access -- might as well be disconnected!
$this->connected = FALSE;
$this->errStr = "Password supplied does not have read access";
@@ -148,32 +148,32 @@ class mpd {
if ( is_null($this->RefreshInfo()) ) { // no read access -- might as well be disconnected!
$this->connected = FALSE;
$this->errStr = "Password required to access server";
- return;
+ return;
}
}
- return true;
+ return true;
} // constructor
/* Connect()
- *
- * Connects to the MPD server.
- *
+ *
+ * Connects to the MPD server.
+ *
* NOTE: This is called automatically upon object instantiation; you should not need to call this directly.
*/
public function Connect() {
debug_event('MPD',"mpd->Connect() / host: ".$this->host.", port: ".$this->port,'5');
$this->mpd_sock = fsockopen($this->host,$this->port,$errNo,$errStr,6);
- /* Vollmerize this bizatch, if we've got php4.3+ we should
+ /* Vollmerize this bizatch, if we've got php4.3+ we should
* have these functions and we need them
*/
- if (function_exists('stream_set_timeout')) {
-
+ if (function_exists('stream_set_timeout')) {
+
/* Set the timeout on the connection */
stream_set_timeout($this->mpd_sock,6);
-
+
/* We want blocking, cause otherwise it doesn't
- * timeout, and feof just keeps on spinning
+ * timeout, and feof just keeps on spinning
*/
stream_set_blocking($this->mpd_sock,TRUE);
$status = socket_get_status($this->mpd_sock);
@@ -181,14 +181,14 @@ class mpd {
if (!$this->mpd_sock) {
$this->errStr = "Socket Error: $errStr ($errNo)";
return NULL;
- }
+ }
else {
while(!feof($this->mpd_sock) && !$status['timed_out']) {
$response = fgets($this->mpd_sock,1024);
- if (function_exists('socket_get_status')) {
+ if (function_exists('socket_get_status')) {
$status = socket_get_status($this->mpd_sock);
}
- if (strstr($response,"OK")) {
+ if (strstr($response,"OK")) {
$this->connected = TRUE;
return $response;
break;
@@ -198,7 +198,7 @@ class mpd {
return NULL;
}
-
+
} // end while
// Generic response
$this->errStr = "Connection not available";
@@ -208,9 +208,9 @@ class mpd {
} // connect
/* SendCommand()
- *
- * Sends a generic command to the MPD server. Several command constants are pre-defined for
- * use (see MPD_CMD_* constant definitions above).
+ *
+ * Sends a generic command to the MPD server. Several command constants are pre-defined for
+ * use (see MPD_CMD_* constant definitions above).
*/
function SendCommand($cmdStr,$arg1 = "",$arg2 = "") {
debug_event('MPD',"mpd->SendCommand() / cmd: ".$cmdStr.", args: ".$arg1." ".$arg2,'5');
@@ -255,11 +255,11 @@ class mpd {
return $respStr;
}
- /* QueueCommand()
+ /* QueueCommand()
*
- * Queues a generic command for later sending to the MPD server. The CommandQueue can hold
- * as many commands as needed, and are sent all at once, in the order they are queued, using
- * the SendCommandQueue() method. The syntax for queueing commands is identical to SendCommand().
+ * Queues a generic command for later sending to the MPD server. The CommandQueue can hold
+ * as many commands as needed, and are sent all at once, in the order they are queued, using
+ * the SendCommandQueue() method. The syntax for queueing commands is identical to SendCommand().
*/
function QueueCommand($cmdStr,$arg1 = "",$arg2 = "") {
if ( $this->debugging ) echo "mpd->QueueCommand() / cmd: ".$cmdStr.", args: ".$arg1." ".$arg2."\n";
@@ -280,7 +280,7 @@ class mpd {
return TRUE;
}
- /* SendCommandQueue()
+ /* SendCommandQueue()
*
* Sends all commands in the Command Queue to the MPD server. See also QueueCommand().
*/
@@ -301,10 +301,10 @@ class mpd {
return $respStr;
}
- /* AdjustVolume()
+ /* AdjustVolume()
*
* Adjusts the mixer volume on the MPD by <modifier>, which can be a positive (volume increase),
- * or negative (volume decrease) value.
+ * or negative (volume decrease) value.
*/
function AdjustVolume($modifier) {
if ( $this->debugging ) echo "mpd->AdjustVolume()\n";
@@ -321,7 +321,7 @@ class mpd {
return $ret;
}
- /* SetVolume()
+ /* SetVolume()
*
* Sets the mixer volume to <newVol>, which should be between 1 - 100.
*/
@@ -353,11 +353,11 @@ class mpd {
return $ret;
}
- /* GetDir()
- *
+ /* GetDir()
+ *
* Retrieves a database directory listing of the <dir> directory and places the results into
- * a multidimensional array. If no directory is specified, the directory listing is at the
- * base of the MPD music path.
+ * a multidimensional array. If no directory is specified, the directory listing is at the
+ * base of the MPD music path.
*/
function GetDir($dir = "") {
if ( $this->debugging ) echo "mpd->GetDir()\n";
@@ -367,10 +367,10 @@ class mpd {
return $dirlist;
}
- /* PLAdd()
- *
- * Adds each track listed in a single-dimensional <trackArray>, which contains filenames
- * of tracks to add, to the end of the playlist. This is used to add many, many tracks to
+ /* PLAdd()
+ *
+ * Adds each track listed in a single-dimensional <trackArray>, which contains filenames
+ * of tracks to add, to the end of the playlist. This is used to add many, many tracks to
* the playlist in one swoop.
*/
function PLAddBulk($trackArray) {
@@ -385,9 +385,9 @@ class mpd {
return $resp;
}
- /* PLAdd()
- *
- * Adds the file <file> to the end of the playlist. <file> must be a track in the MPD database.
+ /* PLAdd()
+ *
+ * Adds the file <file> to the end of the playlist. <file> must be a track in the MPD database.
*/
function PLAdd($fileName) {
if ( $this->debugging ) echo "mpd->PLAdd()\n";
@@ -396,9 +396,9 @@ class mpd {
return $resp;
}
- /* PLMoveTrack()
- *
- * Moves track number <origPos> to position <newPos> in the playlist. This is used to reorder
+ /* PLMoveTrack()
+ *
+ * Moves track number <origPos> to position <newPos> in the playlist. This is used to reorder
* the songs in the playlist.
*/
function PLMoveTrack($origPos, $newPos) {
@@ -406,21 +406,21 @@ class mpd {
if ( ! is_numeric($origPos) ) {
$this->errStr = "PLMoveTrack(): argument 1 must be numeric";
return NULL;
- }
+ }
if ( $origPos < 0 or $origPos > $this->playlist_count ) {
$this->errStr = "PLMoveTrack(): argument 1 out of range";
return NULL;
}
if ( $newPos < 0 ) $newPos = 0;
if ( $newPos > $this->playlist_count ) $newPos = $this->playlist_count;
-
+
if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLMOVETRACK,$origPos,$newPos))) $this->RefreshInfo();
if ( $this->debugging ) echo "mpd->PLMoveTrack() / return\n";
return $resp;
}
- /* PLShuffle()
- *
+ /* PLShuffle()
+ *
* Randomly reorders the songs in the playlist.
*/
function PLShuffle() {
@@ -430,9 +430,9 @@ class mpd {
return $resp;
}
- /* PLLoad()
- *
- * Retrieves the playlist from <file>.m3u and loads it into the current playlist.
+ /* PLLoad()
+ *
+ * Retrieves the playlist from <file>.m3u and loads it into the current playlist.
*/
function PLLoad($file) {
if ( $this->debugging ) echo "mpd->PLLoad()\n";
@@ -441,8 +441,8 @@ class mpd {
return $resp;
}
- /* PLSave()
- *
+ /* PLSave()
+ *
* Saves the playlist to <file>.m3u for later retrieval. The file is saved in the MPD playlist
* directory.
*/
@@ -453,8 +453,8 @@ class mpd {
return $resp;
}
- /* PLClear()
- *
+ /* PLClear()
+ *
* Empties the playlist.
*/
function PLClear() {
@@ -464,8 +464,8 @@ class mpd {
return $resp;
}
- /* PLRemove()
- *
+ /* PLRemove()
+ *
* Removes track <id> from the playlist.
*/
public function PLRemove($id) {
@@ -474,13 +474,13 @@ class mpd {
return NULL;
}
if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLREMOVE,$id))) $this->RefreshInfo();
- debug_event('MPD',"mpd->PLRemove() / return",'5');
+ debug_event('MPD',"mpd->PLRemove() / return",'5');
return $resp;
} // PLRemove
- /* SetRepeat()
- *
- * Enables 'loop' mode -- tells MPD continually loop the playlist. The <repVal> parameter
+ /* SetRepeat()
+ *
+ * Enables 'loop' mode -- tells MPD continually loop the playlist. The <repVal> parameter
* is either 1 (on) or 0 (off).
*/
function SetRepeat($repVal) {
@@ -491,8 +491,8 @@ class mpd {
return $rpt;
}
- /* SetRandom()
- *
+ /* SetRandom()
+ *
* Enables 'randomize' mode -- tells MPD to play songs in the playlist in random order. The
* <rndVal> parameter is either 1 (on) or 0 (off).
*/
@@ -504,10 +504,10 @@ class mpd {
return $resp;
}
- /* Shutdown()
- *
- * Shuts down the MPD server (aka sends the KILL command). This closes the current connection,
- * and prevents future communication with the server.
+ /* Shutdown()
+ *
+ * Shuts down the MPD server (aka sends the KILL command). This closes the current connection,
+ * and prevents future communication with the server.
*/
function Shutdown() {
if ( $this->debugging ) echo "mpd->Shutdown()\n";
@@ -522,15 +522,15 @@ class mpd {
return $resp;
}
- /* DBRefresh()
- *
- * Tells MPD to rescan the music directory for new tracks, and to refresh the Database. Tracks
+ /* DBRefresh()
+ *
+ * Tells MPD to rescan the music directory for new tracks, and to refresh the Database. Tracks
* cannot be played unless they are in the MPD database.
*/
function DBRefresh() {
if ( $this->debugging ) echo "mpd->DBRefresh()\n";
$resp = $this->SendCommand(MPD_CMD_REFRESH);
-
+
// Update local variables
$this->RefreshInfo();
@@ -538,9 +538,9 @@ class mpd {
return $resp;
}
- /* Play()
- *
- * Begins playing the songs in the MPD playlist.
+ /* Play()
+ *
+ * Begins playing the songs in the MPD playlist.
*/
function Play() {
if ( $this->debugging ) echo "mpd->Play()\n";
@@ -549,9 +549,9 @@ class mpd {
return $rpt;
}
- /* Stop()
- *
- * Stops playing the MPD.
+ /* Stop()
+ *
+ * Stops playing the MPD.
*/
function Stop() {
if ( $this->debugging ) echo "mpd->Stop()\n";
@@ -560,10 +560,10 @@ class mpd {
return $rpt;
}
- /* Pause()
- *
+ /* Pause()
+ *
* Toggles pausing on the MPD. Calling it once will pause the player, calling it again
- * will unpause.
+ * will unpause.
*/
function Pause() {
if ( $this->debugging ) echo "mpd->Pause()\n";
@@ -571,12 +571,12 @@ class mpd {
if ( $this->debugging ) echo "mpd->Pause() / return\n";
return $rpt;
}
-
- /* SeekTo()
- *
- * Skips directly to the <idx> song in the MPD playlist.
+
+ /* SeekTo()
+ *
+ * Skips directly to the <idx> song in the MPD playlist.
*/
- function SkipTo($idx) {
+ function SkipTo($idx) {
if ( $this->debugging ) echo "mpd->SkipTo()\n";
if ( ! is_numeric($idx) ) {
$this->errStr = "SkipTo() : argument 1 must be a numeric value";
@@ -587,13 +587,13 @@ class mpd {
return $idx;
}
- /* SeekTo()
- *
+ /* SeekTo()
+ *
* Skips directly to a given position within a track in the MPD playlist. The <pos> argument,
* given in seconds, is the track position to locate. The <track> argument, if supplied is
* the track number in the playlist. If <track> is not specified, the current track is assumed.
*/
- function SeekTo($pos, $track = -1) {
+ function SeekTo($pos, $track = -1) {
if ( $this->debugging ) echo "mpd->SeekTo()\n";
if ( ! is_numeric($pos) ) {
$this->errStr = "SeekTo() : argument 1 must be a numeric value";
@@ -603,18 +603,18 @@ class mpd {
$this->errStr = "SeekTo() : argument 2 must be a numeric value";
return NULL;
}
- if ( $track == -1 ) {
+ if ( $track == -1 ) {
$track = $this->current_track_id;
- }
-
+ }
+
if ( ! is_null($rpt = $this->SendCommand(MPD_CMD_SEEK,$track,$pos))) $this->RefreshInfo();
if ( $this->debugging ) echo "mpd->SeekTo() / return\n";
return $pos;
}
- /* Next()
- *
- * Skips to the next song in the MPD playlist. If not playing, returns an error.
+ /* Next()
+ *
+ * Skips to the next song in the MPD playlist. If not playing, returns an error.
*/
function Next() {
if ( $this->debugging ) echo "mpd->Next()\n";
@@ -623,9 +623,9 @@ class mpd {
return $rpt;
}
- /* Previous()
- *
- * Skips to the previous song in the MPD playlist. If not playing, returns an error.
+ /* Previous()
+ *
+ * Skips to the previous song in the MPD playlist. If not playing, returns an error.
*/
function Previous() {
if ( $this->debugging ) echo "mpd->Previous()\n";
@@ -633,13 +633,13 @@ class mpd {
if ( $this->debugging ) echo "mpd->Previous() / return\n";
return $rpt;
}
-
- /* Search()
- *
- * Searches the MPD database. The search <type> should be one of the following:
+
+ /* Search()
+ *
+ * Searches the MPD database. The search <type> should be one of the following:
* MPD_SEARCH_ARTIST, MPD_SEARCH_TITLE, MPD_SEARCH_ALBUM
- * The search <string> is a case-insensitive locator string. Anything that contains
- * <string> will be returned in the results.
+ * The search <string> is a case-insensitive locator string. Anything that contains
+ * <string> will be returned in the results.
*/
function Search($type,$string) {
if ( $this->debugging ) echo "mpd->Search()\n";
@@ -656,13 +656,13 @@ class mpd {
return $searchlist;
}
- /* Find()
- *
- * Find() looks for exact matches in the MPD database. The find <type> should be one of
- * the following:
+ /* Find()
+ *
+ * Find() looks for exact matches in the MPD database. The find <type> should be one of
+ * the following:
* MPD_SEARCH_ARTIST, MPD_SEARCH_TITLE, MPD_SEARCH_ALBUM
- * The find <string> is a case-insensitive locator string. Anything that exactly matches
- * <string> will be returned in the results.
+ * The find <string> is a case-insensitive locator string. Anything that exactly matches
+ * <string> will be returned in the results.
*/
function Find($type,$string) {
if ( $this->debugging ) echo "mpd->Find()\n";
@@ -679,8 +679,8 @@ class mpd {
return $searchlist;
}
- /* Disconnect()
- *
+ /* Disconnect()
+ *
* Closes the connection to the MPD server.
*/
function Disconnect() {
@@ -693,15 +693,15 @@ class mpd {
unset($this->mpd_sock);
}
- /* GetArtists()
- *
+ /* GetArtists()
+ *
* Returns the list of artists in the database in an associative array.
*/
function GetArtists() {
if ( $this->debugging ) echo "mpd->GetArtists()\n";
if ( is_null($resp = $this->SendCommand(MPD_CMD_TABLE, MPD_TBL_ARTIST))) return NULL;
$arArray = array();
-
+
$arLine = strtok($resp,"\n");
$arName = "";
$arCounter = -1;
@@ -719,8 +719,8 @@ class mpd {
return $arArray;
}
- /* GetAlbums()
- *
+ /* GetAlbums()
+ *
* Returns the list of albums in the database in an associative array. Optional parameter
* is an artist Name which will list all albums by a particular artist.
*/
@@ -760,9 +760,9 @@ class mpd {
return ( 100 * $ver_maj ) + ( 10 * $ver_min ) + ( $ver_rel );
}
- /* _checkCompatibility()
- *
- * Check MPD command compatibility against our internal table. If there is no version
+ /* _checkCompatibility()
+ *
+ * Check MPD command compatibility against our internal table. If there is no version
* listed in the table, allow it by default.
*/
function _checkCompatibility($cmd) {
@@ -794,8 +794,8 @@ class mpd {
return TRUE;
}
- /* _parseFileListResponse()
- *
+ /* _parseFileListResponse()
+ *
* Builds a multidimensional array with MPD response lists.
*
* NOTE: This function is used internally within the class. It should not be used.
@@ -819,13 +819,13 @@ class mpd {
}
$plistLine = strtok("\n");
- }
+ }
}
return $plistArray;
}
- /* RefreshInfo()
- *
+ /* RefreshInfo()
+ *
* Updates all class properties with the values from the MPD server.
*
* NOTE: This function is automatically called upon Connect() as of v1.1.
@@ -842,7 +842,7 @@ class mpd {
list ( $element, $value ) = explode(": ",$statLine);
$stats[$element] = $value;
$statLine = strtok("\n");
- }
+ }
}
// Get the Server Status
@@ -894,8 +894,8 @@ class mpd {
}
/* ------------------ DEPRECATED METHODS -------------------*/
- /* GetStatistics()
- *
+ /* GetStatistics()
+ *
* Retrieves the 'statistics' variables from the server and tosses them into an array.
*
* NOTE: This function really should not be used. Instead, use $this->[variable]. The function
@@ -913,14 +913,14 @@ class mpd {
list ( $element, $value ) = explode(": ",$statsLine);
$statsArray[$element] = $value;
$statsLine = strtok("\n");
- }
+ }
}
if ( $this->debugging ) echo "mpd->GetStatistics() / return: " . print_r($statsArray) ."\n";
return $statsArray;
}
- /* GetStatus()
- *
+ /* GetStatus()
+ *
* Retrieves the 'status' variables from the server and tosses them into an array.
*
* NOTE: This function really should not be used. Instead, use $this->[variable]. The function
@@ -944,8 +944,8 @@ class mpd {
return $statusArray;
}
- /* GetVolume()
- *
+ /* GetVolume()
+ *
* Retrieves the mixer volume from the server.
*
* NOTE: This function really should not be used. Instead, use $this->volume. The function
@@ -963,8 +963,8 @@ class mpd {
return $vol;
}
- /* GetPlaylist()
- *
+ /* GetPlaylist()
+ *
* Retrieves the playlist from the server and tosses it into a multidimensional array.
*
* NOTE: This function really should not be used. Instead, use $this->playlist. The function
@@ -989,7 +989,7 @@ class mpd {
$this->RefreshInfo();
if ($resp = ($this->state == MPD_STATE_STOPPED)) {
$this->PLClear();
- return true;
+ return true;
}
return false;
diff --git a/modules/php_musicbrainz/mbArtist.php b/modules/php_musicbrainz/mbArtist.php
index 7ba126b0..972ca311 100644
--- a/modules/php_musicbrainz/mbArtist.php
+++ b/modules/php_musicbrainz/mbArtist.php
@@ -14,7 +14,7 @@
private $releasesCount = 0;
private $releasesOffset = 0;
private $aliases = array();
-
+
function mbArtist( $id = '', $type = '', $name = '', $sortName = '' ) {
parent::MusicBrainzEntity($id);
$this->type = $type;
@@ -102,7 +102,7 @@
if ( empty( $rresults ) )
return "";
-
+
$keys = array();
foreach ( $rresults as $key => $rr ) {
$rr = $rr->getRelease();
diff --git a/modules/php_musicbrainz/mbArtistAlias.php b/modules/php_musicbrainz/mbArtistAlias.php
index c7e7e95d..3b65fcb6 100644
--- a/modules/php_musicbrainz/mbArtistAlias.php
+++ b/modules/php_musicbrainz/mbArtistAlias.php
@@ -4,7 +4,7 @@
private $value;
private $type;
private $script;
-
+
function mbAristAlias( $value='', $type='', $script='' ) {
$this->value = $value;
$this->type = $type;
diff --git a/modules/php_musicbrainz/mbDisc.php b/modules/php_musicbrainz/mbDisc.php
index 63087016..90dacc06 100644
--- a/modules/php_musicbrainz/mbDisc.php
+++ b/modules/php_musicbrainz/mbDisc.php
@@ -1,7 +1,7 @@
<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
class mbDiscError extends Exception { }
-
+
class mbDisc {
private $id;
private $sectors = 0;
@@ -22,7 +22,7 @@
function getLastTrackNum ( ) { return $this->lastTrackNum; }
function setFirstTrackNum( $track ) { $this->firstTrackNum = $track; }
function getFirstTrackNum( ) { return $this->firstTrackNum; }
-
+
function &getTracks() {
return $this->tracks;
}
@@ -46,7 +46,7 @@
foreach ( $disc->getTracks() as $track )
$toc .= '+' . $track[0];
- return "http://" . $netloc . "/bare/cdlookup.html?id=" . $disc->getId() . "&toc=" . $toc .
+ return "http://" . $netloc . "/bare/cdlookup.html?id=" . $disc->getId() . "&toc=" . $toc .
"&tracks=" . $disc->getLastTrackNum();
}
}
diff --git a/modules/php_musicbrainz/mbEntity.php b/modules/php_musicbrainz/mbEntity.php
index 47089279..86cfdc07 100644
--- a/modules/php_musicbrainz/mbEntity.php
+++ b/modules/php_musicbrainz/mbEntity.php
@@ -21,7 +21,7 @@
function &getRelations( $target_type='', $relation_type='' ) {
if ( $target_type == '' && $relation_type == '' )
return $this->relations;
-
+
$result = array();
if ( empty($target_type) ) {
diff --git a/modules/php_musicbrainz/mbFilter.php b/modules/php_musicbrainz/mbFilter.php
index 02ee41f7..a759fffa 100644
--- a/modules/php_musicbrainz/mbFilter.php
+++ b/modules/php_musicbrainz/mbFilter.php
@@ -6,11 +6,11 @@
class mbArtistFilter implements MusicBrainzFilter {
private $parameterList = array();
-
+
function createParameters() {
return $this->parameterList;
}
-
+
function name( $name ) {
$this->parameterList['name'] = $name;
return $this;
@@ -46,14 +46,14 @@
function releaseType( $rtype ) {
$type = extractFragment($rtype);
-
+
if ( isset( $this->parameters['releasetypes'] ) ) {
$this->parameters['releasetypes'] .= ' ' . $type;
}
else {
$this->parameters['releasetypes'] = $type;
}
-
+
return $this;
}
@@ -71,12 +71,12 @@
$this->parameters['asin'] = $asin;
return $this;
}
-
+
function limit( $limit ) {
$this->parameters['limit'] = $limit;
return $this;
}
-
+
function offset( $offset ) {
$this->parameterList['offset'] = $offset;
return $this;
@@ -135,14 +135,14 @@
return $this;
}
}
-
+
class mbUserFilter implements MusicBrainzFilter {
private $parameters = array();
-
+
function createParameters() {
return $this->parameters;
}
-
+
function name( $value ) {
$this->parameters['name'] = $value;
}
diff --git a/modules/php_musicbrainz/mbLabel.php b/modules/php_musicbrainz/mbLabel.php
index a94443f7..67e069ef 100644
--- a/modules/php_musicbrainz/mbLabel.php
+++ b/modules/php_musicbrainz/mbLabel.php
@@ -34,7 +34,7 @@
function getBeginDate() { return $this->beginDate; }
function setEndDate( $endDate ) { $this->endDate = $endDate; }
function getEndDate() { return $this->endDate; }
-
+
function getUniqueName() {
return empty($this->disambiguation) ? $this->name :
$this->name . ' (' . $this->disambiguation . ')';
diff --git a/modules/php_musicbrainz/mbMetadata.php b/modules/php_musicbrainz/mbMetadata.php
index 076bf6be..45453d6e 100644
--- a/modules/php_musicbrainz/mbMetadata.php
+++ b/modules/php_musicbrainz/mbMetadata.php
@@ -54,13 +54,13 @@
function &getArtistResults () { return $this->artistList; }
function &getTrackResults () { return $this->trackList; }
function &getReleaseResults() { return $this->releaseList; }
-
+
function getUserList2( $remove ) {
$ul = $this->userList;
$this->userList = array();
return $ul;
}
-
+
function getArtistResults2( $remove ) {
$al = $this->artistList;
$this->artistList = array();
diff --git a/modules/php_musicbrainz/mbQuery.php b/modules/php_musicbrainz/mbQuery.php
index 07afd771..df8aa4aa 100644
--- a/modules/php_musicbrainz/mbQuery.php
+++ b/modules/php_musicbrainz/mbQuery.php
@@ -1,9 +1,9 @@
<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
define ( 'NS_MMD_1', "http://musicbrainz.org/ns/mmd-1.0#" );
-
+
require_once( 'xml/xmlParser.php' );
-
+
require_once( 'mbUtil.php' );
require_once( 'mbRelation.php' );
require_once( 'mbEntity.php' );
@@ -39,21 +39,21 @@
$this->ws = new mbWebService();
$this->ownWs = true;
}
-
+
$this->clientId = $clientId;
}
function getUserByName( $name ) {
$metadata = $this->getFromWebService( "user", "", null, mbUserFilter().name($name) );
$list = $metadata->getUserList(true);
-
+
if ( count($list) > 0 ) {
return $list[0];
}
-
+
throw mbResponseError("response didn't contain user data");
}
-
+
function getArtists( mbArtistFilter $artist_filters ) {
$metadata = $this->getFromWebService( "artist", "", null, $artist_filters );
return $metadata->getArtistResults2(true);
@@ -63,12 +63,12 @@
$metadata = $this->getFromWebService( "release", "", null, $release_filters );
return $metadata->getReleaseResults2(true);
}
-
+
function getTracks( mbTrackFilter $track_filters ) {
$metadata = $this->getFromWebService( "track", "", null, $track_filters );
return $metadata->getTrackResults2(true);
}
-
+
function getArtistById( $aID, mbArtistIncludes $artist_includes ) {
try {
$id = extractUuid($aID);
@@ -106,7 +106,7 @@
$includeList = $includes ? $includes->createIncludeTags() : null;
$filterList = $filters ? $filters->createParameters() : null;
$content = $this->ws->get( $entity, $id, $includeList, $filterList );
-
+
try {
$parser = new mbXmlParser();
$parsed_content = $parser->parse($content);
diff --git a/modules/php_musicbrainz/mbRelation.php b/modules/php_musicbrainz/mbRelation.php
index a03efe18..398c950f 100644
--- a/modules/php_musicbrainz/mbRelation.php
+++ b/modules/php_musicbrainz/mbRelation.php
@@ -4,7 +4,7 @@
const DIR_BOTH = 0;
const DIR_FORWARD = 1;
const DIR_BACKWARD = 2;
-
+
const TO_ARTIST = "http://musicbrainz.org/ns/mmd-1.0#Artist";
const TO_TRACK = "http://musicbrainz.org/ns/mmd-1.0#Track";
const TO_RELEASE = "http://musicbrainz.org/ns/mmd-1.0#Release";
@@ -76,7 +76,7 @@
function getEndDate() {
return $this->endDate;
}
-
+
function getDirection() {
return $this->direction;
}
diff --git a/modules/php_musicbrainz/mbRelease.php b/modules/php_musicbrainz/mbRelease.php
index 9bcf4321..27afa4db 100644
--- a/modules/php_musicbrainz/mbRelease.php
+++ b/modules/php_musicbrainz/mbRelease.php
@@ -3,7 +3,7 @@
class mbRelease extends MusicBrainzEntity {
// Types
const TYPE_NONE = "http://musicbrainz.org/ns/mmd-1.0#None";
-
+
const TYPE_ALBUM = "http://musicbrainz.org/ns/mmd-1.0#Album";
const TYPE_SINGLE = "http://musicbrainz.org/ns/mmd-1.0#Single";
const TYPE_EP = "http://musicbrainz.org/ns/mmd-1.0#EP";
@@ -21,7 +21,7 @@
const TYPE_PROMOTION = "http://musicbrainz.org/ns/mmd-1.0#Promotion";
const TYPE_BOOTLEG = "http://musicbrainz.org/ns/mmd-1.0#Bootleg";
const TYPE_PSEUDO_RELEASE = "http://musicbrainz.org/ns/mmd-1.0#Pseudo-Release";
-
+
private $title;
private $textLanguage;
private $textScript;
diff --git a/modules/php_musicbrainz/mbReleaseEvent.php b/modules/php_musicbrainz/mbReleaseEvent.php
index a41fa95b..3131ea55 100644
--- a/modules/php_musicbrainz/mbReleaseEvent.php
+++ b/modules/php_musicbrainz/mbReleaseEvent.php
@@ -11,7 +11,7 @@
$this->country = $country;
$this->dateStr = $dateStr;
}
-
+
function setCountry ( $country ) { $this->country = $country; }
function getCountry ( ) { return $this->country; }
function setCatalogNumber( $c_number ) { $this->catalogNumber = $c_number; }
diff --git a/modules/php_musicbrainz/mbUser.php b/modules/php_musicbrainz/mbUser.php
index 86e384f7..8317bebb 100644
--- a/modules/php_musicbrainz/mbUser.php
+++ b/modules/php_musicbrainz/mbUser.php
@@ -4,29 +4,29 @@
private $name;
private $showNag = false;
private $types = array();
-
+
function mbUser() {
}
-
+
function setName( $name ) { $this->name = $name; }
function getName() { return $this->name; }
-
+
function getShowNag() {
return $this->showNag;
}
-
+
function setShowNag( $value ) {
$this->setShowNag = $value;
}
-
+
function addType( $type ) {
$this->types[] = $type;
}
-
+
function getNumTypes() {
return count($this->types);
}
-
+
function getType( $i ) {
return $this->types[$i];
}
diff --git a/modules/php_musicbrainz/mbUtil.php b/modules/php_musicbrainz/mbUtil.php
index eff5f34c..4ebdb33a 100644
--- a/modules/php_musicbrainz/mbUtil.php
+++ b/modules/php_musicbrainz/mbUtil.php
@@ -1,7 +1,7 @@
<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
class mbValueError extends Exception {}
-
+
function extractFragment( $type ) {
if ( ( $p = parse_url( $type ) ) == false ) {
return $type;
@@ -12,7 +12,7 @@
function extractUuid( $uid ) {
if ( empty($uid) )
return $uid;
-
+
$types = array( "artist/", "release/", "track/" );
for ( $i = 0; $i < 3; $i++ ) {
if ( ($pos = strpos( $uid, $types[$i] )) !== false ) {
@@ -52,7 +52,7 @@
return "";
}
-
+
require_once( 'mbUtil_releasetypenames.php' );
function getReleaseTypeName( $id ) {
if ( isset( $mbReleaseTypeNames[$id] ) )
diff --git a/modules/php_musicbrainz/mbUtil_countrynames.php b/modules/php_musicbrainz/mbUtil_countrynames.php
index 6d0d87e6..c2fa37f8 100644
--- a/modules/php_musicbrainz/mbUtil_countrynames.php
+++ b/modules/php_musicbrainz/mbUtil_countrynames.php
@@ -1,6 +1,6 @@
<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
- $mbCountryNames = array(
+ $mbCountryNames = array(
"BD" => "Bangladesh",
"BE" => "Belgium",
"BF" => "Burkina Faso",
diff --git a/modules/php_musicbrainz/mbUtil_languagenames.php b/modules/php_musicbrainz/mbUtil_languagenames.php
index 5006198d..3e56bf82 100644
--- a/modules/php_musicbrainz/mbUtil_languagenames.php
+++ b/modules/php_musicbrainz/mbUtil_languagenames.php
@@ -1,6 +1,6 @@
<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
- $mbLanguageNames = array(
+ $mbLanguageNames = array(
"ART" => "Artificial (Other)",
"ROH" => "Raeto-Romance",
"SCO" => "Scots",
diff --git a/modules/php_musicbrainz/mbUtil_releasetypenames.php b/modules/php_musicbrainz/mbUtil_releasetypenames.php
index ad4f2bf0..a655dcdc 100644
--- a/modules/php_musicbrainz/mbUtil_releasetypenames.php
+++ b/modules/php_musicbrainz/mbUtil_releasetypenames.php
@@ -1,6 +1,6 @@
<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
- $mbReleaseTypeNames = array(
+ $mbReleaseTypeNames = array(
"http://musicbrainz.org/ns/mmd-1.0#None" => "None",
"http://musicbrainz.org/ns/mmd-1.0#Album" => "Album",
"http://musicbrainz.org/ns/mmd-1.0#Single" => "Single",
diff --git a/modules/php_musicbrainz/mbWebService.php b/modules/php_musicbrainz/mbWebService.php
index 0b59da34..76aa0939 100644
--- a/modules/php_musicbrainz/mbWebService.php
+++ b/modules/php_musicbrainz/mbWebService.php
@@ -4,7 +4,7 @@
function get ( $entity, $id, $include, $filter, $version = '1' );
function post( $entity, $id, $data, $version = '1' );
}
-
+
class mbWebService implements IWebService {
private $host;
private $port;
@@ -31,7 +31,7 @@
return true;
}
-
+
function close() {
if ( $this->fSock != -1 ) {
fclose($this->fSock);
@@ -47,7 +47,7 @@
function parseHeaders( $string ) {
$lines = explode( "\n", $string );
$this->lastHeaders = array();
-
+
foreach ( $lines as $key => $line ) {
// Status line
if ( $key == 0 ) {
@@ -81,7 +81,7 @@
$this->lastHeaders = array();
return false;
}
-
+
function getHeaders() {
return $this->lastHeaders;
}
@@ -91,7 +91,7 @@
$this->lastError = "Trying to write to closed socket.";
return false;
}
-
+
fwrite( $this->fSock, $string . "\r\n" );
fwrite( $this->fSock, "Host: " . $this->host . "\r\n" );
fwrite( $this->fSock, "Accept: */*\r\n" );
@@ -109,7 +109,7 @@
$this->lastError = "Trying to read from closed socket.";
return false;
}
-
+
$buffer = "";
while ( !feof($this->fSock) )
@@ -120,7 +120,7 @@
return $this->parseHeaders($buffer);
}
-
+
function get( $entity, $uid, $includes, $filters, $version="1" ) {
$params = array();
$params['type'] = "xml";
@@ -142,17 +142,17 @@
}
$URI = $this->pathPrefix . "/" . $version . "/" . $entity . "/" . $uid . "?" . $this->build_query( $params );
-
+
if ( $this->fSock == -1 && !$this->connect() )
return false;
-
+
$this->sendRequest( "GET $URI HTTP/1.1" );
$this->lastResponse = $this->getResponse();
$this->close();
if ( isset($this->lastHeaders['HTTP_status']) && $this->lastHeaders['HTTP_status'] != 200 )
return false;
-
+
return $this->lastResponse;
}
@@ -170,11 +170,11 @@
return $this->lastResponse;
}
-
+
function build_query( $array ) {
$first = true;
$query_string = "";
-
+
if ( !is_array($array) || sizeof($array) == 0 )
return "";
diff --git a/modules/php_musicbrainz/mbXmlParser.php b/modules/php_musicbrainz/mbXmlParser.php
index aaad0126..46d39e7c 100644
--- a/modules/php_musicbrainz/mbXmlParser.php
+++ b/modules/php_musicbrainz/mbXmlParser.php
@@ -5,19 +5,19 @@
class mbXmlParser {
private $xml_parser;
private $factory;
-
+
function mbXmlParser() {
$this->xml_parser = new xmlParser();
$this->factory = new mbDefaultFactory();
}
-
+
private function parseList( XMLNode $node, array &$list, $func ) {
for ( $i = 0; $i < $node->nChildNodes(); $i++ ) {
$cnode = $node->getChildNode($i);
$list[] = call_user_func( array( &$this, $func ), $cnode );
}
}
-
+
private function parseResults( XMLNode $node, array &$list, $func, $type ) {
for ( $i = 0; $i < $node->nChildNodes(); $i++ ) {
$cnode = $node->getChildNode($i);
@@ -29,7 +29,7 @@
$list[] = $to_add;
}
}
-
+
private function parseRelations( XMLNode $node, MusicBrainzEntity $entity ) {
$targetType = $node->getAttribute("target-type");
if ( $targetType == '' )
@@ -44,14 +44,14 @@
}
}
}
-
+
private function parseUserResults( XMLNode $node, array &$userList ) {
for ( $i = 0; $i < $node->nChildNodes(); $i++ ) {
$cnode = $node->getChildNode($i);
$userList[] = $this->createUser( $cnode );
}
}
-
+
private function createUser( XMLNode $node ) {
$user = $this->factory->newUser();
for ( $i = 0; $i < $node->nChildNodes(); $i++ ) {
@@ -68,7 +68,7 @@
}
return $user;
}
-
+
private function createArtistAlias( XMLNode $node ) {
$aa = $this->factory->newArtistAlias();
$aa->setType($node->getAttribute("type"));
@@ -77,14 +77,14 @@
return $aa;
}
-
+
private function createTag( XMLNode $node ) {
$tag = $this->factory->newTag();
$tag->setCount($node->getAttribute("count"));
$tag->setName($node->getText());
return $tag;
}
-
+
private function createLabelAlias( XML $node ) {
$la = $this->factory->newLabelAlias();
$la->setType($node->getAttribute("type"));
@@ -92,13 +92,13 @@
$la->setValue($node->getText());
return $la;
}
-
+
private function createDisc( XMLNode $node ) {
$disc = $this->factory->newDisc();
$disc->setId($node->getAttribute("id"));
return $disc;
}
-
+
private function createReleaseEvent( XMLNode $node ) {
$relEvent = $this->factory->newReleaseEvent();
$relEvent->setCountry($node->getAttribute("country"));
@@ -115,7 +115,7 @@
}
return $relEvent;
}
-
+
private function createLabel( XMLNode $node ) {
$label = $this->factory->newLabel();
$label->setId($node->getAttribute("id"));
@@ -160,7 +160,7 @@
return $label;
}
-
+
private function createArtist( XMLNode $node ) {
$artist = $this->factory->newArtist();
$artist->setId($node->getAttribute("id"));
@@ -207,7 +207,7 @@
return $artist;
}
-
+
private function createTrack( XMLNode $node ) {
$track = $this->factory->newTrack();
$track->setId($node->getAttribute("id"));
@@ -238,10 +238,10 @@
break;
}
}
-
+
return $track;
}
-
+
private function createRelease( XMLNode $node ) {
$release = $this->factory->newRelease();
$release->setId($node->getAttribute("id"));
@@ -294,13 +294,13 @@
return $release;
}
-
+
private function createRelation( XMLNode $node, $type ) {
$relation = $this->factory->newRelation();
$relation->setType(extractFragment($node->getAttribute("type"))); // TODO: fixme
$relation->setTargetType($type);
$relation->setTargetId($node->getAttribute("target"));
-
+
$dir = mbRelation::DIR_BOTH;
switch( strtolower($node->getAttribute("direction")) ) {
case "forward":
@@ -340,7 +340,7 @@
return $relation;
}
-
+
function parse( $data ) {
$nodes = $this->xml_parser->parse( $data );
@@ -349,7 +349,7 @@
$md = new mbMetadata();
-
+
for ( $i = 0; $i < $nodes->nChildNodes(); $i++ ) {
$node = $nodes->getChildNode($i);
$name = strtolower($node->getName());
diff --git a/modules/php_musicbrainz/xml/xmlParser.php b/modules/php_musicbrainz/xml/xmlParser.php
index 1d0058da..7e3311cf 100644
--- a/modules/php_musicbrainz/xml/xmlParser.php
+++ b/modules/php_musicbrainz/xml/xmlParser.php
@@ -15,7 +15,7 @@
function getParentNode() {
return $this->parentNode;
}
-
+
function nChildNodes() {
return sizeof($this->childNodes);
}
@@ -46,7 +46,7 @@
return $this->attributes['TEXT'];
}
}
-
+
class xmlParser {
private $_parser;
private $_root_node = null;
@@ -69,7 +69,7 @@
public function lastError() {
return $this->_last_error;
}
-
+
public function parse( $data ) {
if ( !xml_parse( $this->_parser, $data ) ) {
$this->_last_error = xml_get_current_line_number($this->_parser) . ": ". xml_error_string($this->_parser);
@@ -77,7 +77,7 @@
}
return $this->_root_node;
}
-
+
private function start_element_handler( $parser, $name, $attribs ) {
if ( !$this->_root_node ) {
$new_node = new XMLNode( $name, $attribs );
@@ -90,14 +90,14 @@
$old_node->setChildNode( $new_node );
$this->_curr_node = $new_node;
}
-
+
}
private function text_handler( $parser, $text ) {
if ( $this->_curr_node )
$this->_curr_node->setText( $text );
}
-
+
private function end_element_handler( $parser, $name ) {
if ( $this->_root_node ) {
$this->_curr_node = $this->_curr_node->getParentNode();
diff --git a/modules/plugins/Lastfm.plugin.php b/modules/plugins/Lastfm.plugin.php
index 99ac5fd7..24f9862f 100644
--- a/modules/plugins/Lastfm.plugin.php
+++ b/modules/plugins/Lastfm.plugin.php
@@ -20,31 +20,31 @@
*/
-class AmpacheLastfm {
+class AmpacheLastfm {
- public $name ='Last.FM';
- public $description ='Records your played songs to your Last.FM Account';
+ public $name ='Last.FM';
+ public $description ='Records your played songs to your Last.FM Account';
public $url ='';
public $version ='000003';
public $min_ampache ='340007';
public $max_ampache ='340008';
- // These are internal settings used by this class, run this->load to
+ // These are internal settings used by this class, run this->load to
// fill em out
- private $username;
- private $password;
+ private $username;
+ private $password;
private $hostname;
- private $port;
- private $path;
+ private $port;
+ private $path;
private $challenge;
/**
* Constructor
* This function does nothing...
*/
- public function __construct() {
+ public function __construct() {
- return true;
+ return true;
} // PluginLastfm
@@ -53,19 +53,19 @@ class AmpacheLastfm {
* This is a required plugin function it inserts the required preferences
* into Ampache
*/
- public function install() {
+ public function install() {
// Check and see if it's already installed (they've just hit refresh, those dorks)
- if (Preference::exists('lastfm_user')) { return false; }
+ if (Preference::exists('lastfm_user')) { return false; }
- Preference::insert('lastfm_user','Last.FM Username','','25','string','plugins');
- Preference::insert('lastfm_pass','Last.FM Password','','25','string','plugins');
- Preference::insert('lastfm_port','Last.FM Submit Port','','25','string','internal');
- Preference::insert('lastfm_host','Last.FM Submit Host','','25','string','internal');
- Preference::insert('lastfm_url','Last.FM Submit URL','','25','string','internal');
- Preference::insert('lastfm_challenge','Last.FM Submit Challenge','','25','string','internal');
+ Preference::insert('lastfm_user','Last.FM Username','','25','string','plugins');
+ Preference::insert('lastfm_pass','Last.FM Password','','25','string','plugins');
+ Preference::insert('lastfm_port','Last.FM Submit Port','','25','string','internal');
+ Preference::insert('lastfm_host','Last.FM Submit Host','','25','string','internal');
+ Preference::insert('lastfm_url','Last.FM Submit URL','','25','string','internal');
+ Preference::insert('lastfm_challenge','Last.FM Submit Challenge','','25','string','internal');
- return true;
+ return true;
} // install
@@ -74,14 +74,14 @@ class AmpacheLastfm {
* This is a required plugin function it removes the required preferences from
* the database returning it to its origional form
*/
- public function uninstall() {
+ public function uninstall() {
- Preference::delete('lastfm_pass');
- Preference::delete('lastfm_user');
- Preference::delete('lastfm_url');
- Preference::delete('lastfm_host');
- Preference::delete('lastfm_port');
- Preference::delete('lastfm_challenge');
+ Preference::delete('lastfm_pass');
+ Preference::delete('lastfm_user');
+ Preference::delete('lastfm_url');
+ Preference::delete('lastfm_host');
+ Preference::delete('lastfm_port');
+ Preference::delete('lastfm_challenge');
} // uninstall
@@ -90,76 +90,76 @@ class AmpacheLastfm {
* This takes care of queueing and then submiting the tracks eventually this will make sure
* that you've haven't
*/
- public function submit($song,$user_id) {
+ public function submit($song,$user_id) {
// Before we start let's pull the last song submited by this user
- $previous = Stats::get_last_song($user_id);
+ $previous = Stats::get_last_song($user_id);
+
+ $diff = time() - $previous['date'];
- $diff = time() - $previous['date'];
-
// Make sure it wasn't within the last min
- if ($diff < 60) {
- debug_event('LastFM','Last song played within ' . $diff . ' seconds, not recording stats','3');
- return false;
- }
+ if ($diff < 60) {
+ debug_event('LastFM','Last song played within ' . $diff . ' seconds, not recording stats','3');
+ return false;
+ }
- if ($song->time < 30) {
- debug_event('LastFM','Song less then 30 seconds not queueing','3');
- return false;
- }
+ if ($song->time < 30) {
+ debug_event('LastFM','Song less then 30 seconds not queueing','3');
+ return false;
+ }
// Make sure there's actually a username and password before we keep going
- if (!$this->username || !$this->password) { return false; }
-
+ if (!$this->username || !$this->password) { return false; }
+
// Create our scrobbler with everything this time and then queue it
- $scrobbler = new scrobbler($this->username,$this->password,$this->hostname,$this->port,$this->path,$this->challenge);
+ $scrobbler = new scrobbler($this->username,$this->password,$this->hostname,$this->port,$this->path,$this->challenge);
// Check to see if the scrobbling works
- if (!$scrobbler->queue_track($song->f_artist_full,$song->f_album_full,$song->title,time(),$song->time,$song->track)) {
+ if (!$scrobbler->queue_track($song->f_artist_full,$song->f_album_full,$song->title,time(),$song->time,$song->track)) {
// Depending on the error we might need to do soemthing here
- return false;
- }
-
- // Go ahead and submit it now
- if (!$scrobbler->submit_tracks()) {
- debug_event('LastFM','Error Submit Failed: ' . $scrobbler->error_msg,'3');
- if ($scrobbler->reset_handshake) {
+ return false;
+ }
+
+ // Go ahead and submit it now
+ if (!$scrobbler->submit_tracks()) {
+ debug_event('LastFM','Error Submit Failed: ' . $scrobbler->error_msg,'3');
+ if ($scrobbler->reset_handshake) {
debug_event('LastFM','Re-running Handshake due to error','3');
- $this->set_handshake($user_id);
+ $this->set_handshake($user_id);
// Try try again
- if ($scrobbler->submit_tracks()) {
- return true;
- }
- }
- return false;
+ if ($scrobbler->submit_tracks()) {
+ return true;
+ }
+ }
+ return false;
}
- debug_event('LastFM','Submission Successful','5');
-
- return true;
+ debug_event('LastFM','Submission Successful','5');
+
+ return true;
} // submit
- /**
+ /**
* set_handshake
* This runs a handshake and properly updates the preferences as needed, it returns the data
- * as an array so we don't have to requery the db. This requires a userid so it knows who's
+ * as an array so we don't have to requery the db. This requires a userid so it knows who's
* crap to update
*/
- public function set_handshake($user_id) {
-
- $scrobbler = new scrobbler($this->username,$this->password);
- $data = $scrobbler->handshake();
+ public function set_handshake($user_id) {
+
+ $scrobbler = new scrobbler($this->username,$this->password);
+ $data = $scrobbler->handshake();
- if (!$data) {
- debug_event('LastFM','Handshake Failed: ' . $scrobbler->error_msg,'3');
- return false;
- }
+ if (!$data) {
+ debug_event('LastFM','Handshake Failed: ' . $scrobbler->error_msg,'3');
+ return false;
+ }
- $this->hostname = $data['submit_host'];
- $this->port = $data['submit_port'];
- $this->path = $data['submit_url'];
- $this->challenge = $data['challenge'];
+ $this->hostname = $data['submit_host'];
+ $this->port = $data['submit_port'];
+ $this->path = $data['submit_url'];
+ $this->challenge = $data['challenge'];
// Update the preferences
Preference::update('lastfm_port',$user_id,$data['submit_port']);
@@ -167,7 +167,7 @@ class AmpacheLastfm {
Preference::update('lastfm_url',$user_id,$data['submit_url']);
Preference::update('lastfm_challenge',$user_id,$data['challenge']);
- return true;
+ return true;
} // set_handshake
@@ -176,40 +176,40 @@ class AmpacheLastfm {
* This loads up the data we need into this object, this stuff comes from the preferences
* it's passed as a key'd array
*/
- public function load($data,$user_id) {
-
- if (strlen(trim($data['lastfm_user']))) {
- $this->username = trim($data['lastfm_user']);
- }
- else {
- debug_event('LastFM','No Username, not scrobbling','3');
- return false;
- }
- if (strlen(trim($data['lastfm_pass']))) {
- $this->password = trim($data['lastfm_pass']);
- }
- else {
- debug_event('LastFM','No Password, not scrobbling','3');
- return false;
- }
+ public function load($data,$user_id) {
+
+ if (strlen(trim($data['lastfm_user']))) {
+ $this->username = trim($data['lastfm_user']);
+ }
+ else {
+ debug_event('LastFM','No Username, not scrobbling','3');
+ return false;
+ }
+ if (strlen(trim($data['lastfm_pass']))) {
+ $this->password = trim($data['lastfm_pass']);
+ }
+ else {
+ debug_event('LastFM','No Password, not scrobbling','3');
+ return false;
+ }
// If we don't have the other stuff try to get it before giving up
- if (!$data['lastfm_host'] || !$data['lastfm_port'] || !$data['lastfm_url'] || !$data['lastfm_challenge']) {
- debug_event('LastFM','Running Handshake, missing information','3');
- if (!$this->set_handshake($user_id)) {
+ if (!$data['lastfm_host'] || !$data['lastfm_port'] || !$data['lastfm_url'] || !$data['lastfm_challenge']) {
+ debug_event('LastFM','Running Handshake, missing information','3');
+ if (!$this->set_handshake($user_id)) {
debug_event('LastFM','Handshake failed, you lose','3');
- return false;
- }
- }
- else {
+ return false;
+ }
+ }
+ else {
$this->hostname = $data['lastfm_host'];
$this->port = $data['lastfm_port'];
$this->path = $data['lastfm_url'];
$this->challenge = $data['lastfm_challenge'];
- }
-
+ }
+
- return true;
+ return true;
} // load
diff --git a/modules/plugins/Librefm.plugin.php b/modules/plugins/Librefm.plugin.php
index 9b22b183..36d72603 100644
--- a/modules/plugins/Librefm.plugin.php
+++ b/modules/plugins/Librefm.plugin.php
@@ -20,31 +20,31 @@
*/
-class Ampachelibrefm {
+class Ampachelibrefm {
- public $name ='Libre.FM';
- public $description ='Records your played songs to your Libre.FM Account';
+ public $name ='Libre.FM';
+ public $description ='Records your played songs to your Libre.FM Account';
public $url ='';
public $version ='000001';
public $min_ampache ='350001';
public $max_ampache ='360008';
- // These are internal settings used by this class, run this->load to
+ // These are internal settings used by this class, run this->load to
// fill em out
- private $username;
- private $password;
+ private $username;
+ private $password;
private $hostname;
- private $port;
- private $path;
+ private $port;
+ private $path;
private $challenge;
/**
* Constructor
* This function does nothing...
*/
- public function __construct() {
+ public function __construct() {
- return true;
+ return true;
} // Pluginlibrefm
@@ -53,19 +53,19 @@ class Ampachelibrefm {
* This is a required plugin function it inserts the required preferences
* into Ampache
*/
- public function install() {
+ public function install() {
// Check and see if it's already installed (they've just hit refresh, those dorks)
- if (Preference::exists('librefm_user')) { return false; }
+ if (Preference::exists('librefm_user')) { return false; }
- Preference::insert('librefm_user','Libre.FM Username','','25','string','plugins');
- Preference::insert('librefm_pass','Libre.FM Password','','25','string','plugins');
- Preference::insert('librefm_port','Libre.FM Submit Port','','25','string','internal');
- Preference::insert('librefm_host','Libre.FM Submit Host','','25','string','internal');
- Preference::insert('librefm_url','Libre.FM Submit URL','','25','string','internal');
- Preference::insert('librefm_challenge','Libre.FM Submit Challenge','','25','string','internal');
+ Preference::insert('librefm_user','Libre.FM Username','','25','string','plugins');
+ Preference::insert('librefm_pass','Libre.FM Password','','25','string','plugins');
+ Preference::insert('librefm_port','Libre.FM Submit Port','','25','string','internal');
+ Preference::insert('librefm_host','Libre.FM Submit Host','','25','string','internal');
+ Preference::insert('librefm_url','Libre.FM Submit URL','','25','string','internal');
+ Preference::insert('librefm_challenge','Libre.FM Submit Challenge','','25','string','internal');
- return true;
+ return true;
} // install
@@ -74,14 +74,14 @@ class Ampachelibrefm {
* This is a required plugin function it removes the required preferences from
* the database returning it to its origional form
*/
- public function uninstall() {
+ public function uninstall() {
- Preference::delete('librefm_pass');
- Preference::delete('librefm_user');
- Preference::delete('librefm_url');
- Preference::delete('librefm_host');
- Preference::delete('librefm_port');
- Preference::delete('librefm_challenge');
+ Preference::delete('librefm_pass');
+ Preference::delete('librefm_user');
+ Preference::delete('librefm_url');
+ Preference::delete('librefm_host');
+ Preference::delete('librefm_port');
+ Preference::delete('librefm_challenge');
} // uninstall
@@ -90,76 +90,76 @@ class Ampachelibrefm {
* This takes care of queueing and then submiting the tracks eventually this will make sure
* that you've haven't
*/
- public function submit($song,$user_id) {
+ public function submit($song,$user_id) {
// Before we start let's pull the last song submited by this user
- $previous = Stats::get_last_song($user_id);
+ $previous = Stats::get_last_song($user_id);
+
+ $diff = time() - $previous['date'];
- $diff = time() - $previous['date'];
-
// Make sure it wasn't within the last min
- if ($diff < 60) {
- debug_event('librefm','Last song played within ' . $diff . ' seconds, not recording stats','3');
- return false;
- }
+ if ($diff < 60) {
+ debug_event('librefm','Last song played within ' . $diff . ' seconds, not recording stats','3');
+ return false;
+ }
- if ($song->time < 30) {
- debug_event('librefm','Song less then 30 seconds not queueing','3');
- return false;
- }
+ if ($song->time < 30) {
+ debug_event('librefm','Song less then 30 seconds not queueing','3');
+ return false;
+ }
// Make sure there's actually a username and password before we keep going
- if (!$this->username || !$this->password) { return false; }
-
+ if (!$this->username || !$this->password) { return false; }
+
// Create our scrobbler with everything this time and then queue it
- $scrobbler = new scrobbler($this->username,$this->password,$this->hostname,$this->port,$this->path,$this->challenge,'turtle.libre.fm');
+ $scrobbler = new scrobbler($this->username,$this->password,$this->hostname,$this->port,$this->path,$this->challenge,'turtle.libre.fm');
// Check to see if the scrobbling works
- if (!$scrobbler->queue_track($song->f_artist_full,$song->f_album_full,$song->title,time(),$song->time,$song->track)) {
+ if (!$scrobbler->queue_track($song->f_artist_full,$song->f_album_full,$song->title,time(),$song->time,$song->track)) {
// Depending on the error we might need to do soemthing here
- return false;
- }
-
- // Go ahead and submit it now
- if (!$scrobbler->submit_tracks()) {
- debug_event('librefm','Error Submit Failed: ' . $scrobbler->error_msg,'3');
- if ($scrobbler->reset_handshake) {
+ return false;
+ }
+
+ // Go ahead and submit it now
+ if (!$scrobbler->submit_tracks()) {
+ debug_event('librefm','Error Submit Failed: ' . $scrobbler->error_msg,'3');
+ if ($scrobbler->reset_handshake) {
debug_event('librefm','Re-running Handshake due to error','3');
- $this->set_handshake($user_id);
+ $this->set_handshake($user_id);
// Try try again
- if ($scrobbler->submit_tracks()) {
- return true;
- }
- }
- return false;
+ if ($scrobbler->submit_tracks()) {
+ return true;
+ }
+ }
+ return false;
}
- debug_event('librefm','Submission Successful','5');
-
- return true;
+ debug_event('librefm','Submission Successful','5');
+
+ return true;
} // submit
- /**
+ /**
* set_handshake
* This runs a handshake and properly updates the preferences as needed, it returns the data
- * as an array so we don't have to requery the db. This requires a userid so it knows who's
+ * as an array so we don't have to requery the db. This requires a userid so it knows who's
* crap to update
*/
- public function set_handshake($user_id) {
-
- $scrobbler = new scrobbler($this->username,$this->password,'','','','','turtle.libre.fm');
- $data = $scrobbler->handshake();
+ public function set_handshake($user_id) {
+
+ $scrobbler = new scrobbler($this->username,$this->password,'','','','','turtle.libre.fm');
+ $data = $scrobbler->handshake();
- if (!$data) {
- debug_event('librefm','Handshake Failed: ' . $scrobbler->error_msg,'3');
- return false;
- }
+ if (!$data) {
+ debug_event('librefm','Handshake Failed: ' . $scrobbler->error_msg,'3');
+ return false;
+ }
- $this->hostname = $data['submit_host'];
- $this->port = $data['submit_port'];
- $this->path = $data['submit_url'];
- $this->challenge = $data['challenge'];
+ $this->hostname = $data['submit_host'];
+ $this->port = $data['submit_port'];
+ $this->path = $data['submit_url'];
+ $this->challenge = $data['challenge'];
// Update the preferences
Preference::update('librefm_port',$user_id,$data['submit_port']);
@@ -167,7 +167,7 @@ class Ampachelibrefm {
Preference::update('librefm_url',$user_id,$data['submit_url']);
Preference::update('librefm_challenge',$user_id,$data['challenge']);
- return true;
+ return true;
} // set_handshake
@@ -176,40 +176,40 @@ class Ampachelibrefm {
* This loads up the data we need into this object, this stuff comes from the preferences
* it's passed as a key'd array
*/
- public function load($data,$user_id) {
-
- if (strlen(trim($data['librefm_user']))) {
- $this->username = trim($data['librefm_user']);
- }
- else {
- debug_event('librefm','No Username, not scrobbling','3');
- return false;
- }
- if (strlen(trim($data['librefm_pass']))) {
- $this->password = trim($data['librefm_pass']);
- }
- else {
- debug_event('librefm','No Password, not scrobbling','3');
- return false;
- }
+ public function load($data,$user_id) {
+
+ if (strlen(trim($data['librefm_user']))) {
+ $this->username = trim($data['librefm_user']);
+ }
+ else {
+ debug_event('librefm','No Username, not scrobbling','3');
+ return false;
+ }
+ if (strlen(trim($data['librefm_pass']))) {
+ $this->password = trim($data['librefm_pass']);
+ }
+ else {
+ debug_event('librefm','No Password, not scrobbling','3');
+ return false;
+ }
// If we don't have the other stuff try to get it before giving up
- if (!$data['librefm_host'] || !$data['librefm_port'] || !$data['librefm_url'] || !$data['librefm_challenge']) {
- debug_event('librefm','Running Handshake, missing information','3');
- if (!$this->set_handshake($user_id)) {
+ if (!$data['librefm_host'] || !$data['librefm_port'] || !$data['librefm_url'] || !$data['librefm_challenge']) {
+ debug_event('librefm','Running Handshake, missing information','3');
+ if (!$this->set_handshake($user_id)) {
debug_event('librefm','Handshake failed, you lose','3');
- return false;
- }
- }
- else {
+ return false;
+ }
+ }
+ else {
$this->hostname = $data['librefm_host'];
$this->port = $data['librefm_port'];
$this->path = $data['librefm_url'];
$this->challenge = $data['librefm_challenge'];
- }
-
+ }
+
- return true;
+ return true;
} // load
diff --git a/modules/validatemail/validateEmail.php b/modules/validatemail/validateEmail.php
index 3fc83026..78bbf5f6 100644
--- a/modules/validatemail/validateEmail.php
+++ b/modules/validatemail/validateEmail.php
@@ -26,7 +26,7 @@ Organization: webdev.berber.co.il
Date: April 10th, 1999
Changes: - The script now handles all kinds of domains (not only @xxx.yyy) as before.
- Added a debugging mode which also works as a verbose mode.
-
+
By: Frank Vogel vogel@simec.com
Organization: Simec Corp. (http://www.simec.com)
Date: June 13th, 2000
@@ -65,10 +65,10 @@ Organization: KillerSoft < http://www.killersoft.com/ >
with EHLO.
- Added routines to listen for multi-line output from servers.
- Fixed all commands ending in "\n" to end in "\r\n" as specified by accurate SMTP
- communication. THIS FIXES THE "HANG" PROBLEM EXPERIENCED WITH MANY MAIL SERVERS,
+ communication. THIS FIXES THE "HANG" PROBLEM EXPERIENCED WITH MANY MAIL SERVERS,
INCLUDING AOL.COM. (See Disclaimers about AOL.com connections, though ...)
- Added support for Jeffrey E.F. Friedl's definitive email format regex, translated
- from perl into PHP. Will reject email addresses with invalid formatting before
+ from perl into PHP. Will reject email addresses with invalid formatting before
opening any server connections.
- Changed initial "listening" routine to listen for one of two SMTP greeting responses
(220 or 421) instead of just listening for anything. validateEmail is now well-behaved
@@ -80,7 +80,7 @@ Organization: KillerSoft < http://www.killersoft.com/ >
- Modified comments where Shane Gibson's were no longer needed or accurate (due to changes).
Added the comments for features that didn't exist in Shane's version.
- Incremented version number.
-
+
Disclaimers: - All additions and modifications Copyright 2002 KillerSoft.com.
- Program is free for any use as long as these notes & credits remain intact.
- Yes, I know there is no foolproof way to validate an e-mail address. But this is better than
@@ -100,7 +100,7 @@ Organization: KillerSoft < http://www.killersoft.com/ >
through alternate means. So -- this script won't help you in validating AOL.com (and affiliated)
e-mail addresses. BUT ... at least it won't choke/hang on them either, as previous versions
of this script would.
-
+
- Please send bugs, comments or suggestions to info@killersoft.com!
*/
@@ -144,7 +144,7 @@ function validateEmail ( $email, $verbose=0 ) {
global $SERVER_NAME;
// DEFINE PREFERENCES
-
+
// Passed along with the HELO/EHLO statement.
// Leave blank to use $SERVER_NAME.
// Note that most modern MTAs will ignore (but require) whatever you say here ...
@@ -161,30 +161,30 @@ function validateEmail ( $email, $verbose=0 ) {
if (Config::get('mail_domain')) {
$serverName = Config::get('mail_domain');
- }
+ }
else {
$serverName = "domain.tld";
}
// MAIL FROM -- who's asking?
// Good values: nobody, postmaster, info, buckwheat, gumby
$from = "info";
-
+
// fsockopen() timeout - in seconds
$socketTimeout = 15;
-
+
// waitTimeout - how long we'll wait for a server to respond after
// a successful connection. In seconds.
// Recommended to keep this above 35 seconds - some servers are really slow.
$waitTimeout = 50;
-
+
// MX Server cutoff
// Some hosts (like hotmail.com) have MANY MX hosts -- 12 or more.
// Set this to a number where you'd like to say "I get the picture"
// ... so you don't wind up having to hit EVERY MX host.
$mxcutoff = 15;
-
+
// END OF PREFERENCES
-
+
///////////////////////////////////////////////////////////////////////////////
// DO NOT EDIT BELOW THIS LINE
///////////////////////////////////////////////////////////////////////////////
@@ -195,16 +195,16 @@ function validateEmail ( $email, $verbose=0 ) {
// Let's give good commands
$CRLF = "\r\n";
-
+
// Make a few adjustments for verbose mode
if ( $verbose ) {
// Version
$version = "validateEmail 2.0 - http://killersoft.com/contrib/";
-
+
// Start stopwatch
list ( $msecStart, $secStart ) = explode ( " ", microtime() );
-
+
// Adjust verbose output format
// for php.cgi or webserver interface
$sapi_type = php_sapi_name();
@@ -231,29 +231,29 @@ function validateEmail ( $email, $verbose=0 ) {
eval("echo \"Internal: $version - running as ".AddSlashes($sapi_type)."\"; $vNL");
}
}
-
+
// How we'll identify ourselves in SMTP HELO/EHLO argument
if ( $serverName == "" ) $serverName = "$SERVER_NAME";
if ( $serverName == "" ) $serverName = "localhost";
-
+
// Initialize return values with default
$return[0] = false;
$return[1] = "Invalid email address (bad domain name)";
$return[2] = false;
$return[3] = "";
-
+
// make sure that we're dealing with a valid email address format
$isValid = true; // just in case validateEmailFormat is not available
if ( function_exists('validateEmailFormat') ) $isValid = validateEmailFormat ( $email );
-
+
// abort if necessary
if ( !$isValid ) {
if ( $verbose ) eval("echo \"Internal: $email format is invalid! Quitting ...\"; $vNL");
return $return;
-
+
} else {
if ( $verbose ) eval("echo \"Internal: $email is a valid RFC 822 formatted address\"; $vNL");
-
+
// assign our user part and domain parts respectively to seperate
// variables
list ( $user, $domain ) = explode ( "@", $email );
@@ -261,20 +261,20 @@ function validateEmail ( $email, $verbose=0 ) {
eval("echo \"Internal: user ..... $user\"; $vNL");
eval("echo \"Internal: domain ... $domain\"; $vNL");
}
-
+
// split up the domain into sub-parts
$arr = explode ( ".", $domain );
-
+
// figure out how many parts there are in the host/domain name portion
$count = count ( $arr );
-
+
// flag to indicate success
$bSuccess = false;
-
+
// we try this for each qualification step of domain name
// (from full qualified to TopLevel)
for ( $i = 0; $i < $count - 1 && !$bSuccess; $i = $i + 1 ) {
-
+
// create the domain name
$domain = "";
for ( $j = $i; $j < $count; $j = $j + 1 ) {
@@ -284,20 +284,20 @@ function validateEmail ( $email, $verbose=0 ) {
$domain = $domain . ".";
}
if ( $verbose ) eval("echo \"Internal: checking DNS for $domain ... \"; $vNL");
-
+
// Strict Mail Check
if($mail_check == "strict") {
// check that an MX record exists for Top-Level domain
// If it exists, start our email address checking
- if (function_exists('checkdnsrr')) {
+ if (function_exists('checkdnsrr')) {
if ( checkdnsrr ( $domain, "MX" ) ) {
-
+
// Okay -- we've got a valid DNS reverse record.
if ( $verbose ) eval("echo \"Internal: ... Check DNS RR OK!\"; $vNL");
// Test that MX record for host exists,
// then fill 'mxhosts' and 'weight' arrays with correct info
if ( getmxrr ( $domain, $mxhosts, $weight ) ) {
-
+
// Now we've got MX records
if ( $verbose ) {
eval("echo \"Internal: MX LOOKUP RESULTS:\"; $vNL");
@@ -311,18 +311,18 @@ function validateEmail ( $email, $verbose=0 ) {
// determine our MX host cutoff
$mxstop = ($mxcount > $mxcutoff) ? $mxcutoff : $mxcount;
for ( $i = 0; $i < $mxstop ; $i++ ) {
-
+
// open socket on port 25 to mxhost, setting
// returned socket pointer to $sp
if( $verbose ) eval("echo \"Internal: attempting to open $mxhosts[$i] ...\"; $vNL");
$sp = fsockopen ( $mxhosts[$i], 25, $errno, $errstr, $socketTimeout);
-
+
// Greeting Code default
// Sets default greeting code to 421, just in case we
// don't ever hear ANYTHING from this host.
// If we hear nothing, we'll want to skip it.
$greetCode = "421";
-
+
// if $sp connection is good, let's rock on
if ( $sp ) {
if ( $verbose ) {
@@ -334,17 +334,17 @@ function validateEmail ( $email, $verbose=0 ) {
$msec = 0; // milisec count
$tsec = 0; // tensec count
$out = "";
-
+
// set our created socket for $sp to
// non-blocking mode so that our fgets()
// calls will return with a quickness
set_socket_blocking ( $sp, false );
-
+
// as long as our 'out' variable does not begin
// with a valid SMTP greeting (220 or 421),
// keep looping (do) until we get something
do {
-
+
// prepare for clean debug output if necessary
// (puts a line break after the waitMarkers)
if ( $verbose && $msec > 0 ) {
@@ -354,7 +354,7 @@ function validateEmail ( $email, $verbose=0 ) {
// output of the stream assigned to
// 'out' variable
$out = fgets ( $sp, 2500 );
-
+
// Check for multi-line output (###-)
if ( preg_match ( "/^2..-/", $out ) ) {
$end = false;
@@ -369,9 +369,9 @@ function validateEmail ( $email, $verbose=0 ) {
}
}
}
-
+
if ( $verbose && $out != "" ) eval("$clean echo \"Server: ".AddSlashes($out)."\"; $vNL");
-
+
// if we get a "220" code (service ready),
// we're ready to rock on
if ( substr ( $out, 0, 3 ) == "220" ) {
@@ -384,25 +384,25 @@ function validateEmail ( $email, $verbose=0 ) {
} else {
$send = "HELO";
}
-
+
// Set Greeting Code
$greetCode = "220";
-
+
}
-
+
// else if ...
// Perhaps we've gotten a 421 Temporarily Refused error
else if ( substr ( $out, 0, 3 ) == "421" ) {
-
+
//if ( $verbose ) echo " ... moving on\n";
if ( $verbose ) eval("echo \"Internal: $mxhosts[$i] temporarily rejected connection. (421 response)\"; $vNL");
$return[2] = false;
// Set Greeting Code
$greetCode = "421";
break; // get out of this loop
-
+
}
-
+
// increase our waitTimeout counters
// if we still haven't heard anything ...
// Note that the time looping isn't an exact science
@@ -426,34 +426,34 @@ function validateEmail ( $email, $verbose=0 ) {
}
$msec = $msec + 0.25;
usleep(250000);
-
+
} elseif ( $msec == $waitTimeout ) {
-
+
// let's get out of here. Toooo sloooooww ...
if ( $verbose ) eval("$clean echo \"Internal: !! we've waited $waitTimeout seconds !!\nbreaking ...\"; $vNL");
break;
}
-
-
+
+
// end of 'do' loop
} while ( substr ( $out, 0, 3 ) != "220" );
-
+
// Make sure we got a "220" greetCode
// before we start shoveling requests
// at this server.
if ( $greetCode == "220" ) {
-
+
// reset our file pointer to blocking mode,
// so we can wait for communication to finish
// before moving on ...
set_socket_blocking ( $sp, true );
-
+
// talk to the MX mail server, attempt to validate
// ourself. Use "HELO" or "EHLO", as determined above
fputs ( $sp, "$send $serverName"."$CRLF" );
if ( $verbose ) eval("echo \"Client: $send $serverName\"; $vNL");
-
+
// get the mail server's reply, check it
//
$originalOutput = fgets ( $sp, 2500 );
@@ -472,12 +472,12 @@ function validateEmail ( $email, $verbose=0 ) {
}
}
if ( $verbose ) eval("echo \"Server: ".AddSlashes($originalOutput)."\"; $vNL");
-
-
+
+
// if there's a HELP option, let's see it
if ( $verbose ) {
if( preg_match( "/250.HELP/m", $originalOutput ) && $verbose == true ) {
-
+
eval("echo \"Internal: VERBOSE-MODE ONLY: Getting the HELP output\"; $vNL");
// Get the output of the HELP command
fputs ( $sp, "HELP"."$CRLF" );
@@ -499,14 +499,14 @@ function validateEmail ( $email, $verbose=0 ) {
}
}
if ( $verbose ) eval("echo \"Server: ".AddSlashes($output)."\"; $vNL");
-
+
}
}
-
+
// Give the MAIL FROM: header to the server
fputs ( $sp, "MAIL FROM: <$from" . "@" . "$serverName" . ">"."$CRLF");
if ( $verbose ) eval("echo \"Client: MAIL FROM: $leftCarrot"."$from" . "@" . "$serverName" . "$rightCarrot\"; $vNL");
-
+
// Get output again
$output = fgets ( $sp, 2500 );
// Check for multi-line positive output
@@ -524,11 +524,11 @@ function validateEmail ( $email, $verbose=0 ) {
}
}
if ( $verbose ) eval("echo \"Server: ".AddSlashes($output)."\"; $vNL");
-
+
// Give the RCPT TO: header for the email address we're testing
fputs ( $sp, "RCPT TO: <$email>"."$CRLF" );
if ( $verbose ) eval("echo \"Client: RCPT TO: $leftCarrot"."$email"."$rightCarrot\"; $vNL");
-
+
// Get output again
// This will be the one we check for validity
$output = fgets ( $sp, 2500 );
@@ -547,19 +547,19 @@ function validateEmail ( $email, $verbose=0 ) {
}
}
if ( $verbose ) eval("echo \"Server: ".AddSlashes($output)."\"; $vNL");
-
+
// test the last reply code from the mail server
// for the 250 (okay) response
if ( substr ( $output, 0, 3 ) == "250" ) {
-
+
// set our true/false(ness)
// array item for testing
$return[0] = true;
$return[1] = $output;
if ( $verbose ) eval("echo \"Internal: Check for 250 ... Recipient OK\"; $vNL");
-
+
} else {
-
+
// we didn't get a 250
// may be a bogus address
if ( $verbose ) eval("echo \"Internal: Check for 250 ... Response did not begin with 250!\"; $vNL");
@@ -567,19 +567,19 @@ function validateEmail ( $email, $verbose=0 ) {
// reply for user to test if they want
$return[0] = false;
$return[1] = $output;
-
+
}
-
+
// tell the mail server we're done
fputs ( $sp, "QUIT"."$CRLF" );
if ( $verbose ) {
eval("echo \"Client: QUIT\"; $vNL");
- eval("echo \"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\"; $vNL $vNL");
+ eval("echo \"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\"; $vNL $vNL");
}
-
+
// close the socket/file pointer
fclose ( $sp );
-
+
// If we got a good response back on RCPT TO,
// break here
// Otherwise, keep trying MX servers until we
@@ -588,36 +588,36 @@ function validateEmail ( $email, $verbose=0 ) {
if ( $return[0] == true ) {
if ( $verbose ) {
eval("echo \"Internal: Recipient is OK - thanks, $mxhosts[$i]!\"; $vNL");
- eval("echo \"Internal: Stop checking MX hosts ...\"; $vNL");
+ eval("echo \"Internal: Stop checking MX hosts ...\"; $vNL");
}
$bSuccess = true;
break;
}
-
+
} else {
-
+
// greetCode wasn't "220"
// we better skip this one and move on
if ( $verbose ) eval("echo \"Internal: SKIPPING $mxhosts[$i] -- never got 220 welcome\"; $vNL");
// close out this connection
fclose ( $sp );
-
+
} // end of greetCode check
-
+
} else {
// $sp socket pointer was false -- couldn't open it
if ( $verbose ) {
- eval("echo \"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\"; $vNL");
+ eval("echo \"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\"; $vNL");
eval("echo \"Internal: could not open socket to $mxhosts[$i]!\"; $vNL");
eval("echo \"fsockopen error $errno: $errstr\"; $vNL");
- eval("echo \"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\"; $vNL $vNL");
+ eval("echo \"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\"; $vNL $vNL");
}
$return[0] = false;
$return[1] = "fsockopen error $errno: $errstr";
} // end of $sp check
-
+
} // end for $mxhosts
-
+
} // getmxrr test
else {
// getmxrr failed
@@ -625,7 +625,7 @@ function validateEmail ( $email, $verbose=0 ) {
$return[0] = false;
$return[1] = "554 No MX records found for $domain";
} // end getmxrr test
-
+
} // continue checkdnsrr test
else {
if ( $verbose ) eval("echo \"Internal: No DNS Reverse Record available!\"; $vNL");
@@ -649,9 +649,9 @@ function validateEmail ( $email, $verbose=0 ) {
}
} // end walking through each domain possibility
-
+
} // end isValid
-
+
// output elapsed time if Verbose
if ( $verbose ) {
list ( $msecStop, $secStop ) = explode ( " ", microtime() );
@@ -660,7 +660,7 @@ function validateEmail ( $email, $verbose=0 ) {
eval("echo \"Internal: VERBOSE-MODE execution time: $elapsedTime seconds (silent mode somewhat faster)\"; $vNL");
if ( $sapi_type != "cgi" ) echo "</pre>";
}
-
+
// return the array for the user to test against
return $return;
diff --git a/modules/validatemail/validateEmailFormat.php b/modules/validatemail/validateEmailFormat.php
index 94fde197..14ff9cff 100644
--- a/modules/validatemail/validateEmailFormat.php
+++ b/modules/validatemail/validateEmailFormat.php
@@ -87,7 +87,7 @@ function validateEmailFormat ( $email ) {
// Impossible to do properly with a regex, I make do by allowing at most
// one level of nesting.
$ctext = " [^$esc$NonASCII$CRlist()] ";
-
+
// $Cnested matches one non-nested comment.
// It is unrolled, with normal of $ctext, special of $quoted_pair.
$Cnested = "";
@@ -95,7 +95,7 @@ function validateEmailFormat ( $email ) {
$Cnested .= "$ctext*"; // normal*
$Cnested .= "(?: $quoted_pair $ctext* )*"; // (special normal*)*
$Cnested .= "$CloseParen"; // )
-
+
// $comment allows one level of nested parentheses
// It is unrolled, with normal of $ctext, special of ($quoted_pair|$Cnested)
$comment = "";
@@ -106,29 +106,29 @@ function validateEmailFormat ( $email ) {
$comment .= "$ctext*"; // normal*
$comment .= ")*"; // )*
$comment .= "$CloseParen"; // )
-
+
// *********************************************
// $X is optional whitespace/comments
$X = "";
$X .= "[$space$tab]*"; // Nab whitespace
$X .= "(?: $comment [$space$tab]* )*"; // If comment found, allow more spaces
-
-
+
+
// Item 10: atom
$atom_char = "[^($space)<>\@,;:\".$esc$OpenBR$CloseBR$ctrl$NonASCII]";
$atom = "";
$atom .= "$atom_char+"; // some number of atom characters ...
$atom .= "(?!$atom_char)"; // ... not followed by something that
// could be part of an atom
-
+
// Item 11: doublequoted string, unrolled.
$quoted_str = "";
$quoted_str .= "\""; // "
$quoted_str .= "$qtext *"; // normal
$quoted_str .= "(?: $quoted_pair $qtext * )*"; // ( special normal* )*
$quoted_str .= "\""; // "
-
-
+
+
// Item 7: word is an atom or quoted string
$word = "";
$word .= "(?:";
@@ -136,10 +136,10 @@ function validateEmailFormat ( $email ) {
$word .= "|"; // or
$word .= "$quoted_str"; // Quoted string
$word .= ")";
-
+
// Item 12: domain-ref is just an atom
$domain_ref = $atom;
-
+
// Item 13: domain-literal is like a quoted string, but [...] instead of "..."
$domain_lit = "";
$domain_lit .= "$OpenBR"; // [
@@ -154,28 +154,28 @@ function validateEmailFormat ( $email ) {
$sub_domain .= "$domain_lit";
$sub_domain .= ")";
$sub_domain .= "$X"; // optional trailing comments
-
+
// Item 6: domain is a list of subdomains separated by dots
$domain = "";
$domain .= "$sub_domain";
$domain .= "(?:";
$domain .= "$Period $X $sub_domain";
$domain .= ")*";
-
+
// Item 8: a route. A bunch of "@ $domain" separated by commas, followed by a colon.
$route = "";
$route .= "\@ $X $domain";
$route .= "(?: , $X \@ $X $domain )*"; // additional domains
$route .= ":";
$route .= "$X"; // optional trailing comments
-
+
// Item 5: local-part is a bunch of $word separated by periods
$local_part = "";
$local_part .= "$word $X";
$local_part .= "(?:";
$local_part .= "$Period $X $word $X"; // additional words
$local_part .= ")*";
-
+
// Item 2: addr-spec is local@domain
$addr_spec = "$local_part \@ $X $domain";
@@ -185,10 +185,10 @@ function validateEmailFormat ( $email ) {
$route_addr .= "(?: $route )?"; // optional route
$route_addr .= "$addr_spec"; // address spec
$route_addr .= ">";
-
+
// Item 3: phrase........
$phrase_ctrl = '\000-\010\012-\037'; // like ctrl, but without tab
-
+
// Like atom-char, but without listing space, and uses phrase_ctrl.
// Since the class is negated, this matches the same as atom-char plus space and tab
$phrase_char = "[^()<>\@,;:\".$esc$OpenBR$CloseBR$NonASCII$phrase_ctrl]";
@@ -214,7 +214,7 @@ function validateEmailFormat ( $email ) {
// test it and return results
$isValid = preg_match("/^$mailbox$/xS",$email);
-
+
return($isValid);
} // END validateEmailFormat
?>
diff --git a/play/index.php b/play/index.php
index 3bc77b96..88e02b84 100644
--- a/play/index.php
+++ b/play/index.php
@@ -3,7 +3,7 @@
/*
Copyright (c) Ampache.org
- All rights reserved.
+ All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
@@ -24,63 +24,63 @@
This is the wrapper for opening music streams from this server. This script
will play the local version or redirect to the remote server if that be
the case. Also this will update local statistics for songs as well.
- This is also where it decides if you need to be downsampled.
+ This is also where it decides if you need to be downsampled.
*/
define('NO_SESSION','1');
require_once '../lib/init.php';
require_once Config::get('prefix') . '/modules/horde/Browser.php';
-ob_end_clean();
+ob_end_clean();
/* These parameters had better come in on the url. */
$uid = scrub_in($_REQUEST['uid']);
-$oid = $_REQUEST['song'] ? scrub_in($_REQUEST['song']) : scrub_in($_REQUEST['oid']);
+$oid = $_REQUEST['song'] ? scrub_in($_REQUEST['song']) : scrub_in($_REQUEST['oid']);
$sid = scrub_in($_REQUEST['ssid']);
-$xml_rpc = scrub_in($_REQUEST['xml_rpc']);
-$video = make_bool($_REQUEST['video']);
+$xml_rpc = scrub_in($_REQUEST['xml_rpc']);
+$video = make_bool($_REQUEST['video']);
/* This is specifically for tmp playlist requests */
$demo_id = scrub_in($_REQUEST['demo_id']);
-$random = scrub_in($_REQUEST['random']);
+$random = scrub_in($_REQUEST['random']);
// Parse byte range request
$n = sscanf($_SERVER['HTTP_RANGE'], "bytes=%d-%d",$start,$end);
/* First things first, if we don't have a uid/oid stop here */
-if (empty($oid) && empty($demo_id) && empty($random)) {
+if (empty($oid) && empty($demo_id) && empty($random)) {
debug_event('Play',"Error: No Object UID Specified, nothing to play",'2');
echo "Error: No Object UID Specified, nothing to play";
- exit;
+ exit;
}
// If we're XML-RPC and it's enabled, use system user
-if (isset($xml_rpc) AND Config::get('xml_rpc') AND !isset($uid)) {
- $uid = '-1';
-}
+if (isset($xml_rpc) AND Config::get('xml_rpc') AND !isset($uid)) {
+ $uid = '-1';
+}
-if (!isset($uid)) {
- debug_event('Play','Error: No User specified','2');
- echo "Error: No User Specified";
+if (!isset($uid)) {
+ debug_event('Play','Error: No User specified','2');
+ echo "Error: No User Specified";
exit;
}
/* Misc Housework */
$GLOBALS['user'] = new User($uid);
-Preference::init();
+Preference::init();
/* If the user has been disabled (true value) */
if (make_bool($GLOBALS['user']->disabled)) {
debug_event('user_disabled',"Error $user->username is currently disabled, stream access denied",'3');
- echo "Error: User Disabled";
- exit;
+ echo "Error: User Disabled";
+ exit;
}
// If require session is set then we need to make sure we're legit
-if (Config::get('require_session')) {
- if (!Config::get('require_localnet_session') AND Access::check_network('network',$GLOBALS['user']->id,'5')) {
+if (Config::get('require_session')) {
+ if (!Config::get('require_localnet_session') AND Access::check_network('network',$GLOBALS['user']->id,'5')) {
// Localnet defined IP and require localnot session has been turned off we let this one through
- debug_event('LocalNet','Streaming Access Granted to Localnet defined IP ' . $_SERVER['REMOTE_ADDR'],'5');
+ debug_event('LocalNet','Streaming Access Granted to Localnet defined IP ' . $_SERVER['REMOTE_ADDR'],'5');
}
- elseif(!Stream::session_exists($sid)) {
+ elseif(!Stream::session_exists($sid)) {
debug_event('session_expired',"Streaming Access Denied: " . $GLOBALS['user']->username . "'s session has expired",'3');
die(_("Session Expired: please log in again at") . " " . Config::get('web_path') . "/login.php");
}
@@ -98,103 +98,103 @@ $GLOBALS['user']->update_last_seen();
if (Config::get('demo_mode') || (!Access::check('interface','25') AND !isset($xml_rpc))) {
debug_event('access_denied',"Streaming Access Denied:" .Config::get('demo_mode') . "is the value of demo_mode. Current user level is " . $GLOBALS['user']->access,'3');
access_denied();
- exit;
+ exit;
}
-/*
- If they are using access lists let's make sure
+/*
+ If they are using access lists let's make sure
that they have enough access to play this mojo
*/
-if (Config::get('access_control')) {
+if (Config::get('access_control')) {
if (!Access::check_network('stream',$GLOBALS['user']->id,'25') AND
- !Access::check_network('network',$GLOBALS['user']->id,'25')) {
+ !Access::check_network('network',$GLOBALS['user']->id,'25')) {
debug_event('access_denied', "Streaming Access Denied: " . $_SERVER['REMOTE_ADDR'] . " does not have stream level access",'3');
access_denied();
- exit;
+ exit;
}
} // access_control is enabled
-/**
+/**
* If we've got a tmp playlist then get the
* current song, and do any other crazyness
- * we need to
+ * we need to
*/
-if ($demo_id) {
+if ($demo_id) {
$democratic = new Democratic($demo_id);
- $democratic->set_parent();
+ $democratic->set_parent();
// If there is a cooldown we need to make sure this song isn't a repeat
- if (!$democratic->cooldown) {
+ if (!$democratic->cooldown) {
/* This takes into account votes etc and removes the */
$oid = $democratic->get_next_object();
- }
- else {
+ }
+ else {
// Pull history
$oid = $democratic->get_next_object($song_cool_check);
- $oids = $democratic->get_cool_songs();
- while (in_array($oid,$oids)) {
- $song_cool_check++;
+ $oids = $democratic->get_cool_songs();
+ while (in_array($oid,$oids)) {
+ $song_cool_check++;
$oid = $democratic->get_next_object($song_cool_check);
- if ($song_cool_check >= '5') { break; }
+ if ($song_cool_check >= '5') { break; }
} // while we've got the 'new' song in old the array
-
- } // end if we've got a cooldown
+
+ } // end if we've got a cooldown
} // if democratic ID passed
/**
* if we are doing random let's pull the random object
*/
-if ($random) {
- if ($start < 1) {
- $oid = Random::get_single_song($_REQUEST['type']);
+if ($random) {
+ if ($start < 1) {
+ $oid = Random::get_single_song($_REQUEST['type']);
// Save this one incase we do a seek
- $_SESSION['random']['last'] = $oid;
- }
- else {
- $oid = $_SESSION['random']['last'];
- }
-} // if random
-
-if (!$video) {
+ $_SESSION['random']['last'] = $oid;
+ }
+ else {
+ $oid = $_SESSION['random']['last'];
+ }
+} // if random
+
+if (!$video) {
/* Base Checks passed create the song object */
$media = new Song($oid);
$media->format();
}
-else {
- $media = new Video($oid);
- $media->format();
-}
+else {
+ $media = new Video($oid);
+ $media->format();
+}
// Build up the catalog for our current object
$catalog = new Catalog($media->catalog);
/* If the song is disabled */
-if (!make_bool($media->enabled)) {
+if (!make_bool($media->enabled)) {
debug_event('Play',"Error: $media->file is currently disabled, song skipped",'5');
exit;
}
// If we are running in Legalize mode, don't play songs already playing
if (Config::get('lock_songs')) {
- if (!Stream::check_lock_media($media->id,get_class($media))) {
- exit;
+ if (!Stream::check_lock_media($media->id,get_class($media))) {
+ exit;
}
}
/* Check to see if this is a 'remote' catalog */
if ($catalog->catalog_type == 'remote') {
- preg_match("/(.+)\/play\/index.+/",$media->file,$match);
+ preg_match("/(.+)\/play\/index.+/",$media->file,$match);
- $token = xmlRpcClient::ampache_handshake($match['1'],$catalog->key);
+ $token = xmlRpcClient::ampache_handshake($match['1'],$catalog->key);
// If we don't get anything back we failed and should bail now
- if (!$token) {
- debug_event('xmlrpc-stream','Error Unable to get Token from ' . $match['1'] . ' check target servers logs','1');
- exit;
- }
+ if (!$token) {
+ debug_event('xmlrpc-stream','Error Unable to get Token from ' . $match['1'] . ' check target servers logs','1');
+ exit;
+ }
- $sid = xmlRpcClient::ampache_create_stream_session($match['1'],$token);
+ $sid = xmlRpcClient::ampache_create_stream_session($match['1'],$token);
$extra_info = "&xml_rpc=1&sid=$sid";
header("Location: " . $media->file . $extra_info);
@@ -213,17 +213,17 @@ if ($catalog->catalog_type == 'remote') {
} // end if remote catalog
/* If we don't have a file, or the file is not readable */
-if (!$media->file OR !is_readable($media->file)) {
+if (!$media->file OR !is_readable($media->file)) {
// We need to make sure this isn't democratic play, if it is then remove the song
// from the vote list
- if (is_object($tmp_playlist)) {
- $tmp_playlist->delete_track($oid);
+ if (is_object($tmp_playlist)) {
+ $tmp_playlist->delete_track($oid);
}
debug_event('Play',"Error song $media->file ($media->title) does not have a valid filename specified",'2');
- echo "Error: Invalid Song Specified, file not found or file unreadable";
- exit;
+ echo "Error: Invalid Song Specified, file not found or file unreadable";
+ exit;
}
// make fread binary safe
@@ -238,48 +238,48 @@ ignore_user_abort(TRUE);
// Format the song name
$media_name = $media->f_artist_full . " - " . $media->title . "." . $media->type;
-/* If they are just trying to download make sure they have rights
+/* If they are just trying to download make sure they have rights
* and then present them with the download file
*/
-if ($_GET['action'] == 'download' AND Config::get('download')) {
-
+if ($_GET['action'] == 'download' AND Config::get('download')) {
+
// STUPID IE
- $media->format_pattern();
+ $media->format_pattern();
$media_name = str_replace(array('?','/','\\'),"_",$media->f_file);
// Use Horde's Browser class to send the headers
- header("Content-Length: " . $media->size);
- $browser = new Browser();
- $browser->downloadHeaders($media_name,$media->mime,false,$media->size);
- $fp = fopen($media->file,'rb');
- $bytesStreamed = 0;
+ header("Content-Length: " . $media->size);
+ $browser = new Browser();
+ $browser->downloadHeaders($media_name,$media->mime,false,$media->size);
+ $fp = fopen($media->file,'rb');
+ $bytesStreamed = 0;
- if (!is_resource($fp)) {
+ if (!is_resource($fp)) {
debug_event('Play',"Error: Unable to open $media->file for downloading",'2');
- exit();
+ exit();
}
-
+
// Check to see if we should be throttling because we can get away with it
- if (Config::get('rate_limit') > 0) {
- while (!feof($fp)) {
- echo fread($fp,round(Config::get('rate_limit')*1024));
- $bytesStreamed += round(Config::get('rate_limit')*1024);
- flush();
- sleep(1);
- }
- }
- else {
- fpassthru($fp);
- }
+ if (Config::get('rate_limit') > 0) {
+ while (!feof($fp)) {
+ echo fread($fp,round(Config::get('rate_limit')*1024));
+ $bytesStreamed += round(Config::get('rate_limit')*1024);
+ flush();
+ sleep(1);
+ }
+ }
+ else {
+ fpassthru($fp);
+ }
// Make sure that a good chunk of the song has been played
if ($bytesStreamed >= $media->size) {
debug_event('Play','Downloaded, Registering stats for ' . $media->title,'5');
$GLOBALS['user']->update_stats($media->id);
} // if enough bytes are streamed
-
- fclose($fp);
- exit();
+
+ fclose($fp);
+ exit();
} // if they are trying to download and they can
@@ -288,41 +288,41 @@ $browser = new Browser();
header("Accept-Ranges: bytes" );
// Prevent the script from timing out
-set_time_limit(0);
+set_time_limit(0);
/* We're about to start record this persons IP */
-if (Config::get('track_user_ip')) {
+if (Config::get('track_user_ip')) {
$GLOBALS['user']->insert_ip_history();
}
// If we've got downsample remote enabled
-if (Config::get('downsample_remote')) {
- if (!Access::check_network('network',$GLOBALS['user']->id,'0')) {
- debug_event('Downsample','Network Downsample ' . $_SERVER['REMOTE_ADDR'] . ' is not in Local definition','5');
+if (Config::get('downsample_remote')) {
+ if (!Access::check_network('network',$GLOBALS['user']->id,'0')) {
+ debug_event('Downsample','Network Downsample ' . $_SERVER['REMOTE_ADDR'] . ' is not in Local definition','5');
$not_local = true;
}
} // if downsample remote is enabled
// If they are downsampling, or if the song is not a native stream or it's non-local
-if ((Config::get('transcode') == 'always' || !$media->native_stream() || $not_local) && Config::get('transcode') != 'never') {
+if ((Config::get('transcode') == 'always' || !$media->native_stream() || $not_local) && Config::get('transcode') != 'never') {
debug_event('Downsample','Starting Downsample {Transcode:' . Config::get('transcode') . '} {Native Stream:' . $media->native_stream() .'} {Not Local:' . $not_local . '}','5');
$fp = Stream::start_downsample($media,$lastid,$media_name,$start);
$media_name = $media->f_artist_full . " - " . $media->title . "." . $media->type;
// Note that this is downsampling
- $downsampled_song = true;
+ $downsampled_song = true;
} // end if downsampling
-else {
+else {
// Send file, possible at a byte offset
$fp = fopen($media->file, 'rb');
-
- if (!is_resource($fp)) {
+
+ if (!is_resource($fp)) {
debug_event('Play',"Error: Unable to open $media->file for reading",'2');
cleanup_and_exit($lastid);
}
} // else not downsampling
-// Put this song in the now_playing table only if it's a song for now...
-if (get_class($media) == 'Song') {
+// Put this song in the now_playing table only if it's a song for now...
+if (get_class($media) == 'Song') {
Stream::insert_now_playing($media->id,$uid,$media->time,$sid,get_class($media));
}
@@ -332,16 +332,16 @@ if ($start > 0) {
if(isset($end)) {
$end = min($end,$media->size-1);
$stream_size = ($end-$start)+1;
- }
+ }
else {
$stream_size = $media->size - $start;
}
-
+
debug_event('Play','Content-Range header recieved, skipping ahead ' . $start . ' bytes out of ' . $media->size,'5');
$browser->downloadHeaders($media_name, $media->mime, false, $media->size);
- if (!$downsampled_song) {
+ if (!$downsampled_song) {
fseek( $fp, $start );
- }
+ }
$range = $start ."-". $end . "/" . $media->size;
header("HTTP/1.1 206 Partial Content");
header("Content-Range: bytes $range");
@@ -350,22 +350,22 @@ if ($start > 0) {
/* Last but not least pump em out */
else {
- debug_event('Play','Starting stream of ' . $media->file . ' with size ' . $media->size,'5');
+ debug_event('Play','Starting stream of ' . $media->file . ' with size ' . $media->size,'5');
header("Content-Length: $media->size");
$browser->downloadHeaders($media_name, $media->mime, false, $media->size);
- $stream_size = $media->size;
+ $stream_size = $media->size;
}
-
-/* Let's force them to actually play a portion of the song before
+
+/* Let's force them to actually play a portion of the song before
* we count it in the statistics
*/
$bytes_streamed = 0;
$min_bytes_streamed = $media->size / 2;
-// Actually do the streaming
+// Actually do the streaming
do {
- $read_size = min(2048,$stream_size-$bytes_streamed);
- if ($read_size < 1) { break; }
+ $read_size = min(2048,$stream_size-$bytes_streamed);
+ if ($read_size < 1) { break; }
$buf = fread($fp, $read_size);
print($buf);
$bytes_streamed += strlen($buf);
@@ -378,16 +378,16 @@ if($bytes_streamed < $stream_size AND (connection_status() == 0)) {
// Make sure that a good chunk of the song has been played
if ($bytes_streamed > $min_bytes_streamed AND get_class($media) == 'Song') {
- debug_event('Play','Registering stats for ' . $media->title,'5');
-
+ debug_event('Play','Registering stats for ' . $media->title,'5');
+
$GLOBALS['user']->update_stats($media->id);
/* Set the Song as Played if it isn't already */
$media->set_played();
} // if enough bytes are streamed
-else {
- debug_event('Play',$bytes_streamed .' of ' . $media->size . ' streamed, less than ' . $min_bytes_streamed . ' not collecting stats','5');
-}
+else {
+ debug_event('Play',$bytes_streamed .' of ' . $media->size . ' streamed, less than ' . $min_bytes_streamed . ' not collecting stats','5');
+}
/* If this is a voting tmp playlist remove the entry, we do this regardless of play amount */
@@ -400,14 +400,14 @@ if ($demo_id) {
} // if tmp_playlist
/* Clean up any open ends */
-if (Config::get('play_type') == 'downsample' || !$media->native_stream()) {
+if (Config::get('play_type') == 'downsample' || !$media->native_stream()) {
@pclose($fp);
-}
-else {
+}
+else {
@fclose($fp);
}
// Note that the stream has ended
-debug_event('Play','Stream Ended at ' . $bytes_streamed . ' bytes out of ' . $media->size,'5');
+debug_event('Play','Stream Ended at ' . $bytes_streamed . ' bytes out of ' . $media->size,'5');
?>
diff --git a/playlist.php b/playlist.php
index bb1ac99e..226c0e35 100644
--- a/playlist.php
+++ b/playlist.php
@@ -27,39 +27,39 @@
require_once 'lib/init.php';
-show_header();
+show_header();
/* Switch on the action passed in */
-switch ($_REQUEST['action']) {
+switch ($_REQUEST['action']) {
case 'add_dyn_song':
/* Check Rights */
- if (!$playlist->has_access()) {
+ if (!$playlist->has_access()) {
access_denied();
break;
}
-
+
$playlist->add_dyn_song();
$_SESSION['data']['playlist_id'] = $playlist->id;
show_playlist($playlist);
break;
case 'create_playlist':
/* Check rights */
- if (!Access::check('interface','25')) {
+ if (!Access::check('interface','25')) {
access_denied();
break;
- }
-
+ }
+
$playlist_name = scrub_in($_REQUEST['playlist_name']);
$playlist_type = scrub_in($_REQUEST['type']);
- $playlist->create($playlist_name,$playlist_type);
+ $playlist->create($playlist_name,$playlist_type);
$_SESSION['data']['playlist_id'] = $playlist->id;
show_confirmation(_('Playlist Created'),$playlist_name . ' (' . $playlist_type . ') ' . _(' has been created'),'playlist.php');
break;
case 'remove_song':
/* Check em for rights */
- if (!$playlist->has_access()) {
+ if (!$playlist->has_access()) {
access_denied();
break;
}
@@ -67,10 +67,10 @@ switch ($_REQUEST['action']) {
show_playlist($playlist);
break;
case 'show_playlist':
- $playlist = new Playlist($_REQUEST['playlist_id']);
- $playlist->format();
- $object_ids = $playlist->get_items();
- require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
+ $playlist = new Playlist($_REQUEST['playlist_id']);
+ $playlist->format();
+ $object_ids = $playlist->get_items();
+ require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
break;
case 'show_import_playlist':
require_once Config::get('prefix') . '/templates/show_import_playlist.inc.php';
@@ -100,7 +100,7 @@ switch ($_REQUEST['action']) {
break;
case 'set_track_numbers':
/* Make sure they have permission */
- if (!$playlist->has_access()) {
+ if (!$playlist->has_access()) {
access_denied();
break;
}
@@ -116,33 +116,33 @@ switch ($_REQUEST['action']) {
break;
case 'prune_empty':
/* Make sure they have permission */
- if (!$GLOBALS['user']->has_access(100)) {
- access_denied();
+ if (!$GLOBALS['user']->has_access(100)) {
+ access_denied();
break;
}
- prune_empty_playlists();
+ prune_empty_playlists();
$url = Config::get('web_path') . '/playlist.php';
- $title = _('Empty Playlists Deleted');
+ $title = _('Empty Playlists Deleted');
$body = '';
show_confirmation($title,$body,$url);
break;
case 'normalize_tracks':
- $playlist = new Playlist($_REQUEST['playlist_id']);
+ $playlist = new Playlist($_REQUEST['playlist_id']);
/* Make sure they have permission */
- if (!$playlist->has_access()) {
+ if (!$playlist->has_access()) {
access_denied();
break;
}
-
+
/* Normalize the tracks */
$playlist->normalize_tracks();
- $object_ids = $playlist->get_items();
+ $object_ids = $playlist->get_items();
default:
- require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
+ require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
break;
} // switch on the action
-show_footer();
+show_footer();
?>
diff --git a/preferences.php b/preferences.php
index f8e7c4d9..330bd66b 100644
--- a/preferences.php
+++ b/preferences.php
@@ -22,75 +22,75 @@
require 'lib/init.php';
-// Switch on the action
-switch($_REQUEST['action']) {
+// Switch on the action
+switch($_REQUEST['action']) {
case 'update_preferences':
- if ($_POST['method'] == 'admin' && !Access::check('interface','100')) {
- access_denied();
- exit;
- }
-
- if (!Core::form_verify('update_preference','post')) {
- access_denied();
- exit;
- }
-
+ if ($_POST['method'] == 'admin' && !Access::check('interface','100')) {
+ access_denied();
+ exit;
+ }
+
+ if (!Core::form_verify('update_preference','post')) {
+ access_denied();
+ exit;
+ }
+
/* Reset the Theme */
- if ($_POST['method'] == 'admin') {
- $user_id = '-1';
- $fullname = _('Server');
- $_REQUEST['action'] = 'admin';
+ if ($_POST['method'] == 'admin') {
+ $user_id = '-1';
+ $fullname = _('Server');
+ $_REQUEST['action'] = 'admin';
+ }
+ else {
+ $user_id = $GLOBALS['user']->id;
+ $fullname = $GLOBALS['user']->fullname;
}
- else {
- $user_id = $GLOBALS['user']->id;
- $fullname = $GLOBALS['user']->fullname;
- }
/* Update and reset preferences */
- update_preferences($user_id);
+ update_preferences($user_id);
Preference::init();
- $preferences = $GLOBALS['user']->get_preferences($user_id,$_REQUEST['tab']);
+ $preferences = $GLOBALS['user']->get_preferences($user_id,$_REQUEST['tab']);
break;
- case 'admin_update_preferences':
+ case 'admin_update_preferences':
// Make sure only admins here
- if (!Access::check('interface','100')) {
- access_denied();
- exit;
- }
+ if (!Access::check('interface','100')) {
+ access_denied();
+ exit;
+ }
if (!Core::form_verify('update_preference','post')) {
access_denied();
exit;
}
- update_preferences($_POST['user_id']);
- header("Location: " . Config::get('web_path') . "/admin/users.php?action=show_preferences&user_id=" . scrub_out($_POST['user_id']));
+ update_preferences($_POST['user_id']);
+ header("Location: " . Config::get('web_path') . "/admin/users.php?action=show_preferences&user_id=" . scrub_out($_POST['user_id']));
break;
- case 'admin':
+ case 'admin':
// Make sure only admins here
- if (!Access::check('interface','100')) {
- access_denied();
+ if (!Access::check('interface','100')) {
+ access_denied();
exit;
- }
+ }
$fullname= _('Server');
- $preferences = $GLOBALS['user']->get_preferences(-1,$_REQUEST['tab']);
+ $preferences = $GLOBALS['user']->get_preferences(-1,$_REQUEST['tab']);
break;
case 'user':
- if (!Access::check('interface','100')) {
- access_denied();
- exit;
- }
- $client = new User($_REQUEST['user_id']);
- $fullname = $client->fullname;
- $preferences = $client->get_preferences(0,$_REQUEST['tab']);
- break;
- case 'update_user':
+ if (!Access::check('interface','100')) {
+ access_denied();
+ exit;
+ }
+ $client = new User($_REQUEST['user_id']);
+ $fullname = $client->fullname;
+ $preferences = $client->get_preferences(0,$_REQUEST['tab']);
+ break;
+ case 'update_user':
// Make sure we're a user and they came from the form
- if (!Access::check('interface','25') OR !Config::get('use_auth')) {
- access_denied();
- exit;
- }
+ if (!Access::check('interface','25') OR !Config::get('use_auth')) {
+ access_denied();
+ exit;
+ }
if (!Core::form_verify('update_user','post')) {
access_denied();
@@ -98,38 +98,38 @@ switch($_REQUEST['action']) {
}
// Remove the value
- unset($_SESSION['forms']['account']);
+ unset($_SESSION['forms']['account']);
// Don't let them change access, or username here
- unset($_POST['access']);
- $_POST['username'] = $GLOBALS['user']->username;
-
- if (!$GLOBALS['user']->update($_POST)) {
- Error::add('general',_('Error Update Failed'));
- }
- else {
- $_REQUEST['action'] = 'confirm';
- $title = _('Updated');
- $text = _('Your Account has been updated');
- $next_url = Config::get('web_path') . '/preferences.php?tab=account';
- }
+ unset($_POST['access']);
+ $_POST['username'] = $GLOBALS['user']->username;
+
+ if (!$GLOBALS['user']->update($_POST)) {
+ Error::add('general',_('Error Update Failed'));
+ }
+ else {
+ $_REQUEST['action'] = 'confirm';
+ $title = _('Updated');
+ $text = _('Your Account has been updated');
+ $next_url = Config::get('web_path') . '/preferences.php?tab=account';
+ }
break;
- default:
- $fullname = $GLOBALS['user']->fullname;
- $preferences = $GLOBALS['user']->get_preferences(0,$_REQUEST['tab']);
+ default:
+ $fullname = $GLOBALS['user']->fullname;
+ $preferences = $GLOBALS['user']->get_preferences(0,$_REQUEST['tab']);
break;
} // End Switch Action
-show_header();
+show_header();
/**
* switch on the view
*/
-switch ($_REQUEST['action']) {
- case 'confirm':
- show_confirmation($title,$text,$next_url,$cancel);
+switch ($_REQUEST['action']) {
+ case 'confirm':
+ show_confirmation($title,$text,$next_url,$cancel);
break;
- default:
+ default:
// Show the default preferences page
require Config::get('prefix') . '/templates/show_preferences.inc.php';
break;
diff --git a/radio.php b/radio.php
index d51ea21a..41192078 100644
--- a/radio.php
+++ b/radio.php
@@ -22,44 +22,44 @@
require 'lib/init.php';
-show_header();
+show_header();
// Switch on Action
-switch ($_REQUEST['action']) {
- case 'show_create':
- if (!Access::check('interface','25')) {
- access_denied();
- exit;
- }
+switch ($_REQUEST['action']) {
+ case 'show_create':
+ if (!Access::check('interface','25')) {
+ access_denied();
+ exit;
+ }
- require_once Config::get('prefix') . '/templates/show_add_live_stream.inc.php';
+ require_once Config::get('prefix') . '/templates/show_add_live_stream.inc.php';
break;
- case 'create':
- if (!Access::check('interface','25') || Config::get('demo_mode')) {
- access_denied();
- exit;
- }
+ case 'create':
+ if (!Access::check('interface','25') || Config::get('demo_mode')) {
+ access_denied();
+ exit;
+ }
- if (!Core::form_verify('add_radio','post')) {
- access_denied();
- exit;
- }
+ if (!Core::form_verify('add_radio','post')) {
+ access_denied();
+ exit;
+ }
// Try to create the sucker
- $results = Radio::create($_POST);
+ $results = Radio::create($_POST);
- if (!$results) {
- require_once Config::get('prefix') . '/templates/show_add_live_stream.inc.php';
- }
- else {
- $body = _('Radio Station Added');
- $title = '';
- show_confirmation($title,$body,Config::get('web_path') . '/index.php');
- }
+ if (!$results) {
+ require_once Config::get('prefix') . '/templates/show_add_live_stream.inc.php';
+ }
+ else {
+ $body = _('Radio Station Added');
+ $title = '';
+ show_confirmation($title,$body,Config::get('web_path') . '/index.php');
+ }
break;
-} // end data collection
+} // end data collection
-show_footer();
+show_footer();
?>
diff --git a/random.php b/random.php
index 83922d17..5c2a89d8 100644
--- a/random.php
+++ b/random.php
@@ -23,24 +23,24 @@
require_once 'lib/init.php';
-show_header();
+show_header();
-switch ($_REQUEST['action']) {
- case 'get_advanced':
- $object_ids = Random::advanced($_POST);
+switch ($_REQUEST['action']) {
+ case 'get_advanced':
+ $object_ids = Random::advanced($_POST);
// We need to add them to the active playlist
- foreach ($object_ids as $object_id) {
- $GLOBALS['user']->playlist->add_object($object_id,'song');
- }
+ foreach ($object_ids as $object_id) {
+ $GLOBALS['user']->playlist->add_object($object_id,'song');
+ }
case 'advanced':
- default:
- require_once Config::get('prefix') . '/templates/show_random.inc.php';
+ default:
+ require_once Config::get('prefix') . '/templates/show_random.inc.php';
/* require_once Config::get('prefix') . '/templates/show_random_rules.inc.php';*/
break;
-} // end switch
+} // end switch
-show_footer();
+show_footer();
?>
diff --git a/register.php b/register.php
index d2a1463d..80bfed64 100644
--- a/register.php
+++ b/register.php
@@ -27,18 +27,18 @@ require_once 'lib/init.php';
if (!Config::get('allow_public_registration') || Config::get('demo_mode')) {
debug_event('DENIED','Error Attempted registration','1');
access_denied();
- exit();
+ exit();
}
/**
- * These are only needed for this page so they aren't included in init.php
+ * These are only needed for this page so they aren't included in init.php
* this is for email validation and the cool little graphic
*/
require_once Config::get('prefix') . '/modules/validatemail/validateEmailFormat.php';
require_once Config::get('prefix') . '/modules/validatemail/validateEmail.php';
/* Don't even include it if we aren't going to use it */
-if (Config::get('captcha_public_reg')) {
+if (Config::get('captcha_public_reg')) {
define ("CAPTCHA_INVERSE", 1);
include Config::get('prefix') . '/modules/captcha/captcha.php';
}
@@ -46,13 +46,13 @@ if (Config::get('captcha_public_reg')) {
/* Start switch based on action passed */
switch ($_REQUEST['action']) {
- case 'validate':
- $username = scrub_in($_GET['username']);
- $validation = scrub_in($_GET['auth']);
- require_once Config::get('prefix') . '/templates/show_user_activate.inc.php';
- break;
+ case 'validate':
+ $username = scrub_in($_GET['username']);
+ $validation = scrub_in($_GET['auth']);
+ require_once Config::get('prefix') . '/templates/show_user_activate.inc.php';
+ break;
case 'add_user':
- /**
+ /**
* User information has been entered
* we need to check the database for possible existing username first
* if username exists, error and say "Please choose a different name."
@@ -68,11 +68,11 @@ switch ($_REQUEST['action']) {
$pass2 = scrub_in($_POST['password_2']);
/* If we're using the captcha stuff */
- if (Config::get('captcha_public_reg')) {
- $captcha = captcha::solved();
+ if (Config::get('captcha_public_reg')) {
+ $captcha = captcha::solved();
if(!isset ($captcha)) {
Error::add('captcha',_('Error Captcha Required'));
- }
+ }
if (isset ($captcha)) {
if ($captcha) {
$msg="SUCCESS";
@@ -86,7 +86,7 @@ switch ($_REQUEST['action']) {
if (Config::get('user_agreement')) {
if (!$_POST['accept_agreement']) {
Error::add('user_agreement',_("You <U>must</U> accept the user agreement"));
- }
+ }
} // if they have to agree to something
if (!$_POST['username']) {
@@ -115,11 +115,11 @@ switch ($_REQUEST['action']) {
$mmsg = "MAILOK";
}
else {
- Error::add('email',_("Error Email address not confirmed")
+ Error::add('email',_("Error Email address not confirmed")
. "<br />$validate_results[1]");
}
/* End of mailcheck */
-
+
if (!$pass1) {
Error::add('password',_("You must enter a password"));
}
@@ -128,7 +128,7 @@ switch ($_REQUEST['action']) {
Error::add('password',_("Your passwords do not match"));
}
- if (!User::check_username($username)) {
+ if (!User::check_username($username)) {
Error::add('duplicate_user',_("Error Username already exists"));
}
@@ -140,20 +140,20 @@ switch ($_REQUEST['action']) {
/* Attempt to create the new user */
$access = '5';
- switch (Config::get('auto_user')) {
- case 'admin':
- $access = '100';
+ switch (Config::get('auto_user')) {
+ case 'admin':
+ $access = '100';
break;
- case 'user':
- $access = '25';
+ case 'user':
+ $access = '25';
break;
- default:
- case 'guest':
- $access = '5';
+ default:
+ case 'guest':
+ $access = '5';
break;
} // auto-user level
-
+
$new_user = User::create($username,$fullname,$email,$pass1,$access);
if (!$new_user) {
@@ -167,11 +167,11 @@ switch ($_REQUEST['action']) {
$client->update_validation($validation);
Registration::send_confirmation($username, $fullname, $email, $pass1, $validation);
- require_once Config::get('prefix') . '/templates/show_registration_confirmation.inc.php';
+ require_once Config::get('prefix') . '/templates/show_registration_confirmation.inc.php';
break;
case 'show_add_user':
default:
- require_once Config::get('prefix') . '/templates/show_user_registration.inc.php';
+ require_once Config::get('prefix') . '/templates/show_user_registration.inc.php';
break;
} // end switch on action
?>
diff --git a/rss.php b/rss.php
index e5320905..c480c0ec 100644
--- a/rss.php
+++ b/rss.php
@@ -30,9 +30,9 @@ if (!Config::get('use_rss') || Config::get('demo_mode')) {
}
// Add in our base hearder defining the content type
-header("Content-Type: application/xml; charset=" . Config::get('site_charset'));
+header("Content-Type: application/xml; charset=" . Config::get('site_charset'));
-$rss = new AmpacheRSS($_REQUEST['type']);
-echo $rss->get_xml();
+$rss = new AmpacheRSS($_REQUEST['type']);
+echo $rss->get_xml();
?>
diff --git a/search.php b/search.php
index cae80205..4aedf327 100644
--- a/search.php
+++ b/search.php
@@ -22,31 +22,31 @@
require_once 'lib/init.php';
-show_header();
+show_header();
/**
- * action switch
+ * action switch
*/
-switch ($_REQUEST['action']) {
+switch ($_REQUEST['action']) {
case 'quick_search':
/* This needs to be done because we don't know what thing
* they used the quick search to search on until after they've
- * submited it
+ * submited it
*/
$_REQUEST['s_all'] = $_REQUEST['search_string'];
-
- if (strlen($_REQUEST['search_string']) < 1) {
+
+ if (strlen($_REQUEST['search_string']) < 1) {
Error::add('keyword',_('Error: No Keyword Entered'));
- require_once Config::get('prefix') . '/templates/show_search.inc.php';
+ require_once Config::get('prefix') . '/templates/show_search.inc.php';
break;
}
case 'search':
- require_once Config::get('prefix') . '/templates/show_search.inc.php';
- require_once Config::get('prefix') . '/templates/show_search_options.inc.php';
+ require_once Config::get('prefix') . '/templates/show_search.inc.php';
+ require_once Config::get('prefix') . '/templates/show_search_options.inc.php';
$results = run_search($_REQUEST);
- Browse::set_type('song');
- Browse::reset();
- Browse::show_objects($results);
+ Browse::set_type('song');
+ Browse::reset();
+ Browse::show_objects($results);
break;
case 'save_as_track':
$playlist_id = save_search($_REQUEST);
@@ -54,14 +54,14 @@ switch ($_REQUEST['action']) {
show_confirmation("Search Saved","Your Search has been saved as a track in $playlist->name",conf('web_path') . "/search.php");
break;
default:
- require_once Config::get('prefix') . '/templates/show_search.inc.php';
+ require_once Config::get('prefix') . '/templates/show_search.inc.php';
break;
- case 'descriptor':
+ case 'descriptor':
// This is a little special we don't want header/footers so trash what we've got in the OB
- ob_clean();
- require_once Config::get('prefix') . '/templates/show_search_descriptor.inc.php';
- exit;
- break;
+ ob_clean();
+ require_once Config::get('prefix') . '/templates/show_search_descriptor.inc.php';
+ exit;
+ break;
}
/* Show the Footer */
diff --git a/server/ajax.server.php b/server/ajax.server.php
index ca10e0cc..96a510cf 100644
--- a/server/ajax.server.php
+++ b/server/ajax.server.php
@@ -20,208 +20,208 @@
*/
-/* Because this is accessed via Ajax we are going to allow the session_id
+/* Because this is accessed via Ajax we are going to allow the session_id
* as part of the get request
*/
// Set that this is an ajax include
-define('AJAX_INCLUDE','1');
+define('AJAX_INCLUDE','1');
require_once '../lib/init.php';
/* Set the correct headers */
header("Content-type: text/xml; charset=" . Config::get('site_charset'));
header("Content-Disposition: attachment; filename=ajax.xml");
-header("Expires: Tuesday, 27 Mar 1984 05:00:00 GMT");
+header("Expires: Tuesday, 27 Mar 1984 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
-header("Pragma: no-cache");
+header("Pragma: no-cache");
-switch ($_REQUEST['page']) {
- case 'flag':
- require_once Config::get('prefix') . '/server/flag.ajax.php';
- exit;
+switch ($_REQUEST['page']) {
+ case 'flag':
+ require_once Config::get('prefix') . '/server/flag.ajax.php';
+ exit;
break;
- case 'stats':
- require_once Config::get('prefix') . '/server/stats.ajax.php';
- exit;
+ case 'stats':
+ require_once Config::get('prefix') . '/server/stats.ajax.php';
+ exit;
break;
- case 'browse':
- require_once Config::get('prefix') . '/server/browse.ajax.php';
- exit;
+ case 'browse':
+ require_once Config::get('prefix') . '/server/browse.ajax.php';
+ exit;
break;
- case 'random':
- require_once Config::get('prefix') . '/server/random.ajax.php';
- exit;
+ case 'random':
+ require_once Config::get('prefix') . '/server/random.ajax.php';
+ exit;
break;
- case 'playlist':
- require_once Config::get('prefix') . '/server/playlist.ajax.php';
- exit;
+ case 'playlist':
+ require_once Config::get('prefix') . '/server/playlist.ajax.php';
+ exit;
break;
- case 'localplay':
- require_once Config::get('prefix') . '/server/localplay.ajax.php';
- exit;
+ case 'localplay':
+ require_once Config::get('prefix') . '/server/localplay.ajax.php';
+ exit;
break;
case 'tag':
require_once Config::get('prefix') . '/server/tag.ajax.php';
- exit;
+ exit;
break;
- case 'stream':
+ case 'stream':
require_once Config::get('prefix') . '/server/stream.ajax.php';
- exit;
+ exit;
+ break;
+ case 'song':
+ require_once Config::get('prefix') . '/server/song.ajax.php';
+ exit;
+ break;
+ case 'democratic':
+ require_once Config::get('prefix') . '/server/democratic.ajax.php';
+ exit;
break;
- case 'song':
- require_once Config::get('prefix') . '/server/song.ajax.php';
- exit;
- break;
- case 'democratic':
- require_once Config::get('prefix') . '/server/democratic.ajax.php';
- exit;
+ case 'index':
+ require_once Config::get('prefix') . '/server/index.ajax.php';
+ exit;
break;
- case 'index':
- require_once Config::get('prefix') . '/server/index.ajax.php';
- exit;
- break;
- default:
+ default:
// A taste of compatibility
break;
-} // end switch on page
+} // end switch on page
-switch ($_REQUEST['action']) {
- case 'refresh_rightbar':
- $results['rightbar'] = ajax_include('rightbar.inc.php');
+switch ($_REQUEST['action']) {
+ case 'refresh_rightbar':
+ $results['rightbar'] = ajax_include('rightbar.inc.php');
break;
/* Controls the editing of objects */
- case 'show_edit_object':
-
+ case 'show_edit_object':
+
// Set the default required level
- $level = '50';
+ $level = '50';
- switch ($_GET['type']) {
- case 'album':
- $key = 'album_' . $_GET['id'];
- $album = new Album($_GET['id']);
- $album->format();
+ switch ($_GET['type']) {
+ case 'album':
+ $key = 'album_' . $_GET['id'];
+ $album = new Album($_GET['id']);
+ $album->format();
break;
- case 'artist':
- $key = 'artist_' . $_GET['id'];
- $artist = new Artist($_GET['id']);
- $artist->format();
+ case 'artist':
+ $key = 'artist_' . $_GET['id'];
+ $artist = new Artist($_GET['id']);
+ $artist->format();
break;
- case 'song':
- $key = 'song_' . $_GET['id'];
- $song = new Song($_GET['id']);
- $song->format();
+ case 'song':
+ $key = 'song_' . $_GET['id'];
+ $song = new Song($_GET['id']);
+ $song->format();
break;
- case 'live_stream':
- $key = 'live_stream_' . $_GET['id'];
- $radio = new Radio($_GET['id']);
- $radio->format();
+ case 'live_stream':
+ $key = 'live_stream_' . $_GET['id'];
+ $radio = new Radio($_GET['id']);
+ $radio->format();
break;
- case 'playlist':
- $key = 'playlist_row_' . $_GET['id'];
- $playlist = new Playlist($_GET['id']);
- $playlist->format();
+ case 'playlist':
+ $key = 'playlist_row_' . $_GET['id'];
+ $playlist = new Playlist($_GET['id']);
+ $playlist->format();
// If the current user is the owner, only user is required
- if ($playlist->user == $GLOBALS['user']->id) {
- $level = '25';
- }
+ if ($playlist->user == $GLOBALS['user']->id) {
+ $level = '25';
+ }
break;
- default:
- $key = 'rfc3514';
- echo xml_from_array(array($key=>'0x1'));
- exit;
+ default:
+ $key = 'rfc3514';
+ echo xml_from_array(array($key=>'0x1'));
+ exit;
break;
- } // end switch on type
+ } // end switch on type
// Make sure they got them rights
- if (!Access::check('interface',$level)) {
- $results['rfc3514'] = '0x1';
- break;
- }
+ if (!Access::check('interface',$level)) {
+ $results['rfc3514'] = '0x1';
+ break;
+ }
+
+ ob_start();
+ require Config::get('prefix') . '/templates/show_edit_' . $_GET['type'] . '_row.inc.php';
+ $results[$key] = ob_get_contents();
+ ob_end_clean();
+ break;
+ case 'edit_object':
- ob_start();
- require Config::get('prefix') . '/templates/show_edit_' . $_GET['type'] . '_row.inc.php';
- $results[$key] = ob_get_contents();
- ob_end_clean();
- break;
- case 'edit_object':
+ $level = '50';
- $level = '50';
-
- if ($_POST['type'] == 'playlist') {
- $playlist = new Playlist($_POST['id']);
- if ($GLOBALS['user']->id == $playlist->user) {
- $level = '25';
- }
- }
+ if ($_POST['type'] == 'playlist') {
+ $playlist = new Playlist($_POST['id']);
+ if ($GLOBALS['user']->id == $playlist->user) {
+ $level = '25';
+ }
+ }
// Make sure we've got them rights
- if (!Access::check('interface',$level) || Config::get('demo_mode')) {
- $results['rfc3514'] = '0x1';
- break;
- }
+ if (!Access::check('interface',$level) || Config::get('demo_mode')) {
+ $results['rfc3514'] = '0x1';
+ break;
+ }
- switch ($_POST['type']) {
- case 'album':
- $key = 'album_' . $_POST['id'];
- $album = new Album($_POST['id']);
- $songs = $album->get_songs();
- $new_id = $album->update($_POST);
- if ($new_id != $_POST['id']) {
- $album = new Album($new_id);
- foreach ($songs as $song_id) {
- Flag::add($song_id,'song','retag','Inline Album Update');
- }
- }
- $album->format();
+ switch ($_POST['type']) {
+ case 'album':
+ $key = 'album_' . $_POST['id'];
+ $album = new Album($_POST['id']);
+ $songs = $album->get_songs();
+ $new_id = $album->update($_POST);
+ if ($new_id != $_POST['id']) {
+ $album = new Album($new_id);
+ foreach ($songs as $song_id) {
+ Flag::add($song_id,'song','retag','Inline Album Update');
+ }
+ }
+ $album->format();
break;
- case 'artist':
- $key = 'artist_' . $_POST['id'];
- $artist = new Artist($_POST['id']);
- $songs = $artist->get_songs();
- $new_id = $artist->update($_POST);
- if ($new_id != $_POST['id']) {
- $artist = new Artist($new_id);
- foreach ($songs as $song_id) {
- Flag::add($song_id,'song','retag','Inline Artist Update');
- }
- }
- $artist->format();
+ case 'artist':
+ $key = 'artist_' . $_POST['id'];
+ $artist = new Artist($_POST['id']);
+ $songs = $artist->get_songs();
+ $new_id = $artist->update($_POST);
+ if ($new_id != $_POST['id']) {
+ $artist = new Artist($new_id);
+ foreach ($songs as $song_id) {
+ Flag::add($song_id,'song','retag','Inline Artist Update');
+ }
+ }
+ $artist->format();
break;
- case 'song':
- $key = 'song_' . $_POST['id'];
+ case 'song':
+ $key = 'song_' . $_POST['id'];
$song = new Song($_POST['id']);
- Flag::add($song->id,'song','retag','Inline Single Song Update');
- $song->update($_POST);
- $song->format();
+ Flag::add($song->id,'song','retag','Inline Single Song Update');
+ $song->update($_POST);
+ $song->format();
break;
- case 'playlist':
- $key = 'playlist_row_' . $_POST['id'];
- $playlist->update($_POST);
- $playlist->format();
+ case 'playlist':
+ $key = 'playlist_row_' . $_POST['id'];
+ $playlist->update($_POST);
+ $playlist->format();
$count = $playlist->get_song_count();
break;
- case 'live_stream':
- $key = 'live_stream_' . $_POST['id'];
- Radio::update($_POST);
- $radio = new Radio($_POST['id']);
- $radio->format();
+ case 'live_stream':
+ $key = 'live_stream_' . $_POST['id'];
+ Radio::update($_POST);
+ $radio = new Radio($_POST['id']);
+ $radio->format();
break;
- default:
+ default:
$key = 'rfc3514';
- echo xml_from_array(array($key=>'0x1'));
- exit;
+ echo xml_from_array(array($key=>'0x1'));
+ exit;
break;
} // end switch on type
- ob_start();
- require Config::get('prefix') . '/templates/show_' . $_POST['type'] . '_row.inc.php';
- $results[$key] = ob_get_contents();
- ob_end_clean();
+ ob_start();
+ require Config::get('prefix') . '/templates/show_' . $_POST['type'] . '_row.inc.php';
+ $results[$key] = ob_get_contents();
+ ob_end_clean();
break;
case 'current_playlist':
- switch ($_REQUEST['type']) {
+ switch ($_REQUEST['type']) {
case 'delete':
$GLOBALS['user']->playlist->delete_track($_REQUEST['id']);
break;
@@ -229,84 +229,84 @@ switch ($_REQUEST['action']) {
$results['rightbar'] = ajax_include('rightbar.inc.php');
break;
- // Handle the users basketcases...
- case 'basket':
- switch ($_REQUEST['type']) {
- case 'album':
- case 'artist':
- case 'tag':
- $object = new $_REQUEST['type']($_REQUEST['id']);
- $songs = $object->get_songs();
- foreach ($songs as $song_id) {
- $GLOBALS['user']->playlist->add_object($song_id,'song');
+ // Handle the users basketcases...
+ case 'basket':
+ switch ($_REQUEST['type']) {
+ case 'album':
+ case 'artist':
+ case 'tag':
+ $object = new $_REQUEST['type']($_REQUEST['id']);
+ $songs = $object->get_songs();
+ foreach ($songs as $song_id) {
+ $GLOBALS['user']->playlist->add_object($song_id,'song');
} // end foreach
break;
case 'browse_set':
- Browse::set_type($_REQUEST['object_type']);
- $objects = Browse::get_saved();
- foreach ($objects as $object_id) {
- $GLOBALS['user']->playlist->add_object($object_id,'song');
- }
- break;
- case 'album_random':
- case 'artist_random':
+ Browse::set_type($_REQUEST['object_type']);
+ $objects = Browse::get_saved();
+ foreach ($objects as $object_id) {
+ $GLOBALS['user']->playlist->add_object($object_id,'song');
+ }
+ break;
+ case 'album_random':
+ case 'artist_random':
case 'tag_random':
- $data = explode('_',$_REQUEST['type']);
+ $data = explode('_',$_REQUEST['type']);
$type = $data['0'];
- $object = new $type($_REQUEST['id']);
- $songs = $object->get_random_songs();
- foreach ($songs as $song_id) {
- $GLOBALS['user']->playlist->add_object($song_id,'song');
- }
- break;
- case 'playlist':
- $playlist = new Playlist($_REQUEST['id']);
- $items = $playlist->get_items();
- foreach ($items as $item) {
- $GLOBALS['user']->playlist->add_object($item['object_id'],$item['type']);
- }
+ $object = new $type($_REQUEST['id']);
+ $songs = $object->get_random_songs();
+ foreach ($songs as $song_id) {
+ $GLOBALS['user']->playlist->add_object($song_id,'song');
+ }
break;
- case 'playlist_random':
- $playlist = new Playlist($_REQUEST['id']);
- $items = $playlist->get_random_items();
- foreach ($items as $item) {
- $GLOBALS['user']->playlist->add_object($item['object_id'],$item['type']);
- }
+ case 'playlist':
+ $playlist = new Playlist($_REQUEST['id']);
+ $items = $playlist->get_items();
+ foreach ($items as $item) {
+ $GLOBALS['user']->playlist->add_object($item['object_id'],$item['type']);
+ }
break;
- case 'clear_all':
- $GLOBALS['user']->playlist->clear();
+ case 'playlist_random':
+ $playlist = new Playlist($_REQUEST['id']);
+ $items = $playlist->get_random_items();
+ foreach ($items as $item) {
+ $GLOBALS['user']->playlist->add_object($item['object_id'],$item['type']);
+ }
break;
- case 'live_stream':
- $object = new Radio($_REQUEST['id']);
+ case 'clear_all':
+ $GLOBALS['user']->playlist->clear();
+ break;
+ case 'live_stream':
+ $object = new Radio($_REQUEST['id']);
// Confirm its a valid ID
- if ($object->name) {
- $GLOBALS['user']->playlist->add_object($object->id,'radio');
- }
+ if ($object->name) {
+ $GLOBALS['user']->playlist->add_object($object->id,'radio');
+ }
+ break;
+ case 'dynamic':
+ $random_id = Random::get_type_id($_REQUEST['random_type']);
+ $GLOBALS['user']->playlist->add_object($random_id,'random');
break;
- case 'dynamic':
- $random_id = Random::get_type_id($_REQUEST['random_type']);
- $GLOBALS['user']->playlist->add_object($random_id,'random');
+ case 'video':
+ $GLOBALS['user']->playlist->add_object($_REQUEST['id'],'video');
break;
- case 'video':
- $GLOBALS['user']->playlist->add_object($_REQUEST['id'],'video');
- break;
- default:
- case 'song':
- $GLOBALS['user']->playlist->add_object($_REQUEST['id'],'song');
+ default:
+ case 'song':
+ $GLOBALS['user']->playlist->add_object($_REQUEST['id'],'song');
break;
} // end switch
-
- $results['rightbar'] = ajax_include('rightbar.inc.php');
+
+ $results['rightbar'] = ajax_include('rightbar.inc.php');
break;
/* Setting ratings */
case 'set_rating':
- ob_start();
+ ob_start();
$rating = new Rating($_GET['object_id'],$_GET['rating_type']);
$rating->set_rating($_GET['rating']);
// We have to clear the cache now :(
Rating::remove_from_cache('rating_' . $_GET['rating_type'] . '_all',$_GET['object_id']);
Rating::remove_from_cache('rating_' . $_GET['rating_type'] . '_user',$_GET['object_id']);
- Rating::show($_GET['object_id'],$_GET['rating_type']);
+ Rating::show($_GET['object_id'],$_GET['rating_type']);
$key = "rating_" . $_GET['object_id'] . "_" . $_GET['rating_type'];
$results[$key] = ob_get_contents();
ob_end_clean();
@@ -315,20 +315,20 @@ switch ($_REQUEST['action']) {
case 'browse':
if ($_REQUEST['key'] && $_REQUEST['value']) {
// Set any new filters we've just added
- Browse::set_filter($_REQUEST['key'],$_REQUEST['value']);
- }
- if ($_REQUEST['sort']) {
+ Browse::set_filter($_REQUEST['key'],$_REQUEST['value']);
+ }
+ if ($_REQUEST['sort']) {
// Set the new sort value
- Browse::set_sort($_REQUEST['sort']);
- }
+ Browse::set_sort($_REQUEST['sort']);
+ }
// Refresh the browse div with our new filter options
- $object_ids = Browse::get_objects();
+ $object_ids = Browse::get_objects();
- ob_start();
- Browse::show_objects($object_ids, true);
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
+ ob_start();
+ Browse::show_objects($object_ids, true);
+ $results['browse_content'] = ob_get_contents();
+ ob_end_clean();
break;
default:
$results['rfc3514'] = '0x1';
@@ -336,6 +336,6 @@ switch ($_REQUEST['action']) {
} // end switch action
// Go ahead and do the echo
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/browse.ajax.php b/server/browse.ajax.php
index 13cd0153..39966303 100644
--- a/server/browse.ajax.php
+++ b/server/browse.ajax.php
@@ -23,20 +23,20 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
+if (AJAX_INCLUDE != '1') { exit; }
-switch ($_REQUEST['action']) {
- case 'browse':
+switch ($_REQUEST['action']) {
+ case 'browse':
- $object_ids = array();
+ $object_ids = array();
- Browse::set_type($_REQUEST['type']);
+ Browse::set_type($_REQUEST['type']);
// Check 'value' with isset because it can null
//(user type a "start with" word and deletes it)
if ($_REQUEST['key'] && (isset($_REQUEST['multi_alpha_filter']) OR isset($_REQUEST['value']))) {
// Set any new filters we've just added
- Browse::set_filter($_REQUEST['key'],$_REQUEST['multi_alpha_filter']);
+ Browse::set_filter($_REQUEST['key'],$_REQUEST['multi_alpha_filter']);
}
if ($_REQUEST['sort']) {
@@ -50,63 +50,63 @@ switch ($_REQUEST['action']) {
break;
case 'set_sort':
- Browse::set_type($_REQUEST['type']);
+ Browse::set_type($_REQUEST['type']);
- if ($_REQUEST['sort']) {
- Browse::set_sort($_REQUEST['sort']);
- }
+ if ($_REQUEST['sort']) {
+ Browse::set_sort($_REQUEST['sort']);
+ }
- ob_start();
- Browse::show_objects(false);
- $results['browse_content'] = ob_get_clean();
- break;
- case 'toggle_tag':
+ ob_start();
+ Browse::show_objects(false);
+ $results['browse_content'] = ob_get_clean();
+ break;
+ case 'toggle_tag':
$type = $_SESSION['tagcloud_type'] ? $_SESSION['tagcloud_type'] : 'song';
- Browse::set_type($type);
+ Browse::set_type($type);
+
-
- break;
- case 'delete_object':
- switch ($_REQUEST['type']) {
- case 'playlist':
+ break;
+ case 'delete_object':
+ switch ($_REQUEST['type']) {
+ case 'playlist':
// Check the perms we need to on this
- $playlist = new Playlist($_REQUEST['id']);
- if (!$playlist->has_access()) { exit; }
+ $playlist = new Playlist($_REQUEST['id']);
+ if (!$playlist->has_access()) { exit; }
// Delete it!
- $playlist->delete();
+ $playlist->delete();
$key = 'playlist_row_' . $playlist->id;
break;
- case 'live_stream':
- if (!$GLOBALS['user']->has_access('75')) { exit; }
+ case 'live_stream':
+ if (!$GLOBALS['user']->has_access('75')) { exit; }
$radio = new Radio($_REQUEST['id']);
- $radio->delete();
- $key = 'live_stream_' . $radio->id;
- break;
- default:
+ $radio->delete();
+ $key = 'live_stream_' . $radio->id;
+ break;
+ default:
break;
} // end switch on type
- $results[$key] = '';
+ $results[$key] = '';
+
+ break;
+ case 'page':
+ Browse::set_type($_REQUEST['type']);
+ Browse::set_start($_REQUEST['start']);
- break;
- case 'page':
- Browse::set_type($_REQUEST['type']);
- Browse::set_start($_REQUEST['start']);
+ ob_start();
+ Browse::show_objects();
+ $results['browse_content'] = ob_get_clean();
- ob_start();
- Browse::show_objects();
- $results['browse_content'] = ob_get_clean();
-
- break;
- default:
- $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+ default:
+ $results['rfc3514'] = '0x1';
+ break;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/democratic.ajax.php b/server/democratic.ajax.php
index 35593439..241d1211 100644
--- a/server/democratic.ajax.php
+++ b/server/democratic.ajax.php
@@ -23,96 +23,96 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
-
-switch ($_REQUEST['action']) {
- case 'delete_vote':
- $democratic = Democratic::get_current_playlist();
- $democratic->set_parent();
- $democratic->remove_vote($_REQUEST['row_id']);
-
- ob_start();
- $object_ids = $democratic->get_items();
+if (AJAX_INCLUDE != '1') { exit; }
+
+switch ($_REQUEST['action']) {
+ case 'delete_vote':
+ $democratic = Democratic::get_current_playlist();
+ $democratic->set_parent();
+ $democratic->remove_vote($_REQUEST['row_id']);
+
+ ob_start();
+ $object_ids = $democratic->get_items();
Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($object_ids);
+ Browse::reset();
+ Browse::set_static_content(1);
+ Browse::show_objects($object_ids);
- require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php';
+ require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php';
$results['browse_content'] = ob_get_contents();
- ob_end_clean();
+ ob_end_clean();
break;
- case 'add_vote':
+ case 'add_vote':
- $democratic = Democratic::get_current_playlist();
- $democratic->set_parent();
- $democratic->add_vote($_REQUEST['object_id'],$_REQUEST['type']);
+ $democratic = Democratic::get_current_playlist();
+ $democratic->set_parent();
+ $democratic->add_vote($_REQUEST['object_id'],$_REQUEST['type']);
- ob_start();
- $object_ids = $democratic->get_items();
+ ob_start();
+ $object_ids = $democratic->get_items();
Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($object_ids);
-
- require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php';
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
-
- break;
- case 'delete':
- if (!$GLOBALS['user']->has_access('75')) {
- exit;
- }
-
- $democratic = Democratic::get_current_playlist();
- $democratic->set_parent();
- $democratic->delete_votes($_REQUEST['row_id']);
-
- ob_start();
- $object_ids = $democratic->get_items();
+ Browse::reset();
+ Browse::set_static_content(1);
+ Browse::show_objects($object_ids);
+
+ require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php';
+ $results['browse_content'] = ob_get_contents();
+ ob_end_clean();
+
+ break;
+ case 'delete':
+ if (!$GLOBALS['user']->has_access('75')) {
+ exit;
+ }
+
+ $democratic = Democratic::get_current_playlist();
+ $democratic->set_parent();
+ $democratic->delete_votes($_REQUEST['row_id']);
+
+ ob_start();
+ $object_ids = $democratic->get_items();
Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($object_ids);
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
-
- break;
- case 'send_playlist':
- if (!Access::check('interface','75')) {
- exit;
- }
-
- $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=democratic&democratic_id=' . scrub_out($_REQUEST['democratic_id']);
+ Browse::reset();
+ Browse::set_static_content(1);
+ Browse::show_objects($object_ids);
+ $results['browse_content'] = ob_get_contents();
+ ob_end_clean();
+
+ break;
+ case 'send_playlist':
+ if (!Access::check('interface','75')) {
+ exit;
+ }
+
+ $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=democratic&democratic_id=' . scrub_out($_REQUEST['democratic_id']);
$results['rfc3514'] = '<script type="text/javascript">reload_util("'.$_SESSION['iframe']['target'].'")</script>';
- break;
- case 'clear_playlist':
-
- if (!Access::check('interface','100')) {
- exit;
- }
-
- $democratic = new Democratic($_REQUEST['democratic_id']);
- $democratic->set_parent();
- $democratic->clear();
-
- ob_start();
- $object_ids = array();
- Browse::set_type('democratic');
- Browse::reset();
- Browse::set_static_content(1);
- Browse::show_objects($object_ids);
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
-
- break;
- default:
- $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+ case 'clear_playlist':
+
+ if (!Access::check('interface','100')) {
+ exit;
+ }
+
+ $democratic = new Democratic($_REQUEST['democratic_id']);
+ $democratic->set_parent();
+ $democratic->clear();
+
+ ob_start();
+ $object_ids = array();
+ Browse::set_type('democratic');
+ Browse::reset();
+ Browse::set_static_content(1);
+ Browse::show_objects($object_ids);
+ $results['browse_content'] = ob_get_contents();
+ ob_end_clean();
+
+ break;
+ default:
+ $results['rfc3514'] = '0x1';
+ break;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/flag.ajax.php b/server/flag.ajax.php
index a725d98d..7ba8b3d3 100644
--- a/server/flag.ajax.php
+++ b/server/flag.ajax.php
@@ -23,49 +23,49 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
+if (AJAX_INCLUDE != '1') { exit; }
-switch ($_REQUEST['action']) {
- case 'reject':
- if (!Access::check('interface','75')) {
- $results['rfc3514'] = '0x1';
- break;
- }
+switch ($_REQUEST['action']) {
+ case 'reject':
+ if (!Access::check('interface','75')) {
+ $results['rfc3514'] = '0x1';
+ break;
+ }
- // Remove the flag from the table
- $flag = new Flag($_REQUEST['flag_id']);
- $flag->delete();
+ // Remove the flag from the table
+ $flag = new Flag($_REQUEST['flag_id']);
+ $flag->delete();
- $flagged = Flag::get_all();
- ob_start();
- Browse::set_type('flagged');
- Browse::set_static_content(1);
- Browse::save_objects($flagged);
- Browse::show_objects($flagged);
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
+ $flagged = Flag::get_all();
+ ob_start();
+ Browse::set_type('flagged');
+ Browse::set_static_content(1);
+ Browse::save_objects($flagged);
+ Browse::show_objects($flagged);
+ $results['browse_content'] = ob_get_contents();
+ ob_end_clean();
break;
- case 'accept':
- if (!Access::check('interface','75')) {
- $results['rfc3514'] = '0x1';
- break;
- }
+ case 'accept':
+ if (!Access::check('interface','75')) {
+ $results['rfc3514'] = '0x1';
+ break;
+ }
- $flag = new Flag($_REQUEST['flag_id']);
- $flag->approve();
- $flag->format();
- ob_start();
- require_once Config::get('prefix') . '/templates/show_flag_row.inc.php';
- $results['flagged_' . $flag->id] = ob_get_contents();
- ob_end_clean();
+ $flag = new Flag($_REQUEST['flag_id']);
+ $flag->approve();
+ $flag->format();
+ ob_start();
+ require_once Config::get('prefix') . '/templates/show_flag_row.inc.php';
+ $results['flagged_' . $flag->id] = ob_get_contents();
+ ob_end_clean();
- break;
- default:
- $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+ default:
+ $results['rfc3514'] = '0x1';
+ break;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/index.ajax.php b/server/index.ajax.php
index 674a75f2..e84e5bf5 100644
--- a/server/index.ajax.php
+++ b/server/index.ajax.php
@@ -23,33 +23,33 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
+if (AJAX_INCLUDE != '1') { exit; }
-switch ($_REQUEST['action']) {
- case 'random_albums':
- $albums = Album::get_random_albums('6');
- if (count($albums) AND is_array($albums)) {
- ob_start();
- require_once Config::get('prefix') . '/templates/show_random_albums.inc.php';
- $results['random_selection'] = ob_get_clean();
- }
- else {
- $results['random_selection'] = '<!-- None found -->';
- }
+switch ($_REQUEST['action']) {
+ case 'random_albums':
+ $albums = Album::get_random_albums('6');
+ if (count($albums) AND is_array($albums)) {
+ ob_start();
+ require_once Config::get('prefix') . '/templates/show_random_albums.inc.php';
+ $results['random_selection'] = ob_get_clean();
+ }
+ else {
+ $results['random_selection'] = '<!-- None found -->';
+ }
break;
- case 'reloadnp':
- ob_start();
- show_now_playing();
- $results['now_playing'] = ob_get_clean();
- ob_start();
- $data = Song::get_recently_played();
- Song::build_cache(array_keys($data));
- if (count($data)) {
+ case 'reloadnp':
+ ob_start();
+ show_now_playing();
+ $results['now_playing'] = ob_get_clean();
+ ob_start();
+ $data = Song::get_recently_played();
+ Song::build_cache(array_keys($data));
+ if (count($data)) {
require_once Config::get('prefix') . '/templates/show_recently_played.inc.php';
- }
- $results['recently_played'] = ob_get_clean();
- break;
- case 'sidebar':
+ }
+ $results['recently_played'] = ob_get_clean();
+ break;
+ case 'sidebar':
switch ($_REQUEST['button']) {
case 'home':
case 'modules':
@@ -65,18 +65,18 @@ switch ($_REQUEST['action']) {
default:
exit;
break;
- } // end switch on button
+ } // end switch on button
ob_start();
$_SESSION['state']['sidebar_tab'] = $button;
require_once Config::get('prefix') . '/templates/sidebar.inc.php';
$results['sidebar'] = ob_get_contents();
ob_end_clean();
- default:
- $results['rfc3514'] = '0x1';
+ default:
+ $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/localplay.ajax.php b/server/localplay.ajax.php
index 9d4299cb..d505b956 100644
--- a/server/localplay.ajax.php
+++ b/server/localplay.ajax.php
@@ -23,69 +23,69 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
+if (AJAX_INCLUDE != '1') { exit; }
-switch ($_REQUEST['action']) {
- case 'set_instance':
+switch ($_REQUEST['action']) {
+ case 'set_instance':
// Make sure they they are allowed to do this
- if (!Access::check('localplay','5')) {
- debug_event('DENIED','Error attempted to set instance without required level','1');
- exit;
- }
+ if (!Access::check('localplay','5')) {
+ debug_event('DENIED','Error attempted to set instance without required level','1');
+ exit;
+ }
$type = $_REQUEST['instance'] ? 'localplay' : 'stream';
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->set_active_instance($_REQUEST['instance']);
- Preference::update('play_type',$GLOBALS['user']->id,$type);
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->set_active_instance($_REQUEST['instance']);
+ Preference::update('play_type',$GLOBALS['user']->id,$type);
// We should also refesh the sidebar
- ob_start();
- require_once Config::get('prefix') . '/templates/sidebar.inc.php';
- $results['sidebar'] = ob_get_contents();
- ob_end_clean();
+ ob_start();
+ require_once Config::get('prefix') . '/templates/sidebar.inc.php';
+ $results['sidebar'] = ob_get_contents();
+ ob_end_clean();
break;
- case 'command':
+ case 'command':
// Make sure they are allowed to do this
- if (!Access::check('localplay','50')) {
- debug_event('DENIED','Attempted to control Localplay without sufficient access','1');
+ if (!Access::check('localplay','50')) {
+ debug_event('DENIED','Attempted to control Localplay without sufficient access','1');
exit;
- }
+ }
+
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->connect();
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->connect();
-
// Switch on valid commands
- switch ($_REQUEST['command']) {
- case 'prev':
- case 'next':
- case 'stop':
- case 'play':
- case 'pause':
- $command = scrub_in($_REQUEST['command']);
- $localplay->$command();
+ switch ($_REQUEST['command']) {
+ case 'prev':
+ case 'next':
+ case 'stop':
+ case 'play':
+ case 'pause':
+ $command = scrub_in($_REQUEST['command']);
+ $localplay->$command();
break;
- case 'volume_up':
- case 'volume_down':
- case 'volume_mute':
- $command = scrub_in($_REQUEST['command']);
- $localplay->$command();
+ case 'volume_up':
+ case 'volume_down':
+ case 'volume_mute':
+ $command = scrub_in($_REQUEST['command']);
+ $localplay->$command();
// We actually want to refresh something here
- ob_start();
+ ob_start();
require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php';
- $results['localplay_status'] = ob_get_contents();
- ob_end_clean();
+ $results['localplay_status'] = ob_get_contents();
+ ob_end_clean();
break;
- case 'delete_all':
- $localplay->delete_all();
- Browse::save_objects(array());
- ob_start();
- Browse::show_objects();
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
+ case 'delete_all':
+ $localplay->delete_all();
+ Browse::save_objects(array());
+ ob_start();
+ Browse::show_objects();
+ $results['browse_content'] = ob_get_contents();
+ ob_end_clean();
break;
- case 'skip':
+ case 'skip':
$localplay->skip(intval($_REQUEST['id']));
$objects = $localplay->get();
ob_start();
@@ -95,94 +95,94 @@ switch ($_REQUEST['action']) {
$results['browse_content'] = ob_get_contents();
ob_end_clean();
break;
- default:
+ default:
// Nothing
- break;
+ break;
} // end whitelist
- break;
- case 'delete_track':
+ break;
+ case 'delete_track':
// Load Connect... yada yada
- if (!Access::check('localplay','50')) {
- debug_event('DENIED','Attempted to delete track without access','1');
- exit;
- }
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->connect();
+ if (!Access::check('localplay','50')) {
+ debug_event('DENIED','Attempted to delete track without access','1');
+ exit;
+ }
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->connect();
// Scrub in the delete request
- $id = intval($_REQUEST['id']);
+ $id = intval($_REQUEST['id']);
+
+ $localplay->delete_track($id);
- $localplay->delete_track($id);
-
// Wait incase we just deleted what we were playing
sleep(3);
- $objects = $localplay->get();
- $status = $localplay->status();
+ $objects = $localplay->get();
+ $status = $localplay->status();
- ob_start();
+ ob_start();
Browse::set_type('playlist_localplay');
Browse::set_static_content(1);
Browse::show_objects($objects);
- $results['browse_content'] = ob_get_contents();
- ob_end_clean();
+ $results['browse_content'] = ob_get_contents();
+ ob_end_clean();
- break;
- case 'delete_instance':
+ break;
+ case 'delete_instance':
// Make sure that you have access to do this...
- if (!Access::check('localplay','75')) {
- debug_event('DENIED','Attempted to delete instance without access','1');
- exit;
- }
+ if (!Access::check('localplay','75')) {
+ debug_event('DENIED','Attempted to delete instance without access','1');
+ exit;
+ }
// Scrub it in
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->delete_instance($_REQUEST['instance']);
-
- $key = 'localplay_instance_' . $_REQUEST['instance'];
- $results[$key] = '';
- break;
- case 'repeat':
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->delete_instance($_REQUEST['instance']);
+
+ $key = 'localplay_instance_' . $_REQUEST['instance'];
+ $results[$key] = '';
+ break;
+ case 'repeat':
// Make sure that they have access to do this again no clue
- if (!Access::check('localplay','50')) {
- debug_event('DENIED','Attempted to set repeat without access','1');
- exit;
- }
-
- // Scrub her in
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->connect();
+ if (!Access::check('localplay','50')) {
+ debug_event('DENIED','Attempted to set repeat without access','1');
+ exit;
+ }
+
+ // Scrub her in
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->connect();
$localplay->repeat(make_bool($_REQUEST['value']));
- ob_start();
- require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php';
- $results['localplay_status'] = ob_get_contents();
- ob_end_clean();
+ ob_start();
+ require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php';
+ $results['localplay_status'] = ob_get_contents();
+ ob_end_clean();
break;
- case 'random':
+ case 'random':
// Make sure that they have access to do this
- if (!Access::check('localplay','50')) {
- debug_event('DENIED','Attempted to set random without access','1');
- exit;
- }
-
+ if (!Access::check('localplay','50')) {
+ debug_event('DENIED','Attempted to set random without access','1');
+ exit;
+ }
+
// Scrub her in
- $localplay = new Localplay(Config::get('localplay_controller'));
- $localplay->connect();
- $localplay->random(make_bool($_REQUEST['value']));
-
- ob_start();
- require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php';
- $results['localplay_status'] = ob_get_contents();
- ob_end_clean();
-
- break;
- default:
- $results['rfc3514'] = '0x1';
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $localplay->connect();
+ $localplay->random(make_bool($_REQUEST['value']));
+
+ ob_start();
+ require_once Config::get('prefix') . '/templates/show_localplay_status.inc.php';
+ $results['localplay_status'] = ob_get_contents();
+ ob_end_clean();
+
+ break;
+ default:
+ $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/playlist.ajax.php b/server/playlist.ajax.php
index acf47685..9cf209cc 100644
--- a/server/playlist.ajax.php
+++ b/server/playlist.ajax.php
@@ -23,130 +23,130 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
+if (AJAX_INCLUDE != '1') { exit; }
-switch ($_REQUEST['action']) {
- case 'delete_track':
+switch ($_REQUEST['action']) {
+ case 'delete_track':
// Create the object and remove the track
- $playlist = new Playlist($_REQUEST['playlist_id']);
- $playlist->format();
+ $playlist = new Playlist($_REQUEST['playlist_id']);
+ $playlist->format();
if ($playlist->has_access()) {
- $playlist->delete_track($_REQUEST['track_id']);
- }
+ $playlist->delete_track($_REQUEST['track_id']);
+ }
- $object_ids = $playlist->get_items();
- ob_start();
+ $object_ids = $playlist->get_items();
+ ob_start();
Browse::set_type('playlist_song');
Browse::add_supplemental_object('playlist',$playlist->id);
Browse::save_objects($object_ids);
Browse::show_objects($object_ids);
- $results['browse_content'] = ob_get_clean();
+ $results['browse_content'] = ob_get_clean();
break;
- case 'edit_track':
- $playlist = new Playlist($_REQUEST['playlist_id']);
- if (!$playlist->has_access()) {
- $results['rfc3514'] = '0x1';
- break;
- }
+ case 'edit_track':
+ $playlist = new Playlist($_REQUEST['playlist_id']);
+ if (!$playlist->has_access()) {
+ $results['rfc3514'] = '0x1';
+ break;
+ }
// They've got access, show the edit page
- $track = $playlist->get_track($_REQUEST['track_id']);
- $song = new Song($track['object_id']);
- $song->format();
- require_once Config::get('prefix') . '/templates/show_edit_playlist_song_row.inc.php';
- $results['track_' . $track['id']] = ob_get_clean();
- break;
- case 'save_track':
- $playlist = new Playlist($_REQUEST['playlist_id']);
- if (!$playlist->has_access()) {
- $results['rfc3514'] = '0x1';
- break;
- }
- $playlist->format();
+ $track = $playlist->get_track($_REQUEST['track_id']);
+ $song = new Song($track['object_id']);
+ $song->format();
+ require_once Config::get('prefix') . '/templates/show_edit_playlist_song_row.inc.php';
+ $results['track_' . $track['id']] = ob_get_clean();
+ break;
+ case 'save_track':
+ $playlist = new Playlist($_REQUEST['playlist_id']);
+ if (!$playlist->has_access()) {
+ $results['rfc3514'] = '0x1';
+ break;
+ }
+ $playlist->format();
// They've got access, save this guy and re-display row
- $playlist->update_track_number($_GET['track_id'],$_POST['track']);
- $track = $playlist->get_track($_GET['track_id']);
- $song = new Song($track['object_id']);
- $song->format();
- $playlist_track = $track['track'];
+ $playlist->update_track_number($_GET['track_id'],$_POST['track']);
+ $track = $playlist->get_track($_GET['track_id']);
+ $song = new Song($track['object_id']);
+ $song->format();
+ $playlist_track = $track['track'];
require Config::get('prefix') . '/templates/show_playlist_song_row.inc.php';
- $results['track_' . $track['id']] = ob_get_clean();
- break;
+ $results['track_' . $track['id']] = ob_get_clean();
+ break;
case 'create':
- if (!Access::check('interface','25')) {
- debug_event('DENIED','Error:' . $GLOBALS['user']->username . ' does not have user access, unable to create playlist','1');
- break;
- }
+ if (!Access::check('interface','25')) {
+ debug_event('DENIED','Error:' . $GLOBALS['user']->username . ' does not have user access, unable to create playlist','1');
+ break;
+ }
// Pull the current active playlist items
- $objects = $GLOBALS['user']->playlist->get_items();
+ $objects = $GLOBALS['user']->playlist->get_items();
+
+ $name = $GLOBALS['user']->username . ' - ' . date("d/m/Y H:i:s",time());
- $name = $GLOBALS['user']->username . ' - ' . date("d/m/Y H:i:s",time());
-
// generate the new playlist
- $playlist_id = Playlist::create($name,'public');
- if (!$playlist_id) { break; }
- $playlist = new Playlist($playlist_id);
+ $playlist_id = Playlist::create($name,'public');
+ if (!$playlist_id) { break; }
+ $playlist = new Playlist($playlist_id);
// Itterate through and add them to our new playlist
- foreach ($objects as $object_data) {
+ foreach ($objects as $object_data) {
// For now only allow songs on here, we'll change this later
$type = array_shift($object_data);
- if ($type == 'song') {
- $songs[] = array_shift($object_data);
- }
+ if ($type == 'song') {
+ $songs[] = array_shift($object_data);
+ }
} // object_data
-
+
// Add our new songs
- $playlist->add_songs($songs,'ORDERED');
- $playlist->format();
- $object_ids = $playlist->get_items();
- ob_start();
- require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
- $results['content'] = ob_get_clean();
+ $playlist->add_songs($songs,'ORDERED');
+ $playlist->format();
+ $object_ids = $playlist->get_items();
+ ob_start();
+ require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
+ $results['content'] = ob_get_clean();
break;
- case 'append':
+ case 'append':
// Pull the current active playlist items
- $objects = $GLOBALS['user']->playlist->get_items();
+ $objects = $GLOBALS['user']->playlist->get_items();
// Create the playlist object
- $playlist = new Playlist($_REQUEST['playlist_id']);
+ $playlist = new Playlist($_REQUEST['playlist_id']);
- // We need to make sure that they have access
- if (!$playlist->has_access()) {
- break;
- }
+ // We need to make sure that they have access
+ if (!$playlist->has_access()) {
+ break;
+ }
- $songs = array();
+ $songs = array();
// Itterate through and add them to our new playlist
- foreach ($objects as $element) {
- $type = array_shift($element);
- switch ($type) {
- case 'song':
- $songs[] = array_shift($element);
- break;
- } // end switch
+ foreach ($objects as $element) {
+ $type = array_shift($element);
+ switch ($type) {
+ case 'song':
+ $songs[] = array_shift($element);
+ break;
+ } // end switch
} // foreach
- // Override normal include procedure
- Ajax::set_include_override(true);
+ // Override normal include procedure
+ Ajax::set_include_override(true);
// Add our new songs
- $playlist->add_songs($songs,'ORDERED');
- $playlist->format();
- $object_ids = $playlist->get_items();
- ob_start();
- require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
- $results['content'] = ob_get_contents();
- ob_end_clean();
+ $playlist->add_songs($songs,'ORDERED');
+ $playlist->format();
+ $object_ids = $playlist->get_items();
+ ob_start();
+ require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
+ $results['content'] = ob_get_contents();
+ ob_end_clean();
break;
- default:
- $results['rfc3514'] = '0x1';
+ default:
+ $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/random.ajax.php b/server/random.ajax.php
index fa4b850e..f7d69b3c 100644
--- a/server/random.ajax.php
+++ b/server/random.ajax.php
@@ -23,14 +23,14 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
+if (AJAX_INCLUDE != '1') { exit; }
-switch ($_REQUEST['action']) {
+switch ($_REQUEST['action']) {
case 'album':
$album_id = Random::album();
// If we don't get anything stop
- if (!$album_id) { $results['rfc3514'] = '0x1'; break; }
+ if (!$album_id) { $results['rfc3514'] = '0x1'; break; }
$album = new Album($album_id);
$songs = $album->get_songs();
@@ -43,7 +43,7 @@ switch ($_REQUEST['action']) {
$artist_id = Random::artist();
// If we don't get anything stop
- if (!$artist_id) { $results['rfc3514'] = '0x1'; break; }
+ if (!$artist_id) { $results['rfc3514'] = '0x1'; break; }
$artist = new Artist($artist_id);
$songs = $artist->get_songs();
@@ -54,9 +54,9 @@ switch ($_REQUEST['action']) {
break;
case 'playlist':
$playlist_id = Random::playlist();
-
+
// If we don't get any results stop right here!
- if (!$playlist_id) { $results['rfc3514'] = '0x1'; break; }
+ if (!$playlist_id) { $results['rfc3514'] = '0x1'; break; }
$playlist = new Playlist($playlist_id);
$items = $playlist->get_items();
@@ -65,29 +65,29 @@ switch ($_REQUEST['action']) {
}
$results['rightbar'] = ajax_include('rightbar.inc.php');
break;
- case 'advanced_random':
- $object_ids = Random::advanced($_POST);
+ case 'advanced_random':
+ $object_ids = Random::advanced($_POST);
// First add them to the active playlist
- foreach ($object_ids as $object_id) {
- $GLOBALS['user']->playlist->add_object($object_id,'song');
- }
- $results['rightbar'] = ajax_include('rightbar.inc.php');
+ foreach ($object_ids as $object_id) {
+ $GLOBALS['user']->playlist->add_object($object_id,'song');
+ }
+ $results['rightbar'] = ajax_include('rightbar.inc.php');
// Now setup the browse and show them below!
- Browse::set_type('song');
+ Browse::set_type('song');
Browse::save_objects($object_ids);
- ob_start();
- Browse::show_objects();
- $results['browse'] = ob_get_contents();
- ob_end_clean();
-
+ ob_start();
+ Browse::show_objects();
+ $results['browse'] = ob_get_contents();
+ ob_end_clean();
+
break;
- default:
- $results['rfc3514'] = '0x1';
+ default:
+ $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/song.ajax.php b/server/song.ajax.php
index 1ce060e7..14f354d2 100644
--- a/server/song.ajax.php
+++ b/server/song.ajax.php
@@ -23,32 +23,32 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
-
-switch ($_REQUEST['action']) {
- case 'flip_state':
- if (!Access::check('interface','75')) {
- debug_event('DENIED',$GLOBALS['user']->username . ' attempted to change the state of a song','1');
- exit;
- }
-
- $song = new Song($_REQUEST['song_id']);
- $new_enabled = $song->enabled ? '0' : '1';
- $song->update_enabled($new_enabled,$song->id);
- $song->enabled = $new_enabled;
- $song->format();
-
+if (AJAX_INCLUDE != '1') { exit; }
+
+switch ($_REQUEST['action']) {
+ case 'flip_state':
+ if (!Access::check('interface','75')) {
+ debug_event('DENIED',$GLOBALS['user']->username . ' attempted to change the state of a song','1');
+ exit;
+ }
+
+ $song = new Song($_REQUEST['song_id']);
+ $new_enabled = $song->enabled ? '0' : '1';
+ $song->update_enabled($new_enabled,$song->id);
+ $song->enabled = $new_enabled;
+ $song->format();
+
//Return the new Ajax::button
$id = 'button_flip_state_' . $song->id;
$button = $song->enabled ? 'disable' : 'enable';
- $results[$id] = Ajax::button('?page=song&action=flip_state&song_id=' . $song->id,$button,_(ucfirst($button)),'flip_state_' . $song->id);
+ $results[$id] = Ajax::button('?page=song&action=flip_state&song_id=' . $song->id,$button,_(ucfirst($button)),'flip_state_' . $song->id);
break;
- default:
- $results['rfc3514'] = '0x1';
+ default:
+ $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/stats.ajax.php b/server/stats.ajax.php
index d3f11a87..3b824c5f 100644
--- a/server/stats.ajax.php
+++ b/server/stats.ajax.php
@@ -23,14 +23,14 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
+if (AJAX_INCLUDE != '1') { exit; }
-switch ($_REQUEST['action']) {
- default:
- $results['rfc3514'] = '0x1';
+switch ($_REQUEST['action']) {
+ default:
+ $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/stream.ajax.php b/server/stream.ajax.php
index db5d035a..01d6396f 100644
--- a/server/stream.ajax.php
+++ b/server/stream.ajax.php
@@ -23,74 +23,74 @@
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
*/
-if (AJAX_INCLUDE != '1') { exit; }
+if (AJAX_INCLUDE != '1') { exit; }
-switch ($_REQUEST['action']) {
- case 'set_play_type':
+switch ($_REQUEST['action']) {
+ case 'set_play_type':
// Make sure they have the rights to do this
- if (!Preference::has_access('play_type')) {
- $results['rfc3514'] = '0x1';
+ if (!Preference::has_access('play_type')) {
+ $results['rfc3514'] = '0x1';
break;
- }
+ }
- switch ($_POST['type']) {
- case 'stream':
+ switch ($_POST['type']) {
+ case 'stream':
case 'localplay':
- case 'democratic':
- $key = 'allow_' . $_POST['type'] . '_playback';
- if (!Config::get($key)) {
- $results['rfc3514'] = '0x1';
- break 2;
- }
- $new = $_POST['type'];
- break;
- case 'xspf_player':
- $new = $_POST['type'];
+ case 'democratic':
+ $key = 'allow_' . $_POST['type'] . '_playback';
+ if (!Config::get($key)) {
+ $results['rfc3514'] = '0x1';
+ break 2;
+ }
+ $new = $_POST['type'];
+ break;
+ case 'xspf_player':
+ $new = $_POST['type'];
// Rien a faire
- break;
- default:
- $new = 'stream';
- $results['rfc3514'] = '0x1';
- break 2;
- } // end switch
+ break;
+ default:
+ $new = 'stream';
+ $results['rfc3514'] = '0x1';
+ break 2;
+ } // end switch
- $current = Config::get('play_type');
+ $current = Config::get('play_type');
// Go ahead and update their preference
- if (Preference::update('play_type',$GLOBALS['user']->id,$new)) {
- Config::set('play_type',$new,'1');
- }
-
+ if (Preference::update('play_type',$GLOBALS['user']->id,$new)) {
+ Config::set('play_type',$new,'1');
+ }
+
- if (($new == 'localplay' AND $current != 'localplay') OR ($current == 'localplay' AND $new != 'localplay')) {
- $results['rightbar'] = ajax_include('rightbar.inc.php');
- }
+ if (($new == 'localplay' AND $current != 'localplay') OR ($current == 'localplay' AND $new != 'localplay')) {
+ $results['rightbar'] = ajax_include('rightbar.inc.php');
+ }
- $results['rfc3514'] = '0x0';
+ $results['rfc3514'] = '0x0';
break;
- case 'basket':
+ case 'basket':
// Go ahead and see if we should clear the playlist here or not, we might not actually clear it in the session
- // we'll just have to feed it bad data.
- // FIXME: This is sad, will be fixed when I switch how streaming works.
+ // we'll just have to feed it bad data.
+ // FIXME: This is sad, will be fixed when I switch how streaming works.
// Check to see if 'clear' was passed if it was then we need to reset the basket
if ( ($_REQUEST['playlist_method'] == 'clear' || Config::get('playlist_method') == 'clear') AND Config::get('play_type') != 'xspf_player') {
- define('NO_SONGS','1');
- ob_start();
- require_once Config::get('prefix') . '/templates/rightbar.inc.php';
- $results['rightbar'] = ob_get_clean();
+ define('NO_SONGS','1');
+ ob_start();
+ require_once Config::get('prefix') . '/templates/rightbar.inc.php';
+ $results['rightbar'] = ob_get_clean();
}
// We need to set the basket up!
- $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket&playlist_method=' . scrub_out($_REQUEST['playlist_method']);
- $results['rfc3514'] = '<script type="text/javascript">reload_util(\''.$_SESSION['iframe']['target'] . '\');</script>';
+ $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket&playlist_method=' . scrub_out($_REQUEST['playlist_method']);
+ $results['rfc3514'] = '<script type="text/javascript">reload_util(\''.$_SESSION['iframe']['target'] . '\');</script>';
break;
- default:
- $results['rfc3514'] = '0x1';
+ default:
+ $results['rfc3514'] = '0x1';
break;
-} // switch on action;
+} // switch on action;
// We always do this
-echo xml_from_array($results);
+echo xml_from_array($results);
?>
diff --git a/server/tag.ajax.php b/server/tag.ajax.php
index 511265a0..a1c43988 100644
--- a/server/tag.ajax.php
+++ b/server/tag.ajax.php
@@ -44,11 +44,11 @@ switch ($_REQUEST['action']) {
// Set browse method
Browse::set_type('song');
- Browse::set_filter('tag',$_GET['tag_id']);
- $object_ids = Browse::get_objects();
- ob_start();
- Browse::show_objects($object_ids);
- $results['browse_content'] = ob_get_clean();
+ Browse::set_filter('tag',$_GET['tag_id']);
+ $object_ids = Browse::get_objects();
+ ob_start();
+ Browse::show_objects($object_ids);
+ $results['browse_content'] = ob_get_clean();
// Retrive current objects of type based on combined filters
break;
diff --git a/server/xml.server.php b/server/xml.server.php
index f568ca03..1797ece1 100644
--- a/server/xml.server.php
+++ b/server/xml.server.php
@@ -20,30 +20,30 @@
*/
/**
- * This is accessed remotly to allow outside scripts access to ampache information
- * as such it needs to verify the session id that is passed
+ * This is accessed remotly to allow outside scripts access to ampache information
+ * as such it needs to verify the session id that is passed
*/
define('NO_SESSION','1');
require_once '../lib/init.php';
// If it's not a handshake then we can allow it to take up lots of time
-if ($_REQUEST['action'] != 'handshake') {
- set_time_limit(0);
-}
+if ($_REQUEST['action'] != 'handshake') {
+ set_time_limit(0);
+}
/* Set the correct headers */
header("Content-type: text/xml; charset=" . Config::get('site_charset'));
header("Content-Disposition: attachment; filename=information.xml");
// If we don't even have access control on then we can't use this!
-if (!Config::get('access_control')) {
- ob_end_clean();
- debug_event('Access Control','Error Attempted to use XML API with Access Control turned off','3');
+if (!Config::get('access_control')) {
+ ob_end_clean();
+ debug_event('Access Control','Error Attempted to use XML API with Access Control turned off','3');
echo xmlData::error('501',_('Access Control not Enabled'));
- exit;
-}
+ exit;
+}
-/**
+/**
* Verify the existance of the Session they passed in we do allow them to
* login via this interface so we do have an exception for action=login
*/
@@ -58,37 +58,37 @@ if (!vauth::session_exists('api', $_REQUEST['auth']) AND $_REQUEST['action'] !=
$session = vauth::get_session_data($_REQUEST['auth']);
$username = ($_REQUEST['action'] == 'handshake' || $_REQUEST['action'] == 'ping') ? $_REQUEST['user'] : $session['username'];
-if (!Access::check_network('init-api',$username,'5')) {
+if (!Access::check_network('init-api',$username,'5')) {
debug_event('Access Denied','Unauthorized access attempt to API [' . $_SERVER['REMOTE_ADDR'] . ']', '3');
- ob_end_clean();
+ ob_end_clean();
echo xmlData::error('403',_('Unauthorized access attempt to API - ACL Error'));
- exit();
+ exit();
}
-if ($_REQUEST['action'] != 'handshake' AND $_REQUEST['action'] != 'ping') {
- vauth::session_extend($_REQUEST['auth']);
+if ($_REQUEST['action'] != 'handshake' AND $_REQUEST['action'] != 'ping') {
+ vauth::session_extend($_REQUEST['auth']);
$GLOBALS['user'] = User::get_from_username($session['username']);
-}
+}
// Get the list of possible methods for the Ampache API
-$methods = get_class_methods('api');
+$methods = get_class_methods('api');
// Define list of internal functions that should be skipped
-$interal_functions = array('set_filter');
+$interal_functions = array('set_filter');
// Recurse through them and see if we're calling one of them
-foreach ($methods as $method) {
- if (in_array($method,$internal_functions)) { continue; }
+foreach ($methods as $method) {
+ if (in_array($method,$internal_functions)) { continue; }
// If the method is the same as the action being called
// Then let's call this function!
- if ($_GET['action'] == $method) {
+ if ($_GET['action'] == $method) {
call_user_func(array('api',$method),$_GET);
// We only allow a single function to be called, and we assume it's cleaned up!
- exit;
- }
+ exit;
+ }
-} // end foreach methods in API
+} // end foreach methods in API
// If we manage to get here, we still need to hand out an XML document
ob_end_clean();
diff --git a/shout.php b/shout.php
index 1ab93ef6..fa53879b 100644
--- a/shout.php
+++ b/shout.php
@@ -21,42 +21,42 @@
*/
require_once 'lib/init.php';
-show_header();
+show_header();
// Switch on the incomming action
-switch ($_REQUEST['action']) {
- case 'add_shout':
+switch ($_REQUEST['action']) {
+ case 'add_shout':
// Must be at least a user to do this
- if (!Access::check('interface','25')) {
- access_denied();
- exit;
- }
-
- if (!Core::form_verify('add_shout','post')) {
- access_denied();
- exit;
- }
-
- $shout_id = shoutBox::create($_POST);
- header("Location:" . Config::get('web_path'));
- break;
- case 'show_add_shout':
+ if (!Access::check('interface','25')) {
+ access_denied();
+ exit;
+ }
+
+ if (!Core::form_verify('add_shout','post')) {
+ access_denied();
+ exit;
+ }
+
+ $shout_id = shoutBox::create($_POST);
+ header("Location:" . Config::get('web_path'));
+ break;
+ case 'show_add_shout':
// Get our object first
- $object = shoutBox::get_object($_REQUEST['type'],$_REQUEST['id']);
+ $object = shoutBox::get_object($_REQUEST['type'],$_REQUEST['id']);
- if (!$object->id) {
- Error::add('general',_('Invalid Object Selected'));
- Error::display('general');
+ if (!$object->id) {
+ Error::add('general',_('Invalid Object Selected'));
+ Error::display('general');
break;
- }
+ }
// Now go ahead and display the page where we let them add a comment etc
- require_once Config::get('prefix') . '/templates/show_add_shout.inc.php';
- break;
- default:
- header("Location:" . Config::get('web_path'));
+ require_once Config::get('prefix') . '/templates/show_add_shout.inc.php';
+ break;
+ default:
+ header("Location:" . Config::get('web_path'));
break;
} // end switch on action
-show_footer();
+show_footer();
?>
diff --git a/stats.php b/stats.php
index 19ef23c5..7cf6f4cb 100644
--- a/stats.php
+++ b/stats.php
@@ -25,18 +25,18 @@
*/
require_once 'lib/init.php';
-show_header();
+show_header();
/* Switch on the action to be performed */
-switch ($_REQUEST['action']) {
+switch ($_REQUEST['action']) {
// Show a Users "Profile" page
- case 'show_user':
- $client = new User($_REQUEST['user_id']);
- require_once Config::get('prefix') . '/templates/show_user.inc.php';
+ case 'show_user':
+ $client = new User($_REQUEST['user_id']);
+ require_once Config::get('prefix') . '/templates/show_user.inc.php';
break;
case 'user_stats':
/* Get em! */
- $working_user = new User($_REQUEST['user_id']);
+ $working_user = new User($_REQUEST['user_id']);
/* Pull favs */
$favorite_artists = $working_user->get_favorites('artist');
@@ -44,21 +44,21 @@ switch ($_REQUEST['action']) {
$favorite_songs = $working_user->get_favorites('song');
require_once Config::get('prefix') . '/templates/show_user_stats.inc.php';
-
+
break;
// Show stats
- case 'newest':
- require_once Config::get('prefix') . '/templates/show_newest.inc.php';
- break;
- case 'popular':
- require_once Config::get('prefix') . '/templates/show_popular.inc.php';
- break;
- case 'show':
- default:
- require_once Config::get('prefix') . '/templates/show_stats.inc.php';
+ case 'newest':
+ require_once Config::get('prefix') . '/templates/show_newest.inc.php';
+ break;
+ case 'popular':
+ require_once Config::get('prefix') . '/templates/show_popular.inc.php';
+ break;
+ case 'show':
+ default:
+ require_once Config::get('prefix') . '/templates/show_stats.inc.php';
break;
} // end switch on action
-show_footer();
+show_footer();
?>
diff --git a/stream.php b/stream.php
index 911e6b12..7e0ab8b3 100644
--- a/stream.php
+++ b/stream.php
@@ -31,17 +31,17 @@ $media_ids = array();
$web_path = Config::get('web_path');
/**
- * action switch
+ * action switch
*/
-switch ($_REQUEST['action']) {
- case 'basket':
- // Pull in our items (multiple types)
- $media_ids = $GLOBALS['user']->playlist->get_items();
+switch ($_REQUEST['action']) {
+ case 'basket':
+ // Pull in our items (multiple types)
+ $media_ids = $GLOBALS['user']->playlist->get_items();
// Check to see if 'clear' was passed if it was then we need to reset the basket
- if ( ($_REQUEST['playlist_method'] == 'clear' || Config::get('playlist_method') == 'clear') AND Config::get('play_type') != 'xspf_player') {
- $GLOBALS['user']->playlist->clear();
- }
+ if ( ($_REQUEST['playlist_method'] == 'clear' || Config::get('playlist_method') == 'clear') AND Config::get('play_type') != 'xspf_player') {
+ $GLOBALS['user']->playlist->clear();
+ }
break;
/* This is run if we need to gather info based on a tmp playlist */
@@ -50,25 +50,25 @@ switch ($_REQUEST['action']) {
$media_ids = $tmp_playlist->get_items();
break;
case 'play_favorite':
- $data = $GLOBALS['user']->get_favorites($_REQUEST['type']);
- $media_ids = array();
- switch ($_REQUEST['type']) {
+ $data = $GLOBALS['user']->get_favorites($_REQUEST['type']);
+ $media_ids = array();
+ switch ($_REQUEST['type']) {
case 'artist':
case 'album':
- foreach ($data as $value) {
- $songs = $value->get_songs();
- $media_ids = array_merge($media_ids,$songs);
- }
+ foreach ($data as $value) {
+ $songs = $value->get_songs();
+ $media_ids = array_merge($media_ids,$songs);
+ }
break;
case 'song':
- foreach ($data as $value) {
- $media_ids[] = $value->id;
- }
+ foreach ($data as $value) {
+ $media_ids[] = $value->id;
+ }
break;
} // end switch on type
break;
case 'single_song':
- $media_ids[] = array('song',scrub_in($_REQUEST['song_id']));
+ $media_ids[] = array('song',scrub_in($_REQUEST['song_id']));
break;
case 'your_popular_songs':
$media_ids = get_popular_songs($_REQUEST['limit'], 'your', $GLOBALS['user']->id);
@@ -112,25 +112,25 @@ switch ($_REQUEST['action']) {
$options = array('limit' => $_REQUEST['random'], 'random_type' => $_REQUEST['random_type'],'size_limit'=>$_REQUEST['size_limit']);
$media_ids = get_random_songs($options, $matchlist);
break;
- case 'democratic':
- $democratic = new Democratic($_REQUEST['democratic_id']);
- $urls = array($democratic->play_url());
+ case 'democratic':
+ $democratic = new Democratic($_REQUEST['democratic_id']);
+ $urls = array($democratic->play_url());
break;
- case 'download':
- $media_ids[] = array('song',scrub_in($_REQUEST['song_id']));
+ case 'download':
+ $media_ids[] = array('song',scrub_in($_REQUEST['song_id']));
default:
break;
} // end action switch
-/* Now that we've gathered the song information we decide what
+/* Now that we've gathered the song information we decide what
* we should do with it, this is a sensitive time for the song id's
* they don't know where they want to go.. let's help them out
*/
-switch ($_REQUEST['method']) {
+switch ($_REQUEST['method']) {
case 'download':
// Run the access check and exit if they are not allowed to download
- if (!Access::check_function('batch_download')) { access_denied(); exit; }
+ if (!Access::check_function('batch_download')) { access_denied(); exit; }
// Format the zip file
@@ -142,30 +142,30 @@ switch ($_REQUEST['method']) {
case 'stream':
default:
// See if we need a special streamtype
- switch ($_REQUEST['action']) {
- case 'download':
- $stream_type = 'download';
+ switch ($_REQUEST['action']) {
+ case 'download':
+ $stream_type = 'download';
break;
- case 'democratic':
+ case 'democratic':
// Don't let them loop it
- if (Config::get('play_type') == 'democratic') {
- Config::set('play_type','stream','1');
+ if (Config::get('play_type') == 'democratic') {
+ Config::set('play_type','stream','1');
}
default:
- if (Config::get('play_type') == 'stream') {
+ if (Config::get('play_type') == 'stream') {
$stream_type = Config::get('playlist_type');
- }
- else {
- $stream_type = Config::get('play_type');
- }
+ }
+ else {
+ $stream_type = Config::get('play_type');
+ }
break;
- }
+ }
/* Start the Stream */
debug_event('stream.php' , 'Stream Type: '.$stream_type.' Media IDs: '.$media_ids, '5');
$stream = new Stream($stream_type,$media_ids);
- $stream->add_urls($urls);
- $stream->start();
+ $stream->add_urls($urls);
+ $stream->start();
-} // end method switch
+} // end method switch
?>
diff --git a/templates/footer.inc.php b/templates/footer.inc.php
index 4d63a1e3..8a0ac738 100644
--- a/templates/footer.inc.php
+++ b/templates/footer.inc.php
@@ -29,7 +29,7 @@
</div> <!-- end id="maincontainer"-->
<div id="footer">
<a href="http://www.ampache.org/index.php">Ampache v.<?php echo Config::get('version'); ?></a><br />
- Copyright (c) 2001 - 2010 Ampache.org
+ Copyright (c) 2001 - 2010 Ampache.org
<?php echo _('Queries:'); ?><?php echo Dba::$stats['query']; ?> <?php echo _('Cache Hits:'); ?><?php echo database_object::$cache_hit; ?>
</div>
</body>
diff --git a/templates/header.inc.php b/templates/header.inc.php
index 7cda0e5f..41df950c 100644
--- a/templates/header.inc.php
+++ b/templates/header.inc.php
@@ -48,7 +48,7 @@ if (Config::get('use_rss')) { ?>
<script src="<?php echo $web_path; ?>/lib/javascript-base.js" language="javascript" type="text/javascript"></script>
<script src="<?php echo $web_path; ?>/modules/kajax/ajax.js" language="javascript" type="text/javascript"></script>
<script src="<?php echo $web_path; ?>/modules/prototype/prototype.js" language="javascript" type="text/javascript"></script>
-<!-- rfc3514 implementation -->
+<!-- rfc3514 implementation -->
<div id="rfc3514" style="display:none;">0x0</div>
<div id="maincontainer">
<div id="header"><!-- This is the header -->
@@ -71,7 +71,7 @@ if (Config::get('use_rss')) { ?>
<div id="rightbar"><!-- This is the rightbar -->
<?php require_once Config::get('prefix') . '/templates/rightbar.inc.php'; ?>
</div><!-- End rightbar -->
-<!-- Tiny little iframe, used to cheat the system -->
+<!-- Tiny little iframe, used to cheat the system -->
<div id="ajax-loading">Loading . . .</div>
<iframe name="util_iframe" id="util_iframe" style="display:none;" src="<?php echo Config::get('web_path'); ?>/util.php"></iframe>
<div id="content">
diff --git a/templates/list_header.inc.php b/templates/list_header.inc.php
index 202dd8c2..f9ddb842 100644
--- a/templates/list_header.inc.php
+++ b/templates/list_header.inc.php
@@ -28,22 +28,22 @@
*/
// Pull these variables out to allow shorthand (easier for lazy programmers)
-$limit = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
-$start = Browse::get_start();
-$total = Browse::$total_objects;
-$uid = Config::get('list_header_uid');
+$limit = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
+$start = Browse::get_start();
+$total = Browse::$total_objects;
+$uid = Config::get('list_header_uid');
$sides = 5;
// ++ the uid
-Config::set('list_header_uid',$uid+1,1);
+Config::set('list_header_uid',$uid+1,1);
// Next
$next_offset = $start + $limit;
if ($next_offset > $total) { $next_offset = $start; }
// Prev
-$prev_offset = $start - $limit;
-if ($prev_offset < 0) { $prev_offset = '0'; }
+$prev_offset = $start - $limit;
+if ($prev_offset < 0) { $prev_offset = '0'; }
/* Calculate how many pages total exist */
$pages = ceil($total/$limit);
@@ -52,10 +52,10 @@ $pages = ceil($total/$limit);
$page_data = array('up'=>array(),'down'=>array());
// Can't Divide by 0
-if ($start> 0) {
+if ($start> 0) {
$current_page = floor($start/$limit);
}
-else {
+else {
$current_page = 0;
}
@@ -64,20 +64,20 @@ else {
$page = $current_page;
$i = 0;
/* While we have pages left */
-while ($page > 0) {
- if ($i == $sides) { $page_data['down'][1] = '...'; $page_data['down'][0] = '0'; break; }
+while ($page > 0) {
+ if ($i == $sides) { $page_data['down'][1] = '...'; $page_data['down'][0] = '0'; break; }
$i++;
$page = $page - 1;
$page_data['down'][$page] = $page * $limit;
} // while page > 0
// Up Next
-$page = $current_page+1;
+$page = $current_page+1;
$i = 0;
/* While we have pages left */
-while ($page <= $pages) {
+while ($page <= $pages) {
if ($page * $limit > $total) { break; }
- if ($i == $sides) {
+ if ($i == $sides) {
$key = $pages - 1;
if (!$page_data['up'][$key]) { $page_data['up'][$key] = '...'; }
$page_data['up'][$pages] = ($pages-1) * $limit;
@@ -91,7 +91,7 @@ while ($page <= $pages) {
// Sort These Arrays of Hotness
ksort($page_data['up']);
ksort($page_data['down']);
-$browse_type = Browse::get_type();
+$browse_type = Browse::get_type();
// are there enough items to even need this view?
if ($pages > 1) {
@@ -100,14 +100,14 @@ if ($pages > 1) {
<?php echo Ajax::text('?page=browse&action=page&type=' . $browse_type . '&start=' . $prev_offset,_('Prev'),'browse_' . $uid . 'prev','','prev'); ?>
<?php echo Ajax::text('?page=browse&action=page&type=' . $browse_type . '&start=' . $next_offset,_('Next'),'browse_' . $uid . 'next','','next'); ?>
- <?php
+ <?php
/* Echo Everything below us */
- foreach ($page_data['down'] as $page => $offset) {
- if ($offset === '...') { echo '...&nbsp;'; }
- else {
+ foreach ($page_data['down'] as $page => $offset) {
+ if ($offset === '...') { echo '...&nbsp;'; }
+ else {
// Hack Alert
$page++;
- echo Ajax::text('?page=browse&action=page&type=' . $browse_type .'&start=' . $offset,$page,'browse_' . $uid . 'page_' . $page,'','page-nb');
+ echo Ajax::text('?page=browse&action=page&type=' . $browse_type .'&start=' . $offset,$page,'browse_' . $uid . 'page_' . $page,'','page-nb');
}
} // end foreach down
@@ -118,10 +118,10 @@ if ($pages > 1) {
<?php
/* Echo Out Everything Above Us */
- foreach ($page_data['up'] as $page=>$offset) {
- if ($offset === '...') { echo '...&nbsp;'; }
- else {
- echo Ajax::text('?page=browse&action=page&type=' . $browse_type . '&start=' . $offset,$page,'browse_' . $uid . 'page_' . $page,'','page-nb');
+ foreach ($page_data['up'] as $page=>$offset) {
+ if ($offset === '...') { echo '...&nbsp;'; }
+ else {
+ echo Ajax::text('?page=browse&action=page&type=' . $browse_type . '&start=' . $offset,$page,'browse_' . $uid . 'page_' . $page,'','page-nb');
} // end else
} // end foreach up
?>
diff --git a/templates/rightbar.inc.php b/templates/rightbar.inc.php
index ecb686c6..7e931fee 100644
--- a/templates/rightbar.inc.php
+++ b/templates/rightbar.inc.php
@@ -31,12 +31,12 @@
<li>
<?php echo Ajax::text('?page=playlist&action=create',_('Add to New Playlist'),'rb_create_playlist'); ?>
</li>
- <?php
- $playlists = Playlist::get_users($GLOBALS['user']->id);
- Playlist::build_cache($playlists);
- foreach ($playlists as $playlist_id) {
+ <?php
+ $playlists = Playlist::get_users($GLOBALS['user']->id);
+ Playlist::build_cache($playlists);
+ foreach ($playlists as $playlist_id) {
$playlist = new Playlist($playlist_id);
- $playlist->format();
+ $playlist->format();
?>
<li>
<?php echo Ajax::text('?page=playlist&action=append&playlist_id=' . $playlist->id,$playlist->f_name,'rb_append_playlist_' . $playlist->id); ?>
@@ -72,34 +72,34 @@
</ul>
</li>
</ul>
-<?php if (Config::get('play_type') == 'localplay') { require_once Config::get('prefix') . '/templates/show_localplay_control.inc.php'; } ?>
+<?php if (Config::get('play_type') == 'localplay') { require_once Config::get('prefix') . '/templates/show_localplay_control.inc.php'; } ?>
<ul id="rb_current_playlist">
-<?php
+<?php
- $objects = array();
+ $objects = array();
//FIXME :: this is kludgy
- if (NO_SONGS != '1') {
- $objects = $GLOBALS['user']->playlist->get_items();
- }
+ if (NO_SONGS != '1') {
+ $objects = $GLOBALS['user']->playlist->get_items();
+ }
// Limit the number of objects we show here
- if (count($objects) > 100) {
- $truncated = (count($objects) - 100);
- $objects = array_slice($objects,0,100);
- }
+ if (count($objects) > 100) {
+ $truncated = (count($objects) - 100);
+ $objects = array_slice($objects,0,100);
+ }
- $normal_array = array('radio','song','video','random');
+ $normal_array = array('radio','song','video','random');
- foreach ($objects as $uid=>$object_data) {
+ foreach ($objects as $uid=>$object_data) {
$type = array_shift($object_data);
- if (in_array($type,$normal_array)) {
- $object = new $type(array_shift($object_data));
- $object->format();
- }
- if ($type == 'random') {
- $object->f_link = Random::get_type_name($type);
- }
+ if (in_array($type,$normal_array)) {
+ $object = new $type(array_shift($object_data));
+ $object->format();
+ }
+ if ($type == 'random') {
+ $object->f_link = Random::get_type_name($type);
+ }
?>
<li class="<?php echo flip_class(); ?>" >
<?php echo $object->f_link; ?>
@@ -116,12 +116,12 @@
</ul>
-<?php
+<?php
// We do a little magic here to force a iframe reload depending on preference
// We do this last because we want it to load, and we want to know if there is anything
// to even pass
-if (count($objects)) {
- Stream::run_playlist_method();
-}
+if (count($objects)) {
+ Stream::run_playlist_method();
+}
?>
diff --git a/templates/show_access_list.inc.php b/templates/show_access_list.inc.php
index 66e1e84b..8417889e 100644
--- a/templates/show_access_list.inc.php
+++ b/templates/show_access_list.inc.php
@@ -61,11 +61,11 @@
<th><?php echo _('Type'); ?></th>
<th><?php echo _('Action'); ?></th>
</tr>
-<?php
+<?php
/* Start foreach List Item */
- foreach ($list as $access_id) {
- $access = new Access($access_id);
- $access->format();
+ foreach ($list as $access_id) {
+ $access = new Access($access_id);
+ $access->format();
?>
<tr class="<?php echo flip_class(); ?>">
<td><?php echo scrub_out($access->name); ?></td>
diff --git a/templates/show_adds_catalog.inc.php b/templates/show_adds_catalog.inc.php
index 10d96102..fe145026 100644
--- a/templates/show_adds_catalog.inc.php
+++ b/templates/show_adds_catalog.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,9 +22,9 @@
show_box_top();
/* HINT: Catalog Name */
-printf(_('Starting New Song Search on %s catalog'), "<strong>[$this->name]</strong>");
+printf(_('Starting New Song Search on %s catalog'), "<strong>[$this->name]</strong>");
echo "<br />\n";
echo _('Found') . ": <span id=\"add_count_" . $this->id ."\">" . _('None') . "</span><br />\n";
echo _('Reading') . ":<span id=\"add_dir_" . $this->id . "\"></span><br />";
-show_box_bottom();
+show_box_bottom();
?>
diff --git a/templates/show_album_art.inc.php b/templates/show_album_art.inc.php
index e585748a..a279a93a 100644
--- a/templates/show_album_art.inc.php
+++ b/templates/show_album_art.inc.php
@@ -28,29 +28,29 @@ $i = 0;
<?php show_box_top(); ?>
<table class="table-data">
<tr>
-<?php
-while ($i <= $rows) {
+<?php
+while ($i <= $rows) {
$j=0;
- while ($j < 4) {
+ while ($j < 4) {
$key = $i*4+$j;
- $image_url = Config::get('web_path') . '/image.php?type=session&amp;image_index=' . $key;
- $dimensions = Core::image_dimensions(Album::get_image_from_source($_SESSION['form']['images'][$key]));
- if (!isset($images[$key])) { echo "<td>&nbsp;</td>\n"; }
- else {
+ $image_url = Config::get('web_path') . '/image.php?type=session&amp;image_index=' . $key;
+ $dimensions = Core::image_dimensions(Album::get_image_from_source($_SESSION['form']['images'][$key]));
+ if (!isset($images[$key])) { echo "<td>&nbsp;</td>\n"; }
+ else {
?>
<td align="center">
<a href="<?php echo $image_url; ?>" target="_blank"><img src="<?php echo $image_url; ?>" alt="<?php echo _('Album Art'); ?>" border="0" height="175" width="175" /></a>
<br />
<p align="center">
<?php if (is_array($dimensions)) { ?>
- [<?php echo intval($dimensions['width']); ?>x<?php echo intval($dimensions['height']); ?>]
+ [<?php echo intval($dimensions['width']); ?>x<?php echo intval($dimensions['height']); ?>]
<?php } else { ?>
<span class="error"><?php echo _('Invalid'); ?></span>
<?php } ?>
[<a href="<?php echo Config::get('web_path'); ?>/albums.php?action=select_art&amp;image=<?php echo $key; ?>&amp;album_id=<?php echo intval($_REQUEST['album_id']); ?>"><?php echo _('Select'); ?></a>]
</p>
</td>
-<?php
+<?php
} // end else
$j++;
} // end while cells
diff --git a/templates/show_album_row.inc.php b/templates/show_album_row.inc.php
index bcaaa4d5..fe395342 100644
--- a/templates/show_album_row.inc.php
+++ b/templates/show_album_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,7 +25,7 @@
<?php echo Ajax::button('?action=basket&type=album_random&id=' . $album->id,'random',_('Random'),'random_album_' . $album->id); ?>
</td>
<?php
-if (Browse::is_enabled('show_art')) {
+if (Browse::is_enabled('show_art')) {
$name = '[' . $album->f_artist . '] ' . scrub_out($album->full_name);
?>
<td class="cel_cover">
diff --git a/templates/show_albums.inc.php b/templates/show_albums.inc.php
index f854080c..2496c11e 100644
--- a/templates/show_albums.inc.php
+++ b/templates/show_albums.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,7 @@
*/
$web_path = Config::get('web_path');
-$ajax_url = Config::get('ajax_url');
+$ajax_url = Config::get('ajax_url');
?>
<?php require Config::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
@@ -50,17 +50,17 @@ $ajax_url = Config::get('ajax_url');
<th class="col_rating"><?php echo _('Rating'); ?></th>
<th class="cel_action"><?php echo _('Actions'); ?></th>
</tr>
-<?php
- if (Config::get('ratings')) {
- Rating::build_cache('album',$object_ids);
- }
+<?php
+ if (Config::get('ratings')) {
+ Rating::build_cache('album',$object_ids);
+ }
/* Foreach through the albums */
- foreach ($object_ids as $album_id) {
- $album = new Album($album_id);
- $album->format();
+ foreach ($object_ids as $album_id) {
+ $album = new Album($album_id);
+ $album->format();
?>
<tr id="album_<?php echo $album->id; ?>" class="<?php echo flip_class(); ?>">
- <?php require Config::get('prefix') . '/templates/show_album_row.inc.php'; ?>
+ <?php require Config::get('prefix') . '/templates/show_album_row.inc.php'; ?>
</tr>
<?php } //end foreach ($albums as $album) ?>
<?php if (!count($object_ids)) { ?>
diff --git a/templates/show_all_popular.inc.php b/templates/show_all_popular.inc.php
index e4edbd14..ba19e8ac 100644
--- a/templates/show_all_popular.inc.php
+++ b/templates/show_all_popular.inc.php
@@ -1,14 +1,14 @@
<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
/*
-
+
Copyright (c) 2001 - 2006 Ampache.org
- All rights reserved.
+ All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
as published by the Free Software Foundation.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
+
*/
?>
diff --git a/templates/show_alphabet_form.inc.php b/templates/show_alphabet_form.inc.php
index 28fcbd26..65e38350 100644
--- a/templates/show_alphabet_form.inc.php
+++ b/templates/show_alphabet_form.inc.php
@@ -22,7 +22,7 @@
*/
?>
<form style="display:inline;" name="f" method="get" action="<?php echo conf('web_path') . "/$action"; ?>" enctype="multipart/form-data">
- <label for="match" accesskey="S"><?php echo $text; ?></label>
+ <label for="match" accesskey="S"><?php echo $text; ?></label>
<input type="text" size="5" id="match" name="match" value="<?php echo $match; ?>" />
<input type="hidden" name="action" value="<?php echo scrub_out($_REQUEST['action']); ?>">
</form>
diff --git a/templates/show_artist_row.inc.php b/templates/show_artist_row.inc.php
index 23fa0256..c02b27cf 100644
--- a/templates/show_artist_row.inc.php
+++ b/templates/show_artist_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/templates/show_artists.inc.php b/templates/show_artists.inc.php
index 45cefb03..85c079b8 100644
--- a/templates/show_artists.inc.php
+++ b/templates/show_artists.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -43,14 +43,14 @@ $web_path = Config::get('web_path');
<th class="cel_rating"> <?php echo _('Rating'); ?> </th>
<th class="cel_action"> <?php echo _('Action'); ?> </th>
</tr>
-<?php
+<?php
// Cache the ratings we are going to use
-if (Config::get('ratings')) { Rating::build_cache('artist',$object_ids); }
+if (Config::get('ratings')) { Rating::build_cache('artist',$object_ids); }
/* Foreach through every artist that has been passed to us */
-foreach ($object_ids as $artist_id) {
- $artist = new Artist($artist_id);
- $artist->format();
+foreach ($object_ids as $artist_id) {
+ $artist = new Artist($artist_id);
+ $artist->format();
?>
<tr id="artist_<?php echo $artist->id; ?>" class="<?php echo flip_class(); ?>">
<?php require Config::get('prefix') . '/templates/show_artist_row.inc.php'; ?>
diff --git a/templates/show_box_top.inc.php b/templates/show_box_top.inc.php
index bf19987b..45332a8b 100644
--- a/templates/show_box_top.inc.php
+++ b/templates/show_box_top.inc.php
@@ -19,7 +19,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-$class = $class ? $class : 'box';
+$class = $class ? $class : 'box';
?>
<div class="<?php echo $class; ?>">
diff --git a/templates/show_catalog_row.inc.php b/templates/show_catalog_row.inc.php
index 4b4adff4..f61987bb 100644
--- a/templates/show_catalog_row.inc.php
+++ b/templates/show_catalog_row.inc.php
@@ -19,7 +19,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-$web_path = Config::get('web_path');
+$web_path = Config::get('web_path');
?>
<td class="cel_catalog"><?php echo $catalog->f_name_link; ?></td>
<td class="cel_path"><?php echo scrub_out($catalog->f_path); ?></td>
diff --git a/templates/show_catalogs.inc.php b/templates/show_catalogs.inc.php
index fb1f355a..49fe3201 100644
--- a/templates/show_catalogs.inc.php
+++ b/templates/show_catalogs.inc.php
@@ -38,10 +38,10 @@
<th class="cel_lastclean"><?php echo _('Last Clean'); ?></th>
<th class="cel_action"><?php echo _('Actions'); ?></th>
</tr>
-<?php
- foreach ($object_ids as $catalog_id) {
- $catalog = new Catalog($catalog_id);
- $catalog->format();
+<?php
+ foreach ($object_ids as $catalog_id) {
+ $catalog = new Catalog($catalog_id);
+ $catalog->format();
?>
<tr class="<?php echo flip_class(); ?>" id="catalog_<?php echo $catalog->id; ?>">
<?php require Config::get('prefix') . '/templates/show_catalog_row.inc.php'; ?>
diff --git a/templates/show_clean_catalog.inc.php b/templates/show_clean_catalog.inc.php
index 86332d39..60a13c81 100644
--- a/templates/show_clean_catalog.inc.php
+++ b/templates/show_clean_catalog.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,8 +23,8 @@
show_box_top();
/* HINT: Catalog Name */
printf(_('Cleaning the %s Catalog'), "<strong>[" . $this->name . "]</strong>");
-echo "...<br />";
+echo "...<br />";
echo _('Checking') . ": <span id=\"clean_count_" . $this->id . "\"></span>\n<br />";
echo _('Reading') . ":<span id=\"clean_dir_" . $this->id . "\"></span><br />";
-show_box_bottom();
+show_box_bottom();
?>
diff --git a/templates/show_confirmation.inc.php b/templates/show_confirmation.inc.php
index bccf51a6..e183c90e 100644
--- a/templates/show_confirmation.inc.php
+++ b/templates/show_confirmation.inc.php
@@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-$confirmation = Core::form_register($form_name);
+$confirmation = Core::form_register($form_name);
?>
<?php show_box_top(scrub_out($title)); ?>
<?php echo $text; ?>
diff --git a/templates/show_create_democratic.inc.php b/templates/show_create_democratic.inc.php
index ab29dfec..42b7d807 100644
--- a/templates/show_create_democratic.inc.php
+++ b/templates/show_create_democratic.inc.php
@@ -32,7 +32,7 @@ show_box_top(_('Configure Democratic Playlist')); ?>
<td><?php show_playlist_select('democratic',$democratic->base_playlist); ?></td>
</tr>
<tr>
- <td><?php echo _('Cooldown Time'); ?></td>
+ <td><?php echo _('Cooldown Time'); ?></td>
<td><input type="text" size="4" maxlength="6" name="cooldown" value="<?php echo $democratic->cooldown; ?>" /><?php echo _('minutes'); ?></td>
</tr>
<!--
diff --git a/templates/show_debug.inc.php b/templates/show_debug.inc.php
index aa762f73..f575850f 100644
--- a/templates/show_debug.inc.php
+++ b/templates/show_debug.inc.php
@@ -94,18 +94,18 @@
<th class="cel_configuration"><?php echo _('Preference'); ?></th>
<th class="cel_value"><?php echo _('Value'); ?></th>
</tr>
-<?php foreach ($configuration as $key=>$value) {
- if ($key == 'database_password' || $key == 'mysql_password') { $value = '*********'; }
- if (is_array($value)) {
- $string = '';
- foreach ($value as $setting) {
- $string .= $setting . '<br />';
- }
- $value = $string;
- }
- if (Preference::is_boolean($key)) {
- $value = print_boolean($value);
- }
+<?php foreach ($configuration as $key=>$value) {
+ if ($key == 'database_password' || $key == 'mysql_password') { $value = '*********'; }
+ if (is_array($value)) {
+ $string = '';
+ foreach ($value as $setting) {
+ $string .= $setting . '<br />';
+ }
+ $value = $string;
+ }
+ if (Preference::is_boolean($key)) {
+ $value = print_boolean($value);
+ }
?>
<tr class="<?php echo flip_class(); ?>">
<td valign="top"><strong><?php echo $key; ?></strong></td>
diff --git a/templates/show_democratic.inc.php b/templates/show_democratic.inc.php
index ea3410d3..c0f36d5e 100644
--- a/templates/show_democratic.inc.php
+++ b/templates/show_democratic.inc.php
@@ -20,8 +20,8 @@
*/
/* HINT: Democratic Name */
-$string = $democratic->is_enabled() ? sprintf(_('%s Playlist') ,$democratic->name) : _('Democratic Playlist');
-show_box_top($string);
+$string = $democratic->is_enabled() ? sprintf(_('%s Playlist') ,$democratic->name) : _('Democratic Playlist');
+show_box_top($string);
?>
<div id="information_actions">
<ul>
diff --git a/templates/show_democratic_playlist.inc.php b/templates/show_democratic_playlist.inc.php
index 0ca19025..aa7da903 100644
--- a/templates/show_democratic_playlist.inc.php
+++ b/templates/show_democratic_playlist.inc.php
@@ -35,12 +35,12 @@ $web_path = Config::get('web_path');
<?php } ?>
</colgroup>
<?php
-if (!count($object_ids)) {
+if (!count($object_ids)) {
$playlist = new Playlist($democratic->base_playlist);
?>
<tr>
<td>
- <?php echo _('Playing from base Playlist'); ?>:
+ <?php echo _('Playing from base Playlist'); ?>:
<a href="<?php echo $web_path; ?>/playlist.php?action=show_playlist&amp;playlist_id=<?php echo $playlist->id; ?>">
<?php echo scrub_out($playlist->name); ?>
</a>
@@ -62,10 +62,10 @@ else {
<th class="cel_admin"><?php echo _('Admin'); ?></th>
<?php } ?>
</tr>
-<?php
-$democratic = Democratic::get_current_playlist();
-$democratic->set_parent();
-foreach($object_ids as $row_id=>$data) {
+<?php
+$democratic = Democratic::get_current_playlist();
+$democratic->set_parent();
+foreach($object_ids as $row_id=>$data) {
$media = new $data['object_type']($data['object_id']);
$media->format();
?>
@@ -88,9 +88,9 @@ foreach($object_ids as $row_id=>$data) {
</td>
<?php } ?>
</tr>
-<?php
+<?php
} // end foreach
-?>
+?>
<tr class="th-bottom">
<th class="cel_action"><?php echo _('Action'); ?></th>
<th class="cel_votes"><?php echo _('Votes'); ?></th>
diff --git a/templates/show_disabled_songs.inc.php b/templates/show_disabled_songs.inc.php
index e9607de7..9e51c0ad 100644
--- a/templates/show_disabled_songs.inc.php
+++ b/templates/show_disabled_songs.inc.php
@@ -46,7 +46,7 @@
<td class="cel_artist"><?php echo $song->get_artist_name($song->album); ?></td>
<td class="cel_filename"><?php echo $song->file; ?></td>
<td class="cel_additiontime"><?php echo date("h:i:s, m/d/y",$song->addition_time); ?></td>
-
+
</tr>
<?php } if (!count($songs)) { ?>
<tr class="<?php echo flip_class(); ?>">
diff --git a/templates/show_duplicate.inc.php b/templates/show_duplicate.inc.php
index 8dea3fc1..cbdfdae1 100644
--- a/templates/show_duplicate.inc.php
+++ b/templates/show_duplicate.inc.php
@@ -8,7 +8,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
- of the License.
+ of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,7 +27,7 @@
<tr>
<td valign="top"><strong><?php echo _('Search Type'); ?>:</strong></td>
<td>
- <?php
+ <?php
$name = 'check_' . scrub_in($_REQUEST['search_type']);
${$name} = ' checked="checked" ';
?>
diff --git a/templates/show_duplicates.inc.php b/templates/show_duplicates.inc.php
index acc5c209..d22552a6 100644
--- a/templates/show_duplicates.inc.php
+++ b/templates/show_duplicates.inc.php
@@ -32,7 +32,7 @@
<col id="col_bitrate" />
<col id="col_size" />
<col id="col_filename" />
-</colgroup>
+</colgroup>
<tr class="th-top">
<th class="cel_disable"><?php echo _('Disable'); ?></th>
<th class="cel_song"><?php echo _('Song'); ?></th>
@@ -43,18 +43,18 @@
<th class="cel_size"><?php echo _('Size'); ?></th>
<th class="cel_filename"><?php echo _('Filename'); ?></th>
</tr>
-<?php
+<?php
foreach ($duplicates as $item) {
// Gather the duplicates
$songs = Catalog::get_duplicate_info($item,$search_type);
foreach ($songs as $key=>$song_id) {
- $song = new Song($song_id);
- $song->format();
+ $song = new Song($song_id);
+ $song->format();
$row_key = 'duplicate_' . $song_id;
$button_flip_state_id = 'button_flip_state_' . $song_id;
- $current_class = ($key == '0') ? 'row-highlight' : flip_class();
- $button = $song->enabled ? 'disable' : 'enable';
+ $current_class = ($key == '0') ? 'row-highlight' : flip_class();
+ $button = $song->enabled ? 'disable' : 'enable';
?>
<tr id="<?php echo $row_key; ?>" class="<?php echo $current_class; ?>">
<td class="cel_disable" id="<?php echo($button_flip_state_id); ?>">
@@ -68,8 +68,8 @@
<td class="cel_size"><?php echo $song->f_size; ?>MB</td>
<td class="cel_filename"><?php echo scrub_out($song->file); ?></td>
</tr>
-<?php
- } // end foreach ($dinfolist as $dinfo)
+<?php
+ } // end foreach ($dinfolist as $dinfo)
} // end foreach ($flags as $flag)
?>
<tr class="th-bottom">
diff --git a/templates/show_edit_album_row.inc.php b/templates/show_edit_album_row.inc.php
index 8ccbdecd..0f4d5324 100644
--- a/templates/show_edit_album_row.inc.php
+++ b/templates/show_edit_album_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -28,17 +28,17 @@
<input type="text" name="name" value="<?php echo scrub_out($album->full_name); ?>" />
</td>
<td>
- <?php
- if ($album->artist_count == '1') {
- show_artist_select('artist',$album->artist_id);
- }
- else {
- echo _('Various');
- }
+ <?php
+ if ($album->artist_count == '1') {
+ show_artist_select('artist',$album->artist_id);
+ }
+ else {
+ echo _('Various');
+ }
?>
</td>
<td>
- <input type="text" name="year" value="<?php echo scrub_out($album->year); ?>" />
+ <input type="text" name="year" value="<?php echo scrub_out($album->year); ?>" />
</td>
<td>
<input type="text" name="disk" value="<?php echo scrub_out($album->disk); ?>" />
diff --git a/templates/show_edit_artist_row.inc.php b/templates/show_edit_artist_row.inc.php
index 25b5d2f3..341f4b9e 100644
--- a/templates/show_edit_artist_row.inc.php
+++ b/templates/show_edit_artist_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/templates/show_edit_catalog.inc.php b/templates/show_edit_catalog.inc.php
index 2615ee55..56c8de13 100644
--- a/templates/show_edit_catalog.inc.php
+++ b/templates/show_edit_catalog.inc.php
@@ -34,7 +34,7 @@
%T = <?php echo _('track number (padded with leading 0)'); ?><br />
%t = <?php echo _('song title'); ?><br />
%y = <?php echo _('year'); ?><br />
- %o = <?php echo _('other'); ?><br />
+ %o = <?php echo _('other'); ?><br />
</td>
</tr>
<tr>
diff --git a/templates/show_edit_live_stream_row.inc.php b/templates/show_edit_live_stream_row.inc.php
index 5d92a032..cf5b903e 100644
--- a/templates/show_edit_live_stream_row.inc.php
+++ b/templates/show_edit_live_stream_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/templates/show_edit_playlist_row.inc.php b/templates/show_edit_playlist_row.inc.php
index 2f9c87b8..3bb3cd5a 100644
--- a/templates/show_edit_playlist_row.inc.php
+++ b/templates/show_edit_playlist_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,8 +27,8 @@
<td>
<input type="text" name="name" size="9" value="<?php echo scrub_out($playlist->name); ?>" />
</td>
- <td>
- <?php $name = 'select_' . $playlist->type; ${$name} = ' selected="selected"'; ?>
+ <td>
+ <?php $name = 'select_' . $playlist->type; ${$name} = ' selected="selected"'; ?>
<select name="pl_type">
<option value="public"<?php echo $select_public; ?>><?php echo _('Public'); ?></option>
<option value="private"<?php echo $select_private; ?>><?php echo _('Private'); ?></option>
@@ -39,7 +39,7 @@
<?php echo Ajax::button('?action=edit_object&id=' . $playlist->id . '&type=playlist','download',_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?>
</td>
</tr>
-</table>
+</table>
</form>
</td>
diff --git a/templates/show_edit_playlist_song_row.inc.php b/templates/show_edit_playlist_song_row.inc.php
index 6a07be07..3db69d78 100644
--- a/templates/show_edit_playlist_song_row.inc.php
+++ b/templates/show_edit_playlist_song_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/templates/show_edit_song_row.inc.php b/templates/show_edit_song_row.inc.php
index db57fe56..40c8e57f 100644
--- a/templates/show_edit_song_row.inc.php
+++ b/templates/show_edit_song_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/templates/show_export.inc.php b/templates/show_export.inc.php
index 74f753aa..3ad6fb8a 100644
--- a/templates/show_export.inc.php
+++ b/templates/show_export.inc.php
@@ -8,7 +8,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
- of the License.
+ of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,10 +21,10 @@
*/
-$name = 'export_' . $_REQUEST['export_format'];
+$name = 'export_' . $_REQUEST['export_format'];
+${$name} = ' selected="selected"';
+$name = 'catalog_' . $_REQUEST['export_catalog'];
${$name} = ' selected="selected"';
-$name = 'catalog_' . $_REQUEST['export_catalog'];
-${$name} = ' selected="selected"';
show_box_top(_('Export Catalog')); ?>
<form name="duplicates" action="<?php echo Config::get('web_path'); ?>/admin/export.php?action=export" method="post" enctype="multipart/form-data" >
@@ -35,11 +35,11 @@ show_box_top(_('Export Catalog')); ?>
<select id="export_catalog" name="export_catalog">
<option value=""><?php echo _('All'); ?></option>
<?php
- $catalog_ids = Catalog::get_catalogs();
+ $catalog_ids = Catalog::get_catalogs();
foreach ($catalog_ids as $catalog_id) {
$catalog = new Catalog($catalog_id);
- $current_name = 'catalog_' . $catalog->id;
-
+ $current_name = 'catalog_' . $catalog->id;
+
?>
<option value="<?php echo $catalog->id; ?>"<?php echo ${$current_name}; ?>><?php echo scrub_out($catalog->name); ?></option>
<?php
diff --git a/templates/show_flagged.inc.php b/templates/show_flagged.inc.php
index e6adb385..29cadf9e 100644
--- a/templates/show_flagged.inc.php
+++ b/templates/show_flagged.inc.php
@@ -39,11 +39,11 @@ $web_path = Config::get('web_path');
<th class="cel_status"><?php echo _('Status'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
-<?php
-foreach ($object_ids as $flag_id) {
- $flag = new Flag($flag_id);
- $flag->format();
- require Config::get('prefix') . '/templates/show_flag_row.inc.php';
+<?php
+foreach ($object_ids as $flag_id) {
+ $flag = new Flag($flag_id);
+ $flag->format();
+ require Config::get('prefix') . '/templates/show_flag_row.inc.php';
?>
<?php } if (!count($object_ids)) { ?>
<tr class="<?php echo flip_class(); ?>">
diff --git a/templates/show_gather_art.inc.php b/templates/show_gather_art.inc.php
index 7fa701ca..59697657 100644
--- a/templates/show_gather_art.inc.php
+++ b/templates/show_gather_art.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,5 +24,5 @@ show_box_top();
echo "<strong>" . _('Starting Album Art Search') . ". . .</strong><br />\n";
echo _('Searched') . ": <span id=\"count_art_" . $catalog_id . "\">" . _('None') . "</span><br />";
echo _('Reading') . ":<span id=\"read_art_$catalog_id\"></span><br />";
-show_box_bottom();
+show_box_bottom();
?>
diff --git a/templates/show_genre.inc.php b/templates/show_genre.inc.php
index b480d6c7..bf637244 100644
--- a/templates/show_genre.inc.php
+++ b/templates/show_genre.inc.php
@@ -29,7 +29,7 @@ $web_path = Config::get('web_path');
?>
<?php /* HINT: Genre Name */ ?>
<?php show_box_top(sprintf(_('Viewing %s Genre'), $genre->name)); ?>
- [<?php echo $genre->get_album_count(); ?>]
+ [<?php echo $genre->get_album_count(); ?>]
<a href="<?php echo $web_path; ?>/genre.php?action=show_albums&amp;genre_id=<?php echo $genre->id; ?>">
<?php echo _('Albums'); ?></a><br />
[<?php echo $genre->get_artist_count(); ?>]
diff --git a/templates/show_genres.inc.php b/templates/show_genres.inc.php
index fd7a6af7..9195098f 100644
--- a/templates/show_genres.inc.php
+++ b/templates/show_genres.inc.php
@@ -39,9 +39,9 @@
<th class="cel_songs"><?php echo _('Songs'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
-<?php
-foreach ($object_ids as $genre_id) {
- $genre = new Genre($genre_id);
+<?php
+foreach ($object_ids as $genre_id) {
+ $genre = new Genre($genre_id);
$genre->format();
?>
<tr class="<?php echo flip_class(); ?>">
diff --git a/templates/show_import_playlist.inc.php b/templates/show_import_playlist.inc.php
index 21d60379..12e6ccca 100644
--- a/templates/show_import_playlist.inc.php
+++ b/templates/show_import_playlist.inc.php
@@ -28,7 +28,7 @@
<td>
<?php echo _('Filename'); ?>:
</td>
- <td><input type="file" name="filename" value="<?php echo scrub_out($_REQUEST['filename']); ?>" size="45" /></td>
+ <td><input type="file" name="filename" value="<?php echo scrub_out($_REQUEST['filename']); ?>" size="45" /></td>
</tr>
<tr>
<td>
diff --git a/templates/show_index.inc.php b/templates/show_index.inc.php
index ea00693a..dce60143 100644
--- a/templates/show_index.inc.php
+++ b/templates/show_index.inc.php
@@ -23,31 +23,31 @@
<div id="now_playing">
<?php show_now_playing(); ?>
</div> <!-- Close Now Playing Div -->
-<!-- Randomly selected albums of the moment -->
-<?php
-if (Browse::is_enabled('show_art')) {
- echo Ajax::observe('window','load',Ajax::action('?page=index&action=random_albums','random_albums'));
+<!-- Randomly selected albums of the moment -->
+<?php
+if (Browse::is_enabled('show_art')) {
+ echo Ajax::observe('window','load',Ajax::action('?page=index&action=random_albums','random_albums'));
?>
<div id="random_selection">
<?php show_box_top(_('Albums of the Moment')); echo _('Loading...'); show_box_bottom(); ?>
-</div>
+</div>
<?php } ?>
<!-- Recently Played -->
<div id="recently_played">
<?php
$data = Song::get_recently_played();
- Song::build_cache(array_keys($data));
- require_once Config::get('prefix') . '/templates/show_recently_played.inc.php';
+ Song::build_cache(array_keys($data));
+ require_once Config::get('prefix') . '/templates/show_recently_played.inc.php';
?>
</div>
-<!-- Shoutbox Objects, if shoutbox is enabled -->
+<!-- Shoutbox Objects, if shoutbox is enabled -->
<?php if (Config::get('sociable')) { ?>
<div id="shout_objects">
- <?php
- $shouts = shoutBox::get_top('5');
- if (count($shouts)) {
- require_once Config::get('prefix') . '/templates/show_shoutbox.inc.php';
- }
+ <?php
+ $shouts = shoutBox::get_top('5');
+ if (count($shouts)) {
+ require_once Config::get('prefix') . '/templates/show_shoutbox.inc.php';
+ }
?>
</div>
<?php } ?>
diff --git a/templates/show_install.inc.php b/templates/show_install.inc.php
index d3421f74..250219f3 100644
--- a/templates/show_install.inc.php
+++ b/templates/show_install.inc.php
@@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-if (INSTALL != '1') { exit; }
+if (INSTALL != '1') { exit; }
$prefix = realpath(dirname(__FILE__). "/../");
$dir = is_rtl($htmllang) ? 'rtl' : 'ltr';
?>
@@ -32,7 +32,7 @@ $dir = is_rtl($htmllang) ? 'rtl' : 'ltr';
</head>
<body>
<script src="lib/javascript-base.js" language="javascript" type="text/javascript"></script>
-<div id="header">
+<div id="header">
<h1><?php echo _("Ampache Installation"); ?></h1>
<p>Pour l'Amour de la Musique</p>
</div>
@@ -51,7 +51,7 @@ $dir = is_rtl($htmllang) ? 'rtl' : 'ltr';
<?php echo sprintf(_('Once you have ensured that you have the above requirements please fill out the information below. You will only be asked for the required config values. If you would like to make changes to your ampache install at a later date simply edit %s'),$prefix . '/config/ampache.cfg.php'); ?>
</p>
</div>
-
+
<div class="content">
<strong><?php echo _("Step 1 - Creating and Inserting the Ampache Database"); ?></strong><br />
<dl>
@@ -106,7 +106,7 @@ $dir = is_rtl($htmllang) ? 'rtl' : 'ltr';
<td><input type="submit" value="<?php echo _("Insert Database"); ?>" /></td>
</tr>
</table>
-</form>
+</form>
</div>
<div id="bottom">
<p><strong>Ampache Installation.</strong><br />
diff --git a/templates/show_install_account.inc.php b/templates/show_install_account.inc.php
index 15eb76f7..ef1a9676 100644
--- a/templates/show_install_account.inc.php
+++ b/templates/show_install_account.inc.php
@@ -31,7 +31,7 @@ $prefix = realpath(dirname(__FILE__). "/../");
<meta http-equiv="Content-Type" content="text/html; Charset=<?php echo $charset; ?>" />
</head>
<body>
-<div id="header">
+<div id="header">
<h1><?php echo _("Ampache Installation"); ?></h1>
<p>For the love of Music</p>
</div>
diff --git a/templates/show_install_check.inc.php b/templates/show_install_check.inc.php
index 16aee4cd..db67fdc2 100644
--- a/templates/show_install_check.inc.php
+++ b/templates/show_install_check.inc.php
@@ -26,12 +26,12 @@
<tr>
<td><?php echo sprintf(_("%s is readable"),"ampache.cfg.php.dist"); ?></td>
<td>
-<?php
- if (!is_readable($prefix . '/config/ampache.cfg.php.dist')) {
+<?php
+ if (!is_readable($prefix . '/config/ampache.cfg.php.dist')) {
echo debug_result('',false);
- Error::add('install',sprintf(_("%s is readable"),"ampache.cfg.php.dist"));
+ Error::add('install',sprintf(_("%s is readable"),"ampache.cfg.php.dist"));
}
- else {
+ else {
echo debug_result('',true);
}
?>
@@ -43,18 +43,18 @@
<?php
if(!check_php_ver()) {
if (function_exists('hash_algos')) { $algos = hash_algos(); }
- if (strtoupper(substr(PHP_OS,0,3)) == 'WIN') {
+ if (strtoupper(substr(PHP_OS,0,3)) == 'WIN') {
$version_string = phpversion() . " < PHP 5.3 ";
- }
- else {
- $version_string = phpversion() . " ";
- }
+ }
+ else {
+ $version_string = phpversion() . " ";
+ }
$string = $version_string . _('Hash Function Exists') . " " . print_boolean(function_exists('hash_algos')) . " " . _('SHA256 Support') . " " . print_boolean(in_array('sha256',$algos));
- echo debug_result($string,false);
- Error::add('install',_('PHP Version'));
- }
- else {
- echo debug_result(phpversion(),true);
+ echo debug_result($string,false);
+ Error::add('install',_('PHP Version'));
+ }
+ else {
+ echo debug_result(phpversion(),true);
}
?>
</td>
@@ -63,11 +63,11 @@
<td>
<?php
if (!check_php_mysql()) {
- echo debug_result('',false);
- Error::add('install',_('Mysql for PHP'));
- }
+ echo debug_result('',false);
+ Error::add('install',_('Mysql for PHP'));
+ }
else {
- echo debug_result(mysql_get_client_info(),true);
+ echo debug_result(mysql_get_client_info(),true);
}
?>
</td>
@@ -76,11 +76,11 @@
<td>
<?php
if (!check_php_session()) {
- echo debug_result('',false);
- Error::add('install',_('PHP Session Support'));
- }
+ echo debug_result('',false);
+ Error::add('install',_('PHP Session Support'));
+ }
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
</td>
@@ -89,11 +89,11 @@
<td>
<?php
if (!check_php_iconv()) {
- echo debug_result('',false);
- Error::add('install',_('PHP ICONV Support'));
- }
+ echo debug_result('',false);
+ Error::add('install',_('PHP ICONV Support'));
+ }
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
</td>
@@ -102,11 +102,11 @@
<td>
<?php
if (!check_php_pcre()) {
- echo debug_result('',false);
- Error::add('install',_('PHP PCRE Support'));
- }
+ echo debug_result('',false);
+ Error::add('install',_('PHP PCRE Support'));
+ }
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
</td>
@@ -115,11 +115,11 @@
<td>
<?php
if (!check_putenv()) {
- echo debug_result('',false);
- Error::add('install',_('PHP PutENV Support'));
- }
+ echo debug_result('',false);
+ Error::add('install',_('PHP PutENV Support'));
+ }
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
</td>
@@ -129,11 +129,11 @@
<td><?php echo _('Gettext Support'); ?>:</td>
<td>
<?php
- if (!check_gettext()) {
- echo debug_result(_('Gettext Emulator will be used'),false);
- }
+ if (!check_gettext()) {
+ echo debug_result(_('Gettext Emulator will be used'),false);
+ }
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
</td>
@@ -141,24 +141,24 @@
<td><?php echo _('Mbstring Support'); ?>:</td>
<td>
<?php
- if (!check_mbstring()) {
- echo debug_result(_('Multibyte Character may not detect correct'),false);
- }
+ if (!check_mbstring()) {
+ echo debug_result(_('Multibyte Character may not detect correct'),false);
+ }
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
</td>
</tr><tr>
<td><?php echo _('PHP Memory Limit'); ?>:</td>
<td>
-<?php
- if (!check_php_memory()) {
- echo debug_result(_('Memory Limit less then recommended size') . ' ' . ini_get('memory_limit'),false);
- }
- else {
- echo debug_result(ini_get('memory_limit'),true);
- }
+<?php
+ if (!check_php_memory()) {
+ echo debug_result(_('Memory Limit less then recommended size') . ' ' . ini_get('memory_limit'),false);
+ }
+ else {
+ echo debug_result(ini_get('memory_limit'),true);
+ }
?>
</td>
@@ -166,12 +166,12 @@
<td><?php echo _('PHP Execution timelimit'); ?>:</td>
<td>
<?php
- if (!check_php_timelimit()) {
- echo debug_result(_('Execution timelimit less the recommended') . ' ' . ini_get('max_execution_time'),false);
+ if (!check_php_timelimit()) {
+ echo debug_result(_('Execution timelimit less the recommended') . ' ' . ini_get('max_execution_time'),false);
+ }
+ else {
+ echo debug_result(ini_get('max_execution_time') . ' ' . _('seconds'),true);
}
- else {
- echo debug_result(ini_get('max_execution_time') . ' ' . _('seconds'),true);
- }
?>
</td>
</tr>
diff --git a/templates/show_install_config.inc.php b/templates/show_install_config.inc.php
index cbfc7cfd..4ab55bda 100644
--- a/templates/show_install_config.inc.php
+++ b/templates/show_install_config.inc.php
@@ -20,7 +20,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-if (INSTALL != '1') { exit; }
+if (INSTALL != '1') { exit; }
$prefix = realpath(dirname(__FILE__). "/../");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -31,7 +31,7 @@ $prefix = realpath(dirname(__FILE__). "/../");
<meta http-equiv="Content-Type" content="text/html; Charset=<?php echo $charset; ?>" />
</head>
<body>
-<div id="header">
+<div id="header">
<h1><?php echo _('Ampache Installation'); ?></h1>
<p>Pour l'Amour de la Musique</p>
</div>
@@ -92,13 +92,13 @@ $prefix = realpath(dirname(__FILE__). "/../");
<table>
<tr>
<td class="align"><?php echo _('Ampache.cfg.php Exists'); ?></td>
- <td>[
+ <td>[
<?php
if (!is_readable($configfile)) {
- echo debug_result('',false);
+ echo debug_result('',false);
}
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
]
@@ -108,14 +108,14 @@ $prefix = realpath(dirname(__FILE__). "/../");
<td class="align">
<?php echo _('Ampache.cfg.php Configured?'); ?>
</td>
- <td>[
+ <td>[
<?php
$results = @parse_ini_file($configfile);
- if (!check_config_values($results)) {
- echo debug_result('',false);
+ if (!check_config_values($results)) {
+ echo debug_result('',false);
}
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
]
diff --git a/templates/show_install_lang.inc.php b/templates/show_install_lang.inc.php
index 9fd10abc..581af634 100644
--- a/templates/show_install_lang.inc.php
+++ b/templates/show_install_lang.inc.php
@@ -32,7 +32,7 @@ $prefix = realpath(dirname(__FILE__). "/../");
</head>
<body>
<script src="lib/javascript-base.js" language="javascript" type="text/javascript"></script>
-<div id="header">
+<div id="header">
<h1><?php echo _('Ampache Installation'); ?></h1>
<p>For the love of Music</p>
</div>
diff --git a/templates/show_ip_history.inc.php b/templates/show_ip_history.inc.php
index 922884d9..8a3abfe7 100644
--- a/templates/show_ip_history.inc.php
+++ b/templates/show_ip_history.inc.php
@@ -25,7 +25,7 @@
<div id="information_actions">
<ul>
<li>
-<?php if (isset($_REQUEST['all'])){ ?>
+<?php if (isset($_REQUEST['all'])){ ?>
<a href="<?php echo Config::get('web_path')?>/admin/users.php?action=show_ip_history&user_id=<?php echo $working_user->id?>"><?php echo get_user_icon('disable'); ?></a>
<?php echo _('Show Unique'); ?>
<?php }else{ ?>
diff --git a/templates/show_live_stream_row.inc.php b/templates/show_live_stream_row.inc.php
index df6ec43c..c73d0176 100644
--- a/templates/show_live_stream_row.inc.php
+++ b/templates/show_live_stream_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/templates/show_live_streams.inc.php b/templates/show_live_streams.inc.php
index 16cdecf8..5fe8e6d3 100644
--- a/templates/show_live_streams.inc.php
+++ b/templates/show_live_streams.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -37,13 +37,13 @@ $web_path = Config::get('web_path');
<th class="cel_streamname"><?php echo Ajax::text('?page=browse&action=set_sort&sort=name',_('Name'),'live_stream_sort_name'); ?></th>
<th class="cel_callsign"><?php echo Ajax::text('?page=browse&action=set_sort&sort=call_sign',_('Callsign'),'live_stream_call_sign'); ?></th>
<th class="cel_frequency"><?php echo Ajax::text('?page=browse&action=set_sort&sort=frequency',_('Frequency'),'live_stream_frequency'); ?></th>
- <th class="cel_genre"><?php echo _('Tag'); ?></th>
+ <th class="cel_genre"><?php echo _('Tag'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?> </th>
</tr>
-<?php
-foreach ($object_ids as $radio_id) {
- $radio = new Radio($radio_id);
- $radio->format();
+<?php
+foreach ($object_ids as $radio_id) {
+ $radio = new Radio($radio_id);
+ $radio->format();
?>
<tr id="live_stream_<?php echo $radio->id; ?>" class="<?php echo flip_class(); ?>">
<?php require Config::get('prefix') . '/templates/show_live_stream_row.inc.php'; ?>
@@ -59,7 +59,7 @@ foreach ($object_ids as $radio_id) {
<th class="cel_streamname"><?php echo Ajax::text('?page=browse&action=set_sort&sort=name',_('Name'),'live_stream_sort_name_bottom'); ?></th>
<th class="cel_callsign"><?php echo Ajax::text('?page=browse&action=set_sort&sort=call_sign',_('Callsign'),'live_stream_call_sign_bottom'); ?></th>
<th class="cel_frequency"><?php echo Ajax::text('?page=browse&action=set_sort&sort=frequency',_('Frequency'),'live_stream_frequency_bottom'); ?></th>
- <th class="cel_genre"><?php echo _('Tag'); ?></th>
+ <th class="cel_genre"><?php echo _('Tag'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?> </th>
</tr>
</table>
diff --git a/templates/show_localplay_controllers.inc.php b/templates/show_localplay_controllers.inc.php
index dd4b90c4..8df25762 100644
--- a/templates/show_localplay_controllers.inc.php
+++ b/templates/show_localplay_controllers.inc.php
@@ -19,9 +19,9 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-$web_path = Config::get('web_path');
+$web_path = Config::get('web_path');
?>
-<!-- Plugin we've found -->
+<!-- Plugin we've found -->
<table class="tabledata" cellpadding="0" cellspacing="0">
<colgroup>
<col id="col_name" />
@@ -35,19 +35,19 @@ $web_path = Config::get('web_path');
<th class="cel_version"><?php echo _('Version'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
-<?php
-foreach ($controllers as $controller) {
- $localplay = new Localplay($controller);
- if (!$localplay->player_loaded()) { continue; }
- $localplay->format();
- if (Localplay::is_enabled($controller)) {
- $action = 'confirm_uninstall_localplay';
- $action_txt = _('Disable');
- }
- else {
+<?php
+foreach ($controllers as $controller) {
+ $localplay = new Localplay($controller);
+ if (!$localplay->player_loaded()) { continue; }
+ $localplay->format();
+ if (Localplay::is_enabled($controller)) {
+ $action = 'confirm_uninstall_localplay';
+ $action_txt = _('Disable');
+ }
+ else {
$action = 'install_localplay';
$action_txt = _('Activate');
- }
+ }
?>
<tr class="<?php echo flip_class(); ?>">
<td class="cel_name"><?php echo scrub_out($localplay->f_name); ?></td>
diff --git a/templates/show_localplay_instances.inc.php b/templates/show_localplay_instances.inc.php
index 2a9831a2..a3471c1d 100644
--- a/templates/show_localplay_instances.inc.php
+++ b/templates/show_localplay_instances.inc.php
@@ -26,10 +26,10 @@
<tr>
<?php foreach ($fields as $key=>$field) { ?>
<th><?php echo $field['description']; ?></th>
- <?php } ?>
+ <?php } ?>
<th><?php echo _('Action'); ?></th>
</tr>
-<?php foreach ($instances as $uid=>$name) {
+<?php foreach ($instances as $uid=>$name) {
$instance = $localplay->get_instance($uid);
?>
<tr class="<?php echo flip_class(); ?>" id="localplay_instance_<?php echo $uid; ?>">
diff --git a/templates/show_localplay_playlist.inc.php b/templates/show_localplay_playlist.inc.php
index 9459af3d..4331256f 100644
--- a/templates/show_localplay_playlist.inc.php
+++ b/templates/show_localplay_playlist.inc.php
@@ -20,8 +20,8 @@
*/
$localplay = new Localplay(Config::get('localplay_controller'));
-$localplay->connect();
-$status = $localplay->status();
+$localplay->connect();
+$status = $localplay->status();
?>
<?php require Config::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
@@ -35,10 +35,10 @@ $status = $localplay->status();
<th class="cel_name"><?php echo _('Name'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
-<?php
-foreach ($object_ids as $object) {
+<?php
+foreach ($object_ids as $object) {
$class = ' class="cel_name"';
- if ($status['track'] == $object['track']) { $class=' class="cel_name lp_current"'; }
+ if ($status['track'] == $object['track']) { $class=' class="cel_name lp_current"'; }
?>
<tr class="<?php echo flip_class(); ?>" id="localplay_playlist_<?php echo $object['id']; ?>">
<td class="cel_track">
diff --git a/templates/show_localplay_status.inc.php b/templates/show_localplay_status.inc.php
index bb140602..3117efc1 100644
--- a/templates/show_localplay_status.inc.php
+++ b/templates/show_localplay_status.inc.php
@@ -20,8 +20,8 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-$status = $localplay->status();
-$now_playing = $status['track_title'] ? $status['track_title'] . ' - ' . $status['track_album'] . ' - ' . $status['track_artist'] : '';
+$status = $localplay->status();
+$now_playing = $status['track_title'] ? $status['track_title'] . ' - ' . $status['track_album'] . ' - ' . $status['track_artist'] : '';
?>
<?php Ajax::start_container('localplay_status'); ?>
<?php show_box_top(_('Localplay Control') . ' - '. strtoupper($localplay->type)); ?>
@@ -35,12 +35,12 @@ $now_playing = $status['track_title'] ? $status['track_title'] . ' - ' . $status
<?php echo _('Volume'); ?>:<?php echo $status['volume']; ?>%
</li>
<li>
- <?php echo print_boolean($status['repeat']); ?> |
+ <?php echo print_boolean($status['repeat']); ?> |
<?php echo Ajax::text('?page=localplay&action=repeat&value=' . invert_boolean($status['repeat']),print_boolean(invert_boolean($status['repeat'])),'localplay_repeat'); ?>
<?php echo _('Repeat'); ?>
</li>
<li>
- <?php echo print_boolean($status['random']); ?> |
+ <?php echo print_boolean($status['random']); ?> |
<?php echo Ajax::text('?page=localplay&action=random&value=' . invert_boolean($status['random']),print_boolean(invert_boolean($status['random'])),'localplay_random'); ?>
<?php echo _('Random'); ?>
</li>
diff --git a/templates/show_login_form.inc.php b/templates/show_login_form.inc.php
index b38cce8a..dbf0f0ad 100644
--- a/templates/show_login_form.inc.php
+++ b/templates/show_login_form.inc.php
@@ -20,9 +20,9 @@
*/
/* Check and see if their remember me is the same or lower then local
- * if so disable the checkbox
+ * if so disable the checkbox
*/
-if (Config::get('session_length') >= Config::get('remember_length')) {
+if (Config::get('session_length') >= Config::get('remember_length')) {
$remember_disabled = 'disabled="disabled"';
}
$htmllang = str_replace("_","-",Config::get('lang'));
@@ -56,11 +56,11 @@ function focus(){ document.login.username.focus(); }
<form name="login" method="post" enctype="multipart/form-data" action="<?php echo Config::get('web_path'); ?>/login.php">
<div class="loginfield" id="usernamefield">
- <label for="username"><?php echo _('Username'); ?>:</label>
+ <label for="username"><?php echo _('Username'); ?>:</label>
<input class="text_input" type="text" id="username" name="username" value="<?php echo $_REQUEST['username']; ; ?>" />
</div>
<div class="loginfield" id="passwordfield">
- <label for="password"><?php echo _('Password'); ?>:</label>
+ <label for="password"><?php echo _('Password'); ?>:</label>
<input class="text_input" type="password" id="password" name="password" value="" />
</div>
<div class="loginfield" id="remembermefield"><label for="rememberme">
@@ -75,12 +75,12 @@ function focus(){ document.login.username.focus(); }
<input class="button" id="loginbutton" type="submit" value="<?php echo _('Login'); ?>" />
<input type="hidden" name="referrer" value="<?php echo scrub_out($_SERVER['HTTP_REFERRER']); ?>" />
<input type="hidden" name="action" value="login" />
-
+
<?php if (Config::get('allow_public_registration')) { ?>
<a class="button" id="registerbutton" href="<?php echo Config::get('web_path'); ?>/register.php"><?php echo _('Register'); ?></a>
<?php } // end if (conf('allow_public_registration')) ?>
</div>
-
+
</form>
</div>
</div>
diff --git a/templates/show_mail_users.inc.php b/templates/show_mail_users.inc.php
index b656ce06..5a328b5d 100644
--- a/templates/show_mail_users.inc.php
+++ b/templates/show_mail_users.inc.php
@@ -37,7 +37,7 @@
</tr>
<!--
<tr>
- <td colspan="2">
+ <td colspan="2">
<table>
<tr>
<td><?php echo _('Catalog Statistics'); ?>:</td>
@@ -60,7 +60,7 @@
<input type="checkbox" name="pop_artists" value="yes" />
</td>
</tr>
-
+
<tr>
<td><?php echo _('Latest Album Additions'); ?>:</td>
<td>
diff --git a/templates/show_manage_catalogs.inc.php b/templates/show_manage_catalogs.inc.php
index b3850e72..8ea5f460 100644
--- a/templates/show_manage_catalogs.inc.php
+++ b/templates/show_manage_catalogs.inc.php
@@ -47,7 +47,7 @@
</table>
</div>
<?php show_box_bottom(); ?>
-<?php
+<?php
$catalog_ids = Catalog::get_catalogs();
Browse::set_type('catalog');
Browse::set_static_content(1);
diff --git a/templates/show_manage_democratic.inc.php b/templates/show_manage_democratic.inc.php
index b556d333..70e84d4a 100644
--- a/templates/show_manage_democratic.inc.php
+++ b/templates/show_manage_democratic.inc.php
@@ -41,11 +41,11 @@ show_box_top(_('Manage Democratic Playlists')); ?>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
<?php
- foreach ($playlists as $democratic_id) {
- $democratic = new Democratic($democratic_id);
- $democratic->format();
- $playlist = new Playlist($democratic->base_playlist);
- $playlist->format();
+ foreach ($playlists as $democratic_id) {
+ $democratic = new Democratic($democratic_id);
+ $democratic->format();
+ $playlist = new Playlist($democratic->base_playlist);
+ $playlist->format();
?>
<tr class="<?php echo flip_class(); ?>">
<td><?php echo scrub_out($democratic->name); ?></td>
diff --git a/templates/show_manage_shoutbox.inc.php b/templates/show_manage_shoutbox.inc.php
index 178c02a9..c4f38c96 100644
--- a/templates/show_manage_shoutbox.inc.php
+++ b/templates/show_manage_shoutbox.inc.php
@@ -39,16 +39,16 @@ $web_path = Config::get('web_path');
<th class="cel_date"><?php echo _('Date Added'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
-<?php
-foreach ($object_ids as $shout_id) {
- $shout = new shoutBox($shout_id);
+<?php
+foreach ($object_ids as $shout_id) {
+ $shout = new shoutBox($shout_id);
$shout->format();
$object = shoutBox::get_object($shout->object_type,$shout->object_id);
$object->format();
$client = new User($shout->user);
$client->format();
- require Config::get('prefix') . '/templates/show_shout_row.inc.php';
+ require Config::get('prefix') . '/templates/show_shout_row.inc.php';
?>
<?php } if (!count($object_ids)) { ?>
<tr class="<?php echo flip_class(); ?>">
diff --git a/templates/show_now_playing.inc.php b/templates/show_now_playing.inc.php
index 6b06221d..05b3f828 100644
--- a/templates/show_now_playing.inc.php
+++ b/templates/show_now_playing.inc.php
@@ -29,10 +29,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
if (count($results)) {
-$link = Config::get('use_rss') ? ' ' . AmpacheRSS::get_display('nowplaying') : '';
+$link = Config::get('use_rss') ? ' ' . AmpacheRSS::get_display('nowplaying') : '';
?>
<?php show_box_top(_('Now Playing') . $link); ?>
-<?php
+<?php
foreach ($results as $item) {
$media = $item['media'];
$np_user = $item['client'];
diff --git a/templates/show_object_rating.inc.php b/templates/show_object_rating.inc.php
index 9d1ba585..cc917a12 100644
--- a/templates/show_object_rating.inc.php
+++ b/templates/show_object_rating.inc.php
@@ -30,14 +30,14 @@ $base_url = '?action=set_rating&rating_type=' . $rating->type . '&object_id=' .
// decide width of rating (5 stars -> 20% per star)
$width = $rating->preciserating*20;
if ($width < 0) $width = 0;
-
- //set the current rating background
+
+ //set the current rating background
echo "<li class=\"current-rating\" style=\"width:${width}%\" >" . _('Current rating: ');
if ($rating->rating <= 0) {
echo _('not rated yet') . "</li>\n";
}
else printf(_('%s of 5'), $rating->preciserating); echo "</li>\n";
-
+
for ($i=1; $i<6; $i++)
{
?>
diff --git a/templates/show_object_rating_static.inc.php b/templates/show_object_rating_static.inc.php
index 3c2eb640..c45b3ac5 100644
--- a/templates/show_object_rating_static.inc.php
+++ b/templates/show_object_rating_static.inc.php
@@ -30,14 +30,14 @@ $base_url = Config::get('ajax_url') . '?action=set_rating&amp;rating_type=' . $r
// decide width of rating (5 stars -> 20% per star)
$width = $rating->preciserating*20;
if ($width < 0) $width = 0;
-
+
//set the current rating background
echo "<li class=\"current-rating\" style=\"width:${width}%\" >" . _('Current rating: ');
if ($rating->rating <= 0) {
echo _('not rated yet') . "</li>\n";
}
else printf(_('%s of 5') ,$rating->preciserating); echo "</li>\n";
-
+
for ($i=1; $i<6; $i++)
{
?>
diff --git a/templates/show_object_row.inc.php b/templates/show_object_row.inc.php
index 66f2f4c0..b5f4eac4 100644
--- a/templates/show_object_row.inc.php
+++ b/templates/show_object_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,7 +20,7 @@
*/
/**
- * Completely variable row does have UID for Ajax ($object->uid)
+ * Completely variable row does have UID for Ajax ($object->uid)
* build TD's from $headers $key=>$header
*/
diff --git a/templates/show_objects.inc.php b/templates/show_objects.inc.php
index ac65bc1c..5ee54f33 100644
--- a/templates/show_objects.inc.php
+++ b/templates/show_objects.inc.php
@@ -20,7 +20,7 @@
*/
-/*
+/*
* Variable/Non-DB object display takes headers & objects
*/
@@ -31,9 +31,9 @@
<th class="th-top"><?php echo $header; ?></th>
<?php } ?>
</tr>
-<?php
- foreach ($objects as $object) {
- $object->format();
+<?php
+ foreach ($objects as $object) {
+ $object->format();
?>
<tr id="object_row_<?php echo $object->id; ?>" class="<?php echo flip_class(); ?>">
<?php require Config::get('prefix') . '/templates/show_object_row.inc.php'; ?>
diff --git a/templates/show_playlist.inc.php b/templates/show_playlist.inc.php
index a4e0eb8e..225b1e70 100644
--- a/templates/show_playlist.inc.php
+++ b/templates/show_playlist.inc.php
@@ -21,7 +21,7 @@
/**
* Playlist Box
* This box is used for actions on the main screen and on a specific playlist page
- * It changes depending on where it is
+ * It changes depending on where it is
*/
?>
<?php /* HINT: Playlist Type, Playlist Name */ show_box_top(sprintf(_('%s %s Playlist'), $playlist->f_type, $playlist->name)); ?>
@@ -48,9 +48,9 @@
</ul>
</div>
<?php show_box_bottom(); ?>
-<?php
- Browse::set_type('playlist_song');
- Browse::add_supplemental_object('playlist',$playlist->id);
+<?php
+ Browse::set_type('playlist_song');
+ Browse::add_supplemental_object('playlist',$playlist->id);
Browse::set_static_content(1);
- Browse::show_objects($object_ids);
+ Browse::show_objects($object_ids);
?>
diff --git a/templates/show_playlist_row.inc.php b/templates/show_playlist_row.inc.php
index befe0e41..e4ac5cd4 100644
--- a/templates/show_playlist_row.inc.php
+++ b/templates/show_playlist_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/templates/show_playlist_songs.inc.php b/templates/show_playlist_songs.inc.php
index 97e15ac3..09764238 100644
--- a/templates/show_playlist_songs.inc.php
+++ b/templates/show_playlist_songs.inc.php
@@ -21,8 +21,8 @@
*/
// First let's setup some vars we're going to use a lot
-$web_path = Config::get('web_path');
-$ajax_url = Config::get('ajax_url');
+$web_path = Config::get('web_path');
+$ajax_url = Config::get('ajax_url');
?>
<?php require Config::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
@@ -54,14 +54,14 @@ $ajax_url = Config::get('ajax_url');
<?php } ?>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
-<?php
- foreach ($object_ids as $object) {
- $song = new Song($object['object_id']);
- $song->format();
+<?php
+ foreach ($object_ids as $object) {
+ $song = new Song($object['object_id']);
+ $song->format();
$playlist_track = $object['track'];
?>
<tr class="<?php echo flip_class(); ?>" id="track_<?php echo $object['track_id']; ?>">
- <?php require Config::get('prefix') . '/templates/show_playlist_song_row.inc.php'; ?>
+ <?php require Config::get('prefix') . '/templates/show_playlist_song_row.inc.php'; ?>
</tr>
<?php } ?>
<tr class="th-bottom">
diff --git a/templates/show_playlists.inc.php b/templates/show_playlists.inc.php
index 047f09fd..1fbb29ee 100644
--- a/templates/show_playlists.inc.php
+++ b/templates/show_playlists.inc.php
@@ -39,14 +39,14 @@
<th class="cel_owner"><?php echo Ajax::text('?page=browse&action=set_sort&type=playlist&sort=user',_('Owner'),'playlist_sort_owner'); ?></th>
<th class="cel_action"><?php echo _('Actions'); ?></th>
</tr>
-<?php
-foreach ($object_ids as $playlist_id) {
- $playlist = new Playlist($playlist_id);
- $playlist->format();
- $count = $playlist->get_song_count();
+<?php
+foreach ($object_ids as $playlist_id) {
+ $playlist = new Playlist($playlist_id);
+ $playlist->format();
+ $count = $playlist->get_song_count();
?>
<tr class="<?php echo flip_class(); ?>" id="playlist_row_<?php echo $playlist->id; ?>">
- <?php require Config::get('prefix') . '/templates/show_playlist_row.inc.php'; ?>
+ <?php require Config::get('prefix') . '/templates/show_playlist_row.inc.php'; ?>
</tr>
<?php } // end foreach ($playlists as $playlist) ?>
<?php if (!count($object_ids)) { ?>
diff --git a/templates/show_playtype_switch.inc.php b/templates/show_playtype_switch.inc.php
index 66a50303..893b23c0 100644
--- a/templates/show_playtype_switch.inc.php
+++ b/templates/show_playtype_switch.inc.php
@@ -21,14 +21,14 @@
*/
?>
<div id="play_type_switch">
-<?php
+<?php
$name = "is_" . Config::get('play_type');
${$name} = 'selected="selected" ';
if (Preference::has_access('play_type')) {
?>
<form method="post" id="play_type_form" action="javascript.void(0);">
-<select id="play_type_select" name="type">
+<select id="play_type_select" name="type">
<?php if (Config::get('allow_stream_playback')) { ?>
<option value="stream" <?php echo $is_stream; ?>><?php echo _('Stream'); ?></option>
<?php } if (Config::get('allow_localplay_playback')) { ?>
diff --git a/templates/show_plugins.inc.php b/templates/show_plugins.inc.php
index 7f3dec66..7606808e 100644
--- a/templates/show_plugins.inc.php
+++ b/templates/show_plugins.inc.php
@@ -19,9 +19,9 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-$web_path = Config::get('web_path');
+$web_path = Config::get('web_path');
?>
-<!-- Plugin we've found -->
+<!-- Plugin we've found -->
<table class="tabledata" cellpadding="0" cellspacing="0">
<colgroup>
<col id="col_name" />
@@ -35,9 +35,9 @@ $web_path = Config::get('web_path');
<th class="cel_version"><?php echo _('Version'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
-<?php
-foreach ($plugins as $plugin_name) {
- $plugin = new Plugin($plugin_name);
+<?php
+foreach ($plugins as $plugin_name) {
+ $plugin = new Plugin($plugin_name);
if (!Plugin::is_installed($plugin->_plugin->name)) {
$action = "<a href=\"" . $web_path . "/admin/modules.php?action=install_plugin&amp;plugin=" . scrub_out($plugin_name) . "\">" .
_('Activate') . "</a>";
diff --git a/templates/show_preference_admin.inc.php b/templates/show_preference_admin.inc.php
index 2142188e..55cfdc81 100644
--- a/templates/show_preference_admin.inc.php
+++ b/templates/show_preference_admin.inc.php
@@ -31,13 +31,13 @@
<th class="cel_preference"><?php echo _('Preference'); ?></th>
<th class="cel_level"><?php echo _('Level'); ?></th>
</tr>
-<?php foreach ($preferences as $preference) {
+<?php foreach ($preferences as $preference) {
unset($is_25,$is_5,$is_100);
?>
<tr class="<?php echo flip_class(); ?>">
<td class="cel_preference"><?php echo scrub_out(_($preference['description'])); ?></td>
<td class="cel_level">
- <?php $level_name = "is_" . $preference['level']; ${$level_name} = 'selected="selected"'; ?>
+ <?php $level_name = "is_" . $preference['level']; ${$level_name} = 'selected="selected"'; ?>
<select name="prefs[<?php echo scrub_out($preference['name']); ?>]">
<option value="5" <?php echo $is_5; ?>><?php echo _('Guest'); ?></option>
<option value="25" <?php echo $is_25; ?>><?php echo _('User'); ?></option>
diff --git a/templates/show_preference_box.inc.php b/templates/show_preference_box.inc.php
index 3237d927..8d5973c6 100644
--- a/templates/show_preference_box.inc.php
+++ b/templates/show_preference_box.inc.php
@@ -21,10 +21,10 @@
*/
/* I'm cheating a little here, check to see if we want to show the
- * Apply to All button on this page
+ * Apply to All button on this page
*/
-if ((Access::check('interface','100') OR !Config::get('use_auth')) AND $_REQUEST['action'] == 'admin') {
- $is_admin = true;
+if ((Access::check('interface','100') OR !Config::get('use_auth')) AND $_REQUEST['action'] == 'admin') {
+ $is_admin = true;
}
?>
<h4><?php echo _($preferences['title']); ?></h4>
@@ -54,14 +54,14 @@ if ((Access::check('interface','100') OR !Config::get('use_auth')) AND $_REQUEST
<?php if ($is_admin) { ?>
<td class="cel_applytoall"><input type="checkbox" name="check_<?php echo $pref['name']; ?>" value="1" /></td>
<td class="cel_level">
- <?php $name = 'on_' . $pref['level']; ${$name} = 'selected="selected"'; ?>
+ <?php $name = 'on_' . $pref['level']; ${$name} = 'selected="selected"'; ?>
<select name="level_<?php echo $pref['name']; ?>">
- <option value="5" <?php echo $on_5; ?>><?php echo _('Guest'); ?></option>
+ <option value="5" <?php echo $on_5; ?>><?php echo _('Guest'); ?></option>
<option value="25" <?php echo $on_25; ?>><?php echo _('User'); ?></option>
<option value="50" <?php echo $on_50; ?>><?php echo _('Content Manager'); ?></option>
<option value="75" <?php echo $on_75; ?>><?php echo _('Catalog Manager'); ?></option>
<option value="100" <?php echo $on_100; ?>><?php echo _('Admin'); ?></option>
- </select>
+ </select>
<?php unset(${$name}); ?>
</td>
<?php } ?>
diff --git a/templates/show_preferences.inc.php b/templates/show_preferences.inc.php
index 4e75dadc..fc4b853f 100644
--- a/templates/show_preferences.inc.php
+++ b/templates/show_preferences.inc.php
@@ -21,8 +21,8 @@
*/
/**
- * This page has a few tabs, as such we need to figure out which tab we are on
- * and display the information accordingly
+ * This page has a few tabs, as such we need to figure out which tab we are on
+ * and display the information accordingly
*/
?>
@@ -42,8 +42,8 @@
</div>
<?php
} // end if not account
-if ($_REQUEST['tab'] == 'account') {
- $client = $GLOBALS['user'];
+if ($_REQUEST['tab'] == 'account') {
+ $client = $GLOBALS['user'];
require Config::get('prefix') . '/templates/show_account.inc.php';
}
?>
diff --git a/templates/show_random.inc.php b/templates/show_random.inc.php
index 9f733d4f..e1a73b21 100644
--- a/templates/show_random.inc.php
+++ b/templates/show_random.inc.php
@@ -100,12 +100,12 @@
<?php show_box_bottom(); ?>
<div id="browse">
<?php
- if (is_array($object_ids)) {
- Browse::reset_filters();
+ if (is_array($object_ids)) {
+ Browse::reset_filters();
Browse::set_type('song');
- Browse::save_objects($object_ids);
- Browse::show_objects();
+ Browse::save_objects($object_ids);
+ Browse::show_objects();
echo Ajax::observe('window','load',Ajax::action('?action=refresh_rightbar','playlist_refresh_load'));
- }
-?>
+ }
+?>
</div>
diff --git a/templates/show_random_albums.inc.php b/templates/show_random_albums.inc.php
index e0dc3bac..7aee5d48 100644
--- a/templates/show_random_albums.inc.php
+++ b/templates/show_random_albums.inc.php
@@ -19,16 +19,16 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-$web_path = Config::get('web_path');
-$button = Ajax::button('?page=index&action=random_albums','random',_('Refresh'),'random_refresh');
+$web_path = Config::get('web_path');
+$button = Ajax::button('?page=index&action=random_albums','random',_('Refresh'),'random_refresh');
?>
<?php show_box_top(_('Albums of the Moment') . ' ' . $button); ?>
- <?php
+ <?php
if ($albums) {
- foreach ($albums as $album_id) {
- $album = new Album($album_id);
- $album->format();
+ foreach ($albums as $album_id) {
+ $album = new Album($album_id);
+ $album->format();
$name = '[' . $album->f_artist . '] ' . scrub_out($album->full_name);
?>
<div class="random_album">
@@ -48,7 +48,7 @@ $button = Ajax::button('?page=index&action=random_albums','random',_('Refresh'),
?>
<span class="play_album"><?php echo Ajax::button('?action=basket&type=album&id=' . $album->id,'add',_('Play Album'),'play_full_' . $album->id); ?></span>
</div>
-
+
<?php } // end foreach ?>
<?php } // end if albums ?>
diff --git a/templates/show_recently_played.inc.php b/templates/show_recently_played.inc.php
index d1d59d68..d29d9fc0 100644
--- a/templates/show_recently_played.inc.php
+++ b/templates/show_recently_played.inc.php
@@ -21,7 +21,7 @@
*/
/* Define the time places starting at 0 */
-$time_unit = array('',_('seconds ago'),_('minutes ago'),_('hours ago'),_('days ago'),_('weeks ago'),_('months ago'),_('years ago'));
+$time_unit = array('',_('seconds ago'),_('minutes ago'),_('hours ago'),_('days ago'),_('weeks ago'),_('months ago'),_('years ago'));
$link = Config::get('use_rss') ? ' ' . AmpacheRSS::get_display('recently_played') : '';
show_box_top(_('Recently Played') . $link);
?>
@@ -42,15 +42,15 @@ show_box_top(_('Recently Played') . $link);
<th class="cel_username"><?php echo _('Username'); ?></th>
<th class="cel_lastplayed"><?php echo _('Last Played'); ?></th>
</tr>
-<?php foreach ($data as $row) {
+<?php foreach ($data as $row) {
$row_user = new User($row['user']);
- $song = new Song($row['object_id']);
- $amount = intval(time() - $row['date']+2);
+ $song = new Song($row['object_id']);
+ $amount = intval(time() - $row['date']+2);
$time_place = '0';
- while ($amount >= 1) {
- $final = $amount;
- $time_place++;
+ while ($amount >= 1) {
+ $final = $amount;
+ $time_place++;
if ($time_place <= 2) {
$amount = floor($amount/60);
}
@@ -66,15 +66,15 @@ show_box_top(_('Recently Played') . $link);
if ($time_place == '6') {
$amount = floor ($amount/12);
}
- if ($time_place > '6') {
- $final = $amount . '+';
- break;
- }
+ if ($time_place > '6') {
+ $final = $amount . '+';
+ break;
+ }
}
$time_string = $final . ' ' . $time_unit[$time_place];
- $song->format();
+ $song->format();
?>
<tr class="<?php echo flip_class(); ?>">
<td class="cel_add">
diff --git a/templates/show_registration_confirmation.inc.php b/templates/show_registration_confirmation.inc.php
index ce060678..a0f826b7 100644
--- a/templates/show_registration_confirmation.inc.php
+++ b/templates/show_registration_confirmation.inc.php
@@ -21,7 +21,7 @@
*/
$htmllang = str_replace("_","-",Config::get('lang'));
-$web_path = Config::get('web_path');
+$web_path = Config::get('web_path');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $htmllang; ?>" lang="<?php echo $htmllang; ?>">
diff --git a/templates/show_run_add_catalog.inc.php b/templates/show_run_add_catalog.inc.php
index 494dcfbb..1e5fd50a 100644
--- a/templates/show_run_add_catalog.inc.php
+++ b/templates/show_run_add_catalog.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/templates/show_search.inc.php b/templates/show_search.inc.php
index 4dfe3fcc..1cba5861 100644
--- a/templates/show_search.inc.php
+++ b/templates/show_search.inc.php
@@ -100,7 +100,7 @@
<?php } ?>
</select>
</td>
-</tr>
+</tr>
<tr class="<?php echo flip_class(); ?>">
<td><?php echo _('Rating'); ?></td>
<td>
diff --git a/templates/show_shoutbox.inc.php b/templates/show_shoutbox.inc.php
index 85014e51..0c991cec 100644
--- a/templates/show_shoutbox.inc.php
+++ b/templates/show_shoutbox.inc.php
@@ -22,13 +22,13 @@
?>
<?php show_box_top(_('Shoutbox')); ?>
<div id="shoutbox">
-<?php
- foreach ($shouts as $shout_id) {
- $shout = new shoutBox($shout_id);
- $object = shoutBox::get_object($shout->object_type,$shout->object_id);
- $object->format();
- $client = new User($shout->user);
- $client->format();
+<?php
+ foreach ($shouts as $shout_id) {
+ $shout = new shoutBox($shout_id);
+ $object = shoutBox::get_object($shout->object_type,$shout->object_id);
+ $object->format();
+ $client = new User($shout->user);
+ $client->format();
?>
<div class="shout <?php echo flip_class(); ?>">
<?php echo $shout->get_image(); ?>
diff --git a/templates/show_song_row.inc.php b/templates/show_song_row.inc.php
index 34074e95..ca4ca4e4 100644
--- a/templates/show_song_row.inc.php
+++ b/templates/show_song_row.inc.php
@@ -50,6 +50,6 @@
<?php $button_flip_state_id = 'button_flip_state_' . $song_id; ?>
<span id="<?php echo($button_flip_state_id); ?>">
<?php echo Ajax::button('?page=song&action=flip_state&song_id=' . $song->id,$icon,_(ucfirst($icon)),'flip_song_' . $song->id); ?>
- </span>
+ </span>
<?php } ?>
</td>
diff --git a/templates/show_songs.inc.php b/templates/show_songs.inc.php
index 371b862b..0a40b8ad 100644
--- a/templates/show_songs.inc.php
+++ b/templates/show_songs.inc.php
@@ -21,8 +21,8 @@
*/
// First let's setup some vars we're going to use a lot
-$web_path = Config::get('web_path');
-$ajax_url = Config::get('ajax_url');
+$web_path = Config::get('web_path');
+$ajax_url = Config::get('ajax_url');
?>
<?php require Config::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
@@ -52,12 +52,12 @@ $ajax_url = Config::get('ajax_url');
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
<?php
- foreach ($object_ids as $song_id) {
- $song = new Song($song_id);
- $song->format();
+ foreach ($object_ids as $song_id) {
+ $song = new Song($song_id);
+ $song->format();
?>
<tr class="<?php echo flip_class(); ?>" id="song_<?php echo $song->id; ?>">
- <?php require Config::get('prefix') . '/templates/show_song_row.inc.php'; ?>
+ <?php require Config::get('prefix') . '/templates/show_song_row.inc.php'; ?>
</tr>
<?php } ?>
<?php if (!count($object_ids)) { ?>
diff --git a/templates/show_stats.inc.php b/templates/show_stats.inc.php
index f64febcb..142ebcf6 100644
--- a/templates/show_stats.inc.php
+++ b/templates/show_stats.inc.php
@@ -20,7 +20,7 @@
*/
$stats = Catalog::get_stats();
-$catalogs = Catalog::get_catalogs();
+$catalogs = Catalog::get_catalogs();
?>
<?php show_box_top(_('Statistics')); ?>
<em><?php echo _('Catalogs'); ?></em>
@@ -70,10 +70,10 @@ $catalogs = Catalog::get_catalogs();
<th class="cel_video"><?php echo _('Video'); ?></th>
<th class="cel_total"><?php echo _('Catalog Size'); ?></th>
</tr>
-<?php foreach ($catalogs as $catalog_id) {
- $catalog = new Catalog($catalog_id);
- $catalog->format();
- $stats = Catalog::get_stats($catalog_id);
+<?php foreach ($catalogs as $catalog_id) {
+ $catalog = new Catalog($catalog_id);
+ $catalog->format();
+ $stats = Catalog::get_stats($catalog_id);
?>
<tr>
<td class="cel_catalog"><?php echo $catalog->name; ?></td>
diff --git a/templates/show_stats_popular.inc.php b/templates/show_stats_popular.inc.php
index 14c2a30d..63d21927 100644
--- a/templates/show_stats_popular.inc.php
+++ b/templates/show_stats_popular.inc.php
@@ -22,17 +22,17 @@
?>
<div>
<?php
- $objects = Stats::get_top('album');
- $headers = array('f_link'=>_('Most Popular Albums'));
- show_box_top('','info-box box_popular_albums');
- require Config::get('prefix') . '/templates/show_objects.inc.php';
- show_box_bottom();
+ $objects = Stats::get_top('album');
+ $headers = array('f_link'=>_('Most Popular Albums'));
+ show_box_top('','info-box box_popular_albums');
+ require Config::get('prefix') . '/templates/show_objects.inc.php';
+ show_box_bottom();
- $objects = Stats::get_top('artist');
- $headers = array('f_name_link'=>_('Most Popular Artists'));
- show_box_top('','info-box box_popular_artists');
- require Config::get('prefix') . '/templates/show_objects.inc.php';
- show_box_bottom();
+ $objects = Stats::get_top('artist');
+ $headers = array('f_name_link'=>_('Most Popular Artists'));
+ show_box_top('','info-box box_popular_artists');
+ require Config::get('prefix') . '/templates/show_objects.inc.php';
+ show_box_bottom();
?>
</div>
diff --git a/templates/show_tagcloud.inc.php b/templates/show_tagcloud.inc.php
index 25aabddf..a241b65a 100644
--- a/templates/show_tagcloud.inc.php
+++ b/templates/show_tagcloud.inc.php
@@ -9,25 +9,25 @@
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-$web_path = Config::get('web_path');
+*/
+$web_path = Config::get('web_path');
?>
<?php Ajax::start_container('tag_filter'); ?>
-<?php foreach ($object_ids as $data) {
- $tag = new Tag($data['id']);
- $tag->format();
+<?php foreach ($object_ids as $data) {
+ $tag = new Tag($data['id']);
+ $tag->format();
?>
-<span id="click_<?php echo intval($tag->id); ?>" class="<?php echo $tag->f_class; ?>"><?php echo $tag->name; ?></span>
+<span id="click_<?php echo intval($tag->id); ?>" class="<?php echo $tag->f_class; ?>"><?php echo $tag->name; ?></span>
<?php echo Ajax::observe('click_' . intval($tag->id),'click',Ajax::action('?page=tag&action=add_filter&tag_id=' . intval($tag->id),'')); ?>
<?php } ?>
<?php if (!count($object_ids)) { ?>
diff --git a/templates/show_test.inc.php b/templates/show_test.inc.php
index 17572e5d..20fe97c5 100644
--- a/templates/show_test.inc.php
+++ b/templates/show_test.inc.php
@@ -38,7 +38,7 @@
<tr>
<td><font size="+1"><?php echo _('CHECK'); ?></font></td>
<td>
- <font size="+1"><?php echo _('STATUS'); ?></font>
+ <font size="+1"><?php echo _('STATUS'); ?></font>
</td>
<td><font size="+1"><?php echo _('DESCRIPTION'); ?></font></td>
</tr>
@@ -46,13 +46,13 @@
<td valign="top"><?php echo _('PHP Version'); ?></td>
<td valign="top">[
<?php
- if (!check_php_ver()) {
+ if (!check_php_ver()) {
echo debug_result('',false);
- if (function_exists('hash_algos')) { $algos = hash_algos(); }
- $string = "<strong>" . phpversion() . " " . _('Hash Function Exists') . " " . print_boolean(function_exists('hash_algos')) . " " . _('SHA256 Support') . " " . print_boolean(in_array('sha256',$algos)) . "</strong>";
+ if (function_exists('hash_algos')) { $algos = hash_algos(); }
+ $string = "<strong>" . phpversion() . " " . _('Hash Function Exists') . " " . print_boolean(function_exists('hash_algos')) . " " . _('SHA256 Support') . " " . print_boolean(in_array('sha256',$algos)) . "</strong>";
}
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
]
@@ -67,10 +67,10 @@
<td valign="top">[
<?php
if (!check_php_mysql()) {
- echo debug_result('',false);
+ echo debug_result('',false);
}
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
]
@@ -83,11 +83,11 @@
<td valign="top"><?php echo _('PHP Session Support'); ?></td>
<td valign="top">[
<?php
- if (!check_php_session()) {
- echo debug_result('',false);
+ if (!check_php_session()) {
+ echo debug_result('',false);
}
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
]
@@ -100,11 +100,11 @@
<td valign="top"><?php echo _('PHP ICONV Support'); ?></td>
<td valign="top">[
<?php
- if (!check_php_iconv()) {
- echo debug_result('',false);
+ if (!check_php_iconv()) {
+ echo debug_result('',false);
}
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>]
</td>
@@ -116,11 +116,11 @@
<td valign="top"><?php echo _('PHP PCRE Support'); ?></td>
<td valign="top">[
<?php
- if (!check_php_pcre()) {
- echo debug_result('',false);
+ if (!check_php_pcre()) {
+ echo debug_result('',false);
}
- else {
- echo debug_result('',true);
+ else {
+ echo debug_result('',true);
}
?>]
</td>
@@ -132,27 +132,27 @@
<td valign="top"><?php echo _('PHP PutENV Support'); ?></td>
<td valign="top">[
<?php
- if (!check_putenv()) {
- echo debug_result('',false);
+ if (!check_putenv()) {
+ echo debug_result('',false);
+ }
+ else {
+ echo debug_result('',true);
}
- else {
- echo debug_result('',true);
- }
?>]
</td>
<td>
<?php echo _('This test makes sure that PHP isn\'t running in SafeMode and that we are able to modify the memory limits. While not required, without these abilities some features of ampache may not work correctly'); ?>
</td>
-</tr>
+</tr>
<tr>
<td valign="top"><?php echo sprintf(_("%s is readable"),"ampache.cfg.php"); ?></td>
- <td valign="top">[
+ <td valign="top">[
<?php
- if (!is_readable($configfile)) {
- echo debug_result('',false);
+ if (!is_readable($configfile)) {
+ echo debug_result('',false);
}
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
]
@@ -166,15 +166,15 @@
<td valign="top">
<?php echo _('Ampache.cfg.php Configured?'); ?>
</td>
- <td valign="top">[
+ <td valign="top">[
<?php
$results = @parse_ini_file($configfile);
Config::set_by_array($results);
- if (!check_config_values($results)) {
- echo debug_result('',false);
+ if (!check_config_values($results)) {
+ echo debug_result('',false);
}
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
]
@@ -188,12 +188,12 @@
<td valign="top">[
<?php
$db = check_database($results['database_hostname'], $results['database_username'], $results['database_password'],$results['database_name']);
- if (!$db) {
- echo debug_result('',false);
+ if (!$db) {
+ echo debug_result('',false);
}
else {
- echo debug_result('',true);
- }
+ echo debug_result('',true);
+ }
?>
]
</td>
@@ -206,11 +206,11 @@
<td valign="top">[
<?php
$db_inserted = check_database_inserted($db,$results['local_db']);
- if (!$db_inserted) {
- echo debug_result('',false);
+ if (!$db_inserted) {
+ echo debug_result('',false);
}
else {
- echo debug_result('',true);
+ echo debug_result('',true);
}
?>
]
@@ -227,18 +227,18 @@
/*
Check to see if this is Http or https
*/
- if ($_SERVER['HTTPS'] == 'on') {
+ if ($_SERVER['HTTPS'] == 'on') {
$http_type = "https://";
}
- else {
+ else {
$http_type = "http://";
}
$results['web_path'] = $http_type . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . Config::get('web_path');
- if (check_config_values($results)) {
+ if (check_config_values($results)) {
echo "&nbsp;&nbsp;&nbsp;<img src=\"" . $results['web_path'] ."/images/icon_enable.png\" />&nbsp;&nbsp;&nbsp;";
}
else {
- echo debug_result('',false);
+ echo debug_result('',false);
}
?>
diff --git a/templates/show_test_config.inc.php b/templates/show_test_config.inc.php
index 1843f4eb..9a736c1c 100644
--- a/templates/show_test_config.inc.php
+++ b/templates/show_test_config.inc.php
@@ -28,12 +28,12 @@
<title>Ampache -- Config Debug Page</title>
<link rel="stylesheet" href="templates/install.css" type="text/css" media="screen" />
<style type="text/css">
-body {
- text-align:left;
-}
-#content {
- padding-left: 10px;
-}
+body {
+ text-align:left;
+}
+#content {
+ padding-left: 10px;
+}
</style>
</head>
<body bgcolor="#f0f0f0">
@@ -43,7 +43,7 @@ body {
</div>
<div id="content">
<h3 style="color:red;">Ampache.cfg.php Parse Error</h3>
-<p>You've been redirected to this page because your <strong>/config/ampache.cfg.php</strong> was not parsable.
+<p>You've been redirected to this page because your <strong>/config/ampache.cfg.php</strong> was not parsable.
If you are upgrading from 3.3.x please see the directions below.</p>
<h3>Migrating from 3.3.x to 3.4.x</h3>
@@ -59,7 +59,7 @@ This defines which auth methods vauth will attempt to use and in which order, if
The user must exist locally as well<br />
<br />
<strong>tag_order</strong> (<i>id3v2,id3v1,vorbiscomment,quicktime,ape,asf</i>)<br />
-This determines the tag order for all cataloged music. If none of the listed tags are found then ampache will default to
+This determines the tag order for all cataloged music. If none of the listed tags are found then ampache will default to
the first tag format that was found. <br />
<br />
<strong>album_art_order</strong> (<i>db,id3,folder,lastfm,amazon</i>)<br />
diff --git a/templates/show_update_items.inc.php b/templates/show_update_items.inc.php
index e2cefa10..ecc63e0c 100644
--- a/templates/show_update_items.inc.php
+++ b/templates/show_update_items.inc.php
@@ -20,8 +20,8 @@
*/
-show_box_top(_('Starting Update from Tags'));
-Catalog::update_single_item($type,$object_id);
+show_box_top(_('Starting Update from Tags'));
+Catalog::update_single_item($type,$object_id);
?>
<br />
<strong><?php echo _('Update from Tags Complete'); ?></strong>&nbsp;&nbsp;
diff --git a/templates/show_user.inc.php b/templates/show_user.inc.php
index b126d6bd..062b37eb 100644
--- a/templates/show_user.inc.php
+++ b/templates/show_user.inc.php
@@ -22,7 +22,7 @@
*/
$last_seen = $client->last_seen ? date("m\/d\/y - H:i",$client->last_seen) : _('Never');
$create_date = $client->create_date ? date("m\/d\/y - H:i",$client->create_date) : _('Unknown');
-$client->format();
+$client->format();
?>
<?php show_box_top($client->fullname); ?>
<table cellspacing="0">
@@ -37,18 +37,18 @@ $client->format();
<?php } else { ?>
<i style="color:red;"><?php echo _('User is Offline Now'); ?></i>
<?php } ?>
-
+
</td>
<td valign="top">
<h2><?php echo _('Active Playlist'); ?></h2>
<div style="padding-left:10px;">
- <?php
- $tmp_playlist = new tmpPlaylist(tmpPlaylist::get_from_userid($client->id));
- $object_ids = $tmp_playlist->get_items();
- foreach ($object_ids as $object_data) {
- $type = array_shift($object_data);
- $object = new $type(array_shift($object_data));
- $object->format();
+ <?php
+ $tmp_playlist = new tmpPlaylist(tmpPlaylist::get_from_userid($client->id));
+ $object_ids = $tmp_playlist->get_items();
+ foreach ($object_ids as $object_data) {
+ $type = array_shift($object_data);
+ $object = new $type(array_shift($object_data));
+ $object->format();
?>
<?php echo $object->f_link; ?><br />
<?php } ?>
@@ -57,8 +57,8 @@ $client->format();
</tr>
</table>
<?php show_box_bottom(); ?>
-<?php
- $data = Song::get_recently_played($client->id);
- require Config::get('prefix') . '/templates/show_recently_played.inc.php';
+<?php
+ $data = Song::get_recently_played($client->id);
+ require Config::get('prefix') . '/templates/show_recently_played.inc.php';
?>
diff --git a/templates/show_user_activate.inc.php b/templates/show_user_activate.inc.php
index 184e363b..d9e9c356 100644
--- a/templates/show_user_activate.inc.php
+++ b/templates/show_user_activate.inc.php
@@ -21,7 +21,7 @@
*/
$htmllang = str_replace("_","-",Config::get('lang'));
-$web_path = Config::get('web_path');
+$web_path = Config::get('web_path');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $htmllang; ?>" lang="<?php echo $htmllang; ?>">
@@ -42,8 +42,8 @@ $web_path = Config::get('web_path');
<script src="<?php echo $web_path; ?>/modules/prototype/prototype.js" language="javascript" type="text/javascript"></script>
<div id="maincontainer">
-<?php
- if ($validation == User::get_validation($username) AND strlen($validation)) {
+<?php
+ if ($validation == User::get_validation($username) AND strlen($validation)) {
User::activate_user($username);
?>
<h3><?php echo _('User Activated'); ?></h3>
diff --git a/templates/show_user_preferences.inc.php b/templates/show_user_preferences.inc.php
index 3efca35b..4cfe4a28 100644
--- a/templates/show_user_preferences.inc.php
+++ b/templates/show_user_preferences.inc.php
@@ -21,8 +21,8 @@
*/
/**
- * This page has a few tabs, as such we need to figure out which tab we are on
- * and display the information accordingly
+ * This page has a few tabs, as such we need to figure out which tab we are on
+ * and display the information accordingly
*/
?>
@@ -49,7 +49,7 @@
<td>
<div class="formValidation">
<input class="button" type="submit" value="<?php echo _('Update Preferences'); ?>" />
- <?php echo Core::form_register('update_preference'); ?>
+ <?php echo Core::form_register('update_preference'); ?>
<input type="hidden" name="user_id" value="<?php echo scrub_out($_REQUEST['user_id']); ?>" />
</div>
</td>
diff --git a/templates/show_user_recommendations.inc.php b/templates/show_user_recommendations.inc.php
index 1d7531f1..2ae908a6 100644
--- a/templates/show_user_recommendations.inc.php
+++ b/templates/show_user_recommendations.inc.php
@@ -24,34 +24,34 @@
<table class="tabledata">
<tr>
<td valign="top">
- <?php
- if (count($recommended_artists)) {
- $items = $working_user->format_recommendations($recommended_artists,'artist');
- show_info_box(_('Recommended Artists'),'artist',$items);
+ <?php
+ if (count($recommended_artists)) {
+ $items = $working_user->format_recommendations($recommended_artists,'artist');
+ show_info_box(_('Recommended Artists'),'artist',$items);
}
- else {
+ else {
echo "<span class=\"error\">" . _('Not Enough Data') . "</span>";
}
?>
</td>
<td valign="top">
<?php
- if (count($recommended_albums)) {
+ if (count($recommended_albums)) {
$items = $working_user->format_recommendations($recommended_albums,'album');
show_info_box(_('Recommended Albums'),'album',$items);
}
- else {
+ else {
echo "<span class=\"error\">" . _('Not Enough Data') . "</span>";
}
?>
</td>
<td valign="top">
<?php
- if (count($recommended_songs)) {
+ if (count($recommended_songs)) {
$items = $working_user->format_recommendations($recommended_songs,'song');
show_info_box(_('Recommended Songs'),'song',$items);
}
- else {
+ else {
echo "<span class=\"error\">" . _('Not Enough Data') . "</span>";
}
?>
diff --git a/templates/show_user_registration.inc.php b/templates/show_user_registration.inc.php
index 0e2b7769..5cf20676 100644
--- a/templates/show_user_registration.inc.php
+++ b/templates/show_user_registration.inc.php
@@ -21,7 +21,7 @@
*/
$htmllang = str_replace("_","-",Config::get('lang'));
-$web_path = Config::get('web_path');
+$web_path = Config::get('web_path');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $htmllang; ?>" lang="<?php echo $htmllang; ?>">
diff --git a/templates/show_user_row.inc.php b/templates/show_user_row.inc.php
index a1f6d2a5..a9612a75 100644
--- a/templates/show_user_row.inc.php
+++ b/templates/show_user_row.inc.php
@@ -40,7 +40,7 @@
<a href="<?php echo $web_path; ?>/admin/users.php?action=show_preferences&amp;user_id=<?php echo $client->id; ?>"><?php echo get_user_icon('preferences', _('Preferences')); ?></a>
<?php
//FIXME: Fix this for the extra permission levels
- if ($client->disabled == '1') {
+ if ($client->disabled == '1') {
echo "<a href=\"".$web_path."/admin/users.php?action=enable&amp;user_id=$client->id\">" . get_user_icon('enable', _('Enable')) . "</a>";
}
else {
@@ -57,4 +57,4 @@
} else {
echo "<td class=\"cel_online user_offline\"> &nbsp; </td>";
}
-?>
+?>
diff --git a/templates/show_user_stats.inc.php b/templates/show_user_stats.inc.php
index 5b5996c0..05f0f198 100644
--- a/templates/show_user_stats.inc.php
+++ b/templates/show_user_stats.inc.php
@@ -24,40 +24,40 @@
<table class="tabledata">
<tr>
<td valign="top">
- <?php
- if (count($favorite_artists)) {
- $items = $working_user->format_favorites($favorite_artists);
- $title = '<a href="' . Config::get('web_path') . '/stream.php?action=play_favorite&amp;type=artist">' .
+ <?php
+ if (count($favorite_artists)) {
+ $items = $working_user->format_favorites($favorite_artists);
+ $title = '<a href="' . Config::get('web_path') . '/stream.php?action=play_favorite&amp;type=artist">' .
get_user_icon('all', _('Favorite Artists')) . '</a>&nbsp;' . _('Favorite Artists');
- show_info_box($title,'artist',$items);
+ show_info_box($title,'artist',$items);
}
- else {
+ else {
echo "<span class=\"error\">" . _('Not Enough Data') . "</span>";
}
?>
</td>
<td valign="top">
<?php
- if (count($favorite_albums)) {
+ if (count($favorite_albums)) {
$items = $working_user->format_favorites($favorite_albums);
- $title = '<a href="' . Config::get('web_path') . '/stream.php?action=play_favorite&amp;type=album">' .
+ $title = '<a href="' . Config::get('web_path') . '/stream.php?action=play_favorite&amp;type=album">' .
get_user_icon('all', _('Favorite Albums')) . '</a>&nbsp;' . _('Favorite Albums');
show_info_box($title,'album',$items);
}
- else {
+ else {
echo "<span class=\"error\">" . _('Not Enough Data') . "</span>";
}
?>
</td>
<td valign="top">
<?php
- if (count($favorite_songs)) {
- $items = $working_user->format_favorites($favorite_songs);
- $title = '<a href="' . Config::get('web_path') . '/stream.php?action=play_favorite&amp;type=song">' .
+ if (count($favorite_songs)) {
+ $items = $working_user->format_favorites($favorite_songs);
+ $title = '<a href="' . Config::get('web_path') . '/stream.php?action=play_favorite&amp;type=song">' .
get_user_icon('all', _('Favorite Songs')) . '</a>&nbsp;' . _('Favorite Songs');
- show_info_box($title,'your_song',$items);
+ show_info_box($title,'your_song',$items);
}
- else {
+ else {
echo "<span class=\"error\">" . _('Not Enough Data') . "</span>";
}
?>
diff --git a/templates/show_users.inc.php b/templates/show_users.inc.php
index 4685277a..1181a8a8 100644
--- a/templates/show_users.inc.php
+++ b/templates/show_users.inc.php
@@ -48,9 +48,9 @@ $web_path = Config::get('web_path');
<th class="cel_online"><?php echo _('On-line'); ?></th>
</tr>
<?php
-foreach ($object_ids as $user_id) {
- $client = new User($user_id);
- $client->format();
+foreach ($object_ids as $user_id) {
+ $client = new User($user_id);
+ $client->format();
$last_seen = $client->last_seen ? date("m\/d\/Y - H:i",$client->last_seen) : _('Never');
$create_date = $client->create_date ? date("m\/d\/Y - H:i",$client->create_date) : _('Unknown');
?>
diff --git a/templates/show_verify_catalog.inc.php b/templates/show_verify_catalog.inc.php
index 111cea97..7395a757 100644
--- a/templates/show_verify_catalog.inc.php
+++ b/templates/show_verify_catalog.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -26,7 +26,7 @@ printf(_('Updating the %s catalog'), "<strong>[ $catalog->name ]</strong>");
echo "<br />\n";
printf(ngettext('%d item found checking tag information', '%d items found checking tag information', $number), $number);
echo "<br />\n\n";
-echo _('Verifed') . ":<span id=\"verify_count_$catalog_id\">$catalog_verify_found</span><br />";
+echo _('Verifed') . ":<span id=\"verify_count_$catalog_id\">$catalog_verify_found</span><br />";
echo _('Reading') . ":<span id=\"verify_dir_$catalog_id\">$catalog_verify_directory</span><br />";
-show_box_bottom();
+show_box_bottom();
?>
diff --git a/templates/show_video_row.inc.php b/templates/show_video_row.inc.php
index 463e2e48..9fdb3f43 100644
--- a/templates/show_video_row.inc.php
+++ b/templates/show_video_row.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/templates/show_videos.inc.php b/templates/show_videos.inc.php
index e1d1e6da..685cf2cc 100644
--- a/templates/show_videos.inc.php
+++ b/templates/show_videos.inc.php
@@ -7,7 +7,7 @@
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
- as published by the Free Software Foundation.
+ as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -42,11 +42,11 @@ $web_path = Config::get('web_path');
<th class="cel_tags"><?php echo _('Tags'); ?></th>
<th class="cel_action"><?php echo _('Action'); ?></th>
</tr>
-<?php
+<?php
/* Foreach through every artist that has been passed to us */
-foreach ($object_ids as $video_id) {
- $video = new Video($video_id);
- $video->format();
+foreach ($object_ids as $video_id) {
+ $video = new Video($video_id);
+ $video->format();
?>
<tr id="video_<?php echo $video->id; ?>" class="<?php echo flip_class(); ?>">
<?php require Config::get('prefix') . '/templates/show_video_row.inc.php'; ?>
diff --git a/templates/show_xspf_player.inc.php b/templates/show_xspf_player.inc.php
index 95043247..5bfc5ef9 100644
--- a/templates/show_xspf_player.inc.php
+++ b/templates/show_xspf_player.inc.php
@@ -50,11 +50,11 @@
//}
//document.oncontextmenu=new Function("return false")
-// -->
+// -->
</script>
<div id="mp3player">
-<?php
-$player_url = sprintf("%s/modules/flash/xspf_jukebox.swf?autoplay=true&repeat_playlist=true&crossFade=false&shuffle=false&skin_url=%s/modules/flash/Original/&playlist_url=%s",Config::get('web_path'),Config::get('web_path'),$play_url);
+<?php
+$player_url = sprintf("%s/modules/flash/xspf_jukebox.swf?autoplay=true&repeat_playlist=true&crossFade=false&shuffle=false&skin_url=%s/modules/flash/Original/&playlist_url=%s",Config::get('web_path'),Config::get('web_path'),$play_url);
?>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="400" height="170" id="xspf_player" align="middle">
<param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer" />
@@ -65,7 +65,7 @@ $player_url = sprintf("%s/modules/flash/xspf_jukebox.swf?autoplay=true&repeat_pl
<param name="type" value="application/x-shockwave-flash" />
<param name="width" value="400" />
<param name="height" value="170" />
- <param name="name" value="xspf_player" />
+ <param name="name" value="xspf_player" />
<param name="align" value="middle" />
<embed src="<?php echo $player_url; ?>" quality="high" bgcolor="#ffffff" width="400" height="170" name="xspf_player" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
diff --git a/templates/sidebar.inc.php b/templates/sidebar.inc.php
index a78c7e49..6f87eee3 100644
--- a/templates/sidebar.inc.php
+++ b/templates/sidebar.inc.php
@@ -20,7 +20,7 @@
*/
-if (!$_SESSION['state']['sidebar_tab']) { $_SESSION['state']['sidebar_tab'] = 'home'; }
+if (!$_SESSION['state']['sidebar_tab']) { $_SESSION['state']['sidebar_tab'] = 'home'; }
$class_name = 'sidebar_' . $_SESSION['state']['sidebar_tab'];
${$class_name} = ' active';
@@ -28,24 +28,24 @@ ${$class_name} = ' active';
$sidebar_items[] = array('id'=>'home', 'title'=>_('Home'), 'icon'=>'home', 'access'=>5);
$sidebar_items[] = array('id'=>'localplay', 'title'=>_('Localplay'), 'icon'=>'volumeup', 'access'=>5);
$sidebar_items[] = array('id'=>'preferences', 'title'=>_('Preferences'), 'icon'=>'edit', 'access'=>5);
-$sidebar_items[] = array('id'=>'modules','title'=>_('Modules'),'icon'=>'plugin','access'=>100);
+$sidebar_items[] = array('id'=>'modules','title'=>_('Modules'),'icon'=>'plugin','access'=>100);
$sidebar_items[] = array('id'=>'admin', 'title'=>_('Admin'), 'icon'=>'admin', 'access'=>100);
$web_path = Config::get('web_path');
-$ajax_url = Config::get('ajax_url');
+$ajax_url = Config::get('ajax_url');
?>
<ul id="sidebar-tabs">
-<?php
- foreach ($sidebar_items as $item) {
+<?php
+ foreach ($sidebar_items as $item) {
if (Access::check('interface',$item['access'])) {
$li_params = "id='sb_tab_" . $item['id'] . "' class='sb1" . ${'sidebar_'.$item['id'] } . "'";
?><li <?php echo $li_params; ?>>
- <?php
+ <?php
// Button
echo Ajax::button("?page=index&action=sidebar&button=".$item['id'],$item['icon'],$item['title'],'sidebar_'.$item['id']);
-
+
// Include subnav if it's the selected one
// so that it's generated inside its parent li
if ($item['id']==$_SESSION['state']['sidebar_tab']) {
diff --git a/templates/sidebar_localplay.inc.php b/templates/sidebar_localplay.inc.php
index 9dc499c6..74e37775 100644
--- a/templates/sidebar_localplay.inc.php
+++ b/templates/sidebar_localplay.inc.php
@@ -25,8 +25,8 @@
<?php if ($server_allow = Config::get('allow_localplay_playback') AND $controller = Config::get('localplay_controller') AND $access_check = Access::check('localplay','5')) { ?>
<?php
// Little bit of work to be done here
- $localplay = new Localplay(Config::get('localplay_controller'));
- $current_instance = $localplay->current_instance();
+ $localplay = new Localplay(Config::get('localplay_controller'));
+ $current_instance = $localplay->current_instance();
$class = $current_instance ? '' : ' class="active_instance"';
?>
<?php if (Access::check('localplay','25')) { ?>
@@ -43,15 +43,15 @@
<li><h4><?php echo _('Active Instance'); ?></h4>
<ul class="sb3" id="sb_localplay_instances">
<li id="sb_localplay_instances_none"<?php echo $class; ?>><?php echo Ajax::text('?page=localplay&action=set_instance&instance=0',_('None'),'localplay_instance_none'); ?></li>
- <?php
+ <?php
// Requires a little work.. :(
- $instances = $localplay->get_instances();
- foreach ($instances as $uid=>$name) {
- $name = scrub_out($name);
+ $instances = $localplay->get_instances();
+ foreach ($instances as $uid=>$name) {
+ $name = scrub_out($name);
$class = '';
- if ($uid == $current_instance) {
- $class = ' class="active_instance"';
- }
+ if ($uid == $current_instance) {
+ $class = ' class="active_instance"';
+ }
?>
<li id="sb_localplay_instances_<?php echo $uid; ?>"<?php echo $class; ?>><?php echo Ajax::text('?page=localplay&action=set_instance&instance=' . $uid,$name,'localplay_instance_' . $uid); ?></li>
<?php } ?>
diff --git a/templates/sidebar_modules.inc.php b/templates/sidebar_modules.inc.php
index ede8d1ce..8f14b196 100644
--- a/templates/sidebar_modules.inc.php
+++ b/templates/sidebar_modules.inc.php
@@ -1,4 +1,4 @@
-<?php
+<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
/*
@@ -20,7 +20,7 @@
*/
-$ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path');
+$ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path');
?>
<ul class="sb2" id="sb_modules">
<li><h4><?php echo _('Modules'); ?></h4>
diff --git a/templates/sidebar_preferences.inc.php b/templates/sidebar_preferences.inc.php
index 16abe728..0dc6cc3a 100644
--- a/templates/sidebar_preferences.inc.php
+++ b/templates/sidebar_preferences.inc.php
@@ -1,4 +1,4 @@
-<?php
+<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
/*
@@ -24,15 +24,15 @@
* they can have their own preference sections so we need to build the
* links based on that, always ignore 'internal' though
*/
-$catagories = Preference::get_catagories();
+$catagories = Preference::get_catagories();
?>
<ul class="sb2" id="sb_preferences">
<li><h4><?php echo _('Preferences'); ?></h4>
<ul class="sb3" id="sb_preferences_sections">
-<?php
- foreach ($catagories as $name) {
- if ($name == 'system') { continue; }
- $f_name = ucfirst($name);
+<?php
+ foreach ($catagories as $name) {
+ if ($name == 'system') { continue; }
+ $f_name = ucfirst($name);
?>
<li id="sb_preferences_sections_<?php echo $f_name; ?>"><a href="<?php echo $web_path; ?>/preferences.php?tab=<?php echo $name; ?>"><?php echo _($f_name); ?></a></li>
<?php } ?>
diff --git a/templates/subnavbar.inc.php b/templates/subnavbar.inc.php
index 3618ef9c..5c9b8473 100644
--- a/templates/subnavbar.inc.php
+++ b/templates/subnavbar.inc.php
@@ -28,11 +28,11 @@
?>
<ul class="subnavside">
-<?php
- foreach ($items as $item) {
- if ($item['url'] == $item['active']) {
+<?php
+ foreach ($items as $item) {
+ if ($item['url'] == $item['active']) {
$li_class = "class=\"activesubmenu\"";
- }
+ }
$li_id = "id=\"" . $item['cssclass'] . "\"";
?>
<li <?php echo $li_class; echo $li_id; ?>><a href="<?php echo Config::get('web_path') . "/" . $item['url']; ?>"><?php echo $item['title']; ?></a></li>
diff --git a/test.php b/test.php
index 044fff2a..c8a5ee75 100644
--- a/test.php
+++ b/test.php
@@ -27,33 +27,33 @@ $prefix = dirname(__FILE__);
$configfile = "$prefix/config/ampache.cfg.php";
$row_classes = array('even','odd');
-define('INIT_LOADED','1');
+define('INIT_LOADED','1');
require_once $prefix . '/lib/general.lib.php';
require_once $prefix . '/lib/log.lib.php';
-require_once $prefix . '/lib/class/config.class.php';
+require_once $prefix . '/lib/class/config.class.php';
require_once $prefix . '/lib/class/dba.class.php';
require_once $prefix . '/lib/ui.lib.php';
require_once $prefix . '/lib/class/error.class.php';
require_once $prefix . '/lib/class/config.class.php';
require_once $prefix . '/lib/debug.lib.php';
-Dba::_auto_init();
+Dba::_auto_init();
-switch ($_REQUEST['action']) {
- case 'config':
+switch ($_REQUEST['action']) {
+ case 'config':
$configfile = "$prefix/config/ampache.cfg.php";
// On every load of the config file check and see if it's working now
if (count(parse_ini_file($configfile))) {
- require_once $prefix . '/templates/show_test.inc.php';
- break;
- }
- require_once $prefix . '/templates/show_test_config.inc.php';
+ require_once $prefix . '/templates/show_test.inc.php';
+ break;
+ }
+ require_once $prefix . '/templates/show_test_config.inc.php';
break;
default:
require_once $prefix . '/templates/show_test.inc.php';
break;
} // end switch on action
-?>
+?>
diff --git a/themes/classic/theme.cfg.php b/themes/classic/theme.cfg.php
index a2bf6127..c3011b57 100644
--- a/themes/classic/theme.cfg.php
+++ b/themes/classic/theme.cfg.php
@@ -19,7 +19,7 @@
; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; Classic Ampache Theme
+; Classic Ampache Theme
;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Theme Name
@@ -29,7 +29,7 @@
name = "Classic Ampache"
; Theme Author
-; This is just a way of giving credit to the
+; This is just a way of giving credit to the
; person who actually created this theme
; DEFAULT: N/A
author = "Ros"
diff --git a/update.php b/update.php
index e270565d..33361fdc 100644
--- a/update.php
+++ b/update.php
@@ -24,17 +24,17 @@ define('NO_SESSION','1');
require 'lib/init.php';
// Get the version and format it
-$version = Update::get_version();
+$version = Update::get_version();
+
+if ($_REQUEST['action'] == 'update') {
-if ($_REQUEST['action'] == 'update') {
-
/* Run the Update Mojo Here */
Update::run_update();
/* Get the New Version */
$version = Update::get_version();
-}
+}
$htmllang = str_replace("_","-",Config::get('lang'));
?>
@@ -48,7 +48,7 @@ $htmllang = str_replace("_","-",Config::get('lang'));
<title><?php echo _('Ampache Update'); ?></title>
</head>
<body>
-<div id="header">
+<div id="header">
<h1><?php echo _('Ampache Update'); ?></h1>
<p>Pour l'Amour de la Musique.</p>
</div>
diff --git a/util.php b/util.php
index 05a6a927..c2031993 100644
--- a/util.php
+++ b/util.php
@@ -29,13 +29,13 @@ header("Pragma: no-cache");
// This is a little bit of a special file, it takes the
// content of $_SESSION['iframe']['target'] and does a header
// redirect to that spot!
-if (isset($_SESSION['iframe']['target'])) {
- $target = $_SESSION['iframe']['target'];
- unset($_SESSION['iframe']['target']);
- header("Location: " . $target);
-}
-else {
+if (isset($_SESSION['iframe']['target'])) {
+ $target = $_SESSION['iframe']['target'];
+ unset($_SESSION['iframe']['target']);
+ header("Location: " . $target);
+}
+else {
// Prevent the update query as it's pointless
- define('NO_SESSION_UPDATE','1');
-}
+ define('NO_SESSION_UPDATE','1');
+}
?>