1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-05 19:41:55 +02:00

fixed playlists thing for real this time

This commit is contained in:
Karl 'vollmerk' Vollmer 2006-05-13 07:27:16 +00:00
parent ada740ec41
commit 6546c82643
8 changed files with 74 additions and 39 deletions

View file

@ -46,7 +46,8 @@ switch ($_REQUEST['action']) {
include(conf('prefix') . '/templates/flag.inc');
break;
case 'add_to_all_catalogs':
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
$catalog = new Catalog();
$_REQUEST['catalogs'] = $catalog->get_catalog_ids();
case 'add_to_catalog':
if (conf('demo_mode')) { break; }
if ($_REQUEST['catalogs'] ) {
@ -65,7 +66,7 @@ switch ($_REQUEST['action']) {
case _("Add to all Catalogs"):
if (conf('demo_mode')) { break; }
/* If they are using the file MPD type, and it's currently enabled lets do a DBRefresh for em */
/* If they are using the file MPD type, and it's currently enabled lets do a DBRefresh for em
if (conf('mpd_method') == 'file' AND conf('allow_mpd_playback')) {
// Connect to the MPD
if (!class_exists('mpd')) { require_once(conf('prefix') . "/modules/mpd/mpd.class.php"); }
@ -77,6 +78,8 @@ switch ($_REQUEST['action']) {
$myMpd->DBRefresh();
} // if MPD enabled
//FIXME: File Method no longer exists... leaving this in for a bit
*/
$catalogs = $catalog->get_catalogs();
foreach ($catalogs as $data) {
@ -85,7 +88,8 @@ switch ($_REQUEST['action']) {
include(conf('prefix') . '/templates/catalog.inc');
break;
case 'update_all_catalogs':
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
$catalog = new Catalog();
$_REQUEST['catalogs'] = $catalog->get_catalog_ids();
case 'update_catalog':
/* If they are in demo mode stop here */
if (conf('demo_mode')) { break; }
@ -104,11 +108,12 @@ switch ($_REQUEST['action']) {
show_confirmation($title,$body,$url);
break;
case 'full_service':
$catalog = new Catalog();
/* Make sure they aren't in demo mode */
if (conf('demo_mode')) { break; }
if (!$_REQUEST['catalogs']) {
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
$_REQUEST['catalogs'] = $catalog->get_catalog_ids();
}
/* This runs the clean/verify/add in that order */
@ -157,7 +162,8 @@ switch ($_REQUEST['action']) {
show_confirmation($title,$body,$url);
break;
case 'clean_all_catalogs':
$_REQUEST['catalogs'] = Catalog::get_catalog_ids();
$catalog = new Catalog();
$_REQUEST['catalogs'] = $catalog->get_catalog_ids();
case 'clean_catalog':
/* If they are in demo mode stop them here */
if (conf('demo_mode')) { break; }

View file

@ -4,6 +4,10 @@
--------------------------------------------------------------------------
v.3.3.2-Beta3
- Supressed deprecated var warnings in PHP5
- Fixed link to playlist import
- Fixed playlist add on every catalog add (I'm not kidding this
time... really..)
- Fixed Access Control List so that it prevents Login if you are
not inside the allowed range.
- Fixed Localplay/Stream Buttons so that they also work if you

View file

@ -282,7 +282,7 @@ class Catalog {
@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='',$verbose=1) {
function add_files($path,$gather_type='',$parse_m3u=0,$verbose=1) {
/* Strip existing escape slashes and then add them again
This is done because we keep adding to the dir (slashed) + (non slashed)
and a double addslashes would pooch things
@ -377,7 +377,7 @@ class Catalog {
if (is_readable($full_file)) {
if (substr($file,-3,3) == 'm3u' AND $parse_m3u) {
if (substr($file,-3,3) == 'm3u' AND $parse_m3u > 0) {
$this->_playlists[] = $full_file;
} // if it's an m3u
@ -955,7 +955,7 @@ class Catalog {
$start_time = time();
/* Get the songs and then insert them into the db */
$this->add_files($this->path,$type,1,$verbose);
$this->add_files($this->path,$type,0,$verbose);
echo "<script language=\"JavaScript\">";
echo "update_txt('" . $this->count . "','count_add_" . $this->id ."');";
@ -1933,17 +1933,18 @@ class Catalog {
$sql = "SELECT id FROM genre WHERE name LIKE '$genre'";
$db_results = mysql_query($sql, dbh());
$results = mysql_fetch_object($db_results);
$results = mysql_fetch_assoc($db_results);
if (!$results->id) {
if (!$results['id']) {
$sql = "INSERT INTO genre (name) VALUES ('$genre')";
$db_results = mysql_query($sql, dbh());
$results->id = mysql_insert_id(dbh());
$insert_id = mysql_insert_id(dbh());
}
else { $insert_id = $results['id']; }
$this->genres[$genre] = $results->id;
$this->genres[$genre] = $insert_id;
return $results->id;
return $insert_id;
} //check_genre
@ -2122,16 +2123,19 @@ class Catalog {
$results = explode("\n",$data);
$pattern = "/\.(" . conf('catalog_file_pattern');
$pattern .= ")$/i";
foreach ($results as $value) {
// Remove extra whitespace
$value = trim($value);
if (preg_match("/\.[A-Za-z0-9]{3,4}$/",$value)) {
$file[0] = str_replace("/","\\",$value);
$file[1] = str_replace("\\","/",$value);
if (preg_match($pattern,$value)) {
$filename = basename($value);
/* Search for this filename, cause it's a audio file */
$sql = "SELECT id FROM song WHERE file LIKE '%" . sql_escape($file[0]) . "' OR file LIKE '%" . sql_escape($file[1]) . "'";
$sql = "SELECT id FROM song WHERE file LIKE '%" . sql_escape($filename) . "'";
$db_results = mysql_query($sql, dbh());
$song_id = mysql_result($db_results,'id');
$results = mysql_fetch_assoc($db_results);
$song_id = $results['id'];
if ($song_id) { $songs[] = $song_id; }
} // if it's a file

View file

@ -81,6 +81,10 @@ function ampache_error_handler($errno, $errstr, $errfile, $errline) {
break;
} // end switch
/* Don't log var: Deprecated we know shutup! */
if (strstr($errstr,"var: Deprecated. Please use the public/private/protected modifiers")) {
return false;
}
$log_line = "[$error_name] $errstr on line $errline in $errfile";
debug_event('error',$log_line,$level);

View file

@ -428,4 +428,15 @@ function init_preferences() {
} // init_preferences
/**
* show_import_playlist
* This just shows the template for importing playlists
* from something outside Ampache such as a m3u
*/
function show_import_playlist() {
require_once(conf('prefix') . '/templates/show_import_playlist.inc.php');
} // show_import_playlist
?>

View file

@ -48,16 +48,17 @@ class AmazonSearch {
function AmazonSearch($token, $base_url_param = '', $associates_id = 'none') {
if($base_url_param != ''){$this->base_url = $base_url_param . $this->url_suffix;
if (conf('debug')) {
log_event($GLOBALS['user']->username,'amazon-search-results',"Retrieving from " . $base_url_param . $this->url_suffix);
}
/* If we have a base url then use it */
if ($base_url_param != '') {
$this->base_url = $base_url_param . $this->url_suffix;
debug_event('amazon-search-results','Retrieving from ' . $base_url_param . $this->url_suffix,'5');
}
else{ $this->base_url=$this->base_url_default . $this->url_suffix;
if (conf('debug')) {
log_event($GLOBALS['user']->username,'amazon-search-results',"Retrieving from DEFAULT");
}
};
/* Default Operation */
else {
$this->base_url=$this->base_url_default . $this->url_suffix;
debug_event('amazon-search-results','Retrieving from DEFAULT','5');
}
$this->token = $token;
$this->associates_id = $associates_id;
@ -99,12 +100,10 @@ class AmazonSearch {
$snoopy->fetch($url);
$contents = $snoopy->results;
if (conf('debug')) {
log_event($GLOBALS['user']->username,'amazon-search-results',"Retrieved $contents");
}
debug_event('amazon-search-results','Retrieved ' . strlen($contents) . ' chars','5');
if (!xml_parse($this->_parser, $contents)) {
die(sprintf('XML error: %s at line %d',xml_error_string(xml_get_error_code($this->_parser)),xml_get_current_line_number($this->_parser)));
debug_event('amazon-search-results','Error:' . sprintf('XML error: %s at line %d',xml_error_string(xml_get_error_code($this->_parser)),xml_get_current_line_number($this->_parser)),'1');
}
xml_parser_free($this->_parser);

View file

@ -148,6 +148,15 @@ switch ($action) {
case 'show_import_playlist':
show_import_playlist();
break;
case 'import_playlist':
$catalog = new Catalog();
$catalog->import_m3u(scrub_in($_REQUEST['filename']));
$url = conf('web_path') . '/playlist.php';
$title = _('Playlist Imported');
$body = '';
show_confirmation($title,$body,$url);
break;
case 'set_track_numbers':
/* Make sure they have permission */
if (!$playlist->has_access()) {

View file

@ -21,20 +21,18 @@
*/
?>
<form method="post" name="import_playlist" action="<?php echo conf('web_path'); ?>/playlist.php" enctype="multipart/form-data">
<table border="0" cellpadding="0" cellspacing="0" class="border">
<tr class="table-header" >
<td colspan="2" align="center"><?php echo _("Importing a Playlist from a File"); ?></td>
</tr>
<span class="header2"><?php echo _('Importing a Playlist from a File'); ?></span>
<table border="0" cellpadding="0" cellspacing="0" class="border" style="border: 1px solid black;">
<tr class="<?php echo flip_class(); ?>">
<td>
<?php echo _("Filename"); ?>:
<?php echo _('Filename'); ?>:
<?php $GLOBALS['error']->print_error('filename'); ?>
</td>
<td><input type="text" name="filename" value="<?php echo $_REQUEST['filename']; ?>" size="45" /></td>
<td><input type="text" name="filename" value="<?php echo scrub_out($_REQUEST['filename']); ?>" size="45" /></td>
</tr>
<tr class="<?php echo flip_class(); ?>">
<td>
<?php echo _("Playlist Type"); ?>
<?php echo _('Playlist Type'); ?>
</td>
<td>
<select name="playlist_type">
@ -47,7 +45,7 @@
<td>&nbsp;</td>
<td>
<input type="hidden" name="action" value="import_playlist" />
<input type="submit" value="<?php echo _("Import Playlist"); ?>" />
<input type="submit" value="<?php echo _('Import Playlist'); ?>" />
</td>
</tr>
</table>