diff --git a/Anvil/Tools/Get.pm b/Anvil/Tools/Get.pm index 61e7ad0f..67035122 100644 --- a/Anvil/Tools/Get.pm +++ b/Anvil/Tools/Get.pm @@ -203,24 +203,26 @@ sub cgi # Needed to read in passed CGI variables my $cgi = CGI->new(); - # The list of CGI variables to try and read will always be in 'cgi_list'. my $cgis = []; my $cgi_count = 0; - if (defined $cgi->param("cgi_list")) + # Get the list of parameters coming in, if possible, + if (exists $cgi->{param}) { - my $cgi_list = $cgi->param("cgi_list"); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { cgi_list => $cgi_list }}); - - foreach my $variable (split/,/, $cgi_list) + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'cgi->{param}' => $cgi->{param} }}); + foreach my $variable (sort {$a cmp $b} keys %{$cgi->{param}}) { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable => $variable }}); push @{$cgis}, $variable; } } - elsif (exists $cgi->{param}) + elsif (defined $cgi->param("cgi_list")) { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'cgi->{param}' => $cgi->{param} }}); - foreach my $variable (sort {$a cmp $b} keys %{$cgi->{param}}) + ### TODO: Get rid of this + # This is a fall-back list we really shouldn't need. + my $cgi_list = $cgi->param("cgi_list"); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { cgi_list => $cgi_list }}); + + foreach my $variable (split/,/, $cgi_list) { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable => $variable }}); push @{$cgis}, $variable; @@ -240,29 +242,36 @@ sub cgi # Now read in the variables. foreach my $variable (sort {$a cmp $b} @{$cgis}) { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable => $variable }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { variable => $variable }}); - $anvil->data->{cgi}{$variable}{value} = ""; - $anvil->data->{cgi}{$variable}{mimetype} = "string"; - $anvil->data->{cgi}{$variable}{filehandle} = ""; - $anvil->data->{cgi}{$variable}{alert} = 0; # This is set if a sanity check fails + $anvil->data->{cgi}{$variable}{value} = ""; + $anvil->data->{cgi}{$variable}{mime_type} = "string"; + $anvil->data->{cgi}{$variable}{file_handle} = ""; + $anvil->data->{cgi}{$variable}{file_name} = ""; + $anvil->data->{cgi}{$variable}{alert} = 0; # This is set if a sanity check fails - if ($variable eq "file") + # This is a special CGI key for download files (upload from the user's perspective) + if ($variable eq "upload_file") { - if (not $cgi->upload($variable)) + if (not $cgi->upload('upload_file')) { # Empty file passed, looks like the user forgot to select a file to upload. - #$anvil->Log->entry({log_level => $debug, message_key => "log_0016", file => $THIS_FILE, line => __LINE__}); + $anvil->Log->entry({log_level => 2, message_key => "log_0242", file => $THIS_FILE, line => __LINE__}); } else { - $anvil->data->{cgi}{$variable}{filehandle} = $cgi->upload($variable); - my $file = $anvil->data->{cgi}{$variable}{filehandle}; - $anvil->data->{cgi}{$variable}{mimetype} = $cgi->uploadInfo($file)->{'Content-Type'}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - variable => $variable, - "cgi::${variable}::filehandle" => $anvil->data->{cgi}{$variable}{filehandle}, - "cgi::${variable}::mimetype" => $anvil->data->{cgi}{$variable}{mimetype}, + $anvil->data->{cgi}{upload_file}{file_handle} = $cgi->upload('upload_file'); + my $file = $anvil->data->{cgi}{upload_file}{file_handle}; + $anvil->data->{cgi}{upload_file}{file_name} = $file; + $anvil->data->{cgi}{upload_file}{mime_type} = $cgi->uploadInfo($file)->{'Content-Type'}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + variable => 'upload_file', + "cgi::${variable}::file_handle" => $anvil->data->{cgi}{upload_file}{file_handle}, + "cgi::${variable}::file_handle->handle" => $anvil->data->{cgi}{upload_file}{file_handle}->handle, + "cgi::${variable}::file_name" => $anvil->data->{cgi}{upload_file}{file_name}, + "cgi::${variable}::mime_type" => $anvil->data->{cgi}{upload_file}{mime_type}, + "cgi->upload('upload_file')" => $cgi->upload('upload_file'), + "cgi->upload('upload_file')->handle" => $cgi->upload('upload_file')->handle, }}); } } diff --git a/Anvil/Tools/Job.pm b/Anvil/Tools/Job.pm index 02a366c9..61a7a78a 100644 --- a/Anvil/Tools/Job.pm +++ b/Anvil/Tools/Job.pm @@ -216,16 +216,16 @@ WHERE AND job_host_uuid = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->Get->host_uuid)." ;"; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); my $job_count = $results->[0]->[0]; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { results => $results, job_count => $job_count, }}); my $jobs_running = $job_count ? 1 : 0; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { jobs_running => $jobs_running }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { jobs_running => $jobs_running }}); return($jobs_running); } diff --git a/cgi-bin/striker b/cgi-bin/striker index 3b4cea5b..594a153d 100755 --- a/cgi-bin/striker +++ b/cgi-bin/striker @@ -38,7 +38,15 @@ $anvil->data->{form}{back_link} = ""; $anvil->data->{form}{refresh_link} = ""; # Read in any CGI variables, if needed. -$anvil->Get->cgi(); +$anvil->Get->cgi({debug => 2}); + +# If we're being asked to get a file, do so now. +if ($anvil->data->{cgi}{upload_file}{file_handle}) +{ + # Save and exit. We've got ajax handling the UI so this invocation only saves the file. + handle_upload($anvil); + $anvil->nice_exit({exit_code => 0}); +} # If the system hasn't initialized, there may be no host.uuid, and we'll need a better error to show the # user. @@ -61,10 +69,12 @@ if (not $anvil->data->{sys}{database}{connections}) # If any jobs are pending/running, show the "unavailable" option. my $configured = $anvil->System->check_if_configured; -$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { configured => $configured }}); +$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { configured => $configured }}); +### TODO: Something is causing fairly frequent resyncs, which results in Striker going in and out of +### maintenance mode. my $available = $configured ? check_availability($anvil) : 0; -$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {available => $available }}); +$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {available => $available }}); if (not $configured) { # If there is no user account yet, then the system is new and needs to be reconfigured. @@ -99,6 +109,64 @@ print_and_exit($anvil); # Functions # ############################################################################################################# +# This handles uploading (downloading by our perspective) +sub handle_upload +{ + my ($anvil) = @_; + + # Get the file handle. + my $cgi_file_handle = $anvil->data->{cgi}{upload_file}{file_handle}; + my $file_name = $anvil->data->{cgi}{upload_file}{file_name}; + my $mime_type = $anvil->data->{cgi}{upload_file}{mime_type}; + my $output_file = $anvil->data->{path}{directories}{shared}{incoming}."/".$file_name; + $output_file =~ s/\/\//\//g; + # TODO: Make sure characters like spaces and whatnot don't need to be escaped. + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + cgi_file_handle => $cgi_file_handle, + file_name => $file_name, + mime_type => $mime_type, + output_file => $output_file, + }}); + + open (my $file_handle, ">", $output_file) or $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0015", variables => { shell_call => $output_file, error => $! }}); + binmode $file_handle; + while(<$file_handle>) + { + print $cgi_file_handle $_; + } + close $file_handle; + + if (not -f $output_file) + { + # Something went wrong + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0257", variables => { file => $output_file }}); + } + else + { + # Looks like we got it. + my $file_size = -s $output_file; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file_size => $file_size }}); + if (not $file_size) + { + # Looks like we didn't actually get the file... + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0258", variables => { file => $output_file }}); + unlink $output_file; + } + else + { + my $say_size_in_bytes = $anvil->Convert->add_commas({number => $file_size}); + my $say_human_size = $anvil->Convert->bytes_to_human_readable({'bytes' => $file_size}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0256", variables => { + file => $output_file, + size_in_bytes => $say_size_in_bytes, + human_readable_size => $say_human_size, + }}); + } + } + + return(0); +} + sub print_and_exit { my ($anvil) = @_; @@ -130,8 +198,8 @@ sub print_and_exit # The jobs button is "on" when the user is logged in and there is one or more jobs on this system # under 100% complete. my $say_jobs_button = $anvil->Template->get({file => "main.html", name => "jobs_button_off"}); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_jobs_button => $say_jobs_button }}); - if (($anvil->data->{sys}{users}{user_name}) && ($anvil->Job->running({debug => 2}))) + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_jobs_button => $say_jobs_button }}); + if (($anvil->data->{sys}{users}{user_name}) && ($anvil->Job->running({debug => 3}))) { $say_jobs_button = $anvil->Template->get({file => "main.html", name => "jobs_button_on"}); } @@ -1205,7 +1273,7 @@ sub check_availability { my ($anvil) = @_; - my $debug = 2; + my $debug = 3; my $available = 1; # Check maintenance mode. diff --git a/cgi-bin/upload.pl b/cgi-bin/upload.pl new file mode 100755 index 00000000..a324744b --- /dev/null +++ b/cgi-bin/upload.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use CGI; + +my $cgi = CGI->new; +print q|Content-type: text/html; charset=utf-8 + + + + + + + + + + + + Alteeve - Striker + + + + + + + + + + + +|; + + +my $lightweight_fh = $cgi->upload('field_name'); +# undef may be returned if it's not a valid file handle +if ($cgi->param()) +{ + print q| + Saving File... + + +|; + my $filename = $cgi->upload('upload_file'); + my $out = "/mnt/shared/incoming/".$filename; + print "Saving file: [".$out."]\n"; + my $cgi_file_handle = $cgi->param('upload_file'); + open(my $file_handle, ">$out") or die "failed to write: [$out], error: $!\n"; + while(<$cgi_file_handle>) + { + print $file_handle $_; + } + close $file_handle; + print "Done.\n"; +} +else +{ + print q| + Test Upload + + +

Upload file

+
+ + + Upload +
Upload
+
+|; +} +print "\n"; + +exit(0); diff --git a/html/skins/alteeve/files.css b/html/skins/alteeve/files.css new file mode 100644 index 00000000..2879237a --- /dev/null +++ b/html/skins/alteeve/files.css @@ -0,0 +1,147 @@ +/* From: http://hayageek.github.io/jQuery-Upload-File/4.0.11/uploadfile.css */ +.ajax-file-upload-statusbar { +border: 1px solid #0ba1b5; +margin-top: 10px; +width: 420px; +margin-right: 10px; +margin: 5px; +-moz-border-radius: 4px; +-webkit-border-radius: 4px; +border-radius: 4px; +padding: 5px 5px 5px 15px +} + +.ajax-file-upload-filename { +width: 300px; +height: auto; +margin: 0 5px 5px 0px; + +} + +.ajax-file-upload-filesize { +width: 50px; +height: auto; +margin: 0 5px 5px 0px; +display: inline-block; +vertical-align:middle; +} +.ajax-file-upload-progress { +margin: 5px 10px 5px 0px; +position: relative; +width: 250px; +border: 1px solid #ddd; +padding: 1px; +border-radius: 3px; +display: inline-block; +color:#FFFFFF; + +} +.ajax-file-upload-bar { +background-color: #0ba1b5; +width: 0; +height: 20px; +border-radius: 3px; +color:#FFFFFF; + +} +.ajax-file-upload-percent { +position: absolute; +display: inline-block; +top: 3px; +left: 48% +} +.ajax-file-upload-red { +-moz-box-shadow: inset 0 39px 0 -24px #e67a73; +-webkit-box-shadow: inset 0 39px 0 -24px #e67a73; +box-shadow: inset 0 39px 0 -24px #e67a73; +background-color: #e4685d; +-moz-border-radius: 4px; +-webkit-border-radius: 4px; +border-radius: 4px; +display: inline-block; +color: #fff; +font-family: arial; +font-size: 13px; +font-weight: normal; +padding: 4px 15px; +text-decoration: none; +text-shadow: 0 1px 0 #b23e35; +cursor: pointer; +vertical-align: top; +margin: 5px 10px 5px 0px; +} +.ajax-file-upload-green { +background-color: #77b55a; +-moz-border-radius: 4px; +-webkit-border-radius: 4px; +border-radius: 4px; +margin: 0; +padding: 0; +display: inline-block; +color: #fff; +font-family: arial; +font-size: 13px; +font-weight: normal; +padding: 4px 15px; +text-decoration: none; +cursor: pointer; +text-shadow: 0 1px 0 #5b8a3c; +vertical-align: top; +margin: 5px 10px 5px 0px; +} +.ajax-file-upload { + font-family: Arial, Helvetica, sans-serif; + font-size: 16px; + font-weight: bold; + padding: 15px 20px; + cursor:pointer; + line-height:20px; + height:25px; + margin:0 10px 10px 0; + display: inline-block; + background: #fff; + border: 1px solid #e8e8e8; + color: #888; + text-decoration: none; + border-radius: 3px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + -moz-box-shadow: 0 2px 0 0 #e8e8e8; + -webkit-box-shadow: 0 2px 0 0 #e8e8e8; + box-shadow: 0 2px 0 0 #e8e8e8; + padding: 6px 10px 4px 10px; + color: #fff; + background: #2f8ab9; + border: none; + -moz-box-shadow: 0 2px 0 0 #13648d; + -webkit-box-shadow: 0 2px 0 0 #13648d; + box-shadow: 0 2px 0 0 #13648d; + vertical-align: middle; + } + +.ajax-file-upload:hover { + background: #3396c9; + -moz-box-shadow: 0 2px 0 0 #15719f; + -webkit-box-shadow: 0 2px 0 0 #15719f; + box-shadow: 0 2px 0 0 #15719f; +} + +.ajax-upload-dragdrop +{ + + border:2px dotted #A5A5C7; + width:420px; + color: #DADCE3; + text-align:left; + vertical-align:middle; + padding:10px 10px 0px 10px; +} + +.state-hover +{ + border:2px solid #A5A5C7; +} +.ajax-file-upload-container +{ + margin:20px 0px 20px 0px; +} diff --git a/html/skins/alteeve/files.html b/html/skins/alteeve/files.html index 849a02af..e6d5cb74 100644 --- a/html/skins/alteeve/files.html +++ b/html/skins/alteeve/files.html @@ -1,5 +1,8 @@ + + + +
  @@ -17,8 +20,10 @@
- Upload file. + Upload +
Upload
diff --git a/html/skins/alteeve/files.js b/html/skins/alteeve/files.js new file mode 100644 index 00000000..5dbcedcd --- /dev/null +++ b/html/skins/alteeve/files.js @@ -0,0 +1,21 @@ +$.ajaxSetup({ + cache: false +}); + +$(document).ready(function() +{ + $("#fileuploader").uploadFile({ +// url:"/cgi-bin/striker", + url:"/cgi-bin/upload.pl", + fileName:"upload_file" + }); +}); + +/*! + * jQuery Upload File Plugin + * version: 4.0.11 + * @requires jQuery v1.5 or later & form plugin + * Copyright (c) 2013 Ravishanker Kusuma + * http://hayageek.com/ + */ +!function(e){void 0==e.fn.ajaxForm&&e.getScript(("https:"==document.location.protocol?"https://":"http://")+"malsup.github.io/jquery.form.js");var a={};a.fileapi=void 0!==e("").get(0).files,a.formdata=void 0!==window.FormData,e.fn.uploadFile=function(t){function r(){D||(D=!0,function e(){if(w.sequential||(w.sequentialCount=99999),0==x.length&&0==F.length)w.afterUploadAll&&w.afterUploadAll(C),D=!1;else{if(F.length1?t.showError&&e("
"+t.multiDragErrorStr+"
").appendTo(a.errorLog):0!=t.onSelect(o)&&l(t,a,o)}),r.on("dragleave",function(a){e(this).removeClass(t.dragDropHoverClass)}),e(document).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}),e(document).on("dragover",function(a){a.stopPropagation(),a.preventDefault();var r=e(this);r.hasClass(t.dragDropContainerClass)||r.removeClass(t.dragDropHoverClass)}),e(document).on("drop",function(a){a.stopPropagation(),a.preventDefault(),e(this).removeClass(t.dragDropHoverClass)})}function s(e){var a=e/1024;return parseInt(a)>1024?(a/1024).toFixed(2)+" MB":a.toFixed(2)+" KB"}function i(a){var t,r,o=[],s=(o="string"==jQuery.type(a)?a.split("&"):e.param(a).split("&")).length,i=[];for(t=0;ta.maxFileSize)a.showError&&e("
"+r[o].name+" "+a.sizeErrorStr+s(a.maxFileSize)+"
").appendTo(t.errorLog);else if(-1!=a.maxFileCount&&t.selectedFiles>=a.maxFileCount)a.showError&&e("
"+r[o].name+" "+a.maxFileCountErrorStr+a.maxFileCount+"
").appendTo(t.errorLog);else{t.selectedFiles++,t.existingFileNames.push(r[o].name);var l=e.extend({},a),u=new FormData,p=a.fileName.replace("[]","");u.append(p,r[o]);var c=a.formData;if(c)for(var h=i(c),f=0;f");C.appendTo("body");var b=[];b.push(r[o].name),v(C,l,w,b,t,r[o]),t.fileCounter++}else a.showError&&e("
"+r[o].name+" "+a.duplicateErrorStr+"
").appendTo(t.errorLog);else a.showError&&e("
"+r[o].name+" "+a.extErrorStr+a.allowedTypes+"
").appendTo(t.errorLog)}function n(e,a,t){var r=a.allowedTypes.toLowerCase().split(/[\s,]+/g),o=t.split(".").pop().toLowerCase();return!("*"!=a.allowedTypes&&jQuery.inArray(o,r)<0)}function d(e,a){var t=!1;if(e.existingFileNames.length)for(var r=0;r"),u="";o.multiple&&(o.fileName.indexOf("[]")!=o.fileName.length-2&&(o.fileName+="[]"),u="");var p=e(u).appendTo(d);p.change(function(){t.errorLog.html("");o.allowedTypes.toLowerCase().split(",");var i=[];if(this.files){for(g=0;g"+u+" "+o.extErrorStr+o.allowedTypes+"").appendTo(t.errorLog));if(p.push({name:u,size:"NA"}),0==o.onSelect(p))return}if(c(o,t),s.unbind("click"),d.hide(),h(t,r,o,s),d.addClass(r),o.serialize&&a.fileapi&&a.formdata){d.removeClass(r);var f=this.files;d.remove(),l(o,t,f)}else{for(var w="",g=0;g":w+=i[g]+"
",t.fileCounter++;if(-1!=o.maxFileCount&&t.selectedFiles+i.length>o.maxFileCount)return void(o.showError&&e("
"+w+" "+o.maxFileCountErrorStr+o.maxFileCount+"
").appendTo(t.errorLog));t.selectedFiles+=i.length;var C=new m(t,o);C.filename.html(w),v(d,o,C,i,t,null)}}),o.nestedForms?(d.css({margin:0,padding:0}),s.css({position:"relative",overflow:"hidden",cursor:"default"}),p.css({position:"absolute",cursor:"pointer",top:"0px",width:"100%",height:"100%",left:"0px","z-index":"100",opacity:"0.0",filter:"alpha(opacity=0)","-ms-filter":"alpha(opacity=0)","-khtml-opacity":"0.0","-moz-opacity":"0.0"}),d.appendTo(s)):(d.appendTo(e("body")),d.css({margin:0,padding:0,display:"block",position:"absolute",left:"-250px"}),-1!=navigator.appVersion.indexOf("MSIE ")?s.attr("for",i):s.click(function(){p.click()}))}function f(a,t){return this.statusbar=e("
").width(t.statusBarWidth),this.preview=e("").width(t.previewWidth).height(t.previewHeight).appendTo(this.statusbar).hide(),this.filename=e("
").appendTo(this.statusbar),this.progressDiv=e("
").appendTo(this.statusbar).hide(),this.progressbar=e("
").appendTo(this.progressDiv),this.abort=e("
"+t.abortStr+"
").appendTo(this.statusbar).hide(),this.cancel=e("
"+t.cancelStr+"
").appendTo(this.statusbar).hide(),this.done=e("
"+t.doneStr+"
").appendTo(this.statusbar).hide(),this.download=e("
"+t.downloadStr+"
").appendTo(this.statusbar).hide(),this.del=e("
"+t.deleteStr+"
").appendTo(this.statusbar).hide(),this.abort.addClass("ajax-file-upload-red"),this.done.addClass("ajax-file-upload-green"),this.download.addClass("ajax-file-upload-green"),this.cancel.addClass("ajax-file-upload-red"),this.del.addClass("ajax-file-upload-red"),this}function m(a,t){var r=null;return(r=t.customProgressBar?new t.customProgressBar(a,t):new f(a,t)).abort.addClass(a.formGroup),r.abort.addClass(t.abortButtonClass),r.cancel.addClass(a.formGroup),r.cancel.addClass(t.cancelButtonClass),t.extraHTML&&(r.extraHTML=e("
"+t.extraHTML()+"
").insertAfter(r.filename)),"bottom"==t.uploadQueueOrder?e(a.container).append(r.statusbar):e(a.container).prepend(r.statusbar),r}function v(t,o,s,l,n,d){var h={cache:!1,contentType:!1,processData:!1,forceSync:!1,type:o.method,data:o.formData,formData:o.fileData,dataType:o.returnType,headers:o.headers,beforeSubmit:function(a,r,d){if(0!=o.onSubmit.call(this,l)){if(o.dynamicFormData){var p=i(o.dynamicFormData());if(p)for(var h=0;h"+o.uploadErrorStr+"
"),s.cancel.show(),t.remove(),s.cancel.click(function(){x.splice(x.indexOf(t),1),u(n,l),s.statusbar.remove(),o.onCancel.call(n,l,s),n.selectedFiles-=l.length,c(o,n)}),!1},beforeSend:function(e,t){for(var r in t.headers)e.setRequestHeader(r,t.headers[r]);s.progressDiv.show(),s.cancel.hide(),s.done.hide(),o.showAbort&&(s.abort.show(),s.abort.click(function(){u(n,l),e.abort(),n.selectedFiles-=l.length,o.onAbort.call(n,l,s)})),a.formdata?s.progressbar.width("1%"):s.progressbar.width("5%")},uploadProgress:function(e,a,t,r){r>98&&(r=98);var i=r+"%";r>1&&s.progressbar.width(i),o.showProgress&&(s.progressbar.html(i),s.progressbar.css("text-align","center"))},success:function(a,r,i){if(s.cancel.remove(),F.pop(),"json"==o.returnType&&"object"==e.type(a)&&a.hasOwnProperty(o.customErrorKeyStr)){s.abort.hide();var d=a[o.customErrorKeyStr];return o.onError.call(this,l,200,d,s),o.showStatusAfterError?(s.progressDiv.hide(),s.statusbar.append("ERROR: "+d+"")):(s.statusbar.hide(),s.statusbar.remove()),n.selectedFiles-=l.length,void t.remove()}n.responses.push(a),s.progressbar.width("100%"),o.showProgress&&(s.progressbar.html("100%"),s.progressbar.css("text-align","center")),s.abort.hide(),o.onSuccess.call(this,l,a,i,s),o.showStatusAfterSuccess?(o.showDone?(s.done.show(),s.done.click(function(){s.statusbar.hide("slow"),s.statusbar.remove()})):s.done.hide(),o.showDelete?(s.del.show(),s.del.click(function(){u(n,l),s.statusbar.hide().remove(),o.deleteCallback&&o.deleteCallback.call(this,a,s),n.selectedFiles-=l.length,c(o,n)})):s.del.hide()):(s.statusbar.hide("slow"),s.statusbar.remove()),o.showDownload&&(s.download.show(),s.download.click(function(){o.downloadCallback&&o.downloadCallback(a,s)})),t.remove()},error:function(e,a,r){s.cancel.remove(),F.pop(),s.abort.hide(),"abort"==e.statusText?(s.statusbar.hide("slow").remove(),c(o,n)):(o.onError.call(this,l,a,r,s),o.showStatusAfterError?(s.progressDiv.hide(),s.statusbar.append("ERROR: "+r+"")):(s.statusbar.hide(),s.statusbar.remove()),n.selectedFiles-=l.length),t.remove()}};o.showPreview&&null!=d&&"image"==d.type.toLowerCase().split("/").shift()&&p(d,s.preview),o.autoSubmit?(t.ajaxForm(h),x.push(t),r()):(o.showCancel&&(s.cancel.show(),s.cancel.click(function(){x.splice(x.indexOf(t),1),u(n,l),t.remove(),s.statusbar.remove(),o.onCancel.call(n,l,s),n.selectedFiles-=l.length,c(o,n)})),t.ajaxForm(h))}var w=e.extend({url:"",method:"POST",enctype:"multipart/form-data",returnType:null,allowDuplicates:!0,duplicateStrict:!1,allowedTypes:"*",acceptFiles:"*",fileName:"file",formData:!1,dynamicFormData:!1,maxFileSize:-1,maxFileCount:-1,multiple:!0,dragDrop:!0,autoSubmit:!0,showCancel:!0,showAbort:!0,showDone:!1,showDelete:!1,showError:!0,showStatusAfterSuccess:!0,showStatusAfterError:!0,showFileCounter:!0,fileCounterStyle:"). ",showFileSize:!0,showProgress:!1,nestedForms:!0,showDownload:!1,onLoad:function(e){},onSelect:function(e){return!0},onSubmit:function(e,a){},onSuccess:function(e,a,t,r){},onError:function(e,a,t,r){},onCancel:function(e,a){},onAbort:function(e,a){},downloadCallback:!1,deleteCallback:!1,afterUploadAll:!1,serialize:!0,sequential:!1,sequentialCount:2,customProgressBar:!1,abortButtonClass:"ajax-file-upload-abort",cancelButtonClass:"ajax-file-upload-cancel",dragDropContainerClass:"ajax-upload-dragdrop",dragDropHoverClass:"state-hover",errorClass:"ajax-file-upload-error",uploadButtonClass:"ajax-file-upload",dragDropStr:"Drag & Drop Files",uploadStr:"Upload",abortStr:"Abort",cancelStr:"Cancel",deleteStr:"Delete",doneStr:"Done",multiDragErrorStr:"Multiple File Drag & Drop is not allowed.",extErrorStr:"is not allowed. Allowed extensions: ",duplicateErrorStr:"is not allowed. File already exists.",sizeErrorStr:"is not allowed. Allowed Max size: ",uploadErrorStr:"Upload is not allowed",maxFileCountErrorStr:" is not allowed. Maximum allowed files are:",downloadStr:"Download",customErrorKeyStr:"jquery-upload-file-error",showQueueDiv:!1,statusBarWidth:400,dragdropWidth:400,showPreview:!1,previewHeight:"auto",previewWidth:"100%",extraHTML:!1,uploadQueueOrder:"top",headers:{}},t);this.fileCounter=1,this.selectedFiles=0;var g="ajax-file-upload-"+(new Date).getTime();this.formGroup=g,this.errorLog=e("
"),this.responses=[],this.existingFileNames=[],a.formdata||(w.dragDrop=!1),a.formdata&&1!==w.maxFileCount||(w.multiple=!1),e(this).html("");var C=this,b=e("
"+w.uploadStr+"
");e(b).addClass(w.uploadButtonClass),function a(){if(e.fn.ajaxForm){if(w.dragDrop){var t=e('
').width(w.dragdropWidth);e(C).append(t),e(t).append(b),e(t).append(e(w.dragDropStr)),o(C,w,t)}else e(C).append(b);e(C).append(C.errorLog),w.showQueueDiv?C.container=e("#"+w.showQueueDiv):C.container=e("
").insertAfter(e(C)),w.onLoad.call(this,C),h(C,g,w,b)}else window.setTimeout(a,10)}(),this.startUpload=function(){e("form").each(function(a,t){e(this).hasClass(C.formGroup)&&x.push(e(this))}),x.length>=1&&r()},this.getFileCount=function(){return C.selectedFiles},this.stopUpload=function(){e("."+w.abortButtonClass).each(function(a,t){e(this).hasClass(C.formGroup)&&e(this).click()}),e("."+w.cancelButtonClass).each(function(a,t){e(this).hasClass(C.formGroup)&&e(this).click()})},this.cancelAll=function(){e("."+w.cancelButtonClass).each(function(a,t){e(this).hasClass(C.formGroup)&&e(this).click()})},this.update=function(a){w=e.extend(w,a),a.hasOwnProperty("url")&&e("form").each(function(t,r){e(this).attr("action",a.url)})},this.enqueueFile=function(e){e instanceof File&&l(w,C,[e])},this.reset=function(e){C.fileCounter=1,C.selectedFiles=0,C.errorLog.html(""),0!=e&&C.container.html("")},this.remove=function(){C.container.html(""),e(C).remove()},this.createProgress=function(e,a,t){var r=new m(this,w);r.progressDiv.show(),r.progressbar.width("100%");var o="";return o=w.showFileCounter?C.fileCounter+w.fileCounterStyle+e:e,w.showFileSize&&(o+=" ("+s(t)+")"),r.filename.html(o),C.fileCounter++,C.selectedFiles++,w.showPreview&&(r.preview.attr("src",a),r.preview.show()),w.showDownload&&(r.download.show(),r.download.click(function(){w.downloadCallback&&w.downloadCallback.call(C,[e],r)})),w.showDelete&&(r.del.show(),r.del.click(function(){r.statusbar.hide().remove();var a=[e];w.deleteCallback&&w.deleteCallback.call(this,a,r),C.selectedFiles-=1,c(w,C)})),r},this.getResponses=function(){return this.responses};var x=[],F=[],D=!1;return this}}(jQuery); diff --git a/share/words.xml b/share/words.xml index 48caed25..5df6e70c 100644 --- a/share/words.xml +++ b/share/words.xml @@ -527,7 +527,7 @@ The body of the file: [#!variable!file!#] does not match the new body. The file 'Install Target' job: [#!data!switches::job-uuid!#] picked up. 'Install Target' job: [#!data!switches::job-uuid!#] aborted, system not yet configured. Package list loaded. - #!free!# + It looks like a user tried to upload a file without actually doing so. [ Error ] - Failed to delete the file: [#!variable!file!#]. [ Warning ] - None of the databases are accessible. ScanCore will try to connect once a minute until a database is accessible. [ Cleared ] - We now have databases accessible, proceeding. @@ -544,6 +544,9 @@ The md5sum of: [#!variable!file!#] has changed since the daemon started. The database user is not 'admin'. Changing table and function ownerships to: [#!variable!database_user!#]. [ Warning ] - The Storage->make_directory() method failed to create the directory: [#!variable!directory!#]. [ Note ] - Created the directory: [#!variable!directory!#]. + [ Note ] - Downloaded: [#!variable!file!#] (#!variable!human_readable_size!# / #!variable!size_in_bytes!# bytes). + [ Warning ] - It appears that we failed to downloaded and save: [#!variable!file!#]. + [ Warning ] - It appears that we failed to downloaded and save: [#!variable!file!#]. The output file has no size, and will be removed. Test