add_file($target_file); /* Remove it from the catalog */ $sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'"; $db_results = mysql_query($sql, dbh()); } } // end foreach /* Itterate through the files we need to delete */ foreach ($files['delete'] as $data) { $results = unlink($data['file']); if (!$results) { echo "Error: Unable to Delete File: " . $data['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(); /*! @function usage() @discussion echo the help for this script */ function usage( ) { $text = _( " ************* WARNING ************* This script will move, and potentially delete uploaded files. ************* WARNING ************* All files marked for add will be moved to the upload directory. All files marked for deletion will be deleted. This script must be run as a user with sufficient rights to perform the above two functions. \n" ); echo $text; $text = _( "Continue? (Y/N):" ); echo $text; // grab a character ignoring whitespace do { $input= fgetc( STDIN ); } while ( trim( $input ) == '' ); if(strcasecmp($input,"y") != 0 ) { echo "\nExiting...\n"; exit; } } // usage() /*! @function cli_out() @discussion util for error formatting @param $text the message to be output @param $mode to STDERR (0) or STDOUT (1, default) */ function cli_out( $text, $mode = 1 ) { switch( $mode ) { case 0: $dest = STDERR; $pre = _( "Error: " ); $post = _( "!\n" ); break; case 1: default: $dest = STDOUT; $pre = ""; $post = "\n"; } fwrite( $dest, $pre . $text . $post ); } // error_out ?>