1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

Remove old code and fix old php errors

This commit is contained in:
Afterster 2014-05-25 22:54:04 +02:00
parent 59d038335f
commit b16958f44e
92 changed files with 576 additions and 706 deletions

View file

@ -243,7 +243,6 @@ switch ($_REQUEST['action']) {
$body = '';
show_confirmation($title, $body, $url);
break;
default:
case 'show_catalogs':
require_once AmpConfig::get('prefix') . '/templates/show_manage_catalogs.inc.php';
break;

View file

@ -64,8 +64,6 @@ switch ($_REQUEST['action']) {
// We don't want the footer so we're done here
exit;
break;
default:
require_once AmpConfig::get('prefix') . '/templates/show_export.inc.php';
break;

View file

@ -42,7 +42,6 @@ switch ($_REQUEST['action']) {
$browser->downloadHeaders('ampache.cfg.php','text/plain',false,filesize(AmpConfig::get('prefix') . '/config/ampache.cfg.php.dist'));
echo $final;
exit;
break;
case 'reset_db_charset':
Dba::reset_db_charset();
show_confirmation(T_('Database Charset Updated'), T_('Your Database and associated tables have been updated to match your currently configured charset'), AmpConfig::get('web_path').'/admin/system.php?action=show_debug');

View file

@ -40,7 +40,7 @@ switch ($_REQUEST['action']) {
}
/* Clean up the variables */
$user_id = scrub_in($_POST['user_id']);
$user_id = intval($_POST['user_id']);
$username = scrub_in($_POST['username']);
$fullname = scrub_in($_POST['fullname']);
$email = scrub_in($_POST['email']);

View file

@ -108,7 +108,7 @@ switch ($_REQUEST['action']) {
$options['keyword'] = trim($artist . " " . $album_name);
// Attempt to find the art.
$images = $art->gather($options,'6');
$images = $art->gather($options);
if (!empty($_REQUEST['cover'])) {
$path_info = pathinfo($_REQUEST['cover']);

View file

@ -48,59 +48,6 @@ switch ($_REQUEST['action']) {
$target_url = AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $object_id;
require_once AmpConfig::get('prefix') . '/templates/show_update_items.inc.php';
break;
case 'rename':
//die if not enough permissions
if (!$user->has_access('100')) { UI::access_denied(); }
/* Get the artist */
$artist = new Artist($_REQUEST['artist']);
//check if we've been given a target
if ((isset($_POST['artist_id']) && $_POST['artist_id'] != $artist->id ) || (isset($_POST['artist_name']) && $_POST['artist_name'] != "")) {
//if we want to update id3 tags, then get the array of ids now, it's too late afterwards
if (make_bool($_POST['update_id3']))
$songs = $artist->get_songs();
$ret = 0;
$newname = "";
$newid = 0;
//the manual rename takes priority, but if they tested out the insert thing ignore
if ($_POST['artist_name'] != "" && $_POST['artist_name'] != $artist->name) {
//then just change the name of the artist in the db
$ret = $artist->rename($_POST['artist_name']);
$newid = $ret;
$newname = $_POST['artist_name'];
}
//new id?
elseif ($_POST['artist_id'] != $artist->id) {
//merge with other artist
$ret = $artist->merge($_POST['artist_id']);
$newid = $_POST['artist_id'];
$newname = $ret;
} // elseif different artist and id
//if no changes, no changes
// show something other than a blank screen after this
if ($ret) {
show_confirmation (
T_('Renamed artist'),
sprintf(T_('%1$s is now known as %2$s'), $artist->name, $newname),
AmpConfig::get('web_path') . "/artists.php?action=show&artist=" . $newid
);
}
} // if we've got the needed variables
/* Else we've got an error! But be lenient, and just show the form again */
else {
require AmpConfig::get('prefix') . '/templates/show_rename_artist.inc.php';
}
break;
case 'show_rename':
$artist = new Artist($_REQUEST['artist']);
require AmpConfig::get('prefix') . '/templates/show_rename_artist.inc.php';
break;
case 'match':
case 'Match':
$match = scrub_in($_REQUEST['match']);

View file

@ -101,6 +101,8 @@ switch ($_REQUEST['action']) {
// Take whatever we've got and send the zip
$song_files = get_song_files($media_ids);
set_memory_limit($song_files['1']+32);
send_zip($name,$song_files['0']);
if (is_array($song_files['0'])) {
set_memory_limit($song_files['1']+32);
send_zip($name,$song_files['0']);
}
exit;

View file

@ -33,8 +33,7 @@ switch ($_REQUEST['action']) {
$next_url = AmpConfig::get('web_path') . '/broadcast.php?action=delete&id=' . scrub_out($id);
show_confirmation(T_('Broadcast Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_broadcast');
UI::show_footer();
exit();
break;
exit;
case 'delete':
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
@ -49,8 +48,7 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Broadcast Deleted'), T_('The Broadcast has been deleted'), $next_url);
}
UI::show_footer();
exit();
break;
exit;
} // switch on the action
UI::show_footer();

View file

@ -38,8 +38,7 @@ switch ($_REQUEST['action']) {
}
}
UI::show_footer();
exit();
break;
exit;
case 'create':
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
@ -61,8 +60,7 @@ switch ($_REQUEST['action']) {
show_confirmation($title, $body, AmpConfig::get('web_path') . '/browse.php?action=channel');
}
UI::show_footer();
exit();
break;
exit;
case 'show_delete':
UI::show_header();
$id = $_REQUEST['id'];
@ -70,8 +68,7 @@ switch ($_REQUEST['action']) {
$next_url = AmpConfig::get('web_path') . '/channel.php?action=delete&id=' . scrub_out($id);
show_confirmation(T_('Channel Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_channel');
UI::show_footer();
exit();
break;
exit;
case 'delete':
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
@ -86,8 +83,7 @@ switch ($_REQUEST['action']) {
show_confirmation(T_('Channel Deleted'), T_('The Channel has been deleted'), $next_url);
}
UI::show_footer();
exit();
break;
exit;
} // switch on the action
UI::show_footer();

View file

@ -99,11 +99,17 @@ curl_setopt_array($ch, array(
curl_exec($ch);
curl_close($ch);
/**
* @SuppressWarnings("unused")
*/
function progress($totaldownload, $downloaded, $us, $ud)
{
ob_flush();
}
/**
* @SuppressWarnings("unused")
*/
function output_header($ch, $header)
{
$th = trim($header);

View file

@ -145,7 +145,7 @@ class Access
$sql = 'UPDATE `access_list` SET `start` = ?, `end` = ?, `level` = ?, ' .
'`user` = ?, `name` = ?, `type` = ?, `enabled` = ? WHERE `id` = ?';
$db_results = Dba::write($sql,
Dba::write($sql,
array($start, $end, $level, $user, $name, $type, $enabled, $this->id));
return true;
@ -180,7 +180,7 @@ class Access
$sql = 'INSERT INTO `access_list` (`name`, `level`, `start`, `end`, ' .
'`user`,`type`,`enabled`) VALUES (?, ?, ?, ?, ?, ?, ?)';
$db_results = Dba::write($sql, array($name, $level, $start, $end, $user, $type, $enabled));
Dba::write($sql, array($name, $level, $start, $end, $user, $type, $enabled));
return true;
@ -230,7 +230,6 @@ class Access
switch ($type) {
case 'download':
return AmpConfig::get('download');
break ;
case 'batch_download':
if (!function_exists('gzcompress')) {
debug_event('access', 'ZLIB extension not loaded, batch download disabled', 3);
@ -242,7 +241,6 @@ class Access
break;
default:
return false;
break;
}
}
@ -259,7 +257,6 @@ class Access
case 'interface':
case 'stream':
return true;
break;
default:
return false;
}
@ -283,7 +280,6 @@ class Access
break;
default:
return false;
break;
} // end switch on type
$sql = 'SELECT `id` FROM `access_list` ' .
@ -333,24 +329,13 @@ class Access
switch ($type) {
case 'localplay':
// Check their localplay_level
if (AmpConfig::get('localplay_level') >= $level
|| $GLOBALS['user']->access >= 100) {
return true;
} else {
return false;
}
break;
return (AmpConfig::get('localplay_level') >= $level
|| $GLOBALS['user']->access >= 100);
case 'interface':
// Check their standard user level
if ($GLOBALS['user']->access >= $level) {
return true;
} else {
return false;
}
break;
return ($GLOBALS['user']->access >= $level);
default:
return false;
break;
}
return false;
@ -369,10 +354,8 @@ class Access
case 'interface':
case 'network':
return $type;
break;
default:
return 'stream';
break;
}
}
@ -439,17 +422,13 @@ class Access
switch ($this->type) {
case 'rpc':
return T_('API/RPC');
break;
case 'network':
return T_('Local Network Definition');
break;
case 'interface':
return T_('Web Interface');
break;
case 'stream':
default:
return T_('Stream Access');
break;
}
}
}

View file

@ -38,6 +38,7 @@ class Album extends database_object
public $prefix;
public $mbid; // MusicBrainz ID
public $song_count;
public $artist_prefix;
public $artist_name;
public $artist_id;
@ -52,6 +53,7 @@ class Album extends database_object
public $f_link_src;
public $f_link;
public $f_tags;
public $f_title;
// cached information
public $_fake;
@ -445,7 +447,7 @@ class Album extends database_object
}
$this->tags = Tag::get_top_tags('album', $this->id);
$this->f_tags = Tag::get_display($this->tags, $this->id, 'album');
$this->f_tags = Tag::get_display($this->tags);
} // format
@ -490,7 +492,7 @@ class Album extends database_object
$current_id = $this->id;
$updated = 0;
$updated = false;
$songs = null;
if ($artist != $this->artist_id AND $artist) {
// Update every song
@ -498,7 +500,7 @@ class Album extends database_object
foreach ($songs as $song_id) {
Song::update_artist($artist,$song_id);
}
$updated = 1;
$updated = true;
Artist::gc();
}
@ -510,11 +512,11 @@ class Album extends database_object
Song::update_year($year,$song_id);
}
$current_id = $album_id;
$updated = 1;
$updated = true;
self::gc();
}
if ($updated) {
if ($updated && is_array($songs)) {
foreach ($songs as $song_id) {
Song::update_utime($song_id);
} // foreach song of album

View file

@ -35,7 +35,6 @@
*/
class AmpConfig
{
private $_local = array();
private static $_global = array();
public function __construct()

View file

@ -135,10 +135,8 @@ class Art extends database_object
case 'video':
case 'user':
return $type;
break;
default:
return 'album';
break;
}
} // validate_type
@ -278,7 +276,7 @@ class Art extends database_object
// Insert it!
$sql = "INSERT INTO `image` (`image`, `mime`, `size`, `object_type`, `object_id`) VALUES('$image', '$mime', 'original', '$type', '$uid')";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -291,8 +289,7 @@ class Art extends database_object
public function reset()
{
$sql = "DELETE FROM `image` WHERE `object_id` = ? AND `object_type` = ?";
$db_results = Dba::write($sql, array($this->uid, $this->type));
Dba::write($sql, array($this->uid, $this->type));
} // reset
/**
@ -317,8 +314,7 @@ class Art extends database_object
$db_results = Dba::write($sql);
$sql = "INSERT INTO `image` (`image`, `mime`, `size`, `object_type`, `object_id`) VALUES('$source', '$mime', '$size', '$type', '$uid')";
$db_results = Dba::write($sql);
Dba::write($sql);
} // save_thumb
/**
@ -424,13 +420,17 @@ class Art extends database_object
break;
// Turn bmps into pngs
case 'bmp':
$type = 'png';
case 'png':
imagepng($thumbnail);
$mime_type = image_type_to_mime_type(IMAGETYPE_PNG);
break;
} // resized
if (!isset($mime_type)) {
debug_event('Art', 'Eror: No mime type found.', 1);
return false;
}
$data = ob_get_contents();
ob_end_clean();
@ -533,13 +533,9 @@ class Art extends database_object
$row = parent::get_from_cache('art', $key . 'original');
$thumb_mime = $row['mime'];
}
if (!$mime && !$thumb_mime) {
$type = Dba::escape($type);
$uid = Dba::escape($uid);
$sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_type`='$type' AND `object_id`='$uid'";
$db_results = Dba::read($sql);
if (!isset($mime) && !isset($thumb_mime)) {
$sql = "SELECT `object_type`, `object_id`, `mime`, `size` FROM `image` WHERE `object_type` = ? AND `object_id` = ?";
$db_results = Dba::read($sql, array($type, $uid));
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('art', $key . $row['size'], $row);
@ -551,7 +547,7 @@ class Art extends database_object
}
}
$mime = $thumb_mime ? $thumb_mime : $mime;
$mime = isset($thumb_mime) ? $thumb_mime : $mime;
$extension = self::extension($mime);
$name = 'art.' . $extension;
@ -573,7 +569,7 @@ class Art extends database_object
$type . "` ON `" . $type . "`.`id`=" .
"`image`.`object_id` WHERE `object_type`='" .
$type . "' AND `" . $type . "`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
} // foreach
}
@ -591,9 +587,8 @@ class Art extends database_object
$allowed_methods = array('db','lastfm','folder','amazon','google','musicbrainz','tags');
break;
case 'artist':
$allowed_methods = array();
break;
case 'video':
default:
$allowed_methods = array();
break;
}
@ -614,8 +609,6 @@ class Art extends database_object
foreach ($config as $method) {
$data = array();
if (!in_array($method, $allowed_methods)) {
debug_event('Art', "$method not in allowed_methods, skipping", 3);
continue;
@ -844,13 +837,19 @@ class Art extends database_object
'SmallImage'
);
if ($this->type == 'album') {
$album = new Album($this->uid);
} else {
return $images;
}
// Prevent the script from timing out
set_time_limit(0);
if (empty($keywords)) {
$keywords = $this->full_name;
$keywords = $album->full_name;
/* If this isn't a various album combine with artist name */
if ($this->artist_count == '1') { $keywords .= ' ' . $this->artist_name; }
if ($album->artist_count == '1') { $keywords .= ' ' . $album->artist_name; }
}
/* Attempt to retrieve the album art order */
@ -879,11 +878,9 @@ class Art extends database_object
/* Set up the needed variables */
$max_pages_to_search = max(AmpConfig::get('max_amazon_results_pages'),$amazon->_default_results_pages);
$pages_to_search = $max_pages_to_search; //init to max until we know better.
// while we have pages to search
do {
$raw_results = $amazon->search(array('artist'=>$artist,'album'=>$albumname,'keywords'=>$keywords));
$raw_results = $amazon->search(array('artist'=>'', 'album'=>'', 'keywords'=>$keywords));
$total = count($raw_results) + count($search_results);
// If we've gotten more then we wanted
@ -922,9 +919,11 @@ class Art extends database_object
/* Foreach through what we've found */
foreach ($final_results as $result) {
$key = '';
/* Recurse through the images found */
foreach ($possible_keys as $key) {
if (strlen($result[$key])) {
foreach ($possible_keys as $k) {
if (strlen($result[$k])) {
$key = $k;
break;
}
} // foreach
@ -941,6 +940,7 @@ class Art extends database_object
continue;
}
$data = array();
$data['url'] = $result[$key];
$data['mime'] = $mime;
@ -987,7 +987,6 @@ class Art extends database_object
);
foreach ($songs as $song_id) {
$data = array();
$song = new Song($song_id);
$dir = dirname($song->file);
@ -1165,6 +1164,7 @@ class Art extends database_object
*/
public function gather_lastfm($limit, $options = false)
{
$data = array();
// Create the parser object
$lastfm = new LastFMSearch();
@ -1180,6 +1180,9 @@ class Art extends database_object
$album = $media->full_name;
}
break;
default:
return $data;
break;
}
if (AmpConfig::get('proxy_host') AND AmpConfig::get('proxy_port')) {

View file

@ -36,6 +36,8 @@ class Artist extends database_object
public $catalog_id;
public $time;
public $tags;
public $f_tags;
public $object_cnt;
public $f_name;
public $f_full_name;
@ -330,7 +332,7 @@ class Artist extends database_object
$this->f_time = ltrim($hours . ':' . $min . ':' . $sec,'0:');
$this->tags = Tag::get_top_tags('artist', $this->id);
$this->f_tags = Tag::get_display($this->tags, $this->id, 'artist');
$this->f_tags = Tag::get_display($this->tags);
$this->object_cnt = $extra_info['object_cnt'];

View file

@ -84,6 +84,7 @@ class Auth
*/
public static function login($username, $password, $allow_ui = false)
{
$results = array();
foreach (AmpConfig::get('auth_methods') as $method) {
$function_name = $method . '_auth';

View file

@ -112,7 +112,7 @@ class Broadcast extends database_object
$this->f_name = $this->name;
$this->f_link = '<a href="' . AmpConfig::get('web_path') . '/broadcast.php?id=' . $this->id . '">' . scrub_out($this->f_name) . '</a>';
$this->tags = Tag::get_top_tags('broadcast', $this->id);
$this->f_tags = Tag::get_display($this->tags, $this->id, 'broadcast');
$this->f_tags = Tag::get_display($this->tags);
}
public static function get_broadcast_list_sql()

View file

@ -243,12 +243,12 @@ class Browse extends Query
}
}
if ($box_req) {
if (isset($box_req)) {
require $box_req;
}
if ($this->get_show_header()) {
if ($box_req) {
if (isset($box_req)) {
UI::show_box_bottom();
}
echo '<script type="text/javascript">';

View file

@ -76,10 +76,10 @@ abstract class Catalog extends database_object
public function uninstall()
{
$sql = "DELETE FROM `catalog` WHERE `catalog_type` = ?";
$db_results = Dba::query($sql, array($this->get_type()));
Dba::query($sql, array($this->get_type()));
$sql = "DROP TABLE `catalog_" . $this->get_type() ."`";
$db_results = Dba::query($sql);
Dba::query($sql);
return true;
@ -319,7 +319,7 @@ abstract class Catalog extends database_object
$value = Dba::escape($value);
$sql = "UPDATE `catalog` SET `$field`='$value' WHERE `id`='$catalog_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -418,7 +418,7 @@ abstract class Catalog extends database_object
if ($include) {
$sql = 'INSERT INTO `catalog` (`name`, `catalog_type`, ' .
'`rename_pattern`, `sort_pattern`) VALUES (?, ?, ?, ?)';
$db_results = Dba::write($sql, array(
Dba::write($sql, array(
$name,
$type,
$rename_pattern,
@ -466,7 +466,7 @@ abstract class Catalog extends database_object
*
* This returns the current number of unique tags in the database.
*/
public static function count_tags($id = null)
public static function count_tags()
{
// FIXME: Ignores catalog_id
$sql = "SELECT COUNT(`id`) FROM `tag`";
@ -573,6 +573,7 @@ abstract class Catalog extends database_object
$sql_where = "WHERE `song`.`catalog` IN $catlist";
}
$sql_limit = "";
if ($offset > 0 && $size > 0) {
$sql_limit = "LIMIT $offset, $size";
} else if ($size > 0) {
@ -601,11 +602,13 @@ abstract class Catalog extends database_object
*/
public static function get_albums_by_artist($size = 0, $offset = 0, $catalogs = null)
{
$sql_where = "";
if (is_array($catalogs) && count($catalogs)) {
$catlist = '(' . implode(',', $catalogs) . ')';
$sql_where = "WHERE `song`.`catalog` IN $catlist";
}
$sql_limit = "";
if ($offset > 0 && $size > 0) {
$sql_limit = "LIMIT $offset, $size";
} else if ($size > 0) {
@ -620,7 +623,7 @@ abstract class Catalog extends database_object
"LEFT JOIN `artist` ON `artist`.`id` = `song`.`artist` $sql_where GROUP BY `song`.`album` ORDER BY `artist`.`name`, `artist`.`id`, `album`.`name` $sql_limit";
$db_results = Dba::read($sql);
$results = array();
while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id'];
}
@ -771,8 +774,8 @@ abstract class Catalog extends database_object
$meta_file = $dir . '/desktop.ini';
$string = "[.ShellClassInfo]\nIconFile=$file\nIconIndex=0\nInfoTip=$album->full_name";
break;
default:
case 'linux':
default:
$meta_file = $dir . '/.directory';
$string = "Name=$album->full_name\nIcon=$file";
break;
@ -819,7 +822,7 @@ abstract class Catalog extends database_object
{
$date = time();
$sql = "UPDATE `catalog` SET `last_add` = ? WHERE `id` = ?";
$db_results = Dba::write($sql, array($date, $this->id));
Dba::write($sql, array($date, $this->id));
} // update_last_add
@ -831,7 +834,7 @@ abstract class Catalog extends database_object
{
$date = time();
$sql = "UPDATE `catalog` SET `last_clean` = ? WHERE `id` = ?";
$db_results = Dba::write($sql, array($date, $this->id));
Dba::write($sql, array($date, $this->id));
} // update_last_clean
@ -843,7 +846,7 @@ abstract class Catalog extends database_object
{
$sql = "UPDATE `catalog` SET `name` = ?, `rename_pattern` = ?, `sort_pattern` = ? WHERE `id` = ?";
$params = array($data['name'], $data['rename_pattern'], $data['sort_pattern'], $data['catalog_id']);
$db_results = Dba::write($sql, $params);
Dba::write($sql, $params);
return true;
@ -1008,7 +1011,7 @@ abstract class Catalog extends database_object
debug_event('update', "$song->file : differences found, updating database", 5);
$song->update_song($song->id,$new_song);
// Refine our reference
$song = $new_song;
//$song = $new_song;
} else {
debug_event('update', "$song->file : no differences found", 5);
}
@ -1183,7 +1186,6 @@ abstract class Catalog extends database_object
$songs[] = $results['id'];
} else {
// Not found in absolute path, create it from relative path
$finfo = pathinfo($file);
$file = $pinfo['dirname'] . DIRECTORY_SEPARATOR . $file;
// Normalize the file path. realpath requires the files to exists.
$file = realpath($file);
@ -1344,7 +1346,7 @@ abstract class Catalog extends database_object
// Next Remove the Catalog Entry it's self
$sql = "DELETE FROM `catalog` WHERE `id` = ?";
$db_results = Dba::write($sql, array($catalog_id));
Dba::write($sql, array($catalog_id));
// Run the cleaners...
self::gc();

View file

@ -28,6 +28,7 @@ class Channel extends database_object
public $port;
public $start_date;
public $pid;
public $listeners;
public $peak_listeners;
public $object_type;
public $object_id;
@ -180,7 +181,7 @@ class Channel extends database_object
public function format()
{
$this->tags = Tag::get_top_tags('channel', $this->id);
$this->f_tags = Tag::get_display($this->tags, $this->id, 'channel');
$this->f_tags = Tag::get_display($this->tags);
}
public function get_target_object()
@ -260,8 +261,6 @@ class Channel extends database_object
public function get_channel_state()
{
$state = T_("Unknown");
if ($this->check_channel()) {
$state = T_("Running");
} else {
@ -359,7 +358,7 @@ class Channel extends database_object
if (feof($this->transcoder['handle'])) {
$this->media->set_played();
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
$stderr = fread($this->transcoder['stderr'], 4096);
fread($this->transcoder['stderr'], 4096);
fclose($this->transcoder['stderr']);
}
fclose($this->transcoder['handle']);

View file

@ -100,8 +100,8 @@ class Core
debug_event('Core', "Registered $type form $name with SID $sid and expiration $expire ($window seconds from now)", 5);
switch ($type) {
default:
case 'post':
default:
$string = '<input type="hidden" name="form_validation" value="' . $sid . '" />';
break;
case 'get':

View file

@ -40,7 +40,6 @@ class Dba
private static $_sql;
private static $_error;
private static $config;
/**
* constructor
@ -93,12 +92,10 @@ class Dba
if (!$stmt) {
self::$_error = json_encode($dbh->errorInfo());
debug_event('Dba', 'Error: ' . json_encode($dbh->errorInfo()), 1);
$dbh = null;
self::disconnect();
} else if ($stmt->errorCode() && $stmt->errorCode() != '00000') {
self::$_error = json_encode($stmt->errorInfo());
debug_event('Dba', 'Error: ' . json_encode($stmt->errorInfo()), 1);
$dbh = null;
self::disconnect();
return false;
}
@ -458,8 +455,8 @@ class Dba
$target_charset = 'koi8r';
$target_collation = 'koi8r_general_ci';
break;
default;
case 'UTF-8':
default:
$target_charset = 'utf8';
$target_collation = 'utf8_unicode_ci';
break;
@ -487,7 +484,7 @@ class Dba
// Alter the charset for the entire database
$sql = "ALTER DATABASE `" . AmpConfig::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "SHOW TABLES";
$db_results = Dba::read($sql);
@ -499,7 +496,7 @@ class Dba
// Change the tables default charset and colliation
$sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation";
$alter_table = Dba::write($sql);
Dba::write($sql);
// Iterate through the columns of the table
while ($table = Dba::fetch_assoc($describe_results)) {
@ -533,10 +530,10 @@ class Dba
while ($row = Dba::fetch_row($db_results)) {
$sql = "OPTIMIZE TABLE `" . $row[0] . "`";
$db_results_inner = Dba::write($sql);
Dba::write($sql);
$sql = "ANALYZE TABLE `" . $row[0] . "`";
$db_results_inner = Dba::write($sql);
Dba::write($sql);
}
}
}

View file

@ -299,8 +299,6 @@ class Democratic extends Tmp_Playlist
return $results['id'];
}
return null;
} // get_next_object
/**
@ -411,7 +409,7 @@ class Democratic extends Tmp_Playlist
if (!$results = Dba::fetch_assoc($db_results)) {
$sql = "INSERT INTO `tmp_playlist_data` (`tmp_playlist`,`object_id`,`object_type`,`track`) " .
"VALUES ('$tmp_playlist','$object_id','$object_type',$track)";
$db_results = Dba::write($sql);
Dba::write($sql);
$results['id'] = Dba::insert_id();
}
@ -419,7 +417,7 @@ class Democratic extends Tmp_Playlist
$time = time();
$sql = "INSERT INTO user_vote (`user`,`object_id`,`date`) " .
"VALUES ('" . Dba::escape($GLOBALS['user']->id) . "','" . $results['id'] . "','$time')";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
}
@ -436,7 +434,7 @@ class Democratic extends Tmp_Playlist
$user_id = Dba::escape($GLOBALS['user']->id);
$sql = "DELETE FROM `user_vote` WHERE `object_id`='$object_id' AND `user`='$user_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
/* Clean up anything that has no votes */
self::prune_tracks();
@ -454,10 +452,10 @@ class Democratic extends Tmp_Playlist
$row_id = Dba::escape($row_id);
$sql = "DELETE FROM `user_vote` WHERE `object_id`='$row_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "DELETE FROM `tmp_playlist_data` WHERE `id`='$row_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -488,10 +486,10 @@ class Democratic extends Tmp_Playlist
$democratic_id = Dba::escape($democratic_id);
$sql = "DELETE FROM `democratic` WHERE `id`='$democratic_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "DELETE FROM `tmp_playlist` WHERE `session`='$democratic_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
self::prune_tracks();
@ -513,7 +511,7 @@ class Democratic extends Tmp_Playlist
$id = Dba::escape($this->id);
$sql = "UPDATE `democratic` SET `name` = ?, `base_playlist` = ?,`cooldown` = ?, `primary` = ?, `level` = ? WHERE `id` = ?";
$db_results = Dba::write($sql, array($name, $base, $cool, $default, $level, $id));
Dba::write($sql, array($name, $base, $cool, $default, $level, $id));
return true;
@ -562,7 +560,7 @@ class Democratic extends Tmp_Playlist
"LEFT JOIN `user_vote` ON `tmp_playlist_data`.`id`=`user_vote`.`object_id` " .
"LEFT JOIN `tmp_playlist` ON `tmp_playlist`.`id`=`tmp_playlist_data`.`tmp_playlist` " .
"WHERE `user_vote`.`object_id` IS NULL AND `tmp_playlist`.`type` = 'vote'";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -581,7 +579,7 @@ class Democratic extends Tmp_Playlist
$sql = "DELETE FROM `user_vote` USING `user_vote` " .
"LEFT JOIN `tmp_playlist_data` ON `user_vote`.`object_id` = `tmp_playlist_data`.`id` " .
"WHERE `tmp_playlist_data`.`tmp_playlist`='$tmp_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Prune!
self::prune_tracks();
@ -602,7 +600,7 @@ class Democratic extends Tmp_Playlist
$sql = "DELETE FROM `user_vote` USING `user_vote` " .
"LEFT JOIN `tmp_playlist_data` ON `user_vote`.`object_id`=`tmp_playlist_data`.`id` " .
"WHERE `tmp_playlist_data`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;

View file

@ -25,9 +25,11 @@ class Localplay
/* Base Variables */
public $type;
public $f_name;
public $f_description;
public $f_version;
/* Built Variables */
private $_template;
private $_preferences = array();
private $_player;
/**
@ -625,16 +627,12 @@ class Localplay
switch ($state) {
case 'play':
return T_('Now Playing');
break;
case 'stop':
return T_('Stopped');
break;
case 'pause':
return T_('Paused');
break;
default:
return T_('Unknown');
break;
} // switch on state
} // get_user_state

View file

@ -92,6 +92,7 @@ abstract class localplay_controller
$data = array();
$variables = parse_url($url,PHP_URL_QUERY);
if ($variables) {
parse_str($variables,$data);
foreach ($primary_array as $pkey) {
@ -101,6 +102,7 @@ abstract class localplay_controller
}
} // end foreach
}
return $data;

View file

@ -92,8 +92,8 @@ class Mailer
public static function get_users($filter)
{
switch ($filter) {
default:
case 'all':
default:
$sql = "SELECT * FROM `user` WHERE `email` IS NOT NULL";
break;
case 'users':
@ -120,15 +120,6 @@ class Mailer
} // get_users
/**
* add_statistics
* This should be run if we want to add some statistics to this e-mail,
* appends to self::$message
*/
public function add_statistics($methods)
{
} // add_statistics
/**
* send
* This actually sends the mail, how amazing

View file

@ -43,7 +43,7 @@ class Openid
if (strpos(PHP_OS, 'WIN') === 0) {
$store_path = $_ENV['TMP'];
if (!isset($store_path)) {
$dir = 'C:\Windows\Temp';
$store_path = 'C:\Windows\Temp';
}
} else {
$store_path = @$_ENV['TMPDIR'];
@ -67,6 +67,7 @@ class Openid
public static function get_consumer()
{
$consumer = null;
$store = self::get_store();
if ($store) {
$consumer = new Auth_OpenID_Consumer($store);
@ -76,7 +77,7 @@ class Openid
public static function get_return_url()
{
return $return_to = AmpConfig::get('web_path') . '/login.php?auth_mod=openid&step=2';
return AmpConfig::get('web_path') . '/login.php?auth_mod=openid&step=2';
}
public static function get_policies()

View file

@ -33,6 +33,9 @@ class Playlist extends playlist_object
public $genre;
public $date;
public $f_link;
public $f_name_link;
/* Generated Elements */
public $items = array();
@ -129,7 +132,7 @@ class Playlist extends playlist_object
public function get_track($track_id)
{
$sql = "SELECT * FROM `playlist_data` WHERE `id` = ? AND `playlist` = ?";
$db_results = Dba::read($sql, array($track_id, $playlist_id));
$db_results = Dba::read($sql, array($track_id, $this->id));
$row = Dba::fetch_assoc($db_results);
@ -202,13 +205,7 @@ class Playlist extends playlist_object
$db_results = Dba::read($sql, array($this->id));
while ($r = Dba::fetch_assoc($db_results)) {
if ($r['dyn_song']) {
$array = $this->get_dyn_songs($r['dyn_song']);
$results = array_merge($array,$results);
} else {
$results[] = $r['object_id'];
}
} // end while
return $results;
@ -332,15 +329,13 @@ class Playlist extends playlist_object
public function update_track_number($track_id, $index)
{
$sql = "UPDATE `playlist_data` SET `track` = ? WHERE `id` = ?";
$db_results = Dba::write($sql, array($index, $track_id));
Dba::write($sql, array($index, $track_id));
} // update_track_number
/**
* add_songs
* This takes an array of song_ids and then adds it to the playlist
* if you want to add a dyn_song you need to use the one shot function
* add_dyn_song
*/
public function add_songs($song_ids=array(),$ordered=false)
{
@ -354,6 +349,7 @@ class Playlist extends playlist_object
$base_track = $data['track'];
debug_event('add_songs', 'Track number: '.$base_track, '5');
$i = 0;
foreach ($song_ids as $song_id) {
/* We need the songs track */
$song = new Song($song_id);
@ -370,7 +366,7 @@ class Playlist extends playlist_object
if ($song->id) {
$sql = "INSERT INTO `playlist_data` (`playlist`,`object_id`,`object_type`,`track`) " .
" VALUES (?, ?, 'song', ?)";
$db_results = Dba::write($sql, array($this->id, $song->id, $track));
Dba::write($sql, array($this->id, $song->id, $track));
} // if valid id
} // end foreach songs
@ -385,10 +381,9 @@ class Playlist extends playlist_object
public static function create($name,$type)
{
$sql = "INSERT INTO `playlist` (`name`,`user`,`type`,`date`) VALUES (?, ?, ?, ?)";
$db_results = Dba::write($sql, array($name, $GLOBALS['user']->id, $type, time()));
Dba::write($sql, array($name, $GLOBALS['user']->id, $type, time()));
$insert_id = Dba::insert_id();
return $insert_id;
} // create
@ -410,7 +405,7 @@ class Playlist extends playlist_object
public function delete_track($id)
{
$sql = "DELETE FROM `playlist_data` WHERE `playlist_data`.`playlist` = ? AND `playlist_data`.`id` = ? LIMIT 1";
$db_results = Dba::write($sql, array($this->id, $id));
Dba::write($sql, array($this->id, $id));
return true;
@ -423,7 +418,7 @@ class Playlist extends playlist_object
public function delete_track_number($track)
{
$sql = "DELETE FROM `playlist_data` WHERE `playlist_data`.`playlist` = ? AND `playlist_data`.`track` = ? LIMIT 1";
$db_results = Dba::write($sql, array($this->id, $track));
Dba::write($sql, array($this->id, $track));
return true;
@ -436,13 +431,13 @@ class Playlist extends playlist_object
public function delete()
{
$sql = "DELETE FROM `playlist_data` WHERE `playlist` = ?";
$db_results = Dba::write($sql, array($this->id));
Dba::write($sql, array($this->id));
$sql = "DELETE FROM `playlist` WHERE `id` = ?";
$db_results = Dba::write($sql, array($this->id));
Dba::write($sql, array($this->id));
$sql = "DELETE FROM `object_count` WHERE `object_type`='playlist' AND `object_id` = ?";
$db_results = Dba::write($sql, array($this->id));
Dba::write($sql, array($this->id));
return true;

View file

@ -32,6 +32,10 @@ abstract class playlist_object extends database_object
public $user;
public $type;
public $f_type;
public $f_name;
public $f_user;
/**
* format
* This takes the current playlist object and gussies it up a little
@ -64,8 +68,6 @@ abstract class playlist_object extends database_object
return Access::check('interface','100');
}
return false;
} // has_access

View file

@ -596,7 +596,7 @@ class Plex_Api
} elseif ($view == "albums") {
Plex_XML_Data::setSectionAlbums($r, $catalog);
} elseif ($view == "recentlyadded") {
Plex_XML_Data::setCustomSectionView($r, $catalog, Stats::get_recent('album', 25, 0, $key));
Plex_XML_Data::setCustomSectionView($r, $catalog, Stats::get_recent('album', 25, $key));
}
}
}
@ -945,7 +945,7 @@ class Plex_Api
$robj = new Rating(Plex_XML_Data::getAmpacheId($id), "artist");
} else if (Plex_XML_Data::isAlbum($id)) {
$robj = new Rating(Plex_XML_Data::getAmpacheId($id), "album");
} else if (Plex_XML_Data::isSong($id)) {
} else if (Plex_XML_Data::isTrack($id)) {
$robj = new Rating(Plex_XML_Data::getAmpacheId($id), "song");
}

View file

@ -169,20 +169,6 @@ class Plex_XML_Data
return AmpConfig::get('myplex_published');
}
public static function createFailedResponse($version = "")
{
$response = self::createResponse($version);
$response->addAttribute('status', 'failed');
return $response;
}
public static function createSuccessResponse($version = "")
{
$response = self::createResponse($version);
$response->addAttribute('status', 'ok');
return $response;
}
public static function createContainer()
{
$response = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><MediaContainer/>');
@ -651,12 +637,14 @@ class Plex_XML_Data
self::addArtistMeta($xdir, $artist);
$tags = Tag::get_top_tags('artist', $artist->id);
if (is_array($tags)) {
foreach ($tags as $tag_id=>$value) {
$tag = new Tag($tag_id);
$xgenre = $xdir->addChild('Genre');
$xgenre->addAttribute('tag', $tag->name);
}
}
}
public static function addArtistMeta($xml, $artist)
{
@ -703,12 +691,14 @@ class Plex_XML_Data
}
$tags = Tag::get_top_tags('album', $album->id);
if (is_array($tags)) {
foreach ($tags as $tag_id=>$value) {
$tag = new Tag($tag_id);
$xgenre = $xdir->addChild('Genre');
$xgenre->addAttribute('tag', $tag->name);
}
}
}
public static function addAlbumMeta($xml, $album)
{
@ -789,6 +779,7 @@ class Plex_XML_Data
$time = $song->time * 1000;
$xdir->addAttribute('title', $song->title);
$albumid = self::getAlbumId($song->album);
$album = new Album($song->album);
$xdir->addAttribute('parentRatingKey', $albumid);
$xdir->addAttribute('parentKey', self::getMetadataUri($albumid));
$xdir->addAttribute('originalTitle', $album->f_artist_full);
@ -831,7 +822,7 @@ class Plex_XML_Data
$xml->addAttribute('ratingKey', $id);
$xml->addAttribute('key', self::getMetadataUri($id));
return $xsong;
return $xml;
}
public static function createMyPlexAccount()

View file

@ -272,7 +272,7 @@ class Plugin
$version = Dba::escape($version);
$sql = "REPLACE INTO `update_info` SET `key`='$name', `value`='$version'";
$db_results = Dba::read($sql);
Dba::write($sql);
return true;
@ -287,7 +287,7 @@ class Plugin
$name = Dba::escape('Plugin_' . $this->_plugin->name);
$sql = "DELETE FROM `update_info` WHERE `key`='$name'";
$db_results = Dba::read($sql);
Dba::write($sql);
return true;

View file

@ -87,7 +87,7 @@ class Preference extends database_object
if ($applytodefault AND Access::check('interface', '100')) {
$sql = "UPDATE `preference` SET `value`='$value' WHERE `id`='$id'";
$db_results = Dba::write($sql);
Dba::write($sql);
}
$value = Dba::escape($value);
@ -95,10 +95,10 @@ class Preference extends database_object
if (self::has_access($name)) {
$user_id = Dba::escape($user_id);
$sql = "UPDATE `user_preference` SET `value`='$value' WHERE `preference`='$id'$user_check";
$db_results = Dba::write($sql);
Dba::write($sql);
Preference::clear_from_session();
parent::remove_from_cache('get_by_user', user_id);
parent::remove_from_cache('get_by_user', $user_id);
return true;
} else {
@ -125,7 +125,7 @@ class Preference extends database_object
$level = Dba::escape($level);
$sql = "UPDATE `preference` SET `level`='$level' WHERE `id`='$preference_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -141,7 +141,7 @@ class Preference extends database_object
$value = Dba::escape($value);
$sql = "UPDATE `user_preference` SET `value`='$value' WHERE `preference`='$preference_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
parent::clear_cache();
@ -258,6 +258,7 @@ class Preference extends database_object
{
$user_id = Dba::escape($user_id);
$user_limit = "";
if ($user_id != '-1') {
$user_limit = "AND `preference`.`catagory` != 'system'";
}
@ -318,7 +319,7 @@ class Preference extends database_object
$sql = "DELETE FROM `preference` WHERE `id`='$id'";
}
$db_results = Dba::write($sql);
Dba::write($sql);
self::rebuild_preferences();
@ -334,7 +335,7 @@ class Preference extends database_object
$new = Dba::escape($new);
$sql = "UPDATE `preference` SET `name`='$new' WHERE `name`='$old'";
$db_results = Dba::write($sql);
Dba::write($sql);
}
/**
@ -346,10 +347,10 @@ class Preference extends database_object
// First remove garbage
$sql = "DELETE FROM `user_preference` USING `user_preference` LEFT JOIN `preference` ON `preference`.`id`=`user_preference`.`preference` " .
"WHERE `preference`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
// Now add anything that we are missing back in, except System
$sql = "SELECT * FROM `preference` WHERE `type`!='system'";
//$sql = "SELECT * FROM `preference` WHERE `type`!='system'";
//FIXME: Uhh WTF shouldn't there be something here??
} // rebuild_preferences
@ -457,6 +458,7 @@ class Preference extends database_object
"LEFT JOIN `user_preference` ON `user_preference`.`preference`=`preference`.`id` AND `user_preference`.`user`='$user_id' AND `preference`.`catagory`!='system'";
$db_results = Dba::read($sql);
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$value = $row['system_value'] ? $row['system_value'] : $row['value'];
$name = $row['name'];

View file

@ -54,7 +54,7 @@ class Query
$sql = 'INSERT INTO `tmp_browse` (`sid`, `data`) ' .
'VALUES(?, ?)';
$db_results = Dba::write($sql, array($sid, $data));
Dba::write($sql, array($sid, $data));
$this->id = Dba::insert_id();
} else {
@ -277,7 +277,7 @@ class Query
$sql = 'DELETE FROM `tmp_browse` USING `tmp_browse` LEFT JOIN ' .
'`session` ON `session`.`id` = `tmp_browse`.`sid` ' .
'WHERE `session`.`id` IS NULL';
$db_results = Dba::write($sql);
Dba::write($sql);
}
/**
@ -390,7 +390,6 @@ class Query
default:
// Rien a faire
return false;
break;
} // end switch
// If we've set a filter we need to reset the totals
@ -1049,6 +1048,10 @@ class Query
{
$sql = $this->get_base_sql();
$filter_sql = "";
$join_sql = "";
$having_sql = "";
$order_sql = "";
if (!isset($this->_state['custom']) || !$this->_state['custom']) {
$filter_sql = $this->get_filter_sql();
$join_sql = $this->get_join_sql();
@ -1508,7 +1511,6 @@ class Query
case 'codec':
$sql = "`live_stream`.`codec`";
break;
break;
} // end switch
break;
case 'genre':
@ -1643,9 +1645,9 @@ class Query
break;
} // end switch
if ($sql) { $sql_sort = "$sql $order,"; }
if (isset($sql)) { return "$sql $order,"; }
return $sql_sort;
return "";
} // sql_sort
@ -1698,6 +1700,7 @@ class Query
$db_results = Dba::read($sql);
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row['id'];
}
@ -1720,8 +1723,7 @@ class Query
$sql = 'UPDATE `tmp_browse` SET `data` = ? ' .
'WHERE `sid` = ? AND `id` = ?';
$db_results = Dba::write($sql,
array($data, session_id(), $id));
Dba::write($sql, array($data, session_id(), $id));
}
}
@ -1746,8 +1748,7 @@ class Query
$sql = 'UPDATE `tmp_browse` SET `object_data` = ? ' .
'WHERE `sid` = ? AND `id` = ?';
$db_results = Dba::write($sql,
array($data, session_id(), $id));
Dba::write($sql, array($data, session_id(), $id));
}
}

View file

@ -39,6 +39,10 @@ class Radio extends database_object implements media
public $codec;
public $catalog;
public $f_link;
public $f_name_link;
public $f_url_link;
/**
* Constructor
* This takes a flagged.id and then pulls in the information for said flag entry
@ -152,7 +156,7 @@ class Radio extends database_object implements media
public function delete()
{
$sql = "DELETE FROM `live_stream` WHERE `id` = ?";
$db_results = Dba::write($sql, array($this->id));
Dba::write($sql, array($this->id));
return true;
@ -206,7 +210,7 @@ class Radio extends database_object implements media
$db_results = Dba::read($sql, $params);
$radios = array();
while ($results = Dba::featch_assoc($db_results)) {
while ($results = Dba::fetch_assoc($db_results)) {
$radios[] = $results['id'];
}

View file

@ -74,6 +74,7 @@ class Random
*/
public static function get_single_song($type)
{
$song_id = 0;
$method_name = 'get_' . $type;
if (method_exists('Random', $method_name)) {
@ -125,6 +126,7 @@ class Random
// Get the last album played by us
$data = $GLOBALS['user']->get_recently_played('1', 'album');
$where_sql = "";
if ($data[0]) {
$where_sql = " AND `song`.`album`='" . $data[0] . "' ";
}
@ -157,6 +159,7 @@ class Random
$results = array();
$data = $GLOBALS['user']->get_recently_played('1','artist');
$where_sql = "";
if ($data[0]) {
$where_sql = " AND `song`.`artist`='" . $data[0] . "' ";
}
@ -192,6 +195,7 @@ class Random
// Generate our matchlist
/* 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); }
$search_data = Search::clean_request($data);
@ -204,6 +208,7 @@ class Random
$search_info = $search->to_sql();
}
$sql = "";
switch ($type) {
case 'song':
$sql = "SELECT `song`.`id`, `size`, `time` " .
@ -272,6 +277,10 @@ class Random
$db_results = Dba::read($sql);
$results = array();
$size_total = 0;
$fuzzy_size = 0;
$time_total = 0;
$fuzzy_time = 0;
while ($row = Dba::fetch_assoc($db_results)) {
// If size limit is specified
@ -331,7 +340,6 @@ class Random
switch ($type) {
case 'song':
return $results;
break;
case 'album':
$songs = array();
foreach ($results as $result) {
@ -339,7 +347,6 @@ class Random
$songs = array_merge($songs, $album->get_songs());
}
return $songs;
break;
case 'artist':
$songs = array();
foreach ($results as $result) {
@ -347,10 +354,8 @@ class Random
$songs = array_merge($songs, $artist->get_songs());
}
return $songs;
break;
default:
return false;
break;
}
} // advanced

View file

@ -223,7 +223,7 @@ class Rating extends database_object
}
$user_id = intval($user_id);
debug_event('Rating', "Setting rating for $type $id to $rating", 5);
debug_event('Rating', "Setting rating for $this->type $this->id to $rating", 5);
// If score is -1, then remove rating
if ($rating == '-1') {
@ -238,7 +238,7 @@ class Rating extends database_object
"VALUES (?, ?, ?, ?)";
$params = array($this->id, $this->type, $rating, $user_id);
}
$db_results = Dba::write($sql, $params);
Dba::write($sql, $params);
parent::add_to_cache('rating_' . $type . '_user' . $user_id, $id, $rating);

View file

@ -182,7 +182,7 @@ class Recommendation
}
}
if (!$similars || count($similars) == 0) {
if (!isset($similars) || count($similars) == 0) {
$similars = $cache['items'];
}
if ($similars) {
@ -274,7 +274,7 @@ class Recommendation
}
}
if (!$similars || count($similars) == 0) {
if (!isset($similars) || count($similars) == 0) {
$similars = $cache['items'];
}
if ($similars) {

View file

@ -35,6 +35,9 @@ class Search extends playlist_object
public $basetypes;
public $types;
public $f_link;
public $f_name_link;
/**
* constructor
*/
@ -469,6 +472,7 @@ class Search extends playlist_object
*/
public static function clean_request($data)
{
$request = array();
foreach ($data as $key => $value) {
$prefix = substr($key, 0, 4);
$value = trim($value);
@ -554,8 +558,8 @@ class Search extends playlist_object
// Generate BASE SQL
$limit_sql = "";
if ($limit > 0) {
$limit_sql = ' LIMIT ' . $limit;
$offset = intval($data['offset']);
$limit_sql = ' LIMIT ';
if ($offset) $limit_sql .= $offset . ",";
@ -586,7 +590,7 @@ class Search extends playlist_object
{
$id = Dba::escape($this->id);
$sql = "DELETE FROM `search` WHERE `id` = ?";
$db_results = Dba::write($sql, array($id));
Dba::write($sql, array($id));
return true;
}
@ -715,7 +719,7 @@ class Search extends playlist_object
}
$sql = "INSERT INTO `search` (`name`, `type`, `user`, `rules`, `logic_operator`) VALUES (?, ?, ?, ?, ?)";
$db_results = Dba::write($sql, array($this->name, $this->type, $GLOBALS['user']->id, serialize($this->rules), $this->logic_operator));
Dba::write($sql, array($this->name, $this->type, $GLOBALS['user']->id, serialize($this->rules), $this->logic_operator));
$insert_id = Dba::insert_id();
$this->id = $insert_id;
return $insert_id;
@ -729,6 +733,7 @@ class Search extends playlist_object
*/
public function to_js()
{
$js = "";
foreach ($this->rules as $rule) {
$js .= '<script type="text/javascript">' .
'SearchRow.add("' . $rule[0] . '","' .
@ -785,7 +790,7 @@ class Search extends playlist_object
}
if ($type == 'boolean') {
return make_bool($input);
return make_bool($data);
}
return $data;
@ -807,8 +812,10 @@ class Search extends playlist_object
foreach ($this->rules as $rule) {
$type = $this->name_to_basetype($rule[0]);
foreach ($this->basetypes[$type] as $operator) {
if ($operator['name'] == $rule[1]) {
$operator = array();
foreach ($this->basetypes[$type] as $op) {
if ($op['name'] == $rule[1]) {
$operator = $op;
break;
}
}
@ -1037,7 +1044,6 @@ class Search extends playlist_object
"WHERE `object_count`.`object_type` = 'song'" .
"GROUP BY `object_count`.`object_id` HAVING COUNT(*) $sql_match_operator '$input')";
break;
break;
case 'catalog':
$where[] = "`song`.`catalog` $sql_match_operator '$input'";
break;
@ -1076,7 +1082,7 @@ class Search extends playlist_object
$join['catalog'] = AmpConfig::get('catalog_disable');
$where_sql = implode(" $sql_logic_operator ", $where) . $group;
$where_sql = implode(" $sql_logic_operator ", $where);
// now that we know which things we want to JOIN...
if ($join['artist']) {
@ -1145,8 +1151,10 @@ class Search extends playlist_object
foreach ($this->rules as $rule) {
$type = $this->name_to_basetype($rule[0]);
foreach ($this->basetypes[$type] as $operator) {
if ($operator['name'] == $rule[1]) {
$operator = array();
foreach ($this->basetypes[$type] as $op) {
if ($op['name'] == $rule[1]) {
$operator = $op;
break;
}
}

View file

@ -36,22 +36,6 @@ class Session
// Rien a faire
} // __construct
/**
* open
*
* This function is for opening a new session so we just verify that we
* have a database connection, nothing more is needed.
*/
public static function open($save_path, $session_name)
{
if (!Dba::dbh()) {
debug_event('session', 'Could not start session, no database connection', 1);
return false;
}
return true;
}
/**
* close
*
@ -73,8 +57,6 @@ class Session
return true;
}
$length = AmpConfig::get('session_length');
// Check to see if remember me cookie is set, if so use remember
// length, otherwise use the session length
$expire = isset($_COOKIE[AmpConfig::get('session_name') . '_remember'])
@ -82,7 +64,7 @@ class Session
: time() + AmpConfig::get('session_length');
$sql = 'UPDATE `session` SET `value` = ?, `expire` = ? WHERE `id` = ?';
$db_results = Dba::read($sql, array($value, $expire, $key));
Dba::write($sql, array($value, $expire, $key));
debug_event('session', 'Writing to ' . $key . ' with expiration ' . $expire, 6);
@ -100,7 +82,7 @@ class Session
// Remove anything and EVERYTHING
$sql = 'DELETE FROM `session` WHERE `id` = ?';
$db_results = Dba::write($sql, array($key));
Dba::write($sql, array($key));
debug_event('SESSION', 'Deleting Session with key:' . $key, 6);
@ -118,7 +100,7 @@ class Session
public static function gc()
{
$sql = 'DELETE FROM `session` WHERE `expire` < ?';
$db_results = Dba::write($sql, array(time()));
Dba::write($sql, array(time()));
// Also clean up things that use sessions as keys
Query::gc();
@ -279,10 +261,10 @@ class Session
* exists
*
* This checks to see if the specified session of the specified type
* exists, it also provides an array of keyed data that may be required
* exists
* based on the type.
*/
public static function exists($type, $key, $data=array())
public static function exists($type, $key)
{
// Switch on the type they pass
switch ($type) {
@ -312,7 +294,6 @@ class Session
break;
default:
return false;
break;
}
// Default to false

View file

@ -22,6 +22,27 @@
class Share extends database_object
{
public $id;
public $user;
public $object_type;
public $object_id;
public $allow_stream;
public $allow_download;
public $creation_date;
public $lastvisit_date;
public $expire_days;
public $max_counter;
public $counter;
public $secret;
public $public_url;
public $f_object_link;
public $f_user;
public $f_allow_stream;
public $f_allow_download;
public $f_creation_date;
public $f_lastvisite_date;
/**
* Constructor
*/
@ -77,7 +98,6 @@ class Share extends database_object
case 'song':
case 'playlist':
return $type;
break;
default:
return '';
}
@ -108,7 +128,7 @@ class Share extends database_object
break;
}
}
} catch (Exeption $e) {
} catch (Exception $e) {
debug_event('share', 'Share plugin error: ' . $e->getMessage(), '1');
}
}

View file

@ -26,6 +26,11 @@ class Shoutbox
public $object_type;
public $object_id;
public $user;
public $sticky;
public $text;
public $data;
public $f_link;
/**
* Constructor
@ -170,7 +175,7 @@ class Shoutbox
$image_string = "<img class=\"shoutboximage\" height=\"75\" width=\"75\" src=\"" . AmpConfig::get('web_path') . "/image.php?id=" . $song->album . "&amp;thumb=1\" />";
break;
default:
// Rien a faire
$image_string = "";
break;
} // end switch
@ -187,7 +192,7 @@ class Shoutbox
$sticky = isset($data['sticky']) ? 1 : 0;
$sql = "INSERT INTO `user_shout` (`user`,`date`,`text`,`sticky`,`object_id`,`object_type`, `data`) " .
"VALUES (? , ?, ?, ?, ?, ?, ?)";
$db_results = Dba::write($sql, array($GLOBALS['user']->id, time(), strip_tags($data['comment']), $sticky, $data['object_id'], $data['object_type'], $data['data']));
Dba::write($sql, array($GLOBALS['user']->id, time(), strip_tags($data['comment']), $sticky, $data['object_id'], $data['object_type'], $data['data']));
$insert_id = Dba::insert_id();
@ -206,7 +211,7 @@ class Shoutbox
$sticky = make_bool($data['sticky']);
$sql = "UPDATE `user_shout` SET `text`='$text', `sticky`='$sticky' WHERE `id`='$id'";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -235,7 +240,7 @@ class Shoutbox
// Delete the shoutbox post
$shout_id = Dba::escape($shout_id);
$sql = "DELETE FROM `user_shout` WHERE `id`='$shout_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
} // delete

View file

@ -45,7 +45,9 @@ class Song extends database_object implements media
public $update_time;
public $mbid; // MusicBrainz ID
public $catalog;
public $waveform;
public $tags;
public $language;
public $comment;
public $lyrics;
@ -58,6 +60,16 @@ class Song extends database_object implements media
public $f_track;
public $f_bitrate;
public $link;
public $f_file;
public $f_title_full;
public $f_link;
public $f_album_link;
public $f_artist_link;
public $f_tags;
public $f_size;
public $f_lyrics;
public $f_pattern;
public $count;
/* Setting Variables */
public $_fake = false; // If this is a 'construct_from_array' object
@ -327,39 +339,29 @@ class Song extends database_object implements media
case 'spx':
case 'ogg':
return 'application/ogg';
break;
case 'wma':
case 'asf':
return 'audio/x-ms-wma';
break;
case 'mp3':
case 'mpeg3':
return 'audio/mpeg';
break;
case 'rm':
case 'ra':
return 'audio/x-realaudio';
break;
case 'flac';
return 'audio/x-flac';
break;
case 'wv':
return 'audio/x-wavpack';
break;
case 'aac':
case 'mp4':
case 'm4a':
return 'audio/mp4';
break;
case 'aacp':
return 'audio/aacp';
break;
case 'mpc':
return 'audio/x-musepack';
break;
default:
return 'audio/mpeg';
break;
}
return true;
@ -423,14 +425,14 @@ class Song extends database_object implements media
public static function get_duplicate_info($dupe, $search_type)
{
$sql = 'SELECT `id` FROM `song` ' .
"WHERE `title`='" . Dba::escape($item['title']) . "' ";
"WHERE `title`='" . Dba::escape($dupe['title']) . "' ";
if ($search_type == 'artist_title' ||
$search_type == 'artist_album_title') {
$sql .= "AND `artist`='" . Dba::escape($item['artist']) . "' ";
$sql .= "AND `artist`='" . Dba::escape($dupe['artist']) . "' ";
}
if ($search_type == 'artist_album_title') {
$sql .= "AND `album` = '" . Dba::escape($item['album']) . "' ";
$sql .= "AND `album` = '" . Dba::escape($dupe['album']) . "' ";
}
$sql .= 'ORDER BY `time`,`bitrate`,`size`';
@ -504,6 +506,7 @@ class Song extends database_object implements media
// Remove some stuff we don't care about
unset($song->catalog,$song->played,$song->enabled,$song->addition_time,$song->update_time,$song->type);
$array = array();
$string_array = array('title','comment','lyrics');
$skip_array = array('id','tag_id','mime','mb_artistid','mbid');
@ -569,7 +572,6 @@ class Song extends database_object implements media
$function = 'update_' . $key;
self::$function($value, $this->id);
$this->$key = $value;
$updated = 1;
}
break;
case 'edit_tags':
@ -612,7 +614,7 @@ class Song extends database_object implements media
"`mbid`='$mbid', " .
"`update_time`='$update_time' WHERE `id`='$song_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
$comment = Dba::escape($new_song->comment);
$language = Dba::escape($new_song->language);
@ -620,7 +622,7 @@ class Song extends database_object implements media
$sql = "UPDATE `song_data` SET `lyrics`='$lyrics', `language`='$language', `comment`='$comment' " .
"WHERE `song_id`='$song_id'";
$db_results = Dba::write($sql);
Dba::write($sql);
} // update_song
@ -808,7 +810,7 @@ class Song extends database_object implements media
if (!strlen(trim($value)) && $field != 'comment') { return false; }
$sql = "UPDATE `song` SET `$field` = ? WHERE `id` = ?";
$db_results = Dba::write($sql, array($value, $song_id));
Dba::write($sql, array($value, $song_id));
return true;
@ -825,7 +827,7 @@ class Song extends database_object implements media
if (!Access::check('interface',$level)) { return false; }
$sql = "UPDATE `song_data` SET `$field` = ? WHERE `song_id` = ?";
$db_results = Dba::write($sql, array($value, $song_id));
Dba::write($sql, array($value, $song_id));
return true;
@ -878,7 +880,7 @@ class Song extends database_object implements media
// Get the top tags
$this->tags = Tag::get_top_tags('song', $this->id);
$this->f_tags = Tag::get_display($this->tags, $this->id, 'song');
$this->f_tags = Tag::get_display($this->tags);
// Format the size
$this->f_size = UI::format_bytes($this->size);
@ -977,12 +979,16 @@ class Song extends database_object implements media
*/
public function get_rel_path($file_path=0,$catalog_id=0)
{
$info = null;
if (!$file_path) {
$info = $this->_get_info();
$file_path = $info->file;
$file_path = $info['file'];
}
if (!$catalog_id) {
$catalog_id = $info->catalog;
if (!is_array($info)) {
$info = $this->_get_info();
}
$catalog_id = $info['catalog'];
}
$catalog = Catalog::create_from_id( $catalog_id );
return $catalog->get_rel_path($file_path);

View file

@ -35,6 +35,18 @@ class Song_Preview extends database_object implements media
public $mbid; // MusicBrainz ID
public $enabled = true;
public $f_file;
public $f_artist;
public $f_artist_full;
public $f_artist_link;
public $f_title;
public $f_title_full;
public $link;
public $f_link;
public $f_album_link;
public $f_album;
public $f_track;
/**
* Constructor
*
@ -114,6 +126,7 @@ class Song_Preview extends database_object implements media
"WHERE `id` IN $idlist";
$db_results = Dba::read($sql);
$artists = array();
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('song_preview', $row['id'], $row);
if ($row['artist']) {

View file

@ -244,16 +244,10 @@ class Stats
/**
* get_recent
* This returns the recent X for type Y from the
* last stats_threshold days
* This returns the recent X for type Y
*/
public static function get_recent($type, $count='',$threshold = '',$offset='')
public static function get_recent($type, $count='',$offset='')
{
/* If they don't pass one, then use the preference */
if (!$threshold) {
$threshold = AmpConfig::get('stats_threshold');
}
if (!$count) {
$count = AmpConfig::get('popular_threshold');
}
@ -329,7 +323,6 @@ class Stats
return $type;
default:
return 'song';
break;
} // end switch
} // validate_type
@ -359,7 +352,7 @@ class Stats
* This returns an array of the newest artists/albums/whatever
* in this ampache instance
*/
public static function get_newest($type, $limit='', $offset='', $catalog=0)
public static function get_newest($type, $count='', $offset='', $catalog=0)
{
if (!$count) { $count = AmpConfig::get('popular_threshold'); }
if (!$offset) {

View file

@ -186,7 +186,7 @@ class Stream
$sql = "DELETE FROM `now_playing` USING `now_playing` " .
"LEFT JOIN `session` ON `session`.`id` = `now_playing`.`id` " .
"WHERE `session`.`id` IS NULL OR `now_playing`.`expire` < '" . time() . "'";
$db_results = Dba::write($sql);
Dba::write($sql);
}
/**
@ -203,7 +203,7 @@ class Stream
$sql = 'REPLACE INTO `now_playing` ' .
'(`id`,`object_id`,`object_type`, `user`, `expire`, `insertion`) ' .
'VALUES (?, ?, ?, ?, ?, ?)';
$db_result = Dba::write($sql, array($sid, $oid, $type, $uid, $time, time()));
Dba::write($sql, array($sid, $oid, $type, $uid, $time, time()));
}
/**
@ -215,7 +215,7 @@ class Stream
public static function clear_now_playing()
{
$sql = 'TRUNCATE `now_playing`';
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
}
@ -227,10 +227,6 @@ class Stream
*/
public static function get_now_playing()
{
$maxsql = '';
if (AmpConfig::get('now_playing_per_user')) {
$maxsql = ', ';
}
$sql = 'SELECT `session`.`agent`, `np`.* FROM `now_playing` AS `np` ';
$sql .= 'LEFT JOIN `session` ON `session`.`id` = `np`.`id` ';
@ -323,11 +319,10 @@ class Stream
if (!defined('AJAX_INCLUDE')) { return false; }
switch (AmpConfig::get('playlist_method')) {
default:
case 'clear':
case 'default':
default:
return true;
break;
case 'send':
$_SESSION['iframe']['target'] = AmpConfig::get('web_path') . '/stream.php?action=basket';
break;
@ -349,6 +344,7 @@ class Stream
*/
public static function get_base_url()
{
$session_string = '';
if (AmpConfig::get('require_session')) {
$session_string = 'ssid=' . self::$session . '&';
}

View file

@ -191,6 +191,7 @@ class Stream_Playlist
case 'localplay':
case 'web_player':
// These are valid, but witchy
$ct = "";
$redirect = false;
unset($ext);
break;
@ -300,6 +301,7 @@ class Stream_Playlist
{
echo "[playlist]\n";
echo 'NumberOfEntries=' . count($this->urls) . "\n";
$i = 0;
foreach ($this->urls as $url) {
$i++;
echo 'File' . $i . '='. $url->url . "\n";
@ -343,6 +345,7 @@ class Stream_Playlist
*/
public function create_xspf()
{
$result = "";
foreach ($this->urls as $url) {
$xml = array();

View file

@ -530,6 +530,9 @@ class Subsonic_Api
$album = new Album(Subsonic_XML_Data::getAmpacheId($musicFolderId));
$finput = $album->name;
$ftype = "artist";
} else {
$finput = "";
$ftype = "";
}
$search['rule_'.$i.'_input'] = $finput;
$search['rule_'.$i.'_operator'] = 4;
@ -579,6 +582,8 @@ class Subsonic_Api
$tag = Tag::construct_from_name($genre);
if ($tag->id) {
$songs = Tag::get_tag_objects("song", $tag->id, $count, $offset);
} else {
$songs = array();
}
$r = Subsonic_XML_Data::createSuccessResponse();
Subsonic_XML_Data::addSongsByGenre($r, $songs);
@ -1009,6 +1014,8 @@ class Subsonic_Api
$type = 'album';
} else if (Subsonic_XML_Data::isSong($i)) {
$type = 'song';
} else {
$type = "";
}
$ids[] = array('id' => $aid, 'type' => $type);
}

View file

@ -387,14 +387,14 @@ class Subsonic_XML_Data
foreach ($tags as $tag) {
$otag = new Tag($tag['id']);
$xgenre = $xgenres->addChild('genre', $otag->name);
$xgenres->addChild('genre', $otag->name);
}
}
public static function addVideos($xml)
{
// Not supported yet
$xvideos = $xml->addChild('videos');
$xml->addChild('videos');
}
public static function addPlaylists($xml, $playlists)

View file

@ -100,7 +100,7 @@ class Tag extends database_object
$db_results = Dba::read($sql);
$tags = array();
$tag_map = array();
while ($row = Dba::fetch_assoc($db_results)) {
$tags[$row['object_id']][$row['tag_id']] = array('user'=>$row['user'], 'id'=>$row['tag_id'], 'name'=>$row['name']);
$tag_map[$row['object_id']] = array('id'=>$row['id'],'tag_id'=>$row['tag_id'],'user'=>$row['user'],'object_type'=>$type,'object_id'=>$row['object_id']);
@ -150,8 +150,8 @@ class Tag extends database_object
}
// We've got the tag id, let's see if it's already got a map, if not then create the map and return the value
if (!$map_id = self::tag_map_exists($type,$id,$tag_id,$user)) {
$map_id = self::add_tag_map($type,$id,$tag_id,$user);
if (!$map_id = self::tag_map_exists($type,$id,$tag_id,$uid)) {
$map_id = self::add_tag_map($type,$id,$tag_id,$uid);
}
return $map_id;
@ -169,7 +169,7 @@ class Tag extends database_object
$value = Dba::escape($value);
$sql = "REPLACE INTO `tag` SET `name`='$value'";
$db_results = Dba::write($sql);
Dba::write($sql);
$insert_id = Dba::insert_id();
parent::add_to_cache('tag_name', $value, $insert_id);
@ -209,7 +209,7 @@ class Tag extends database_object
$sql = "INSERT INTO `tag_map` (`tag_id`,`user`,`object_type`,`object_id`) " .
"VALUES ('$tag_id','$uid','$type','$id')";
$db_results = Dba::write($sql);
Dba::write($sql);
$insert_id = Dba::insert_id();
parent::add_to_cache('tag_map_' . $type,$insert_id,array('tag_id'=>$tag_id,'user'=>$uid,'object_type'=>$type,'object_id'=>$id));
@ -228,24 +228,24 @@ class Tag extends database_object
{
$sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `song` ON `song`.`id`=`tag_map`.`object_id` " .
"WHERE `tag_map`.`object_type`='song' AND `song`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `album` ON `album`.`id`=`tag_map`.`object_id` " .
"WHERE `tag_map`.`object_type`='album' AND `album`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `artist` ON `artist`.`id`=`tag_map`.`object_id` " .
"WHERE `tag_map`.`object_type`='artist' AND `artist`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "DELETE FROM `tag_map` USING `tag_map` LEFT JOIN `video` ON `video`.`id`=`tag_map`.`object_id` " .
"WHERE `tag_map`.`object_type`='video' AND `video`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
// Now nuke the tags themselves
$sql = "DELETE FROM `tag` USING `tag` LEFT JOIN `tag_map` ON `tag`.`id`=`tag_map`.`tag_id` " .
"WHERE `tag_map`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
}
/**
@ -256,10 +256,10 @@ class Tag extends database_object
public function delete()
{
$sql = "DELETE FROM `tag_map` WHERE `tag_map`.`tag_id`='".$this->id."'";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "DELETE FROM `tag` WHERE `tag`.`id`='".$this->id."'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Call the garbage collector to clean everything
Tag::gc();
@ -374,6 +374,7 @@ class Tag extends database_object
{
if (!self::validate_type($type)) { return array(); }
$limit_sql = "";
if ($count) {
$limit_sql = "LIMIT ";
if ($offset) $limit_sql .= intval($offset) . ',';
@ -470,6 +471,7 @@ class Tag extends database_object
$ctags = Tag::get_top_tags($type, $object_id);
$editedTags = explode(",", $tags_comma);
if (is_array($ctags)) {
foreach ($ctags as $ctid => $ctv) {
if ($ctv['id'] != '') {
$ctag = new Tag($ctv['id']);
@ -492,6 +494,7 @@ class Tag extends database_object
}
}
}
}
// Look if we need to add some new tags
foreach ($editedTags as $tk => $tv) {
@ -509,6 +512,7 @@ class Tag extends database_object
*/
public function count($type='')
{
$filter_sql = "";
if ($type) {
$filter_sql = " AND `object_type`='" . Dba::escape($type) . "'";
}
@ -534,13 +538,8 @@ class Tag extends database_object
{
if (!self::validate_type($type)) { return false; }
$type = Dba::escape($type);
$tag_id = Dba::escape($this->id);
$object_id = Dba::escape($object_id);
$user_id = Dba::escape($GLOBALS['user']->id);
$sql = "DELETE FROM `tag_map` WHERE `tag_id`='$tag_id' AND `object_type`='$type' AND `object_id`='$object_id' AND `user`='$user_id'";
$db_results = Dba::write($sql);
$sql = "DELETE FROM `tag_map` WHERE `tag_id` = ? AND `object_type` = ? AND `object_id` = ? AND `user` = ?";
Dba::write($sql, array($this->id, $type, $object_id, $GLOBALS['user']->id));
return true;

View file

@ -203,11 +203,8 @@ class Tmp_Playlist extends database_object
*/
public function clear()
{
$id = Dba::escape($this->id);
$sql = "DELETE FROM `tmp_playlist_data` WHERE " .
"`tmp_playlist`='$id'";
$db_results = Dba::write($sql);
$sql = "DELETE FROM `tmp_playlist_data` WHERE `tmp_playlist` = ?";
Dba::write($sql, array($this->id));
return true;
@ -221,14 +218,10 @@ class Tmp_Playlist extends database_object
*/
public static function create($data)
{
$sessid = Dba::escape($data['session_id']);
$type = Dba::escape($data['type']);
$object_type = Dba::escape($data['object_type']);
$sql = "INSERT INTO `tmp_playlist` " .
"(`session`,`type`,`object_type`) " .
" VALUES ('$sessid','$type','$object_type')";
$db_results = Dba::write($sql);
" VALUES (?, ?, ?)";
Dba::write($sql, array($data['session_id'], $data['type'], $data['object_type']));
$id = Dba::insert_id();
@ -247,7 +240,7 @@ class Tmp_Playlist extends database_object
{
$sql = "UPDATE `tmp_playlist` SET " .
"`base_playlist`= ? WHERE `id`= ?";
$db_results = Dba::write($sql, array($playlist_id, $id));
Dba::write($sql, array($playlist_id, $this->id));
return true;
@ -261,7 +254,7 @@ class Tmp_Playlist extends database_object
public static function session_clean($sessid, $id)
{
$sql = "DELETE FROM `tmp_playlist` WHERE `session`= ? AND `id` != ?";
$db_results = Dba::write($sql, array($sessid, $id));
Dba::write($sql, array($sessid, $id));
/* Remove associated tracks */
self::prune_tracks();
@ -293,7 +286,7 @@ class Tmp_Playlist extends database_object
"ON `session`.`id`=`tmp_playlist`.`session` " .
"WHERE `session`.`id` IS NULL " .
"AND `tmp_playlist`.`type` != 'vote'";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -311,7 +304,7 @@ class Tmp_Playlist extends database_object
"`tmp_playlist_data` LEFT JOIN `tmp_playlist` ON " .
"`tmp_playlist_data`.`tmp_playlist`=`tmp_playlist`.`id` " .
"WHERE `tmp_playlist`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
} // prune_tracks
@ -325,7 +318,7 @@ class Tmp_Playlist extends database_object
$sql = "INSERT INTO `tmp_playlist_data` " .
"(`object_id`,`tmp_playlist`,`object_type`) " .
" VALUES (?, ?, ?)";
$db_results = Dba::write($sql, array($object_id, $this->id, $object_type));
Dba::write($sql, array($object_id, $this->id, $object_type));
return true;
@ -353,7 +346,7 @@ class Tmp_Playlist extends database_object
{
/* delete the track its self */
$sql = "DELETE FROM `tmp_playlist_data` WHERE `id` = ?";
$db_results = Dba::write($sql, array($id));
Dba::write($sql, array($id));
return true;

View file

@ -29,7 +29,7 @@ class UI
private static $_ticker;
private static $_icon_cache;
public function __construct($data)
public function __construct()
{
return false;
}
@ -217,7 +217,7 @@ END;
$icon_url = self::_find_icon($name);
if (isset($hover_name)) {
$hover_url = self::_find_icon($hover_text);
$hover_url = self::_find_icon($hover_name);
}
if ($bUseSprite) {
$tag = '<span class="sprite sprite-icon_'.$name.'"';
@ -232,7 +232,7 @@ END;
$tag .= 'alt="' . $title . '" ';
$tag .= 'title="' . $title . '" ';
if (isset($hover_name)) {
if (isset($hover_name) && isset($hover_url)) {
$tag .= 'onmouseover="this.src=\'' . $hover_url . '\'; return true;"';
$tag .= 'onmouseout="this.src=\'' . $icon_url . '\'; return true;" ';
}

View file

@ -56,6 +56,7 @@ class Update
*/
public static function get_version()
{
$version = "";
/* Make sure that update_info exits */
$sql = "SHOW TABLES LIKE 'update_info'";
$db_results = Dba::read($sql);
@ -67,7 +68,6 @@ class Update
if (!Dba::num_rows($db_results)) {
// They can't upgrade, they are too old
header("Location: test.php");
} // if table isn't found
else {
@ -459,13 +459,11 @@ class Update
{
/* Nuke All Active session before we start the mojo */
$sql = "TRUNCATE session";
$db_results = Dba::write($sql);
Dba::write($sql);
// Prevent the script from timing out, which could be bad
set_time_limit(0);
$methods = array();
$current_version = self::get_version();
// Run a check to make sure that they don't try to upgrade from a version that
@ -870,13 +868,13 @@ class Update
{
$sql = "DELETE FROM `preference` WHERE `name`='localplay_mpd_hostname' OR `name`='localplay_mpd_port' " .
"OR `name`='direct_link' OR `name`='localplay_mpd_password' OR `name`='catalog_echo_count'";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "UPDATE `preference` SET `description`='Localplay Access' WHERE `name`='localplay_level'";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "UPDATE `access_list` SET `type`='rpc' WHERE `type`='xml-rpc'";
$db_results = Dba::write($sql);
Dba::write($sql);
// We're not manipulating the structure, so we'll pretend it always works
return true;
@ -944,7 +942,7 @@ class Update
$rating = Dba::escape($row['rating']);
$id = Dba::escape($row['id']);
$sql = "UPDATE `rating` SET `rating`='$rating' WHERE `id`='$id'";
$db_results = Dba::write($sql);
Dba::write($sql);
}
return $retval;
@ -1442,7 +1440,7 @@ class Update
"', '" . $row['art_mime'] .
"', 'original', '" . $type . "', '" .
$row['object_id'] . "')";
$db_other_results = Dba::write($sql);
Dba::write($sql);
}
$sql = "DROP TABLE `" . $type . "_data`";
$retval = Dba::write($sql) ? $retval : false;
@ -1746,10 +1744,10 @@ class Update
}
$sql = "ALTER TABLE `catalog` DROP `path`, DROP `remote_username`, DROP `remote_password`";
$retval = Dba::write($sql);
Dba::write($sql);
$sql = "ALTER TABLE `catalog` MODIFY COLUMN `catalog_type` varchar(128)";
$retval = Dba::write($sql);
Dba::write($sql);
$sql = "UPDATE `artist` SET `mbid` = null WHERE `mbid` = ''";
Dba::write($sql);
@ -1775,14 +1773,14 @@ class Update
$sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('song_page_title','1','Show current song in Web player page title',25,'boolean','interface')";
$retval = Dba::write($sql);
Dba::write($sql);
$id = Dba::insert_id();
$sql = "INSERT INTO `user_preference` VALUES (-1,?,'1')";
$retval = Dba::write($sql, array($id));
Dba::write($sql, array($id));
return $retval;
return true;
}
/**

View file

@ -45,6 +45,17 @@ class User extends database_object
// Constructed variables
public $prefs = array();
public $playlist;
public $f_last_seen;
public $f_create_date;
public $link;
public $f_link;
public $f_useage;
public $ip_history;
public $f_avatar;
public $f_avatar_mini;
public $f_avatar_medium;
/**
* Constructor
@ -202,6 +213,7 @@ class User extends database_object
*/
public static function get_from_email($email)
{
$user = null;
$sql = "SELECT `id` FROM `user` WHERE `email` = ?";
$db_results = Dba::read($sql, array($email));
if ($results = Dba::fetch_assoc($db_results)) {
@ -239,9 +251,10 @@ class User extends database_object
return parent::get_from_cache('user_catalog',$this->id);
}
$sql = "SELECT * FROM `user_catalog` WHERE `user`='$user_id'";
$db_results = Dba::read($sql);
$sql = "SELECT * FROM `user_catalog` WHERE `user` = ?";
$db_results = Dba::read($sql, array($this->id));
$catalogs = array();
while ($row = Dba::fetch_assoc($db_results)) {
$catalogs[] = $row['catalog'];
}
@ -266,11 +279,10 @@ class User extends database_object
// Fill out the user id
$user_id = $system ? Dba::escape(-1) : Dba::escape($this->id);
$user_limit = "";
if (!$system) {
$user_limit = "AND preference.catagory != 'system'";
}
if ($type != '0') {
} else if ($type != '0') {
$user_limit = "AND preference.catagory = '" . Dba::escape($type) . "'";
}
@ -281,7 +293,7 @@ class User extends database_object
" ORDER BY preference.catagory, preference.description";
$db_results = Dba::read($sql);
$results = array();
/* Ok this is crapy, need to clean this up or improve the code FIXME */
while ($r = Dba::fetch_assoc($db_results)) {
$type = $r['catagory'];
@ -319,8 +331,6 @@ class User extends database_object
*/
public function get_favorites($type)
{
$web_path = AmpConfig::get('web_path');
$results = Stats::get_user(AmpConfig::get('popular_threshold'),$type,$this->id,1);
$items = array();
@ -523,7 +533,7 @@ class User extends database_object
{
$sql = "UPDATE `user` SET `username` = ? WHERE `id` = ?";
$this->username = $new_username;
$db_results = Dba::write($sql, array($new_username, $this->id));
Dba::write($sql, array($new_username, $this->id));
} // update_username
@ -550,7 +560,7 @@ class User extends database_object
public function update_fullname($new_fullname)
{
$sql = "UPDATE `user` SET `fullname` = ? WHERE `id` = ?";
$db_results = Dba::write($sql, array($new_fullname, $this->id));
Dba::write($sql, array($new_fullname, $this->id));
} // update_fullname
@ -561,7 +571,7 @@ class User extends database_object
public function update_email($new_email)
{
$sql = "UPDATE `user` SET `email` = ? WHERE `id` = ?";
$db_results = Dba::write($sql, array($new_email, $this->id));
Dba::write($sql, array($new_email, $this->id));
} // update_email
@ -573,7 +583,7 @@ class User extends database_object
{
$new_website = rtrim($new_website, "/");
$sql = "UPDATE `user` SET `website` = ? WHERE `id` = ?";
$db_results = Dba::write($sql, array($new_website, $this->id));
Dba::write($sql, array($new_website, $this->id));
} // update_website
@ -584,7 +594,7 @@ class User extends database_object
public function update_apikey($new_apikey)
{
$sql = "UPDATE `user` SET `apikey` = ? WHERE `id` = ?";
$db_results = Dba::write($sql, array($new_apikey, $this->id));
Dba::write($sql, array($new_apikey, $this->id));
} // update_website
@ -624,11 +634,11 @@ class User extends database_object
if (!Dba::num_rows($db_results)) { return false; }
$sql = "UPDATE `user` SET `disabled`='1' WHERE id='" . $this->id . "'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Delete any sessions they may have
$sql = "DELETE FROM `session` WHERE `username`='" . Dba::escape($this->username) . "'";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -641,7 +651,7 @@ class User extends database_object
public function enable()
{
$sql = "UPDATE `user` SET `disabled`='0' WHERE id='" . $this->id . "'";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -662,7 +672,7 @@ class User extends database_object
$new_access = Dba::escape($new_access);
$sql = "UPDATE `user` SET `access`='$new_access' WHERE `id`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
} // update_access
@ -673,7 +683,7 @@ class User extends database_object
public function update_last_seen()
{
$sql = "UPDATE user SET last_seen='" . time() . "' WHERE `id`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
} // update_last_seen
@ -722,7 +732,7 @@ class User extends database_object
if ($plugin->load($user)) {
$plugin->_plugin->save_songplay($song_info);
}
} catch (Exeption $e) {
} catch (Exception $e) {
debug_event('user.class.php', 'Stats plugin error: ' . $e->getMessage(), '1');
}
}
@ -749,13 +759,13 @@ class User extends database_object
$agent = Dba::escape($_SERVER['HTTP_USER_AGENT']);
$sql = "INSERT INTO `ip_history` (`ip`,`user`,`date`,`agent`) VALUES ('$ip','$user','$date','$agent')";
$db_results = Dba::write($sql);
Dba::write($sql);
/* Clean up old records... sometimes */
if (rand(1,100) > 60) {
$date = time() - (86400*AmpConfig::get('user_ip_cardinality'));
$sql = "DELETE FROM `ip_history` WHERE `date` < $date";
$db_results = Dba::write($sql);
Dba::write($sql);
}
return true;
@ -838,6 +848,7 @@ class User extends database_object
"WHERE `object_count`.`user`='$this->id' AND `object_count`.`object_type`='song'";
$db_results = Dba::read($sql);
$total = 0;
while ($r = Dba::fetch_assoc($db_results)) {
$total = $total + $r['size'];
}
@ -864,41 +875,6 @@ class User extends database_object
} // format_user
/**
* format_recommendations
* This takes an array of [object_id] = ratings
* and displays them in a semi-pretty format
*/
function format_recommendations($items,$type)
{
foreach ($items as $object_id=>$rating) {
switch ($type) {
case 'artist':
$object = new Artist($object_id);
$object->format_artist();
$name = $object->link;
break;
case 'album':
$object = new Album($object_id);
$object->format_album();
$name = $object->f_link;
break;
case 'song':
$object = new Song($object_id);
$object->format_song();
$name = $object->f_link;
break;
} // end switch on type
$results[] = "<li>$name -- " . get_rating_name($rating) . "<br />\n</li>";
} // end foreach items
return $results;
} // format_recommendations
/**
* access_name_to_level
* This takes the access name for the user and returns the level
@ -908,23 +884,16 @@ class User extends database_object
switch ($level) {
case 'admin':
return '100';
break;
case 'user':
return '25';
break;
case 'manager':
return '75';
break;
case 'guest':
return '5';
break;
default:
return '0';
break;
}
return false;
} // access_name_to_level
/**
@ -951,7 +920,7 @@ class User extends database_object
$r['value'] = Dba::escape($r['value']);
$sql = "DELETE FROM `user_preference` WHERE `user`='$user_id' AND `preference`='" . $r['preference'] . "' AND" .
" `value`='" . Dba::escape($r['value']) . "'";
$delete_results = Dba::write($sql);
Dba::write($sql);
} // if its set
else {
$results[$pref_id] = 1;
@ -990,7 +959,7 @@ class User extends database_object
}
$value = Dba::escape($r['value']);
$sql = "INSERT INTO user_preference (`user`,`preference`,`value`) VALUES ('$user_id','$key','$value')";
$insert_db = Dba::write($sql);
Dba::write($sql);
}
} // while preferences
@ -1008,7 +977,7 @@ class User extends database_object
foreach ($results as $data) {
$sql = "DELETE FROM user_preference WHERE user='$data'";
$db_results = Dba::write($sql);
Dba::write($sql);
}
} // fix_preferences
@ -1034,56 +1003,56 @@ class User extends database_object
// Delete their playlists
$sql = "DELETE FROM `playlist` WHERE `user`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Clean up the playlist data table
$sql = "DELETE FROM `playlist_data` USING `playlist_data` " .
"LEFT JOIN `playlist` ON `playlist`.`id`=`playlist_data`.`playlist` " .
"WHERE `playlist`.`id` IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
// Delete any stats they have
$sql = "DELETE FROM `object_count` WHERE `user`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Clear the IP history for this user
$sql = "DELETE FROM `ip_history` WHERE `user`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Nuke any access lists that are specific to this user
$sql = "DELETE FROM `access_list` WHERE `user`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Delete their ratings
$sql = "DELETE FROM `rating` WHERE `user`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Delete their tags
$sql = "DELETE FROM `tag_map` WHERE `user`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Clean out the tags
$sql = "DELETE FROM `tags` USING `tag_map` LEFT JOIN `tag_map` ON tag_map.id=tags.map_id AND tag_map.id IS NULL";
$db_results = Dba::write($sql);
Dba::write($sql);
// Delete their preferences
$sql = "DELETE FROM `user_preference` WHERE `user`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Delete their voted stuff in democratic play
$sql = "DELETE FROM `user_vote` WHERE `user`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Delete their shoutbox posts
$sql = "DELETE FROM `user_shout` WHERE `user='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
// Delete the user itself
$sql = "DELETE FROM `user` WHERE `id`='$this->id'";
$db_results = Dba::write($sql);
Dba::write($sql);
$sql = "DELETE FROM `session` WHERE `username`='" . Dba::escape($this->username) . "'";
$db_results = Dba::write($sql);
Dba::write($sql);
return true;
@ -1107,10 +1076,8 @@ class User extends database_object
*/
public static function get_validation($username)
{
$usename = Dba::escape($username);
$sql = "SELECT `validation` FROM `user` WHERE `username`='$username'";
$db_results = Dba::read($sql);
$sql = "SELECT `validation` FROM `user` WHERE `username` = ?";
$db_results = Dba::read($sql, array($username));
$row = Dba::fetch_assoc($db_results);
@ -1131,6 +1098,7 @@ class User extends database_object
"ORDER BY `date` DESC LIMIT $limit";
$db_results = Dba::read($sql);
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row['object_id'];
}
@ -1153,6 +1121,7 @@ class User extends database_object
if ($count < 1) { $count = '1'; }
$limit_sql = "LIMIT " . intval($count);
$group_sql = "";
if ($distinct) { $group_sql = "GROUP BY `ip`"; }
/* Select ip history */
@ -1236,7 +1205,7 @@ class User extends database_object
$username = Dba::escape($username);
$sql = "UPDATE `user` SET `disabled`='0' WHERE `username` = ?";
$db_results = Dba::write($sql, array($username));
Dba::write($sql, array($username));
} // activate_user

View file

@ -75,7 +75,7 @@ class Userflag extends database_object
if (!isset($userflags[$id])) {
$userflag = 0;
} else {
$userflag = intval($user_ratings[$id]);
$userflag = intval($userflags[$id]);
}
parent::add_to_cache('userflag_' . $type . '_user' . $user_id, $id, $userflag);
}
@ -112,7 +112,7 @@ class Userflag extends database_object
$db_results = Dba::read($sql, array($user_id, $this->id, $this->type));
$flagged = false;
if ($results = Dba::fetch_assoc($db_results)) {
if (Dba::fetch_assoc($db_results)) {
$flagged = true;
}
@ -147,7 +147,7 @@ class Userflag extends database_object
"VALUES (?, ?, ?, ?)";
$params = array($this->id, $this->type, $user_id, time());
}
$db_results = Dba::write($sql, $params);
Dba::write($sql, $params);
parent::add_to_cache('userflag_' . $this->type . '_user' . $user_id, $this->id, $flagged);

View file

@ -35,6 +35,7 @@ class vainfo
public $filename = '';
public $type = '';
public $tags = array();
public $islocal;
protected $_raw = array();
protected $_getID3 = '';
@ -106,6 +107,7 @@ class vainfo
if ($encoding_id3v1) {
$this->encoding_id3v1 = $encoding_id3v1;
} else {
$tags = array();
foreach ($test_tags as $tag) {
if ($value = $this->_raw['id3v1'][$tag]) {
$tags[$tag] = $value;
@ -117,6 +119,7 @@ class vainfo
if (AmpConfig::get('getid3_detect_id3v2_encoding')) {
// The user has told us to be moronic, so let's do that thing
$tags = array();
foreach ($test_tags as $tag) {
if ($value = $this->_raw['id3v2']['comments'][$tag]) {
$tags[$tag] = $value;
@ -154,6 +157,7 @@ class vainfo
debug_event('vainfo', 'encoding detection: ' . json_encode($encodings), 5);
$high = 0;
$encoding = '';
foreach ($encodings as $key => $value) {
if ($value > $high) {
$encoding = $key;
@ -189,7 +193,7 @@ class vainfo
try {
$this->_raw = $this->_getID3->analyze(Core::conv_lc_file($this->filename));
} catch (Exception $error) {
debug_event('getID2', 'Unable to catalog file: ' . $error->message, 1);
debug_event('getID2', 'Unable to catalog file: ' . $error->getMessage(), 1);
}
}
@ -493,10 +497,8 @@ class vainfo
case 'mp2':
case 'mpeg3':
return 'mp3';
break;
case 'vorbis':
return 'ogg';
break;
case 'flac':
case 'flv':
case 'mpg':
@ -510,7 +512,6 @@ class vainfo
/* Log the fact that we couldn't figure it out */
debug_event('vainfo','Unable to determine file type from ' . $type . ' on file ' . $this->filename,'5');
return $type;
break;
}
}
@ -809,6 +810,7 @@ class vainfo
// Pull out our actual matches
preg_match($pattern, $filename, $matches);
if ($matches != null) {
// The first element is the full match text
$matched = array_shift($matches);
debug_event('vainfo', $pattern . ' matched ' . $matched . ' on ' . $filename, 5);
@ -825,6 +827,7 @@ class vainfo
if ($this->islocal) {
$results['size'] = filesize(Core::conv_lc_file($origin));
}
}
return $results;
}

View file

@ -27,6 +27,20 @@ class Video extends database_object implements media
public $enabled;
public $file;
public $size;
public $video_codec;
public $audio_codec;
public $resolution_x;
public $resolution_y;
public $time;
public $mime;
public $tags;
public $f_title;
public $f_link;
public $f_codec;
public $f_resolution;
public $f_tags;
public $f_length;
/**
* Constructor

View file

@ -30,6 +30,16 @@ class Wanted extends database_object
public $mbid;
public $artist;
public $artist_mbid;
public $name;
public $year;
public $accepted;
public $release_mbid;
public $user;
public $f_name_link;
public $f_artist_link;
public $f_user;
public $songs;
/**
* Constructor
@ -68,6 +78,7 @@ class Wanted extends database_object
}
$owngroups = array();
$wartist = array();
if ($artist) {
$albums = $artist->get_albums();
foreach ($albums as $id) {
@ -82,7 +93,6 @@ class Wanted extends database_object
}
}
} else {
$wartist = array();
$wartist['mbid'] = $mbid;
$wartist['name'] = $martist->name;
parent::add_to_cache('missing_artist', $mbid, $wartist);

View file

@ -77,6 +77,7 @@ class Waveform
$catalog = Catalog::create_from_id($song->catalog);
if ($catalog->get_type() == 'local') {
$transcode_to = 'wav';
$transcode_cfg = AmpConfig::get('transcode');
$valid_types = $song->get_stream_types();
if ($song->type != $transcode_to) {
@ -231,6 +232,9 @@ class Waveform
$temp = chr((ord($bytes[1]) & 127) + $temp);
$data = floor(self::findValues($bytes[0], $temp) / 256);
break;
default:
$data = 0;
break;
}
// skip bytes for memory optimization

View file

@ -24,7 +24,7 @@ class WebPlayer
{
public static function is_playlist_radio($playlist)
{
$radioas = array();
$radios = array();
foreach ($playlist->urls as $item) {
if ($item->type == "radio") {
@ -67,6 +67,7 @@ class WebPlayer
$types = array('real' => 'mp3', 'player' => '');
$browsers = array_keys(self::browser_info());
$browser = '';
if (count($browsers) > 0 ) {
$browser = $browsers[0];
}
@ -229,7 +230,7 @@ class WebPlayer
$js['filetype'] = $types['player'];
$js['url'] = $url;
if ($urlinfo['type'] == 'song') {
$js['poster'] = $item->image_url . (!$iframed ? '&thumb=4' : '');
$js['poster'] = $item->image_url . (!AmpConfig::get('iframes') ? '&thumb=4' : '');
}
debug_event("webplayer.class.php", "Return get_media_js_param {".json_encode($js)."}", 5);

View file

@ -251,8 +251,8 @@ class XML_Data
"\t<artists>" . intval($counts['artist']) . "</artists>\n" .
"\t<songs>" . intval($counts['song']) . "</songs>\n" .
"\t<videos>" . intval($counts['video']) . "</videos>\n" .
"\t<playlists>" . intval($count['playlist']) . "</playlists>\n" .
"\t<stream>" . intval($count['live_stream']) . "</stream>\n" .
"\t<playlists>" . intval($counts['playlist']) . "</playlists>\n" .
"\t<stream>" . intval($counts['live_stream']) . "</stream>\n" .
"</tag>\n";
} // end foreach
@ -325,6 +325,7 @@ class XML_Data
Rating::build_cache('album',$albums);
$string = "";
foreach ($albums as $album_id) {
$album = new Album($album_id);
$album->format();
@ -352,7 +353,7 @@ class XML_Data
"\t<preciserating>" . $rating->get_user_rating() . "</preciserating>\n" .
"\t<rating>" . $rating->get_user_rating() . "</rating>\n" .
"\t<averagerating>" . $rating->get_average_rating() . "</averagerating>\n" .
"\t<mbid>" . $artist->mbid . "</mbid>\n" .
"\t<mbid>" . $album->mbid . "</mbid>\n" .
"</album>\n";
} // end foreach
@ -417,6 +418,7 @@ class XML_Data
Song::build_cache($songs);
Stream::set_session($_REQUEST['auth']);
$string = "";
// Foreach the ids!
foreach ($songs as $song_id) {
$song = new Song($song_id);
@ -476,7 +478,6 @@ class XML_Data
}
$string = '';
foreach ($videos as $video_id) {
$video = new Video($video_id);
$video->format();
@ -520,15 +521,13 @@ class XML_Data
$song->format();
//FIXME: This is duplicate code and so wrong, functions need to be improved
$tag_string = '';
$tag = new Tag($song->tags['0']);
$song->genre = $tag->id;
$song->f_genre = $tag->name;
$tag_string = self::tags_string($song->tags);
$rating = new Rating($song_id,'song');
$rating = new Rating($song->id,'song');
$art_url = Art::url($song->album, 'album', $_REQUEST['auth']);

View file

@ -282,6 +282,7 @@ function generate_config($current)
$data = explode("\n",$dist);
$final = "";
foreach ($data as $line) {
if (preg_match("/^;?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$line,$matches)
|| preg_match("/^;?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $line, $matches)

View file

@ -34,11 +34,13 @@ require_once $prefix . '/lib/class/session.class.php';
Session::_auto_init();
// Set up for redirection on important error cases
$http_type = "http://";
$path = preg_replace('#(.*)/(\w+\.php)$#', '$1', $_SERVER['PHP_SELF']);
$path = $http_type . $_SERVER['HTTP_HOST'] . $path;
// Check to make sure the config file exists. If it doesn't then go ahead and
// send them over to the install script.
$results = array();
if (!file_exists($configfile)) {
$link = $path . '/install.php';
} else {

View file

@ -99,9 +99,6 @@ function install_check_status($configfile)
return false;
}
/* Defaut to no */
return false;
} // install_check_status
function install_check_server_apache()
@ -176,7 +173,7 @@ function install_insert_db($db_user = null, $db_pass = null, $create_db = true,
{
$database = AmpConfig::get('database_name');
// Make sure that the database name is valid
$is_valid = preg_match('/([^\d\w\_\-])/', $database, $matches);
preg_match('/([^\d\w\_\-])/', $database, $matches);
if (count($matches)) {
Error::add('general', T_('Error: Invalid database name.'));
@ -246,9 +243,9 @@ function install_insert_db($db_user = null, $db_pass = null, $create_db = true,
if (AmpConfig::get('lang') != 'en_US') {
// FIXME: 31? I hate magic.
$sql = 'UPDATE `preference` SET `value`= ? WHERE `id` = 31';
$db_results = Dba::write($sql, array(AmpConfig::get('lang')));
Dba::write($sql, array(AmpConfig::get('lang')));
$sql = 'UPDATE `user_preference` SET `value` = ? WHERE `preference` = 31';
$db_results = Dba::write($sql, array(AmpConfig::get('lang')));
Dba::write($sql, array(AmpConfig::get('lang')));
}
return true;
@ -264,7 +261,7 @@ function install_create_config($download = false)
$config_file = AmpConfig::get('prefix') . '/config/ampache.cfg.php';
/* Attempt to make DB connection */
$dbh = Dba::dbh();
Dba::dbh();
$params = AmpConfig::get_all();
if (empty($params['database_username']) || empty($params['database_password'])) {
@ -364,7 +361,7 @@ function command_exists($command)
if ($process !== false) {
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);

View file

@ -68,6 +68,9 @@ if (empty($_REQUEST['step'])) {
} elseif ($_SERVER['HTTP_REMOTE_USER']) {
$username = $_SERVER['HTTP_REMOTE_USER'];
}
else {
$username = '';
}
$password = '';
}
@ -94,7 +97,7 @@ if (empty($_REQUEST['step'])) {
}
}
if (!empty($username)) {
if (!empty($username) && isset($auth)) {
$user = User::get_from_username($username);
if ($user->disabled) {
@ -134,13 +137,13 @@ if (!empty($username)) {
// This allows stealing passwords validated by external means
// such as LDAP
if (AmpConfig::get('auth_password_save') && $auth['success'] && $password) {
if (AmpConfig::get('auth_password_save') && $auth['success'] && isset($password)) {
$user->update_password($password);
}
}
/* If the authentication was a success */
if ($auth['success']) {
if ($auth['success'] && isset($user)) {
// $auth->info are the fields specified in the config file
// to retrieve for each user
Session::create($auth);

View file

@ -28,8 +28,6 @@
*/
function update_preferences($pref_id=0)
{
$pref_user = new User($pref_id);
/* Get current keys */
$sql = "SELECT `id`,`name`,`type` FROM `preference`";
@ -38,6 +36,7 @@ function update_preferences($pref_id=0)
$db_results = Dba::read($sql);
$results = array();
// Collect the current possible keys
while ($r = Dba::fetch_assoc($db_results)) {
$results[] = array('id' => $r['id'], 'name' => $r['name'],'type' => $r['type']);
@ -46,7 +45,6 @@ function update_preferences($pref_id=0)
/* Foreach through possible keys and assign them */
foreach ($results as $data) {
/* Get the Value from POST/GET var called $data */
$type = $data['type'];
$name = $data['name'];
$apply_to_all = 'check_' . $data['name'];
$new_level = 'level_' . $data['name'];
@ -107,7 +105,7 @@ function update_preference($user_id,$name,$pref_id,$value)
/* Else make sure that the current users has the right to do this */
if (Preference::has_access($name)) {
$sql = "UPDATE `user_preference` SET `value` = ? WHERE `preference` = ? AND `user` = ?";
$db_results = Dba::write($sql, array($value, $pref_id, $user_id));
Dba::write($sql, array($value, $pref_id, $user_id));
return true;
}
@ -121,9 +119,6 @@ function update_preference($user_id,$name,$pref_id,$value)
*/
function create_preference_input($name,$value)
{
$len = strlen($value);
if ($len <= 1) { $len = 8; }
if (!Preference::has_access($name)) {
if ($value == '1') {
echo "Enabled";

View file

@ -41,26 +41,19 @@ function get_rating_name($score)
switch ($score) {
case '0':
return T_("Don't Play");
break;
case '1':
return T_("It's Pretty Bad");
break;
case '2':
return T_("It's Ok");
break;
case '3':
return T_("It's Pretty Good");
break;
case '4':
return T_("I Love It!");
break;
case '5':
return T_("It's Insane");
break;
// I'm fired
default:
return T_("Off the Charts!");
break;
} // end switch
return true;

View file

@ -81,7 +81,7 @@ function get_theme($name)
*/
function get_theme_author($theme_name)
{
$theme_path = AmpConfig::get('prefix') . '/themes/' . AmpConfig::get('theme_name') . '/theme.cfg.php';
$theme_path = AmpConfig::get('prefix') . '/themes/' . $theme_name . '/theme.cfg.php';
$results = read_config($theme_path);
return $results['author'];

View file

@ -180,8 +180,6 @@ function show_preference_box($preferences)
} // show_preference_box
static $album_id_cnt = 0;
/**
* show_album_select
* This displays a select of every album that we've got in Ampache (which can be
@ -189,9 +187,11 @@ static $album_id_cnt = 0;
*/
function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0)
{
static $album_id_cnt = 0;
// Generate key to use for HTML element ID
if ($song_id) {
$key = "album_select_$song_id";
$key = "album_select_" . $song_id;
} else {
$key = "album_select_c" . ++$album_id_cnt;
}
@ -225,8 +225,6 @@ function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0)
} // show_album_select
static $artist_id_cnt = 0;
/**
* show_artist_select
* This is the same as show_album_select except it's *gasp* for artists! How
@ -234,9 +232,10 @@ static $artist_id_cnt = 0;
*/
function show_artist_select($name='artist', $artist_id=0, $allow_add=0, $song_id=0)
{
static $artist_id_cnt = 0;
// Generate key to use for HTML element ID
if ($song_id) {
$key = "artist_select_$song_id";
$key = "artist_select_" . $song_id;
} else {
$key = "artist_select_c" . ++$artist_id_cnt;
}
@ -415,7 +414,6 @@ function xml_from_array($array, $callback = false, $type = '')
} // end foreach
return $string;
break;
case 'xspf':
foreach ($array as $key=>$value) {
if (is_array($value)) {
@ -435,7 +433,6 @@ function xml_from_array($array, $callback = false, $type = '')
} // end foreach
return $string;
break;
default:
foreach ($array as $key => $value) {
// No numeric keys
@ -459,7 +456,6 @@ function xml_from_array($array, $callback = false, $type = '')
}
return UI::clean_utf8($string);
break;
}
} // xml_from_array
@ -489,7 +485,6 @@ function xml_get_header($type)
" <key>Tracks</key>\n" .
" <dict>\n";
return $header;
break;
case 'xspf':
$header = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" .
"<!-- XML Generated by Ampache v." . AmpConfig::get('version') . " -->";
@ -500,11 +495,9 @@ function xml_get_header($type)
"<info>". AmpConfig::get('web_path') ."</info>\n" .
"<trackList>\n\n\n\n";
return $header;
break;
default:
$header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
return $header;
break;
}
} //xml_get_header
@ -520,12 +513,10 @@ function xml_get_footer($type)
"</dict>\n" .
"</plist>\n";
return $footer;
break;
case 'xspf':
$footer = " </trackList>\n" .
"</playlist>\n";
return $footer;
break;
default:
break;
@ -571,7 +562,6 @@ function show_now_playing()
Session::gc();
Stream::gc_now_playing();
$web_path = AmpConfig::get('web_path');
$results = Stream::get_now_playing();
require_once AmpConfig::get('prefix') . '/templates/show_now_playing.inc.php';

Binary file not shown.

View file

@ -3575,7 +3575,7 @@ msgstr "Partager"
#: ../../templates/show_album.inc.php:131
#: ../../templates/show_album_row.inc.php:79
msgid "Album edit"
msgstr "Edition de l'album"
msgstr "Edition album"
#: ../../templates/show_album.inc.php:66
#: ../../templates/show_artist.inc.php:63
@ -3709,7 +3709,7 @@ msgstr "Tout ajouter aléatoirement à la liste de lecture temporaire"
#: ../../templates/show_artist.inc.php:122
#: ../../templates/show_artist_row.inc.php:61
msgid "Artist edit"
msgstr "Edition de l'artiste"
msgstr "Edition artiste"
#: ../../templates/show_artist.inc.php:123
msgid "Edit Artist"

View file

@ -71,8 +71,8 @@ switch ($_REQUEST['action']) {
$fields = $localplay->get_instance_fields();
require_once AmpConfig::get('prefix') . '/templates/show_localplay_instances.inc.php';
break;
default:
case 'show_playlist':
default:
if (!Access::check('localplay','5')) { UI::access_denied(); break; }
// Init and then connect to our localplay instance
$localplay = new Localplay(AmpConfig::get('localplay_controller'));

View file

@ -68,8 +68,8 @@ if ($type == 'playlist') {
}
/* This is specifically for tmp playlist requests */
$demo_id = scrub_in($_REQUEST['demo_id']);
$random = scrub_in($_REQUEST['random']);
$demo_id = Dba::escape($_REQUEST['demo_id']);
$random = Dba::escape($_REQUEST['random']);
/* First things first, if we don't have a uid/oid stop here */
if (empty($oid) && empty($demo_id) && empty($random)) {
@ -155,7 +155,7 @@ if (AmpConfig::get('access_control')) {
} // access_control is enabled
// Handle playlist downloads
if ($type == 'playlist') {
if ($type == 'playlist' && isset($playlist_type)) {
$playlist = new Stream_Playlist($oid);
// Some rudimentary security
if ($uid != $playlist->user) {
@ -181,6 +181,7 @@ if ($demo_id) {
$oid = $democratic->get_next_object();
} else {
// Pull history
$song_cool_check = 0;
$oid = $democratic->get_next_object($song_cool_check);
$oids = $democratic->get_cool_songs();
while (in_array($oid,$oids)) {
@ -196,7 +197,7 @@ if ($demo_id) {
* if we are doing random let's pull the random object
*/
if ($random) {
if ($start < 1) {
if ($_REQUEST['start'] < 1) {
$oid = Random::get_single_song($_REQUEST['random_type']);
// Save this one in case we do a seek
$_SESSION['random']['last'] = $oid;
@ -225,7 +226,7 @@ if ($media->catalog) {
if (!make_bool($media->enabled)) {
debug_event('Play', "Error: $media->file is currently disabled, song skipped", '5');
// Check to see if this is a democratic playlist, if so remove it completely
if ($demo_id) { $democratic->delete_from_oid($oid, 'song'); }
if ($demo_id && isset($democratic)) { $democratic->delete_from_oid($oid, 'song'); }
exit;
}
@ -413,6 +414,8 @@ if (get_class($media) == 'Song') {
// Handle Content-Range
$start = 0;
$end = 0;
sscanf($_SERVER['HTTP_RANGE'], "bytes=%d-%d", $start, $end);
if ($start > 0 || $end > 0) {
@ -449,7 +452,7 @@ if ($transcode) {
header('Accept-Ranges: bytes');
}
$mime = $transcode
$mime = ($transcode && isset($transcoder))
? $media->type_to_mime($transcoder['format'])
: $media->mime;
@ -498,7 +501,7 @@ if ($demo_id) { $democratic->delete_from_oid($oid,'song'); }
if ($transcode) {
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
$stderr = fread($transcoder['stderr'], 8192);
fread($transcoder['stderr'], 8192);
fclose($transcoder['stderr']);
}
fclose($fp);

View file

@ -39,16 +39,6 @@ UI::show_header();
/* Switch on the action passed in */
switch ($_REQUEST['action']) {
case 'add_dyn_song':
/* Check Rights */
if (!$playlist->has_access()) {
UI::access_denied();
break;
}
$playlist->add_dyn_song();
$_SESSION['data']['playlist_id'] = $playlist->id;
break;
case 'create_playlist':
/* Check rights */
if (!Access::check('interface','25')) {
@ -67,14 +57,6 @@ switch ($_REQUEST['action']) {
// If we made it here, we didn't have sufficient rights.
UI::access_denied();
break;
case 'remove_song':
/* Check em for rights */
if (!$playlist->has_access()) {
UI::access_denied();
break;
}
$playlist->remove_songs($_REQUEST['song']);
break;
case 'show_playlist':
$playlist = new Playlist($_REQUEST['playlist_id']);
$playlist->format();

View file

@ -22,6 +22,10 @@
require_once 'lib/init.php';
$title = "";
$text = "";
$next_url = "";
// Switch on the action
switch ($_REQUEST['action']) {
case 'update_preferences':
@ -35,6 +39,7 @@ switch ($_REQUEST['action']) {
exit;
}
$system = false;
/* Reset the Theme */
if ($_POST['method'] == 'admin') {
$user_id = '-1';

View file

@ -29,9 +29,11 @@ switch ($_REQUEST['action']) {
$object_ids = Random::advanced($_REQUEST['type'], $_POST);
// We need to add them to the active playlist
if (is_array($object_ids)) {
foreach ($object_ids as $object_id) {
$GLOBALS['user']->playlist->add_object($object_id, 'song');
}
}
case 'advanced':
default:
require_once AmpConfig::get('prefix') . '/templates/show_random.inc.php';

View file

@ -122,8 +122,8 @@ switch ($_REQUEST['action']) {
case 'user':
$access = '25';
break;
default:
case 'guest':
default:
$access = '5';
break;
} // auto-user level

View file

@ -46,14 +46,14 @@ switch ($_REQUEST['action']) {
$playlist = new Search();
$playlist->parse_rules(Search::clean_request($_REQUEST));
$playlist->save();
default:
require_once AmpConfig::get('prefix') . '/templates/show_search.inc.php';
break;
case 'descriptor':
// This is a little special we don't want header/footers so trash what we've got in the OB
ob_clean();
require_once AmpConfig::get('prefix') . '/templates/show_search_descriptor.inc.php';
exit;
default:
require_once AmpConfig::get('prefix') . '/templates/show_search.inc.php';
break;
}

View file

@ -38,54 +38,42 @@ switch ($page) {
case 'stats':
require_once AmpConfig::get('prefix') . '/server/stats.ajax.php';
exit;
break;
case 'browse':
require_once AmpConfig::get('prefix') . '/server/browse.ajax.php';
exit;
break;
case 'random':
require_once AmpConfig::get('prefix') . '/server/random.ajax.php';
exit;
break;
case 'playlist':
require_once AmpConfig::get('prefix') . '/server/playlist.ajax.php';
exit;
break;
case 'localplay':
require_once AmpConfig::get('prefix') . '/server/localplay.ajax.php';
exit;
break;
case 'tag':
require_once AmpConfig::get('prefix') . '/server/tag.ajax.php';
exit;
break;
case 'stream':
require_once AmpConfig::get('prefix') . '/server/stream.ajax.php';
exit;
break;
case 'song':
require_once AmpConfig::get('prefix') . '/server/song.ajax.php';
exit;
break;
case 'democratic':
require_once AmpConfig::get('prefix') . '/server/democratic.ajax.php';
exit;
break;
case 'index':
require_once AmpConfig::get('prefix') . '/server/index.ajax.php';
exit;
case 'catalog':
require_once AmpConfig::get('prefix') . '/server/catalog.ajax.php';
exit;
break;
case 'search':
require_once AmpConfig::get('prefix') . '/server/search.ajax.php';
exit;
break;
case 'player':
require_once AmpConfig::get('prefix') . '/server/player.ajax.php';
exit;
break;
default:
// A taste of compatibility
break;
@ -115,8 +103,8 @@ switch ($_REQUEST['action']) {
}
if ($_POST['type'] == 'smartplaylist_row' ||
$_POST['type'] == 'smartplaylist_title') {
$playlist = new Search('song', $_POST['id']);
if ($GLOBALS['user']->id == $playlist->user) {
$smartpl = new Search('song', $_POST['id']);
if ($GLOBALS['user']->id == $smartpl->user) {
$level = '25';
}
}
@ -158,17 +146,21 @@ switch ($_REQUEST['action']) {
case 'playlist_row':
case 'playlist_title':
$key = 'playlist_row_' . $_POST['id'];
if (isset($playlist)) {
$playlist->update($_POST);
$playlist->format();
$count = $playlist->get_song_count();
}
break;
case 'smartplaylist_row':
case 'smartplaylist_title':
$key = 'smartplaylist_row_' . $_POST['id'];
$playlist->name = $_POST['name'];
$playlist->type = $_POST['pl_type'];
$playlist->update();
$playlist->format();
if (isset($smartpl)) {
$smartpl->name = $_POST['name'];
$smartpl->type = $_POST['pl_type'];
$smartpl->update();
$smartpl->format();
}
break;
case 'live_stream_row':
$key = 'live_stream_' . $_POST['id'];
@ -194,7 +186,6 @@ switch ($_REQUEST['action']) {
$key = 'rfc3514';
echo xoutput_from_array(array($key=>'0x1'));
exit;
break;
} // end switch on type
$results['id'] = $new_id;

View file

@ -45,6 +45,7 @@ if (isset($_REQUEST['show_header']) && $_REQUEST['show_header']) {
debug_event('browse.ajax.php', 'Called for action: {'.$_REQUEST['action'].'}', '5');
$results = array();
switch ($_REQUEST['action']) {
case 'browse':
$object_ids = array();
@ -62,7 +63,7 @@ switch ($_REQUEST['action']) {
$browse->set_sort($_REQUEST['sort']);
}
if ($_REQUEST['catalog_key'] || $SESSION['catalog'] != 0) {
if ($_REQUEST['catalog_key'] || $_SESSION['catalog'] != 0) {
$browse->set_filter('catalog',$_REQUEST['catalog_key']);
$_SESSION['catalog'] = $_REQUEST['catalog_key'];
} elseif ($_REQUEST['catalog_key'] == 0) {
@ -115,8 +116,7 @@ switch ($_REQUEST['action']) {
$key = 'live_stream_' . $radio->id;
break;
default:
break;
exit;
} // end switch on type
$results[$key] = '';

View file

@ -28,6 +28,8 @@ if (!defined('AJAX_INCLUDE')) { exit; }
$democratic = Democratic::get_current_playlist();
$democratic->set_parent();
$show_browse = false;
$results = array();
switch ($_REQUEST['action']) {
case 'delete_vote':
$democratic->remove_vote($_REQUEST['row_id']);

View file

@ -25,6 +25,7 @@
*/
if (!defined('AJAX_INCLUDE')) { exit; }
$results = array();
switch ($_REQUEST['action']) {
case 'random_albums':
$albums = Album::get_random(6, true);
@ -133,6 +134,7 @@ switch ($_REQUEST['action']) {
$mbid = $_REQUEST['mbid'];
if (empty($_REQUEST['artist'])) {
$artist_mbid = $_REQUEST['artist_mbid'];
$artist = null;
} else {
$artist = $_REQUEST['artist'];
$aobj = new Artist($artist);
@ -200,7 +202,6 @@ switch ($_REQUEST['action']) {
break;
default:
exit;
break;
} // end switch on button
ob_start();

View file

@ -25,6 +25,7 @@
*/
if (!defined('AJAX_INCLUDE')) { exit; }
$results = array();
switch ($_REQUEST['action']) {
case 'set_instance':
// Make sure they they are allowed to do this

View file

@ -26,6 +26,7 @@
*/
if (!defined('AJAX_INCLUDE')) { exit; }
$results = array();
switch ($_REQUEST['action']) {
case 'show_broadcasts':
ob_start();
@ -34,7 +35,6 @@ switch ($_REQUEST['action']) {
ob_end_clean();
echo $results;
exit;
break;
case 'broadcast':
$broadcast_id = $_GET['broadcast_id'];
if (empty($broadcast_id)) {

View file

@ -25,6 +25,7 @@
*/
if (!defined('AJAX_INCLUDE')) { exit; }
$results = array();
switch ($_REQUEST['action']) {
case 'delete_track':
// Create the object and remove the track

View file

@ -25,6 +25,7 @@
*/
if (!defined('AJAX_INCLUDE')) { exit; }
$results = array();
switch ($_REQUEST['action']) {
case 'song':
$songs = Random::get_default();
@ -73,12 +74,14 @@ switch ($_REQUEST['action']) {
$results['rightbar'] = UI::ajax_include('rightbar.inc.php');
break;
case 'advanced_random':
$object_ids = Random::advanced($_POST);
$object_ids = Random::advanced('song', $_POST);
// First add them to the active playlist
if (is_array($object_ids)) {
foreach ($object_ids as $object_id) {
$GLOBALS['user']->playlist->add_object($object_id,'song');
}
}
$results['rightbar'] = UI::ajax_include('rightbar.inc.php');
// Now setup the browse and show them below!

View file

@ -28,6 +28,7 @@ if (!defined('AJAX_INCLUDE')) { exit; }
debug_event('stream.ajax.php', 'Called for action {'.$_REQUEST['action'].'}', 5);
$results = array();
switch ($_REQUEST['action']) {
case 'set_play_type':
// Make sure they have the rights to do this

View file

@ -25,6 +25,7 @@
*/
if (!defined('AJAX_INCLUDE')) { exit; }
$results = array();
switch ($_REQUEST['action']) {
case 'show_add_tag':
@ -47,7 +48,6 @@ switch ($_REQUEST['action']) {
$tag->delete();
header('Location: ' . AmpConfig::get('web_path') . '/browse.php?action=tag');
exit;
break;
case 'remove_tag_map':
debug_event('tag.ajax', 'Removing tag map...', '5');
$tag = new Tag($_GET['tag_id']);

View file

@ -53,8 +53,7 @@ switch ($action) {
}
}
UI::show_footer();
exit();
break;
exit;
case 'create':
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
@ -86,8 +85,7 @@ switch ($action) {
show_confirmation($title, $body, AmpConfig::get('web_path') . '/stats.php?action=share');
}
UI::show_footer();
exit();
break;
exit;
case 'show_delete':
UI::show_header();
$id = $_REQUEST['id'];
@ -95,8 +93,7 @@ switch ($action) {
$next_url = AmpConfig::get('web_path') . '/share.php?action=delete&id=' . scrub_out($id);
show_confirmation(T_('Share Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_share');
UI::show_footer();
exit();
break;
exit;
case 'delete':
if (AmpConfig::get('demo_mode')) {
UI::access_denied();
@ -110,8 +107,7 @@ switch ($action) {
show_confirmation(T_('Share Deleted'), T_('The Share has been deleted'), $next_url);
}
UI::show_footer();
exit();
break;
exit;
}
/**

View file

@ -45,7 +45,7 @@ switch ($_REQUEST['action']) {
// Get our object first
$object = Shoutbox::get_object($_REQUEST['type'],$_REQUEST['id']);
if (!$object->id) {
if (!$object || !$object->id) {
Error::add('general', T_('Invalid Object Selected'));
Error::display('general');
break;

View file

@ -100,7 +100,6 @@ switch ($_REQUEST['action']) {
break;
case 'artist_random':
$artist = new Artist($_REQUEST['artist_id']);
$artist->get_count();
$media_ids = $artist->get_random_songs();
break;
case 'album_random':
@ -123,7 +122,7 @@ switch ($_REQUEST['action']) {
break;
case 'playlist':
$playlist = new Playlist($_REQUEST['playlist_id']);
$songs = $playlist->get_songs($_REQUEST['song']);
$songs = $playlist->get_songs();
foreach ($songs as $song) {
$media_ids[] = array(
'object_type' => 'song',
@ -141,9 +140,10 @@ switch ($_REQUEST['action']) {
break;
case 'playlist_random':
$playlist = new Playlist($_REQUEST['playlist_id']);
$media_ids = $playlist->get_random_songs();
$media_ids = $playlist->get_random_items();
break;
case 'random':
$matchlist = array();
if ($_REQUEST['genre'][0] != '-1') {
$matchlist['genre'] = $_REQUEST['genre'];
}

View file

@ -1,40 +0,0 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* Copyright 2001 - 2014 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
?>
<script type='text/javascript'>
function insert()
{
document.getElementById('artist_name').value = '<?php echo $artist->name; ?>';
}
</script>
<?php /* HINT: Artist Name */ UI::show_box_top(sprintf(T_('Rename %s'), $artist->name)); ?>
<form name="rename_artist" method="post" action="<?php echo AmpConfig::get('web_path'); ?>/artists.php?action=rename&amp;artist=<?php echo $artist->id; ?>" style="Display:inline;">
<?php show_artist_pulldown($artist->id, "artist_id", 4); ?>
<br />
<?php echo T_('OR'); ?><br />
<input type="text" name="artist_name" value="<?php echo scrub_out($_REQUEST['artist_name']); ?>" id="artist_name" />
<a href="javascript:insert()">[<?php echo T_('Insert current'); ?>]</a><br />
<?php $GLOBALS['error']->print_error('artist_name'); ?>
<input type="checkbox" name="update_id3" value="yes" />&nbsp; <?php echo T_('Update id3 tags') ?><br />
<input type="submit" value="<?php echo T_('Rename'); ?>" /><br />
</form>
<?php UI::show_box_bottom(); ?>