1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 17:59:21 +02:00

catalog build technically works now, still working out some issues with the dynamic updating of the current state

This commit is contained in:
Karl 'vollmerk' Vollmer 2007-05-14 07:12:15 +00:00
parent 779f4bf4e5
commit 641e7de637
21 changed files with 365 additions and 630 deletions

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
Copyright (c) 2001 - 2006 Ampache.org Copyright (c) 2001 - 2007 Ampache.org
All rights reserved. All rights reserved.
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -20,23 +20,17 @@
*/ */
require '../lib/init.php';
/*!
@header Admin Catalog
This document handles actions for catalog creation and passes them off to the catalog class
*/
require('../lib/init.php');
if (!$GLOBALS['user']->has_access(100)) { if (!$GLOBALS['user']->has_access(100)) {
access_denied(); access_denied();
exit;
} }
// We'll need this
/* Set any vars we are going to need */
$catalog = new Catalog($_REQUEST['catalog_id']); $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 */ /* Big switch statement to handle various actions */
switch ($_REQUEST['action']) { switch ($_REQUEST['action']) {
@ -169,39 +163,45 @@ switch ($_REQUEST['action']) {
$body = ''; $body = '';
show_confirmation($title,$body,$url); show_confirmation($title,$body,$url);
break; break;
// FIXME!
case 'add_catalog': case 'add_catalog':
/* Wah Demo! */ /* Wah Demo! */
if (conf('demo_mode')) { break; } if (Config::get('demo_mode')) { break; }
if ($_REQUEST['path'] AND $_REQUEST['name']) { if (!strlen($_REQUEST['path']) || !strlen($_REQUEST['name'])) {
/* Throw all of the album art types into an array */ Error::add('general','Error Name and path not specified');
$art = array('id3'=>$_REQUEST['art_id3v2'],'amazon'=>$_REQUEST['art_amazon'],'folder'=>$_REQUEST['art_folder']); }
/* Enclose it in a purrty box! */ if (substr($_REQUEST['path'],0,7) != 'http://' && $_REQUEST['type'] == 'remote') {
echo "<div class=\"confirmation-box\">"; Error::add('general','Error Remote selected, but path is not a URL');
}
/* Create the Catalog */ if ($_REQUEST['type'] == 'remote' && !strlen($_REQUEST['key'])) {
$catalog->new_catalog($_REQUEST['path'], Error::add('general','Error Remote Catalog specified, but no key provided');
$_REQUEST['name'], }
$_REQUEST['key'],
$_REQUEST['rename_pattern'],
$_REQUEST['sort_pattern'],
$_REQUEST['type'],
$_REQUEST['gather_art'],
$_REQUEST['parse_m3u'],
$art);
echo "</div>\n"; // If an error hasn't occured
if (!Error::$state) {
$url = conf('web_path') . '/admin/index.php'; $catalog_id = Catalog::create($_REQUEST);
$title = _('Catalog Created');
$body = _('Catalog Created and Songs Indexed'); if (!$catalog_id) {
show_confirmation($title,$body,$url); require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
break;
}
$catalog = new Catalog($catalog_id);
// Run our initial add
$catalog->run_add($_REQUEST);
show_box_top();
echo "<h2>" . _('Catalog Created') . "</h2>";
Error::display('general');
Error::display('catalog_add');
show_box_bottom();
} }
else { else {
$error = "Please complete the form."; require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
include(conf('prefix') . '/templates/show_add_catalog.inc.php');
} }
break; break;
case 'clear_stats': case 'clear_stats':
@ -214,7 +214,7 @@ switch ($_REQUEST['action']) {
show_confirmation($title,$body,$url); show_confirmation($title,$body,$url);
break; break;
case 'show_add_catalog': case 'show_add_catalog':
include(conf('prefix') . '/templates/show_add_catalog.inc.php'); require Config::get('prefix') . '/templates/show_add_catalog.inc.php';
break; break;
case 'clear_now_playing': case 'clear_now_playing':
if (conf('demo_mode')) { break; } if (conf('demo_mode')) { break; }

View file

@ -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 'lib/init.php';
require_once Config::get('prefix') . '/templates/header.inc.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 * going to let them break their servers
*/ */
if (Config::get('refresh_limit') > 5) { if (Config::get('refresh_limit') > 5) {
$refresh_limit = Config::get('refresh_limit');
$ajax_url = Config::get('ajax_url') . '?action=reloadnp' . Config::get('ajax_info'); $ajax_url = Config::get('ajax_url') . '?action=reloadnp' . Config::get('ajax_info');
/* Can't have the &amp; stuff in the Javascript */ /* Can't have the &amp; stuff in the Javascript */
$ajax_url = str_replace("&amp;","&",$ajax_url); $ajax_url = str_replace("&amp;","&",$ajax_url);

View file

@ -78,6 +78,8 @@ function get_random_albums($count='') {
$total = count($albums); $total = count($albums);
if ($total == '0') { return array(); }
for ($i=0; $i <= $count; $i++) { for ($i=0; $i <= $count; $i++) {
$record = rand(0,$total); $record = rand(0,$total);
if (isset($results[$record]) || !$albums[$record]) { $i--; } if (isset($results[$record]) || !$albums[$record]) { $i--; }

View file

@ -45,12 +45,11 @@ class Catalog {
public $genres = array(); public $genres = array();
/** /**
* Catalog * Constructor
* Catalog class constructor, pulls catalog information * Catalog class constructor, pulls catalog information
* @catagory Catalog * $catalog_id The ID of the catalog you want to build information from
* @param $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; } if (!$catalog_id) { return false; }
@ -127,16 +126,88 @@ class Catalog {
$results = self::count_songs($catalog_id); $results = self::count_songs($catalog_id);
$results = array_merge(self::count_users($catalog_id),$results); $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; return $results;
} // get_stats } // 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 &amp; stuff in the Javascript */
$ajax_url = str_replace("&amp;","&",$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 * count_songs
* This returns the current # of songs, albums, artists, genres * This returns the current # of songs, albums, artists, genres
@ -200,71 +271,6 @@ class Catalog {
} // count_users } // 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 @function add_file
@ -288,17 +294,15 @@ class Catalog {
} // add_file } // add_file
/*! /**
@function add_files * add_files
@discussion Recurses throught $this->path and pulls out all mp3s and returns the full * 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 * path in an array. Passes gather_type to determin if we need to check id3
information against the db. * 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
*/ */
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,"/")) { if (strstr($path,"/")) {
$slash_type = '/'; $slash_type = '/';
} }
@ -306,15 +310,12 @@ class Catalog {
$slash_type = '\\'; $slash_type = '\\';
} }
// Prevent the script from timing out
set_time_limit(0);
/* Open up the directory */ /* Open up the directory */
$handle = opendir($path); $handle = opendir($path);
if (!is_resource($handle)) { if (!is_resource($handle)) {
debug_event('read',"Unable to Open $path",'5','ampache-catalog'); 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 */ /* Recurse through this dir and create the files array */
@ -328,7 +329,7 @@ class Catalog {
/* Change the dir so is_dir works correctly */ /* Change the dir so is_dir works correctly */
if (!chdir($path)) { if (!chdir($path)) {
debug_event('read',"Unable to chdir $path",'2','ampache-catalog'); 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 */ /* Create the new path */
@ -338,7 +339,7 @@ class Catalog {
// if it was set the day before // if it was set the day before
unset($failed_check); unset($failed_check);
if (conf('no_symlinks')) { if (Config::get('no_symlinks')) {
if (is_link($full_file)) { if (is_link($full_file)) {
debug_event('read',"Skipping Symbolic Link $path",'5','ampache-catalog'); debug_event('read',"Skipping Symbolic Link $path",'5','ampache-catalog');
continue; continue;
@ -347,7 +348,7 @@ class Catalog {
/* If it's a dir run this function again! */ /* If it's a dir run this function again! */
if (is_dir($full_file)) { 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 */ /* Skip to the next file */
continue; continue;
} //it's a directory } //it's a directory
@ -357,8 +358,8 @@ class Catalog {
* to detect if it's a audio file for now the source for * to detect if it's a audio file for now the source for
* this is in the /modules/init.php file * this is in the /modules/init.php file
*/ */
$pattern = "/\.(" . conf('catalog_file_pattern'); $pattern = "/\.(" . Config::get('catalog_file_pattern');
if ($parse_m3u) { if ($options['parse_m3u']) {
$pattern .= "|m3u)$/i"; $pattern .= "|m3u)$/i";
} }
else { else {
@ -368,69 +369,55 @@ class Catalog {
/* see if this is a valid audio file or playlist file */ /* see if this is a valid audio file or playlist file */
if (preg_match($pattern ,$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 */ /* Now that we're sure its a file get filesize */
$file_size = @filesize($full_file); $file_size = @filesize($full_file);
if (!$file_size) { if (!$file_size) {
debug_event('read',"Unable to get filesize for $full_file",'2','ampache-catalog'); 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 } // file_size check
if (is_readable($full_file)) { 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) { if (substr($file,-3,3) == 'm3u' AND $parse_m3u > 0) {
$this->_playlists[] = $full_file; $this->_playlists[] = $full_file;
} // if it's an m3u } // 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
else { 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 } // end while reading directory
@ -439,7 +426,7 @@ class Catalog {
/* Close the dir handle */ /* Close the dir handle */
@closedir($handle); @closedir($handle);
} //add_files } // add_files
/*! /*!
@function get_albums @function get_albums
@ -1651,75 +1638,18 @@ class Catalog {
} //verify_catalog } //verify_catalog
/**
/*! * check_artist
@function create_catalog_entry * $artist checks if there then return id else insert and return id
@discussion Creates a new catalog from path and type */
@param $path The root path for this catalog public function check_artist($artist) {
@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) {
// Only get the var ones.. less func calls // 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 */ /* Clean up the artist */
$artist = trim($artist); $artist = trim($artist);
$artist = sql_escape($artist); $artist = Dba::escape($artist);
/* Ohh no the artist has lost it's mojo! */ /* Ohh no the artist has lost it's mojo! */
@ -1741,12 +1671,12 @@ class Catalog {
} // if we've seen this artist before } // if we've seen this artist before
/* Setup the checking sql statement */ /* Setup the checking sql statement */
$sql = "SELECT id FROM artist WHERE name LIKE '$artist' "; $sql = "SELECT `id` FROM `artist` WHERE `name` LIKE '$artist' ";
$db_results = mysql_query($sql, dbh()); $db_results = Dba::query($sql);
/* If it's found */ /* If it's found */
if ($r = mysql_fetch_object($db_results)) { if ($r = Dba::fetch_assoc($db_results)) {
$artist_id = $r->id; $artist_id = $r['id'];
} //if found } //if found
/* If not found create */ /* If not found create */
@ -1758,17 +1688,15 @@ class Catalog {
$prefix_txt = "'$prefix'"; $prefix_txt = "'$prefix'";
} }
$sql = "INSERT INTO artist (name, prefix) VALUES ('$artist', $prefix_txt)"; $sql = "INSERT INTO `artist` (`name`, `prefix`) VALUES ('$artist',$prefix_txt)";
$db_results = mysql_query($sql, dbh()); $db_results = Dba::query($sql);
$artist_id = mysql_insert_id(dbh()); $artist_id = Dba::insert_id();
if (!$db_results) { if (!$db_results) {
echo "Error Inserting Artist:$artist <br />"; Error::add('general',"Inserting Artist:$artist");
flush();
} }
} //not found } // not found
if ($cache_limit) { if ($cache_limit) {
@ -1785,23 +1713,21 @@ class Catalog {
return $artist_id; return $artist_id;
} //check_artist } // check_artist
/**
/*! * check_album
@function check_album * Takes $album and checks if there then return id else insert and return id
@disucssion Takes $album and checks if there then return id else insert and return id */
@param $album The name of the album public function check_album($album,$album_year=0) {
*/
function check_album($album,$album_year=0) {
/* Clean up the album name */ /* Clean up the album name */
$album = trim($album); $album = trim($album);
$album = sql_escape($album); $album = Dba::escape($album);
$album_year = intval($album_year); $album_year = intval($album_year);
// Set it once to reduce function calls // 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 */ /* Ohh no the album has lost it's mojo */
if (!$album) { if (!$album) {
@ -1822,12 +1748,12 @@ class Catalog {
} }
/* Setup the Query */ /* Setup the Query */
$sql = "SELECT id,art FROM album WHERE name LIKE '$album'"; $sql = "SELECT `id` FROM `album` WHERE `name` = '$album'";
if ($album_year) { $sql .= " AND year='$album_year'"; } if ($album_year) { $sql .= " AND `year`='$album_year'"; }
$db_results = mysql_query($sql, dbh()); $db_results = Dba::query($sql);
/* If it's found */ /* If it's found */
if ($r = mysql_fetch_assoc($db_results)) { if ($r = Dba::fetch_assoc($db_results)) {
$album_id = $r['id']; $album_id = $r['id'];
// If we don't have art put it in the needs me some art array // If we don't have art put it in the needs me some art array
@ -1846,9 +1772,9 @@ class Catalog {
$prefix_txt = "'$prefix'"; $prefix_txt = "'$prefix'";
} }
$sql = "INSERT INTO album (name, prefix,year) VALUES ('$album',$prefix_txt,'$album_year')"; $sql = "INSERT INTO `album` (`name`, `prefix`,`year`) VALUES ('$album',$prefix_txt,'$album_year')";
$db_results = mysql_query($sql, dbh()); $db_results = Dba::query($sql);
$album_id = mysql_insert_id(dbh()); $album_id = Dba::insert_id();
if (!$db_results) { if (!$db_results) {
debug_event('album',"Error Unable to insert Album:$album",'2'); debug_event('album',"Error Unable to insert Album:$album",'2');
@ -1874,15 +1800,14 @@ class Catalog {
return $album_id; return $album_id;
} //check_album } // check_album
/*! /**
@function check_genre * check_genre
@discussion Finds the Genre_id from the text name * Finds the Genre_id from the text name
@param $genre The name of the genre */
*/ public function check_genre($genre) {
function check_genre($genre) {
/* If a genre isn't specified force one */ /* If a genre isn't specified force one */
if (strlen(trim($genre)) < 1) { if (strlen(trim($genre)) < 1) {
@ -1894,16 +1819,16 @@ class Catalog {
} }
/* Look in the genre table */ /* Look in the genre table */
$genre = sql_escape($genre); $genre = Dba::escape($genre);
$sql = "SELECT id FROM genre WHERE name LIKE '$genre'"; $sql = "SELECT `id` FROM `genre` WHERE `name` = '$genre'";
$db_results = mysql_query($sql, dbh()); $db_results = Dba::query($sql);
$results = mysql_fetch_assoc($db_results); $results = Dba::fetch_assoc($db_results);
if (!$results['id']) { if (!$results['id']) {
$sql = "INSERT INTO genre (name) VALUES ('$genre')"; $sql = "INSERT INTO `genre` (`name`) VALUES ('$genre')";
$db_results = mysql_query($sql, dbh()); $db_results = Dba::query($sql);
$insert_id = mysql_insert_id(dbh()); $insert_id = Dba::insert_id();
} }
else { $insert_id = $results['id']; } else { $insert_id = $results['id']; }
@ -1911,41 +1836,36 @@ class Catalog {
return $insert_id; return $insert_id;
} //check_genre } // check_genre
/**
/*! * check_title
@function check_title * this checks to make sure something is
@discussion this checks to make sure something is * set on the title, if it isn't it looks at the
set on the title, if it isn't it looks at the * filename and trys to set the title based on that
filename and trys to set the title based on that */
*/ public function check_title($title,$file=0) {
function check_title($title,$file=0) {
if (strlen(trim($title)) < 1) { if (strlen(trim($title)) < 1) {
preg_match("/.+\/(.*)\.....?$/",$file,$matches); preg_match("/.+\/(.*)\.....?$/",$file,$matches);
$title = sql_escape($matches[1]); $title = Dba::escape($matches[1]);
} }
return $title; return $title;
} //check_title } // check_title
/**
/*! * insert_local_song
@function insert_local_song * Insert a song that isn't already in the database this
@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
function is in here so we don't have to create a song object */
@param $file The file name we are adding (full path) public function insert_local_song($file,$file_info) {
@param $file_info The information of the file, size etc taken from stat()
*/
function insert_local_song($file,$file_info) {
/* Create the vainfo object and get info */ /* Create the vainfo object and get info */
$vainfo = new vainfo($file,'',$this->sort_pattern,$this->rename_pattern); $vainfo = new vainfo($file,'',$this->sort_pattern,$this->rename_pattern);
$vainfo->get_info(); $vainfo->get_info();
$song_obj = new Song();
$key = get_tag_type($vainfo->tags); $key = get_tag_type($vainfo->tags);
@ -1953,7 +1873,7 @@ class Catalog {
$results = clean_tag_info($vainfo->tags,$key,$file); $results = clean_tag_info($vainfo->tags,$key,$file);
/* Set the vars here... so we don't have to do the '" . $blah['asd'] . "' */ /* 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']; $artist = $results['artist'];
$album = $results['album']; $album = $results['album'];
$genre = $results['genre']; $genre = $results['genre'];
@ -1976,34 +1896,28 @@ class Catalog {
$genre_id = $this->check_genre($genre); $genre_id = $this->check_genre($genre);
$album_id = $this->check_album($album,$year); $album_id = $this->check_album($album,$year);
$title = $this->check_title($title,$file); $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')"; " VALUES ('$add_file','$this->id','$album_id','$artist_id','$title','$bitrate','$rate','$mode','$size','$song_time','$track','$genre_id','$current_time','$year')";
$db_results = Dba::query($sql);
$db_results = mysql_query($sql, dbh());
if (!$db_results) { if (!$db_results) {
debug_event('insert',"Unable to insert $file -- $sql",'5','ampache-catalog'); 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 = Dba::insert_id();
$song_id = mysql_insert_id(dbh());
/* Add the EXT information */ /* 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')"; " VALUES ('$song_id','$comment','$lyrics')";
$db_results = mysql_query($sql,dbh()); $db_results = Dba::query($sql);
if (!$db_results) { if (!$db_results) {
debug_event('insert',"Unable to insert EXT Info for $file -- $sql",'5','ampache-catalog'); 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 } // insert_local_song
/*! /*!
@ -2053,12 +1967,10 @@ class Catalog {
} // check_remote_song } // check_remote_song
/*! /**
@function check_local_mp3 * check_local_mp3
@discussion Checks the song to see if it's there already returns true if found, false if not * 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
*/
function check_local_mp3($full_file, $gather_type='') { function check_local_mp3($full_file, $gather_type='') {
if ($gather_type == 'fast_add') { 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'"; $sql = "SELECT `id` FROM `song` WHERE `file` = '$full_file'";
$db_results = mysql_query($sql, dbh()); $db_results = Dba::query($sql);
//If it's found then return true //If it's found then return true
if (mysql_fetch_row($db_results)) { if (Dba::fetch_row($db_results)) {
return true; return true;
} }

View file

@ -621,6 +621,9 @@ class Update {
"VALUES ('playlist_method','50','Playlist Method','5','string','streaming')"; "VALUES ('playlist_method','50','Playlist Method','5','string','streaming')";
$db_results = Dba::query($sql); $db_results = Dba::query($sql);
$sql = "ALTER TABLE `update_info` ADD UNIQUE (`key`)";
$db_results = Dba::query($sql);
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::query($sql);

View file

@ -55,7 +55,7 @@ class vainfo {
$this->encoding = $encoding; $this->encoding = $encoding;
} }
else { else {
$this->encoding = conf('site_charset'); $this->encoding = Config::get('site_charset');
} }
/* These are needed for the filename mojo */ /* These are needed for the filename mojo */

View file

@ -190,7 +190,7 @@ function extend_session($sid) {
function get_tag_type($results) { function get_tag_type($results) {
/* Pull In the config option */ /* Pull In the config option */
$order = conf('tag_order'); $order = Config::get('tag_order');
if (!is_array($order)) { if (!is_array($order)) {
$order = array($order); $order = array($order);
@ -236,12 +236,7 @@ function clean_tag_info($results,$key,$filename) {
$info['title'] = stripslashes(trim($results[$key]['title'])); $info['title'] = stripslashes(trim($results[$key]['title']));
$info['year'] = intval($results[$key]['year']); $info['year'] = intval($results[$key]['year']);
$info['track'] = intval($results[$key]['track']); $info['track'] = intval($results[$key]['track']);
$info['comment'] = sql_escape(str_replace($clean_array,$wipe_array,$results[$key]['comment'])); $info['comment'] = Dba::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);
}
/* This are pulled from the info array */ /* This are pulled from the info array */
$info['bitrate'] = intval($results['info']['bitrate']); $info['bitrate'] = intval($results['info']['bitrate']);

View file

@ -193,7 +193,6 @@ if (NO_SESSION != '1' AND Config::get('use_auth')) {
if (!$GLOBALS['user']->id AND !Config::get('demo_mode')) { logout(); exit; } if (!$GLOBALS['user']->id AND !Config::get('demo_mode')) { logout(); exit; }
/* Load preferences and theme */ /* Load preferences and theme */
set_theme();
$GLOBALS['user']->update_last_seen(); $GLOBALS['user']->update_last_seen();
} }
elseif (!Config::get('use_auth')) { elseif (!Config::get('use_auth')) {
@ -210,7 +209,6 @@ elseif (!Config::get('use_auth')) {
$GLOBALS['user']->username = '-1'; $GLOBALS['user']->username = '-1';
$GLOBALS['user']->access = $auth['access']; $GLOBALS['user']->access = $auth['access'];
$_SESSION['userdata']['username'] = $auth['username']; $_SESSION['userdata']['username'] = $auth['username'];
set_theme();
} }
// If Auth, but no session is set // If Auth, but no session is set
else { else {

View file

@ -422,8 +422,8 @@ function insert_preference($name,$description,$default,$level,$type,$catagory) {
function init_preferences() { function init_preferences() {
/* Get Global Preferences */ /* Get Global Preferences */
$sql = "SELECT preferences.name,user_preference.value FROM preferences,user_preference WHERE user_preference.user='-1' " . $sql = "SELECT preference.name,user_preference.value FROM preference,user_preference WHERE user_preference.user='-1' " .
" AND user_preference.preference = preferences.id AND preferences.catagory='system'"; " AND user_preference.preference = preference.id AND preference.catagory='system'";
$db_results = Dba::query($sql); $db_results = Dba::query($sql);
while ($r = Dba::fetch_assoc($db_results)) { 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 */ /* Now we need to allow the user to override some stuff that's been set by the above */
$user_id = '-1'; $user_id = '-1';
if ($GLOBALS['user']->id) { if ($GLOBALS['user']->username) {
$user_id = Dba::escape($GLOBALS['user']->id); $user_id = Dba::escape($GLOBALS['user']->id);
} }
$sql = "SELECT preferences.name,user_preference.value FROM preferences,user_preference WHERE user_preference.user='$user_id' " . $sql = "SELECT preference.name,user_preference.value FROM preference,user_preference WHERE user_preference.user='$user_id' " .
" AND user_preference.preference = preferences.id AND preferences.catagory != 'system'"; " AND user_preference.preference = preference.id AND preference.catagory != 'system'";
$db_results = Dba::query($sql); $db_results = Dba::query($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {

View file

@ -76,54 +76,6 @@ function get_theme($name) {
} // get_theme } // 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 @function get_theme_author
@discussion returns the author of this theme @discussion returns the author of this theme

View file

@ -495,11 +495,10 @@ function show_local_catalog_info() {
$db_results = Dba::query($query); $db_results = Dba::query($query);
// Make sure we have something to display // Make sure we have something to display
if (!Dba::num_rows($db_results)) { if (Dba::num_rows($db_results) < 1) {
show_box_top(); show_box_top();
$items[] = "<span align=\"center\" class=\"error\">" . _('No Catalogs Found!') . "</span><br />"; echo "<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>"; echo "<a href=\"" . Config::get('web_path') . "/admin/catalog.php?action=show_add_catalog\">" ._('Add a Catalog') . "</a>";
show_info_box('','catalog',$items);
show_box_bottom(); show_box_bottom();
return false; return false;
} }
@ -1196,11 +1195,13 @@ function show_box_bottom() {
* this function takes a name and a returns either a text representation * this function takes a name and a returns either a text representation
* or an <img /> tag * 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 */ /* Because we do a lot of calls cache the URLs */
static $url_cache = array(); static $url_cache = array();
if (!$title) { $title = $name; }
if (isset($url_cache[$name])) { if (isset($url_cache[$name])) {
$img_url = $url_cache[$name]; $img_url = $url_cache[$name];
$cache_url = true; $cache_url = true;
@ -1239,7 +1240,7 @@ function get_user_icon($name,$hover_name='') {
} // end if not cached } // 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; return $string;

View file

@ -38,6 +38,7 @@ if (Config::get('access_control')) {
if (!Access::check_network('interface',$_SERVER['REMOTE_ADDR'],'','5')) { 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'); debug_event('access_denied','Access Denied:' . $_SERVER['REMOTE_ADDR'] . ' is not in the Interface Access list','3');
access_denied(); access_denied();
exit();
} }
} // access_control is enabled } // access_control is enabled

View file

@ -271,6 +271,30 @@ switch ($action) {
ob_end_clean(); ob_end_clean();
echo xml_from_array($results); echo xml_from_array($results);
break; 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: default:
$results['3514'] = '0x1'; $results['3514'] = '0x1';
echo xml_from_array($results); echo xml_from_array($results);

View file

@ -366,7 +366,7 @@ CREATE TABLE `preference` (
LOCK TABLES `preference` WRITE; LOCK TABLES `preference` WRITE;
/*!40000 ALTER TABLE `preference` DISABLE KEYS */; /*!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 */; /*!40000 ALTER TABLE `preference` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
@ -550,7 +550,7 @@ CREATE TABLE `tmp_playlist` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `session` (`session`), KEY `session` (`session`),
KEY `type` (`type`) KEY `type` (`type`)
) TYPE=MyISAM AUTO_INCREMENT=4; ) TYPE=MyISAM;
-- --
-- Dumping data for table `tmp_playlist` -- Dumping data for table `tmp_playlist`
@ -591,7 +591,7 @@ DROP TABLE IF EXISTS `update_info`;
CREATE TABLE `update_info` ( CREATE TABLE `update_info` (
`key` varchar(128) NOT NULL default '', `key` varchar(128) NOT NULL default '',
`value` varchar(255) NOT NULL default '', `value` varchar(255) NOT NULL default '',
KEY `key` (`key`) UNIQUE KEY `key` (`key`)
) TYPE=MyISAM; ) TYPE=MyISAM;
-- --
@ -652,7 +652,6 @@ CREATE TABLE `user_preference` (
LOCK TABLES `user_preference` WRITE; LOCK TABLES `user_preference` WRITE;
/*!40000 ALTER TABLE `user_preference` DISABLE KEYS */; /*!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 */; /*!40000 ALTER TABLE `user_preference` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;
@ -685,4 +684,4 @@ UNLOCK TABLES;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!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

View file

@ -23,7 +23,7 @@
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
<!-- Begin <!-- Begin
// Set refresh interval (in seconds) // Set refresh interval (in seconds)
var refreshinterval=<?php echo Config::get('refresh_limit'); ?>; var refreshinterval=<?php echo $refresh_limit ?>;
function doLoad() function doLoad()
{ {
@ -42,7 +42,7 @@ function refresh()
} }
// start with page-load // start with page-load
window.onload=doLoad; doLoad;
// End --> // End -->
</script> </script>

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
Copyright (c) 2001 - 2006 Ampache.org Copyright (c) 2001 - 2007 Ampache.org
All rights reserved. All rights reserved.
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -22,41 +22,38 @@
$default_rename = "%a - %T - %t"; $default_rename = "%a - %T - %t";
$default_sort = "%a/%A"; $default_sort = "%a/%A";
?> ?>
<?php show_box_top(_('Add a Catalog')); ?> <?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> <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>
<?php Error::display('general'); ?>
<form name="update_catalog" method="post" action="<?php echo conf('web_path'); ?>/admin/catalog.php" enctype="multipart/form-data"> <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"> <table class="tabledata" cellpadding="0" border="0" cellspacing="0">
<tr> <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><input size="60" type="text" name="name" value="<?php echo $_REQUEST['name']; ?>" /></td>
<td style="vertical-align:top; font-family: monospace;" rowspan="6"> <td style="vertical-align:top; font-family: monospace;" rowspan="6">
<strong><?php echo _("Auto-inserted Fields"); ?>:</strong><br /> <strong><?php echo _('Auto-inserted Fields'); ?>:</strong><br />
%A = <?php echo _("album name"); ?><br /> %A = <?php echo _('album name'); ?><br />
%a = <?php echo _("artist name"); ?><br /> %a = <?php echo _('artist name'); ?><br />
%c = <?php echo _("id3 comment"); ?><br /> %c = <?php echo _('id3 comment'); ?><br />
%g = <?php echo _("genre"); ?><br /> %g = <?php echo _('genre'); ?><br />
%T = <?php echo _("track number (padded with leading 0)"); ?><br /> %T = <?php echo _('track number (padded with leading 0)'); ?><br />
%t = <?php echo _("song title"); ?><br /> %t = <?php echo _('song title'); ?><br />
%y = <?php echo _("year"); ?><br /> %y = <?php echo _('year'); ?><br />
%o = <?php echo _("other"); ?><br /> %o = <?php echo _('other'); ?><br />
</td> </td>
</tr> </tr>
<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> <td><input size="60" type="text" name="path" value="<?php echo $_REQUEST['path']; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td><?php echo _("Catalog Type"); ?>: </td> <td><?php echo _('Catalog Type'); ?>: </td>
<td> <td>
<select name="type"> <select name="type">
<option value="local"><?php echo _("Local"); ?></option> <option value="local"><?php echo _('Local'); ?></option>
<option value="remote"><?php echo _("Remote"); ?></option> <option value="remote"><?php echo _('Remote'); ?></option>
</select> </select>
</td> </td>
</tr> </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> <td><input size="30" type="text" name="key" value="" /><span class="error">*<?php echo _('Required for Remote Catalogs'); ?></span></td>
</tr> </tr>
<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> <td><input size="60" type="text" name="rename_pattern" value="<?php echo $default_rename; ?>" /></td>
</tr> </tr>
<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> <td valign="top"><input size="60" type="text" name="sort_pattern" value="<?php echo $default_sort; ?>" /></td>
</tr> </tr>
<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> <td><input type="checkbox" name="gather_art" value="1" /></td>
</tr> </tr>
<tr> <tr>
@ -87,12 +84,9 @@ $default_sort = "%a/%A";
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
<input type="hidden" name="action" value="add_catalog" /> <input type="hidden" name="action" value="add_catalog" />
<input class="button" type="submit" value="<?php echo _("Add Catalog"); ?>" />&nbsp;&nbsp; <input class="button" type="submit" value="<?php echo _('Add Catalog'); ?>" />
<input class="button" type="reset" value="<?php echo _("Reset"); ?>" />&nbsp;&nbsp;
<input type="button" onclick="javascript:history.go(-1)" value="<?php echo _("Cancel"); ?>" />
</td> </td>
</tr> </tr>
</table> </table>
</form> </form>
<?php show_box_bottom(); ?> <?php show_box_bottom(); ?>

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
Copyright (c) 2001 - 2006 Ampache.org Copyright (c) 2001 - 2007 Ampache.org
All rights reserved. All rights reserved.
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or

View file

@ -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 />

View file

@ -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'; } if (!$_SESSION['state']['sidebar_tab']) { $_SESSION['state']['sidebar_tab'] = 'home'; }
$class_name = 'sidebar_' . $_SESSION['state']['sidebar_tab']; $class_name = 'sidebar_' . $_SESSION['state']['sidebar_tab'];
${$class_name} = ' class="active" '; ${$class_name} = ' class="active" ';
@ -46,178 +28,26 @@ $ajax_url = Config::get('ajax_url');
?> ?>
<ul id="sidebar-tabs"> <ul id="sidebar-tabs">
<li <?php echo $sidebar_home; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=home');" > <li <?php echo $sidebar_home; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=home');" >
<?php echo get_user_icon('home'); ?> <?php echo get_user_icon('home','',_('Home')); ?>
</li> </li>
<li <?php echo $sidebar_browse; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=browse');" > <li <?php echo $sidebar_browse; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=browse');" >
<?php echo get_user_icon('browse'); ?> <?php echo get_user_icon('browse','',_('Browse')); ?>
</li> </li>
<li <?php echo $sidebar_search; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=search');" > <li <?php echo $sidebar_search; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=search');" >
<?php echo get_user_icon('view'); ?> <?php echo get_user_icon('view','',_('Search')); ?>
</li> </li>
<li <?php echo $sidebar_preferences; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=preferences');" > <li <?php echo $sidebar_preferences; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=preferences');" >
<?php echo get_user_icon('edit'); ?> <?php echo get_user_icon('edit','',_('Preferences')); ?>
</li> </li>
<?php if ($GLOBALS['user']->has_access('100')) { ?> <?php if ($GLOBALS['user']->has_access('100')) { ?>
<li <?php echo $sidebar_admin; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=admin');" > <li <?php echo $sidebar_admin; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=admin');" >
<?php echo get_user_icon('admin'); ?> <?php echo get_user_icon('admin','',_('Admin')); ?>
</li> </li>
<?php } ?> <?php } ?>
<li <?php echo $sidebar_player; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=player');" > <li <?php echo $sidebar_player; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=sidebar&amp;button=player');" >
<?php echo get_user_icon('all'); ?> <?php echo get_user_icon('all','',_('Player')); ?>
</li> </li>
</ul> </ul>
<div id="sidebar-page"> <div id="sidebar-page">
<?php require_once Config::get('prefix') . '/templates/sidebar_' . $_SESSION['state']['sidebar_tab'] . '.inc.php'; ?> <?php require_once Config::get('prefix') . '/templates/sidebar_' . $_SESSION['state']['sidebar_tab'] . '.inc.php'; ?>
</div> </div>
<!--
<h3>&nbsp;</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&amp;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>
-->

View file

@ -1,8 +1,10 @@
<h4><?php echo _('Browse By'); ?></h4> <h4><?php echo _('Catalogs'); ?></h4>
<select name="type"> <a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_add_catalog"><?php echo _('Add a Catalog'); ?></a>
<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>
<hr /> <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 />

View file

@ -255,6 +255,7 @@ h3#content_title span {
clear: left; clear: left;
background-color:#c0c0c0; background-color:#c0c0c0;
padding-left:5px; padding-left:5px;
font-size: 0.8em;
} }
#sidebar-page select { #sidebar-page select {
width: 120px; width: 120px;