| | @@ -520,10 +520,56 @@ |
| 520 | 520 | db_end_transaction(0); |
| 521 | 521 | }else{ |
| 522 | 522 | usage("add|cat|edit|export|list|revert|remove|sync|touch"); |
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | + |
| 526 | +/* |
| 527 | +** Emit an HTML form for uploading a new unversioned file if |
| 528 | +** the current user has WrUnver permissions, else this is |
| 529 | +** a no-op. |
| 530 | +** |
| 531 | +** If this function detects that the form it emits has been submitted, |
| 532 | +** it will add the uploaded file to the unversioned file list before |
| 533 | +** returning. |
| 534 | +** |
| 535 | +** Intended only for use by /uvlist, and its form's action is that |
| 536 | +** page. |
| 537 | +*/ |
| 538 | +static void uvlist_upload(void){ |
| 539 | + const char * aContent; |
| 540 | + if( !g.perm.WrUnver ) return; |
| 541 | + aContent = P("f"); |
| 542 | + if( aContent!=0 ){ |
| 543 | + const char * const zName = P("f:filename"); |
| 544 | + int const nContent = atoi(PD("f:bytes","0")); |
| 545 | + const char * zError = 0; |
| 546 | + Blob content; |
| 547 | + if( zName[0]==0 ){ |
| 548 | + zError = "be an empty string"; |
| 549 | + }else if( contains_whitespace(zName) ){ |
| 550 | + zError = "contain spaces"; |
| 551 | + } |
| 552 | + if( zError ){ |
| 553 | + fossil_fatal("Unversioned filenames may not %s: %Q", |
| 554 | + zError, zName); |
| 555 | + } |
| 556 | + unversioned_schema(); |
| 557 | + db_begin_transaction(); |
| 558 | + content_rcvid_init("#!fossil /uvlist upload"); |
| 559 | + blob_init(&content, aContent, nContent); |
| 560 | + unversioned_write(zName, &content, time(0)); |
| 561 | + blob_reset(&content); |
| 562 | + db_end_transaction(0); |
| 563 | + CX("<div>Added: %s</div>", zName); |
| 564 | + } |
| 565 | + form_begin("enctype='multipart/form-data'", "%R/uvlist"); |
| 566 | + CX("<label for='uvupload'>Upload unversioned file:</label>"); |
| 567 | + CX("<input type='file' id='uvupload' name='f'/>"); |
| 568 | + CX("<input type='submit' value='Upload'/>"); |
| 569 | + CX("</form>"); |
| 570 | +} |
| 525 | 571 | |
| 526 | 572 | /* |
| 527 | 573 | ** WEBPAGE: uvlist |
| 528 | 574 | ** |
| 529 | 575 | ** Display a list of all unversioned files in the repository. |
| | @@ -545,10 +591,11 @@ |
| 545 | 591 | login_check_credentials(); |
| 546 | 592 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 547 | 593 | cgi_check_for_malice(); |
| 548 | 594 | etag_check(ETAG_DATA,0); |
| 549 | 595 | style_header("Unversioned Files"); |
| 596 | + uvlist_upload(); |
| 550 | 597 | if( !db_table_exists("repository","unversioned") ){ |
| 551 | 598 | @ No unversioned files on this server |
| 552 | 599 | style_finish_page(); |
| 553 | 600 | return; |
| 554 | 601 | } |
| 555 | 602 | |