diff options
-rw-r--r-- | admin/catalog.php | 74 | ||||
-rw-r--r-- | index.php | 6 | ||||
-rw-r--r-- | lib/album.lib.php | 2 | ||||
-rw-r--r-- | lib/class/catalog.class.php | 512 | ||||
-rw-r--r-- | lib/class/update.class.php | 3 | ||||
-rwxr-xr-x | lib/class/vainfo.class.php | 2 | ||||
-rw-r--r-- | lib/general.lib.php | 9 | ||||
-rw-r--r-- | lib/init.php | 2 | ||||
-rw-r--r-- | lib/preferences.php | 10 | ||||
-rw-r--r-- | lib/themes.php | 48 | ||||
-rw-r--r-- | lib/ui.lib.php | 15 | ||||
-rw-r--r-- | login.php | 1 | ||||
-rw-r--r-- | server/ajax.server.php | 24 | ||||
-rwxr-xr-x | sql/ampache.sql | 9 | ||||
-rw-r--r-- | templates/javascript_refresh.inc.php | 4 | ||||
-rw-r--r-- | templates/show_add_catalog.inc.php | 48 | ||||
-rw-r--r-- | templates/show_index.inc.php | 2 | ||||
-rw-r--r-- | templates/show_run_add_catalog.inc.php | 25 | ||||
-rw-r--r-- | templates/sidebar.inc.php | 182 | ||||
-rw-r--r-- | templates/sidebar_admin.inc.php | 16 | ||||
-rw-r--r-- | themes/classic/templates/default.css | 1 |
21 files changed, 365 insertions, 630 deletions
diff --git a/admin/catalog.php b/admin/catalog.php index a855f116..8428730c 100644 --- a/admin/catalog.php +++ b/admin/catalog.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -20,23 +20,17 @@ */ - -/*! - @header Admin Catalog - This document handles actions for catalog creation and passes them off to the catalog class -*/ - -require('../lib/init.php'); +require '../lib/init.php'; if (!$GLOBALS['user']->has_access(100)) { access_denied(); + exit; } - -/* Set any vars we are going to need */ +// We'll need this $catalog = new Catalog($_REQUEST['catalog_id']); -show_template('header'); +require_once Config::get('prefix') . '/templates/header.inc.php'; /* Big switch statement to handle various actions */ switch ($_REQUEST['action']) { @@ -169,39 +163,45 @@ switch ($_REQUEST['action']) { $body = ''; show_confirmation($title,$body,$url); break; - // FIXME! case 'add_catalog': /* Wah Demo! */ - if (conf('demo_mode')) { break; } + if (Config::get('demo_mode')) { break; } + + if (!strlen($_REQUEST['path']) || !strlen($_REQUEST['name'])) { + Error::add('general','Error Name and path not specified'); + } + + if (substr($_REQUEST['path'],0,7) != 'http://' && $_REQUEST['type'] == 'remote') { + Error::add('general','Error Remote selected, but path is not a URL'); + } - if ($_REQUEST['path'] AND $_REQUEST['name']) { - /* Throw all of the album art types into an array */ - $art = array('id3'=>$_REQUEST['art_id3v2'],'amazon'=>$_REQUEST['art_amazon'],'folder'=>$_REQUEST['art_folder']); + if ($_REQUEST['type'] == 'remote' && !strlen($_REQUEST['key'])) { + Error::add('general','Error Remote Catalog specified, but no key provided'); + } - /* Enclose it in a purrty box! */ - echo "<div class=\"confirmation-box\">"; - - /* Create the Catalog */ - $catalog->new_catalog($_REQUEST['path'], - $_REQUEST['name'], - $_REQUEST['key'], - $_REQUEST['rename_pattern'], - $_REQUEST['sort_pattern'], - $_REQUEST['type'], - $_REQUEST['gather_art'], - $_REQUEST['parse_m3u'], - $art); + // If an error hasn't occured + if (!Error::$state) { + + $catalog_id = Catalog::create($_REQUEST); - echo "</div>\n"; + if (!$catalog_id) { + require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; + break; + } + + $catalog = new Catalog($catalog_id); + + // Run our initial add + $catalog->run_add($_REQUEST); - $url = conf('web_path') . '/admin/index.php'; - $title = _('Catalog Created'); - $body = _('Catalog Created and Songs Indexed'); - show_confirmation($title,$body,$url); + show_box_top(); + echo "<h2>" . _('Catalog Created') . "</h2>"; + Error::display('general'); + Error::display('catalog_add'); + show_box_bottom(); } else { - $error = "Please complete the form."; - include(conf('prefix') . '/templates/show_add_catalog.inc.php'); + require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; } break; case 'clear_stats': @@ -214,7 +214,7 @@ switch ($_REQUEST['action']) { show_confirmation($title,$body,$url); break; case 'show_add_catalog': - include(conf('prefix') . '/templates/show_add_catalog.inc.php'); + require Config::get('prefix') . '/templates/show_add_catalog.inc.php'; break; case 'clear_now_playing': if (conf('demo_mode')) { break; } @@ -19,11 +19,6 @@ */ -/*! - @header Index of Ampache - @discussion Do most of the dirty work of displaying the mp3 catalog - -*/ require_once 'lib/init.php'; require_once Config::get('prefix') . '/templates/header.inc.php'; @@ -35,6 +30,7 @@ $action = scrub_in($_REQUEST['action']); * going to let them break their servers */ if (Config::get('refresh_limit') > 5) { + $refresh_limit = Config::get('refresh_limit'); $ajax_url = Config::get('ajax_url') . '?action=reloadnp' . Config::get('ajax_info'); /* Can't have the & stuff in the Javascript */ $ajax_url = str_replace("&","&",$ajax_url); diff --git a/lib/album.lib.php b/lib/album.lib.php index ceb6cdf2..94ee1726 100644 --- a/lib/album.lib.php +++ b/lib/album.lib.php @@ -78,6 +78,8 @@ function get_random_albums($count='') { $total = count($albums); + if ($total == '0') { return array(); } + for ($i=0; $i <= $count; $i++) { $record = rand(0,$total); if (isset($results[$record]) || !$albums[$record]) { $i--; } diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 2f78949b..1a1d678f 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -45,12 +45,11 @@ class Catalog { public $genres = array(); /** - * Catalog + * Constructor * Catalog class constructor, pulls catalog information - * @catagory Catalog - * @param $catalog_id The ID of the catalog you want to build information from + * $catalog_id The ID of the catalog you want to build information from */ - function Catalog($catalog_id = 0) { + public function __construct($catalog_id = '') { if (!$catalog_id) { return false; } @@ -127,17 +126,89 @@ class Catalog { $results = self::count_songs($catalog_id); $results = array_merge(self::count_users($catalog_id),$results); -// $results->songs = $this->count_songs($catalog_id); -// $results->albums = $this->count_albums($catalog_id); -// $results->artists = $this->count_artists($catalog_id); -// $results->size = $this->get_song_size($catalog_id); -// $results->time = $this->get_song_time($catalog_id); - return $results; } // get_stats /** + * create + * This creates a new catalog entry and then returns the insert id + * it checks to make sure this path is not already used before creating + * the catalog + */ + public static function create($data) { + + $path = Dba::escape($data['path']); + + // Make sure the path is readable/exists + if (!is_readable($data['path'])) { + Error::add('general','Error: ' . scrub_out($data['path']) . ' is not readable or does not exist'); + return false; + } + + // Make sure this path isn't already in use by an existing catalog + $sql = "SELECT `id` FROM `catalog` WHERE `path`='$path'"; + $db_results = Dba::query($sql); + + if (Dba::num_rows($db_results)) { + Error::add('general','Error: Catalog with ' . $path . ' already exists'); + return false; + } + + $name = Dba::escape($data['name']); + $catalog_type = Dba::escape($data['catalog_type']); + $rename_pattern = Dba::escape($data['rename_pattern']); + $sort_pattern = Dba::escape($data['sort_pattern']); + $gather_types = Dba::escape($data['gather_types']); + $key = Dba::escape($data['key']); + + // Ok we're good to go ahead and insert this record + $sql = "INSERT INTO `catalog` (`name`,`path`,`catalog_type`,`rename_pattern`,`sort_pattern`,`gather_types`,`key`) " . + "VALUES ('$name','$path','$catalog_type','$rename_pattern','$sort_pattern','$gather_types','$key')"; + $db_results = Dba::query($sql); + + $insert_id = Dba::insert_id(); + + return $insert_id; + + } // create + + /** + * run_add + * This runs the add to catalog function + * it includes the javascript refresh stuff and then starts rolling + * throught the path for this catalog + */ + public function run_add($options) { + + // Catalog Add start + $start_time = time(); + + // Setup the 10 sec ajax request hotness + $refresh_limit = 10; + $ajax_url = Config::get('ajax_url') . '?action=catalog&type=add_files'; + /* Can't have the & stuff in the Javascript */ + $ajax_url = str_replace("&","&",$ajax_url); + require_once Config::get('prefix') . '/templates/javascript_refresh.inc.php'; + + show_box_top(); + echo _('Starting New Song Search on') . " <strong>[$this->name]</strong> " . _('catalog') . "<br />"; + echo "<div id=\"catalog_update\">"; + require_once Config::get('prefix') . '/templates/show_run_add_catalog.inc.php'; + echo "</div>"; + show_box_bottom(); + + // Prevent the script from timing out and flush what we've got + set_time_limit(0); + flush(); + + $this->add_files($this->path,$options); + + return true; + + } // run_add + + /** * count_songs * This returns the current # of songs, albums, artists, genres * in this catalog @@ -200,71 +271,6 @@ class Catalog { } // count_users - /*! - @function get_song_size - @discussion Get the total size of songs in all or a specific catalog - @param $catalog_id If set tells us to pick a specific catalog - */ - function get_song_size($catalog_id=0) { - - $sql = "SELECT SUM(song.size) FROM song"; - if ($catalog_id) { - $sql .= " WHERE catalog='$catalog_id'"; - } - - $db_results = mysql_query($sql, dbh()); - - $results = mysql_fetch_field($db_results); - - /* Convert it into MB */ - $results = ($results / 1048576); - - return $results; - - } // get_song_size - - - /*! - @function count_artists - @discussion Count the number of artists in all catalogs or in a specific one - @param $catalog_id If set tells us to pick a specific catalog - */ - function count_artists($catalog_id=0) { - - $sql = "SELECT DISTINCT(song.artist) FROM song"; - if ($catalog_id) { - $sql .= " WHERE catalog='$catalog_id'"; - } - - $db_results = mysql_query($sql,dbh()); - - $results = mysql_num_rows($db_results); - - return $results; - - } // count_artists - - - /*! - @function count_albums - @discussion Count the number of albums in all catalogs or in a specific one - @param $catalog_id If set tells us to pick a specific catalog - */ - function count_albums($catalog_id=0) { - - $sql = "SELECT DISTINCT(song.album) FROM song"; - if ($catalog_id) { - $sql .=" WHERE catalog='$catalog_id'"; - } - - $db_results = mysql_query($sql, dbh()); - - $results = mysql_num_rows($db_results); - - return $results; - - } // count_albums - /*! @function add_file @@ -288,17 +294,15 @@ class Catalog { } // add_file - /*! - @function add_files - @discussion Recurses throught $this->path and pulls out all mp3s and returns the full - path in an array. Passes gather_type to determin if we need to check id3 - information against the db. - @param $path The root path you want to start grabing files from - @param $gather_type=0 Determins if we need to check the id3 tags of the file or not - @param $parse_m3u Tells Ampache to look at m3us + /** + * add_files + * Recurses throught $this->path and pulls out all mp3s and returns the full + * path in an array. Passes gather_type to determin if we need to check id3 + * information against the db. */ - function add_files($path,$gather_type='',$parse_m3u=0,$verbose=1) { + public function add_files($path,$options) { + // Correctly detect the slash we need to use here if (strstr($path,"/")) { $slash_type = '/'; } @@ -306,15 +310,12 @@ class Catalog { $slash_type = '\\'; } - // Prevent the script from timing out - set_time_limit(0); - /* Open up the directory */ $handle = opendir($path); if (!is_resource($handle)) { debug_event('read',"Unable to Open $path",'5','ampache-catalog'); - echo "<font class=\"error\">" . _("Error: Unable to open") . " $path</font><br />\n"; + Error::add('catalog_add',_('Error: Unable to open') . ' ' . $path); } /* Recurse through this dir and create the files array */ @@ -328,7 +329,7 @@ class Catalog { /* Change the dir so is_dir works correctly */ if (!chdir($path)) { debug_event('read',"Unable to chdir $path",'2','ampache-catalog'); - echo "<font class=\"error\">" . _('Error: Unable to change to directory') . " $path</font><br />\n"; + Error::add('catalog_add',_('Error: Unable to change to directory') . ' ' . $path); } /* Create the new path */ @@ -338,7 +339,7 @@ class Catalog { // if it was set the day before unset($failed_check); - if (conf('no_symlinks')) { + if (Config::get('no_symlinks')) { if (is_link($full_file)) { debug_event('read',"Skipping Symbolic Link $path",'5','ampache-catalog'); continue; @@ -347,7 +348,7 @@ class Catalog { /* If it's a dir run this function again! */ if (is_dir($full_file)) { - $this->add_files($full_file,$gather_type,$parse_m3u); + $this->add_files($full_file,$options); /* Skip to the next file */ continue; } //it's a directory @@ -357,8 +358,8 @@ class Catalog { * to detect if it's a audio file for now the source for * this is in the /modules/init.php file */ - $pattern = "/\.(" . conf('catalog_file_pattern'); - if ($parse_m3u) { + $pattern = "/\.(" . Config::get('catalog_file_pattern'); + if ($options['parse_m3u']) { $pattern .= "|m3u)$/i"; } else { @@ -368,69 +369,55 @@ class Catalog { /* see if this is a valid audio file or playlist file */ if (preg_match($pattern ,$file)) { - /* Once we're sure that it is a valid file - * we need to check to see if it's new, only - * if we're doing a fast add - */ - if ($gather_type == 'fast_add') { - $file_time = filemtime($full_file); - if ($file_time < $this->last_add) { - debug_event('fast_add',"Skipping $full_file because last add is newer then file mod time",'5','ampache-catalog'); - continue; - } - } // if fast_add - /* Now that we're sure its a file get filesize */ $file_size = @filesize($full_file); if (!$file_size) { debug_event('read',"Unable to get filesize for $full_file",'2','ampache-catalog'); - echo "<span class=\"error\">" . _("Error: Unable to get filesize for") . " $full_file</span><br />"; + Error::add('catalog_add',_('Error: Unable to get filesize for') . ' ' . $full_file); } // file_size check - - if (is_readable($full_file)) { - - if (substr($file,-3,3) == 'm3u' AND $parse_m3u > 0) { - $this->_playlists[] = $full_file; - } // if it's an m3u - - else { - - /* see if the current song is in the catalog */ - $found = $this->check_local_mp3($full_file); - - /* If not found then insert, gets id3 information - * and then inserts it into the database - */ - if (!$found) { - $this->insert_local_song($full_file,$file_size); - - /* Stupid little cutesie thing */ - $this->count++; - if ( !($this->count%conf('catalog_echo_count')) AND $verbose) { - echo "<script type=\"text/javascript\">"; - echo "update_txt('" . $this->count . "','count_add_" . $this->id ."');"; - echo "</script>\n"; - flush(); - } //echos song count - - } // not found - - } // if it's not an m3u - - } // is readable - else { - // not readable, warn user - debug_event('read',"$full_file is not readable by ampache",'2','ampache-catalog'); - echo "$full_file " . _('is not readable by ampache') . ".<br />\n"; - } - - } //if it's a mp3 and is greater than 0 bytes + if (!is_readable($full_file)) { + // not readable, warn user + debug_event('read',"$full_file is not readable by ampache",'2','ampache-catalog'); + Error::add('catalog_add',"$full_file " . _('is not readable by ampache')); + continue; + } + + if (substr($file,-3,3) == 'm3u' AND $parse_m3u > 0) { + $this->_playlists[] = $full_file; + } // if it's an m3u else { - debug_event('read',"$full_file ignored, non audio file or 0 bytes",'5','ampache-catalog'); - } // else not an audio file or 0 size + + /* see if the current song is in the catalog */ + $found = $this->check_local_mp3($full_file); + + /* If not found then insert, gets id3 information + * and then inserts it into the database + */ + if (!$found) { + $this->insert_local_song($full_file,$file_size); + + /* Stupid little cutesie thing */ + $this->count++; + if ( !($this->count%Config::get('catalog_echo_count'))) { + $sql = "REPLACE INTO `update_info` (`key`,`value`) " . + "VALUES('catalog_add_found','$this->count')"; + $db_results = Dba::query($sql); + $sql = "REPLACE INTO `update_info` (`key`,`value`) " . + "VALUES('catalog_add_directory','" . Dba::escape($path) . "')"; + $db_results = Dba::query($sql); + } // update our current state + + } // not found + + } // if it's not an m3u + + } //if it matches the pattern + else { + debug_event('read',"$full_file ignored, non audio file or 0 bytes",'5','ampache-catalog'); + } // else not an audio file } // end while reading directory @@ -439,7 +426,7 @@ class Catalog { /* Close the dir handle */ @closedir($handle); - } //add_files + } // add_files /*! @function get_albums @@ -1651,75 +1638,18 @@ class Catalog { } //verify_catalog - - /*! - @function create_catalog_entry - @discussion Creates a new catalog from path and type - @param $path The root path for this catalog - @param $name The name of the new catalog - */ - function create_catalog_entry($path,$name,$key=0,$ren=0,$sort=0, $type='') { - - if (!$type) { $type = 'local'; } - - // Current time - $date = time(); - - $path = sql_escape($path); - $name = sql_escape($name); - $key = sql_escape($key); - $ren = sql_escape($ren); - $sort = sql_escape($sort); - $type = sql_escape($type); - - if($ren && $sort) { - $sql = "INSERT INTO catalog (path,name,last_update,`key`,rename_pattern,sort_pattern,catalog_type) " . - " VALUES ('$path','$name','$date', '$key', '$ren', '$sort','$type')"; - } - else { - $sql = "INSERT INTO catalog (path,name,`key`,`catalog_type`,last_update) VALUES ('$path','$name','$key','$type','$date')"; - } - - $db_results = mysql_query($sql, dbh()); - $catalog_id = mysql_insert_id(dbh()); - - return $catalog_id; - - } //create_catalog_entry - - - /*! - @function check_catalog - @discussion Checks for the $path already in the catalog table - @param $path The root path for the catalog we are checking - */ - function check_catalog($path) { - - $path = sql_escape($path); - - $sql = "SELECT id FROM catalog WHERE path='$path'"; - $db_results = mysql_query($sql, dbh()); - - $results = mysql_fetch_object($db_results); - - return $results->id; - - } //check_catalog - - - /*! - @function check_artist - @discussion Takes $artist checks if there then return id else insert and return id - @param $artist The name of the artist - */ - function check_artist($artist) { + /** + * check_artist + * $artist checks if there then return id else insert and return id + */ + public function check_artist($artist) { // Only get the var ones.. less func calls - $cache_limit = conf('artist_cache_limit'); + $cache_limit = Config::get('artist_cache_limit'); /* Clean up the artist */ $artist = trim($artist); - $artist = sql_escape($artist); + $artist = Dba::escape($artist); /* Ohh no the artist has lost it's mojo! */ @@ -1741,12 +1671,12 @@ class Catalog { } // if we've seen this artist before /* Setup the checking sql statement */ - $sql = "SELECT id FROM artist WHERE name LIKE '$artist' "; - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT `id` FROM `artist` WHERE `name` LIKE '$artist' "; + $db_results = Dba::query($sql); /* If it's found */ - if ($r = mysql_fetch_object($db_results)) { - $artist_id = $r->id; + if ($r = Dba::fetch_assoc($db_results)) { + $artist_id = $r['id']; } //if found /* If not found create */ @@ -1758,17 +1688,15 @@ class Catalog { $prefix_txt = "'$prefix'"; } - $sql = "INSERT INTO artist (name, prefix) VALUES ('$artist', $prefix_txt)"; - $db_results = mysql_query($sql, dbh()); - $artist_id = mysql_insert_id(dbh()); - + $sql = "INSERT INTO `artist` (`name`, `prefix`) VALUES ('$artist',$prefix_txt)"; + $db_results = Dba::query($sql); + $artist_id = Dba::insert_id(); if (!$db_results) { - echo "Error Inserting Artist:$artist <br />"; - flush(); + Error::add('general',"Inserting Artist:$artist"); } - } //not found + } // not found if ($cache_limit) { @@ -1785,23 +1713,21 @@ class Catalog { return $artist_id; - } //check_artist + } // check_artist - - /*! - @function check_album - @disucssion Takes $album and checks if there then return id else insert and return id - @param $album The name of the album - */ - function check_album($album,$album_year=0) { + /** + * check_album + * Takes $album and checks if there then return id else insert and return id + */ + public function check_album($album,$album_year=0) { /* Clean up the album name */ $album = trim($album); - $album = sql_escape($album); + $album = Dba::escape($album); $album_year = intval($album_year); // Set it once to reduce function calls - $cache_limit = conf('album_cache_limit'); + $cache_limit = Config::get('album_cache_limit'); /* Ohh no the album has lost it's mojo */ if (!$album) { @@ -1822,12 +1748,12 @@ class Catalog { } /* Setup the Query */ - $sql = "SELECT id,art FROM album WHERE name LIKE '$album'"; - if ($album_year) { $sql .= " AND year='$album_year'"; } - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT `id` FROM `album` WHERE `name` = '$album'"; + if ($album_year) { $sql .= " AND `year`='$album_year'"; } + $db_results = Dba::query($sql); /* If it's found */ - if ($r = mysql_fetch_assoc($db_results)) { + if ($r = Dba::fetch_assoc($db_results)) { $album_id = $r['id']; // If we don't have art put it in the needs me some art array @@ -1846,9 +1772,9 @@ class Catalog { $prefix_txt = "'$prefix'"; } - $sql = "INSERT INTO album (name, prefix,year) VALUES ('$album',$prefix_txt,'$album_year')"; - $db_results = mysql_query($sql, dbh()); - $album_id = mysql_insert_id(dbh()); + $sql = "INSERT INTO `album` (`name`, `prefix`,`year`) VALUES ('$album',$prefix_txt,'$album_year')"; + $db_results = Dba::query($sql); + $album_id = Dba::insert_id(); if (!$db_results) { debug_event('album',"Error Unable to insert Album:$album",'2'); @@ -1874,15 +1800,14 @@ class Catalog { return $album_id; - } //check_album + } // check_album - /*! - @function check_genre - @discussion Finds the Genre_id from the text name - @param $genre The name of the genre - */ - function check_genre($genre) { + /** + * check_genre + * Finds the Genre_id from the text name + */ + public function check_genre($genre) { /* If a genre isn't specified force one */ if (strlen(trim($genre)) < 1) { @@ -1894,16 +1819,16 @@ class Catalog { } /* Look in the genre table */ - $genre = sql_escape($genre); - $sql = "SELECT id FROM genre WHERE name LIKE '$genre'"; - $db_results = mysql_query($sql, dbh()); + $genre = Dba::escape($genre); + $sql = "SELECT `id` FROM `genre` WHERE `name` = '$genre'"; + $db_results = Dba::query($sql); - $results = mysql_fetch_assoc($db_results); + $results = Dba::fetch_assoc($db_results); if (!$results['id']) { - $sql = "INSERT INTO genre (name) VALUES ('$genre')"; - $db_results = mysql_query($sql, dbh()); - $insert_id = mysql_insert_id(dbh()); + $sql = "INSERT INTO `genre` (`name`) VALUES ('$genre')"; + $db_results = Dba::query($sql); + $insert_id = Dba::insert_id(); } else { $insert_id = $results['id']; } @@ -1911,41 +1836,36 @@ class Catalog { return $insert_id; - } //check_genre - - - /*! - @function check_title - @discussion this checks to make sure something is - set on the title, if it isn't it looks at the - filename and trys to set the title based on that - */ - function check_title($title,$file=0) { + } // check_genre + + /** + * check_title + * this checks to make sure something is + * set on the title, if it isn't it looks at the + * filename and trys to set the title based on that + */ + public function check_title($title,$file=0) { if (strlen(trim($title)) < 1) { preg_match("/.+\/(.*)\.....?$/",$file,$matches); - $title = sql_escape($matches[1]); + $title = Dba::escape($matches[1]); } return $title; - } //check_title - + } // check_title - /*! - @function insert_local_song - @discussion Insert a song that isn't already in the database this - function is in here so we don't have to create a song object - @param $file The file name we are adding (full path) - @param $file_info The information of the file, size etc taken from stat() - */ - function insert_local_song($file,$file_info) { + /** + * insert_local_song + * Insert a song that isn't already in the database this + * function is in here so we don't have to create a song object + */ + public function insert_local_song($file,$file_info) { /* Create the vainfo object and get info */ $vainfo = new vainfo($file,'',$this->sort_pattern,$this->rename_pattern); $vainfo->get_info(); - $song_obj = new Song(); $key = get_tag_type($vainfo->tags); @@ -1953,7 +1873,7 @@ class Catalog { $results = clean_tag_info($vainfo->tags,$key,$file); /* Set the vars here... so we don't have to do the '" . $blah['asd'] . "' */ - $title = sql_escape($results['title']); + $title = Dba::escape($results['title']); $artist = $results['artist']; $album = $results['album']; $genre = $results['genre']; @@ -1976,34 +1896,28 @@ class Catalog { $genre_id = $this->check_genre($genre); $album_id = $this->check_album($album,$year); $title = $this->check_title($title,$file); - $add_file = sql_escape($file); + $add_file = Dba::escape($file); - $sql = "INSERT INTO song (file,catalog,album,artist,title,bitrate,rate,mode,size,time,track,genre,addition_time,year)" . + $sql = "INSERT INTO `song` (file,catalog,album,artist,title,bitrate,rate,mode,size,time,track,genre,addition_time,year)" . " VALUES ('$add_file','$this->id','$album_id','$artist_id','$title','$bitrate','$rate','$mode','$size','$song_time','$track','$genre_id','$current_time','$year')"; - - $db_results = mysql_query($sql, dbh()); + $db_results = Dba::query($sql); if (!$db_results) { debug_event('insert',"Unable to insert $file -- $sql",'5','ampache-catalog'); - echo "<span style=\"color: #F00;\">Error Adding $file </span><hr />$sql<hr />"; + Error::add('catalog_add','Error Adding ' . $file . ' SQL:' . $sql); } - - $song_id = mysql_insert_id(dbh()); + $song_id = Dba::insert_id(); /* Add the EXT information */ - $sql = "INSERT INTO song_ext_data (song_id,comment,lyrics) " . + $sql = "INSERT INTO `song_data` (`song_id`,`comment`,`lyrics`) " . " VALUES ('$song_id','$comment','$lyrics')"; - $db_results = mysql_query($sql,dbh()); + $db_results = Dba::query($sql); if (!$db_results) { debug_event('insert',"Unable to insert EXT Info for $file -- $sql",'5','ampache-catalog'); - flush(); } - /* Clear Variables */ - unset($results,$audio_info,$song_obj); - } // insert_local_song /*! @@ -2053,12 +1967,10 @@ class Catalog { } // check_remote_song - /*! - @function check_local_mp3 - @discussion Checks the song to see if it's there already returns true if found, false if not - @param $full_file The full file name that we are checking - @param $gather_type=0 If we need to check id3 tags or not - */ + /** + * check_local_mp3 + * Checks the song to see if it's there already returns true if found, false if not + */ function check_local_mp3($full_file, $gather_type='') { if ($gather_type == 'fast_add') { @@ -2068,13 +1980,13 @@ class Catalog { } } - $full_file = sql_escape($full_file); + $full_file = Dba::escape($full_file); - $sql = "SELECT id FROM song WHERE file = '$full_file'"; - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT `id` FROM `song` WHERE `file` = '$full_file'"; + $db_results = Dba::query($sql); //If it's found then return true - if (mysql_fetch_row($db_results)) { + if (Dba::fetch_row($db_results)) { return true; } diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 13bfdfdb..0f44a4b0 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -621,6 +621,9 @@ class Update { "VALUES ('playlist_method','50','Playlist Method','5','string','streaming')"; $db_results = Dba::query($sql); + $sql = "ALTER TABLE `update_info` ADD UNIQUE (`key`)"; + $db_results = Dba::query($sql); + $sql = "SELECT `id` FROM `user`"; $db_results = Dba::query($sql); diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php index cdf793ab..e2212838 100755 --- a/lib/class/vainfo.class.php +++ b/lib/class/vainfo.class.php @@ -55,7 +55,7 @@ class vainfo { $this->encoding = $encoding; } else { - $this->encoding = conf('site_charset'); + $this->encoding = Config::get('site_charset'); } /* These are needed for the filename mojo */ diff --git a/lib/general.lib.php b/lib/general.lib.php index c9283f08..4ee9796f 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -190,7 +190,7 @@ function extend_session($sid) { function get_tag_type($results) { /* Pull In the config option */ - $order = conf('tag_order'); + $order = Config::get('tag_order'); if (!is_array($order)) { $order = array($order); @@ -236,12 +236,7 @@ function clean_tag_info($results,$key,$filename) { $info['title'] = stripslashes(trim($results[$key]['title'])); $info['year'] = intval($results[$key]['year']); $info['track'] = intval($results[$key]['track']); - $info['comment'] = sql_escape(str_replace($clean_array,$wipe_array,$results[$key]['comment'])); - - if (strlen($info['comment']) > 254) { - debug_event('catalog','Error: Comment over 254 Char, truncating',4); - $info['comment'] = substr($info['comment'],0,254); - } + $info['comment'] = Dba::escape(str_replace($clean_array,$wipe_array,$results[$key]['comment'])); /* This are pulled from the info array */ $info['bitrate'] = intval($results['info']['bitrate']); diff --git a/lib/init.php b/lib/init.php index 3a72f40a..c443b1d7 100644 --- a/lib/init.php +++ b/lib/init.php @@ -193,7 +193,6 @@ if (NO_SESSION != '1' AND Config::get('use_auth')) { if (!$GLOBALS['user']->id AND !Config::get('demo_mode')) { logout(); exit; } /* Load preferences and theme */ - set_theme(); $GLOBALS['user']->update_last_seen(); } elseif (!Config::get('use_auth')) { @@ -210,7 +209,6 @@ elseif (!Config::get('use_auth')) { $GLOBALS['user']->username = '-1'; $GLOBALS['user']->access = $auth['access']; $_SESSION['userdata']['username'] = $auth['username']; - set_theme(); } // If Auth, but no session is set else { diff --git a/lib/preferences.php b/lib/preferences.php index 5fb1a696..531532cd 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -422,8 +422,8 @@ function insert_preference($name,$description,$default,$level,$type,$catagory) { function init_preferences() { /* Get Global Preferences */ - $sql = "SELECT preferences.name,user_preference.value FROM preferences,user_preference WHERE user_preference.user='-1' " . - " AND user_preference.preference = preferences.id AND preferences.catagory='system'"; + $sql = "SELECT preference.name,user_preference.value FROM preference,user_preference WHERE user_preference.user='-1' " . + " AND user_preference.preference = preference.id AND preference.catagory='system'"; $db_results = Dba::query($sql); while ($r = Dba::fetch_assoc($db_results)) { @@ -433,12 +433,12 @@ function init_preferences() { /* Now we need to allow the user to override some stuff that's been set by the above */ $user_id = '-1'; - if ($GLOBALS['user']->id) { + if ($GLOBALS['user']->username) { $user_id = Dba::escape($GLOBALS['user']->id); } - $sql = "SELECT preferences.name,user_preference.value FROM preferences,user_preference WHERE user_preference.user='$user_id' " . - " AND user_preference.preference = preferences.id AND preferences.catagory != 'system'"; + $sql = "SELECT preference.name,user_preference.value FROM preference,user_preference WHERE user_preference.user='$user_id' " . + " AND user_preference.preference = preference.id AND preference.catagory != 'system'"; $db_results = Dba::query($sql); while ($r = Dba::fetch_assoc($db_results)) { diff --git a/lib/themes.php b/lib/themes.php index d7b23ace..edee2406 100644 --- a/lib/themes.php +++ b/lib/themes.php @@ -77,54 +77,6 @@ function get_theme($name) { } // get_theme /*! - @function set_theme - @discussion Resets all of the colors for this theme -*/ -function set_theme_colors($theme_name,$user_id) { - - if (make_bool($user_id)) { - $user_sql = "`user`='$user_id' AND"; - } - - - /* We assume if we've made it this far we've got the right to do it - This could be dangerous but eah! - */ - $theme = get_theme($theme_name); - $GLOBALS['theme'] = $theme; - if (!count($theme)) { return false; } - - foreach ($theme as $key=>$color) { - - $sql = "SELECT id FROM preferences WHERE name='" . sql_escape($key) . "'"; - $db_results = mysql_query($sql, dbh()); - - $results = mysql_fetch_array($db_results); - // Quick hack this needs to be fixed - if ($results) { - $sql = "UPDATE user_preference SET `value`='" . sql_escape($color) . "' WHERE $user_sql " . - " preference='" . $results[0] . "'"; - $db_results = mysql_query($sql, dbh()); - } - - } // theme colors - -} // set_theme_colors - -/*! - @function set_theme - @discussion this sets the needed vars for the theme -*/ -function set_theme() { - - if (strlen(Config::get('theme_name')) > 0) { - $theme_path = "/themes/" . Config::get('theme_name'); - Config::set(array('theme_path'=>$theme_path),1); - } - -} // set_theme - -/*! @function get_theme_author @discussion returns the author of this theme */ diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 0310f6df..3a7d3f7e 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -493,13 +493,12 @@ function show_local_catalog_info() { /* Before we display anything make sure that they have a catalog */ $query = "SELECT * FROM catalog"; $db_results = Dba::query($query); - + // Make sure we have something to display - if (!Dba::num_rows($db_results)) { + if (Dba::num_rows($db_results) < 1) { show_box_top(); - $items[] = "<span align=\"center\" class=\"error\">" . _('No Catalogs Found!') . "</span><br />"; - $items[] = "<a href=\"" . Config::get('web_path') . "/admin/catalog.php?action=show_add_catalog\">" ._('Add a Catalog') . "</a>"; - show_info_box('','catalog',$items); + echo "<span align=\"center\" class=\"error\">" . _('No Catalogs Found!') . "</span><br />"; + echo "<a href=\"" . Config::get('web_path') . "/admin/catalog.php?action=show_add_catalog\">" ._('Add a Catalog') . "</a>"; show_box_bottom(); return false; } @@ -1196,11 +1195,13 @@ function show_box_bottom() { * this function takes a name and a returns either a text representation * or an <img /> tag */ -function get_user_icon($name,$hover_name='') { +function get_user_icon($name,$hover_name='',$title='') { /* Because we do a lot of calls cache the URLs */ static $url_cache = array(); + if (!$title) { $title = $name; } + if (isset($url_cache[$name])) { $img_url = $url_cache[$name]; $cache_url = true; @@ -1239,7 +1240,7 @@ function get_user_icon($name,$hover_name='') { } // end if not cached - $string = "<img style=\"cursor: pointer;\" src=\"$img_url\" border=\"0\" alt=\"" . ucfirst($name) . "\" title=\"" . ucfirst($name) . "\" $hov_txt/>"; + $string = "<img style=\"cursor: pointer;\" src=\"$img_url\" border=\"0\" alt=\"" . ucfirst($title) . "\" title=\"" . ucfirst($title) . "\" $hov_txt/>"; return $string; @@ -38,6 +38,7 @@ if (Config::get('access_control')) { if (!Access::check_network('interface',$_SERVER['REMOTE_ADDR'],'','5')) { debug_event('access_denied','Access Denied:' . $_SERVER['REMOTE_ADDR'] . ' is not in the Interface Access list','3'); access_denied(); + exit(); } } // access_control is enabled diff --git a/server/ajax.server.php b/server/ajax.server.php index 0ef48273..4f60573b 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -271,6 +271,30 @@ switch ($action) { ob_end_clean(); echo xml_from_array($results); break; + case 'catalog': + switch ($_REQUEST['type']) { + case 'add_files': + $sql = "SELECT * FROM `update_info` WHERE `key` LIKE 'catalog_add_%'"; + $template = '/templates/show_run_add_catalog.inc.php'; + break; + case 'update_files': + case 'clean_files': + default: + break; + } // end switch on type + + $db_results = Dba::query($sql); + + while ($data = Dba::fetch_assoc($db_results)) { + ${$data['key']} = $data['value']; + } + + ob_start(); + require_once Config::get('prefix') . $template; + $results['catalog_update'] = ob_get_contents(); + ob_end_clean(); + echo xml_from_array($results); + break; default: $results['3514'] = '0x1'; echo xml_from_array($results); diff --git a/sql/ampache.sql b/sql/ampache.sql index e6674e76..1beffc8f 100755 --- a/sql/ampache.sql +++ b/sql/ampache.sql @@ -366,7 +366,7 @@ CREATE TABLE `preference` ( LOCK TABLES `preference` WRITE; /*!40000 ALTER TABLE `preference` DISABLE KEYS */; -INSERT INTO `preference` VALUES (1,'download','0','Allow Downloads',100,'boolean','options'),(4,'popular_threshold','10','Popular Threshold',25,'integer','interface'),(19,'sample_rate','32','Downsample Bitrate',25,'string','streaming'),(22,'site_title','Ampache :: Pour l\'Amour de la Musique','Website Title',100,'string','system'),(23,'lock_songs','0','Lock Songs',100,'boolean','system'),(24,'force_http_play','1','Forces Http play regardless of port',100,'boolean','system'),(25,'http_port','80','Non-Standard Http Port',100,'integer','system'),(26,'catalog_echo_count','100','Catalog Echo Interval',100,'integer','system'),(41,'localplay_controller','0','Localplay Type',100,'special','streaming'),(29,'play_type','stream','Type of Playback',25,'special','streaming'),(30,'direct_link','1','Allow Direct Links',100,'boolean','options'),(31,'lang','en_US','Language',100,'special','interface'),(32,'playlist_type','m3u','Playlist Type',100,'special','streaming'),(33,'theme_name','classic','Theme',0,'special','interface'),(34,'ellipse_threshold_album','27','Album Ellipse Threshold',0,'integer','interface'),(35,'ellipse_threshold_artist','27','Artist Ellipse Threshold',0,'integer','interface'),(36,'ellipse_threshold_title','27','Title Ellipse Threshold',0,'integer','interface'),(51,'offset_limit','50','Offset Limit',5,'integer','interface'),(40,'localplay_level','0','Localplay Access Level',100,'special','streaming'),(43,'allow_downsample_playback','0','Allow Downsampling',100,'boolean','system'),(44,'allow_stream_playback','1','Allow Streaming',100,'boolean','system'),(45,'allow_democratic_playback','0','Allow Democratic Play',100,'boolean','system'),(46,'allow_localplay_playback','0','Allow Localplay Play',100,'boolean','system'),(47,'stats_threshold','7','Statistics Day Threshold',25,'integer','interface'),(49,'min_object_count','1','Min Element Count',5,'integer','interface'),(50,'random_method','default','Random Method',5,'string','interface'); +INSERT INTO `preference` VALUES (1,'download','0','Allow Downloads',100,'boolean','options'),(4,'popular_threshold','10','Popular Threshold',25,'integer','interface'),(19,'sample_rate','32','Downsample Bitrate',25,'string','streaming'),(22,'site_title','Ampache :: Pour l\'Amour de la Musique','Website Title',100,'string','system'),(23,'lock_songs','0','Lock Songs',100,'boolean','system'),(24,'force_http_play','1','Forces Http play regardless of port',100,'boolean','system'),(25,'http_port','80','Non-Standard Http Port',100,'integer','system'),(26,'catalog_echo_count','50','Catalog Echo Interval',100,'integer','system'),(41,'localplay_controller','0','Localplay Type',100,'special','streaming'),(29,'play_type','stream','Type of Playback',25,'special','streaming'),(30,'direct_link','1','Allow Direct Links',100,'boolean','options'),(31,'lang','en_US','Language',100,'special','interface'),(32,'playlist_type','m3u','Playlist Type',100,'special','streaming'),(33,'theme_name','classic','Theme',0,'special','interface'),(34,'ellipse_threshold_album','27','Album Ellipse Threshold',0,'integer','interface'),(35,'ellipse_threshold_artist','27','Artist Ellipse Threshold',0,'integer','interface'),(36,'ellipse_threshold_title','27','Title Ellipse Threshold',0,'integer','interface'),(51,'offset_limit','50','Offset Limit',5,'integer','interface'),(40,'localplay_level','0','Localplay Access Level',100,'special','streaming'),(43,'allow_downsample_playback','0','Allow Downsampling',100,'boolean','system'),(44,'allow_stream_playback','1','Allow Streaming',100,'boolean','system'),(45,'allow_democratic_playback','0','Allow Democratic Play',100,'boolean','system'),(46,'allow_localplay_playback','0','Allow Localplay Play',100,'boolean','system'),(47,'stats_threshold','7','Statistics Day Threshold',25,'integer','interface'),(49,'min_object_count','1','Min Element Count',5,'integer','interface'),(50,'random_method','default','Random Method',5,'string','interface'); /*!40000 ALTER TABLE `preference` ENABLE KEYS */; UNLOCK TABLES; @@ -550,7 +550,7 @@ CREATE TABLE `tmp_playlist` ( PRIMARY KEY (`id`), KEY `session` (`session`), KEY `type` (`type`) -) TYPE=MyISAM AUTO_INCREMENT=4; +) TYPE=MyISAM; -- -- Dumping data for table `tmp_playlist` @@ -591,7 +591,7 @@ DROP TABLE IF EXISTS `update_info`; CREATE TABLE `update_info` ( `key` varchar(128) NOT NULL default '', `value` varchar(255) NOT NULL default '', - KEY `key` (`key`) + UNIQUE KEY `key` (`key`) ) TYPE=MyISAM; -- @@ -652,7 +652,6 @@ CREATE TABLE `user_preference` ( LOCK TABLES `user_preference` WRITE; /*!40000 ALTER TABLE `user_preference` DISABLE KEYS */; -INSERT INTO `user_preference` VALUES (-1,43,'0'),(-1,40,'0'),(-1,51,'50'),(-1,36,'27'),(-1,35,'27'),(-1,34,'27'),(-1,33,'classic'),(-1,32,'m3u'),(-1,31,'en_US'),(-1,30,'1'),(-1,29,'stream'),(-1,41,'0'),(-1,26,'100'),(-1,25,'80'),(-1,24,'1'),(-1,23,'0'),(-1,22,'Ampache :: Pour l\'Amour de la Musique'),(-1,19,'32'),(-1,4,'10'),(-1,1,'0'),(-1,44,'1'),(-1,45,'0'),(-1,46,'0'),(-1,47,'7'),(-1,49,'1'),(-1,50,'default'); /*!40000 ALTER TABLE `user_preference` ENABLE KEYS */; UNLOCK TABLES; @@ -685,4 +684,4 @@ UNLOCK TABLES; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2007-05-13 21:34:12 +-- Dump completed on 2007-05-14 7:11:20 diff --git a/templates/javascript_refresh.inc.php b/templates/javascript_refresh.inc.php index c53c9cd8..7362f2f3 100644 --- a/templates/javascript_refresh.inc.php +++ b/templates/javascript_refresh.inc.php @@ -23,7 +23,7 @@ <script type="text/javascript" language="javascript"> <!-- Begin // Set refresh interval (in seconds) -var refreshinterval=<?php echo Config::get('refresh_limit'); ?>; +var refreshinterval=<?php echo $refresh_limit ?>; function doLoad() { @@ -42,7 +42,7 @@ function refresh() } // start with page-load -window.onload=doLoad; +doLoad; // End --> </script> diff --git a/templates/show_add_catalog.inc.php b/templates/show_add_catalog.inc.php index c1f74639..16661417 100644 --- a/templates/show_add_catalog.inc.php +++ b/templates/show_add_catalog.inc.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -22,41 +22,38 @@ $default_rename = "%a - %T - %t"; $default_sort = "%a/%A"; - ?> - <?php show_box_top(_('Add a Catalog')); ?> - <p><?php echo _("In the form below enter either a local path (i.e. /data/music) or the URL to a remote Ampache installation (i.e http://theotherampache.com)"); ?></p> - -<form name="update_catalog" method="post" action="<?php echo conf('web_path'); ?>/admin/catalog.php" enctype="multipart/form-data"> +<?php Error::display('general'); ?> +<form name="update_catalog" method="post" action="<?php echo Config::get('web_path'); ?>/admin/catalog.php" enctype="multipart/form-data"> <table class="tabledata" cellpadding="0" border="0" cellspacing="0"> <tr> - <td><?php echo _("Catalog Name"); ?>: </td> + <td><?php echo _('Catalog Name'); ?>: </td> <td><input size="60" type="text" name="name" value="<?php echo $_REQUEST['name']; ?>" /></td> <td style="vertical-align:top; font-family: monospace;" rowspan="6"> - <strong><?php echo _("Auto-inserted Fields"); ?>:</strong><br /> - %A = <?php echo _("album name"); ?><br /> - %a = <?php echo _("artist name"); ?><br /> - %c = <?php echo _("id3 comment"); ?><br /> - %g = <?php echo _("genre"); ?><br /> - %T = <?php echo _("track number (padded with leading 0)"); ?><br /> - %t = <?php echo _("song title"); ?><br /> - %y = <?php echo _("year"); ?><br /> - %o = <?php echo _("other"); ?><br /> + <strong><?php echo _('Auto-inserted Fields'); ?>:</strong><br /> + %A = <?php echo _('album name'); ?><br /> + %a = <?php echo _('artist name'); ?><br /> + %c = <?php echo _('id3 comment'); ?><br /> + %g = <?php echo _('genre'); ?><br /> + %T = <?php echo _('track number (padded with leading 0)'); ?><br /> + %t = <?php echo _('song title'); ?><br /> + %y = <?php echo _('year'); ?><br /> + %o = <?php echo _('other'); ?><br /> </td> </tr> <tr> - <td><?php echo _("Path"); ?>: </td> + <td><?php echo _('Path'); ?>: </td> <td><input size="60" type="text" name="path" value="<?php echo $_REQUEST['path']; ?>" /></td> </tr> <tr> - <td><?php echo _("Catalog Type"); ?>: </td> + <td><?php echo _('Catalog Type'); ?>: </td> <td> <select name="type"> - <option value="local"><?php echo _("Local"); ?></option> - <option value="remote"><?php echo _("Remote"); ?></option> + <option value="local"><?php echo _('Local'); ?></option> + <option value="remote"><?php echo _('Remote'); ?></option> </select> </td> </tr> @@ -65,17 +62,17 @@ $default_sort = "%a/%A"; <td><input size="30" type="text" name="key" value="" /><span class="error">*<?php echo _('Required for Remote Catalogs'); ?></span></td> </tr> <tr> - <td><?php echo _("Filename Pattern"); ?>: </td> + <td><?php echo _('Filename Pattern'); ?>: </td> <td><input size="60" type="text" name="rename_pattern" value="<?php echo $default_rename; ?>" /></td> </tr> <tr> - <td><?php echo _("Folder Pattern"); ?>:<br /><?php echo _("(no leading or ending '/')"); ?></td> + <td><?php echo _('Folder Pattern'); ?>:<br /><?php echo _("(no leading or ending '/')"); ?></td> <td valign="top"><input size="60" type="text" name="sort_pattern" value="<?php echo $default_sort; ?>" /></td> </tr> <tr> - <td valign="top"><?php echo _("Gather Album Art"); ?>:</td> + <td valign="top"><?php echo _('Gather Album Art'); ?>:</td> <td><input type="checkbox" name="gather_art" value="1" /></td> </tr> <tr> @@ -87,12 +84,9 @@ $default_sort = "%a/%A"; <td> </td> <td> <input type="hidden" name="action" value="add_catalog" /> - <input class="button" type="submit" value="<?php echo _("Add Catalog"); ?>" /> - <input class="button" type="reset" value="<?php echo _("Reset"); ?>" /> - <input type="button" onclick="javascript:history.go(-1)" value="<?php echo _("Cancel"); ?>" /> + <input class="button" type="submit" value="<?php echo _('Add Catalog'); ?>" /> </td> </tr> - </table> </form> <?php show_box_bottom(); ?> diff --git a/templates/show_index.inc.php b/templates/show_index.inc.php index 525ddc07..0afacb0e 100644 --- a/templates/show_index.inc.php +++ b/templates/show_index.inc.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2006 Ampache.org + Copyright (c) 2001 - 2007 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/templates/show_run_add_catalog.inc.php b/templates/show_run_add_catalog.inc.php new file mode 100644 index 00000000..65a79240 --- /dev/null +++ b/templates/show_run_add_catalog.inc.php @@ -0,0 +1,25 @@ +<?php +/* + + Copyright (c) 2001 - 2007 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. + +*/ + +// Get the count of the number of items in their playlist +?> +<?php echo _('Found'); ?>:<?php echo $catalog_add_found; ?><br /> +<?php echo _('Reading'); ?>:<?php echo $catalog_add_directory; ?><br /> diff --git a/templates/sidebar.inc.php b/templates/sidebar.inc.php index 2a490551..13612552 100644 --- a/templates/sidebar.inc.php +++ b/templates/sidebar.inc.php @@ -19,24 +19,6 @@ */ -/** - * This is kind of the wrong place to do this, but let's define the different submenu's that could possibly be - * displayed on this page, this calls the show_submenu($items); function which takes an array of items - * that have ['title'] ['url'] ['active'] and ['cssclass'] url assumes no Config::get('web_path') - */ - -$admin_items[] = array('title'=>_('Users'),'url'=>'admin/users.php','active'=>$location['page'], 'cssclass'=>'sidebar_admin_users'); -$admin_items[] = array('title'=>_('Mail Users'),'url'=>'admin/mail.php','active'=>$location['page'], 'cssclass'=>'sidebar_admin_mail_users'); -$admin_items[] = array('title'=>_('Catalog'),'url'=>'admin/index.php','active'=>$location['page'], 'cssclass'=>'sidebar_admin_catalog'); -$admin_items[] = array('title'=>_('Config'),'url'=>'admin/preferences.php','active'=>$location['page'], 'cssclass'=>'sidebar_admin_config'); -$admin_items[] = array('title'=>_('Access List'),'url'=>'admin/access.php','active'=>$location['page'], 'cssclass'=>'sidebar_admin_access_list'); - -$browse_items[] = array('title'=>_("Albums"),'url'=>'albums.php','active'=>$location['page'], 'cssclass'=>'sidebar_browse_albums'); -$browse_items[] = array('title'=>_("Artists"),'url'=>'artists.php','active'=>$location['page'], 'cssclass'=>'sidebar_browse_artists'); -$browse_items[] = array('title'=>_("Genre"),'url'=>'browse.php?action=genre','active'=>$location['page'], 'cssclass'=>'sidebar_browse_genre'); -$browse_items[] = array('title'=>_('Song Title'),'url'=>'browse.php?action=song_title','active'=>$location['page'], 'cssclass'=>'sidebar_browse_song_title'); - - if (!$_SESSION['state']['sidebar_tab']) { $_SESSION['state']['sidebar_tab'] = 'home'; } $class_name = 'sidebar_' . $_SESSION['state']['sidebar_tab']; ${$class_name} = ' class="active" '; @@ -46,178 +28,26 @@ $ajax_url = Config::get('ajax_url'); ?> <ul id="sidebar-tabs"> <li <?php echo $sidebar_home; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&button=home');" > - <?php echo get_user_icon('home'); ?> + <?php echo get_user_icon('home','',_('Home')); ?> </li> <li <?php echo $sidebar_browse; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&button=browse');" > - <?php echo get_user_icon('browse'); ?> + <?php echo get_user_icon('browse','',_('Browse')); ?> </li> <li <?php echo $sidebar_search; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&button=search');" > - <?php echo get_user_icon('view'); ?> + <?php echo get_user_icon('view','',_('Search')); ?> </li> <li <?php echo $sidebar_preferences; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&button=preferences');" > - <?php echo get_user_icon('edit'); ?> + <?php echo get_user_icon('edit','',_('Preferences')); ?> </li> <?php if ($GLOBALS['user']->has_access('100')) { ?> <li <?php echo $sidebar_admin; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&button=admin');" > - <?php echo get_user_icon('admin'); ?> + <?php echo get_user_icon('admin','',_('Admin')); ?> </li> <?php } ?> <li <?php echo $sidebar_player; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&button=player');" > - <?php echo get_user_icon('all'); ?> + <?php echo get_user_icon('all','',_('Player')); ?> </li> </ul> <div id="sidebar-page"> <?php require_once Config::get('prefix') . '/templates/sidebar_' . $_SESSION['state']['sidebar_tab'] . '.inc.php'; ?> </div> -<!-- -<h3> </h3> -<ul id="navlist"> - <li id="sidebar_home"<?php - if ($location['page'] == "index.php"){ - echo " class=\"activetopmenu\" "; - }?>> - <a href="<?php echo $web_path; ?>/index.php"><?php echo _('Home'); ?></a> - </li> -<?php if ($GLOBALS['user']->has_access(100)) { ?> - <li id="sidebar_admin"<?php - if ($location['page'] == 'admin/index.php' || - $location['page'] == 'admin/users.php' || - $location['page'] == 'admin/mail.php' || - $location['page'] == 'admin/catalog.php' || - $location['page'] == 'admin/preferences.php' || - $location['page'] == 'admin/access.php' ){ - echo " class=\"activetopmenu\" "; - }?>> - <a href="<?php echo $web_path; ?>/admin/index.php"><?php echo _('Admin'); ?></a> - <?php - if ($GLOBALS['theme']['submenu'] != 'simple' AND $GLOBALS['theme']['submenu'] != 'full') { - show_submenu($admin_items); - echo "\t</li>\n"; - } - else { - if ($location['section'] == 'admin' || $GLOBALS['theme']['submenu'] == 'full') { - echo "\t</li>\n"; - show_submenu($admin_items); - } - } // end if browse sub menu -} // end if access - ?> - - <li id="sidebar_prefs"<?php - if ($location['page'] == "preferences.php" ){ - echo " class=\"activetopmenu\" "; - }?>> - <a href="<?php echo $web_path; ?>/preferences.php"><?php echo _('Preferences'); ?></a> - </li> - <li id="sidebar_browse"<?php - if ($location['page'] == "browse.php" || - $location['page'] == "artists.php" || - $location['page'] == "albums.php" ){ - echo " class=\"activetopmenu\" "; - }?>> - <a href="<?php echo $web_path; ?>/browse.php"><?php echo _('Browse'); ?></a> - <?php - if ($GLOBALS['theme']['submenu'] != 'simple' AND $GLOBALS['theme']['submenu'] != 'full') { - show_submenu($browse_items); - echo "\t</li>\n"; - } - else { - if ($location['section'] == 'browse' || $GLOBALS['theme']['submenu'] == 'full') { - echo "\t</li>\n"; - show_submenu($browse_items); - } - } - ?> - <li id="sidebar_plists"<?php - if ($location['page'] == "playlist.php"){ - echo " class=\"activetopmenu\" "; - }?>> - <a href="<?php echo $web_path; ?>/playlist.php"><?php echo _('Playlists'); ?></a> - </li> - <li id="sidebar_stats"<?php - if ($location['page'] == "stats.php"){ - echo " class=\"activetopmenu\" "; - }?>> - <a href="<?php echo $web_path; ?>/stats.php"><?php echo _('Statistics'); ?></a> - </li> - <li id="sidebar_search"<?php - if ($location['page'] == "search.php"){ - echo " class=\"activetopmenu\" "; - }?>> - <a href="<?php echo $web_path; ?>/search.php"><?php echo _('Search'); ?></a> - </li> -<?php if ($GLOBALS['theme']['orientation'] != 'horizontal') { ?> - <li id="sidebar_subsearch"> - <form name="sub_search" method="post" action="<?php echo $web_path; ?>/search.php" enctype="multipart/form-data" style="Display:inline"> - <input type="text" name="search_string" value="" size="5" /> - <input class="smallbutton" type="submit" value="<?php echo _('Search'); ?>" /> - <input type="hidden" name="action" value="quick_search" /> - <input type="hidden" name="method" value="fuzzy" /> - <input type="hidden" name="object_type" value="song" /> - </form> - </li> -<?php } // end if ($GLOBALS['theme']['orientation'] != 'horizontal')?> - <li id="sidebar_random"<?php - if ($location['page'] == "randomplay.php"){ - echo " class=\"activetopmenu\" "; - }?>> - <a href="<?php echo $web_path; ?>/randomplay.php"><?php echo _('Random'); ?></a> - </li> -<?php if ($GLOBALS['theme']['orientation'] != 'horizontal') { ?> - <li id="sidebar_form"> - <form name="sub_random" method="post" enctype="multipart/form-data" action="<?php echo $web_path; ?>/song.php?action=random&method=stream" style="Display:inline"> - <select name="random" > - <option value="1">1</option> - <option value="5" selected="selected">5</option> - <option value="10">10</option> - <option value="20">20</option> - <option value="30">30</option> - <option value="50">50</option> - <option value="100">100</option> - <option value="500">500</option> - <option value="1000">1000</option> - <option value="-1"><?php echo _('All'); ?></option> - </select> - <?php show_genre_pulldown('genre','','','13',''); ?> - <br /> - <select name="random_type" > - <option value="Songs"><?php echo _('Songs'); ?></option> - <option value="length"><?php echo _('Minutes'); ?></option> - <option value="full_artist"><?php echo _('Artists'); ?></option> - <option value="full_album"><?php echo _('Albums'); ?></option> - <option value="unplayed"><?php echo _('Less Played'); ?></option> - </select> - <br /> - <?php show_catalog_pulldown('catalog',''); ?> - <br /> - <input class="smallbutton" type="submit" value="<?php echo _('Enqueue'); ?>" /> - </form> - </li> -<?php } // end if ($GLOBALS['theme']['orientation'] != 'horizontal') ?> -<?php if ($GLOBALS['user']->prefs['localplay_level'] > 0 AND Config::get('allow_localplay_playback')) { ?> - <li id="sidebar_localplay"> - <a href="<?php echo $web_path; ?>/localplay.php"><?php echo _('Localplay'); ?></a> - </li> -<?php if ($GLOBALS['theme']['orientation'] != 'horizontal') { ?> - <li id="sidebar_localplay_ctrl"> - <?php //require_once(Config::get('prefix') . '/templates/show_localplay_control.inc.php'); ?> - </li> -<?php } // if horizontal orientation ?> -<?php } // if localplay access ?> - <li> - <?php - $required_info = Config::get('ajax_info'); - $ajax_url = Config::get('ajax_url'); - ?> - <?php //require_once(Config::get('prefix') . '/templates/show_playtype_switch.inc.php'); ?> - </li> -<?php if (Config::get('allow_democratic_playback')) { ?> - <li> - <a href="<?php echo $web_path; ?>/tv.php"><?php echo _('Democratic View'); ?></a> - </li> -<?php } // if democratic play ?> -<?php if (Config::get('use_auth')) { ?> - <li id="sidebar_logout"><a href="<?php echo $web_path; ?>/logout.php"><?php echo _('Logout'); ?></a></li> -<?php } // end (Config::get('use_auth'))?> -</ul> ---> diff --git a/templates/sidebar_admin.inc.php b/templates/sidebar_admin.inc.php index e5e2867b..59ca5b2a 100644 --- a/templates/sidebar_admin.inc.php +++ b/templates/sidebar_admin.inc.php @@ -1,8 +1,10 @@ -<h4><?php echo _('Browse By'); ?></h4> -<select name="type"> - <option value="song"><?php echo _('Song Title'); ?></option> - <option value="album"><?php echo _('Albums'); ?></option> - <option value="artist"><?php echo _('Artist'); ?></option> - <option value="genre"><?php echo _('Genre'); ?></option> -</select> +<h4><?php echo _('Catalogs'); ?></h4> +<a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_add_catalog"><?php echo _('Add a Catalog'); ?></a> <hr /> +<h4><?php echo _('Other Tools'); ?></h4> +<a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_now_playing"><?php echo _('Clear Now Playing'); ?></a> +<a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_stats"><?php echo _('Clear Catalog Stats'); ?></a> +<a href="<?php echo $web_path; ?>/admin/catalog.php?action=gather_album_art"><?php echo _('Gather Album Art'); ?></a> +<hr /> + + diff --git a/themes/classic/templates/default.css b/themes/classic/templates/default.css index 6a08299d..77583fe3 100644 --- a/themes/classic/templates/default.css +++ b/themes/classic/templates/default.css @@ -255,6 +255,7 @@ h3#content_title span { clear: left; background-color:#c0c0c0; padding-left:5px; + font-size: 0.8em; } #sidebar-page select { width: 120px; |