mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 17:59:21 +02:00
Use latest php-cs-fixer version
This commit is contained in:
parent
356b8f1e43
commit
47a6585c88
298 changed files with 7977 additions and 4559 deletions
|
@ -6,7 +6,7 @@ php:
|
||||||
- 5.6
|
- 5.6
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- wget http://cs.sensiolabs.org/get/php-cs-fixer.phar
|
- wget http://get.sensiolabs.org/php-cs-fixer.phar
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- chmod +x scripts/tests/syntax.sh
|
- chmod +x scripts/tests/syntax.sh
|
||||||
|
|
|
@ -40,7 +40,9 @@ switch ($_REQUEST['action']) {
|
||||||
show_confirmation(T_('Deleted'), T_('Your Access List Entry has been removed'),$url);
|
show_confirmation(T_('Deleted'), T_('Your Access List Entry has been removed'),$url);
|
||||||
break;
|
break;
|
||||||
case 'show_delete_record':
|
case 'show_delete_record':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
$access = new Access($_GET['access_id']);
|
$access = new Access($_GET['access_id']);
|
||||||
show_confirmation(T_('Deletion Request'), T_('Are you sure you want to permanently delete') . ' ' . $access->name,
|
show_confirmation(T_('Deletion Request'), T_('Are you sure you want to permanently delete') . ' ' . $access->name,
|
||||||
'admin/access.php?action=delete_record&access_id=' . $access->id,1,'delete_access');
|
'admin/access.php?action=delete_record&access_id=' . $access->id,1,'delete_access');
|
||||||
|
|
|
@ -55,7 +55,9 @@ switch ($_REQUEST['action']) {
|
||||||
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
|
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
|
||||||
break;
|
break;
|
||||||
case 'add_to_catalog':
|
case 'add_to_catalog':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=add_to_catalog&catalogs=" . $sse_catalogs;
|
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=add_to_catalog&catalogs=" . $sse_catalogs;
|
||||||
sse_worker($sse_url);
|
sse_worker($sse_url);
|
||||||
|
@ -67,21 +69,28 @@ switch ($_REQUEST['action']) {
|
||||||
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
|
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
|
||||||
break;
|
break;
|
||||||
case 'update_catalog':
|
case 'update_catalog':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=update_catalog&catalogs=" . $sse_catalogs;
|
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=update_catalog&catalogs=" . $sse_catalogs;
|
||||||
sse_worker($sse_url);
|
sse_worker($sse_url);
|
||||||
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
|
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
|
||||||
break;
|
break;
|
||||||
case 'full_service':
|
case 'full_service':
|
||||||
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
UI::access_denied();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=full_service&catalogs=" . $sse_catalogs;
|
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=full_service&catalogs=" . $sse_catalogs;
|
||||||
sse_worker($sse_url);
|
sse_worker($sse_url);
|
||||||
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
|
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
|
||||||
break;
|
break;
|
||||||
case 'delete_catalog':
|
case 'delete_catalog':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Core::form_verify('delete_catalog')) {
|
if (!Core::form_verify('delete_catalog')) {
|
||||||
UI::access_denied();
|
UI::access_denied();
|
||||||
|
@ -92,7 +101,9 @@ switch ($_REQUEST['action']) {
|
||||||
/* Delete the sucker, we don't need to check perms as thats done above */
|
/* Delete the sucker, we don't need to check perms as thats done above */
|
||||||
foreach ($catalogs as $catalog_id) {
|
foreach ($catalogs as $catalog_id) {
|
||||||
$deleted = Catalog::delete($catalog_id);
|
$deleted = Catalog::delete($catalog_id);
|
||||||
if (!$deleted) break;
|
if (!$deleted) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$next_url = AmpConfig::get('web_path') . '/admin/catalog.php';
|
$next_url = AmpConfig::get('web_path') . '/admin/catalog.php';
|
||||||
if ($deleted) {
|
if ($deleted) {
|
||||||
|
@ -106,7 +117,9 @@ switch ($_REQUEST['action']) {
|
||||||
show_confirmation(T_('Catalog Delete'), T_('Confirm Deletion Request'),$next_url,1,'delete_catalog');
|
show_confirmation(T_('Catalog Delete'), T_('Confirm Deletion Request'),$next_url,1,'delete_catalog');
|
||||||
break;
|
break;
|
||||||
case 'enable_disabled':
|
case 'enable_disabled':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$songs = $_REQUEST['song'];
|
$songs = $_REQUEST['song'];
|
||||||
|
|
||||||
|
@ -134,7 +147,9 @@ switch ($_REQUEST['action']) {
|
||||||
break;
|
break;
|
||||||
case 'update_catalog_settings':
|
case 'update_catalog_settings':
|
||||||
/* No Demo Here! */
|
/* No Demo Here! */
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update the catalog */
|
/* Update the catalog */
|
||||||
Catalog::update_settings($_POST);
|
Catalog::update_settings($_POST);
|
||||||
|
@ -145,7 +160,9 @@ switch ($_REQUEST['action']) {
|
||||||
show_confirmation($title,$body,$url);
|
show_confirmation($title,$body,$url);
|
||||||
break;
|
break;
|
||||||
case 'update_from':
|
case 'update_from':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=update_from&add_path=" . scrub_in($_POST['add_path']) . "&update_path=" . $_POST['update_path'];
|
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=update_from&add_path=" . scrub_in($_POST['add_path']) . "&update_path=" . $_POST['update_path'];
|
||||||
sse_worker($sse_url);
|
sse_worker($sse_url);
|
||||||
|
@ -153,7 +170,9 @@ switch ($_REQUEST['action']) {
|
||||||
break;
|
break;
|
||||||
case 'add_catalog':
|
case 'add_catalog':
|
||||||
/* Wah Demo! */
|
/* Wah Demo! */
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
|
|
||||||
|
@ -172,7 +191,6 @@ switch ($_REQUEST['action']) {
|
||||||
|
|
||||||
// If an error hasn't occured
|
// 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) {
|
if (!$catalog_id) {
|
||||||
|
@ -189,7 +207,10 @@ switch ($_REQUEST['action']) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'clear_stats':
|
case 'clear_stats':
|
||||||
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
UI::access_denied();
|
||||||
|
break;
|
||||||
|
}
|
||||||
Stats::clear();
|
Stats::clear();
|
||||||
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
|
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
|
||||||
$title = T_('Catalog statistics cleared');
|
$title = T_('Catalog statistics cleared');
|
||||||
|
@ -200,13 +221,18 @@ switch ($_REQUEST['action']) {
|
||||||
require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php';
|
require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php';
|
||||||
break;
|
break;
|
||||||
case 'clear_now_playing':
|
case 'clear_now_playing':
|
||||||
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
UI::access_denied();
|
||||||
|
break;
|
||||||
|
}
|
||||||
Stream::clear_now_playing();
|
Stream::clear_now_playing();
|
||||||
show_confirmation(T_('Now Playing Cleared'), T_('All now playing data has been cleared'),AmpConfig::get('web_path') . '/admin/catalog.php');
|
show_confirmation(T_('Now Playing Cleared'), T_('All now playing data has been cleared'),AmpConfig::get('web_path') . '/admin/catalog.php');
|
||||||
break;
|
break;
|
||||||
case 'show_disabled':
|
case 'show_disabled':
|
||||||
/* Stop the demo hippies */
|
/* Stop the demo hippies */
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$songs = Song::get_disabled();
|
$songs = Song::get_disabled();
|
||||||
if (count($songs)) {
|
if (count($songs)) {
|
||||||
|
@ -217,7 +243,10 @@ switch ($_REQUEST['action']) {
|
||||||
break;
|
break;
|
||||||
case 'show_delete_catalog':
|
case 'show_delete_catalog':
|
||||||
/* Stop the demo hippies */
|
/* Stop the demo hippies */
|
||||||
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
UI::access_denied();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$catalog = Catalog::create_from_id($_REQUEST['catalog_id']);
|
$catalog = Catalog::create_from_id($_REQUEST['catalog_id']);
|
||||||
$nexturl = AmpConfig::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']);
|
$nexturl = AmpConfig::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']);
|
||||||
|
|
|
@ -32,7 +32,9 @@ UI::show_header();
|
||||||
// Switch on the actions
|
// Switch on the actions
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'update_user':
|
case 'update_user':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Core::form_verify('edit_user','post')) {
|
if (!Core::form_verify('edit_user','post')) {
|
||||||
UI::access_denied();
|
UI::access_denied();
|
||||||
|
@ -112,7 +114,9 @@ switch ($_REQUEST['action']) {
|
||||||
show_confirmation(T_('User Updated'), $client->fullname . "(" . $client->username . ")" . T_('updated'), AmpConfig::get('web_path'). '/admin/users.php');
|
show_confirmation(T_('User Updated'), $client->fullname . "(" . $client->username . ")" . T_('updated'), AmpConfig::get('web_path'). '/admin/users.php');
|
||||||
break;
|
break;
|
||||||
case 'add_user':
|
case 'add_user':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Core::form_verify('add_user','post')) {
|
if (!Core::form_verify('add_user','post')) {
|
||||||
UI::access_denied();
|
UI::access_denied();
|
||||||
|
@ -161,7 +165,13 @@ switch ($_REQUEST['action']) {
|
||||||
$user = new User($user_id);
|
$user = new User($user_id);
|
||||||
$user->upload_avatar();
|
$user->upload_avatar();
|
||||||
|
|
||||||
if ($access == 5) { $access = T_('Guest');} elseif ($access == 25) { $access = T_('User');} elseif ($access == 100) { $access = T_('Admin');}
|
if ($access == 5) {
|
||||||
|
$access = T_('Guest');
|
||||||
|
} elseif ($access == 25) {
|
||||||
|
$access = T_('User');
|
||||||
|
} elseif ($access == 100) {
|
||||||
|
$access = T_('Admin');
|
||||||
|
}
|
||||||
|
|
||||||
/* HINT: %1 Username, %2 Access num */
|
/* HINT: %1 Username, %2 Access num */
|
||||||
show_confirmation(T_('New User Added'),sprintf(T_('%1$s has been created with an access level of %2$s'), $username, $access), AmpConfig::get('web_path').'/admin/users.php');
|
show_confirmation(T_('New User Added'),sprintf(T_('%1$s has been created with an access level of %2$s'), $username, $access), AmpConfig::get('web_path').'/admin/users.php');
|
||||||
|
@ -183,12 +193,16 @@ switch ($_REQUEST['action']) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'show_edit':
|
case 'show_edit':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
$client = new User($_REQUEST['user_id']);
|
$client = new User($_REQUEST['user_id']);
|
||||||
require_once AmpConfig::get('prefix') . '/templates/show_edit_user.inc.php';
|
require_once AmpConfig::get('prefix') . '/templates/show_edit_user.inc.php';
|
||||||
break;
|
break;
|
||||||
case 'confirm_delete':
|
case 'confirm_delete':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (!Core::form_verify('delete_user')) {
|
if (!Core::form_verify('delete_user')) {
|
||||||
UI::access_denied();
|
UI::access_denied();
|
||||||
exit;
|
exit;
|
||||||
|
@ -201,7 +215,9 @@ switch ($_REQUEST['action']) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
$client = new User($_REQUEST['user_id']);
|
$client = new User($_REQUEST['user_id']);
|
||||||
show_confirmation(T_('Deletion Request'),
|
show_confirmation(T_('Deletion Request'),
|
||||||
sprintf(T_('Are you sure you want to permanently delete %s?'), $client->fullname),
|
sprintf(T_('Are you sure you want to permanently delete %s?'), $client->fullname),
|
||||||
|
@ -214,7 +230,9 @@ switch ($_REQUEST['action']) {
|
||||||
show_confirmation(T_('User Avatar Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_avatar');
|
show_confirmation(T_('User Avatar Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_avatar');
|
||||||
break;
|
break;
|
||||||
case 'delete_avatar':
|
case 'delete_avatar':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Core::form_verify('delete_avatar','post')) {
|
if (!Core::form_verify('delete_avatar','post')) {
|
||||||
UI::access_denied();
|
UI::access_denied();
|
||||||
|
@ -234,7 +252,9 @@ switch ($_REQUEST['action']) {
|
||||||
show_confirmation(T_('Generate new API Key'), T_('Confirm API Key Generation'), $next_url, 1, 'generate_apikey');
|
show_confirmation(T_('Generate new API Key'), T_('Confirm API Key Generation'), $next_url, 1, 'generate_apikey');
|
||||||
break;
|
break;
|
||||||
case 'generate_apikey':
|
case 'generate_apikey':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Core::form_verify('generate_apikey','post')) {
|
if (!Core::form_verify('generate_apikey','post')) {
|
||||||
UI::access_denied();
|
UI::access_denied();
|
||||||
|
@ -260,7 +280,9 @@ switch ($_REQUEST['action']) {
|
||||||
require AmpConfig::get('prefix') . '/templates/show_ip_history.inc.php';
|
require AmpConfig::get('prefix') . '/templates/show_ip_history.inc.php';
|
||||||
break;
|
break;
|
||||||
case 'show_add_user':
|
case 'show_add_user':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
require_once AmpConfig::get('prefix') . '/templates/show_add_user.inc.php';
|
require_once AmpConfig::get('prefix') . '/templates/show_add_user.inc.php';
|
||||||
break;
|
break;
|
||||||
case 'show_preferences':
|
case 'show_preferences':
|
||||||
|
|
|
@ -27,7 +27,9 @@ require_once AmpConfig::get('prefix') . '/templates/header.inc.php';
|
||||||
/* Switch on Action */
|
/* Switch on Action */
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$album_id = scrub_in($_REQUEST['album_id']);
|
$album_id = scrub_in($_REQUEST['album_id']);
|
||||||
show_confirmation(
|
show_confirmation(
|
||||||
|
@ -39,7 +41,9 @@ switch ($_REQUEST['action']) {
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'confirm_delete':
|
case 'confirm_delete':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$album = new Album($_REQUEST['album_id']);
|
$album = new Album($_REQUEST['album_id']);
|
||||||
if (!Catalog::can_remove($album)) {
|
if (!Catalog::can_remove($album)) {
|
||||||
|
|
14
artists.php
14
artists.php
|
@ -29,7 +29,9 @@ UI::show_header();
|
||||||
*/
|
*/
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$artist_id = scrub_in($_REQUEST['artist_id']);
|
$artist_id = scrub_in($_REQUEST['artist_id']);
|
||||||
show_confirmation(
|
show_confirmation(
|
||||||
|
@ -41,7 +43,9 @@ switch ($_REQUEST['action']) {
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'confirm_delete':
|
case 'confirm_delete':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$artist = new Artist($_REQUEST['artist_id']);
|
$artist = new Artist($_REQUEST['artist_id']);
|
||||||
if (!Catalog::can_remove($artist)) {
|
if (!Catalog::can_remove($artist)) {
|
||||||
|
@ -83,7 +87,11 @@ switch ($_REQUEST['action']) {
|
||||||
case 'match':
|
case 'match':
|
||||||
case 'Match':
|
case 'Match':
|
||||||
$match = scrub_in($_REQUEST['match']);
|
$match = scrub_in($_REQUEST['match']);
|
||||||
if ($match == "Browse" || $match == "Show_all") { $chr = ""; } else { $chr = $match; }
|
if ($match == "Browse" || $match == "Show_all") {
|
||||||
|
$chr = "";
|
||||||
|
} else {
|
||||||
|
$chr = $match;
|
||||||
|
}
|
||||||
/* Enclose this in the purty box! */
|
/* Enclose this in the purty box! */
|
||||||
require AmpConfig::get('prefix') . '/templates/show_box_top.inc.php';
|
require AmpConfig::get('prefix') . '/templates/show_box_top.inc.php';
|
||||||
show_alphabet_list('artists','artists.php',$match);
|
show_alphabet_list('artists','artists.php',$match);
|
||||||
|
|
12
arts.php
12
arts.php
|
@ -26,7 +26,10 @@ require_once AmpConfig::get('prefix') . '/templates/header.inc.php';
|
||||||
|
|
||||||
$object_type = $_GET['object_type'];
|
$object_type = $_GET['object_type'];
|
||||||
$object_id = $_GET['object_id'];
|
$object_id = $_GET['object_id'];
|
||||||
if (!Core::is_library_item($object_type)) { UI::access_denied(); exit; }
|
if (!Core::is_library_item($object_type)) {
|
||||||
|
UI::access_denied();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
$burl = '';
|
$burl = '';
|
||||||
if (isset($_GET['burl'])) {
|
if (isset($_GET['burl'])) {
|
||||||
$burl = base64_decode($_GET['burl']);
|
$burl = base64_decode($_GET['burl']);
|
||||||
|
@ -34,7 +37,10 @@ if (isset($_GET['burl'])) {
|
||||||
$item = new $object_type($object_id);
|
$item = new $object_type($object_id);
|
||||||
|
|
||||||
// If not a content manager user then kick em out
|
// If not a content manager user then kick em out
|
||||||
if (!Access::check('interface', 50) && (!Access::check('interface', 25) || $item->get_user_owner() != $GLOBALS['user']->id)) { UI::access_denied(); exit; }
|
if (!Access::check('interface', 50) && (!Access::check('interface', 25) || $item->get_user_owner() != $GLOBALS['user']->id)) {
|
||||||
|
UI::access_denied();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* Switch on Action */
|
/* Switch on Action */
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
|
@ -87,9 +93,7 @@ switch ($_REQUEST['action']) {
|
||||||
$art->insert($image_data,$upload['0']['mime']);
|
$art->insert($image_data,$upload['0']['mime']);
|
||||||
show_confirmation(T_('Art Inserted'), '', $burl);
|
show_confirmation(T_('Art Inserted'), '', $burl);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} // if image data
|
} // if image data
|
||||||
|
|
||||||
} // if it's an upload
|
} // if it's an upload
|
||||||
|
|
||||||
$keywords = $item->get_keywords();
|
$keywords = $item->get_keywords();
|
||||||
|
|
|
@ -50,7 +50,9 @@ if (count($params) > 0) {
|
||||||
$act = strtolower(implode('_', array_slice($params, 0, $i)));
|
$act = strtolower(implode('_', array_slice($params, 0, $i)));
|
||||||
$act = str_replace("-", "_", $act);
|
$act = str_replace("-", "_", $act);
|
||||||
foreach ($methods as $method) {
|
foreach ($methods as $method) {
|
||||||
if (in_array($method, $internal_functions)) { continue; }
|
if (in_array($method, $internal_functions)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// If the method is the same as the action being called
|
// If the method is the same as the action being called
|
||||||
// Then let's call this function!
|
// Then let's call this function!
|
||||||
|
@ -59,7 +61,6 @@ if (count($params) > 0) {
|
||||||
// We only allow a single function to be called, and we assume it's cleaned up!
|
// 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,9 @@ if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we aren't resizing just trash thumb
|
// If we aren't resizing just trash thumb
|
||||||
if (!AmpConfig::get('resize_images')) { $_GET['thumb'] = null; }
|
if (!AmpConfig::get('resize_images')) {
|
||||||
|
$_GET['thumb'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Legacy stuff - should be removed after a version or so
|
// FIXME: Legacy stuff - should be removed after a version or so
|
||||||
if (!isset($_GET['object_type'])) {
|
if (!isset($_GET['object_type'])) {
|
||||||
|
@ -49,8 +51,9 @@ if (!isset($_GET['object_type'])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = $_GET['object_type'];
|
$type = $_GET['object_type'];
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
exit;
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* Decide what size this image is */
|
/* Decide what size this image is */
|
||||||
$size = Art::get_thumb_size($_GET['thumb']);
|
$size = Art::get_thumb_size($_GET['thumb']);
|
||||||
|
|
|
@ -166,7 +166,9 @@ switch ($_REQUEST['action']) {
|
||||||
}
|
}
|
||||||
case 'show_create_account':
|
case 'show_create_account':
|
||||||
$results = parse_ini_file($configfile);
|
$results = parse_ini_file($configfile);
|
||||||
if (!isset($created_config)) $created_config = true;
|
if (!isset($created_config)) {
|
||||||
|
$created_config = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure we've got a valid config file */
|
/* Make sure we've got a valid config file */
|
||||||
if (!check_config_values($results) || !$created_config) {
|
if (!check_config_values($results) || !$created_config) {
|
||||||
|
@ -212,3 +214,4 @@ switch ($_REQUEST['action']) {
|
||||||
require_once 'templates/show_install_lang.inc.php';
|
require_once 'templates/show_install_lang.inc.php';
|
||||||
break;
|
break;
|
||||||
} // end action switch
|
} // end action switch
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,9 @@ UI::show_header();
|
||||||
// Switch on the incomming action
|
// Switch on the incomming action
|
||||||
switch ($_REQUEST['action']) {
|
switch ($_REQUEST['action']) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$label_id = scrub_in($_REQUEST['label_id']);
|
$label_id = scrub_in($_REQUEST['label_id']);
|
||||||
show_confirmation(
|
show_confirmation(
|
||||||
|
@ -39,7 +41,9 @@ switch ($_REQUEST['action']) {
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'confirm_delete':
|
case 'confirm_delete':
|
||||||
if (AmpConfig::get('demo_mode')) { break; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$label = new Label($_REQUEST['label_id']);
|
$label = new Label($_REQUEST['label_id']);
|
||||||
if (!Catalog::can_remove($label)) {
|
if (!Catalog::can_remove($label)) {
|
||||||
|
|
|
@ -93,7 +93,9 @@ class Access
|
||||||
*/
|
*/
|
||||||
public function __construct($access_id = null)
|
public function __construct($access_id = null)
|
||||||
{
|
{
|
||||||
if (!$access_id) { return false; }
|
if (!$access_id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Assign id for use in get_info() */
|
/* Assign id for use in get_info() */
|
||||||
$this->id = intval($access_id);
|
$this->id = intval($access_id);
|
||||||
|
@ -232,7 +234,6 @@ class Access
|
||||||
Dba::write($sql, array($name, $level, $start, $end, $user, $type, $enabled));
|
Dba::write($sql, array($name, $level, $start, $end, $user, $type, $enabled));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -476,7 +477,9 @@ class Access
|
||||||
*/
|
*/
|
||||||
public function get_user_name()
|
public function get_user_name()
|
||||||
{
|
{
|
||||||
if ($this->user == '-1') { return T_('All'); }
|
if ($this->user == '-1') {
|
||||||
|
return T_('All');
|
||||||
|
}
|
||||||
|
|
||||||
$user = new User($this->user);
|
$user = new User($this->user);
|
||||||
return $user->fullname . " (" . $user->username . ")";
|
return $user->fullname . " (" . $user->username . ")";
|
||||||
|
|
|
@ -40,7 +40,6 @@ class Ajax
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Rien a faire
|
// Rien a faire
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +77,6 @@ class Ajax
|
||||||
$observe .= "</script>";
|
$observe .= "</script>";
|
||||||
|
|
||||||
return $observe;
|
return $observe;
|
||||||
|
|
||||||
} // observe
|
} // observe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,7 +118,6 @@ class Ajax
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ajax_string;
|
return $ajax_string;
|
||||||
|
|
||||||
} // action
|
} // action
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,7 +153,6 @@ class Ajax
|
||||||
$string .= self::observe($source, 'click', $ajax_string, $confirm);
|
$string .= self::observe($source, 'click', $ajax_string, $confirm);
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
|
|
||||||
} // button
|
} // button
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +189,6 @@ class Ajax
|
||||||
}
|
}
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
|
|
||||||
} // text
|
} // text
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -206,7 +201,6 @@ class Ajax
|
||||||
echo "<script type=\"text/javascript\"><!--\n";
|
echo "<script type=\"text/javascript\"><!--\n";
|
||||||
echo "$action";
|
echo "$action";
|
||||||
echo "\n--></script>";
|
echo "\n--></script>";
|
||||||
|
|
||||||
} // run
|
} // run
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,7 +212,6 @@ class Ajax
|
||||||
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
|
} // set_include_override
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,14 +223,15 @@ class Ajax
|
||||||
*/
|
*/
|
||||||
public static function start_container($name, $class = '')
|
public static function start_container($name, $class = '')
|
||||||
{
|
{
|
||||||
if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; }
|
if (defined('AJAX_INCLUDE') && !self::$include_override) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
echo '<div id="' . scrub_out($name) . '"';
|
echo '<div id="' . scrub_out($name) . '"';
|
||||||
if (!empty($class)) {
|
if (!empty($class)) {
|
||||||
echo ' class="' . scrub_out($class) . '"';
|
echo ' class="' . scrub_out($class) . '"';
|
||||||
}
|
}
|
||||||
echo '>';
|
echo '>';
|
||||||
|
|
||||||
} // start_container
|
} // start_container
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -246,12 +240,13 @@ class Ajax
|
||||||
*/
|
*/
|
||||||
public static function end_container()
|
public static function end_container()
|
||||||
{
|
{
|
||||||
if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; }
|
if (defined('AJAX_INCLUDE') && !self::$include_override) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
|
|
||||||
self::$include_override = false;
|
self::$include_override = false;
|
||||||
|
|
||||||
} // end_container
|
} // end_container
|
||||||
|
|
||||||
} // end Ajax class
|
} // end Ajax class
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,9 @@ class Album extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public function __construct($id=null)
|
public function __construct($id=null)
|
||||||
{
|
{
|
||||||
if (!$id) { return false; }
|
if (!$id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the information from the db */
|
/* Get the information from the db */
|
||||||
$info = $this->get_info($id);
|
$info = $this->get_info($id);
|
||||||
|
@ -206,7 +208,6 @@ class Album extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,7 +227,6 @@ class Album extends database_object implements library_item
|
||||||
$album->_fake = true; // Make sure that we tell em it's fake
|
$album->_fake = true; // Make sure that we tell em it's fake
|
||||||
|
|
||||||
return $album;
|
return $album;
|
||||||
|
|
||||||
} // construct_from_array
|
} // construct_from_array
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,7 +263,6 @@ class Album extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // build_cache
|
} // build_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -333,7 +332,6 @@ class Album extends database_object implements library_item
|
||||||
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
|
} // _get_extra_info
|
||||||
|
|
||||||
public function can_edit($user = null)
|
public function can_edit($user = null)
|
||||||
|
@ -342,20 +340,25 @@ class Album extends database_object implements library_item
|
||||||
$user = $GLOBALS['user']->id;
|
$user = $GLOBALS['user']->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user)
|
if (!$user) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->user !== null && $user == $this->user)
|
if ($this->user !== null && $user == $this->user) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (Access::check('interface', 50, $user))
|
if (Access::check('interface', 50, $user)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->album_artist)
|
if (!$this->album_artist) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!AmpConfig::get('upload_allow_edit'))
|
if (!AmpConfig::get('upload_allow_edit')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$owner = $this->get_user_owner();
|
$owner = $this->get_user_owner();
|
||||||
return ($owner && $owner === $user);
|
return ($owner && $owner === $user);
|
||||||
|
@ -410,8 +413,8 @@ class Album extends database_object implements library_item
|
||||||
$sql .= 'AND `album`.`mbid` IS NULL ';
|
$sql .= 'AND `album`.`mbid` IS NULL ';
|
||||||
}
|
}
|
||||||
if ($prefix) {
|
if ($prefix) {
|
||||||
$sql .= 'AND `album`.`prefix` = ? ';
|
$sql .= 'AND `album`.`prefix` = ? ';
|
||||||
$params[] = $prefix;
|
$params[] = $prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($album_artist) {
|
if ($album_artist) {
|
||||||
|
@ -490,7 +493,6 @@ class Album extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_songs
|
} // get_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -554,7 +556,6 @@ class Album extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_album_suite
|
} // get_album_suite
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -571,7 +572,6 @@ class Album extends database_object implements library_item
|
||||||
$data = Dba::fetch_assoc($db_results);
|
$data = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // has_track
|
} // has_track
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -605,7 +605,9 @@ class Album extends database_object implements library_item
|
||||||
if ($details) {
|
if ($details) {
|
||||||
/* Pull the advanced information */
|
/* Pull the advanced information */
|
||||||
$data = $this->_get_extra_info($limit_threshold);
|
$data = $this->_get_extra_info($limit_threshold);
|
||||||
foreach ($data as $key=>$value) { $this->$key = $value; }
|
foreach ($data as $key=>$value) {
|
||||||
|
$this->$key = $value;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->album_artist) {
|
if ($this->album_artist) {
|
||||||
$Album_artist = new Artist($this->album_artist);
|
$Album_artist = new Artist($this->album_artist);
|
||||||
|
@ -649,7 +651,6 @@ class Album extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->f_release_type = ucwords($this->release_type);
|
$this->f_release_type = ucwords($this->release_type);
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -773,8 +774,9 @@ class Album extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public function get_user_owner()
|
public function get_user_owner()
|
||||||
{
|
{
|
||||||
if (!$this->album_artist)
|
if (!$this->album_artist) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$artist = new Artist($this->album_artist);
|
$artist = new Artist($this->album_artist);
|
||||||
return $artist->get_user_owner();
|
return $artist->get_user_owner();
|
||||||
|
@ -804,9 +806,11 @@ class Album extends database_object implements library_item
|
||||||
if (Art::has_db($this->id, 'album')) {
|
if (Art::has_db($this->id, 'album')) {
|
||||||
$id = $this->id;
|
$id = $this->id;
|
||||||
$type = 'album';
|
$type = 'album';
|
||||||
} else if (Art::has_db($this->artist_id, 'artist')) {
|
} else {
|
||||||
$id = $this->artist_id;
|
if (Art::has_db($this->artist_id, 'artist')) {
|
||||||
$type = 'artist';
|
$id = $this->artist_id;
|
||||||
|
$type = 'artist';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id !== null && $type !== null) {
|
if ($id !== null && $type !== null) {
|
||||||
|
@ -838,7 +842,6 @@ class Album extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_random_songs
|
} // get_random_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -880,7 +883,9 @@ class Album extends database_object implements library_item
|
||||||
|
|
||||||
$album_id = self::check($name, $year, $disk, $mbid, $mbid_group, $album_artist, $release_type);
|
$album_id = self::check($name, $year, $disk, $mbid, $mbid_group, $album_artist, $release_type);
|
||||||
if ($album_id != $this->id) {
|
if ($album_id != $this->id) {
|
||||||
if (!is_array($songs)) { $songs = $this->get_songs(); }
|
if (!is_array($songs)) {
|
||||||
|
$songs = $this->get_songs();
|
||||||
|
}
|
||||||
foreach ($songs as $song_id) {
|
foreach ($songs as $song_id) {
|
||||||
Song::update_album($album_id,$song_id);
|
Song::update_album($album_id,$song_id);
|
||||||
Song::update_year($year,$song_id);
|
Song::update_year($year,$song_id);
|
||||||
|
@ -928,7 +933,6 @@ class Album extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $current_id;
|
return $current_id;
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1067,5 +1071,5 @@ class Album extends database_object implements library_item
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end of album class
|
} //end of album class
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ class Ampache_RSS
|
||||||
public function __construct($type)
|
public function __construct($type)
|
||||||
{
|
{
|
||||||
$this->type = self::validate_type($type);
|
$this->type = self::validate_type($type);
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +80,6 @@ class Ampache_RSS
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} // get_xml
|
} // get_xml
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +97,6 @@ class Ampache_RSS
|
||||||
);
|
);
|
||||||
|
|
||||||
return scrub_out(AmpConfig::get('site_title')) . ' - ' . $titles[$this->type];
|
return scrub_out(AmpConfig::get('site_title')) . ' - ' . $titles[$this->type];
|
||||||
|
|
||||||
} // get_title
|
} // get_title
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +108,6 @@ class Ampache_RSS
|
||||||
{
|
{
|
||||||
//FIXME: For now don't do any kind of translating
|
//FIXME: For now don't do any kind of translating
|
||||||
return 'Ampache RSS Feeds';
|
return 'Ampache RSS Feeds';
|
||||||
|
|
||||||
} // get_description
|
} // get_description
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,7 +125,6 @@ class Ampache_RSS
|
||||||
}
|
}
|
||||||
|
|
||||||
return $type;
|
return $type;
|
||||||
|
|
||||||
} // validate_type
|
} // validate_type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,7 +154,6 @@ class Ampache_RSS
|
||||||
$string .= '</a>';
|
$string .= '</a>';
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
|
|
||||||
} // get_display
|
} // get_display
|
||||||
|
|
||||||
// type specific functions below, these are called semi-dynamically based on the current type //
|
// type specific functions below, these are called semi-dynamically based on the current type //
|
||||||
|
@ -203,7 +197,6 @@ class Ampache_RSS
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // load_now_playing
|
} // load_now_playing
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,7 +213,6 @@ class Ampache_RSS
|
||||||
$element = array_shift($data);
|
$element = array_shift($data);
|
||||||
|
|
||||||
return $element['expire'];
|
return $element['expire'];
|
||||||
|
|
||||||
} // pubdate_now_playing
|
} // pubdate_now_playing
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -276,11 +268,9 @@ class Ampache_RSS
|
||||||
'comments'=>$client->username,
|
'comments'=>$client->username,
|
||||||
'pubDate'=>date("r",$item['date']));
|
'pubDate'=>date("r",$item['date']));
|
||||||
$results[] = $xml_array;
|
$results[] = $xml_array;
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // load_recently_played
|
} // load_recently_played
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -306,11 +296,9 @@ class Ampache_RSS
|
||||||
'pubDate' => date("c", $album->get_addtime_first_song())
|
'pubDate' => date("c", $album->get_addtime_first_song())
|
||||||
);
|
);
|
||||||
$results[] = $xml_array;
|
$results[] = $xml_array;
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // load_latest_album
|
} // load_latest_album
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -336,11 +324,9 @@ class Ampache_RSS
|
||||||
'pubDate' => ''
|
'pubDate' => ''
|
||||||
);
|
);
|
||||||
$results[] = $xml_array;
|
$results[] = $xml_array;
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // load_latest_artist
|
} // load_latest_artist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -370,11 +356,9 @@ class Ampache_RSS
|
||||||
'pubDate' => date("c", $shout->date)
|
'pubDate' => date("c", $shout->date)
|
||||||
);
|
);
|
||||||
$results[] = $xml_array;
|
$results[] = $xml_array;
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // load_latest_shout
|
} // load_latest_shout
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -389,7 +373,6 @@ class Ampache_RSS
|
||||||
$element = array_shift($data);
|
$element = array_shift($data);
|
||||||
|
|
||||||
return $element['date'];
|
return $element['date'];
|
||||||
|
|
||||||
} // pubdate_recently_played
|
} // pubdate_recently_played
|
||||||
|
|
||||||
} // end Ampache_RSS class
|
} // end Ampache_RSS class
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ class Api
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
// Rien a faire
|
// Rien a faire
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +76,9 @@ class Api
|
||||||
*/
|
*/
|
||||||
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) {
|
switch ($filter) {
|
||||||
case 'add':
|
case 'add':
|
||||||
|
@ -112,7 +113,6 @@ class Api
|
||||||
} // end filter
|
} // end filter
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // set_filter
|
} // set_filter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -257,7 +257,6 @@ class Api
|
||||||
'catalogs'=>$catalog['catalog']));
|
'catalogs'=>$catalog['catalog']));
|
||||||
return true;
|
return true;
|
||||||
} // match
|
} // match
|
||||||
|
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
debug_event('API','Login Failed, unable to match passphrase','1');
|
debug_event('API','Login Failed, unable to match passphrase','1');
|
||||||
|
@ -286,7 +285,6 @@ class Api
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::keyed_array($xmldata);
|
echo XML_Data::keyed_array($xmldata);
|
||||||
|
|
||||||
} // ping
|
} // ping
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,7 +313,6 @@ class Api
|
||||||
// echo out the resulting xml document
|
// echo out the resulting xml document
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::artists($artists);
|
echo XML_Data::artists($artists);
|
||||||
|
|
||||||
} // artists
|
} // artists
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -328,7 +325,6 @@ class Api
|
||||||
{
|
{
|
||||||
$uid = scrub_in($input['filter']);
|
$uid = scrub_in($input['filter']);
|
||||||
echo XML_Data::artists(array($uid));
|
echo XML_Data::artists(array($uid));
|
||||||
|
|
||||||
} // artist
|
} // artist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,7 +343,6 @@ class Api
|
||||||
XML_Data::set_limit($input['limit']);
|
XML_Data::set_limit($input['limit']);
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::albums($albums);
|
echo XML_Data::albums($albums);
|
||||||
|
|
||||||
} // artist_albums
|
} // artist_albums
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -365,7 +360,6 @@ class Api
|
||||||
XML_Data::set_limit($input['limit']);
|
XML_Data::set_limit($input['limit']);
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::songs($songs);
|
echo XML_Data::songs($songs);
|
||||||
|
|
||||||
} // artist_songs
|
} // artist_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -390,7 +384,6 @@ class Api
|
||||||
XML_Data::set_limit($input['limit']);
|
XML_Data::set_limit($input['limit']);
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::albums($albums);
|
echo XML_Data::albums($albums);
|
||||||
|
|
||||||
} // albums
|
} // albums
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -402,7 +395,6 @@ class Api
|
||||||
{
|
{
|
||||||
$uid = scrub_in($input['filter']);
|
$uid = scrub_in($input['filter']);
|
||||||
echo XML_Data::albums(array($uid));
|
echo XML_Data::albums(array($uid));
|
||||||
|
|
||||||
} // album
|
} // album
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -421,7 +413,6 @@ class Api
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::songs($songs);
|
echo XML_Data::songs($songs);
|
||||||
|
|
||||||
} // album_songs
|
} // album_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -445,7 +436,6 @@ class Api
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::tags($tags);
|
echo XML_Data::tags($tags);
|
||||||
|
|
||||||
} // tags
|
} // tags
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,7 +448,6 @@ class Api
|
||||||
$uid = scrub_in($input['filter']);
|
$uid = scrub_in($input['filter']);
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::tags(array($uid));
|
echo XML_Data::tags(array($uid));
|
||||||
|
|
||||||
} // tag
|
} // tag
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -476,7 +465,6 @@ class Api
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::artists($artists);
|
echo XML_Data::artists($artists);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // tag_artists
|
} // tag_artists
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -494,7 +482,6 @@ class Api
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::albums($albums);
|
echo XML_Data::albums($albums);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // tag_albums
|
} // tag_albums
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -511,7 +498,6 @@ class Api
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::songs($songs);
|
echo XML_Data::songs($songs);
|
||||||
|
|
||||||
} // tag_songs
|
} // tag_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -538,7 +524,6 @@ class Api
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::songs($songs);
|
echo XML_Data::songs($songs);
|
||||||
|
|
||||||
} // songs
|
} // songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -552,7 +537,6 @@ class Api
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::songs(array($uid));
|
echo XML_Data::songs(array($uid));
|
||||||
|
|
||||||
} // song
|
} // song
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -590,7 +574,6 @@ class Api
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::playlists($playlist_ids);
|
echo XML_Data::playlists($playlist_ids);
|
||||||
|
|
||||||
} // playlists
|
} // playlists
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -604,7 +587,6 @@ class Api
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::playlists(array($uid));
|
echo XML_Data::playlists(array($uid));
|
||||||
|
|
||||||
} // playlist
|
} // playlist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -628,7 +610,6 @@ class Api
|
||||||
XML_Data::set_limit($input['limit']);
|
XML_Data::set_limit($input['limit']);
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo XML_Data::songs($songs,$items);
|
echo XML_Data::songs($songs,$items);
|
||||||
|
|
||||||
} // playlist_songs
|
} // playlist_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -681,7 +662,6 @@ class Api
|
||||||
$playlist->add_songs(array($song));
|
$playlist->add_songs(array($song));
|
||||||
echo XML_Data::single_string('success');
|
echo XML_Data::single_string('success');
|
||||||
}
|
}
|
||||||
|
|
||||||
} // playlist_add_song
|
} // playlist_add_song
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -700,7 +680,6 @@ class Api
|
||||||
$playlist->delete_track_number($track);
|
$playlist->delete_track_number($track);
|
||||||
echo XML_Data::single_string('success');
|
echo XML_Data::single_string('success');
|
||||||
}
|
}
|
||||||
|
|
||||||
} // playlist_remove_song
|
} // playlist_remove_song
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -724,7 +703,6 @@ class Api
|
||||||
$results = Search::run($array);
|
$results = Search::run($array);
|
||||||
|
|
||||||
echo XML_Data::songs($results);
|
echo XML_Data::songs($results);
|
||||||
|
|
||||||
} // search_songs
|
} // search_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -747,7 +725,6 @@ class Api
|
||||||
XML_Data::set_limit($input['limit']);
|
XML_Data::set_limit($input['limit']);
|
||||||
|
|
||||||
echo XML_Data::videos($video_ids);
|
echo XML_Data::videos($video_ids);
|
||||||
|
|
||||||
} // videos
|
} // videos
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -760,8 +737,6 @@ class Api
|
||||||
$video_id = scrub_in($input['filter']);
|
$video_id = scrub_in($input['filter']);
|
||||||
|
|
||||||
echo XML_Data::videos(array($video_id));
|
echo XML_Data::videos(array($video_id));
|
||||||
|
|
||||||
|
|
||||||
} // video
|
} // video
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -789,7 +764,6 @@ class Api
|
||||||
echo XML_Data::error('405', T_('Invalid Request'));
|
echo XML_Data::error('405', T_('Invalid Request'));
|
||||||
break;
|
break;
|
||||||
} // end switch on command
|
} // end switch on command
|
||||||
|
|
||||||
} // localplay
|
} // localplay
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -851,7 +825,6 @@ class Api
|
||||||
echo XML_Data::error('405', T_('Invalid Request'));
|
echo XML_Data::error('405', T_('Invalid Request'));
|
||||||
break;
|
break;
|
||||||
} // switch on method
|
} // switch on method
|
||||||
|
|
||||||
} // democratic
|
} // democratic
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -868,28 +841,36 @@ class Api
|
||||||
$albums = null;
|
$albums = null;
|
||||||
if ($type == "newest") {
|
if ($type == "newest") {
|
||||||
$albums = Stats::get_newest("album", $limit, $offset);
|
$albums = Stats::get_newest("album", $limit, $offset);
|
||||||
} else if ($type == "highest") {
|
|
||||||
$albums = Rating::get_highest("album", $limit, $offset);
|
|
||||||
} else if ($type == "frequent") {
|
|
||||||
$albums = Stats::get_top("album", $limit, '', $offset);
|
|
||||||
} else if ($type == "recent") {
|
|
||||||
if (!empty($username)) {
|
|
||||||
$user = User::get_from_username($username);
|
|
||||||
if ($user !== null) {
|
|
||||||
$albums = $user->get_recently_played($limit, 'album');
|
|
||||||
} else {
|
|
||||||
debug_event('api', 'User `' . $username . '` cannot be found.', 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$albums = Stats::get_recent("album", $limit, $offset);
|
|
||||||
}
|
|
||||||
} else if ($type == "flagged") {
|
|
||||||
$albums = Userflag::get_latest('album');
|
|
||||||
} else {
|
} else {
|
||||||
if (!$limit) {
|
if ($type == "highest") {
|
||||||
$limit = AmpConfig::get('popular_threshold');
|
$albums = Rating::get_highest("album", $limit, $offset);
|
||||||
|
} else {
|
||||||
|
if ($type == "frequent") {
|
||||||
|
$albums = Stats::get_top("album", $limit, '', $offset);
|
||||||
|
} else {
|
||||||
|
if ($type == "recent") {
|
||||||
|
if (!empty($username)) {
|
||||||
|
$user = User::get_from_username($username);
|
||||||
|
if ($user !== null) {
|
||||||
|
$albums = $user->get_recently_played($limit, 'album');
|
||||||
|
} else {
|
||||||
|
debug_event('api', 'User `' . $username . '` cannot be found.', 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$albums = Stats::get_recent("album", $limit, $offset);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($type == "flagged") {
|
||||||
|
$albums = Userflag::get_latest('album');
|
||||||
|
} else {
|
||||||
|
if (!$limit) {
|
||||||
|
$limit = AmpConfig::get('popular_threshold');
|
||||||
|
}
|
||||||
|
$albums = Album::get_random($limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$albums = Album::get_random($limit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($albums !== null) {
|
if ($albums !== null) {
|
||||||
|
@ -996,5 +977,5 @@ class Api
|
||||||
debug_event('api', 'Sociable feature is not enabled.', 3);
|
debug_event('api', 'Sociable feature is not enabled.', 3);
|
||||||
}
|
}
|
||||||
} // last_shouts
|
} // last_shouts
|
||||||
|
|
||||||
} // API class
|
} // API class
|
||||||
|
|
||||||
|
|
|
@ -81,12 +81,12 @@ class Art extends database_object
|
||||||
*/
|
*/
|
||||||
public function __construct($uid, $type = 'album', $kind = 'default')
|
public function __construct($uid, $type = 'album', $kind = 'default')
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->uid = intval($uid);
|
$this->uid = intval($uid);
|
||||||
$this->kind = $kind;
|
$this->kind = $kind;
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +99,9 @@ class Art extends database_object
|
||||||
*/
|
*/
|
||||||
public static function build_cache($object_ids)
|
public static function build_cache($object_ids)
|
||||||
{
|
{
|
||||||
if (!is_array($object_ids) || !count($object_ids)) { return false; }
|
if (!is_array($object_ids) || !count($object_ids)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$uidlist = '(' . implode(',', $object_ids) . ')';
|
$uidlist = '(' . implode(',', $object_ids) . ')';
|
||||||
$sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_id` IN $uidlist";
|
$sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_id` IN $uidlist";
|
||||||
$db_results = Dba::read($sql);
|
$db_results = Dba::read($sql);
|
||||||
|
@ -110,7 +112,6 @@ class Art extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // build_cache
|
} // build_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,10 +174,11 @@ class Art extends database_object
|
||||||
$data = explode("/", $mime);
|
$data = explode("/", $mime);
|
||||||
$extension = $data['1'];
|
$extension = $data['1'];
|
||||||
|
|
||||||
if ($extension == 'jpeg') { $extension = 'jpg'; }
|
if ($extension == 'jpeg') {
|
||||||
|
$extension = 'jpg';
|
||||||
|
}
|
||||||
|
|
||||||
return $extension;
|
return $extension;
|
||||||
|
|
||||||
} // extension
|
} // extension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,8 +204,8 @@ class Art extends database_object
|
||||||
// Check to make sure PHP:GD exists. If so, we can sanity check
|
// Check to make sure PHP:GD exists. If so, we can sanity check
|
||||||
// the image.
|
// the image.
|
||||||
if (function_exists('ImageCreateFromString')) {
|
if (function_exists('ImageCreateFromString')) {
|
||||||
$image = ImageCreateFromString($source);
|
$image = ImageCreateFromString($source);
|
||||||
if (!$image || imagesx($image) < 5 || imagesy($image) < 5) {
|
if (!$image || imagesx($image) < 5 || imagesy($image) < 5) {
|
||||||
debug_event('Art', 'Image failed PHP-GD test',1);
|
debug_event('Art', 'Image failed PHP-GD test',1);
|
||||||
$test = false;
|
$test = false;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +236,6 @@ class Art extends database_object
|
||||||
} else {
|
} else {
|
||||||
return $this->thumb;
|
return $this->thumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,18 +259,22 @@ class Art extends database_object
|
||||||
$this->raw = $results['image'];
|
$this->raw = $results['image'];
|
||||||
}
|
}
|
||||||
$this->raw_mime = $results['mime'];
|
$this->raw_mime = $results['mime'];
|
||||||
} else if (AmpConfig::get('resize_images') && $results['size'] == '275x275') {
|
} else {
|
||||||
if (AmpConfig::get('album_art_store_disk')) {
|
if (AmpConfig::get('resize_images') && $results['size'] == '275x275') {
|
||||||
$this->thumb = self::read_from_dir($results['size'], $this->type, $this->uid, $this->kind);
|
if (AmpConfig::get('album_art_store_disk')) {
|
||||||
} else {
|
$this->thumb = self::read_from_dir($results['size'], $this->type, $this->uid, $this->kind);
|
||||||
$this->thumb = $results['image'];
|
} else {
|
||||||
|
$this->thumb = $results['image'];
|
||||||
|
}
|
||||||
|
$this->raw_mime = $results['mime'];
|
||||||
}
|
}
|
||||||
$this->raw_mime = $results['mime'];
|
|
||||||
}
|
}
|
||||||
$this->id = $results['id'];
|
$this->id = $results['id'];
|
||||||
}
|
}
|
||||||
// If we get nothing return false
|
// If we get nothing return false
|
||||||
if (!$this->raw) { return false; }
|
if (!$this->raw) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// If there is no thumb and we want thumbs
|
// If there is no thumb and we want thumbs
|
||||||
if (!$this->thumb && AmpConfig::get('resize_images')) {
|
if (!$this->thumb && AmpConfig::get('resize_images')) {
|
||||||
|
@ -286,7 +291,6 @@ class Art extends database_object
|
||||||
} // if no thumb, but art and we want to resize
|
} // if no thumb, but art and we want to resize
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // get_db
|
} // get_db
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -345,7 +349,9 @@ class Art extends database_object
|
||||||
public function insert($source, $mime = '')
|
public function insert($source, $mime = '')
|
||||||
{
|
{
|
||||||
// Disabled in demo mode cause people suck and upload porn
|
// Disabled in demo mode cause people suck and upload porn
|
||||||
if (AmpConfig::get('demo_mode')) { return false; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Check to make sure we like this image
|
// Check to make sure we like this image
|
||||||
if (!self::test_image($source)) {
|
if (!self::test_image($source)) {
|
||||||
|
@ -404,7 +410,6 @@ class Art extends database_object
|
||||||
Dba::write($sql, array($source, $mime, $sizetext, $width, $height, $this->type, $this->uid, $this->kind));
|
Dba::write($sql, array($source, $mime, $sizetext, $width, $height, $this->type, $this->uid, $this->kind));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // insert
|
} // insert
|
||||||
|
|
||||||
public static function check_dimensions($dimensions)
|
public static function check_dimensions($dimensions)
|
||||||
|
@ -521,9 +526,13 @@ class Art extends database_object
|
||||||
|
|
||||||
if (Core::is_readable($path)) {
|
if (Core::is_readable($path)) {
|
||||||
foreach (scandir($path) as $file) {
|
foreach (scandir($path) as $file) {
|
||||||
if ('.' === $file || '..' === $file) continue;
|
if ('.' === $file || '..' === $file) {
|
||||||
elseif (is_dir($path . '/' . $file)) self::delete_rec_dir($path . '/' . $file);
|
continue;
|
||||||
else unlink($path . '/' . $file);
|
} elseif (is_dir($path . '/' . $file)) {
|
||||||
|
self::delete_rec_dir($path . '/' . $file);
|
||||||
|
} else {
|
||||||
|
unlink($path . '/' . $file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rmdir($path);
|
rmdir($path);
|
||||||
}
|
}
|
||||||
|
@ -599,7 +608,6 @@ class Art extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_thumb
|
} // get_thumb
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -702,7 +710,6 @@ class Art extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return array('thumb' => $data, 'thumb_mime' => $mime_type);
|
return array('thumb' => $data, 'thumb_mime' => $mime_type);
|
||||||
|
|
||||||
} // generate_thumb
|
} // generate_thumb
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -772,7 +779,6 @@ class Art extends database_object
|
||||||
} // if data song
|
} // if data song
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} // get_from_source
|
} // get_from_source
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -786,8 +792,9 @@ class Art extends database_object
|
||||||
*/
|
*/
|
||||||
public static function url($uid,$type,$sid=null,$thumb=null)
|
public static function url($uid,$type,$sid=null,$thumb=null)
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
|
if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
|
||||||
$sid = $sid ? scrub_out($sid) : scrub_out(session_id());
|
$sid = $sid ? scrub_out($sid) : scrub_out(session_id());
|
||||||
|
@ -816,8 +823,10 @@ class Art extends database_object
|
||||||
parent::add_to_cache('art', $key . $row['size'], $row);
|
parent::add_to_cache('art', $key . $row['size'], $row);
|
||||||
if ($row['size'] == 'original') {
|
if ($row['size'] == 'original') {
|
||||||
$mime = $row['mime'];
|
$mime = $row['mime'];
|
||||||
} else if ($row['size'] == '275x275' && AmpConfig::get('resize_images')) {
|
} else {
|
||||||
$thumb_mime = $row['mime'];
|
if ($row['size'] == '275x275' && AmpConfig::get('resize_images')) {
|
||||||
|
$thumb_mime = $row['mime'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -846,7 +855,6 @@ class Art extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
|
|
||||||
} // url
|
} // url
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -973,8 +981,9 @@ class Art extends database_object
|
||||||
$data = $plugin->_plugin->gather_arts($type, $options, $limit);
|
$data = $plugin->_plugin->gather_arts($type, $options, $limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (in_array($method_name, $methods)) {
|
} else {
|
||||||
debug_event('Art', "Method used: $method_name", 3);
|
if (in_array($method_name, $methods)) {
|
||||||
|
debug_event('Art', "Method used: $method_name", 3);
|
||||||
// Some of these take options!
|
// Some of these take options!
|
||||||
switch ($method_name) {
|
switch ($method_name) {
|
||||||
case 'gather_lastfm':
|
case 'gather_lastfm':
|
||||||
|
@ -987,8 +996,9 @@ class Art extends database_object
|
||||||
$data = $this->{$method_name}($limit);
|
$data = $this->{$method_name}($limit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug_event("Art", $method_name . " not defined", 1);
|
debug_event("Art", $method_name . " not defined", 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the results we got to the current set
|
// Add the results we got to the current set
|
||||||
|
@ -997,11 +1007,9 @@ class Art extends database_object
|
||||||
if ($limit && count($results) >= $limit) {
|
if ($limit && count($results) >= $limit) {
|
||||||
return array_slice($results, 0, $limit);
|
return array_slice($results, 0, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // gather
|
} // gather
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1173,7 +1181,6 @@ class Art extends database_object
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
return $images;
|
return $images;
|
||||||
|
|
||||||
} // gather_musicbrainz
|
} // gather_musicbrainz
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1216,9 +1223,11 @@ class Art extends database_object
|
||||||
$song = new Song($song_id);
|
$song = new Song($song_id);
|
||||||
$dirs[] = Core::conv_lc_file( dirname($song->file) );
|
$dirs[] = Core::conv_lc_file( dirname($song->file) );
|
||||||
}
|
}
|
||||||
} else if ($this->type == 'video') {
|
} else {
|
||||||
$media = new Video($this->uid);
|
if ($this->type == 'video') {
|
||||||
$dirs[] = Core::conv_lc_file( dirname($media->file) );
|
$media = new Video($this->uid);
|
||||||
|
$dirs[] = Core::conv_lc_file( dirname($media->file) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($dirs as $dir) {
|
foreach ($dirs as $dir) {
|
||||||
|
@ -1284,10 +1293,8 @@ class Art extends database_object
|
||||||
'mime' => 'image/' . $extension,
|
'mime' => 'image/' . $extension,
|
||||||
'title' => 'Folder'
|
'title' => 'Folder'
|
||||||
);
|
);
|
||||||
|
|
||||||
} // end while reading dir
|
} // end while reading dir
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
|
|
||||||
} // end foreach dirs
|
} // end foreach dirs
|
||||||
|
|
||||||
if (is_array($preferred)) {
|
if (is_array($preferred)) {
|
||||||
|
@ -1302,7 +1309,6 @@ class Art extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_values($results);
|
return array_values($results);
|
||||||
|
|
||||||
} // gather_folder
|
} // gather_folder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1376,7 +1382,9 @@ class Art extends database_object
|
||||||
$mtype = strtolower(get_class($media));
|
$mtype = strtolower(get_class($media));
|
||||||
$data = array();
|
$data = array();
|
||||||
$getID3 = new getID3();
|
$getID3 = new getID3();
|
||||||
try { $id3 = $getID3->analyze($media->file); } catch (Exception $error) {
|
try {
|
||||||
|
$id3 = $getID3->analyze($media->file);
|
||||||
|
} catch (Exception $error) {
|
||||||
debug_event('getid3', $error->getMessage(), 1);
|
debug_event('getid3', $error->getMessage(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1411,7 +1419,6 @@ class Art extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1452,8 +1459,9 @@ class Art extends database_object
|
||||||
$mime = 'image/' . $results['extension'];
|
$mime = 'image/' . $results['extension'];
|
||||||
|
|
||||||
$images[] = array('url' => $match, 'mime' => $mime, 'title' => 'Google');
|
$images[] = array('url' => $match, 'mime' => $mime, 'title' => 'Google');
|
||||||
if ($limit > 0 && count($images) >= $limit)
|
if ($limit > 0 && count($images) >= $limit) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@ -1461,7 +1469,6 @@ class Art extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $images;
|
return $images;
|
||||||
|
|
||||||
} // gather_google
|
} // gather_google
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1487,10 +1494,14 @@ class Art extends database_object
|
||||||
try {
|
try {
|
||||||
$xmldata = Recommendation::album_search($data['artist'], $data['album']);
|
$xmldata = Recommendation::album_search($data['artist'], $data['album']);
|
||||||
|
|
||||||
if (!count($xmldata)) { return array(); }
|
if (!count($xmldata)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$coverart = (array) $xmldata->coverart;
|
$coverart = (array) $xmldata->coverart;
|
||||||
if (!$coverart) { return array(); }
|
if (!$coverart) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
ksort($coverart);
|
ksort($coverart);
|
||||||
foreach ($coverart as $url) {
|
foreach ($coverart as $url) {
|
||||||
|
@ -1513,7 +1524,6 @@ class Art extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $images;
|
return $images;
|
||||||
|
|
||||||
} // gather_lastfm
|
} // gather_lastfm
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1677,8 +1687,9 @@ class Art extends database_object
|
||||||
*/
|
*/
|
||||||
public static function display($object_type, $object_id, $name, $thumb, $link = null, $show_default = true, $kind = 'default')
|
public static function display($object_type, $object_id, $name, $thumb, $link = null, $show_default = true, $kind = 'default')
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($object_type))
|
if (!Core::is_library_item($object_type)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$show_default) {
|
if (!$show_default) {
|
||||||
// Don't show any image if not available
|
// Don't show any image if not available
|
||||||
|
@ -1733,5 +1744,5 @@ class Art extends database_object
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Art
|
} // Art
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,9 @@ class Artist extends database_object implements library_item
|
||||||
public function __construct($id=null,$catalog_init=0)
|
public function __construct($id=null,$catalog_init=0)
|
||||||
{
|
{
|
||||||
/* If they failed to pass in an id, just run for it */
|
/* If they failed to pass in an id, just run for it */
|
||||||
if (!$id) { return false; }
|
if (!$id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->catalog_id = $catalog_init;
|
$this->catalog_id = $catalog_init;
|
||||||
/* Get the information from the db */
|
/* Get the information from the db */
|
||||||
|
@ -150,7 +152,6 @@ class Artist extends database_object implements library_item
|
||||||
} // foreach info
|
} // foreach info
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} //constructor
|
} //constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,7 +172,6 @@ class Artist extends database_object implements library_item
|
||||||
$artist->_fake = true;
|
$artist->_fake = true;
|
||||||
|
|
||||||
return $artist;
|
return $artist;
|
||||||
|
|
||||||
} // construct_from_array
|
} // construct_from_array
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,15 +196,17 @@ class Artist extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public static function build_cache($ids, $extra=false, $limit_threshold = '')
|
public static function build_cache($ids, $extra=false, $limit_threshold = '')
|
||||||
{
|
{
|
||||||
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 `artist` WHERE `id` IN $idlist";
|
$sql = "SELECT * FROM `artist` WHERE `id` IN $idlist";
|
||||||
$db_results = Dba::read($sql);
|
$db_results = Dba::read($sql);
|
||||||
|
|
||||||
while ($row = Dba::fetch_assoc($db_results)) {
|
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 we need to also pull the extra information, this is normally only used when we are doing the human display
|
||||||
|
@ -220,11 +222,9 @@ class Artist extends database_object implements library_item
|
||||||
}
|
}
|
||||||
parent::add_to_cache('artist_extra',$row['artist'],$row);
|
parent::add_to_cache('artist_extra',$row['artist'],$row);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end if extra
|
} // end if extra
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // build_cache
|
} // build_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,7 +243,6 @@ class Artist extends database_object implements library_item
|
||||||
$object = new Artist($row['id']);
|
$object = new Artist($row['id']);
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
|
|
||||||
} // get_from_name
|
} // get_from_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,7 +320,6 @@ class Artist extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_albums
|
} // get_albums
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -348,7 +346,6 @@ class Artist extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_songs
|
} // get_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -376,7 +373,6 @@ class Artist extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_random_songs
|
} // get_random_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -418,7 +414,6 @@ class Artist extends database_object implements library_item
|
||||||
$this->catalog_id = $row['catalog_id'];
|
$this->catalog_id = $row['catalog_id'];
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
|
|
||||||
} // _get_extra_info
|
} // _get_extra_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -437,7 +432,9 @@ class Artist extends database_object implements library_item
|
||||||
$this->f_full_name = trim(trim($this->prefix) . ' ' . trim($this->name));
|
$this->f_full_name = trim(trim($this->prefix) . ' ' . trim($this->name));
|
||||||
|
|
||||||
// If this is a memory-only object, we're done here
|
// If this is a memory-only object, we're done here
|
||||||
if (!$this->id) { return true; }
|
if (!$this->id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->catalog_id) {
|
if ($this->catalog_id) {
|
||||||
$this->link = AmpConfig::get('web_path') . '/artists.php?action=show&catalog=' . $this->catalog_id . '&artist=' . $this->id;
|
$this->link = AmpConfig::get('web_path') . '/artists.php?action=show&catalog=' . $this->catalog_id . '&artist=' . $this->id;
|
||||||
|
@ -471,7 +468,6 @@ class Artist extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -627,12 +623,14 @@ class Artist extends database_object implements library_item
|
||||||
$user = $GLOBALS['user']->id;
|
$user = $GLOBALS['user']->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user)
|
if (!$user) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (AmpConfig::get('upload_allow_edit')) {
|
if (AmpConfig::get('upload_allow_edit')) {
|
||||||
if ($this->user !== null && $user == $this->user)
|
if ($this->user !== null && $user == $this->user) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Access::check('interface', 50, $user);
|
return Access::check('interface', 50, $user);
|
||||||
|
@ -653,7 +651,9 @@ class Artist extends database_object implements library_item
|
||||||
$name = $trimmed['string'];
|
$name = $trimmed['string'];
|
||||||
$prefix = $trimmed['prefix'];
|
$prefix = $trimmed['prefix'];
|
||||||
|
|
||||||
if ($mbid == '') $mbid = null;
|
if ($mbid == '') {
|
||||||
|
$mbid = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
$name = T_('Unknown (Orphaned)');
|
$name = T_('Unknown (Orphaned)');
|
||||||
|
@ -725,7 +725,6 @@ class Artist extends database_object implements library_item
|
||||||
|
|
||||||
self::$_mapcache[$name][$mbid] = $id;
|
self::$_mapcache[$name][$mbid] = $id;
|
||||||
return $id;
|
return $id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -773,9 +772,11 @@ class Artist extends database_object implements library_item
|
||||||
Rating::gc();
|
Rating::gc();
|
||||||
Userflag::gc();
|
Userflag::gc();
|
||||||
} // if updated
|
} // if updated
|
||||||
} else if ($this->mbid != $mbid) {
|
} else {
|
||||||
$sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?';
|
if ($this->mbid != $mbid) {
|
||||||
Dba::write($sql, array($mbid, $current_id));
|
$sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?';
|
||||||
|
Dba::write($sql, array($mbid, $current_id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update artist name (if we don't want to use the MusicBrainz name)
|
// Update artist name (if we don't want to use the MusicBrainz name)
|
||||||
|
@ -810,7 +811,6 @@ class Artist extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $current_id;
|
return $current_id;
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -894,5 +894,5 @@ class Artist extends database_object implements library_item
|
||||||
|
|
||||||
return $deleted;
|
return $deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of artist class
|
} // end of artist class
|
||||||
|
|
||||||
|
|
|
@ -85,5 +85,5 @@ class Artist_Event
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of recommendation class
|
} // end of recommendation class
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,9 @@ class Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = self::$function_name($username, $password);
|
$results = self::$function_name($username, $password);
|
||||||
if ($results['success'] || ($allow_ui && !empty($results['ui_required']))) { break; }
|
if ($results['success'] || ($allow_ui && !empty($results['ui_required']))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
@ -377,11 +379,8 @@ class Auth
|
||||||
$results['email'] = $info[0][$ldap_email_field][0];
|
$results['email'] = $info[0][$ldap_email_field][0];
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // if we get something good back
|
} // if we get something good back
|
||||||
|
|
||||||
} // if something was sent back
|
} // if something was sent back
|
||||||
|
|
||||||
} // if failed connect
|
} // if failed connect
|
||||||
|
|
||||||
/* Default to bad news */
|
/* Default to bad news */
|
||||||
|
@ -389,7 +388,6 @@ class Auth
|
||||||
$results['error'] = 'LDAP login attempt failed';
|
$results['error'] = 'LDAP login attempt failed';
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // ldap_auth
|
} // ldap_auth
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -481,11 +479,11 @@ class Auth
|
||||||
$results['ui_required'] = $form_html;
|
$results['ui_required'] = $form_html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug_event('auth', $website . ' is not a valid OpenID.', '3');
|
debug_event('auth', $website . ' is not a valid OpenID.', '3');
|
||||||
$results['success'] = false;
|
$results['success'] = false;
|
||||||
$results['error'] = 'Not a valid OpenID.';
|
$results['error'] = 'Not a valid OpenID.';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug_event('auth', 'Cannot initialize OpenID resources.', '3');
|
debug_event('auth', 'Cannot initialize OpenID resources.', '3');
|
||||||
$results['success'] = false;
|
$results['success'] = false;
|
||||||
|
@ -516,35 +514,37 @@ class Auth
|
||||||
if ($response->status == Auth_OpenID_CANCEL) {
|
if ($response->status == Auth_OpenID_CANCEL) {
|
||||||
$results['success'] = false;
|
$results['success'] = false;
|
||||||
$results['error'] = 'OpenID verification cancelled.';
|
$results['error'] = 'OpenID verification cancelled.';
|
||||||
} else if ($response->status == Auth_OpenID_FAILURE) {
|
} else {
|
||||||
$results['success'] = false;
|
if ($response->status == Auth_OpenID_FAILURE) {
|
||||||
$results['error'] = 'OpenID authentication failed: ' . $response->message;
|
$results['success'] = false;
|
||||||
} else if ($response->status == Auth_OpenID_SUCCESS) {
|
$results['error'] = 'OpenID authentication failed: ' . $response->message;
|
||||||
// Extract the identity URL and Simple Registration data (if it was returned).
|
} else {
|
||||||
|
if ($response->status == Auth_OpenID_SUCCESS) {
|
||||||
|
// Extract the identity URL and Simple Registration data (if it was returned).
|
||||||
$sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
|
$sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
|
||||||
$sreg = $sreg_resp->contents();
|
$sreg = $sreg_resp->contents();
|
||||||
|
|
||||||
$results['website'] = $response->getDisplayIdentifier();
|
$results['website'] = $response->getDisplayIdentifier();
|
||||||
if (@$sreg['email']) {
|
if (@$sreg['email']) {
|
||||||
$results['email'] = $sreg['email'];
|
$results['email'] = $sreg['email'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@$sreg['nickname']) {
|
if (@$sreg['nickname']) {
|
||||||
$results['username'] = $sreg['nickname'];
|
$results['username'] = $sreg['nickname'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@$sreg['fullname']) {
|
if (@$sreg['fullname']) {
|
||||||
$results['name'] = $sreg['fullname'];
|
$results['name'] = $sreg['fullname'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = User::get_from_website($results['website']);
|
$users = User::get_from_website($results['website']);
|
||||||
if (count($users) > 0) {
|
if (count($users) > 0) {
|
||||||
if (count($users) == 1) {
|
if (count($users) == 1) {
|
||||||
$user = new User($users[0]);
|
$user = new User($users[0]);
|
||||||
$results['success'] = true;
|
$results['success'] = true;
|
||||||
$results['username'] = $user->username;
|
$results['username'] = $user->username;
|
||||||
} else {
|
} else {
|
||||||
// Several users for the same website/openid? Allowed but stupid, try to get a match on username.
|
// Several users for the same website/openid? Allowed but stupid, try to get a match on username.
|
||||||
// Should we make website field unique?
|
// Should we make website field unique?
|
||||||
foreach ($users as $id) {
|
foreach ($users as $id) {
|
||||||
$user = new User($id);
|
$user = new User($id);
|
||||||
|
@ -553,16 +553,18 @@ class Auth
|
||||||
$results['username'] = $user->username;
|
$results['username'] = $user->username;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Don't return success if an user already exists for this username but don't have this openid identity as website
|
// Don't return success if an user already exists for this username but don't have this openid identity as website
|
||||||
$user = User::get_from_username($results['username']);
|
$user = User::get_from_username($results['username']);
|
||||||
if ($user->id) {
|
if ($user->id) {
|
||||||
$results['success'] = false;
|
$results['success'] = false;
|
||||||
$results['error'] = 'No user associated to this OpenID and username already taken.';
|
$results['error'] = 'No user associated to this OpenID and username already taken.';
|
||||||
} else {
|
} else {
|
||||||
$results['success'] = true;
|
$results['success'] = true;
|
||||||
$results['error'] = 'No user associated to this OpenID.';
|
$results['error'] = 'No user associated to this OpenID.';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,9 @@ class Broadcast extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public function __construct($id=0)
|
public function __construct($id=0)
|
||||||
{
|
{
|
||||||
if (!$id) { return true; }
|
if (!$id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the information from the db */
|
/* Get the information from the db */
|
||||||
$info = $this->get_info($id);
|
$info = $this->get_info($id);
|
||||||
|
@ -404,7 +406,6 @@ class Broadcast extends database_object implements library_item
|
||||||
|
|
||||||
public static function gc()
|
public static function gc()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -421,5 +422,5 @@ class Broadcast extends database_object implements library_item
|
||||||
{
|
{
|
||||||
return $oid;
|
return $oid;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of broadcast class
|
} // end of broadcast class
|
||||||
|
|
||||||
|
|
|
@ -438,5 +438,5 @@ class Broadcast_Server implements MessageComponentInterface
|
||||||
|
|
||||||
return $websocket_address . '/broadcast';
|
return $websocket_address . '/broadcast';
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of broadcast_server class
|
} // end of broadcast_server class
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,6 @@ class Browse extends Query
|
||||||
public function set_simple_browse($value)
|
public function set_simple_browse($value)
|
||||||
{
|
{
|
||||||
$this->set_is_simple($value);
|
$this->set_is_simple($value);
|
||||||
|
|
||||||
} // set_simple_browse
|
} // set_simple_browse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +77,6 @@ class Browse extends Query
|
||||||
$_SESSION['browse']['supplemental'][$this->id][$class] = intval($uid);
|
$_SESSION['browse']['supplemental'][$this->id][$class] = intval($uid);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // add_supplemental_object
|
} // add_supplemental_object
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,7 +95,6 @@ class Browse extends Query
|
||||||
}
|
}
|
||||||
|
|
||||||
return $objects;
|
return $objects;
|
||||||
|
|
||||||
} // get_supplemental_objects
|
} // get_supplemental_objects
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +110,6 @@ class Browse extends Query
|
||||||
// Checking if value is suitable
|
// Checking if value is suitable
|
||||||
$start = $_SESSION[$name]['start'];
|
$start = $_SESSION[$name]['start'];
|
||||||
if ($this->get_offset() > 0) {
|
if ($this->get_offset() > 0) {
|
||||||
|
|
||||||
$set_page = floor($start / $this->get_offset());
|
$set_page = floor($start / $this->get_offset());
|
||||||
if ($this->get_total() > $this->get_offset()) {
|
if ($this->get_total() > $this->get_offset()) {
|
||||||
$total_pages = ceil($this->get_total() / $this->get_offset());
|
$total_pages = ceil($this->get_total() / $this->get_offset());
|
||||||
|
@ -155,8 +151,10 @@ class Browse extends Query
|
||||||
$this->get_offset(),
|
$this->get_offset(),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
} else if (!count($object_ids)) {
|
} else {
|
||||||
$this->set_total(0);
|
if (!count($object_ids)) {
|
||||||
|
$this->set_total(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load any additional object we need for this
|
// Load any additional object we need for this
|
||||||
|
@ -363,7 +361,6 @@ class Browse extends Query
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ajax::end_container();
|
Ajax::end_container();
|
||||||
|
|
||||||
} // show_object
|
} // show_object
|
||||||
|
|
||||||
public function show_next_link($argument = null)
|
public function show_next_link($argument = null)
|
||||||
|
@ -533,5 +530,5 @@ class Browse extends Query
|
||||||
{
|
{
|
||||||
return $this->_state['threshold'];
|
return $this->_state['threshold'];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // browse
|
} // browse
|
||||||
|
|
||||||
|
|
|
@ -1922,8 +1922,9 @@ abstract class Catalog extends database_object
|
||||||
|
|
||||||
$catalog = self::create_from_id($catalog_id);
|
$catalog = self::create_from_id($catalog_id);
|
||||||
|
|
||||||
if (!$catalog->id)
|
if (!$catalog->id) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'DELETE FROM `catalog_' . $catalog->get_type() . '` WHERE catalog_id = ?';
|
$sql = 'DELETE FROM `catalog_' . $catalog->get_type() . '` WHERE catalog_id = ?';
|
||||||
$db_results = Dba::write($sql, array($catalog_id));
|
$db_results = Dba::write($sql, array($catalog_id));
|
||||||
|
@ -2057,14 +2058,17 @@ abstract class Catalog extends database_object
|
||||||
$user = $GLOBALS['user']->id;
|
$user = $GLOBALS['user']->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user)
|
if (!$user) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!AmpConfig::get('delete_from_disk'))
|
if (!AmpConfig::get('delete_from_disk')) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return (Access::check('interface','75') || ($libitem->get_user_owner() == $user && AmpConfig::get('upload_allow_remove')));
|
return (Access::check('interface','75') || ($libitem->get_user_owner() == $user && AmpConfig::get('upload_allow_remove')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// end of catalog class
|
// end of catalog class
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,9 @@ class Channel extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
public function __construct($id=0)
|
public function __construct($id=0)
|
||||||
{
|
{
|
||||||
if (!$id) { return true; }
|
if (!$id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the information from the db */
|
/* Get the information from the db */
|
||||||
$info = $this->get_info($id);
|
$info = $this->get_info($id);
|
||||||
|
@ -423,8 +425,9 @@ class Channel extends database_object implements media, library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_resource($this->transcoder['handle'])) {
|
if (is_resource($this->transcoder['handle'])) {
|
||||||
if (ftell($this->transcoder['handle']) == 0)
|
if (ftell($this->transcoder['handle']) == 0) {
|
||||||
$this->header_chunk = '';
|
$this->header_chunk = '';
|
||||||
|
}
|
||||||
$chunk = fread($this->transcoder['handle'], $this->chunk_size);
|
$chunk = fread($this->transcoder['handle'], $this->chunk_size);
|
||||||
$this->media_bytes_streamed += strlen($chunk);
|
$this->media_bytes_streamed += strlen($chunk);
|
||||||
|
|
||||||
|
@ -453,11 +456,13 @@ class Channel extends database_object implements media, library_item
|
||||||
$ogg_sum_segm_laces += hexdec(substr($hex, 27*2 + $segm*2, 2));
|
$ogg_sum_segm_laces += hexdec(substr($hex, 27*2 + $segm*2, 2));
|
||||||
}
|
}
|
||||||
$this->header_chunk .= substr($clchunk, 0, 27 + $ogg_nr_of_segments + $ogg_sum_segm_laces);
|
$this->header_chunk .= substr($clchunk, 0, 27 + $ogg_nr_of_segments + $ogg_sum_segm_laces);
|
||||||
if (strlen($clchunk) < (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces))
|
if (strlen($clchunk) < (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces)) {
|
||||||
$this->header_chunk_remainder = (int) (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces - strlen($clchunk));
|
$this->header_chunk_remainder = (int) (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces - strlen($clchunk));
|
||||||
|
}
|
||||||
$clchunk = substr($clchunk, 27 + $ogg_nr_of_segments + $ogg_sum_segm_laces);
|
$clchunk = substr($clchunk, 27 + $ogg_nr_of_segments + $ogg_sum_segm_laces);
|
||||||
} else //no more interesting headers
|
} else { //no more interesting headers
|
||||||
$clchunk = '';
|
$clchunk = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//debug_event('channel', 'File handle pointer: ' . ftell($this->transcoder['handle']) ,'5');
|
//debug_event('channel', 'File handle pointer: ' . ftell($this->transcoder['handle']) ,'5');
|
||||||
|
@ -531,15 +536,15 @@ class Channel extends database_object implements media, library_item
|
||||||
|
|
||||||
public static function gc()
|
public static function gc()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function strtohex($x)
|
private function strtohex($x)
|
||||||
{
|
{
|
||||||
$s='';
|
$s='';
|
||||||
foreach(str_split($x) as $c) $s.=sprintf("%02X",ord($c));
|
foreach (str_split($x) as $c) {
|
||||||
|
$s.=sprintf("%02X",ord($c));
|
||||||
|
}
|
||||||
return($s);
|
return($s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end of channel class
|
} // end of channel class
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ class Clip extends Video
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +69,6 @@ class Clip extends Video
|
||||||
Dba::write($sql, array($data['id'], $data['artist'], $data['song']));
|
Dba::write($sql, array($data['id'], $data['artist'], $data['song']));
|
||||||
|
|
||||||
return $data['id'];
|
return $data['id'];
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +81,6 @@ class Clip extends Video
|
||||||
Dba::write($sql, array($data['artist'], $data['song'], $this->id));
|
Dba::write($sql, array($data['artist'], $data['song'], $this->id));
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +107,6 @@ class Clip extends Video
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} //format
|
} //format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,5 +133,5 @@ class Clip extends Video
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Clip class
|
} // Clip class
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ class Core
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // construction
|
} // construction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +109,6 @@ class Core
|
||||||
} // end switch on type
|
} // end switch on type
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
|
|
||||||
} // form_register
|
} // form_register
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,7 +158,6 @@ class Core
|
||||||
// OMG HAX0RZ
|
// OMG HAX0RZ
|
||||||
debug_event('Core', "$type form $sid failed consistency check, rejecting request", 2);
|
debug_event('Core', "$type form $sid failed consistency check, rejecting request", 2);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // form_verify
|
} // form_verify
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,19 +168,24 @@ class Core
|
||||||
*/
|
*/
|
||||||
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);
|
$width = imagesx($image);
|
||||||
$height = imagesy($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
|
} // image_dimensions
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -326,3 +328,4 @@ class Core
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
} // Core
|
} // Core
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,6 @@ class Daap_Api
|
||||||
if (!isset($_GET['session-id'])) {
|
if (!isset($_GET['session-id'])) {
|
||||||
debug_event('daap', 'Missing session id.', '');
|
debug_event('daap', 'Missing session id.', '');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$sql = "SELECT * FROM `daap_session` WHERE `id` = ?";
|
$sql = "SELECT * FROM `daap_session` WHERE `id` = ?";
|
||||||
$db_results = Dba::read($sql, array($_GET['session-id']));
|
$db_results = Dba::read($sql, array($_GET['session-id']));
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,9 @@ abstract class database_object
|
||||||
$table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));
|
$table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));
|
||||||
|
|
||||||
// Make sure we've got a real id
|
// Make sure we've got a real id
|
||||||
if (!is_numeric($id)) { return array(); }
|
if (!is_numeric($id)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
if (self::is_cached($table_name,$id)) {
|
if (self::is_cached($table_name,$id)) {
|
||||||
return self::get_from_cache($table_name,$id);
|
return self::get_from_cache($table_name,$id);
|
||||||
|
@ -54,14 +56,15 @@ abstract class database_object
|
||||||
$sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
|
$sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
|
||||||
$db_results = Dba::read($sql);
|
$db_results = Dba::read($sql);
|
||||||
|
|
||||||
if (!$db_results) { return array(); }
|
if (!$db_results) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$row = Dba::fetch_assoc($db_results);
|
$row = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
self::add_to_cache($table_name,$id,$row);
|
self::add_to_cache($table_name,$id,$row);
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
|
|
||||||
} // get_info
|
} // get_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,10 +82,11 @@ abstract class database_object
|
||||||
public static function is_cached($index, $id)
|
public static function is_cached($index, $id)
|
||||||
{
|
{
|
||||||
// Make sure we've got some parents here before we dive below
|
// Make sure we've got some parents here before we dive below
|
||||||
if (!isset(self::$object_cache[$index])) { return false; }
|
if (!isset(self::$object_cache[$index])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return isset(self::$object_cache[$index][$id]);
|
return isset(self::$object_cache[$index][$id]);
|
||||||
|
|
||||||
} // is_cached
|
} // is_cached
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +102,6 @@ abstract class database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // get_from_cache
|
} // get_from_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,11 +110,12 @@ abstract class database_object
|
||||||
*/
|
*/
|
||||||
public static function add_to_cache($index, $id, $data)
|
public static function add_to_cache($index, $id, $data)
|
||||||
{
|
{
|
||||||
if (!self::$_enabled) { return false; }
|
if (!self::$_enabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$value = is_null($data) ? false : $data;
|
$value = is_null($data) ? false : $data;
|
||||||
self::$object_cache[$index][$id] = $value;
|
self::$object_cache[$index][$id] = $value;
|
||||||
|
|
||||||
} // add_to_cache
|
} // add_to_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,7 +128,6 @@ abstract class database_object
|
||||||
if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
|
if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
|
||||||
unset(self::$object_cache[$index][$id]);
|
unset(self::$object_cache[$index][$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // remove_from_cache
|
} // remove_from_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,7 +137,6 @@ abstract class database_object
|
||||||
public static function _auto_init()
|
public static function _auto_init()
|
||||||
{
|
{
|
||||||
self::$_enabled = AmpConfig::get('memory_cache');
|
self::$_enabled = AmpConfig::get('memory_cache');
|
||||||
|
|
||||||
} // _auto_init
|
} // _auto_init
|
||||||
|
|
||||||
} // end database_object
|
} // end database_object
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Make sure they aren't directly accessing it */
|
/* Make sure they aren't directly accessing it */
|
||||||
if (!defined('INIT_LOADED') || INIT_LOADED != '1') { exit; }
|
if (!defined('INIT_LOADED') || INIT_LOADED != '1') {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dba Class
|
* Dba Class
|
||||||
|
@ -48,7 +50,6 @@ class Dba
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
// Rien a faire
|
// Rien a faire
|
||||||
|
|
||||||
} // construct
|
} // construct
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,12 +94,14 @@ class Dba
|
||||||
self::$_error = json_encode($dbh->errorInfo());
|
self::$_error = json_encode($dbh->errorInfo());
|
||||||
debug_event('Dba', 'Error: ' . json_encode($dbh->errorInfo()), 1);
|
debug_event('Dba', 'Error: ' . json_encode($dbh->errorInfo()), 1);
|
||||||
self::disconnect();
|
self::disconnect();
|
||||||
} else if ($stmt->errorCode() && $stmt->errorCode() != '00000') {
|
} else {
|
||||||
self::$_error = json_encode($stmt->errorInfo());
|
if ($stmt->errorCode() && $stmt->errorCode() != '00000') {
|
||||||
debug_event('Dba', 'Error: ' . json_encode($stmt->errorInfo()), 1);
|
self::$_error = json_encode($stmt->errorInfo());
|
||||||
self::finish($stmt);
|
debug_event('Dba', 'Error: ' . json_encode($stmt->errorInfo()), 1);
|
||||||
self::disconnect();
|
self::finish($stmt);
|
||||||
return false;
|
self::disconnect();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $stmt;
|
return $stmt;
|
||||||
|
|
|
@ -52,14 +52,15 @@ class Democratic extends Tmp_Playlist
|
||||||
*/
|
*/
|
||||||
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) {
|
foreach ($info as $key=>$value) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +69,9 @@ class Democratic extends Tmp_Playlist
|
||||||
*/
|
*/
|
||||||
public static function build_vote_cache($ids)
|
public static function build_vote_cache($ids)
|
||||||
{
|
{
|
||||||
if (!is_array($ids) || !count($ids)) { return false; }
|
if (!is_array($ids) || !count($ids)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$idlist = '(' . implode(',', $ids) . ')';
|
$idlist = '(' . implode(',', $ids) . ')';
|
||||||
|
|
||||||
|
@ -83,7 +86,6 @@ class Democratic extends Tmp_Playlist
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // build_vote_cache
|
} // build_vote_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,10 +95,11 @@ class Democratic extends Tmp_Playlist
|
||||||
*/
|
*/
|
||||||
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
|
} // is_enabled
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,8 +116,6 @@ class Democratic extends Tmp_Playlist
|
||||||
$row = Dba::fetch_assoc($db_results);
|
$row = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
$this->tmp_playlist = $row['id'];
|
$this->tmp_playlist = $row['id'];
|
||||||
|
|
||||||
|
|
||||||
} // set_parent
|
} // set_parent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +142,6 @@ class Democratic extends Tmp_Playlist
|
||||||
Preference::update_all($play_method,'clear');
|
Preference::update_all($play_method,'clear');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // set_user_preferences
|
} // set_user_preferences
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,7 +170,6 @@ class Democratic extends Tmp_Playlist
|
||||||
$this->f_level = T_('Admin');
|
$this->f_level = T_('Admin');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,7 +189,6 @@ class Democratic extends Tmp_Playlist
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_playlists
|
} // get_playlists
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,7 +212,6 @@ class Democratic extends Tmp_Playlist
|
||||||
$object = new Democratic($democratic_id);
|
$object = new Democratic($democratic_id);
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
|
|
||||||
} // get_current_playlist
|
} // get_current_playlist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -259,7 +256,6 @@ class Democratic extends Tmp_Playlist
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_items
|
} // get_items
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -271,7 +267,6 @@ class Democratic extends Tmp_Playlist
|
||||||
$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 Stream_URL::format($link);
|
return Stream_URL::format($link);
|
||||||
|
|
||||||
} // play_url
|
} // play_url
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -306,7 +301,6 @@ class Democratic extends Tmp_Playlist
|
||||||
$results = Dba::fetch_assoc($db_results);
|
$results = Dba::fetch_assoc($db_results);
|
||||||
return $results['id'];
|
return $results['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // get_next_object
|
} // get_next_object
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -327,7 +321,6 @@ class Democratic extends Tmp_Playlist
|
||||||
$row = Dba::fetch_assoc($db_results);
|
$row = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $row['id'];
|
return $row['id'];
|
||||||
|
|
||||||
} // get_uid_from_object_id
|
} // get_uid_from_object_id
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -343,7 +336,6 @@ class Democratic extends Tmp_Playlist
|
||||||
$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
|
} // get_cool_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -363,7 +355,6 @@ class Democratic extends Tmp_Playlist
|
||||||
$this->_add_vote($object_id, $type);
|
$this->_add_vote($object_id, $type);
|
||||||
}
|
}
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
} // vote
|
} // vote
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -396,7 +387,6 @@ class Democratic extends Tmp_Playlist
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // has_vote
|
} // has_vote
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -457,7 +447,6 @@ class Democratic extends Tmp_Playlist
|
||||||
self::prune_tracks();
|
self::prune_tracks();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // remove_vote
|
} // remove_vote
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -475,7 +464,6 @@ class Democratic extends Tmp_Playlist
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete_votes
|
} // delete_votes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -488,10 +476,11 @@ class Democratic extends Tmp_Playlist
|
||||||
if ($row_id) {
|
if ($row_id) {
|
||||||
debug_event('Democratic','Removing Votes for ' . $oid . ' of type ' . $object_type,'5');
|
debug_event('Democratic','Removing Votes for ' . $oid . ' of type ' . $object_type,'5');
|
||||||
$this->delete_votes($row_id);
|
$this->delete_votes($row_id);
|
||||||
} else { debug_event('Democratic','Unable to find Votes for ' . $oid . ' of type ' . $object_type,'3'); }
|
} else {
|
||||||
|
debug_event('Democratic','Unable to find Votes for ' . $oid . ' of type ' . $object_type,'3');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete_from_oid
|
} // delete_from_oid
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -511,7 +500,6 @@ class Democratic extends Tmp_Playlist
|
||||||
self::prune_tracks();
|
self::prune_tracks();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete
|
} // delete
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -531,7 +519,6 @@ class Democratic extends Tmp_Playlist
|
||||||
Dba::write($sql, array($name, $base, $cool, $default, $level, $id));
|
Dba::write($sql, array($name, $base, $cool, $default, $level, $id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -562,7 +549,6 @@ class Democratic extends Tmp_Playlist
|
||||||
}
|
}
|
||||||
|
|
||||||
return $db_results;
|
return $db_results;
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -580,7 +566,6 @@ class Democratic extends Tmp_Playlist
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // prune_tracks
|
} // prune_tracks
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -607,7 +592,6 @@ class Democratic extends Tmp_Playlist
|
||||||
self::clear_votes();
|
self::clear_votes();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // clear_playlist
|
} // clear_playlist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -622,7 +606,6 @@ class Democratic extends Tmp_Playlist
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // clear_votes
|
} // clear_votes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -642,7 +625,6 @@ class Democratic extends Tmp_Playlist
|
||||||
$results = Dba::fetch_assoc($db_results);
|
$results = Dba::fetch_assoc($db_results);
|
||||||
parent::add_to_cache('democratic_vote', $id, $results['count']);
|
parent::add_to_cache('democratic_vote', $id, $results['count']);
|
||||||
return $results['count'];
|
return $results['count'];
|
||||||
|
|
||||||
} // get_vote
|
} // get_vote
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -666,6 +648,5 @@ class Democratic extends Tmp_Playlist
|
||||||
parent::add_to_cache('democratic_vote', $object_id, $voters);
|
parent::add_to_cache('democratic_vote', $object_id, $voters);
|
||||||
return $voters;
|
return $voters;
|
||||||
} // get_voters
|
} // get_voters
|
||||||
|
|
||||||
|
|
||||||
} // Democratic class
|
} // Democratic class
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ class Error
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
// Rien a faire
|
// Rien a faire
|
||||||
|
|
||||||
} // __construct
|
} // __construct
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +50,6 @@ class Error
|
||||||
foreach (self::$errors as $key=>$error) {
|
foreach (self::$errors as $key=>$error) {
|
||||||
$_SESSION['errors'][$key] = $error;
|
$_SESSION['errors'][$key] = $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // __destruct
|
} // __destruct
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +84,6 @@ class Error
|
||||||
ob_flush();
|
ob_flush();
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // add
|
} // add
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,10 +92,11 @@ class Error
|
||||||
*/
|
*/
|
||||||
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
|
} // occurred
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,10 +105,11 @@ class Error
|
||||||
*/
|
*/
|
||||||
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];
|
return Error::$errors[$name];
|
||||||
|
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,10 +120,11 @@ class Error
|
||||||
public static function display($name)
|
public static function display($name)
|
||||||
{
|
{
|
||||||
// Be smart about this, if no error don't print
|
// Be smart about this, if no error don't print
|
||||||
if (!isset(Error::$errors[$name])) { return ''; }
|
if (!isset(Error::$errors[$name])) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
echo '<p class="alert alert-danger">' . T_(Error::$errors[$name]) . '</p>';
|
echo '<p class="alert alert-danger">' . T_(Error::$errors[$name]) . '</p>';
|
||||||
|
|
||||||
} // display
|
} // display
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,13 +133,14 @@ class Error
|
||||||
*/
|
*/
|
||||||
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
|
// Re-insert them
|
||||||
foreach ($_SESSION['errors'] as $key=>$error) {
|
foreach ($_SESSION['errors'] as $key=>$error) {
|
||||||
self::add($key,$error);
|
self::add($key,$error);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // auto_init
|
} // auto_init
|
||||||
|
|
||||||
} // Error
|
} // Error
|
||||||
|
|
||||||
|
|
|
@ -493,10 +493,12 @@ class Graph
|
||||||
$blink = $libitem->f_link;
|
$blink = $libitem->f_link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($user_id) {
|
} else {
|
||||||
$u = new User($user_id);
|
if ($user_id) {
|
||||||
$u->format();
|
$u = new User($user_id);
|
||||||
$blink = $u->f_link;
|
$u->format();
|
||||||
|
$blink = $u->f_link;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once AmpConfig::get('prefix') . '/templates/show_graphs.inc.php';
|
require_once AmpConfig::get('prefix') . '/templates/show_graphs.inc.php';
|
||||||
|
|
|
@ -85,7 +85,9 @@ class Label extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public function __construct($id=null)
|
public function __construct($id=null)
|
||||||
{
|
{
|
||||||
if (!$id) { return false; }
|
if (!$id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$info = $this->get_info($id);
|
$info = $this->get_info($id);
|
||||||
foreach ($info as $key=>$value) {
|
foreach ($info as $key=>$value) {
|
||||||
|
@ -201,12 +203,14 @@ class Label extends database_object implements library_item
|
||||||
$user = $GLOBALS['user']->id;
|
$user = $GLOBALS['user']->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$user)
|
if (!$user) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (AmpConfig::get('upload_allow_edit')) {
|
if (AmpConfig::get('upload_allow_edit')) {
|
||||||
if ($this->user !== null && $user == $this->user)
|
if ($this->user !== null && $user == $this->user) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Access::check('interface', 50, $user);
|
return Access::check('interface', 50, $user);
|
||||||
|
@ -336,7 +340,6 @@ class Label extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_songs
|
} // get_songs
|
||||||
|
|
||||||
public function remove()
|
public function remove()
|
||||||
|
@ -383,7 +386,9 @@ class Label extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public static function get_display($labels, $link=false)
|
public static function get_display($labels, $link=false)
|
||||||
{
|
{
|
||||||
if (!is_array($labels)) { return ''; }
|
if (!is_array($labels)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$results = '';
|
$results = '';
|
||||||
|
|
||||||
|
@ -402,7 +407,6 @@ class Label extends database_object implements library_item
|
||||||
$results = rtrim($results, ', ');
|
$results = rtrim($results, ', ');
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_display
|
} // get_display
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -433,9 +437,11 @@ class Label extends database_object implements library_item
|
||||||
if ($found) {
|
if ($found) {
|
||||||
debug_event('label.class', 'Already found. Do nothing.', '5');
|
debug_event('label.class', 'Already found. Do nothing.', '5');
|
||||||
unset($editedLabels[$lk]);
|
unset($editedLabels[$lk]);
|
||||||
} else if ($overwrite) {
|
} else {
|
||||||
debug_event('label.class', 'Not found in the new list. Delete it.', '5');
|
if ($overwrite) {
|
||||||
$clabel->remove_artist_assoc($artist_id);
|
debug_event('label.class', 'Not found in the new list. Delete it.', '5');
|
||||||
|
$clabel->remove_artist_assoc($artist_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,5 +41,5 @@ interface library_item extends playable_item
|
||||||
public function update(array $data);
|
public function update(array $data);
|
||||||
|
|
||||||
public static function gc();
|
public static function gc();
|
||||||
|
|
||||||
} // end interface
|
} // end interface
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ class License
|
||||||
$this->_get_info($id);
|
$this->_get_info($id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,7 +76,6 @@ class License
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // _get_info
|
} // _get_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,7 +92,6 @@ class License
|
||||||
$insert_id = Dba::insert_id();
|
$insert_id = Dba::insert_id();
|
||||||
|
|
||||||
return $insert_id;
|
return $insert_id;
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,7 +106,6 @@ class License
|
||||||
Dba::write($sql, array($data['name'], $data['description'], $data['external_link'], $this->id));
|
Dba::write($sql, array($data['name'], $data['description'], $data['external_link'], $this->id));
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +126,6 @@ class License
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM `license` WHERE `id` = ?";
|
$sql = "DELETE FROM `license` WHERE `id` = ?";
|
||||||
Dba::write($sql, array($license_id));
|
Dba::write($sql, array($license_id));
|
||||||
|
|
||||||
} // delete
|
} // delete
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,5 +145,5 @@ class License
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
} // get_licenses
|
} // get_licenses
|
||||||
|
|
||||||
} // License class
|
} // License class
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,9 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
public function __construct($id = null)
|
public function __construct($id = null)
|
||||||
{
|
{
|
||||||
if (!$id) { return false; }
|
if (!$id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$info = $this->get_info($id, 'live_stream');
|
$info = $this->get_info($id, 'live_stream');
|
||||||
|
|
||||||
|
@ -84,7 +86,6 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
foreach ($info as $key=>$value) {
|
foreach ($info as $key=>$value) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,7 +101,6 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
$this->f_url_link = "<a target=\"_blank\" href=\"" . $this->url . "\">" . $this->url . "</a>";
|
$this->f_url_link = "<a target=\"_blank\" href=\"" . $this->url . "\">" . $this->url . "</a>";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
public function get_keywords()
|
public function get_keywords()
|
||||||
|
@ -201,7 +201,6 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
Dba::write($sql, array($data['name'], $data['site_url'], $data['url'], $data['codec'], $this->id));
|
Dba::write($sql, array($data['name'], $data['site_url'], $data['url'], $data['codec'], $this->id));
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,7 +229,9 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
Error::add('catalog', T_('Invalid Catalog'));
|
Error::add('catalog', T_('Invalid Catalog'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Error::occurred()) { return false; }
|
if (Error::occurred()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// If we've made it this far everything must be ok... I hope
|
// If we've made it this far everything must be ok... I hope
|
||||||
$sql = "INSERT INTO `live_stream` (`name`,`site_url`,`url`,`catalog`,`codec`) " .
|
$sql = "INSERT INTO `live_stream` (`name`,`site_url`,`url`,`catalog`,`codec`) " .
|
||||||
|
@ -238,7 +239,6 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
$db_results = Dba::write($sql, array($data['name'], $data['site_url'], $data['url'], $catalog->id, $data['codec']));
|
$db_results = Dba::write($sql, array($data['name'], $data['site_url'], $data['url'], $catalog->id, $data['codec']));
|
||||||
|
|
||||||
return $db_results;
|
return $db_results;
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,7 +251,6 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
Dba::write($sql, array($this->id));
|
Dba::write($sql, array($this->id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete
|
} // delete
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,7 +271,6 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
$radio = new Live_Stream($oid);
|
$radio = new Live_Stream($oid);
|
||||||
|
|
||||||
return $radio->url . $additional_params;
|
return $radio->url . $additional_params;
|
||||||
|
|
||||||
} // play_url
|
} // play_url
|
||||||
|
|
||||||
public function get_stream_name()
|
public function get_stream_name()
|
||||||
|
@ -316,12 +314,11 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
|
|
||||||
public static function gc()
|
public static function gc()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_played($user, $agent, $location)
|
public function set_played($user, $agent, $location)
|
||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end of radio class
|
} //end of radio class
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ class Localplay
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
||||||
$this->_get_info();
|
$this->_get_info();
|
||||||
|
|
||||||
} // Localplay
|
} // Localplay
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +55,6 @@ class Localplay
|
||||||
private function _get_info()
|
private function _get_info()
|
||||||
{
|
{
|
||||||
$this->_load_player();
|
$this->_load_player();
|
||||||
|
|
||||||
} // _get_info
|
} // _get_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +69,6 @@ class Localplay
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // player_loaded
|
} // player_loaded
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,13 +78,13 @@ class Localplay
|
||||||
*/
|
*/
|
||||||
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_name = ucfirst($this->type);
|
||||||
$this->f_description = $this->_player->get_description();
|
$this->f_description = $this->_player->get_description();
|
||||||
$this->f_version = $this->_player->get_version();
|
$this->f_version = $this->_player->get_version();
|
||||||
|
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +95,9 @@ class Localplay
|
||||||
*/
|
*/
|
||||||
private function _load_player()
|
private function _load_player()
|
||||||
{
|
{
|
||||||
if (!$this->type) { return false; }
|
if (!$this->type) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$filename = AmpConfig::get('prefix') . '/modules/localplay/' . $this->type . '.controller.php';
|
$filename = AmpConfig::get('prefix') . '/modules/localplay/' . $this->type . '.controller.php';
|
||||||
$include = require_once $filename;
|
$include = require_once $filename;
|
||||||
|
@ -117,7 +116,6 @@ class Localplay
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // _load_player
|
} // _load_player
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +129,6 @@ class Localplay
|
||||||
$name = scrub_out($name);
|
$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;
|
return $name;
|
||||||
|
|
||||||
} // format_name
|
} // format_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,8 +148,9 @@ class Localplay
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
|
if (substr($file,-14,14) != 'controller.php') {
|
||||||
if (substr($file,-14,14) != 'controller.php') { continue; }
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure it isn't a dir */
|
/* Make sure it isn't a dir */
|
||||||
if (!is_dir($file)) {
|
if (!is_dir($file)) {
|
||||||
|
@ -163,7 +161,6 @@ class Localplay
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_controllers
|
} // get_controllers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,10 +173,11 @@ class Localplay
|
||||||
// Load the controller and then check for its preferences
|
// Load the controller and then check for its preferences
|
||||||
$localplay = new Localplay($controller);
|
$localplay = new Localplay($controller);
|
||||||
// If we can't even load it no sense in going on
|
// If we can't even load it no sense in going on
|
||||||
if (!isset($localplay->_player)) { return false; }
|
if (!isset($localplay->_player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return $localplay->_player->is_installed();
|
return $localplay->_player->is_installed();
|
||||||
|
|
||||||
} // is_enabled
|
} // is_enabled
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +191,6 @@ class Localplay
|
||||||
$installed = $this->_player->install();
|
$installed = $this->_player->install();
|
||||||
|
|
||||||
return $installed;
|
return $installed;
|
||||||
|
|
||||||
} // install
|
} // install
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,7 +209,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // uninstall
|
} // uninstall
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,7 +224,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // connect
|
} // connect
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,7 +239,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // play
|
} // play
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,7 +254,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // stop
|
} // stop
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,7 +263,6 @@ class Localplay
|
||||||
{
|
{
|
||||||
debug_event('localplay', 'Deprecated add method called: ' . json_encode($object), 5);
|
debug_event('localplay', 'Deprecated add method called: ' . json_encode($object), 5);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // add
|
} // add
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -285,7 +277,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // add_url
|
} // add_url
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -302,7 +293,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // repeat
|
} // repeat
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -319,7 +309,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // random
|
} // random
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -337,7 +326,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // status
|
} // status
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -356,7 +344,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -371,7 +358,9 @@ class Localplay
|
||||||
$value = int($value);
|
$value = int($value);
|
||||||
|
|
||||||
/* Make sure that it's between 0 and 100 */
|
/* Make sure that it's between 0 and 100 */
|
||||||
if ($value > 100 OR $value < 0) { return false; }
|
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');
|
debug_event('localplay','Error: Unable to set volume, check ' . $this->type . ' controller','1');
|
||||||
|
@ -379,7 +368,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // volume_set
|
} // volume_set
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -395,7 +383,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // volume_up
|
} // volume_up
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -411,7 +398,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // volume_down
|
} // volume_down
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -427,7 +413,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // volume_mute
|
} // volume_mute
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,7 +427,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // skip
|
} // skip
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -458,7 +442,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // next
|
} // next
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -474,7 +457,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // prev
|
} // prev
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -490,7 +472,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // pause
|
} // pause
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -502,7 +483,6 @@ class Localplay
|
||||||
$instances = $this->_player->get_instances();
|
$instances = $this->_player->get_instances();
|
||||||
|
|
||||||
return $instances;
|
return $instances;
|
||||||
|
|
||||||
} // get_instances
|
} // get_instances
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -514,7 +494,6 @@ class Localplay
|
||||||
$data = $this->_player->get_instance();
|
$data = $this->_player->get_instance();
|
||||||
|
|
||||||
return $data['id'];
|
return $data['id'];
|
||||||
|
|
||||||
} // current_instance
|
} // current_instance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -526,7 +505,6 @@ class Localplay
|
||||||
$data = $this->_player->get_instance($uid);
|
$data = $this->_player->get_instance($uid);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // get_instance
|
} // get_instance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -538,7 +516,6 @@ class Localplay
|
||||||
$data = $this->_player->update_instance($uid,$data);
|
$data = $this->_player->update_instance($uid,$data);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // update_instance
|
} // update_instance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -548,7 +525,6 @@ class Localplay
|
||||||
public function add_instance($data)
|
public function add_instance($data)
|
||||||
{
|
{
|
||||||
$this->_player->add_instance($data);
|
$this->_player->add_instance($data);
|
||||||
|
|
||||||
} // add_instance
|
} // add_instance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -558,7 +534,6 @@ class Localplay
|
||||||
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
|
} // delete_instance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -568,7 +543,6 @@ class Localplay
|
||||||
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
|
} // set_active_instance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -585,7 +559,6 @@ class Localplay
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete
|
} // delete
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -601,7 +574,6 @@ class Localplay
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete_all
|
} // delete_all
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -614,7 +586,6 @@ class Localplay
|
||||||
$fields = $this->_player->instance_fields();
|
$fields = $this->_player->instance_fields();
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
|
||||||
} // get_instance_fields
|
} // get_instance_fields
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -634,7 +605,6 @@ class Localplay
|
||||||
default:
|
default:
|
||||||
return T_('Unknown');
|
return T_('Unknown');
|
||||||
} // switch on state
|
} // switch on state
|
||||||
|
|
||||||
} // get_user_state
|
} // get_user_state
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -657,8 +627,6 @@ class Localplay
|
||||||
$track_name = "[" . $status['track'] . "] - " . $track_name;
|
$track_name = "[" . $status['track'] . "] - " . $track_name;
|
||||||
|
|
||||||
return $track_name;
|
return $track_name;
|
||||||
|
|
||||||
} // get_user_playing
|
} // get_user_playing
|
||||||
|
|
||||||
|
|
||||||
} // end localplay class
|
} // end localplay class
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ abstract class localplay_controller
|
||||||
$url = call_user_func(array($class,'play_url'),$object->id);
|
$url = call_user_func(array($class,'play_url'),$object->id);
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
|
|
||||||
} // get_url
|
} // get_url
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,12 +101,10 @@ abstract class localplay_controller
|
||||||
$data['primary_key'] = $pkey;
|
$data['primary_key'] = $pkey;
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // parse_url
|
} // parse_url
|
||||||
|
|
||||||
} // end localplay_controller interface
|
} // end localplay_controller interface
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ class Mailer
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Eh bien.
|
// Eh bien.
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +116,6 @@ class Mailer
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_users
|
} // get_users
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,5 +207,5 @@ class Mailer
|
||||||
|
|
||||||
return $this->send($mail);
|
return $this->send($mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Mailer class
|
} // Mailer class
|
||||||
|
|
||||||
|
|
|
@ -61,5 +61,5 @@ interface media
|
||||||
public function get_stream_name();
|
public function get_stream_name();
|
||||||
|
|
||||||
public function set_played($user, $agent, $location);
|
public function set_played($user, $agent, $location);
|
||||||
|
|
||||||
} // end interface
|
} // end interface
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ class memory_object
|
||||||
$this->_data[$key] = $value;
|
$this->_data[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __set($name, $value)
|
public function __set($name, $value)
|
||||||
|
|
|
@ -45,7 +45,6 @@ class Movie extends Video
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +74,6 @@ class Movie extends Video
|
||||||
Dba::write($sql, array($data['id'], $name, $prefix, $data['summary'], $data['year']));
|
Dba::write($sql, array($data['id'], $name, $prefix, $data['summary'], $data['year']));
|
||||||
|
|
||||||
return $data['id'];
|
return $data['id'];
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,7 +104,6 @@ class Movie extends Video
|
||||||
$this->year = $year;
|
$this->year = $year;
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,7 +121,6 @@ class Movie extends Video
|
||||||
$this->f_link = '<a href="' . $this->link . '">' . $this->f_title . '</a>';
|
$this->f_link = '<a href="' . $this->link . '">' . $this->f_title . '</a>';
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} //format
|
} //format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,5 +156,5 @@ class Movie extends Video
|
||||||
|
|
||||||
return $deleted;
|
return $deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Movie class
|
} // Movie class
|
||||||
|
|
||||||
|
|
|
@ -93,5 +93,5 @@ class Openid
|
||||||
|
|
||||||
return $policies;
|
return $policies;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of Openid class
|
} // end of Openid class
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ class Personal_Video extends Video
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +68,6 @@ class Personal_Video extends Video
|
||||||
Dba::write($sql, array($data['id'], $data['location'], $data['summary']));
|
Dba::write($sql, array($data['id'], $data['location'], $data['summary']));
|
||||||
|
|
||||||
return $data['id'];
|
return $data['id'];
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +82,6 @@ class Personal_Video extends Video
|
||||||
Dba::write($sql, array($data['location'], $data['summary'], $this->id));
|
Dba::write($sql, array($data['location'], $data['summary'], $this->id));
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +96,6 @@ class Personal_Video extends Video
|
||||||
$this->f_location = $this->location;
|
$this->f_location = $this->location;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} //format
|
} //format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,5 +111,5 @@ class Personal_Video extends Video
|
||||||
|
|
||||||
return $deleted;
|
return $deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Personal_Video class
|
} // Personal_Video class
|
||||||
|
|
||||||
|
|
|
@ -77,5 +77,5 @@ interface playable_item
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
public function get_catalogs();
|
public function get_catalogs();
|
||||||
|
|
||||||
} // end interface
|
} // end interface
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ class Playlist extends playlist_object
|
||||||
foreach ($info as $key=>$value) {
|
foreach ($info as $key=>$value) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Playlist
|
} // Playlist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,7 +72,9 @@ class Playlist extends playlist_object
|
||||||
*/
|
*/
|
||||||
public static function build_cache($ids)
|
public static function build_cache($ids)
|
||||||
{
|
{
|
||||||
if (!count($ids)) { return false; }
|
if (!count($ids)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$idlist = '(' . implode(',',$ids) . ')';
|
$idlist = '(' . implode(',',$ids) . ')';
|
||||||
|
|
||||||
|
@ -83,7 +84,6 @@ class Playlist extends playlist_object
|
||||||
while ($row = Dba::fetch_assoc($db_results)) {
|
while ($row = Dba::fetch_assoc($db_results)) {
|
||||||
parent::add_to_cache('playlist',$row['id'],$row);
|
parent::add_to_cache('playlist',$row['id'],$row);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // build_cache
|
} // build_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +122,6 @@ class Playlist extends playlist_object
|
||||||
parent::format($details);
|
parent::format($details);
|
||||||
$this->link = AmpConfig::get('web_path') . '/playlist.php?action=show_playlist&playlist_id=' . $this->id;
|
$this->link = AmpConfig::get('web_path') . '/playlist.php?action=show_playlist&playlist_id=' . $this->id;
|
||||||
$this->f_link = '<a href="' . $this->link . '">' . $this->f_name . '</a>';
|
$this->f_link = '<a href="' . $this->link . '">' . $this->f_name . '</a>';
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,7 +137,6 @@ class Playlist extends playlist_object
|
||||||
$row = Dba::fetch_assoc($db_results);
|
$row = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
|
|
||||||
} // get_track
|
} // get_track
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,7 +162,6 @@ class Playlist extends playlist_object
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_items
|
} // get_items
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,7 +179,6 @@ class Playlist extends playlist_object
|
||||||
$db_results = Dba::read($sql, array($this->id));
|
$db_results = Dba::read($sql, array($this->id));
|
||||||
|
|
||||||
while ($row = Dba::fetch_assoc($db_results)) {
|
while ($row = Dba::fetch_assoc($db_results)) {
|
||||||
|
|
||||||
$results[] = array(
|
$results[] = array(
|
||||||
'object_type' => $row['object_type'],
|
'object_type' => $row['object_type'],
|
||||||
'object_id' => $row['object_id']
|
'object_id' => $row['object_id']
|
||||||
|
@ -190,7 +186,6 @@ class Playlist extends playlist_object
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_random_items
|
} // get_random_items
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -210,7 +205,6 @@ class Playlist extends playlist_object
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_songs
|
} // get_songs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,7 +220,6 @@ class Playlist extends playlist_object
|
||||||
$results = Dba::fetch_row($db_results);
|
$results = Dba::fetch_row($db_results);
|
||||||
|
|
||||||
return $results['0'];
|
return $results['0'];
|
||||||
|
|
||||||
} // get_song_count
|
} // get_song_count
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,7 +237,6 @@ class Playlist extends playlist_object
|
||||||
$results = Dba::fetch_row($db_results);
|
$results = Dba::fetch_row($db_results);
|
||||||
|
|
||||||
return $results['0'];
|
return $results['0'];
|
||||||
|
|
||||||
} // get_total_duration
|
} // get_total_duration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,7 +256,6 @@ class Playlist extends playlist_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_users
|
} // get_users
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -292,7 +283,6 @@ class Playlist extends playlist_object
|
||||||
if ($this->_update_item('type',$new_type,50)) {
|
if ($this->_update_item('type',$new_type,50)) {
|
||||||
$this->type = $new_type;
|
$this->type = $new_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // update_type
|
} // update_type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -304,7 +294,6 @@ class Playlist extends playlist_object
|
||||||
if ($this->_update_item('name',$new_name,50)) {
|
if ($this->_update_item('name',$new_name,50)) {
|
||||||
$this->name = $new_name;
|
$this->name = $new_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // update_name
|
} // update_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,7 +310,6 @@ class Playlist extends playlist_object
|
||||||
$db_results = Dba::write($sql, array($value, $this->id));
|
$db_results = Dba::write($sql, array($value, $this->id));
|
||||||
|
|
||||||
return $db_results;
|
return $db_results;
|
||||||
|
|
||||||
} // update_item
|
} // update_item
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,7 +320,6 @@ class Playlist extends playlist_object
|
||||||
{
|
{
|
||||||
$sql = "UPDATE `playlist_data` SET `track` = ? WHERE `id` = ?";
|
$sql = "UPDATE `playlist_data` SET `track` = ? WHERE `id` = ?";
|
||||||
Dba::write($sql, array($index, $track_id));
|
Dba::write($sql, array($index, $track_id));
|
||||||
|
|
||||||
} // update_track_number
|
} // update_track_number
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -362,7 +349,6 @@ class Playlist extends playlist_object
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->add_medias($medias, $ordered);
|
$this->add_medias($medias, $ordered);
|
||||||
|
|
||||||
} // add_songs
|
} // add_songs
|
||||||
|
|
||||||
public function add_medias($medias, $ordered=false)
|
public function add_medias($medias, $ordered=false)
|
||||||
|
@ -395,7 +381,6 @@ class Playlist extends playlist_object
|
||||||
" VALUES (?, ?, ?, ?)";
|
" VALUES (?, ?, ?, ?)";
|
||||||
Dba::write($sql, array($this->id, $data['object_id'], $data['object_type'], $track));
|
Dba::write($sql, array($this->id, $data['object_id'], $data['object_type'], $track));
|
||||||
} // if valid id
|
} // if valid id
|
||||||
|
|
||||||
} // end foreach medias
|
} // end foreach medias
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +402,6 @@ class Playlist extends playlist_object
|
||||||
|
|
||||||
$insert_id = Dba::insert_id();
|
$insert_id = Dba::insert_id();
|
||||||
return $insert_id;
|
return $insert_id;
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -427,7 +411,6 @@ class Playlist extends playlist_object
|
||||||
public function set_items()
|
public function set_items()
|
||||||
{
|
{
|
||||||
$this->items = $this->get_items();
|
$this->items = $this->get_items();
|
||||||
|
|
||||||
} // set_items
|
} // set_items
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,7 +423,6 @@ class Playlist extends playlist_object
|
||||||
Dba::write($sql, array($this->id, $id));
|
Dba::write($sql, array($this->id, $id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete_track
|
} // delete_track
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -453,7 +435,6 @@ class Playlist extends playlist_object
|
||||||
Dba::write($sql, array($this->id, $track));
|
Dba::write($sql, array($this->id, $track));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete_track_number
|
} // delete_track_number
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,7 +453,6 @@ class Playlist extends playlist_object
|
||||||
Dba::write($sql, array($this->id));
|
Dba::write($sql, array($this->id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete
|
} // delete
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -511,7 +491,6 @@ class Playlist extends playlist_object
|
||||||
} // foreach re-ordered results
|
} // foreach re-ordered results
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // sort_tracks
|
} // sort_tracks
|
||||||
|
|
||||||
} // class Playlist
|
} // class Playlist
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,6 @@ abstract class playlist_object extends database_object implements library_item
|
||||||
$client->format();
|
$client->format();
|
||||||
$this->f_user = $client->f_name;
|
$this->f_user = $client->f_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +91,6 @@ abstract class playlist_object extends database_object implements library_item
|
||||||
} else {
|
} else {
|
||||||
return Access::check('interface', 75);
|
return Access::check('interface', 75);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // has_access
|
} // has_access
|
||||||
|
|
||||||
public function get_medias($filter_type = null)
|
public function get_medias($filter_type = null)
|
||||||
|
@ -174,5 +172,5 @@ abstract class playlist_object extends database_object implements library_item
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end playlist_object
|
} // end playlist_object
|
||||||
|
|
||||||
|
|
|
@ -177,8 +177,8 @@ class Plex_Api
|
||||||
if (!$sid) {
|
if (!$sid) {
|
||||||
$sid = $myplex_token;
|
$sid = $myplex_token;
|
||||||
if ($sid) {
|
if ($sid) {
|
||||||
session_id($sid);
|
session_id($sid);
|
||||||
Session::create_cookie();
|
Session::create_cookie();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($sid) && Session::exists('api', $sid)) {
|
if (!empty($sid) && Session::exists('api', $sid)) {
|
||||||
|
@ -319,7 +319,8 @@ class Plex_Api
|
||||||
);
|
);
|
||||||
$action = 'users/sign_in.xml';
|
$action = 'users/sign_in.xml';
|
||||||
|
|
||||||
$res = self::myPlexRequest($action, $options, $headers);;
|
$res = self::myPlexRequest($action, $options, $headers);
|
||||||
|
;
|
||||||
return $res['xml']['authenticationToken'];
|
return $res['xml']['authenticationToken'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,7 +559,6 @@ class Plex_Api
|
||||||
{
|
{
|
||||||
if (count($params) == 2) {
|
if (count($params) == 2) {
|
||||||
if ($params[0] == ':' && $params[1] == 'transcode') {
|
if ($params[0] == ':' && $params[1] == 'transcode') {
|
||||||
|
|
||||||
$width = $_REQUEST['width'];
|
$width = $_REQUEST['width'];
|
||||||
$height = $_REQUEST['height'];
|
$height = $_REQUEST['height'];
|
||||||
$url = $_REQUEST['url'];
|
$url = $_REQUEST['url'];
|
||||||
|
@ -698,15 +698,18 @@ class Plex_Api
|
||||||
|
|
||||||
$videoResolution = $_GET['videoResolution'];
|
$videoResolution = $_GET['videoResolution'];
|
||||||
$maxVideoBitrate = $_GET['maxVideoBitrate'];
|
$maxVideoBitrate = $_GET['maxVideoBitrate'];
|
||||||
if (!$maxVideoBitrate)
|
if (!$maxVideoBitrate) {
|
||||||
$maxVideoBitrate = 8175;
|
$maxVideoBitrate = 8175;
|
||||||
|
}
|
||||||
|
|
||||||
echo "#EXTM3U\n";
|
echo "#EXTM3U\n";
|
||||||
echo "#EXT-X-STREAM-INF:PROGRAM-ID=1";
|
echo "#EXT-X-STREAM-INF:PROGRAM-ID=1";
|
||||||
if ($maxVideoBitrate)
|
if ($maxVideoBitrate) {
|
||||||
echo ",BANDWIDTH=" . ($maxVideoBitrate * 1000);
|
echo ",BANDWIDTH=" . ($maxVideoBitrate * 1000);
|
||||||
if ($videoResolution)
|
}
|
||||||
|
if ($videoResolution) {
|
||||||
echo ",RESOLUTION=" . $videoResolution;
|
echo ",RESOLUTION=" . $videoResolution;
|
||||||
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
echo "hls.m3u8?" . substr($_SERVER['QUERY_STRING'], strpos($_SERVER['QUERY_STRING'], '&') + 1);
|
echo "hls.m3u8?" . substr($_SERVER['QUERY_STRING'], strpos($_SERVER['QUERY_STRING'], '&') + 1);
|
||||||
} elseif ($protocol == "http") {
|
} elseif ($protocol == "http") {
|
||||||
|
@ -949,7 +952,6 @@ class Plex_Api
|
||||||
}
|
}
|
||||||
Plex_XML_Data::addPlaylist($r, $litem);
|
Plex_XML_Data::addPlaylist($r, $litem);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$subact = $params[1];
|
$subact = $params[1];
|
||||||
if ($subact == "children") {
|
if ($subact == "children") {
|
||||||
|
@ -957,18 +959,24 @@ class Plex_Api
|
||||||
$litem = new Artist($id);
|
$litem = new Artist($id);
|
||||||
$litem->format();
|
$litem->format();
|
||||||
Plex_XML_Data::setArtistRoot($r, $litem);
|
Plex_XML_Data::setArtistRoot($r, $litem);
|
||||||
} else if (Plex_XML_Data::isAlbum($key)) {
|
} else {
|
||||||
$litem = new Album($id);
|
if (Plex_XML_Data::isAlbum($key)) {
|
||||||
$litem->format();
|
$litem = new Album($id);
|
||||||
Plex_XML_Data::setAlbumRoot($r, $litem);
|
$litem->format();
|
||||||
} else if (Plex_XML_Data::isTVShow($key)) {
|
Plex_XML_Data::setAlbumRoot($r, $litem);
|
||||||
$litem = new TVShow($id);
|
} else {
|
||||||
$litem->format();
|
if (Plex_XML_Data::isTVShow($key)) {
|
||||||
Plex_XML_Data::setTVShowRoot($r, $litem);
|
$litem = new TVShow($id);
|
||||||
} else if (Plex_XML_Data::isTVShowSeason($key)) {
|
$litem->format();
|
||||||
$litem = new TVShow_Season($id);
|
Plex_XML_Data::setTVShowRoot($r, $litem);
|
||||||
$litem->format();
|
} else {
|
||||||
Plex_XML_Data::setTVShowSeasonRoot($r, $litem);
|
if (Plex_XML_Data::isTVShowSeason($key)) {
|
||||||
|
$litem = new TVShow_Season($id);
|
||||||
|
$litem->format();
|
||||||
|
Plex_XML_Data::setTVShowSeasonRoot($r, $litem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} elseif ($subact == "thumbs" || $subact == "posters" || $subact == "arts" || $subact == 'backgrounds') {
|
} elseif ($subact == "thumbs" || $subact == "posters" || $subact == "arts" || $subact == 'backgrounds') {
|
||||||
$kind = Plex_XML_Data::getPhotoKind($subact);
|
$kind = Plex_XML_Data::getPhotoKind($subact);
|
||||||
|
@ -1000,16 +1008,26 @@ class Plex_Api
|
||||||
$art = null;
|
$art = null;
|
||||||
if (Plex_XML_Data::isArtist($key)) {
|
if (Plex_XML_Data::isArtist($key)) {
|
||||||
$art = new Art($id, "artist", $kind);
|
$art = new Art($id, "artist", $kind);
|
||||||
} else if (Plex_XML_Data::isAlbum($key)) {
|
} else {
|
||||||
$art = new Art($id, "album", $kind);
|
if (Plex_XML_Data::isAlbum($key)) {
|
||||||
} else if (Plex_XML_Data::isTrack($key)) {
|
$art = new Art($id, "album", $kind);
|
||||||
$art = new Art($id, "song", $kind);
|
} else {
|
||||||
} else if (Plex_XML_Data::isTVShow($key)) {
|
if (Plex_XML_Data::isTrack($key)) {
|
||||||
$art = new Art($id, "tvshow", $kind);
|
$art = new Art($id, "song", $kind);
|
||||||
} else if (Plex_XML_Data::isTVShowSeason($key)) {
|
} else {
|
||||||
$art = new Art($id, "tvshow_season", $kind);
|
if (Plex_XML_Data::isTVShow($key)) {
|
||||||
} else if (Plex_XML_Data::isVideo($key)) {
|
$art = new Art($id, "tvshow", $kind);
|
||||||
$art = new Art($id, "video", $kind);
|
} else {
|
||||||
|
if (Plex_XML_Data::isTVShowSeason($key)) {
|
||||||
|
$art = new Art($id, "tvshow_season", $kind);
|
||||||
|
} else {
|
||||||
|
if (Plex_XML_Data::isVideo($key)) {
|
||||||
|
$art = new Art($id, "video", $kind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($art != null) {
|
if ($art != null) {
|
||||||
|
@ -1071,9 +1089,9 @@ class Plex_Api
|
||||||
CURLOPT_SSL_VERIFYHOST => false,
|
CURLOPT_SSL_VERIFYHOST => false,
|
||||||
CURLOPT_TIMEOUT => 0
|
CURLOPT_TIMEOUT => 0
|
||||||
));
|
));
|
||||||
if (curl_exec($ch) === false) {
|
if (curl_exec($ch) === false) {
|
||||||
debug_event('plex-api', 'Curl error: ' . curl_error($ch),1);
|
debug_event('plex-api', 'Curl error: ' . curl_error($ch),1);
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1245,7 +1263,9 @@ class Plex_Api
|
||||||
$userid = $params[0];
|
$userid = $params[0];
|
||||||
}
|
}
|
||||||
// Not supported yet
|
// Not supported yet
|
||||||
if ($userid > 1) { self::createError(404); }
|
if ($userid > 1) {
|
||||||
|
self::createError(404);
|
||||||
|
}
|
||||||
|
|
||||||
$r = Plex_XML_Data::createAccountContainer();
|
$r = Plex_XML_Data::createAccountContainer();
|
||||||
Plex_XML_Data::setAccounts($r, $userid);
|
Plex_XML_Data::setAccounts($r, $userid);
|
||||||
|
@ -1373,7 +1393,9 @@ class Plex_Api
|
||||||
if ($res['status'] == '201') {
|
if ($res['status'] == '201') {
|
||||||
Plex_XML_Data::setMyPlexSubscription($res['xml']);
|
Plex_XML_Data::setMyPlexSubscription($res['xml']);
|
||||||
self::apiOutput($res['xml']->asXML());
|
self::apiOutput($res['xml']->asXML());
|
||||||
} else { self::createError($res['status']); }
|
} else {
|
||||||
|
self::createError($res['status']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1099,57 +1099,57 @@ class Plex_XML_Data
|
||||||
|
|
||||||
public static function addSong(SimpleXMLElement $xml, Song $song)
|
public static function addSong(SimpleXMLElement $xml, Song $song)
|
||||||
{
|
{
|
||||||
$xdir = $xml->addChild('Track');
|
$xdir = $xml->addChild('Track');
|
||||||
self::addSongMeta($xdir, $song);
|
self::addSongMeta($xdir, $song);
|
||||||
$time = $song->time * 1000;
|
$time = $song->time * 1000;
|
||||||
$xdir->addAttribute('title', $song->title);
|
$xdir->addAttribute('title', $song->title);
|
||||||
$id = self::getAlbumId($song->id);
|
$id = self::getAlbumId($song->id);
|
||||||
$albumid = self::getAlbumId($song->album);
|
$albumid = self::getAlbumId($song->album);
|
||||||
$artistid = self::getAlbumId($song->artist);
|
$artistid = self::getAlbumId($song->artist);
|
||||||
$xdir->addAttribute('grandparentRatingKey', $artistid);
|
$xdir->addAttribute('grandparentRatingKey', $artistid);
|
||||||
$xdir->addAttribute('parentRatingKey', $albumid);
|
$xdir->addAttribute('parentRatingKey', $albumid);
|
||||||
$xdir->addAttribute('grandparentKey', self::getMetadataUri($albumid));
|
$xdir->addAttribute('grandparentKey', self::getMetadataUri($albumid));
|
||||||
$xdir->addAttribute('parentKey', self::getMetadataUri($albumid));
|
$xdir->addAttribute('parentKey', self::getMetadataUri($albumid));
|
||||||
$xdir->addAttribute('grandparentTitle', $song->f_artist);
|
$xdir->addAttribute('grandparentTitle', $song->f_artist);
|
||||||
$xdir->addAttribute('parentTitle', $song->f_album);
|
$xdir->addAttribute('parentTitle', $song->f_album);
|
||||||
$xdir->addAttribute('originalTitle', $song->f_artist);
|
$xdir->addAttribute('originalTitle', $song->f_artist);
|
||||||
$xdir->addAttribute('summary', '');
|
$xdir->addAttribute('summary', '');
|
||||||
$xdir->addAttribute('art', self::getMetadataUri($id) . '/art/' . $id);
|
$xdir->addAttribute('art', self::getMetadataUri($id) . '/art/' . $id);
|
||||||
$xdir->addAttribute('grandparentThumb', self::getMetadataUri($artistid) . '/thumb/' . $artistid);
|
$xdir->addAttribute('grandparentThumb', self::getMetadataUri($artistid) . '/thumb/' . $artistid);
|
||||||
$xdir->addAttribute('parentThumb', self::getMetadataUri($albumid) . '/thumb/' . $albumid);
|
$xdir->addAttribute('parentThumb', self::getMetadataUri($albumid) . '/thumb/' . $albumid);
|
||||||
$xdir->addAttribute('thumb', self::getMetadataUri($albumid) . '/thumb/' . $albumid); // No song art, set album art
|
$xdir->addAttribute('thumb', self::getMetadataUri($albumid) . '/thumb/' . $albumid); // No song art, set album art
|
||||||
$xdir->addAttribute('index', $song->track);
|
$xdir->addAttribute('index', $song->track);
|
||||||
$xdir->addAttribute('duration', $time);
|
$xdir->addAttribute('duration', $time);
|
||||||
$xdir->addAttribute('type', 'track');
|
$xdir->addAttribute('type', 'track');
|
||||||
$xdir->addAttribute('addedAt', '');
|
$xdir->addAttribute('addedAt', '');
|
||||||
$xdir->addAttribute('updatedAt', '');
|
$xdir->addAttribute('updatedAt', '');
|
||||||
|
|
||||||
$rating = new Rating($song->id, "song");
|
$rating = new Rating($song->id, "song");
|
||||||
$rating_value = $rating->get_average_rating();
|
$rating_value = $rating->get_average_rating();
|
||||||
if ($rating_value > 0) {
|
if ($rating_value > 0) {
|
||||||
$xdir->addAttribute('rating', intval($rating_value * 2));
|
$xdir->addAttribute('rating', intval($rating_value * 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmedia = $xdir->addChild('Media');
|
$xmedia = $xdir->addChild('Media');
|
||||||
$mediaid = self::getSongId($song->id);
|
$mediaid = self::getSongId($song->id);
|
||||||
$xmedia->addAttribute('id', $mediaid);
|
$xmedia->addAttribute('id', $mediaid);
|
||||||
$xmedia->addAttribute('duration', $time);
|
$xmedia->addAttribute('duration', $time);
|
||||||
$xmedia->addAttribute('bitrate', intval($song->bitrate / 1000));
|
$xmedia->addAttribute('bitrate', intval($song->bitrate / 1000));
|
||||||
$xmedia->addAttribute('audioChannels', $song->channels);
|
$xmedia->addAttribute('audioChannels', $song->channels);
|
||||||
// Type != Codec != Container, but that's how Ampache works today...
|
// Type != Codec != Container, but that's how Ampache works today...
|
||||||
$xmedia->addAttribute('audioCodec', $song->type);
|
$xmedia->addAttribute('audioCodec', $song->type);
|
||||||
$xmedia->addAttribute('container', $song->type);
|
$xmedia->addAttribute('container', $song->type);
|
||||||
|
|
||||||
$xpart = $xmedia->addChild('Part');
|
$xpart = $xmedia->addChild('Part');
|
||||||
$partid = self::getPartId($mediaid);
|
$partid = self::getPartId($mediaid);
|
||||||
$xpart->addAttribute('id', $partid);
|
$xpart->addAttribute('id', $partid);
|
||||||
$xpart->addAttribute('key', self::getPartUri($partid, $song->type));
|
$xpart->addAttribute('key', self::getPartUri($partid, $song->type));
|
||||||
$xpart->addAttribute('duration', $time);
|
$xpart->addAttribute('duration', $time);
|
||||||
$xpart->addAttribute('file', $song->file);
|
$xpart->addAttribute('file', $song->file);
|
||||||
$xpart->addAttribute('size', $song->size);
|
$xpart->addAttribute('size', $song->size);
|
||||||
$xpart->addAttribute('container', $song->type);
|
$xpart->addAttribute('container', $song->type);
|
||||||
|
|
||||||
return $xdir;
|
return $xdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addSongMeta(SimpleXMLElement $xml, Song $song)
|
public static function addSongMeta(SimpleXMLElement $xml, Song $song)
|
||||||
|
@ -1227,29 +1227,29 @@ class Plex_XML_Data
|
||||||
$xvid->addAttribute('updatedAt', '');
|
$xvid->addAttribute('updatedAt', '');
|
||||||
$xvid->addAttribute('thumb', self::getMetadataUri($id) . '/thumb/' . $id);
|
$xvid->addAttribute('thumb', self::getMetadataUri($id) . '/thumb/' . $id);
|
||||||
|
|
||||||
$xmedia = $xvid->addChild('Media');
|
$xmedia = $xvid->addChild('Media');
|
||||||
$xmedia->addAttribute('id', $id); // Same ID that video => OK?
|
$xmedia->addAttribute('id', $id); // Same ID that video => OK?
|
||||||
$xmedia->addAttribute('duration', $time);
|
$xmedia->addAttribute('duration', $time);
|
||||||
$xmedia->addAttribute('bitrate', intval($video->bitrate / 1000));
|
$xmedia->addAttribute('bitrate', intval($video->bitrate / 1000));
|
||||||
$xmedia->addAttribute('audioChannels', $video->channels);
|
$xmedia->addAttribute('audioChannels', $video->channels);
|
||||||
// Type != Codec != Container, but that's how Ampache works today...
|
// Type != Codec != Container, but that's how Ampache works today...
|
||||||
$xmedia->addAttribute('audioCodec', $video->audio_codec);
|
$xmedia->addAttribute('audioCodec', $video->audio_codec);
|
||||||
$xmedia->addAttribute('videoCodec', $video->video_codec);
|
$xmedia->addAttribute('videoCodec', $video->video_codec);
|
||||||
$xmedia->addAttribute('container', $video->type);
|
$xmedia->addAttribute('container', $video->type);
|
||||||
$xmedia->addAttribute('width', $video->resolution_x);
|
$xmedia->addAttribute('width', $video->resolution_x);
|
||||||
$xmedia->addAttribute('height', $video->resolution_y);
|
$xmedia->addAttribute('height', $video->resolution_y);
|
||||||
//$xmedia->addAttribute('videoResolution', 'sd'); // TODO
|
//$xmedia->addAttribute('videoResolution', 'sd'); // TODO
|
||||||
//$xmedia->addAttribute('aspectRatio', '1.78'); // TODO
|
//$xmedia->addAttribute('aspectRatio', '1.78'); // TODO
|
||||||
$xmedia->addAttribute('videoFrameRate', intval(ceil($video->frame_rate)) . 'p');
|
$xmedia->addAttribute('videoFrameRate', intval(ceil($video->frame_rate)) . 'p');
|
||||||
|
|
||||||
$xpart = $xmedia->addChild('Part');
|
$xpart = $xmedia->addChild('Part');
|
||||||
$partid = self::getPartId($id);
|
$partid = self::getPartId($id);
|
||||||
$xpart->addAttribute('id', $partid);
|
$xpart->addAttribute('id', $partid);
|
||||||
$xpart->addAttribute('key', self::getPartUri($partid, $video->type));
|
$xpart->addAttribute('key', self::getPartUri($partid, $video->type));
|
||||||
$xpart->addAttribute('duration', $time);
|
$xpart->addAttribute('duration', $time);
|
||||||
$xpart->addAttribute('file', $video->file);
|
$xpart->addAttribute('file', $video->file);
|
||||||
$xpart->addAttribute('size', $video->size);
|
$xpart->addAttribute('size', $video->size);
|
||||||
$xpart->addAttribute('container', $video->type);
|
$xpart->addAttribute('container', $video->type);
|
||||||
|
|
||||||
// TODO: support Writer/Director tags here as part of Video/
|
// TODO: support Writer/Director tags here as part of Video/
|
||||||
/*
|
/*
|
||||||
|
@ -1267,29 +1267,29 @@ class Plex_XML_Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($details) {
|
if ($details) {
|
||||||
// Subtitles
|
// Subtitles
|
||||||
$subtitles = $video->get_subtitles();
|
$subtitles = $video->get_subtitles();
|
||||||
foreach ($subtitles as $subtitle) {
|
foreach ($subtitles as $subtitle) {
|
||||||
$streamid = hexdec(bin2hex($subtitle['lang_code'])) . $partid;
|
$streamid = hexdec(bin2hex($subtitle['lang_code'])) . $partid;
|
||||||
$xstream = $xpart->addChild('Stream');
|
$xstream = $xpart->addChild('Stream');
|
||||||
$xstream->addAttribute('id', $streamid);
|
$xstream->addAttribute('id', $streamid);
|
||||||
$xstream->addAttribute('key', '/library/streams/' . $streamid);
|
$xstream->addAttribute('key', '/library/streams/' . $streamid);
|
||||||
$xstream->addAttribute('streamType', '3');
|
$xstream->addAttribute('streamType', '3');
|
||||||
$xstream->addAttribute('codec', 'srt');
|
$xstream->addAttribute('codec', 'srt');
|
||||||
$xstream->addAttribute('language', $subtitle['lang_name']);
|
$xstream->addAttribute('language', $subtitle['lang_name']);
|
||||||
$xstream->addAttribute('languageCode', $subtitle['lang_code']);
|
$xstream->addAttribute('languageCode', $subtitle['lang_code']);
|
||||||
$xstream->addAttribute('format', 'srt');
|
$xstream->addAttribute('format', 'srt');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: support real audio/video streams!
|
// TODO: support real audio/video streams!
|
||||||
/*
|
/*
|
||||||
<Stream id="93" streamType="1" codec="mpeg4" index="0" bitrate="833" bitDepth="8" chromaSubsampling="4:2:0" colorSpace="yuv" duration="2989528" frameRate="23,976" gmc="0" height="352" level="5" profile="asp" qpel="0" scanType="progressive" width="624" />
|
<Stream id="93" streamType="1" codec="mpeg4" index="0" bitrate="833" bitDepth="8" chromaSubsampling="4:2:0" colorSpace="yuv" duration="2989528" frameRate="23,976" gmc="0" height="352" level="5" profile="asp" qpel="0" scanType="progressive" width="624" />
|
||||||
<Stream id="94" streamType="2" selected="1" codec="mp3" index="1" channels="2" bitrate="135" bitrateMode="vbr" duration="2989488" samplingRate="48000" />
|
<Stream id="94" streamType="2" selected="1" codec="mp3" index="1" channels="2" bitrate="135" bitrateMode="vbr" duration="2989488" samplingRate="48000" />
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return $xvid;
|
return $xvid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setPlaylists(SimpleXMLElement $xml)
|
public static function setPlaylists(SimpleXMLElement $xml)
|
||||||
|
@ -1738,10 +1738,11 @@ class Plex_XML_Data
|
||||||
|
|
||||||
protected static function getPathDelimiter()
|
protected static function getPathDelimiter()
|
||||||
{
|
{
|
||||||
if (strpos(PHP_OS, 'WIN') === 0)
|
if (strpos(PHP_OS, 'WIN') === 0) {
|
||||||
return '\\';
|
return '\\';
|
||||||
else
|
} else {
|
||||||
return '/';
|
return '/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setBrowseService(SimpleXMLElement $xml, $path)
|
public static function setBrowseService(SimpleXMLElement $xml, $path)
|
||||||
|
|
|
@ -41,7 +41,6 @@ class Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +63,6 @@ class Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // _get_info
|
} // _get_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,8 +73,9 @@ class Plugin
|
||||||
{
|
{
|
||||||
// make static cache for optimization when multiple call
|
// make static cache for optimization when multiple call
|
||||||
static $plugins_list = array();
|
static $plugins_list = array();
|
||||||
if (isset($plugins_list[$type]))
|
if (isset($plugins_list[$type])) {
|
||||||
return $plugins_list[$type];
|
return $plugins_list[$type];
|
||||||
|
}
|
||||||
|
|
||||||
$plugins_list[$type] = array();
|
$plugins_list[$type] = array();
|
||||||
|
|
||||||
|
@ -90,8 +89,12 @@ class Plugin
|
||||||
// Recurse the directory
|
// Recurse the directory
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
// Ignore non-plugin files
|
// Ignore non-plugin files
|
||||||
if (substr($file,-10,10) != 'plugin.php') { continue; }
|
if (substr($file,-10,10) != 'plugin.php') {
|
||||||
if (is_dir($file)) { continue; }
|
continue;
|
||||||
|
}
|
||||||
|
if (is_dir($file)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$plugin_name = basename($file,'.plugin.php');
|
$plugin_name = basename($file,'.plugin.php');
|
||||||
if ($type != '') {
|
if ($type != '') {
|
||||||
$plugin = new Plugin($plugin_name);
|
$plugin = new Plugin($plugin_name);
|
||||||
|
@ -116,7 +119,6 @@ class Plugin
|
||||||
ksort($plugins_list[$type]);
|
ksort($plugins_list[$type]);
|
||||||
|
|
||||||
return $plugins_list[$type];
|
return $plugins_list[$type];
|
||||||
|
|
||||||
} // get_plugins
|
} // get_plugins
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +168,6 @@ class Plugin
|
||||||
|
|
||||||
// We've passed all of the tests
|
// We've passed all of the tests
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // is_valid
|
} // is_valid
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,7 +179,6 @@ class Plugin
|
||||||
{
|
{
|
||||||
/* All we do is check the version */
|
/* All we do is check the version */
|
||||||
return self::get_plugin_version($plugin_name);
|
return self::get_plugin_version($plugin_name);
|
||||||
|
|
||||||
} // is_installed
|
} // is_installed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -206,7 +206,6 @@ class Plugin
|
||||||
$this->_plugin->uninstall();
|
$this->_plugin->uninstall();
|
||||||
|
|
||||||
$this->remove_plugin_version();
|
$this->remove_plugin_version();
|
||||||
|
|
||||||
} // uninstall
|
} // uninstall
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -249,7 +248,6 @@ class Plugin
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // get_plugin_version
|
} // get_plugin_version
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,7 +262,6 @@ class Plugin
|
||||||
$results = Dba::fetch_assoc($db_results);
|
$results = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $results['value'];
|
return $results['value'];
|
||||||
|
|
||||||
} // get_ampache_db_version
|
} // get_ampache_db_version
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,7 +277,6 @@ class Plugin
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // set_plugin_version
|
} // set_plugin_version
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -295,7 +291,6 @@ class Plugin
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // remove_plugin_version
|
} // remove_plugin_version
|
||||||
|
|
||||||
} //end plugin class
|
} //end plugin class
|
||||||
|
|
||||||
|
|
|
@ -293,13 +293,15 @@ class Preference extends database_object
|
||||||
$params = array($id, $default);
|
$params = array($id, $default);
|
||||||
$sql = "INSERT INTO `user_preference` VALUES (-1,?,?)";
|
$sql = "INSERT INTO `user_preference` VALUES (-1,?,?)";
|
||||||
$db_results = Dba::write($sql, $params);
|
$db_results = Dba::write($sql, $params);
|
||||||
if (!$db_results)
|
if (!$db_results) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if ($catagory !== "system") {
|
if ($catagory !== "system") {
|
||||||
$sql = "INSERT INTO `user_preference` SELECT `user`.`id`, ?, ? FROM `user`";
|
$sql = "INSERT INTO `user_preference` SELECT `user`.`id`, ?, ? FROM `user`";
|
||||||
$db_results = Dba::write($sql, $params);
|
$db_results = Dba::write($sql, $params);
|
||||||
if (!$db_results)
|
if (!$db_results) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -477,3 +479,4 @@ class Preference extends database_object
|
||||||
$_SESSION['userdata']['uid'] = $user_id;
|
$_SESSION['userdata']['uid'] = $user_id;
|
||||||
} // init
|
} // init
|
||||||
} // end Preference class
|
} // end Preference class
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,9 @@ class PrivateMsg extends database_object
|
||||||
*/
|
*/
|
||||||
public function __construct($id=null)
|
public function __construct($id=null)
|
||||||
{
|
{
|
||||||
if (!$id) { return false; }
|
if (!$id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$info = $this->get_info($id, 'user_pvmsg');
|
$info = $this->get_info($id, 'user_pvmsg');
|
||||||
foreach ($info as $key=>$value) {
|
foreach ($info as $key=>$value) {
|
||||||
|
|
|
@ -89,7 +89,6 @@ class Query
|
||||||
|
|
||||||
$db_results = Dba::read($sql, array($id, $sid));
|
$db_results = Dba::read($sql, array($id, $sid));
|
||||||
if ($results = Dba::fetch_assoc($db_results)) {
|
if ($results = Dba::fetch_assoc($db_results)) {
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->_state = (array) self::_unserialize($results['data']);
|
$this->_state = (array) self::_unserialize($results['data']);
|
||||||
|
|
||||||
|
@ -485,14 +484,24 @@ class Query
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
if ($this->is_static_content()) { return false; }
|
if ($this->is_static_content()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$this->_state['filter'][$key] = $value;
|
$this->_state['filter'][$key] = $value;
|
||||||
if ($key == 'regex_match') unset($this->_state['filter']['regex_not_match']);
|
if ($key == 'regex_match') {
|
||||||
if ($key == 'regex_not_match') unset($this->_state['filter']['regex_match']);
|
unset($this->_state['filter']['regex_not_match']);
|
||||||
|
}
|
||||||
|
if ($key == 'regex_not_match') {
|
||||||
|
unset($this->_state['filter']['regex_match']);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'playlist_type':
|
case 'playlist_type':
|
||||||
// Must be a content manager to turn this off
|
// Must be a content manager to turn this off
|
||||||
if (Access::check('interface','100')) { unset($this->_state['filter'][$key]); } else { $this->_state['filter'][$key] = '1'; }
|
if (Access::check('interface','100')) {
|
||||||
|
unset($this->_state['filter'][$key]);
|
||||||
|
} else {
|
||||||
|
$this->_state['filter'][$key] = '1';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Rien a faire
|
// Rien a faire
|
||||||
|
@ -504,7 +513,6 @@ class Query
|
||||||
$this->set_start(0);
|
$this->set_start(0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // set_filter
|
} // set_filter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -524,7 +532,6 @@ class Query
|
||||||
$this->set_is_simple(false);
|
$this->set_is_simple(false);
|
||||||
$this->set_start(0);
|
$this->set_start(0);
|
||||||
$this->set_offset(AmpConfig::get('offset_limit') ? AmpConfig::get('offset_limit') : '25');
|
$this->set_offset(AmpConfig::get('offset_limit') ? AmpConfig::get('offset_limit') : '25');
|
||||||
|
|
||||||
} // reset
|
} // reset
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -534,7 +541,6 @@ class Query
|
||||||
public function reset_base()
|
public function reset_base()
|
||||||
{
|
{
|
||||||
$this->_state['base'] = NULL;
|
$this->_state['base'] = NULL;
|
||||||
|
|
||||||
} // reset_base
|
} // reset_base
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -544,7 +550,6 @@ class Query
|
||||||
public function reset_select()
|
public function reset_select()
|
||||||
{
|
{
|
||||||
$this->_state['select'] = array();
|
$this->_state['select'] = array();
|
||||||
|
|
||||||
} // reset_select
|
} // reset_select
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -554,7 +559,6 @@ class Query
|
||||||
public function reset_having()
|
public function reset_having()
|
||||||
{
|
{
|
||||||
unset($this->_state['having']);
|
unset($this->_state['having']);
|
||||||
|
|
||||||
} // reset_having
|
} // reset_having
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -564,7 +568,6 @@ class Query
|
||||||
public function reset_join()
|
public function reset_join()
|
||||||
{
|
{
|
||||||
unset($this->_state['join']);
|
unset($this->_state['join']);
|
||||||
|
|
||||||
} // reset_join
|
} // reset_join
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -574,7 +577,6 @@ class Query
|
||||||
public function reset_filters()
|
public function reset_filters()
|
||||||
{
|
{
|
||||||
$this->_state['filter'] = array();
|
$this->_state['filter'] = array();
|
||||||
|
|
||||||
} // reset_filters
|
} // reset_filters
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -584,7 +586,6 @@ class Query
|
||||||
public function reset_total()
|
public function reset_total()
|
||||||
{
|
{
|
||||||
unset($this->_state['total']);
|
unset($this->_state['total']);
|
||||||
|
|
||||||
} // reset_total
|
} // reset_total
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -599,7 +600,6 @@ class Query
|
||||||
return isset($this->_state['filter'][$key])
|
return isset($this->_state['filter'][$key])
|
||||||
? $this->_state['filter'][$key]
|
? $this->_state['filter'][$key]
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
} // get_filter
|
} // get_filter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -610,7 +610,6 @@ class Query
|
||||||
public function get_start()
|
public function get_start()
|
||||||
{
|
{
|
||||||
return $this->_state['start'];
|
return $this->_state['start'];
|
||||||
|
|
||||||
} // get_start
|
} // get_start
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -659,7 +658,6 @@ class Query
|
||||||
$this->_state['total'] = $num_rows;
|
$this->_state['total'] = $num_rows;
|
||||||
|
|
||||||
return $num_rows;
|
return $num_rows;
|
||||||
|
|
||||||
} // get_total
|
} // get_total
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -735,7 +733,6 @@ class Query
|
||||||
public function get_type()
|
public function get_type()
|
||||||
{
|
{
|
||||||
return $this->_state['type'];
|
return $this->_state['type'];
|
||||||
|
|
||||||
} // get_type
|
} // get_type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -768,7 +765,6 @@ class Query
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->resort_objects();
|
$this->resort_objects();
|
||||||
|
|
||||||
} // set_sort
|
} // set_sort
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -779,7 +775,6 @@ class Query
|
||||||
public function set_offset($offset)
|
public function set_offset($offset)
|
||||||
{
|
{
|
||||||
$this->_state['offset'] = abs($offset);
|
$this->_state['offset'] = abs($offset);
|
||||||
|
|
||||||
} // set_offset
|
} // set_offset
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -802,7 +797,6 @@ class Query
|
||||||
public function set_select($field)
|
public function set_select($field)
|
||||||
{
|
{
|
||||||
$this->_state['select'][] = $field;
|
$this->_state['select'][] = $field;
|
||||||
|
|
||||||
} // set_select
|
} // set_select
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -817,7 +811,6 @@ class Query
|
||||||
public function set_join($type, $table, $source, $dest, $priority)
|
public function set_join($type, $table, $source, $dest, $priority)
|
||||||
{
|
{
|
||||||
$this->_state['join'][$priority][$table] = strtoupper($type) . ' JOIN ' . $table . ' ON ' . $source . '=' . $dest;
|
$this->_state['join'][$priority][$table] = strtoupper($type) . ' JOIN ' . $table . ' ON ' . $source . '=' . $dest;
|
||||||
|
|
||||||
} // set_join
|
} // set_join
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -829,7 +822,6 @@ class Query
|
||||||
public function set_having($condition)
|
public function set_having($condition)
|
||||||
{
|
{
|
||||||
$this->_state['having'] = $condition;
|
$this->_state['having'] = $condition;
|
||||||
|
|
||||||
} // set_having
|
} // set_having
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -855,7 +847,6 @@ class Query
|
||||||
{
|
{
|
||||||
$value = make_bool($value);
|
$value = make_bool($value);
|
||||||
$this->_state['simple'] = $value;
|
$this->_state['simple'] = $value;
|
||||||
|
|
||||||
} // set_is_simple
|
} // set_is_simple
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -870,7 +861,6 @@ class Query
|
||||||
$value = make_bool($value);
|
$value = make_bool($value);
|
||||||
|
|
||||||
$this->_state['static'] = $value;
|
$this->_state['static'] = $value;
|
||||||
|
|
||||||
} // set_static_content
|
} // set_static_content
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -890,7 +880,6 @@ class Query
|
||||||
public function is_simple()
|
public function is_simple()
|
||||||
{
|
{
|
||||||
return $this->_state['simple'];
|
return $this->_state['simple'];
|
||||||
|
|
||||||
} // is_simple
|
} // is_simple
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -920,7 +909,6 @@ class Query
|
||||||
}
|
}
|
||||||
|
|
||||||
return $objects;
|
return $objects;
|
||||||
|
|
||||||
} // get_saved
|
} // get_saved
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -955,7 +943,6 @@ class Query
|
||||||
$this->save_objects($filtered);
|
$this->save_objects($filtered);
|
||||||
|
|
||||||
return $filtered;
|
return $filtered;
|
||||||
|
|
||||||
} // get_objects
|
} // get_objects
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -967,7 +954,9 @@ class Query
|
||||||
private function set_base_sql($force = false, $custom_base = '')
|
private function set_base_sql($force = false, $custom_base = '')
|
||||||
{
|
{
|
||||||
// Only allow it to be set once
|
// Only allow it to be set once
|
||||||
if (strlen($this->_state['base']) && !$force) { return true; }
|
if (strlen($this->_state['base']) && !$force) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Custom sql base
|
// Custom sql base
|
||||||
if ($force && !empty($custom_base)) {
|
if ($force && !empty($custom_base)) {
|
||||||
|
@ -1094,7 +1083,6 @@ class Query
|
||||||
{
|
{
|
||||||
$select_string = implode(", ", $this->_state['select']);
|
$select_string = implode(", ", $this->_state['select']);
|
||||||
return $select_string;
|
return $select_string;
|
||||||
|
|
||||||
} // get_select
|
} // get_select
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1107,7 +1095,6 @@ class Query
|
||||||
{
|
{
|
||||||
$sql = str_replace("%%SELECT%%", $this->get_select(), $this->_state['base']);
|
$sql = str_replace("%%SELECT%%", $this->get_select(), $this->_state['base']);
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
} // get_base_sql
|
} // get_base_sql
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1125,7 +1112,6 @@ class Query
|
||||||
|
|
||||||
foreach ($this->_state['filter']
|
foreach ($this->_state['filter']
|
||||||
as $key => $value) {
|
as $key => $value) {
|
||||||
|
|
||||||
$sql .= $this->sql_filter($key, $value);
|
$sql .= $this->sql_filter($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1149,7 +1135,6 @@ class Query
|
||||||
$sql = rtrim($sql,'AND ') . ' ';
|
$sql = rtrim($sql,'AND ') . ' ';
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
} // get_filter_sql
|
} // get_filter_sql
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1174,7 +1159,6 @@ class Query
|
||||||
$sql = rtrim($sql,',');
|
$sql = rtrim($sql,',');
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
} // get_sort_sql
|
} // get_sort_sql
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1184,12 +1168,13 @@ class Query
|
||||||
*/
|
*/
|
||||||
private function get_limit_sql()
|
private function get_limit_sql()
|
||||||
{
|
{
|
||||||
if (!$this->is_simple() || $this->get_start() < 0) { return ''; }
|
if (!$this->is_simple() || $this->get_start() < 0) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$sql = ' LIMIT ' . intval($this->get_start()) . ',' . intval($this->get_offset());
|
$sql = ' LIMIT ' . intval($this->get_start()) . ',' . intval($this->get_offset());
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
} // get_limit_sql
|
} // get_limit_sql
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1212,7 +1197,6 @@ class Query
|
||||||
} // end foreach of this level of joins
|
} // end foreach of this level of joins
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
} // get_join_sql
|
} // get_join_sql
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1225,7 +1209,6 @@ class Query
|
||||||
$sql = isset($this->_state['having']) ? $this->_state['having'] : '';
|
$sql = isset($this->_state['having']) ? $this->_state['having'] : '';
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
|
|
||||||
} // get_having_sql
|
} // get_having_sql
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1254,12 +1237,11 @@ class Query
|
||||||
$final_sql = $sql . $join_sql . $filter_sql . $having_sql;
|
$final_sql = $sql . $join_sql . $filter_sql . $having_sql;
|
||||||
|
|
||||||
if ( $this->get_type() == 'artist' && !$this->_state['custom'] ) {
|
if ( $this->get_type() == 'artist' && !$this->_state['custom'] ) {
|
||||||
$final_sql .= " GROUP BY `" . $this->get_type() . "`.`name` ";
|
$final_sql .= " GROUP BY `" . $this->get_type() . "`.`name` ";
|
||||||
}
|
}
|
||||||
$final_sql .= $order_sql . $limit_sql;
|
$final_sql .= $order_sql . $limit_sql;
|
||||||
|
|
||||||
return $final_sql;
|
return $final_sql;
|
||||||
|
|
||||||
} // get_sql
|
} // get_sql
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1293,7 +1275,6 @@ class Query
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // post_process
|
} // post_process
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1328,10 +1309,14 @@ class Query
|
||||||
$filter_sql = " `song`.`title` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `song`.`title` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `song`.`title` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `song`.`title` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `song`.`title` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `song`.`title` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
$filter_sql = " `song`.`title` LIKE '" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `song`.`title` LIKE '" . Dba::escape($value) . "%' AND ";
|
||||||
|
@ -1392,10 +1377,14 @@ class Query
|
||||||
$filter_sql = " `album`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `album`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `album`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `album`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `album`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `album`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
$this->set_join('left', '`song`', '`album`.`id`', '`song`.`album`', 100);
|
$this->set_join('left', '`song`', '`album`.`id`', '`song`.`album`', 100);
|
||||||
|
@ -1465,10 +1454,14 @@ class Query
|
||||||
$filter_sql = " `artist`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `artist`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `artist`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `artist`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `artist`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `artist`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
$this->set_join('left', '`song`', '`artist`.`id`', '`song`.`artist`', 100);
|
$this->set_join('left', '`song`', '`artist`.`id`', '`song`.`artist`', 100);
|
||||||
|
@ -1509,10 +1502,14 @@ class Query
|
||||||
$filter_sql = " `live_stream`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `live_stream`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `live_stream`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `live_stream`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `live_stream`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `live_stream`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
$filter_sql = " `live_stream`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `live_stream`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
|
||||||
|
@ -1532,10 +1529,14 @@ class Query
|
||||||
$filter_sql = " `playlist`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `playlist`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `playlist`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `playlist`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `playlist`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `playlist`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
$filter_sql = " `playlist`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `playlist`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
|
||||||
|
@ -1555,10 +1556,14 @@ class Query
|
||||||
$filter_sql = " `search`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `search`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `search`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `search`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `search`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `search`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
$filter_sql = " `search`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `search`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
|
||||||
|
@ -1575,10 +1580,14 @@ class Query
|
||||||
$filter_sql = " `tag`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `tag`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `tag`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `tag`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `tag`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `tag`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'exact_match':
|
case 'exact_match':
|
||||||
$filter_sql = " `tag`.`name` = '" . Dba::escape($value) . "' AND ";
|
$filter_sql = " `tag`.`name` = '" . Dba::escape($value) . "' AND ";
|
||||||
|
@ -1606,10 +1615,14 @@ class Query
|
||||||
$filter_sql = " `video`.`title` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `video`.`title` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `video`.`title` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `video`.`title` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `video`.`title` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `video`.`title` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
$filter_sql = " `video`.`title` LIKE '" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `video`.`title` LIKE '" . Dba::escape($value) . "%' AND ";
|
||||||
|
@ -1625,10 +1638,14 @@ class Query
|
||||||
$filter_sql = " `license`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `license`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `license`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `license`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `license`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `license`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'exact_match':
|
case 'exact_match':
|
||||||
$filter_sql = " `license`.`name` = '" . Dba::escape($value) . "' AND ";
|
$filter_sql = " `license`.`name` = '" . Dba::escape($value) . "' AND ";
|
||||||
|
@ -1644,10 +1661,14 @@ class Query
|
||||||
$filter_sql = " `tvshow`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `tvshow`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `tvshow`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `tvshow`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `tvshow`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `tvshow`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'exact_match':
|
case 'exact_match':
|
||||||
$filter_sql = " `tvshow`.`name` = '" . Dba::escape($value) . "' AND ";
|
$filter_sql = " `tvshow`.`name` = '" . Dba::escape($value) . "' AND ";
|
||||||
|
@ -1695,10 +1716,14 @@ class Query
|
||||||
$filter_sql = " `label`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `label`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `label`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `label`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `label`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `label`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
$filter_sql = " `label`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `label`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
|
||||||
|
@ -1714,10 +1739,14 @@ class Query
|
||||||
$filter_sql = " `user_pvmsg`.`subject` LIKE '%" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `user_pvmsg`.`subject` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||||
break;
|
break;
|
||||||
case 'regex_match':
|
case 'regex_match':
|
||||||
if (!empty($value)) $filter_sql = " `user_pvmsg`.`subject` REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `user_pvmsg`.`subject` REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'regex_not_match':
|
case 'regex_not_match':
|
||||||
if (!empty($value)) $filter_sql = " `user_pvmsg`.`subject` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
if (!empty($value)) {
|
||||||
|
$filter_sql = " `user_pvmsg`.`subject` NOT REGEXP '" . Dba::escape($value) . "' AND ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'starts_with':
|
case 'starts_with':
|
||||||
$filter_sql = " `user_pvmsg`.`subject` LIKE '" . Dba::escape($value) . "%' AND ";
|
$filter_sql = " `user_pvmsg`.`subject` LIKE '" . Dba::escape($value) . "%' AND ";
|
||||||
|
@ -1749,7 +1778,6 @@ class Query
|
||||||
} // end switch on type
|
} // end switch on type
|
||||||
|
|
||||||
return $filter_sql;
|
return $filter_sql;
|
||||||
|
|
||||||
} // sql_filter
|
} // sql_filter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1766,7 +1794,6 @@ class Query
|
||||||
private function logic_filter($object_id)
|
private function logic_filter($object_id)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // logic_filter
|
} // logic_filter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1781,7 +1808,9 @@ class Query
|
||||||
*/
|
*/
|
||||||
private function sql_sort($field, $order)
|
private function sql_sort($field, $order)
|
||||||
{
|
{
|
||||||
if ($order != 'DESC') { $order == 'ASC'; }
|
if ($order != 'DESC') {
|
||||||
|
$order == 'ASC';
|
||||||
|
}
|
||||||
|
|
||||||
// Depending on the type of browsing we are doing we can apply
|
// Depending on the type of browsing we are doing we can apply
|
||||||
// different filters that apply to different fields
|
// different filters that apply to different fields
|
||||||
|
@ -2123,10 +2152,11 @@ class Query
|
||||||
break;
|
break;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
if (isset($sql) && !empty($sql)) { return "$sql $order,"; }
|
if (isset($sql) && !empty($sql)) {
|
||||||
|
return "$sql $order,";
|
||||||
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
} // sql_sort
|
} // sql_sort
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2223,7 +2253,6 @@ class Query
|
||||||
$this->save_objects($results);
|
$this->save_objects($results);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // resort_objects
|
} // resort_objects
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2269,7 +2298,6 @@ class Query
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // save_objects
|
} // save_objects
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2280,7 +2308,6 @@ class Query
|
||||||
public function get_state()
|
public function get_state()
|
||||||
{
|
{
|
||||||
return $this->_state;
|
return $this->_state;
|
||||||
|
|
||||||
} // get_state
|
} // get_state
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2304,5 +2331,5 @@ class Query
|
||||||
{
|
{
|
||||||
$this->_state['ak'] = $ak;
|
$this->_state['ak'] = $ak;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // query
|
} // query
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ class Random
|
||||||
$results = Dba::fetch_assoc($db_results);
|
$results = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $results['id'];
|
return $results['id'];
|
||||||
|
|
||||||
} // artist
|
} // artist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +64,6 @@ class Random
|
||||||
$results = Dba::fetch_assoc($db_results);
|
$results = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $results['id'];
|
return $results['id'];
|
||||||
|
|
||||||
} // playlist
|
} // playlist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +81,6 @@ class Random
|
||||||
$song_id = array_pop($song_ids);
|
$song_id = array_pop($song_ids);
|
||||||
|
|
||||||
return $song_id;
|
return $song_id;
|
||||||
|
|
||||||
} // get_single_song
|
} // get_single_song
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +109,6 @@ class Random
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_default
|
} // get_default
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,7 +142,6 @@ class Random
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_album
|
} // get_album
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,7 +174,6 @@ class Random
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_artist
|
} // get_artist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,7 +190,11 @@ class Random
|
||||||
|
|
||||||
/* If they've passed -1 as limit then get everything */
|
/* If they've passed -1 as limit then get everything */
|
||||||
$limit_sql = "";
|
$limit_sql = "";
|
||||||
if ($data['random'] == "-1") { unset($data['random']); } else { $limit_sql = "LIMIT " . Dba::escape($limit); }
|
if ($data['random'] == "-1") {
|
||||||
|
unset($data['random']);
|
||||||
|
} else {
|
||||||
|
$limit_sql = "LIMIT " . Dba::escape($limit);
|
||||||
|
}
|
||||||
|
|
||||||
$search_data = Search::clean_request($data);
|
$search_data = Search::clean_request($data);
|
||||||
|
|
||||||
|
@ -304,7 +302,8 @@ class Random
|
||||||
|
|
||||||
// If we are within 4mb of target then jump ship
|
// If we are within 4mb of target then jump ship
|
||||||
if (($data['size_limit'] - floor($size_total)) < 4) {
|
if (($data['size_limit'] - floor($size_total)) < 4) {
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
} // if size_limit
|
} // if size_limit
|
||||||
|
|
||||||
// If length really does matter
|
// If length really does matter
|
||||||
|
@ -313,7 +312,8 @@ class Random
|
||||||
$new_time = floor($row['time'] / 60);
|
$new_time = floor($row['time'] / 60);
|
||||||
|
|
||||||
if ($fuzzy_time > 100) {
|
if ($fuzzy_time > 100) {
|
||||||
break;;
|
break;
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the new one would go over skip!
|
// If the new one would go over skip!
|
||||||
|
@ -334,7 +334,6 @@ class Random
|
||||||
if (!$data['size_limit'] && !$data['length']) {
|
if (!$data['size_limit'] && !$data['length']) {
|
||||||
$results[] = $row['id'];
|
$results[] = $row['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end while results
|
} // end while results
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
@ -358,5 +357,5 @@ class Random
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} // advanced
|
} // advanced
|
||||||
|
|
||||||
} //end of random class
|
} //end of random class
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ class Rating extends database_object
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +75,9 @@ class Rating extends database_object
|
||||||
*/
|
*/
|
||||||
public static function build_cache($type, $ids)
|
public static function build_cache($type, $ids)
|
||||||
{
|
{
|
||||||
if (!is_array($ids) OR !count($ids)) { return false; }
|
if (!is_array($ids) OR !count($ids)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$ratings = array();
|
$ratings = array();
|
||||||
$user_ratings = array();
|
$user_ratings = array();
|
||||||
|
@ -119,7 +120,6 @@ class Rating extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // build_cache
|
} // build_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,29 +129,28 @@ class Rating extends database_object
|
||||||
*/
|
*/
|
||||||
public function get_user_rating($user_id = null)
|
public function get_user_rating($user_id = null)
|
||||||
{
|
{
|
||||||
if (is_null($user_id)) {
|
if (is_null($user_id)) {
|
||||||
$user_id = $GLOBALS['user']->id;
|
$user_id = $GLOBALS['user']->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = 'rating_' . $this->type . '_user' . $user_id;
|
$key = 'rating_' . $this->type . '_user' . $user_id;
|
||||||
if (parent::is_cached($key, $this->id)) {
|
if (parent::is_cached($key, $this->id)) {
|
||||||
return parent::get_from_cache($key, $this->id);
|
return parent::get_from_cache($key, $this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT `rating` FROM `rating` WHERE `user` = ? ".
|
$sql = "SELECT `rating` FROM `rating` WHERE `user` = ? ".
|
||||||
"AND `object_id` = ? AND `object_type` = ?";
|
"AND `object_id` = ? AND `object_type` = ?";
|
||||||
$db_results = Dba::read($sql, array($user_id, $this->id, $this->type));
|
$db_results = Dba::read($sql, array($user_id, $this->id, $this->type));
|
||||||
|
|
||||||
$rating = 0;
|
$rating = 0;
|
||||||
|
|
||||||
if ($results = Dba::fetch_assoc($db_results)) {
|
if ($results = Dba::fetch_assoc($db_results)) {
|
||||||
$rating = $results['rating'];
|
$rating = $results['rating'];
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::add_to_cache($key, $this->id, $rating);
|
parent::add_to_cache($key, $this->id, $rating);
|
||||||
return $rating;
|
return $rating;
|
||||||
|
} // get_user_rating
|
||||||
} // get_user_rating
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_average_rating
|
* get_average_rating
|
||||||
|
@ -172,7 +171,6 @@ class Rating extends database_object
|
||||||
|
|
||||||
parent::add_to_cache('rating_' . $this->type . '_all', $this->id, $results['rating']);
|
parent::add_to_cache('rating_' . $this->type . '_all', $this->id, $results['rating']);
|
||||||
return $results['rating'];
|
return $results['rating'];
|
||||||
|
|
||||||
} // get_average_rating
|
} // get_average_rating
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,7 +217,6 @@ class Rating extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,7 +258,6 @@ class Rating extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // set_rating
|
} // set_rating
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,7 +268,9 @@ class Rating extends database_object
|
||||||
public static function show($object_id, $type, $static=false)
|
public static function show($object_id, $type, $static=false)
|
||||||
{
|
{
|
||||||
// If ratings aren't enabled don't do anything
|
// If ratings aren't enabled don't do anything
|
||||||
if (!AmpConfig::get('ratings')) { return false; }
|
if (!AmpConfig::get('ratings')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$rating = new Rating($object_id, $type);
|
$rating = new Rating($object_id, $type);
|
||||||
|
|
||||||
|
@ -281,7 +279,6 @@ class Rating extends database_object
|
||||||
} else {
|
} else {
|
||||||
require AmpConfig::get('prefix') . '/templates/show_object_rating.inc.php';
|
require AmpConfig::get('prefix') . '/templates/show_object_rating.inc.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
} // show
|
} // show
|
||||||
|
|
||||||
} //end rating class
|
} //end rating class
|
||||||
|
|
||||||
|
|
|
@ -358,5 +358,5 @@ class Recommendation
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
} // get_artist_info
|
} // get_artist_info
|
||||||
|
|
||||||
} // end of recommendation class
|
} // end of recommendation class
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ class Registration
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Rien a faire
|
// Rien a faire
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +88,6 @@ Website: %s
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // send_confirmation
|
} // send_confirmation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,18 +119,21 @@ Website: %s
|
||||||
{
|
{
|
||||||
$filename = AmpConfig::get('prefix') . '/config/registration_agreement.php';
|
$filename = AmpConfig::get('prefix') . '/config/registration_agreement.php';
|
||||||
|
|
||||||
if (!file_exists($filename)) { return false; }
|
if (!file_exists($filename)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for existance */
|
/* Check for existance */
|
||||||
$fp = fopen($filename,'r');
|
$fp = fopen($filename,'r');
|
||||||
|
|
||||||
if (!$fp) { return false; }
|
if (!$fp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$data = fread($fp,filesize($filename));
|
$data = fread($fp,filesize($filename));
|
||||||
|
|
||||||
/* Scrub and show */
|
/* Scrub and show */
|
||||||
echo $data;
|
echo $data;
|
||||||
|
|
||||||
} // show_agreement
|
} // show_agreement
|
||||||
|
|
||||||
} // end registration class
|
} // end registration class
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,9 @@ class scrobbler
|
||||||
$this->submit_port = $port;
|
$this->submit_port = $port;
|
||||||
$this->submit_url = $url;
|
$this->submit_url = $url;
|
||||||
$this->queued_tracks = array();
|
$this->queued_tracks = array();
|
||||||
if ($scrobble_host) { $this->scrobble_host = $scrobble_host; }
|
if ($scrobble_host) {
|
||||||
|
$this->scrobble_host = $scrobble_host;
|
||||||
|
}
|
||||||
} // scrobbler
|
} // scrobbler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +58,6 @@ class scrobbler
|
||||||
public function get_error_msg()
|
public function get_error_msg()
|
||||||
{
|
{
|
||||||
return $this->error_msg;
|
return $this->error_msg;
|
||||||
|
|
||||||
} // get_error_msg
|
} // get_error_msg
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +66,6 @@ class scrobbler
|
||||||
public function get_queue_count()
|
public function get_queue_count()
|
||||||
{
|
{
|
||||||
return count($this->queued_tracks);
|
return count($this->queued_tracks);
|
||||||
|
|
||||||
} // get_queue_count
|
} // get_queue_count
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +140,6 @@ class scrobbler
|
||||||
// Remove any extra junk around the challenge
|
// Remove any extra junk around the challenge
|
||||||
$data['challenge'] = trim($response[1]);
|
$data['challenge'] = trim($response[1]);
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // handshake
|
} // handshake
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,7 +165,6 @@ class scrobbler
|
||||||
|
|
||||||
$this->queued_tracks[$timestamp] = $newtrack;
|
$this->queued_tracks[$timestamp] = $newtrack;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // queue_track
|
} // queue_track
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,7 +261,6 @@ class scrobbler
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // submit_tracks
|
} // submit_tracks
|
||||||
|
|
||||||
} // end audioscrobbler class
|
} // end audioscrobbler class
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ class Search extends playlist_object
|
||||||
'sql' => '<=>'
|
'sql' => '<=>'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->basetypes['boolean_numeric'][] = array(
|
$this->basetypes['boolean_numeric'][] = array(
|
||||||
'name' => 'ne',
|
'name' => 'ne',
|
||||||
'description' => T_('is not'),
|
'description' => T_('is not'),
|
||||||
'sql' => '<>'
|
'sql' => '<>'
|
||||||
|
@ -382,7 +382,7 @@ class Search extends playlist_object
|
||||||
|
|
||||||
$playlists = array();
|
$playlists = array();
|
||||||
foreach (Search::get_searches() as $playlistid) {
|
foreach (Search::get_searches() as $playlistid) {
|
||||||
// Slightly different from the above so we don't instigate
|
// Slightly different from the above so we don't instigate
|
||||||
// a vicious loop.
|
// a vicious loop.
|
||||||
$playlists[$playlistid] = Search::get_name_byid($playlistid);
|
$playlists[$playlistid] = Search::get_name_byid($playlistid);
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,6 @@ class Search extends playlist_object
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
} // end switch on searchtype
|
} // end switch on searchtype
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -607,7 +606,7 @@ class Search extends playlist_object
|
||||||
$db_results = Dba::read($sql);
|
$db_results = Dba::read($sql);
|
||||||
$r = Dba::fetch_assoc($db_results);
|
$r = Dba::fetch_assoc($db_results);
|
||||||
return $r['name'];
|
return $r['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_searches
|
* get_searches
|
||||||
|
@ -649,7 +648,9 @@ class Search extends playlist_object
|
||||||
$limit_sql = "";
|
$limit_sql = "";
|
||||||
if ($limit > 0) {
|
if ($limit > 0) {
|
||||||
$limit_sql = ' LIMIT ';
|
$limit_sql = ' LIMIT ';
|
||||||
if ($offset) $limit_sql .= $offset . ",";
|
if ($offset) {
|
||||||
|
$limit_sql .= $offset . ",";
|
||||||
|
}
|
||||||
$limit_sql .= $limit;
|
$limit_sql .= $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,9 @@ class Session
|
||||||
*/
|
*/
|
||||||
public static function destroy($key)
|
public static function destroy($key)
|
||||||
{
|
{
|
||||||
if (!strlen($key)) { return false; }
|
if (!strlen($key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove anything and EVERYTHING
|
// Remove anything and EVERYTHING
|
||||||
$sql = 'DELETE FROM `session` WHERE `id` = ?';
|
$sql = 'DELETE FROM `session` WHERE `id` = ?';
|
||||||
|
@ -231,7 +233,9 @@ class Session
|
||||||
$geoname = $data['geo_name'];
|
$geoname = $data['geo_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strlen($value)) { $value = ' '; }
|
if (!strlen($value)) {
|
||||||
|
$value = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
/* Insert the row */
|
/* Insert the row */
|
||||||
$sql = 'INSERT INTO `session` (`id`,`username`,`ip`,`type`,`agent`,`value`,`expire`,`geo_latitude`,`geo_longitude`, `geo_name`) ' .
|
$sql = 'INSERT INTO `session` (`id`,`username`,`ip`,`type`,`agent`,`value`,`expire`,`geo_latitude`,`geo_longitude`, `geo_name`) ' .
|
||||||
|
@ -259,7 +263,9 @@ class Session
|
||||||
$session_name = AmpConfig::get('session_name');
|
$session_name = AmpConfig::get('session_name');
|
||||||
|
|
||||||
// No cookie no go!
|
// No cookie no go!
|
||||||
if (!isset($_COOKIE[$session_name])) { return false; }
|
if (!isset($_COOKIE[$session_name])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Set up the cookie params before we start the session.
|
// Set up the cookie params before we start the session.
|
||||||
// This is vital
|
// This is vital
|
||||||
|
@ -541,5 +547,4 @@ class Session
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,9 @@ class Share extends database_object
|
||||||
*/
|
*/
|
||||||
public function __construct($id=0)
|
public function __construct($id=0)
|
||||||
{
|
{
|
||||||
if (!$id) { return true; }
|
if (!$id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the information from the db */
|
/* Get the information from the db */
|
||||||
$info = $this->get_info($id);
|
$info = $this->get_info($id);
|
||||||
|
@ -115,9 +117,13 @@ class Share extends database_object
|
||||||
public static function create_share($object_type, $object_id, $allow_stream=true, $allow_download=true, $expire=0, $secret='', $max_counter=0, $description='')
|
public static function create_share($object_type, $object_id, $allow_stream=true, $allow_download=true, $expire=0, $secret='', $max_counter=0, $description='')
|
||||||
{
|
{
|
||||||
$object_type = self::format_type($object_type);
|
$object_type = self::format_type($object_type);
|
||||||
if (empty($object_type)) return '';
|
if (empty($object_type)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
if (!$allow_stream && !$allow_download) return '';
|
if (!$allow_stream && !$allow_download) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO `share` (`user`, `object_type`, `object_id`, `creation_date`, `allow_stream`, `allow_download`, `expire_days`, `secret`, `counter`, `max_counter`, `description`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
$sql = "INSERT INTO `share` (`user`, `object_type`, `object_id`, `creation_date`, `allow_stream`, `allow_download`, `expire_days`, `secret`, `counter`, `max_counter`, `description`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
$params = array($GLOBALS['user']->id, $object_type, $object_id, time(), $allow_stream ?: 0, $allow_download ?: 0, $expire, $secret, 0, $max_counter, $description);
|
$params = array($GLOBALS['user']->id, $object_type, $object_id, time(), $allow_stream ?: 0, $allow_download ?: 0, $expire, $secret, 0, $max_counter, $description);
|
||||||
|
@ -321,7 +327,9 @@ class Share extends database_object
|
||||||
$songs = $object->get_songs();
|
$songs = $object->get_songs();
|
||||||
foreach ($songs as $id) {
|
foreach ($songs as $id) {
|
||||||
$is_shared = ($media_id == $id);
|
$is_shared = ($media_id == $id);
|
||||||
if ($is_shared) { break; }
|
if ($is_shared) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -375,5 +383,5 @@ class Share extends database_object
|
||||||
echo "</li>";
|
echo "</li>";
|
||||||
echo "</ul>";
|
echo "</ul>";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of recommendation class
|
} // end of recommendation class
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ class Shoutbox
|
||||||
$this->_get_info($shout_id);
|
$this->_get_info($shout_id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +64,6 @@ class Shoutbox
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // _get_info
|
} // _get_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +120,6 @@ class Shoutbox
|
||||||
}
|
}
|
||||||
|
|
||||||
return $shouts;
|
return $shouts;
|
||||||
|
|
||||||
} // get_top
|
} // get_top
|
||||||
|
|
||||||
public static function get_shouts_since($time)
|
public static function get_shouts_since($time)
|
||||||
|
@ -136,7 +133,6 @@ class Shoutbox
|
||||||
}
|
}
|
||||||
|
|
||||||
return $shouts;
|
return $shouts;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,7 +151,6 @@ class Shoutbox
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_sticky
|
} // get_sticky
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,13 +159,13 @@ class Shoutbox
|
||||||
*/
|
*/
|
||||||
public static function get_object($type,$object_id)
|
public static function get_object($type,$object_id)
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$object = new $type($object_id);
|
$object = new $type($object_id);
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
|
|
||||||
} // get_object
|
} // get_object
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,7 +181,6 @@ class Shoutbox
|
||||||
}
|
}
|
||||||
|
|
||||||
return $image_string;
|
return $image_string;
|
||||||
|
|
||||||
} // get_image
|
} // get_image
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,8 +189,9 @@ class Shoutbox
|
||||||
*/
|
*/
|
||||||
public static function create(array $data)
|
public static function create(array $data)
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($data['object_type']))
|
if (!Core::is_library_item($data['object_type'])) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sticky = isset($data['sticky']) ? 1 : 0;
|
$sticky = isset($data['sticky']) ? 1 : 0;
|
||||||
$user = intval($data['user'] ?: $GLOBALS['user']->id);
|
$user = intval($data['user'] ?: $GLOBALS['user']->id);
|
||||||
|
@ -237,7 +232,6 @@ class Shoutbox
|
||||||
}
|
}
|
||||||
|
|
||||||
return $insert_id;
|
return $insert_id;
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -250,7 +244,6 @@ class Shoutbox
|
||||||
Dba::write($sql, array($data['comment'], make_bool($data['sticky']), $this->id));
|
Dba::write($sql, array($data['comment'], make_bool($data['sticky']), $this->id));
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,7 +257,6 @@ class Shoutbox
|
||||||
$this->f_date = date("m\/d\/Y - H:i", $this->date);
|
$this->f_date = date("m\/d\/Y - H:i", $this->date);
|
||||||
$this->f_text = preg_replace('/(\r\n|\n|\r)/', '<br />', $this->text);
|
$this->f_text = preg_replace('/(\r\n|\n|\r)/', '<br />', $this->text);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} //format
|
} //format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +270,6 @@ class Shoutbox
|
||||||
$shout_id = Dba::escape($shout_id);
|
$shout_id = Dba::escape($shout_id);
|
||||||
$sql = "DELETE FROM `user_shout` WHERE `id`='$shout_id'";
|
$sql = "DELETE FROM `user_shout` WHERE `id`='$shout_id'";
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
} // delete
|
} // delete
|
||||||
|
|
||||||
public function get_display($details = true, $jsbuttons = false)
|
public function get_display($details = true, $jsbuttons = false)
|
||||||
|
@ -343,5 +334,5 @@ class Shoutbox
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Shoutbox class
|
} // Shoutbox class
|
||||||
|
|
||||||
|
|
|
@ -58,5 +58,5 @@ class Slideshow
|
||||||
|
|
||||||
return $images;
|
return $images;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of Slideshow class
|
} // end of Slideshow class
|
||||||
|
|
||||||
|
|
|
@ -293,7 +293,9 @@ class Song extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
public function __construct($id = null, $limit_threshold = '')
|
public function __construct($id = null, $limit_threshold = '')
|
||||||
{
|
{
|
||||||
if (!$id) { return false; }
|
if (!$id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->id = intval($id);
|
$this->id = intval($id);
|
||||||
|
|
||||||
|
@ -310,7 +312,6 @@ class Song extends database_object implements media, library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -444,12 +445,16 @@ class Song extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
public static function build_cache($song_ids, $limit_threshold = '')
|
public static function build_cache($song_ids, $limit_threshold = '')
|
||||||
{
|
{
|
||||||
if (!is_array($song_ids) || !count($song_ids)) { return false; }
|
if (!is_array($song_ids) || !count($song_ids)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$idlist = '(' . implode(',', $song_ids) . ')';
|
$idlist = '(' . implode(',', $song_ids) . ')';
|
||||||
|
|
||||||
// Callers might have passed array(false) because they are dumb
|
// Callers might have passed array(false) because they are dumb
|
||||||
if ($idlist == '()') { return false; }
|
if ($idlist == '()') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Song data cache
|
// Song data cache
|
||||||
$sql = 'SELECT `song`.`id`, `file`, `catalog`, `album`, ' .
|
$sql = 'SELECT `song`.`id`, `file`, `catalog`, `album`, ' .
|
||||||
|
@ -508,7 +513,6 @@ class Song extends database_object implements media, library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // build_cache
|
} // build_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -567,7 +571,6 @@ class Song extends database_object implements media, library_item
|
||||||
parent::add_to_cache('song_data',$id,$results);
|
parent::add_to_cache('song_data',$id,$results);
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // _get_ext_info
|
} // _get_ext_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -583,7 +586,6 @@ class Song extends database_object implements media, library_item
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
} // fill_ext_info
|
} // fill_ext_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -644,7 +646,9 @@ class Song extends database_object implements media, library_item
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$sql = "SELECT `id` FROM `song` WHERE `enabled`='0'";
|
$sql = "SELECT `id` FROM `song` WHERE `enabled`='0'";
|
||||||
if ($count) { $sql .= " LIMIT $count"; }
|
if ($count) {
|
||||||
|
$sql .= " LIMIT $count";
|
||||||
|
}
|
||||||
$db_results = Dba::read($sql);
|
$db_results = Dba::read($sql);
|
||||||
|
|
||||||
while ($r = Dba::fetch_assoc($db_results)) {
|
while ($r = Dba::fetch_assoc($db_results)) {
|
||||||
|
@ -664,7 +668,7 @@ class Song extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
public static function find_duplicates($search_type)
|
public static function find_duplicates($search_type)
|
||||||
{
|
{
|
||||||
$where_sql = $_REQUEST['search_disabled'] ? '' : "WHERE `enabled` != '0'";
|
$where_sql = $_REQUEST['search_disabled'] ? '' : "WHERE `enabled` != '0'";
|
||||||
$sql = 'SELECT `id`, `artist`, `album`, `title`, ' .
|
$sql = 'SELECT `id`, `artist`, `album`, `title`, ' .
|
||||||
'COUNT(`title`) FROM `song` ' . $where_sql .
|
'COUNT(`title`) FROM `song` ' . $where_sql .
|
||||||
' GROUP BY `title`';
|
' GROUP BY `title`';
|
||||||
|
@ -729,12 +733,15 @@ class Song extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
public function get_album_name($album_id=0)
|
public function get_album_name($album_id=0)
|
||||||
{
|
{
|
||||||
if (!$album_id) { $album_id = $this->album; }
|
if (!$album_id) {
|
||||||
$album = new Album($album_id);
|
$album_id = $this->album;
|
||||||
if ($album->prefix)
|
}
|
||||||
return $album->prefix . " " . $album->name;
|
$album = new Album($album_id);
|
||||||
else
|
if ($album->prefix) {
|
||||||
return $album->name;
|
return $album->prefix . " " . $album->name;
|
||||||
|
} else {
|
||||||
|
return $album->name;
|
||||||
|
}
|
||||||
} // get_album_name
|
} // get_album_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -745,13 +752,15 @@ class Song extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
public function get_artist_name($artist_id=0)
|
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);
|
$artist = new Artist($artist_id);
|
||||||
if ($artist->prefix)
|
if ($artist->prefix) {
|
||||||
return $artist->prefix . " " . $artist->name;
|
return $artist->prefix . " " . $artist->name;
|
||||||
else
|
} else {
|
||||||
return $artist->name;
|
return $artist->name;
|
||||||
|
}
|
||||||
} // get_artist_name
|
} // get_artist_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -762,13 +771,15 @@ class Song extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
public function get_album_artist_name($album_artist_id=0)
|
public function get_album_artist_name($album_artist_id=0)
|
||||||
{
|
{
|
||||||
if (!$album_artist_id) { $album_artist_id = $this->albumartist; }
|
if (!$album_artist_id) {
|
||||||
|
$album_artist_id = $this->albumartist;
|
||||||
|
}
|
||||||
$album_artist = new Artist($album_artist_id);
|
$album_artist = new Artist($album_artist_id);
|
||||||
if ($album_artist->prefix)
|
if ($album_artist->prefix) {
|
||||||
return $album_artist->prefix . " " . $album_artist->name;
|
return $album_artist->prefix . " " . $album_artist->name;
|
||||||
else
|
} else {
|
||||||
return $album_artist->name;
|
return $album_artist->name;
|
||||||
|
}
|
||||||
} // get_album_artist_name
|
} // get_album_artist_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -794,7 +805,6 @@ class Song extends database_object implements media, library_item
|
||||||
self::update_played(true, $this->id);
|
self::update_played(true, $this->id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // set_played
|
} // set_played
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -821,7 +831,9 @@ class Song extends database_object implements media, library_item
|
||||||
|
|
||||||
// Foreach them
|
// Foreach them
|
||||||
foreach ($fields as $key=>$value) {
|
foreach ($fields as $key=>$value) {
|
||||||
if (in_array($key,$skip_array)) { continue; }
|
if (in_array($key,$skip_array)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$songData = is_array($song->$key) ? implode(" ", $song->$key) : $song->$key;
|
$songData = is_array($song->$key) ? implode(" ", $song->$key) : $song->$key;
|
||||||
$newSongData = is_array($new_song->$key) ? implode(" ", $new_song->$key) : $new_song->$key;
|
$newSongData = is_array($new_song->$key) ? implode(" ", $new_song->$key) : $new_song->$key;
|
||||||
|
@ -838,7 +850,6 @@ class Song extends database_object implements media, library_item
|
||||||
$array['element'][$key] = 'OLD:' . $songData . ' --> ' . $newSongData;
|
$array['element'][$key] = 'OLD:' . $songData . ' --> ' . $newSongData;
|
||||||
}
|
}
|
||||||
} // end else
|
} // end else
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
if ($array['change']) {
|
if ($array['change']) {
|
||||||
|
@ -846,7 +857,6 @@ class Song extends database_object implements media, library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $array;
|
return $array;
|
||||||
|
|
||||||
} // compare_song_information
|
} // compare_song_information
|
||||||
|
|
||||||
|
|
||||||
|
@ -964,7 +974,6 @@ class Song extends database_object implements media, library_item
|
||||||
"WHERE `song_id` = ?";
|
"WHERE `song_id` = ?";
|
||||||
Dba::write($sql, array($new_song->lyrics, $new_song->language, $new_song->comment, $new_song->replaygain_track_gain,
|
Dba::write($sql, array($new_song->lyrics, $new_song->language, $new_song->comment, $new_song->replaygain_track_gain,
|
||||||
$new_song->replaygain_track_peak, $new_song->replaygain_album_gain, $new_song->replaygain_album_peak, $song_id));
|
$new_song->replaygain_track_peak, $new_song->replaygain_album_gain, $new_song->replaygain_album_peak, $song_id));
|
||||||
|
|
||||||
} // update_song
|
} // update_song
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -976,7 +985,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_year($new_year, $song_id)
|
public static function update_year($new_year, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('year', $new_year, $song_id, 50, true);
|
self::_update_item('year', $new_year, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_year
|
} // update_year
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -988,7 +996,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_label($new_value, $song_id)
|
public static function update_label($new_value, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_ext_item('label', $new_value, $song_id, 50, true);
|
self::_update_ext_item('label', $new_value, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_label
|
} // update_label
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1000,7 +1007,6 @@ class Song extends database_object implements media, library_item
|
||||||
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, true);
|
self::_update_ext_item('language', $new_lang, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_language
|
} // update_language
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1012,7 +1018,6 @@ class Song extends database_object implements media, library_item
|
||||||
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, true);
|
self::_update_ext_item('comment', $new_comment, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_comment
|
} // update_comment
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1024,7 +1029,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_lyrics($new_lyrics, $song_id)
|
public static function update_lyrics($new_lyrics, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_ext_item('lyrics', $new_lyrics, $song_id, 50, true);
|
self::_update_ext_item('lyrics', $new_lyrics, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_lyrics
|
} // update_lyrics
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1036,7 +1040,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_title($new_title,$song_id)
|
public static function update_title($new_title,$song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('title', $new_title, $song_id, 50, true);
|
self::_update_item('title', $new_title, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_title
|
} // update_title
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1048,7 +1051,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_composer($new_value, $song_id)
|
public static function update_composer($new_value, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('composer', $new_value, $song_id, 50, true);
|
self::_update_item('composer', $new_value, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_composer
|
} // update_composer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1060,7 +1062,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_publisher($new_value, $song_id)
|
public static function update_publisher($new_value, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('publisher', $new_value, $song_id, 50, true);
|
self::_update_item('publisher', $new_value, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_publisher
|
} // update_publisher
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1072,7 +1073,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_bitrate($new_bitrate, $song_id)
|
public static function update_bitrate($new_bitrate, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('bitrate', $new_bitrate, $song_id, 50, true);
|
self::_update_item('bitrate', $new_bitrate, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_bitrate
|
} // update_bitrate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1084,7 +1084,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_rate($new_rate, $song_id)
|
public static function update_rate($new_rate, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('rate', $new_rate, $song_id, 50, true);
|
self::_update_item('rate', $new_rate, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_rate
|
} // update_rate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1096,7 +1095,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_mode($new_mode, $song_id)
|
public static function update_mode($new_mode, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('mode', $new_mode, $song_id, 50, true);
|
self::_update_item('mode', $new_mode, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_mode
|
} // update_mode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1108,7 +1106,6 @@ class Song extends database_object implements media, library_item
|
||||||
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);
|
self::_update_item('size', $new_size, $song_id, 50);
|
||||||
|
|
||||||
} // update_size
|
} // update_size
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1120,7 +1117,6 @@ class Song extends database_object implements media, library_item
|
||||||
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, true);
|
self::_update_item('time', $new_time, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_time
|
} // update_time
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1132,7 +1128,6 @@ class Song extends database_object implements media, library_item
|
||||||
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, true);
|
self::_update_item('track', $new_track, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_track
|
} // update_track
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1144,7 +1139,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_mbid($new_mbid, $song_id)
|
public static function update_mbid($new_mbid, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('mbid', $new_mbid, $song_id, 50);
|
self::_update_item('mbid', $new_mbid, $song_id, 50);
|
||||||
|
|
||||||
} // update_mbid
|
} // update_mbid
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1156,7 +1150,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_license($new_license, $song_id)
|
public static function update_license($new_license, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('license', $new_license, $song_id, 50, true);
|
self::_update_item('license', $new_license, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_license
|
} // update_license
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1168,7 +1161,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_artist($new_artist, $song_id)
|
public static function update_artist($new_artist, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('artist', $new_artist, $song_id, 50);
|
self::_update_item('artist', $new_artist, $song_id, 50);
|
||||||
|
|
||||||
} // update_artist
|
} // update_artist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1180,7 +1172,6 @@ class Song extends database_object implements media, library_item
|
||||||
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, true);
|
self::_update_item('album', $new_album, $song_id, 50, true);
|
||||||
|
|
||||||
} // update_album
|
} // update_album
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1191,10 +1182,11 @@ class Song extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
public static function update_utime($song_id, $time=0)
|
public static function update_utime($song_id, $time=0)
|
||||||
{
|
{
|
||||||
if (!$time) { $time = time(); }
|
if (!$time) {
|
||||||
|
$time = time();
|
||||||
|
}
|
||||||
|
|
||||||
self::_update_item('update_time', $time, $song_id, 75, true);
|
self::_update_item('update_time', $time, $song_id, 75, true);
|
||||||
|
|
||||||
} // update_utime
|
} // update_utime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1206,7 +1198,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_played($new_played, $song_id)
|
public static function update_played($new_played, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('played', ($new_played ? 1 : 0), $song_id, 25);
|
self::_update_item('played', ($new_played ? 1 : 0), $song_id, 25);
|
||||||
|
|
||||||
} // update_played
|
} // update_played
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1218,7 +1209,6 @@ class Song extends database_object implements media, library_item
|
||||||
public static function update_enabled($new_enabled, $song_id)
|
public static function update_enabled($new_enabled, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('enabled', ($new_enabled ? 1 : 0), $song_id, 75, true);
|
self::_update_item('enabled', ($new_enabled ? 1 : 0), $song_id, 75, true);
|
||||||
|
|
||||||
} // update_enabled
|
} // update_enabled
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1243,14 +1233,17 @@ class Song extends database_object implements media, library_item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Check them Rights! */
|
/* Check them Rights! */
|
||||||
if (!Access::check('interface', $level)) { return false; }
|
if (!Access::check('interface', $level)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Can't update to blank */
|
/* Can't update to blank */
|
||||||
if (!strlen(trim($value)) && $field != 'comment') { return false; }
|
if (!strlen(trim($value)) && $field != 'comment') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "UPDATE `song` SET `$field` = ? WHERE `id` = ?";
|
$sql = "UPDATE `song` SET `$field` = ? WHERE `id` = ?";
|
||||||
return Dba::write($sql, array($value, $song_id));
|
return Dba::write($sql, array($value, $song_id));
|
||||||
|
|
||||||
} // _update_item
|
} // _update_item
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1274,11 +1267,12 @@ class Song extends database_object implements media, library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check them rights boy! */
|
/* Check them rights boy! */
|
||||||
if (!Access::check('interface',$level)) { return false; }
|
if (!Access::check('interface',$level)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "UPDATE `song_data` SET `$field` = ? WHERE `song_id` = ?";
|
$sql = "UPDATE `song_data` SET `$field` = ? WHERE `song_id` = ?";
|
||||||
return Dba::write($sql, array($value, $song_id));
|
return Dba::write($sql, array($value, $song_id));
|
||||||
|
|
||||||
} // _update_ext_item
|
} // _update_ext_item
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1348,7 +1342,6 @@ class Song extends database_object implements media, library_item
|
||||||
|
|
||||||
$this->f_publisher = $this->label;
|
$this->f_publisher = $this->label;
|
||||||
$this->f_composer = $this->composer;
|
$this->f_composer = $this->composer;
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1460,8 +1453,9 @@ class Song extends database_object implements media, library_item
|
||||||
|
|
||||||
public function get_description()
|
public function get_description()
|
||||||
{
|
{
|
||||||
if (!empty($this->comment))
|
if (!empty($this->comment)) {
|
||||||
return $this->comment;
|
return $this->comment;
|
||||||
|
}
|
||||||
|
|
||||||
$album = new Album($this->album);
|
$album = new Album($this->album);
|
||||||
$album->format();
|
$album->format();
|
||||||
|
@ -1476,12 +1470,16 @@ class Song extends database_object implements media, library_item
|
||||||
if (Art::has_db($this->id, 'song')) {
|
if (Art::has_db($this->id, 'song')) {
|
||||||
$id = $this->id;
|
$id = $this->id;
|
||||||
$type = 'song';
|
$type = 'song';
|
||||||
} else if (Art::has_db($this->album, 'album')) {
|
} else {
|
||||||
$id = $this->album;
|
if (Art::has_db($this->album, 'album')) {
|
||||||
$type = 'album';
|
$id = $this->album;
|
||||||
} else if (Art::has_db($this->artist, 'artist')) {
|
$type = 'album';
|
||||||
$id = $this->artist;
|
} else {
|
||||||
$type = 'artist';
|
if (Art::has_db($this->artist, 'artist')) {
|
||||||
|
$id = $this->artist;
|
||||||
|
$type = 'artist';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id !== null && $type !== null) {
|
if ($id !== null && $type !== null) {
|
||||||
|
@ -1509,7 +1507,6 @@ class Song extends database_object implements media, library_item
|
||||||
// $fields['recently Played'] = true;
|
// $fields['recently Played'] = true;
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
|
||||||
} // get_fields
|
} // get_fields
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1532,7 +1529,6 @@ class Song extends database_object implements media, library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $songs;
|
return $songs;
|
||||||
|
|
||||||
} // get_from_path
|
} // get_from_path
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1558,7 +1554,6 @@ class Song extends database_object implements media, library_item
|
||||||
}
|
}
|
||||||
$catalog = Catalog::create_from_id( $catalog_id );
|
$catalog = Catalog::create_from_id( $catalog_id );
|
||||||
return $catalog->get_rel_path($file_path);
|
return $catalog->get_rel_path($file_path);
|
||||||
|
|
||||||
} // get_rel_path
|
} // get_rel_path
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1572,7 +1567,9 @@ class Song extends database_object implements media, library_item
|
||||||
public static function generic_play_url($object_type, $object_id, $additional_params, $player=null, $local=false)
|
public static function generic_play_url($object_type, $object_id, $additional_params, $player=null, $local=false)
|
||||||
{
|
{
|
||||||
$media = new $object_type($object_id);
|
$media = new $object_type($object_id);
|
||||||
if (!$media->id) return null;
|
if (!$media->id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$uid = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
|
$uid = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
|
||||||
$type = $media->type;
|
$type = $media->type;
|
||||||
|
@ -1648,12 +1645,14 @@ class Song extends database_object implements media, library_item
|
||||||
if ($user_id) {
|
if ($user_id) {
|
||||||
// If user is not empty, we're looking directly to user personal info (admin view)
|
// If user is not empty, we're looking directly to user personal info (admin view)
|
||||||
$sql .= "AND `user`='$user_id' ";
|
$sql .= "AND `user`='$user_id' ";
|
||||||
} else if (!Access::check('interface','100')) {
|
} else {
|
||||||
// If user identifier is empty, we need to retrieve only users which have allowed view of personnal info
|
if (!Access::check('interface','100')) {
|
||||||
|
// If user identifier is empty, we need to retrieve only users which have allowed view of personnal info
|
||||||
$personal_info_id = Preference::id_from_name('allow_personal_info_recent');
|
$personal_info_id = Preference::id_from_name('allow_personal_info_recent');
|
||||||
if ($personal_info_id) {
|
if ($personal_info_id) {
|
||||||
$current_user = $GLOBALS['user']->id;
|
$current_user = $GLOBALS['user']->id;
|
||||||
$sql .= "AND `user` IN (SELECT `user` FROM `user_preference` WHERE (`preference`='$personal_info_id' AND `value`='1') OR `user`='$current_user') ";
|
$sql .= "AND `user` IN (SELECT `user` FROM `user_preference` WHERE (`preference`='$personal_info_id' AND `value`='1') OR `user`='$current_user') ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql .= "ORDER BY `date` DESC ";
|
$sql .= "ORDER BY `date` DESC ";
|
||||||
|
@ -1666,11 +1665,12 @@ class Song extends database_object implements media, library_item
|
||||||
$row['geo_name'] = Stats::get_cached_place_name($row['latitude'], $row['longitude']);
|
$row['geo_name'] = Stats::get_cached_place_name($row['latitude'], $row['longitude']);
|
||||||
}
|
}
|
||||||
$results[] = $row;
|
$results[] = $row;
|
||||||
if (count($results) >= AmpConfig::get('popular_threshold')) { break; }
|
if (count($results) >= AmpConfig::get('popular_threshold')) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_recently_played
|
} // get_recently_played
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1735,13 +1735,17 @@ class Song extends database_object implements media, library_item
|
||||||
|
|
||||||
if ($target) {
|
if ($target) {
|
||||||
debug_event('media', 'Explicit format request {' . $target . '}', 5);
|
debug_event('media', 'Explicit format request {' . $target . '}', 5);
|
||||||
} else if ($target = AmpConfig::get('encode_target_' . $source)) {
|
|
||||||
debug_event('media', 'Defaulting to configured target format for ' . $source, 5);
|
|
||||||
} else if ($target = AmpConfig::get($setting_target)) {
|
|
||||||
debug_event('media', 'Using default target format', 5);
|
|
||||||
} else {
|
} else {
|
||||||
$target = $source;
|
if ($target = AmpConfig::get('encode_target_' . $source)) {
|
||||||
debug_event('media', 'No default target for ' . $source . ', choosing to resample', 5);
|
debug_event('media', 'Defaulting to configured target format for ' . $source, 5);
|
||||||
|
} else {
|
||||||
|
if ($target = AmpConfig::get($setting_target)) {
|
||||||
|
debug_event('media', 'Using default target format', 5);
|
||||||
|
} else {
|
||||||
|
$target = $source;
|
||||||
|
debug_event('media', 'No default target for ' . $source . ', choosing to resample', 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_event('media', 'Transcode settings: from ' . $source . ' to ' . $target, 5);
|
debug_event('media', 'Transcode settings: from ' . $source . ' to ' . $target, 5);
|
||||||
|
@ -1947,5 +1951,5 @@ class Song extends database_object implements media, library_item
|
||||||
|
|
||||||
return $deleted;
|
return $deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of song class
|
} // end of song class
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,9 @@ class Song_Preview extends database_object implements media, playable_item
|
||||||
*/
|
*/
|
||||||
public function __construct($id = null)
|
public function __construct($id = null)
|
||||||
{
|
{
|
||||||
if (!$id) { return false; }
|
if (!$id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->id = intval($id);
|
$this->id = intval($id);
|
||||||
|
|
||||||
|
@ -71,7 +73,6 @@ class Song_Preview extends database_object implements media, playable_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,12 +114,16 @@ class Song_Preview extends database_object implements media, playable_item
|
||||||
*/
|
*/
|
||||||
public static function build_cache($song_ids)
|
public static function build_cache($song_ids)
|
||||||
{
|
{
|
||||||
if (!is_array($song_ids) || !count($song_ids)) { return false; }
|
if (!is_array($song_ids) || !count($song_ids)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$idlist = '(' . implode(',', $song_ids) . ')';
|
$idlist = '(' . implode(',', $song_ids) . ')';
|
||||||
|
|
||||||
// Callers might have passed array(false) because they are dumb
|
// Callers might have passed array(false) because they are dumb
|
||||||
if ($idlist == '()') { return false; }
|
if ($idlist == '()') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Song data cache
|
// Song data cache
|
||||||
$sql = 'SELECT `id`, `file`, `album_mbid`, `artist`, `artist_mbid`, `title`, `disk`, `track`, `mbid` ' .
|
$sql = 'SELECT `id`, `file`, `album_mbid`, `artist`, `artist_mbid`, `title`, `disk`, `track`, `mbid` ' .
|
||||||
|
@ -137,7 +142,6 @@ class Song_Preview extends database_object implements media, playable_item
|
||||||
Artist::build_cache($artists);
|
Artist::build_cache($artists);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // build_cache
|
} // build_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,13 +181,15 @@ class Song_Preview extends database_object implements media, playable_item
|
||||||
*/
|
*/
|
||||||
public function get_artist_name($artist_id=0)
|
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);
|
$artist = new Artist($artist_id);
|
||||||
if ($artist->prefix)
|
if ($artist->prefix) {
|
||||||
return $artist->prefix . " " . $artist->name;
|
return $artist->prefix . " " . $artist->name;
|
||||||
else
|
} else {
|
||||||
return $artist->name;
|
return $artist->name;
|
||||||
|
}
|
||||||
} // get_album_name
|
} // get_album_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,7 +223,6 @@ class Song_Preview extends database_object implements media, playable_item
|
||||||
$this->f_track = $this->track;
|
$this->f_track = $this->track;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
public function get_fullname()
|
public function get_fullname()
|
||||||
|
@ -281,7 +286,6 @@ class Song_Preview extends database_object implements media, playable_item
|
||||||
$url = Stream::get_base_url($local) . "type=song_preview&oid=" . $song->id . "&uid=" . $user_id . "&name=" . $song_name;
|
$url = Stream::get_base_url($local) . "type=song_preview&oid=" . $song->id . "&uid=" . $user_id . "&name=" . $song_name;
|
||||||
|
|
||||||
return Stream_URL::format($url . $additional_params);
|
return Stream_URL::format($url . $additional_params);
|
||||||
|
|
||||||
} // play_url
|
} // play_url
|
||||||
|
|
||||||
public function stream()
|
public function stream()
|
||||||
|
@ -290,8 +294,9 @@ class Song_Preview extends database_object implements media, playable_item
|
||||||
foreach (Plugin::get_plugins('stream_song_preview') as $plugin_name) {
|
foreach (Plugin::get_plugins('stream_song_preview') as $plugin_name) {
|
||||||
$plugin = new Plugin($plugin_name);
|
$plugin = new Plugin($plugin_name);
|
||||||
if ($plugin->load($GLOBALS['user'])) {
|
if ($plugin->load($GLOBALS['user'])) {
|
||||||
if ($plugin->_plugin->stream_song_preview($this->file))
|
if ($plugin->_plugin->stream_song_preview($this->file)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,5 +350,5 @@ class Song_Preview extends database_object implements media, playable_item
|
||||||
'WHERE `session`.`id` IS NULL';
|
'WHERE `session`.`id` IS NULL';
|
||||||
return Dba::write($sql);
|
return Dba::write($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of song_preview class
|
} // end of song_preview class
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ class Stats
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,12 +102,15 @@ class Stats
|
||||||
$latitude = null;
|
$latitude = null;
|
||||||
$longitude = null;
|
$longitude = null;
|
||||||
$geoname = null;
|
$geoname = null;
|
||||||
if (isset($location['latitude']))
|
if (isset($location['latitude'])) {
|
||||||
$latitude = $location['latitude'];
|
$latitude = $location['latitude'];
|
||||||
if (isset($location['longitude']))
|
}
|
||||||
|
if (isset($location['longitude'])) {
|
||||||
$longitude = $location['longitude'];
|
$longitude = $location['longitude'];
|
||||||
if (isset($location['name']))
|
}
|
||||||
|
if (isset($location['name'])) {
|
||||||
$geoname = $location['name'];
|
$geoname = $location['name'];
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO `object_count` (`object_type`,`object_id`,`count_type`,`date`,`user`,`agent`, `geo_latitude`, `geo_longitude`, `geo_name`) " .
|
$sql = "INSERT INTO `object_count` (`object_type`,`object_id`,`count_type`,`date`,`user`,`agent`, `geo_latitude`, `geo_longitude`, `geo_name`) " .
|
||||||
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
@ -142,7 +144,6 @@ class Stats
|
||||||
}
|
}
|
||||||
|
|
||||||
return count($results) > 0;
|
return count($results) > 0;
|
||||||
|
|
||||||
} // is_already_inserted
|
} // is_already_inserted
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,7 +206,6 @@ class Stats
|
||||||
$results = Dba::fetch_assoc($db_results);
|
$results = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_last_song
|
} // get_last_song
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,7 +236,6 @@ class Stats
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_object_history
|
} // get_object_history
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,7 +290,6 @@ class Stats
|
||||||
$results[] = $row['id'];
|
$results[] = $row['id'];
|
||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_top
|
} // get_top
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -345,7 +343,6 @@ class Stats
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_recent
|
} // get_recent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -379,7 +376,6 @@ class Stats
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_user
|
} // get_user
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,7 +400,6 @@ class Stats
|
||||||
default:
|
default:
|
||||||
return 'song';
|
return 'song';
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
} // validate_type
|
} // validate_type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -424,7 +419,7 @@ class Stats
|
||||||
$sql = "SELECT DISTINCT(`$type`) as `id`, MIN(`addition_time`) AS `real_atime` FROM `" . $base_type . "` ";
|
$sql = "SELECT DISTINCT(`$type`) as `id`, MIN(`addition_time`) AS `real_atime` FROM `" . $base_type . "` ";
|
||||||
$sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `" . $base_type . "`.`catalog` ";
|
$sql .= "LEFT JOIN `catalog` ON `catalog`.`id` = `" . $base_type . "`.`catalog` ";
|
||||||
if (AmpConfig::get('catalog_disable')) {
|
if (AmpConfig::get('catalog_disable')) {
|
||||||
$sql .= "WHERE `catalog`.`enabled` = '1' ";
|
$sql .= "WHERE `catalog`.`enabled` = '1' ";
|
||||||
}
|
}
|
||||||
if ($catalog > 0) {
|
if ($catalog > 0) {
|
||||||
$sql .= "AND `catalog` = '" . scrub_in($catalog) ."' ";
|
$sql .= "AND `catalog` = '" . scrub_in($catalog) ."' ";
|
||||||
|
@ -441,7 +436,9 @@ class Stats
|
||||||
*/
|
*/
|
||||||
public static function get_newest($type, $count='', $offset='', $catalog=0)
|
public static function get_newest($type, $count='', $offset='', $catalog=0)
|
||||||
{
|
{
|
||||||
if (!$count) { $count = AmpConfig::get('popular_threshold'); }
|
if (!$count) {
|
||||||
|
$count = AmpConfig::get('popular_threshold');
|
||||||
|
}
|
||||||
if (!$offset) {
|
if (!$offset) {
|
||||||
$limit = $count;
|
$limit = $count;
|
||||||
} else {
|
} else {
|
||||||
|
@ -459,7 +456,6 @@ class Stats
|
||||||
} // end while results
|
} // end while results
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
|
|
||||||
} // get_newest
|
} // get_newest
|
||||||
|
|
||||||
} // Stats class
|
} // Stats class
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,6 @@ class Stream
|
||||||
$frame = gmdate("H:i:s", $sec);
|
$frame = gmdate("H:i:s", $sec);
|
||||||
|
|
||||||
if (AmpConfig::get('transcode_cmd') && AmpConfig::get('transcode_input') && AmpConfig::get('encode_get_image')) {
|
if (AmpConfig::get('transcode_cmd') && AmpConfig::get('transcode_input') && AmpConfig::get('encode_get_image')) {
|
||||||
|
|
||||||
$command = AmpConfig::get('transcode_cmd') . ' ' . AmpConfig::get('transcode_input') . ' ' . AmpConfig::get('encode_get_image');
|
$command = AmpConfig::get('transcode_cmd') . ' ' . AmpConfig::get('transcode_input') . ' ' . AmpConfig::get('encode_get_image');
|
||||||
$string_map = array(
|
$string_map = array(
|
||||||
'%FILE%' => scrub_arg($media->file),
|
'%FILE%' => scrub_arg($media->file),
|
||||||
|
@ -256,8 +255,9 @@ class Stream
|
||||||
// Windows doesn't like to provide stderr as a pipe
|
// Windows doesn't like to provide stderr as a pipe
|
||||||
$descriptors[2] = array('pipe', 'w');
|
$descriptors[2] = array('pipe', 'w');
|
||||||
$cmdPrefix = "exec ";
|
$cmdPrefix = "exec ";
|
||||||
} else
|
} else {
|
||||||
$cmdPrefix = "start /B ";
|
$cmdPrefix = "start /B ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
debug_event('stream', "Transcode command prefix: " . $cmdPrefix, 3);
|
debug_event('stream', "Transcode command prefix: " . $cmdPrefix, 3);
|
||||||
|
@ -398,7 +398,6 @@ class Stream
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_now_playing
|
} // get_now_playing
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -431,7 +430,9 @@ class Stream
|
||||||
public static function run_playlist_method()
|
public static function run_playlist_method()
|
||||||
{
|
{
|
||||||
// If this wasn't ajax included run away
|
// If this wasn't ajax included run away
|
||||||
if (!defined('AJAX_INCLUDE')) { return false; }
|
if (!defined('AJAX_INCLUDE')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (AmpConfig::get('playlist_method')) {
|
switch (AmpConfig::get('playlist_method')) {
|
||||||
case 'send':
|
case 'send':
|
||||||
|
@ -451,7 +452,6 @@ class Stream
|
||||||
echo "<script type=\"text/javascript\">";
|
echo "<script type=\"text/javascript\">";
|
||||||
echo Core::get_reloadutil() . "('".$_SESSION['iframe']['target']."');";
|
echo Core::get_reloadutil() . "('".$_SESSION['iframe']['target']."');";
|
||||||
echo "</script>";
|
echo "</script>";
|
||||||
|
|
||||||
} // run_playlist_method
|
} // run_playlist_method
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -487,7 +487,6 @@ class Stream
|
||||||
$url = $web_path . "/play/index.php?$session_string";
|
$url = $web_path . "/play/index.php?$session_string";
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
|
|
||||||
} // get_base_url
|
} // get_base_url
|
||||||
|
|
||||||
} //end of stream class
|
} //end of stream class
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,9 @@ class Stream_Playlist
|
||||||
*/
|
*/
|
||||||
public function add_urls($urls = array())
|
public function add_urls($urls = array())
|
||||||
{
|
{
|
||||||
if (!is_array($urls)) { return false; }
|
if (!is_array($urls)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($urls as $url) {
|
foreach ($urls as $url) {
|
||||||
$this->_add_url(new Stream_URL(array(
|
$this->_add_url(new Stream_URL(array(
|
||||||
|
@ -296,7 +298,6 @@ class Stream_Playlist
|
||||||
foreach ($this->urls as $url) {
|
foreach ($this->urls as $url) {
|
||||||
echo $url->url . "\n";
|
echo $url->url . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // simple_m3u
|
} // simple_m3u
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,7 +315,6 @@ class Stream_Playlist
|
||||||
echo $url->url . "\n";
|
echo $url->url . "\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // create_m3u
|
} // create_m3u
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -360,7 +360,6 @@ class Stream_Playlist
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</ASX>\n";
|
echo "</ASX>\n";
|
||||||
|
|
||||||
} // create_asx
|
} // create_asx
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -397,14 +396,12 @@ class Stream_Playlist
|
||||||
}
|
}
|
||||||
|
|
||||||
$result .= XML_Data::keyed_array($xml, true);
|
$result .= XML_Data::keyed_array($xml, true);
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
XML_Data::set_type('xspf');
|
XML_Data::set_type('xspf');
|
||||||
echo XML_Data::header();
|
echo XML_Data::header();
|
||||||
echo $result;
|
echo $result;
|
||||||
echo XML_Data::footer();
|
echo XML_Data::footer();
|
||||||
|
|
||||||
} // create_xspf
|
} // create_xspf
|
||||||
|
|
||||||
public function create_hls()
|
public function create_hls()
|
||||||
|
@ -461,7 +458,6 @@ class Stream_Playlist
|
||||||
} else {
|
} else {
|
||||||
require AmpConfig::get('prefix') . '/templates/create_web_player.inc.php';
|
require AmpConfig::get('prefix') . '/templates/create_web_player.inc.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
} // create_web_player
|
} // create_web_player
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -492,7 +488,6 @@ class Stream_Playlist
|
||||||
}
|
}
|
||||||
$localplay->play();
|
$localplay->play();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // create_localplay
|
} // create_localplay
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,8 +41,9 @@ class Stream_URL extends memory_object
|
||||||
$url = substr($url, 0, $posargs + 6) . 'index.php?';
|
$url = substr($url, 0, $posargs + 6) . 'index.php?';
|
||||||
$args = explode('/', $argsstr);
|
$args = explode('/', $argsstr);
|
||||||
for ($i = 0; $i < count($args); $i += 2) {
|
for ($i = 0; $i < count($args); $i += 2) {
|
||||||
if ($i > 0)
|
if ($i > 0) {
|
||||||
$url .= '&';
|
$url .= '&';
|
||||||
|
}
|
||||||
$url .= $args[$i] . '=' . $args[$i + 1];
|
$url .= $args[$i] . '=' . $args[$i + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,9 @@ class Subsonic_Api
|
||||||
{
|
{
|
||||||
if (empty($input[$parameter])) {
|
if (empty($input[$parameter])) {
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
if ($addheader) self::setHeader($input['f']);
|
if ($addheader) {
|
||||||
|
self::setHeader($input['f']);
|
||||||
|
}
|
||||||
self::apiOutput($input, Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM));
|
self::apiOutput($input, Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +71,9 @@ class Subsonic_Api
|
||||||
if ($encpwd !== false) {
|
if ($encpwd !== false) {
|
||||||
$hex = substr($password, 4);
|
$hex = substr($password, 4);
|
||||||
$decpwd = '';
|
$decpwd = '';
|
||||||
for ($i=0; $i<strlen($hex); $i+=2) $decpwd .= chr(hexdec(substr($hex,$i,2)));
|
for ($i=0; $i<strlen($hex); $i+=2) {
|
||||||
|
$decpwd .= chr(hexdec(substr($hex,$i,2)));
|
||||||
|
}
|
||||||
$password = $decpwd;
|
$password = $decpwd;
|
||||||
}
|
}
|
||||||
return $password;
|
return $password;
|
||||||
|
@ -145,10 +149,12 @@ class Subsonic_Api
|
||||||
{
|
{
|
||||||
if (strtolower($f) == "json") {
|
if (strtolower($f) == "json") {
|
||||||
header("Content-type: application/json; charset=" . AmpConfig::get('site_charset'));
|
header("Content-type: application/json; charset=" . AmpConfig::get('site_charset'));
|
||||||
} else if (strtolower($f) == "jsonp") {
|
|
||||||
header("Content-type: text/javascript; charset=" . AmpConfig::get('site_charset'));
|
|
||||||
} else {
|
} else {
|
||||||
header("Content-type: text/xml; charset=" . AmpConfig::get('site_charset'));
|
if (strtolower($f) == "jsonp") {
|
||||||
|
header("Content-type: text/javascript; charset=" . AmpConfig::get('site_charset'));
|
||||||
|
} else {
|
||||||
|
header("Content-type: text/xml; charset=" . AmpConfig::get('site_charset'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
header("access-control-allow-origin: *");
|
header("access-control-allow-origin: *");
|
||||||
}
|
}
|
||||||
|
@ -164,15 +170,17 @@ class Subsonic_Api
|
||||||
{
|
{
|
||||||
if ($f == "json") {
|
if ($f == "json") {
|
||||||
echo json_encode(self::xml2json($xml), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
|
echo json_encode(self::xml2json($xml), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
|
||||||
} else if ($f == "jsonp") {
|
|
||||||
echo $callback . '(' . json_encode(self::xml2json($xml), JSON_PRETTY_PRINT) . ')';
|
|
||||||
} else {
|
} else {
|
||||||
$xmlstr = $xml->asXml();
|
if ($f == "jsonp") {
|
||||||
|
echo $callback . '(' . json_encode(self::xml2json($xml), JSON_PRETTY_PRINT) . ')';
|
||||||
|
} else {
|
||||||
|
$xmlstr = $xml->asXml();
|
||||||
// Format xml output
|
// Format xml output
|
||||||
$dom = new DOMDocument();
|
$dom = new DOMDocument();
|
||||||
$dom->loadXML($xmlstr);
|
$dom->loadXML($xmlstr);
|
||||||
$dom->formatOutput = true;
|
$dom->formatOutput = true;
|
||||||
echo $dom->saveXML();
|
echo $dom->saveXML();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,8 +210,10 @@ class Subsonic_Api
|
||||||
foreach ($namespaces as $prefix => $namespace) {
|
foreach ($namespaces as $prefix => $namespace) {
|
||||||
foreach ($xml->attributes($namespace) as $attributeName => $attribute) {
|
foreach ($xml->attributes($namespace) as $attributeName => $attribute) {
|
||||||
//replace characters in attribute name
|
//replace characters in attribute name
|
||||||
if ($options['keySearch']) $attributeName =
|
if ($options['keySearch']) {
|
||||||
|
$attributeName =
|
||||||
str_replace($options['keySearch'], $options['keyReplace'], $attributeName);
|
str_replace($options['keySearch'], $options['keyReplace'], $attributeName);
|
||||||
|
}
|
||||||
$attributeKey = $options['attributePrefix']
|
$attributeKey = $options['attributePrefix']
|
||||||
. ($prefix ? $prefix . $options['namespaceSeparator'] : '')
|
. ($prefix ? $prefix . $options['namespaceSeparator'] : '')
|
||||||
. $attributeName;
|
. $attributeName;
|
||||||
|
@ -226,10 +236,14 @@ class Subsonic_Api
|
||||||
list($childTagName, $childProperties) = each($childArray);
|
list($childTagName, $childProperties) = each($childArray);
|
||||||
|
|
||||||
//replace characters in tag name
|
//replace characters in tag name
|
||||||
if ($options['keySearch']) $childTagName =
|
if ($options['keySearch']) {
|
||||||
|
$childTagName =
|
||||||
str_replace($options['keySearch'], $options['keyReplace'], $childTagName);
|
str_replace($options['keySearch'], $options['keyReplace'], $childTagName);
|
||||||
|
}
|
||||||
//add namespace prefix, if any
|
//add namespace prefix, if any
|
||||||
if ($prefix) $childTagName = $prefix . $options['namespaceSeparator'] . $childTagName;
|
if ($prefix) {
|
||||||
|
$childTagName = $prefix . $options['namespaceSeparator'] . $childTagName;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($tagsArray[$childTagName])) {
|
if (!isset($tagsArray[$childTagName])) {
|
||||||
//only entry with this key
|
//only entry with this key
|
||||||
|
@ -253,7 +267,9 @@ class Subsonic_Api
|
||||||
//get text content of node
|
//get text content of node
|
||||||
$textContentArray = array();
|
$textContentArray = array();
|
||||||
$plainText = trim((string) $xml);
|
$plainText = trim((string) $xml);
|
||||||
if ($plainText !== '') $textContentArray[$options['textContent']] = $plainText;
|
if ($plainText !== '') {
|
||||||
|
$textContentArray[$options['textContent']] = $plainText;
|
||||||
|
}
|
||||||
|
|
||||||
//stick it all together
|
//stick it all together
|
||||||
$propertiesArray = !$options['autoText'] || $attributesArray || $tagsArray || ($plainText === '')
|
$propertiesArray = !$options['autoText'] || $attributesArray || $tagsArray || ($plainText === '')
|
||||||
|
@ -302,12 +318,12 @@ class Subsonic_Api
|
||||||
*/
|
*/
|
||||||
public static function getmusicfolders($input)
|
public static function getmusicfolders($input)
|
||||||
{
|
{
|
||||||
self::check_version($input);
|
self::check_version($input);
|
||||||
|
|
||||||
$r = Subsonic_XML_Data::createSuccessResponse();
|
$r = Subsonic_XML_Data::createSuccessResponse();
|
||||||
Subsonic_XML_Data::addMusicFolders($r, Catalog::get_catalogs());
|
Subsonic_XML_Data::addMusicFolders($r, Catalog::get_catalogs());
|
||||||
self::apiOutput($input, $r);
|
self::apiOutput($input, $r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getIndexes
|
* getIndexes
|
||||||
|
@ -316,41 +332,53 @@ class Subsonic_Api
|
||||||
*/
|
*/
|
||||||
public static function getindexes($input)
|
public static function getindexes($input)
|
||||||
{
|
{
|
||||||
self::check_version($input);
|
self::check_version($input);
|
||||||
|
|
||||||
$musicFolderId = $input['musicFolderId'];
|
$musicFolderId = $input['musicFolderId'];
|
||||||
$ifModifiedSince = $input['ifModifiedSince'];
|
$ifModifiedSince = $input['ifModifiedSince'];
|
||||||
|
|
||||||
$catalogs = array();
|
$catalogs = array();
|
||||||
if (!empty($musicFolderId) && $musicFolderId != '-1') {
|
if (!empty($musicFolderId) && $musicFolderId != '-1') {
|
||||||
$catalogs[] = $musicFolderId;
|
$catalogs[] = $musicFolderId;
|
||||||
} else {
|
} else {
|
||||||
$catalogs = Catalog::get_catalogs();
|
$catalogs = Catalog::get_catalogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
$lastmodified = 0;
|
$lastmodified = 0;
|
||||||
$fcatalogs = array();
|
$fcatalogs = array();
|
||||||
|
|
||||||
foreach ($catalogs as $id) {
|
foreach ($catalogs as $id) {
|
||||||
$clastmodified = 0;
|
$clastmodified = 0;
|
||||||
$catalog = Catalog::create_from_id($id);
|
$catalog = Catalog::create_from_id($id);
|
||||||
|
|
||||||
if ($catalog->last_update > $clastmodified) $clastmodified = $catalog->last_update;
|
if ($catalog->last_update > $clastmodified) {
|
||||||
if ($catalog->last_add > $clastmodified) $clastmodified = $catalog->last_add;
|
$clastmodified = $catalog->last_update;
|
||||||
if ($catalog->last_clean > $clastmodified) $clastmodified = $catalog->last_clean;
|
}
|
||||||
|
if ($catalog->last_add > $clastmodified) {
|
||||||
|
$clastmodified = $catalog->last_add;
|
||||||
|
}
|
||||||
|
if ($catalog->last_clean > $clastmodified) {
|
||||||
|
$clastmodified = $catalog->last_clean;
|
||||||
|
}
|
||||||
|
|
||||||
if ($clastmodified > $lastmodified) $lastmodified = $clastmodified;
|
if ($clastmodified > $lastmodified) {
|
||||||
if (!empty($ifModifiedSince) && $clastmodified > ($ifModifiedSince / 1000)) $fcatalogs[] = $id;
|
$lastmodified = $clastmodified;
|
||||||
}
|
}
|
||||||
if (empty($ifModifiedSince)) $fcatalogs = $catalogs;
|
if (!empty($ifModifiedSince) && $clastmodified > ($ifModifiedSince / 1000)) {
|
||||||
|
$fcatalogs[] = $id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($ifModifiedSince)) {
|
||||||
|
$fcatalogs = $catalogs;
|
||||||
|
}
|
||||||
|
|
||||||
$r = Subsonic_XML_Data::createSuccessResponse();
|
$r = Subsonic_XML_Data::createSuccessResponse();
|
||||||
if (count($fcatalogs) > 0) {
|
if (count($fcatalogs) > 0) {
|
||||||
$artists = Catalog::get_artists($fcatalogs);
|
$artists = Catalog::get_artists($fcatalogs);
|
||||||
Subsonic_XML_Data::addArtistsIndexes($r, $artists, $lastmodified);
|
Subsonic_XML_Data::addArtistsIndexes($r, $artists, $lastmodified);
|
||||||
}
|
}
|
||||||
self::apiOutput($input, $r);
|
self::apiOutput($input, $r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMusicDirectory
|
* getMusicDirectory
|
||||||
|
@ -359,19 +387,21 @@ class Subsonic_Api
|
||||||
*/
|
*/
|
||||||
public static function getmusicdirectory($input)
|
public static function getmusicdirectory($input)
|
||||||
{
|
{
|
||||||
self::check_version($input);
|
self::check_version($input);
|
||||||
|
|
||||||
$id = self::check_parameter($input, 'id');
|
$id = self::check_parameter($input, 'id');
|
||||||
|
|
||||||
$r = Subsonic_XML_Data::createSuccessResponse();
|
$r = Subsonic_XML_Data::createSuccessResponse();
|
||||||
if (Subsonic_XML_Data::isArtist($id)) {
|
if (Subsonic_XML_Data::isArtist($id)) {
|
||||||
$artist = new Artist(Subsonic_XML_Data::getAmpacheId($id));
|
$artist = new Artist(Subsonic_XML_Data::getAmpacheId($id));
|
||||||
Subsonic_XML_Data::addArtistDirectory($r, $artist);
|
Subsonic_XML_Data::addArtistDirectory($r, $artist);
|
||||||
} else if (Subsonic_XML_Data::isAlbum($id)) {
|
} else {
|
||||||
$album = new Album(Subsonic_XML_Data::getAmpacheId($id));
|
if (Subsonic_XML_Data::isAlbum($id)) {
|
||||||
Subsonic_XML_Data::addAlbumDirectory($r, $album);
|
$album = new Album(Subsonic_XML_Data::getAmpacheId($id));
|
||||||
}
|
Subsonic_XML_Data::addAlbumDirectory($r, $album);
|
||||||
self::apiOutput($input, $r);
|
}
|
||||||
|
}
|
||||||
|
self::apiOutput($input, $r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -487,52 +517,70 @@ class Subsonic_Api
|
||||||
$albums = array();
|
$albums = array();
|
||||||
if ($type == "random") {
|
if ($type == "random") {
|
||||||
$albums = Album::get_random($size);
|
$albums = Album::get_random($size);
|
||||||
} else if ($type == "newest") {
|
} else {
|
||||||
$albums = Stats::get_newest("album", $size, $offset, $musicFolderId);
|
if ($type == "newest") {
|
||||||
} else if ($type == "highest") {
|
$albums = Stats::get_newest("album", $size, $offset, $musicFolderId);
|
||||||
$albums = Rating::get_highest("album", $size, $offset);
|
} else {
|
||||||
} else if ($type == "frequent") {
|
if ($type == "highest") {
|
||||||
$albums = Stats::get_top("album", $size, '', $offset);
|
$albums = Rating::get_highest("album", $size, $offset);
|
||||||
} else if ($type == "recent") {
|
} else {
|
||||||
$albums = Stats::get_recent("album", $size, $offset);
|
if ($type == "frequent") {
|
||||||
} else if ($type == "starred") {
|
$albums = Stats::get_top("album", $size, '', $offset);
|
||||||
$albums = Userflag::get_latest('album');
|
} else {
|
||||||
} else if ($type == "alphabeticalByName") {
|
if ($type == "recent") {
|
||||||
$albums = Catalog::get_albums($size, $offset, $catalogs);
|
$albums = Stats::get_recent("album", $size, $offset);
|
||||||
} else if ($type == "alphabeticalByArtist") {
|
} else {
|
||||||
$albums = Catalog::get_albums_by_artist($size, $offset, $catalogs);
|
if ($type == "starred") {
|
||||||
} else if ($type == "byYear") {
|
$albums = Userflag::get_latest('album');
|
||||||
$fromYear = $input['fromYear'];
|
} else {
|
||||||
$toYear = $input['toYear'];
|
if ($type == "alphabeticalByName") {
|
||||||
|
$albums = Catalog::get_albums($size, $offset, $catalogs);
|
||||||
|
} else {
|
||||||
|
if ($type == "alphabeticalByArtist") {
|
||||||
|
$albums = Catalog::get_albums_by_artist($size, $offset, $catalogs);
|
||||||
|
} else {
|
||||||
|
if ($type == "byYear") {
|
||||||
|
$fromYear = $input['fromYear'];
|
||||||
|
$toYear = $input['toYear'];
|
||||||
|
|
||||||
if ($fromYear || $toYear) {
|
if ($fromYear || $toYear) {
|
||||||
$search = array();
|
$search = array();
|
||||||
$search['limit'] = $size;
|
$search['limit'] = $size;
|
||||||
$search['offset'] = $offset;
|
$search['offset'] = $offset;
|
||||||
$search['type'] = "album";
|
$search['type'] = "album";
|
||||||
$i = 0;
|
$i = 0;
|
||||||
if ($fromYear) {
|
if ($fromYear) {
|
||||||
$search['rule_'.$i.'_input'] = $fromYear;
|
$search['rule_'.$i.'_input'] = $fromYear;
|
||||||
$search['rule_'.$i.'_operator'] = 0;
|
$search['rule_'.$i.'_operator'] = 0;
|
||||||
$search['rule_'.$i.''] = "year";
|
$search['rule_'.$i.''] = "year";
|
||||||
++$i;
|
++$i;
|
||||||
|
}
|
||||||
|
if ($toYear) {
|
||||||
|
$search['rule_'.$i.'_input'] = $toYear;
|
||||||
|
$search['rule_'.$i.'_operator'] = 1;
|
||||||
|
$search['rule_'.$i.''] = "year";
|
||||||
|
++$i;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = new Search(null, 'album');
|
||||||
|
$albums = $query->run($search);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($type == "byGenre") {
|
||||||
|
$genre = self::check_parameter($input, 'genre');
|
||||||
|
|
||||||
|
$tag_id = Tag::tag_exists($genre);
|
||||||
|
if ($tag_id) {
|
||||||
|
$albums = Tag::get_tag_objects('album', $tag_id, $size, $offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($toYear) {
|
|
||||||
$search['rule_'.$i.'_input'] = $toYear;
|
|
||||||
$search['rule_'.$i.'_operator'] = 1;
|
|
||||||
$search['rule_'.$i.''] = "year";
|
|
||||||
++$i;
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = new Search(null, 'album');
|
|
||||||
$albums = $query->run($search);
|
|
||||||
}
|
|
||||||
} else if ($type == "byGenre") {
|
|
||||||
$genre = self::check_parameter($input, 'genre');
|
|
||||||
|
|
||||||
$tag_id = Tag::tag_exists($genre);
|
|
||||||
if ($tag_id) {
|
|
||||||
$albums = Tag::get_tag_objects('album', $tag_id, $size, $offset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,7 +614,9 @@ class Subsonic_Api
|
||||||
self::check_version($input, "1.2.0");
|
self::check_version($input, "1.2.0");
|
||||||
|
|
||||||
$size = $input['size'];
|
$size = $input['size'];
|
||||||
if (!$size) $size = 10;
|
if (!$size) {
|
||||||
|
$size = 10;
|
||||||
|
}
|
||||||
$genre = $input['genre'];
|
$genre = $input['genre'];
|
||||||
$fromYear = $input['fromYear'];
|
$fromYear = $input['fromYear'];
|
||||||
$toYear = $input['toYear'];
|
$toYear = $input['toYear'];
|
||||||
|
@ -601,15 +651,17 @@ class Subsonic_Api
|
||||||
$finput = $artist->name;
|
$finput = $artist->name;
|
||||||
$operator = 4;
|
$operator = 4;
|
||||||
$ftype = "artist";
|
$ftype = "artist";
|
||||||
} else if (Subsonic_XML_Data::isAlbum($musicFolderId)) {
|
|
||||||
$album = new Album(Subsonic_XML_Data::getAmpacheId($musicFolderId));
|
|
||||||
$finput = $album->name;
|
|
||||||
$operator = 4;
|
|
||||||
$ftype = "artist";
|
|
||||||
} else {
|
} else {
|
||||||
$finput = intval($musicFolderId);
|
if (Subsonic_XML_Data::isAlbum($musicFolderId)) {
|
||||||
$operator = 0;
|
$album = new Album(Subsonic_XML_Data::getAmpacheId($musicFolderId));
|
||||||
$ftype = "catalog";
|
$finput = $album->name;
|
||||||
|
$operator = 4;
|
||||||
|
$ftype = "artist";
|
||||||
|
} else {
|
||||||
|
$finput = intval($musicFolderId);
|
||||||
|
$operator = 0;
|
||||||
|
$ftype = "catalog";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$search['rule_'.$i.'_input'] = $finput;
|
$search['rule_'.$i.'_input'] = $finput;
|
||||||
$search['rule_'.$i.'_operator'] = $operator;
|
$search['rule_'.$i.'_operator'] = $operator;
|
||||||
|
@ -710,7 +762,9 @@ class Subsonic_Api
|
||||||
|
|
||||||
$sartist = array();
|
$sartist = array();
|
||||||
$sartist['limit'] = $artistCount;
|
$sartist['limit'] = $artistCount;
|
||||||
if ($artistOffset) $sartist['offset'] = $artistOffset;
|
if ($artistOffset) {
|
||||||
|
$sartist['offset'] = $artistOffset;
|
||||||
|
}
|
||||||
$sartist['rule_1_input'] = $query;
|
$sartist['rule_1_input'] = $query;
|
||||||
$sartist['rule_1_operator'] = $operator;
|
$sartist['rule_1_operator'] = $operator;
|
||||||
$sartist['rule_1'] = "name";
|
$sartist['rule_1'] = "name";
|
||||||
|
@ -719,7 +773,9 @@ class Subsonic_Api
|
||||||
|
|
||||||
$salbum = array();
|
$salbum = array();
|
||||||
$salbum['limit'] = $albumCount;
|
$salbum['limit'] = $albumCount;
|
||||||
if ($albumOffset) $salbum['offset'] = $albumOffset;
|
if ($albumOffset) {
|
||||||
|
$salbum['offset'] = $albumOffset;
|
||||||
|
}
|
||||||
$salbum['rule_1_input'] = $query;
|
$salbum['rule_1_input'] = $query;
|
||||||
$salbum['rule_1_operator'] = $operator;
|
$salbum['rule_1_operator'] = $operator;
|
||||||
$salbum['rule_1'] = "title";
|
$salbum['rule_1'] = "title";
|
||||||
|
@ -728,7 +784,9 @@ class Subsonic_Api
|
||||||
|
|
||||||
$ssong = array();
|
$ssong = array();
|
||||||
$ssong['limit'] = $songCount;
|
$ssong['limit'] = $songCount;
|
||||||
if ($songOffset) $ssong['offset'] = $songOffset;
|
if ($songOffset) {
|
||||||
|
$ssong['offset'] = $songOffset;
|
||||||
|
}
|
||||||
$ssong['rule_1_input'] = $query;
|
$ssong['rule_1_input'] = $query;
|
||||||
$ssong['rule_1_operator'] = $operator;
|
$ssong['rule_1_operator'] = $operator;
|
||||||
$ssong['rule_1'] = "anywhere";
|
$ssong['rule_1'] = "anywhere";
|
||||||
|
@ -814,14 +872,16 @@ class Subsonic_Api
|
||||||
if ($playlistId) {
|
if ($playlistId) {
|
||||||
self::_updatePlaylist($playlistId, $name, $songId);
|
self::_updatePlaylist($playlistId, $name, $songId);
|
||||||
$r = Subsonic_XML_Data::createSuccessResponse();
|
$r = Subsonic_XML_Data::createSuccessResponse();
|
||||||
} else if (!empty($name)) {
|
|
||||||
$playlistId = Playlist::create($name, 'private');
|
|
||||||
if (count($songId) > 0) {
|
|
||||||
self::_updatePlaylist($playlistId, "", $songId);
|
|
||||||
}
|
|
||||||
$r = Subsonic_XML_Data::createSuccessResponse();
|
|
||||||
} else {
|
} else {
|
||||||
$r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM);
|
if (!empty($name)) {
|
||||||
|
$playlistId = Playlist::create($name, 'private');
|
||||||
|
if (count($songId) > 0) {
|
||||||
|
self::_updatePlaylist($playlistId, "", $songId);
|
||||||
|
}
|
||||||
|
$r = Subsonic_XML_Data::createSuccessResponse();
|
||||||
|
} else {
|
||||||
|
$r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self::apiOutput($input, $r);
|
self::apiOutput($input, $r);
|
||||||
}
|
}
|
||||||
|
@ -945,8 +1005,10 @@ class Subsonic_Api
|
||||||
$url = '';
|
$url = '';
|
||||||
if (Subsonic_XML_Data::isVideo($fileid)) {
|
if (Subsonic_XML_Data::isVideo($fileid)) {
|
||||||
$url = Video::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params, 'api', function_exists('curl_version'));
|
$url = Video::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params, 'api', function_exists('curl_version'));
|
||||||
} else if (Subsonic_XML_Data::isSong($fileid)) {
|
} else {
|
||||||
$url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params, 'api', function_exists('curl_version'));
|
if (Subsonic_XML_Data::isSong($fileid)) {
|
||||||
|
$url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params, 'api', function_exists('curl_version'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($url)) {
|
if (!empty($url)) {
|
||||||
|
@ -1015,10 +1077,14 @@ class Subsonic_Api
|
||||||
$art = null;
|
$art = null;
|
||||||
if (Subsonic_XML_Data::isArtist($id)) {
|
if (Subsonic_XML_Data::isArtist($id)) {
|
||||||
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "artist");
|
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "artist");
|
||||||
} else if (Subsonic_XML_Data::isAlbum($id)) {
|
} else {
|
||||||
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "album");
|
if (Subsonic_XML_Data::isAlbum($id)) {
|
||||||
} else if (Subsonic_XML_Data::isSong($id)) {
|
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "album");
|
||||||
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "song");
|
} else {
|
||||||
|
if (Subsonic_XML_Data::isSong($id)) {
|
||||||
|
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "song");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($art != null) {
|
if ($art != null) {
|
||||||
|
@ -1057,10 +1123,14 @@ class Subsonic_Api
|
||||||
$robj = null;
|
$robj = null;
|
||||||
if (Subsonic_XML_Data::isArtist($id)) {
|
if (Subsonic_XML_Data::isArtist($id)) {
|
||||||
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "artist");
|
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "artist");
|
||||||
} else if (Subsonic_XML_Data::isAlbum($id)) {
|
} else {
|
||||||
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "album");
|
if (Subsonic_XML_Data::isAlbum($id)) {
|
||||||
} else if (Subsonic_XML_Data::isSong($id)) {
|
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "album");
|
||||||
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "song");
|
} else {
|
||||||
|
if (Subsonic_XML_Data::isSong($id)) {
|
||||||
|
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "song");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($robj != null) {
|
if ($robj != null) {
|
||||||
|
@ -1143,36 +1213,44 @@ class Subsonic_Api
|
||||||
$aid = Subsonic_XML_Data::getAmpacheId($i);
|
$aid = Subsonic_XML_Data::getAmpacheId($i);
|
||||||
if (Subsonic_XML_Data::isArtist($i)) {
|
if (Subsonic_XML_Data::isArtist($i)) {
|
||||||
$type = 'artist';
|
$type = 'artist';
|
||||||
} else if (Subsonic_XML_Data::isAlbum($i)) {
|
|
||||||
$type = 'album';
|
|
||||||
} else if (Subsonic_XML_Data::isSong($i)) {
|
|
||||||
$type = 'song';
|
|
||||||
} else {
|
} else {
|
||||||
$type = "";
|
if (Subsonic_XML_Data::isAlbum($i)) {
|
||||||
|
$type = 'album';
|
||||||
|
} else {
|
||||||
|
if (Subsonic_XML_Data::isSong($i)) {
|
||||||
|
$type = 'song';
|
||||||
|
} else {
|
||||||
|
$type = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$ids[] = array('id' => $aid, 'type' => $type);
|
$ids[] = array('id' => $aid, 'type' => $type);
|
||||||
}
|
}
|
||||||
} else if ($albumId) {
|
|
||||||
if (!is_array($albumId)) {
|
|
||||||
$albumId = array($albumId);
|
|
||||||
}
|
|
||||||
foreach ($albumId as $i) {
|
|
||||||
$aid = Subsonic_XML_Data::getAmpacheId($i);
|
|
||||||
$ids[] = array('id' => $aid, 'album');
|
|
||||||
}
|
|
||||||
} else if ($artistId) {
|
|
||||||
if (!is_array($artistId)) {
|
|
||||||
$artistId = array($artistId);
|
|
||||||
}
|
|
||||||
foreach ($artistId as $i) {
|
|
||||||
$aid = Subsonic_XML_Data::getAmpacheId($i);
|
|
||||||
$ids[] = array('id' => $aid, 'artist');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM);
|
if ($albumId) {
|
||||||
|
if (!is_array($albumId)) {
|
||||||
|
$albumId = array($albumId);
|
||||||
|
}
|
||||||
|
foreach ($albumId as $i) {
|
||||||
|
$aid = Subsonic_XML_Data::getAmpacheId($i);
|
||||||
|
$ids[] = array('id' => $aid, 'album');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($artistId) {
|
||||||
|
if (!is_array($artistId)) {
|
||||||
|
$artistId = array($artistId);
|
||||||
|
}
|
||||||
|
foreach ($artistId as $i) {
|
||||||
|
$aid = Subsonic_XML_Data::getAmpacheId($i);
|
||||||
|
$ids[] = array('id' => $aid, 'artist');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($ids as $i) {
|
foreach ($ids as $i) {
|
||||||
$flag = new Userflag($i['id'], $i['type']);
|
$flag = new Userflag($i['id'], $i['type']);
|
||||||
$flag->set_flag($star);
|
$flag->set_flag($star);
|
||||||
}
|
}
|
||||||
|
@ -1317,8 +1395,10 @@ class Subsonic_Api
|
||||||
$object_id = Subsonic_XML_Data::getAmpacheId($id);
|
$object_id = Subsonic_XML_Data::getAmpacheId($id);
|
||||||
if (Subsonic_XML_Data::isAlbum($id)) {
|
if (Subsonic_XML_Data::isAlbum($id)) {
|
||||||
$object_type = 'album';
|
$object_type = 'album';
|
||||||
} else if (Subsonic_XML_Data::isSong($id)) {
|
} else {
|
||||||
$object_type = 'song';
|
if (Subsonic_XML_Data::isSong($id)) {
|
||||||
|
$object_type = 'song';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($object_type)) {
|
if (!empty($object_type)) {
|
||||||
|
@ -1548,8 +1628,9 @@ class Subsonic_Api
|
||||||
break;
|
break;
|
||||||
case 'skip':
|
case 'skip':
|
||||||
if (isset($input['index'])) {
|
if (isset($input['index'])) {
|
||||||
if ($localplay->skip($input['index']))
|
if ($localplay->skip($input['index'])) {
|
||||||
$ret = $localplay->play();
|
$ret = $localplay->play();
|
||||||
|
}
|
||||||
} elseif (isset($input['offset'])) {
|
} elseif (isset($input['offset'])) {
|
||||||
debug_event('subsonic', 'Skip with offset is not supported on JukeboxControl.', 5);
|
debug_event('subsonic', 'Skip with offset is not supported on JukeboxControl.', 5);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -137,7 +137,9 @@ class Subsonic_XML_Data
|
||||||
|
|
||||||
public static function createResponse($version = "")
|
public static function createResponse($version = "")
|
||||||
{
|
{
|
||||||
if (empty($version)) $version = Subsonic_XML_Data::API_VERSION;
|
if (empty($version)) {
|
||||||
|
$version = Subsonic_XML_Data::API_VERSION;
|
||||||
|
}
|
||||||
$response = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><subsonic-response/>');
|
$response = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><subsonic-response/>');
|
||||||
$response->addAttribute('xmlns', 'http://subsonic.org/restapi');
|
$response->addAttribute('xmlns', 'http://subsonic.org/restapi');
|
||||||
$response->addAttribute('type', 'ampache');
|
$response->addAttribute('type', 'ampache');
|
||||||
|
@ -147,7 +149,9 @@ class Subsonic_XML_Data
|
||||||
|
|
||||||
public static function createError($code, $message = "", $version = "")
|
public static function createError($code, $message = "", $version = "")
|
||||||
{
|
{
|
||||||
if (empty($version)) $version = Subsonic_XML_Data::API_VERSION;
|
if (empty($version)) {
|
||||||
|
$version = Subsonic_XML_Data::API_VERSION;
|
||||||
|
}
|
||||||
$response = self::createFailedResponse($version);
|
$response = self::createFailedResponse($version);
|
||||||
self::setError($response, $code, $message);
|
self::setError($response, $code, $message);
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -222,8 +226,13 @@ class Subsonic_XML_Data
|
||||||
foreach ($artists as $artist) {
|
foreach ($artists as $artist) {
|
||||||
if (strlen($artist->name) > 0) {
|
if (strlen($artist->name) > 0) {
|
||||||
$letter = strtoupper($artist->name[0]);
|
$letter = strtoupper($artist->name[0]);
|
||||||
if ($letter == "X" || $letter == "Y" || $letter == "Z") $letter = "X-Z";
|
if ($letter == "X" || $letter == "Y" || $letter == "Z") {
|
||||||
else if (!preg_match("/^[A-W]$/", $letter)) $letter = "#";
|
$letter = "X-Z";
|
||||||
|
} else {
|
||||||
|
if (!preg_match("/^[A-W]$/", $letter)) {
|
||||||
|
$letter = "#";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($letter != $xlastletter) {
|
if ($letter != $xlastletter) {
|
||||||
$xlastletter = $letter;
|
$xlastletter = $letter;
|
||||||
|
@ -271,11 +280,11 @@ class Subsonic_XML_Data
|
||||||
|
|
||||||
public static function addAlbumList($xml, $albums, $elementName="albumList")
|
public static function addAlbumList($xml, $albums, $elementName="albumList")
|
||||||
{
|
{
|
||||||
$xlist = $xml->addChild(htmlspecialchars($elementName));
|
$xlist = $xml->addChild(htmlspecialchars($elementName));
|
||||||
foreach ($albums as $id) {
|
foreach ($albums as $id) {
|
||||||
$album = new Album($id);
|
$album = new Album($id);
|
||||||
self::addAlbum($xlist, $album);
|
self::addAlbum($xlist, $album);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addAlbum($xml, $album, $songs=false, $elementName="album")
|
public static function addAlbum($xml, $album, $songs=false, $elementName="album")
|
||||||
|
@ -323,10 +332,10 @@ class Subsonic_XML_Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addSong($xml, $song, $elementName='song')
|
public static function addSong($xml, $song, $elementName='song')
|
||||||
{
|
{
|
||||||
self::createSong($xml, $song, $elementName);
|
self::createSong($xml, $song, $elementName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createSong($xml, $song, $elementName='song')
|
public static function createSong($xml, $song, $elementName='song')
|
||||||
{
|
{
|
||||||
|
@ -363,9 +372,13 @@ class Subsonic_XML_Data
|
||||||
$xsong->addAttribute('year', $song->year);
|
$xsong->addAttribute('year', $song->year);
|
||||||
}
|
}
|
||||||
$tags = Tag::get_object_tags('song', $song->id);
|
$tags = Tag::get_object_tags('song', $song->id);
|
||||||
if (count($tags) > 0) $xsong->addAttribute('genre', $tags[0]['name']);
|
if (count($tags) > 0) {
|
||||||
|
$xsong->addAttribute('genre', $tags[0]['name']);
|
||||||
|
}
|
||||||
$xsong->addAttribute('size', $song->size);
|
$xsong->addAttribute('size', $song->size);
|
||||||
if ($album->disk > 0) $xsong->addAttribute('discNumber', $album->disk);
|
if ($album->disk > 0) {
|
||||||
|
$xsong->addAttribute('discNumber', $album->disk);
|
||||||
|
}
|
||||||
$xsong->addAttribute('suffix', $song->type);
|
$xsong->addAttribute('suffix', $song->type);
|
||||||
$xsong->addAttribute('contentType', $song->mime);
|
$xsong->addAttribute('contentType', $song->mime);
|
||||||
// Create a clean fake path instead of song real file path to have better offline mode storage on Subsonic clients
|
// Create a clean fake path instead of song real file path to have better offline mode storage on Subsonic clients
|
||||||
|
@ -468,7 +481,9 @@ class Subsonic_XML_Data
|
||||||
$xvideo->addAttribute('year', $video->year);
|
$xvideo->addAttribute('year', $video->year);
|
||||||
}
|
}
|
||||||
$tags = Tag::get_object_tags('video', $video->id);
|
$tags = Tag::get_object_tags('video', $video->id);
|
||||||
if (count($tags) > 0) $xvideo->addAttribute('genre', $tags[0]['name']);
|
if (count($tags) > 0) {
|
||||||
|
$xvideo->addAttribute('genre', $tags[0]['name']);
|
||||||
|
}
|
||||||
$xvideo->addAttribute('size', $video->size);
|
$xvideo->addAttribute('size', $video->size);
|
||||||
$xvideo->addAttribute('suffix', $video->type);
|
$xvideo->addAttribute('suffix', $video->type);
|
||||||
$xvideo->addAttribute('contentType', $video->mime);
|
$xvideo->addAttribute('contentType', $video->mime);
|
||||||
|
|
|
@ -38,14 +38,15 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
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) {
|
foreach ($info as $key=>$value) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
} // constructor
|
} // constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +60,6 @@ class Tag extends database_object implements library_item
|
||||||
$tag = new Tag($tag_id);
|
$tag = new Tag($tag_id);
|
||||||
|
|
||||||
return $tag;
|
return $tag;
|
||||||
|
|
||||||
} // construct_from_name
|
} // construct_from_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +69,9 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
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) . ')';
|
||||||
|
|
||||||
|
@ -89,10 +91,13 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
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; }
|
if (!is_array($ids) OR !count($ids)) {
|
||||||
|
|
||||||
if (!Core::is_library_item($type))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Core::is_library_item($type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$idlist = '(' . implode(',',$ids) . ')';
|
$idlist = '(' . implode(',',$ids) . ')';
|
||||||
|
|
||||||
|
@ -121,7 +126,6 @@ class Tag extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // build_map_cache
|
} // build_map_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,14 +135,19 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public static function add($type, $id, $value, $user=false)
|
public static function add($type, $id, $value, $user=false)
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_numeric($id)) { return false; }
|
if (!is_numeric($id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$cleaned_value = $value;
|
$cleaned_value = $value;
|
||||||
|
|
||||||
if (!strlen($cleaned_value)) { return false; }
|
if (!strlen($cleaned_value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$uid = ($user === false) ? intval($user) : intval($GLOBALS['user']->id);
|
$uid = ($user === false) ? intval($user) : intval($GLOBALS['user']->id);
|
||||||
|
|
||||||
|
@ -158,7 +167,6 @@ class Tag extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $map_id;
|
return $map_id;
|
||||||
|
|
||||||
} // add
|
} // add
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,7 +175,9 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public static function add_tag($value)
|
public static function add_tag($value)
|
||||||
{
|
{
|
||||||
if (!strlen($value)) { return false; }
|
if (!strlen($value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "REPLACE INTO `tag` SET `name` = ?";
|
$sql = "REPLACE INTO `tag` SET `name` = ?";
|
||||||
Dba::write($sql, array($value));
|
Dba::write($sql, array($value));
|
||||||
|
@ -176,7 +186,6 @@ class Tag extends database_object implements library_item
|
||||||
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
|
} // add_tag
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,7 +195,9 @@ class Tag extends database_object implements library_item
|
||||||
public function update(array $data)
|
public function update(array $data)
|
||||||
{
|
{
|
||||||
//debug_event('tag.class', 'Updating tag {'.$this->id.'} with name {'.$name.'}...', '5');
|
//debug_event('tag.class', 'Updating tag {'.$this->id.'} with name {'.$name.'}...', '5');
|
||||||
if (!strlen($data['name'])) { return false; }
|
if (!strlen($data['name'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE `tag` SET `name` = ? WHERE `id` = ?';
|
$sql = 'UPDATE `tag` SET `name` = ? WHERE `id` = ?';
|
||||||
Dba::write($sql, array($data[name], $this->id));
|
Dba::write($sql, array($data[name], $this->id));
|
||||||
|
@ -213,7 +224,6 @@ class Tag extends database_object implements library_item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
||||||
} // add_tag
|
} // add_tag
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,11 +283,14 @@ class Tag extends database_object implements library_item
|
||||||
{
|
{
|
||||||
$uid = ($user == '') ? intval($GLOBALS['user']->id) : intval($user);
|
$uid = ($user == '') ? intval($GLOBALS['user']->id) : intval($user);
|
||||||
$tag_id = intval($tag_id);
|
$tag_id = intval($tag_id);
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$id = intval($object_id);
|
$id = intval($object_id);
|
||||||
|
|
||||||
if (!$tag_id || !$id) { return false; }
|
if (!$tag_id || !$id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// If tag merged to another one, add reference to the merge destination
|
// If tag merged to another one, add reference to the merge destination
|
||||||
$parent = new Tag($tag_id);
|
$parent = new Tag($tag_id);
|
||||||
|
@ -295,7 +308,6 @@ class Tag extends database_object implements library_item
|
||||||
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
|
} // add_tag_map
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -378,7 +390,6 @@ class Tag extends database_object implements library_item
|
||||||
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_exists
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -388,8 +399,9 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
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 (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM `tag_map` LEFT JOIN `tag` ON `tag`.`id` = `tag_map`.`tag_id` LEFT JOIN `tag_merge` ON `tag`.`id`=`tag_merge`.`tag_id` " .
|
$sql = "SELECT * FROM `tag_map` LEFT JOIN `tag` ON `tag`.`id` = `tag_map`.`tag_id` LEFT JOIN `tag_merge` ON `tag`.`id`=`tag_merge`.`tag_id` " .
|
||||||
"WHERE (`tag_map`.`tag_id` = ? OR `tag_map`.`tag_id` = `tag_merge`.`merged_to`) AND `tag_map`.`user` = ? AND `tag_map`.`object_id` = ? AND `tag_map`.`object_type` = ?";
|
"WHERE (`tag_map`.`tag_id` = ? OR `tag_map`.`tag_id` = `tag_merge`.`merged_to`) AND `tag_map`.`user` = ? AND `tag_map`.`object_id` = ? AND `tag_map`.`object_type` = ?";
|
||||||
|
@ -398,7 +410,6 @@ class Tag extends database_object implements library_item
|
||||||
$results = Dba::fetch_assoc($db_results);
|
$results = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $results['id'];
|
return $results['id'];
|
||||||
|
|
||||||
} // tag_map_exists
|
} // tag_map_exists
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -407,8 +418,9 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public static function get_top_tags($type, $object_id, $limit = 10)
|
public static function get_top_tags($type, $object_id, $limit = 10)
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return array();
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$object_id = intval($object_id);
|
$object_id = intval($object_id);
|
||||||
|
|
||||||
|
@ -427,7 +439,6 @@ class Tag extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_top_tags
|
} // get_top_tags
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -437,8 +448,9 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public static function get_object_tags($type, $id)
|
public static function get_object_tags($type, $id)
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " .
|
$sql = "SELECT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " .
|
||||||
"LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " .
|
"LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " .
|
||||||
|
@ -460,13 +472,16 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public static function get_tag_objects($type,$tag_id,$count='',$offset='')
|
public static function get_tag_objects($type,$tag_id,$count='',$offset='')
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$limit_sql = "";
|
$limit_sql = "";
|
||||||
if ($count) {
|
if ($count) {
|
||||||
$limit_sql = "LIMIT ";
|
$limit_sql = "LIMIT ";
|
||||||
if ($offset) $limit_sql .= intval($offset) . ',';
|
if ($offset) {
|
||||||
|
$limit_sql .= intval($offset) . ',';
|
||||||
|
}
|
||||||
$limit_sql .= intval($count);
|
$limit_sql .= intval($count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +541,6 @@ class Tag extends database_object implements library_item
|
||||||
|
|
||||||
parent::add_to_cache('tags_list', 'no_name', $results);
|
parent::add_to_cache('tags_list', 'no_name', $results);
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_tags
|
} // get_tags
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -538,7 +552,9 @@ class Tag extends database_object implements library_item
|
||||||
public static function get_display($tags, $link=false, $filter_type='')
|
public static function get_display($tags, $link=false, $filter_type='')
|
||||||
{
|
{
|
||||||
//debug_event('tag.class.php', 'Get display tags called...', '5');
|
//debug_event('tag.class.php', 'Get display tags called...', '5');
|
||||||
if (!is_array($tags)) { return ''; }
|
if (!is_array($tags)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$results = '';
|
$results = '';
|
||||||
|
|
||||||
|
@ -561,7 +577,6 @@ class Tag extends database_object implements library_item
|
||||||
$results = rtrim($results, ', ');
|
$results = rtrim($results, ', ');
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_display
|
} // get_display
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -592,9 +607,11 @@ class Tag extends database_object implements library_item
|
||||||
if ($found) {
|
if ($found) {
|
||||||
debug_event('tag.class', 'Already found. Do nothing.', '5');
|
debug_event('tag.class', 'Already found. Do nothing.', '5');
|
||||||
unset($editedTags[$tk]);
|
unset($editedTags[$tk]);
|
||||||
} else if ($overwrite) {
|
} else {
|
||||||
debug_event('tag.class', 'Not found in the new list. Delete it.', '5');
|
if ($overwrite) {
|
||||||
$ctag->remove_map($type, $object_id);
|
debug_event('tag.class', 'Not found in the new list. Delete it.', '5');
|
||||||
|
$ctag->remove_map($type, $object_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -658,7 +675,6 @@ class Tag extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // count
|
} // count
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -667,8 +683,9 @@ class Tag extends database_object implements library_item
|
||||||
*/
|
*/
|
||||||
public function remove_map($type, $object_id)
|
public function remove_map($type, $object_id)
|
||||||
{
|
{
|
||||||
if (!Core::is_library_item($type))
|
if (!Core::is_library_item($type)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Review the tag edition per user.
|
// TODO: Review the tag edition per user.
|
||||||
|
|
||||||
|
@ -676,12 +693,10 @@ class Tag extends database_object implements library_item
|
||||||
Dba::write($sql, array($this->id, $type, $object_id));//, $GLOBALS['user']->id));
|
Dba::write($sql, array($this->id, $type, $object_id));//, $GLOBALS['user']->id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // remove_map
|
} // remove_map
|
||||||
|
|
||||||
public function format($details = true)
|
public function format($details = true)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_keywords()
|
public function get_keywords()
|
||||||
|
@ -763,5 +778,5 @@ class Tag extends database_object implements library_item
|
||||||
Art::display('tag', $this->id, $this->get_fullname(), $thumb, $this->link);
|
Art::display('tag', $this->id, $this->get_fullname(), $thumb, $this->link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of Tag class
|
} // end of Tag class
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,9 @@ class Tmp_Playlist extends database_object
|
||||||
*/
|
*/
|
||||||
public function __construct($playlist_id='')
|
public function __construct($playlist_id='')
|
||||||
{
|
{
|
||||||
if (!$playlist_id) { return false; }
|
if (!$playlist_id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->id = intval($playlist_id);
|
$this->id = intval($playlist_id);
|
||||||
$info = $this->_get_info();
|
$info = $this->_get_info();
|
||||||
|
@ -58,7 +60,6 @@ class Tmp_Playlist extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // __construct
|
} // __construct
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,7 +75,6 @@ class Tmp_Playlist extends database_object
|
||||||
$results = Dba::fetch_assoc($db_results);
|
$results = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // _get_info
|
} // _get_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,7 +102,6 @@ class Tmp_Playlist extends database_object
|
||||||
$playlist = new Tmp_Playlist($results['0']);
|
$playlist = new Tmp_Playlist($results['0']);
|
||||||
|
|
||||||
return $playlist;
|
return $playlist;
|
||||||
|
|
||||||
} // get_from_session
|
} // get_from_session
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,7 +127,6 @@ class Tmp_Playlist extends database_object
|
||||||
$data = Dba::fetch_assoc($db_results);
|
$data = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $data['id'];
|
return $data['id'];
|
||||||
|
|
||||||
} // get_from_userid
|
} // get_from_userid
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,7 +155,6 @@ class Tmp_Playlist extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
|
|
||||||
} // get_items
|
} // get_items
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,7 +172,6 @@ class Tmp_Playlist extends database_object
|
||||||
$results = Dba::fetch_assoc($db_results);
|
$results = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $results['object_id'];
|
return $results['object_id'];
|
||||||
|
|
||||||
} // get_next_object
|
} // get_next_object
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,7 +190,6 @@ class Tmp_Playlist extends database_object
|
||||||
$results = Dba::fetch_row($db_results);
|
$results = Dba::fetch_row($db_results);
|
||||||
|
|
||||||
return $results['0'];
|
return $results['0'];
|
||||||
|
|
||||||
} // count_items
|
} // count_items
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +202,6 @@ class Tmp_Playlist extends database_object
|
||||||
Dba::write($sql, array($this->id));
|
Dba::write($sql, array($this->id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // clear
|
} // clear
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -229,7 +223,6 @@ class Tmp_Playlist extends database_object
|
||||||
self::session_clean($data['session_id'], $id);
|
self::session_clean($data['session_id'], $id);
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,7 +236,6 @@ class Tmp_Playlist extends database_object
|
||||||
Dba::write($sql, array($playlist_id, $this->id));
|
Dba::write($sql, array($playlist_id, $this->id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // update_playlist
|
} // update_playlist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,7 +252,6 @@ class Tmp_Playlist extends database_object
|
||||||
self::prune_tracks();
|
self::prune_tracks();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // session_clean
|
} // session_clean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -289,7 +280,6 @@ class Tmp_Playlist extends database_object
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // prune_playlists
|
} // prune_playlists
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -305,7 +295,6 @@ class Tmp_Playlist extends database_object
|
||||||
"`tmp_playlist_data`.`tmp_playlist`=`tmp_playlist`.`id` " .
|
"`tmp_playlist_data`.`tmp_playlist`=`tmp_playlist`.`id` " .
|
||||||
"WHERE `tmp_playlist`.`id` IS NULL";
|
"WHERE `tmp_playlist`.`id` IS NULL";
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
} // prune_tracks
|
} // prune_tracks
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,7 +310,6 @@ class Tmp_Playlist extends database_object
|
||||||
Dba::write($sql, array($object_id, $this->id, $object_type));
|
Dba::write($sql, array($object_id, $this->id, $object_type));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // add_object
|
} // add_object
|
||||||
|
|
||||||
public function add_medias($medias)
|
public function add_medias($medias)
|
||||||
|
@ -339,10 +327,11 @@ class Tmp_Playlist extends database_object
|
||||||
public function vote_active()
|
public function vote_active()
|
||||||
{
|
{
|
||||||
/* Going to do a little more here later */
|
/* Going to do a little more here later */
|
||||||
if ($this->type == 'vote') { return true; }
|
if ($this->type == 'vote') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // vote_active
|
} // vote_active
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -356,7 +345,6 @@ class Tmp_Playlist extends database_object
|
||||||
Dba::write($sql, array($id));
|
Dba::write($sql, array($id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete_track
|
} // delete_track
|
||||||
|
|
||||||
} // class Tmp_Playlist
|
} // class Tmp_Playlist
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,9 @@ class TVShow extends database_object implements library_item
|
||||||
public function __construct($id='')
|
public function __construct($id='')
|
||||||
{
|
{
|
||||||
/* If they failed to pass in an id, just run for it */
|
/* 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 */
|
/* Get the information from the db */
|
||||||
$info = $this->get_info($id);
|
$info = $this->get_info($id);
|
||||||
|
@ -59,7 +61,6 @@ class TVShow extends database_object implements library_item
|
||||||
} // foreach info
|
} // foreach info
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} //constructor
|
} //constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,7 +88,6 @@ class TVShow extends database_object implements library_item
|
||||||
|
|
||||||
$object = new TVShow($row['id']);
|
$object = new TVShow($row['id']);
|
||||||
return $object;
|
return $object;
|
||||||
|
|
||||||
} // get_from_name
|
} // get_from_name
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,7 +105,6 @@ class TVShow extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_seasons
|
} // get_seasons
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,7 +132,6 @@ class TVShow extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_episodes
|
} // get_episodes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +166,6 @@ class TVShow extends database_object implements library_item
|
||||||
$this->catalog_id = $row['catalog_id'];
|
$this->catalog_id = $row['catalog_id'];
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
|
|
||||||
} // _get_extra_info
|
} // _get_extra_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -327,7 +324,6 @@ class TVShow extends database_object implements library_item
|
||||||
|
|
||||||
self::$_mapcache[$name]['null'] = $id;
|
self::$_mapcache[$name]['null'] = $id;
|
||||||
return $id;
|
return $id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -386,7 +382,6 @@ class TVShow extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $current_id;
|
return $current_id;
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -436,5 +431,5 @@ class TVShow extends database_object implements library_item
|
||||||
|
|
||||||
return $deleted;
|
return $deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of tvshow class
|
} // end of tvshow class
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ class TVShow_Episode extends Video
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +111,6 @@ class TVShow_Episode extends Video
|
||||||
Dba::write($sql, array($data['id'], $data['original_name'], $data['tvshow_season'], $data['tvshow_episode'], $data['summary']));
|
Dba::write($sql, array($data['id'], $data['original_name'], $data['tvshow_season'], $data['tvshow_episode'], $data['summary']));
|
||||||
|
|
||||||
return $data['id'];
|
return $data['id'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,7 +135,6 @@ class TVShow_Episode extends Video
|
||||||
$this->summary = $summary;
|
$this->summary = $summary;
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,8 +205,9 @@ class TVShow_Episode extends Video
|
||||||
|
|
||||||
public function get_description()
|
public function get_description()
|
||||||
{
|
{
|
||||||
if (!empty($this->summary))
|
if (!empty($this->summary)) {
|
||||||
return $this->summary;
|
return $this->summary;
|
||||||
|
}
|
||||||
|
|
||||||
$season = new TVShow_Season($this->season);
|
$season = new TVShow_Season($this->season);
|
||||||
return $season->get_description();
|
return $season->get_description();
|
||||||
|
@ -223,14 +221,16 @@ class TVShow_Episode extends Video
|
||||||
if (Art::has_db($this->id, 'video')) {
|
if (Art::has_db($this->id, 'video')) {
|
||||||
$id = $this->id;
|
$id = $this->id;
|
||||||
$type = 'video';
|
$type = 'video';
|
||||||
} else if (Art::has_db($this->season, 'tvshow_season')) {
|
|
||||||
$id = $this->season;
|
|
||||||
$type = 'tvshow_season';
|
|
||||||
} else {
|
} else {
|
||||||
$season = new TVShow_Season($this->season);
|
if (Art::has_db($this->season, 'tvshow_season')) {
|
||||||
if (Art::has_db($season->tvshow, 'tvshow')) {
|
$id = $this->season;
|
||||||
$id = $season->tvshow;
|
$type = 'tvshow_season';
|
||||||
$type = 'tvshow';
|
} else {
|
||||||
|
$season = new TVShow_Season($this->season);
|
||||||
|
if (Art::has_db($season->tvshow, 'tvshow')) {
|
||||||
|
$id = $season->tvshow;
|
||||||
|
$type = 'tvshow';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,9 @@ class TVShow_Season extends database_object implements library_item
|
||||||
public function __construct($id='')
|
public function __construct($id='')
|
||||||
{
|
{
|
||||||
/* If they failed to pass in an id, just run for it */
|
/* 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 */
|
/* Get the information from the db */
|
||||||
$info = $this->get_info($id);
|
$info = $this->get_info($id);
|
||||||
|
@ -56,7 +58,6 @@ class TVShow_Season extends database_object implements library_item
|
||||||
} // foreach info
|
} // foreach info
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} //constructor
|
} //constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +96,6 @@ class TVShow_Season extends database_object implements library_item
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_episodes
|
} // get_episodes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +122,6 @@ class TVShow_Season extends database_object implements library_item
|
||||||
$this->catalog_id = $row['catalog_id'];
|
$this->catalog_id = $row['catalog_id'];
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
|
|
||||||
} // _get_extra_info
|
} // _get_extra_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,9 +235,11 @@ class TVShow_Season extends database_object implements library_item
|
||||||
if (Art::has_db($this->id, 'tvshow_season')) {
|
if (Art::has_db($this->id, 'tvshow_season')) {
|
||||||
$id = $this->id;
|
$id = $this->id;
|
||||||
$type = 'tvshow_season';
|
$type = 'tvshow_season';
|
||||||
} else if (Art::has_db($this->tvshow, 'tvshow')) {
|
} else {
|
||||||
$id = $this->tvshow;
|
if (Art::has_db($this->tvshow, 'tvshow')) {
|
||||||
$type = 'tvshow';
|
$id = $this->tvshow;
|
||||||
|
$type = 'tvshow';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id !== null && $type !== null) {
|
if ($id !== null && $type !== null) {
|
||||||
|
@ -298,7 +299,6 @@ class TVShow_Season extends database_object implements library_item
|
||||||
|
|
||||||
self::$_mapcache[$name]['null'] = $id;
|
self::$_mapcache[$name]['null'] = $id;
|
||||||
return $id;
|
return $id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -345,5 +345,5 @@ class TVShow_Season extends database_object implements library_item
|
||||||
$sql = "UPDATE `tvshow_season` SET `tvshow` = ? WHERE `id` = ?";
|
$sql = "UPDATE `tvshow_season` SET `tvshow` = ? WHERE `id` = ?";
|
||||||
return Dba::write($sql, array($tvshow_id, $season_id));
|
return Dba::write($sql, array($tvshow_id, $season_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of tvshow_season class
|
} // end of tvshow_season class
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ class Update
|
||||||
}
|
}
|
||||||
|
|
||||||
return $version;
|
return $version;
|
||||||
|
|
||||||
} // get_version
|
} // get_version
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -523,13 +522,16 @@ class Update
|
||||||
}
|
}
|
||||||
$update_needed = false;
|
$update_needed = false;
|
||||||
|
|
||||||
if (!defined('CLI')) { echo "<ul>\n"; }
|
if (!defined('CLI')) {
|
||||||
|
echo "<ul>\n";
|
||||||
|
}
|
||||||
|
|
||||||
foreach (self::$versions as $update) {
|
foreach (self::$versions as $update) {
|
||||||
|
|
||||||
if ($update['version'] > $current_version) {
|
if ($update['version'] > $current_version) {
|
||||||
$update_needed = true;
|
$update_needed = true;
|
||||||
if (!defined('CLI')) { echo '<li><b>'; }
|
if (!defined('CLI')) {
|
||||||
|
echo '<li><b>';
|
||||||
|
}
|
||||||
echo 'Version: ', self::format_version($update['version']);
|
echo 'Version: ', self::format_version($update['version']);
|
||||||
if (defined('CLI')) {
|
if (defined('CLI')) {
|
||||||
echo "\n", str_replace('<br />', "\n", $update['description']), "\n";
|
echo "\n", str_replace('<br />', "\n", $update['description']), "\n";
|
||||||
|
@ -537,13 +539,16 @@ class Update
|
||||||
echo '</b><br />', $update['description'], "<br /></li>\n";
|
echo '</b><br />', $update['description'], "<br /></li>\n";
|
||||||
}
|
}
|
||||||
} // if newer
|
} // if newer
|
||||||
|
|
||||||
} // foreach versions
|
} // foreach versions
|
||||||
|
|
||||||
if (!defined('CLI')) { echo "</ul>\n"; }
|
if (!defined('CLI')) {
|
||||||
|
echo "</ul>\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (!$update_needed) {
|
if (!$update_needed) {
|
||||||
if (!defined('CLI')) { echo '<p align="center">'; }
|
if (!defined('CLI')) {
|
||||||
|
echo '<p align="center">';
|
||||||
|
}
|
||||||
echo T_('No updates needed.');
|
echo T_('No updates needed.');
|
||||||
if (!defined('CLI')) {
|
if (!defined('CLI')) {
|
||||||
echo ' [<a href="', AmpConfig::get('web_path'), '">', T_('Return to main page'), '</a>]</p>';
|
echo ' [<a href="', AmpConfig::get('web_path'), '">', T_('Return to main page'), '</a>]</p>';
|
||||||
|
@ -602,9 +607,7 @@ class Update
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end foreach version
|
} // end foreach version
|
||||||
|
|
||||||
// Once we've run all of the updates let's re-sync the character set as
|
// Once we've run all of the updates let's re-sync the character set as
|
||||||
|
@ -2860,9 +2863,9 @@ class Update
|
||||||
{
|
{
|
||||||
$retval = true;
|
$retval = true;
|
||||||
|
|
||||||
$sql = "ALTER TABLE `video` ADD `release_date` date NULL AFTER `enabled`, " .
|
$sql = "ALTER TABLE `video` ADD `release_date` date NULL AFTER `enabled`, " .
|
||||||
"ADD `played` tinyint(1) unsigned DEFAULT '1' NOT NULL AFTER `enabled`";
|
"ADD `played` tinyint(1) unsigned DEFAULT '1' NOT NULL AFTER `enabled`";
|
||||||
$retval = Dba::write($sql) ? $retval : false;
|
$retval = Dba::write($sql) ? $retval : false;
|
||||||
|
|
||||||
$sql = "CREATE TABLE `tvshow` (" .
|
$sql = "CREATE TABLE `tvshow` (" .
|
||||||
"`id` int(11) unsigned NOT NULL AUTO_INCREMENT," .
|
"`id` int(11) unsigned NOT NULL AUTO_INCREMENT," .
|
||||||
|
|
|
@ -217,5 +217,5 @@ class Upload
|
||||||
|
|
||||||
return $rootdir;
|
return $rootdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Upload class
|
} // Upload class
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ class Upnp_Api
|
||||||
case 'SearchCriteria':
|
case 'SearchCriteria':
|
||||||
$reader->read();
|
$reader->read();
|
||||||
if ($reader->nodeType == XMLReader::TEXT) {
|
if ($reader->nodeType == XMLReader::TEXT) {
|
||||||
$retArr['searchcriteria'] = $reader->value;
|
$retArr['searchcriteria'] = $reader->value;
|
||||||
} # end if
|
} # end if
|
||||||
break;
|
break;
|
||||||
case 'SortCriteria':
|
case 'SortCriteria':
|
||||||
|
@ -600,8 +600,9 @@ class Upnp_Api
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($maxCount == 0)
|
if ($maxCount == 0) {
|
||||||
$maxCount = count($mediaItems);
|
$maxCount = count($mediaItems);
|
||||||
|
}
|
||||||
return array($maxCount, $mediaItems);
|
return array($maxCount, $mediaItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -840,8 +841,9 @@ class Upnp_Api
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($maxCount == 0)
|
if ($maxCount == 0) {
|
||||||
$maxCount = count($mediaItems);
|
$maxCount = count($mediaItems);
|
||||||
|
}
|
||||||
return array($maxCount, $mediaItems);
|
return array($maxCount, $mediaItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -858,8 +860,9 @@ class Upnp_Api
|
||||||
$title = preg_replace('~[^\\pL\d\.\s\(\)\.\,\'\"]+~u', '-', $title);
|
$title = preg_replace('~[^\\pL\d\.\s\(\)\.\,\'\"]+~u', '-', $title);
|
||||||
///debug_event('upnp_class', 'replace >>> ' . $title, 5);
|
///debug_event('upnp_class', 'replace >>> ' . $title, 5);
|
||||||
|
|
||||||
if ($title == "")
|
if ($title == "") {
|
||||||
$title = '(no title)';
|
$title = '(no title)';
|
||||||
|
}
|
||||||
|
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,9 @@ class User extends database_object
|
||||||
*/
|
*/
|
||||||
public function __construct($user_id=0)
|
public function __construct($user_id=0)
|
||||||
{
|
{
|
||||||
if (!$user_id) { return false; }
|
if (!$user_id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->id = intval($user_id);
|
$this->id = intval($user_id);
|
||||||
|
|
||||||
|
@ -155,13 +157,16 @@ class User extends database_object
|
||||||
|
|
||||||
foreach ($info as $key=>$value) {
|
foreach ($info as $key=>$value) {
|
||||||
// Let's not save the password in this object :S
|
// Let's not save the password in this object :S
|
||||||
if ($key == 'password') { continue; }
|
if ($key == 'password') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the Full name is always filled
|
// Make sure the Full name is always filled
|
||||||
if (strlen($this->fullname) < 1) { $this->fullname = $this->username; }
|
if (strlen($this->fullname) < 1) {
|
||||||
|
$this->fullname = $this->username;
|
||||||
|
}
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,7 +222,6 @@ class User extends database_object
|
||||||
parent::add_to_cache('user',$id,$data);
|
parent::add_to_cache('user',$id,$data);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
} // _get_info
|
} // _get_info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,7 +235,6 @@ class User extends database_object
|
||||||
$session_id = session_id();
|
$session_id = session_id();
|
||||||
|
|
||||||
$this->playlist = Tmp_Playlist::get_from_session($session_id);
|
$this->playlist = Tmp_Playlist::get_from_session($session_id);
|
||||||
|
|
||||||
} // load_playlist
|
} // load_playlist
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -265,7 +268,6 @@ class User extends database_object
|
||||||
$user = new User($results['id']);
|
$user = new User($results['id']);
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
|
||||||
} // get_from_username
|
} // get_from_username
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -288,7 +290,6 @@ class User extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
|
||||||
} // get_from_apikey
|
} // get_from_apikey
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -306,7 +307,6 @@ class User extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
|
||||||
} // get_from_email
|
} // get_from_email
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -323,7 +323,6 @@ class User extends database_object
|
||||||
$users[] = $results['id'];
|
$users[] = $results['id'];
|
||||||
}
|
}
|
||||||
return $users;
|
return $users;
|
||||||
|
|
||||||
} // get_from_website
|
} // get_from_website
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,7 +346,6 @@ class User extends database_object
|
||||||
parent::add_to_cache('user_catalog',$this->id,$catalogs);
|
parent::add_to_cache('user_catalog',$this->id,$catalogs);
|
||||||
|
|
||||||
return $catalogs;
|
return $catalogs;
|
||||||
|
|
||||||
} // get_catalogs
|
} // get_catalogs
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -367,8 +365,10 @@ class User extends database_object
|
||||||
$user_limit = "";
|
$user_limit = "";
|
||||||
if (!$system) {
|
if (!$system) {
|
||||||
$user_limit = "AND preference.catagory != 'system'";
|
$user_limit = "AND preference.catagory != 'system'";
|
||||||
} else if ($type != '0') {
|
} else {
|
||||||
$user_limit = "AND preference.catagory = '" . Dba::escape($type) . "'";
|
if ($type != '0') {
|
||||||
|
$user_limit = "AND preference.catagory = '" . Dba::escape($type) . "'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -384,13 +384,14 @@ class User extends database_object
|
||||||
while ($r = Dba::fetch_assoc($db_results)) {
|
while ($r = Dba::fetch_assoc($db_results)) {
|
||||||
$type = $r['catagory'];
|
$type = $r['catagory'];
|
||||||
$admin = false;
|
$admin = false;
|
||||||
if ($type == 'system') { $admin = true; }
|
if ($type == 'system') {
|
||||||
|
$admin = true;
|
||||||
|
}
|
||||||
$type_array[$type][$r['name']] = array('name'=>$r['name'],'level'=>$r['level'],'description'=>$r['description'],'value'=>$r['value']);
|
$type_array[$type][$r['name']] = array('name'=>$r['name'],'level'=>$r['level'],'description'=>$r['description'],'value'=>$r['value']);
|
||||||
$results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]);
|
$results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]);
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_preferences
|
} // get_preferences
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -453,11 +454,9 @@ class User extends database_object
|
||||||
$data->f_name = $data->f_link;
|
$data->f_name = $data->f_link;
|
||||||
$items[] = $data;
|
$items[] = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
|
|
||||||
} // get_favorites
|
} // get_favorites
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -490,7 +489,6 @@ class User extends database_object
|
||||||
$key = $user_info['user'];
|
$key = $user_info['user'];
|
||||||
$users[$key]++;
|
$users[$key]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
/* now we've got your ratings, and all users and the # of ratings that match your ratings
|
/* now we've got your ratings, and all users and the # of ratings that match your ratings
|
||||||
|
@ -510,20 +508,20 @@ class User extends database_object
|
||||||
|
|
||||||
while ($r = Dba::fetch_assoc($db_results)) {
|
while ($r = Dba::fetch_assoc($db_results)) {
|
||||||
$key = $r['object_id'];
|
$key = $r['object_id'];
|
||||||
if (isset($ratings[$key])) { continue; }
|
if (isset($ratings[$key])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Let's only get 5 total for now */
|
/* Let's only get 5 total for now */
|
||||||
if (count($recommendations) > 5) { return $recommendations; }
|
if (count($recommendations) > 5) {
|
||||||
|
return $recommendations;
|
||||||
|
}
|
||||||
|
|
||||||
$recommendations[$key] = $r['user_rating'];
|
$recommendations[$key] = $r['user_rating'];
|
||||||
|
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
|
|
||||||
} // end foreach users
|
} // end foreach users
|
||||||
|
|
||||||
return $recommendations;
|
return $recommendations;
|
||||||
|
|
||||||
} // get_recommendations
|
} // get_recommendations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -545,7 +543,6 @@ class User extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // is_logged_in
|
} // is_logged_in
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -555,12 +552,15 @@ class User extends database_object
|
||||||
*/
|
*/
|
||||||
public function has_access($needed_level)
|
public function has_access($needed_level)
|
||||||
{
|
{
|
||||||
if (AmpConfig::get('demo_mode')) { return true; }
|
if (AmpConfig::get('demo_mode')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->access >= $needed_level) { return true; }
|
if ($this->access >= $needed_level) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // has_access
|
} // has_access
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -570,9 +570,13 @@ class User extends database_object
|
||||||
*/
|
*/
|
||||||
public static function is_registered()
|
public static function is_registered()
|
||||||
{
|
{
|
||||||
if (!$GLOBALS['user']->id) return false;
|
if (!$GLOBALS['user']->id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!AmpConfig::get('use_auth') && $GLOBALS['user']->access <= 5) return false;
|
if (!AmpConfig::get('use_auth') && $GLOBALS['user']->access <= 5) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -644,7 +648,6 @@ class User extends database_object
|
||||||
$sql = "UPDATE `user` SET `username` = ? WHERE `id` = ?";
|
$sql = "UPDATE `user` SET `username` = ? WHERE `id` = ?";
|
||||||
$this->username = $new_username;
|
$this->username = $new_username;
|
||||||
Dba::write($sql, array($new_username, $this->id));
|
Dba::write($sql, array($new_username, $this->id));
|
||||||
|
|
||||||
} // update_username
|
} // update_username
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -660,7 +663,6 @@ class User extends database_object
|
||||||
$this->validation = $new_validation;
|
$this->validation = $new_validation;
|
||||||
|
|
||||||
return $db_results;
|
return $db_results;
|
||||||
|
|
||||||
} // update_validation
|
} // update_validation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -671,7 +673,6 @@ class User extends database_object
|
||||||
{
|
{
|
||||||
$sql = "UPDATE `user` SET `fullname` = ? WHERE `id` = ?";
|
$sql = "UPDATE `user` SET `fullname` = ? WHERE `id` = ?";
|
||||||
Dba::write($sql, array($new_fullname, $this->id));
|
Dba::write($sql, array($new_fullname, $this->id));
|
||||||
|
|
||||||
} // update_fullname
|
} // update_fullname
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -682,7 +683,6 @@ class User extends database_object
|
||||||
{
|
{
|
||||||
$sql = "UPDATE `user` SET `fullname_public` = ? WHERE `id` = ?";
|
$sql = "UPDATE `user` SET `fullname_public` = ? WHERE `id` = ?";
|
||||||
Dba::write($sql, array($new_fullname_public ? '1' : '0', $this->id));
|
Dba::write($sql, array($new_fullname_public ? '1' : '0', $this->id));
|
||||||
|
|
||||||
} // update_fullname_public
|
} // update_fullname_public
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -693,7 +693,6 @@ class User extends database_object
|
||||||
{
|
{
|
||||||
$sql = "UPDATE `user` SET `email` = ? WHERE `id` = ?";
|
$sql = "UPDATE `user` SET `email` = ? WHERE `id` = ?";
|
||||||
Dba::write($sql, array($new_email, $this->id));
|
Dba::write($sql, array($new_email, $this->id));
|
||||||
|
|
||||||
} // update_email
|
} // update_email
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -705,7 +704,6 @@ class User extends database_object
|
||||||
$new_website = rtrim($new_website, "/");
|
$new_website = rtrim($new_website, "/");
|
||||||
$sql = "UPDATE `user` SET `website` = ? WHERE `id` = ?";
|
$sql = "UPDATE `user` SET `website` = ? WHERE `id` = ?";
|
||||||
Dba::write($sql, array($new_website, $this->id));
|
Dba::write($sql, array($new_website, $this->id));
|
||||||
|
|
||||||
} // update_website
|
} // update_website
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -736,7 +734,6 @@ class User extends database_object
|
||||||
{
|
{
|
||||||
$sql = "UPDATE `user` SET `apikey` = ? WHERE `id` = ?";
|
$sql = "UPDATE `user` SET `apikey` = ? WHERE `id` = ?";
|
||||||
Dba::write($sql, array($new_apikey, $this->id));
|
Dba::write($sql, array($new_apikey, $this->id));
|
||||||
|
|
||||||
} // update_website
|
} // update_website
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -772,7 +769,9 @@ class User extends database_object
|
||||||
$sql = "SELECT `id` FROM `user` WHERE `disabled` = '0' AND `id` != '" . $this->id . "' AND `access`='100'";
|
$sql = "SELECT `id` FROM `user` WHERE `disabled` = '0' AND `id` != '" . $this->id . "' AND `access`='100'";
|
||||||
$db_results = Dba::read($sql);
|
$db_results = Dba::read($sql);
|
||||||
|
|
||||||
if (!Dba::num_rows($db_results)) { return false; }
|
if (!Dba::num_rows($db_results)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "UPDATE `user` SET `disabled`='1' WHERE id='" . $this->id . "'";
|
$sql = "UPDATE `user` SET `disabled`='1' WHERE id='" . $this->id . "'";
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
@ -782,7 +781,6 @@ class User extends database_object
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // disable
|
} // disable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -795,7 +793,6 @@ class User extends database_object
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // enable
|
} // enable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -808,13 +805,14 @@ class User extends database_object
|
||||||
if ($new_access < '100') {
|
if ($new_access < '100') {
|
||||||
$sql = "SELECT `id` FROM user WHERE `access`='100' AND `id` != '$this->id'";
|
$sql = "SELECT `id` FROM user WHERE `access`='100' AND `id` != '$this->id'";
|
||||||
$db_results = Dba::read($sql);
|
$db_results = Dba::read($sql);
|
||||||
if (!Dba::num_rows($db_results)) { return false; }
|
if (!Dba::num_rows($db_results)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_access = Dba::escape($new_access);
|
$new_access = Dba::escape($new_access);
|
||||||
$sql = "UPDATE `user` SET `access`='$new_access' WHERE `id`='$this->id'";
|
$sql = "UPDATE `user` SET `access`='$new_access' WHERE `id`='$this->id'";
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
} // update_access
|
} // update_access
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -825,7 +823,6 @@ class User extends database_object
|
||||||
{
|
{
|
||||||
$sql = "UPDATE user SET last_seen='" . time() . "' WHERE `id`='$this->id'";
|
$sql = "UPDATE user SET last_seen='" . time() . "' WHERE `id`='$this->id'";
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
|
|
||||||
} // update_last_seen
|
} // update_last_seen
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -840,7 +837,9 @@ class User extends database_object
|
||||||
$user = $this->id;
|
$user = $this->id;
|
||||||
|
|
||||||
// We shouldn't test on file only
|
// We shouldn't test on file only
|
||||||
if (!strlen($media->file)) { return false; }
|
if (!strlen($media->file)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$noscrobble) {
|
if (!$noscrobble) {
|
||||||
$this->set_preferences();
|
$this->set_preferences();
|
||||||
|
@ -863,7 +862,6 @@ class User extends database_object
|
||||||
$media->set_played($user, $agent, $location);
|
$media->set_played($user, $agent, $location);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // update_stats
|
} // update_stats
|
||||||
|
|
||||||
public static function save_mediaplay($user, $media)
|
public static function save_mediaplay($user, $media)
|
||||||
|
@ -911,7 +909,6 @@ class User extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // insert_ip_history
|
} // insert_ip_history
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -957,7 +954,9 @@ class User extends database_object
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
$db_results = Dba::write($sql, $params);
|
$db_results = Dba::write($sql, $params);
|
||||||
|
|
||||||
if (!$db_results) { return false; }
|
if (!$db_results) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the insert_id
|
// Get the insert_id
|
||||||
$insert_id = Dba::insert_id();
|
$insert_id = Dba::insert_id();
|
||||||
|
@ -966,7 +965,6 @@ class User extends database_object
|
||||||
self::fix_preferences($insert_id);
|
self::fix_preferences($insert_id);
|
||||||
|
|
||||||
return $insert_id;
|
return $insert_id;
|
||||||
|
|
||||||
} // create
|
} // create
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -982,8 +980,9 @@ class User extends database_object
|
||||||
$db_results = Dba::write($sql, array($new_password, $this->id));
|
$db_results = Dba::write($sql, array($new_password, $this->id));
|
||||||
|
|
||||||
// Clear this (temp fix)
|
// Clear this (temp fix)
|
||||||
if ($db_results) { unset($_SESSION['userdata']['password']); }
|
if ($db_results) {
|
||||||
|
unset($_SESSION['userdata']['password']);
|
||||||
|
}
|
||||||
} // update_password
|
} // update_password
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -995,10 +994,18 @@ class User extends database_object
|
||||||
public function format($details = true)
|
public function format($details = true)
|
||||||
{
|
{
|
||||||
/* If they have a last seen date */
|
/* If they have a last seen date */
|
||||||
if (!$this->last_seen) { $this->f_last_seen = T_('Never'); } else { $this->f_last_seen = date("m\/d\/Y - H:i",$this->last_seen); }
|
if (!$this->last_seen) {
|
||||||
|
$this->f_last_seen = T_('Never');
|
||||||
|
} else {
|
||||||
|
$this->f_last_seen = date("m\/d\/Y - H:i",$this->last_seen);
|
||||||
|
}
|
||||||
|
|
||||||
/* If they have a create date */
|
/* If they have a create date */
|
||||||
if (!$this->create_date) { $this->f_create_date = T_('Unknown'); } else { $this->f_create_date = date("m\/d\/Y - H:i",$this->create_date); }
|
if (!$this->create_date) {
|
||||||
|
$this->f_create_date = T_('Unknown');
|
||||||
|
} else {
|
||||||
|
$this->f_create_date = date("m\/d\/Y - H:i",$this->create_date);
|
||||||
|
}
|
||||||
|
|
||||||
$this->f_name = ($this->fullname_public ? $this->fullname : $this->username);
|
$this->f_name = ($this->fullname_public ? $this->fullname : $this->username);
|
||||||
|
|
||||||
|
@ -1037,7 +1044,6 @@ class User extends database_object
|
||||||
if (!empty($avatar['url_medium'])) {
|
if (!empty($avatar['url_medium'])) {
|
||||||
$this->f_avatar_medium = '<img src="' . $avatar['url_medium'] . '" title="' . $avatar['title'] . '" style="width: 64px; height: 64px;" />';
|
$this->f_avatar_medium = '<img src="' . $avatar['url_medium'] . '" title="' . $avatar['title'] . '" style="width: 64px; height: 64px;" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
} // format_user
|
} // format_user
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1058,7 +1064,6 @@ class User extends database_object
|
||||||
default:
|
default:
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
} // access_name_to_level
|
} // access_name_to_level
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1115,7 +1120,6 @@ class User extends database_object
|
||||||
$db_results = Dba::read($sql);
|
$db_results = Dba::read($sql);
|
||||||
|
|
||||||
while ($r = Dba::fetch_assoc($db_results)) {
|
while ($r = Dba::fetch_assoc($db_results)) {
|
||||||
|
|
||||||
$key = $r['id'];
|
$key = $r['id'];
|
||||||
|
|
||||||
/* Check if this preference is set */
|
/* Check if this preference is set */
|
||||||
|
@ -1128,7 +1132,6 @@ class User extends database_object
|
||||||
Dba::write($sql);
|
Dba::write($sql);
|
||||||
}
|
}
|
||||||
} // while preferences
|
} // while preferences
|
||||||
|
|
||||||
} // fix_preferences
|
} // fix_preferences
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1212,7 +1215,6 @@ class User extends database_object
|
||||||
Dba::write($sql, array($this->username));
|
Dba::write($sql, array($this->username));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // delete
|
} // delete
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1224,7 +1226,6 @@ class User extends database_object
|
||||||
public function is_online( $delay = 1200 )
|
public function is_online( $delay = 1200 )
|
||||||
{
|
{
|
||||||
return time() - $this->last_seen <= $delay;
|
return time() - $this->last_seen <= $delay;
|
||||||
|
|
||||||
} // is_online
|
} // is_online
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1239,7 +1240,6 @@ class User extends database_object
|
||||||
$row = Dba::fetch_assoc($db_results);
|
$row = Dba::fetch_assoc($db_results);
|
||||||
|
|
||||||
return $row['validation'];
|
return $row['validation'];
|
||||||
|
|
||||||
} // get_validation
|
} // get_validation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1249,7 +1249,9 @@ class User extends database_object
|
||||||
*/
|
*/
|
||||||
public function get_recently_played($limit,$type='')
|
public function get_recently_played($limit,$type='')
|
||||||
{
|
{
|
||||||
if (!$type) { $type = 'song'; }
|
if (!$type) {
|
||||||
|
$type = 'song';
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM `object_count` WHERE `object_type` = ? AND `user` = ? " .
|
$sql = "SELECT * FROM `object_count` WHERE `object_type` = ? AND `user` = ? " .
|
||||||
"ORDER BY `date` DESC LIMIT " . $limit;
|
"ORDER BY `date` DESC LIMIT " . $limit;
|
||||||
|
@ -1261,7 +1263,6 @@ class User extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_recently_played
|
} // get_recently_played
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1275,11 +1276,15 @@ class User extends database_object
|
||||||
$count = $count ? intval($count) : intval(AmpConfig::get('user_ip_cardinality'));
|
$count = $count ? intval($count) : intval(AmpConfig::get('user_ip_cardinality'));
|
||||||
|
|
||||||
// Make sure it's something
|
// Make sure it's something
|
||||||
if ($count < 1) { $count = '1'; }
|
if ($count < 1) {
|
||||||
|
$count = '1';
|
||||||
|
}
|
||||||
$limit_sql = "LIMIT " . intval($count);
|
$limit_sql = "LIMIT " . intval($count);
|
||||||
|
|
||||||
$group_sql = "";
|
$group_sql = "";
|
||||||
if ($distinct) { $group_sql = "GROUP BY `ip`"; }
|
if ($distinct) {
|
||||||
|
$group_sql = "GROUP BY `ip`";
|
||||||
|
}
|
||||||
|
|
||||||
/* Select ip history */
|
/* Select ip history */
|
||||||
$sql = "SELECT `ip`,`date` FROM `ip_history`" .
|
$sql = "SELECT `ip`,`date` FROM `ip_history`" .
|
||||||
|
@ -1294,7 +1299,6 @@ class User extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_ip_history
|
} // get_ip_history
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1364,7 +1368,6 @@ class User extends database_object
|
||||||
|
|
||||||
$sql = "UPDATE `user` SET `disabled`='0' WHERE `username` = ?";
|
$sql = "UPDATE `user` SET `disabled`='0' WHERE `username` = ?";
|
||||||
Dba::write($sql, array($username));
|
Dba::write($sql, array($username));
|
||||||
|
|
||||||
} // activate_user
|
} // activate_user
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1399,7 +1402,6 @@ class User extends database_object
|
||||||
//FIXME: combined with the song title to make sure that the REFERER
|
//FIXME: combined with the song title to make sure that the REFERER
|
||||||
//FIXME: is in the access list with full rights
|
//FIXME: is in the access list with full rights
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // is_xmlrpc
|
} // is_xmlrpc
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1467,8 +1469,9 @@ class User extends database_object
|
||||||
*/
|
*/
|
||||||
public function toggle_follow($user_id)
|
public function toggle_follow($user_id)
|
||||||
{
|
{
|
||||||
if (!$user_id || $user_id === $this->id)
|
if (!$user_id || $user_id === $this->id) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$params = array($this->id, $user_id);
|
$params = array($this->id, $user_id);
|
||||||
if ($this->is_following($user_id)) {
|
if ($this->is_following($user_id)) {
|
||||||
|
@ -1493,8 +1496,9 @@ class User extends database_object
|
||||||
$user_id = $GLOBALS['user']->id;
|
$user_id = $GLOBALS['user']->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user_id === $this->id)
|
if ($user_id === $this->id) {
|
||||||
return "";
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
$followed = $this->is_followed_by($user_id);
|
$followed = $this->is_followed_by($user_id);
|
||||||
|
|
||||||
|
@ -1521,7 +1525,6 @@ class User extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // check_username
|
} // check_username
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1547,7 +1550,6 @@ class User extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // rebuild_all_preferences
|
} // rebuild_all_preferences
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1574,5 +1576,5 @@ class User extends database_object
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end user class
|
} //end user class
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ class Userflag extends database_object
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +52,9 @@ class Userflag extends database_object
|
||||||
*/
|
*/
|
||||||
public static function build_cache($type, $ids, $user_id = null)
|
public static function build_cache($type, $ids, $user_id = null)
|
||||||
{
|
{
|
||||||
if (!is_array($ids) OR !count($ids)) { return false; }
|
if (!is_array($ids) OR !count($ids)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_null($user_id)) {
|
if (is_null($user_id)) {
|
||||||
$user_id = $GLOBALS['user']->id;
|
$user_id = $GLOBALS['user']->id;
|
||||||
|
@ -81,7 +82,6 @@ class Userflag extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // build_cache
|
} // build_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -129,7 +129,6 @@ class Userflag extends database_object
|
||||||
|
|
||||||
parent::add_to_cache($key, $this->id, $flagged);
|
parent::add_to_cache($key, $this->id, $flagged);
|
||||||
return $flagged;
|
return $flagged;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +162,6 @@ class Userflag extends database_object
|
||||||
parent::add_to_cache('userflag_' . $this->type . '_user' . $user_id, $this->id, $flagged);
|
parent::add_to_cache('userflag_' . $this->type . '_user' . $user_id, $this->id, $flagged);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // set_flag
|
} // set_flag
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,7 +231,6 @@ class Userflag extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_latest
|
} // get_latest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,11 +241,12 @@ class Userflag extends database_object
|
||||||
public static function show($object_id, $type)
|
public static function show($object_id, $type)
|
||||||
{
|
{
|
||||||
// If user flags aren't enabled don't do anything
|
// If user flags aren't enabled don't do anything
|
||||||
if (!AmpConfig::get('userflags')) { return false; }
|
if (!AmpConfig::get('userflags')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$userflag = new Userflag($object_id, $type);
|
$userflag = new Userflag($object_id, $type);
|
||||||
require AmpConfig::get('prefix') . '/templates/show_object_userflag.inc.php';
|
require AmpConfig::get('prefix') . '/templates/show_object_userflag.inc.php';
|
||||||
|
|
||||||
} // show
|
} // show
|
||||||
|
|
||||||
} //end rating class
|
} //end rating class
|
||||||
|
|
||||||
|
|
|
@ -152,22 +152,26 @@ class vainfo
|
||||||
*/
|
*/
|
||||||
private static function _detect_encoding($tags, $mb_order)
|
private static function _detect_encoding($tags, $mb_order)
|
||||||
{
|
{
|
||||||
if (!function_exists('mb_detect_encoding'))
|
if (!function_exists('mb_detect_encoding')) {
|
||||||
return 'ISO-8859-1';
|
return 'ISO-8859-1';
|
||||||
|
}
|
||||||
|
|
||||||
$encodings = array();
|
$encodings = array();
|
||||||
if (is_array($tags)) {
|
if (is_array($tags)) {
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (is_array($tag))
|
if (is_array($tag)) {
|
||||||
$tag = implode(" ", $tag);
|
$tag = implode(" ", $tag);
|
||||||
|
}
|
||||||
$enc = mb_detect_encoding($tag, $mb_order, true);
|
$enc = mb_detect_encoding($tag, $mb_order, true);
|
||||||
if ($enc != false)
|
if ($enc != false) {
|
||||||
$encodings[$enc]++;
|
$encodings[$enc]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$enc = mb_detect_encoding($tags, $mb_order, true);
|
$enc = mb_detect_encoding($tags, $mb_order, true);
|
||||||
if ($enc != false)
|
if ($enc != false) {
|
||||||
$encodings[$enc]++;
|
$encodings[$enc]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//!!debug_event('vainfo', 'encoding detection: ' . json_encode($encodings), 5);
|
//!!debug_event('vainfo', 'encoding detection: ' . json_encode($encodings), 5);
|
||||||
|
@ -1248,3 +1252,4 @@ class vainfo
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
} // end class vainfo
|
} // end class vainfo
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,6 @@ class Video extends database_object implements media, library_item
|
||||||
$this->type = strtolower($data['extension']);
|
$this->type = strtolower($data['extension']);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,7 +227,9 @@ class Video extends database_object implements media, library_item
|
||||||
*/
|
*/
|
||||||
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) . ')';
|
||||||
|
|
||||||
|
@ -238,7 +239,6 @@ class Video extends database_object implements media, library_item
|
||||||
while ($row = Dba::fetch_assoc($db_results)) {
|
while ($row = Dba::fetch_assoc($db_results)) {
|
||||||
parent::add_to_cache('video',$row['id'],$row);
|
parent::add_to_cache('video',$row['id'],$row);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // build_cache
|
} // build_cache
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -285,7 +285,6 @@ class Video extends database_object implements media, library_item
|
||||||
if ($this->release_date) {
|
if ($this->release_date) {
|
||||||
$this->f_release_date = date('Y-m-d', $this->release_date);
|
$this->f_release_date = date('Y-m-d', $this->release_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // format
|
} // format
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -474,8 +473,9 @@ class Video extends database_object implements media, library_item
|
||||||
{
|
{
|
||||||
$dtypes = self::get_derived_types();
|
$dtypes = self::get_derived_types();
|
||||||
foreach ($dtypes as $dtype) {
|
foreach ($dtypes as $dtype) {
|
||||||
if (strtolower($type) == strtolower($dtype))
|
if (strtolower($type) == strtolower($dtype)) {
|
||||||
return $type;
|
return $type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Video';
|
return 'Video';
|
||||||
|
@ -631,7 +631,6 @@ class Video extends database_object implements media, library_item
|
||||||
$this->release_date = $release_date;
|
$this->release_date = $release_date;
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
|
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -715,7 +714,6 @@ class Video extends database_object implements media, library_item
|
||||||
Video::update_played(true, $this->id);
|
Video::update_played(true, $this->id);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // set_played
|
} // set_played
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1001,7 +999,6 @@ class Video extends database_object implements media, library_item
|
||||||
public static function update_played($new_played, $song_id)
|
public static function update_played($new_played, $song_id)
|
||||||
{
|
{
|
||||||
self::_update_item('played', ($new_played ? 1 : 0),$song_id,'25');
|
self::_update_item('played', ($new_played ? 1 : 0),$song_id,'25');
|
||||||
|
|
||||||
} // update_played
|
} // update_played
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1019,16 +1016,19 @@ class Video extends database_object implements media, library_item
|
||||||
private static function _update_item($field, $value, $song_id, $level)
|
private static function _update_item($field, $value, $song_id, $level)
|
||||||
{
|
{
|
||||||
/* Check them Rights! */
|
/* Check them Rights! */
|
||||||
if (!Access::check('interface',$level)) { return false; }
|
if (!Access::check('interface',$level)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Can't update to blank */
|
/* Can't update to blank */
|
||||||
if (!strlen(trim($value))) { return false; }
|
if (!strlen(trim($value))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "UPDATE `video` SET `$field` = ? WHERE `id` = ?";
|
$sql = "UPDATE `video` SET `$field` = ? WHERE `id` = ?";
|
||||||
Dba::write($sql, array($value, $song_id));
|
Dba::write($sql, array($value, $song_id));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // _update_item
|
} // _update_item
|
||||||
|
|
||||||
} // end Video class
|
} // end Video class
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,9 @@ class Wanted extends database_object
|
||||||
*/
|
*/
|
||||||
public function __construct($id=0)
|
public function __construct($id=0)
|
||||||
{
|
{
|
||||||
if (!$id) { return true; }
|
if (!$id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the information from the db */
|
/* Get the information from the db */
|
||||||
$info = $this->get_info($id);
|
$info = $this->get_info($id);
|
||||||
|
@ -372,7 +374,6 @@ class Wanted extends database_object
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -467,8 +468,9 @@ class Wanted extends database_object
|
||||||
$plugin = new Plugin($plugin_name);
|
$plugin = new Plugin($plugin_name);
|
||||||
if ($plugin->load($GLOBALS['user'])) {
|
if ($plugin->load($GLOBALS['user'])) {
|
||||||
$song['file'] = $plugin->_plugin->get_song_preview($track['id'], $artist_name, $track['title']);
|
$song['file'] = $plugin->_plugin->get_song_preview($track['id'], $artist_name, $track['title']);
|
||||||
if ($song['file'] != null)
|
if ($song['file'] != null) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +509,6 @@ class Wanted extends database_object
|
||||||
$user = new User($this->user);
|
$user = new User($this->user);
|
||||||
$user->format();
|
$user->format();
|
||||||
$this->f_user = $user->f_name;
|
$this->f_user = $user->f_name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -541,5 +542,5 @@ class Wanted extends database_object
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of recommendation class
|
} // end of recommendation class
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ class Waveform
|
||||||
{
|
{
|
||||||
// Static
|
// Static
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // Constructor
|
} // Constructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,7 +160,7 @@ class Waveform
|
||||||
hexdec(substr($input, 2, 2)),
|
hexdec(substr($input, 2, 2)),
|
||||||
hexdec(substr($input, 4, 2))
|
hexdec(substr($input, 4, 2))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create waveform from song file.
|
* Create waveform from song file.
|
||||||
|
@ -222,32 +221,35 @@ class Waveform
|
||||||
|
|
||||||
// fill background of image
|
// fill background of image
|
||||||
if ($background == "") {
|
if ($background == "") {
|
||||||
// transparent background specified
|
// transparent background specified
|
||||||
imagesavealpha($img, true);
|
imagesavealpha($img, true);
|
||||||
$transparentColor = imagecolorallocatealpha($img, 0, 0, 0, 127);
|
$transparentColor = imagecolorallocatealpha($img, 0, 0, 0, 127);
|
||||||
imagefill($img, 0, 0, $transparentColor);
|
imagefill($img, 0, 0, $transparentColor);
|
||||||
} else {
|
} else {
|
||||||
list($br, $bg, $bb) = self::html2rgb($background);
|
list($br, $bg, $bb) = self::html2rgb($background);
|
||||||
imagefilledrectangle($img, 0, 0, (int) ($data_size / $detail), $height, imagecolorallocate($img, $br, $bg, $bb));
|
imagefilledrectangle($img, 0, 0, (int) ($data_size / $detail), $height, imagecolorallocate($img, $br, $bg, $bb));
|
||||||
} while (!feof($handle) && $data_point < $data_size) {
|
}
|
||||||
|
while (!feof($handle) && $data_point < $data_size) {
|
||||||
if ($data_point++ % $detail == 0) {
|
if ($data_point++ % $detail == 0) {
|
||||||
$bytes = array();
|
$bytes = array();
|
||||||
|
|
||||||
// get number of bytes depending on bitrate
|
// get number of bytes depending on bitrate
|
||||||
for ($i = 0; $i < $byte; $i++)
|
for ($i = 0; $i < $byte; $i++) {
|
||||||
$bytes[$i] = fgetc($handle);
|
$bytes[$i] = fgetc($handle);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($byte) {
|
switch ($byte) {
|
||||||
// get value for 8-bit wav
|
// get value for 8-bit wav
|
||||||
case 1:
|
case 1:
|
||||||
$data = self::findValues($bytes[0], $bytes[1]);
|
$data = self::findValues($bytes[0], $bytes[1]);
|
||||||
break;
|
break;
|
||||||
// get value for 16-bit wav
|
// get value for 16-bit wav
|
||||||
case 2:
|
case 2:
|
||||||
if(ord($bytes[1]) & 128)
|
if (ord($bytes[1]) & 128) {
|
||||||
$temp = 0;
|
$temp = 0;
|
||||||
else
|
} else {
|
||||||
$temp = 128;
|
$temp = 128;
|
||||||
|
}
|
||||||
$temp = chr((ord($bytes[1]) & 127) + $temp);
|
$temp = chr((ord($bytes[1]) & 127) + $temp);
|
||||||
$data = floor(self::findValues($bytes[0], $temp) / 256);
|
$data = floor(self::findValues($bytes[0], $temp) / 256);
|
||||||
break;
|
break;
|
||||||
|
@ -265,8 +267,8 @@ class Waveform
|
||||||
$v = (int) ($data / 255 * $height);
|
$v = (int) ($data / 255 * $height);
|
||||||
|
|
||||||
// don't print flat values on the canvas if not necessary
|
// don't print flat values on the canvas if not necessary
|
||||||
if (!($v / $height == 0.5 && !$draw_flat))
|
if (!($v / $height == 0.5 && !$draw_flat)) {
|
||||||
// draw the line on the image using the $v value and centering it vertically on the canvas
|
// draw the line on the image using the $v value and centering it vertically on the canvas
|
||||||
imageline(
|
imageline(
|
||||||
$img,
|
$img,
|
||||||
// x1
|
// x1
|
||||||
|
@ -279,9 +281,9 @@ class Waveform
|
||||||
$height - ($height - $v),
|
$height - ($height - $v),
|
||||||
imagecolorallocate($img, $r, $g, $b)
|
imagecolorallocate($img, $r, $g, $b)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// skip this one due to lack of detail
|
// skip this one due to lack of detail
|
||||||
fseek($handle, $ratio + $byte, SEEK_CUR);
|
fseek($handle, $ratio + $byte, SEEK_CUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,5 +324,5 @@ class Waveform
|
||||||
$sql = "UPDATE `song_data` SET `waveform` = ? WHERE `song_id` = ?";
|
$sql = "UPDATE `song_data` SET `waveform` = ? WHERE `song_id` = ?";
|
||||||
return Dba::write($sql, array($waveform, $song_id));
|
return Dba::write($sql, array($waveform, $song_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Waveform class
|
} // Waveform class
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,9 @@ class WebDAV_Catalog extends DAV\Collection
|
||||||
debug_event('webdav', 'Found ' . count($matches) . ' childs.', 5);
|
debug_event('webdav', 'Found ' . count($matches) . ' childs.', 5);
|
||||||
// Always return first match
|
// Always return first match
|
||||||
// Warning: this means that two items with the same name will not be supported for now
|
// Warning: this means that two items with the same name will not be supported for now
|
||||||
if (count($matches) > 0)
|
if (count($matches) > 0) {
|
||||||
return WebDAV_Directory::getChildFromArray($matches[0]);
|
return WebDAV_Directory::getChildFromArray($matches[0]);
|
||||||
|
}
|
||||||
|
|
||||||
throw new DAV\Exception\NotFound('The artist with name: ' . $name . ' could not be found');
|
throw new DAV\Exception\NotFound('The artist with name: ' . $name . ' could not be found');
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,12 @@ class WebDAV_Directory extends DAV\Collection
|
||||||
$matches = $this->libitem->search_childrens($name);
|
$matches = $this->libitem->search_childrens($name);
|
||||||
// Always return first match
|
// Always return first match
|
||||||
// Warning: this means that two items with the same name will not be supported for now
|
// Warning: this means that two items with the same name will not be supported for now
|
||||||
if (count($matches) > 0)
|
if (count($matches) > 0) {
|
||||||
return WebDAV_Directory::getChildFromArray($matches[0]);
|
return WebDAV_Directory::getChildFromArray($matches[0]);
|
||||||
|
}
|
||||||
|
|
||||||
throw new DAV\Exception\NotFound('The child with name: ' . $name . ' could not be found');;
|
throw new DAV\Exception\NotFound('The child with name: ' . $name . ' could not be found');
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getChildFromArray($array)
|
public static function getChildFromArray($array)
|
||||||
|
|
|
@ -64,14 +64,18 @@ class WebPlayer
|
||||||
$urlinfo = Stream_URL::parse($item->url);
|
$urlinfo = Stream_URL::parse($item->url);
|
||||||
if ($urlinfo['id'] && Core::is_media($urlinfo['type'])) {
|
if ($urlinfo['id'] && Core::is_media($urlinfo['type'])) {
|
||||||
$media = new $urlinfo['type']($urlinfo['id']);
|
$media = new $urlinfo['type']($urlinfo['id']);
|
||||||
} else if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
|
} else {
|
||||||
$media = new Song_Preview($urlinfo['id']);
|
if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
|
||||||
} else if (isset($urlinfo['demo_id'])) {
|
$media = new Song_Preview($urlinfo['id']);
|
||||||
$democratic = new Democratic($urlinfo['demo_id']);
|
} else {
|
||||||
if ($democratic->id) {
|
if (isset($urlinfo['demo_id'])) {
|
||||||
$song_id = $democratic->get_next_object();
|
$democratic = new Democratic($urlinfo['demo_id']);
|
||||||
if ($song_id) {
|
if ($democratic->id) {
|
||||||
$media = new Song($song_id);
|
$song_id = $democratic->get_next_object();
|
||||||
|
if ($song_id) {
|
||||||
|
$media = new Song($song_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,22 +118,45 @@ class WebPlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($urlinfo['type'] == 'song') {
|
if ($urlinfo['type'] == 'song') {
|
||||||
if ($types['real'] == "ogg" || $types['real'] == "opus") $types['player'] = "oga";
|
if ($types['real'] == "ogg" || $types['real'] == "opus") {
|
||||||
else if ($types['real'] == "mp4") $types['player'] = "m4a";
|
$types['player'] = "oga";
|
||||||
} else if ($urlinfo['type'] == 'video') {
|
} else {
|
||||||
if ($types['real'] == "ogg") $types['player'] = "ogv";
|
if ($types['real'] == "mp4") {
|
||||||
else if ($types['real'] == "webm") $types['player'] = "webmv";
|
$types['player'] = "m4a";
|
||||||
else if ($types['real'] == "mp4") $types['player'] = "m4v";
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($urlinfo['type'] == 'video') {
|
||||||
|
if ($types['real'] == "ogg") {
|
||||||
|
$types['player'] = "ogv";
|
||||||
|
} else {
|
||||||
|
if ($types['real'] == "webm") {
|
||||||
|
$types['player'] = "webmv";
|
||||||
|
} else {
|
||||||
|
if ($types['real'] == "mp4") {
|
||||||
|
$types['player'] = "m4v";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if ($item->type == 'live_stream') {
|
|
||||||
$types['real'] = $item->codec;
|
|
||||||
if ($types['real'] == "ogg" || $types['real'] == "opus") $types['player'] = "oga";
|
|
||||||
} else {
|
} else {
|
||||||
$ext = pathinfo($item->url, PATHINFO_EXTENSION);
|
if ($item->type == 'live_stream') {
|
||||||
if (!empty($ext)) $types['real'] = $ext;
|
$types['real'] = $item->codec;
|
||||||
|
if ($types['real'] == "ogg" || $types['real'] == "opus") {
|
||||||
|
$types['player'] = "oga";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$ext = pathinfo($item->url, PATHINFO_EXTENSION);
|
||||||
|
if (!empty($ext)) {
|
||||||
|
$types['real'] = $ext;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($types['player'])) $types['player'] = $types['real'];
|
if (empty($types['player'])) {
|
||||||
|
$types['player'] = $types['real'];
|
||||||
|
}
|
||||||
|
|
||||||
debug_event("webplayer.class.php", "Types {".json_encode($types)."}", 5);
|
debug_event("webplayer.class.php", "Types {".json_encode($types)."}", 5);
|
||||||
return $types;
|
return $types;
|
||||||
|
@ -209,10 +236,11 @@ class WebPlayer
|
||||||
{
|
{
|
||||||
$js = array();
|
$js = array();
|
||||||
foreach (array('title', 'author') as $member) {
|
foreach (array('title', 'author') as $member) {
|
||||||
if ($member == "author")
|
if ($member == "author") {
|
||||||
$kmember = "artist";
|
$kmember = "artist";
|
||||||
else
|
} else {
|
||||||
$kmember = $member;
|
$kmember = $member;
|
||||||
|
}
|
||||||
|
|
||||||
$js[$kmember] = $item->$member;
|
$js[$kmember] = $item->$member;
|
||||||
}
|
}
|
||||||
|
@ -226,14 +254,18 @@ class WebPlayer
|
||||||
|
|
||||||
if ($urlinfo['id'] && Core::is_media($urlinfo['type'])) {
|
if ($urlinfo['id'] && Core::is_media($urlinfo['type'])) {
|
||||||
$media = new $urlinfo['type']($urlinfo['id']);
|
$media = new $urlinfo['type']($urlinfo['id']);
|
||||||
} else if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
|
} else {
|
||||||
$media = new Song_Preview($urlinfo['id']);
|
if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
|
||||||
} else if (isset($urlinfo['demo_id'])) {
|
$media = new Song_Preview($urlinfo['id']);
|
||||||
$democratic = new Democratic($urlinfo['demo_id']);
|
} else {
|
||||||
if ($democratic->id) {
|
if (isset($urlinfo['demo_id'])) {
|
||||||
$song_id = $democratic->get_next_object();
|
$democratic = new Democratic($urlinfo['demo_id']);
|
||||||
if ($song_id) {
|
if ($democratic->id) {
|
||||||
$media = new Song($song_id);
|
$song_id = $democratic->get_next_object();
|
||||||
|
if ($song_id) {
|
||||||
|
$media = new Song($song_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -845,3 +845,4 @@ class XML_Data
|
||||||
return $dom->saveXML($dom->documentElement);
|
return $dom->saveXML($dom->documentElement);
|
||||||
}
|
}
|
||||||
} // XML_Data
|
} // XML_Data
|
||||||
|
|
||||||
|
|
|
@ -114,12 +114,11 @@ function check_config_values($conf)
|
||||||
}
|
}
|
||||||
if (isset($conf['debug'])) {
|
if (isset($conf['debug'])) {
|
||||||
if (!isset($conf['log_path'])) {
|
if (!isset($conf['log_path'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // check_config_values
|
} // check_config_values
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,7 +137,6 @@ function check_php_memory()
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // check_php_memory
|
} // check_php_memory
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,7 +148,6 @@ function check_php_timelimit()
|
||||||
{
|
{
|
||||||
$current = intval(ini_get('max_execution_time'));
|
$current = intval(ini_get('max_execution_time'));
|
||||||
return ($current >= 60 || $current == 0);
|
return ($current >= 60 || $current == 0);
|
||||||
|
|
||||||
} // check_php_timelimit
|
} // check_php_timelimit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,7 +38,6 @@ function set_memory_limit($new_limit)
|
||||||
if ($current_limit < $new_limit) {
|
if ($current_limit < $new_limit) {
|
||||||
ini_set (memory_limit, $new_limit);
|
ini_set (memory_limit, $new_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // set_memory_limit
|
} // set_memory_limit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +55,7 @@ function generate_password($length)
|
||||||
for ($i = 0; $i < $length; $i++) {
|
for ($i = 0; $i < $length; $i++) {
|
||||||
if ($alt == 1) {
|
if ($alt == 1) {
|
||||||
$password .= $consonants[(rand(0,strlen($consonants)-1))];
|
$password .= $consonants[(rand(0,strlen($consonants)-1))];
|
||||||
$alt = 0;
|
$alt = 0;
|
||||||
} else {
|
} else {
|
||||||
$password .= $vowels[(rand(0,strlen($vowels)-1))];
|
$password .= $vowels[(rand(0,strlen($vowels)-1))];
|
||||||
$alt = 1;
|
$alt = 1;
|
||||||
|
@ -64,7 +63,6 @@ function generate_password($length)
|
||||||
}
|
}
|
||||||
|
|
||||||
return $password;
|
return $password;
|
||||||
|
|
||||||
} // generate_password
|
} // generate_password
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,7 +91,6 @@ function scrub_in($input)
|
||||||
function scrub_out($string)
|
function scrub_out($string)
|
||||||
{
|
{
|
||||||
return htmlentities($string, ENT_QUOTES, AmpConfig::get('site_charset'));
|
return htmlentities($string, ENT_QUOTES, AmpConfig::get('site_charset'));
|
||||||
|
|
||||||
} // scrub_out
|
} // scrub_out
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +100,6 @@ function scrub_out($string)
|
||||||
function unhtmlentities($string)
|
function unhtmlentities($string)
|
||||||
{
|
{
|
||||||
return html_entity_decode($string, ENT_QUOTES, AmpConfig::get('site_charset'));
|
return html_entity_decode($string, ENT_QUOTES, AmpConfig::get('site_charset'));
|
||||||
|
|
||||||
} //unhtmlentities
|
} //unhtmlentities
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,7 +128,6 @@ function make_bool($string)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bool) $string;
|
return (bool) $string;
|
||||||
|
|
||||||
} // make_bool
|
} // make_bool
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +137,6 @@ function make_bool($string)
|
||||||
function invert_bool($value)
|
function invert_bool($value)
|
||||||
{
|
{
|
||||||
return make_bool($value) ? false : true;
|
return make_bool($value) ? false : true;
|
||||||
|
|
||||||
} // invert_bool
|
} // invert_bool
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,12 +158,10 @@ function get_languages()
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
|
|
||||||
$full_file = AmpConfig::get('prefix') . '/locale/' . $file;
|
$full_file = AmpConfig::get('prefix') . '/locale/' . $file;
|
||||||
|
|
||||||
/* Check to see if it's a directory */
|
/* Check to see if it's a directory */
|
||||||
if (is_dir($full_file) AND substr($file,0,1) != '.' AND $file != 'base') {
|
if (is_dir($full_file) AND substr($file,0,1) != '.' AND $file != 'base') {
|
||||||
|
|
||||||
switch ($file) {
|
switch ($file) {
|
||||||
case 'af_ZA'; $name = 'Afrikaans'; break; /* Afrikaans */
|
case 'af_ZA'; $name = 'Afrikaans'; break; /* Afrikaans */
|
||||||
case 'bg_BG'; $name = 'Български'; break; /* Bulgarian */
|
case 'bg_BG'; $name = 'Български'; break; /* Bulgarian */
|
||||||
|
@ -222,7 +214,6 @@ function get_languages()
|
||||||
|
|
||||||
$results[$file] = $name;
|
$results[$file] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
// Sort the list of languages by country code
|
// Sort the list of languages by country code
|
||||||
|
@ -232,7 +223,6 @@ function get_languages()
|
||||||
$results = array( "en_US" => "English (US)" ) + $results;
|
$results = array( "en_US" => "English (US)" ) + $results;
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_languages
|
} // get_languages
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,7 +256,6 @@ function translate_pattern_code($code)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // translate_pattern_code
|
} // translate_pattern_code
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -290,7 +279,6 @@ function generate_config($current)
|
||||||
if (preg_match("/^;?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$line,$matches)
|
if (preg_match("/^;?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$line,$matches)
|
||||||
|| preg_match("/^;?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $line, $matches)
|
|| preg_match("/^;?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $line, $matches)
|
||||||
|| preg_match("/^;?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$line,$matches)) {
|
|| preg_match("/^;?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$line,$matches)) {
|
||||||
|
|
||||||
$key = $matches[1];
|
$key = $matches[1];
|
||||||
$value = $matches[2];
|
$value = $matches[2];
|
||||||
|
|
||||||
|
@ -344,11 +332,15 @@ if (!function_exists('apache_request_headers')) {
|
||||||
if (substr($name, 0, 5) == 'HTTP_') {
|
if (substr($name, 0, 5) == 'HTTP_') {
|
||||||
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
|
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
|
||||||
$headers[$name] = $value;
|
$headers[$name] = $value;
|
||||||
} else if ($name == "CONTENT_TYPE") {
|
} else {
|
||||||
$headers["Content-Type"] = $value;
|
if ($name == "CONTENT_TYPE") {
|
||||||
} else if ($name == "CONTENT_LENGTH") {
|
$headers["Content-Type"] = $value;
|
||||||
$headers["Content-Length"] = $value;
|
} else {
|
||||||
}
|
if ($name == "CONTENT_LENGTH") {
|
||||||
|
$headers["Content-Length"] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $headers;
|
return $headers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,10 @@ if ((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PRO
|
||||||
|
|
||||||
if (isset($_SERVER['HTTP_X_FORWARDED_PORT'])) {
|
if (isset($_SERVER['HTTP_X_FORWARDED_PORT'])) {
|
||||||
$http_port = $_SERVER['HTTP_X_FORWARDED_PORT'];
|
$http_port = $_SERVER['HTTP_X_FORWARDED_PORT'];
|
||||||
} else if (isset($_SERVER['SERVER_PORT'])) {
|
} else {
|
||||||
$http_port = $_SERVER['SERVER_PORT'];
|
if (isset($_SERVER['SERVER_PORT'])) {
|
||||||
|
$http_port = $_SERVER['SERVER_PORT'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!isset($http_port) || empty($http_port)) {
|
if (!isset($http_port) || empty($http_port)) {
|
||||||
$http_port = 80;
|
$http_port = 80;
|
||||||
|
|
|
@ -206,7 +206,8 @@ if (!defined('NO_SESSION') && AmpConfig::get('use_auth')) {
|
||||||
$GLOBALS['user']->access = intval($auth['access']);
|
$GLOBALS['user']->access = intval($auth['access']);
|
||||||
}
|
}
|
||||||
if (!$GLOBALS['user']->id AND !AmpConfig::get('demo_mode')) {
|
if (!$GLOBALS['user']->id AND !AmpConfig::get('demo_mode')) {
|
||||||
Auth::logout(session_id()); exit;
|
Auth::logout(session_id());
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
$GLOBALS['user']->update_last_seen();
|
$GLOBALS['user']->update_last_seen();
|
||||||
}
|
}
|
||||||
|
@ -221,7 +222,6 @@ else {
|
||||||
} else {
|
} else {
|
||||||
$GLOBALS['user'] = new User();
|
$GLOBALS['user'] = new User();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // If NO_SESSION passed
|
} // If NO_SESSION passed
|
||||||
|
|
||||||
$GLOBALS['user']->format(false);
|
$GLOBALS['user']->format(false);
|
||||||
|
|
|
@ -26,31 +26,31 @@
|
||||||
*/
|
*/
|
||||||
function split_sql($sql)
|
function split_sql($sql)
|
||||||
{
|
{
|
||||||
$sql = trim($sql);
|
$sql = trim($sql);
|
||||||
$sql = preg_replace("/\n#[^\n]*\n/", "\n", $sql);
|
$sql = preg_replace("/\n#[^\n]*\n/", "\n", $sql);
|
||||||
$buffer = array();
|
$buffer = array();
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$in_string = false;
|
$in_string = false;
|
||||||
for ($i=0; $i<strlen($sql)-1; $i++) {
|
for ($i=0; $i<strlen($sql)-1; $i++) {
|
||||||
if ($sql[$i] == ";" && !$in_string) {
|
if ($sql[$i] == ";" && !$in_string) {
|
||||||
$ret[] = substr($sql, 0, $i);
|
$ret[] = substr($sql, 0, $i);
|
||||||
$sql = substr($sql, $i + 1);
|
$sql = substr($sql, $i + 1);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
}
|
|
||||||
if ($in_string && ($sql[$i] == $in_string) && $buffer[1] != "\\") {
|
|
||||||
$in_string = false;
|
|
||||||
} elseif (!$in_string && ($sql[$i] == '"' || $sql[$i] == "'") && (!isset($buffer[0]) || $buffer[0] != "\\")) {
|
|
||||||
$in_string = $sql[$i];
|
|
||||||
}
|
|
||||||
if (isset($buffer[1])) {
|
|
||||||
$buffer[0] = $buffer[1];
|
|
||||||
}
|
|
||||||
$buffer[1] = $sql[$i];
|
|
||||||
}
|
}
|
||||||
if (!empty($sql)) {
|
if ($in_string && ($sql[$i] == $in_string) && $buffer[1] != "\\") {
|
||||||
$ret[] = $sql;
|
$in_string = false;
|
||||||
|
} elseif (!$in_string && ($sql[$i] == '"' || $sql[$i] == "'") && (!isset($buffer[0]) || $buffer[0] != "\\")) {
|
||||||
|
$in_string = $sql[$i];
|
||||||
}
|
}
|
||||||
return($ret);
|
if (isset($buffer[1])) {
|
||||||
|
$buffer[0] = $buffer[1];
|
||||||
|
}
|
||||||
|
$buffer[1] = $sql[$i];
|
||||||
|
}
|
||||||
|
if (!empty($sql)) {
|
||||||
|
$ret[] = $sql;
|
||||||
|
}
|
||||||
|
return($ret);
|
||||||
} // split_sql
|
} // split_sql
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +98,6 @@ function install_check_status($configfile)
|
||||||
Error::add('general', T_('Existing Database detected, unable to continue installation'));
|
Error::add('general', T_('Existing Database detected, unable to continue installation'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // install_check_status
|
} // install_check_status
|
||||||
|
|
||||||
function install_check_server_apache()
|
function install_check_server_apache()
|
||||||
|
@ -340,7 +339,6 @@ function install_create_account($username, $password, $password2)
|
||||||
User::fix_preferences('-1');
|
User::fix_preferences('-1');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // install_create_account
|
} // install_create_account
|
||||||
|
|
||||||
function command_exists($command)
|
function command_exists($command)
|
||||||
|
|
|
@ -53,7 +53,6 @@ function log_event($username, $event_name, $event_description, $log_name)
|
||||||
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";
|
echo "Warning: Unable to write to log ($log_filename) Please check your log_path variable in ampache.cfg.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // log_event
|
} // log_event
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -151,5 +150,5 @@ function debug_event($type, $message, $level, $file = '', $username = '')
|
||||||
foreach (explode("\n", $message) as $line) {
|
foreach (explode("\n", $message) as $line) {
|
||||||
log_event($username, $type, $line, $file);
|
log_event($username, $type, $line, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // debug_event
|
} // debug_event
|
||||||
|
|
||||||
|
|
|
@ -187,10 +187,10 @@ if (isset($auth) && $auth['success'] && isset($user)) {
|
||||||
strpos($_POST['referrer'], 'update.php') === false &&
|
strpos($_POST['referrer'], 'update.php') === false &&
|
||||||
strpos($_POST['referrer'], 'activate.php') === false &&
|
strpos($_POST['referrer'], 'activate.php') === false &&
|
||||||
strpos($_POST['referrer'], 'admin') === false ) {
|
strpos($_POST['referrer'], 'admin') === false ) {
|
||||||
|
header('Location: ' . $_POST['referrer']);
|
||||||
header('Location: ' . $_POST['referrer']);
|
exit();
|
||||||
exit();
|
|
||||||
} // if we've got a referrer
|
} // if we've got a referrer
|
||||||
header('Location: ' . AmpConfig::get('web_path') . '/index.php');
|
header('Location: ' . AmpConfig::get('web_path') . '/index.php');
|
||||||
exit();
|
exit();
|
||||||
} // auth success
|
} // auth success
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,9 @@ function update_preferences($pref_id=0)
|
||||||
$sql = "SELECT `id`,`name`,`type` FROM `preference`";
|
$sql = "SELECT `id`,`name`,`type` FROM `preference`";
|
||||||
|
|
||||||
/* If it isn't the System Account's preferences */
|
/* If it isn't the System Account's preferences */
|
||||||
if ($pref_id != '-1') { $sql .= " WHERE `catagory` != 'system'"; }
|
if ($pref_id != '-1') {
|
||||||
|
$sql .= " WHERE `catagory` != 'system'";
|
||||||
|
}
|
||||||
|
|
||||||
$db_results = Dba::read($sql);
|
$db_results = Dba::read($sql);
|
||||||
|
|
||||||
|
@ -61,8 +63,12 @@ function update_preferences($pref_id=0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/_pass$/', $name)) {
|
if (preg_match('/_pass$/', $name)) {
|
||||||
if ($value == '******') { unset($_REQUEST[$name]); } else if (preg_match('/md5_pass$/', $name)) {
|
if ($value == '******') {
|
||||||
$value = md5($value);
|
unset($_REQUEST[$name]);
|
||||||
|
} else {
|
||||||
|
if (preg_match('/md5_pass$/', $name)) {
|
||||||
|
$value = md5($value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,12 +80,10 @@ function update_preferences($pref_id=0)
|
||||||
if (Access::check('interface','100') && $_REQUEST[$new_level]) {
|
if (Access::check('interface','100') && $_REQUEST[$new_level]) {
|
||||||
Preference::update_level($id,$_REQUEST[$new_level]);
|
Preference::update_level($id,$_REQUEST[$new_level]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end foreach preferences
|
} // end foreach preferences
|
||||||
|
|
||||||
// Now that we've done that we need to invalidate the cached preverences
|
// Now that we've done that we need to invalidate the cached preverences
|
||||||
Preference::clear_from_session();
|
Preference::clear_from_session();
|
||||||
|
|
||||||
} // update_preferences
|
} // update_preferences
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +114,6 @@ function update_preference($user_id,$name,$pref_id,$value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} // update_preference
|
} // update_preference
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -199,7 +202,8 @@ function create_preference_input($name,$value)
|
||||||
$is_true = '';
|
$is_true = '';
|
||||||
$is_false = '';
|
$is_false = '';
|
||||||
if ($value == '1') {
|
if ($value == '1') {
|
||||||
$is_true = "selected=\"selected\""; } else {
|
$is_true = "selected=\"selected\"";
|
||||||
|
} else {
|
||||||
$is_false = "selected=\"selected\"";
|
$is_false = "selected=\"selected\"";
|
||||||
}
|
}
|
||||||
echo "<select name=\"$name\">\n";
|
echo "<select name=\"$name\">\n";
|
||||||
|
@ -264,9 +268,13 @@ function create_preference_input($name,$value)
|
||||||
echo "<select name=\"$name\">\n";
|
echo "<select name=\"$name\">\n";
|
||||||
echo "\t<option value=\"\">" . T_('None') . "</option>\n";
|
echo "\t<option value=\"\">" . T_('None') . "</option>\n";
|
||||||
foreach ($controllers as $controller) {
|
foreach ($controllers as $controller) {
|
||||||
if (!Localplay::is_enabled($controller)) { continue; }
|
if (!Localplay::is_enabled($controller)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$is_selected = '';
|
$is_selected = '';
|
||||||
if ($value == $controller) { $is_selected = 'selected="selected"'; }
|
if ($value == $controller) {
|
||||||
|
$is_selected = 'selected="selected"';
|
||||||
|
}
|
||||||
echo "\t<option value=\"" . $controller . "\" $is_selected>" . ucfirst($controller) . "</option>\n";
|
echo "\t<option value=\"" . $controller . "\" $is_selected>" . ucfirst($controller) . "</option>\n";
|
||||||
} // end foreach
|
} // end foreach
|
||||||
echo "</select>\n";
|
echo "</select>\n";
|
||||||
|
@ -294,7 +302,9 @@ function create_preference_input($name,$value)
|
||||||
echo "<select name=\"$name\">\n";
|
echo "<select name=\"$name\">\n";
|
||||||
foreach ($themes as $theme) {
|
foreach ($themes as $theme) {
|
||||||
$is_selected = "";
|
$is_selected = "";
|
||||||
if ($value == $theme['path']) { $is_selected = "selected=\"selected\""; }
|
if ($value == $theme['path']) {
|
||||||
|
$is_selected = "selected=\"selected\"";
|
||||||
|
}
|
||||||
echo "\t<option value=\"" . $theme['path'] . "\" $is_selected>" . $theme['name'] . "</option>\n";
|
echo "\t<option value=\"" . $theme['path'] . "\" $is_selected>" . $theme['name'] . "</option>\n";
|
||||||
} // foreach themes
|
} // foreach themes
|
||||||
echo "</select>\n";
|
echo "</select>\n";
|
||||||
|
@ -364,5 +374,5 @@ function create_preference_input($name,$value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // create_preference_input
|
} // create_preference_input
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ function show_rating($object_id,$type)
|
||||||
$rating = new Rating($object_id,$type);
|
$rating = new Rating($object_id,$type);
|
||||||
|
|
||||||
require AmpConfig::get('prefix') . '/templates/show_object_rating.inc.php';
|
require AmpConfig::get('prefix') . '/templates/show_object_rating.inc.php';
|
||||||
|
|
||||||
} // show_rating
|
} // show_rating
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,5 +54,5 @@ function get_rating_name($score)
|
||||||
default:
|
default:
|
||||||
return T_("Off the Charts!");
|
return T_("Off the Charts!");
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
} // get_rating_name
|
} // get_rating_name
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ function get_themes()
|
||||||
$handle = opendir(AmpConfig::get('prefix') . '/themes');
|
$handle = opendir(AmpConfig::get('prefix') . '/themes');
|
||||||
|
|
||||||
if (!is_resource($handle)) {
|
if (!is_resource($handle)) {
|
||||||
debug_event('theme', 'Failed to open /themes directory', 2);
|
debug_event('theme', 'Failed to open /themes directory', 2);
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
|
@ -56,7 +56,6 @@ function get_themes()
|
||||||
ksort($results);
|
ksort($results);
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_themes
|
} // get_themes
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -66,13 +65,14 @@ function get_themes()
|
||||||
*/
|
*/
|
||||||
function get_theme($name)
|
function get_theme($name)
|
||||||
{
|
{
|
||||||
if (strlen($name) < 1) { return false; }
|
if (strlen($name) < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$config_file = AmpConfig::get('prefix') . "/themes/" . $name . "/theme.cfg.php";
|
$config_file = AmpConfig::get('prefix') . "/themes/" . $name . "/theme.cfg.php";
|
||||||
$results = parse_ini_file($config_file);
|
$results = parse_ini_file($config_file);
|
||||||
$results['path'] = $name;
|
$results['path'] = $name;
|
||||||
return $results;
|
return $results;
|
||||||
|
|
||||||
} // get_theme
|
} // get_theme
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -85,7 +85,6 @@ function get_theme_author($theme_name)
|
||||||
$results = read_config($theme_path);
|
$results = read_config($theme_path);
|
||||||
|
|
||||||
return $results['author'];
|
return $results['author'];
|
||||||
|
|
||||||
} // get_theme_author
|
} // get_theme_author
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -101,5 +100,5 @@ function theme_exists($theme_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // theme_exists
|
} // theme_exists
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue