From ff606dbefca94580b56a081c5d3089037a2d033d Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sun, 22 Jul 2007 18:32:09 +0000 Subject: removed some old/legacy functions fixed download and merged it into the /play --- download/index.php | 101 --------------- lib/class/album.class.php | 4 +- lib/class/artist.class.php | 2 +- lib/class/song.class.php | 6 +- lib/ui.lib.php | 237 ++--------------------------------- play/index.php | 50 ++++++-- server/ajax.server.php | 15 ++- templates/show_edit_song_row.inc.php | 47 +++++++ templates/show_song_row.inc.php | 41 ++++++ templates/show_songs.inc.php | 22 +--- 10 files changed, 162 insertions(+), 363 deletions(-) delete mode 100644 download/index.php create mode 100644 templates/show_edit_song_row.inc.php create mode 100644 templates/show_song_row.inc.php diff --git a/download/index.php b/download/index.php deleted file mode 100644 index ff4b0e9e..00000000 --- a/download/index.php +++ /dev/null @@ -1,101 +0,0 @@ -has_access('25') || !$GLOBALS['user']->prefs['download']) { - debug_event('access_denied',"Download Access Denied, " . $GLOBALS['user']->username . " doesn't have sufficent rights",'3'); - access_denied(); -} - -/* - If they are using access lists let's make sure - that they have enough access to play this mojo -*/ -if (conf('access_control')) { - $access = new Access(0); - if (!$access->check('stream', $_SERVER['REMOTE_ADDR'],$GLOBALS['user']->id,'50') || - !$access->check('network', $_SERVER['REMOTE_ADDR'],$GLOBALS['user']->id,'50')) { - debug_event('access_denied', "Download Access Denied, " . $_SERVER['REMOTE_ADDR'] . " does not have download level",'3'); - access_denied(); - } -} // access_control is enabled - -/* Check for a song id */ -if (!$_REQUEST['song_id']) { - echo "Error: No Song found, download failed"; - debug_event('download','No Song found, download failed','2'); -} - -/* If we're got require_session check for a valid session */ -if (conf('require_session')) { - if (!session_exists(scrub_in($_REQUEST['sid']))) { - die(_("Session Expired: please log in again at") . " " . conf('web_path') . "/login.php"); - debug_event('session_expired',"Download Access Denied: " . $GLOBALS['user']->username . "'s session has expired",'3'); - } -} // if require_session - - -/* If the request is to download it... why is this here? */ -if ($_REQUEST['action'] == 'download') { - $song = new Song($_REQUEST['song_id']); - $song->format_song(); - $song->format_type(); - $song_name = str_replace('"'," ",$song->f_artist_full . " - " . $song->title . "." . $song->type); - - /* Because of some issues with IE remove ? and / from the filename */ - $song_name = str_replace(array('?','/','\\'),"_",$song_name); - - // Use Horde's Browser class to send the right headers for different browsers - // Should get the mime-type from the song rather than hard-coding it. - header("Content-Length: " . $song->size); - $browser->downloadHeaders($song_name, $song->mime, false, $song->size); - $fp = fopen($song->file, 'r'); - - /* We need to check and see if throttling is enabled */ - $speed = intval(conf('throttle_download')); - if ($speed > 0) { - while(!feof($fp)) { - echo fread($fp, round($speed*1024)); - flush(); - sleep(1); - } - } // if limiting - /* Otherwise just pump it out as fast as you can */ - else { - fpassthru($fp); - } // else no limit - - fclose($fp); - -} // If they've requested a download - -?> diff --git a/lib/class/album.class.php b/lib/class/album.class.php index f03a1990..fc54f390 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -184,11 +184,11 @@ class Album { foreach ($data as $key=>$value) { $this->$key = $value; } /* Truncate the string if it's to long */ - $this->f_name = scrub_out(truncate_with_ellipse($this->name,Config::get('ellipse_threshold_album'))); + $this->f_name = scrub_out(truncate_with_ellipsis($this->name,Config::get('ellipsis_threshold_album'))); $this->f_name_link = "id) . "\" title=\"" . scrub_out($this->name) . "\">" . $this->f_name . ""; $this->f_title = $name; if ($this->artist_count == '1') { - $artist = scrub_out(truncate_with_ellipse(trim($this->artist_prefix . ' ' . $this->artist_name),Config::get('ellipse_threshold_album'))); + $artist = scrub_out(truncate_with_ellipsis(trim($this->artist_prefix . ' ' . $this->artist_name),Config::get('ellipsis_threshold_album'))); $this->f_artist = "artist_id . "\">" . $artist . ""; } else { diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index eb18b539..3de53153 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -183,7 +183,7 @@ class Artist { public function format() { /* Combine prefix and name, trim then add ... if needed */ - $name = truncate_with_ellipse(trim($this->prefix . " " . $this->name)); + $name = truncate_with_ellipsis(trim($this->prefix . " " . $this->name)); $this->f_name = $name; //FIXME: This shouldn't be scrubing right here!!!! diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 4200ff2a..1dd7aa20 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -629,14 +629,14 @@ class Song { // Format the album name $this->f_album_full = $this->get_album_name(); - $this->f_album = truncate_with_ellipse($this->f_album_full,Config::get('ellipse_threshold_album')); + $this->f_album = truncate_with_ellipsis($this->f_album_full,Config::get('ellipse_threshold_album')); // Format the artist name $this->f_artist_full = $this->get_artist_name(); - $this->f_artist = truncate_with_ellipse($this->f_artist_full,Config::get('ellipse_threshold_artist')); + $this->f_artist = truncate_with_ellipsis($this->f_artist_full,Config::get('ellipse_threshold_artist')); // Format the title - $this->f_title = truncate_with_ellipse($this->title,Config::get('ellipse_threshold_title')); + $this->f_title = truncate_with_ellipsis($this->title,Config::get('ellipse_threshold_title')); // Create Links for the different objects $this->f_link = "id . "\">$this->f_title"; diff --git a/lib/ui.lib.php b/lib/ui.lib.php index d7aaa0aa..7ae9e4ec 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -69,18 +69,6 @@ function flip_class($array=0) { } // flip_class -/** - * clear_now_playing - * Clears the now playing information incase something has - * gotten stuck in there - */ -function clear_now_playing() { - - $sql = "TRUNCATE TABLE `now_playing`"; - $db_results = Dba::query($sql); - -} // clear_now_playing - /** * _ * checks to see if the alias _ is defined @@ -94,14 +82,6 @@ if (!function_exists('_')) { } // if _ isn't defined -/** - * show_admin_menu - * shows the admin menu - */ -function show_admin_menu ($admin_highlight) { - include(conf('prefix') . "/templates/admin_menu.inc"); -} // show_admin_menu - /** * access_denied * throws an error if they try to do something @@ -187,21 +167,6 @@ function show_local_control () { } // show_local_control -/** - * truncate_with_ellipse - * truncates a text file to specified length by adding - * thre dots (ellipse) to the end - * (Thx Nedko Arnaudov) - * @todo Fix Spelling! - * @depreciated - */ -function truncate_with_ellipse($text, $max=27) { - - /* Run the function with the correct spelling */ - return truncate_with_ellipsis($text,$max); - -} // truncate_with_ellipse - /** * truncate_with_ellipsis * Correct Spelling function that truncates text to a specific lenght @@ -327,8 +292,7 @@ function get_now_playing($filter='') { * if they don't: insert them * */ - -function set_artist_rating($artist_id, $rate_user, $rating) { +function set_artist_rating ($artist_id, $rate_user, $rating) { $artist_id = sql_escape($artist_id); $sql = "SELECT * FROM ratings WHERE user='$rate_user' AND object_type='artist' AND object_id='$artist_id'"; @@ -646,84 +610,6 @@ function show_genre($genre_id) { } // show_genre -function show_random_play_bar() { - - require (conf('prefix') . '/templates/show_random_play_bar.inc.php'); - -} // show_random_play_bar() - - -/* - * show_artist_pulldown() - * - * Helper functions for album and artist functions - * - */ -function show_artist_pulldown ($artist_id,$select_name='artist') { - - $sq = "SELECT `id`,`name` FROM `artist` ORDER BY `name`"; - $db_results = Dba::query($sq); - - echo "\n\n"; - -} // show_artist_pulldown - -/** - * show_catalog_pulldown - * This has been changed, first is the name of the - * dropdown select, the second is the style to be applied - * - */ -function show_catalog_pulldown ($name='catalog',$style) { - - $sql = "SELECT `id`,`name` FROM `catalog` ORDER BY `name`"; - $db_result = Dba::query($sql); - - echo "\n\n"; - -} // show_catalog_pulldown - - -/** - * show_submenu - * This shows the submenu mojo for the sidebar, and I guess honestly anything - * else you would want it to... takes an array of items which have ['url'] ['title'] - * and ['active'] - */ -function show_submenu($items) { - - require Config::get('prefix') . '/templates/subnavbar.inc.php'; - -} // show_submenu - - /** * get_location * This function gets the information about said persons currently location @@ -840,49 +726,6 @@ function show_preference_box($preferences) { } // show_preference_box - -/** - * show_genre_pulldown - * This shows a select of all of the genres, it takes the name of the select - * the currently selected and then the size - * - */ -function show_genre_pulldown ($name,$selected='',$size=1,$width=0,$style='') { - - /* Get them genre hippies */ - $sql = "SELECT genre.id,genre.name FROM genre ORDER BY genre.name"; - $db_result = Dba::query($sql); - - if ($size > 0) { - $multiple_txt = "multiple=\"multiple\" size=\"$size\""; - } - if ($style) { - $style_txt = "style=\"$style\""; - } - - echo "\n"; - -} // show_genre_pulldown - /** * good_email * Don't get me started... I'm sure the indenting is still wrong on this @@ -1023,24 +866,6 @@ function show_playlist_import() { } // show_playlist_import -/** - * show_songs - * Still not happy with this function, but at least it's in the right - * place now - */ -function show_songs ($song_ids, $playlist, $album=0) { - - $dbh = dbh(); - - $totaltime = 0; - $totalsize = 0; - - require (conf('prefix') . "/templates/show_songs.inc"); - - return true; - -} // show_songs - /** * show_album_select * This displays a select of every album that we've got in Ampache, (it can be hella long) it's used @@ -1050,10 +875,10 @@ function show_album_select($name='album',$album_id=0) { echo "\n"; - $sql = "SELECT id, name, prefix FROM artist ORDER BY name"; - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT `id`, `name`, `prefix` FROM `artist` ORDER BY `name`"; + $db_results = Dba::query($sql); - while ($r = mysql_fetch_assoc($db_results)) { + while ($r = Dba::fetch_assoc($db_results)) { $selected = ''; $artist_name = trim($r['prefix'] . " " . $r['name']); if ($r['id'] == $artist_id) { @@ -1103,10 +928,10 @@ function show_genre_select($name='genre',$genre_id=0) { echo " + + + artist); ?> + + + album); ?> + + + genre); ?> + + + + + + + + id . '&type=song','download',_('Save Changes'),'save_song_' . $song->id,'edit_song_' . $song->id); ?> + + + + diff --git a/templates/show_song_row.inc.php b/templates/show_song_row.inc.php new file mode 100644 index 00000000..cc6668ec --- /dev/null +++ b/templates/show_song_row.inc.php @@ -0,0 +1,41 @@ + + + id,'add',_('Add'),'add_' . $song->id); ?> + +f_link; ?> +f_artist_link; ?> +f_album_link; ?> +f_genre_link; ?> +f_track; ?> +f_time; ?> + + prefs['download']) { ?> + + + + + + has_access(100)) { ?> + id,'edit',_('Edit'),'edit_song_' . $song->id); ?> + + diff --git a/templates/show_songs.inc.php b/templates/show_songs.inc.php index 224b552f..4f2e1e9f 100644 --- a/templates/show_songs.inc.php +++ b/templates/show_songs.inc.php @@ -47,26 +47,8 @@ $ajax_url = Config::get('ajax_url'); $song = new Song($song_id); $song->format(); ?> - - - id,'add',_('Add'),'add_' . $song->id); ?> - - f_link; ?> - f_artist_link; ?> - f_album_link; ?> - f_genre_link; ?> - f_track; ?> - f_time; ?> - - - - - has_access(100)) { ?> - - - - - + + -- cgit