1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 01:39:28 +02:00

Use latest php-cs-fixer version

This commit is contained in:
Afterster 2015-07-29 21:59:12 +02:00
parent 356b8f1e43
commit 47a6585c88
298 changed files with 7977 additions and 4559 deletions

View file

@ -6,7 +6,7 @@ php:
- 5.6
before_install:
- wget http://cs.sensiolabs.org/get/php-cs-fixer.phar
- wget http://get.sensiolabs.org/php-cs-fixer.phar
before_script:
- chmod +x scripts/tests/syntax.sh

View file

@ -40,7 +40,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Deleted'), T_('Your Access List Entry has been removed'),$url);
break;
case 'show_delete_record':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$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');

View file

@ -55,7 +55,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'add_to_catalog':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=add_to_catalog&catalogs=" . $sse_catalogs;
sse_worker($sse_url);
@ -67,21 +69,28 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'update_catalog':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=update_catalog&catalogs=" . $sse_catalogs;
sse_worker($sse_url);
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'full_service':
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
break;
}
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=full_service&catalogs=" . $sse_catalogs;
sse_worker($sse_url);
show_confirmation(T_('Catalog Update started...'), '', AmpConfig::get('web_path') . '/admin/catalog.php', 0, 'confirmation', false);
break;
case 'delete_catalog':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('delete_catalog')) {
UI::access_denied();
@ -92,7 +101,9 @@ switch ($_REQUEST['action']) {
/* Delete the sucker, we don't need to check perms as thats done above */
foreach ($catalogs as $catalog_id) {
$deleted = Catalog::delete($catalog_id);
if (!$deleted) break;
if (!$deleted) {
break;
}
}
$next_url = AmpConfig::get('web_path') . '/admin/catalog.php';
if ($deleted) {
@ -106,7 +117,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Catalog Delete'), T_('Confirm Deletion Request'),$next_url,1,'delete_catalog');
break;
case 'enable_disabled':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$songs = $_REQUEST['song'];
@ -134,7 +147,9 @@ switch ($_REQUEST['action']) {
break;
case 'update_catalog_settings':
/* No Demo Here! */
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
/* Update the catalog */
Catalog::update_settings($_POST);
@ -145,7 +160,9 @@ switch ($_REQUEST['action']) {
show_confirmation($title,$body,$url);
break;
case 'update_from':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$sse_url = AmpConfig::get('web_path') . "/server/sse.server.php?worker=catalog&action=update_from&add_path=" . scrub_in($_POST['add_path']) . "&update_path=" . $_POST['update_path'];
sse_worker($sse_url);
@ -153,7 +170,9 @@ switch ($_REQUEST['action']) {
break;
case 'add_catalog':
/* Wah Demo! */
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
ob_end_flush();
@ -172,7 +191,6 @@ switch ($_REQUEST['action']) {
// If an error hasn't occured
if (!Error::occurred()) {
$catalog_id = Catalog::create($_POST);
if (!$catalog_id) {
@ -189,7 +207,10 @@ switch ($_REQUEST['action']) {
}
break;
case 'clear_stats':
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
break;
}
Stats::clear();
$url = AmpConfig::get('web_path') . '/admin/catalog.php';
$title = T_('Catalog statistics cleared');
@ -200,13 +221,18 @@ switch ($_REQUEST['action']) {
require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php';
break;
case 'clear_now_playing':
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
break;
}
Stream::clear_now_playing();
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 */
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$songs = Song::get_disabled();
if (count($songs)) {
@ -217,7 +243,10 @@ switch ($_REQUEST['action']) {
break;
case 'show_delete_catalog':
/* Stop the demo hippies */
if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; }
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
break;
}
$catalog = Catalog::create_from_id($_REQUEST['catalog_id']);
$nexturl = AmpConfig::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']);

View file

@ -32,7 +32,9 @@ UI::show_header();
// Switch on the actions
switch ($_REQUEST['action']) {
case 'update_user':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('edit_user','post')) {
UI::access_denied();
@ -112,7 +114,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('User Updated'), $client->fullname . "(" . $client->username . ")" . T_('updated'), AmpConfig::get('web_path'). '/admin/users.php');
break;
case 'add_user':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('add_user','post')) {
UI::access_denied();
@ -161,7 +165,13 @@ switch ($_REQUEST['action']) {
$user = new User($user_id);
$user->upload_avatar();
if ($access == 5) { $access = T_('Guest');} elseif ($access == 25) { $access = T_('User');} elseif ($access == 100) { $access = T_('Admin');}
if ($access == 5) {
$access = T_('Guest');
} elseif ($access == 25) {
$access = T_('User');
} elseif ($access == 100) {
$access = T_('Admin');
}
/* HINT: %1 Username, %2 Access num */
show_confirmation(T_('New User Added'),sprintf(T_('%1$s has been created with an access level of %2$s'), $username, $access), AmpConfig::get('web_path').'/admin/users.php');
@ -183,12 +193,16 @@ switch ($_REQUEST['action']) {
}
break;
case 'show_edit':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$client = new User($_REQUEST['user_id']);
require_once AmpConfig::get('prefix') . '/templates/show_edit_user.inc.php';
break;
case 'confirm_delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('delete_user')) {
UI::access_denied();
exit;
@ -201,7 +215,9 @@ switch ($_REQUEST['action']) {
}
break;
case 'delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$client = new User($_REQUEST['user_id']);
show_confirmation(T_('Deletion Request'),
sprintf(T_('Are you sure you want to permanently delete %s?'), $client->fullname),
@ -214,7 +230,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('User Avatar Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_avatar');
break;
case 'delete_avatar':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('delete_avatar','post')) {
UI::access_denied();
@ -234,7 +252,9 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Generate new API Key'), T_('Confirm API Key Generation'), $next_url, 1, 'generate_apikey');
break;
case 'generate_apikey':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
if (!Core::form_verify('generate_apikey','post')) {
UI::access_denied();
@ -260,7 +280,9 @@ switch ($_REQUEST['action']) {
require AmpConfig::get('prefix') . '/templates/show_ip_history.inc.php';
break;
case 'show_add_user':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
require_once AmpConfig::get('prefix') . '/templates/show_add_user.inc.php';
break;
case 'show_preferences':

View file

@ -27,7 +27,9 @@ require_once AmpConfig::get('prefix') . '/templates/header.inc.php';
/* Switch on Action */
switch ($_REQUEST['action']) {
case 'delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$album_id = scrub_in($_REQUEST['album_id']);
show_confirmation(
@ -39,7 +41,9 @@ switch ($_REQUEST['action']) {
);
break;
case 'confirm_delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$album = new Album($_REQUEST['album_id']);
if (!Catalog::can_remove($album)) {

View file

@ -29,7 +29,9 @@ UI::show_header();
*/
switch ($_REQUEST['action']) {
case 'delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$artist_id = scrub_in($_REQUEST['artist_id']);
show_confirmation(
@ -41,7 +43,9 @@ switch ($_REQUEST['action']) {
);
break;
case 'confirm_delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$artist = new Artist($_REQUEST['artist_id']);
if (!Catalog::can_remove($artist)) {
@ -83,7 +87,11 @@ switch ($_REQUEST['action']) {
case 'match':
case 'Match':
$match = scrub_in($_REQUEST['match']);
if ($match == "Browse" || $match == "Show_all") { $chr = ""; } else { $chr = $match; }
if ($match == "Browse" || $match == "Show_all") {
$chr = "";
} else {
$chr = $match;
}
/* Enclose this in the purty box! */
require AmpConfig::get('prefix') . '/templates/show_box_top.inc.php';
show_alphabet_list('artists','artists.php',$match);

View file

@ -26,7 +26,10 @@ require_once AmpConfig::get('prefix') . '/templates/header.inc.php';
$object_type = $_GET['object_type'];
$object_id = $_GET['object_id'];
if (!Core::is_library_item($object_type)) { UI::access_denied(); exit; }
if (!Core::is_library_item($object_type)) {
UI::access_denied();
exit;
}
$burl = '';
if (isset($_GET['burl'])) {
$burl = base64_decode($_GET['burl']);
@ -34,7 +37,10 @@ if (isset($_GET['burl'])) {
$item = new $object_type($object_id);
// If not a content manager user then kick em out
if (!Access::check('interface', 50) && (!Access::check('interface', 25) || $item->get_user_owner() != $GLOBALS['user']->id)) { UI::access_denied(); exit; }
if (!Access::check('interface', 50) && (!Access::check('interface', 25) || $item->get_user_owner() != $GLOBALS['user']->id)) {
UI::access_denied();
exit;
}
/* Switch on Action */
switch ($_REQUEST['action']) {
@ -87,9 +93,7 @@ switch ($_REQUEST['action']) {
$art->insert($image_data,$upload['0']['mime']);
show_confirmation(T_('Art Inserted'), '', $burl);
break;
} // if image data
} // if it's an upload
$keywords = $item->get_keywords();

View file

@ -50,7 +50,9 @@ if (count($params) > 0) {
$act = strtolower(implode('_', array_slice($params, 0, $i)));
$act = str_replace("-", "_", $act);
foreach ($methods as $method) {
if (in_array($method, $internal_functions)) { continue; }
if (in_array($method, $internal_functions)) {
continue;
}
// If the method is the same as the action being called
// Then let's call this function!
@ -59,7 +61,6 @@ if (count($params) > 0) {
// We only allow a single function to be called, and we assume it's cleaned up!
exit();
}
} // end foreach methods in API
}
}

View file

@ -41,7 +41,9 @@ if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
}
// If we aren't resizing just trash thumb
if (!AmpConfig::get('resize_images')) { $_GET['thumb'] = null; }
if (!AmpConfig::get('resize_images')) {
$_GET['thumb'] = null;
}
// FIXME: Legacy stuff - should be removed after a version or so
if (!isset($_GET['object_type'])) {
@ -49,8 +51,9 @@ if (!isset($_GET['object_type'])) {
}
$type = $_GET['object_type'];
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
exit;
}
/* Decide what size this image is */
$size = Art::get_thumb_size($_GET['thumb']);

View file

@ -166,7 +166,9 @@ switch ($_REQUEST['action']) {
}
case 'show_create_account':
$results = parse_ini_file($configfile);
if (!isset($created_config)) $created_config = true;
if (!isset($created_config)) {
$created_config = true;
}
/* Make sure we've got a valid config file */
if (!check_config_values($results) || !$created_config) {
@ -212,3 +214,4 @@ switch ($_REQUEST['action']) {
require_once 'templates/show_install_lang.inc.php';
break;
} // end action switch

View file

@ -27,7 +27,9 @@ UI::show_header();
// Switch on the incomming action
switch ($_REQUEST['action']) {
case 'delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$label_id = scrub_in($_REQUEST['label_id']);
show_confirmation(
@ -39,7 +41,9 @@ switch ($_REQUEST['action']) {
);
break;
case 'confirm_delete':
if (AmpConfig::get('demo_mode')) { break; }
if (AmpConfig::get('demo_mode')) {
break;
}
$label = new Label($_REQUEST['label_id']);
if (!Catalog::can_remove($label)) {

View file

@ -93,7 +93,9 @@ class Access
*/
public function __construct($access_id = null)
{
if (!$access_id) { return false; }
if (!$access_id) {
return false;
}
/* Assign id for use in get_info() */
$this->id = intval($access_id);
@ -232,7 +234,6 @@ class Access
Dba::write($sql, array($name, $level, $start, $end, $user, $type, $enabled));
return true;
}
/**
@ -476,7 +477,9 @@ class Access
*/
public function get_user_name()
{
if ($this->user == '-1') { return T_('All'); }
if ($this->user == '-1') {
return T_('All');
}
$user = new User($this->user);
return $user->fullname . " (" . $user->username . ")";

View file

@ -40,7 +40,6 @@ class Ajax
public function __construct()
{
// Rien a faire
} // constructor
/**
@ -78,7 +77,6 @@ class Ajax
$observe .= "</script>";
return $observe;
} // observe
/**
@ -120,7 +118,6 @@ class Ajax
}
return $ajax_string;
} // action
/**
@ -156,7 +153,6 @@ class Ajax
$string .= self::observe($source, 'click', $ajax_string, $confirm);
return $string;
} // button
/**
@ -193,7 +189,6 @@ class Ajax
}
return $string;
} // text
/**
@ -206,7 +201,6 @@ class Ajax
echo "<script type=\"text/javascript\"><!--\n";
echo "$action";
echo "\n--></script>";
} // run
/**
@ -218,7 +212,6 @@ class Ajax
public static function set_include_override($value)
{
self::$include_override = make_bool($value);
} // set_include_override
/**
@ -230,14 +223,15 @@ class Ajax
*/
public static function start_container($name, $class = '')
{
if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; }
if (defined('AJAX_INCLUDE') && !self::$include_override) {
return true;
}
echo '<div id="' . scrub_out($name) . '"';
if (!empty($class)) {
echo ' class="' . scrub_out($class) . '"';
}
echo '>';
} // start_container
/**
@ -246,12 +240,13 @@ class Ajax
*/
public static function end_container()
{
if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; }
if (defined('AJAX_INCLUDE') && !self::$include_override) {
return true;
}
echo "</div>";
self::$include_override = false;
} // end_container
} // end Ajax class

View file

@ -187,7 +187,9 @@ class Album extends database_object implements library_item
*/
public function __construct($id=null)
{
if (!$id) { return false; }
if (!$id) {
return false;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -206,7 +208,6 @@ class Album extends database_object implements library_item
}
return true;
} // constructor
/**
@ -226,7 +227,6 @@ class Album extends database_object implements library_item
$album->_fake = true; // Make sure that we tell em it's fake
return $album;
} // construct_from_array
/**
@ -263,7 +263,6 @@ class Album extends database_object implements library_item
}
return true;
} // build_cache
/**
@ -333,7 +332,6 @@ class Album extends database_object implements library_item
parent::add_to_cache('album_extra', $this->id, $results);
return $results;
} // _get_extra_info
public function can_edit($user = null)
@ -342,20 +340,25 @@ class Album extends database_object implements library_item
$user = $GLOBALS['user']->id;
}
if (!$user)
if (!$user) {
return false;
}
if ($this->user !== null && $user == $this->user)
if ($this->user !== null && $user == $this->user) {
return true;
}
if (Access::check('interface', 50, $user))
if (Access::check('interface', 50, $user)) {
return true;
}
if (!$this->album_artist)
if (!$this->album_artist) {
return false;
}
if (!AmpConfig::get('upload_allow_edit'))
if (!AmpConfig::get('upload_allow_edit')) {
return false;
}
$owner = $this->get_user_owner();
return ($owner && $owner === $user);
@ -490,7 +493,6 @@ class Album extends database_object implements library_item
}
return $results;
} // get_songs
/**
@ -554,7 +556,6 @@ class Album extends database_object implements library_item
}
return $results;
} // get_album_suite
/**
@ -571,7 +572,6 @@ class Album extends database_object implements library_item
$data = Dba::fetch_assoc($db_results);
return $data;
} // has_track
/**
@ -605,7 +605,9 @@ class Album extends database_object implements library_item
if ($details) {
/* Pull the advanced information */
$data = $this->_get_extra_info($limit_threshold);
foreach ($data as $key=>$value) { $this->$key = $value; }
foreach ($data as $key=>$value) {
$this->$key = $value;
}
if ($this->album_artist) {
$Album_artist = new Artist($this->album_artist);
@ -649,7 +651,6 @@ class Album extends database_object implements library_item
}
$this->f_release_type = ucwords($this->release_type);
} // format
/**
@ -773,8 +774,9 @@ class Album extends database_object implements library_item
*/
public function get_user_owner()
{
if (!$this->album_artist)
if (!$this->album_artist) {
return null;
}
$artist = new Artist($this->album_artist);
return $artist->get_user_owner();
@ -804,10 +806,12 @@ class Album extends database_object implements library_item
if (Art::has_db($this->id, 'album')) {
$id = $this->id;
$type = 'album';
} else if (Art::has_db($this->artist_id, 'artist')) {
} else {
if (Art::has_db($this->artist_id, 'artist')) {
$id = $this->artist_id;
$type = 'artist';
}
}
if ($id !== null && $type !== null) {
Art::display($type, $id, $this->get_fullname(), $thumb, $this->link);
@ -838,7 +842,6 @@ class Album extends database_object implements library_item
}
return $results;
} // get_random_songs
/**
@ -880,7 +883,9 @@ class Album extends database_object implements library_item
$album_id = self::check($name, $year, $disk, $mbid, $mbid_group, $album_artist, $release_type);
if ($album_id != $this->id) {
if (!is_array($songs)) { $songs = $this->get_songs(); }
if (!is_array($songs)) {
$songs = $this->get_songs();
}
foreach ($songs as $song_id) {
Song::update_album($album_id,$song_id);
Song::update_year($year,$song_id);
@ -928,7 +933,6 @@ class Album extends database_object implements library_item
}
return $current_id;
} // update
/**
@ -1067,5 +1071,5 @@ class Album extends database_object implements library_item
return $results;
}
} //end of album class

View file

@ -40,7 +40,6 @@ class Ampache_RSS
public function __construct($type)
{
$this->type = self::validate_type($type);
} // constructor
/**
@ -81,7 +80,6 @@ class Ampache_RSS
}
return null;
} // get_xml
/**
@ -99,7 +97,6 @@ class Ampache_RSS
);
return scrub_out(AmpConfig::get('site_title')) . ' - ' . $titles[$this->type];
} // get_title
/**
@ -111,7 +108,6 @@ class Ampache_RSS
{
//FIXME: For now don't do any kind of translating
return 'Ampache RSS Feeds';
} // get_description
/**
@ -129,7 +125,6 @@ class Ampache_RSS
}
return $type;
} // validate_type
/**
@ -159,7 +154,6 @@ class Ampache_RSS
$string .= '</a>';
return $string;
} // get_display
// type specific functions below, these are called semi-dynamically based on the current type //
@ -203,7 +197,6 @@ class Ampache_RSS
} // end foreach
return $results;
} // load_now_playing
/**
@ -220,7 +213,6 @@ class Ampache_RSS
$element = array_shift($data);
return $element['expire'];
} // pubdate_now_playing
/**
@ -276,11 +268,9 @@ class Ampache_RSS
'comments'=>$client->username,
'pubDate'=>date("r",$item['date']));
$results[] = $xml_array;
} // end foreach
return $results;
} // load_recently_played
/**
@ -306,11 +296,9 @@ class Ampache_RSS
'pubDate' => date("c", $album->get_addtime_first_song())
);
$results[] = $xml_array;
} // end foreach
return $results;
} // load_latest_album
/**
@ -336,11 +324,9 @@ class Ampache_RSS
'pubDate' => ''
);
$results[] = $xml_array;
} // end foreach
return $results;
} // load_latest_artist
/**
@ -370,11 +356,9 @@ class Ampache_RSS
'pubDate' => date("c", $shout->date)
);
$results[] = $xml_array;
} // end foreach
return $results;
} // load_latest_shout
/**
@ -389,7 +373,6 @@ class Ampache_RSS
$element = array_shift($data);
return $element['date'];
} // pubdate_recently_played
} // end Ampache_RSS class

View file

@ -51,7 +51,6 @@ class Api
private function __construct()
{
// Rien a faire
} // constructor
/**
@ -77,7 +76,9 @@ class Api
*/
public static function set_filter($filter,$value)
{
if (!strlen($value)) { return false; }
if (!strlen($value)) {
return false;
}
switch ($filter) {
case 'add':
@ -112,7 +113,6 @@ class Api
} // end filter
return true;
} // set_filter
/**
@ -257,7 +257,6 @@ class Api
'catalogs'=>$catalog['catalog']));
return true;
} // match
} // end while
debug_event('API','Login Failed, unable to match passphrase','1');
@ -286,7 +285,6 @@ class Api
ob_end_clean();
echo XML_Data::keyed_array($xmldata);
} // ping
/**
@ -315,7 +313,6 @@ class Api
// echo out the resulting xml document
ob_end_clean();
echo XML_Data::artists($artists);
} // artists
/**
@ -328,7 +325,6 @@ class Api
{
$uid = scrub_in($input['filter']);
echo XML_Data::artists(array($uid));
} // artist
/**
@ -347,7 +343,6 @@ class Api
XML_Data::set_limit($input['limit']);
ob_end_clean();
echo XML_Data::albums($albums);
} // artist_albums
/**
@ -365,7 +360,6 @@ class Api
XML_Data::set_limit($input['limit']);
ob_end_clean();
echo XML_Data::songs($songs);
} // artist_songs
/**
@ -390,7 +384,6 @@ class Api
XML_Data::set_limit($input['limit']);
ob_end_clean();
echo XML_Data::albums($albums);
} // albums
/**
@ -402,7 +395,6 @@ class Api
{
$uid = scrub_in($input['filter']);
echo XML_Data::albums(array($uid));
} // album
/**
@ -421,7 +413,6 @@ class Api
ob_end_clean();
echo XML_Data::songs($songs);
} // album_songs
/**
@ -445,7 +436,6 @@ class Api
ob_end_clean();
echo XML_Data::tags($tags);
} // tags
/**
@ -458,7 +448,6 @@ class Api
$uid = scrub_in($input['filter']);
ob_end_clean();
echo XML_Data::tags(array($uid));
} // tag
/**
@ -476,7 +465,6 @@ class Api
ob_end_clean();
echo XML_Data::artists($artists);
}
} // tag_artists
/**
@ -494,7 +482,6 @@ class Api
ob_end_clean();
echo XML_Data::albums($albums);
}
} // tag_albums
/**
@ -511,7 +498,6 @@ class Api
ob_end_clean();
echo XML_Data::songs($songs);
} // tag_songs
/**
@ -538,7 +524,6 @@ class Api
ob_end_clean();
echo XML_Data::songs($songs);
} // songs
/**
@ -552,7 +537,6 @@ class Api
ob_end_clean();
echo XML_Data::songs(array($uid));
} // song
/**
@ -590,7 +574,6 @@ class Api
ob_end_clean();
echo XML_Data::playlists($playlist_ids);
} // playlists
/**
@ -604,7 +587,6 @@ class Api
ob_end_clean();
echo XML_Data::playlists(array($uid));
} // playlist
/**
@ -628,7 +610,6 @@ class Api
XML_Data::set_limit($input['limit']);
ob_end_clean();
echo XML_Data::songs($songs,$items);
} // playlist_songs
/**
@ -681,7 +662,6 @@ class Api
$playlist->add_songs(array($song));
echo XML_Data::single_string('success');
}
} // playlist_add_song
/**
@ -700,7 +680,6 @@ class Api
$playlist->delete_track_number($track);
echo XML_Data::single_string('success');
}
} // playlist_remove_song
/**
@ -724,7 +703,6 @@ class Api
$results = Search::run($array);
echo XML_Data::songs($results);
} // search_songs
/**
@ -747,7 +725,6 @@ class Api
XML_Data::set_limit($input['limit']);
echo XML_Data::videos($video_ids);
} // videos
/**
@ -760,8 +737,6 @@ class Api
$video_id = scrub_in($input['filter']);
echo XML_Data::videos(array($video_id));
} // video
/**
@ -789,7 +764,6 @@ class Api
echo XML_Data::error('405', T_('Invalid Request'));
break;
} // end switch on command
} // localplay
/**
@ -851,7 +825,6 @@ class Api
echo XML_Data::error('405', T_('Invalid Request'));
break;
} // switch on method
} // democratic
/**
@ -868,11 +841,14 @@ class Api
$albums = null;
if ($type == "newest") {
$albums = Stats::get_newest("album", $limit, $offset);
} else if ($type == "highest") {
} else {
if ($type == "highest") {
$albums = Rating::get_highest("album", $limit, $offset);
} else if ($type == "frequent") {
} else {
if ($type == "frequent") {
$albums = Stats::get_top("album", $limit, '', $offset);
} else if ($type == "recent") {
} else {
if ($type == "recent") {
if (!empty($username)) {
$user = User::get_from_username($username);
if ($user !== null) {
@ -883,7 +859,8 @@ class Api
} else {
$albums = Stats::get_recent("album", $limit, $offset);
}
} else if ($type == "flagged") {
} else {
if ($type == "flagged") {
$albums = Userflag::get_latest('album');
} else {
if (!$limit) {
@ -891,6 +868,10 @@ class Api
}
$albums = Album::get_random($limit);
}
}
}
}
}
if ($albums !== null) {
ob_end_clean();
@ -996,5 +977,5 @@ class Api
debug_event('api', 'Sociable feature is not enabled.', 3);
}
} // last_shouts
} // API class

View file

@ -81,12 +81,12 @@ class Art extends database_object
*/
public function __construct($uid, $type = 'album', $kind = 'default')
{
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return false;
}
$this->type = $type;
$this->uid = intval($uid);
$this->kind = $kind;
} // constructor
/**
@ -99,7 +99,9 @@ class Art extends database_object
*/
public static function build_cache($object_ids)
{
if (!is_array($object_ids) || !count($object_ids)) { return false; }
if (!is_array($object_ids) || !count($object_ids)) {
return false;
}
$uidlist = '(' . implode(',', $object_ids) . ')';
$sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_id` IN $uidlist";
$db_results = Dba::read($sql);
@ -110,7 +112,6 @@ class Art extends database_object
}
return true;
} // build_cache
/**
@ -173,10 +174,11 @@ class Art extends database_object
$data = explode("/", $mime);
$extension = $data['1'];
if ($extension == 'jpeg') { $extension = 'jpg'; }
if ($extension == 'jpeg') {
$extension = 'jpg';
}
return $extension;
} // extension
/**
@ -234,7 +236,6 @@ class Art extends database_object
} else {
return $this->thumb;
}
} // get
@ -258,7 +259,8 @@ class Art extends database_object
$this->raw = $results['image'];
}
$this->raw_mime = $results['mime'];
} else if (AmpConfig::get('resize_images') && $results['size'] == '275x275') {
} else {
if (AmpConfig::get('resize_images') && $results['size'] == '275x275') {
if (AmpConfig::get('album_art_store_disk')) {
$this->thumb = self::read_from_dir($results['size'], $this->type, $this->uid, $this->kind);
} else {
@ -266,10 +268,13 @@ class Art extends database_object
}
$this->raw_mime = $results['mime'];
}
}
$this->id = $results['id'];
}
// If we get nothing return false
if (!$this->raw) { return false; }
if (!$this->raw) {
return false;
}
// If there is no thumb and we want thumbs
if (!$this->thumb && AmpConfig::get('resize_images')) {
@ -286,7 +291,6 @@ class Art extends database_object
} // if no thumb, but art and we want to resize
return true;
} // get_db
/**
@ -345,7 +349,9 @@ class Art extends database_object
public function insert($source, $mime = '')
{
// Disabled in demo mode cause people suck and upload porn
if (AmpConfig::get('demo_mode')) { return false; }
if (AmpConfig::get('demo_mode')) {
return false;
}
// Check to make sure we like this image
if (!self::test_image($source)) {
@ -404,7 +410,6 @@ class Art extends database_object
Dba::write($sql, array($source, $mime, $sizetext, $width, $height, $this->type, $this->uid, $this->kind));
return true;
} // insert
public static function check_dimensions($dimensions)
@ -521,9 +526,13 @@ class Art extends database_object
if (Core::is_readable($path)) {
foreach (scandir($path) as $file) {
if ('.' === $file || '..' === $file) continue;
elseif (is_dir($path . '/' . $file)) self::delete_rec_dir($path . '/' . $file);
else unlink($path . '/' . $file);
if ('.' === $file || '..' === $file) {
continue;
} elseif (is_dir($path . '/' . $file)) {
self::delete_rec_dir($path . '/' . $file);
} else {
unlink($path . '/' . $file);
}
}
rmdir($path);
}
@ -599,7 +608,6 @@ class Art extends database_object
}
return $results;
} // get_thumb
/**
@ -702,7 +710,6 @@ class Art extends database_object
}
return array('thumb' => $data, 'thumb_mime' => $mime_type);
} // generate_thumb
/**
@ -772,7 +779,6 @@ class Art extends database_object
} // if data song
return null;
} // get_from_source
/**
@ -786,8 +792,9 @@ class Art extends database_object
*/
public static function url($uid,$type,$sid=null,$thumb=null)
{
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return null;
}
if (AmpConfig::get('use_auth') && AmpConfig::get('require_session')) {
$sid = $sid ? scrub_out($sid) : scrub_out(session_id());
@ -816,11 +823,13 @@ class Art extends database_object
parent::add_to_cache('art', $key . $row['size'], $row);
if ($row['size'] == 'original') {
$mime = $row['mime'];
} else if ($row['size'] == '275x275' && AmpConfig::get('resize_images')) {
} else {
if ($row['size'] == '275x275' && AmpConfig::get('resize_images')) {
$thumb_mime = $row['mime'];
}
}
}
}
$mime = isset($thumb_mime) ? $thumb_mime : (isset($mime) ? $mime : null);
$extension = self::extension($mime);
@ -846,7 +855,6 @@ class Art extends database_object
}
return $url;
} // url
/**
@ -973,7 +981,8 @@ class Art extends database_object
$data = $plugin->_plugin->gather_arts($type, $options, $limit);
}
}
} else if (in_array($method_name, $methods)) {
} else {
if (in_array($method_name, $methods)) {
debug_event('Art', "Method used: $method_name", 3);
// Some of these take options!
switch ($method_name) {
@ -990,6 +999,7 @@ class Art extends database_object
} else {
debug_event("Art", $method_name . " not defined", 1);
}
}
// Add the results we got to the current set
$results = array_merge($results, (array) $data);
@ -997,11 +1007,9 @@ class Art extends database_object
if ($limit && count($results) >= $limit) {
return array_slice($results, 0, $limit);
}
} // end foreach
return $results;
} // gather
///////////////////////////////////////////////////////////////////////
@ -1173,7 +1181,6 @@ class Art extends database_object
} // end foreach
return $images;
} // gather_musicbrainz
/**
@ -1216,10 +1223,12 @@ class Art extends database_object
$song = new Song($song_id);
$dirs[] = Core::conv_lc_file( dirname($song->file) );
}
} else if ($this->type == 'video') {
} else {
if ($this->type == 'video') {
$media = new Video($this->uid);
$dirs[] = Core::conv_lc_file( dirname($media->file) );
}
}
foreach ($dirs as $dir) {
if (isset($processed[$dir])) {
@ -1284,10 +1293,8 @@ class Art extends database_object
'mime' => 'image/' . $extension,
'title' => 'Folder'
);
} // end while reading dir
closedir($handle);
} // end foreach dirs
if (is_array($preferred)) {
@ -1302,7 +1309,6 @@ class Art extends database_object
}
return array_values($results);
} // gather_folder
/**
@ -1376,7 +1382,9 @@ class Art extends database_object
$mtype = strtolower(get_class($media));
$data = array();
$getID3 = new getID3();
try { $id3 = $getID3->analyze($media->file); } catch (Exception $error) {
try {
$id3 = $getID3->analyze($media->file);
} catch (Exception $error) {
debug_event('getid3', $error->getMessage(), 1);
}
@ -1411,7 +1419,6 @@ class Art extends database_object
}
return $data;
}
/**
@ -1452,16 +1459,16 @@ class Art extends database_object
$mime = 'image/' . $results['extension'];
$images[] = array('url' => $match, 'mime' => $mime, 'title' => 'Google');
if ($limit > 0 && count($images) >= $limit)
if ($limit > 0 && count($images) >= $limit) {
break;
}
}
}
} catch (Exception $e) {
debug_event('Art', 'Error getting google images: ' . $e->getMessage(), '1');
}
return $images;
} // gather_google
/**
@ -1487,10 +1494,14 @@ class Art extends database_object
try {
$xmldata = Recommendation::album_search($data['artist'], $data['album']);
if (!count($xmldata)) { return array(); }
if (!count($xmldata)) {
return array();
}
$coverart = (array) $xmldata->coverart;
if (!$coverart) { return array(); }
if (!$coverart) {
return array();
}
ksort($coverart);
foreach ($coverart as $url) {
@ -1513,7 +1524,6 @@ class Art extends database_object
}
return $images;
} // gather_lastfm
/**
@ -1677,8 +1687,9 @@ class Art extends database_object
*/
public static function display($object_type, $object_id, $name, $thumb, $link = null, $show_default = true, $kind = 'default')
{
if (!Core::is_library_item($object_type))
if (!Core::is_library_item($object_type)) {
return false;
}
if (!$show_default) {
// Don't show any image if not available
@ -1733,5 +1744,5 @@ class Art extends database_object
return true;
}
} // Art

View file

@ -139,7 +139,9 @@ class Artist extends database_object implements library_item
public function __construct($id=null,$catalog_init=0)
{
/* If they failed to pass in an id, just run for it */
if (!$id) { return false; }
if (!$id) {
return false;
}
$this->catalog_id = $catalog_init;
/* Get the information from the db */
@ -150,7 +152,6 @@ class Artist extends database_object implements library_item
} // foreach info
return true;
} //constructor
/**
@ -171,7 +172,6 @@ class Artist extends database_object implements library_item
$artist->_fake = true;
return $artist;
} // construct_from_array
/**
@ -196,7 +196,9 @@ class Artist extends database_object implements library_item
*/
public static function build_cache($ids, $extra=false, $limit_threshold = '')
{
if (!is_array($ids) OR !count($ids)) { return false; }
if (!is_array($ids) OR !count($ids)) {
return false;
}
$idlist = '(' . implode(',', $ids) . ')';
@ -220,11 +222,9 @@ class Artist extends database_object implements library_item
}
parent::add_to_cache('artist_extra',$row['artist'],$row);
}
} // end if extra
return true;
} // build_cache
/**
@ -243,7 +243,6 @@ class Artist extends database_object implements library_item
$object = new Artist($row['id']);
return $object;
} // get_from_name
/**
@ -321,7 +320,6 @@ class Artist extends database_object implements library_item
}
return $results;
} // get_albums
/**
@ -348,7 +346,6 @@ class Artist extends database_object implements library_item
}
return $results;
} // get_songs
/**
@ -376,7 +373,6 @@ class Artist extends database_object implements library_item
}
return $results;
} // get_random_songs
/**
@ -418,7 +414,6 @@ class Artist extends database_object implements library_item
$this->catalog_id = $row['catalog_id'];
return $row;
} // _get_extra_info
/**
@ -437,7 +432,9 @@ class Artist extends database_object implements library_item
$this->f_full_name = trim(trim($this->prefix) . ' ' . trim($this->name));
// If this is a memory-only object, we're done here
if (!$this->id) { return true; }
if (!$this->id) {
return true;
}
if ($this->catalog_id) {
$this->link = AmpConfig::get('web_path') . '/artists.php?action=show&catalog=' . $this->catalog_id . '&artist=' . $this->id;
@ -471,7 +468,6 @@ class Artist extends database_object implements library_item
}
return true;
} // format
/**
@ -627,13 +623,15 @@ class Artist extends database_object implements library_item
$user = $GLOBALS['user']->id;
}
if (!$user)
if (!$user) {
return false;
}
if (AmpConfig::get('upload_allow_edit')) {
if ($this->user !== null && $user == $this->user)
if ($this->user !== null && $user == $this->user) {
return true;
}
}
return Access::check('interface', 50, $user);
}
@ -653,7 +651,9 @@ class Artist extends database_object implements library_item
$name = $trimmed['string'];
$prefix = $trimmed['prefix'];
if ($mbid == '') $mbid = null;
if ($mbid == '') {
$mbid = null;
}
if (!$name) {
$name = T_('Unknown (Orphaned)');
@ -725,7 +725,6 @@ class Artist extends database_object implements library_item
self::$_mapcache[$name][$mbid] = $id;
return $id;
}
/**
@ -773,10 +772,12 @@ class Artist extends database_object implements library_item
Rating::gc();
Userflag::gc();
} // if updated
} else if ($this->mbid != $mbid) {
} else {
if ($this->mbid != $mbid) {
$sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?';
Dba::write($sql, array($mbid, $current_id));
}
}
// Update artist name (if we don't want to use the MusicBrainz name)
$trimmed = Catalog::trim_prefix(trim($name));
@ -810,7 +811,6 @@ class Artist extends database_object implements library_item
}
return $current_id;
} // update
/**
@ -894,5 +894,5 @@ class Artist extends database_object implements library_item
return $deleted;
}
} // end of artist class

View file

@ -85,5 +85,5 @@ class Artist_Event
return false;
}
} // end of recommendation class

View file

@ -100,7 +100,9 @@ class Auth
}
$results = self::$function_name($username, $password);
if ($results['success'] || ($allow_ui && !empty($results['ui_required']))) { break; }
if ($results['success'] || ($allow_ui && !empty($results['ui_required']))) {
break;
}
}
return $results;
@ -377,11 +379,8 @@ class Auth
$results['email'] = $info[0][$ldap_email_field][0];
return $results;
} // if we get something good back
} // if something was sent back
} // if failed connect
/* Default to bad news */
@ -389,7 +388,6 @@ class Auth
$results['error'] = 'LDAP login attempt failed';
return $results;
} // ldap_auth
/**
@ -516,10 +514,12 @@ class Auth
if ($response->status == Auth_OpenID_CANCEL) {
$results['success'] = false;
$results['error'] = 'OpenID verification cancelled.';
} else if ($response->status == Auth_OpenID_FAILURE) {
} else {
if ($response->status == Auth_OpenID_FAILURE) {
$results['success'] = false;
$results['error'] = 'OpenID authentication failed: ' . $response->message;
} else if ($response->status == Auth_OpenID_SUCCESS) {
} else {
if ($response->status == Auth_OpenID_SUCCESS) {
// Extract the identity URL and Simple Registration data (if it was returned).
$sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
$sreg = $sreg_resp->contents();
@ -567,6 +567,8 @@ class Auth
}
}
}
}
}
return $results;
}

View file

@ -78,7 +78,9 @@ class Broadcast extends database_object implements library_item
*/
public function __construct($id=0)
{
if (!$id) { return true; }
if (!$id) {
return true;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -404,7 +406,6 @@ class Broadcast extends database_object implements library_item
public static function gc()
{
}
/*
@ -421,5 +422,5 @@ class Broadcast extends database_object implements library_item
{
return $oid;
}
} // end of broadcast class

View file

@ -438,5 +438,5 @@ class Broadcast_Server implements MessageComponentInterface
return $websocket_address . '/broadcast';
}
} // end of broadcast_server class

View file

@ -63,7 +63,6 @@ class Browse extends Query
public function set_simple_browse($value)
{
$this->set_is_simple($value);
} // set_simple_browse
/**
@ -78,7 +77,6 @@ class Browse extends Query
$_SESSION['browse']['supplemental'][$this->id][$class] = intval($uid);
return true;
} // add_supplemental_object
/**
@ -97,7 +95,6 @@ class Browse extends Query
}
return $objects;
} // get_supplemental_objects
/**
@ -113,7 +110,6 @@ class Browse extends Query
// Checking if value is suitable
$start = $_SESSION[$name]['start'];
if ($this->get_offset() > 0) {
$set_page = floor($start / $this->get_offset());
if ($this->get_total() > $this->get_offset()) {
$total_pages = ceil($this->get_total() / $this->get_offset());
@ -155,9 +151,11 @@ class Browse extends Query
$this->get_offset(),
true
);
} else if (!count($object_ids)) {
} else {
if (!count($object_ids)) {
$this->set_total(0);
}
}
// Load any additional object we need for this
$extra_objects = $this->get_supplemental_objects();
@ -363,7 +361,6 @@ class Browse extends Query
}
}
Ajax::end_container();
} // show_object
public function show_next_link($argument = null)
@ -533,5 +530,5 @@ class Browse extends Query
{
return $this->_state['threshold'];
}
} // browse

View file

@ -1922,8 +1922,9 @@ abstract class Catalog extends database_object
$catalog = self::create_from_id($catalog_id);
if (!$catalog->id)
if (!$catalog->id) {
return false;
}
$sql = 'DELETE FROM `catalog_' . $catalog->get_type() . '` WHERE catalog_id = ?';
$db_results = Dba::write($sql, array($catalog_id));
@ -2057,14 +2058,17 @@ abstract class Catalog extends database_object
$user = $GLOBALS['user']->id;
}
if (!$user)
if (!$user) {
return false;
}
if (!AmpConfig::get('delete_from_disk'))
if (!AmpConfig::get('delete_from_disk')) {
return false;
}
return (Access::check('interface','75') || ($libitem->get_user_owner() == $user && AmpConfig::get('upload_allow_remove')));
}
}
// end of catalog class

View file

@ -59,7 +59,9 @@ class Channel extends database_object implements media, library_item
*/
public function __construct($id=0)
{
if (!$id) { return true; }
if (!$id) {
return true;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -423,8 +425,9 @@ class Channel extends database_object implements media, library_item
}
if (is_resource($this->transcoder['handle'])) {
if (ftell($this->transcoder['handle']) == 0)
if (ftell($this->transcoder['handle']) == 0) {
$this->header_chunk = '';
}
$chunk = fread($this->transcoder['handle'], $this->chunk_size);
$this->media_bytes_streamed += strlen($chunk);
@ -453,13 +456,15 @@ class Channel extends database_object implements media, library_item
$ogg_sum_segm_laces += hexdec(substr($hex, 27*2 + $segm*2, 2));
}
$this->header_chunk .= substr($clchunk, 0, 27 + $ogg_nr_of_segments + $ogg_sum_segm_laces);
if (strlen($clchunk) < (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces))
if (strlen($clchunk) < (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces)) {
$this->header_chunk_remainder = (int) (27 + $ogg_nr_of_segments + $ogg_sum_segm_laces - strlen($clchunk));
}
$clchunk = substr($clchunk, 27 + $ogg_nr_of_segments + $ogg_sum_segm_laces);
} else //no more interesting headers
} else { //no more interesting headers
$clchunk = '';
}
}
}
//debug_event('channel', 'File handle pointer: ' . ftell($this->transcoder['handle']) ,'5');
//debug_event('channel', 'CHUNK : ' . $chunk, '5');
//debug_event('channel', 'Chunk size: ' . strlen($chunk) ,'5');
@ -531,15 +536,15 @@ class Channel extends database_object implements media, library_item
public static function gc()
{
}
private function strtohex($x)
{
$s='';
foreach(str_split($x) as $c) $s.=sprintf("%02X",ord($c));
foreach (str_split($x) as $c) {
$s.=sprintf("%02X",ord($c));
}
return($s);
}
} // end of channel class

View file

@ -44,7 +44,6 @@ class Clip extends Video
}
return true;
} // Constructor
/**
@ -70,7 +69,6 @@ class Clip extends Video
Dba::write($sql, array($data['id'], $data['artist'], $data['song']));
return $data['id'];
} // create
/**
@ -83,7 +81,6 @@ class Clip extends Video
Dba::write($sql, array($data['artist'], $data['song'], $this->id));
return $this->id;
} // update
/**
@ -110,7 +107,6 @@ class Clip extends Video
}
return true;
} //format
/**
@ -137,5 +133,5 @@ class Clip extends Video
return null;
}
} // Clip class

View file

@ -36,7 +36,6 @@ class Core
private function __construct()
{
return false;
} // construction
/**
@ -110,7 +109,6 @@ class Core
} // end switch on type
return $string;
} // form_register
/**
@ -160,7 +158,6 @@ class Core
// OMG HAX0RZ
debug_event('Core', "$type form $sid failed consistency check, rejecting request", 2);
return false;
} // form_verify
/**
@ -171,19 +168,24 @@ class Core
*/
public static function image_dimensions($image_data)
{
if (!function_exists('ImageCreateFromString')) { return false; }
if (!function_exists('ImageCreateFromString')) {
return false;
}
$image = ImageCreateFromString($image_data);
if (!$image) { return false; }
if (!$image) {
return false;
}
$width = imagesx($image);
$height = imagesy($image);
if (!$width || !$height) { return false; }
if (!$width || !$height) {
return false;
}
return array('width'=>$width,'height'=>$height);
} // image_dimensions
/*
@ -326,3 +328,4 @@ class Core
return $options;
}
} // Core

View file

@ -173,7 +173,6 @@ class Daap_Api
if (!isset($_GET['session-id'])) {
debug_event('daap', 'Missing session id.', '');
} else {
$sql = "SELECT * FROM `daap_session` WHERE `id` = ?";
$db_results = Dba::read($sql, array($_GET['session-id']));

View file

@ -45,7 +45,9 @@ abstract class database_object
$table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));
// Make sure we've got a real id
if (!is_numeric($id)) { return array(); }
if (!is_numeric($id)) {
return array();
}
if (self::is_cached($table_name,$id)) {
return self::get_from_cache($table_name,$id);
@ -54,14 +56,15 @@ abstract class database_object
$sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
$db_results = Dba::read($sql);
if (!$db_results) { return array(); }
if (!$db_results) {
return array();
}
$row = Dba::fetch_assoc($db_results);
self::add_to_cache($table_name,$id,$row);
return $row;
} // get_info
/**
@ -79,10 +82,11 @@ abstract class database_object
public static function is_cached($index, $id)
{
// Make sure we've got some parents here before we dive below
if (!isset(self::$object_cache[$index])) { return false; }
if (!isset(self::$object_cache[$index])) {
return false;
}
return isset(self::$object_cache[$index][$id]);
} // is_cached
/**
@ -98,7 +102,6 @@ abstract class database_object
}
return false;
} // get_from_cache
/**
@ -107,11 +110,12 @@ abstract class database_object
*/
public static function add_to_cache($index, $id, $data)
{
if (!self::$_enabled) { return false; }
if (!self::$_enabled) {
return false;
}
$value = is_null($data) ? false : $data;
self::$object_cache[$index][$id] = $value;
} // add_to_cache
/**
@ -124,7 +128,6 @@ abstract class database_object
if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
unset(self::$object_cache[$index][$id]);
}
} // remove_from_cache
/**
@ -134,7 +137,6 @@ abstract class database_object
public static function _auto_init()
{
self::$_enabled = AmpConfig::get('memory_cache');
} // _auto_init
} // end database_object

View file

@ -21,7 +21,9 @@
*/
/* Make sure they aren't directly accessing it */
if (!defined('INIT_LOADED') || INIT_LOADED != '1') { exit; }
if (!defined('INIT_LOADED') || INIT_LOADED != '1') {
exit;
}
/**
* Dba Class
@ -48,7 +50,6 @@ class Dba
private function __construct()
{
// Rien a faire
} // construct
/**
@ -93,13 +94,15 @@ class Dba
self::$_error = json_encode($dbh->errorInfo());
debug_event('Dba', 'Error: ' . json_encode($dbh->errorInfo()), 1);
self::disconnect();
} else if ($stmt->errorCode() && $stmt->errorCode() != '00000') {
} else {
if ($stmt->errorCode() && $stmt->errorCode() != '00000') {
self::$_error = json_encode($stmt->errorInfo());
debug_event('Dba', 'Error: ' . json_encode($stmt->errorInfo()), 1);
self::finish($stmt);
self::disconnect();
return false;
}
}
return $stmt;
}

View file

@ -52,14 +52,15 @@ class Democratic extends Tmp_Playlist
*/
public function __construct($id='')
{
if (!$id) { return false; }
if (!$id) {
return false;
}
$info = $this->get_info($id);
foreach ($info as $key=>$value) {
$this->$key = $value;
}
} // constructor
/**
@ -68,7 +69,9 @@ class Democratic extends Tmp_Playlist
*/
public static function build_vote_cache($ids)
{
if (!is_array($ids) || !count($ids)) { return false; }
if (!is_array($ids) || !count($ids)) {
return false;
}
$idlist = '(' . implode(',', $ids) . ')';
@ -83,7 +86,6 @@ class Democratic extends Tmp_Playlist
}
return true;
} // build_vote_cache
/**
@ -93,10 +95,11 @@ class Democratic extends Tmp_Playlist
*/
public function is_enabled()
{
if ($this->tmp_playlist) { return true; }
if ($this->tmp_playlist) {
return true;
}
return false;
} // is_enabled
/**
@ -113,8 +116,6 @@ class Democratic extends Tmp_Playlist
$row = Dba::fetch_assoc($db_results);
$this->tmp_playlist = $row['id'];
} // set_parent
/**
@ -141,7 +142,6 @@ class Democratic extends Tmp_Playlist
Preference::update_all($play_method,'clear');
return true;
} // set_user_preferences
/**
@ -170,7 +170,6 @@ class Democratic extends Tmp_Playlist
$this->f_level = T_('Admin');
break;
}
} // format
/**
@ -190,7 +189,6 @@ class Democratic extends Tmp_Playlist
}
return $results;
} // get_playlists
/**
@ -214,7 +212,6 @@ class Democratic extends Tmp_Playlist
$object = new Democratic($democratic_id);
return $object;
} // get_current_playlist
/**
@ -259,7 +256,6 @@ class Democratic extends Tmp_Playlist
}
return $results;
} // get_items
/**
@ -271,7 +267,6 @@ class Democratic extends Tmp_Playlist
$link = Stream::get_base_url() . 'uid=' . scrub_out($GLOBALS['user']->id) . '&demo_id=' . scrub_out($this->id);
return Stream_URL::format($link);
} // play_url
/**
@ -306,7 +301,6 @@ class Democratic extends Tmp_Playlist
$results = Dba::fetch_assoc($db_results);
return $results['id'];
}
} // get_next_object
/**
@ -327,7 +321,6 @@ class Democratic extends Tmp_Playlist
$row = Dba::fetch_assoc($db_results);
return $row['id'];
} // get_uid_from_object_id
/**
@ -343,7 +336,6 @@ class Democratic extends Tmp_Playlist
$song_ids = Stats::get_object_history($GLOBALS['user']->id, $cool_time);
return $song_ids;
} // get_cool_songs
/**
@ -363,7 +355,6 @@ class Democratic extends Tmp_Playlist
$this->_add_vote($object_id, $type);
}
} // end foreach
} // vote
/**
@ -396,7 +387,6 @@ class Democratic extends Tmp_Playlist
}
return false;
} // has_vote
/**
@ -457,7 +447,6 @@ class Democratic extends Tmp_Playlist
self::prune_tracks();
return true;
} // remove_vote
/**
@ -475,7 +464,6 @@ class Democratic extends Tmp_Playlist
Dba::write($sql);
return true;
} // delete_votes
/**
@ -488,10 +476,11 @@ class Democratic extends Tmp_Playlist
if ($row_id) {
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'); }
} else {
debug_event('Democratic','Unable to find Votes for ' . $oid . ' of type ' . $object_type,'3');
}
return true;
} // delete_from_oid
/**
@ -511,7 +500,6 @@ class Democratic extends Tmp_Playlist
self::prune_tracks();
return true;
} // delete
/**
@ -531,7 +519,6 @@ class Democratic extends Tmp_Playlist
Dba::write($sql, array($name, $base, $cool, $default, $level, $id));
return true;
} // update
/**
@ -562,7 +549,6 @@ class Democratic extends Tmp_Playlist
}
return $db_results;
} // create
/**
@ -580,7 +566,6 @@ class Democratic extends Tmp_Playlist
Dba::write($sql);
return true;
} // prune_tracks
/**
@ -607,7 +592,6 @@ class Democratic extends Tmp_Playlist
self::clear_votes();
return true;
} // clear_playlist
/**
@ -622,7 +606,6 @@ class Democratic extends Tmp_Playlist
Dba::write($sql);
return true;
} // clear_votes
/**
@ -642,7 +625,6 @@ class Democratic extends Tmp_Playlist
$results = Dba::fetch_assoc($db_results);
parent::add_to_cache('democratic_vote', $id, $results['count']);
return $results['count'];
} // get_vote
/**
@ -666,6 +648,5 @@ class Democratic extends Tmp_Playlist
parent::add_to_cache('democratic_vote', $object_id, $voters);
return $voters;
} // get_voters
} // Democratic class

View file

@ -39,7 +39,6 @@ class Error
private function __construct()
{
// Rien a faire
} // __construct
/**
@ -51,7 +50,6 @@ class Error
foreach (self::$errors as $key=>$error) {
$_SESSION['errors'][$key] = $error;
}
} // __destruct
/**
@ -86,7 +84,6 @@ class Error
ob_flush();
flush();
}
} // add
/**
@ -95,10 +92,11 @@ class Error
*/
public static function occurred()
{
if (self::$state == '1') { return true; }
if (self::$state == '1') {
return true;
}
return false;
} // occurred
/**
@ -107,10 +105,11 @@ class Error
*/
public static function get($name)
{
if (!isset(Error::$errors[$name])) { return ''; }
if (!isset(Error::$errors[$name])) {
return '';
}
return Error::$errors[$name];
} // get
/**
@ -121,10 +120,11 @@ class Error
public static function display($name)
{
// Be smart about this, if no error don't print
if (!isset(Error::$errors[$name])) { return ''; }
if (!isset(Error::$errors[$name])) {
return '';
}
echo '<p class="alert alert-danger">' . T_(Error::$errors[$name]) . '</p>';
} // display
/**
@ -133,13 +133,14 @@ class Error
*/
public static function auto_init()
{
if (!is_array($_SESSION['errors'])) { return false; }
if (!is_array($_SESSION['errors'])) {
return false;
}
// Re-insert them
foreach ($_SESSION['errors'] as $key=>$error) {
self::add($key,$error);
}
} // auto_init
} // Error

View file

@ -493,11 +493,13 @@ class Graph
$blink = $libitem->f_link;
}
}
} else if ($user_id) {
} else {
if ($user_id) {
$u = new User($user_id);
$u->format();
$blink = $u->f_link;
}
}
require_once AmpConfig::get('prefix') . '/templates/show_graphs.inc.php';
}

View file

@ -85,7 +85,9 @@ class Label extends database_object implements library_item
*/
public function __construct($id=null)
{
if (!$id) { return false; }
if (!$id) {
return false;
}
$info = $this->get_info($id);
foreach ($info as $key=>$value) {
@ -201,13 +203,15 @@ class Label extends database_object implements library_item
$user = $GLOBALS['user']->id;
}
if (!$user)
if (!$user) {
return false;
}
if (AmpConfig::get('upload_allow_edit')) {
if ($this->user !== null && $user == $this->user)
if ($this->user !== null && $user == $this->user) {
return true;
}
}
return Access::check('interface', 50, $user);
}
@ -336,7 +340,6 @@ class Label extends database_object implements library_item
}
return $results;
} // get_songs
public function remove()
@ -383,7 +386,9 @@ class Label extends database_object implements library_item
*/
public static function get_display($labels, $link=false)
{
if (!is_array($labels)) { return ''; }
if (!is_array($labels)) {
return '';
}
$results = '';
@ -402,7 +407,6 @@ class Label extends database_object implements library_item
$results = rtrim($results, ', ');
return $results;
} // get_display
/**
@ -433,13 +437,15 @@ class Label extends database_object implements library_item
if ($found) {
debug_event('label.class', 'Already found. Do nothing.', '5');
unset($editedLabels[$lk]);
} else if ($overwrite) {
} else {
if ($overwrite) {
debug_event('label.class', 'Not found in the new list. Delete it.', '5');
$clabel->remove_artist_assoc($artist_id);
}
}
}
}
}
// Look if we need to add some new labels
foreach ($editedLabels as $lk => $lv) {

View file

@ -41,5 +41,5 @@ interface library_item extends playable_item
public function update(array $data);
public static function gc();
} // end interface

View file

@ -56,7 +56,6 @@ class License
$this->_get_info($id);
return true;
} // Constructor
/**
@ -77,7 +76,6 @@ class License
}
return true;
} // _get_info
/**
@ -94,7 +92,6 @@ class License
$insert_id = Dba::insert_id();
return $insert_id;
} // create
/**
@ -109,7 +106,6 @@ class License
Dba::write($sql, array($data['name'], $data['description'], $data['external_link'], $this->id));
return $this->id;
} // create
/**
@ -130,7 +126,6 @@ class License
{
$sql = "DELETE FROM `license` WHERE `id` = ?";
Dba::write($sql, array($license_id));
} // delete
/**
@ -150,5 +145,5 @@ class License
return $results;
} // get_licenses
} // License class

View file

@ -76,7 +76,9 @@ class Live_Stream extends database_object implements media, library_item
*/
public function __construct($id = null)
{
if (!$id) { return false; }
if (!$id) {
return false;
}
$info = $this->get_info($id, 'live_stream');
@ -84,7 +86,6 @@ class Live_Stream extends database_object implements media, library_item
foreach ($info as $key=>$value) {
$this->$key = $value;
}
} // constructor
/**
@ -100,7 +101,6 @@ class Live_Stream extends database_object implements media, library_item
$this->f_url_link = "<a target=\"_blank\" href=\"" . $this->url . "\">" . $this->url . "</a>";
return true;
} // format
public function get_keywords()
@ -201,7 +201,6 @@ class Live_Stream extends database_object implements media, library_item
Dba::write($sql, array($data['name'], $data['site_url'], $data['url'], $data['codec'], $this->id));
return $this->id;
} // update
/**
@ -230,7 +229,9 @@ class Live_Stream extends database_object implements media, library_item
Error::add('catalog', T_('Invalid Catalog'));
}
if (Error::occurred()) { return false; }
if (Error::occurred()) {
return false;
}
// If we've made it this far everything must be ok... I hope
$sql = "INSERT INTO `live_stream` (`name`,`site_url`,`url`,`catalog`,`codec`) " .
@ -238,7 +239,6 @@ class Live_Stream extends database_object implements media, library_item
$db_results = Dba::write($sql, array($data['name'], $data['site_url'], $data['url'], $catalog->id, $data['codec']));
return $db_results;
} // create
/**
@ -251,7 +251,6 @@ class Live_Stream extends database_object implements media, library_item
Dba::write($sql, array($this->id));
return true;
} // delete
/**
@ -272,7 +271,6 @@ class Live_Stream extends database_object implements media, library_item
$radio = new Live_Stream($oid);
return $radio->url . $additional_params;
} // play_url
public function get_stream_name()
@ -316,12 +314,11 @@ class Live_Stream extends database_object implements media, library_item
public static function gc()
{
}
public function set_played($user, $agent, $location)
{
// Do nothing
}
} //end of radio class

View file

@ -43,7 +43,6 @@ class Localplay
$this->type = $type;
$this->_get_info();
} // Localplay
/**
@ -56,7 +55,6 @@ class Localplay
private function _get_info()
{
$this->_load_player();
} // _get_info
/**
@ -71,7 +69,6 @@ class Localplay
} else {
return false;
}
} // player_loaded
/**
@ -81,13 +78,13 @@ class Localplay
*/
public function format()
{
if (!is_object($this->_player)) { return false; }
if (!is_object($this->_player)) {
return false;
}
$this->f_name = ucfirst($this->type);
$this->f_description = $this->_player->get_description();
$this->f_version = $this->_player->get_version();
} // format
/**
@ -98,7 +95,9 @@ class Localplay
*/
private function _load_player()
{
if (!$this->type) { return false; }
if (!$this->type) {
return false;
}
$filename = AmpConfig::get('prefix') . '/modules/localplay/' . $this->type . '.controller.php';
$include = require_once $filename;
@ -117,7 +116,6 @@ class Localplay
return false;
}
}
} // _load_player
/**
@ -131,7 +129,6 @@ class Localplay
$name = scrub_out($name);
$name = Ajax::text('?page=localplay&action=command&command=skip&id=' . $id,$name,'localplay_skip_' . $id);
return $name;
} // format_name
/**
@ -151,8 +148,9 @@ class Localplay
$results = array();
while (false !== ($file = readdir($handle))) {
if (substr($file,-14,14) != 'controller.php') { continue; }
if (substr($file,-14,14) != 'controller.php') {
continue;
}
/* Make sure it isn't a dir */
if (!is_dir($file)) {
@ -163,7 +161,6 @@ class Localplay
} // end while
return $results;
} // get_controllers
/**
@ -176,10 +173,11 @@ class Localplay
// Load the controller and then check for its preferences
$localplay = new Localplay($controller);
// If we can't even load it no sense in going on
if (!isset($localplay->_player)) { return false; }
if (!isset($localplay->_player)) {
return false;
}
return $localplay->_player->is_installed();
} // is_enabled
/**
@ -193,7 +191,6 @@ class Localplay
$installed = $this->_player->install();
return $installed;
} // install
/**
@ -212,7 +209,6 @@ class Localplay
}
return true;
} // uninstall
/**
@ -228,7 +224,6 @@ class Localplay
}
return true;
} // connect
/**
@ -244,7 +239,6 @@ class Localplay
}
return true;
} // play
/**
@ -260,7 +254,6 @@ class Localplay
}
return true;
} // stop
/**
@ -270,7 +263,6 @@ class Localplay
{
debug_event('localplay', 'Deprecated add method called: ' . json_encode($object), 5);
return false;
} // add
/**
@ -285,7 +277,6 @@ class Localplay
}
return true;
} // add_url
/**
@ -302,7 +293,6 @@ class Localplay
}
return $data;
} // repeat
/**
@ -319,7 +309,6 @@ class Localplay
}
return $data;
} // random
/**
@ -337,7 +326,6 @@ class Localplay
}
return $data;
} // status
/**
@ -356,7 +344,6 @@ class Localplay
}
return $data;
} // get
/**
@ -371,7 +358,9 @@ class Localplay
$value = int($value);
/* Make sure that it's between 0 and 100 */
if ($value > 100 OR $value < 0) { return false; }
if ($value > 100 OR $value < 0) {
return false;
}
if (!$this->_player->volume($value)) {
debug_event('localplay','Error: Unable to set volume, check ' . $this->type . ' controller','1');
@ -379,7 +368,6 @@ class Localplay
}
return true;
} // volume_set
/**
@ -395,7 +383,6 @@ class Localplay
}
return true;
} // volume_up
/**
@ -411,7 +398,6 @@ class Localplay
}
return true;
} // volume_down
/**
@ -427,7 +413,6 @@ class Localplay
}
return true;
} // volume_mute
/**
@ -442,7 +427,6 @@ class Localplay
}
return true;
} // skip
/**
@ -458,7 +442,6 @@ class Localplay
}
return true;
} // next
/**
@ -474,7 +457,6 @@ class Localplay
}
return true;
} // prev
/**
@ -490,7 +472,6 @@ class Localplay
}
return true;
} // pause
/**
@ -502,7 +483,6 @@ class Localplay
$instances = $this->_player->get_instances();
return $instances;
} // get_instances
/**
@ -514,7 +494,6 @@ class Localplay
$data = $this->_player->get_instance();
return $data['id'];
} // current_instance
/**
@ -526,7 +505,6 @@ class Localplay
$data = $this->_player->get_instance($uid);
return $data;
} // get_instance
/**
@ -538,7 +516,6 @@ class Localplay
$data = $this->_player->update_instance($uid,$data);
return $data;
} // update_instance
/**
@ -548,7 +525,6 @@ class Localplay
public function add_instance($data)
{
$this->_player->add_instance($data);
} // add_instance
/**
@ -558,7 +534,6 @@ class Localplay
public function delete_instance($instance_uid)
{
$this->_player->delete_instance($instance_uid);
} // delete_instance
/**
@ -568,7 +543,6 @@ class Localplay
public function set_active_instance($instance)
{
$this->_player->set_active_instance($instance);
} // set_active_instance
/**
@ -585,7 +559,6 @@ class Localplay
return true;
} // delete
/**
@ -601,7 +574,6 @@ class Localplay
}
return true;
} // delete_all
/**
@ -614,7 +586,6 @@ class Localplay
$fields = $this->_player->instance_fields();
return $fields;
} // get_instance_fields
/**
@ -634,7 +605,6 @@ class Localplay
default:
return T_('Unknown');
} // switch on state
} // get_user_state
/**
@ -657,8 +627,6 @@ class Localplay
$track_name = "[" . $status['track'] . "] - " . $track_name;
return $track_name;
} // get_user_playing
} // end localplay class

View file

@ -68,7 +68,6 @@ abstract class localplay_controller
$url = call_user_func(array($class,'play_url'),$object->id);
return $url;
} // get_url
/**
@ -102,12 +101,10 @@ abstract class localplay_controller
$data['primary_key'] = $pkey;
return $data;
}
} // end foreach
}
return $data;
} // parse_url
} // end localplay_controller interface

View file

@ -44,7 +44,6 @@ class Mailer
public function __construct()
{
// Eh bien.
} // Constructor
/**
@ -117,7 +116,6 @@ class Mailer
}
return $results;
} // get_users
/**
@ -209,5 +207,5 @@ class Mailer
return $this->send($mail);
}
} // Mailer class

View file

@ -61,5 +61,5 @@ interface media
public function get_stream_name();
public function set_played($user, $agent, $location);
} // end interface

View file

@ -35,7 +35,6 @@ class memory_object
$this->_data[$key] = $value;
}
}
}
public function __set($name, $value)

View file

@ -45,7 +45,6 @@ class Movie extends Video
}
return true;
} // Constructor
/**
@ -75,7 +74,6 @@ class Movie extends Video
Dba::write($sql, array($data['id'], $name, $prefix, $data['summary'], $data['year']));
return $data['id'];
} // create
/**
@ -106,7 +104,6 @@ class Movie extends Video
$this->year = $year;
return $this->id;
} // update
/**
@ -124,7 +121,6 @@ class Movie extends Video
$this->f_link = '<a href="' . $this->link . '">' . $this->f_title . '</a>';
return true;
} //format
/**
@ -160,5 +156,5 @@ class Movie extends Video
return $deleted;
}
} // Movie class

View file

@ -93,5 +93,5 @@ class Openid
return $policies;
}
} // end of Openid class

View file

@ -43,7 +43,6 @@ class Personal_Video extends Video
}
return true;
} // Constructor
/**
@ -69,7 +68,6 @@ class Personal_Video extends Video
Dba::write($sql, array($data['id'], $data['location'], $data['summary']));
return $data['id'];
} // create
/**
@ -84,7 +82,6 @@ class Personal_Video extends Video
Dba::write($sql, array($data['location'], $data['summary'], $this->id));
return $this->id;
} // update
/**
@ -99,7 +96,6 @@ class Personal_Video extends Video
$this->f_location = $this->location;
return true;
} //format
/**
@ -115,5 +111,5 @@ class Personal_Video extends Video
return $deleted;
}
} // Personal_Video class

View file

@ -77,5 +77,5 @@ interface playable_item
* @return int[]
*/
public function get_catalogs();
} // end interface

View file

@ -51,7 +51,6 @@ class Playlist extends playlist_object
foreach ($info as $key=>$value) {
$this->$key = $value;
}
} // Playlist
/**
@ -73,7 +72,9 @@ class Playlist extends playlist_object
*/
public static function build_cache($ids)
{
if (!count($ids)) { return false; }
if (!count($ids)) {
return false;
}
$idlist = '(' . implode(',',$ids) . ')';
@ -83,7 +84,6 @@ class Playlist extends playlist_object
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('playlist',$row['id'],$row);
}
} // build_cache
/**
@ -122,7 +122,6 @@ class Playlist extends playlist_object
parent::format($details);
$this->link = AmpConfig::get('web_path') . '/playlist.php?action=show_playlist&playlist_id=' . $this->id;
$this->f_link = '<a href="' . $this->link . '">' . $this->f_name . '</a>';
} // format
/**
@ -138,7 +137,6 @@ class Playlist extends playlist_object
$row = Dba::fetch_assoc($db_results);
return $row;
} // get_track
/**
@ -164,7 +162,6 @@ class Playlist extends playlist_object
} // end while
return $results;
} // get_items
/**
@ -182,7 +179,6 @@ class Playlist extends playlist_object
$db_results = Dba::read($sql, array($this->id));
while ($row = Dba::fetch_assoc($db_results)) {
$results[] = array(
'object_type' => $row['object_type'],
'object_id' => $row['object_id']
@ -190,7 +186,6 @@ class Playlist extends playlist_object
} // end while
return $results;
} // get_random_items
/**
@ -210,7 +205,6 @@ class Playlist extends playlist_object
} // end while
return $results;
} // get_songs
/**
@ -226,7 +220,6 @@ class Playlist extends playlist_object
$results = Dba::fetch_row($db_results);
return $results['0'];
} // get_song_count
/**
@ -244,7 +237,6 @@ class Playlist extends playlist_object
$results = Dba::fetch_row($db_results);
return $results['0'];
} // get_total_duration
/**
@ -264,7 +256,6 @@ class Playlist extends playlist_object
}
return $results;
} // get_users
/**
@ -292,7 +283,6 @@ class Playlist extends playlist_object
if ($this->_update_item('type',$new_type,50)) {
$this->type = $new_type;
}
} // update_type
/**
@ -304,7 +294,6 @@ class Playlist extends playlist_object
if ($this->_update_item('name',$new_name,50)) {
$this->name = $new_name;
}
} // update_name
/**
@ -321,7 +310,6 @@ class Playlist extends playlist_object
$db_results = Dba::write($sql, array($value, $this->id));
return $db_results;
} // update_item
/**
@ -332,7 +320,6 @@ class Playlist extends playlist_object
{
$sql = "UPDATE `playlist_data` SET `track` = ? WHERE `id` = ?";
Dba::write($sql, array($index, $track_id));
} // update_track_number
/**
@ -362,7 +349,6 @@ class Playlist extends playlist_object
);
}
$this->add_medias($medias, $ordered);
} // add_songs
public function add_medias($medias, $ordered=false)
@ -395,7 +381,6 @@ class Playlist extends playlist_object
" VALUES (?, ?, ?, ?)";
Dba::write($sql, array($this->id, $data['object_id'], $data['object_type'], $track));
} // if valid id
} // end foreach medias
}
@ -417,7 +402,6 @@ class Playlist extends playlist_object
$insert_id = Dba::insert_id();
return $insert_id;
} // create
/**
@ -427,7 +411,6 @@ class Playlist extends playlist_object
public function set_items()
{
$this->items = $this->get_items();
} // set_items
/**
@ -440,7 +423,6 @@ class Playlist extends playlist_object
Dba::write($sql, array($this->id, $id));
return true;
} // delete_track
/**
@ -453,7 +435,6 @@ class Playlist extends playlist_object
Dba::write($sql, array($this->id, $track));
return true;
} // delete_track_number
/**
@ -472,7 +453,6 @@ class Playlist extends playlist_object
Dba::write($sql, array($this->id));
return true;
} // delete
/**
@ -511,7 +491,6 @@ class Playlist extends playlist_object
} // foreach re-ordered results
return true;
} // sort_tracks
} // class Playlist

View file

@ -74,7 +74,6 @@ abstract class playlist_object extends database_object implements library_item
$client->format();
$this->f_user = $client->f_name;
}
} // format
/**
@ -92,7 +91,6 @@ abstract class playlist_object extends database_object implements library_item
} else {
return Access::check('interface', 75);
}
} // has_access
public function get_medias($filter_type = null)
@ -174,5 +172,5 @@ abstract class playlist_object extends database_object implements library_item
{
return array();
}
} // end playlist_object

View file

@ -319,7 +319,8 @@ class Plex_Api
);
$action = 'users/sign_in.xml';
$res = self::myPlexRequest($action, $options, $headers);;
$res = self::myPlexRequest($action, $options, $headers);
;
return $res['xml']['authenticationToken'];
}
@ -558,7 +559,6 @@ class Plex_Api
{
if (count($params) == 2) {
if ($params[0] == ':' && $params[1] == 'transcode') {
$width = $_REQUEST['width'];
$height = $_REQUEST['height'];
$url = $_REQUEST['url'];
@ -698,15 +698,18 @@ class Plex_Api
$videoResolution = $_GET['videoResolution'];
$maxVideoBitrate = $_GET['maxVideoBitrate'];
if (!$maxVideoBitrate)
if (!$maxVideoBitrate) {
$maxVideoBitrate = 8175;
}
echo "#EXTM3U\n";
echo "#EXT-X-STREAM-INF:PROGRAM-ID=1";
if ($maxVideoBitrate)
if ($maxVideoBitrate) {
echo ",BANDWIDTH=" . ($maxVideoBitrate * 1000);
if ($videoResolution)
}
if ($videoResolution) {
echo ",RESOLUTION=" . $videoResolution;
}
echo "\n";
echo "hls.m3u8?" . substr($_SERVER['QUERY_STRING'], strpos($_SERVER['QUERY_STRING'], '&') + 1);
} elseif ($protocol == "http") {
@ -949,7 +952,6 @@ class Plex_Api
}
Plex_XML_Data::addPlaylist($r, $litem);
}
} else {
$subact = $params[1];
if ($subact == "children") {
@ -957,19 +959,25 @@ class Plex_Api
$litem = new Artist($id);
$litem->format();
Plex_XML_Data::setArtistRoot($r, $litem);
} else if (Plex_XML_Data::isAlbum($key)) {
} else {
if (Plex_XML_Data::isAlbum($key)) {
$litem = new Album($id);
$litem->format();
Plex_XML_Data::setAlbumRoot($r, $litem);
} else if (Plex_XML_Data::isTVShow($key)) {
} else {
if (Plex_XML_Data::isTVShow($key)) {
$litem = new TVShow($id);
$litem->format();
Plex_XML_Data::setTVShowRoot($r, $litem);
} else if (Plex_XML_Data::isTVShowSeason($key)) {
} else {
if (Plex_XML_Data::isTVShowSeason($key)) {
$litem = new TVShow_Season($id);
$litem->format();
Plex_XML_Data::setTVShowSeasonRoot($r, $litem);
}
}
}
}
} elseif ($subact == "thumbs" || $subact == "posters" || $subact == "arts" || $subact == 'backgrounds') {
$kind = Plex_XML_Data::getPhotoKind($subact);
if ($createMode) {
@ -1000,17 +1008,27 @@ class Plex_Api
$art = null;
if (Plex_XML_Data::isArtist($key)) {
$art = new Art($id, "artist", $kind);
} else if (Plex_XML_Data::isAlbum($key)) {
} else {
if (Plex_XML_Data::isAlbum($key)) {
$art = new Art($id, "album", $kind);
} else if (Plex_XML_Data::isTrack($key)) {
} else {
if (Plex_XML_Data::isTrack($key)) {
$art = new Art($id, "song", $kind);
} else if (Plex_XML_Data::isTVShow($key)) {
} else {
if (Plex_XML_Data::isTVShow($key)) {
$art = new Art($id, "tvshow", $kind);
} else if (Plex_XML_Data::isTVShowSeason($key)) {
} else {
if (Plex_XML_Data::isTVShowSeason($key)) {
$art = new Art($id, "tvshow_season", $kind);
} else if (Plex_XML_Data::isVideo($key)) {
} else {
if (Plex_XML_Data::isVideo($key)) {
$art = new Art($id, "video", $kind);
}
}
}
}
}
}
if ($art != null) {
$art->get_db();
@ -1245,7 +1263,9 @@ class Plex_Api
$userid = $params[0];
}
// Not supported yet
if ($userid > 1) { self::createError(404); }
if ($userid > 1) {
self::createError(404);
}
$r = Plex_XML_Data::createAccountContainer();
Plex_XML_Data::setAccounts($r, $userid);
@ -1373,7 +1393,9 @@ class Plex_Api
if ($res['status'] == '201') {
Plex_XML_Data::setMyPlexSubscription($res['xml']);
self::apiOutput($res['xml']->asXML());
} else { self::createError($res['status']); }
} else {
self::createError($res['status']);
}
}
}

View file

@ -1738,11 +1738,12 @@ class Plex_XML_Data
protected static function getPathDelimiter()
{
if (strpos(PHP_OS, 'WIN') === 0)
if (strpos(PHP_OS, 'WIN') === 0) {
return '\\';
else
} else {
return '/';
}
}
public static function setBrowseService(SimpleXMLElement $xml, $path)
{

View file

@ -41,7 +41,6 @@ class Plugin
}
return true;
} // Constructor
@ -64,7 +63,6 @@ class Plugin
}
return true;
} // _get_info
/**
@ -75,8 +73,9 @@ class Plugin
{
// make static cache for optimization when multiple call
static $plugins_list = array();
if (isset($plugins_list[$type]))
if (isset($plugins_list[$type])) {
return $plugins_list[$type];
}
$plugins_list[$type] = array();
@ -90,8 +89,12 @@ class Plugin
// Recurse the directory
while (false !== ($file = readdir($handle))) {
// Ignore non-plugin files
if (substr($file,-10,10) != 'plugin.php') { continue; }
if (is_dir($file)) { continue; }
if (substr($file,-10,10) != 'plugin.php') {
continue;
}
if (is_dir($file)) {
continue;
}
$plugin_name = basename($file,'.plugin.php');
if ($type != '') {
$plugin = new Plugin($plugin_name);
@ -116,7 +119,6 @@ class Plugin
ksort($plugins_list[$type]);
return $plugins_list[$type];
} // get_plugins
/**
@ -166,7 +168,6 @@ class Plugin
// We've passed all of the tests
return true;
} // is_valid
/**
@ -178,7 +179,6 @@ class Plugin
{
/* All we do is check the version */
return self::get_plugin_version($plugin_name);
} // is_installed
/**
@ -206,7 +206,6 @@ class Plugin
$this->_plugin->uninstall();
$this->remove_plugin_version();
} // uninstall
/**
@ -249,7 +248,6 @@ class Plugin
}
return false;
} // get_plugin_version
/**
@ -264,7 +262,6 @@ class Plugin
$results = Dba::fetch_assoc($db_results);
return $results['value'];
} // get_ampache_db_version
/**
@ -280,7 +277,6 @@ class Plugin
Dba::write($sql);
return true;
} // set_plugin_version
/**
@ -295,7 +291,6 @@ class Plugin
Dba::write($sql);
return true;
} // remove_plugin_version
} //end plugin class

View file

@ -293,14 +293,16 @@ class Preference extends database_object
$params = array($id, $default);
$sql = "INSERT INTO `user_preference` VALUES (-1,?,?)";
$db_results = Dba::write($sql, $params);
if (!$db_results)
if (!$db_results) {
return false;
}
if ($catagory !== "system") {
$sql = "INSERT INTO `user_preference` SELECT `user`.`id`, ?, ? FROM `user`";
$db_results = Dba::write($sql, $params);
if (!$db_results)
if (!$db_results) {
return false;
}
}
return true;
} // insert
@ -477,3 +479,4 @@ class Preference extends database_object
$_SESSION['userdata']['uid'] = $user_id;
} // init
} // end Preference class

View file

@ -93,7 +93,9 @@ class PrivateMsg extends database_object
*/
public function __construct($id=null)
{
if (!$id) { return false; }
if (!$id) {
return false;
}
$info = $this->get_info($id, 'user_pvmsg');
foreach ($info as $key=>$value) {

View file

@ -89,7 +89,6 @@ class Query
$db_results = Dba::read($sql, array($id, $sid));
if ($results = Dba::fetch_assoc($db_results)) {
$this->id = $id;
$this->_state = (array) self::_unserialize($results['data']);
@ -485,14 +484,24 @@ class Query
case 'regex_match':
case 'regex_not_match':
case 'starts_with':
if ($this->is_static_content()) { return false; }
if ($this->is_static_content()) {
return false;
}
$this->_state['filter'][$key] = $value;
if ($key == 'regex_match') unset($this->_state['filter']['regex_not_match']);
if ($key == 'regex_not_match') unset($this->_state['filter']['regex_match']);
if ($key == 'regex_match') {
unset($this->_state['filter']['regex_not_match']);
}
if ($key == 'regex_not_match') {
unset($this->_state['filter']['regex_match']);
}
break;
case 'playlist_type':
// Must be a content manager to turn this off
if (Access::check('interface','100')) { unset($this->_state['filter'][$key]); } else { $this->_state['filter'][$key] = '1'; }
if (Access::check('interface','100')) {
unset($this->_state['filter'][$key]);
} else {
$this->_state['filter'][$key] = '1';
}
break;
default:
// Rien a faire
@ -504,7 +513,6 @@ class Query
$this->set_start(0);
return true;
} // set_filter
/**
@ -524,7 +532,6 @@ class Query
$this->set_is_simple(false);
$this->set_start(0);
$this->set_offset(AmpConfig::get('offset_limit') ? AmpConfig::get('offset_limit') : '25');
} // reset
/**
@ -534,7 +541,6 @@ class Query
public function reset_base()
{
$this->_state['base'] = NULL;
} // reset_base
/**
@ -544,7 +550,6 @@ class Query
public function reset_select()
{
$this->_state['select'] = array();
} // reset_select
/**
@ -554,7 +559,6 @@ class Query
public function reset_having()
{
unset($this->_state['having']);
} // reset_having
/**
@ -564,7 +568,6 @@ class Query
public function reset_join()
{
unset($this->_state['join']);
} // reset_join
/**
@ -574,7 +577,6 @@ class Query
public function reset_filters()
{
$this->_state['filter'] = array();
} // reset_filters
/**
@ -584,7 +586,6 @@ class Query
public function reset_total()
{
unset($this->_state['total']);
} // reset_total
/**
@ -599,7 +600,6 @@ class Query
return isset($this->_state['filter'][$key])
? $this->_state['filter'][$key]
: false;
} // get_filter
/**
@ -610,7 +610,6 @@ class Query
public function get_start()
{
return $this->_state['start'];
} // get_start
/**
@ -659,7 +658,6 @@ class Query
$this->_state['total'] = $num_rows;
return $num_rows;
} // get_total
/**
@ -735,7 +733,6 @@ class Query
public function get_type()
{
return $this->_state['type'];
} // get_type
/**
@ -768,7 +765,6 @@ class Query
}
$this->resort_objects();
} // set_sort
/**
@ -779,7 +775,6 @@ class Query
public function set_offset($offset)
{
$this->_state['offset'] = abs($offset);
} // set_offset
/**
@ -802,7 +797,6 @@ class Query
public function set_select($field)
{
$this->_state['select'][] = $field;
} // set_select
/**
@ -817,7 +811,6 @@ class Query
public function set_join($type, $table, $source, $dest, $priority)
{
$this->_state['join'][$priority][$table] = strtoupper($type) . ' JOIN ' . $table . ' ON ' . $source . '=' . $dest;
} // set_join
/**
@ -829,7 +822,6 @@ class Query
public function set_having($condition)
{
$this->_state['having'] = $condition;
} // set_having
/**
@ -855,7 +847,6 @@ class Query
{
$value = make_bool($value);
$this->_state['simple'] = $value;
} // set_is_simple
/**
@ -870,7 +861,6 @@ class Query
$value = make_bool($value);
$this->_state['static'] = $value;
} // set_static_content
/**
@ -890,7 +880,6 @@ class Query
public function is_simple()
{
return $this->_state['simple'];
} // is_simple
/**
@ -920,7 +909,6 @@ class Query
}
return $objects;
} // get_saved
/**
@ -955,7 +943,6 @@ class Query
$this->save_objects($filtered);
return $filtered;
} // get_objects
/**
@ -967,7 +954,9 @@ class Query
private function set_base_sql($force = false, $custom_base = '')
{
// Only allow it to be set once
if (strlen($this->_state['base']) && !$force) { return true; }
if (strlen($this->_state['base']) && !$force) {
return true;
}
// Custom sql base
if ($force && !empty($custom_base)) {
@ -1094,7 +1083,6 @@ class Query
{
$select_string = implode(", ", $this->_state['select']);
return $select_string;
} // get_select
/**
@ -1107,7 +1095,6 @@ class Query
{
$sql = str_replace("%%SELECT%%", $this->get_select(), $this->_state['base']);
return $sql;
} // get_base_sql
/**
@ -1125,7 +1112,6 @@ class Query
foreach ($this->_state['filter']
as $key => $value) {
$sql .= $this->sql_filter($key, $value);
}
@ -1149,7 +1135,6 @@ class Query
$sql = rtrim($sql,'AND ') . ' ';
return $sql;
} // get_filter_sql
/**
@ -1174,7 +1159,6 @@ class Query
$sql = rtrim($sql,',');
return $sql;
} // get_sort_sql
/**
@ -1184,12 +1168,13 @@ class Query
*/
private function get_limit_sql()
{
if (!$this->is_simple() || $this->get_start() < 0) { return ''; }
if (!$this->is_simple() || $this->get_start() < 0) {
return '';
}
$sql = ' LIMIT ' . intval($this->get_start()) . ',' . intval($this->get_offset());
return $sql;
} // get_limit_sql
/**
@ -1212,7 +1197,6 @@ class Query
} // end foreach of this level of joins
return $sql;
} // get_join_sql
/**
@ -1225,7 +1209,6 @@ class Query
$sql = isset($this->_state['having']) ? $this->_state['having'] : '';
return $sql;
} // get_having_sql
/**
@ -1259,7 +1242,6 @@ class Query
$final_sql .= $order_sql . $limit_sql;
return $final_sql;
} // get_sql
/**
@ -1293,7 +1275,6 @@ class Query
} // end foreach
return $results;
} // post_process
/**
@ -1328,10 +1309,14 @@ class Query
$filter_sql = " `song`.`title` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `song`.`title` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `song`.`title` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `song`.`title` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `song`.`title` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'starts_with':
$filter_sql = " `song`.`title` LIKE '" . Dba::escape($value) . "%' AND ";
@ -1392,10 +1377,14 @@ class Query
$filter_sql = " `album`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `album`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `album`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `album`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `album`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'starts_with':
$this->set_join('left', '`song`', '`album`.`id`', '`song`.`album`', 100);
@ -1465,10 +1454,14 @@ class Query
$filter_sql = " `artist`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `artist`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `artist`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `artist`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `artist`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'starts_with':
$this->set_join('left', '`song`', '`artist`.`id`', '`song`.`artist`', 100);
@ -1509,10 +1502,14 @@ class Query
$filter_sql = " `live_stream`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `live_stream`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `live_stream`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `live_stream`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `live_stream`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'starts_with':
$filter_sql = " `live_stream`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
@ -1532,10 +1529,14 @@ class Query
$filter_sql = " `playlist`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `playlist`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `playlist`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `playlist`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `playlist`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'starts_with':
$filter_sql = " `playlist`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
@ -1555,10 +1556,14 @@ class Query
$filter_sql = " `search`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `search`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `search`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `search`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `search`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'starts_with':
$filter_sql = " `search`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
@ -1575,10 +1580,14 @@ class Query
$filter_sql = " `tag`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `tag`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `tag`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `tag`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `tag`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'exact_match':
$filter_sql = " `tag`.`name` = '" . Dba::escape($value) . "' AND ";
@ -1606,10 +1615,14 @@ class Query
$filter_sql = " `video`.`title` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `video`.`title` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `video`.`title` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `video`.`title` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `video`.`title` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'starts_with':
$filter_sql = " `video`.`title` LIKE '" . Dba::escape($value) . "%' AND ";
@ -1625,10 +1638,14 @@ class Query
$filter_sql = " `license`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `license`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `license`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `license`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `license`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'exact_match':
$filter_sql = " `license`.`name` = '" . Dba::escape($value) . "' AND ";
@ -1644,10 +1661,14 @@ class Query
$filter_sql = " `tvshow`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `tvshow`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `tvshow`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `tvshow`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `tvshow`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'exact_match':
$filter_sql = " `tvshow`.`name` = '" . Dba::escape($value) . "' AND ";
@ -1695,10 +1716,14 @@ class Query
$filter_sql = " `label`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `label`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `label`.`name` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `label`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `label`.`name` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'starts_with':
$filter_sql = " `label`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
@ -1714,10 +1739,14 @@ class Query
$filter_sql = " `user_pvmsg`.`subject` LIKE '%" . Dba::escape($value) . "%' AND ";
break;
case 'regex_match':
if (!empty($value)) $filter_sql = " `user_pvmsg`.`subject` REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `user_pvmsg`.`subject` REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'regex_not_match':
if (!empty($value)) $filter_sql = " `user_pvmsg`.`subject` NOT REGEXP '" . Dba::escape($value) . "' AND ";
if (!empty($value)) {
$filter_sql = " `user_pvmsg`.`subject` NOT REGEXP '" . Dba::escape($value) . "' AND ";
}
break;
case 'starts_with':
$filter_sql = " `user_pvmsg`.`subject` LIKE '" . Dba::escape($value) . "%' AND ";
@ -1749,7 +1778,6 @@ class Query
} // end switch on type
return $filter_sql;
} // sql_filter
/**
@ -1766,7 +1794,6 @@ class Query
private function logic_filter($object_id)
{
return true;
} // logic_filter
/**
@ -1781,7 +1808,9 @@ class Query
*/
private function sql_sort($field, $order)
{
if ($order != 'DESC') { $order == 'ASC'; }
if ($order != 'DESC') {
$order == 'ASC';
}
// Depending on the type of browsing we are doing we can apply
// different filters that apply to different fields
@ -2123,10 +2152,11 @@ class Query
break;
} // end switch
if (isset($sql) && !empty($sql)) { return "$sql $order,"; }
if (isset($sql) && !empty($sql)) {
return "$sql $order,";
}
return "";
} // sql_sort
/**
@ -2223,7 +2253,6 @@ class Query
$this->save_objects($results);
return true;
} // resort_objects
/**
@ -2269,7 +2298,6 @@ class Query
}
return true;
} // save_objects
/**
@ -2280,7 +2308,6 @@ class Query
public function get_state()
{
return $this->_state;
} // get_state
/**
@ -2304,5 +2331,5 @@ class Query
{
$this->_state['ak'] = $ak;
}
} // query

View file

@ -47,7 +47,6 @@ class Random
$results = Dba::fetch_assoc($db_results);
return $results['id'];
} // artist
/**
@ -65,7 +64,6 @@ class Random
$results = Dba::fetch_assoc($db_results);
return $results['id'];
} // playlist
/**
@ -83,7 +81,6 @@ class Random
$song_id = array_pop($song_ids);
return $song_id;
} // get_single_song
/**
@ -112,7 +109,6 @@ class Random
}
return $results;
} // get_default
/**
@ -146,7 +142,6 @@ class Random
}
return $results;
} // get_album
/**
@ -179,7 +174,6 @@ class Random
}
return $results;
} // get_artist
/**
@ -196,7 +190,11 @@ class Random
/* If they've passed -1 as limit then get everything */
$limit_sql = "";
if ($data['random'] == "-1") { unset($data['random']); } else { $limit_sql = "LIMIT " . Dba::escape($limit); }
if ($data['random'] == "-1") {
unset($data['random']);
} else {
$limit_sql = "LIMIT " . Dba::escape($limit);
}
$search_data = Search::clean_request($data);
@ -304,7 +302,8 @@ class Random
// If we are within 4mb of target then jump ship
if (($data['size_limit'] - floor($size_total)) < 4) {
break; }
break;
}
} // if size_limit
// If length really does matter
@ -313,7 +312,8 @@ class Random
$new_time = floor($row['time'] / 60);
if ($fuzzy_time > 100) {
break;;
break;
;
}
// If the new one would go over skip!
@ -334,7 +334,6 @@ class Random
if (!$data['size_limit'] && !$data['length']) {
$results[] = $row['id'];
}
} // end while results
switch ($type) {
@ -358,5 +357,5 @@ class Random
return false;
}
} // advanced
} //end of random class

View file

@ -43,7 +43,6 @@ class Rating extends database_object
$this->type = $type;
return true;
} // Constructor
/**
@ -76,7 +75,9 @@ class Rating extends database_object
*/
public static function build_cache($type, $ids)
{
if (!is_array($ids) OR !count($ids)) { return false; }
if (!is_array($ids) OR !count($ids)) {
return false;
}
$ratings = array();
$user_ratings = array();
@ -119,7 +120,6 @@ class Rating extends database_object
}
return true;
} // build_cache
/**
@ -150,7 +150,6 @@ class Rating extends database_object
parent::add_to_cache($key, $this->id, $rating);
return $rating;
} // get_user_rating
/**
@ -172,7 +171,6 @@ class Rating extends database_object
parent::add_to_cache('rating_' . $this->type . '_all', $this->id, $results['rating']);
return $results['rating'];
} // get_average_rating
/**
@ -219,7 +217,6 @@ class Rating extends database_object
}
return $results;
}
/**
@ -261,7 +258,6 @@ class Rating extends database_object
}
return true;
} // set_rating
/**
@ -272,7 +268,9 @@ class Rating extends database_object
public static function show($object_id, $type, $static=false)
{
// If ratings aren't enabled don't do anything
if (!AmpConfig::get('ratings')) { return false; }
if (!AmpConfig::get('ratings')) {
return false;
}
$rating = new Rating($object_id, $type);
@ -281,7 +279,6 @@ class Rating extends database_object
} else {
require AmpConfig::get('prefix') . '/templates/show_object_rating.inc.php';
}
} // show
} //end rating class

View file

@ -358,5 +358,5 @@ class Recommendation
return $results;
} // get_artist_info
} // end of recommendation class

View file

@ -35,7 +35,6 @@ class Registration
public function __construct()
{
// Rien a faire
} // constructor
/**
@ -89,7 +88,6 @@ Website: %s
}
return true;
} // send_confirmation
/**
@ -121,18 +119,21 @@ Website: %s
{
$filename = AmpConfig::get('prefix') . '/config/registration_agreement.php';
if (!file_exists($filename)) { return false; }
if (!file_exists($filename)) {
return false;
}
/* Check for existance */
$fp = fopen($filename,'r');
if (!$fp) { return false; }
if (!$fp) {
return false;
}
$data = fread($fp,filesize($filename));
/* Scrub and show */
echo $data;
} // show_agreement
} // end registration class

View file

@ -47,8 +47,9 @@ class scrobbler
$this->submit_port = $port;
$this->submit_url = $url;
$this->queued_tracks = array();
if ($scrobble_host) { $this->scrobble_host = $scrobble_host; }
if ($scrobble_host) {
$this->scrobble_host = $scrobble_host;
}
} // scrobbler
/**
@ -57,7 +58,6 @@ class scrobbler
public function get_error_msg()
{
return $this->error_msg;
} // get_error_msg
/**
@ -66,7 +66,6 @@ class scrobbler
public function get_queue_count()
{
return count($this->queued_tracks);
} // get_queue_count
/**
@ -141,7 +140,6 @@ class scrobbler
// Remove any extra junk around the challenge
$data['challenge'] = trim($response[1]);
return $data;
} // handshake
/**
@ -167,7 +165,6 @@ class scrobbler
$this->queued_tracks[$timestamp] = $newtrack;
return true;
} // queue_track
/**
@ -264,7 +261,6 @@ class scrobbler
}
return true;
} // submit_tracks
} // end audioscrobbler class

View file

@ -547,7 +547,6 @@ class Search extends playlist_object
);
break;
} // end switch on searchtype
} // end constructor
/**
@ -649,7 +648,9 @@ class Search extends playlist_object
$limit_sql = "";
if ($limit > 0) {
$limit_sql = ' LIMIT ';
if ($offset) $limit_sql .= $offset . ",";
if ($offset) {
$limit_sql .= $offset . ",";
}
$limit_sql .= $limit;
}

View file

@ -83,7 +83,9 @@ class Session
*/
public static function destroy($key)
{
if (!strlen($key)) { return false; }
if (!strlen($key)) {
return false;
}
// Remove anything and EVERYTHING
$sql = 'DELETE FROM `session` WHERE `id` = ?';
@ -231,7 +233,9 @@ class Session
$geoname = $data['geo_name'];
}
if (!strlen($value)) { $value = ' '; }
if (!strlen($value)) {
$value = ' ';
}
/* Insert the row */
$sql = 'INSERT INTO `session` (`id`,`username`,`ip`,`type`,`agent`,`value`,`expire`,`geo_latitude`,`geo_longitude`, `geo_name`) ' .
@ -259,7 +263,9 @@ class Session
$session_name = AmpConfig::get('session_name');
// No cookie no go!
if (!isset($_COOKIE[$session_name])) { return false; }
if (!isset($_COOKIE[$session_name])) {
return false;
}
// Set up the cookie params before we start the session.
// This is vital
@ -541,5 +547,4 @@ class Session
return true;
}
}

View file

@ -50,7 +50,9 @@ class Share extends database_object
*/
public function __construct($id=0)
{
if (!$id) { return true; }
if (!$id) {
return true;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -115,9 +117,13 @@ class Share extends database_object
public static function create_share($object_type, $object_id, $allow_stream=true, $allow_download=true, $expire=0, $secret='', $max_counter=0, $description='')
{
$object_type = self::format_type($object_type);
if (empty($object_type)) return '';
if (empty($object_type)) {
return '';
}
if (!$allow_stream && !$allow_download) return '';
if (!$allow_stream && !$allow_download) {
return '';
}
$sql = "INSERT INTO `share` (`user`, `object_type`, `object_id`, `creation_date`, `allow_stream`, `allow_download`, `expire_days`, `secret`, `counter`, `max_counter`, `description`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$params = array($GLOBALS['user']->id, $object_type, $object_id, time(), $allow_stream ?: 0, $allow_download ?: 0, $expire, $secret, 0, $max_counter, $description);
@ -321,7 +327,9 @@ class Share extends database_object
$songs = $object->get_songs();
foreach ($songs as $id) {
$is_shared = ($media_id == $id);
if ($is_shared) { break; }
if ($is_shared) {
break;
}
}
break;
default:
@ -375,5 +383,5 @@ class Share extends database_object
echo "</li>";
echo "</ul>";
}
} // end of recommendation class

View file

@ -46,7 +46,6 @@ class Shoutbox
$this->_get_info($shout_id);
return true;
} // Constructor
/**
@ -65,7 +64,6 @@ class Shoutbox
}
return true;
} // _get_info
/**
@ -122,7 +120,6 @@ class Shoutbox
}
return $shouts;
} // get_top
public static function get_shouts_since($time)
@ -136,7 +133,6 @@ class Shoutbox
}
return $shouts;
}
/**
@ -155,7 +151,6 @@ class Shoutbox
}
return $results;
} // get_sticky
/**
@ -164,13 +159,13 @@ class Shoutbox
*/
public static function get_object($type,$object_id)
{
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return false;
}
$object = new $type($object_id);
return $object;
} // get_object
/**
@ -186,7 +181,6 @@ class Shoutbox
}
return $image_string;
} // get_image
/**
@ -195,8 +189,9 @@ class Shoutbox
*/
public static function create(array $data)
{
if (!Core::is_library_item($data['object_type']))
if (!Core::is_library_item($data['object_type'])) {
return false;
}
$sticky = isset($data['sticky']) ? 1 : 0;
$user = intval($data['user'] ?: $GLOBALS['user']->id);
@ -237,7 +232,6 @@ class Shoutbox
}
return $insert_id;
} // create
/**
@ -250,7 +244,6 @@ class Shoutbox
Dba::write($sql, array($data['comment'], make_bool($data['sticky']), $this->id));
return $this->id;
} // create
/**
@ -264,7 +257,6 @@ class Shoutbox
$this->f_date = date("m\/d\/Y - H:i", $this->date);
$this->f_text = preg_replace('/(\r\n|\n|\r)/', '<br />', $this->text);
return true;
} //format
/**
@ -278,7 +270,6 @@ class Shoutbox
$shout_id = Dba::escape($shout_id);
$sql = "DELETE FROM `user_shout` WHERE `id`='$shout_id'";
Dba::write($sql);
} // delete
public function get_display($details = true, $jsbuttons = false)
@ -343,5 +334,5 @@ class Shoutbox
return $results;
}
} // Shoutbox class

View file

@ -58,5 +58,5 @@ class Slideshow
return $images;
}
} // end of Slideshow class

View file

@ -293,7 +293,9 @@ class Song extends database_object implements media, library_item
*/
public function __construct($id = null, $limit_threshold = '')
{
if (!$id) { return false; }
if (!$id) {
return false;
}
$this->id = intval($id);
@ -310,7 +312,6 @@ class Song extends database_object implements media, library_item
}
return true;
} // constructor
/**
@ -444,12 +445,16 @@ class Song extends database_object implements media, library_item
*/
public static function build_cache($song_ids, $limit_threshold = '')
{
if (!is_array($song_ids) || !count($song_ids)) { return false; }
if (!is_array($song_ids) || !count($song_ids)) {
return false;
}
$idlist = '(' . implode(',', $song_ids) . ')';
// Callers might have passed array(false) because they are dumb
if ($idlist == '()') { return false; }
if ($idlist == '()') {
return false;
}
// Song data cache
$sql = 'SELECT `song`.`id`, `file`, `catalog`, `album`, ' .
@ -508,7 +513,6 @@ class Song extends database_object implements media, library_item
}
return true;
} // build_cache
/**
@ -567,7 +571,6 @@ class Song extends database_object implements media, library_item
parent::add_to_cache('song_data',$id,$results);
return $results;
} // _get_ext_info
/**
@ -583,7 +586,6 @@ class Song extends database_object implements media, library_item
$this->$key = $value;
}
} // end foreach
} // fill_ext_info
/**
@ -644,7 +646,9 @@ class Song extends database_object implements media, library_item
$results = array();
$sql = "SELECT `id` FROM `song` WHERE `enabled`='0'";
if ($count) { $sql .= " LIMIT $count"; }
if ($count) {
$sql .= " LIMIT $count";
}
$db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) {
@ -729,12 +733,15 @@ class Song extends database_object implements media, library_item
*/
public function get_album_name($album_id=0)
{
if (!$album_id) { $album_id = $this->album; }
if (!$album_id) {
$album_id = $this->album;
}
$album = new Album($album_id);
if ($album->prefix)
if ($album->prefix) {
return $album->prefix . " " . $album->name;
else
} else {
return $album->name;
}
} // get_album_name
/**
@ -745,13 +752,15 @@ class Song extends database_object implements media, library_item
*/
public function get_artist_name($artist_id=0)
{
if (!$artist_id) { $artist_id = $this->artist; }
if (!$artist_id) {
$artist_id = $this->artist;
}
$artist = new Artist($artist_id);
if ($artist->prefix)
if ($artist->prefix) {
return $artist->prefix . " " . $artist->name;
else
} else {
return $artist->name;
}
} // get_artist_name
/**
@ -762,13 +771,15 @@ class Song extends database_object implements media, library_item
*/
public function get_album_artist_name($album_artist_id=0)
{
if (!$album_artist_id) { $album_artist_id = $this->albumartist; }
if (!$album_artist_id) {
$album_artist_id = $this->albumartist;
}
$album_artist = new Artist($album_artist_id);
if ($album_artist->prefix)
if ($album_artist->prefix) {
return $album_artist->prefix . " " . $album_artist->name;
else
} else {
return $album_artist->name;
}
} // get_album_artist_name
/**
@ -794,7 +805,6 @@ class Song extends database_object implements media, library_item
self::update_played(true, $this->id);
return true;
} // set_played
/**
@ -821,7 +831,9 @@ class Song extends database_object implements media, library_item
// Foreach them
foreach ($fields as $key=>$value) {
if (in_array($key,$skip_array)) { continue; }
if (in_array($key,$skip_array)) {
continue;
}
$songData = is_array($song->$key) ? implode(" ", $song->$key) : $song->$key;
$newSongData = is_array($new_song->$key) ? implode(" ", $new_song->$key) : $new_song->$key;
@ -838,7 +850,6 @@ class Song extends database_object implements media, library_item
$array['element'][$key] = 'OLD:' . $songData . ' --> ' . $newSongData;
}
} // end else
} // end foreach
if ($array['change']) {
@ -846,7 +857,6 @@ class Song extends database_object implements media, library_item
}
return $array;
} // compare_song_information
@ -964,7 +974,6 @@ class Song extends database_object implements media, library_item
"WHERE `song_id` = ?";
Dba::write($sql, array($new_song->lyrics, $new_song->language, $new_song->comment, $new_song->replaygain_track_gain,
$new_song->replaygain_track_peak, $new_song->replaygain_album_gain, $new_song->replaygain_album_peak, $song_id));
} // update_song
/**
@ -976,7 +985,6 @@ class Song extends database_object implements media, library_item
public static function update_year($new_year, $song_id)
{
self::_update_item('year', $new_year, $song_id, 50, true);
} // update_year
/**
@ -988,7 +996,6 @@ class Song extends database_object implements media, library_item
public static function update_label($new_value, $song_id)
{
self::_update_ext_item('label', $new_value, $song_id, 50, true);
} // update_label
/**
@ -1000,7 +1007,6 @@ class Song extends database_object implements media, library_item
public static function update_language($new_lang, $song_id)
{
self::_update_ext_item('language', $new_lang, $song_id, 50, true);
} // update_language
/**
@ -1012,7 +1018,6 @@ class Song extends database_object implements media, library_item
public static function update_comment($new_comment, $song_id)
{
self::_update_ext_item('comment', $new_comment, $song_id, 50, true);
} // update_comment
/**
@ -1024,7 +1029,6 @@ class Song extends database_object implements media, library_item
public static function update_lyrics($new_lyrics, $song_id)
{
self::_update_ext_item('lyrics', $new_lyrics, $song_id, 50, true);
} // update_lyrics
/**
@ -1036,7 +1040,6 @@ class Song extends database_object implements media, library_item
public static function update_title($new_title,$song_id)
{
self::_update_item('title', $new_title, $song_id, 50, true);
} // update_title
/**
@ -1048,7 +1051,6 @@ class Song extends database_object implements media, library_item
public static function update_composer($new_value, $song_id)
{
self::_update_item('composer', $new_value, $song_id, 50, true);
} // update_composer
/**
@ -1060,7 +1062,6 @@ class Song extends database_object implements media, library_item
public static function update_publisher($new_value, $song_id)
{
self::_update_item('publisher', $new_value, $song_id, 50, true);
} // update_publisher
/**
@ -1072,7 +1073,6 @@ class Song extends database_object implements media, library_item
public static function update_bitrate($new_bitrate, $song_id)
{
self::_update_item('bitrate', $new_bitrate, $song_id, 50, true);
} // update_bitrate
/**
@ -1084,7 +1084,6 @@ class Song extends database_object implements media, library_item
public static function update_rate($new_rate, $song_id)
{
self::_update_item('rate', $new_rate, $song_id, 50, true);
} // update_rate
/**
@ -1096,7 +1095,6 @@ class Song extends database_object implements media, library_item
public static function update_mode($new_mode, $song_id)
{
self::_update_item('mode', $new_mode, $song_id, 50, true);
} // update_mode
/**
@ -1108,7 +1106,6 @@ class Song extends database_object implements media, library_item
public static function update_size($new_size, $song_id)
{
self::_update_item('size', $new_size, $song_id, 50);
} // update_size
/**
@ -1120,7 +1117,6 @@ class Song extends database_object implements media, library_item
public static function update_time($new_time, $song_id)
{
self::_update_item('time', $new_time, $song_id, 50, true);
} // update_time
/**
@ -1132,7 +1128,6 @@ class Song extends database_object implements media, library_item
public static function update_track($new_track, $song_id)
{
self::_update_item('track', $new_track, $song_id, 50, true);
} // update_track
/**
@ -1144,7 +1139,6 @@ class Song extends database_object implements media, library_item
public static function update_mbid($new_mbid, $song_id)
{
self::_update_item('mbid', $new_mbid, $song_id, 50);
} // update_mbid
/**
@ -1156,7 +1150,6 @@ class Song extends database_object implements media, library_item
public static function update_license($new_license, $song_id)
{
self::_update_item('license', $new_license, $song_id, 50, true);
} // update_license
/**
@ -1168,7 +1161,6 @@ class Song extends database_object implements media, library_item
public static function update_artist($new_artist, $song_id)
{
self::_update_item('artist', $new_artist, $song_id, 50);
} // update_artist
/**
@ -1180,7 +1172,6 @@ class Song extends database_object implements media, library_item
public static function update_album($new_album, $song_id)
{
self::_update_item('album', $new_album, $song_id, 50, true);
} // update_album
/**
@ -1191,10 +1182,11 @@ class Song extends database_object implements media, library_item
*/
public static function update_utime($song_id, $time=0)
{
if (!$time) { $time = time(); }
if (!$time) {
$time = time();
}
self::_update_item('update_time', $time, $song_id, 75, true);
} // update_utime
/**
@ -1206,7 +1198,6 @@ class Song 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);
} // update_played
/**
@ -1218,7 +1209,6 @@ class Song extends database_object implements media, library_item
public static function update_enabled($new_enabled, $song_id)
{
self::_update_item('enabled', ($new_enabled ? 1 : 0), $song_id, 75, true);
} // update_enabled
/**
@ -1243,14 +1233,17 @@ class Song extends database_object implements media, library_item
}
}
/* Check them Rights! */
if (!Access::check('interface', $level)) { return false; }
if (!Access::check('interface', $level)) {
return false;
}
/* Can't update to blank */
if (!strlen(trim($value)) && $field != 'comment') { return false; }
if (!strlen(trim($value)) && $field != 'comment') {
return false;
}
$sql = "UPDATE `song` SET `$field` = ? WHERE `id` = ?";
return Dba::write($sql, array($value, $song_id));
} // _update_item
/**
@ -1274,11 +1267,12 @@ class Song extends database_object implements media, library_item
}
/* Check them rights boy! */
if (!Access::check('interface',$level)) { return false; }
if (!Access::check('interface',$level)) {
return false;
}
$sql = "UPDATE `song_data` SET `$field` = ? WHERE `song_id` = ?";
return Dba::write($sql, array($value, $song_id));
} // _update_ext_item
/**
@ -1348,7 +1342,6 @@ class Song extends database_object implements media, library_item
$this->f_publisher = $this->label;
$this->f_composer = $this->composer;
} // format
/**
@ -1460,8 +1453,9 @@ class Song extends database_object implements media, library_item
public function get_description()
{
if (!empty($this->comment))
if (!empty($this->comment)) {
return $this->comment;
}
$album = new Album($this->album);
$album->format();
@ -1476,13 +1470,17 @@ class Song extends database_object implements media, library_item
if (Art::has_db($this->id, 'song')) {
$id = $this->id;
$type = 'song';
} else if (Art::has_db($this->album, 'album')) {
} else {
if (Art::has_db($this->album, 'album')) {
$id = $this->album;
$type = 'album';
} else if (Art::has_db($this->artist, 'artist')) {
} else {
if (Art::has_db($this->artist, 'artist')) {
$id = $this->artist;
$type = 'artist';
}
}
}
if ($id !== null && $type !== null) {
Art::display($type, $id, $this->get_fullname(), $thumb, $this->link);
@ -1509,7 +1507,6 @@ class Song extends database_object implements media, library_item
// $fields['recently Played'] = true;
return $fields;
} // get_fields
/**
@ -1532,7 +1529,6 @@ class Song extends database_object implements media, library_item
}
return $songs;
} // get_from_path
/**
@ -1558,7 +1554,6 @@ class Song extends database_object implements media, library_item
}
$catalog = Catalog::create_from_id( $catalog_id );
return $catalog->get_rel_path($file_path);
} // get_rel_path
/**
@ -1572,7 +1567,9 @@ class Song extends database_object implements media, library_item
public static function generic_play_url($object_type, $object_id, $additional_params, $player=null, $local=false)
{
$media = new $object_type($object_id);
if (!$media->id) return null;
if (!$media->id) {
return null;
}
$uid = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
$type = $media->type;
@ -1648,7 +1645,8 @@ class Song extends database_object implements media, library_item
if ($user_id) {
// 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')) {
} else {
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) {
@ -1656,6 +1654,7 @@ class Song extends database_object implements media, library_item
$sql .= "AND `user` IN (SELECT `user` FROM `user_preference` WHERE (`preference`='$personal_info_id' AND `value`='1') OR `user`='$current_user') ";
}
}
}
$sql .= "ORDER BY `date` DESC ";
$db_results = Dba::read($sql);
@ -1666,11 +1665,12 @@ class Song extends database_object implements media, library_item
$row['geo_name'] = Stats::get_cached_place_name($row['latitude'], $row['longitude']);
}
$results[] = $row;
if (count($results) >= AmpConfig::get('popular_threshold')) { break; }
if (count($results) >= AmpConfig::get('popular_threshold')) {
break;
}
}
return $results;
} // get_recently_played
/**
@ -1735,14 +1735,18 @@ class Song extends database_object implements media, library_item
if ($target) {
debug_event('media', 'Explicit format request {' . $target . '}', 5);
} else if ($target = AmpConfig::get('encode_target_' . $source)) {
} else {
if ($target = AmpConfig::get('encode_target_' . $source)) {
debug_event('media', 'Defaulting to configured target format for ' . $source, 5);
} else if ($target = AmpConfig::get($setting_target)) {
} else {
if ($target = AmpConfig::get($setting_target)) {
debug_event('media', 'Using default target format', 5);
} else {
$target = $source;
debug_event('media', 'No default target for ' . $source . ', choosing to resample', 5);
}
}
}
debug_event('media', 'Transcode settings: from ' . $source . ' to ' . $target, 5);
@ -1947,5 +1951,5 @@ class Song extends database_object implements media, library_item
return $deleted;
}
} // end of song class

View file

@ -54,7 +54,9 @@ class Song_Preview extends database_object implements media, playable_item
*/
public function __construct($id = null)
{
if (!$id) { return false; }
if (!$id) {
return false;
}
$this->id = intval($id);
@ -71,7 +73,6 @@ class Song_Preview extends database_object implements media, playable_item
}
return true;
} // constructor
/**
@ -113,12 +114,16 @@ class Song_Preview extends database_object implements media, playable_item
*/
public static function build_cache($song_ids)
{
if (!is_array($song_ids) || !count($song_ids)) { return false; }
if (!is_array($song_ids) || !count($song_ids)) {
return false;
}
$idlist = '(' . implode(',', $song_ids) . ')';
// Callers might have passed array(false) because they are dumb
if ($idlist == '()') { return false; }
if ($idlist == '()') {
return false;
}
// Song data cache
$sql = 'SELECT `id`, `file`, `album_mbid`, `artist`, `artist_mbid`, `title`, `disk`, `track`, `mbid` ' .
@ -137,7 +142,6 @@ class Song_Preview extends database_object implements media, playable_item
Artist::build_cache($artists);
return true;
} // build_cache
/**
@ -177,13 +181,15 @@ class Song_Preview extends database_object implements media, playable_item
*/
public function get_artist_name($artist_id=0)
{
if (!$artist_id) { $artist_id = $this->artist; }
if (!$artist_id) {
$artist_id = $this->artist;
}
$artist = new Artist($artist_id);
if ($artist->prefix)
if ($artist->prefix) {
return $artist->prefix . " " . $artist->name;
else
} else {
return $artist->name;
}
} // get_album_name
/**
@ -217,7 +223,6 @@ class Song_Preview extends database_object implements media, playable_item
$this->f_track = $this->track;
return true;
} // format
public function get_fullname()
@ -281,7 +286,6 @@ class Song_Preview extends database_object implements media, playable_item
$url = Stream::get_base_url($local) . "type=song_preview&oid=" . $song->id . "&uid=" . $user_id . "&name=" . $song_name;
return Stream_URL::format($url . $additional_params);
} // play_url
public function stream()
@ -290,10 +294,11 @@ class Song_Preview extends database_object implements media, playable_item
foreach (Plugin::get_plugins('stream_song_preview') as $plugin_name) {
$plugin = new Plugin($plugin_name);
if ($plugin->load($GLOBALS['user'])) {
if ($plugin->_plugin->stream_song_preview($this->file))
if ($plugin->_plugin->stream_song_preview($this->file)) {
break;
}
}
}
return $data;
}
@ -345,5 +350,5 @@ class Song_Preview extends database_object implements media, playable_item
'WHERE `session`.`id` IS NULL';
return Dba::write($sql);
}
} // end of song_preview class

View file

@ -46,7 +46,6 @@ class Stats
public function __construct()
{
return true;
} // Constructor
/**
@ -103,12 +102,15 @@ class Stats
$latitude = null;
$longitude = null;
$geoname = null;
if (isset($location['latitude']))
if (isset($location['latitude'])) {
$latitude = $location['latitude'];
if (isset($location['longitude']))
}
if (isset($location['longitude'])) {
$longitude = $location['longitude'];
if (isset($location['name']))
}
if (isset($location['name'])) {
$geoname = $location['name'];
}
$sql = "INSERT INTO `object_count` (`object_type`,`object_id`,`count_type`,`date`,`user`,`agent`, `geo_latitude`, `geo_longitude`, `geo_name`) " .
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
@ -142,7 +144,6 @@ class Stats
}
return count($results) > 0;
} // is_already_inserted
/**
@ -205,7 +206,6 @@ class Stats
$results = Dba::fetch_assoc($db_results);
return $results;
} // get_last_song
/**
@ -236,7 +236,6 @@ class Stats
}
return $results;
} // get_object_history
/**
@ -291,7 +290,6 @@ class Stats
$results[] = $row['id'];
}
return $results;
} // get_top
/**
@ -345,7 +343,6 @@ class Stats
}
return $results;
} // get_recent
/**
@ -379,7 +376,6 @@ class Stats
}
return $results;
} // get_user
/**
@ -404,7 +400,6 @@ class Stats
default:
return 'song';
} // end switch
} // validate_type
/**
@ -441,7 +436,9 @@ class Stats
*/
public static function get_newest($type, $count='', $offset='', $catalog=0)
{
if (!$count) { $count = AmpConfig::get('popular_threshold'); }
if (!$count) {
$count = AmpConfig::get('popular_threshold');
}
if (!$offset) {
$limit = $count;
} else {
@ -459,7 +456,6 @@ class Stats
} // end while results
return $items;
} // get_newest
} // Stats class

View file

@ -219,7 +219,6 @@ class Stream
$frame = gmdate("H:i:s", $sec);
if (AmpConfig::get('transcode_cmd') && AmpConfig::get('transcode_input') && AmpConfig::get('encode_get_image')) {
$command = AmpConfig::get('transcode_cmd') . ' ' . AmpConfig::get('transcode_input') . ' ' . AmpConfig::get('encode_get_image');
$string_map = array(
'%FILE%' => scrub_arg($media->file),
@ -256,8 +255,9 @@ class Stream
// Windows doesn't like to provide stderr as a pipe
$descriptors[2] = array('pipe', 'w');
$cmdPrefix = "exec ";
} else
} else {
$cmdPrefix = "start /B ";
}
debug_event('stream', "Transcode command prefix: " . $cmdPrefix, 3);
@ -398,7 +398,6 @@ class Stream
} // end while
return $results;
} // get_now_playing
/**
@ -431,7 +430,9 @@ class Stream
public static function run_playlist_method()
{
// If this wasn't ajax included run away
if (!defined('AJAX_INCLUDE')) { return false; }
if (!defined('AJAX_INCLUDE')) {
return false;
}
switch (AmpConfig::get('playlist_method')) {
case 'send':
@ -451,7 +452,6 @@ class Stream
echo "<script type=\"text/javascript\">";
echo Core::get_reloadutil() . "('".$_SESSION['iframe']['target']."');";
echo "</script>";
} // run_playlist_method
/**
@ -487,7 +487,6 @@ class Stream
$url = $web_path . "/play/index.php?$session_string";
return $url;
} // get_base_url
} //end of stream class

View file

@ -275,7 +275,9 @@ class Stream_Playlist
*/
public function add_urls($urls = array())
{
if (!is_array($urls)) { return false; }
if (!is_array($urls)) {
return false;
}
foreach ($urls as $url) {
$this->_add_url(new Stream_URL(array(
@ -296,7 +298,6 @@ class Stream_Playlist
foreach ($this->urls as $url) {
echo $url->url . "\n";
}
} // simple_m3u
/**
@ -314,7 +315,6 @@ class Stream_Playlist
echo $url->url . "\n";
$i++;
}
} // create_m3u
/**
@ -360,7 +360,6 @@ class Stream_Playlist
}
echo "</ASX>\n";
} // create_asx
/**
@ -397,14 +396,12 @@ class Stream_Playlist
}
$result .= XML_Data::keyed_array($xml, true);
} // end foreach
XML_Data::set_type('xspf');
echo XML_Data::header();
echo $result;
echo XML_Data::footer();
} // create_xspf
public function create_hls()
@ -461,7 +458,6 @@ class Stream_Playlist
} else {
require AmpConfig::get('prefix') . '/templates/create_web_player.inc.php';
}
} // create_web_player
/**
@ -492,7 +488,6 @@ class Stream_Playlist
}
$localplay->play();
}
} // create_localplay
/**

View file

@ -41,8 +41,9 @@ class Stream_URL extends memory_object
$url = substr($url, 0, $posargs + 6) . 'index.php?';
$args = explode('/', $argsstr);
for ($i = 0; $i < count($args); $i += 2) {
if ($i > 0)
if ($i > 0) {
$url .= '&';
}
$url .= $args[$i] . '=' . $args[$i + 1];
}
}

View file

@ -54,7 +54,9 @@ class Subsonic_Api
{
if (empty($input[$parameter])) {
ob_end_clean();
if ($addheader) self::setHeader($input['f']);
if ($addheader) {
self::setHeader($input['f']);
}
self::apiOutput($input, Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM));
exit;
}
@ -69,7 +71,9 @@ class Subsonic_Api
if ($encpwd !== false) {
$hex = substr($password, 4);
$decpwd = '';
for ($i=0; $i<strlen($hex); $i+=2) $decpwd .= chr(hexdec(substr($hex,$i,2)));
for ($i=0; $i<strlen($hex); $i+=2) {
$decpwd .= chr(hexdec(substr($hex,$i,2)));
}
$password = $decpwd;
}
return $password;
@ -145,11 +149,13 @@ class Subsonic_Api
{
if (strtolower($f) == "json") {
header("Content-type: application/json; charset=" . AmpConfig::get('site_charset'));
} else if (strtolower($f) == "jsonp") {
} else {
if (strtolower($f) == "jsonp") {
header("Content-type: text/javascript; charset=" . AmpConfig::get('site_charset'));
} else {
header("Content-type: text/xml; charset=" . AmpConfig::get('site_charset'));
}
}
header("access-control-allow-origin: *");
}
@ -164,7 +170,8 @@ class Subsonic_Api
{
if ($f == "json") {
echo json_encode(self::xml2json($xml), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
} else if ($f == "jsonp") {
} else {
if ($f == "jsonp") {
echo $callback . '(' . json_encode(self::xml2json($xml), JSON_PRETTY_PRINT) . ')';
} else {
$xmlstr = $xml->asXml();
@ -175,6 +182,7 @@ class Subsonic_Api
echo $dom->saveXML();
}
}
}
/**
* xml2json based from http://outlandish.com/blog/xml-to-json/
@ -202,8 +210,10 @@ class Subsonic_Api
foreach ($namespaces as $prefix => $namespace) {
foreach ($xml->attributes($namespace) as $attributeName => $attribute) {
//replace characters in attribute name
if ($options['keySearch']) $attributeName =
if ($options['keySearch']) {
$attributeName =
str_replace($options['keySearch'], $options['keyReplace'], $attributeName);
}
$attributeKey = $options['attributePrefix']
. ($prefix ? $prefix . $options['namespaceSeparator'] : '')
. $attributeName;
@ -226,10 +236,14 @@ class Subsonic_Api
list($childTagName, $childProperties) = each($childArray);
//replace characters in tag name
if ($options['keySearch']) $childTagName =
if ($options['keySearch']) {
$childTagName =
str_replace($options['keySearch'], $options['keyReplace'], $childTagName);
}
//add namespace prefix, if any
if ($prefix) $childTagName = $prefix . $options['namespaceSeparator'] . $childTagName;
if ($prefix) {
$childTagName = $prefix . $options['namespaceSeparator'] . $childTagName;
}
if (!isset($tagsArray[$childTagName])) {
//only entry with this key
@ -253,7 +267,9 @@ class Subsonic_Api
//get text content of node
$textContentArray = array();
$plainText = trim((string) $xml);
if ($plainText !== '') $textContentArray[$options['textContent']] = $plainText;
if ($plainText !== '') {
$textContentArray[$options['textContent']] = $plainText;
}
//stick it all together
$propertiesArray = !$options['autoText'] || $attributesArray || $tagsArray || ($plainText === '')
@ -335,14 +351,26 @@ class Subsonic_Api
$clastmodified = 0;
$catalog = Catalog::create_from_id($id);
if ($catalog->last_update > $clastmodified) $clastmodified = $catalog->last_update;
if ($catalog->last_add > $clastmodified) $clastmodified = $catalog->last_add;
if ($catalog->last_clean > $clastmodified) $clastmodified = $catalog->last_clean;
if ($clastmodified > $lastmodified) $lastmodified = $clastmodified;
if (!empty($ifModifiedSince) && $clastmodified > ($ifModifiedSince / 1000)) $fcatalogs[] = $id;
if ($catalog->last_update > $clastmodified) {
$clastmodified = $catalog->last_update;
}
if ($catalog->last_add > $clastmodified) {
$clastmodified = $catalog->last_add;
}
if ($catalog->last_clean > $clastmodified) {
$clastmodified = $catalog->last_clean;
}
if ($clastmodified > $lastmodified) {
$lastmodified = $clastmodified;
}
if (!empty($ifModifiedSince) && $clastmodified > ($ifModifiedSince / 1000)) {
$fcatalogs[] = $id;
}
}
if (empty($ifModifiedSince)) {
$fcatalogs = $catalogs;
}
if (empty($ifModifiedSince)) $fcatalogs = $catalogs;
$r = Subsonic_XML_Data::createSuccessResponse();
if (count($fcatalogs) > 0) {
@ -367,10 +395,12 @@ class Subsonic_Api
if (Subsonic_XML_Data::isArtist($id)) {
$artist = new Artist(Subsonic_XML_Data::getAmpacheId($id));
Subsonic_XML_Data::addArtistDirectory($r, $artist);
} else if (Subsonic_XML_Data::isAlbum($id)) {
} else {
if (Subsonic_XML_Data::isAlbum($id)) {
$album = new Album(Subsonic_XML_Data::getAmpacheId($id));
Subsonic_XML_Data::addAlbumDirectory($r, $album);
}
}
self::apiOutput($input, $r);
}
@ -487,21 +517,29 @@ class Subsonic_Api
$albums = array();
if ($type == "random") {
$albums = Album::get_random($size);
} else if ($type == "newest") {
} else {
if ($type == "newest") {
$albums = Stats::get_newest("album", $size, $offset, $musicFolderId);
} else if ($type == "highest") {
} else {
if ($type == "highest") {
$albums = Rating::get_highest("album", $size, $offset);
} else if ($type == "frequent") {
} else {
if ($type == "frequent") {
$albums = Stats::get_top("album", $size, '', $offset);
} else if ($type == "recent") {
} else {
if ($type == "recent") {
$albums = Stats::get_recent("album", $size, $offset);
} else if ($type == "starred") {
} else {
if ($type == "starred") {
$albums = Userflag::get_latest('album');
} else if ($type == "alphabeticalByName") {
} else {
if ($type == "alphabeticalByName") {
$albums = Catalog::get_albums($size, $offset, $catalogs);
} else if ($type == "alphabeticalByArtist") {
} else {
if ($type == "alphabeticalByArtist") {
$albums = Catalog::get_albums_by_artist($size, $offset, $catalogs);
} else if ($type == "byYear") {
} else {
if ($type == "byYear") {
$fromYear = $input['fromYear'];
$toYear = $input['toYear'];
@ -527,7 +565,8 @@ class Subsonic_Api
$query = new Search(null, 'album');
$albums = $query->run($search);
}
} else if ($type == "byGenre") {
} else {
if ($type == "byGenre") {
$genre = self::check_parameter($input, 'genre');
$tag_id = Tag::tag_exists($genre);
@ -535,6 +574,15 @@ class Subsonic_Api
$albums = Tag::get_tag_objects('album', $tag_id, $size, $offset);
}
}
}
}
}
}
}
}
}
}
}
if (count($albums)) {
$r = Subsonic_XML_Data::createSuccessResponse();
@ -566,7 +614,9 @@ class Subsonic_Api
self::check_version($input, "1.2.0");
$size = $input['size'];
if (!$size) $size = 10;
if (!$size) {
$size = 10;
}
$genre = $input['genre'];
$fromYear = $input['fromYear'];
$toYear = $input['toYear'];
@ -601,7 +651,8 @@ class Subsonic_Api
$finput = $artist->name;
$operator = 4;
$ftype = "artist";
} else if (Subsonic_XML_Data::isAlbum($musicFolderId)) {
} else {
if (Subsonic_XML_Data::isAlbum($musicFolderId)) {
$album = new Album(Subsonic_XML_Data::getAmpacheId($musicFolderId));
$finput = $album->name;
$operator = 4;
@ -611,6 +662,7 @@ class Subsonic_Api
$operator = 0;
$ftype = "catalog";
}
}
$search['rule_'.$i.'_input'] = $finput;
$search['rule_'.$i.'_operator'] = $operator;
$search['rule_'.$i.''] = $ftype;
@ -710,7 +762,9 @@ class Subsonic_Api
$sartist = array();
$sartist['limit'] = $artistCount;
if ($artistOffset) $sartist['offset'] = $artistOffset;
if ($artistOffset) {
$sartist['offset'] = $artistOffset;
}
$sartist['rule_1_input'] = $query;
$sartist['rule_1_operator'] = $operator;
$sartist['rule_1'] = "name";
@ -719,7 +773,9 @@ class Subsonic_Api
$salbum = array();
$salbum['limit'] = $albumCount;
if ($albumOffset) $salbum['offset'] = $albumOffset;
if ($albumOffset) {
$salbum['offset'] = $albumOffset;
}
$salbum['rule_1_input'] = $query;
$salbum['rule_1_operator'] = $operator;
$salbum['rule_1'] = "title";
@ -728,7 +784,9 @@ class Subsonic_Api
$ssong = array();
$ssong['limit'] = $songCount;
if ($songOffset) $ssong['offset'] = $songOffset;
if ($songOffset) {
$ssong['offset'] = $songOffset;
}
$ssong['rule_1_input'] = $query;
$ssong['rule_1_operator'] = $operator;
$ssong['rule_1'] = "anywhere";
@ -814,7 +872,8 @@ class Subsonic_Api
if ($playlistId) {
self::_updatePlaylist($playlistId, $name, $songId);
$r = Subsonic_XML_Data::createSuccessResponse();
} else if (!empty($name)) {
} else {
if (!empty($name)) {
$playlistId = Playlist::create($name, 'private');
if (count($songId) > 0) {
self::_updatePlaylist($playlistId, "", $songId);
@ -823,6 +882,7 @@ class Subsonic_Api
} else {
$r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM);
}
}
self::apiOutput($input, $r);
}
@ -945,9 +1005,11 @@ class Subsonic_Api
$url = '';
if (Subsonic_XML_Data::isVideo($fileid)) {
$url = Video::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params, 'api', function_exists('curl_version'));
} else if (Subsonic_XML_Data::isSong($fileid)) {
} else {
if (Subsonic_XML_Data::isSong($fileid)) {
$url = Song::play_url(Subsonic_XML_Data::getAmpacheId($fileid), $params, 'api', function_exists('curl_version'));
}
}
if (!empty($url)) {
self::follow_stream($url);
@ -1015,11 +1077,15 @@ class Subsonic_Api
$art = null;
if (Subsonic_XML_Data::isArtist($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "artist");
} else if (Subsonic_XML_Data::isAlbum($id)) {
} else {
if (Subsonic_XML_Data::isAlbum($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "album");
} else if (Subsonic_XML_Data::isSong($id)) {
} else {
if (Subsonic_XML_Data::isSong($id)) {
$art = new Art(Subsonic_XML_Data::getAmpacheId($id), "song");
}
}
}
if ($art != null) {
$art->get_db();
@ -1057,11 +1123,15 @@ class Subsonic_Api
$robj = null;
if (Subsonic_XML_Data::isArtist($id)) {
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "artist");
} else if (Subsonic_XML_Data::isAlbum($id)) {
} else {
if (Subsonic_XML_Data::isAlbum($id)) {
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "album");
} else if (Subsonic_XML_Data::isSong($id)) {
} else {
if (Subsonic_XML_Data::isSong($id)) {
$robj = new Rating(Subsonic_XML_Data::getAmpacheId($id), "song");
}
}
}
if ($robj != null) {
$robj->set_rating($rating);
@ -1143,16 +1213,21 @@ class Subsonic_Api
$aid = Subsonic_XML_Data::getAmpacheId($i);
if (Subsonic_XML_Data::isArtist($i)) {
$type = 'artist';
} else if (Subsonic_XML_Data::isAlbum($i)) {
} else {
if (Subsonic_XML_Data::isAlbum($i)) {
$type = 'album';
} else if (Subsonic_XML_Data::isSong($i)) {
} else {
if (Subsonic_XML_Data::isSong($i)) {
$type = 'song';
} else {
$type = "";
}
}
}
$ids[] = array('id' => $aid, 'type' => $type);
}
} else if ($albumId) {
} else {
if ($albumId) {
if (!is_array($albumId)) {
$albumId = array($albumId);
}
@ -1160,7 +1235,8 @@ class Subsonic_Api
$aid = Subsonic_XML_Data::getAmpacheId($i);
$ids[] = array('id' => $aid, 'album');
}
} else if ($artistId) {
} else {
if ($artistId) {
if (!is_array($artistId)) {
$artistId = array($artistId);
}
@ -1171,6 +1247,8 @@ class Subsonic_Api
} else {
$r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM);
}
}
}
foreach ($ids as $i) {
$flag = new Userflag($i['id'], $i['type']);
@ -1317,9 +1395,11 @@ class Subsonic_Api
$object_id = Subsonic_XML_Data::getAmpacheId($id);
if (Subsonic_XML_Data::isAlbum($id)) {
$object_type = 'album';
} else if (Subsonic_XML_Data::isSong($id)) {
} else {
if (Subsonic_XML_Data::isSong($id)) {
$object_type = 'song';
}
}
if (!empty($object_type)) {
$r = Subsonic_XML_Data::createSuccessResponse();
@ -1548,8 +1628,9 @@ class Subsonic_Api
break;
case 'skip':
if (isset($input['index'])) {
if ($localplay->skip($input['index']))
if ($localplay->skip($input['index'])) {
$ret = $localplay->play();
}
} elseif (isset($input['offset'])) {
debug_event('subsonic', 'Skip with offset is not supported on JukeboxControl.', 5);
} else {

View file

@ -137,7 +137,9 @@ class Subsonic_XML_Data
public static function createResponse($version = "")
{
if (empty($version)) $version = Subsonic_XML_Data::API_VERSION;
if (empty($version)) {
$version = Subsonic_XML_Data::API_VERSION;
}
$response = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><subsonic-response/>');
$response->addAttribute('xmlns', 'http://subsonic.org/restapi');
$response->addAttribute('type', 'ampache');
@ -147,7 +149,9 @@ class Subsonic_XML_Data
public static function createError($code, $message = "", $version = "")
{
if (empty($version)) $version = Subsonic_XML_Data::API_VERSION;
if (empty($version)) {
$version = Subsonic_XML_Data::API_VERSION;
}
$response = self::createFailedResponse($version);
self::setError($response, $code, $message);
return $response;
@ -222,8 +226,13 @@ class Subsonic_XML_Data
foreach ($artists as $artist) {
if (strlen($artist->name) > 0) {
$letter = strtoupper($artist->name[0]);
if ($letter == "X" || $letter == "Y" || $letter == "Z") $letter = "X-Z";
else if (!preg_match("/^[A-W]$/", $letter)) $letter = "#";
if ($letter == "X" || $letter == "Y" || $letter == "Z") {
$letter = "X-Z";
} else {
if (!preg_match("/^[A-W]$/", $letter)) {
$letter = "#";
}
}
if ($letter != $xlastletter) {
$xlastletter = $letter;
@ -363,9 +372,13 @@ class Subsonic_XML_Data
$xsong->addAttribute('year', $song->year);
}
$tags = Tag::get_object_tags('song', $song->id);
if (count($tags) > 0) $xsong->addAttribute('genre', $tags[0]['name']);
if (count($tags) > 0) {
$xsong->addAttribute('genre', $tags[0]['name']);
}
$xsong->addAttribute('size', $song->size);
if ($album->disk > 0) $xsong->addAttribute('discNumber', $album->disk);
if ($album->disk > 0) {
$xsong->addAttribute('discNumber', $album->disk);
}
$xsong->addAttribute('suffix', $song->type);
$xsong->addAttribute('contentType', $song->mime);
// Create a clean fake path instead of song real file path to have better offline mode storage on Subsonic clients
@ -468,7 +481,9 @@ class Subsonic_XML_Data
$xvideo->addAttribute('year', $video->year);
}
$tags = Tag::get_object_tags('video', $video->id);
if (count($tags) > 0) $xvideo->addAttribute('genre', $tags[0]['name']);
if (count($tags) > 0) {
$xvideo->addAttribute('genre', $tags[0]['name']);
}
$xvideo->addAttribute('size', $video->size);
$xvideo->addAttribute('suffix', $video->type);
$xvideo->addAttribute('contentType', $video->mime);

View file

@ -38,14 +38,15 @@ class Tag extends database_object implements library_item
*/
public function __construct($id)
{
if (!$id) { return false; }
if (!$id) {
return false;
}
$info = $this->get_info($id);
foreach ($info as $key=>$value) {
$this->$key = $value;
} // end foreach
} // constructor
/**
@ -59,7 +60,6 @@ class Tag extends database_object implements library_item
$tag = new Tag($tag_id);
return $tag;
} // construct_from_name
/**
@ -69,7 +69,9 @@ class Tag extends database_object implements library_item
*/
public static function build_cache($ids)
{
if (!is_array($ids) OR !count($ids)) { return false; }
if (!is_array($ids) OR !count($ids)) {
return false;
}
$idlist = '(' . implode(',', $ids) . ')';
@ -89,10 +91,13 @@ class Tag extends database_object implements library_item
*/
public static function build_map_cache($type, $ids)
{
if (!is_array($ids) OR !count($ids)) { return false; }
if (!Core::is_library_item($type))
if (!is_array($ids) OR !count($ids)) {
return false;
}
if (!Core::is_library_item($type)) {
return false;
}
$idlist = '(' . implode(',',$ids) . ')';
@ -121,7 +126,6 @@ class Tag extends database_object implements library_item
}
return true;
} // build_map_cache
/**
@ -131,14 +135,19 @@ class Tag extends database_object implements library_item
*/
public static function add($type, $id, $value, $user=false)
{
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return false;
}
if (!is_numeric($id)) { return false; }
if (!is_numeric($id)) {
return false;
}
$cleaned_value = $value;
if (!strlen($cleaned_value)) { return false; }
if (!strlen($cleaned_value)) {
return false;
}
$uid = ($user === false) ? intval($user) : intval($GLOBALS['user']->id);
@ -158,7 +167,6 @@ class Tag extends database_object implements library_item
}
return $map_id;
} // add
/**
@ -167,7 +175,9 @@ class Tag extends database_object implements library_item
*/
public static function add_tag($value)
{
if (!strlen($value)) { return false; }
if (!strlen($value)) {
return false;
}
$sql = "REPLACE INTO `tag` SET `name` = ?";
Dba::write($sql, array($value));
@ -176,7 +186,6 @@ class Tag extends database_object implements library_item
parent::add_to_cache('tag_name', $value, $insert_id);
return $insert_id;
} // add_tag
/**
@ -186,7 +195,9 @@ class Tag extends database_object implements library_item
public function update(array $data)
{
//debug_event('tag.class', 'Updating tag {'.$this->id.'} with name {'.$name.'}...', '5');
if (!strlen($data['name'])) { return false; }
if (!strlen($data['name'])) {
return false;
}
$sql = 'UPDATE `tag` SET `name` = ? WHERE `id` = ?';
Dba::write($sql, array($data[name], $this->id));
@ -213,7 +224,6 @@ class Tag extends database_object implements library_item
}
}
return $this->id;
} // add_tag
/**
@ -273,11 +283,14 @@ class Tag extends database_object implements library_item
{
$uid = ($user == '') ? intval($GLOBALS['user']->id) : intval($user);
$tag_id = intval($tag_id);
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return false;
}
$id = intval($object_id);
if (!$tag_id || !$id) { return false; }
if (!$tag_id || !$id) {
return false;
}
// If tag merged to another one, add reference to the merge destination
$parent = new Tag($tag_id);
@ -295,7 +308,6 @@ class Tag extends database_object implements library_item
parent::add_to_cache('tag_map_' . $type,$insert_id,array('tag_id'=>$tag_id,'user'=>$uid,'object_type'=>$type,'object_id'=>$id));
return $insert_id;
} // add_tag_map
/**
@ -378,7 +390,6 @@ class Tag extends database_object implements library_item
parent::add_to_cache('tag_name',$results['name'],$results['id']);
return $results['id'];
} // tag_exists
/**
@ -388,8 +399,9 @@ class Tag extends database_object implements library_item
*/
public static function tag_map_exists($type,$object_id,$tag_id,$user)
{
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return false;
}
$sql = "SELECT * FROM `tag_map` LEFT JOIN `tag` ON `tag`.`id` = `tag_map`.`tag_id` LEFT JOIN `tag_merge` ON `tag`.`id`=`tag_merge`.`tag_id` " .
"WHERE (`tag_map`.`tag_id` = ? OR `tag_map`.`tag_id` = `tag_merge`.`merged_to`) AND `tag_map`.`user` = ? AND `tag_map`.`object_id` = ? AND `tag_map`.`object_type` = ?";
@ -398,7 +410,6 @@ class Tag extends database_object implements library_item
$results = Dba::fetch_assoc($db_results);
return $results['id'];
} // tag_map_exists
/**
@ -407,8 +418,9 @@ class Tag extends database_object implements library_item
*/
public static function get_top_tags($type, $object_id, $limit = 10)
{
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return array();
}
$object_id = intval($object_id);
@ -427,7 +439,6 @@ class Tag extends database_object implements library_item
}
return $results;
} // get_top_tags
/**
@ -437,8 +448,9 @@ class Tag extends database_object implements library_item
*/
public static function get_object_tags($type, $id)
{
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return false;
}
$sql = "SELECT `tag_map`.`id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " .
"LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " .
@ -460,13 +472,16 @@ class Tag extends database_object implements library_item
*/
public static function get_tag_objects($type,$tag_id,$count='',$offset='')
{
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return false;
}
$limit_sql = "";
if ($count) {
$limit_sql = "LIMIT ";
if ($offset) $limit_sql .= intval($offset) . ',';
if ($offset) {
$limit_sql .= intval($offset) . ',';
}
$limit_sql .= intval($count);
}
@ -526,7 +541,6 @@ class Tag extends database_object implements library_item
parent::add_to_cache('tags_list', 'no_name', $results);
return $results;
} // get_tags
/**
@ -538,7 +552,9 @@ class Tag extends database_object implements library_item
public static function get_display($tags, $link=false, $filter_type='')
{
//debug_event('tag.class.php', 'Get display tags called...', '5');
if (!is_array($tags)) { return ''; }
if (!is_array($tags)) {
return '';
}
$results = '';
@ -561,7 +577,6 @@ class Tag extends database_object implements library_item
$results = rtrim($results, ', ');
return $results;
} // get_display
/**
@ -592,13 +607,15 @@ class Tag extends database_object implements library_item
if ($found) {
debug_event('tag.class', 'Already found. Do nothing.', '5');
unset($editedTags[$tk]);
} else if ($overwrite) {
} else {
if ($overwrite) {
debug_event('tag.class', 'Not found in the new list. Delete it.', '5');
$ctag->remove_map($type, $object_id);
}
}
}
}
}
// Look if we need to add some new tags
foreach ($editedTags as $tk => $tv) {
@ -658,7 +675,6 @@ class Tag extends database_object implements library_item
}
return $results;
} // count
/**
@ -667,8 +683,9 @@ class Tag extends database_object implements library_item
*/
public function remove_map($type, $object_id)
{
if (!Core::is_library_item($type))
if (!Core::is_library_item($type)) {
return false;
}
// TODO: Review the tag edition per user.
@ -676,12 +693,10 @@ class Tag extends database_object implements library_item
Dba::write($sql, array($this->id, $type, $object_id));//, $GLOBALS['user']->id));
return true;
} // remove_map
public function format($details = true)
{
}
public function get_keywords()
@ -763,5 +778,5 @@ class Tag extends database_object implements library_item
Art::display('tag', $this->id, $this->get_fullname(), $thumb, $this->link);
}
}
} // end of Tag class

View file

@ -48,7 +48,9 @@ class Tmp_Playlist extends database_object
*/
public function __construct($playlist_id='')
{
if (!$playlist_id) { return false; }
if (!$playlist_id) {
return false;
}
$this->id = intval($playlist_id);
$info = $this->_get_info();
@ -58,7 +60,6 @@ class Tmp_Playlist extends database_object
}
return true;
} // __construct
/**
@ -74,7 +75,6 @@ class Tmp_Playlist extends database_object
$results = Dba::fetch_assoc($db_results);
return $results;
} // _get_info
/**
@ -102,7 +102,6 @@ class Tmp_Playlist extends database_object
$playlist = new Tmp_Playlist($results['0']);
return $playlist;
} // get_from_session
/**
@ -128,7 +127,6 @@ class Tmp_Playlist extends database_object
$data = Dba::fetch_assoc($db_results);
return $data['id'];
} // get_from_userid
/**
@ -157,7 +155,6 @@ class Tmp_Playlist extends database_object
}
return $items;
} // get_items
/**
@ -175,7 +172,6 @@ class Tmp_Playlist extends database_object
$results = Dba::fetch_assoc($db_results);
return $results['object_id'];
} // get_next_object
/**
@ -194,7 +190,6 @@ class Tmp_Playlist extends database_object
$results = Dba::fetch_row($db_results);
return $results['0'];
} // count_items
/**
@ -207,7 +202,6 @@ class Tmp_Playlist extends database_object
Dba::write($sql, array($this->id));
return true;
} // clear
/**
@ -229,7 +223,6 @@ class Tmp_Playlist extends database_object
self::session_clean($data['session_id'], $id);
return $id;
} // create
/**
@ -243,7 +236,6 @@ class Tmp_Playlist extends database_object
Dba::write($sql, array($playlist_id, $this->id));
return true;
} // update_playlist
/**
@ -260,7 +252,6 @@ class Tmp_Playlist extends database_object
self::prune_tracks();
return true;
} // session_clean
/**
@ -289,7 +280,6 @@ class Tmp_Playlist extends database_object
Dba::write($sql);
return true;
} // prune_playlists
/**
@ -305,7 +295,6 @@ class Tmp_Playlist extends database_object
"`tmp_playlist_data`.`tmp_playlist`=`tmp_playlist`.`id` " .
"WHERE `tmp_playlist`.`id` IS NULL";
Dba::write($sql);
} // prune_tracks
/**
@ -321,7 +310,6 @@ class Tmp_Playlist extends database_object
Dba::write($sql, array($object_id, $this->id, $object_type));
return true;
} // add_object
public function add_medias($medias)
@ -339,10 +327,11 @@ class Tmp_Playlist extends database_object
public function vote_active()
{
/* Going to do a little more here later */
if ($this->type == 'vote') { return true; }
if ($this->type == 'vote') {
return true;
}
return false;
} // vote_active
/**
@ -356,7 +345,6 @@ class Tmp_Playlist extends database_object
Dba::write($sql, array($id));
return true;
} // delete_track
} // class Tmp_Playlist

View file

@ -49,7 +49,9 @@ class TVShow extends database_object implements library_item
public function __construct($id='')
{
/* If they failed to pass in an id, just run for it */
if (!$id) { return false; }
if (!$id) {
return false;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -59,7 +61,6 @@ class TVShow extends database_object implements library_item
} // foreach info
return true;
} //constructor
/**
@ -87,7 +88,6 @@ class TVShow extends database_object implements library_item
$object = new TVShow($row['id']);
return $object;
} // get_from_name
/**
@ -105,7 +105,6 @@ class TVShow extends database_object implements library_item
}
return $results;
} // get_seasons
/**
@ -133,7 +132,6 @@ class TVShow extends database_object implements library_item
}
return $results;
} // get_episodes
/**
@ -168,7 +166,6 @@ class TVShow extends database_object implements library_item
$this->catalog_id = $row['catalog_id'];
return $row;
} // _get_extra_info
/**
@ -327,7 +324,6 @@ class TVShow extends database_object implements library_item
self::$_mapcache[$name]['null'] = $id;
return $id;
}
/**
@ -386,7 +382,6 @@ class TVShow extends database_object implements library_item
}
return $current_id;
} // update
/**
@ -436,5 +431,5 @@ class TVShow extends database_object implements library_item
return $deleted;
}
} // end of tvshow class

View file

@ -48,7 +48,6 @@ class TVShow_Episode extends Video
}
return true;
}
/**
@ -112,7 +111,6 @@ class TVShow_Episode extends Video
Dba::write($sql, array($data['id'], $data['original_name'], $data['tvshow_season'], $data['tvshow_episode'], $data['summary']));
return $data['id'];
}
/**
@ -137,7 +135,6 @@ class TVShow_Episode extends Video
$this->summary = $summary;
return $this->id;
}
/**
@ -208,8 +205,9 @@ class TVShow_Episode extends Video
public function get_description()
{
if (!empty($this->summary))
if (!empty($this->summary)) {
return $this->summary;
}
$season = new TVShow_Season($this->season);
return $season->get_description();
@ -223,7 +221,8 @@ class TVShow_Episode extends Video
if (Art::has_db($this->id, 'video')) {
$id = $this->id;
$type = 'video';
} else if (Art::has_db($this->season, 'tvshow_season')) {
} else {
if (Art::has_db($this->season, 'tvshow_season')) {
$id = $this->season;
$type = 'tvshow_season';
} else {
@ -233,6 +232,7 @@ class TVShow_Episode extends Video
$type = 'tvshow';
}
}
}
if ($id !== null && $type !== null) {
Art::display($type, $id, $this->get_fullname(), $thumb, $this->link);

View file

@ -46,7 +46,9 @@ class TVShow_Season extends database_object implements library_item
public function __construct($id='')
{
/* If they failed to pass in an id, just run for it */
if (!$id) { return false; }
if (!$id) {
return false;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -56,7 +58,6 @@ class TVShow_Season extends database_object implements library_item
} // foreach info
return true;
} //constructor
/**
@ -95,7 +96,6 @@ class TVShow_Season extends database_object implements library_item
}
return $results;
} // get_episodes
/**
@ -122,7 +122,6 @@ class TVShow_Season extends database_object implements library_item
$this->catalog_id = $row['catalog_id'];
return $row;
} // _get_extra_info
/**
@ -236,10 +235,12 @@ class TVShow_Season extends database_object implements library_item
if (Art::has_db($this->id, 'tvshow_season')) {
$id = $this->id;
$type = 'tvshow_season';
} else if (Art::has_db($this->tvshow, 'tvshow')) {
} else {
if (Art::has_db($this->tvshow, 'tvshow')) {
$id = $this->tvshow;
$type = 'tvshow';
}
}
if ($id !== null && $type !== null) {
Art::display($type, $id, $this->get_fullname(), $thumb, $this->link);
@ -298,7 +299,6 @@ class TVShow_Season extends database_object implements library_item
self::$_mapcache[$name]['null'] = $id;
return $id;
}
/**
@ -345,5 +345,5 @@ class TVShow_Season extends database_object implements library_item
$sql = "UPDATE `tvshow_season` SET `tvshow` = ? WHERE `id` = ?";
return Dba::write($sql, array($tvshow_id, $season_id));
}
} // end of tvshow_season class

View file

@ -79,7 +79,6 @@ class Update
}
return $version;
} // get_version
/**
@ -523,13 +522,16 @@ class Update
}
$update_needed = false;
if (!defined('CLI')) { echo "<ul>\n"; }
if (!defined('CLI')) {
echo "<ul>\n";
}
foreach (self::$versions as $update) {
if ($update['version'] > $current_version) {
$update_needed = true;
if (!defined('CLI')) { echo '<li><b>'; }
if (!defined('CLI')) {
echo '<li><b>';
}
echo 'Version: ', self::format_version($update['version']);
if (defined('CLI')) {
echo "\n", str_replace('<br />', "\n", $update['description']), "\n";
@ -537,13 +539,16 @@ class Update
echo '</b><br />', $update['description'], "<br /></li>\n";
}
} // if newer
} // foreach versions
if (!defined('CLI')) { echo "</ul>\n"; }
if (!defined('CLI')) {
echo "</ul>\n";
}
if (!$update_needed) {
if (!defined('CLI')) { echo '<p align="center">'; }
if (!defined('CLI')) {
echo '<p align="center">';
}
echo T_('No updates needed.');
if (!defined('CLI')) {
echo ' [<a href="', AmpConfig::get('web_path'), '">', T_('Return to main page'), '</a>]</p>';
@ -602,9 +607,7 @@ class Update
return false;
}
}
}
} // end foreach version
// Once we've run all of the updates let's re-sync the character set as

View file

@ -217,5 +217,5 @@ class Upload
return $rootdir;
}
} // Upload class

View file

@ -600,8 +600,9 @@ class Upnp_Api
break;
}
if ($maxCount == 0)
if ($maxCount == 0) {
$maxCount = count($mediaItems);
}
return array($maxCount, $mediaItems);
}
@ -840,8 +841,9 @@ class Upnp_Api
break;
}
if ($maxCount == 0)
if ($maxCount == 0) {
$maxCount = count($mediaItems);
}
return array($maxCount, $mediaItems);
}
@ -858,8 +860,9 @@ class Upnp_Api
$title = preg_replace('~[^\\pL\d\.\s\(\)\.\,\'\"]+~u', '-', $title);
///debug_event('upnp_class', 'replace >>> ' . $title, 5);
if ($title == "")
if ($title == "") {
$title = '(no title)';
}
return $title;
}

View file

@ -147,7 +147,9 @@ class User extends database_object
*/
public function __construct($user_id=0)
{
if (!$user_id) { return false; }
if (!$user_id) {
return false;
}
$this->id = intval($user_id);
@ -155,13 +157,16 @@ class User extends database_object
foreach ($info as $key=>$value) {
// Let's not save the password in this object :S
if ($key == 'password') { continue; }
if ($key == 'password') {
continue;
}
$this->$key = $value;
}
// Make sure the Full name is always filled
if (strlen($this->fullname) < 1) { $this->fullname = $this->username; }
if (strlen($this->fullname) < 1) {
$this->fullname = $this->username;
}
} // Constructor
/**
@ -217,7 +222,6 @@ class User extends database_object
parent::add_to_cache('user',$id,$data);
return $data;
} // _get_info
/**
@ -231,7 +235,6 @@ class User extends database_object
$session_id = session_id();
$this->playlist = Tmp_Playlist::get_from_session($session_id);
} // load_playlist
/**
@ -265,7 +268,6 @@ class User extends database_object
$user = new User($results['id']);
return $user;
} // get_from_username
/**
@ -288,7 +290,6 @@ class User extends database_object
}
return $user;
} // get_from_apikey
/**
@ -306,7 +307,6 @@ class User extends database_object
}
return $user;
} // get_from_email
/**
@ -323,7 +323,6 @@ class User extends database_object
$users[] = $results['id'];
}
return $users;
} // get_from_website
/**
@ -347,7 +346,6 @@ class User extends database_object
parent::add_to_cache('user_catalog',$this->id,$catalogs);
return $catalogs;
} // get_catalogs
/**
@ -367,9 +365,11 @@ class User extends database_object
$user_limit = "";
if (!$system) {
$user_limit = "AND preference.catagory != 'system'";
} else if ($type != '0') {
} else {
if ($type != '0') {
$user_limit = "AND preference.catagory = '" . Dba::escape($type) . "'";
}
}
$sql = "SELECT preference.name, preference.description, preference.catagory, preference.level, user_preference.value " .
@ -384,13 +384,14 @@ class User extends database_object
while ($r = Dba::fetch_assoc($db_results)) {
$type = $r['catagory'];
$admin = false;
if ($type == 'system') { $admin = true; }
if ($type == 'system') {
$admin = true;
}
$type_array[$type][$r['name']] = array('name'=>$r['name'],'level'=>$r['level'],'description'=>$r['description'],'value'=>$r['value']);
$results[$type] = array ('title'=>ucwords($type),'admin'=>$admin,'prefs'=>$type_array[$type]);
} // end while
return $results;
} // get_preferences
/**
@ -453,11 +454,9 @@ class User extends database_object
$data->f_name = $data->f_link;
$items[] = $data;
}
} // end foreach
return $items;
} // get_favorites
/**
@ -490,7 +489,6 @@ class User extends database_object
$key = $user_info['user'];
$users[$key]++;
}
} // end while
/* now we've got your ratings, and all users and the # of ratings that match your ratings
@ -510,20 +508,20 @@ class User extends database_object
while ($r = Dba::fetch_assoc($db_results)) {
$key = $r['object_id'];
if (isset($ratings[$key])) { continue; }
if (isset($ratings[$key])) {
continue;
}
/* Let's only get 5 total for now */
if (count($recommendations) > 5) { return $recommendations; }
if (count($recommendations) > 5) {
return $recommendations;
}
$recommendations[$key] = $r['user_rating'];
} // end while
} // end foreach users
return $recommendations;
} // get_recommendations
/**
@ -545,7 +543,6 @@ class User extends database_object
}
return false;
} // is_logged_in
/**
@ -555,12 +552,15 @@ class User extends database_object
*/
public function has_access($needed_level)
{
if (AmpConfig::get('demo_mode')) { return true; }
if (AmpConfig::get('demo_mode')) {
return true;
}
if ($this->access >= $needed_level) { return true; }
if ($this->access >= $needed_level) {
return true;
}
return false;
} // has_access
/**
@ -570,9 +570,13 @@ class User extends database_object
*/
public static function is_registered()
{
if (!$GLOBALS['user']->id) return false;
if (!$GLOBALS['user']->id) {
return false;
}
if (!AmpConfig::get('use_auth') && $GLOBALS['user']->access <= 5) return false;
if (!AmpConfig::get('use_auth') && $GLOBALS['user']->access <= 5) {
return false;
}
return true;
}
@ -644,7 +648,6 @@ class User extends database_object
$sql = "UPDATE `user` SET `username` = ? WHERE `id` = ?";
$this->username = $new_username;
Dba::write($sql, array($new_username, $this->id));
} // update_username
/**
@ -660,7 +663,6 @@ class User extends database_object
$this->validation = $new_validation;
return $db_results;
} // update_validation
/**
@ -671,7 +673,6 @@ class User extends database_object
{
$sql = "UPDATE `user` SET `fullname` = ? WHERE `id` = ?";
Dba::write($sql, array($new_fullname, $this->id));
} // update_fullname
/**
@ -682,7 +683,6 @@ class User extends database_object
{
$sql = "UPDATE `user` SET `fullname_public` = ? WHERE `id` = ?";
Dba::write($sql, array($new_fullname_public ? '1' : '0', $this->id));
} // update_fullname_public
/**
@ -693,7 +693,6 @@ class User extends database_object
{
$sql = "UPDATE `user` SET `email` = ? WHERE `id` = ?";
Dba::write($sql, array($new_email, $this->id));
} // update_email
/**
@ -705,7 +704,6 @@ class User extends database_object
$new_website = rtrim($new_website, "/");
$sql = "UPDATE `user` SET `website` = ? WHERE `id` = ?";
Dba::write($sql, array($new_website, $this->id));
} // update_website
/**
@ -736,7 +734,6 @@ class User extends database_object
{
$sql = "UPDATE `user` SET `apikey` = ? WHERE `id` = ?";
Dba::write($sql, array($new_apikey, $this->id));
} // update_website
/**
@ -772,7 +769,9 @@ class User extends database_object
$sql = "SELECT `id` FROM `user` WHERE `disabled` = '0' AND `id` != '" . $this->id . "' AND `access`='100'";
$db_results = Dba::read($sql);
if (!Dba::num_rows($db_results)) { return false; }
if (!Dba::num_rows($db_results)) {
return false;
}
$sql = "UPDATE `user` SET `disabled`='1' WHERE id='" . $this->id . "'";
Dba::write($sql);
@ -782,7 +781,6 @@ class User extends database_object
Dba::write($sql);
return true;
} // disable
/**
@ -795,7 +793,6 @@ class User extends database_object
Dba::write($sql);
return true;
} // enable
/**
@ -808,13 +805,14 @@ class User extends database_object
if ($new_access < '100') {
$sql = "SELECT `id` FROM user WHERE `access`='100' AND `id` != '$this->id'";
$db_results = Dba::read($sql);
if (!Dba::num_rows($db_results)) { return false; }
if (!Dba::num_rows($db_results)) {
return false;
}
}
$new_access = Dba::escape($new_access);
$sql = "UPDATE `user` SET `access`='$new_access' WHERE `id`='$this->id'";
Dba::write($sql);
} // update_access
/*!
@ -825,7 +823,6 @@ class User extends database_object
{
$sql = "UPDATE user SET last_seen='" . time() . "' WHERE `id`='$this->id'";
Dba::write($sql);
} // update_last_seen
/**
@ -840,7 +837,9 @@ class User extends database_object
$user = $this->id;
// We shouldn't test on file only
if (!strlen($media->file)) { return false; }
if (!strlen($media->file)) {
return false;
}
if (!$noscrobble) {
$this->set_preferences();
@ -863,7 +862,6 @@ class User extends database_object
$media->set_played($user, $agent, $location);
return true;
} // update_stats
public static function save_mediaplay($user, $media)
@ -911,7 +909,6 @@ class User extends database_object
}
return true;
} // insert_ip_history
/**
@ -957,7 +954,9 @@ class User extends database_object
$sql .= ")";
$db_results = Dba::write($sql, $params);
if (!$db_results) { return false; }
if (!$db_results) {
return false;
}
// Get the insert_id
$insert_id = Dba::insert_id();
@ -966,7 +965,6 @@ class User extends database_object
self::fix_preferences($insert_id);
return $insert_id;
} // create
/**
@ -982,8 +980,9 @@ class User extends database_object
$db_results = Dba::write($sql, array($new_password, $this->id));
// Clear this (temp fix)
if ($db_results) { unset($_SESSION['userdata']['password']); }
if ($db_results) {
unset($_SESSION['userdata']['password']);
}
} // update_password
/**
@ -995,10 +994,18 @@ class User extends database_object
public function format($details = true)
{
/* If they have a last seen date */
if (!$this->last_seen) { $this->f_last_seen = T_('Never'); } else { $this->f_last_seen = date("m\/d\/Y - H:i",$this->last_seen); }
if (!$this->last_seen) {
$this->f_last_seen = T_('Never');
} else {
$this->f_last_seen = date("m\/d\/Y - H:i",$this->last_seen);
}
/* If they have a create date */
if (!$this->create_date) { $this->f_create_date = T_('Unknown'); } else { $this->f_create_date = date("m\/d\/Y - H:i",$this->create_date); }
if (!$this->create_date) {
$this->f_create_date = T_('Unknown');
} else {
$this->f_create_date = date("m\/d\/Y - H:i",$this->create_date);
}
$this->f_name = ($this->fullname_public ? $this->fullname : $this->username);
@ -1037,7 +1044,6 @@ class User extends database_object
if (!empty($avatar['url_medium'])) {
$this->f_avatar_medium = '<img src="' . $avatar['url_medium'] . '" title="' . $avatar['title'] . '" style="width: 64px; height: 64px;" />';
}
} // format_user
/**
@ -1058,7 +1064,6 @@ class User extends database_object
default:
return '0';
}
} // access_name_to_level
/**
@ -1115,7 +1120,6 @@ class User extends database_object
$db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) {
$key = $r['id'];
/* Check if this preference is set */
@ -1128,7 +1132,6 @@ class User extends database_object
Dba::write($sql);
}
} // while preferences
} // fix_preferences
/**
@ -1212,7 +1215,6 @@ class User extends database_object
Dba::write($sql, array($this->username));
return true;
} // delete
/**
@ -1224,7 +1226,6 @@ class User extends database_object
public function is_online( $delay = 1200 )
{
return time() - $this->last_seen <= $delay;
} // is_online
/**
@ -1239,7 +1240,6 @@ class User extends database_object
$row = Dba::fetch_assoc($db_results);
return $row['validation'];
} // get_validation
/**
@ -1249,7 +1249,9 @@ class User extends database_object
*/
public function get_recently_played($limit,$type='')
{
if (!$type) { $type = 'song'; }
if (!$type) {
$type = 'song';
}
$sql = "SELECT * FROM `object_count` WHERE `object_type` = ? AND `user` = ? " .
"ORDER BY `date` DESC LIMIT " . $limit;
@ -1261,7 +1263,6 @@ class User extends database_object
}
return $results;
} // get_recently_played
/**
@ -1275,11 +1276,15 @@ class User extends database_object
$count = $count ? intval($count) : intval(AmpConfig::get('user_ip_cardinality'));
// Make sure it's something
if ($count < 1) { $count = '1'; }
if ($count < 1) {
$count = '1';
}
$limit_sql = "LIMIT " . intval($count);
$group_sql = "";
if ($distinct) { $group_sql = "GROUP BY `ip`"; }
if ($distinct) {
$group_sql = "GROUP BY `ip`";
}
/* Select ip history */
$sql = "SELECT `ip`,`date` FROM `ip_history`" .
@ -1294,7 +1299,6 @@ class User extends database_object
}
return $results;
} // get_ip_history
/**
@ -1364,7 +1368,6 @@ class User extends database_object
$sql = "UPDATE `user` SET `disabled`='0' WHERE `username` = ?";
Dba::write($sql, array($username));
} // activate_user
/**
@ -1399,7 +1402,6 @@ class User extends database_object
//FIXME: combined with the song title to make sure that the REFERER
//FIXME: is in the access list with full rights
return true;
} // is_xmlrpc
/**
@ -1467,8 +1469,9 @@ class User extends database_object
*/
public function toggle_follow($user_id)
{
if (!$user_id || $user_id === $this->id)
if (!$user_id || $user_id === $this->id) {
return false;
}
$params = array($this->id, $user_id);
if ($this->is_following($user_id)) {
@ -1493,8 +1496,9 @@ class User extends database_object
$user_id = $GLOBALS['user']->id;
}
if ($user_id === $this->id)
if ($user_id === $this->id) {
return "";
}
$followed = $this->is_followed_by($user_id);
@ -1521,7 +1525,6 @@ class User extends database_object
}
return true;
} // check_username
/**
@ -1547,7 +1550,6 @@ class User extends database_object
}
return true;
} // rebuild_all_preferences
/**
@ -1574,5 +1576,5 @@ class User extends database_object
return true;
}
} //end user class

View file

@ -43,7 +43,6 @@ class Userflag extends database_object
$this->type = $type;
return true;
} // Constructor
/**
@ -53,7 +52,9 @@ class Userflag extends database_object
*/
public static function build_cache($type, $ids, $user_id = null)
{
if (!is_array($ids) OR !count($ids)) { return false; }
if (!is_array($ids) OR !count($ids)) {
return false;
}
if (is_null($user_id)) {
$user_id = $GLOBALS['user']->id;
@ -81,7 +82,6 @@ class Userflag extends database_object
}
return true;
} // build_cache
/**
@ -129,7 +129,6 @@ class Userflag extends database_object
parent::add_to_cache($key, $this->id, $flagged);
return $flagged;
}
/**
@ -163,7 +162,6 @@ class Userflag extends database_object
parent::add_to_cache('userflag_' . $this->type . '_user' . $user_id, $this->id, $flagged);
return true;
} // set_flag
/**
@ -233,7 +231,6 @@ class Userflag extends database_object
}
return $results;
} // get_latest
/**
@ -244,11 +241,12 @@ class Userflag extends database_object
public static function show($object_id, $type)
{
// If user flags aren't enabled don't do anything
if (!AmpConfig::get('userflags')) { return false; }
if (!AmpConfig::get('userflags')) {
return false;
}
$userflag = new Userflag($object_id, $type);
require AmpConfig::get('prefix') . '/templates/show_object_userflag.inc.php';
} // show
} //end rating class

View file

@ -152,23 +152,27 @@ class vainfo
*/
private static function _detect_encoding($tags, $mb_order)
{
if (!function_exists('mb_detect_encoding'))
if (!function_exists('mb_detect_encoding')) {
return 'ISO-8859-1';
}
$encodings = array();
if (is_array($tags)) {
foreach ($tags as $tag) {
if (is_array($tag))
if (is_array($tag)) {
$tag = implode(" ", $tag);
}
$enc = mb_detect_encoding($tag, $mb_order, true);
if ($enc != false)
if ($enc != false) {
$encodings[$enc]++;
}
}
} else {
$enc = mb_detect_encoding($tags, $mb_order, true);
if ($enc != false)
if ($enc != false) {
$encodings[$enc]++;
}
}
//!!debug_event('vainfo', 'encoding detection: ' . json_encode($encodings), 5);
$high = 0;
@ -1248,3 +1252,4 @@ class vainfo
return $data;
}
} // end class vainfo

View file

@ -198,7 +198,6 @@ class Video extends database_object implements media, library_item
$this->type = strtolower($data['extension']);
return true;
} // Constructor
/**
@ -228,7 +227,9 @@ class Video extends database_object implements media, library_item
*/
public static function build_cache($ids=array())
{
if (!is_array($ids) OR !count($ids)) { return false; }
if (!is_array($ids) OR !count($ids)) {
return false;
}
$idlist = '(' . implode(',',$ids) . ')';
@ -238,7 +239,6 @@ class Video extends database_object implements media, library_item
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('video',$row['id'],$row);
}
} // build_cache
/**
@ -285,7 +285,6 @@ class Video extends database_object implements media, library_item
if ($this->release_date) {
$this->f_release_date = date('Y-m-d', $this->release_date);
}
} // format
/**
@ -474,9 +473,10 @@ class Video extends database_object implements media, library_item
{
$dtypes = self::get_derived_types();
foreach ($dtypes as $dtype) {
if (strtolower($type) == strtolower($dtype))
if (strtolower($type) == strtolower($dtype)) {
return $type;
}
}
return 'Video';
}
@ -631,7 +631,6 @@ class Video extends database_object implements media, library_item
$this->release_date = $release_date;
return $this->id;
} // update
/**
@ -715,7 +714,6 @@ class Video extends database_object implements media, library_item
Video::update_played(true, $this->id);
return true;
} // set_played
/**
@ -1001,7 +999,6 @@ 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');
} // update_played
/**
@ -1019,16 +1016,19 @@ class Video extends database_object implements media, library_item
private static function _update_item($field, $value, $song_id, $level)
{
/* Check them Rights! */
if (!Access::check('interface',$level)) { return false; }
if (!Access::check('interface',$level)) {
return false;
}
/* Can't update to blank */
if (!strlen(trim($value))) { return false; }
if (!strlen(trim($value))) {
return false;
}
$sql = "UPDATE `video` SET `$field` = ? WHERE `id` = ?";
Dba::write($sql, array($value, $song_id));
return true;
} // _update_item
} // end Video class

View file

@ -93,7 +93,9 @@ class Wanted extends database_object
*/
public function __construct($id=0)
{
if (!$id) { return true; }
if (!$id) {
return true;
}
/* Get the information from the db */
$info = $this->get_info($id);
@ -372,7 +374,6 @@ class Wanted extends database_object
}
return false;
}
/**
@ -467,10 +468,11 @@ class Wanted extends database_object
$plugin = new Plugin($plugin_name);
if ($plugin->load($GLOBALS['user'])) {
$song['file'] = $plugin->_plugin->get_song_preview($track['id'], $artist_name, $track['title']);
if ($song['file'] != null)
if ($song['file'] != null) {
break;
}
}
}
if ($song != null) {
$this->songs[] = new Song_Preview(Song_preview::insert($song));
@ -507,7 +509,6 @@ class Wanted extends database_object
$user = new User($this->user);
$user->format();
$this->f_user = $user->f_name;
}
/**
@ -541,5 +542,5 @@ class Wanted extends database_object
return $results;
}
} // end of recommendation class

View file

@ -62,7 +62,6 @@ class Waveform
{
// Static
return false;
} // Constructor
/**
@ -229,13 +228,15 @@ class Waveform
} else {
list($br, $bg, $bb) = self::html2rgb($background);
imagefilledrectangle($img, 0, 0, (int) ($data_size / $detail), $height, imagecolorallocate($img, $br, $bg, $bb));
} while (!feof($handle) && $data_point < $data_size) {
}
while (!feof($handle) && $data_point < $data_size) {
if ($data_point++ % $detail == 0) {
$bytes = array();
// get number of bytes depending on bitrate
for ($i = 0; $i < $byte; $i++)
for ($i = 0; $i < $byte; $i++) {
$bytes[$i] = fgetc($handle);
}
switch ($byte) {
// get value for 8-bit wav
@ -244,10 +245,11 @@ class Waveform
break;
// get value for 16-bit wav
case 2:
if(ord($bytes[1]) & 128)
if (ord($bytes[1]) & 128) {
$temp = 0;
else
} else {
$temp = 128;
}
$temp = chr((ord($bytes[1]) & 127) + $temp);
$data = floor(self::findValues($bytes[0], $temp) / 256);
break;
@ -265,7 +267,7 @@ class Waveform
$v = (int) ($data / 255 * $height);
// don't print flat values on the canvas if not necessary
if (!($v / $height == 0.5 && !$draw_flat))
if (!($v / $height == 0.5 && !$draw_flat)) {
// draw the line on the image using the $v value and centering it vertically on the canvas
imageline(
$img,
@ -279,7 +281,7 @@ class Waveform
$height - ($height - $v),
imagecolorallocate($img, $r, $g, $b)
);
}
} else {
// skip this one due to lack of detail
fseek($handle, $ratio + $byte, SEEK_CUR);
@ -322,5 +324,5 @@ class Waveform
$sql = "UPDATE `song_data` SET `waveform` = ? WHERE `song_id` = ?";
return Dba::write($sql, array($waveform, $song_id));
}
} // Waveform class

View file

@ -61,8 +61,9 @@ class WebDAV_Catalog extends DAV\Collection
debug_event('webdav', 'Found ' . count($matches) . ' childs.', 5);
// Always return first match
// Warning: this means that two items with the same name will not be supported for now
if (count($matches) > 0)
if (count($matches) > 0) {
return WebDAV_Directory::getChildFromArray($matches[0]);
}
throw new DAV\Exception\NotFound('The artist with name: ' . $name . ' could not be found');
}

View file

@ -69,10 +69,12 @@ class WebDAV_Directory extends DAV\Collection
$matches = $this->libitem->search_childrens($name);
// Always return first match
// Warning: this means that two items with the same name will not be supported for now
if (count($matches) > 0)
if (count($matches) > 0) {
return WebDAV_Directory::getChildFromArray($matches[0]);
}
throw new DAV\Exception\NotFound('The child with name: ' . $name . ' could not be found');;
throw new DAV\Exception\NotFound('The child with name: ' . $name . ' could not be found');
;
}
public static function getChildFromArray($array)

View file

@ -64,9 +64,11 @@ class WebPlayer
$urlinfo = Stream_URL::parse($item->url);
if ($urlinfo['id'] && Core::is_media($urlinfo['type'])) {
$media = new $urlinfo['type']($urlinfo['id']);
} else if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
} else {
if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
$media = new Song_Preview($urlinfo['id']);
} else if (isset($urlinfo['demo_id'])) {
} else {
if (isset($urlinfo['demo_id'])) {
$democratic = new Democratic($urlinfo['demo_id']);
if ($democratic->id) {
$song_id = $democratic->get_next_object();
@ -75,6 +77,8 @@ class WebPlayer
}
}
}
}
}
if ($media != null) {
$ftype = $media->type;
@ -114,22 +118,45 @@ class WebPlayer
}
if ($urlinfo['type'] == 'song') {
if ($types['real'] == "ogg" || $types['real'] == "opus") $types['player'] = "oga";
else if ($types['real'] == "mp4") $types['player'] = "m4a";
} else if ($urlinfo['type'] == 'video') {
if ($types['real'] == "ogg") $types['player'] = "ogv";
else if ($types['real'] == "webm") $types['player'] = "webmv";
else if ($types['real'] == "mp4") $types['player'] = "m4v";
if ($types['real'] == "ogg" || $types['real'] == "opus") {
$types['player'] = "oga";
} else {
if ($types['real'] == "mp4") {
$types['player'] = "m4a";
}
} else if ($item->type == 'live_stream') {
}
} else {
if ($urlinfo['type'] == 'video') {
if ($types['real'] == "ogg") {
$types['player'] = "ogv";
} else {
if ($types['real'] == "webm") {
$types['player'] = "webmv";
} else {
if ($types['real'] == "mp4") {
$types['player'] = "m4v";
}
}
}
}
}
} else {
if ($item->type == 'live_stream') {
$types['real'] = $item->codec;
if ($types['real'] == "ogg" || $types['real'] == "opus") $types['player'] = "oga";
if ($types['real'] == "ogg" || $types['real'] == "opus") {
$types['player'] = "oga";
}
} else {
$ext = pathinfo($item->url, PATHINFO_EXTENSION);
if (!empty($ext)) $types['real'] = $ext;
if (!empty($ext)) {
$types['real'] = $ext;
}
}
}
if (empty($types['player'])) $types['player'] = $types['real'];
if (empty($types['player'])) {
$types['player'] = $types['real'];
}
debug_event("webplayer.class.php", "Types {".json_encode($types)."}", 5);
return $types;
@ -209,10 +236,11 @@ class WebPlayer
{
$js = array();
foreach (array('title', 'author') as $member) {
if ($member == "author")
if ($member == "author") {
$kmember = "artist";
else
} else {
$kmember = $member;
}
$js[$kmember] = $item->$member;
}
@ -226,9 +254,11 @@ class WebPlayer
if ($urlinfo['id'] && Core::is_media($urlinfo['type'])) {
$media = new $urlinfo['type']($urlinfo['id']);
} else if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
} else {
if ($urlinfo['id'] && $urlinfo['type'] == 'song_preview') {
$media = new Song_Preview($urlinfo['id']);
} else if (isset($urlinfo['demo_id'])) {
} else {
if (isset($urlinfo['demo_id'])) {
$democratic = new Democratic($urlinfo['demo_id']);
if ($democratic->id) {
$song_id = $democratic->get_next_object();
@ -237,6 +267,8 @@ class WebPlayer
}
}
}
}
}
if ($media != null) {
$media->format();

View file

@ -845,3 +845,4 @@ class XML_Data
return $dom->saveXML($dom->documentElement);
}
} // XML_Data

View file

@ -119,7 +119,6 @@ function check_config_values($conf)
}
return true;
} // check_config_values
/**
@ -138,7 +137,6 @@ function check_php_memory()
}
return true;
} // check_php_memory
/**
@ -150,7 +148,6 @@ function check_php_timelimit()
{
$current = intval(ini_get('max_execution_time'));
return ($current >= 60 || $current == 0);
} // check_php_timelimit
/**

View file

@ -38,7 +38,6 @@ function set_memory_limit($new_limit)
if ($current_limit < $new_limit) {
ini_set (memory_limit, $new_limit);
}
} // set_memory_limit
/**
@ -64,7 +63,6 @@ function generate_password($length)
}
return $password;
} // generate_password
/**
@ -93,7 +91,6 @@ function scrub_in($input)
function scrub_out($string)
{
return htmlentities($string, ENT_QUOTES, AmpConfig::get('site_charset'));
} // scrub_out
/**
@ -103,7 +100,6 @@ function scrub_out($string)
function unhtmlentities($string)
{
return html_entity_decode($string, ENT_QUOTES, AmpConfig::get('site_charset'));
} //unhtmlentities
/**
@ -132,7 +128,6 @@ function make_bool($string)
}
return (bool) $string;
} // make_bool
/**
@ -142,7 +137,6 @@ function make_bool($string)
function invert_bool($value)
{
return make_bool($value) ? false : true;
} // invert_bool
/**
@ -164,12 +158,10 @@ function get_languages()
$results = array();
while (false !== ($file = readdir($handle))) {
$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') {
switch ($file) {
case 'af_ZA'; $name = 'Afrikaans'; break; /* Afrikaans */
case 'bg_BG'; $name = '&#x0411;&#x044a;&#x043b;&#x0433;&#x0430;&#x0440;&#x0441;&#x043a;&#x0438;'; break; /* Bulgarian */
@ -222,7 +214,6 @@ function get_languages()
$results[$file] = $name;
}
} // end while
// Sort the list of languages by country code
@ -232,7 +223,6 @@ function get_languages()
$results = array( "en_US" => "English (US)" ) + $results;
return $results;
} // get_languages
/**
@ -266,7 +256,6 @@ function translate_pattern_code($code)
}
return false;
} // translate_pattern_code
/**
@ -290,7 +279,6 @@ function generate_config($current)
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)) {
$key = $matches[1];
$value = $matches[2];
@ -344,12 +332,16 @@ if (!function_exists('apache_request_headers')) {
if (substr($name, 0, 5) == 'HTTP_') {
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
$headers[$name] = $value;
} else if ($name == "CONTENT_TYPE") {
} else {
if ($name == "CONTENT_TYPE") {
$headers["Content-Type"] = $value;
} else if ($name == "CONTENT_LENGTH") {
} else {
if ($name == "CONTENT_LENGTH") {
$headers["Content-Length"] = $value;
}
}
}
}
return $headers;
}

View file

@ -67,9 +67,11 @@ if ((isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PRO
if (isset($_SERVER['HTTP_X_FORWARDED_PORT'])) {
$http_port = $_SERVER['HTTP_X_FORWARDED_PORT'];
} else if (isset($_SERVER['SERVER_PORT'])) {
} else {
if (isset($_SERVER['SERVER_PORT'])) {
$http_port = $_SERVER['SERVER_PORT'];
}
}
if (!isset($http_port) || empty($http_port)) {
$http_port = 80;
}

View file

@ -206,7 +206,8 @@ if (!defined('NO_SESSION') && AmpConfig::get('use_auth')) {
$GLOBALS['user']->access = intval($auth['access']);
}
if (!$GLOBALS['user']->id AND !AmpConfig::get('demo_mode')) {
Auth::logout(session_id()); exit;
Auth::logout(session_id());
exit;
}
$GLOBALS['user']->update_last_seen();
}
@ -221,7 +222,6 @@ else {
} else {
$GLOBALS['user'] = new User();
}
} // If NO_SESSION passed
$GLOBALS['user']->format(false);

View file

@ -98,7 +98,6 @@ function install_check_status($configfile)
Error::add('general', T_('Existing Database detected, unable to continue installation'));
return false;
}
} // install_check_status
function install_check_server_apache()
@ -340,7 +339,6 @@ function install_create_account($username, $password, $password2)
User::fix_preferences('-1');
return true;
} // install_create_account
function command_exists($command)

View file

@ -53,7 +53,6 @@ function log_event($username, $event_name, $event_description, $log_name)
if (!$log_write) {
echo "Warning: Unable to write to log ($log_filename) Please check your log_path variable in ampache.cfg.php";
}
} // log_event
/*
@ -151,5 +150,5 @@ function debug_event($type, $message, $level, $file = '', $username = '')
foreach (explode("\n", $message) as $line) {
log_event($username, $type, $line, $file);
}
} // debug_event

View file

@ -187,10 +187,10 @@ if (isset($auth) && $auth['success'] && isset($user)) {
strpos($_POST['referrer'], 'update.php') === false &&
strpos($_POST['referrer'], 'activate.php') === false &&
strpos($_POST['referrer'], 'admin') === false ) {
header('Location: ' . $_POST['referrer']);
exit();
} // if we've got a referrer
header('Location: ' . AmpConfig::get('web_path') . '/index.php');
exit();
} // auth success

View file

@ -32,7 +32,9 @@ function update_preferences($pref_id=0)
$sql = "SELECT `id`,`name`,`type` FROM `preference`";
/* If it isn't the System Account's preferences */
if ($pref_id != '-1') { $sql .= " WHERE `catagory` != 'system'"; }
if ($pref_id != '-1') {
$sql .= " WHERE `catagory` != 'system'";
}
$db_results = Dba::read($sql);
@ -61,10 +63,14 @@ function update_preferences($pref_id=0)
}
if (preg_match('/_pass$/', $name)) {
if ($value == '******') { unset($_REQUEST[$name]); } else if (preg_match('/md5_pass$/', $name)) {
if ($value == '******') {
unset($_REQUEST[$name]);
} else {
if (preg_match('/md5_pass$/', $name)) {
$value = md5($value);
}
}
}
/* Run the update for this preference only if it's set */
if (isset($_REQUEST[$name])) {
@ -74,12 +80,10 @@ function update_preferences($pref_id=0)
if (Access::check('interface','100') && $_REQUEST[$new_level]) {
Preference::update_level($id,$_REQUEST[$new_level]);
}
} // end foreach preferences
// Now that we've done that we need to invalidate the cached preverences
Preference::clear_from_session();
} // update_preferences
/**
@ -110,7 +114,6 @@ function update_preference($user_id,$name,$pref_id,$value)
}
return false;
} // update_preference
/**
@ -199,7 +202,8 @@ function create_preference_input($name,$value)
$is_true = '';
$is_false = '';
if ($value == '1') {
$is_true = "selected=\"selected\""; } else {
$is_true = "selected=\"selected\"";
} else {
$is_false = "selected=\"selected\"";
}
echo "<select name=\"$name\">\n";
@ -264,9 +268,13 @@ function create_preference_input($name,$value)
echo "<select name=\"$name\">\n";
echo "\t<option value=\"\">" . T_('None') . "</option>\n";
foreach ($controllers as $controller) {
if (!Localplay::is_enabled($controller)) { continue; }
if (!Localplay::is_enabled($controller)) {
continue;
}
$is_selected = '';
if ($value == $controller) { $is_selected = 'selected="selected"'; }
if ($value == $controller) {
$is_selected = 'selected="selected"';
}
echo "\t<option value=\"" . $controller . "\" $is_selected>" . ucfirst($controller) . "</option>\n";
} // end foreach
echo "</select>\n";
@ -294,7 +302,9 @@ function create_preference_input($name,$value)
echo "<select name=\"$name\">\n";
foreach ($themes as $theme) {
$is_selected = "";
if ($value == $theme['path']) { $is_selected = "selected=\"selected\""; }
if ($value == $theme['path']) {
$is_selected = "selected=\"selected\"";
}
echo "\t<option value=\"" . $theme['path'] . "\" $is_selected>" . $theme['name'] . "</option>\n";
} // foreach themes
echo "</select>\n";
@ -364,5 +374,5 @@ function create_preference_input($name,$value)
break;
}
} // create_preference_input

View file

@ -29,7 +29,6 @@ function show_rating($object_id,$type)
$rating = new Rating($object_id,$type);
require AmpConfig::get('prefix') . '/templates/show_object_rating.inc.php';
} // show_rating
/**
@ -55,5 +54,5 @@ function get_rating_name($score)
default:
return T_("Off the Charts!");
} // end switch
} // get_rating_name

View file

@ -56,7 +56,6 @@ function get_themes()
ksort($results);
return $results;
} // get_themes
/*!
@ -66,13 +65,14 @@ function get_themes()
*/
function get_theme($name)
{
if (strlen($name) < 1) { return false; }
if (strlen($name) < 1) {
return false;
}
$config_file = AmpConfig::get('prefix') . "/themes/" . $name . "/theme.cfg.php";
$results = parse_ini_file($config_file);
$results['path'] = $name;
return $results;
} // get_theme
/*!
@ -85,7 +85,6 @@ function get_theme_author($theme_name)
$results = read_config($theme_path);
return $results['author'];
} // get_theme_author
/*!
@ -101,5 +100,5 @@ function theme_exists($theme_name)
}
return true;
} // theme_exists

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