summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/class/album.class.php5
-rw-r--r--lib/class/localplay.class.php20
-rw-r--r--lib/class/stream.class.php57
-rw-r--r--lib/class/update.class.php4
-rw-r--r--lib/class/user.class.php12
-rw-r--r--lib/debug.lib.php28
-rw-r--r--lib/general.lib.php1
-rw-r--r--lib/init.php4
-rw-r--r--lib/preferences.php18
9 files changed, 122 insertions, 27 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 50d7d490..12c668ae 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -385,6 +385,11 @@ class Album {
*/
function insert_art($image, $mime) {
+ /* Have to disable this for Demo because people suck and try to
+ * insert PORN :(
+ */
+ if (conf('demo_mode')) { return false; }
+
// Check for PHP:GD and if we have it make sure this image is of some size
if (function_exists('ImageCreateFromString')) {
$im = @ImageCreateFromString($image);
diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php
index 9dbc7958..ba5c3c2a 100644
--- a/lib/class/localplay.class.php
+++ b/lib/class/localplay.class.php
@@ -165,6 +165,7 @@ class Localplay {
$this->_function_map['delete_all'] = $data['delete_all'];
$this->_function_map['randomize'] = $data['randomize'];
$this->_function_map['move'] = $data['move'];
+ $this->_function_map['add_url'] = $data['add_url'];
} // _map_functions
@@ -249,6 +250,25 @@ class Localplay {
} // add
/**
+ * add_url
+ * This directly adds an array of URLs to the localplay module. This is really how I should
+ * have done add, will migrate to this eventually
+ */
+ function add_url($urls) {
+
+ $function = $this->_function_map['add_url'];
+
+ if (!$this->_player->$function($urls)) {
+ debug_event('localplay','Error Unable to add urls, check ' . $this->type . ' controller','1');
+ return false;
+ }
+
+
+ return true;
+
+ } // add_url
+
+ /**
* repeat
* This turns the repeat feature of a localplay method on or
* off, takes a 0/1 value
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index 6a5599a2..254a0fd4 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -19,16 +19,20 @@
*/
-/*!
- @header Stream Class
-*/
-
+/**
+ * Stream
+ * This class is used to generate the Playlists and pass them on
+ * With Localplay this actually just sends the commands to the localplay
+ * module in question. It has two sources for data
+ * songs (array of ids) and urls (array of full urls)
+ */
class Stream {
/* Variables from DB */
var $type;
var $web_path;
var $songs = array();
+ var $urls = array();
var $sess;
/*!
@@ -84,7 +88,7 @@ class Stream {
*/
function manual_url_add($url) {
-
+ $this->urls[] = $url;
} // manual_url_add
@@ -98,6 +102,8 @@ class Stream {
header("Cache-control: public");
header("Content-Disposition: filename=playlist.m3u");
header("Content-Type: audio/x-mpegurl;");
+
+ /* Foreach songs */
foreach ($this->songs as $song_id) {
$song = new Song($song_id);
if ($song->type == ".flac") { $song->type = ".ogg"; }
@@ -107,6 +113,11 @@ class Stream {
echo "$this->web_path/play/index.php?song=$song_id&uid=$this->user_id&sid=$this->sess&ds=$ds&stupidwinamp=." . $song->type . "\n";
} // end foreach
+ /* Foreach the additional URLs */
+ foreach ($this->urls as $url) {
+ echo "$url\n";
+ }
+
} // simple_m3u
/*!
@@ -133,6 +144,12 @@ class Stream {
echo $song->get_url() . "\n";
} // end foreach
+ /* Foreach URLS */
+ foreach ($this->urls as $url) {
+ echo "#EXTINF: URL-Add\n";
+ echo $url . "\n";
+ }
+
} // create_m3u
/*!
@@ -141,12 +158,15 @@ class Stream {
*/
function create_pls() {
+ /* Count entries */
+ $total_entries = count($this->songs) + count($this->urls);
+
// Send the client a pls playlist
header("Cache-control: public");
header("Content-Disposition: filename=playlist.pls");
header("Content-Type: audio/x-scpls;");
echo "[Playlist]\n";
- echo "NumberOfEntries=" . count($this->songs) . "\n";
+ echo "NumberOfEntries=$total_entries\n";
foreach ($this->songs as $song_id) {
$i++;
$song = new Song($song_id);
@@ -157,6 +177,15 @@ class Stream {
echo "Title" . $i . "=$song_name\n";
echo "Length" . $i . "=-1\n";
} // end foreach songs
+
+ /* Foreach Additional URLs */
+ foreach ($this->urls as $url) {
+ $i++;
+ echo "File" . $i ."=$url\n";
+ echo "Title". $i . "=AddedURL\n";
+ echo "Length" . $i . "=-1\n";
+ } // end foreach urls
+
echo "Version=2\n";
} // create_pls
@@ -188,6 +217,15 @@ class Stream {
} // end foreach
+ /* Foreach urls */
+ foreach ($this->urls as $url) {
+ echo "<ENTRY>\n";
+ echo "<TITLE>AddURL</TITLE>\n";
+ echo "<AUTHOR>AddURL</AUTHOR>\n";
+ echo "<REF HREF=\"$url\" />\n";
+ echo "</ENTRY>\n";
+ } // end foreach
+
echo "</ASX>\n";
} // create_asx
@@ -280,6 +318,12 @@ class Stream {
$localplay = init_localplay();
$localplay->connect();
$localplay->add($this->songs);
+
+ /* Check for Support */
+ if ($localplay->has_function('add_url')) {
+ $localplay->add_url($this->urls);
+ }
+
$localplay->play();
header("Location: " . return_referer());
@@ -315,7 +359,6 @@ class Stream {
} // foreach songs
} // create_ram
-
} //end of stream class
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index 41d56f3d..9375883b 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -2093,6 +2093,10 @@ class Update {
while ($r = mysql_fetch_assoc($db_results)) {
$user->fix_preferences($r['username']);
} // while results
+
+ /* Drop the unused user_catalog table */
+ $sql = "DROP TABLE `user_catalog`";
+ $db_results = mysql_query($sql,dbh());
$this->set_version('db_version','333002');
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index 9c8572af..fefca81f 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -248,6 +248,7 @@ class User {
/**
* update_preference
+ * //FIXME: Unused at this point, should be removed or used
* updates a single preference if the query fails
* it attempts to insert the preference instead
* @package User
@@ -255,14 +256,21 @@ class User {
* @todo Do a has_preference_access check
*/
function update_preference($preference_id, $value, $username=0) {
-
+
+ if (!has_preference_access(get_preference_name($preference_id))) {
+ return false;
+ }
+
if (!$username) {
$username = $this->username;
}
if (!conf('use_auth')) { $username = '-1'; }
- $value = sql_escape($value);
+ $value = sql_escape($value);
+ $preference_id = sql_escape($preference_id);
+ $username = sql_escape($username);
+
$sql = "UPDATE user_preference SET value='$value' WHERE user='$username' AND preference='$preference_id'";
$db_results = @mysql_query($sql, dbh());
diff --git a/lib/debug.lib.php b/lib/debug.lib.php
index 04e77887..cccfd8e6 100644
--- a/lib/debug.lib.php
+++ b/lib/debug.lib.php
@@ -225,22 +225,6 @@ function check_config_values($conf) {
} // check_config_values
/*!
- @function show_compare_config
- @discussion shows the difference between ampache.cfg
- and ampache.cfg.dst
-*/
-function show_compare_config($prefix) {
-
- // Live Config File
- $live_config = $prefix . "/config/ampache.cfg.php";
-
- // Generic Config File
- $generic_config = $prefix . "/config/ampache.cfg.dist";
-
-} // show_compare_config
-
-
-/*!
@function debug_read_config
@discussion this is the same as the read config function
except it will pull config values with a # before them
@@ -328,8 +312,16 @@ function debug_compare_configs($config,$dist_config) {
foreach ($dist_results as $key=>$value) {
if (!isset($results[$key])) {
- $missing[$key] = $value;
- }
+ /* If it's an array we need to split it out */
+ if (is_array($value)) {
+ foreach ($value as $element) {
+ $missing[$key][] = $element;
+ }
+ }
+ else {
+ $missing[$key] = $value;
+ } // end else not array
+ } // if it's not set
} // end foreach conf
diff --git a/lib/general.lib.php b/lib/general.lib.php
index b6c7c3fc..f49acb85 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -864,6 +864,7 @@ function get_languages() {
case 'es_ES'; $name = 'Espa&ntilde;ol'; break;
case 'fr_FR'; $name = 'Fran&ccedil;ais'; break;
case 'it_IT'; $name = 'Italiano'; break;
+ case 'is_IS'; $name = '&Iacute;slenska'; break;
case 'nl_NL'; $name = 'Nederlands'; break;
case 'tr_TR'; $name = _('Turkish'); break;
case 'zh_CN'; $name = _('Simplified Chinese') . " (&#x7b80;&#x4f53;&#x4e2d;&#x6587;)"; break;
diff --git a/lib/init.php b/lib/init.php
index 5a9895fb..d645f0ae 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -112,6 +112,10 @@ if (!$results['user_ip_cardinality']) {
if (!$results['local_length']) {
$results['local_length'] = '9000';
}
+/* Default it for now until I can get the auto-config updater working */
+if (!$results['tag_order']) {
+ $results['tag_order'] = array('id3v2','id3v1','vorbiscomment','quicktime','file');
+}
/* Variables needed for vauth Module */
diff --git a/lib/preferences.php b/lib/preferences.php
index ac18479c..6d1d5a5a 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -368,6 +368,24 @@ function get_preference_id($name) {
} // get_preference_id
/**
+ * get_preference_name
+ * This does the inverse of the above function and returns the preference name from the ID
+ * This is usefull for doing... the opposite of above. Amazing isn't it.
+ */
+function get_preference_name($id) {
+
+ $id = sql_escape($id);
+
+ $sql = "SELECT name FROM preferences WHERE id='$id'";
+ $db_results = mysql_query($sql,dbh());
+
+ $results = mysql_fetch_assoc($db_results);
+
+ return $results['name'];
+
+} // get_preference_name
+
+/**
* insert_preference
* This creates a new preference record in the
* preferences table this is used by the modules