1: # The LearningOnline Network with CAPA
2: # Handler to rename files, etc, in construction space
3: #
4: # This file responds to the various buttons and events
5: # in the top frame of the construction space directory.
6: # Each event is processed in two phases. The first phase
7: # presents a page that describes the proposed action to the user
8: # and requests confirmation. The second phase commits the action
9: # and displays a page showing the results of the action.
10: #
11: #
12: # $Id: loncfile.pm,v 1.100.2.4 2010/04/13 22:28:42 raeburn Exp $
13: #
14: # Copyright Michigan State University Board of Trustees
15: #
16: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
17: #
18: # LON-CAPA is free software; you can redistribute it and/or modify
19: # it under the terms of the GNU General Public License as published by
20: # the Free Software Foundation; either version 2 of the License, or
21: # (at your option) any later version.
22: #
23: # LON-CAPA is distributed in the hope that it will be useful,
24: # but WITHOUT ANY WARRANTY; without even the implied warranty of
25: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26: # GNU General Public License for more details.
27: #
28: # You should have received a copy of the GNU General Public License
29: # along with LON-CAPA; if not, write to the Free Software
30: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31: #
32: # /home/httpd/html/adm/gpl.txt
33: #
34: # http://www.lon-capa.org/
35: #
36: =pod
37:
38: =head1 NAME
39:
40: Apache::loncfile - Construction space file management.
41:
42: =head1 SYNOPSIS
43:
44: Content handler for buttons on the top frame of the construction space
45: directory.
46:
47: =head1 INTRODUCTION
48:
49: loncfile is invoked when buttons in the top frame of the construction
50: space directory listing are clicked. All operations proceed in two phases.
51: The first phase describes to the user exactly what will be done. If the user
52: confirms the operation, the second phase commits the operation and indicates
53: completion. When the user dismisses the output of phase2, they are returned to
54: an "appropriate" directory listing in general.
55:
56: This is part of the LearningOnline Network with CAPA project
57: described at http://www.lon-capa.org.
58:
59: =head2 Subroutines
60:
61: =cut
62:
63: package Apache::loncfile;
64:
65: use strict;
66: use Apache::File;
67: use File::Basename;
68: use File::Copy;
69: use HTML::Entities();
70: use Apache::Constants qw(:common :http :methods);
71: use Apache::loncacc;
72: use Apache::lonnet;
73: use Apache::loncommon();
74: use Apache::lonlocal;
75: use LONCAPA qw(:DEFAULT :match);
76:
77:
78: my $DEBUG=0;
79: my $r; # Needs to be global for some stuff RF.
80:
81: =pod
82:
83: =item Debug($request, $message)
84:
85: If debugging is enabled puts out a debugging message determined by the
86: caller. The debug message goes to the Apache error log file. Debugging
87: is enabled by setting the module global DEBUG variable to nonzero (TRUE).
88:
89: Parameters:
90:
91: =over 4
92:
93: =item $request - The current request operation.
94:
95: =item $message - The message to put in the log file.
96:
97: =back
98:
99: Returns:
100: nothing.
101:
102: =cut
103:
104: sub Debug {
105: # Put out the indicated message butonly if DEBUG is true.
106: if ($DEBUG) {
107: my ($r,$message) = @_;
108: $r->log_reason($message);
109: }
110: }
111:
112: sub done {
113: my ($url)=@_;
114: my $done=&mt("Done");
115: return(<<ENDDONE);
116: <a href="$url">$done</a>
117: <script type="text/javascript">
118: location.href="$url";
119: </script>
120: ENDDONE
121: }
122:
123: =pod
124:
125: =item URLToPath($url)
126:
127: Convert a URL to a file system path.
128:
129: In order to manipulate the construction space objects, it is necessary
130: to access url identified objects a filespace objects. This function
131: translates a construction space URL to a file system path.
132: Parameters:
133:
134: =over 4
135:
136: =item Url - string [in] The url to convert.
137:
138: =back
139:
140: Returns:
141:
142: =over 4
143:
144: =item The corresponding file system path.
145:
146: =back
147:
148: Global References
149:
150: =over 4
151:
152: =item $r - Request object [in] Referenced in the &Debug calls.
153:
154: =back
155:
156: =cut
157:
158: sub URLToPath {
159: my $Url = shift;
160: &Debug($r, "UrlToPath got: $Url");
161: $Url=~ s/\/+/\//g;
162: $Url=~ s/^https?\:\/\/[^\/]+//;
163: $Url=~ s/^\///;
164: $Url=~ s/(\~|priv\/)($match_username)\//\/home\/$2\/public_html\//;
165: &Debug($r, "Returning $Url \n");
166: return $Url;
167: }
168:
169: sub url {
170: my $fn=shift;
171: $fn=~s/^\/home\/($match_username)\/public\_html/\/priv\/$1/;
172: $fn=&HTML::Entities::encode($fn,'<>"&');
173: return $fn;
174: }
175:
176: sub display {
177: my $fn=shift;
178: $fn=~s-^/home/($match_username)/public_html-/priv/$1-;
179: return '<span class="LC_filename">'.$fn.'</span>';
180: }
181:
182:
183: # see if the file is
184: # a) published (return 0 if not)
185: # b) if, so obsolete (return 0 if not)
186:
187: sub obsolete_unpub {
188: my ($user,$domain,$construct)=@_;
189: my $published=$construct;
190: $published=~
191: s/^\/home\/$user\/public\_html\//\/home\/httpd\/html\/res\/$domain\/$user\//;
192: if (-e $published) {
193: if (&Apache::lonnet::metadata($published,'obsolete')) {
194: return 1;
195: }
196: return 0;
197: } else {
198: return 1;
199: }
200: }
201:
202: # see if directory is empty
203: # ignores any .meta, .save, .bak, and .log files created for a previously
204: # published file, which has since been marked obsolete and deleted.
205: sub empty_directory {
206: my ($dirname,$phase) = @_;
207: if (opendir DIR, $dirname) {
208: my @files = grep(!/^\.\.?$/, readdir(DIR)); # ignore . and ..
209: if (@files) {
210: my @orphans = grep(/\.(meta|save|log|bak)$/,@files);
211: if (scalar(@files) - scalar(@orphans) > 0) {
212: return 0;
213: } else {
214: if (($phase eq 'Delete2') && (@orphans > 0)) {
215: foreach my $file (@orphans) {
216: if ($file =~ /\.(meta|save|log|bak)$/) {
217: unlink($dirname.$file);
218: }
219: }
220: }
221: }
222: }
223: closedir(DIR);
224: return 1;
225: }
226: return 0;
227: }
228:
229: =pod
230:
231: =item exists($user, $domain, $file)
232:
233: Determine if a resource file name has been published or exists
234: in the construction space.
235:
236: Parameters:
237:
238: =over 4
239:
240: =item $user - string [in] - Name of the user for which to check.
241:
242: =item $domain - string [in] - Name of the domain in which the resource
243: might have been published.
244:
245: =item $file - string [in] - Name of the file.
246:
247: =item $creating - string [in] - optional, type of object being created,
248: either 'directory' or 'file'. Defaults to
249: 'file' if unspecified.
250:
251: =back
252:
253: Returns:
254:
255: =over 4
256:
257: =item string - Either undef, 'warning' or 'error' depending on the
258: type of problem
259:
260: =item string - Either where the resource exists as an html string that can
261: be embedded in a dialog or an empty string if the resource
262: does not exist.
263:
264: =back
265:
266: =cut
267:
268: sub exists {
269: my ($user, $domain, $construct, $creating) = @_;
270: $creating ||= 'file';
271:
272: my $published=$construct;
273: $published=~
274: s{^/home/$user/public_html/}{/home/httpd/html/res/$domain/$user/};
275: my ($type,$result);
276: if ( -d $construct ) {
277: return ('error','<p><span class="LC_error">'.&mt('Error: destination for operation is an existing directory.').'</span></p>');
278:
279: }
280:
281: if ( -e $published) {
282: if ( -e $construct ) {
283: $type = 'warning';
284: $result.='<p><span class="LC_warning">'.&mt('Warning: target file exists, and has been published!').'</span></p>';
285: } else {
286: my $published_type = (-d $published) ? 'directory' : 'file';
287:
288: if ($published_type eq $creating) {
289: $type = 'warning';
290: $result.='<p><span class="LC_warning">'.&mt("Warning: a published $published_type of this name exists.").'</span></p>';
291: } else {
292: $type = 'error';
293: $result.='<p><span class="LC_error">'.&mt("Error: a published $published_type of this name exists.").'</span></p>';
294: }
295: }
296: } elsif ( -e $construct) {
297: $type = 'warning';
298: $result.='<p><span class="LC_warning">'.&mt('Warning: target file exists!').'</span></p>';
299: }
300:
301: return ($type,$result);
302: }
303:
304: =pod
305:
306: =item checksuffix($old, $new)
307:
308: Determine if a resource filename suffix (the stuff after the .) would change
309: as a result of this operation.
310:
311: Parameters:
312:
313: =over 4
314:
315: =item $old = string [in] Previous filename.
316:
317: =item $new = string [in] Resultant filename.
318:
319: =back
320:
321: Returns:
322:
323: =over 4
324:
325: =item Empty string if everything worked.
326:
327: =item String containing an error message if there was a problem.
328:
329: =back
330:
331: =cut
332:
333: sub checksuffix {
334: my ($old,$new) = @_;
335: my $result;
336: my $oldsuffix;
337: my $newsuffix;
338: if ($new=~m:(.*/*)([^/]+)\.(\w+)$:) { $newsuffix=$3; }
339: if ($old=~m:(.*)/+([^/]+)\.(\w+)$:) { $oldsuffix=$3; }
340: if (lc($oldsuffix) ne lc($newsuffix)) {
341: $result.=
342: '<p><span class="LC_warning">'.&mt('Warning: change of MIME type!').'</span></p>';
343: }
344: return $result;
345: }
346:
347: sub cleanDest {
348: my ($request,$dest,$subdir,$fn,$uname)=@_;
349: #remove bad characters
350: my $foundbad=0;
351: if ($subdir && $dest =~/\./) {
352: $foundbad=1;
353: $dest=~s/\.//g;
354: }
355: $dest =~ s/(\s+$|^\s+)//g;
356: if ($dest=~/[\#\?&%\":]/) {
357: $foundbad=1;
358: $dest=~s/[\#\?&%\":]//g;
359: }
360: if ($dest=~m|/|) {
361: my ($newpath)=($dest=~m|(.*)/|);
362: $newpath=&relativeDest($fn,$newpath,$uname);
363: if (! -d "$newpath") {
364: $request->print('<p><span class="LC_warning">'
365: .&mt("You have requested to create file in directory [_1] which doesn't exist. The requested directory path has been removed from the requested file name."
366: ,&display($newpath))
367: .'</span></p>');
368: $dest=~s|.*/||;
369: }
370: }
371: if ($dest =~ /\.(\d+)\.(\w+)$/){
372: $request->print('<p><span class="LC_warning">'
373: .&mt('Bad filename [_1]',&display($dest))
374: .'<br />'
375: .&mt('[_1](name).(number).(extension)[_2] not allowed.','<tt>','</tt>')
376: .'<br />'
377: .&mt('Removing the [_1].number.[_2] from requested filename.','<tt>','</tt>')
378: .'</span></p>');
379: $dest =~ s/\.(\d+)(\.\w+)$/$2/;
380: }
381: if ($foundbad) {
382: $request->print('<p><span class="LC_warning">'
383: .&mt('Invalid characters in requested name have been removed.')
384: .'</span></p>'
385: );
386: }
387: return $dest;
388: }
389:
390: sub relativeDest {
391: my ($fn,$newfilename,$uname)=@_;
392: if ($newfilename=~/^\//) {
393: # absolute, simply add path
394: $newfilename='/home/'.$uname.'/public_html/';
395: } else {
396: my $dir=$fn;
397: $dir=~s/\/[^\/]+$//;
398: $newfilename=$dir.'/'.$newfilename;
399: }
400: $newfilename=~s://+:/:g; # remove duplicate /
401: while ($newfilename=~m:/\.\./:) {
402: $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
403: }
404: return $newfilename;
405: }
406:
407: =pod
408:
409: =item CloseForm1($request, $user, $file)
410:
411: Close of a form on the successful completion of phase 1 processing
412:
413: Parameters:
414:
415: =over 4
416:
417: =item $request - Apache Request Object [in] - Apache server request object.
418:
419: =item $cancelurl - the url to go to on cancel.
420:
421: =back
422:
423: =cut
424:
425: sub CloseForm1 {
426: my ($request, $fn) = @_;
427: $request->print('<p><input type="submit" value="'.&mt('Continue').'" /></p></form>');
428: $request->print('<form action="'.&url($fn).
429: '" method="post"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>');
430: }
431:
432:
433: =pod
434:
435: =item CloseForm2($request, $user, $directory)
436:
437: Successfully close off the phase 2 form.
438:
439: Parameters:
440:
441: =over 4
442:
443: =item $request - Apache Request object [in] - The request that is being
444: executed.
445:
446: =item $user - string [in] - Name of the user that is initiating the
447: request.
448:
449: =item $directory - string [in] - Directory in which the operation is
450: being done relative to the top level construction space
451: directory.
452:
453: =back
454:
455: =cut
456:
457: sub CloseForm2 {
458: my ($request, $user, $fn) = @_;
459: $request->print(&done(&url($fn)));
460: }
461:
462: =pod
463:
464: =item Rename1($request, $filename, $user, $domain, $dir)
465:
466: Perform phase 1 processing of the file rename operation.
467:
468: Parameters:
469:
470: =over 4
471:
472: =item $request - Apache Request Object [in] The request object for the
473: current request.
474:
475: =item $filename - The filename relative to construction space.
476:
477: =item $user - Name of the user making the request.
478:
479: =item $domain - User login domain.
480:
481: =item $dir - Directory specification of the path to the file.
482:
483: =back
484:
485: Side effects:
486:
487: =over 4
488:
489: =item A new form is displayed prompting for confirmation. The newfilename
490: hidden field of this form is loaded with
491: new filename relative to the current directory ($dir).
492:
493: =back
494:
495: =cut
496:
497: sub Rename1 {
498: my ($request, $user, $domain, $fn, $newfilename, $style) = @_;
499:
500: if(-e $fn) {
501: if($newfilename) {
502: # is dest a dir
503: if ($style eq 'move') {
504: if (-d $newfilename) {
505: if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; }
506: }
507: }
508: if ($newfilename =~ m|/[^\.]+$|) {
509: #no extension add on original extension
510: if ($fn =~ m|/[^\.]*\.([^\.]+)$|) {
511: $newfilename.='.'.$1;
512: }
513: }
514: $request->print(&checksuffix($fn, $newfilename));
515: #renaming a dir, delete the trailing /
516: #remove second to last element for current dir
517: if (-d $fn) {
518: $newfilename=~/\.(\w+)$/;
519: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
520: $request->print('<p><span class="LC_error">'.
521: &mt('Cannot change MIME type of a directory.').
522: '</span>'.
523: '<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a></p>');
524: return;
525: }
526: $newfilename=~s/\/[^\/]+\/([^\/]+)$/\/$1/;
527: }
528: $newfilename=~s://+:/:g; # remove duplicate /
529: while ($newfilename=~m:/\.\./:) {
530: $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
531: }
532: my ($type, $return)=&exists($user, $domain, $newfilename);
533: $request->print($return);
534: if ($type eq 'error') {
535: $request->print('<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
536: return;
537: }
538: unless (&obsolete_unpub($user,$domain,$fn)) {
539: $request->print('<p><span class="LC_error">'
540: .&mt('Cannot rename or move non-obsolete published file.')
541: .'</span><br />'
542: .'<a href="'.&url($fn).'">'.&mt('Cancel').'</a></p>'
543: );
544: return;
545: }
546: my $action;
547: if ($style eq 'rename') {
548: $action='Rename';
549: } else {
550: $action='Move';
551: }
552: $request->print('<input type="hidden" name="newfilename" value="'
553: .$newfilename.'" />'
554: .'<p>'
555: .&mt($action.' [_1] to [_2]?',
556: &display($fn),
557: &display($newfilename))
558: .'</p>'
559: );
560: &CloseForm1($request, $fn);
561: } else {
562: $request->print('<p class="LC_error">'.&mt('No new filename specified.').'</p></form>');
563: return;
564: }
565: } else {
566: $request->print('<p class="LC_error">'
567: .&mt('No such file: [_1]',
568: &display($fn))
569: .'</p></form>'
570: );
571: return;
572: }
573:
574: }
575:
576: =pod
577:
578: =item Delete1
579:
580: Performs phase 1 processing of the delete operation. In phase one
581: we just check to be sure the file exists.
582:
583: Parameters:
584:
585: =over 4
586:
587: =item $request - Apache Request Object [in] request object for the current
588: request.
589:
590: =item $user - string [in] Name of the user initiating the request.
591:
592: =item $domain - string [in] Domain the initiating user is logged in as
593:
594: =item $filename - string [in] Source filename.
595:
596: =back
597:
598: =cut
599:
600: sub Delete1 {
601: my ($request, $user, $domain, $fn) = @_;
602:
603: if( -e $fn) {
604: $request->print('<input type="hidden" name="newfilename" value="'.
605: $fn.'" />');
606: if (-d $fn) {
607: unless (&empty_directory($fn,'Delete1')) {
608: $request->print('<p>'
609: .'<span class="LC_error">'
610: .&mt('Only empty directories may be deleted.')
611: .'</span><br />'
612: .&mt('You must delete the contents of the directory first.')
613: .'</p>'
614: .'<p><a href="'.&url($fn).'">'.&mt('Cancel').'</a></p>'
615: );
616: return;
617: }
618: } else {
619: unless (&obsolete_unpub($user,$domain,$fn)) {
620: $request->print('<p><span class="LC_error">'
621: .&mt('Cannot delete non-obsolete published file.')
622: .'</span><br />'
623: .'<a href="'.&url($fn).'">'.&mt('Cancel').'</a></p>'
624: );
625: return;
626: }
627: }
628: $request->print('<p>'
629: .&mt('Delete [_1]?',
630: &display($fn))
631: .'</p>'
632: );
633: &CloseForm1($request, $fn);
634: } else {
635: $request->print('<p class="LC_error">'
636: .&mt('No such file: [_1]',
637: &display($fn))
638: .'</p></form>'
639: );
640: }
641: }
642:
643: =pod
644:
645: =item Copy1($request, $user, $domain, $filename, $newfilename)
646:
647: Performs phase 1 processing of the construction space copy command.
648: Ensure that the source file exists. Ensure that a destination exists,
649: also warn if the destination already exists.
650:
651: Parameters:
652:
653: =over 4
654:
655: =item $request - Apache Request Object [in] request object for the current
656: request.
657:
658: =item $user - string [in] Name of the user initiating the request.
659:
660: =item $domain - string [in] Domain the initiating user is logged in as
661:
662: =item $fn - string [in] Source filename.
663:
664: =item $newfilename-string [in] Destination filename.
665:
666: =back
667:
668: =cut
669:
670: sub Copy1 {
671: my ($request, $user, $domain, $fn, $newfilename) = @_;
672:
673: if(-e $fn) {
674: # is dest a dir
675: if (-d $newfilename) {
676: if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; }
677: }
678: if ($newfilename =~ m|/[^\.]+$|) {
679: #no extension add on original extension
680: if ($fn =~ m|/[^\.]*\.([^\.]+)$|) { $newfilename.='.'.$1; }
681: }
682: $newfilename=~s://+:/:g; # remove duplicate /
683: while ($newfilename=~m:/\.\./:) {
684: $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
685: }
686: $request->print(&checksuffix($fn,$newfilename));
687: my ($type,$return)=&exists($user, $domain, $newfilename);
688: $request->print($return);
689: if ($type eq 'error') {
690: $request->print('<br /><a href="'.&url($fn).'">'.&mt('Cancel').'</a>');
691: return;
692: }
693:
694: $request->print(
695: '<input type="hidden" name="newfilename"'
696: .' value="'.$newfilename.'" />'
697: .'<p>'
698: .&mt('Copy [_1] to [_2]?',
699: &display($fn),
700: &display($newfilename))
701: .'</p>'
702: );
703: &CloseForm1($request, $fn);
704: } else {
705: $request->print('<p class="LC_error">'
706: .&mt('No such file: [_1]',
707: &display($fn))
708: .'</p></form>'
709: );
710: }
711: }
712:
713: =pod
714:
715: =item NewDir1
716:
717: Does all phase 1 processing of directory creation:
718: Ensures that the user provides a new directory name,
719: and that the directory does not already exist.
720:
721: Parameters:
722:
723: =over 4
724:
725: =item $request - Apache Request Object [in] - Server request object for the
726: current url.
727:
728: =item $username - Name of the user that is requesting the directory creation.
729:
730: =item $domain - Domain user is in
731:
732: =item $fn - source file.
733:
734: =item $newdir - Name of the directory to be created; path relative to the
735: top level of construction space.
736: =back
737:
738: Side Effects:
739:
740: =over 4
741:
742: =item A new form is displayed. Clicking on the confirmation button
743: causes the newdir operation to transition into phase 2. The hidden field
744: "newfilename" is set with the construction space path to the new directory.
745:
746:
747: =back
748:
749: =cut
750:
751:
752: sub NewDir1 {
753: my ($request, $username, $domain, $fn, $newfilename, $mode) = @_;
754:
755: my ($type, $result)=&exists($username,$domain,$newfilename,'directory');
756: $request->print($result);
757: if ($type eq 'error') {
758: $request->print('</form>');
759: } else {
760: if ($mode eq 'testbank') {
761: $request->print('<input type="hidden" name="callingmode" value="testbank" />');
762: } elsif ($mode eq 'imsimport') {
763: $request->print('<input type="hidden" name="callingmode" value="imsimport" />');
764: }
765: $request->print('<input type="hidden" name="newfilename" value="'
766: .$newfilename.'" />'
767: .'<p>'
768: .&mt('Make new directory [_1]?',
769: &display($newfilename))
770: .'</p>'
771: );
772: &CloseForm1($request, $fn);
773: }
774: }
775:
776:
777: sub Decompress1 {
778: my ($request, $user, $domain, $fn) = @_;
779: if( -e $fn) {
780: $request->print('<input type="hidden" name="newfilename" value="'.$fn.'" />');
781: $request->print('<p>'
782: .&mt('Decompress [_1]?',
783: &display($fn))
784: .'</p>'
785: );
786: &CloseForm1($request, $fn);
787: } else {
788: $request->print('<p class="LC_error">'
789: .&mt('No such file: [_1]',
790: &display($fn))
791: .'</p></form>'
792: );
793: }
794: }
795:
796: =pod
797:
798: =item NewFile1
799:
800: Does all phase 1 processing of file creation:
801: Ensures that the user provides a new filename, adds proper extension
802: if needed and that the file does not already exist, if it is a html,
803: problem, page, or sequence, it then creates a form link to hand the
804: actual creation off to the proper handler.
805:
806: Parameters:
807:
808: =over 4
809:
810: =item $request - Apache Request Object [in] - Server request object for the
811: current url.
812:
813: =item $username - Name of the user that is requesting the directory creation.
814:
815: =item $domain - Name of the domain of the user
816:
817: =item $fn - Source file name
818:
819: =item $newfilename
820: - Name of the file to be created; no path information
821: =back
822:
823: Side Effects:
824:
825: =over 4
826:
827: =item 2 new forms are displayed. Clicking on the confirmation button
828: causes the browser to attempt to load the specfied URL, allowing the
829: proper handler to take care of file creation. There is also a Cancel
830: button which returns you to the driectory listing you came from
831:
832: =back
833:
834: =cut
835:
836: sub NewFile1 {
837: my ($request, $user, $domain, $fn, $newfilename) = @_;
838: return if (&filename_check($newfilename) ne 'ok');
839:
840: if ($env{'form.action'} =~ /new(.+)file/) {
841: my $extension=$1;
842: if ($newfilename !~ /\Q.$extension\E$/) {
843: if ($newfilename =~ m|/[^/.]*\.(?:[^/.]+)$|) {
844: #already has an extension strip it and add in expected one
845: $newfilename =~ s|(/[^./])\.(?:[^.]+)$|$1|;
846: }
847: $newfilename.=".$extension";
848: }
849: }
850: my ($type, $result)=&exists($user,$domain,$newfilename);
851: $request->print($result);
852: if ($type eq 'error') {
853: $request->print('</form>');
854: } else {
855: my $extension;
856:
857: if ($newfilename =~ m{[^/.]+\.([^/.]+)$}) {
858: $extension = $1;
859: }
860:
861: my @okexts = qw(xml html xhtml htm xhtm problem page sequence rights sty task library js css txt);
862:
863: if (($extension eq '') || (!grep(/^\Q$extension\E/,@okexts))) {
864: my $validexts = '.'.join(', .',@okexts);
865: $request->print('<p class="LC_warning">'.
866: &mt('Invalid filename: ').&display($newfilename).'</p><p>'.
867: &mt('The name of the new file needs to end with an appropriate file extension to indicate the type of file to create.').'<br />'.
868: &mt('The following are valid extensions: [_1].',$validexts).
869: '</p></form><p>'.
870: '<form name="fileaction" action="/adm/cfile" method="post">'.
871: '<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'.
872: '<input type="hidden" name="action" value="newfile" />'.
873: '<span class ="LC_nobreak">'.&mt('Enter a file name: ').'<input type="text" name="newfilename" value="Type Name Here" onfocus="if (this.value == '."'Type Name Here') this.value=''".'" /> <input type="submit" value="Go" />'.
874: '</span></form></p>'.
875: '<p><form action="'.&url($fn).
876: '" method="post"><p><input type="submit" value="'.&mt('Cancel').'" /></form></p>');
877: return;
878: }
879:
880: $request->print('<p>'.&mt('Make new file').' '.&display($newfilename).'?</p>');
881: $request->print('</form>');
882:
883: $request->print('<form action="'.&url($newfilename).
884: '" method="post"><p><input type="submit" value="'.&mt('Continue').'" /></p></form>');
885: $request->print('<form action="'.&url($fn).
886: '" method="post"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>');
887: }
888: return;
889: }
890:
891: sub filename_check {
892: my ($newfilename) = @_;
893: ##Informs User (name).(number).(extension) not allowed
894: if($newfilename =~ /\.(\d+)\.(\w+)$/){
895: $r->print('<span class="LC_error">'.$newfilename.
896: ' - '.&mt('Bad Filename').'<br />('.&mt('name').').('.&mt('number').').('.&mt('extension').') '.
897: ' '.&mt('Not Allowed').'</span>');
898: return;
899: }
900: if($newfilename =~ /(\:\:\:|\&\&\&|\_\_\_)/){
901: $r->print('<span class="LC_error">'.$newfilename.
902: ' - '.&mt('Bad Filename').'<br />('.&mt('Must not include').' '.$1.') '.
903: ' '.&mt('Not Allowed').'</span>');
904: return;
905: }
906: return 'ok';
907: }
908:
909: =pod
910:
911: =item phaseone($r, $fn, $uname, $udom)
912:
913: Peforms phase one processing of the request. In phase one, error messages
914: are returned if the request cannot be performed (e.g. attempts to manipulate
915: files that are nonexistent). If the operation can be performed, what is
916: about to be done will be presented to the user for confirmation. If the
917: user confirms the request, then phase two is executed, the action
918: performed and reported to the user.
919:
920: Parameters:
921:
922: =over 4
923:
924: =item $r - request object [in] - The Apache request being executed.
925:
926: =item $fn = string [in] - The filename being manipulated by the
927: request.
928:
929: =item $uname - string [in] Name of user logged in and doing this action.
930:
931: =item $udom - string [in] Domain name under which the user logged in.
932:
933: =back
934:
935: =cut
936:
937: sub phaseone {
938: my ($r,$fn,$uname,$udom)=@_;
939:
940: my $doingdir=0;
941: if ($env{'form.action'} eq 'newdir') { $doingdir=1; }
942: my $newfilename=&cleanDest($r,$env{'form.newfilename'},$doingdir,$fn,$uname);
943: $newfilename=&relativeDest($fn,$newfilename,$uname);
944: $r->print('<form action="/adm/cfile" method="post">'.
945: '<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'.
946: '<input type="hidden" name="phase" value="two" />'.
947: '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />');
948:
949: if ($env{'form.action'} eq 'rename') {
950: &Rename1($r, $uname, $udom, $fn, $newfilename, 'rename');
951: } elsif ($env{'form.action'} eq 'move') {
952: &Rename1($r, $uname, $udom, $fn, $newfilename, 'move');
953: } elsif ($env{'form.action'} eq 'delete') {
954: &Delete1($r, $uname, $udom, $fn);
955: } elsif ($env{'form.action'} eq 'decompress') {
956: &Decompress1($r, $uname, $udom, $fn);
957: } elsif ($env{'form.action'} eq 'copy') {
958: if($newfilename) {
959: &Copy1($r, $uname, $udom, $fn, $newfilename);
960: } else {
961: $r->print('<p class="LC_error">'
962: .&mt('No new filename specified.')
963: .'</p></form>'
964: );
965: }
966: } elsif ($env{'form.action'} eq 'newdir') {
967: my $mode = '';
968: if (exists($env{'form.callingmode'}) ) {
969: $mode = $env{'form.callingmode'};
970: }
971: &NewDir1($r, $uname, $udom, $fn, $newfilename, $mode);
972: } elsif ($env{'form.action'} eq 'newfile' ||
973: $env{'form.action'} eq 'newhtmlfile' ||
974: $env{'form.action'} eq 'newproblemfile' ||
975: $env{'form.action'} eq 'newpagefile' ||
976: $env{'form.action'} eq 'newsequencefile' ||
977: $env{'form.action'} eq 'newrightsfile' ||
978: $env{'form.action'} eq 'newstyfile' ||
979: $env{'form.action'} eq 'newtaskfile' ||
980: $env{'form.action'} eq 'newlibraryfile' ||
981: $env{'form.action'} eq 'Select Action') {
982: my $empty=&mt('Type Name Here');
983: if (($newfilename!~/\/$/) && ($newfilename!~/$empty$/)) {
984: &NewFile1($r, $uname, $udom, $fn, $newfilename);
985: } else {
986: $r->print('<p class="LC_error">'
987: .&mt('No new filename specified.')
988: .'</p></form>'
989: );
990: }
991: }
992: }
993:
994: =pod
995:
996: =item Rename2($request, $user, $directory, $oldfile, $newfile)
997:
998: Performs phase 2 processing of a rename reequest. This is where the
999: actual rename is performed.
1000:
1001: Parameters
1002:
1003: =over 4
1004:
1005: =item $request - Apache request object [in] The request being processed.
1006:
1007: =item $user - string [in] The name of the user initiating the request.
1008:
1009: =item $directory - string [in] The name of the directory relative to the
1010: construction space top level of the renamed file.
1011:
1012: =item $oldfile - Name of the file.
1013:
1014: =item $newfile - Name of the new file.
1015:
1016: =back
1017:
1018: Returns:
1019:
1020: =over 4
1021:
1022: =item 1 Success.
1023:
1024: =item 0 Failure.
1025:
1026: =cut
1027:
1028: sub Rename2 {
1029:
1030: my ($request, $user, $directory, $oldfile, $newfile) = @_;
1031:
1032: &Debug($request, "Rename2 directory: ".$directory." old file: ".$oldfile.
1033: " new file ".$newfile."\n");
1034: &Debug($request, "Target is: ".$directory.'/'.
1035: $newfile);
1036: if (-e $oldfile) {
1037:
1038: my $oRN=$oldfile;
1039: my $nRN=$newfile;
1040: unless (rename($oldfile,$newfile)) {
1041: $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
1042: return 0;
1043: }
1044: ## If old name.(extension) exits, move under new name.
1045: ## If it doesn't exist and a new.(extension) exists
1046: ## delete it (only concern when renaming over files)
1047: my $tmp1=$oRN.'.meta';
1048: my $tmp2=$nRN.'.meta';
1049: if(-e $tmp1){
1050: unless(rename($tmp1,$tmp2)){ }
1051: } elsif(-e $tmp2){
1052: unlink $tmp2;
1053: }
1054: $tmp1=$oRN.'.save';
1055: $tmp2=$nRN.'.save';
1056: if(-e $tmp1){
1057: unless(rename($tmp1,$tmp2)){ }
1058: } elsif(-e $tmp2){
1059: unlink $tmp2;
1060: }
1061: $tmp1=$oRN.'.log';
1062: $tmp2=$nRN.'.log';
1063: if(-e $tmp1){
1064: unless(rename($tmp1,$tmp2)){ }
1065: } elsif(-e $tmp2){
1066: unlink $tmp2;
1067: }
1068: $tmp1=$oRN.'.bak';
1069: $tmp2=$nRN.'.bak';
1070: if(-e $tmp1){
1071: unless(rename($tmp1,$tmp2)){ }
1072: } elsif(-e $tmp2){
1073: unlink $tmp2;
1074: }
1075: } else {
1076: $request->print('<p>'
1077: .&mt('No such file: [_1]',
1078: &display($oldfile))
1079: .'</p></form>'
1080: );
1081: return 0;
1082: }
1083: return 1;
1084: }
1085:
1086: =pod
1087:
1088: =item Delete2($request, $user, $filename)
1089:
1090: Performs phase two of a delete. The user has confirmed that they want
1091: to delete the selected file. The file is deleted and the results of the
1092: delete attempt are indicated.
1093:
1094: Parameters:
1095:
1096: =over 4
1097:
1098: =item $request - Apache Request object [in] the request object for the current
1099: delete operation.
1100:
1101: =item $user - string [in] The name of the user initiating the delete
1102: request.
1103:
1104: =item $filename - string [in] The name of the file, relative to construction
1105: space, to delete.
1106:
1107: =back
1108:
1109: Returns:
1110: 1 - success.
1111: 0 - Failure.
1112:
1113: =cut
1114:
1115: sub Delete2 {
1116: my ($request, $user, $filename) = @_;
1117: if (-d $filename) {
1118: unless (&empty_directory($filename,'Delete2')) {
1119: $request->print('<span class="LC_error">'.&mt('Error: Directory Non Empty').'</span>');
1120: return 0;
1121: } else {
1122: if(-e $filename) {
1123: unless(rmdir($filename)) {
1124: $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
1125: return 0;
1126: }
1127: } else {
1128: $request->print('<p class="LC_error">'.&mt('No such file').'</p></form>');
1129: return 0;
1130: }
1131: }
1132: } else {
1133: if(-e $filename) {
1134: unless(unlink($filename)) {
1135: $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
1136: return 0;
1137: }
1138: } else {
1139: $request->print('<p class="LC_error">'.&mt('No such file').'</p></form>');
1140: return 0;
1141: }
1142: }
1143: return 1;
1144: }
1145:
1146: =pod
1147:
1148: =item Copy2($request, $username, $dir, $oldfile, $newfile)
1149:
1150: Performs phase 2 of a copy. The file is copied and the status
1151: of that copy is reported back to the user.
1152:
1153: =over 4
1154:
1155: =item $request - Apache request object [in]; the apache request currently
1156: being executed.
1157:
1158: =item $username - string [in] Name of the user who is requesting the copy.
1159:
1160: =item $dir - string [in] Directory path relative to the construction space
1161: of the destination file.
1162:
1163: =item $oldfile - string [in] Name of the source file.
1164:
1165: =item $newfile - string [in] Name of the destination file.
1166:
1167:
1168: =back
1169:
1170: Returns 0 failure, and 1 successs.
1171:
1172: =cut
1173:
1174: sub Copy2 {
1175: my ($request, $username, $dir, $oldfile, $newfile) = @_;
1176: &Debug($request ,"Will try to copy $oldfile to $newfile");
1177: if(-e $oldfile) {
1178: if ($oldfile eq $newfile) {
1179: $request->print('<span class="LC_error">'.&mt('Warning').': '.&mt('Name of new file is the same as name of old file').' - '.&mt('no action taken').'.</span>');
1180: return 1;
1181: }
1182: unless (copy($oldfile, $newfile)) {
1183: $request->print('<span class="LC_error">'.&mt('copy Error').': '.$!.'</span>');
1184: return 0;
1185: } elsif (!chmod(0660, $newfile)) {
1186: $request->print('<span class="LC_error">'.&mt('chmod error').': '.$!.'</span>');
1187: return 0;
1188: } elsif (-e $oldfile.'.meta' &&
1189: !copy($oldfile.'.meta', $newfile.'.meta') &&
1190: !chmod(0660, $newfile.'.meta')) {
1191: $request->print('<span class="LC_error">'.&mt('copy metadata error').
1192: ': '.$!.'</span>');
1193: return 0;
1194: } else {
1195: return 1;
1196: }
1197: } else {
1198: $request->print('<p class="LC_error">'.&mt('No such file').'</p>');
1199: return 0;
1200: }
1201: return 1;
1202: }
1203:
1204: =pod
1205:
1206: =item NewDir2($request, $user, $newdirectory)
1207:
1208: Performs phase 2 processing of directory creation. This involves creating the directory and
1209: reporting the results of that creation to the user.
1210:
1211: Parameters:
1212: =over 4
1213:
1214: =item $request - Apache request object [in]. Object representing the current HTTP request.
1215:
1216: =item $user - string [in] The name of the user that is initiating the request.
1217:
1218: =item $newdirectory - string [in] The full path of the directory being created.
1219:
1220: =back
1221:
1222: Returns 0 - failure 1 - success.
1223:
1224: =cut
1225:
1226: sub NewDir2 {
1227: my ($request, $user, $newdirectory) = @_;
1228:
1229: unless(mkdir($newdirectory, 02770)) {
1230: $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
1231: return 0;
1232: }
1233: unless(chmod(02770, ($newdirectory))) {
1234: $request->print('<span class="LC_error">'.&mt('Error').': '.$!.'</span>');
1235: return 0;
1236: }
1237: return 1;
1238: }
1239:
1240: sub decompress2 {
1241: my ($r, $user, $dir, $file) = @_;
1242: &Apache::lonnet::appenv({'cgi.file' => $file});
1243: &Apache::lonnet::appenv({'cgi.dir' => $dir});
1244: my $result=&Apache::lonnet::ssi_body('/cgi-bin/decompress.pl');
1245: $r->print($result);
1246: &Apache::lonnet::delenv('cgi.file');
1247: &Apache::lonnet::delenv('cgi.dir');
1248: return 1;
1249: }
1250:
1251: =pod
1252:
1253: =item phasetwo($r, $fn, $uname, $udom)
1254:
1255: Controls the phase 2 processing of file management
1256: requests for construction space. In phase one, the user
1257: was asked to confirm the operation. In phase 2, the operation
1258: is performed and the result is shown.
1259:
1260: The strategy is to break out the processing into specific action processors
1261: named action2 where action is the requested action and the 2 denotes
1262: phase 2 processing.
1263:
1264: Parameters:
1265:
1266: =over 4
1267:
1268: =item $r - Apache Request object [in] The request object for this httpd
1269: transaction.
1270:
1271: =item $fn - string [in] A filename indicating the object that is being
1272: manipulated.
1273:
1274: =item $uname - string [in] The name of the user initiating the file management
1275: request.
1276:
1277: =item $udom - string [in] The login domain of the user initiating the
1278: file management request.
1279: =back
1280:
1281: =cut
1282:
1283: sub phasetwo {
1284: my ($r,$fn,$uname,$udom)=@_;
1285:
1286: &Debug($r, "loncfile - Entering phase 2 for $fn");
1287:
1288: # Break down the file into its component pieces.
1289:
1290: my $dir; # Directory path
1291: my $main; # Filename.
1292: my $suffix; # Extension.
1293: if ($fn=~m:(.*)/([^/]+):) {
1294: $dir=$1; # Directory path
1295: $main=$2; # Filename.
1296: }
1297: if($main=~m:\.(\w+)$:){ # Fixes problems with filenames with no extensions
1298: $suffix=$1; #This is the actually filename extension if it exists
1299: $main=~s/\.\w+$//; #strip the extension
1300: }
1301: my $dest; #
1302: my $dest_dir; # On success this is where we'll go.
1303: my $disp_newname; #
1304: my $dest_newname; #
1305: &Debug($r,"loncfile::phase2 dir = $dir main = $main suffix = $suffix");
1306: &Debug($r," newfilename = ".$env{'form.newfilename'});
1307:
1308: my $conspace=$fn;
1309:
1310: &Debug($r,"loncfile::phase2 Full construction space name: $conspace");
1311:
1312: &Debug($r,"loncfie::phase2 action is $env{'form.action'}");
1313:
1314: # Select the appropriate processing sub.
1315: if ($env{'form.action'} eq 'decompress') {
1316: $main .= '.'.$suffix;
1317: if(!&decompress2($r, $uname, $dir, $main)) {
1318: return ;
1319: }
1320: $dest = $dir."/.";
1321: } elsif ($env{'form.action'} eq 'rename' ||
1322: $env{'form.action'} eq 'move') {
1323: if($env{'form.newfilename'}) {
1324: if (!defined($dir)) {
1325: $fn=~m:^(.*)/:;
1326: $dir=$1;
1327: }
1328: if(!&Rename2($r, $uname, $dir, $fn, $env{'form.newfilename'})) {
1329: return;
1330: }
1331: $dest = $dir."/";
1332: $dest_newname = $env{'form.newfilename'};
1333: $env{'form.newfilename'} =~ /.+(\/.+$)/;
1334: $disp_newname = $1;
1335: $disp_newname =~ s/\///;
1336: }
1337: } elsif ($env{'form.action'} eq 'delete') {
1338: if(!&Delete2($r, $uname, $env{'form.newfilename'})) {
1339: return ;
1340: }
1341: # Once a resource is deleted, we just list the directory that
1342: # previously held it.
1343: #
1344: $dest = $dir."/."; # Parent dir.
1345: } elsif ($env{'form.action'} eq 'copy') {
1346: if($env{'form.newfilename'}) {
1347: if(!&Copy2($r, $uname, $dir, $fn, $env{'form.newfilename'})) {
1348: return ;
1349: }
1350: $dest = $env{'form.newfilename'};
1351: } else {
1352: $r->print('<p class="LC_error">'.&mt('No New filename specified').'</p></form>');
1353: return;
1354: }
1355:
1356: } elsif ($env{'form.action'} eq 'newdir') {
1357: my $newdir= $env{'form.newfilename'};
1358: if(!&NewDir2($r, $uname, $newdir)) {
1359: return;
1360: }
1361: $dest = $newdir."/";
1362: }
1363: if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) {
1364: $r->print('<h3><a href="javascript:self.close()">'.&mt('Done').'</a></h3>');
1365: } else {
1366: if ($env{'form.action'} eq 'rename') {
1367: $r->print('<h3><a href="'.&url($dest).'">'.&mt('Return to Directory').'</a></h3>');
1368: $r->print('<h3><a href="'.&url($dest_newname).'">'.$disp_newname.'</a></h3>');
1369: } else {
1370: $r->print(&done(&url($dest)));
1371: }
1372: }
1373: }
1374:
1375: sub handler {
1376:
1377: $r=shift;
1378:
1379: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress','action','filename','newfilename']);
1380:
1381: &Debug($r, "loncfile.pm - handler entered");
1382: &Debug($r, " filename: ".$env{'form.filename'});
1383: &Debug($r, " newfilename: ".$env{'form.newfilename'});
1384: #
1385: # Determine the root filename
1386: # This could come in as "filename", which actually is a URL, or
1387: # as "qualifiedfilename", which is indeed a real filename in filesystem
1388: #
1389: my $fn;
1390:
1391: if ($env{'form.filename'}) {
1392: &Debug($r, "test: $env{'form.filename'}");
1393: $fn=&unescape($env{'form.filename'});
1394: $fn=&URLToPath($fn);
1395: } elsif($ENV{'QUERY_STRING'} && $env{'form.phase'} ne 'two') {
1396: #Just hijack the script only the first time around to inject the
1397: #correct information for further processing
1398: $fn=&unescape($env{'form.decompress'});
1399: $fn=&URLToPath($fn);
1400: $env{'form.action'}="decompress";
1401: } elsif ($env{'form.qualifiedfilename'}) {
1402: $fn=$env{'form.qualifiedfilename'};
1403: } else {
1404: &Debug($r, "loncfile::handler - no form.filename");
1405: $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
1406: ' unspecified filename for cfile', $r->filename);
1407: return HTTP_NOT_FOUND;
1408: }
1409:
1410: unless ($fn) {
1411: &Debug($r, "loncfile::handler - doctored url is empty");
1412: $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
1413: ' trying to cfile non-existing file', $r->filename);
1414: return HTTP_NOT_FOUND;
1415: }
1416:
1417: # ----------------------------------------------------------- Start page output
1418: my $uname;
1419: my $udom;
1420:
1421: ($uname,$udom)=
1422: &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain'));
1423: &Debug($r,
1424: "loncfile::handler constructaccess uname = $uname domain = $udom");
1425: unless (($uname) && ($udom)) {
1426: $r->log_reason($uname.' at '.$udom.
1427: ' trying to manipulate file '.$env{'form.filename'}.
1428: ' ('.$fn.') - not authorized',
1429: $r->filename);
1430: return HTTP_NOT_ACCEPTABLE;
1431: }
1432:
1433:
1434: &Apache::loncommon::content_type($r,'text/html');
1435: $r->send_http_header;
1436:
1437: my (%loaditem,$js);
1438:
1439: if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) {
1440: my $newdirname = $env{'form.newfilename'};
1441: $js = qq|
1442: <script type="text/javascript">
1443: function writeDone() {
1444: window.focus();
1445: opener.document.info.newdir.value = "$newdirname";
1446: setTimeout("self.close()",10000);
1447: }
1448: </script>
1449: |;
1450: $loaditem{'onload'} = "writeDone()";
1451: }
1452:
1453: $r->print(&Apache::loncommon::start_page('Construction Space File Operation',
1454: $js,
1455: {'add_entries' => \%loaditem,}));
1456:
1457: $r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>');
1458:
1459: if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
1460: $r->print('<p class="LC_warning">'
1461: .&mt('Co-Author [_1]',$uname.':'.$udom)
1462: .'</p>'
1463: );
1464: }
1465:
1466:
1467: &Debug($r, "loncfile::handler Form action is $env{'form.action'} ");
1468: if ($env{'form.action'} eq 'delete') {
1469: $r->print('<h3>'.&mt('Delete').'</h3>');
1470: } elsif ($env{'form.action'} eq 'rename') {
1471: $r->print('<h3>'.&mt('Rename').'</h3>');
1472: } elsif ($env{'form.action'} eq 'move') {
1473: $r->print('<h3>'.&mt('Move').'</h3>');
1474: } elsif ($env{'form.action'} eq 'newdir') {
1475: $r->print('<h3>'.&mt('New Directory').'</h3>');
1476: } elsif ($env{'form.action'} eq 'decompress') {
1477: $r->print('<h3>'.&mt('Decompress').'</h3>');
1478: } elsif ($env{'form.action'} eq 'copy') {
1479: $r->print('<h3>'.&mt('Copy').'</h3>');
1480: } elsif ($env{'form.action'} eq 'newfile' ||
1481: $env{'form.action'} eq 'newhtmlfile' ||
1482: $env{'form.action'} eq 'newproblemfile' ||
1483: $env{'form.action'} eq 'newpagefile' ||
1484: $env{'form.action'} eq 'newsequencefile' ||
1485: $env{'form.action'} eq 'newrightsfile' ||
1486: $env{'form.action'} eq 'newstyfile' ||
1487: $env{'form.action'} eq 'newtaskfile' ||
1488: $env{'form.action'} eq 'newlibraryfile' ||
1489: $env{'form.action'} eq 'Select Action' ) {
1490: $r->print('<h3>'.&mt('New Resource').'</h3>');
1491: } else {
1492: $r->print('<p class="LC_error">'
1493: .&mt('Unknown Action').' '.$env{'form.action'}
1494: .'</p>'
1495: .&Apache::loncommon::end_page()
1496: );
1497: return OK;
1498: }
1499: if ($env{'form.phase'} eq 'two') {
1500: &Debug($r, "loncfile::handler entering phase2");
1501: &phasetwo($r,$fn,$uname,$udom);
1502: } else {
1503: &Debug($r, "loncfile::handler entering phase1");
1504: &phaseone($r,$fn,$uname,$udom);
1505: }
1506:
1507: $r->print(&Apache::loncommon::end_page());
1508: return OK;
1509: }
1510:
1511: 1;
1512: __END__
1513:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>