Changeset 23138

Show
Ignore:
Timestamp:
14.10.2010 23:58:30 (9 years ago)
Author:
davidb
Message:

Elimination of rand_string

Location:
main/trunk/greenstone2
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/cgi-bin/talkback-progressbar.pl

    r23137 r23138  
    116116    if ($gsdl_cgi->param('process')) {  
    117117 
    118     my $rand_string  = $gsdl_cgi->param('rand_string'); 
    119118    my $uploadedfile = $gsdl_cgi->param('uploadedfile'); 
    120     my $full_filename = &util::filename_cat($gsdl_tmp_dir, 
    121                         "$rand_string-$uploadedfile"); 
     119    my $full_filename = &util::filename_cat($gsdl_tmp_dir,$uploadedfile); 
    122120 
    123121    my $done_html = &talkback::generate_done_html($full_filename); 
     
    136134    my $upload_html_form; 
    137135 
    138     if (defined $gsdl_cgi->param('rand_string')) {  
    139         my $rand_string = $gsdl_cgi->param('rand_string'); 
    140  
    141         # Light-weight (hidden) form with progress bar 
    142  
    143         $upload_html_form  
    144         = &talkback::generate_upload_form_progressbar($rand_string); 
    145     } 
    146     else { 
    147         print STDERR "Warning: Neither 'processing' nor 'rand_string' was set\n"; 
    148         $upload_html_form  
    149         = &talkback::generate_malformed_args_html(); 
    150          
    151     } 
     136    my $oid     = $gsdl_cgi->param('oid'); 
     137    my $collect = $gsdl_cgi->param('collect'); 
     138 
     139    my $uniq_file = "$collect-$oid-doc.xml"; 
     140    # Light-weight (hidden) form with progress bar 
     141 
     142    $upload_html_form  
     143        = &talkback::generate_upload_form_progressbar($uniq_file); 
    152144     
    153145        print $perlAjax->build_html($gsdl_cgi, $upload_html_form); 
  • main/trunk/greenstone2/cgi-bin/talkback-transfer.pl

    r23091 r23138  
    1 #/usr/bin/perl -w 
     1#!/usr/bin/perl -w 
    22 
    33use strict; 
     
    1818 
    1919 
     20sub get_infodb_type 
     21{ 
     22    my ($collect_home,$collect) = @_; 
     23 
     24    print STDERR "*** Need to implement extracting infodb_type from collect.cfg\n"; 
     25    return "gdbm"; 
     26} 
     27 
     28 
     29sub oid_to_docxml_filename 
     30{ 
     31    my ($collect_home,$collect,$docid) = @_; 
     32 
     33    my $infodb_type = get_infodb_type($collect_home,$collect); 
     34 
     35    # Obtain the collect and archive dir     
     36    my $archive_dir = &util::filename_cat($collect_home,$collect,"archives"); 
     37 
     38    # Obtain the doc.xml path for the specified docID 
     39    my $arcinfo_doc_filename  
     40    = &dbutil::get_infodb_file_path($infodb_type, "archiveinf-doc",  
     41                    $archive_dir); 
     42    my $doc_rec_string  
     43    = &dbutil::read_infodb_entry($infodb_type, $arcinfo_doc_filename,  
     44                     $docid); 
     45    my $doc_rec = &dbutil::convert_infodb_string_to_hash($doc_rec_string);     
     46    my $doc_xml_file = $doc_rec->{'doc-file'}->[0]; 
     47     
     48    # The $doc_xml_file is relative to the archives, so now let's get the  
     49    # full path 
     50    my $archives_dir = &util::filename_cat($collect_home,$collect,"archives");     
     51    my $doc_xml_filename = &util::filename_cat($archives_dir,$doc_xml_file); 
     52 
     53    return $doc_xml_filename; 
     54} 
     55 
    2056sub main 
    2157{ 
     
    2460    $gsdl_cgi->setup_gsdl(); 
    2561 
     62    my $gsdl_home = $gsdl_cgi->get_gsdl_home(); 
     63    my $collect_home = &util::filename_cat($gsdl_home,"collect"); 
     64 
     65    require dbutil; 
    2666    require talkback; 
    2767 
    28     my $rand_string; 
    29     if (defined $gsdl_cgi->param('rand_string')) {  
    30     $rand_string = $gsdl_cgi->param('rand_string'); 
    31     } 
    32     else { 
    33     $rand_string = "b310f690273cdc025e5a9b49fca8eee8"; 
     68    my $oid     = $gsdl_cgi->{'oid'}; 
     69    my $collect = $gsdl_cgi->{'collect'}; 
     70 
     71    # sanity check 
     72    if (!defined $oid || !defined $collect) { 
     73    print STDOUT "Content-type:text/plain\n\n"; 
     74    print STDOUT "ERROR: Malformed CGI argments.  Neeed to specify 'oid' and 'collect'\n"; 
     75    exit 0; 
    3476    } 
    3577 
    36     my $uploadedfile; 
    37     if (defined $gsdl_cgi->param('uploadedfile')) {  
    38     $uploadedfile = $gsdl_cgi->param('uploadedfile'); 
    39     } 
    40     else { 
    41     $uploadedfile = "C:\\cygwin\\tmp\\test-medium.pdf"; 
    42     } 
     78    my $uniq_prefix = "$collect-$oid"; 
    4379 
    44     my $talktoUploadURL; 
    45     if (defined $gsdl_cgi->param('talkbackUpload')) {  
    46     $talktoUploadURL = $gsdl_cgi->param('talktoUpload'); 
    47     } 
    48     else { 
    49     $talktoUploadURL = "http://www.nzdl.org/gsdl-new/cgi-bin/talkback-progressbar.pl"; 
    50     } 
     80    my $docxml_filename = oid_to_docxml_filename($collect_home,$collect,$oid); 
     81 
     82    my $talktoUploadURL = $gsdl_cgi->param('talktoUpload'); 
    5183 
    5284    my $browser = LWP::UserAgent->new(agent => 'Perl File Upload'); 
     
    5688       [ 'yes_upload'   => '1', 
    5789         'process'      => '1', 
    58          'rand_string'  => $rand_string, 
    59          'uploadedfile' => [$uploadedfile, "test-medium.pdf"]  
     90         'uploadedfile' => [$docxml_filename, "$uniq_prefix-doc.xml"]  
    6091         ], 
    6192       'Content_Type' => 'form-data' 
  • main/trunk/greenstone2/macros/talkback.dm

    r23090 r23138  
    44_talkfromcgi_ {} 
    55_talktocgi_   {} 
    6  
    7 # Set by the runtime system 
    8 _randString_ {} 
    96 
    107_talkfromLibrary_        {_talkfromcgi_/library.cgi} 
     
    2421      <input type="hidden" name="yes_upload" value="1" /> 
    2522      <input type="hidden" name="process" value="1" /> 
    26       <input type="hidden" name="rand_string" id="rand_string" value="_randString_" /> 
    2723      <input type="hidden" name="collect" value="_cgiargc_" /> 
    2824      <input type="hidden" name="oid" value="" /> 
     
    4743  <div style="width: 450px;"> 
    4844    <iframe frameborder="0" width="400" height="80" 
    49       src="_talkfromUploadProgress_?rand\_string=_randString_"> 
     45      src="_talkfromUploadProgress_"> 
    5046    </iframe> 
    5147  </div> 
  • main/trunk/greenstone2/perllib/talkback.pm

    r23085 r23138  
    3131sub generate_upload_form 
    3232{ 
    33     my ($rand_string) = @_; 
     33    my ($uniq_file) = @_; 
    3434 
    3535    my $upload_html_form = <<EOF 
     
    4444      <input type="hidden" name="yes_upload" value="1" /> 
    4545      <input type="hidden" name="process" value="1" /> 
    46       <input type="hidden" name="rand_string" id="rand_string" value="$rand_string" /> 
    4746 
    4847      <p> 
     
    5352 
    5453      <script language="Javascript">  
    55         setInterval("check_status(['check_upload__1', 'rand_string', 'uploadedfile'], ['statusbar']);", '1000'); 
     54        setInterval("check_status(['check_upload__1', '', 'uploadedfile'], ['statusbar']);", '1000'); 
    5655      </script>  
    5756 
     
    7170sub generate_upload_form_progressbar 
    7271{ 
    73     my ($rand_string) = @_; 
     72    my ($uniq_file) = @_; 
    7473 
    7574    my $upload_html_form = <<EOF 
     
    8483          action="talkback-progressbar.pl" 
    8584          enctype="multipart/form-data" method="post"> 
    86       <input type="hidden" name="uploadedfile" value="test-medium.pdf" /> 
    87       <input type="hidden" name="rand_string" id="rand_string" value="$rand_string" /> 
     85      <input type="hidden" name="uploadedfile" value="$uniq_file" /> 
    8886    </form> 
    8987 
    9088 
    9189    <script type="text/javascript">  
    92       setInterval("check_status(['check_upload__1', 'rand_string', 'uploadedfile'], ['statusbar']);", '1000'); 
     90      setInterval("check_status(['check_upload__1', '$uniq_file', 'uploadedfile'], ['statusbar']);", '1000'); 
    9391 
    9492    </script>  
     
    150148    <hr />  
    151149    <p>  
    152      Malformed CGI arguments.  Need either CGI 'processing' or 'rand_string' set. 
     150     Malformed CGI arguments. 
    153151    </p> 
    154152  </body>