diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-12-18 00:10:07 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-12-18 00:10:07 +0000 |
commit | 68ac06b30b06f982f18f4ec31691c94684fc07e2 (patch) | |
tree | d0c41afc488aca7eb6b861792fa916979b21454f | |
parent | 7c661ba685287efd21512f9f0203641200bffed2 (diff) | |
download | ampache-68ac06b30b06f982f18f4ec31691c94684fc07e2.tar.gz ampache-68ac06b30b06f982f18f4ec31691c94684fc07e2.tar.bz2 ampache-68ac06b30b06f982f18f4ec31691c94684fc07e2.zip |
* Last DB Update for 3.3.3 Stable Branche
* Improved Recommendation view
* Removed Upload
-rwxr-xr-x | docs/CHANGELOG | 4 | ||||
-rw-r--r-- | lib/class/album.class.php | 20 | ||||
-rw-r--r-- | lib/class/artist.class.php | 34 | ||||
-rw-r--r-- | lib/class/update.class.php | 25 | ||||
-rw-r--r-- | lib/class/user.class.php | 8 | ||||
-rw-r--r-- | templates/show_upload.inc | 59 | ||||
-rw-r--r-- | templates/show_uploads.inc | 74 | ||||
-rw-r--r-- | templates/sidebar.inc.php | 9 | ||||
-rw-r--r-- | update.php | 7 | ||||
-rw-r--r-- | upload.php | 223 |
10 files changed, 58 insertions, 405 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 59f1244e..556ed00b 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,10 @@ -------------------------------------------------------------------------- v.3.3.3-Beta1 + - Moved Comment information to seperate table and added lyrics + row, no support for lyrics yet though. + - Removed Upload functionality (broken, and time better spent on + other features) - Added Recommendations based on Ratings to Stats page - Encoded the LastFM password so that it isn't displayed or stored in plain text. diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 12c668ae..6810c22c 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -130,11 +130,12 @@ class Album { } // get_song_ids - /*! - @function format_album - @dicussion reformats this object with f_name, f_songs and f_artist - that contain links etc... - */ + /** + * format_album + * reformats this object with f_name, f_songs and f_artist + * that contain links etc... + * //FIXME: Rename to format() so that it can be called more dynamicly between object types + */ function format_album() { $web_path = conf('web_path'); @@ -143,6 +144,7 @@ class Album { $name = scrub_out(truncate_with_ellipse($this->name,conf('ellipse_threshold_album'))); $artist = scrub_out($this->artist); $this->f_name = "<a href=\"$web_path/albums.php?action=show&album=" . $this->id . "\" title=\"" . scrub_out($this->name) . "\">" . $name . "</a>"; + $this->f_link = "<a href=\"$web_path/albums.php?action=show&album=" . scrub_out($this->id) . "\" title=\"" . scrub_out($this->name) . "\">" . $name . "</a>"; $this->f_songs = "<div align=\"center\">" . $this->songs . "</div>"; if ($this->artist_count == '1') { $this->f_artist = "<a href=\"$web_path/artists.php?action=show&artist=" . $this->artist_id . "\">" . $artist . "</a>"; @@ -157,10 +159,10 @@ class Album { } // format_album - /*! - @function get_art - @discussion get art wrapper function - */ + /** + * get_art + * get art wrapper function + */ function get_art($fast = 0) { /* Check DB first */ diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index 0681a0ab..fbbca4d1 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.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 @@ -20,10 +19,9 @@ */ -/*! - @header Artist Class -*/ - +/** + * Artist Class + */ class Artist { /* Variables from DB */ @@ -54,6 +52,7 @@ class Artist { $this->prefix = $info['prefix']; } // if info + return true; } //constructor @@ -77,6 +76,7 @@ class Artist { /*! @function get_albums @discussion gets the albums for this artist + //FIXME: Appears to not be used? */ function get_albums($sql) { @@ -99,11 +99,11 @@ class Artist { */ function get_songs() { - $sql = "SELECT song.id FROM song WHERE song.artist='$this->id'"; + $sql = "SELECT song.id FROM song WHERE song.artist='" . sql_escape($this->id) . "'"; $db_results = mysql_query($sql, dbh()); - while ($r = mysql_fetch_object($db_results)) { - $results[] = new Song($r->id); + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = new Song($r['id']); } return $results; @@ -186,14 +186,17 @@ class Artist { function format_artist() { /* Combine prefix and name, trim then add ... if needed */ - $name = htmlspecialchars(truncate_with_ellipse(trim($this->prefix . " " . $this->name))); + $name = scrub_out(truncate_with_ellipse(trim($this->prefix . " " . $this->name))); $this->f_name = $this->name; + //FIXME: This shouldn't be scrubing right here!!!! $this->full_name = scrub_out(trim($this->prefix . " " . $this->name)); - //FIXME: This shouldn't be set like this, f_name should be like this + + //FIXME: This should be f_link $this->link = "<a href=\"" . conf('web_path') . "/artists.php?action=show&artist=" . $this->id . "\" title=\"" . $this->full_name . "\">" . $name . "</a>"; $this->name = $this->link; - return $artist; + + return true; } // format_artist @@ -410,8 +413,7 @@ class Artist { return levenshtein($name1,$name2) <= $distance; break; } - } //compare_loose + } // compare_loose -} //end of artist class - +} // end of artist class ?> diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 9375883b..9db77f45 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -329,11 +329,12 @@ class Update { $version[] = array('version' => '333001','description' => $update_string); - $update_string = '- Added object_tag table for Web2.0 Tag information.<br />' . + $update_string = '- Added object_tag table for Web2.0 style tag information.<br />' . '- Added song_ext_data for holding comments,lyrics and other large fields, not commonly used.<br />' . - '- Added Timezone as a per user preference.'; + '- Added Timezone as a per user preference.<br />' . + '- Delete Upload Table and Upload Preferences.<br />'; - //$version[] = array('version' => '333002','description' => $update_string); + $version[] = array('version' => '333002','description' => $update_string); return $version; @@ -382,11 +383,12 @@ class Update { $sql = "DELETE * FROM session"; $db_results = mysql_query($sql, dbh()); - /* Verify that there are no plugins installed */ + /* Verify that there are no plugins installed + //FIXME: provide a link to remove all plugins, otherwise this could turn into a catch 22 if (!$this->plugins_installed()) { $GLOBALS['error']->add_error('general',_('Plugins detected, please remove all Plugins and try again')); return false; - } + } */ $methods = array(); @@ -2037,7 +2039,7 @@ class Update { function update_333002 () { /* First add the two tables */ - $sql = "CREATE TABLE `song_ext_data` (`song_id` INT( 11 ) UNSIGNED NOT NULL ,`comment` TEXT NULL ,`lyrics` TEXT NULL , UNIQUE (`song_id`)"; + $sql = "CREATE TABLE `song_ext_data` (`song_id` INT( 11 ) UNSIGNED NOT NULL ,`comment` TEXT NULL ,`lyrics` TEXT NULL , UNIQUE (`song_id`))"; $db_results = mysql_query($sql,dbh()); $sql = "CREATE TABLE `tags` (`map_id` INT( 11 ) UNSIGNED NOT NULL ,`name` VARCHAR( 32 ) NOT NULL ,`order` TINYINT( 2 ) NOT NULL)"; @@ -2074,15 +2076,18 @@ class Update { } // end while comments fetching - $sql = "ALTER TABLE `song` DROP `comment`"; $db_results = mysql_query($sql,dbh()); /* Add the Preference for Timezone */ $sql = "INSERT INTO preferences (`name`,`value`,`description`,`level`,`type`,`catagory`) " . - " VALUES ('time_zone','GMT','Local Timezone','5','string','interface')"; + " VALUES ('time_zone','GMT','Local Timezone','100','string','system')"; $db_results = mysql_query($sql,dbh()); + /* Delete the upload related preferences */ + $sql = "DELETE FROM preferences WHERE `name`='upload' OR `name`='upload_dir' OR `name`='quarantine_dir'"; + $db_results = mysql_query($sql,dbh()); + /* Fix every users preferences */ $sql = "SELECT * FROM user"; $db_results = mysql_query($sql, dbh()); @@ -2098,6 +2103,10 @@ class Update { $sql = "DROP TABLE `user_catalog`"; $db_results = mysql_query($sql,dbh()); + /* Drop the defunct Upload table */ + $sql = "DROP TABLE `upload`"; + $db_results = mysql_query($sql,dbh()); + $this->set_version('db_version','333002'); } // update_333002 diff --git a/lib/class/user.class.php b/lib/class/user.class.php index f662e7df..b84b4e89 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -688,20 +688,20 @@ class User { case 'artist': $object = new Artist($object_id); $object->format_artist(); - $name = $object->f_name; + $name = $object->link; break; case 'album': $object = new Album($object_id); $object->format_album(); - $name = $object->f_name; + $name = $object->f_link; break; case 'song': $object = new Song($object_id); $object->format_song(); - $name = $object->f_title; + $name = $object->f_link; break; } // end switch on type - $results[] = "<li>$name -- $rating<br />\n</li>"; + $results[] = "<li>$name -- " . get_rating_name($rating) . "<br />\n</li>"; } // end foreach items diff --git a/templates/show_upload.inc b/templates/show_upload.inc deleted file mode 100644 index 7e394006..00000000 --- a/templates/show_upload.inc +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2006 Ampache.org - All rights reserved. - - *Created by Lamar* - - 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. - - 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. - -*/ -?> - -<form action="<?php echo conf('web_path'); ?>/upload.php?" method="post" name="upload_form" enctype="multipart/form-data" id="upload_form"> -<?php show_box_top(_('Uploading Music to Ampache')); ?> -<table> -<tr> - <td> - <b><?php echo _('The following Audio file formats are supported'); ?></b> - <ul> - <li>OGG</li> - <li>Mp3</li> - <li>Mpc</li> - <li>Flac</li> - <li>WMA</li> - <li>Mp4/M4a/AAC</li> - </ul> - <?php $GLOBALS['error']->print_error('general'); ?> - </td> -</tr> -<tr> - <td> - <input size="40" type="file" name="ul_path1" id="ul_path1" /> - <?php $GLOBALS['error']->print_error('ul_path1'); ?> - </td> -</tr> -<tr> - <td> - <input type="hidden" name="action" value="upload" /> - <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo _('max_upload_size'); ?>" /> - <input class='button' type="submit" value="<?php echo _('Upload'); ?>" /> - </td> -</tr> -</table> -<?php show_box_bottom(); ?> -</form> - diff --git a/templates/show_uploads.inc b/templates/show_uploads.inc deleted file mode 100644 index 6553c932..00000000 --- a/templates/show_uploads.inc +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2006 Ampache.org - All rights reserved. - - *Created by Rosensama* - - 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. - - 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. - -*/ - -/* Get the current Quarantined Uploads */ -$uploads = get_uploads(); - -if (count($uploads)) { -?> -<table class="tabledata" cellspacing="0" cellpadding="0" border="1"> -<tr class="table-header"> - <td><?php echo _('Action'); ?></td> - <td><?php echo _('Status'); ?></td> - <td><?php echo _('Song'); ?></td> - <td><?php echo _('Artist'); ?></td> - <td><?php echo _('Album'); ?></td> - <td><?php echo _('Genre'); ?></td> - <td><?php echo _('Time'); ?></td> - <td><?php echo _('Bitrate'); ?></td> - <td><?php echo _('Size'); ?></td> - <td><?php echo _('Filename'); ?></td> - <td><?php echo _('User'); ?></td> - <td><?php echo _('Date'); ?></td> -</tr> -<?php foreach ($uploads as $upload) { ?> -<tr class="<?php echo flip_class(); ?>"> - <?php if($GLOBALS['user']->has_access(100)) { ?> - <td align="center"> - <div class="text-action"> - <?php if ($upload['action'] != 'add') { ?> - <a href="<?php echo conf('web_path'); ?>/upload.php?action=add&id=<?php echo $upload['id']; ?>"><?php echo _('Add'); ?></a> - <?php } elseif ($upload['action'] != 'delete') { ?> - <a href="<?php echo conf('web_path'); ?>/upload.php?action=delete&id=<?php echo $upload['id']; ?>"><?php echo _('Delete'); ?></a> - <?php } ?> - </div> - </td> - <?php } else { ?> - <td>N/A</td> - <?php } ?> - <td style="<?php echo show_upload_status_style($upload['action']); ?>"> </td> - <td><?php echo $upload['title']; ?></td> - <td><?php echo $upload['artist']; ?></td> - <td><?php echo $upload['album']; ?></td> - <td><?php echo $upload['time']; ?></td> - <td><?php echo $upload['genre']; ?></td> - <td><?php echo intval($upload['bitrate']/1000); ?> - <?php echo $upload['mode']; ?></td> - <td><?php echo sprintf("%.2f",($upload['size']/1048576)); ?>MB</td> - <td><?php echo $upload['file']; ?></td> - <td><?php echo $upload['user']; ?></td> - <td><?php echo date('m/d/Y H:i:s',$upload['addition_time']); ?></td> -</tr> -<?php } ?> -</table> -<?php } // if count uploads ?> diff --git a/templates/sidebar.inc.php b/templates/sidebar.inc.php index af3bc38b..62568d53 100644 --- a/templates/sidebar.inc.php +++ b/templates/sidebar.inc.php @@ -101,15 +101,6 @@ $web_path = conf('web_path'); } } ?> - -<?php if ($GLOBALS['user']->prefs['upload']) { ?> - <li<?php - if ($location['page'] == "upload.php"){ - echo " id=\"activetopmenu\" "; - }?>> - <a href="<?php echo $web_path; ?>/upload.php"><?php echo _('Upload'); ?></a> - </li> -<?php } // end if ($GLOBALS['user']->prefs['upload']) ?> <li<?php if ($location['page'] == "playlist.php"){ echo " id=\"activetopmenu\" "; @@ -77,17 +77,18 @@ $htmllang = str_replace("_","-",conf('lang')); <div class="notify"> This page handles all database updates to Ampache starting with 3.2. According to your database your current version is: <?php echo $update->format_version($version); ; ?>. the following updates need to be performed<br /><br /> +<div style="font-size:1.2em;font-weight:bold;text-align:center;"><?php $GLOBALS['error']->print_error('general'); ?></div> </div> <div class="content"> -<?php $update->display_update(); ?> +<?php $update->display_update(); ?> <form method="post" enctype="multipart/form-data" action="<?php echo conf('web_path'); ; ?>/update.php?action=update"> -<?php if ($update->need_update()) { ?><input type="submit" value="Update Now!" /> <?php } ?> +<?php if ($update->need_update()) { ?><input type="submit" value="Update Now!" /> <?php } ?> </form> </div> <div id="bottom"> <p><b>Ampache Installation.</b><br /> - For the love of Music.</p> + Pour l'Amour de la Musique.</p> </div> </div> </body> diff --git a/upload.php b/upload.php deleted file mode 100644 index 0cb5f427..00000000 --- a/upload.php +++ /dev/null @@ -1,223 +0,0 @@ -<?php -/* - - 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. - - 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. - -*/ -/* - - Copyright (c) 2003 Lamar - All rights reserved. - - **Revised by Vollmerk** - **Chopped to bits and made into PHP nuggets by RosenSama** 2005 - -*/ - -/* FIXME: Things left to do - --need to add debug logging - --Add purge link in catalog admin - --Why do I need to echo something before the message table to show it? - --Handle when uploaded file is a compressed arvchive - --play quar song by admin - --TEST! -*/ - -require_once('lib/init.php'); - -// Set page header -show_template('header'); - -// Access Control -if(!$GLOBALS['user']->prefs['upload'] || conf('demo_mode')) { - access_denied(); -} - -$action = scrub_in( $_REQUEST['action'] ); - -switch( $action ) { - case 'upload': - /* Break if they don't have rights */ - if (!$GLOBALS['user']->prefs['upload'] OR !$GLOBALS['user']->has_access(25)) { - break; - } - - /* IF we need to quarantine this */ - if ($GLOBALS['user']->prefs['quarantine']) { - /* Make sure the quarantine dir is writeable */ - if (!check_upload_directory(conf('quarantine_dir'))) { - $GLOBALS['error']->add_error('general',"Error: Quarantine Directory isn't writeable"); - debug_event('upload',"Error: Quarantine Directory isn't writeable",'2'); - } // if unwriteable - - $catalog_id = find_upload_catalog(conf('quarantine_dir')); - - /* Make sure that it's not in a catalog dir */ - if ($catalog_id) { - $GLOBALS['error']->add_error('general',"Error: Quarantine Directory inside a catalog"); - debug_event('upload',"Error: Quarantine Directory inside a catalog",'2'); - } // if in catalog dir - - foreach ($_FILES as $key => $file) { - - if (strlen($_FILES[$key]['name'])) { - /* Check size and extension */ - if (!check_upload_extension($key)) { - $GLOBALS['error']->add_error($key,"Error: Invalid Extension"); - } - if (!check_upload_size($key)) { - $GLOBALS['error']->add_error($key,"Error: File to large"); - } - - if (!$GLOBALS['error']->error_state) { - $new_filename = upload_file($key,conf('quarantine_dir')); - /* Record this upload then we're done */ - if ($new_filename) { insert_quarantine_record($user->username,'quarantine',$new_filename); } - } // if we havn't had an error - - } // end if there is a file to check - - } // end foreach files - - if ($GLOBALS['error']->error_state) { - show_upload(); - } - else { - show_confirmation(_('Upload Quarantined'), _('Your Upload(s) have been quarantined and will be reviewed for addition'),'upload.php'); - } - - } // if quarantine - - /* Else direct upload time baby! */ - else { - /* Make sure the quarantine dir is writeable */ - if (!check_upload_directory($GLOBALS['user']->prefs['upload_dir'])) { - $GLOBALS['error']->add_error('general',"Error: Upload Directory isn't writeable"); - debug_event('upload',"Error: Upload Directory isn't writeable",'2'); - } // if unwriteable - - $catalog_id = find_upload_catalog($user->prefs['upload_dir']); - $catalog = new Catalog($catalog_id); - - /* Make sure that it's not in a catalog dir */ - if (!$catalog_id) { - $GLOBALS['error']->add_error('general',"Error: Upload Directory not inside a catalog"); - debug_event('upload',"Error: Upload Directory not inside a catalog",'2'); - } // if in catalog dir - - /* Foreach through the post files */ - foreach ($_FILES as $key => $file) { - - if (strlen($_FILES[$key]['name']) && strlen($_FILES[$key]['tmp_name'])) { - /* Check size and extension */ - if (!check_upload_extension($key)) { - $GLOBALS['error']->add_error($key,"Error: Invalid Extension"); - } - if (!check_upload_size($key)) { - $GLOBALS['error']->add_error($key,"Error: File to large"); - } - - if (!$GLOBALS['error']->error_state) { - $new_filename = upload_file($key,$user->prefs['upload_dir']); - - /* We aren't doing the quarantine thing, so just insert it */ - if ($new_filename) { $catalog->insert_local_song($new_filename,filesize($new_filename)); } - } // if we havn't had an error - - } // if there is a file to check - - elseif (strlen($_FILES[$key]['name'])) { - $GLOBALS['error']->add_error($key,'Error: Total Filesize to large, file not uploaded'); - } - - } // end foreach files - - if ($GLOBALS['error']->error_state) { - show_upload(); - } - else { - show_confirmation(_('Files Uploaded'), _('Your Upload(s) have been inserted into Ampache and are now live'),"upload.php"); - } - - } // man this is a bad idea, the catch all should be the conservative option... oooh well - break; - case 'add': - /* Make sure they have access */ - if($GLOBALS['user']->has_access(100)) { - $id = scrub_in($_REQUEST['id']); - update_quarantine_record($id,'add'); - show_confirmation(_('Upload Added'),_('The Upload has been scheduled for a catalog add, please run command line script to add file'),"upload.php"); - } - else { - access_denied(); - } - break; - case 'delete': - /* Make sure they got them rights */ - if($GLOBALS['user']->has_access(100)) { - $id = scrub_in($_REQUEST['id']); - update_quarantine_record($id,'delete'); - show_confirmation(_('Upload Deleted'),_('The Upload has been scheduled for deletion, please run command line script to permently delete this file'),"upload.php"); - } - else { - access_denied(); - } - break; - case 'ack': - // everything is ready to bulk ack once we pass multiple ids and put them in $id[] - if($GLOBALS['user']->has_access(100)) { - $id[] = scrub_in($_REQUEST['id']); - $status = upload_ack( $id ); - } else { - access_denied(); - } - break; - - case 'purge': - if($GLOBALS['user']->has_access(100)) { - $status = upload_purge(); - } else { - access_denied(); - } - break; - - default: - show_upload(); - break; -} // end switch on $action - -// display any messages -if( $status ) { - show_box_top(); - print( "<table align='center'>\n" ); - print( "<th>Filename</th><th>Result</th>\n" ); - foreach( $status as $status_row ) { - $filename = $status_row[0]; - $result = $status_row[1]; - $color = "color='green'"; - if( $status_row[2] ) { - $color = "color='red'"; - } - print( "<tr>\n"); - print( "<td><font $color>$filename</font></td><td><font $color>$result</font></td>\n"); - print( "</tr>\n"); - } // end for each status element - print( "</table>\n" ); - show_box_bottom(); -} // end if any messages - -/* Show the Page Footer */ -show_footer(); -?> |