add_file($new_filename); $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']); $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(strcmp($input,"y") != 0 ) { 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 ?>