summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-09-03 19:16:18 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-09-03 19:16:18 +0000
commit219c3592744fc85a2332b20868622879fae20c1c (patch)
treee07123549724e1deeb02251041ab1e352a0d601c /lib
parent32180a41a11c46f30d24b6ac497601c577bf10cd (diff)
downloadampache-219c3592744fc85a2332b20868622879fae20c1c.tar.gz
ampache-219c3592744fc85a2332b20868622879fae20c1c.tar.bz2
ampache-219c3592744fc85a2332b20868622879fae20c1c.zip
tweaked the stats information, removed folders, was just to slow.. :( removed playlist.lib.php as its not longer needed
Diffstat (limited to 'lib')
-rw-r--r--lib/class/catalog.class.php37
-rw-r--r--lib/init.php1
-rw-r--r--lib/playlist.lib.php176
3 files changed, 22 insertions, 192 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 985388b7..30e78262 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -230,25 +230,32 @@ class Catalog {
if ($catalog_id) { $catalog_search = "WHERE `catalog`='" . Dba::escape($catalog_id) . "'"; }
- $sql = "SELECT `id`,`album`,`artist`,`genre`,`file`,`size`,`time` FROM `song` $catalog_search";
+ $sql = "SELECT COUNT(`id`),SUM(`time`),SUM(`size`) FROM `song` $catalog_search";
$db_results = Dba::query($sql);
+ $data = Dba::fetch_row($db_results);
+ $songs = $data['0'];
+ $time = $data['1'];
+ $size = $data['2'];
- while ($data = Dba::fetch_assoc($db_results)) {
- $albums[$data['album']] = true;
- $artists[$data['artist']] = true;
- $genres[$data['genre']] = true;
- $dir = basename($data['file']);
- $folders[$dir] = true;
- $size += $data['size'];
- $time += $data['time'];
- $songs++;
- }
+ $sql = "SELECT COUNT(`album`) FROM `song` $catalog_search GROUP BY `album`";
+ $db_results = Dba::query($sql);
+ $data = Dba::fetch_row($db_results);
+ $albums = $data['0'];
+
+ $sql = "SELECT COUNT(`artist`) FROM `song` $catalog_search GROUP BY `artist`";
+ $db_results = Dba::query($sql);
+ $data = Dba::fetch_row($db_results);
+ $artists = $data['0'];
+
+ $sql = "SELECT COUNT(`genre`) FROM `song` $catalog_search GROUP BY `genre`";
+ $db_results = Dba::query($sql);
+ $data = Dba::fetch_row($db_results);
+ $genres = $data['0'];
$results['songs'] = $songs;
- $results['albums'] = count($albums);
- $results['artists'] = count($artists);
- $results['genres'] = count($genres);
- $results['folders'] = count($folders);
+ $results['albums'] = $albums;
+ $results['artists'] = $artists;
+ $results['genres'] = $genres;
$results['size'] = $size;
$results['time'] = $time;
diff --git a/lib/init.php b/lib/init.php
index 147d2581..7e4c07c4 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -125,7 +125,6 @@ require_once $prefix . '/lib/gettext.php';
require_once $prefix . '/lib/batch.lib.php';
require_once $prefix . '/lib/themes.php';
require_once $prefix . '/lib/stream.lib.php';
-require_once $prefix . '/lib/playlist.lib.php';
require_once $prefix . '/lib/democratic.lib.php';
require_once $prefix . '/lib/xmlrpc.php';
require_once $prefix . '/modules/xmlrpc/xmlrpc.inc';
diff --git a/lib/playlist.lib.php b/lib/playlist.lib.php
deleted file mode 100644
index e0468241..00000000
--- a/lib/playlist.lib.php
+++ /dev/null
@@ -1,176 +0,0 @@
-<?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.
-
-*/
-/**
- * Playlist Library
- * This file should contain the functions that don't fit inside the object, but
- * still are related to handling playlists
- */
-
-/**
- * show_playlists
- * This shows all of the current playlists. Depending on your rights you may just
- * get to see Public + Yours Private or if you're an admin then you get to see
- * Public + Yours + Private
- */
-function show_playlists() {
-
- show_playlist_menu();
-
- /* Always show yours first */
- $playlists = get_playlists('private');
- $type = 'Private';
- require (conf('prefix') . '/templates/show_playlists.inc.php');
-
- /* Now for some Admin? */
- if ($GLOBALS['user']->has_access(100)) {
- $playlists = get_playlists('adminprivate');
- $type = 'Admin';
- require (conf('prefix') . '/templates/show_playlists.inc.php');
- }
-
- /* Always Show Public */
- $playlists = get_playlists('public');
- $type = 'Public';
- require (conf('prefix') . '/templates/show_playlists.inc.php');
-
-} // show_playlists
-
-/**
- * show_playlist_edit
- * This function shows the edit form for a playlist, nothing special here
- */
-function show_playlist_edit($playlist_id) {
-
- $playlist = new Playlist($playlist_id);
- /* Chuck em out if they don't have the rights */
- if (!$playlist->has_access()) { access_denied(); return false; }
-
- require_once (conf('prefix') . '/templates/show_playlist_edit.inc.php');
-
-} // show_playlist_edit
-
-/**
- * get_playlists
- * This function takes private,adminprivate or public and returns an array of playlist objects
- * that match, it checks permission
- */
-function get_playlists($type) {
-
- switch ($type) {
- case 'private':
- $sql = "SELECT id FROM playlist WHERE user='" . sql_escape($GLOBALS['user']->id) . "'" .
- " AND type='private' ORDER BY name";
- break;
- case 'adminprivate':
- if (!$GLOBALS['user']->has_access(100)) { return false; }
- $sql = "SELECT id FROM playlist WHERE user!='" . sql_escape($GLOBALS['user']->id) . "'" .
- " AND type='private' ORDER BY name";
- break;
- default:
- case 'public':
- $sql = "SELECT id FROM playlist WHERE type='public' ORDER BY name";
- break;
- } // end switch
-
- $db_results = mysql_query($sql, dbh());
-
- $results = array();
-
- while ($r = mysql_fetch_assoc($db_results)) {
- $playlist = new Playlist($r['id']);
- $results[] = $playlist;
- }
-
- return $results;
-
-} // get_playlists
-
-/**
- * prune_empty_playlists
- * This function goes through and deletes any playlists which have
- * no songs in them. This can only be done by a full admin
- */
-function prune_empty_playlists() {
-
-
- $sql = "SELECT playlist.id FROM playlist LEFT JOIN playlist_data ON playlist.id=playlist_data.playlist " .
- "WHERE playlist_data.id IS NULL";
- $db_results = mysql_query($sql, dbh());
-
- $results = array();
-
- while ($r = mysql_fetch_assoc($db_results)) {
- $results[] = $r['id'];
- }
-
- /* Delete the Playlists */
- foreach ($results as $playlist_id) {
- $playlist = new Playlist($playlist_id);
- $playlist->delete();
- }
-
- return true;
-
-} // prune_empty_playlists
-
-/**
- * show_playlist_select
- * This shows the playlist select box, it takes a playlist ID and a type as an optional
- * param, the type is 'normal','democratic','dynamic' these are hacks and make baby vollmer cry
- * but I'm too lazy to fix them right now
- */
-function show_playlist_select($playlist_id=0,$type='') {
-
- /* If democratic show everything, else normal */
- if ($type == 'democratic') {
- $where_sql = '1=1';
- }
- else {
- $where_sql = " `user` = '" . Dba::escape($GLOBALS['user']->id) . "'";
- }
-
- $sql = "SELECT id,name FROM playlist " .
- "WHERE " . $where_sql . " ORDER BY `name`";
- $db_results = Dba::query($sql);
-
- echo "<select name=\"playlist_id\">\n";
-
- /* The first value changes depending on our type */
- if ($type == 'democratic') {
- echo "\t<option value=\"0\">" . _('All') . "</option>\n";
- }
- elseif ($type != 'dynamic') {
- echo "\t<option value=\"0\"> -" . _('New Playlist') . "- </option>\n";
- }
-
- while ($r = mysql_fetch_assoc($db_results)) {
- $select_txt = '';
- if ($playlist_id == $r['id']) { $select_txt = ' selected="selected" '; }
-
- echo "\t<option value=\"" . scrub_out($r['id']) . "\"$select_txt>" . scrub_out($r['name']) . "</option>\n";
-
- } // end while
-
- echo '</select>';
-
-} // show_playlist_select
-
-?>