summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-20 02:59:31 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-12-20 02:59:31 +0000
commitd62207327c99ea070985d46eaa8399b139914a86 (patch)
tree2b44571cd8639a27b1649f97c57c02b5cb5e5395
parentb47b6976239b8e35284c9fa84610cec2dd6d4cd4 (diff)
downloadampache-d62207327c99ea070985d46eaa8399b139914a86.tar.gz
ampache-d62207327c99ea070985d46eaa8399b139914a86.tar.bz2
ampache-d62207327c99ea070985d46eaa8399b139914a86.zip
* Added new icons, and speed up icon display
* Fixed ORDER BY `track` on play selected * Started work on editing/flagging albums and artists
-rw-r--r--admin/flag.php15
-rwxr-xr-xdocs/CHANGELOG6
-rw-r--r--images/icon_all.pngbin0 -> 385 bytes
-rw-r--r--images/icon_edit.pngbin703 -> 714 bytes
-rw-r--r--images/icon_random.pngbin0 -> 164 bytes
-rw-r--r--lib/debug.lib.php99
-rw-r--r--lib/song.php33
-rw-r--r--lib/ui.lib.php48
-rw-r--r--modules/lib.php31
-rw-r--r--play/index.php4
-rw-r--r--templates/show_album.inc10
-rw-r--r--templates/show_albums.inc19
-rw-r--r--templates/show_artist.inc18
-rw-r--r--templates/show_edit_album.inc.php35
-rw-r--r--themes/classic/templates/default.css4
15 files changed, 212 insertions, 110 deletions
diff --git a/admin/flag.php b/admin/flag.php
index f36b0651..87c83405 100644
--- a/admin/flag.php
+++ b/admin/flag.php
@@ -5,9 +5,8 @@
All rights reserved.
This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
+ 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
@@ -97,6 +96,16 @@ switch ($action) {
show_confirmation(_('Song Updated'),_('The requested song has been updated'),$_SESSION['source']);
break;
+ // Show the page for editing a full album
+ case 'show_edit_album':
+
+
+ beak;
+ // Show the page for editing a full artist
+ case 'show_edit_artist':
+
+
+ break;
/* Done by 'Select' code passes array of song ids */
case 'mass_update':
$songs = $_REQUEST['songs'];
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index b7f85d31..a38f8308 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,12 @@
--------------------------------------------------------------------------
v.3.3.3-Beta3
+ - Fixed ORDER BY `track` that was missing on play selected and
+ reduced it to a single query, rather then one per object
+ - Fixed ip history being tracked even if disabled in config
+ - Improved performance of icon rendering due to increased use
+ - Added error handling for if /config/ampache.cfg.php.dist is
+ not readable
- Added new Icons from http://www.famfamfam.com from the Silk
subset. (Thx kalrnux && Mark James)
diff --git a/images/icon_all.png b/images/icon_all.png
new file mode 100644
index 00000000..a8b3ede3
--- /dev/null
+++ b/images/icon_all.png
Binary files differ
diff --git a/images/icon_edit.png b/images/icon_edit.png
index fb2efb87..af486c94 100644
--- a/images/icon_edit.png
+++ b/images/icon_edit.png
Binary files differ
diff --git a/images/icon_random.png b/images/icon_random.png
new file mode 100644
index 00000000..90d5766d
--- /dev/null
+++ b/images/icon_random.png
Binary files differ
diff --git a/lib/debug.lib.php b/lib/debug.lib.php
index cccfd8e6..ca0d55cb 100644
--- a/lib/debug.lib.php
+++ b/lib/debug.lib.php
@@ -233,63 +233,68 @@ function check_config_values($conf) {
*/
function debug_read_config($config_file,$debug) {
- $fp = @fopen($config_file,'r');
- if(!is_resource($fp)) return false;
- $file_data = fread($fp,filesize($config_file));
- fclose($fp);
+ $fp = @fopen($config_file,'r');
+ if(!is_resource($fp)) return false;
+ $file_data = fread($fp,filesize($config_file));
+ fclose($fp);
- // explode the var by \n's
- $data = explode("\n",$file_data);
- if($debug) echo "<pre>";
- $count = 0;
+ // explode the var by \n's
+ $data = explode("\n",$file_data);
+ if($debug) echo "<pre>";
+ $count = 0;
- $results = array();
+ if (!count($data)) {
+ debug_event('debug_read_config','Error Unable to Read config file','1');
+ return false;
+ }
+
+ $results = array();
- foreach($data as $value) {
- $count++;
+ foreach($data as $value) {
+ $count++;
- $value = trim($value);
+ $value = trim($value);
- if (preg_match("/^#?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$value,$matches)
- || preg_match("/^#?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $value, $matches)
- || preg_match("/^#?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$value,$matches)) {
-
-
- if (is_array($results[$matches[1]]) && isset($matches[2]) ) {
- if($debug) echo "Adding value <strong>$matches[2]</strong> to existing key <strong>$matches[1]</strong>\n";
- array_push($results[$matches[1]], $matches[2]);
- }
-
- elseif (isset($results[$matches[1]]) && isset($matches[2]) ) {
- if($debug) echo "Adding value <strong>$matches[2]</strong> to existing key $matches[1]</strong>\n";
- $results[$matches[1]] = array($results[$matches[1]],$matches[2]);
- }
-
- elseif ($matches[2] !== "") {
- if($debug) echo "Adding value <strong>$matches[2]</strong> for key <strong>$matches[1]</strong>\n";
- $results[$matches[1]] = $matches[2];
- }
-
- // if there is something there and it's not a comment
- elseif ($value{0} !== "#" AND strlen(trim($value)) > 0 AND !$test AND strlen($matches[2]) > 0) {
- echo "Error Invalid Config Entry --> Line:$count"; return false;
- } // elseif it's not a comment and there is something there
-
- else {
- if($debug) echo "Key <strong>$matches[1]</strong> defined, but no value set\n";
- }
+ if (preg_match("/^#?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$value,$matches)
+ || preg_match("/^#?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $value, $matches)
+ || preg_match("/^#?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$value,$matches)) {
+
+
+ if (is_array($results[$matches[1]]) && isset($matches[2]) ) {
+ if($debug) echo "Adding value <strong>$matches[2]</strong> to existing key <strong>$matches[1]</strong>\n";
+ array_push($results[$matches[1]], $matches[2]);
+ }
+
+ elseif (isset($results[$matches[1]]) && isset($matches[2]) ) {
+ if($debug) echo "Adding value <strong>$matches[2]</strong> to existing key $matches[1]</strong>\n";
+ $results[$matches[1]] = array($results[$matches[1]],$matches[2]);
+ }
+
+ elseif ($matches[2] !== "") {
+ if($debug) echo "Adding value <strong>$matches[2]</strong> for key <strong>$matches[1]</strong>\n";
+ $results[$matches[1]] = $matches[2];
+ }
+
+ // if there is something there and it's not a comment
+ elseif ($value{0} !== "#" AND strlen(trim($value)) > 0 AND !$test AND strlen($matches[2]) > 0) {
+ echo "Error Invalid Config Entry --> Line:$count"; return false;
+ } // elseif it's not a comment and there is something there
+
+ else {
+ if($debug) echo "Key <strong>$matches[1]</strong> defined, but no value set\n";
+ }
- } // end else
+ } // end else
- } // foreach
+ } // foreach
- if (isset($config_name) && isset(${$config_name}) && count(${$config_name})) {
- $results[$config_name] = ${$config_name};
- }
+ if (isset($config_name) && isset(${$config_name}) && count(${$config_name})) {
+ $results[$config_name] = ${$config_name};
+ }
- if($debug) echo "</pre>";
+ if($debug) echo "</pre>";
- return $results;
+ return $results;
} // debug_read_config
diff --git a/lib/song.php b/lib/song.php
index b1d3579d..8aa24ead 100644
--- a/lib/song.php
+++ b/lib/song.php
@@ -45,6 +45,39 @@ function get_songs($sql, $action=0) {
} // get_songs
/**
+ * get_songs_from_type
+ * This gets an array of songs based on the type and from the results array
+ * can pull songs from an array of albums, artists whatever
+ */
+function get_songs_from_type($type,$results,$artist_id='') {
+
+ // Init the array
+ $songs = array();
+
+ $type = sql_escape($type);
+
+ $sql = "SELECT id FROM song WHERE ";
+
+ foreach ($results as $value) {
+ $value = sql_escape($value);
+ $sql .= "`$type`='$value' OR ";
+ }
+
+ // Run the long query
+ $sql = rtrim($sql,'OR ');
+ $sql .= " ORDER BY `track`";
+
+ $db_results = mysql_query($sql,dbh());
+
+ while ($r = mysql_fetch_assoc($db_results)) {
+ $songs[] = $r['id'];
+ }
+
+ return $songs;
+
+} // get_song_from_type
+
+/**
* get_recently_played
* This function returns the last X songs that have been played
* It uses the 'popular' threshold to determine how many to pull
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 169ce48b..a407af24 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -1274,29 +1274,47 @@ function show_box_bottom() {
* or an <img /> tag
*/
function get_user_icon($name,$hover_name='') {
+
+ /* Because we do a lot of calls cache the URLs */
+ static $url_cache = array();
- $icon_name = 'icon_' . $name . '.png';
-
- /* Build the image url */
- if (file_exists(conf('prefix') . '/themes/' . $GLOBALS['theme']['path'] . '/images/' . $icon_name)) {
- $img_url = conf('web_path') . conf('theme_path') . '/images/' . $icon_name;
+ if (isset($url_cache[$name])) {
+ $img_url = $url_cache[$name];
+ $cache_url = true;
}
- else {
- $img_url = conf('web_path') . '/images/' . $icon_name;
+ if (isset($url_cache[$hover_name])) {
+ $hover_url = $url_cache[$hover_name];
+ $cache_hover = true;
}
+
+ if (empty($hover_name)) { $cache_hover = true; }
- /* If Hover, then build its url */
- if (!empty($hover_name)) {
- $hover_icon = 'icon_' . $hover_name . '.png';
+ if (!isset($cache_url) OR !isset($cache_hover)) {
+
+ $icon_name = 'icon_' . $name . '.png';
+
+ /* Build the image url */
if (file_exists(conf('prefix') . '/themes/' . $GLOBALS['theme']['path'] . '/images/' . $icon_name)) {
- $hov_url = conf('web_path') . conf('theme_path') . '/images/' . $hover_icon;
+ $img_url = conf('web_path') . conf('theme_path') . '/images/' . $icon_name;
}
else {
- $hov_url = conf('web_path') . '/images/' . $hover_icon;
+ $img_url = conf('web_path') . '/images/' . $icon_name;
}
-
- $hov_txt = "onMouseOver=\"this.src='$hov_url'; return true;\" onMouseOut=\"this.src='$img_url'; return true;\"";
- }
+
+ /* If Hover, then build its url */
+ if (!empty($hover_name)) {
+ $hover_icon = 'icon_' . $hover_name . '.png';
+ if (file_exists(conf('prefix') . '/themes/' . $GLOBALS['theme']['path'] . '/images/' . $icon_name)) {
+ $hov_url = conf('web_path') . conf('theme_path') . '/images/' . $hover_icon;
+ }
+ else {
+ $hov_url = conf('web_path') . '/images/' . $hover_icon;
+ }
+
+ $hov_txt = "onMouseOver=\"this.src='$hov_url'; return true;\" onMouseOut=\"this.src='$img_url'; return true;\"";
+ } // end hover
+
+ } // end if not cached
$string = "<img style=\"cursor: pointer;\" src=\"$img_url\" border=\"0\" alt=\"$name\" title=\"$name\" $hov_txt/>";
diff --git a/modules/lib.php b/modules/lib.php
index 93e4c812..6e06d7f8 100644
--- a/modules/lib.php
+++ b/modules/lib.php
@@ -9,37 +9,6 @@
*/
-
-
-// Used by playlist functions when you have an array of something of type
-// and you want to extract the songs from it whether type is artists or albums
-function get_songs_from_type ($type, $results, $artist_id = 0) {
-
- $dbh = dbh();
-
- $count = 0;
- $song = array();
-
- foreach ($results as $value) {
-
- // special case from the album view where we don't want every orphan
- if ($type == 'album' && ($value == 'orphans' || $artist_id != 0)) {
- $sql = "SELECT id FROM song WHERE $type = '$value' AND artist = '$artist_id'";
- $db_result = mysql_query($sql, $dbh);
- }
- else {
- $sql = "SELECT id FROM song WHERE $type = '$value'";
- $db_result = mysql_query($sql, $dbh);
- }
-
- while ( $r = mysql_fetch_row($db_result) ) {
- $song[$count] = $r[0];
- $count++;
- }
- }
- return $song;
-}
-
// This function makes baby vollmer cry, need to fix
//FIXME
function get_artist_info ($artist_id) {
diff --git a/play/index.php b/play/index.php
index 07504b80..280636eb 100644
--- a/play/index.php
+++ b/play/index.php
@@ -210,7 +210,9 @@ header("Accept-Ranges: bytes" );
set_time_limit(0);
/* We're about to start record this persons IP */
-$user->insert_ip_history();
+if (conf('track_user_ip')) {
+ $user->insert_ip_history();
+}
/* If access control is on and they aren't local, downsample! */
if (conf('access_control') AND conf('downsample_remote')) {
diff --git a/templates/show_album.inc b/templates/show_album.inc
index d1251407..264756d0 100644
--- a/templates/show_album.inc
+++ b/templates/show_album.inc
@@ -53,16 +53,16 @@ $title = scrub_out($album->name) . ' -- ' . $album->f_artist;
?>
<strong><?php echo _('Actions'); ?>:</strong><br />
&nbsp;&nbsp;<a href="<?php echo $web_path; ?>/song.php?action=album&amp;album_id=<?php echo $album->id; ?>"><?php echo _("Play Album"); ; ?></a><br />
- &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/song.php?action=album_random&amp;album_id=<?php echo $album->id; ; ?>"><?php echo _("Play Random from Album"); ; ?></a><br />
+ &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/song.php?action=album_random&amp;album_id=<?php echo $album->id; ?>"><?php echo _("Play Random from Album"); ; ?></a><br />
<?php if ( ($GLOBALS['user']->has_access('75')) || (!conf('use_auth'))) { ?>
- &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/albums.php?action=clear_art&amp;album_id=<?php echo $album->id; ; ?>"><?php echo _("Reset Album Art"); ; ?></a><br />
+ &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/albums.php?action=clear_art&amp;album_id=<?php echo $album->id; ?>"><?php echo _("Reset Album Art"); ; ?></a><br />
<?php } ?>
- &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/albums.php?action=find_art&amp;album_id=<?php echo $album->id; ; ?>"><?php echo _("Find Album Art"); ; ?></a><br />
+ &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/albums.php?action=find_art&amp;album_id=<?php echo $album->id; ?>"><?php echo _("Find Album Art"); ; ?></a><br />
<?php if (($GLOBALS['user']->has_access('100')) || (!conf('use_auth'))) { ?>
- &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/albums.php?action=update_from_tags&amp;album_id=<?php echo $album->id; ; ?>"><?php echo _("Update from tags"); ?></a><br />
+ &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/albums.php?action=update_from_tags&amp;album_id=<?php echo $album->id; ?>"><?php echo _("Update from tags"); ?></a><br />
<?php } ?>
<?php if (batch_ok()) { ?>
- &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/batch.php?action=alb&amp;id=<?php echo $album->id; ; ?>"><?php echo _('Download'); ?></a><br />
+ &nbsp;&nbsp;<a href="<?php echo $web_path; ?>/batch.php?action=alb&amp;id=<?php echo $album->id; ?>"><?php echo _('Download'); ?></a><br />
<?php } ?>
</div>
<?php require (conf('prefix') . '/templates/show_box_bottom.inc.php'); ?>
diff --git a/templates/show_albums.inc b/templates/show_albums.inc
index 17cf5496..5787af2f 100644
--- a/templates/show_albums.inc
+++ b/templates/show_albums.inc
@@ -56,11 +56,22 @@ foreach ($albums as $album) {
<td><?php echo $album->f_artist; ?></td>
<td><?php echo $album->songs; ?></td>
<td><?php echo $album->year; ?></td>
- <td nowrap="nowrap"> <?php echo _("Play"); ?> :
- <a href="<?php echo $web_path; ?>/song.php?action=album&amp;album_id=<?php echo $album->id; ?>"><?php echo _("All"); ?></a> |
- <a href="<?php echo $web_path; ?>/song.php?action=album_random&amp;album_id=<?php echo $album->id; ?>"><?php echo _("Random"); ?></a>
+ <td nowrap="nowrap">
+ <a href="<?php echo $web_path; ?>/song.php?action=album&amp;album_id=<?php echo $album->id; ?>">
+ <?php echo get_user_icon('all'); ?>
+ </a>
+ <a href="<?php echo $web_path; ?>/song.php?action=album_random&amp;album_id=<?php echo $album->id; ?>">
+ <?php echo get_user_icon('random'); ?>
+ </a>
<?php if (batch_ok()) { ?>
- | <a href="<?php echo $web_path; ?>/batch.php?action=alb&amp;id=<?php echo $album->id; ?>"><?php echo _('Download'); ?></a>
+ <a href="<?php echo $web_path; ?>/batch.php?action=alb&amp;id=<?php echo $album->id; ?>">
+ <?php echo get_user_icon('download'); ?>
+ </a>
+ <?php } ?>
+ <?php if ($GLOBALS['user']->has_access('50')) { ?>
+ <a href="<?php echo $web_path; ?>/admin/flag.php?action=show_edit_album&amp;album_id=<?php echo $album->id; ?>">
+ <?php echo get_user_icon('edit'); ?>
+ </a>
<?php } ?>
</td>
</tr>
diff --git a/templates/show_artist.inc b/templates/show_artist.inc
index b4b013dc..f4e426a5 100644
--- a/templates/show_artist.inc
+++ b/templates/show_artist.inc
@@ -35,7 +35,7 @@ $web_path = conf('web_path');
<th><?php echo _('Cover'); ?></th>
<th><a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;artist=<?php echo $artist->id ?>&amp;keep_view=true&amp;sort_type=album.name&amp;sort_order=0"><?php echo _('Album Name'); ?></th>
<th><a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;artist=<?php echo $artist->id ?>&amp;keep_view=true&amp;sort_type=album.year&amp;sort_order=0"><?php echo _('Album Year'); ?></th>
- <th><?php echo _('Total Tracks'); ?></th>
+ <th><?php echo _('Tracks'); ?></th>
<th><?php echo _('Action'); ?></th>
</tr>
<?php
@@ -59,10 +59,22 @@ foreach ($albums as $album) {
<td><?php echo $album->year; ?></td>
<td><?php echo $count; ?></td>
<td>
- <a href="<?php echo $web_path; ?>/song.php?action=album&amp;album_id=<?php echo $id; ?>"><?php echo _('Play'); ?></a>
+ <a href="<?php echo $web_path; ?>/song.php?action=album&amp;album_id=<?php echo $id; ?>">
+ <?php echo get_user_icon('all'); ?>
+ </a>
+ <a href="<?php echo $web_path; ?>/song.php?action=album_random&amp;album_id=<?php echo $album->id; ?>">
+ <?php echo get_user_icon('random'); ?>
+ </a>
<?php if (batch_ok()) { ?>
- | <a href="<?php echo $web_path; ?>/batch.php?action=alb&amp;id=<?php echo $album->id; ?>"><?php echo _('Download'); ?></a>
+ <a href="<?php echo $web_path; ?>/batch.php?action=alb&amp;id=<?php echo $album->id; ?>">
+ <?php echo get_user_icon('download'); ?>
+ </a>
<?php } ?>
+ <?php if ($GLOBALS['user']->has_access('100')) { ?>
+ <a href="<?php echo $web_path; ?>/admin/flag.php?action=album&amp;album_id=<?php echo $album->id; ?>">
+ <?php echo get_user_icon('edit'); ?>
+ </a>
+ <?php } ?>
</td>
</tr>
<?php } //end foreach ($albums as $album)?>
diff --git a/templates/show_edit_album.inc.php b/templates/show_edit_album.inc.php
new file mode 100644
index 00000000..6b6c42fa
--- /dev/null
+++ b/templates/show_edit_album.inc.php
@@ -0,0 +1,35 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2006 Ampache.org
+ All rights reserved.
+
+ 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.
+
+*/
+?>
+
+<?php show_box_top(_('Edit Album')); ?>
+<form name="edit_album" method="post" enctype="multipart/form-data" action="<?php echo conf('web_path'); ?>/admin/flag.php?action=edit_album">
+<table class="tabledata">
+<tr class="<?php echo flip_class(); ?>">
+ <td>&nbsp;</td>
+ <td>
+ <input type="hidden" name="album_id" value="<?php echo $album->id; ?>" />
+ <input type="submit" value="<?php echo _('Update Album'); ?>" />
+ </td>
+</tr>
+</table>
+</form>
+<?php show_box_bottom(); ?>
diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css
index 15dafc76..ddc3b459 100644
--- a/themes/classic/templates/default.css
+++ b/themes/classic/templates/default.css
@@ -91,8 +91,10 @@ textarea {
font-size: 12px;
}
.table-header {
- background: url(../images/ampache-light-bg.gif) #dddddd repeat-x;
+// background: url(../images/ampache-light-bg.gif) #dddddd repeat-x;
+ background: #a0a0a0;
vertical-align: top;
+ text-align:center;
}
.header1
{