summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-08-12 00:42:52 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-08-12 00:42:52 +0000
commitce6b9a00c1a9d81aaa5f7fdb868737a5f0b29fa4 (patch)
treed8e627a1dc29bcfb04916071bf92b1f4aae0324f /bin
parentf74e8927606223ebda3e0e00a94ae7a032a7d72f (diff)
downloadampache-ce6b9a00c1a9d81aaa5f7fdb868737a5f0b29fa4.tar.gz
ampache-ce6b9a00c1a9d81aaa5f7fdb868737a5f0b29fa4.tar.bz2
ampache-ce6b9a00c1a9d81aaa5f7fdb868737a5f0b29fa4.zip
it should now work for linux only
Diffstat (limited to 'bin')
-rw-r--r--bin/quarantine_migration.php.inc64
1 files changed, 41 insertions, 23 deletions
diff --git a/bin/quarantine_migration.php.inc b/bin/quarantine_migration.php.inc
index 363188ff..e23dddab 100644
--- a/bin/quarantine_migration.php.inc
+++ b/bin/quarantine_migration.php.inc
@@ -46,45 +46,63 @@ 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 . " \n");
+ cli_out("\n" . _("Error: Unable to write to") . $upload_dir);
+ exit;
}
+$catalog_id = find_upload_catalog($upload_dir);
+
+if (!$catalog_id) {
+ cli_out(_("Error: Upload directory not inside a catalog"));
+ exit;
+} // we must have a valid upload dir
+
+$catalog = new Catalog($catalog_id);
/* Itterate through the files we need to move */
$adds = &$files['add'];
foreach ($adds as $data) {
/* Make sure that the target filename doesn't exist */
-
+
$command = "mv " . $data['file'] . " " . $upload_dir;
$command = escapeshellcmd($command);
+
+ exec($command,$return,$error);
+
+ if (!$error) {
+ cli_out("\n" . _("Moved") . " " . $data['file']);
+
+ $new_filename = $upload_dir . "/" . basename($data['file']);
+
+ cli_out(_("Adding") . " " . $new_filename . " " . _("to database"));
+
+ $catalog->add_file($new_filename);
- if (exec($command)) {
- cli_out("\n" . _("Moved") . " " . $data['file'] . "\n");
$sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'";
$db_results = mysql_query($sql, dbh());
}
else {
- cli_out("\n" . _("Move Failed") . " " . $data['file'] . "\n");
+ cli_out(_("Move Failed") . " " . $data['file']);
}
+
} // end foreach
-exit();
+/* Itterate through the files we need to delete */
+$deletes = &$files['delete'];
+foreach ($deletes as $data) {
- if( !$file_move_ok ) {
- $text = $file . _( ' could not move file to quarantine directory ' ) . $dest_filename;
- cli_out( $text, 0 );
- continue;
- } else {
- $text = _( 'Moved ' ) . $file . _( ' to ' ) . $dest_filename . ".\n";
- cli_out( $text, 1 );
- }
- // update upload table
- $sql = "UPDATE upload SET file = $dest_filename WHERE id = $results->id";
- $db_results = mysql_query( $sql, dbh() );
+ unlink($data['file']);
+ cli_out(_("Deleted") . " " . $data['file']);
+
+ $sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'";
+ $db_results = mysql_query($sql, dbh());
-exit;
+} // end foreach
+
+
+exit();
/*!
@function usage()
@@ -104,17 +122,17 @@ marked for deletion will be deleted. This script must be run as a user with
sufficient rights to perform the above two functions.
\n" );
- cli_out( $text, 1 );
+ echo $text;
- $text = _( "Continue? (Y/N):\t" );
- cli_out( $text, 1 );
+ $text = _( "Continue? (Y/N):" );
+ echo $text;
// grab a character ignoring whitespace
do {
$input= fgetc( STDIN );
} while ( trim( $input ) == '' );
- if( $input != 'Y' ) {
+ if(strcmp($input,"y") != 0 ) {
exit;
}
} // usage()
@@ -137,7 +155,7 @@ function cli_out( $text, $mode = 1 ) {
default:
$dest = STDOUT;
$pre = "";
- $post = "";
+ $post = "\n";
}
fwrite( $dest, $pre . $text . $post );
} // error_out