summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/quarantine_migration.php.inc2
-rwxr-xr-xdocs/CHANGELOG2
-rw-r--r--lib/class/stream.class.php14
-rw-r--r--lib/class/tmp_playlist.class.php133
-rw-r--r--lib/preferences.php3
-rw-r--r--modules/archive/archive.lib.php29
6 files changed, 160 insertions, 23 deletions
diff --git a/bin/quarantine_migration.php.inc b/bin/quarantine_migration.php.inc
index df81f290..4dfcde6f 100644
--- a/bin/quarantine_migration.php.inc
+++ b/bin/quarantine_migration.php.inc
@@ -26,6 +26,8 @@
$no_session='1';
require_once('../lib/init.php');
+init_preferences();
+
usage();
// grab list of files from table
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index 535094c7..750689b6 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,8 @@
--------------------------------------------------------------------------
v.3.3.3-Alpha1
+ - Fixed false positive error and PHP5 related error on archive
+ creation
- Added <image> tag for album art and ability to filter rss feed
by user by adding ?username=<username> to rss link.
- Added LDAP/Active Directory auth support (Thx Rubin & pb1dft)
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index ea9baf9f..5c9a54fa 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -280,6 +280,20 @@ class Stream {
} // create_localplay
+ /**
+ * create_democratic
+ * This 'votes' on the songs it inserts them into
+ * a tmp_playlist with user of -1 (System)
+ */
+ function create_democratic() {
+
+ $tmp_playlist = new tmpPlaylist('-1');
+ $tmp_playlist->vote($this->songs);
+
+ header("Location: " . return_referer());
+
+ } // create_democratic
+
/*!
@function create_mpd
@discussion function that passes information to
diff --git a/lib/class/tmp_playlist.class.php b/lib/class/tmp_playlist.class.php
index 7c29c235..2bf4cd4a 100644
--- a/lib/class/tmp_playlist.class.php
+++ b/lib/class/tmp_playlist.class.php
@@ -78,4 +78,137 @@ class tmpPlaylist {
} // _get_info
+ /**
+ * get_items
+ * This returns an array of all object_ids currently in this tmpPlaylist
+ */
+ function get_items() {
+
+ $sql = "SELECT object_id FROM tmp_playlist_data " .
+ "WHERE tmp_playlist_data.tmp_playlist='" . sql_escape($this->id) . "'";
+ $db_results = mysql_query($sql, dbh());
+
+ while ($results = mysql_fetch_assoc($db_results)) {
+ $items[] = $results['id'];
+ }
+
+ return $items;
+
+ } // get_items
+
+ /**
+ * ceate
+ * This function initializes a new tmpPlaylist it is assoicated with the current
+ * session rather then a user, as you could have same user multiple locations
+ */
+ function create($sessid,$type,$object_type,$base_playlist) {
+
+ $sessid = sql_escape($sessid);
+ $type = sql_escape($type);
+ $object_type = sql_escape($object_type);
+ $base_playlist = sql_escape($base_playlist);
+
+ $sql = "INSERT INTO tmp_playlist (`session`,`type`,`object_type`,`base_playlist`) " .
+ " VALUES ('$sessid','$type','$object_type','$base_playlist')";
+ $db_results = mysql_query($sql, dbh());
+
+ $id = mysql_insert_id(dbh());
+
+ return $id;
+
+ } // create
+
+ /**
+ * vote
+ * This function is called by users to vote on a system wide playlist
+ * This adds the specified objects to the tmp_playlist and adds a 'vote'
+ * by this user, naturally it checks to make sure that the user hasn't
+ * already voted on any of these objects
+ */
+ function vote($items) {
+
+ /* Itterate through the objects if no vote, add to playlist and vote */
+ foreach ($items as $object_id) {
+ if (!$this->has_vote($object_id)) {
+ $this->add_vote($object_id);
+ }
+ } // end foreach
+
+
+ } // vote
+
+ /**
+ * add_vote
+ * This takes a object id and user and actually inserts the row
+ */
+ function add_vote($object_id) {
+
+ $object_id = sql_escape($object_id);
+
+ /* If it's on the playlist just vote */
+ $sql = "SELECT id FROM tmp_playlist_data " .
+ "WHERE tmp_playlist_data.object_id='$object_id'";
+ $db_results = mysql_query($sql, dbh());
+
+ /* If it's not there, add it and pull ID */
+ if (!$results = mysql_fetch_assoc($db_results)) {
+ $sql = "INSERT INTO tmp_playlist_data (`tmp_playlist`,`object_id`) " .
+ "VALUES ('-1','$object_id')";
+ $db_results = mysql_query($sql, dbh());
+ $results['id'] = mysql_insert_id(dbh());
+ }
+
+ /* Vote! */
+ $sql = "INSERT INTO user_vote (`user`,`object_id`) " .
+ "VALUES ('" . sql_escape($GLOBALS['user']->id) . "','" . $results['id'] . "')";
+ $db_results = mysql_query($sql, dbh());
+
+ return true;
+
+ } // add_vote
+
+ /**
+ * has_vote
+ * This checks to see if the current user has already voted on this object
+ */
+ function has_vote($object_id) {
+
+ /* Query vote table */
+ $sql = "SELECT tmp_playlist_data.id FROM user_vote " .
+ "INNER JOIN tmp_playlist_data ON tmp_playlist_data.id=user_vote.object_id " .
+ "WHERE user_vote.user='" . sql_escape($GLOBALS['user']->id) . "' " .
+ " AND tmp_playlist_data.object_id='" . sql_escape($object_id) . "' " .
+ " AND tmp_playlist_data.tmp_playlist='-1'";
+ $db_results = mysql_query($sql, dbh());
+
+ /* If we find row, they've voted!! */
+ if (mysql_num_rows($db_results)) {
+ return false;
+ }
+
+ return true;
+
+ } // has_vote
+
+ /**
+ * delete_track
+ * This deletes a track and any assoicated votes, we only check for
+ * votes if it's a -1 session
+ */
+ function delete_track($id) {
+
+ $id = sql_escape($id);
+
+ /* If this is a -1 session then kill votes as well */
+ if ($this->session = '-1') {
+ $sql = "DELETE FROM user_vote WHERE object_id='$id'";
+ $db_results = mysql_query($sql, dbh());
+ }
+
+ /* delete the track its self */
+ $sql = "DELETE FROM tmp_playlist_data WHERE id='$id'";
+ $db_results = mysql_query($sql,dbh());
+
+ } // delete_track
+
} // class tmpPlaylist
diff --git a/lib/preferences.php b/lib/preferences.php
index ba28affb..81957c67 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -268,6 +268,9 @@ function create_preference_input($name,$value) {
if (conf('allow_downsample_playback')) {
echo "\t<option value=\"downsample\" $is_down>" . _('Downsample') . "</option>\n";
}
+ if (conf('allow_democratic_playback')) {
+ echo "\t<option value=\"democratic\" $is_demo>" . _('Voting') . "</option>\n";
+ }
echo "\t<option value=\"localplay\" $is_local>" . _('Localplay') . "</option>\n";
echo "</select>\n";
break;
diff --git a/modules/archive/archive.lib.php b/modules/archive/archive.lib.php
index 2f67af19..f6662c60 100644
--- a/modules/archive/archive.lib.php
+++ b/modules/archive/archive.lib.php
@@ -134,7 +134,10 @@ class archive
if ($this->options['type'] == "gzip" || $this->options['type'] == "bzip")
unlink($this->options['basedir'] . "/" . $this->options['name'] . ".tmp");
}
- }
+
+ return true;
+
+ } // create_archive
function add_data($data)
{
@@ -228,9 +231,7 @@ class archive
chdir($pwd);
unset ($current, $pwd);
-
- usort($files, array ("archive", "sort_files"));
-
+
return $files;
}
@@ -270,24 +271,6 @@ class archive
return $files;
}
- function sort_files($a, $b)
- {
- if ($a['type'] != $b['type'])
- if ($a['type'] == 5 || $b['type'] == 2)
- return -1;
- else if ($a['type'] == 2 || $b['type'] == 5)
- return 1;
- else if ($a['type'] == 5)
- return strcmp(strtolower($a['name']), strtolower($b['name']));
- else if ($a['ext'] != $b['ext'])
- return strcmp($a['ext'], $b['ext']);
- else if ($a['stat'][7] != $b['stat'][7])
- return $a['stat'][7] > $b['stat'][7] ? -1 : 1;
- else
- return strcmp(strtolower($a['name']), strtolower($b['name']));
- return 0;
- }
-
function download_file()
{
if ($this->options['inmemory'] == 0)
@@ -666,4 +649,4 @@ class zip_file extends archive
return 1;
}
-} ?> \ No newline at end of file
+} ?>