summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-03-27 04:29:23 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-03-27 04:29:23 +0000
commit7673d000dd8ec85908a99a1174840c8ca3c53e16 (patch)
tree8cbce751084279e680055f156824c52ea3b3b88b /bin
parent75434cbeb6e6c2e4107b9932a79b3d146dbdcc0f (diff)
downloadampache-7673d000dd8ec85908a99a1174840c8ca3c53e16.tar.gz
ampache-7673d000dd8ec85908a99a1174840c8ca3c53e16.tar.bz2
ampache-7673d000dd8ec85908a99a1174840c8ca3c53e16.zip
added some more to flagging and updated mail page to fit new standards
Diffstat (limited to 'bin')
-rw-r--r--bin/quarantine_migration.php.inc74
-rw-r--r--bin/sort_files.php.inc11
2 files changed, 48 insertions, 37 deletions
diff --git a/bin/quarantine_migration.php.inc b/bin/quarantine_migration.php.inc
index e23dddab..803317ef 100644
--- a/bin/quarantine_migration.php.inc
+++ b/bin/quarantine_migration.php.inc
@@ -1,6 +1,9 @@
<?php
/*
+ Copyright 2001 - 2006 Ampache.org
+ All Rights Reserved
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
@@ -15,10 +18,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- created by RosenSama 2005
-
- call: php quarantine_migration.php
+ created by RosenSama 2005
+ call: php quarantine_migration.php
*/
$no_session='1';
@@ -46,7 +48,7 @@ while ($results = mysql_fetch_assoc($db_results)) {
$upload_dir = conf('upload_dir');
if (!@is_writeable($upload_dir)) {
- cli_out("\n" . _("Error: Unable to write to") . $upload_dir);
+ echo "\n" . _('Error: Unable to write to') . " $upload_dir ". "\n";
exit;
}
@@ -60,48 +62,57 @@ if (!$catalog_id) {
$catalog = new Catalog($catalog_id);
/* Itterate through the files we need to move */
-$adds = &$files['add'];
-foreach ($adds as $data) {
+foreach ($files['add'] as $data) {
/* Make sure that the target filename doesn't exist */
+ $target_file = $upload_dir . "/" . basename($data['file']);
+
+ if (file_exists($target_file)) {
+ echo 'Error: File Exists';
+ debug_event('file_exists','Error: $target_file already exist','1');
+ continue;
+ }
+
+ $results = copy($data['file'],$target_file);
+ if (!$results) { echo "Error: Unable to copy " . $data['file'] . " skipping...\n"; continue; }
- $command = "mv " . $data['file'] . " " . $upload_dir;
- $command = escapeshellcmd($command);
-
- exec($command,$return,$error);
+ /* Check the filesize to make sure it copied */
+ $new_sum = filesize($target_file);
+ $old_sum = filesize($data['file']);
+
+ if ($new_sum != $old_sum || !$new_sum) {
+ echo "Error: Size Inconsistency, not deleting " . $data['file'] . "\n";
+ continue;
+ }
+
+ $results = unlink($data['file']);
+ if (!$results) { echo "Error: Unable to delete " . $data['file'] . "\n";}
- if (!$error) {
- cli_out("\n" . _("Moved") . " " . $data['file']);
+ else {
+ echo _('Adding') . " " . $target_file . " " . _('to database') . "\n";
- $new_filename = $upload_dir . "/" . basename($data['file']);
-
- cli_out(_("Adding") . " " . $new_filename . " " . _("to database"));
+ $catalog->add_file($target_file);
- $catalog->add_file($new_filename);
-
+ /* Remove it from the catalog */
$sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'";
$db_results = mysql_query($sql, dbh());
}
- else {
- cli_out(_("Move Failed") . " " . $data['file']);
- }
-
-
+
} // end foreach
/* Itterate through the files we need to delete */
-$deletes = &$files['delete'];
-foreach ($deletes as $data) {
-
- unlink($data['file']);
- cli_out(_("Deleted") . " " . $data['file']);
+foreach ($files['delete'] as $data) {
- $sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'";
- $db_results = mysql_query($sql, dbh());
+ $results = unlink($data['file']);
+ if (!$results) { echo "Error: Unable to Delete File\n"; }
+ else {
+ echo _('Deleted') . " " . $data['file'] . "\n";
+ $sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'";
+ $db_results = mysql_query($sql, dbh());
+ }
} // end foreach
-
exit();
/*!
@@ -132,7 +143,8 @@ sufficient rights to perform the above two functions.
$input= fgetc( STDIN );
} while ( trim( $input ) == '' );
- if(strcmp($input,"y") != 0 ) {
+ if(strcasecmp($input,"y") != 0 ) {
+ echo "\nExiting...\n";
exit;
}
} // usage()
diff --git a/bin/sort_files.php.inc b/bin/sort_files.php.inc
index d0ccc31a..7f446873 100644
--- a/bin/sort_files.php.inc
+++ b/bin/sort_files.php.inc
@@ -249,7 +249,7 @@ function sort_move_file($song,$fullname) {
echo "\tMaking $path Directory\n";
}
else {
- if (conf('debug')) { log_event('commandline','mkdir',"Creating $path directory"); }
+ debug_event('mkdir',"Creating $path directory",'5');
$results = mkdir($path);
if (!$results) {
echo "Error: Unable to create $path move failed\n";
@@ -270,14 +270,13 @@ function sort_move_file($song,$fullname) {
/* Check for file existance */
if (file_exists($fullname)) {
- if (conf('debug')) { log_event('commandline','file exists','Error: $fullname already exists'); }
+ debug_event('file exists','Error: $fullname already exists','1');
echo "Error: $fullname already exists\n";
return false;
}
$results = copy($song->file,$fullname);
- if (conf('debug')) { log_event('commandline','copy','Copied ' . $song->file . ' to ' . $fullname); }
-
+ debug_event('copy','Copied ' . $song->file . ' to ' . $fullname,'5');
/* Look for the folder art and copy that as well */
if (!conf('album_art_preferred_filename')) {
@@ -289,12 +288,12 @@ function sort_move_file($song,$fullname) {
$old_art = $old_dir . "/" . conf('album_art_preferred_filename');
}
- if (conf('debug')) { log_event('commandline','copy_art','Copied ' . $old_art . ' to ' . $folder_art); }
+ debug_event('copy_art','Copied ' . $old_art . ' to ' . $folder_art,'5');
@copy($old_art,$folder_art);
if (!$results) { echo "Error: Unable to copy file to $fullname\n"; return false; }
- /* Check the md5sums */
+ /* Check the filesize */
$new_sum = filesize($fullname);
$old_sum = filesize($song->file);