summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/class/catalog.class.php67
-rw-r--r--lib/class/democratic.class.php6
-rw-r--r--lib/general.lib.php8
3 files changed, 35 insertions, 46 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 1e468e82..3fb50cd6 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -92,8 +92,9 @@ class Catalog {
private function _create_filecache() {
if (count($this->_filecache) == 0) {
+ $catalog_id = Dba::escape($this->id);
// Get _EVERYTHING_
- $sql = "SELECT `id`,`file` FROM `song` WHERE `catalog`='$this->id'";
+ $sql = "SELECT `id`,`file` FROM `song` WHERE `catalog`='$catalog_id'";
$db_results = Dba::query($sql);
// Populate the filecache
@@ -411,12 +412,14 @@ class Catalog {
if (!is_resource($handle)) {
debug_event('read',"Unable to Open $path",'5','ampache-catalog');
Error::add('catalog_add',_('Error: Unable to open') . ' ' . $path);
+ return false;
}
/* Change the dir so is_dir works correctly */
if (!chdir($path)) {
debug_event('read',"Unable to chdir $path",'2','ampache-catalog');
Error::add('catalog_add',_('Error: Unable to change to directory') . ' ' . $path);
+ return false;
}
// Ensure that we've got our cache
@@ -429,7 +432,6 @@ class Catalog {
if ($file == '.' || $file == '..') { continue; }
debug_event('read',"Starting work on $file inside $path",'5','ampache-catalog');
-
/* Create the new path */
$full_file = $path.$slash_type.$file;
@@ -483,7 +485,7 @@ class Catalog {
if (preg_match($pattern ,$file)) {
/* Now that we're sure its a file get filesize */
- $file_size = @filesize($full_file);
+ $file_size = filesize($full_file);
if (!$file_size) {
debug_event('read',"Unable to get filesize for $full_file",'2','ampache-catalog');
@@ -496,31 +498,33 @@ class Catalog {
Error::add('catalog_add',"$full_file " . _('is not readable by ampache'));
continue;
}
+
+ // Check to make sure the filename is of the expected charset
+ if (function_exists('iconv')) {
+ if (strcmp($full_file,iconv(Config::get('site_charset'),Config::get('site_charset') . '//IGNORE',$full_file)) != '0') {
+ debug_event('read',$full_file . ' has non-' . Config::get('site_charset') . ' characters and can not be indexed','1');
+ Error::add('catalog_add',$full_file . ' ' . _('does not match site charset'));
+ continue;
+ }
+ } // end if iconv
if (substr($file,-3,3) == 'm3u' AND $parse_m3u > 0) {
$this->_playlists[] = $full_file;
} // if it's an m3u
else {
-
- /* 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%10)) {
- $file = str_replace(array('(',')','\''),'',$full_file);
- echo "<script type=\"text/javascript\">\n";
- echo "update_txt('" . $this->count ."','add_count_" . $this->id . "');";
- echo "update_txt('" . addslashes(htmlentities($file)) . "','add_dir_" . $this->id . "');";
- echo "\n</script>\n";
- flush();
- } // update our current state
-
- } // not found
+ $this->insert_local_song($full_file,$file_size);
+
+ /* Stupid little cutesie thing */
+ $this->count++;
+ if ( !($this->count%10)) {
+ $file = str_replace(array('(',')','\''),'',$full_file);
+ echo "<script type=\"text/javascript\">\n";
+ echo "update_txt('" . $this->count ."','add_count_" . $this->id . "');";
+ echo "update_txt('" . addslashes(htmlentities($file)) . "','add_dir_" . $this->id . "');";
+ echo "\n</script>\n";
+ flush();
+ } // update our current state
} // if it's not an m3u
@@ -1701,27 +1705,8 @@ class Catalog {
$info = self::update_song_from_tags($song,$this->sort_pattern,$this->rename_pattern);
$album_id = $song->album;
if ($info['change']) {
-
- // Check our cache, this avoids at the very least 2 queriest per song
- if (!$album_art_check_cache[$song->album]) {
- $album = new Album($song->album);
- if (!$album->has_art) {
- $found = $album->find_art($options,1);
- if (count($found)) {
- $image = get_image_from_source($found['0']);
- $album->insert_art($image,$found['mime']);
- $album_art_check_cache[$album->id] = 1;
- }
- } // if no art
- else {
- $album_art_check_cache[$album->id] = 1;
- }
- } // if not in cache
-
- flush();
$total_updated++;
}
-
unset($info);
} // end skip
diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php
index af1be060..cebb3272 100644
--- a/lib/class/democratic.class.php
+++ b/lib/class/democratic.class.php
@@ -426,6 +426,11 @@ class Democratic extends tmpPlaylist {
$sql = "DELETE FROM `democratic` WHERE `id`='$democratic_id'";
$db_results = Dba::query($sql);
+ $sql = "DELETE FROM `tmp_playlist` WHERE `session`='$democratic_id'";
+ $db_results = Dba::query($sql);
+
+ self::prune_tracks();
+
return true;
} // delete
@@ -464,7 +469,6 @@ class Democratic extends tmpPlaylist {
parent::create($insert_id,'vote','song');
}
-
return $db_results;
} // create
diff --git a/lib/general.lib.php b/lib/general.lib.php
index 4e9f39c5..e9cf0e3b 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -382,7 +382,7 @@ function get_languages() {
$results = array();
/* Prepend English */
- $results['en_US'] = _('English');
+ $results['en_US'] = 'English';
while ($file = readdir($handle)) {
@@ -393,16 +393,16 @@ function get_languages() {
switch($file) {
case 'de_DE'; $name = 'Deutsch'; break;
- case 'en_US'; $name = _('English'); break;
+ case 'en_US'; $name = 'English'; break;
case 'ca_CA'; $name = 'Catal&#224;'; break;
- case 'en_GB'; $name = _('British English'); break;
+ case 'en_GB'; $name = 'British English'; break;
case 'es_ES'; $name = 'Espa&ntilde;ol'; break;
case 'el_GR'; $name = 'Greek (&#x0395;&#x03bb;&#x03bb;&#x03b7;&#x03bd;&#x03b9;&#x03ba;&#x03ac;)'; break;
case 'fr_FR'; $name = 'Fran&ccedil;ais'; break;
case 'it_IT'; $name = 'Italiano'; break;
case 'is_IS'; $name = '&Iacute;slenska'; break;
case 'nl_NL'; $name = 'Nederlands'; break;
- case 'tr_TR'; $name = _('Turkish'); break;
+ case 'tr_TR'; $name = 'Turkish'; break;
case 'zh_CN'; $name = _('Simplified Chinese') . " (&#x7b80;&#x4f53;&#x4e2d;&#x6587;)"; break;
case 'ru_RU'; $name = 'Russian (&#x0420;&#x0443;&#x0441;&#x0441;&#x043a;&#x0438;&#x0439;)'; break;
default: $name = _('Unknown'); break;