1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00
Fix coding guidelines incoherences. Code should match PSR1/2 now, and
php-cs is set to check it on each commit.

Also fixed the Git hook to take into account only added, modified,
copied and renamed files (preventing errors when trying to check deleted
files).

Closes #1260.
This commit is contained in:
Phyks (Lucas Verney) 2016-06-17 12:20:43 +02:00
parent 178e53a82e
commit 2bb142eeb8
283 changed files with 1332 additions and 1347 deletions

1
.gitignore vendored
View file

@ -25,3 +25,4 @@ web.config
robots.txt
php-cs-fixer.phar
.php_cs.cache
cs_fixer_tmp_*

View file

@ -14,6 +14,8 @@ $finder = Symfony\CS\Finder\DefaultFinder::create()
;
return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->fixers(array('-psr0'))
->finder($finder)
->setUsingCache(true)
;

View file

@ -22,7 +22,7 @@
require_once '../lib/init.php';
if (!Access::check('interface','100')) {
if (!Access::check('interface', '100')) {
UI::access_denied();
exit();
}
@ -37,7 +37,7 @@ switch ($_REQUEST['action']) {
}
Access::delete($_REQUEST['access_id']);
$url = AmpConfig::get('web_path') . '/admin/access.php';
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;
case 'show_delete_record':
if (AmpConfig::get('demo_mode')) {
@ -45,12 +45,12 @@ switch ($_REQUEST['action']) {
}
$access = new Access($_GET['access_id']);
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');
break;
case 'add_host':
// Make sure we've got a valid form submission
if (!Core::form_verify('add_acl','post')) {
if (!Core::form_verify('add_acl', 'post')) {
UI::access_denied();
exit;
}
@ -71,7 +71,7 @@ switch ($_REQUEST['action']) {
if (!AmpError::occurred()) {
$url = AmpConfig::get('web_path') . '/admin/access.php';
show_confirmation(T_('Added'), T_('Your new Access Control List(s) have been created'),$url);
show_confirmation(T_('Added'), T_('Your new Access Control List(s) have been created'), $url);
} else {
$action = 'show_add_' . $_POST['type'];
require_once AmpConfig::get('prefix') . UI::find_template('show_add_access.inc.php');

View file

@ -23,7 +23,7 @@
require_once '../lib/init.php';
require_once AmpConfig::get('prefix') . '/modules/catalog/local/local.catalog.php';
if (!Access::check('interface','100')) {
if (!Access::check('interface', '100')) {
UI::access_denied();
exit;
}
@ -109,7 +109,7 @@ switch ($_REQUEST['action']) {
break;
case 'show_delete_catalog':
$next_url = AmpConfig::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalogs[]=' . implode(',', $catalogs);
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;
case 'enable_disabled':
if (AmpConfig::get('demo_mode')) {
@ -128,7 +128,7 @@ switch ($_REQUEST['action']) {
}
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
$title = count($songs) . nT_(' Disabled Song Processed', ' Disabled Songs Processed', count($songs));
show_confirmation($title,$body,$url);
show_confirmation($title, $body, $url);
break;
case 'clean_all_catalogs':
catalog_worker('clean_all_catalogs');
@ -150,7 +150,7 @@ switch ($_REQUEST['action']) {
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
$title = T_('Catalog Updated');
$body = '';
show_confirmation($title,$body,$url);
show_confirmation($title, $body, $url);
break;
case 'update_from':
if (AmpConfig::get('demo_mode')) {
@ -176,7 +176,7 @@ switch ($_REQUEST['action']) {
AmpError::add('general', T_('Error: Name not specified'));
}
if (!Core::form_verify('add_catalog','post')) {
if (!Core::form_verify('add_catalog', 'post')) {
UI::access_denied();
exit;
}
@ -217,7 +217,7 @@ switch ($_REQUEST['action']) {
break;
}
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;
case 'show_disabled':
/* Stop the demo hippies */
@ -241,7 +241,7 @@ switch ($_REQUEST['action']) {
$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']);
show_confirmation(T_('Delete Catalog'), T_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1);
show_confirmation(T_('Delete Catalog'), T_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)", $nexturl, 1);
break;
case 'show_customize_catalog':
$catalog = Catalog::create_from_id($_REQUEST['catalog_id']);

View file

@ -22,7 +22,7 @@
require_once '../lib/init.php';
if (!Access::check('interface','100')) {
if (!Access::check('interface', '100')) {
UI::access_denied();
exit;
}

View file

@ -22,7 +22,7 @@
require_once '../lib/init.php';
if (!Access::check('interface','100')) {
if (!Access::check('interface', '100')) {
UI::access_denied();
exit;
}
@ -47,7 +47,7 @@ switch ($_REQUEST['action']) {
header("Content-Transfer-Encoding: binary");
header("Cache-control: public");
$date = date("d/m/Y",time());
$date = date("d/m/Y", time());
switch ($_REQUEST['export_format']) {
case 'itunes':

View file

@ -22,7 +22,7 @@
require_once '../lib/init.php';
if (!Access::check('interface',100)) {
if (!Access::check('interface', 100)) {
UI::access_denied();
exit();
}

View file

@ -22,7 +22,7 @@
require_once '../lib/init.php';
if (!Access::check('interface','100')) {
if (!Access::check('interface', '100')) {
UI::access_denied();
exit;
}
@ -41,7 +41,7 @@ switch ($_REQUEST['action']) {
License::create($_POST);
$text = T_('License Created');
}
show_confirmation($text,'',AmpConfig::get('web_path') . '/admin/license.php');
show_confirmation($text, '', AmpConfig::get('web_path') . '/admin/license.php');
break;
case 'show_edit':
$license = new License($_REQUEST['license_id']);
@ -50,7 +50,7 @@ switch ($_REQUEST['action']) {
break;
case 'delete':
License::delete($_REQUEST['license_id']);
show_confirmation(T_('License Deleted'),'',AmpConfig::get('web_path') . '/admin/license.php');
show_confirmation(T_('License Deleted'), '', AmpConfig::get('web_path') . '/admin/license.php');
break;
default:
$browse = new Browse();

View file

@ -22,7 +22,7 @@
require_once '../lib/init.php';
if (!Access::check('interface','75')) {
if (!Access::check('interface', '75')) {
UI::access_denied();
exit();
}
@ -67,7 +67,7 @@ switch ($_REQUEST['action']) {
$body = T_('Your E-mail was not sent.');
}
$url = AmpConfig::get('web_path') . '/admin/mail.php';
show_confirmation($title,$body,$url);
show_confirmation($title, $body, $url);
break;
default:

View file

@ -44,15 +44,15 @@ switch ($_REQUEST['action']) {
// Go ahead and enable Localplay (Admin->System) as we assume they want to do that
// if they are enabling this
Preference::update('allow_localplay_playback','-1','1');
Preference::update('localplay_level',$GLOBALS['user']->id,'100');
Preference::update('localplay_controller',$GLOBALS['user']->id,$localplay->type);
Preference::update('allow_localplay_playback', '-1', '1');
Preference::update('localplay_level', $GLOBALS['user']->id, '100');
Preference::update('localplay_controller', $GLOBALS['user']->id, $localplay->type);
/* Show Confirmation */
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_localplay';
$title = T_('localplay enabled');
$body = '';
show_confirmation($title ,$body, $url);
show_confirmation($title, $body, $url);
break;
case 'install_catalog_type':
$type = (string) scrub_in($_REQUEST['type']);
@ -69,21 +69,21 @@ switch ($_REQUEST['action']) {
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_catalog_types';
$title = T_('Module enabled');
$body = '';
show_confirmation($title ,$body, $url);
show_confirmation($title, $body, $url);
break;
case 'confirm_uninstall_localplay':
$type = (string) scrub_in($_REQUEST['type']);
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_localplay&type=' . $type;
$title = T_('Are you sure you want to disable this module?');
$body = '';
show_confirmation($title,$body,$url,1);
show_confirmation($title, $body, $url, 1);
break;
case 'confirm_uninstall_catalog_type':
$type = (string) scrub_in($_REQUEST['type']);
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_catalog_type&type=' . $type;
$title = T_('Are you sure you want to disable this module?');
$body = '';
show_confirmation($title,$body,$url,1);
show_confirmation($title, $body, $url, 1);
break;
case 'uninstall_localplay':
$type = (string) scrub_in($_REQUEST['type']);
@ -95,7 +95,7 @@ switch ($_REQUEST['action']) {
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_localplay';
$title = T_('Module disabled');
$body = '';
show_confirmation($title,$body,$url);
show_confirmation($title, $body, $url);
break;
case 'uninstall_catalog_type':
$type = (string) scrub_in($_REQUEST['type']);
@ -117,17 +117,17 @@ switch ($_REQUEST['action']) {
case 'install_plugin':
/* Verify that this plugin exists */
$plugins = Plugin::get_plugins();
if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
if (!array_key_exists($_REQUEST['plugin'], $plugins)) {
debug_event('plugins', 'Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected', '1');
break;
}
$plugin = new Plugin($_REQUEST['plugin']);
if (!$plugin->install()) {
debug_event('plugins','Error: Plugin Install Failed, ' . $_REQUEST['plugin'],'1');
debug_event('plugins', 'Error: Plugin Install Failed, ' . $_REQUEST['plugin'], '1');
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
$title = T_('Unable to Install Plugin');
$body = '';
show_confirmation($title,$body,$url);
show_confirmation($title, $body, $url);
break;
}
@ -138,20 +138,20 @@ switch ($_REQUEST['action']) {
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
$title = T_('Plugin enabled');
$body = '';
show_confirmation($title,$body,$url);
show_confirmation($title, $body, $url);
break;
case 'confirm_uninstall_plugin':
$plugin = scrub_in($_REQUEST['plugin']);
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=uninstall_plugin&plugin=' . $plugin;
$title = T_('Are you sure you want to disable this plugin?');
$body = '';
show_confirmation($title,$body,$url,1);
show_confirmation($title, $body, $url, 1);
break;
case 'uninstall_plugin':
/* Verify that this plugin exists */
$plugins = Plugin::get_plugins();
if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
if (!array_key_exists($_REQUEST['plugin'], $plugins)) {
debug_event('plugins', 'Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected', '1');
break;
}
$plugin = new Plugin($_REQUEST['plugin']);
@ -164,13 +164,13 @@ switch ($_REQUEST['action']) {
$url = AmpConfig::get('web_path') . '/admin/modules.php?action=show_plugins';
$title = T_('Plugin disabled');
$body = '';
show_confirmation($title,$body,$url);
show_confirmation($title, $body, $url);
break;
case 'upgrade_plugin':
/* Verify that this plugin exists */
$plugins = Plugin::get_plugins();
if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
if (!array_key_exists($_REQUEST['plugin'], $plugins)) {
debug_event('plugins', 'Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected', '1');
break;
}
$plugin = new Plugin($_REQUEST['plugin']);

View file

@ -22,7 +22,7 @@
require_once '../lib/init.php';
if (!Access::check('interface','100')) {
if (!Access::check('interface', '100')) {
UI::access_denied();
exit;
}
@ -36,11 +36,11 @@ switch ($_REQUEST['action']) {
if ($shout->id) {
$shout->update($_POST);
}
show_confirmation(T_('Shoutbox Post Updated'),'',AmpConfig::get('web_path') . '/admin/shout.php');
show_confirmation(T_('Shoutbox Post Updated'), '', AmpConfig::get('web_path') . '/admin/shout.php');
break;
case 'show_edit':
$shout = new Shoutbox($_REQUEST['shout_id']);
$object = Shoutbox::get_object($shout->object_type,$shout->object_id);
$object = Shoutbox::get_object($shout->object_type, $shout->object_id);
$object->format();
$client = new User($shout->user);
$client->format();
@ -48,7 +48,7 @@ switch ($_REQUEST['action']) {
break;
case 'delete':
Shoutbox::delete($_REQUEST['shout_id']);
show_confirmation(T_('Shoutbox Post Deleted'),'',AmpConfig::get('web_path') . '/admin/shout.php');
show_confirmation(T_('Shoutbox Post Deleted'), '', AmpConfig::get('web_path') . '/admin/shout.php');
break;
default:
$browse = new Browse();

View file

@ -22,7 +22,7 @@
require_once '../lib/init.php';
if (!Access::check('interface',100) or AmpConfig::get('demo_mode')) {
if (!Access::check('interface', 100) or AmpConfig::get('demo_mode')) {
UI::access_denied();
exit();
}
@ -39,7 +39,7 @@ switch ($_REQUEST['action']) {
$current = parse_ini_file(AmpConfig::get('prefix') . '/config/ampache.cfg.php');
$final = generate_config($current);
$browser = new Horde_Browser();
$browser->downloadHeaders('ampache.cfg.php', 'text/plain',false,filesize(AmpConfig::get('prefix') . '/config/ampache.cfg.php.dist'));
$browser->downloadHeaders('ampache.cfg.php', 'text/plain', false, filesize(AmpConfig::get('prefix') . '/config/ampache.cfg.php.dist'));
echo $final;
exit;
case 'write_config':

View file

@ -22,7 +22,7 @@
require_once '../lib/init.php';
if (!Access::check('interface','100')) {
if (!Access::check('interface', '100')) {
UI::access_denied();
exit();
}
@ -36,7 +36,7 @@ switch ($_REQUEST['action']) {
break;
}
if (!Core::form_verify('edit_user','post')) {
if (!Core::form_verify('edit_user', 'post')) {
UI::access_denied();
exit;
}
@ -118,7 +118,7 @@ switch ($_REQUEST['action']) {
break;
}
if (!Core::form_verify('add_user','post')) {
if (!Core::form_verify('add_user', 'post')) {
UI::access_denied();
exit;
}
@ -174,7 +174,7 @@ switch ($_REQUEST['action']) {
}
/* 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');
break;
case 'enable':
$client = new User($_REQUEST['user_id']);
@ -182,12 +182,12 @@ switch ($_REQUEST['action']) {
if (!AmpConfig::get('user_no_email_confirm')) {
Registration::send_account_enabled($client->username, $client->fullname, $client->email);
}
show_confirmation(T_('User Enabled'),$client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path') . '/admin/users.php');
show_confirmation(T_('User Enabled'), $client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path') . '/admin/users.php');
break;
case 'disable':
$client = new User($_REQUEST['user_id']);
if ($client->disable()) {
show_confirmation(T_('User Disabled'),$client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path') . '/admin/users.php');
show_confirmation(T_('User Disabled'), $client->fullname . ' (' . $client->username . ')', AmpConfig::get('web_path') . '/admin/users.php');
} else {
show_confirmation(T_('Error'), T_('Unable to Disabled last Administrator'), AmpConfig::get('web_path') . '/admin/users.php');
}
@ -221,7 +221,7 @@ switch ($_REQUEST['action']) {
$client = new User($_REQUEST['user_id']);
show_confirmation(T_('Deletion Request'),
sprintf(T_('Are you sure you want to permanently delete %s?'), $client->fullname),
AmpConfig::get('web_path') . "/admin/users.php?action=confirm_delete&user_id=" . $_REQUEST['user_id'],1,'delete_user');
AmpConfig::get('web_path') . "/admin/users.php?action=confirm_delete&user_id=" . $_REQUEST['user_id'], 1, 'delete_user');
break;
case 'show_delete_avatar':
$user_id = $_REQUEST['user_id'];
@ -234,7 +234,7 @@ switch ($_REQUEST['action']) {
break;
}
if (!Core::form_verify('delete_avatar','post')) {
if (!Core::form_verify('delete_avatar', 'post')) {
UI::access_denied();
exit;
}
@ -256,7 +256,7 @@ switch ($_REQUEST['action']) {
break;
}
if (!Core::form_verify('generate_apikey','post')) {
if (!Core::form_verify('generate_apikey', 'post')) {
UI::access_denied();
exit;
}
@ -273,7 +273,7 @@ switch ($_REQUEST['action']) {
$working_user = new User($_REQUEST['user_id']);
if (!isset($_REQUEST['all'])) {
$history = $working_user->get_ip_history(0,1);
$history = $working_user->get_ip_history(0, 1);
} else {
$history = $working_user->get_ip_history();
}
@ -295,7 +295,7 @@ switch ($_REQUEST['action']) {
$browse->reset_filters();
$browse->set_type('user');
$browse->set_simple_browse(true);
$browse->set_sort('name','ASC');
$browse->set_sort('name', 'ASC');
$user_ids = $browse->get_objects();
$browse->show_objects($user_ids);
$browse->store();

View file

@ -60,7 +60,7 @@ switch ($_REQUEST['action']) {
break;
case 'update_from_tags':
// Make sure they are a 'power' user at least
if (!Access::check('interface','75')) {
if (!Access::check('interface', '75')) {
UI::access_denied();
exit;
}
@ -73,7 +73,7 @@ switch ($_REQUEST['action']) {
case 'set_track_numbers':
debug_event('albums', 'Set track numbers called.', '5');
if (!Access::check('interface','75')) {
if (!Access::check('interface', '75')) {
UI::access_denied();
exit;
}

View file

@ -94,8 +94,8 @@ switch ($_REQUEST['action']) {
}
/* Enclose this in the purty box! */
require AmpConfig::get('prefix') . UI::find_template('show_box_top.inc.php');
show_alphabet_list('artists','artists.php',$match);
show_alphabet_form($chr, T_('Show Artists starting with'),"artists.php?action=match");
show_alphabet_list('artists', 'artists.php', $match);
show_alphabet_form($chr, T_('Show Artists starting with'), "artists.php?action=match");
require AmpConfig::get('prefix') . UI::find_template('show_box_bottom.inc.php');
if ($match === "Browse") {

View file

@ -64,7 +64,7 @@ switch ($_REQUEST['action']) {
// If we got something back insert it
if ($image_data) {
$art = new Art($object_id, $object_type);
$art->insert($image_data,$_FILES['file']['type']);
$art->insert($image_data, $_FILES['file']['type']);
show_confirmation(T_('Art Inserted'), '', $burl);
}
// Else it failed
@ -90,7 +90,7 @@ switch ($_REQUEST['action']) {
$image_data = Art::get_from_source($upload, $object_type);
if ($image_data) {
$art->insert($image_data,$upload['0']['mime']);
$art->insert($image_data, $upload['0']['mime']);
show_confirmation(T_('Art Inserted'), '', $burl);
break;
} // if image data

View file

@ -96,7 +96,7 @@ if (Core::is_playable_item($_REQUEST['action'])) {
break;
} // switch on type
} // foreach media_id
$name = 'Batch-' . date("dmY",time());
$name = 'Batch-' . date("dmY", time());
default:
// Rien a faire
break;
@ -118,6 +118,6 @@ session_write_close();
$song_files = get_media_files($media_ids);
if (is_array($song_files['0'])) {
set_memory_limit($song_files['1']+32);
send_zip($name,$song_files['0']);
send_zip($name, $song_files['0']);
}
exit;

View file

@ -73,17 +73,17 @@ switch ($_REQUEST['action']) {
case 'file':
break;
case 'album':
$browse->set_filter('catalog',$_SESSION['catalog']);
$browse->set_filter('catalog', $_SESSION['catalog']);
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('name','ASC');
$browse->set_sort('name', 'ASC');
$browse->update_browse_from_session(); // Update current index depending on what is in session.
$browse->show_objects();
break;
case 'tag':
//FIXME: This whole thing is ugly, even though it works.
$browse->set_sort('count','ASC');
$browse->set_sort('count', 'ASC');
// This one's a doozy
$browse_type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'artist';
$browse->set_simple_browse(false);
@ -101,20 +101,20 @@ switch ($_REQUEST['action']) {
require_once AmpConfig::get('prefix') . UI::find_template('browse_content.inc.php');
break;
case 'artist':
$browse->set_filter('catalog',$_SESSION['catalog']);
$browse->set_filter('catalog', $_SESSION['catalog']);
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('name','ASC');
$browse->set_sort('name', 'ASC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
case 'song':
$browse->set_filter('catalog',$_SESSION['catalog']);
$browse->set_filter('catalog', $_SESSION['catalog']);
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('title','ASC');
$browse->set_sort('title', 'ASC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
@ -122,7 +122,7 @@ switch ($_REQUEST['action']) {
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('name','ASC');
$browse->set_sort('name', 'ASC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
@ -130,15 +130,15 @@ switch ($_REQUEST['action']) {
break;
case 'playlist':
$browse->set_sort('type','ASC');
$browse->set_sort('last_update','DESC');
$browse->set_filter('playlist_type','1');
$browse->set_sort('type', 'ASC');
$browse->set_sort('last_update', 'DESC');
$browse->set_filter('playlist_type', '1');
$browse->update_browse_from_session();
$browse->show_objects();
break;
case 'smartplaylist':
$browse->set_sort('type', 'ASC');
$browse->set_filter('playlist_type','1');
$browse->set_filter('playlist_type', '1');
$browse->update_browse_from_session();
$browse->show_objects();
break;
@ -156,7 +156,7 @@ switch ($_REQUEST['action']) {
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('title','ASC');
$browse->set_sort('title', 'ASC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
@ -164,7 +164,7 @@ switch ($_REQUEST['action']) {
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('name','ASC');
$browse->set_sort('name', 'ASC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
@ -172,7 +172,7 @@ switch ($_REQUEST['action']) {
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('season_number','ASC');
$browse->set_sort('season_number', 'ASC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
@ -190,12 +190,12 @@ switch ($_REQUEST['action']) {
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('name','ASC');
$browse->set_sort('name', 'ASC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
case 'pvmsg':
$browse->set_sort('creation_date','DESC');
$browse->set_sort('creation_date', 'DESC');
$folder = $_REQUEST['folder'];
if ($folder === "sent") {
$browse->set_filter('user', $GLOBALS['user']->id);
@ -209,7 +209,7 @@ switch ($_REQUEST['action']) {
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('title','ASC');
$browse->set_sort('title', 'ASC');
$browse->update_browse_from_session();
$browse->show_objects();
break;
@ -217,7 +217,7 @@ switch ($_REQUEST['action']) {
if (AmpConfig::get('catalog_disable')) {
$browse->set_filter('catalog_enabled', '1');
}
$browse->set_sort('pubdate','DESC');
$browse->set_sort('pubdate', 'DESC');
$browse->update_browse_from_session();
$browse->show_objects();
break;

View file

@ -48,7 +48,7 @@ switch ($_REQUEST['action']) {
exit;
}
if (!Core::form_verify('add_channel','post')) {
if (!Core::form_verify('add_channel', 'post')) {
UI::access_denied();
exit;
}

View file

@ -27,7 +27,7 @@
the case. Also this will update local statistics for songs as well.
This is also where it decides if you need to be downsampled.
*/
define('NO_SESSION','1');
define('NO_SESSION', '1');
require_once '../lib/init.php';
ob_end_clean();
@ -59,9 +59,9 @@ if ($channel->is_private) {
Preference::init();
if (AmpConfig::get('access_control')) {
if (!Access::check_network('stream',$GLOBALS['user']->id,'25') and
!Access::check_network('network',$GLOBALS['user']->id,'25')) {
debug_event('UI::access_denied', "Streaming Access Denied: " . $_SERVER['REMOTE_ADDR'] . " does not have stream level access",'3');
if (!Access::check_network('stream', $GLOBALS['user']->id, '25') and
!Access::check_network('network', $GLOBALS['user']->id, '25')) {
debug_event('UI::access_denied', "Streaming Access Denied: " . $_SERVER['REMOTE_ADDR'] . " does not have stream level access", '3');
UI::access_denied();
exit;
}

View file

@ -20,7 +20,7 @@
*
*/
define('NO_SESSION','1');
define('NO_SESSION', '1');
require_once '../lib/init.php';
if (!AmpConfig::get('daap_backend')) {

View file

@ -37,7 +37,7 @@ switch ($_REQUEST['action']) {
$democratic->set_parent();
$democratic->format();
case 'show_create':
if (!Access::check('interface','75')) {
if (!Access::check('interface', '75')) {
UI::access_denied();
break;
}
@ -46,7 +46,7 @@ switch ($_REQUEST['action']) {
require_once AmpConfig::get('prefix') . UI::find_template('show_create_democratic.inc.php');
break;
case 'delete':
if (!Access::check('interface','75')) {
if (!Access::check('interface', '75')) {
UI::access_denied();
break;
}
@ -56,11 +56,11 @@ switch ($_REQUEST['action']) {
$title = '';
$text = T_('The Requested Playlist has been deleted.');
$url = AmpConfig::get('web_path') . '/democratic.php?action=manage_playlists';
show_confirmation($title,$text,$url);
show_confirmation($title, $text, $url);
break;
case 'create':
// Only power users here
if (!Access::check('interface','75')) {
if (!Access::check('interface', '75')) {
UI::access_denied();
break;
}
@ -89,7 +89,7 @@ switch ($_REQUEST['action']) {
header("Location: " . AmpConfig::get('web_path') . "/democratic.php?action=show");
break;
case 'manage_playlists':
if (!Access::check('interface','75')) {
if (!Access::check('interface', '75')) {
UI::access_denied();
break;
}

View file

@ -22,7 +22,7 @@
// This file is a little weird it needs to allow API session
// this needs to be done a little better, but for now... eah
define('NO_SESSION','1');
define('NO_SESSION', '1');
require_once 'lib/init.php';
// Check to see if they've got an interface session or a valid API session, if not GTFO

View file

@ -29,13 +29,13 @@
// This file is a little weird it needs to allow API session
// this needs to be done a little better, but for now... eah
define('NO_SESSION','1');
define('NO_SESSION', '1');
require_once 'lib/init.php';
if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
// Check to see if they've got an interface session or a valid API session, if not GTFO
if (!Session::exists('interface', $_COOKIE[AmpConfig::get('session_name')]) && !Session::exists('api', $_REQUEST['auth'])) {
debug_event('image','Access denied, checked cookie session:' . $_COOKIE[AmpConfig::get('session_name')] . ' and auth:' . $_REQUEST['auth'], 1);
debug_event('image', 'Access denied, checked cookie session:' . $_COOKIE[AmpConfig::get('session_name')] . ' and auth:' . $_REQUEST['auth'], 1);
exit;
}
}

View file

@ -101,7 +101,7 @@ if (!$htmllang) {
AmpConfig::set('lang', $htmllang, true);
AmpConfig::set('site_charset', $charset ?: 'UTF-8', true);
load_gettext();
header ('Content-Type: text/html; charset=' . AmpConfig::get('site_charset'));
header('Content-Type: text/html; charset=' . AmpConfig::get('site_charset'));
// Correct potential \ or / in the dirname
$safe_dirname = get_web_path();
@ -182,7 +182,7 @@ switch ($_REQUEST['action']) {
if (install_check_status($configfile)) {
require_once AmpConfig::get('prefix') . UI::find_template('show_install_account.inc.php');
} else {
header ("Location: " . $web_path . '/login.php');
header("Location: " . $web_path . '/login.php');
}
break;
case 'create_account':
@ -196,7 +196,7 @@ switch ($_REQUEST['action']) {
break;
}
header ("Location: " . $web_path . '/index.php');
header("Location: " . $web_path . '/index.php');
break;
case 'init':
require_once 'templates/show_install.inc.php';

View file

@ -60,12 +60,12 @@ switch ($_REQUEST['action']) {
break;
case 'add_label':
// Must be at least a content manager or edit upload enabled
if (!Access::check('interface','50') && !AmpConfig::get('upload_allow_edit')) {
if (!Access::check('interface', '50') && !AmpConfig::get('upload_allow_edit')) {
UI::access_denied();
exit;
}
if (!Core::form_verify('add_label','post')) {
if (!Core::form_verify('add_label', 'post')) {
UI::access_denied();
exit;
}
@ -104,7 +104,7 @@ switch ($_REQUEST['action']) {
exit;
}
case 'show_add_label':
if (Access::check('interface','50') || AmpConfig::get('upload_allow_edit')) {
if (Access::check('interface', '50') || AmpConfig::get('upload_allow_edit')) {
require_once AmpConfig::get('prefix') . UI::find_template('show_add_label.inc.php');
} else {
echo T_('Label cannot be found.');

View file

@ -47,7 +47,7 @@ function get_media_files($media_ids)
}
if ($media->enabled) {
$media->format();
$total_size += sprintf("%.2f",($media->size/1048576));
$total_size += sprintf("%.2f", ($media->size/1048576));
$dirname = '';
$parent = $media->get_parent();
if ($parent != null) {
@ -81,7 +81,7 @@ function send_zip($name, $media_files)
throw new Exception('Missing ZipStream dependency.');
}
$arc = new ZipStream\ZipStream($name . ".zip" );
$arc = new ZipStream\ZipStream($name . ".zip");
$options = array(
'comment' => AmpConfig::get('file_zip_comment'),
);

View file

@ -102,7 +102,7 @@ class Repository
$nameParts = explode('\\', $className);
$tableName = preg_replace_callback(
'/(?<=.)([A-Z])/',
function($m) {
function ($m) {
return '_' . strtolower($m[0]);
}, end($nameParts));
return lcfirst($tableName);
@ -225,6 +225,6 @@ class Repository
public function camelCaseToUnderscore($string)
{
return strtolower(preg_replace('/(?<=\\w)(?=[A-Z])/','_$1', $string));
return strtolower(preg_replace('/(?<=\\w)(?=[A-Z])/', '_$1', $string));
}
}

View file

@ -56,7 +56,7 @@ class Ajax
{
$non_quoted = array('document', 'window');
if (in_array($source,$non_quoted)) {
if (in_array($source, $non_quoted)) {
$source_txt = $source;
} else {
$source_txt = "'#$source'";
@ -105,7 +105,7 @@ class Ajax
$non_quoted = array('document','window');
if (in_array($source,$non_quoted)) {
if (in_array($source, $non_quoted)) {
$source_txt = $source;
} else {
$source_txt = "'$source'";

View file

@ -475,7 +475,7 @@ class Album extends database_object implements library_item
* @param string $artist
* @return int[]
*/
public function get_songs($limit = 0,$artist='')
public function get_songs($limit = 0, $artist='')
{
$results = array();
@ -881,7 +881,7 @@ class Album extends database_object implements library_item
// Update every song
$songs = $this->get_songs();
foreach ($songs as $song_id) {
Song::update_artist($artist,$song_id);
Song::update_artist($artist, $song_id);
}
$updated = true;
Artist::gc();
@ -898,8 +898,8 @@ class Album extends database_object implements library_item
$songs = $this->get_songs();
}
foreach ($songs as $song_id) {
Song::update_album($album_id,$song_id);
Song::update_year($year,$song_id);
Song::update_album($album_id, $song_id);
Song::update_year($year, $song_id);
Song::write_id3_for_song($song_id);
}
$current_id = $album_id;

View file

@ -66,7 +66,7 @@ class Ampache_RSS
$data_function = 'load_' . $this->type;
$pub_date_function = 'pubdate_' . $this->type;
$data = call_user_func(array('Ampache_RSS',$data_function));
$data = call_user_func(array('Ampache_RSS', $data_function));
$pub_date = null;
if (method_exists('Ampache_RSS', $pub_date_function)) {
$pub_date = call_user_func(array('Ampache_RSS', $pub_date_function));
@ -119,7 +119,7 @@ class Ampache_RSS
{
$valid_types = array('now_playing','recently_played','latest_album','latest_artist','latest_shout','podcast');
if (!in_array($type,$valid_types)) {
if (!in_array($type, $valid_types)) {
return 'now_playing';
}
@ -252,7 +252,7 @@ class Ampache_RSS
$amount = floor($amount/4);
}
if ($time_place == '6') {
$amount = floor ($amount/12);
$amount = floor($amount/12);
}
if ($time_place > '6') {
$final = $amount . '+';
@ -266,7 +266,7 @@ class Ampache_RSS
'link'=>str_replace('&amp;', '&', $song->link),
'description'=>$song->title . ' - ' . $song->f_artist_full . ' - ' . $song->f_album_full . ' - ' . $time_string,
'comments'=>$client->username,
'pubDate'=>date("r",$item['date']));
'pubDate'=>date("r", $item['date']));
$results[] = $xml_array;
}
} // end foreach

View file

@ -57,7 +57,7 @@ class AmpError
* This is a public static function it adds a new error message to the array
* It can optionally clobber rather then adding to the error message
*/
public static function add($name,$message,$clobber=0)
public static function add($name, $message, $clobber=0)
{
// Make sure its set first
if (!isset(AmpError::$errors[$name])) {
@ -139,7 +139,7 @@ class AmpError
// Re-insert them
foreach ($_SESSION['errors'] as $key=>$error) {
self::add($key,$error);
self::add($key, $error);
}
} // auto_init
} // Error

View file

@ -74,7 +74,7 @@ class Api
* @param int|string|boolean|null $value
* @return boolean
*/
public static function set_filter($filter,$value)
public static function set_filter($filter, $value)
{
if (!strlen($value)) {
return false;
@ -83,32 +83,32 @@ class Api
switch ($filter) {
case 'add':
// Check for a range, if no range default to gt
if (strpos($value,'/')) {
$elements = explode('/',$value);
self::$browse->set_filter('add_lt',strtotime($elements['1']));
self::$browse->set_filter('add_gt',strtotime($elements['0']));
if (strpos($value, '/')) {
$elements = explode('/', $value);
self::$browse->set_filter('add_lt', strtotime($elements['1']));
self::$browse->set_filter('add_gt', strtotime($elements['0']));
} else {
self::$browse->set_filter('add_gt',strtotime($value));
self::$browse->set_filter('add_gt', strtotime($value));
}
break;
case 'update':
// Check for a range, if no range default to gt
if (strpos($value,'/')) {
$elements = explode('/',$value);
self::$browse->set_filter('update_lt',strtotime($elements['1']));
self::$browse->set_filter('update_gt',strtotime($elements['0']));
if (strpos($value, '/')) {
$elements = explode('/', $value);
self::$browse->set_filter('update_lt', strtotime($elements['1']));
self::$browse->set_filter('update_gt', strtotime($elements['0']));
} else {
self::$browse->set_filter('update_gt',strtotime($value));
self::$browse->set_filter('update_gt', strtotime($value));
}
break;
case 'alpha_match':
self::$browse->set_filter('alpha_match',$value);
self::$browse->set_filter('alpha_match', $value);
break;
case 'exact_match':
self::$browse->set_filter('exact_match',$value);
self::$browse->set_filter('exact_match', $value);
break;
case 'enabled':
self::$browse->set_filter('enabled',$value);
self::$browse->set_filter('enabled', $value);
break;
default:
// Rien a faire
@ -259,10 +259,10 @@ class Api
echo XML_Data::keyed_array(array('auth'=>$token,
'api'=>self::$version,
'session_expire'=>date("c",time()+AmpConfig::get('session_length')-60),
'update'=>date("c",$row['update']),
'add'=>date("c",$row['add']),
'clean'=>date("c",$row['clean']),
'session_expire'=>date("c", time()+AmpConfig::get('session_length')-60),
'update'=>date("c", $row['update']),
'add'=>date("c", $row['add']),
'clean'=>date("c", $row['clean']),
'songs'=>$song['song'],
'albums'=>$album['album'],
'artists'=>$artist['artist'],
@ -273,7 +273,7 @@ class Api
} // match
} // end while
debug_event('API','Login Failed, unable to match passphrase','1');
debug_event('API', 'Login Failed, unable to match passphrase', '1');
echo XML_Data::error('401', T_('Error Invalid Handshake - ') . T_('Invalid Username/Password'));
return false;
@ -292,10 +292,10 @@ class Api
// Check and see if we should extend the api sessions (done if valid sess is passed)
if (Session::exists('api', $input['auth'])) {
Session::extend($input['auth']);
$xmldata = array_merge(array('session_expire'=>date("c",time()+AmpConfig::get('session_length')-60)),$xmldata);
$xmldata = array_merge(array('session_expire'=>date("c", time()+AmpConfig::get('session_length')-60)), $xmldata);
}
debug_event('API','Ping Received from ' . $_SERVER['REMOTE_ADDR'] . ' :: ' . $input['auth'],'5');
debug_event('API', 'Ping Received from ' . $_SERVER['REMOTE_ADDR'] . ' :: ' . $input['auth'], '5');
ob_end_clean();
echo XML_Data::keyed_array($xmldata);
@ -312,12 +312,12 @@ class Api
{
self::$browse->reset_filters();
self::$browse->set_type('artist');
self::$browse->set_sort('name','ASC');
self::$browse->set_sort('name', 'ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
Api::set_filter('add',$input['add']);
Api::set_filter('update',$input['update']);
Api::set_filter($method, $input['filter']);
Api::set_filter('add', $input['add']);
Api::set_filter('update', $input['update']);
// Set the offset
XML_Data::set_offset($input['offset']);
@ -385,11 +385,11 @@ class Api
{
self::$browse->reset_filters();
self::$browse->set_type('album');
self::$browse->set_sort('name','ASC');
self::$browse->set_sort('name', 'ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
Api::set_filter('add',$input['add']);
Api::set_filter('update',$input['update']);
Api::set_filter($method, $input['filter']);
Api::set_filter('add', $input['add']);
Api::set_filter('update', $input['update']);
$albums = self::$browse->get_objects();
@ -438,10 +438,10 @@ class Api
{
self::$browse->reset_filters();
self::$browse->set_type('tag');
self::$browse->set_sort('name','ASC');
self::$browse->set_sort('name', 'ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
Api::set_filter($method, $input['filter']);
$tags = self::$browse->get_objects();
// Set the offset
@ -471,7 +471,7 @@ class Api
*/
public static function tag_artists($input)
{
$artists = Tag::get_tag_objects('artist',$input['filter']);
$artists = Tag::get_tag_objects('artist', $input['filter']);
if ($artists) {
XML_Data::set_offset($input['offset']);
XML_Data::set_limit($input['limit']);
@ -488,7 +488,7 @@ class Api
*/
public static function tag_albums($input)
{
$albums = Tag::get_tag_objects('album',$input['filter']);
$albums = Tag::get_tag_objects('album', $input['filter']);
if ($albums) {
XML_Data::set_offset($input['offset']);
XML_Data::set_limit($input['limit']);
@ -505,7 +505,7 @@ class Api
*/
public static function tag_songs($input)
{
$songs = Tag::get_tag_objects('song',$input['filter']);
$songs = Tag::get_tag_objects('song', $input['filter']);
XML_Data::set_offset($input['offset']);
XML_Data::set_limit($input['limit']);
@ -523,14 +523,14 @@ class Api
{
self::$browse->reset_filters();
self::$browse->set_type('song');
self::$browse->set_sort('title','ASC');
self::$browse->set_sort('title', 'ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
Api::set_filter('add',$input['add']);
Api::set_filter('update',$input['update']);
Api::set_filter($method, $input['filter']);
Api::set_filter('add', $input['add']);
Api::set_filter('update', $input['update']);
// Filter out disabled songs
Api::set_filter('enabled','1');
Api::set_filter('enabled', '1');
$songs = self::$browse->get_objects();
@ -578,10 +578,10 @@ class Api
{
self::$browse->reset_filters();
self::$browse->set_type('playlist');
self::$browse->set_sort('name','ASC');
self::$browse->set_sort('name', 'ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
Api::set_filter($method, $input['filter']);
self::$browse->set_filter('playlist_type', '1');
$playlist_ids = self::$browse->get_objects();
@ -625,7 +625,7 @@ class Api
XML_Data::set_offset($input['offset']);
XML_Data::set_limit($input['limit']);
ob_end_clean();
echo XML_Data::songs($songs,$items);
echo XML_Data::songs($songs, $items);
} // playlist_songs
/**
@ -762,10 +762,10 @@ class Api
{
self::$browse->reset_filters();
self::$browse->set_type('video');
self::$browse->set_sort('title','ASC');
self::$browse->set_sort('title', 'ASC');
$method = $input['exact'] ? 'exact_match' : 'alpha_match';
Api::set_filter($method,$input['filter']);
Api::set_filter($method, $input['filter']);
$video_ids = self::$browse->get_objects();
@ -851,7 +851,7 @@ class Api
echo XML_Data::error('400', T_('Media Object Invalid or Not Specified'));
}
$uid = $democratic->get_uid_from_object_id($media->id,$type);
$uid = $democratic->get_uid_from_object_id($media->id, $type);
$democratic->remove_vote($uid);
// Everything was ok

View file

@ -211,7 +211,7 @@ class Art extends database_object
if (function_exists('ImageCreateFromString')) {
$image = @ImageCreateFromString($source);
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;
}
@imagedestroy($image);
@ -291,7 +291,7 @@ class Art extends database_object
$this->thumb = $data['thumb'];
$this->thumb_mime = $data['thumb_mime'];
} else {
debug_event('Art','Unable to retrieve or generate thumbnail for ' . $this->type . '::' . $this->id,1);
debug_event('Art', 'Unable to retrieve or generate thumbnail for ' . $this->type . '::' . $this->id, 1);
}
} // if no thumb, but art and we want to resize
@ -514,7 +514,7 @@ class Art extends database_object
}
$fp = fopen($path, "wb");
fwrite($fp, $source);
fclose ($fp);
fclose($fp);
return true;
}
@ -662,7 +662,7 @@ class Art extends database_object
*/
public function generate_thumb($image, $size, $mime)
{
$data = explode("/",$mime);
$data = explode("/", $mime);
$type = strtolower($data['1']);
if (!self::test_image($image)) {
@ -671,32 +671,32 @@ class Art extends database_object
}
if (!function_exists('gd_info')) {
debug_event('Art','PHP-GD Not found - unable to resize art',1);
debug_event('Art', 'PHP-GD Not found - unable to resize art', 1);
return false;
}
// Check and make sure we can resize what you've asked us to
if (($type == 'jpg' or $type == 'jpeg') and !(imagetypes() & IMG_JPG)) {
debug_event('Art','PHP-GD Does not support JPGs - unable to resize',1);
debug_event('Art', 'PHP-GD Does not support JPGs - unable to resize', 1);
return false;
}
if ($type == 'png' and !imagetypes() & IMG_PNG) {
debug_event('Art','PHP-GD Does not support PNGs - unable to resize',1);
debug_event('Art', 'PHP-GD Does not support PNGs - unable to resize', 1);
return false;
}
if ($type == 'gif' and !imagetypes() & IMG_GIF) {
debug_event('Art','PHP-GD Does not support GIFs - unable to resize',1);
debug_event('Art', 'PHP-GD Does not support GIFs - unable to resize', 1);
return false;
}
if ($type == 'bmp' and !imagetypes() & IMG_WBMP) {
debug_event('Art','PHP-GD Does not support BMPs - unable to resize',1);
debug_event('Art', 'PHP-GD Does not support BMPs - unable to resize', 1);
return false;
}
$source = imagecreatefromstring($image);
if (!$source) {
debug_event('Art','Failed to create Image from string - Source Image is damaged / malformed',1);
debug_event('Art', 'Failed to create Image from string - Source Image is damaged / malformed', 1);
return false;
}
@ -706,7 +706,7 @@ class Art extends database_object
$thumbnail = imagecreatetruecolor($size['width'], $size['height']);
if (!imagecopyresampled($thumbnail, $source, 0, 0, 0, 0, $size['width'], $size['height'], $source_size['width'], $source_size['height'])) {
debug_event('Art','Unable to create resized image',1);
debug_event('Art', 'Unable to create resized image', 1);
imagedestroy($source);
imagedestroy($thumbnail);
return false;
@ -796,8 +796,8 @@ class Art extends database_object
// Check to see if it's a FILE
if (isset($data['file'])) {
$handle = fopen($data['file'],'rb');
$image_data = fread($handle,Core::get_filesize($data['file']));
$handle = fopen($data['file'], 'rb');
$image_data = fread($handle, Core::get_filesize($data['file']));
fclose($handle);
return $image_data;
}
@ -830,7 +830,7 @@ class Art extends database_object
* @param int|null $thumb
* @return string
*/
public static function url($uid,$type,$sid=null,$thumb=null)
public static function url($uid, $type, $sid=null, $thumb=null)
{
if (!self::is_valid_type($type)) {
return null;
@ -1006,7 +1006,7 @@ class Art extends database_object
$config = array($config);
}
debug_event('Art','Searching using:' . json_encode($config), 3);
debug_event('Art', 'Searching using:' . json_encode($config), 3);
$plugin_names = Plugin::get_plugins('gather_arts');
foreach ($config as $method) {
@ -1044,7 +1044,7 @@ class Art extends database_object
// Add the results we got to the current set
$results = array_merge($results, (array) $data);
debug_event('Art','results:' . json_encode($results), 3);
debug_event('Art', 'results:' . json_encode($results), 3);
if ($limit && count($results) >= $limit) {
return array_slice($results, 0, $limit);
@ -1200,7 +1200,7 @@ class Art extends database_object
);
foreach ($release->relations as $ar) {
$arurl = $ar->url->resource;
debug_event('mbz-gatherart', "Found URL AR: " . $arurl , '5');
debug_event('mbz-gatherart', "Found URL AR: " . $arurl, '5');
foreach ($coverartsites as $casite) {
if (strpos($arurl, $casite['domain']) !== false) {
debug_event('mbz-gatherart', "Matched coverart site: " . $casite['name'], '5');
@ -1263,12 +1263,12 @@ class Art extends database_object
$songs = $media->get_songs();
foreach ($songs as $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') {
$media = new Video($this->uid);
$dirs[] = Core::conv_lc_file( dirname($media->file) );
$dirs[] = Core::conv_lc_file(dirname($media->file));
}
}

View file

@ -140,7 +140,7 @@ class Artist extends database_object implements library_item
* @param int|null $id
* @param int $catalog_init
*/
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 (!$id) {
@ -210,7 +210,7 @@ class Artist extends database_object implements library_item
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('artist',$row['id'],$row);
parent::add_to_cache('artist', $row['id'], $row);
}
// If we need to also pull the extra information, this is normally only used when we are doing the human display
@ -224,7 +224,7 @@ class Artist extends database_object implements library_item
if (AmpConfig::get('show_played_times')) {
$row['object_cnt'] = Stats::get_object_count('artist', $row['artist'], $limit_threshold);
}
parent::add_to_cache('artist_extra',$row['artist'],$row);
parent::add_to_cache('artist_extra', $row['artist'], $row);
}
} // end if extra
@ -391,8 +391,8 @@ class Artist extends database_object implements library_item
private function _get_extra_info($catalog=0, $limit_threshold ='')
{
// Try to find it in the cache and save ourselves the trouble
if (parent::is_cached('artist_extra',$this->id) ) {
$row = parent::get_from_cache('artist_extra',$this->id);
if (parent::is_cached('artist_extra', $this->id)) {
$row = parent::get_from_cache('artist_extra', $this->id);
} else {
$params = array($this->id);
// Calculation
@ -421,7 +421,7 @@ class Artist extends database_object implements library_item
if (AmpConfig::get('show_played_times')) {
$row['object_cnt'] = Stats::get_object_count('artist', $row['artist'], $limit_threshold);
}
parent::add_to_cache('artist_extra',$row['artist'],$row);
parent::add_to_cache('artist_extra', $row['artist'], $row);
}
/* Set Object Vars */
@ -466,12 +466,12 @@ class Artist extends database_object implements library_item
$extra_info = $this->_get_extra_info($this->catalog_id, $limit_threshold);
//Format the new time thingy that we just got
$min = sprintf("%02d",(floor($extra_info['time']/60)%60));
$min = sprintf("%02d", (floor($extra_info['time']/60)%60));
$sec = sprintf("%02d",($extra_info['time']%60));
$sec = sprintf("%02d", ($extra_info['time']%60));
$hours = floor($extra_info['time']/3600);
$this->f_time = ltrim($hours . ':' . $min . ':' . $sec,'0:');
$this->f_time = ltrim($hours . ':' . $min . ':' . $sec, '0:');
$this->tags = Tag::get_top_tags('artist', $this->id);
$this->f_tags = Tag::get_display($this->tags, true, 'artist');
@ -775,7 +775,7 @@ class Artist extends database_object implements library_item
if ($artist_id != null && $artist_id != $this->id) {
$songs = $this->get_songs();
foreach ($songs as $song_id) {
Song::update_artist($artist_id,$song_id);
Song::update_artist($artist_id, $song_id);
}
$updated = true;
$current_id = $artist_id;

View file

@ -45,7 +45,7 @@ class Bookmark extends database_object
* This is run every time a new object is created, and requires
* the id and type of object that we need to pull for
*/
public function __construct ($object_id, $object_type = null, $user_id = null)
public function __construct($object_id, $object_type = null, $user_id = null)
{
if (!$object_id) {
return false;

View file

@ -1225,7 +1225,7 @@ abstract class Catalog extends database_object
// If they've enabled resizing of images generate a thumbnail
if (AmpConfig::get('resize_images')) {
$size = array('width' => 275, 'height' => 275);
$thumb = $art->generate_thumb($image,$size ,$result['mime']);
$thumb = $art->generate_thumb($image, $size, $result['mime']);
if (is_array($thumb)) {
$art->save_thumb($thumb['thumb'], $thumb['thumb_mime'], $size);
}
@ -2293,7 +2293,7 @@ abstract class Catalog extends database_object
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')));
}
public static function process_action($action, $catalogs, $options = null)
@ -2377,7 +2377,7 @@ abstract class Catalog extends database_object
if ($catalog_id = Catalog_local::get_from_path($options['update_path'])) {
$songs = Song::get_from_path($options['update_path']);
foreach ($songs as $song_id) {
Catalog::update_single_item('song',$song_id);
Catalog::update_single_item('song', $song_id);
}
}
} // end if update

View file

@ -181,8 +181,8 @@ class Channel extends database_object implements media, library_item
{
if ($this->id) {
if ($GLOBALS['user']->has_access('75')) {
echo Ajax::button('?page=index&action=start_channel&id=' . $this->id,'run', T_('Start Channel'),'channel_start_' . $this->id);
echo " " . Ajax::button('?page=index&action=stop_channel&id=' . $this->id,'stop', T_('Stop Channel'),'channel_stop_' . $this->id);
echo Ajax::button('?page=index&action=start_channel&id=' . $this->id, 'run', T_('Start Channel'), 'channel_start_' . $this->id);
echo " " . Ajax::button('?page=index&action=stop_channel&id=' . $this->id, 'stop', T_('Stop Channel'), 'channel_stop_' . $this->id);
echo " <a id=\"edit_channel_ " . $this->id . "\" onclick=\"showEditDialog('channel_row', '" . $this->id . "', 'edit_channel_" . $this->id . "', '" . T_('Channel edit') . "', 'channel_row_', 'refresh_channel')\">" . UI::get_icon('edit', T_('Edit')) . "</a>";
echo " <a href=\"" . AmpConfig::get('web_path') . "/channel.php?action=show_delete&id=" . $this->id . "\">" . UI::get_icon('delete', T_('Delete')) . "</a>";
}
@ -542,7 +542,7 @@ class Channel extends database_object implements media, library_item
{
$s='';
foreach (str_split($x) as $c) {
$s.=sprintf("%02X",ord($c));
$s.=sprintf("%02X", ord($c));
}
return($s);
}

View file

@ -338,8 +338,8 @@ class Core
*/
public static function is_session_started()
{
if (php_sapi_name() !== 'cli' ) {
if (version_compare(phpversion(), '5.4.0', '>=') ) {
if (php_sapi_name() !== 'cli') {
if (version_compare(phpversion(), '5.4.0', '>=')) {
return session_status() === PHP_SESSION_ACTIVE ? true : false;
} else {
return session_id() === '' ? false : true;

View file

@ -40,7 +40,7 @@ abstract class database_object
* get_info
* retrieves the info from the database and puts it in the cache
*/
public function get_info($id,$table_name='')
public function get_info($id, $table_name='')
{
$table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));
@ -49,8 +49,8 @@ abstract class database_object
return array();
}
if (self::is_cached($table_name,$id)) {
return self::get_from_cache($table_name,$id);
if (self::is_cached($table_name, $id)) {
return self::get_from_cache($table_name, $id);
}
$sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
@ -62,7 +62,7 @@ abstract class database_object
$row = Dba::fetch_assoc($db_results);
self::add_to_cache($table_name,$id,$row);
self::add_to_cache($table_name, $id, $row);
return $row;
} // get_info
@ -123,7 +123,7 @@ abstract class database_object
* This function clears something from the cache, there are a few places we need to do this
* in order to have things display correctly
*/
public static function remove_from_cache($index,$id)
public static function remove_from_cache($index, $id)
{
if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
unset(self::$object_cache[$index][$id]);

View file

@ -532,11 +532,11 @@ class Dba
if (
(strpos($table['Type'], 'varchar') !== false) ||
(strpos($table['Type'], 'enum') !== false) ||
(strpos($table['Table'],'text') !== false)) {
(strpos($table['Table'], 'text') !== false)) {
$sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset;
$charset_results = Dba::write($sql);
if (!$charset_results) {
debug_event('CHARSET','Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset,'3');
debug_event('CHARSET', 'Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset, '3');
} // if it fails
}
}

View file

@ -132,14 +132,14 @@ class Democratic extends Tmp_Playlist
//FIXME: Code in single user stuff
$preference_id = Preference::id_from_name('play_type');
Preference::update_level($preference_id,'75');
Preference::update_all($preference_id,'democratic');
Preference::update_level($preference_id, '75');
Preference::update_all($preference_id, 'democratic');
$allow_demo = Preference::id_from_name('allow_democratic_playback');
Preference::update_all($allow_demo,'1');
Preference::update_all($allow_demo, '1');
$play_method = Preference::id_from_name('playlist_method');
Preference::update_all($play_method,'clear');
Preference::update_all($play_method, 'clear');
return true;
} // set_user_preferences
@ -470,14 +470,14 @@ class Democratic extends Tmp_Playlist
* delete_from_oid
* This takes an OID and type and removes the object from the democratic playlist
*/
public function delete_from_oid($oid,$object_type)
public function delete_from_oid($oid, $object_type)
{
$row_id = $this->get_uid_from_object_id($oid,$object_type);
$row_id = $this->get_uid_from_object_id($oid, $object_type);
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);
} else {
debug_event('Democratic','Unable to find Votes for ' . $oid . ' of type ' . $object_type,'3');
debug_event('Democratic', 'Unable to find Votes for ' . $oid . ' of type ' . $object_type, '3');
}
return true;

View file

@ -300,51 +300,51 @@ class Graph
$height = 260;
}
$MyData->setSerieDescription("TimeStamp","time");
$MyData->setSerieDescription("TimeStamp", "time");
$MyData->setAbscissa("TimeStamp");
switch ($zoom) {
case 'hour':
$MyData->setXAxisDisplay(AXIS_FORMAT_TIME,"H:00");
$MyData->setXAxisDisplay(AXIS_FORMAT_TIME, "H:00");
break;
case 'year':
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE,"Y");
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "Y");
break;
case 'month':
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE,"Y-m");
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "Y-m");
break;
case 'day':
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE,"Y-m-d");
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE, "Y-m-d");
break;
}
/* Create the pChart object */
$myPicture = new CpChart\Classes\pImage($width,$height,$MyData);
$myPicture = new CpChart\Classes\pImage($width, $height, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = false;
/* Draw a background */
$Settings = array("R"=>90, "G"=>90, "B"=>90, "Dash"=>1, "DashR"=>120, "DashG"=>120, "DashB"=>120);
$myPicture->drawFilledRectangle(0,0,$width,$height,$Settings);
$myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR"=>200, "StartG"=>200, "StartB"=>200, "EndR"=>50, "EndG"=>50, "EndB"=>50, "Alpha"=>50);
$myPicture->drawGradientArea(0,0,$width,$height,DIRECTION_VERTICAL,$Settings);
$myPicture->drawGradientArea(0,0,$width,$height,DIRECTION_HORIZONTAL,$Settings);
$myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_HORIZONTAL, $Settings);
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,$width-1,$height-1,array("R"=>0,"G"=>0,"B"=>0));
$myPicture->drawRectangle(0, 0, $width-1, $height-1, array("R"=>0, "G"=>0, "B"=>0));
$font_path = AmpConfig::get('prefix') . "/lib/vendor/szymach/c-pchart/src/Resources/fonts";
/* Write the chart title */
$myPicture->setFontProperties(array("FontName"=>$font_path . "/Forgotte.ttf","FontSize"=>11));
$myPicture->drawText(150,35,$title,array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
$myPicture->setFontProperties(array("FontName"=>$font_path . "/Forgotte.ttf", "FontSize"=>11));
$myPicture->drawText(150, 35, $title, array("FontSize"=>20, "Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>$font_path . "/pf_arma_five.ttf","FontSize"=>6));
$myPicture->setFontProperties(array("FontName"=>$font_path . "/pf_arma_five.ttf", "FontSize"=>6));
/* Define the chart area */
$myPicture->setGraphArea(60,40,$width-20,$height-50);
$myPicture->setGraphArea(60, 40, $width-20, $height-50);
/* Draw the scale */
$scaleSettings = array("XMargin"=>10,"YMargin"=>10,"Floating"=>true,"GridR"=>200,"GridG"=>200,"GridB"=>200,"RemoveSkippedAxis"=>true,"DrawSubTicks"=>false,"Mode"=>SCALE_MODE_START0,"LabelRotation"=>45,"LabelingMethod"=>LABELING_DIFFERENT);
@ -354,14 +354,14 @@ class Graph
$myPicture->Antialias = true;
/* Draw the line chart */
$myPicture->setShadow(true,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->setShadow(true, array("X"=>1, "Y"=>1, "R"=>0, "G"=>0, "B"=>0, "Alpha"=>10));
$myPicture->drawLineChart();
/* Write a label over the chart */
$myPicture->writeLabel("Inbound",720);
$myPicture->writeLabel("Inbound", 720);
/* Write the chart legend */
$myPicture->drawLegend(280,20,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
$myPicture->drawLegend(280, 20, array("Style"=>LEGEND_NOBORDER, "Mode"=>LEGEND_HORIZONTAL));
header("Content-Disposition: filename=\"ampache-graph.png\"");
/* Render the picture (choose the best way) */
@ -474,7 +474,7 @@ class Graph
}
}
if (($owner_id <= 0 || $owner_id != $GLOBALS['user']->id) && !Access::check('interface','50')) {
if (($owner_id <= 0 || $owner_id != $GLOBALS['user']->id) && !Access::check('interface', '50')) {
UI::access_denied();
} else {
$user_id = $_REQUEST['user_id'];

View file

@ -27,11 +27,11 @@
* This function is here for retrocompatibility with PHP < 5.6.
* For PHP >= 5.6, one can use array_filter with flag ARRAY_FILTER_USE_KEY.
*/
function array_filter_key ($array, $callback)
function array_filter_key($array, $callback)
{
foreach ($array as $key => $value) {
if (! call_user_func ($callback, $key)) {
unset ($array[$key]);
if (! call_user_func($callback, $key)) {
unset($array[$key]);
}
}
return $array;
@ -60,14 +60,14 @@ class LDAPException extends Exception
*
* @param mixed $message
*/
public function __construct ($message)
public function __construct($message)
{
if (is_int ($message)) {
if (is_int($message)) {
$message = 'LDAP error: [' . $message . '] ' . ldap_err2str($message);
}
debug_event('LDAP', 'Exception: ' . $message, 6);
parent::__construct ($message);
parent::__construct($message);
}
}
@ -98,7 +98,7 @@ class LDAP
* This function is here to return a real array {number} => {field} => {value array}
* instead of the custom LDAP search results provided by the ldap_* library.
*/
private static function clean_search_results ($sr)
private static function clean_search_results($sr)
{
$sr_clean = [];
@ -106,7 +106,7 @@ class LDAP
$sr_clean[$i] = [];
foreach ($result as $field => $values) {
if ($field == 'count' || is_int ($field)) {
if ($field == 'count' || is_int($field)) {
continue;
} elseif ($field == 'dn') {
$sr_clean[$i][$field] = $values;
@ -129,23 +129,23 @@ class LDAP
* the given parameters are plausibe and can be used to open a
* connection as soon as one is needed.
*/
private static function connect ()
private static function connect()
{
if (! $url = AmpConfig::get('ldap_url')) {
throw new LDAPException('Required configuration value missing: ldap_url');
}
if (! $link = ldap_connect ($url)) {
if (! $link = ldap_connect($url)) {
throw new LDAPException('Could not connect to ' . $url);
}
$protocol_version = AmpConfig::get('ldap_protocol_version', 3);
if (! ldap_set_option ($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version)) {
if (! ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version)) {
throw new LDAPException('Could not set option PROTOCOL_VERSION to ' . $protocol_version);
}
if (AmpConfig::get('ldap_start_tls', "false") != "false") {
if (! ldap_start_tls ($link)) {
if (! ldap_start_tls($link)) {
throw new LDAPException('Could not use StartTLS');
}
}
@ -157,7 +157,7 @@ class LDAP
/**
* Binds to the LDAP
*/
private static function bind ($link, $username = null, $password = null)
private static function bind($link, $username = null, $password = null)
{
debug_event('LDAP', "binding with username `$username`", 5);
@ -166,7 +166,7 @@ class LDAP
$password = AmpConfig::get('ldap_password', '');
}
if (! ldap_bind ($link, $username, $password)) {
if (! ldap_bind($link, $username, $password)) {
throw new LDAPException("Could not bind to server using username `$username`");
}
}
@ -175,25 +175,25 @@ class LDAP
/**
* Unbinds from the LDAP
*/
private static function unbind ($link)
private static function unbind($link)
{
ldap_unbind ($link);
ldap_unbind($link);
}
/**
* Read attributes for a DN from the LDAP
*/
private static function read ($link, $dn, $attrs = [], $filter='objectClass=*')
private static function read($link, $dn, $attrs = [], $filter='objectClass=*')
{
$attrs_json = json_encode ($attrs);
$attrs_json = json_encode($attrs);
debug_event('LDAP', "reading attributes $attrs_json in `$dn`", 5);
if (! $result = ldap_read ($link, $dn, $filter, $attrs)) {
if (! $result = ldap_read($link, $dn, $filter, $attrs)) {
throw new LDAPException("Could not read attributes `$attrs_json` for dn `$dn`");
}
if (! $infos = ldap_get_entries ($link, $result)) {
if (! $infos = ldap_get_entries($link, $result)) {
throw new LDAPException("Empty search result for dn `$dn`");
}
@ -204,24 +204,24 @@ class LDAP
/**
* Search for a DN in the LDAP
*/
private static function search ($link, $base_dn, $filter, $only_one_result = true)
private static function search($link, $base_dn, $filter, $only_one_result = true)
{
debug_event('LDAP', "searching in `$base_dn` for `$filter`", 5);
if (! $result = ldap_search ($link, $base_dn, $filter)) {
if (! $result = ldap_search($link, $base_dn, $filter)) {
throw new LDAPException(ldap_errno($link));
}
$entries = ldap_get_entries ($link, $result);
$entries = ldap_get_entries($link, $result);
$entries = self::clean_search_results($entries);
if ($only_one_result) {
if (count ($entries) < 1) {
if (count($entries) < 1) {
throw new LDAPException("Empty search results for filter `$filter`");
}
if (count ($entries) > 1) {
if (count($entries) > 1) {
throw new LDAPException("Too many search results for filter `$filter`");
}
@ -243,10 +243,10 @@ class LDAP
* @param string $password
* @return array
*/
public static function auth ($username, $password)
public static function auth($username, $password)
{
try {
$link = self::connect ();
$link = self::connect();
self::bind($link);
/* Search for the user with given base_dn, filter, objectclass and username */
@ -255,7 +255,7 @@ class LDAP
throw new LDAPException('Required configuration value missing: ldap_filter');
}
if (strpos ($filter, '%v') !== false) {
if (strpos($filter, '%v') !== false) {
$filter = str_replace('%v', $username, $filter);
} else {
$filter = "($filter=$username)"; // Backward compatibility
@ -266,23 +266,23 @@ class LDAP
}
$search = "(&(objectclass=$objectclass)$filter)";
debug_event ('LDAP', 'search: ' . $search, 5);
debug_event('LDAP', 'search: ' . $search, 5);
if (! $base_dn = AmpConfig::get('ldap_search_dn')) {
throw new LDAPException('Required configuration value missing: ldap_search_dn');
}
$user_entry = self::search ($link, $base_dn, $search, true);
$user_entry = self::search($link, $base_dn, $search, true);
$user_dn = $user_entry['dn'];
self::bind ($link, $user_dn, $password);
self::bind($link, $user_dn, $password);
/* Test if the user is in the required group (optional) */
if ($group_dn = AmpConfig::get('ldap_require_group')) {
$member_attribute = AmpConfig::get('ldap_member_attribute', 'member');
$group_infos = self::read ($link, $group_dn, [$member_attribute]);
$group_infos = self::read($link, $group_dn, [$member_attribute]);
if (! preg_grep("/^$user_dn\$/i", $group_infos[$member_attribute])) {
throw new LDAPException("`$user_dn` is not member of the group `$group_dn`");
@ -331,8 +331,8 @@ class LDAP
];
}
if (isset ($link)) {
self::unbind ($link);
if (isset($link)) {
self::unbind($link);
}
debug_event('LDAP', 'Return value of authentication: ' . json_encode($return_value), 5);

View file

@ -193,9 +193,9 @@ class Live_Stream extends database_object implements media, library_item
$allowed_array = array('https','http','mms','mmsh','mmsu','mmst','rtsp','rtmp');
$elements = explode(":",$data['url']);
$elements = explode(":", $data['url']);
if (!in_array($elements['0'],$allowed_array)) {
if (!in_array($elements['0'], $allowed_array)) {
AmpError::add('general', T_('Invalid URL must be mms:// , https:// or http://'));
}

View file

@ -104,14 +104,14 @@ class Localplay
if (!$include) {
/* Throw Error Here */
debug_event('localplay','Unable to load ' . $this->type . ' controller','2');
debug_event('localplay', 'Unable to load ' . $this->type . ' controller', '2');
return false;
} // include
else {
$class_name = "Ampache" . $this->type;
$this->_player = new $class_name();
if (!($this->_player instanceof localplay_controller)) {
debug_event('Localplay',$this->type . ' not an instance of controller abstract, unable to load','1');
debug_event('Localplay', $this->type . ' not an instance of controller abstract, unable to load', '1');
unset($this->_player);
return false;
}
@ -124,10 +124,10 @@ class Localplay
* is supported in the current player, if so it returns a 'skip to'
* link, otherwise it returns just the text
*/
public function format_name($name,$id)
public function format_name($name, $id)
{
$name = scrub_out($name);
$name = Ajax::text('?page=localplay&action=command&command=skip&id=' . $id,$name,'localplay_skip_' . $id);
$name = Ajax::text('?page=localplay&action=command&command=skip&id=' . $id, $name, 'localplay_skip_' . $id);
return $name;
} // format_name
@ -142,7 +142,7 @@ class Localplay
$handle = opendir($basedir);
if (!is_resource($handle)) {
debug_event('Localplay','Error: Unable to read localplay controller directory','1');
debug_event('Localplay', 'Error: Unable to read localplay controller directory', '1');
return array();
}
@ -212,7 +212,7 @@ class Localplay
// If its our current player, reset player to nothing
if (AmpConfig::get('localplay_controller') == $this->type) {
Preference::update('localplay_controller',$GLOBALS['user']->id,'');
Preference::update('localplay_controller', $GLOBALS['user']->id, '');
}
return true;
@ -226,7 +226,7 @@ class Localplay
public function connect()
{
if (!$this->_player->connect()) {
debug_event('localplay','Error Unable to connect, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error Unable to connect, check ' . $this->type . ' controller', '1');
return false;
}
@ -241,7 +241,7 @@ class Localplay
public function play()
{
if (!$this->_player->play()) {
debug_event('localplay','Error Unable to start playback, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error Unable to start playback, check ' . $this->type . ' controller', '1');
return false;
}
@ -256,7 +256,7 @@ class Localplay
public function stop()
{
if (!$this->_player->stop()) {
debug_event('localplay','Error Unable to stop playback, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error Unable to stop playback, check ' . $this->type . ' controller', '1');
return false;
}
@ -296,7 +296,7 @@ class Localplay
$data = $this->_player->repeat($state);
if (!$data) {
debug_event('localplay',"Error Unable to set Repeat to $state",'1');
debug_event('localplay', "Error Unable to set Repeat to $state", '1');
}
return $data;
@ -312,7 +312,7 @@ class Localplay
$data = $this->_player->random($state);
if (!$data) {
debug_event('localplay',"Error Unable to set Random to $state",'1');
debug_event('localplay', "Error Unable to set Random to $state", '1');
}
return $data;
@ -328,7 +328,7 @@ class Localplay
$data = $this->_player->status();
if (!count($data)) {
debug_event('localplay','Error Unable to get status, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error Unable to get status, check ' . $this->type . ' controller', '1');
return false;
}
@ -346,7 +346,7 @@ class Localplay
$data = $this->_player->get();
if (!count($data) or !is_array($data)) {
debug_event('localplay','Error Unable to get song info, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error Unable to get song info, check ' . $this->type . ' controller', '1');
return array();
}
@ -370,7 +370,7 @@ class Localplay
}
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');
return false;
}
@ -385,7 +385,7 @@ class Localplay
public function volume_up()
{
if (!$this->_player->volume_up()) {
debug_event('localplay','Error: Unable to increase volume, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error: Unable to increase volume, check ' . $this->type . ' controller', '1');
return false;
}
@ -400,7 +400,7 @@ class Localplay
public function volume_down()
{
if (!$this->_player->volume_down()) {
debug_event('localplay','Error: Unable to decrese volume, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error: Unable to decrese volume, check ' . $this->type . ' controller', '1');
return false;
}
@ -415,7 +415,7 @@ class Localplay
public function volume_mute()
{
if (!$this->_player->volume(0)) {
debug_event('localplay','Error: Unable to mute volume, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error: Unable to mute volume, check ' . $this->type . ' controller', '1');
return false;
}
@ -429,7 +429,7 @@ class Localplay
public function skip($track_id)
{
if (!$this->_player->skip($track_id)) {
debug_event('localplay','Error: Unable to skip to next song, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error: Unable to skip to next song, check ' . $this->type . ' controller', '1');
return false;
}
@ -444,7 +444,7 @@ class Localplay
public function next()
{
if (!$this->_player->next()) {
debug_event('localplay','Error: Unable to skip to next song, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error: Unable to skip to next song, check ' . $this->type . ' controller', '1');
return false;
}
@ -459,7 +459,7 @@ class Localplay
public function prev()
{
if (!$this->_player->prev()) {
debug_event('localplay','Error: Unable to skip to previous song, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error: Unable to skip to previous song, check ' . $this->type . ' controller', '1');
return false;
}
@ -474,7 +474,7 @@ class Localplay
public function pause()
{
if (!$this->_player->pause()) {
debug_event('localplay','Error: Unable to pause song, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error: Unable to pause song, check ' . $this->type . ' controller', '1');
return false;
}
@ -518,9 +518,9 @@ class Localplay
* update_instance
* This updates the specified instance with a named array of data (_POST most likely)
*/
public function update_instance($uid,$data)
public function update_instance($uid, $data)
{
$data = $this->_player->update_instance($uid,$data);
$data = $this->_player->update_instance($uid, $data);
return $data;
} // update_instance
@ -560,7 +560,7 @@ class Localplay
public function delete_track($object_id)
{
if (!$this->_player->delete_track($object_id)) {
debug_event('localplay','Error: Unable to remove songs, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error: Unable to remove songs, check ' . $this->type . ' controller', '1');
return false;
}
@ -576,7 +576,7 @@ class Localplay
public function delete_all()
{
if (!$this->_player->clear_playlist()) {
debug_event('localplay','Error: Unable to delete entire playlist, check ' . $this->type . ' controller','1');
debug_event('localplay', 'Error: Unable to delete entire playlist, check ' . $this->type . ' controller', '1');
return false;
}
@ -629,7 +629,7 @@ class Localplay
/* This is a cheezball fix for when we were unable to find a
* artist/album (or one wasn't provided)
*/
$track_name = ltrim(ltrim($track_name,' - '),' - ');
$track_name = ltrim(ltrim($track_name, ' - '), ' - ');
$track_name = "[" . $status['track'] . "] - " . $track_name;

View file

@ -45,7 +45,7 @@ abstract class localplay_controller
// For display we need the following 'instance' functions
abstract public function add_instance($data);
abstract public function delete_instance($id);
abstract public function update_instance($id,$post);
abstract public function update_instance($id, $post);
abstract public function get_instances();
abstract public function instance_fields();
abstract public function set_active_instance($uid);
@ -65,7 +65,7 @@ abstract class localplay_controller
$class = get_class($object);
$url = call_user_func(array($class,'play_url'),$object->id);
$url = call_user_func(array($class, 'play_url'), $object->id);
return $url;
} // get_url
@ -92,9 +92,9 @@ abstract class localplay_controller
$primary_array = array('oid','demo_id','random');
$data = array();
$variables = parse_url($url,PHP_URL_QUERY);
$variables = parse_url($url, PHP_URL_QUERY);
if ($variables) {
parse_str($variables,$data);
parse_str($variables, $data);
foreach ($primary_array as $pkey) {
if ($data[$pkey]) {

View file

@ -78,13 +78,13 @@ class Playlist extends playlist_object
return false;
}
$idlist = '(' . implode(',',$ids) . ')';
$idlist = '(' . implode(',', $ids) . ')';
$sql = "SELECT * FROM `playlist` WHERE `id` IN $idlist";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('playlist',$row['id'],$row);
parent::add_to_cache('playlist', $row['id'], $row);
}
} // build_cache
@ -300,7 +300,7 @@ class Playlist extends playlist_object
*/
private function update_type($new_type)
{
if ($this->_update_item('type',$new_type,50)) {
if ($this->_update_item('type', $new_type, 50)) {
$this->type = $new_type;
}
} // update_type
@ -311,7 +311,7 @@ class Playlist extends playlist_object
*/
private function update_name($new_name)
{
if ($this->_update_item('name',$new_name,50)) {
if ($this->_update_item('name', $new_name, 50)) {
$this->name = $new_name;
}
} // update_name
@ -323,7 +323,7 @@ class Playlist extends playlist_object
private function update_last_update()
{
$last_update = time();
if ($this->_update_item('last_update',$last_update,50)) {
if ($this->_update_item('last_update', $last_update, 50)) {
$this->last_update = $last_update;
}
} // update_last_update
@ -332,9 +332,9 @@ class Playlist extends playlist_object
* _update_item
* This is the generic update function, it does the escaping and error checking
*/
private function _update_item($field,$value,$level)
private function _update_item($field, $value, $level)
{
if ($GLOBALS['user']->id != $this->user && !Access::check('interface',$level)) {
if ($GLOBALS['user']->id != $this->user && !Access::check('interface', $level)) {
return false;
}

View file

@ -119,7 +119,7 @@ class Plex_Api
// Need to get a match between Plex and Ampache users
if ($match_users) {
if (!AmpConfig::get('access_control')) {
debug_event('Access Control', 'Error Attempted to use Plex with Access Control turned off and plex/ampache link enabled.','3');
debug_event('Access Control', 'Error Attempted to use Plex with Access Control turned off and plex/ampache link enabled.', '3');
self::createError(401);
}
@ -333,7 +333,7 @@ class Plex_Api
public static function registerMyPlex($authtoken)
{
$headers = array (
$headers = array(
'Content-Type: text/xml'
);
$action = 'servers.xml?auth_token=' . $authtoken;
@ -352,7 +352,7 @@ class Plex_Api
public static function publishDeviceConnection($authtoken)
{
$headers = array ();
$headers = array();
$action = 'devices/' . Plex_XML_Data::getMachineIdentifier() . '?Connection[][uri]=' . Plex_XML_Data::getServerUri() . '&X-Plex-Token=' . $authtoken;
$curlopts = array(
CURLOPT_CUSTOMREQUEST => "PUT"
@ -363,7 +363,7 @@ class Plex_Api
public static function unregisterMyPlex($authtoken)
{
$headers = array (
$headers = array(
'Content-Type: text/xml'
);
$action = 'servers/' . Plex_XML_Data::getMachineIdentifier() . '.xml?auth_token=' . $authtoken;
@ -1092,7 +1092,7 @@ class Plex_Api
CURLOPT_TIMEOUT => 0
));
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);
}

View file

@ -98,7 +98,7 @@ class Plugin
$handle = opendir($basedir);
if (!is_resource($handle)) {
debug_event('Plugins','Unable to read plugins directory','1');
debug_event('Plugins', 'Unable to read plugins directory', '1');
}
// Recurse the directory
@ -172,15 +172,15 @@ class Plugin
}
/* Make sure we've got the required methods */
if (!method_exists($this->_plugin,'install')) {
if (!method_exists($this->_plugin, 'install')) {
return false;
}
if (!method_exists($this->_plugin,'uninstall')) {
if (!method_exists($this->_plugin, 'uninstall')) {
return false;
}
if (!method_exists($this->_plugin,'load')) {
if (!method_exists($this->_plugin, 'load')) {
return false;
}

View file

@ -125,7 +125,7 @@ class Podcast extends database_object implements library_item
private function _get_extra_info()
{
// Try to find it in the cache and save ourselves the trouble
if (parent::is_cached('podcast_extra', $this->id) ) {
if (parent::is_cached('podcast_extra', $this->id)) {
$row = parent::get_from_cache('podcast_extra', $this->id);
} else {
$sql = "SELECT COUNT(`podcast_episode`.`id`) AS `episode_count` FROM `podcast_episode` " .
@ -133,7 +133,7 @@ class Podcast extends database_object implements library_item
$db_results = Dba::read($sql, array($this->id));
$row = Dba::fetch_assoc($db_results);
parent::add_to_cache('podcast_extra',$this->id,$row);
parent::add_to_cache('podcast_extra', $this->id, $row);
}
/* Set Object Vars */

View file

@ -282,7 +282,7 @@ class Podcast_Episode extends database_object implements media, library_item
*/
public static function update_played($new_played, $id)
{
self::_update_item('played', ($new_played ? 1 : 0),$id,'25');
self::_update_item('played', ($new_played ? 1 : 0), $id, '25');
} // update_played
/**
@ -300,7 +300,7 @@ class Podcast_Episode extends database_object implements media, library_item
private static function _update_item($field, $value, $song_id, $level)
{
/* Check them Rights! */
if (!Access::check('interface',$level)) {
if (!Access::check('interface', $level)) {
return false;
}

View file

@ -70,7 +70,7 @@ class Preference extends database_object
* update
* This updates a single preference from the given name or id
*/
public static function update($preference,$user_id,$value,$applytoall=false,$applytodefault=false)
public static function update($preference, $user_id, $value, $applytoall=false, $applytodefault=false)
{
// First prepare
if (!is_numeric($preference)) {
@ -80,7 +80,7 @@ class Preference extends database_object
$name = self::name_from_id($preference);
$id = $preference;
}
if ($applytoall and Access::check('interface','100')) {
if ($applytoall and Access::check('interface', '100')) {
$user_check = "";
} else {
$user_check = " AND `user`='$user_id'";
@ -117,7 +117,7 @@ class Preference extends database_object
* update_level
* This takes a preference ID and updates the level required to update it (performed by an admin)
*/
public static function update_level($preference,$level)
public static function update_level($preference, $level)
{
// First prepare
if (!is_numeric($preference)) {
@ -139,7 +139,7 @@ class Preference extends database_object
* update_all
* This takes a preference id and a value and updates all users with the new info
*/
public static function update_all($preference_id,$value)
public static function update_all($preference_id, $value)
{
$preference_id = Dba::escape($preference_id);
$value = Dba::escape($value);
@ -184,7 +184,7 @@ class Preference extends database_object
$db_results = Dba::read($sql);
$data = Dba::fetch_assoc($db_results);
if (Access::check('interface',$data['level'])) {
if (Access::check('interface', $data['level'])) {
return true;
}
@ -283,7 +283,7 @@ class Preference extends database_object
* This inserts a new preference into the preference table
* it does NOT sync up the users, that should be done independently
*/
public static function insert($name,$description,$default,$level,$type,$catagory,$subcatagory=null)
public static function insert($name, $description, $default, $level, $type, $catagory, $subcatagory=null)
{
if ($subcatagory !== null) {
$subcatagory = strtolower($subcatagory);
@ -374,10 +374,10 @@ class Preference extends database_object
foreach ($results as $key=>$data) {
if (!is_array($data)) {
if (strcasecmp($data,"true") == "0") {
if (strcasecmp($data, "true") == "0") {
$results[$key] = 1;
}
if (strcasecmp($data,"false") == "0") {
if (strcasecmp($data, "false") == "0") {
$results[$key] = 0;
}
}
@ -431,7 +431,7 @@ class Preference extends database_object
'transcode_m4a','transcode_mp3','transcode_ogg','transcode_flac',
'shoutcast_active','httpq_active','show_lyrics');
if (in_array($key,$boolean_array)) {
if (in_array($key, $boolean_array)) {
return true;
}

View file

@ -246,7 +246,7 @@ class Query
)
);
if (Access::check('interface','50')) {
if (Access::check('interface', '50')) {
array_push(self::$allowed_filters['playlist'], 'playlist_type');
}
@ -514,7 +514,7 @@ class Query
break;
case 'playlist_type':
// Must be a content manager to turn this off
if (Access::check('interface','100')) {
if (Access::check('interface', '100')) {
unset($this->_state['filter'][$key]);
} else {
$this->_state['filter'][$key] = '1';
@ -760,7 +760,7 @@ class Query
* @param string $sort
* @param string $order
*/
public function set_sort($sort,$order='')
public function set_sort($sort, $order='')
{
// If it's not in our list, smeg off!
if (!in_array($sort, self::$allowed_sorts[$this->get_type()])) {
@ -800,7 +800,7 @@ class Query
*
* @param int $catalog_number
*/
public function set_catalog( $catalog_number )
public function set_catalog($catalog_number)
{
$this->catalog = $catalog_number;
debug_event("Catalog", "set catalog id: " . $this->catalog, "5");
@ -1160,7 +1160,7 @@ class Query
$sql .= $dis . " AND ";
}
$sql = rtrim($sql,'AND ') . ' ';
$sql = rtrim($sql, 'AND ') . ' ';
return $sql;
} // get_filter_sql
@ -1183,8 +1183,8 @@ class Query
$sql .= $this->sql_sort($key, $value);
}
$sql = rtrim($sql,'ORDER BY ');
$sql = rtrim($sql,',');
$sql = rtrim($sql, 'ORDER BY ');
$sql = rtrim($sql, ',');
return $sql;
} // get_sort_sql
@ -1264,7 +1264,7 @@ class Query
$limit_sql = $limit ? $this->get_limit_sql() : '';
$final_sql = $sql . $join_sql . $filter_sql . $having_sql;
if ( ($this->get_type() == 'artist' || $this->get_type() == 'album') && !$this->_state['custom'] ) {
if (($this->get_type() == 'artist' || $this->get_type() == 'album') && !$this->_state['custom']) {
$final_sql .= " GROUP BY `" . $this->get_type() . "`.`name`, `" . $this->get_type() . "`.`id` ";
}
$final_sql .= $order_sql . $limit_sql;
@ -1328,7 +1328,7 @@ class Query
foreach ($value as $tag_id) {
$filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
}
$filter_sql = rtrim($filter_sql,'AND') . ') AND ';
$filter_sql = rtrim($filter_sql, 'AND') . ') AND ';
break;
case 'exact_match':
$filter_sql = " `song`.`title` = '" . Dba::escape($value) . "' AND ";
@ -1399,7 +1399,7 @@ class Query
foreach ($value as $tag_id) {
$filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
}
$filter_sql = rtrim($filter_sql,'AND') . ') AND ';
$filter_sql = rtrim($filter_sql, 'AND') . ') AND ';
break;
case 'exact_match':
$filter_sql = " `album`.`name` = '" . Dba::escape($value) . "' AND ";
@ -1437,8 +1437,8 @@ class Query
break;
case 'catalog':
if ($value != 0) {
$this->set_join('left','`song`','`album`.`id`','`song`.`album`', 100);
$this->set_join('left','`catalog`','`song`.`catalog`','`catalog`.`id`', 100);
$this->set_join('left', '`song`', '`album`.`id`', '`song`.`album`', 100);
$this->set_join('left', '`catalog`', '`song`.`catalog`', '`catalog`.`id`', 100);
$filter_sql = " (`song`.`catalog` = '$value') AND ";
}
break;
@ -1469,12 +1469,12 @@ class Query
foreach ($value as $tag_id) {
$filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
}
$filter_sql = rtrim($filter_sql,'AND') . ') AND ';
$filter_sql = rtrim($filter_sql, 'AND') . ') AND ';
break;
case 'catalog':
if ($value != 0) {
$this->set_join('left','`song`','`artist`.`id`','`song`.`artist`', 100);
$this->set_join('left','`catalog`','`song`.`catalog`','`catalog`.`id`', 100);
$this->set_join('left', '`song`', '`artist`.`id`', '`song`.`artist`', 100);
$this->set_join('left', '`catalog`', '`song`.`catalog`', '`catalog`.`id`', 100);
$filter_sql = " (`catalog`.`id` = '$value') AND ";
}
break;
@ -1640,7 +1640,7 @@ class Query
foreach ($value as $tag_id) {
$filter_sql .= " `tag_map`.`tag_id`='" . Dba::escape($tag_id) . "' AND";
}
$filter_sql = rtrim($filter_sql,'AND') . ') AND ';
$filter_sql = rtrim($filter_sql, 'AND') . ') AND ';
break;
case 'alpha_match':
$filter_sql = " `video`.`title` LIKE '%" . Dba::escape($value) . "%' AND ";
@ -2331,7 +2331,7 @@ class Query
$object_id = Dba::escape($object_id);
$where_sql .= "'$object_id',";
}
$where_sql = rtrim($where_sql,',');
$where_sql = rtrim($where_sql, ',');
$where_sql .= ")";
@ -2343,8 +2343,8 @@ class Query
$order_sql .= $this->sql_sort($key, $value);
}
// Clean her up
$order_sql = rtrim($order_sql,"ORDER BY ");
$order_sql = rtrim($order_sql,",");
$order_sql = rtrim($order_sql, "ORDER BY ");
$order_sql = rtrim($order_sql, ",");
$sql = $sql . $this->get_join_sql() . $where_sql . $order_sql;
} // if not simple

View file

@ -152,7 +152,7 @@ class Random
{
$results = array();
$data = $GLOBALS['user']->get_recently_played('1','artist');
$data = $GLOBALS['user']->get_recently_played('1', 'artist');
$where_sql = "";
if ($data[0]) {
$where_sql = " AND `song`.`artist`='" . $data[0] . "' ";

View file

@ -124,13 +124,13 @@ Website: %s
}
/* Check for existance */
$fp = fopen($filename,'r');
$fp = fopen($filename, 'r');
if (!$fp) {
return false;
}
$data = fread($fp,filesize($filename));
$data = fread($fp, filesize($filename));
/* Scrub and show */
echo $data;

View file

@ -34,7 +34,7 @@ class scrobbler
* Constructor
* This is the constructer it takes a username and password
*/
public function __construct($api_key, $scheme='https',$host='',$challenge='', $secret='')
public function __construct($api_key, $scheme='https', $host='', $challenge='', $secret='')
{
$this->error_msg = '';
$this->challenge = $challenge;
@ -127,7 +127,7 @@ class scrobbler
* This is a generic caller for HTTP requests
* It need the method (GET/POST), the url and the parameters
*/
public function get_session_key ($token=null)
public function get_session_key($token=null)
{
if (!is_null($token)) {
$vars = array(
@ -169,10 +169,10 @@ class scrobbler
* submit the track or talk to LastFM / Libre in anyway, kind of useless for our uses but its
* here, and that's how it is.
*/
public function queue_track($artist, $album, $title, $timestamp, $length,$track)
public function queue_track($artist, $album, $title, $timestamp, $length, $track)
{
if ($length < 30) {
debug_event('Scrobbler',"Not queuing track, too short",'5');
debug_event('Scrobbler', "Not queuing track, too short", '5');
return false;
}

View file

@ -512,7 +512,7 @@ class Session
$auth = false;
$cname = AmpConfig::get('session_name') . '_remember';
if (isset($_COOKIE[$cname])) {
list ($username, $token, $mac) = explode(':', $_COOKIE[$cname]);
list($username, $token, $mac) = explode(':', $_COOKIE[$cname]);
if ($mac === hash_hmac('sha256', $username . ':' . $token, AmpConfig::get('secret_key'))) {
$sql = "SELECT * FROM `session_remember` WHERE `username` = ? AND `token` = ? AND `expire` >= ?";
$db_results = Dba::read($sql, array($username, $token, time()));

View file

@ -100,7 +100,7 @@ class Shoutbox
// If we've already got too many stop here
if (count($shouts) > $limit) {
$shouts = array_slice($shouts,0,$limit);
$shouts = array_slice($shouts, 0, $limit);
return $shouts;
}
@ -157,7 +157,7 @@ class Shoutbox
* get_object
* This takes a type and an ID and returns a created object
*/
public static function get_object($type,$object_id)
public static function get_object($type, $object_id)
{
if (!Core::is_library_item($type)) {
return false;
@ -306,10 +306,10 @@ class Shoutbox
if ($details) {
$html .= "<div class='shoutbox-actions'>";
if ($jsbuttons) {
$html .= Ajax::button('?page=stream&action=directplay&playtype=' . $this->object_type . '&' . $this->object_type . '_id=' . $this->object_id,'play', T_('Play'),'play_' . $this->object_type . '_' . $this->object_id);
$html .= Ajax::button('?action=basket&type=' . $this->object_type . '&id=' . $this->object_id,'add', T_('Add'),'add_' . $this->object_type . '_' . $this->object_id);
$html .= Ajax::button('?page=stream&action=directplay&playtype=' . $this->object_type . '&' . $this->object_type . '_id=' . $this->object_id, 'play', T_('Play'), 'play_' . $this->object_type . '_' . $this->object_id);
$html .= Ajax::button('?action=basket&type=' . $this->object_type . '&id=' . $this->object_id, 'add', T_('Add'), 'add_' . $this->object_type . '_' . $this->object_id);
}
if (Access::check('interface','25')) {
if (Access::check('interface', '25')) {
$html .= "<a href=\"" . AmpConfig::get('web_path') . "/shout.php?action=show_add_shout&type=" . $this->object_type . "&id=" . $this->object_id . "\">" . UI::get_icon('comment', T_('Post Shout')) . "</a>";
}
$html .= "</div>";

View file

@ -593,8 +593,8 @@ class Song extends database_object implements media, library_item
{
$id = intval($this->id);
if (parent::is_cached('song_data',$id)) {
return parent::get_from_cache('song_data',$id);
if (parent::is_cached('song_data', $id)) {
return parent::get_from_cache('song_data', $id);
}
$sql = "SELECT * FROM song_data WHERE `song_id` = ?";
@ -602,7 +602,7 @@ class Song extends database_object implements media, library_item
$results = Dba::fetch_assoc($db_results);
parent::add_to_cache('song_data',$id,$results);
parent::add_to_cache('song_data', $id, $results);
return $results;
} // _get_ext_info
@ -902,7 +902,7 @@ class Song extends database_object implements media, library_item
public static function compare_song_information(Song $song, Song $new_song)
{
// Remove some stuff we don't care about
unset($song->catalog,$song->played,$song->enabled,$song->addition_time,$song->update_time,$song->type);
unset($song->catalog, $song->played, $song->enabled, $song->addition_time, $song->update_time, $song->type);
$string_array = array('title','comment','lyrics','composer','tags');
$skip_array = array('id','tag_id','mime','artist_mbid','album_mbid','albumartist_mbid','albumartist','mbid','mb_albumid_group','waveform','object_cnt');
@ -919,7 +919,7 @@ class Song extends database_object implements media, library_item
// Foreach them
foreach ($fields as $key=>$value) {
$key = trim($key);
if (empty($key) || in_array($key,$skip_array)) {
if (empty($key) || in_array($key, $skip_array)) {
continue;
}
@ -1171,7 +1171,7 @@ class Song extends database_object implements media, library_item
* @param string $new_title
* @param int $song_id
*/
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);
} // update_title
@ -1401,7 +1401,7 @@ class Song extends database_object implements media, library_item
}
/* Check them rights boy! */
if (!Access::check('interface',$level)) {
if (!Access::check('interface', $level)) {
return false;
}
@ -1637,7 +1637,7 @@ class Song extends database_object implements media, library_item
{
$fields = get_class_vars('Song');
unset($fields['id'],$fields['_transcoded'],$fields['_fake'],$fields['cache_hit'],$fields['mime'],$fields['type']);
unset($fields['id'], $fields['_transcoded'], $fields['_fake'], $fields['cache_hit'], $fields['mime'], $fields['type']);
// Some additional fields
$fields['tag'] = true;
@ -1679,7 +1679,7 @@ class Song extends database_object implements media, library_item
* @param int $catalog_id
* @return string
*/
public function get_rel_path($file_path=null,$catalog_id=0)
public function get_rel_path($file_path=null, $catalog_id=0)
{
$info = null;
if (!$file_path) {
@ -1692,7 +1692,7 @@ class Song extends database_object implements media, library_item
}
$catalog_id = $info['catalog'];
}
$catalog = Catalog::create_from_id( $catalog_id );
$catalog = Catalog::create_from_id($catalog_id);
return $catalog->get_rel_path($file_path);
} // get_rel_path
@ -1785,7 +1785,7 @@ class Song extends database_object implements media, library_item
// If user is not empty, we're looking directly to user personal info (admin view)
$sql .= "AND `user`='$user_id' ";
} else {
if (!Access::check('interface','100')) {
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');
if ($personal_info_id) {

View file

@ -217,7 +217,7 @@ class Stats
* This returns the objects that have happened for $user_id sometime after $time
* used primarly by the democratic cooldown code
*/
public static function get_object_history($user_id='',$time)
public static function get_object_history($user_id='', $time)
{
$user_id = $user_id ? $user_id : $GLOBALS['user']->id;
@ -271,7 +271,7 @@ class Stats
* This returns the top X for type Y from the
* last stats_threshold days
*/
public static function get_top($type,$count='',$threshold = '',$offset='')
public static function get_top($type, $count='', $threshold = '', $offset='')
{
if (!$count) {
$count = AmpConfig::get('popular_threshold');
@ -323,7 +323,7 @@ class Stats
* get_recent
* This returns the recent X for type Y
*/
public static function get_recent($type, $count='',$offset='')
public static function get_recent($type, $count='', $offset='')
{
if (!$count) {
$count = AmpConfig::get('popular_threshold');
@ -354,7 +354,7 @@ class Stats
* This gets all stats for atype based on user with thresholds and all
* If full is passed, doesn't limit based on date
*/
public static function get_user($count,$type,$user,$full='')
public static function get_user($count, $type, $user, $full='')
{
$count = intval($count);
$type = self::validate_type($type);

View file

@ -378,7 +378,7 @@ class Stream
'AND `np`.`insertion` = `np2`.`max_insertion` ';
}
if (!Access::check('interface','100')) {
if (!Access::check('interface', '100')) {
// We need to check only for users which have allowed view of personnal info
$personal_info_id = Preference::id_from_name('allow_personal_info_now');
if ($personal_info_id) {
@ -481,12 +481,12 @@ class Stream
}
if (AmpConfig::get('force_http_play')) {
$web_path = str_replace("https://", "http://",$web_path);
$web_path = str_replace("https://", "http://", $web_path);
}
$http_port = AmpConfig::get('http_port');
if (!empty($http_port) && $http_port != 80 && $http_port != 443) {
if (preg_match("/:(\d+)/",$web_path,$matches)) {
if (preg_match("/:(\d+)/", $web_path, $matches)) {
$web_path = str_replace(':' . $matches['1'], ':' . $http_port, $web_path);
} else {
$web_path = str_replace(AmpConfig::get('http_host'), AmpConfig::get('http_host') . ':' . $http_port, $web_path);

View file

@ -71,7 +71,7 @@ class Subsonic_Api
$hex = substr($password, 4);
$decpwd = '';
for ($i=0; $i<strlen($hex); $i+=2) {
$decpwd .= chr(hexdec(substr($hex,$i,2)));
$decpwd .= chr(hexdec(substr($hex, $i, 2)));
}
$password = $decpwd;
}
@ -97,7 +97,7 @@ class Subsonic_Api
} else {
if (substr($header, 0, 5) === "HTTP/") {
// if $header starts with HTTP/ assume it's the status line
http_response_code(curl_getinfo($ch,CURLINFO_HTTP_CODE));
http_response_code(curl_getinfo($ch, CURLINFO_HTTP_CODE));
}
}
return strlen($header);
@ -1181,7 +1181,7 @@ class Subsonic_Api
self::check_version($input, "1.7.0");
$r = Subsonic_XML_Data::createSuccessResponse();
Subsonic_XML_Data::addStarred($r, Userflag::get_latest('artist',null,99999), Userflag::get_latest('album',null,99999), Userflag::get_latest('song',null,99999), $elementName);
Subsonic_XML_Data::addStarred($r, Userflag::get_latest('artist', null, 99999), Userflag::get_latest('album', null, 99999), Userflag::get_latest('song', null, 99999), $elementName);
self::apiOutput($input, $r);
}

View file

@ -99,7 +99,7 @@ class Tag extends database_object implements library_item
return false;
}
$idlist = '(' . implode(',',$ids) . ')';
$idlist = '(' . implode(',', $ids) . ')';
$sql = "SELECT `tag_map`.`id`,`tag_map`.`tag_id`, `tag`.`name`,`tag_map`.`object_id`,`tag_map`.`user` FROM `tag` " .
"LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " .
@ -163,13 +163,13 @@ class Tag extends database_object implements library_item
}
if (!$tag_id) {
debug_event('Error','Error unable to create tag value:' . $cleaned_value . ' unknown error','1');
debug_event('Error', 'Error unable to create tag value:' . $cleaned_value . ' unknown error', '1');
return false;
}
// We've got the tag id, let's see if it's already got a map, if not then create the map and return the value
if (!$map_id = self::tag_map_exists($type,$id,$tag_id,$uid)) {
$map_id = self::add_tag_map($type,$id,$tag_id,$uid);
if (!$map_id = self::tag_map_exists($type, $id, $tag_id, $uid)) {
$map_id = self::add_tag_map($type, $id, $tag_id, $uid);
}
return $map_id;
@ -285,7 +285,7 @@ class Tag extends database_object implements library_item
* add_tag_map
* This adds a specific tag to the map for specified object
*/
public static function add_tag_map($type,$object_id,$tag_id,$user=true)
public static function add_tag_map($type, $object_id, $tag_id, $user=true)
{
if ($user === true) {
$uid = intval($GLOBALS['user']->id);
@ -319,7 +319,7 @@ class Tag extends database_object implements library_item
}
$insert_id = Dba::insert_id();
parent::add_to_cache('tag_map_' . $type,$insert_id,array('tag_id'=>$tag_id,'user'=>$uid,'object_type'=>$type,'object_id'=>$id));
parent::add_to_cache('tag_map_' . $type, $insert_id, array('tag_id'=>$tag_id, 'user'=>$uid, 'object_type'=>$type, 'object_id'=>$id));
return $insert_id;
} // add_tag_map
@ -392,8 +392,8 @@ class Tag extends database_object implements library_item
*/
public static function tag_exists($value)
{
if (parent::is_cached('tag_name',$value)) {
return parent::get_from_cache('tag_name',$value);
if (parent::is_cached('tag_name', $value)) {
return parent::get_from_cache('tag_name', $value);
}
$sql = "SELECT * FROM `tag` WHERE `name` = ?";
@ -401,7 +401,7 @@ class Tag extends database_object implements library_item
$results = Dba::fetch_assoc($db_results);
parent::add_to_cache('tag_name',$results['name'],$results['id']);
parent::add_to_cache('tag_name', $results['name'], $results['id']);
return $results['id'];
} // tag_exists
@ -485,7 +485,7 @@ class Tag extends database_object implements library_item
* get_tag_objects
* This gets the objects from a specified tag and returns an array of object ids, nothing more
*/
public static function get_tag_objects($type,$tag_id,$count='',$offset='')
public static function get_tag_objects($type, $tag_id, $count='', $offset='')
{
if (!Core::is_library_item($type)) {
return false;

View file

@ -302,7 +302,7 @@ class Tmp_Playlist extends database_object
* This adds the object of $this->object_type to this tmp playlist
* it takes an optional type, default is song
*/
public function add_object($object_id,$object_type)
public function add_object($object_id, $object_type)
{
$sql = "INSERT INTO `tmp_playlist_data` " .
"(`object_id`,`tmp_playlist`,`object_type`) " .

View file

@ -141,7 +141,7 @@ class TVShow extends database_object implements library_item
private function _get_extra_info()
{
// Try to find it in the cache and save ourselves the trouble
if (parent::is_cached('tvshow_extra', $this->id) ) {
if (parent::is_cached('tvshow_extra', $this->id)) {
$row = parent::get_from_cache('tvshow_extra', $this->id);
} else {
$sql = "SELECT COUNT(`tvshow_episode`.`id`) AS `episode_count`, `video`.`catalog` as `catalog_id` FROM `tvshow_season` " .
@ -157,7 +157,7 @@ class TVShow extends database_object implements library_item
$row2 = Dba::fetch_assoc($db_results);
$row['season_count'] = $row2['season_count'];
parent::add_to_cache('tvshow_extra',$this->id,$row);
parent::add_to_cache('tvshow_extra', $this->id, $row);
}
/* Set Object Vars */

View file

@ -105,7 +105,7 @@ class TVShow_Season extends database_object implements library_item
private function _get_extra_info()
{
// Try to find it in the cache and save ourselves the trouble
if (parent::is_cached('tvshow_extra', $this->id) ) {
if (parent::is_cached('tvshow_extra', $this->id)) {
$row = parent::get_from_cache('tvshow_extra', $this->id);
} else {
$sql = "SELECT COUNT(`tvshow_episode`.`id`) AS `episode_count`, `video`.`catalog` as `catalog_id` FROM `tvshow_episode` " .
@ -114,7 +114,7 @@ class TVShow_Season extends database_object implements library_item
$db_results = Dba::read($sql, array($this->id));
$row = Dba::fetch_assoc($db_results);
parent::add_to_cache('tvshow_extra',$this->id,$row);
parent::add_to_cache('tvshow_extra', $this->id, $row);
}
/* Set Object Vars */

View file

@ -646,8 +646,8 @@ class Update
// exists and run the bugger.
if ($version['version'] > $current_version) {
$update_function = "update_" . $version['version'];
if (in_array($update_function,$methods)) {
$success = call_user_func(array('Update',$update_function));
if (in_array($update_function, $methods)) {
$success = call_user_func(array('Update', $update_function));
// If the update fails drop out
if ($success) {
@ -2196,9 +2196,9 @@ class Update
$sql = "INSERT INTO `user_preference` VALUES (-1,?,'1')";
$retval &= Dba::write($sql, array($id));
Preference::insert('autoupdate_lastcheck','AutoUpdate last check time','','25','string','internal');
Preference::insert('autoupdate_lastversion','AutoUpdate last version from last check','','25','string','internal');
Preference::insert('autoupdate_lastversion_new','AutoUpdate last version from last check is newer','','25','boolean','internal');
Preference::insert('autoupdate_lastcheck', 'AutoUpdate last check time', '', '25', 'string', 'internal');
Preference::insert('autoupdate_lastversion', 'AutoUpdate last version from last check', '', '25', 'string', 'internal');
Preference::insert('autoupdate_lastversion_new', 'AutoUpdate last version from last check is newer', '', '25', 'boolean', 'internal');
return $retval;
}

View file

@ -178,12 +178,12 @@ class Upnp_Api
$xmlDoc->appendChild($ndDIDL);
# Return empty DIDL if no items present:
if ( (!isset($prmItems)) || (!is_array($prmItems)) ) {
if ((!isset($prmItems)) || (!is_array($prmItems))) {
return $xmlDoc;
}
# sometimes here comes only one single item, not an array. Convert it to array. (TODO - UGLY)
if ( (count($prmItems) > 0) && (!is_array($prmItems[0])) ) {
if ((count($prmItems) > 0) && (!is_array($prmItems[0]))) {
$prmItems = array($prmItems);
}
@ -259,7 +259,7 @@ class Upnp_Api
$ndTag = $xmlDoc->createElement($key);
$ndItem->appendChild($ndTag);
# check if string is already utf-8 encoded
$ndTag_text = $xmlDoc->createTextNode((mb_detect_encoding($value,'auto')=='UTF-8')?$value:utf8_encode($value));
$ndTag_text = $xmlDoc->createTextNode((mb_detect_encoding($value, 'auto')=='UTF-8')?$value:utf8_encode($value));
$ndTag->appendChild($ndTag_text);
}
if ($useRes) {
@ -294,7 +294,7 @@ class Upnp_Api
$ndEnvelope->appendChild($ndBody);
$ndBrowseResp = $doc->createElementNS('urn:schemas-upnp-org:service:ContentDirectory:1', $prmResponseType);
$ndBody->appendChild($ndBrowseResp);
$ndResult = $doc->createElement('Result',$prmDIDL);
$ndResult = $doc->createElement('Result', $prmDIDL);
$ndBrowseResp->appendChild($ndResult);
$ndNumRet = $doc->createElement('NumberReturned', $prmNumRet);
$ndBrowseResp->appendChild($ndNumRet);
@ -761,7 +761,7 @@ class Upnp_Api
$video = new TVShow_Episode($pathreq[3]);
if ($video->id) {
$video->format();
$meta = self::_itemVideo($video, $root . '/tvshows/' . $pathreq[1] . '/' . $pathreq[2] );
$meta = self::_itemVideo($video, $root . '/tvshows/' . $pathreq[1] . '/' . $pathreq[2]);
}
break;
}

View file

@ -201,8 +201,8 @@ class User extends database_object
{
$id = intval($this->id);
if (parent::is_cached('user',$id)) {
return parent::get_from_cache('user',$id);
if (parent::is_cached('user', $id)) {
return parent::get_from_cache('user', $id);
}
$data = array();
@ -219,7 +219,7 @@ class User extends database_object
$data = Dba::fetch_assoc($db_results);
parent::add_to_cache('user',$id,$data);
parent::add_to_cache('user', $id, $data);
return $data;
} // _get_info
@ -331,8 +331,8 @@ class User extends database_object
*/
public function get_catalogs()
{
if (parent::is_cached('user_catalog',$this->id)) {
return parent::get_from_cache('user_catalog',$this->id);
if (parent::is_cached('user_catalog', $this->id)) {
return parent::get_from_cache('user_catalog', $this->id);
}
$sql = "SELECT * FROM `user_catalog` WHERE `user` = ?";
@ -343,7 +343,7 @@ class User extends database_object
$catalogs[] = $row['catalog'];
}
parent::add_to_cache('user_catalog',$this->id,$catalogs);
parent::add_to_cache('user_catalog', $this->id, $catalogs);
return $catalogs;
} // get_catalogs
@ -388,7 +388,7 @@ class User extends database_object
$admin = true;
}
$type_array[$type][$r['name']] = array('name'=>$r['name'],'level'=>$r['level'],'description'=>$r['description'],'value'=>$r['value'],'subcategory'=>$r['subcatagory']);
$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
return $results;
@ -418,7 +418,7 @@ class User extends database_object
*/
public function get_favorites($type)
{
$results = Stats::get_user(AmpConfig::get('popular_threshold'),$type,$this->id,1);
$results = Stats::get_user(AmpConfig::get('popular_threshold'), $type, $this->id, 1);
$items = array();
@ -888,10 +888,10 @@ class User extends database_object
{
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$sip = $_SERVER['HTTP_X_FORWARDED_FOR'];
debug_event('User Ip', 'Login from ip adress: ' . $sip,'3');
debug_event('User Ip', 'Login from ip adress: ' . $sip, '3');
} else {
$sip = $_SERVER['REMOTE_ADDR'];
debug_event('User Ip', 'Login from ip adress: ' . $sip,'3');
debug_event('User Ip', 'Login from ip adress: ' . $sip, '3');
}
// Remove port information if any
@ -910,7 +910,7 @@ class User extends database_object
Dba::write($sql);
/* Clean up old records... sometimes */
if (rand(1,100) > 60) {
if (rand(1, 100) > 60) {
$date = time() - (86400*AmpConfig::get('user_ip_cardinality'));
$sql = "DELETE FROM `ip_history` WHERE `date` < $date";
Dba::write($sql);
@ -981,7 +981,7 @@ class User extends database_object
*/
public function update_password($new_password)
{
$new_password = hash('sha256',$new_password);
$new_password = hash('sha256', $new_password);
$new_password = Dba::escape($new_password);
$sql = "UPDATE `user` SET `password` = ? WHERE `id` = ?";
@ -1005,14 +1005,14 @@ class User extends database_object
if (!$this->last_seen) {
$this->f_last_seen = T_('Never');
} else {
$this->f_last_seen = date("m\/d\/Y - H:i",$this->last_seen);
$this->f_last_seen = date("m\/d\/Y - H:i", $this->last_seen);
}
/* 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);
$this->f_create_date = date("m\/d\/Y - H:i", $this->create_date);
}
$this->f_name = ($this->fullname_public ? $this->fullname : $this->username);
@ -1232,7 +1232,7 @@ class User extends database_object
* calcs difference between now and last_seen
* if less than delay, we consider them still online
*/
public function is_online( $delay = 1200 )
public function is_online($delay = 1200)
{
return time() - $this->last_seen <= $delay;
} // is_online
@ -1256,7 +1256,7 @@ class User extends database_object
* This gets the recently played items for this user respecting
* the limit passed
*/
public function get_recently_played($limit,$type='')
public function get_recently_played($limit, $type='')
{
if (!$type) {
$type = 'song';
@ -1279,7 +1279,7 @@ class User extends database_object
* This returns the ip_history from the
* last AmpConfig::get('user_ip_cardinality') days
*/
public function get_ip_history($count='',$distinct='')
public function get_ip_history($count='', $distinct='')
{
$username = Dba::escape($this->id);
$count = $count ? intval($count) : intval(AmpConfig::get('user_ip_cardinality'));
@ -1354,7 +1354,7 @@ class User extends database_object
return $avatar;
} // get_avatar
public function update_avatar ($data, $mime = '')
public function update_avatar($data, $mime = '')
{
$art = new Art($this->id, 'user');
$art->insert($data, $mime);

View file

@ -74,7 +74,7 @@ class Useractivity extends database_object
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('user_activity',$row['id'],$row);
parent::add_to_cache('user_activity', $row['id'], $row);
}
}
/**

View file

@ -269,10 +269,10 @@ class vainfo
if ($tagWriter->WriteTags()) {
if (!empty($tagWriter->warnings)) {
debug_event('vainfo' , 'FWarnings ' . implode("\n", $tagWriter->warnings), 5);
debug_event('vainfo', 'FWarnings ' . implode("\n", $tagWriter->warnings), 5);
}
} else {
debug_event('vainfo' , 'Failed to write tags! ' . implode("\n", $tagWriter->errors), 5);
debug_event('vainfo', 'Failed to write tags! ' . implode("\n", $tagWriter->errors), 5);
}
}
} // write_id3
@ -691,7 +691,7 @@ class vainfo
return $type;
default:
/* Log the fact that we couldn't figure it out */
debug_event('vainfo','Unable to determine file type from ' . $type . ' on file ' . $this->filename,'5');
debug_event('vainfo', 'Unable to determine file type from ' . $type . ' on file ' . $this->filename, '5');
return $type;
}
@ -1049,29 +1049,29 @@ class vainfo
$episode = array();
$tvyear = array();
$temp = array();
preg_match("~(?<=\(\[\<\{)[1|2][0-9]{3}|[1|2][0-9]{3}~", $filepath,$tvyear);
preg_match("~(?<=\(\[\<\{)[1|2][0-9]{3}|[1|2][0-9]{3}~", $filepath, $tvyear);
$results['year'] = !empty($tvyear) ? intval($tvyear[0]) : null;
if (preg_match("~[Ss](\d+)[Ee](\d+)~", $file, $seasonEpisode)) {
$temp = preg_split("~(((\.|_|\s)[Ss]\d+(\.|_)*[Ee]\d+))~",$file,2);
$temp = preg_split("~(((\.|_|\s)[Ss]\d+(\.|_)*[Ee]\d+))~", $file, 2);
preg_match("~(?<=[Ss])\d+~", $file, $season);
preg_match("~(?<=[Ee])\d+~", $file, $episode);
} else {
if (preg_match("~[\_\-\.\s](\d{1,2})[xX](\d{1,2})~", $file, $seasonEpisode)) {
$temp = preg_split("~[\.\_\s\-\_]\d+[xX]\d{2}[\.\s\-\_]*|$~",$file);
$temp = preg_split("~[\.\_\s\-\_]\d+[xX]\d{2}[\.\s\-\_]*|$~", $file);
preg_match("~\d+(?=[Xx])~", $file, $season);
preg_match("~(?<=[Xx])\d+~", $file, $episode);
} else {
if (preg_match("~[S|s]eason[\_\-\.\s](\d+)[\.\-\s\_]?\s?[e|E]pisode[\s\-\.\_]?(\d+)[\.\s\-\_]?~", $file, $seasonEpisode)) {
$temp = preg_split("~[\.\s\-\_][S|s]eason[\s\-\.\_](\d+)[\.\s\-\_]?\s?[e|E]pisode[\s\-\.\_](\d+)([\s\-\.\_])*~",$file,3);
$temp = preg_split("~[\.\s\-\_][S|s]eason[\s\-\.\_](\d+)[\.\s\-\_]?\s?[e|E]pisode[\s\-\.\_](\d+)([\s\-\.\_])*~", $file, 3);
preg_match("~(?<=[Ss]eason[\.\s\-\_])\d+~", $file, $season);
preg_match("~(?<=[Ee]pisode[\.\s\-\_])\d+~", $file, $episode);
} else {
if (preg_match("~[\_\-\.\s](\d)(\d\d)[\_\-\.\s]*~", $file, $seasonEpisode)) {
$temp = preg_split("~[\.\s\-\_](\d)(\d\d)[\.\s\-\_]~",$file);
$temp = preg_split("~[\.\s\-\_](\d)(\d\d)[\.\s\-\_]~", $file);
$season[0] = $seasonEpisode[1];
if (preg_match("~[\_\-\.\s](\d)(\d\d)[\_\-\.\s]~", $file, $seasonEpisode)) {
$temp = preg_split("~[\.\s\-\_](\d)(\d\d)[\.\s\-\_]~",$file);
$temp = preg_split("~[\.\s\-\_](\d)(\d\d)[\.\s\-\_]~", $file);
$season[0] = $seasonEpisode[1];
$episode[0] = $seasonEpisode[2];
}
@ -1182,21 +1182,21 @@ class vainfo
private function removeCommonAbbreviations($name)
{
$abbr = explode(",",AmpConfig::get('common_abbr'));
$commonabbr = preg_replace("~\n~", '',$abbr);
$abbr = explode(",", AmpConfig::get('common_abbr'));
$commonabbr = preg_replace("~\n~", '', $abbr);
$commonabbr[] = '[1|2][0-9]{3}'; //Remove release year
//scan for brackets, braces, etc and ignore case.
for ($i=0; $i< count($commonabbr);$i++) {
$commonabbr[$i] = "~\[*|\(*|\<*|\{*\b(?i)" . trim($commonabbr[$i]) . "\b\]*|\)*|\>*|\}*~";
}
$string = preg_replace($commonabbr,'',$name);
$string = preg_replace($commonabbr, '', $name);
return $string;
}
private function formatVideoName($name)
{
return ucwords(trim($this->removeCommonAbbreviations(str_replace(['.','_','-'], ' ', $name), "\s\t\n\r\0\x0B\.\_\-")));
return ucwords(trim($this->removeCommonAbbreviations(str_replace(['.', '_', '-'], ' ', $name), "\s\t\n\r\0\x0B\.\_\-")));
}

View file

@ -235,13 +235,13 @@ class Video extends database_object implements media, library_item
return false;
}
$idlist = '(' . implode(',',$ids) . ')';
$idlist = '(' . implode(',', $ids) . ')';
$sql = "SELECT * FROM `video` WHERE `video`.`id` IN $idlist";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('video',$row['id'],$row);
parent::add_to_cache('video', $row['id'], $row);
}
} // build_cache
@ -746,7 +746,7 @@ class Video extends database_object implements media, library_item
public static function compare_video_information(Video $video, Video $new_video)
{
// Remove some stuff we don't care about
unset($video->catalog,$video->played,$video->enabled,$video->addition_time,$video->update_time,$video->type);
unset($video->catalog, $video->played, $video->enabled, $video->addition_time, $video->update_time, $video->type);
$string_array = array('title','tags');
$skip_array = array('id','tag_id','mime','object_cnt');
@ -1036,7 +1036,7 @@ class Video extends database_object implements media, library_item
*/
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
/**
@ -1054,7 +1054,7 @@ class Video extends database_object implements media, library_item
private static function _update_item($field, $value, $song_id, $level)
{
/* Check them Rights! */
if (!Access::check('interface',$level)) {
if (!Access::check('interface', $level)) {
return false;
}

View file

@ -214,7 +214,7 @@ class Wanted extends database_object
{
$wartist = array();
if (parent::is_cached('missing_artist', $mbid) ) {
if (parent::is_cached('missing_artist', $mbid)) {
$wartist = parent::get_from_cache('missing_artist', $mbid);
} else {
$mb = new MusicBrainz(new RequestsHttpAdapter());
@ -408,14 +408,14 @@ class Wanted extends database_object
if ($this->id) {
if (!$this->accepted) {
if ($GLOBALS['user']->has_access('75')) {
echo Ajax::button('?page=index&action=accept_wanted&mbid=' . $this->mbid,'enable', T_('Accept'),'wanted_accept_' . $this->mbid);
echo Ajax::button('?page=index&action=accept_wanted&mbid=' . $this->mbid, 'enable', T_('Accept'), 'wanted_accept_' . $this->mbid);
}
}
if ($GLOBALS['user']->has_access('75') || (Wanted::has_wanted($this->mbid) && $this->accepted != '1')) {
echo " " . Ajax::button('?page=index&action=remove_wanted&mbid=' . $this->mbid,'disable', T_('Remove'),'wanted_remove_' . $this->mbid);
echo " " . Ajax::button('?page=index&action=remove_wanted&mbid=' . $this->mbid, 'disable', T_('Remove'), 'wanted_remove_' . $this->mbid);
}
} else {
echo Ajax::button('?page=index&action=add_wanted&mbid=' . $this->mbid . ($this->artist ? '&artist=' . $this->artist : '&artist_mbid=' . $this->artist_mbid) . '&name=' . urlencode($this->name) . '&year=' . $this->year,'add_wanted', T_('Add to wanted list'),'wanted_add_' . $this->mbid);
echo Ajax::button('?page=index&action=add_wanted&mbid=' . $this->mbid . ($this->artist ? '&artist=' . $this->artist : '&artist_mbid=' . $this->artist_mbid) . '&name=' . urlencode($this->name) . '&year=' . $this->year, 'add_wanted', T_('Add to wanted list'), 'wanted_add_' . $this->mbid);
}
}

View file

@ -154,7 +154,7 @@ class Waveform
*/
protected static function html2rgb($input)
{
$input=($input[0]=="#")?substr($input, 1,6):substr($input, 0,6);
$input=($input[0]=="#")?substr($input, 1, 6):substr($input, 0, 6);
return array(
hexdec(substr($input, 0, 2)),
hexdec(substr($input, 2, 2)),
@ -319,7 +319,7 @@ class Waveform
imagedestroy($img);
$imgdata = ob_get_contents();
ob_clean ();
ob_clean();
return $imgdata;
}

View file

@ -86,7 +86,7 @@ class XML_Data
*/
public static function set_type($type)
{
if (!in_array($type,array('rss','xspf','itunes'))) {
if (!in_array($type, array('rss', 'xspf', 'itunes'))) {
return false;
}
@ -103,7 +103,7 @@ class XML_Data
* @param string $string Error message
* @return string return error message xml
*/
public static function error($code,$string)
public static function error($code, $string)
{
$string = "\t<error code=\"$code\"><![CDATA[$string]]></error>";
return self::output_xml($string);
@ -218,7 +218,7 @@ class XML_Data
* @param boolean $callback (description here...)
* @return string return xml
*/
public static function keyed_array($array,$callback='')
public static function keyed_array($array, $callback='')
{
$string = '';
@ -233,7 +233,7 @@ class XML_Data
// If it's an array, run again
if (is_array($value)) {
$value = self::keyed_array($value,1);
$value = self::keyed_array($value, 1);
$string .= "<$key$attribute>\n$value\n</$key>\n";
} else {
$string .= "\t<$key$attribute><![CDATA[$value]]></$key>\n";
@ -258,7 +258,7 @@ class XML_Data
public static function tags($tags)
{
if (count($tags) > self::$limit or self::$offset > 0) {
$tags = array_splice($tags,self::$offset,self::$limit);
$tags = array_splice($tags, self::$offset, self::$limit);
}
$string = '';
@ -294,18 +294,18 @@ class XML_Data
public static function artists($artists, $include=[], $full_xml=true)
{
if (count($artists) > self::$limit or self::$offset > 0) {
$artists = array_splice($artists,self::$offset,self::$limit);
$artists = array_splice($artists, self::$offset, self::$limit);
}
$string = '';
Rating::build_cache('artist',$artists);
Rating::build_cache('artist', $artists);
foreach ($artists as $artist_id) {
$artist = new Artist($artist_id);
$artist->format();
$rating = new Rating($artist_id,'artist');
$rating = new Rating($artist_id, 'artist');
$tag_string = self::tags_string($artist->tags);
// Build the Art URL, include session
@ -355,17 +355,17 @@ class XML_Data
public static function albums($albums, $include=[], $full_xml=true)
{
if (count($albums) > self::$limit or self::$offset > 0) {
$albums = array_splice($albums,self::$offset,self::$limit);
$albums = array_splice($albums, self::$offset, self::$limit);
}
Rating::build_cache('album',$albums);
Rating::build_cache('album', $albums);
$string = "";
foreach ($albums as $album_id) {
$album = new Album($album_id);
$album->format();
$rating = new Rating($album_id,'album');
$rating = new Rating($album_id, 'album');
// Build the Art URL, include session
$art_url = AmpConfig::get('web_path') . '/image.php?object_id=' . $album->id . '&object_type=album&auth=' . scrub_out($_REQUEST['auth']);
@ -413,7 +413,7 @@ class XML_Data
public static function playlists($playlists)
{
if (count($playlists) > self::$limit or self::$offset > 0) {
$playlists = array_slice($playlists,self::$offset,self::$limit);
$playlists = array_slice($playlists, self::$offset, self::$limit);
}
$string = '';
@ -532,7 +532,7 @@ class XML_Data
public static function videos($videos)
{
if (count($videos) > self::$limit or self::$offset > 0) {
$videos = array_slice($videos,self::$offset,self::$limit);
$videos = array_slice($videos, self::$offset, self::$limit);
}
$string = '';
@ -585,7 +585,7 @@ class XML_Data
$tag_string = self::tags_string($song->tags);
$rating = new Rating($song->id,'song');
$rating = new Rating($song->id, 'song');
$art_url = Art::url($song->album, 'album', $_REQUEST['auth']);
@ -800,7 +800,7 @@ class XML_Data
break;
case 'rss':
$header = "<?xml version=\"1.0\" encoding=\"" . AmpConfig::get('site_charset') . "\" ?>\n " .
"<!-- RSS Generated by Ampache v." . AmpConfig::get('version') . " on " . date("r",time()) . "-->\n" .
"<!-- RSS Generated by Ampache v." . AmpConfig::get('version') . " on " . date("r", time()) . "-->\n" .
"<rss version=\"2.0\">\n<channel>\n";
break;
default:

View file

@ -83,7 +83,7 @@ function check_php_pdo_mysql()
function check_mbstring_func_overload()
{
if ( ini_get('mbstring.func_overload') > 0) {
if (ini_get('mbstring.func_overload') > 0) {
return false;
}
return true;
@ -138,7 +138,7 @@ function check_config_values($conf)
function check_php_memory()
{
$current_memory = ini_get('memory_limit');
$current_memory = substr($current_memory,0,strlen($current_memory)-1);
$current_memory = substr($current_memory, 0, strlen($current_memory)-1);
if (intval($current_memory) < 48) {
return false;
@ -178,11 +178,11 @@ function check_override_memory()
{
/* Check memory */
$current_memory = ini_get('memory_limit');
$current_memory = substr($current_memory,0,strlen($current_memory)-1);
$current_memory = substr($current_memory, 0, strlen($current_memory)-1);
$new_limit = ($current_memory+16) . "M";
/* Bump it by 16 megs (for getid3)*/
if (!ini_set('memory_limit',$new_limit)) {
if (!ini_set('memory_limit', $new_limit)) {
return false;
}

View file

@ -36,7 +36,7 @@ function set_memory_limit($new_limit)
$new_limit = UI::unformat_bytes($new_limit);
if ($current_limit < $new_limit) {
ini_set (memory_limit, $new_limit);
ini_set(memory_limit, $new_limit);
}
} // set_memory_limit
@ -54,10 +54,10 @@ function generate_password($length)
for ($i = 0; $i < $length; $i++) {
if ($alt == 1) {
$password .= $consonants[(rand(0,strlen($consonants)-1))];
$password .= $consonants[(rand(0, strlen($consonants)-1))];
$alt = 0;
} else {
$password .= $vowels[(rand(0,strlen($vowels)-1))];
$password .= $vowels[(rand(0, strlen($vowels)-1))];
$alt = 1;
}
}
@ -123,7 +123,7 @@ function scrub_arg($arg)
*/
function make_bool($string)
{
if (strcasecmp($string,'false') == 0 || $string == '0') {
if (strcasecmp($string, 'false') == 0 || $string == '0') {
return false;
}
@ -152,7 +152,7 @@ function get_languages()
$handle = @opendir(AmpConfig::get('prefix') . '/locale');
if (!is_resource($handle)) {
debug_event('language','Error unable to open locale directory','1');
debug_event('language', 'Error unable to open locale directory', '1');
}
$results = array();
@ -161,7 +161,7 @@ function get_languages()
$full_file = AmpConfig::get('prefix') . '/locale/' . $file;
/* 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) {
case 'af_ZA'; $name = 'Afrikaans'; break; /* Afrikaans */
case 'bg_BG'; $name = '&#x0411;&#x044a;&#x043b;&#x0433;&#x0430;&#x0440;&#x0441;&#x043a;&#x0438;'; break; /* Bulgarian */
@ -269,17 +269,17 @@ function generate_config($current)
{
// Start building the new config file
$distfile = AmpConfig::get('prefix') . '/config/ampache.cfg.php.dist';
$handle = fopen($distfile,'r');
$dist = fread($handle,filesize($distfile));
$handle = fopen($distfile, 'r');
$dist = fread($handle, filesize($distfile));
fclose($handle);
$data = explode("\n",$dist);
$data = explode("\n", $dist);
$final = "";
foreach ($data as $line) {
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+[\'\"]{0}(.*)[\'\"]{0}$/",$line,$matches)) {
|| preg_match("/^;?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/", $line, $matches)) {
$key = $matches[1];
$value = $matches[2];

View file

@ -60,7 +60,7 @@ if (file_exists($composer_autoload)) {
}
// Check to see if this is http or https
if ((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' )
if ((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
|| (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')) {
$http_type = 'https://';
} else {

View file

@ -61,7 +61,7 @@ if (!check_php() || !check_dependencies_folder()) {
// Do the redirect if we can't continue
if (!empty($link)) {
header ("Location: $link");
header("Location: $link");
exit();
}
@ -129,13 +129,13 @@ $old_error_handler = set_error_handler('ampache_error_handler');
/* Check their PHP Vars to make sure we're cool here */
$post_size = @ini_get('post_max_size');
if (substr($post_size,strlen($post_size)-1,strlen($post_size)) != 'M') {
if (substr($post_size, strlen($post_size)-1, strlen($post_size)) != 'M') {
/* Sane value time */
ini_set('post_max_size','8M');
ini_set('post_max_size', '8M');
}
// In case the local setting is 0
ini_set('session.gc_probability','5');
ini_set('session.gc_probability', '5');
if (!isset($results['memory_limit']) ||
(UI::unformat_bytes($results['memory_limit']) < UI::unformat_bytes('32M'))
@ -235,7 +235,7 @@ AmpConfig::set('ajax_url', AmpConfig::get('web_path') . '/server/ajax.server.php
AmpConfig::set('ajax_server', AmpConfig::get('web_path') . '/server', true);
/* Set CHARSET */
header ("Content-Type: text/html; charset=" . AmpConfig::get('site_charset'));
header("Content-Type: text/html; charset=" . AmpConfig::get('site_charset'));
/* Clean up a bit */
unset($array);

View file

@ -228,7 +228,7 @@ function install_insert_db($db_user = null, $db_pass = null, $create_db = true,
$pieces[$i] = trim($pieces[$i]);
if (!empty($pieces[$i]) && $pieces[$i] != '#') {
if (!$result = Dba::write($pieces[$i])) {
$errors[] = array ( Dba::error(), $pieces[$i] );
$errors[] = array( Dba::error(), $pieces[$i] );
}
}
}
@ -328,7 +328,7 @@ function install_create_account($username, $password, $password2)
$username = Dba::escape($username);
$password = Dba::escape($password);
$insert_id = User::create($username,'Administrator','','',$password,'100');
$insert_id = User::create($username, 'Administrator', '', '', $password, '100');
if (!$insert_id) {
AmpError::add('general', sprintf(T_('Administrative user creation failed: %s'), Dba::error()));
@ -478,7 +478,7 @@ function install_config_use_case($case)
}
}
function install_config_backends(Array $backends)
function install_config_backends(array $backends)
{
$dbconfig = array(
'subsonic_backend' => '0',

View file

@ -189,7 +189,7 @@ if (isset($auth) && $auth['success'] && isset($user)) {
$GLOBALS['user'] = $user;
// If an admin, check for update
if (AmpConfig::get('autoupdate') && Access::check('interface','100')) {
if (AmpConfig::get('autoupdate') && Access::check('interface', '100')) {
AutoUpdate::is_update_available(true);
}
@ -203,7 +203,7 @@ if (isset($auth) && $auth['success'] && isset($user)) {
strpos($_POST['referrer'], 'logout.php') === false &&
strpos($_POST['referrer'], 'update.php') === false &&
strpos($_POST['referrer'], 'activate.php') === false &&
strpos($_POST['referrer'], 'admin') === false ) {
strpos($_POST['referrer'], 'admin') === false) {
header('Location: ' . $_POST['referrer']);
exit();
} // if we've got a referrer

View file

@ -74,11 +74,11 @@ function update_preferences($pref_id=0)
/* Run the update for this preference only if it's set */
if (isset($_REQUEST[$name])) {
Preference::update($id,$pref_id,$value,$_REQUEST[$apply_to_all]);
Preference::update($id, $pref_id, $value, $_REQUEST[$apply_to_all]);
}
if (Access::check('interface','100') && $_REQUEST[$new_level]) {
Preference::update_level($id,$_REQUEST[$new_level]);
if (Access::check('interface', '100') && $_REQUEST[$new_level]) {
Preference::update_level($id, $_REQUEST[$new_level]);
}
} // end foreach preferences
@ -90,20 +90,20 @@ function update_preferences($pref_id=0)
* update_preference
* This function updates a single preference and is called by the update_preferences function
*/
function update_preference($user_id,$name,$pref_id,$value)
function update_preference($user_id, $name, $pref_id, $value)
{
$apply_check = "check_" . $name;
$level_check = "level_" . $name;
/* First see if they are an administrator and we are applying this to everything */
if ($GLOBALS['user']->has_access(100) and make_bool($_REQUEST[$apply_check])) {
Preference::update_all($pref_id,$value);
Preference::update_all($pref_id, $value);
return true;
}
/* Check and see if they are an admin and the level def is set */
if ($GLOBALS['user']->has_access(100) and make_bool($_REQUEST[$level_check])) {
Preference::update_level($pref_id,$_REQUEST[$level_check]);
Preference::update_level($pref_id, $_REQUEST[$level_check]);
}
/* Else make sure that the current users has the right to do this */
@ -120,7 +120,7 @@ function update_preference($user_id,$name,$pref_id,$value)
* create_preference_input
* takes the key and then creates the correct type of input for updating it
*/
function create_preference_input($name,$value)
function create_preference_input($name, $value)
{
if (!Preference::has_access($name)) {
if ($value == '1') {

View file

@ -24,9 +24,9 @@
* show_rating
* This takes an artist id and includes the right file
*/
function show_rating($object_id,$type)
function show_rating($object_id, $type)
{
$rating = new Rating($object_id,$type);
$rating = new Rating($object_id, $type);
require AmpConfig::get('prefix') . UI::find_template('show_object_rating.inc.php');
} // show_rating

View file

@ -38,9 +38,9 @@
* @param integer $cancel T/F show a cancel button that uses return_referrer()
* @return void
*/
function show_confirmation($title,$text,$next_url,$cancel=0,$form_name='confirmation',$visible=true)
function show_confirmation($title, $text, $next_url, $cancel=0, $form_name='confirmation', $visible=true)
{
if (substr_count($next_url,AmpConfig::get('web_path'))) {
if (substr_count($next_url, AmpConfig::get('web_path'))) {
$path = $next_url;
} else {
$path = AmpConfig::get('web_path') . "/$next_url";
@ -83,10 +83,10 @@ function return_referer()
} else {
$file = basename($referer);
/* Strip off the filename */
$referer = substr($referer,0,strlen($referer)-strlen($file));
$referer = substr($referer, 0, strlen($referer)-strlen($file));
}
if (substr($referer,strlen($referer)-6,6) == 'admin/') {
if (substr($referer, strlen($referer)-6, 6) == 'admin/') {
$file = 'admin/' . $file;
}
@ -116,7 +116,7 @@ function get_location()
/* Sanatize the $_SERVER['PHP_SELF'] variable */
$source = str_replace(AmpConfig::get('raw_web_path'), "", $source);
$location['page'] = preg_replace("/^\/(.+\.php)\/?.*/","$1",$source);
$location['page'] = preg_replace("/^\/(.+\.php)\/?.*/", "$1", $source);
switch ($location['page']) {
case 'index.php':
@ -432,7 +432,7 @@ function show_catalog_select($name='catalog', $catalog_id=0, $style='', $allow_n
* This displays a select of every album that we've got in Ampache (which can be
* hella long). It's used by the Edit page and takes a $name and a $album_id
*/
function show_license_select($name='license',$license_id=0,$song_id=0)
function show_license_select($name='license', $license_id=0, $song_id=0)
{
static $license_id_cnt = 0;
@ -474,7 +474,7 @@ function show_license_select($name='license',$license_id=0,$song_id=0)
* This one is for users! shows a select/option statement so you can pick a user
* to blame
*/
function show_user_select($name,$selected='',$style='')
function show_user_select($name, $selected='', $style='')
{
echo "<select name=\"$name\" style=\"$style\">\n";
echo "\t<option value=\"\">" . T_('All') . "</option>\n";
@ -500,7 +500,7 @@ function show_user_select($name,$selected='',$style='')
* show_playlist_select
* This one is for playlists!
*/
function show_playlist_select($name,$selected='',$style='')
function show_playlist_select($name, $selected='', $style='')
{
echo "<select name=\"$name\" style=\"$style\">\n";
echo "\t<option value=\"\">" . T_('None') . "</option>\n";

View file

@ -25,7 +25,7 @@ require_once 'lib/init.php';
UI::show_header();
// Check to see if we've got the rights to be here
if (!AmpConfig::get('allow_localplay_playback') || !Access::check('interface','25')) {
if (!AmpConfig::get('allow_localplay_playback') || !Access::check('interface', '25')) {
UI::access_denied();
exit;
}
@ -33,7 +33,7 @@ if (!AmpConfig::get('allow_localplay_playback') || !Access::check('interface','2
switch ($_REQUEST['action']) {
case 'show_add_instance':
// This requires 50 or better
if (!Access::check('localplay','75')) {
if (!Access::check('localplay', '75')) {
UI::access_denied();
break;
}
@ -45,7 +45,7 @@ switch ($_REQUEST['action']) {
break;
case 'add_instance':
// This requires 50 or better!
if (!Access::check('localplay','75')) {
if (!Access::check('localplay', '75')) {
UI::access_denied();
break;
}
@ -57,17 +57,17 @@ switch ($_REQUEST['action']) {
break;
case 'update_instance':
// Make sure they gots them rights
if (!Access::check('localplay','75')) {
if (!Access::check('localplay', '75')) {
UI::access_denied();
break;
}
$localplay = new Localplay(AmpConfig::get('localplay_controller'));
$localplay->update_instance($_REQUEST['instance'],$_POST);
$localplay->update_instance($_REQUEST['instance'], $_POST);
header("Location:" . AmpConfig::get('web_path') . "/localplay.php?action=show_instances");
break;
case 'edit_instance':
// Check to make sure they've got the access
if (!Access::check('localplay','75')) {
if (!Access::check('localplay', '75')) {
UI::access_denied();
break;
}
@ -78,7 +78,7 @@ switch ($_REQUEST['action']) {
break;
case 'show_instances':
// First build the localplay object and then get the instances
if (!Access::check('localplay','5')) {
if (!Access::check('localplay', '5')) {
UI::access_denied();
break;
}
@ -89,7 +89,7 @@ switch ($_REQUEST['action']) {
break;
case 'show_playlist':
default:
if (!Access::check('localplay','5')) {
if (!Access::check('localplay', '5')) {
UI::access_denied();
break;
}

View file

@ -28,4 +28,4 @@ require_once 'lib/init.php';
// To end a legitimate session, just call logout.
setcookie(AmpConfig::get('session_name') . '_remember', null, -1);
Auth::logout('',false);
Auth::logout('', false);

View file

@ -20,7 +20,7 @@
*
*/
define('NO_SESSION','1');
define('NO_SESSION', '1');
require_once 'lib/init.php';
$action = (isset($_POST['action'])) ? $_POST['action'] : "";
@ -47,7 +47,7 @@ switch ($action) {
require AmpConfig::get('prefix') . UI::find_template('show_lostpassword_form.inc.php');
}
function send_newpassword($email,$current_ip)
function send_newpassword($email, $current_ip)
{
/* get the Client and set the new password */
$client = User::get_from_email($email);

View file

@ -154,7 +154,7 @@ class Catalog_local extends Catalog
// Keep going until the path stops changing
$old_path = $component_path;
$component_path = realpath($component_path . '/../');
} while (strcmp($component_path,$old_path) != 0);
} while (strcmp($component_path, $old_path) != 0);
return false;
}
@ -169,7 +169,7 @@ class Catalog_local extends Catalog
public static function create_type($catalog_id, $data)
{
// Clean up the path just in case
$path = rtrim(rtrim(trim($data['path']),'/'),'\\');
$path = rtrim(rtrim(trim($data['path']), '/'), '\\');
if (!strlen($path)) {
AmpError::add('general', T_('Error: Path not specified'));
@ -248,9 +248,9 @@ class Catalog_local extends Catalog
debug_event('Memory', UI::format_bytes(memory_get_usage(true)), 5);
/* Recurse through this dir and create the files array */
while ( false !== ( $file = readdir($handle) ) ) {
while (false !== ($file = readdir($handle))) {
/* Skip to next if we've got . or .. */
if (substr($file,0,1) == '.') {
if (substr($file, 0, 1) == '.') {
continue;
}
@ -298,7 +298,7 @@ class Catalog_local extends Catalog
/* If it's a dir run this function again! */
if (is_dir($full_file)) {
$this->add_files($full_file,$options);
$this->add_files($full_file, $options);
/* Change the dir so is_dir works correctly */
if (!chdir($full_file)) {
@ -429,8 +429,8 @@ class Catalog_local extends Catalog
$start_time = time();
// Make sure the path doesn't end in a / or \
$this->path = rtrim($this->path,'/');
$this->path = rtrim($this->path,'\\');
$this->path = rtrim($this->path, '/');
$this->path = rtrim($this->path, '\\');
// Prevent the script from timing out and flush what we've got
set_time_limit(0);
@ -549,7 +549,7 @@ class Catalog_local extends Catalog
while ($row = Dba::fetch_assoc($db_results)) {
$count++;
if (UI::check_ticker()) {
$file = str_replace(array('(',')','\''), '', $row['file']);
$file = str_replace(array('(', ')', '\''), '', $row['file']);
UI::update_text('verify_count_' . $this->id, $count);
UI::update_text('verify_dir_' . $this->id, scrub_out($file));
}
@ -561,7 +561,7 @@ class Catalog_local extends Catalog
}
$media = new $media_type($row['id']);
$info = self::update_media_from_tags($media, $this->get_gather_types(), $this->sort_pattern,$this->rename_pattern);
$info = self::update_media_from_tags($media, $this->get_gather_types(), $this->sort_pattern, $this->rename_pattern);
if ($info['change']) {
$changed++;
}
@ -613,7 +613,7 @@ class Catalog_local extends Catalog
if ($dead_count) {
$dead_total += $dead_count;
$sql = "DELETE FROM `$media_type` WHERE `id` IN " .
'(' . implode(',',$dead) . ')';
'(' . implode(',', $dead) . ')';
$db_results = Dba::write($sql);
}
}
@ -642,7 +642,7 @@ class Catalog_local extends Catalog
debug_event('clean', 'Starting work on ' . $results['file'] . '(' . $results['id'] . ')', 5);
$count++;
if (UI::check_ticker()) {
$file = str_replace(array('(',')', '\''), '', $results['file']);
$file = str_replace(array('(', ')', '\''), '', $results['file']);
UI::update_text('clean_count_' . $this->id, $count);
UI::update_text('clean_dir_' . $this->id, scrub_out($file));
}
@ -784,11 +784,11 @@ class Catalog_local extends Catalog
{
/* Create the vainfo object and get info */
$gtypes = $this->get_gather_types('video');
$vainfo = new vainfo($file, $gtypes,'','','',$this->sort_pattern,$this->rename_pattern);
$vainfo = new vainfo($file, $gtypes, '', '', '', $this->sort_pattern, $this->rename_pattern);
$vainfo->get_info();
$tag_name = vainfo::get_tag_type($vainfo->tags, 'metadata_order_video');
$results = vainfo::clean_tag_info($vainfo->tags,$tag_name,$file);
$results = vainfo::clean_tag_info($vainfo->tags, $tag_name, $file);
$results['catalog'] = $this->id;
$id = Video::insert($results, $gtypes, $options);
@ -830,7 +830,7 @@ class Catalog_local extends Catalog
{
$file_date = filemtime($full_file);
if ($file_date < $this->last_add) {
debug_event('Check','Skipping ' . $full_file . ' File modify time before last add run','3');
debug_event('Check', 'Skipping ' . $full_file . ' File modify time before last add run', '3');
return true;
}
@ -848,7 +848,7 @@ class Catalog_local extends Catalog
public function get_rel_path($file_path)
{
$catalog_path = rtrim($this->path, "/");
return( str_replace( $catalog_path . "/", "", $file_path ) );
return(str_replace($catalog_path . "/", "", $file_path));
}
/**

View file

@ -140,7 +140,7 @@ class Catalog_remote extends Catalog
$username = $data['username'];
$password = $data['password'];
if (substr($uri,0,7) != 'http://' && substr($uri,0,8) != 'https://') {
if (substr($uri, 0, 7) != 'http://' && substr($uri, 0, 8) != 'https://') {
AmpError::add('general', T_('Error: Remote selected, but path is not a URL'));
return false;
}
@ -250,7 +250,7 @@ class Catalog_remote extends Catalog
$songs = $remote_handle->send_command('songs', array('offset' => $start, 'limit' => $step));
} catch (Exception $e) {
debug_event('catalog', 'Songs parsing error: ' . $e->getMessage(), 1);
AmpError::add('general',$e->getMessage());
AmpError::add('general', $e->getMessage());
AmpError::display('general');
flush();
}
@ -346,7 +346,7 @@ class Catalog_remote extends Catalog
public function get_rel_path($file_path)
{
$catalog_path = rtrim($this->uri, "/");
return( str_replace( $catalog_path . "/", "", $file_path ) );
return(str_replace($catalog_path . "/", "", $file_path));
}
/**

View file

@ -142,7 +142,7 @@ class Catalog_subsonic extends Catalog
$username = $data['username'];
$password = $data['password'];
if (substr($uri,0,7) != 'http://' && substr($uri,0,8) != 'https://') {
if (substr($uri, 0, 7) != 'http://' && substr($uri, 0, 8) != 'https://') {
AmpError::add('general', T_('Error: Subsonic selected, but path is not a URL'));
return false;
}
@ -340,7 +340,7 @@ class Catalog_subsonic extends Catalog
public function get_rel_path($file_path)
{
$catalog_path = rtrim($this->uri, "/");
return( str_replace( $catalog_path . "/", "", $file_path ) );
return(str_replace($catalog_path . "/", "", $file_path));
}
public function url_to_songid($url)

View file

@ -181,5 +181,3 @@ class SubsonicClient
return $this->_querySubsonic($action, $o);
}
}
?>

View file

@ -95,7 +95,7 @@ class AmpacheHttpq extends localplay_controller
$db_results = Dba::write($sql);
// Add an internal preference for the users current active instance
Preference::insert('httpq_active','HTTPQ Active Instance','0','25','integer','internal','httpq');
Preference::insert('httpq_active', 'HTTPQ Active Instance', '0', '25', 'integer', 'internal', 'httpq');
return true;
} // install
@ -222,7 +222,7 @@ class AmpacheHttpq extends localplay_controller
* set_active_instance
* This sets the specified instance as the 'active' one
*/
public function set_active_instance($uid,$user_id='')
public function set_active_instance($uid, $user_id='')
{
// Not an admin? bubkiss!
if (!$GLOBALS['user']->has_access('100')) {
@ -231,7 +231,7 @@ class AmpacheHttpq extends localplay_controller
$user_id = $user_id ? $user_id : $GLOBALS['user']->id;
Preference::update('httpq_active',$user_id,intval($uid));
Preference::update('httpq_active', $user_id, intval($uid));
AmpConfig::set('httpq_active', intval($uid), true);
return true;
@ -448,7 +448,7 @@ class AmpacheHttpq extends localplay_controller
return array();
}
$songs = explode("::",$list);
$songs = explode("::", $list);
foreach ($songs as $key=>$entry) {
$data = array();
@ -551,7 +551,7 @@ class AmpacheHttpq extends localplay_controller
public function connect()
{
$options = self::get_instance();
$this->_httpq = new HttpQPlayer($options['host'],$options['password'],$options['port']);
$this->_httpq = new HttpQPlayer($options['host'], $options['password'], $options['port']);
// Test our connection by retriving the version
if (!is_null($this->_httpq->version())) {

View file

@ -72,7 +72,7 @@ class HttpQPlayer
public function version()
{
$args = array();
$results = $this->sendCommand('getversion',$args);
$results = $this->sendCommand('getversion', $args);
// a return of 0 is a bad value
if ($results == '0') {
@ -138,7 +138,7 @@ class HttpQPlayer
public function skip($pos)
{
$args = array('index'=>$pos);
$results = $this->sendCommand('setplaylistpos',$args);
$results = $this->sendCommand('setplaylistpos', $args);
if ($results == '0') {
return null;
@ -206,7 +206,7 @@ class HttpQPlayer
public function repeat($value)
{
$args = array('enable'=>$value);
$results = $this->sendCommand('repeat',$args);
$results = $this->sendCommand('repeat', $args);
if ($results == '0') {
$results = null;
@ -222,7 +222,7 @@ class HttpQPlayer
public function random($value)
{
$args = array('enable'=>$value);
$results = $this->sendCommand('shuffle',$args);
$results = $this->sendCommand('shuffle', $args);
if ($results == '0') {
$results = null;
@ -238,7 +238,7 @@ class HttpQPlayer
public function delete_pos($track)
{
$args = array('index'=>$track);
$results = $this->sendCommand('deletepos',$args);
$results = $this->sendCommand('deletepos', $args);
if ($results == '0') {
$results = null;
@ -254,7 +254,7 @@ class HttpQPlayer
public function state()
{
$args = array();
$results = $this->sendCommand('isplaying',$args);
$results = $this->sendCommand('isplaying', $args);
if ($results == '1') {
$state = 'play';
@ -276,13 +276,13 @@ class HttpQPlayer
public function get_volume()
{
$args = array();
$results = $this->sendCommand('getvolume',$args);
$results = $this->sendCommand('getvolume', $args);
if ($results == '0') {
$results = null;
} else {
/* Need to make this out of 100 */
$results = round((($results / 255) * 100),2);
$results = round((($results / 255) * 100), 2);
}
return $results;
@ -295,7 +295,7 @@ class HttpQPlayer
public function volume_up()
{
$args = array();
$results = $this->sendCommand('volumeup',$args);
$results = $this->sendCommand('volumeup', $args);
if ($results == '0') {
return null;
@ -311,7 +311,7 @@ class HttpQPlayer
public function volume_down()
{
$args = array();
$results = $this->sendCommand('volumedown',$args);
$results = $this->sendCommand('volumedown', $args);
if ($results == '0') {
return null;
@ -331,7 +331,7 @@ class HttpQPlayer
// Convert it to base 255
$value = $value*2.55;
$args = array('level'=>$value);
$results = $this->sendCommand('setvolume',$args);
$results = $this->sendCommand('setvolume', $args);
if ($results == '0') {
return null;
@ -347,7 +347,7 @@ class HttpQPlayer
public function clear_playlist()
{
$args = array();
$results = $this->sendcommand('flushplaylist',$args);
$results = $this->sendcommand('flushplaylist', $args);
if ($results == '0') {
return null;
@ -363,7 +363,7 @@ class HttpQPlayer
public function get_repeat()
{
$args = array();
$results = $this->sendCommand('repeat_status',$args);
$results = $this->sendCommand('repeat_status', $args);
return $results;
} // get_repeat
@ -375,7 +375,7 @@ class HttpQPlayer
public function get_random()
{
$args = array();
$results = $this->sendCommand('shuffle_status',$args);
$results = $this->sendCommand('shuffle_status', $args);
return $results;
} // get_random
@ -389,10 +389,10 @@ class HttpQPlayer
{
// First get the current POS
$pos = $this->sendCommand('getlistpos',array());
$pos = $this->sendCommand('getlistpos', array());
// Now get the filename
$file = $this->sendCommand('getplaylistfile',array('index'=>$pos));
$file = $this->sendCommand('getplaylistfile', array('index'=>$pos));
return $file;
} // get_now_playing
@ -406,7 +406,7 @@ class HttpQPlayer
{
// Pull a delimited list of all tracks
$results = $this->sendCommand('getplaylistfile',array('delim'=>'::'));
$results = $this->sendCommand('getplaylistfile', array('delim'=>'::'));
if ($results == '0') {
$results = null;
@ -425,7 +425,7 @@ class HttpQPlayer
$fp = fsockopen($this->host, $this->port, $errno, $errstr);
if (!$fp) {
debug_event('httpq',"HttpQPlayer: $errstr ($errno)",'1');
debug_event('httpq', "HttpQPlayer: $errstr ($errno)", '1');
return null;
}
@ -447,11 +447,11 @@ class HttpQPlayer
fclose($fp);
// Explode the results by line break and take 4th line (results)
$data = explode("\n",$data);
$data = explode("\n", $data);
$result = $data['4'];
return $result;
} // sendCommand
} // End HttpQPlayer Class
?>
;

View file

@ -244,7 +244,7 @@ class mpd
/* We want blocking, cause otherwise it doesn't
* timeout, and feof just keeps on spinning
*/
stream_set_blocking($this->_mpd_sock,true);
stream_set_blocking($this->_mpd_sock, true);
$status = socket_get_status($this->_mpd_sock);
if (!$this->_mpd_sock) {
@ -252,7 +252,7 @@ class mpd
return false;
} else {
while (!feof($this->_mpd_sock) && !$status['timed_out']) {
$response = fgets($this->_mpd_sock,1024);
$response = fgets($this->_mpd_sock, 1024);
if (function_exists('socket_get_status')) {
$status = socket_get_status($this->_mpd_sock);
}
@ -261,7 +261,7 @@ class mpd
return $response;
break;
}
if (strncmp(self::RESPONSE_ERR,$response,strlen(self::RESPONSE_ERR)) == 0) {
if (strncmp(self::RESPONSE_ERR, $response, strlen(self::RESPONSE_ERR)) == 0) {
$this->_error('Connect', "Server responded with: $response");
return false;
}
@ -281,14 +281,14 @@ class mpd
public function SendCommand($command, $arguments = null, $refresh_info = true)
{
$this->_debug('SendCommand', "cmd: $command, args: " . json_encode($arguments), 5);
if ( ! $this->connected ) {
if (! $this->connected) {
$this->_error('SendCommand', 'Not connected', 1);
return false;
} else {
$response_string = '';
// Check the command compatibility:
if ( ! self::_checkCompatibility($command, $this->mpd_version) ) {
if (! self::_checkCompatibility($command, $this->mpd_version)) {
return false;
}
@ -302,7 +302,7 @@ class mpd
}
}
fputs($this->_mpd_sock,"$command\n");
fputs($this->_mpd_sock, "$command\n");
while (!feof($this->_mpd_sock)) {
$response = fgets($this->_mpd_sock, 1024);
@ -320,7 +320,7 @@ class mpd
// Build the response string
$response_string .= $response;
}
$this->_debug('SendCommand', "response: $response_string" , 5);
$this->_debug('SendCommand', "response: $response_string", 5);
}
if ($refresh_info) {
@ -340,7 +340,7 @@ class mpd
public function QueueCommand($command, $arguments = '')
{
$this->_debug('QueueCommand', "start; cmd: $command args: " . json_encode($arguments), 5);
if ( ! $this->connected ) {
if (! $this->connected) {
$this->_error('QueueCommand', 'Not connected');
return false;
}
@ -372,7 +372,7 @@ class mpd
public function SendCommandQueue()
{
$this->_debug('SendCommandQueue', 'start', 5);
if ( ! $this->connected ) {
if (! $this->connected) {
_error('SendCommandQueue', 'Not connected');
return false;
}
@ -424,7 +424,7 @@ class mpd
public function AdjustVolume($value)
{
$this->_debug('AdjustVolume', 'start', 5);
if ( ! is_numeric($value) ) {
if (! is_numeric($value)) {
$this->_error('AdjustVolume', "argument must be numeric: $value");
return false;
}
@ -498,7 +498,7 @@ class mpd
{
$this->_debug('PLAddBulk', 'start', 5);
$num_files = count($trackArray);
for ( $i = 0; $i < $num_files; $i++ ) {
for ($i = 0; $i < $num_files; $i++) {
$this->QueueCommand(self::COMMAND_ADD, $trackArray[$i]);
}
$response = $this->SendCommandQueue();
@ -602,7 +602,7 @@ class mpd
*/
public function PLRemove($id)
{
if ( ! is_numeric($id) ) {
if (! is_numeric($id)) {
$this->_error('PLRemove', "id must be numeric: $id");
return false;
}
@ -716,7 +716,7 @@ class mpd
public function SkipTo($idx)
{
$this->_debug('SkipTo', 'start', 5);
if ( ! is_numeric($idx) ) {
if (! is_numeric($idx)) {
$this->_error('SkipTo', "argument must be numeric: $idx");
return false;
}
@ -736,15 +736,15 @@ class mpd
public function SeekTo($pos, $track = -1)
{
$this->_debug('SeekTo', 'start', 5);
if ( ! is_numeric($pos) ) {
if (! is_numeric($pos)) {
$this->_error('SeekTo', "pos must be numeric: $pos");
return false;
}
if ( ! is_numeric($track) ) {
if (! is_numeric($track)) {
$this->_error('SeekTo', "track must be numeric: $track");
return false;
}
if ( $track == -1 ) {
if ($track == -1) {
$track = $this->current_track_id;
}
@ -787,13 +787,13 @@ class mpd
* The search <string> is a case-insensitive locator string. Anything
* that contains <string> will be returned in the results.
*/
public function Search($type,$string)
public function Search($type, $string)
{
$this->_debug('Search', 'start', 5);
if ( $type != self::SEARCH_ARTIST &&
if ($type != self::SEARCH_ARTIST &&
$type != self::SEARCH_ALBUM &&
$type != self::SEARCH_TITLE ) {
$type != self::SEARCH_TITLE) {
$this->_error('Search', 'invalid search type');
return false;
}
@ -820,9 +820,9 @@ class mpd
public function Find($type, $string)
{
$this->_debug('Find', 'start', 5);
if ( $type != self::SEARCH_ARTIST &&
if ($type != self::SEARCH_ARTIST &&
$type != self::SEARCH_ALBUM &&
$type != self::SEARCH_TITLE ) {
$type != self::SEARCH_TITLE) {
$this->_error('Find', 'invalid find type');
return false;
}
@ -1025,5 +1025,4 @@ class mpd
}
}
} // end class mpd
?>
;

View file

@ -97,7 +97,7 @@ class AmpacheMpd extends localplay_controller
$db_results = Dba::write($sql);
// Add an internal preference for the users current active instance
Preference::insert('mpd_active','MPD Active Instance','0','25','integer','internal','mpd');
Preference::insert('mpd_active', 'MPD Active Instance', '0', '25', 'integer', 'internal', 'mpd');
return true;
} // install
@ -201,7 +201,7 @@ class AmpacheMpd extends localplay_controller
* update_instance
* This takes an ID and an array of data and updates the instance specified
*/
public function update_instance($uid,$data)
public function update_instance($uid, $data)
{
$uid = Dba::escape($uid);
$host = $data['host'] ? Dba::escape($data['host']) : '127.0.0.1';
@ -234,7 +234,7 @@ class AmpacheMpd extends localplay_controller
* set_active_instance
* This sets the specified instance as the 'active' one
*/
public function set_active_instance($uid,$user_id='')
public function set_active_instance($uid, $user_id='')
{
// Not an admin? bubkiss!
if (!$GLOBALS['user']->has_access('100')) {
@ -243,7 +243,7 @@ class AmpacheMpd extends localplay_controller
$user_id = $user_id ? $user_id : $GLOBALS['user']->id;
Preference::update('mpd_active',$user_id,intval($uid));
Preference::update('mpd_active', $user_id, intval($uid));
AmpConfig::set('mpd_active', intval($uid), true);
return true;

View file

@ -93,7 +93,7 @@ class AmpacheUPnP extends localplay_controller
$db_results = Dba::query($sql);
// Add an internal preference for the users current active instance
Preference::insert('upnp_active', 'UPnP Active Instance', '0', '25', 'integer', 'internal','upnp');
Preference::insert('upnp_active', 'UPnP Active Instance', '0', '25', 'integer', 'internal', 'upnp');
return true;
}

View file

@ -71,12 +71,12 @@ class UPnPDevice
* @param string $method Method name
* @param array $arguments Key-Value array
*/
public function sendRequestToDevice( $method, $arguments, $type = 'RenderingControl')
public function sendRequestToDevice($method, $arguments, $type = 'RenderingControl')
{
$body ='<?xml version="1.0" encoding="utf-8"?>';
$body .='<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body>';
$body .=' <u:' . $method . ' xmlns:u="urn:schemas-upnp-org:service:' . $type . ':1">';
foreach ( $arguments as $arg=>$value ) {
foreach ($arguments as $arg=>$value) {
$body .=' <' . $arg . '>' . $value . '</' . $arg . '>';
}
$body .=' </u:' . $method . '>';
@ -97,16 +97,16 @@ class UPnPDevice
//debug_event('upnpdevice', 'sendRequestToDevice Hdr: ' . print_r($header, true), 5);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $controlUrl );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_URL, $controlUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec( $ch );
curl_close( $ch );
$response = curl_exec($ch);
curl_close($ch);
//debug_event('upnpdevice', 'sendRequestToDevice response: ' . $response, 5);
$headers = array();

View file

@ -200,11 +200,11 @@ class UPnPPlayer
private function CallAsyncURL($url)
{
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_FRESH_CONNECT, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_exec( $ch );
curl_close( $ch );
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_exec($ch);
curl_close($ch);
}
/**
@ -332,7 +332,7 @@ class UPnPPlayer
$instanceId = 0;
$channel = 'Master';
$response = $this->Device()->sendRequestToDevice( 'SetVolume', array(
$response = $this->Device()->sendRequestToDevice('SetVolume', array(
'InstanceID' => $instanceId,
'Channel' => $channel,
'DesiredVolume' => $desiredVolume
@ -349,7 +349,7 @@ class UPnPPlayer
$instanceId = 0;
$channel = 'Master';
$response = $this->Device()->sendRequestToDevice( 'GetVolume', array(
$response = $this->Device()->sendRequestToDevice('GetVolume', array(
'InstanceID' => $instanceId,
'Channel' => $channel
));
@ -385,4 +385,4 @@ class UPnPPlayer
debug_event('upnpPlayer', 'ReadIndState:' . $this->_intState, 5);
}
} // End UPnPPlayer Class
?>
;

View file

@ -138,5 +138,3 @@ class UPnPPlaylist
}
}
}
?>

Some files were not shown because too many files have changed in this diff Show more